|
|
@@ -1,12 +1,17 @@
|
|
|
package com.mokamrp.privates.service.impl;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.mokamrp.privates.mapper.pojo.Group;
|
|
|
import com.mokamrp.privates.mapper.pojo.GroupCorp;
|
|
|
import com.mokamrp.privates.mapper.GroupCorpMapper;
|
|
|
+import com.mokamrp.privates.mapper.pojo.UserCorp;
|
|
|
import com.mokamrp.privates.service.GroupCorpService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -34,4 +39,45 @@ public class GroupCorpServiceImpl extends ServiceImpl<GroupCorpMapper, GroupCorp
|
|
|
List<Map<String, Object>> res = groupCorpMapper.selectGroupCorp();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业绑定分组
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean setGroupCorp(Integer groupId,List<Integer> corpIds){
|
|
|
+ //.当前库里当前组的所有企业
|
|
|
+ List<GroupCorp> corps = this.list(new QueryWrapper<GroupCorp>().eq("group_id",groupId));
|
|
|
+ List<GroupCorp> add = new ArrayList<GroupCorp>();
|
|
|
+ //.遍历本次需要绑定的企业ID
|
|
|
+ for (int c = 0; c < corpIds.size(); c++) {
|
|
|
+ //.遍历当前分组里的企业 和本次绑定企业
|
|
|
+ Boolean hasCorp = false;
|
|
|
+ for (GroupCorp groupCorp : corps) {
|
|
|
+ if (groupCorp.getCorpId().equals(corpIds.get(c))) {
|
|
|
+ hasCorp = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hasCorp == false) {
|
|
|
+ GroupCorp groupCorpObj = new GroupCorp();
|
|
|
+ groupCorpObj.setCorpId(corpIds.get(c));
|
|
|
+ groupCorpObj.setGroupId(groupId);
|
|
|
+ add.add(groupCorpObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (add.size() > 0) {
|
|
|
+ this.saveBatch(add);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业解绑分组
|
|
|
+ * @param groupId
|
|
|
+ * @param corpId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean unSetGroupCorp(Integer groupId,Integer corpId){
|
|
|
+ Boolean res = this.remove(new QueryWrapper<GroupCorp>().eq("group_id",groupId).eq("corp_id",corpId));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|