瀏覽代碼

fix 修改查询时,排除admin角色去查询对应的部门id

Administrator 3 年之前
父節點
當前提交
b1e33bb73a

+ 23 - 7
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -11,6 +11,7 @@ import com.boman.common.core.utils.sql.SqlUtil;
 import com.boman.common.core.web.page.PageDomain;
 import com.boman.common.core.web.page.TableSupport;
 import com.boman.domain.SysDept;
+import com.boman.domain.SysRole;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.system.api.RemoteDeptService;
 import com.boman.system.api.RemoteDictDataService;
@@ -33,6 +34,8 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -115,6 +118,16 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         Long deptId = vaccineInfoOperation.getDeptId();
         if (deptId == null) {
             deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
+            //判断是否是管理员
+            List<SysRole> roles = AuthUtils.getLoginUser().getSysUser().getRoles();
+            if (roles.size() > 0) {
+                for (SysRole role : roles) {
+                    String roleKey = role.getRoleKey();
+                    if ("admin".equals(roleKey) || "city".equals(roleKey)) {
+                        deptId = null;
+                    }
+                }
+            }
         }
         Map<String, Object> params = vaccineInfoOperation.getParams();
         if (params != null) {
@@ -155,15 +168,18 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
                 PageHelper.startPage(pageNum, pageSize, orderBy);
             }
-            List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
-            List<Long> deptIdList = new ArrayList<>();
-            if (sysDepts != null && sysDepts.size() > 0) {
-                for (SysDept sysDept : sysDepts) {
-                    Long id = sysDept.getId();
-                    deptIdList.add(id);
+
+            if (deptId != null){
+                List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
+                List<Long> deptIdList = new ArrayList<>();
+                if (sysDepts != null && sysDepts.size() > 0) {
+                    for (SysDept sysDept : sysDepts) {
+                        Long id = sysDept.getId();
+                        deptIdList.add(id);
+                    }
                 }
+                vaccineInfoOperation.setDeptIdList(deptIdList);
             }
-            vaccineInfoOperation.setDeptIdList(deptIdList);
             LOGGER.info("查询开始");
             vaccineInfoOperations = vaccineInfoMapper.selectVaccineInfoList(vaccineInfoOperation);
             LOGGER.info("查询结束");