|
|
@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
@@ -55,14 +56,16 @@ public class DzAgentController extends BaseController
|
|
|
public AjaxResult list(DzAgent dzAgent)
|
|
|
{
|
|
|
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
|
|
|
+ List<DzAgent> allList = Lists.newArrayList();
|
|
|
if(UserTypeEnum.isAgent(sysUser.getUserType())) {
|
|
|
dzAgent.setParentId(sysUser.getUserTypeId());
|
|
|
+ allList.add(dzAgentService.selectDzAgentByAgentId(sysUser.getUserTypeId()));
|
|
|
} else if(!UserTypeEnum.isSys(sysUser.getUserType())) {
|
|
|
dzAgent.setDeptId(sysUser.getDeptId());
|
|
|
}
|
|
|
- List<DzAgent> list = dzAgentService.selectDzAgentList(dzAgent);
|
|
|
+ allList.addAll(dzAgentService.selectDzAgentList(dzAgent));
|
|
|
//处理关联学校的显示
|
|
|
- List<Long> distinctSchoolIds = list.stream()
|
|
|
+ List<Long> distinctSchoolIds = allList.stream()
|
|
|
.map(DzAgent::getSchoolIds)
|
|
|
.filter(Objects::nonNull) // 过滤null数组
|
|
|
.filter(array -> array.length > 0) // 过滤空数组
|
|
|
@@ -72,7 +75,7 @@ public class DzAgentController extends BaseController
|
|
|
//查询学校名称
|
|
|
if (CollectionUtil.isNotEmpty(distinctSchoolIds)){
|
|
|
Map<Long, DzSchool> schoolMap = schoolService.selectDzSchoolListByIds(distinctSchoolIds).stream().collect(Collectors.toMap(DzSchool::getId, school -> school));
|
|
|
- for (DzAgent agent : list) {
|
|
|
+ for (DzAgent agent : allList) {
|
|
|
if (agent.getSchoolIds() != null&&agent.getSchoolIds().length>0) {
|
|
|
String schoolName = Arrays.stream(agent.getSchoolIds())
|
|
|
.filter(Objects::nonNull) // 过滤null值
|
|
|
@@ -87,7 +90,7 @@ public class DzAgentController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return success(list);
|
|
|
+ return success(allList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -121,6 +124,9 @@ public class DzAgentController extends BaseController
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody DzAgent dzAgent)
|
|
|
{
|
|
|
+ if(UserTypeEnum.isAgent(SecurityUtils.getLoginUser().getUser().getUserType())) {
|
|
|
+ dzAgent.setParentId(SecurityUtils.getLoginUser().getUser().getUserTypeId());
|
|
|
+ }
|
|
|
setSchools(dzAgent);
|
|
|
return toAjax(dzAgentService.insertDzAgent(dzAgent));
|
|
|
}
|