|
|
@@ -6,9 +6,12 @@ import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
import com.mokamrp.privates.entity.pangu.AddFosterwxMobileHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxStationService;
|
|
|
import org.aspectj.weaver.loadtime.Aj;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -19,8 +22,10 @@ import com.mokamrp.privates.controller.BaseController;
|
|
|
import javax.validation.Valid;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -40,6 +45,9 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
|
|
|
|
|
|
@Autowired
|
|
|
public FosterwxStationService fosterwxStationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxMobileService fosterwxMobileService;
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -69,6 +77,24 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
|
|
|
if (addFosterwxMobileHandle.getFriends() == null || addFosterwxMobileHandle.getFriends().size() <= 0){
|
|
|
return AjaxResult.error(HttpMsg.error);
|
|
|
}
|
|
|
+ //.判断好友微信名称是否同样的超过3个
|
|
|
+ FosterwxMobile fosterwxMobile = fosterwxMobileService.getOne(new QueryWrapper<FosterwxMobile>().eq("id",addFosterwxMobileHandle.getMobileId()));
|
|
|
+ List<FosterwxMobile> mobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id",fosterwxMobile.getStationId()));
|
|
|
+ List<Integer> mobileIds = mobileList.stream().map(FosterwxMobile::getId).collect(Collectors.toList());
|
|
|
+ List<FosterwxMobileWxfriend> friends = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>()
|
|
|
+ .in("mobile_id",mobileIds)
|
|
|
+ );
|
|
|
+ Map<String,Boolean> friendsNames = new HashMap<>();
|
|
|
+ for (FosterwxMobileWxfriend add :addFosterwxMobileHandle.getFriends()){
|
|
|
+ if(friendsNames.get(add.getWxName()) == null){
|
|
|
+ return AjaxResult.error(HttpMsg.wxFriendResume+add.getWxName());
|
|
|
+ }
|
|
|
+ friendsNames.put(add.getWxName(),true);
|
|
|
+ Boolean findRes = this.checkWxFriendCnt(friends,add.getWxName());
|
|
|
+ if (!findRes){
|
|
|
+ return AjaxResult.error(HttpMsg.wxFriendCntMax3+add.getWxName());
|
|
|
+ }
|
|
|
+ }
|
|
|
fosterwxMobileWxfriendService.removeAndAdd(addFosterwxMobileHandle);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
@@ -92,6 +118,24 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
|
|
|
if (addFosterwxMobileHandle.getFriends() == null || addFosterwxMobileHandle.getFriends().size() <= 0){
|
|
|
return AjaxResult.error(HttpMsg.error);
|
|
|
}
|
|
|
+ //.判断好友微信名称是否同样的超过3个
|
|
|
+ FosterwxMobile fosterwxMobile = fosterwxMobileService.getOne(new QueryWrapper<FosterwxMobile>().eq("id",addFosterwxMobileHandle.getMobileId()));
|
|
|
+ List<FosterwxMobile> mobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id",fosterwxMobile.getStationId()));
|
|
|
+ List<Integer> mobileIds = mobileList.stream().map(FosterwxMobile::getId).collect(Collectors.toList());
|
|
|
+ List<FosterwxMobileWxfriend> friends = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>()
|
|
|
+ .in("mobile_id",mobileIds)
|
|
|
+ );
|
|
|
+ Map<String,Boolean> friendsNames = new HashMap<>();
|
|
|
+ for (FosterwxMobileWxfriend add :addFosterwxMobileHandle.getFriends()){
|
|
|
+ if(friendsNames.get(add.getWxName()) == null){
|
|
|
+ return AjaxResult.error(HttpMsg.wxFriendResume+add.getWxName());
|
|
|
+ }
|
|
|
+ friendsNames.put(add.getWxName(),true);
|
|
|
+ Boolean findRes = this.checkWxFriendCnt(friends,add.getWxName());
|
|
|
+ if (!findRes){
|
|
|
+ return AjaxResult.error(HttpMsg.wxFriendCntMax3+add.getWxName());
|
|
|
+ }
|
|
|
+ }
|
|
|
//.登录验证
|
|
|
FosterwxStation fosterwxStation = fosterwxStationService.getAuthInfo(token);
|
|
|
if (fosterwxStation == null){
|
|
|
@@ -100,5 +144,18 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
|
|
|
fosterwxMobileWxfriendService.removeAndAdd(addFosterwxMobileHandle);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
+
|
|
|
+ private Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row,String wxName){
|
|
|
+ Integer findCnt = 0;
|
|
|
+ for (FosterwxMobileWxfriend fosterwxMobileWxfriend : row){
|
|
|
+ if (fosterwxMobileWxfriend.getWxName().equals(wxName)){
|
|
|
+ findCnt++;
|
|
|
+ }
|
|
|
+ if (findCnt >= 3){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|