|
|
@@ -12,18 +12,19 @@ import com.template.model.result.PageUtils;
|
|
|
import com.template.model.weixin.AuthorListGroup;
|
|
|
import com.template.services.SmartAuthorGroupService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author ceshi
|
|
|
@@ -59,7 +60,7 @@ public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMap
|
|
|
Page<SmartAuthorGroup> page = new Page<>(currentPage, pageCount);
|
|
|
QueryWrapper<SmartAuthorGroup> queryWrapper = new QueryWrapper<>();
|
|
|
//queryWrapper.like(StringUtils.hasText(name), "name", name);
|
|
|
- IPage<SmartAuthorGroup> result = smartAuthorGroupMapper.selectPage(page,queryWrapper);
|
|
|
+ IPage<SmartAuthorGroup> result = smartAuthorGroupMapper.selectPage(page, queryWrapper);
|
|
|
return new PageUtils<>(result);
|
|
|
}
|
|
|
|
|
|
@@ -97,13 +98,13 @@ public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMap
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<SmartAuthorGroup> smartAuthorGroup(Integer userId){
|
|
|
+ public List<SmartAuthorGroup> smartAuthorGroup(Integer userId) {
|
|
|
List<SmartAuthorGroup> result = smartAuthorGroupMapper.smartAuthorGroup(userId);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SmartAuthorGroup> smartAuthorGroupSuperAdmins(Integer userId){
|
|
|
+ public List<SmartAuthorGroup> smartAuthorGroupSuperAdmins(Integer userId) {
|
|
|
List<SmartAuthorGroup> result = smartAuthorGroupMapper.smartAuthorGroupSuperAdmin(userId);
|
|
|
return result;
|
|
|
}
|
|
|
@@ -151,44 +152,48 @@ public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SmartAuthorGroupManager> getSmartAuthorGroupManager(String groupId){
|
|
|
+ public List<SmartAuthorGroupManager> getSmartAuthorGroupManager(String groupId) {
|
|
|
List<SmartAuthorGroupManager> list = smartAuthorGroupMapper.getSmartAuthorGroupManager(groupId);
|
|
|
- if (list.size()>0){
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- SmartAuthorGroupManager smartAuthorGroupManager = list.get(i);
|
|
|
- if (smartAuthorGroupManager.getDepartmentManage()!=null && !smartAuthorGroupManager.getDepartmentManage().equals("")){
|
|
|
- String[] manageId = smartAuthorGroupManager.getDepartmentManage().split(",");
|
|
|
- QueryWrapper<SmartDepartment> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.eq("deleted", 0);
|
|
|
- queryWrapper1.in("id", Arrays.asList(manageId));
|
|
|
- List<SmartDepartment> list1 = smartDepartmentMapper.selectList(queryWrapper1);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ List<String> departmentStrs = list.stream().map(SmartAuthorGroupManager::getDepartments).collect(Collectors.toList());
|
|
|
+ List<String> departmentIds = Arrays.asList(StringUtils.join(departmentStrs, ',').split(",")).stream().distinct().collect(Collectors.toList());
|
|
|
+ QueryWrapper<SmartDepartment> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq("deleted", 0);
|
|
|
+ queryWrapper1.in("id", departmentIds);
|
|
|
+ List<SmartDepartment> departmentDatas = smartDepartmentMapper.selectList(queryWrapper1);
|
|
|
+
|
|
|
+ for (SmartAuthorGroupManager smartAuthorGroupManager : list) {
|
|
|
+ if (smartAuthorGroupManager.getDepartmentManage() != null && !smartAuthorGroupManager.getDepartmentManage().equals("")) {
|
|
|
+ List<String> manageIds = Arrays.asList(smartAuthorGroupManager.getDepartmentManage().split(","));
|
|
|
List<JSONObject> departmentManageJson = new ArrayList<>();
|
|
|
- if (list1.size()>0){
|
|
|
- for (int j = 0; j < list1.size(); j++) {
|
|
|
- JSONObject jsonObject1 = new JSONObject();
|
|
|
- jsonObject1.put("id", list1.get(j).getId());
|
|
|
- jsonObject1.put("name", list1.get(j).getName());
|
|
|
- departmentManageJson.add(jsonObject1);
|
|
|
+ for (String manageId : manageIds) {
|
|
|
+ if (departmentDatas != null && departmentDatas.size() > 0) {
|
|
|
+ Optional<SmartDepartment> oDepartment = departmentDatas.stream().filter(e -> String.valueOf(e.getId()).equals(manageId)).findFirst();
|
|
|
+ if(oDepartment != null && oDepartment.isPresent()){
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("id", oDepartment.get().getId());
|
|
|
+ jsonObject1.put("name", oDepartment.get().getName());
|
|
|
+ departmentManageJson.add(jsonObject1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- list.get(i).setDepartmentManageJson(departmentManageJson);
|
|
|
+ smartAuthorGroupManager.setDepartmentManageJson(departmentManageJson);
|
|
|
}
|
|
|
- if (smartAuthorGroupManager.getDepartmentView()!=null && !smartAuthorGroupManager.getDepartmentView().equals("")){
|
|
|
- String[] viewId = smartAuthorGroupManager.getDepartmentView().split(",");
|
|
|
- QueryWrapper<SmartDepartment> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.eq("deleted", 0);
|
|
|
- queryWrapper1.in("id", Arrays.asList(viewId));
|
|
|
- List<SmartDepartment> list1 = smartDepartmentMapper.selectList(queryWrapper1);
|
|
|
+ if (smartAuthorGroupManager.getDepartmentView() != null && !smartAuthorGroupManager.getDepartmentView().equals("")) {
|
|
|
+ List<String> viewIds = Arrays.asList(smartAuthorGroupManager.getDepartmentView().split(","));
|
|
|
List<JSONObject> departmentViewJson = new ArrayList<>();
|
|
|
- if (list1.size()>0){
|
|
|
- for (int j = 0; j < list1.size(); j++) {
|
|
|
- JSONObject jsonObject1 = new JSONObject();
|
|
|
- jsonObject1.put("id", list1.get(j).getId());
|
|
|
- jsonObject1.put("name", list1.get(j).getName());
|
|
|
- departmentViewJson.add(jsonObject1);
|
|
|
+ for (String viewId : viewIds) {
|
|
|
+ if (departmentDatas != null && departmentDatas.size() > 0) {
|
|
|
+ Optional<SmartDepartment> oDepartment = departmentDatas.stream().filter(e -> String.valueOf(e.getId()).equals(viewId)).findFirst();
|
|
|
+ if(oDepartment != null && oDepartment.isPresent()){
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("id", oDepartment.get().getId());
|
|
|
+ jsonObject1.put("name", oDepartment.get().getName());
|
|
|
+ departmentViewJson.add(jsonObject1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- list.get(i).setDepartmentViewJson(departmentViewJson);
|
|
|
+ smartAuthorGroupManager.setDepartmentViewJson(departmentViewJson);
|
|
|
}
|
|
|
}
|
|
|
}
|