Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

zhaomuran 5 сар өмнө
parent
commit
dc27a0b027

+ 1 - 1
bound-link-api/blink-admin/src/main/java/com/cloud/sa/admin/module/system/datascope/domain/DataScopeSqlConfig.java

@@ -24,7 +24,7 @@ public class DataScopeSqlConfig {
     /**
      * join sql 具体实现类
      */
-    private Class joinSqlImplClazz;
+    private Class<?> joinSqlImplClazz;
 
     private String joinSql;
 

+ 29 - 8
bound-link-api/blink-admin/src/main/java/com/cloud/sa/admin/module/system/datascope/service/DataScopeSqlConfigService.java

@@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
  * @Author 云畅联: admin
  * @Date 2020/11/28  20:59:17
 
- * 
+ *
  */
 @Slf4j
 @Service
@@ -44,6 +44,12 @@ public class DataScopeSqlConfigService {
 
     private static final String DEPARTMENT_PARAM = "#departmentIds";
 
+    /**
+     * 用于拼接查看本人数据范围的 SQL
+     */
+    private static final String CREATE_USER_ID_EQUALS = "create_user_id = ";
+
+
     private final ConcurrentHashMap<String, DataScopeSqlConfig> dataScopeMethodMap = new ConcurrentHashMap<>();
 
     @Resource
@@ -92,14 +98,26 @@ public class DataScopeSqlConfigService {
      * 组装需要拼接的sql
      */
     public String getJoinSql(Map<String, Object> paramMap, DataScopeSqlConfig sqlConfigDTO) {
-        DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
-        String joinSql = sqlConfigDTO.getJoinSql();
+//        DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
+//        String joinSql = sqlConfigDTO.getJoinSql();
         Long employeeId = BlinkRequestUtil.getRequestUserId();
         if (employeeId == null) {
             return "";
         }
+
+        DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
+        DataScopeViewTypeEnum viewTypeEnum = dataScopeViewService.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
+
+        // 数据权限设置为仅本人可见时 直接返回 create_user_id = employeeId
+        if (DataScopeViewTypeEnum.ME == viewTypeEnum) {
+            return CREATE_USER_ID_EQUALS + employeeId;
+        }
+
+        String joinSql = sqlConfigDTO.getJoinSql();
+
         if (DataScopeWhereInTypeEnum.CUSTOM_STRATEGY == sqlConfigDTO.getDataScopeWhereInType()) {
-            Class strategyClass = sqlConfigDTO.getJoinSqlImplClazz();
+            //Class strategyClass = sqlConfigDTO.getJoinSqlImplClazz();
+            Class<?> strategyClass = sqlConfigDTO.getJoinSqlImplClazz();
             if (strategyClass == null) {
                 log.warn("data scope custom strategy class is null");
                 return "";
@@ -109,11 +127,13 @@ public class DataScopeSqlConfigService {
                 log.warn("data scope custom strategy class:{} ,bean is null", sqlConfigDTO.getJoinSqlImplClazz());
                 return "";
             }
-            DataScopeViewTypeEnum viewTypeEnum = dataScopeViewService.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
-            return powerStrategy.getCondition(viewTypeEnum,paramMap, sqlConfigDTO);
+//            DataScopeViewTypeEnum viewTypeEnum = dataScopeViewService.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
+//            return powerStrategy.getCondition(viewTypeEnum,paramMap, sqlConfigDTO);
+            return powerStrategy.getCondition(viewTypeEnum, paramMap, sqlConfigDTO);
         }
         if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
-            List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(dataScopeTypeEnum, employeeId);
+            //List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(dataScopeTypeEnum, employeeId);
+            List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(viewTypeEnum, employeeId);
             if (CollectionUtils.isEmpty(canViewEmployeeIds)) {
                 return "";
             }
@@ -122,7 +142,8 @@ public class DataScopeSqlConfigService {
             return sql;
         }
         if (DataScopeWhereInTypeEnum.DEPARTMENT == sqlConfigDTO.getDataScopeWhereInType()) {
-            List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeTypeEnum, employeeId);
+            //List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeTypeEnum, employeeId);
+            List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(viewTypeEnum, employeeId);
             if (CollectionUtils.isEmpty(canViewDepartmentIds)) {
                 return "";
             }

+ 17 - 9
bound-link-api/blink-admin/src/main/java/com/cloud/sa/admin/module/system/datascope/service/DataScopeViewService.java

@@ -3,13 +3,13 @@ package com.cloud.sa.admin.module.system.datascope.service;
 import com.cloud.sa.admin.module.system.datascope.constant.DataScopeTypeEnum;
 import com.cloud.sa.admin.module.system.datascope.constant.DataScopeViewTypeEnum;
 import com.cloud.sa.admin.module.system.department.service.DepartmentService;
-import com.google.common.collect.Lists;
 import com.cloud.sa.admin.module.system.employee.dao.EmployeeDao;
 import com.cloud.sa.admin.module.system.employee.domain.entity.EmployeeEntity;
 import com.cloud.sa.admin.module.system.role.dao.RoleDataScopeDao;
 import com.cloud.sa.admin.module.system.role.dao.RoleEmployeeDao;
 import com.cloud.sa.admin.module.system.role.domain.entity.RoleDataScopeEntity;
 import com.cloud.sa.base.common.util.BlinkEnumUtil;
+import com.google.common.collect.Lists;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
@@ -24,8 +24,6 @@ import java.util.stream.Collectors;
  *
  * @Author 云畅联: admin
  * @Date 2020/11/28  20:59:17
-
- * 
  */
 @Service
 public class DataScopeViewService {
@@ -45,8 +43,9 @@ public class DataScopeViewService {
     /**
      * 获取某人可以查看的所有人员信息
      */
-    public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
-        DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
+//    public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
+//        DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
+    public List<Long> getCanViewEmployeeId(DataScopeViewTypeEnum viewType, Long employeeId) {
         if (DataScopeViewTypeEnum.ME == viewType) {
             return this.getMeEmployeeIdList(employeeId);
         }
@@ -62,10 +61,13 @@ public class DataScopeViewService {
     /**
      * 获取某人可以查看的所有部门信息
      */
-    public List<Long> getCanViewDepartmentId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
-        DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
+//    public List<Long> getCanViewDepartmentId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
+//        DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
+    public List<Long> getCanViewDepartmentId(DataScopeViewTypeEnum viewType, Long employeeId) {
         if (DataScopeViewTypeEnum.ME == viewType) {
-            return this.getMeDepartmentIdList(employeeId);
+            //return this.getMeDepartmentIdList(employeeId);
+            // 数据可见范围类型为本人时 不可以查看任何部门数据
+            return Lists.newArrayList(0L);
         }
         if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
             return this.getMeDepartmentIdList(employeeId);
@@ -90,7 +92,9 @@ public class DataScopeViewService {
      * 根据员工id 获取各数据范围最大的可见范围 map<dataScopeType,viewType></>
      */
     public DataScopeViewTypeEnum getEmployeeDataScopeViewType(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
-        if (employeeId == null) {
+        EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
+        if (employeeEntity == null || employeeEntity.getEmployeeId() == null) {
+//        if (employeeId == null) {
             return DataScopeViewTypeEnum.ME;
         }
 
@@ -99,6 +103,10 @@ public class DataScopeViewService {
         if (CollectionUtils.isEmpty(roleIdList)) {
             return DataScopeViewTypeEnum.ME;
         }
+        // 如果是超级管理员 则可查看全部
+        if (employeeEntity.getAdministratorFlag()) {
+            return DataScopeViewTypeEnum.ALL;
+        }
         //未设置角色数据范围 默认本人
         List<RoleDataScopeEntity> dataScopeRoleList = roleDataScopeDao.listByRoleIdList(roleIdList);
         if (CollectionUtils.isEmpty(dataScopeRoleList)) {

+ 13 - 2
bound-link-api/blink-admin/src/main/java/com/cloud/sa/admin/module/system/login/service/LoginService.java

@@ -162,7 +162,13 @@ public class LoginService implements StpInterface {
         // 验证登录名
         EmployeeEntity employeeEntity = employeeService.getByLoginName(loginForm.getLoginName());
         if (null == employeeEntity) {
-            return ResponseDTO.userErrorParam("登录名不存在!");
+            return ResponseDTO.userErrorParam("登录名或密码错误!");
+        }
+
+        // 验证账号状态
+        if (employeeEntity.getDeletedFlag()) {
+            saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL);
+            return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
         }
 
         // 验证账号状态
@@ -250,7 +256,8 @@ public class LoginService implements StpInterface {
         // 验证手机号
         EmployeeEntity employeeEntity = employeeService.getByPhone(mobile);
         if (null == employeeEntity) {
-            return ResponseDTO.userErrorParam("登录名不存在!");
+            //return ResponseDTO.userErrorParam("登录名不存在!");
+            return ResponseDTO.ok();
         }
 
         // 验证账号状态
@@ -594,6 +601,10 @@ public class LoginService implements StpInterface {
         if (null == employeeEntity) {
             return ResponseDTO.userErrorParam("登录名不存在!");
         }
+        // 验证账号状态
+        if (employeeEntity.getDeletedFlag()) {
+            return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
+        }
 
         // 验证账号状态
         if (employeeEntity.getDisabledFlag()) {

+ 4 - 0
bound-link-api/blink-base/src/main/java/com/cloud/sa/base/module/support/securityprotect/service/Level3ProtectConfigService.java

@@ -159,6 +159,10 @@ public class Level3ProtectConfigService {
             this.maxUploadFileSizeMb = configForm.getMaxUploadFileSizeMb();
         }
 
+        if (configForm.getLoginFailMaxTimes() != null) {
+            this.loginFailMaxTimes = configForm.getLoginFailMaxTimes();
+        }
+
         if (configForm.getLoginFailLockMinutes() != null) {
             this.loginFailLockSeconds = configForm.getLoginFailLockMinutes() * 60;
         }