Procházet zdrojové kódy

Merge branch 'dev_v1.0.0' of http://git.qmth.com.cn/sop/server into dev_v1.0.0

shudonghui před 1 rokem
rodič
revize
a80dd07bed
61 změnil soubory, kde provedl 2586 přidání a 89 odebrání
  1. 5 5
      pom.xml
  2. 14 0
      sop-business/src/main/java/com/qmth/sop/business/annotation/EditKey.java
  3. 26 0
      sop-business/src/main/java/com/qmth/sop/business/annotation/OperationLog.java
  4. 306 0
      sop-business/src/main/java/com/qmth/sop/business/aspect/LogAspect.java
  5. 32 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/LogArgsDto.java
  6. 63 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/RoleDto.java
  7. 119 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/UserDto.java
  8. 82 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/VerifyCodeCheckDto.java
  9. 71 0
      sop-business/src/main/java/com/qmth/sop/business/bean/result/AppInfoResult.java
  10. 32 0
      sop-business/src/main/java/com/qmth/sop/business/bean/result/SysLogResult.java
  11. 56 0
      sop-business/src/main/java/com/qmth/sop/business/cache/CommonCacheService.java
  12. 119 0
      sop-business/src/main/java/com/qmth/sop/business/cache/impl/CommonCacheServiceImpl.java
  13. 136 0
      sop-business/src/main/java/com/qmth/sop/business/entity/BasicSchool.java
  14. 4 2
      sop-business/src/main/java/com/qmth/sop/business/entity/BasicVerifyCode.java
  15. 68 0
      sop-business/src/main/java/com/qmth/sop/business/entity/SysLog.java
  16. 53 0
      sop-business/src/main/java/com/qmth/sop/business/entity/SysUser.java
  17. 11 0
      sop-business/src/main/java/com/qmth/sop/business/entity/SysUserRole.java
  18. 132 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TSAuth.java
  19. 16 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/BasicSchoolMapper.java
  20. 17 1
      sop-business/src/main/java/com/qmth/sop/business/mapper/SysLogMapper.java
  21. 10 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/SysRoleMapper.java
  22. 34 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/SysUserMapper.java
  23. 11 1
      sop-business/src/main/java/com/qmth/sop/business/mapper/SysUserRoleMapper.java
  24. 24 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TSAuthMapper.java
  25. 16 0
      sop-business/src/main/java/com/qmth/sop/business/service/BasicSchoolService.java
  26. 15 0
      sop-business/src/main/java/com/qmth/sop/business/service/SysLogService.java
  27. 9 0
      sop-business/src/main/java/com/qmth/sop/business/service/SysRoleService.java
  28. 20 0
      sop-business/src/main/java/com/qmth/sop/business/service/SysUserRoleService.java
  29. 48 0
      sop-business/src/main/java/com/qmth/sop/business/service/SysUserService.java
  30. 51 0
      sop-business/src/main/java/com/qmth/sop/business/service/TSAuthService.java
  31. 20 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/BasicSchoolServiceImpl.java
  32. 2 2
      sop-business/src/main/java/com/qmth/sop/business/service/impl/BasicVerifyCodeServiceImpl.java
  33. 11 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysLogServiceImpl.java
  34. 4 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysOrgServiceImpl.java
  35. 12 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysRoleServiceImpl.java
  36. 26 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java
  37. 198 6
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java
  38. 191 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TSAuthServiceImpl.java
  39. 84 50
      sop-business/src/main/resources/db/install/sop_db.sql
  40. 12 0
      sop-business/src/main/resources/db/log/caozixuan_update_log.sql
  41. 33 0
      sop-business/src/main/resources/db/log/shudonghui_update_log.sql
  42. 60 0
      sop-business/src/main/resources/db/log/wangliang_update_log.sql
  43. 5 0
      sop-business/src/main/resources/mapper/BasicSchoolMapper.xml
  44. 18 0
      sop-business/src/main/resources/mapper/SysLogMapper.xml
  45. 14 0
      sop-business/src/main/resources/mapper/SysRoleMapper.xml
  46. 70 0
      sop-business/src/main/resources/mapper/SysUserMapper.xml
  47. 13 0
      sop-business/src/main/resources/mapper/SysUserRoleMapper.xml
  48. 14 0
      sop-business/src/main/resources/mapper/TSAuthMapper.xml
  49. 4 4
      sop-common/pom.xml
  50. 24 0
      sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java
  51. 3 1
      sop-common/src/main/java/com/qmth/sop/common/enums/AuthEnum.java
  52. 4 0
      sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java
  53. 20 6
      sop-common/src/main/java/com/qmth/sop/common/enums/LogTypeEnum.java
  54. 15 0
      sop-common/src/main/java/com/qmth/sop/common/util/ServletUtil.java
  55. 19 0
      sop-server/src/main/java/com/qmth/sop/server/api/BasicSchoolController.java
  56. 9 4
      sop-server/src/main/java/com/qmth/sop/server/api/SysController.java
  57. 28 2
      sop-server/src/main/java/com/qmth/sop/server/api/SysLogController.java
  58. 46 3
      sop-server/src/main/java/com/qmth/sop/server/api/SysUserController.java
  59. 19 0
      sop-server/src/main/java/com/qmth/sop/server/api/TSAuthController.java
  60. 5 0
      sop-server/src/main/java/com/qmth/sop/server/start/StartRunning.java
  61. 3 2
      sop-server/src/main/resources/application.properties

+ 5 - 5
pom.xml

@@ -121,11 +121,11 @@
 <!--                <artifactId>tools-poi</artifactId>-->
 <!--                <version>${qmth.boot.version}</version>-->
 <!--            </dependency>-->
-<!--            <dependency>-->
-<!--                <groupId>com.qmth.boot</groupId>-->
-<!--                <artifactId>core-solar</artifactId>-->
-<!--                <version>${qmth.boot.version}</version>-->
-<!--            </dependency>-->
+            <dependency>
+                <groupId>com.qmth.boot</groupId>
+                <artifactId>core-solar</artifactId>
+                <version>${qmth.boot.version}</version>
+            </dependency>
             <dependency>
                 <groupId>com.qmth.boot</groupId>
                 <artifactId>core-logging</artifactId>

+ 14 - 0
sop-business/src/main/java/com/qmth/sop/business/annotation/EditKey.java

@@ -0,0 +1,14 @@
+package com.qmth.sop.business.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @Description: 编辑 新增和更新的主键
+ * @Author: CaoZixuan
+ * @Date: 2023-08-07
+ */
+@Documented
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface EditKey {
+}

+ 26 - 0
sop-business/src/main/java/com/qmth/sop/business/annotation/OperationLog.java

@@ -0,0 +1,26 @@
+package com.qmth.sop.business.annotation;
+
+import com.qmth.sop.common.enums.LogTypeEnum;
+
+import java.lang.annotation.*;
+
+/**
+ * @Description: 操作日志注解
+ * @Author: CaoZixuan
+ * @Date: 2023-08-03
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface OperationLog {
+
+    /**
+     * 日志记录 - 具体操作的内容(默认为空)
+     */
+    String detail() default "";
+
+    /**
+     * 日志记录 - 自定义记录操作类型(默认 - 未知)
+     */
+    LogTypeEnum logType() default LogTypeEnum.UN_KNOW;
+}

+ 306 - 0
sop-business/src/main/java/com/qmth/sop/business/aspect/LogAspect.java

@@ -0,0 +1,306 @@
+package com.qmth.sop.business.aspect;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.annotation.EditKey;
+import com.qmth.sop.business.annotation.OperationLog;
+import com.qmth.sop.business.bean.dto.LogArgsDto;
+import com.qmth.sop.business.entity.SysLog;
+import com.qmth.sop.business.entity.SysPrivilege;
+import com.qmth.sop.business.entity.SysRole;
+import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.service.SysLogService;
+import com.qmth.sop.business.service.SysPrivilegeService;
+import com.qmth.sop.business.service.SysUserRoleService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.LogTypeEnum;
+import com.qmth.sop.common.enums.PrivilegeEnum;
+import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
+import org.apache.commons.collections4.CollectionUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.validation.BeanPropertyBindingResult;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 日志操作记录拦截aop
+ * @Author: CaoZixuan
+ * @Date: 2023-08-03
+ */
+@Aspect
+@Component
+public class LogAspect {
+    @Resource
+    private SysLogService sysLogService;
+    @Resource
+    private SysPrivilegeService sysPrivilegeService;
+    @Resource
+    private SysUserRoleService sysUserRoleService;
+
+    private final static Logger log = LoggerFactory.getLogger(LogAspect.class);
+
+    /**
+     * 日志注解切入点
+     */
+    @Pointcut("@annotation(com.qmth.sop.business.annotation.OperationLog)")
+    public void operationLog() {
+
+    }
+
+    /**
+     * 环绕增强,操作日志环绕切入
+     *
+     * @param joinPoint joinPoint
+     * @return return
+     * @throws Throwable Throwable
+     */
+    @Around(value = "operationLog()")
+    public Object aroundOperationLogPoint(ProceedingJoinPoint joinPoint) throws Throwable {
+        Object res = null;
+        long beginTime = System.currentTimeMillis();
+        long endTime = 0;
+        String runStatus = "成功";
+        try {
+            res = joinPoint.proceed();
+            endTime = System.currentTimeMillis();
+            return res;
+        } catch (Exception e) {
+            endTime = System.currentTimeMillis();
+            res = "Exception: " + e.getMessage();
+            runStatus = "失败";
+            log.error(SystemConstant.LOG_ERROR, e);
+            if (e instanceof ApiException) {
+                return ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                return ResultUtil.error(e.getMessage());
+            }
+        } finally {
+            try {
+                //方法执行完成后增加日志
+                addOperationLog(joinPoint, res, endTime - beginTime, runStatus);
+            } catch (Exception e) {
+                log.error("LogAspect 操作失败:" + e.getMessage());
+                e.printStackTrace();
+            }
+        }
+
+    }
+
+    /**
+     * 记录日志操作
+     *
+     * @param joinPoint joinPoint
+     * @param res       返回值
+     * @param time      方法执行时间
+     * @param runStatus 方法执行状态
+     */
+    private void addOperationLog(JoinPoint joinPoint, Object res, long time, String runStatus) throws IllegalAccessException {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        String userName = requestUser.getLoginName();
+        HttpServletRequest request = ServletUtil.getRequest();
+        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+        Long privilegeId = ServletUtil.getCurrentPrivilegeId();
+        Object[] args = joinPoint.getArgs();
+        String[] paramsName = signature.getParameterNames();
+
+        SysLog sysLog = new SysLog();
+
+        // 方法中的信息
+        sysLog.setId(SystemConstant.getDbUuid());
+
+        sysLog.setUrl(request.getServletPath());
+        sysLog.setArgs(this.getTranslateArgs(paramsName, args));
+        sysLog.setRunTime(time);
+        sysLog.setRunStatus(runStatus);
+        sysLog.setUserId(requestUser.getId());
+        sysLog.setUserName(userName);
+        sysLog.setCreateTime(System.currentTimeMillis());
+
+        // 注解中的信息
+        OperationLog annotation = signature.getMethod().getAnnotation(OperationLog.class);
+        if (annotation != null) {
+            List<SysRole> sysRoleList = sysUserRoleService.listRoleByUserId(requestUser.getId());
+            String detail = annotation.detail();
+            if (detail != null && detail.length() > 0) {
+                detail = getDetail(((MethodSignature) joinPoint.getSignature()).getParameterNames(), joinPoint.getArgs(), annotation);
+            } else {
+                detail = autoCreateOperationLogDetailByUrlAndPrivilegeId(request.getServletPath(), privilegeId);
+            }
+            if (CollectionUtils.isNotEmpty(sysRoleList)) {
+                String roleNames = sysRoleList.stream().map(SysRole::getName).collect(Collectors.joining(","));
+                detail = "[" + roleNames + "] " + detail;
+            }
+            sysLog.setContent(detail);
+
+            LogTypeEnum logType = annotation.logType();
+            if (LogTypeEnum.EDIT.equals(logType)) {
+                logType = this.getAddOrUpdateByParam(args);
+            }
+
+            sysLog.setType(logType);
+        }
+        // 保存操作日志
+        sysLogService.save(sysLog);
+    }
+
+    private String getTranslateArgs(String[] paramsName, Object[] args) {
+        List<LogArgsDto> logArgsDtoList = new ArrayList<>();
+        for (int i = 0; i < args.length; i++) {
+            if (Objects.nonNull(args[i]) && (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse || args[i] instanceof CommonsMultipartFile || args[i] instanceof MultipartFile || args[i] instanceof BeanPropertyBindingResult)) {
+                continue;
+            }
+            LogArgsDto logArgsDto = new LogArgsDto();
+            logArgsDto.setArg(args[i]);
+            logArgsDto.setParamName(paramsName[i]);
+            logArgsDtoList.add(logArgsDto);
+        }
+        return JSON.toJSONString(logArgsDtoList);
+    }
+
+    private LogTypeEnum getAddOrUpdateByParam(Object[] args) throws IllegalAccessException {
+        for (Object arg : args) {
+            if (Objects.nonNull(arg) && (arg instanceof HttpServletRequest || arg instanceof HttpServletResponse || arg instanceof MultipartFile || arg instanceof BeanPropertyBindingResult)) {
+                continue;
+            }
+            Class<?> clazz = arg.getClass();
+            Field[] fields = clazz.getDeclaredFields();
+            for (Field field : fields) {
+                EditKey editKey = field.getAnnotation(EditKey.class);
+                if (editKey != null) {
+                    // 捕捉到编辑对象的id
+                    field.setAccessible(true);
+                    Object obj = field.get(arg);
+                    if (Objects.nonNull(obj)) {
+                        return LogTypeEnum.UPDATE;
+                    } else {
+                        return LogTypeEnum.ADD;
+                    }
+                }
+            }
+            Class<?> supperClazz = clazz.getSuperclass();
+            if (Objects.nonNull(supperClazz)) {
+                Field[] supperFields = supperClazz.getDeclaredFields();
+                for (Field field : supperFields) {
+                    EditKey editKey = field.getAnnotation(EditKey.class);
+                    if (editKey != null) {
+                        // 捕捉到编辑对象的id
+                        field.setAccessible(true);
+                        Object obj = field.get(arg);
+                        if (Objects.nonNull(obj)) {
+                            return LogTypeEnum.UPDATE;
+                        } else {
+                            return LogTypeEnum.ADD;
+                        }
+                    }
+                }
+            }
+        }
+        return LogTypeEnum.EDIT;
+    }
+
+    /**
+     * 对当前登录用户和占位符处理
+     *
+     * @param argNames   方法参数名称数组
+     * @param args       方法参数数组
+     * @param annotation 注解信息
+     * @return 返回处理后的描述
+     */
+    private String getDetail(String[] argNames, Object[] args, OperationLog annotation) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+
+
+        Map<Object, Object> map = new HashMap<>();
+        for (int i = 0; i < argNames.length; i++) {
+            if (Objects.nonNull(args[i]) && (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse || args[i] instanceof CommonsMultipartFile || args[i] instanceof MultipartFile || args[i] instanceof BeanPropertyBindingResult)) {
+                continue;
+            }
+            map.put(argNames[i], args[i]);
+        }
+
+        String detail = annotation.detail();
+        try {
+            detail = "'" + requestUser.getRealName() + "'=》" + annotation.detail();
+            for (Map.Entry<Object, Object> entry : map.entrySet()) {
+                Object k = entry.getKey();
+                Object v = entry.getValue();
+                detail = detail.replace("{{" + k + "}}", JSON.toJSONString(v));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return detail;
+    }
+
+    /**
+     * 根据权限url和所在菜单的权限id自动创建操作日志详情
+     *
+     * @param url         url
+     * @param privilegeId 所属菜单的权限id
+     * @return 操作日志详情
+     */
+    private String autoCreateOperationLogDetailByUrlAndPrivilegeId(String url, Long privilegeId) {
+        String result = "";
+        SysPrivilege menu = sysPrivilegeService.getById(privilegeId);
+        SysPrivilege urlP = sysPrivilegeService.getOne(new QueryWrapper<SysPrivilege>()
+                .lambda()
+                .select(SysPrivilege::getName)
+                .eq(SysPrivilege::getUrl, url)
+                .eq(SysPrivilege::getType, PrivilegeEnum.URL));
+        if (Objects.nonNull(menu) && Objects.nonNull(urlP)) {
+            result = result + menu.getName() + SystemConstant.CATALOG_LINK + urlP.getName();
+        } else if (Objects.nonNull(menu)) {
+            result = result + menu.getName();
+        } else if (Objects.nonNull(urlP)) {
+            result = result + urlP.getName();
+        }
+        return result;
+    }
+
+    @Before(value = "operationLog()")
+    public void doBeforeAdvice(JoinPoint joinPoint) {
+        log.info("进入方法前执行.....");
+    }
+
+    /**
+     * 处理完请求,返回内容
+     *
+     * @param ret ret
+     */
+    @AfterReturning(returning = "ret", pointcut = "operationLog()")
+    public void doAfterReturning(Object ret) {
+        log.info("方法的返回值 : " + ret);
+    }
+
+    /**
+     * 后置异常通知
+     */
+    @AfterThrowing(value = "operationLog()")
+    public void throwss(JoinPoint jp) {
+        log.info("方法异常时执行.....");
+    }
+
+
+    /**
+     * 后置最终通知,final增强,不管是抛出异常或者正常退出都会执行
+     */
+    @After(value = "operationLog()")
+    public void after(JoinPoint jp) {
+        log.info("方法最后执行.....");
+    }
+}

+ 32 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/LogArgsDto.java

@@ -0,0 +1,32 @@
+package com.qmth.sop.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 日志方法中参数Dto
+ * @Author: CaoZixuan
+ * @Date: 2023-08-07
+ */
+public class LogArgsDto {
+    @ApiModelProperty(value = "参数")
+    private Object arg;
+
+    @ApiModelProperty(value = "参数名称")
+    private String paramName;
+
+    public Object getArg() {
+        return arg;
+    }
+
+    public void setArg(Object arg) {
+        this.arg = arg;
+    }
+
+    public String getParamName() {
+        return paramName;
+    }
+
+    public void setParamName(String paramName) {
+        this.paramName = paramName;
+    }
+}

+ 63 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/RoleDto.java

@@ -0,0 +1,63 @@
+package com.qmth.sop.business.bean.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.enums.RoleTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 用户dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/8/7
+ */
+public class RoleDto implements Serializable {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    @ApiModelProperty(value = "角色名称")
+    private String name;
+
+    @ApiModelProperty(value = "是否启用,0:停用,1:启用")
+    private Boolean enable;
+
+    @ApiModelProperty(value = "角色类别,ADMIN:超级管理员,PMO:总负责人,BUSSINESS:业务线负责人,REGION_MANAGER:大区经理,REGION_COORDINATOR:区域协调人,EFFECT_ENGINEER:实施工程师,ASSISTANT_ENGINEER:助理工程师,QA:QA,CUSTOM:技术客服")
+    private RoleTypeEnum type;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public RoleTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(RoleTypeEnum type) {
+        this.type = type;
+    }
+}

+ 119 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/UserDto.java

@@ -0,0 +1,119 @@
+package com.qmth.sop.business.bean.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.enums.GenderEnum;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @Description: 用户dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/8/7
+ */
+public class UserDto implements Serializable {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    private String loginName;
+    private String realName;
+    private String mobileNumber;
+    private Boolean enable;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long orgId;
+
+    private String orgName;
+    private GenderEnum gender;
+    private String genderStr;
+    private List<RoleDto> roles;
+
+    public String getGenderStr() {
+        if (Objects.nonNull(this.gender)) {
+            return this.gender.getTitle();
+        } else {
+            return genderStr;
+        }
+    }
+
+    public void setGenderStr(String genderStr) {
+        this.genderStr = genderStr;
+    }
+
+    public GenderEnum getGender() {
+        return gender;
+    }
+
+    public void setGender(GenderEnum gender) {
+        this.gender = gender;
+    }
+
+    public List<RoleDto> getRoles() {
+        return roles;
+    }
+
+    public void setRoles(List<RoleDto> roles) {
+        this.roles = roles;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getLoginName() {
+        return loginName;
+    }
+
+    public void setLoginName(String loginName) {
+        this.loginName = loginName;
+    }
+
+    public String getRealName() {
+        return realName;
+    }
+
+    public void setRealName(String realName) {
+        this.realName = realName;
+    }
+
+    public String getMobileNumber() {
+        return mobileNumber;
+    }
+
+    public void setMobileNumber(String mobileNumber) {
+        this.mobileNumber = mobileNumber;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+}

+ 82 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/VerifyCodeCheckDto.java

@@ -0,0 +1,82 @@
+package com.qmth.sop.business.bean.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 短信验证码校验dto
+ * @Author: CaoZixuan
+ * @Date: 2021-10-09
+ */
+public class VerifyCodeCheckDto extends BaseEntity {
+
+    @ApiModelProperty(value = "机构id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long orgId;
+
+    @ApiModelProperty(value = "发送用户id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long userId;
+
+    @ApiModelProperty(value = "发送用户手机号")
+    private String mobilePhone;
+
+    @ApiModelProperty(value = "到期时间")
+    private Long expireTime;
+
+    @ApiModelProperty(value = "延期时间(分钟)")
+    private Integer validPeriod;
+
+    @ApiModelProperty(value = "四位验证码")
+    private String verifyCode;
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getMobilePhone() {
+        return mobilePhone;
+    }
+
+    public void setMobilePhone(String mobilePhone) {
+        this.mobilePhone = mobilePhone;
+    }
+
+    public Long getExpireTime() {
+        return expireTime;
+    }
+
+    public void setExpireTime(Long expireTime) {
+        this.expireTime = expireTime;
+    }
+
+    public Integer getValidPeriod() {
+        return validPeriod;
+    }
+
+    public void setValidPeriod(Integer validPeriod) {
+        this.validPeriod = validPeriod;
+    }
+
+    public String getVerifyCode() {
+        return verifyCode;
+    }
+
+    public void setVerifyCode(String verifyCode) {
+        this.verifyCode = verifyCode;
+    }
+}

+ 71 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/AppInfoResult.java

@@ -0,0 +1,71 @@
+package com.qmth.sop.business.bean.result;
+
+import com.qmth.sop.common.enums.AuthEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: appinfo result
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/2/17
+ */
+public class AppInfoResult implements Serializable {
+
+    @ApiModelProperty(value = "过期时间")
+    Long expireTime;
+
+    @ApiModelProperty(value = "accessKey")
+    String accessKey;
+
+    @ApiModelProperty(value = "accessSecret")
+    String accessSecret;
+
+    @ApiModelProperty(value = "激活模式")
+    AuthEnum authMode;
+
+    public AppInfoResult() {
+
+    }
+
+    public AppInfoResult(Long expireTime, String accessKey, String accessSecret, AuthEnum authMode) {
+        this.expireTime = expireTime;
+        this.accessKey = accessKey;
+        this.accessSecret = accessSecret;
+        this.authMode = authMode;
+    }
+
+    public Long getExpireTime() {
+        return expireTime;
+    }
+
+    public void setExpireTime(Long expireTime) {
+        this.expireTime = expireTime;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+
+    public AuthEnum getAuthMode() {
+        return authMode;
+    }
+
+    public void setAuthMode(AuthEnum authMode) {
+        this.authMode = authMode;
+    }
+}

+ 32 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/SysLogResult.java

@@ -0,0 +1,32 @@
+package com.qmth.sop.business.bean.result;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 系统日志查询结果类
+ * @Author: CaoZixuan
+ * @Date: 2023-08-07
+ */
+public class SysLogResult {
+    @ApiModelProperty("日志内容")
+    private String content;
+
+    @ApiModelProperty("创建时间")
+    private Long createTime;
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+}

+ 56 - 0
sop-business/src/main/java/com/qmth/sop/business/cache/CommonCacheService.java

@@ -348,4 +348,60 @@ public interface CommonCacheService {
      * @param roleId
      */
     public void removeRoleCache(Long roleId);
+
+    /**
+     * 添加学校缓存
+     *
+     * @param schoolId
+     * @return
+     */
+    public BasicSchool schoolCache(Long schoolId);
+
+    /**
+     * 添加学校缓存
+     *
+     * @param code
+     * @return
+     */
+    public BasicSchool schoolCache(String code);
+
+    /**
+     * 更新学校缓存
+     *
+     * @param schoolId
+     * @return
+     */
+    public BasicSchool updateSchoolCache(Long schoolId);
+
+    /**
+     * 更新学校缓存
+     *
+     * @param code
+     * @return
+     */
+    public BasicSchool updateSchoolCache(String code);
+
+    /**
+     * 删除学校缓存
+     *
+     * @param schoolId
+     */
+    public void removeSchoolCache(Long schoolId);
+
+    /**
+     * 删除学校缓存
+     *
+     * @param code
+     */
+    public void removeSchoolCache(String code);
+
+    /**
+     * 删除学校缓存
+     */
+    public void removeSchoolIdCache();
+
+    /**
+     * 删除学校缓存
+     */
+    public void removeSchoolCodeCache();
 }

+ 119 - 0
sop-business/src/main/java/com/qmth/sop/business/cache/impl/CommonCacheServiceImpl.java

@@ -69,6 +69,9 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     @Resource
     TDTablePropService tdTablePropService;
 
+    @Resource
+    BasicSchoolService basicSchoolService;
+
     /**
      * 添加用户缓存
      *
@@ -643,6 +646,122 @@ public class CommonCacheServiceImpl implements CommonCacheService {
         cacheService.evict(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
     }
 
+    /**
+     * 添加学校缓存
+     *
+     * @param schoolId
+     * @return
+     */
+    @Override
+    public BasicSchool schoolCache(Long schoolId) {
+        return schoolCacheCommon(schoolId);
+    }
+
+    /**
+     * 添加学校缓存
+     *
+     * @param code
+     * @return
+     */
+    @Override
+    public BasicSchool schoolCache(String code) {
+        return schoolCacheCommon(code);
+    }
+
+    /**
+     * 更新学校缓存
+     *
+     * @param schoolId
+     * @return
+     */
+    @Override
+    public BasicSchool updateSchoolCache(Long schoolId) {
+        cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
+        return schoolCacheCommon(schoolId);
+    }
+
+    /**
+     * 更新学校缓存
+     *
+     * @param code
+     * @return
+     */
+    @Override
+    public BasicSchool updateSchoolCache(String code) {
+        cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
+        return schoolCacheCommon(code);
+    }
+
+    /**
+     * 删除学校缓存
+     *
+     * @param schoolId
+     */
+    @Override
+    public void removeSchoolCache(Long schoolId) {
+        cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
+    }
+
+    /**
+     * 删除学校缓存
+     *
+     * @param code
+     */
+    @Override
+    public void removeSchoolCache(String code) {
+        cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
+    }
+
+    /**
+     * 删除学校缓存
+     */
+    @Override
+    public void removeSchoolIdCache() {
+        cacheService.clear(SystemConstant.SCHOOL_CACHE);
+    }
+
+    /**
+     * 删除学校缓存
+     */
+    @Override
+    public void removeSchoolCodeCache() {
+        cacheService.clear(SystemConstant.SCHOOL_CODE_CACHE);
+    }
+
+    /**
+     * 学校缓存共用
+     *
+     * @param schoolId
+     * @return
+     */
+    protected BasicSchool schoolCacheCommon(Long schoolId) {
+        BasicSchool basicSchool = (BasicSchool) cacheService.get(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
+        if (Objects.isNull(basicSchool)) {
+            basicSchool = basicSchoolService.getById(schoolId);
+            if (Objects.nonNull(basicSchool)) {
+                cacheService.put(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId), basicSchool);
+            }
+        }
+        return basicSchool;
+    }
+
+    /**
+     * 学校缓存共用
+     *
+     * @param code
+     * @return
+     */
+    protected BasicSchool schoolCacheCommon(String code) {
+        BasicSchool basicSchool = (BasicSchool) cacheService.get(SystemConstant.SCHOOL_CODE_CACHE, code);
+        if (Objects.isNull(basicSchool)) {
+            basicSchool = basicSchoolService.getOne(new QueryWrapper<BasicSchool>().lambda().eq(BasicSchool::getCode, code));
+            if (Objects.nonNull(basicSchool)) {
+                cacheService.put(SystemConstant.SCHOOL_CODE_CACHE, code, basicSchool);
+            }
+        }
+        return basicSchool;
+    }
+
     /**
      * 角色缓存共用
      *

+ 136 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/BasicSchool.java

@@ -0,0 +1,136 @@
+package com.qmth.sop.business.entity;
+
+import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.contant.SystemConstant;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 学校表
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+@ApiModel(value = "BasicSchool对象", description = "学校表")
+public class BasicSchool extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "学校编码")
+    private String code;
+
+    @ApiModelProperty(value = "域名")
+    private String domainName;
+
+    @ApiModelProperty(value = "学校名称")
+    private String name;
+
+    @ApiModelProperty(value = "是否启用,false:停用,true:启用")
+    private Boolean enable;
+
+    @ApiModelProperty(value = "访问key")
+    private String accessKey;
+
+    @ApiModelProperty(value = "访问秘钥")
+    private String accessSecret;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "学校logo")
+    private String logo;
+
+
+    public BasicSchool() {
+
+    }
+
+    public BasicSchool(Long id, String code, String name, String accessKey, String accessSecret) {
+        this.code = code;
+        this.domainName = code;
+        this.name = name;
+        this.accessKey = accessKey;
+        this.accessSecret = accessSecret;
+        setId(id);
+        this.enable = true;
+    }
+
+    public BasicSchool(String code, String name, String accessKey, String accessSecret, String logo) {
+        this.code = code;
+        this.domainName = code;
+        this.name = name;
+        this.accessKey = accessKey;
+        this.accessSecret = accessSecret;
+        this.logo = logo;
+        setId(SystemConstant.getDbUuid());
+        this.enable = true;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getLogo() {
+        return logo;
+    }
+
+    public void setLogo(String logo) {
+        this.logo = logo;
+    }
+}

+ 4 - 2
sop-business/src/main/java/com/qmth/sop/business/entity/BasicVerifyCode.java

@@ -46,9 +46,10 @@ public class BasicVerifyCode extends BaseEntity implements Serializable {
 
     }
 
-    public BasicVerifyCode(Long userId, String mobileNumber, Long expireTime, Integer validPeriod, String verifyCode) {
+    public BasicVerifyCode(Long userId, Long orgId, String mobileNumber, Long expireTime, Integer validPeriod, String verifyCode) {
         setId(SystemConstant.getDbUuid());
         this.userId = userId;
+        this.orgId = orgId;
         this.mobileNumber = mobileNumber;
         this.expireTime = expireTime;
         this.validPeriod = validPeriod;
@@ -57,8 +58,9 @@ public class BasicVerifyCode extends BaseEntity implements Serializable {
         setCreateTime(System.currentTimeMillis());
     }
 
-    public void updateVerifyCodeInfo(Long userId, Long expireTime, Integer validPeriod, String verifyCode) {
+    public void updateVerifyCodeInfo(Long userId, Long orgId, Long expireTime, Integer validPeriod, String verifyCode) {
         this.expireTime = expireTime;
+        this.orgId = orgId;
         this.validPeriod = validPeriod;
         this.verifyCode = verifyCode;
         setUpdateId(userId);

+ 68 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysLog.java

@@ -25,6 +25,13 @@ public class SysLog implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
 
+    @ApiModelProperty(value = "用户对象id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long userId;
+
+    @ApiModelProperty(value = "用户名称")
+    private String userName;
+
     @ApiModelProperty(value = "类别,LOGIN:登录,LOGOUT:退出以及数据库DDL和DML操作")
     private LogTypeEnum type;
 
@@ -38,6 +45,12 @@ public class SysLog implements Serializable {
     @ApiModelProperty(value = "内容")
     private String content;
 
+    @ApiModelProperty(value = "请求的url")
+    private String url;
+
+    @ApiModelProperty(value = "参数")
+    private String args;
+
     @ApiModelProperty(value = "更改前内容")
     private String updateBeforeObj;
 
@@ -47,6 +60,13 @@ public class SysLog implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Long createTime;
 
+    @ApiModelProperty(value = "方法运行时间")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long runTime;
+
+    @ApiModelProperty(value = "运行状态")
+    private String runStatus;
+
     public Long getId() {
         return id;
     }
@@ -55,6 +75,22 @@ public class SysLog implements Serializable {
         this.id = id;
     }
 
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
     public LogTypeEnum getType() {
         return type;
     }
@@ -87,6 +123,22 @@ public class SysLog implements Serializable {
         this.content = content;
     }
 
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getArgs() {
+        return args;
+    }
+
+    public void setArgs(String args) {
+        this.args = args;
+    }
+
     public String getUpdateBeforeObj() {
         return updateBeforeObj;
     }
@@ -110,4 +162,20 @@ public class SysLog implements Serializable {
     public void setCreateTime(Long createTime) {
         this.createTime = createTime;
     }
+
+    public Long getRunTime() {
+        return runTime;
+    }
+
+    public void setRunTime(Long runTime) {
+        this.runTime = runTime;
+    }
+
+    public String getRunStatus() {
+        return runStatus;
+    }
+
+    public void setRunStatus(String runStatus) {
+        this.runStatus = runStatus;
+    }
 }

+ 53 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysUser.java

@@ -1,12 +1,18 @@
 package com.qmth.sop.business.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.enums.GenderEnum;
 import com.qmth.sop.common.enums.UserSourceEnum;
+import com.qmth.sop.common.util.Base64Util;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Length;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -23,9 +29,12 @@ public class SysUser extends BaseEntity implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "用户名")
+    @NotBlank(message = "请输入登录名")
+    @Length(message = "登录名不能超过{max}个字符", max = 30)
     private String loginName;
 
     @ApiModelProperty(value = "姓名")
+    @Length(message = "姓名不能超过{max}个字符", max = 32)
     private String realName;
 
     @ApiModelProperty(value = "工号")
@@ -35,15 +44,20 @@ public class SysUser extends BaseEntity implements Serializable {
     private String password;
 
     @ApiModelProperty(value = "手机号")
+    @Length(message = "手机号码不能超过{max}个字符", max = 25)
     private String mobileNumber;
 
     @ApiModelProperty(value = "机构id")
     @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "请选择机构")
     private Long orgId;
 
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     private Boolean enable;
 
+    @ApiModelProperty(value = "性别,MAN:男,WOMAN:女")
+    private GenderEnum gender;
+
     @ApiModelProperty(value = "密码修改次数,默认为0")
     private Integer pwdCount;
 
@@ -56,6 +70,45 @@ public class SysUser extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "来源,SYSTEM:系统自带,ARCHIVES:档案")
     private UserSourceEnum source;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @TableField(exist = false)
+    @NotNull(message = "请选择角色")
+    private Long[] roleIds;
+
+    public Long[] getRoleIds() {
+        return roleIds;
+    }
+
+    public void setRoleIds(Long[] roleIds) {
+        this.roleIds = roleIds;
+    }
+
+    public GenderEnum getGender() {
+        return gender;
+    }
+
+    public void setGender(GenderEnum gender) {
+        this.gender = gender;
+    }
+
+    /**
+     * 设置密码
+     *
+     * @param password
+     */
+    public void setPasswordInfo(String password) {
+        this.password = Base64Util.encode(password.substring(password.length() - 6, password.length()).getBytes());
+    }
+
+    /**
+     * 更新密码
+     *
+     * @param password
+     */
+    public void updatePasswordInfo(String password) {
+        this.password = Base64Util.encode(password.substring(password.length() - 6, password.length()).getBytes());
+    }
+
     public UserSourceEnum getSource() {
         return source;
     }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysUserRole.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.entity;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.contant.SystemConstant;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -39,6 +40,16 @@ public class SysUserRole implements Serializable {
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     private Boolean enable;
 
+    public SysUserRole() {
+
+    }
+
+    public SysUserRole(Long userId, Long roleId) {
+        this.id = SystemConstant.getDbUuid();
+        this.userId = userId;
+        this.roleId = roleId;
+    }
+
     public Long getId() {
         return id;
     }

+ 132 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TSAuth.java

@@ -0,0 +1,132 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.AuthEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 激活授权配置表
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+@ApiModel(value="TSAuth对象", description="激活授权配置表")
+public class TSAuth extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "学校id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long schoolId;
+
+    @ApiModelProperty(value = "accessKey")
+    private String accessKey;
+
+    @ApiModelProperty(value = "accessSecret")
+    private String accessSecret;
+
+    @ApiModelProperty(value = "离线授权证书")
+    private String description;
+
+    @ApiModelProperty(value = "授权类型")
+    private AuthEnum type;
+
+    @ApiModelProperty(value = "过期时间")
+    private Long expireTime;
+
+    @ApiModelProperty(value = "文件数据")
+    private byte[] file;
+
+    public TSAuth() {
+
+    }
+
+    public TSAuth(Long schoolId, String accessKey, String accessSecret, AuthEnum type, Long expireTime) {
+        setId(SystemConstant.getDbUuid());
+        this.schoolId = schoolId;
+        this.accessKey = accessKey;
+        this.accessSecret = accessSecret;
+        this.type = type;
+        this.expireTime = expireTime;
+    }
+
+    public TSAuth(Long schoolId, String description, AuthEnum type, Long expireTime) {
+        setId(SystemConstant.getDbUuid());
+        this.schoolId = schoolId;
+        this.description = description;
+        this.type = type;
+        this.expireTime = expireTime;
+    }
+
+    public TSAuth(Long schoolId, byte[] file, AuthEnum type, Long expireTime) {
+        setId(SystemConstant.getDbUuid());
+        this.schoolId = schoolId;
+        this.file = file;
+        this.type = type;
+        this.expireTime = expireTime;
+    }
+
+    public Long getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Long schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public AuthEnum getType() {
+        return type;
+    }
+
+    public void setType(AuthEnum type) {
+        this.type = type;
+    }
+
+    public Long getExpireTime() {
+        return expireTime;
+    }
+
+    public void setExpireTime(Long expireTime) {
+        this.expireTime = expireTime;
+    }
+
+    public byte[] getFile() {
+        return file;
+    }
+
+    public void setFile(byte[] file) {
+        this.file = file;
+    }
+}

+ 16 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/BasicSchoolMapper.java

@@ -0,0 +1,16 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.sop.business.entity.BasicSchool;
+
+/**
+ * <p>
+ * 学校表 Mapper 接口
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+public interface BasicSchoolMapper extends BaseMapper<BasicSchool> {
+
+}

+ 17 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/SysLogMapper.java

@@ -1,7 +1,11 @@
 package com.qmth.sop.business.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.result.SysLogResult;
 import com.qmth.sop.business.entity.SysLog;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -12,5 +16,17 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2023-08-01
  */
 public interface SysLogMapper extends BaseMapper<SysLog> {
-
+    /**
+     * 日志分页查询
+     *
+     * @param iPage     分页参数
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     * @param content   内容
+     * @return 分页结果
+     */
+    IPage<SysLogResult> page(@Param("iPage") Page<SysLogResult> iPage,
+                             @Param("startTime") Long startTime,
+                             @Param("endTime") Long endTime,
+                             @Param("content") String content);
 }

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SysRoleMapper.java

@@ -2,6 +2,9 @@ package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.sop.business.entity.SysRole;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,11 @@ import com.qmth.sop.business.entity.SysRole;
  */
 public interface SysRoleMapper extends BaseMapper<SysRole> {
 
+    /**
+     * 根据userId查询角色
+     *
+     * @param userId
+     * @return
+     */
+    List<SysRole> listRolesByUserId(@Param("userId") Long userId);
 }

+ 34 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SysUserMapper.java

@@ -1,11 +1,15 @@
 package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.dto.UserDto;
+import com.qmth.sop.business.bean.dto.VerifyCodeCheckDto;
 import com.qmth.sop.business.bean.result.SysUserResult;
 import com.qmth.sop.business.entity.SysUser;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -32,4 +36,34 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      * @return
      */
     List<SysUserResult> findSysUserResultList(@Param("orgId") Long orgId);
+
+    /**
+     * 根据用户(id和手机号)查询验证码发送几率
+     *
+     * @param userId       用户id
+     * @param mobileNumber 用户手机号
+     * @return 更新条数
+     */
+    int updateVerifyCodeExpiredTime(@Param("userId") Long userId, @Param("mobileNumber") String mobileNumber);
+
+    /**
+     * 根据用户(id和手机号)查询验证码发送几率
+     *
+     * @param userId       用户id
+     * @param mobileNumber 用户手机号
+     * @return 验证码记录结果
+     */
+    List<VerifyCodeCheckDto> findVerifyCodeByUser(@Param("userId") Long userId, @Param("mobileNumber") String mobileNumber);
+
+    /**
+     * 查询用户
+     *
+     * @param iPage
+     * @param userInfo
+     * @param orgId
+     * @param roleId
+     * @param enable
+     * @return
+     */
+    IPage<UserDto> query(IPage<Map> iPage, @Param("userInfo") String userInfo, @Param("orgId") Long orgId, @Param("roleId") Long roleId, @Param("enable") Boolean enable);
 }

+ 11 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/SysUserRoleMapper.java

@@ -1,7 +1,11 @@
 package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.sop.business.entity.SysRole;
 import com.qmth.sop.business.entity.SysUserRole;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +16,11 @@ import com.qmth.sop.business.entity.SysUserRole;
  * @since 2023-07-17
  */
 public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
-
+    /**
+     * 根据用户id查询角色集合
+     *
+     * @param userId 用户id
+     * @return 角色集合
+     */
+    List<SysRole> listRoleByUserId(@Param("userId") Long userId);
 }

+ 24 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TSAuthMapper.java

@@ -0,0 +1,24 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.sop.business.entity.TSAuth;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 激活授权配置表 Mapper 接口
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+public interface TSAuthMapper extends BaseMapper<TSAuth> {
+
+    /**
+     * 查询最后激活信息
+     *
+     * @param authEnum
+     * @return
+     */
+    TSAuth lastAuthInfo(@Param("authEnum") String authEnum);
+}

+ 16 - 0
sop-business/src/main/java/com/qmth/sop/business/service/BasicSchoolService.java

@@ -0,0 +1,16 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.entity.BasicSchool;
+
+/**
+ * <p>
+ * 学校表 服务类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+public interface BasicSchoolService extends IService<BasicSchool> {
+
+}

+ 15 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysLogService.java

@@ -1,7 +1,11 @@
 package com.qmth.sop.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.result.SysLogResult;
 import com.qmth.sop.business.entity.SysLog;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +17,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface SysLogService extends IService<SysLog> {
 
+    /**
+     * 日志分页查询
+     *
+     * @param startTime  开始时间
+     * @param endTime    结束时间
+     * @param content    内容
+     * @param pageNumber 分页页数
+     * @param pageSize   分页容量
+     * @return 分页结果
+     */
+    IPage<SysLogResult> page(Long startTime, Long endTime, String content, int pageNumber, int pageSize);
 }

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysRoleService.java

@@ -3,6 +3,8 @@ package com.qmth.sop.business.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.entity.SysRole;
 
+import java.util.List;
+
 /**
  * <p>
  * 角色表 服务类
@@ -13,4 +15,11 @@ import com.qmth.sop.business.entity.SysRole;
  */
 public interface SysRoleService extends IService<SysRole> {
 
+    /**
+     * 根据userId查询角色
+     *
+     * @param userId
+     * @return
+     */
+    List<SysRole> listRolesByUserId(Long userId);
 }

+ 20 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysUserRoleService.java

@@ -2,8 +2,12 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.result.MenuResult;
+import com.qmth.sop.business.entity.SysRole;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.SysUserRole;
 
+import java.util.List;
+
 /**
  * <p>
  * 用户和角色关联表 服务类
@@ -20,4 +24,20 @@ public interface SysUserRoleService extends IService<SysUserRole> {
      * @return
      */
     MenuResult listByUserId();
+
+    /**
+     * 根据用户id查询该用户所包含的角色集合
+     *
+     * @param userId 用户id
+     * @return 角色集合
+     */
+    List<SysRole> listRoleByUserId(Long userId);
+
+    /**
+     * 新增用户权限
+     *
+     * @param sysUser
+     * @param roleIds
+     */
+    public void addUserRolePrivilege(SysUser sysUser, Long[] roleIds);
 }

+ 48 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysUserService.java

@@ -1,6 +1,8 @@
 package com.qmth.sop.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.dto.UserDto;
 import com.qmth.sop.business.bean.result.LoginResult;
 import com.qmth.sop.business.bean.result.SysUserResult;
 import com.qmth.sop.business.entity.SysUser;
@@ -8,6 +10,7 @@ import com.qmth.sop.common.enums.AppSourceEnum;
 
 import java.security.NoSuchAlgorithmException;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -45,4 +48,49 @@ public interface SysUserService extends IService<SysUser> {
      * @return
      */
     List<SysUserResult> findSysUserResultList(Long orgId);
+
+    /**
+     * 强行过期用户手机号验证码(过期时间改为验证码发送时间)
+     *
+     * @param userId       用户id
+     * @param mobileNumber 用户手机号
+     */
+    void expiredVerifyCode(Long userId, String mobileNumber);
+
+    /**
+     * 校验短信验证码
+     *
+     * @param userId       用户id
+     * @param mobileNumber 用户手机号
+     * @param code         验证码
+     */
+    void checkSmsCode(Long userId, String mobileNumber, String code);
+
+    /**
+     * 查询用户
+     *
+     * @param iPage
+     * @param userInfo
+     * @param orgId
+     * @param roleId
+     * @param enable
+     * @return
+     */
+    IPage<UserDto> query(IPage<Map> iPage, String userInfo, Long orgId, Long roleId, Boolean enable);
+
+    /**
+     * 新增/修改用户
+     *
+     * @param sysUser
+     * @return
+     */
+    Boolean saveUser(SysUser sysUser);
+
+    /**
+     * 启用/禁用用户
+     *
+     * @param sysUser
+     * @return
+     */
+    Boolean enable(SysUser sysUser) throws NoSuchAlgorithmException;
 }

+ 51 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TSAuthService.java

@@ -0,0 +1,51 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.boot.core.solar.model.AppInfo;
+import com.qmth.sop.business.entity.TSAuth;
+import com.qmth.sop.common.enums.AuthEnum;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 激活授权配置表 服务类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+public interface TSAuthService extends IService<TSAuth> {
+
+    /**
+     * 授权信息初始化
+     *
+     * @return
+     */
+    AppInfo appInfoInit();
+
+    /**
+     * 保存授权信息
+     *
+     * @param appInfo
+     * @param authEnum
+     * @param file
+     * @throws Exception
+     */
+    public void saveAuthInfo(AppInfo appInfo, AuthEnum authEnum, byte[] file) throws Exception;
+
+    /**
+     * 更新学校启用/禁用
+     *
+     * @param orgCodesMap
+     */
+    public void updateSchoolEnable(Map<String, String> orgCodesMap);
+
+    /**
+     * 查询最后激活信息
+     *
+     * @param authEnum
+     * @return
+     */
+    TSAuth lastAuthInfo(AuthEnum authEnum);
+}

+ 20 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/BasicSchoolServiceImpl.java

@@ -0,0 +1,20 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.entity.BasicSchool;
+import com.qmth.sop.business.mapper.BasicSchoolMapper;
+import com.qmth.sop.business.service.BasicSchoolService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 学校表 服务实现类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+@Service
+public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolMapper, BasicSchool> implements BasicSchoolService {
+
+}

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/BasicVerifyCodeServiceImpl.java

@@ -77,9 +77,9 @@ public class BasicVerifyCodeServiceImpl extends ServiceImpl<BasicVerifyCodeMappe
                 Optional.ofNullable(sysConfigSmsExpiredTime).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置短信验证码有效时间"));
                 Integer codeExpiredTime = Integer.parseInt(sysConfigSmsExpiredTime.getConfigValue());
                 if (Objects.isNull(basicVerifyCode)) {
-                    basicVerifyCode = new BasicVerifyCode(sysUser.getId(), mobileNumber, SystemConstant.processMiniute(Duration.ofMinutes(2)), codeExpiredTime, verifyCode);
+                    basicVerifyCode = new BasicVerifyCode(sysUser.getId(), sysUser.getOrgId(), mobileNumber, SystemConstant.processMiniute(Duration.ofMinutes(2)), codeExpiredTime, verifyCode);
                 } else {
-                    basicVerifyCode.updateVerifyCodeInfo(sysUser.getId(), SystemConstant.processMiniute(Duration.ofMinutes(2)), codeExpiredTime, verifyCode);
+                    basicVerifyCode.updateVerifyCodeInfo(sysUser.getId(), sysUser.getOrgId(), SystemConstant.processMiniute(Duration.ofMinutes(2)), codeExpiredTime, verifyCode);
                 }
                 this.saveOrUpdate(basicVerifyCode);
             } else {

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysLogServiceImpl.java

@@ -1,9 +1,13 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.result.SysLogResult;
 import com.qmth.sop.business.entity.SysLog;
 import com.qmth.sop.business.mapper.SysLogMapper;
 import com.qmth.sop.business.service.SysLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.common.contant.SystemConstant;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +21,11 @@ import org.springframework.stereotype.Service;
 @Service
 public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {
 
+    @Override
+    public IPage<SysLogResult> page(Long startTime, Long endTime, String content, int pageNumber, int pageSize) {
+        if (content != null && content.length() > 0) {
+            content = SystemConstant.translateSpecificSign(content);
+        }
+        return this.baseMapper.page(new Page<>(pageNumber, pageSize), startTime, endTime, content);
+    }
 }

+ 4 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysOrgServiceImpl.java

@@ -151,6 +151,10 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     @Override
     @Transactional
     public Boolean enable(SysOrg org) {
+        Optional.ofNullable(org).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("参数不能为空"));
+        Optional.ofNullable(org.getId()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("id不能为空"));
+        Optional.ofNullable(org.getEnable()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("启用/禁用不能为空"));
+
         // 禁用时,校验机构
         if (!org.getEnable()) {
             // 机构下是否有用户

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysRoleServiceImpl.java

@@ -6,6 +6,8 @@ import com.qmth.sop.business.mapper.SysRoleMapper;
 import com.qmth.sop.business.service.SysRoleService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 角色表 服务实现类
@@ -17,4 +19,14 @@ import org.springframework.stereotype.Service;
 @Service
 public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
 
+    /**
+     * 根据userId查询角色
+     *
+     * @param userId
+     * @return
+     */
+    @Override
+    public List<SysRole> listRolesByUserId(Long userId) {
+        return this.baseMapper.listRolesByUserId(userId);
+    }
 }

+ 26 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java

@@ -3,14 +3,19 @@ package com.qmth.sop.business.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.result.MenuResult;
 import com.qmth.sop.business.cache.CommonCacheService;
+import com.qmth.sop.business.entity.SysRole;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.SysUserRole;
 import com.qmth.sop.business.mapper.SysUserRoleMapper;
 import com.qmth.sop.business.service.SysUserRoleService;
 import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -36,4 +41,25 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         return commonCacheService.userMenuCache(sysUser.getId());
     }
+
+    @Override
+    public List<SysRole> listRoleByUserId(Long userId) {
+        return this.baseMapper.listRoleByUserId(userId);
+    }
+
+    /**
+     * 新增用户权限
+     *
+     * @param sysUser
+     * @param roleIds
+     */
+    @Override
+    @Transactional
+    public void addUserRolePrivilege(SysUser sysUser, Long[] roleIds) {
+        List<SysUserRole> sysUserRoleList = new ArrayList<>();
+        for (int i = 0; i < roleIds.length; i++) {
+            sysUserRoleList.add(new SysUserRole(sysUser.getId(), roleIds[i]));
+        }
+        this.saveBatch(sysUserRoleList);
+    }
 }

+ 198 - 6
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java

@@ -1,26 +1,37 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.gson.reflect.TypeToken;
+import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.core.enums.Platform;
 import com.qmth.sop.business.bean.auth.AuthBean;
 import com.qmth.sop.business.bean.auth.ExpireTimeBean;
+import com.qmth.sop.business.bean.dto.RoleDto;
+import com.qmth.sop.business.bean.dto.UserDto;
+import com.qmth.sop.business.bean.dto.VerifyCodeCheckDto;
 import com.qmth.sop.business.bean.result.LoginResult;
 import com.qmth.sop.business.bean.result.SysUserResult;
 import com.qmth.sop.business.cache.CommonCacheService;
-import com.qmth.sop.business.entity.SysRole;
-import com.qmth.sop.business.entity.SysUser;
-import com.qmth.sop.business.entity.TBSession;
+import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.mapper.SysUserMapper;
+import com.qmth.sop.business.service.SysRoleService;
+import com.qmth.sop.business.service.SysUserRoleService;
 import com.qmth.sop.business.service.SysUserService;
 import com.qmth.sop.business.service.TBSessionService;
 import com.qmth.sop.business.util.AuthUtil;
+import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.AppSourceEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
-import com.qmth.sop.common.util.IpUtil;
-import com.qmth.sop.common.util.ServletUtil;
-import com.qmth.sop.common.util.SessionUtil;
+import com.qmth.sop.common.enums.FieldUniqueEnum;
+import com.qmth.sop.common.util.*;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.security.NoSuchAlgorithmException;
@@ -44,6 +55,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     @Resource
     TBSessionService tbSessionService;
 
+    @Resource
+    SysRoleService sysRoleService;
+
+    @Resource
+    SysUserRoleService sysUserRoleService;
+
     @Override
     public LoginResult login(String password, SysUser sysUser, AppSourceEnum appSource) throws NoSuchAlgorithmException {
         //停用
@@ -125,4 +142,179 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     public List<SysUserResult> findSysUserResultList(Long orgId) {
         return this.baseMapper.findSysUserResultList(orgId);
     }
+
+    /**
+     * 强行过期用户手机号验证码(过期时间改为验证码发送时间)
+     *
+     * @param userId       用户id
+     * @param mobileNumber 用户手机号
+     */
+    @Override
+    @Transactional
+    public void expiredVerifyCode(Long userId, String mobileNumber) {
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_CODE_ENABLE);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未启用短信验证码"));
+        Boolean enable = Boolean.valueOf(sysConfig.getConfigValue());
+        if (enable) {
+            int count = this.baseMapper.updateVerifyCodeExpiredTime(userId, mobileNumber);
+            if (count != 1) {
+                throw ExceptionResultEnum.ERROR.exception("验证码过期失败");
+            }
+        }
+    }
+
+    /**
+     * 校验短信验证码
+     *
+     * @param userId       用户id
+     * @param mobileNumber 用户手机号
+     * @param code         验证码
+     */
+    @Override
+    public void checkSmsCode(Long userId, String mobileNumber, String code) {
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_CODE_ENABLE);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未启用短信验证码"));
+        Boolean enable = Boolean.valueOf(sysConfig.getConfigValue());
+        if (enable) {
+            SysConfig sysConfigNormal = commonCacheService.addSysConfigCache(SystemConstant.SMS_NORMAL_CODE);
+            Optional.ofNullable(sysConfigNormal).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置万能短信验证码"));
+            if (!Objects.equals(sysConfigNormal.getConfigValue(), code)) {
+                List<VerifyCodeCheckDto> verifyCodeCheckDtoList = this.baseMapper.findVerifyCodeByUser(userId, mobileNumber);
+                if (verifyCodeCheckDtoList.size() < 1) {
+                    throw ExceptionResultEnum.ERROR.exception("验证码错误");
+                }
+                VerifyCodeCheckDto accessControl = verifyCodeCheckDtoList.get(0);
+                if (Objects.isNull(accessControl) || !Objects.equals(accessControl.getVerifyCode(), code)) {
+                    throw ExceptionResultEnum.ERROR.exception("验证码错误");
+                }
+
+                if (new Date(accessControl.getExpireTime()).before(new Date())) {
+                    throw ExceptionResultEnum.ERROR.exception("验证码已过期");
+                }
+            }
+        }
+    }
+
+    /**
+     * 查询用户
+     *
+     * @param iPage
+     * @param userInfo
+     * @param orgId
+     * @param roleId
+     * @param enable
+     * @return
+     */
+    @Override
+    public IPage<UserDto> query(IPage<Map> iPage, String userInfo, Long orgId, Long roleId, Boolean enable) {
+        IPage<UserDto> userDtoIPage = this.baseMapper.query(iPage, userInfo, orgId, roleId, enable);
+        if (Objects.nonNull(userDtoIPage) && !CollectionUtils.isEmpty(userDtoIPage.getRecords())) {
+            userDtoIPage.getRecords().forEach(m -> {
+                //角色
+                List<SysRole> roles = sysRoleService.listRolesByUserId(Long.valueOf(m.getId()));
+                if (!CollectionUtils.isEmpty(roles)) {
+                    m.setRoles(GsonUtil.fromJson(GsonUtil.toJson(roles), new TypeToken<List<RoleDto>>() {
+                    }.getType()));
+                }
+            });
+        }
+        return userDtoIPage;
+    }
+
+    /**
+     * 新增/修改用户
+     *
+     * @param sysUser
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean saveUser(SysUser sysUser) {
+        SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
+        try {
+            SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+            if (Objects.isNull(sysUser.getId())) {//新增用户
+                sysUser.insertInfo(requestUser.getId());
+                sysUser.setPasswordInfo(sysUser.getMobileNumber());
+                sysUserService.save(sysUser);
+                sysUserRoleService.addUserRolePrivilege(sysUser, sysUser.getRoleIds());
+            } else {//修改用户
+                sysUser.updatePasswordInfo(sysUser.getMobileNumber());
+                SysUser dbUser = this.getById(sysUser.getId());
+                Optional.ofNullable(dbUser).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
+
+                List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(sysUser.getId());
+                List<Long> userRolesList = Arrays.asList(sysUser.getRoleIds());
+                Set<Long> dbUserRolesList = sysUserRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet());
+                int count = (int) dbUserRolesList.stream().filter(s -> !userRolesList.contains(s)).count();
+                sysUserService.update(new UpdateWrapper<SysUser>().lambda()
+                        .eq(SysUser::getId, sysUser.getId())
+                        .set(SysUser::getLoginName, sysUser.getLoginName())
+                        .set(SysUser::getRealName, sysUser.getRealName())
+                        .set(SysUser::getCode, sysUser.getCode())
+                        .set(SysUser::getMobileNumber, sysUser.getMobileNumber())
+                        .set(SysUser::getPassword, sysUser.getPassword())
+                        .set(SysUser::getGender, sysUser.getGender())
+                        .set(SysUser::getOrgId, sysUser.getOrgId())
+                        .set(SysUser::getUpdateId, requestUser.getId())
+                        .set(SysUser::getUpdateTime, System.currentTimeMillis())
+                );
+                //如果修改了角色,需要重新登录
+                if (count > 0 || dbUserRolesList.size() != userRolesList.size()) {
+                    QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
+                    sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, sysUser.getId());
+                    sysUserRoleService.remove(sysUserRoleQueryWrapper);
+
+                    commonCacheService.removeUserRolePrivilegeCache(sysUser.getId());
+                    sysUserRoleService.addUserRolePrivilege(sysUser, sysUser.getRoleIds());
+                    sysUserService.removeUserInfo(sysUser.getId(), true);
+                } else if (!dbUser.getOrgId().equals(sysUser.getOrgId())) {
+                    sysUserService.removeUserInfo(sysUser.getId(), true);
+                }
+                //如果修改了机构或手机号,需更新用户缓存
+                if (Objects.nonNull(dbUser.getOrgId()) && (dbUser.getOrgId().longValue() != sysUser.getOrgId().longValue()
+                        || !Objects.equals(dbUser.getMobileNumber(), sysUser.getMobileNumber()))) {
+                    commonCacheService.updateUserCache(sysUser.getId());
+                    commonCacheService.updateUserAuthCache(sysUser.getId());
+                }
+            }
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            if (e instanceof DuplicateKeyException) {
+                String errorColumn = e.getCause().toString();
+                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");
+                throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
+            } else if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 启用/禁用用户
+     *
+     * @param sysUser
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean enable(SysUser sysUser) throws NoSuchAlgorithmException {
+        Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("参数不能为空"));
+        Optional.ofNullable(sysUser.getId()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("id不能为空"));
+        Optional.ofNullable(sysUser.getEnable()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("启用/禁用不能为空"));
+
+        SysUser sysUserDb = this.getById(sysUser.getId());
+        Optional.ofNullable(sysUserDb).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
+
+        this.update(new UpdateWrapper<SysUser>().lambda().set(SysUser::getEnable, sysUser.getEnable()).eq(SysUser::getId, sysUser.getId()));
+        commonCacheService.updateUserCache(sysUser.getId());
+        //如果状态为禁用,需要踢下线重新登录
+        if (!sysUser.getEnable()) {
+            this.removeUserInfo(sysUser.getId(), true);
+        }
+        return true;
+    }
 }

+ 191 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TSAuthServiceImpl.java

@@ -0,0 +1,191 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.core.solar.config.SolarProperties;
+import com.qmth.boot.core.solar.model.AppInfo;
+import com.qmth.boot.core.solar.model.OrgInfo;
+import com.qmth.boot.core.solar.service.SolarService;
+import com.qmth.sop.business.cache.CommonCacheService;
+import com.qmth.sop.business.entity.BasicSchool;
+import com.qmth.sop.business.entity.TSAuth;
+import com.qmth.sop.business.mapper.TSAuthMapper;
+import com.qmth.sop.business.service.BasicSchoolService;
+import com.qmth.sop.business.service.TSAuthService;
+import com.qmth.sop.common.contant.SpringContextHolder;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.AuthEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+/**
+ * <p>
+ * 激活授权配置表 服务实现类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+@Service
+public class TSAuthServiceImpl extends ServiceImpl<TSAuthMapper, TSAuth> implements TSAuthService {
+    private final static Logger log = LoggerFactory.getLogger(TSAuthServiceImpl.class);
+
+    @Resource
+    SolarProperties solarProperties;
+
+    @Resource
+    SolarService solarService;
+
+    @Resource
+    CommonCacheService commonCacheService;
+
+    @Resource
+    BasicSchoolService basicSchoolService;
+
+    /**
+     * 授权信息初始化
+     *
+     * @return
+     */
+    @Override
+    public AppInfo appInfoInit() {
+        AppInfo appInfo = null;
+        try {
+            TSAuthService tsAuthService = SpringContextHolder.getBean(TSAuthService.class);
+            appInfo = solarService.getAppInfo();
+            if (Objects.nonNull(appInfo) && Objects.nonNull(solarProperties)) {
+                if (Objects.nonNull(solarProperties.getAccessKey())
+                        && !Objects.equals(solarProperties.getAccessKey().trim(), "")
+                        && Objects.nonNull(solarProperties.getAccessSecret())
+                        && !Objects.equals(solarProperties.getAccessSecret().trim(), "")) {//在线激活
+                    tsAuthService.saveAuthInfo(appInfo, AuthEnum.ON_LINE, null);
+                } else if (Objects.nonNull(solarProperties.getLicense())
+                        && !Objects.equals(solarProperties.getLicense().trim(), "")) {//离线激活
+                    tsAuthService.saveAuthInfo(appInfo, AuthEnum.OFF_LINE, null);
+                }
+            } else {
+                QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
+                tsAuthQueryWrapper.lambda().isNotNull(TSAuth::getFile);
+                List<TSAuth> tsAuthList = tsAuthService.list(tsAuthQueryWrapper);
+                if (!CollectionUtils.isEmpty(tsAuthList)) {
+                    for (TSAuth t : tsAuthList) {
+                        appInfo = solarService.update(t.getFile());
+                        tsAuthService.saveAuthInfo(appInfo, AuthEnum.OFF_LINE, t.getFile());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+        }
+        return appInfo;
+    }
+
+    /**
+     * 保存鉴权信息
+     *
+     * @param appInfo
+     * @param authEnum
+     * @param file
+     * @throws Exception
+     */
+    @Override
+    @Transactional
+    public void saveAuthInfo(AppInfo appInfo, AuthEnum authEnum, byte[] file) throws Exception {
+        List<OrgInfo> orgInfoList = solarService.getOrgList();
+        List<TSAuth> tsAuthList = null;
+        Map<String, String> orgCodesMap = null;
+        Set<BasicSchool> basicSchoolSet = null;
+        TSAuthService tsAuthService = SpringContextHolder.getBean(TSAuthService.class);
+        if (!CollectionUtils.isEmpty(orgInfoList)) {
+            tsAuthList = new ArrayList<>();
+            basicSchoolSet = new HashSet<>();
+            orgCodesMap = new HashMap<>();
+        }
+
+        Long expireTime = null;
+        if (Objects.nonNull(appInfo) && Objects.nonNull(appInfo.getControl())) {
+            expireTime = Objects.nonNull(appInfo.getControl().getExpireTime()) ? appInfo.getControl().getExpireTime() : -1;
+        }
+        for (OrgInfo o : orgInfoList) {
+            orgCodesMap.put(o.getCode(), o.getCode());
+            if (authEnum == AuthEnum.OFF_LINE) {
+                if (Objects.isNull(file)) {
+                    tsAuthList.add(new TSAuth(o.getId(), solarProperties.getLicense(), authEnum, expireTime));
+                } else {
+                    tsAuthList.add(new TSAuth(o.getId(), file, authEnum, expireTime));
+                }
+            } else {
+                tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, expireTime));
+            }
+            QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
+            basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, o.getCode());
+            BasicSchool basicSchool = basicSchoolService.getOne(basicSchoolQueryWrapper);
+            if (Objects.isNull(basicSchool)) {//不存在则创建学校
+                basicSchool = new BasicSchool(o.getId(), o.getCode(), o.getName(), o.getAccessKey(), o.getAccessSecret());
+                if (Objects.nonNull(o.getLogo()) && (!o.getLogo().startsWith("https:") || !o.getLogo().startsWith("http"))) {
+                    basicSchool.setLogo("data:image/png;base64," + o.getLogo());
+                } else {
+                    basicSchool.setLogo(o.getLogoUrl());
+                }
+                basicSchoolSet.add(basicSchool);
+            } else {
+                basicSchool.setAccessKey(o.getAccessKey());
+                basicSchool.setAccessSecret(o.getAccessSecret());
+                basicSchool.setLogo(Objects.nonNull(o.getLogoUrl()) ? o.getLogoUrl() : basicSchool.getLogo());
+                basicSchoolSet.add(basicSchool);
+            }
+        }
+
+        if (!CollectionUtils.isEmpty(tsAuthList) && !CollectionUtils.isEmpty(orgCodesMap)) {
+            tsAuthService.remove(new QueryWrapper<TSAuth>().lambda().ge(TSAuth::getId, 0L));
+            tsAuthService.saveOrUpdateBatch(tsAuthList);
+
+            if (!CollectionUtils.isEmpty(basicSchoolSet)) {
+                basicSchoolService.saveOrUpdateBatch(basicSchoolSet);
+                commonCacheService.removeSchoolIdCache();
+                commonCacheService.removeSchoolCodeCache();
+            }
+
+            tsAuthService.updateSchoolEnable(orgCodesMap);
+        }
+    }
+
+    /**
+     * 更新学校启用/禁用
+     *
+     * @param orgCodesMap
+     */
+    @Override
+    public void updateSchoolEnable(Map<String, String> orgCodesMap) {
+        List<BasicSchool> basicSchoolList = basicSchoolService.list();
+        if (!CollectionUtils.isEmpty(basicSchoolList)) {
+            for (BasicSchool b : basicSchoolList) {
+                if (orgCodesMap.containsKey(b.getCode())) {
+                    b.setEnable(true);
+                } else {
+                    b.setEnable(false);
+                }
+            }
+            basicSchoolService.saveOrUpdateBatch(basicSchoolList);
+            commonCacheService.removeSchoolIdCache();
+            commonCacheService.removeSchoolCodeCache();
+        }
+    }
+
+    /**
+     * 查询最后激活信息
+     *
+     * @param authEnum
+     * @return
+     */
+    @Override
+    public TSAuth lastAuthInfo(AuthEnum authEnum) {
+        return this.baseMapper.lastAuthInfo(Objects.nonNull(authEnum) ? authEnum.name() : null);
+    }
+}

+ 84 - 50
sop-business/src/main/resources/db/install/sop_db.sql

@@ -19,6 +19,28 @@ CREATE TABLE `basic_attachment` (
                                     PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='所有附件记录表';
 
+-- ----------------------------
+-- Table structure for basic_school
+-- ----------------------------
+DROP TABLE IF EXISTS `basic_school`;
+CREATE TABLE `basic_school` (
+                                `id` bigint NOT NULL COMMENT '主键',
+                                `code` varchar(20) NOT NULL COMMENT '学校编码',
+                                `domain_name` varchar(20) DEFAULT NULL COMMENT '域名',
+                                `name` varchar(100) DEFAULT NULL COMMENT '学校名称',
+                                `enable` tinyint NOT NULL DEFAULT '1' COMMENT '是否启用,false:停用,true:启用',
+                                `access_key` varchar(50) DEFAULT NULL COMMENT '访问key',
+                                `access_secret` varchar(50) DEFAULT NULL COMMENT '访问秘钥',
+                                `remark` text COMMENT '备注',
+                                `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                                `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                                `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                                `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                                `logo` mediumtext COMMENT '学校logo',
+                                PRIMARY KEY (`id`) USING BTREE,
+                                UNIQUE KEY `code` (`code`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学校表';
+
 -- ----------------------------
 -- Table structure for basic_sms_message
 -- ----------------------------
@@ -586,9 +608,9 @@ INSERT INTO `sys_privilege` VALUES (66, '用户登出', '/api/admin/common/logou
 INSERT INTO `sys_privilege` VALUES (67, '文件上传', '/api/admin/common/file/upload', 'URL', 64, 3, 'SYS', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` VALUES (68, '文件下载', '/api/admin/common/file/download', 'URL', 64, 4, 'SYS', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` VALUES (69, '文件预览', '/api/admin/common/file/preview', 'URL', 64, 5, 'SYS', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` VALUES (70, '人员档案导入', '/api/admin/user/archives/import', 'URL', 64, 1, 'AUTH', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` VALUES (71, '人员档案导出', '/api/admin/user/archives/export', 'URL', 64, 2, 'AUTH', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` VALUES (72, '任务管理查询', '/api/admin/task/query', 'URL', 64, 3, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (70, '人员档案导入', '/api/admin/user/archives/import', 'URL', 33, 1, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (71, '人员档案导出', '/api/admin/user/archives/export', 'URL', 33, 2, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (72, '任务管理查询', '/api/admin/task/query', 'URL', 240, 1, 'AUTH', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` VALUES (73, '下载导入模板', '/api/admin/common/download_import_template', 'URL', 64, 6, 'SYS', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` VALUES (74, '列表', 'List', 'LIST', 3, 1, 'AUTH', NULL, 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (75, '查询', 'Select', 'BUTTON', 3, 3, 'AUTH', NULL, 1, 0, 1);
@@ -628,11 +650,11 @@ INSERT INTO `sys_privilege` VALUES (108, '列表', 'List', 'LIST', 10, 1, 'AUTH'
 INSERT INTO `sys_privilege` VALUES (109, '查询条件', 'Condition', 'CONDITION', 10, 1, 'AUTH', NULL, 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (110, '查询', 'Select', 'BUTTON', 10, 2, 'AUTH', NULL, 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (111, '列表', 'List', 'LIST', 13, 1, 'AUTH', NULL, 1, 0, 1);
-INSERT INTO `sys_privilege` VALUES (112, '新增', 'Add', 'BUTTON', 13, 1, 'AUTH', NULL, 1, 0, 1);
+INSERT INTO `sys_privilege` VALUES (112, '新增', 'Add', 'BUTTON', 13, 1, 'AUTH', '249', 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (113, '查询条件', 'Condition', 'CONDITION', 13, 1, 'AUTH', NULL, 1, 0, 1);
-INSERT INTO `sys_privilege` VALUES (114, '修改', 'Update', 'LINK', 13, 1, 'AUTH', NULL, 1, 0, 1);
-INSERT INTO `sys_privilege` VALUES (115, '启用/禁用', 'Enable', 'LINK', 13, 2, 'AUTH', NULL, 1, 0, 1);
-INSERT INTO `sys_privilege` VALUES (116, '查询', 'Select', 'BUTTON', 13, 2, 'AUTH', NULL, 1, 0, 1);
+INSERT INTO `sys_privilege` VALUES (114, '修改', 'Update', 'LINK', 13, 1, 'AUTH', '249', 1, 0, 1);
+INSERT INTO `sys_privilege` VALUES (115, '启用/禁用', 'Enable', 'LINK', 13, 2, 'AUTH', '250', 1, 0, 1);
+INSERT INTO `sys_privilege` VALUES (116, '查询', 'Select', 'BUTTON', 13, 2, 'AUTH', '248', 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (117, '列表', 'List', 'LIST', 15, 1, 'AUTH', NULL, 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (118, '新增', 'Add', 'BUTTON', 15, 1, 'AUTH', NULL, 1, 0, 1);
 INSERT INTO `sys_privilege` VALUES (119, '查询条件', 'Condition', 'CONDITION', 15, 1, 'AUTH', NULL, 1, 0, 1);
@@ -768,6 +790,39 @@ INSERT INTO `sys_privilege` VALUES (248, '组织架构查询', '/api/admin/org/l
 INSERT INTO `sys_privilege` VALUES (249, '组织架构保存/修改', '/api/admin/org/save', 'URL', 13, 2, 'AUTH', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` VALUES (250, '组织架构启用/禁用', '/api/admin/org/enable', 'URL', 13, 3, 'AUTH', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` VALUES (251, '获取机构下所有用户', '/api/admin/common/get_org_user_list', 'URL', 64, 9, 'SYS', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (252, '用户查询', '/api/admin/user/list', 'URL', 15, 1, 'AUTH', '122', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (253, '服务档位删除', '/api/sys/level/delete', 'URL', 6, 2, 'AUTH', '92', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (254, '服务档位', '/api/sys/level/get', 'URL', 6, 3, 'AUTH', '90,91', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (255, '服务档位列表', '/api/sys/level/list', 'URL', 6, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (256, '服务档位列表', '/api/sys/level/query', 'URL', 6, 5, 'AUTH', '89', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (257, '服务档位修改', '/api/sys/level/update', 'URL', 6, 6, 'AUTH', '91', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (258, '客户新增', '/api/sys/custom/add', 'URL', 3, 1, 'AUTH', '79', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (259, '客户删除', '/api/sys/custom/delete', 'URL', 3, 2, 'AUTH', '78', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (260, '客户查询', '/api/sys/custom/get', 'URL', 3, 3, 'AUTH', '77,78', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (261, '客户批量导入', '/api/sys/custom/import', 'URL', 3, 4, 'AUTH', '80', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (262, '客户查询条件', '/api/sys/custom/query', 'URL', 3, 5, 'AUTH', '75', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (263, '客户修改', '/api/sys/custom/update', 'URL', 3, 6, 'AUTH', '77', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (264, '供应商新增', '/api/sys/supplier/add', 'URL', 4, 1, 'AUTH', '81', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (265, '供应商启用/禁用', '/api/sys/supplier/enable', 'URL', 4, 2, 'AUTH', '84', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (266, '供应商列表', '/api/sys/supplier/get', 'URL', 4, 3, 'AUTH', '81,83', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (267, '供应商列表', '/api/sys/supplier/list', 'URL', 4, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (268, '供应商列表', '/api/sys/supplier/query', 'URL', 4, 5, 'AUTH', '82', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (269, '供应商修改', '/api/sys/supplier/update', 'URL', 4, 6, 'AUTH', '83', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (270, '设备新增', '/api/sys/device/add', 'URL', 5, 1, 'AUTH', '87', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (271, '设备作废', '/api/sys/device/delete', 'URL', 5, 2, 'AUTH', '88', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (272, '设备作废', '/api/sys/device/disable', 'URL', 5, 3, 'AUTH', '88', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (273, '设备查询条件', '/api/sys/device/get', 'URL', 5, 4, 'AUTH', '86', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (274, '设备列表', '/api/sys/device/list', 'URL', 5, 5, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (275, '设备查询条件', '/api/sys/device/query', 'URL', 5, 6, 'AUTH', '85,86', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (276, '设备新增', '/api/sys/device/update', 'URL', 5, 7, 'AUTH', '87', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (277, '考勤新增', '/api/sys/ding/group/add', 'URL', 7, 1, 'AUTH', '94', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (278, '考勤删除', '/api/sys/ding/group/delete', 'URL', 7, 2, 'AUTH', '96', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (279, '考勤查询', '/api/sys/ding/group/get', 'URL', 7, 3, 'AUTH', '94,95', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (280, '考勤查询', '/api/sys/ding/group/list', 'URL', 7, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (281, '考勤查询条件', '/api/sys/ding/group/query', 'URL', 7, 5, 'AUTH', '106', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (282, '考勤修改', '/api/sys/ding/group/update', 'URL', 7, 6, 'AUTH', '95', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (283, '用户新增/修改', '/api/admin/user/save', 'URL', 15, 2, 'AUTH', '120', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (284, '用户启用/禁用', '/api/admin/user/enable', 'URL', 15, 3, 'AUTH', '121', 1, 1, 0);
 COMMIT;
 
 -- ----------------------------
@@ -1056,6 +1111,7 @@ CREATE TABLE `sys_user` (
                             `password` varchar(50) NOT NULL COMMENT '密码',
                             `mobile_number` varchar(30) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '手机号',
                             `org_id` bigint DEFAULT NULL COMMENT '机构id',
+                            `gender` varchar(20) DEFAULT NULL COMMENT '性别,MAN:男,WOMAN:女',
                             `enable` tinyint NOT NULL DEFAULT '1' COMMENT '是否启用,0:停用,1:启用',
                             `pwd_count` tinyint DEFAULT '0' COMMENT '密码修改次数,默认为0',
                             `pwd_update_time` bigint DEFAULT NULL COMMENT '密码修改时间',
@@ -1072,8 +1128,8 @@ CREATE TABLE `sys_user` (
 -- Records of sys_user
 -- ----------------------------
 BEGIN;
-INSERT INTO `sys_user` VALUES (1, 'sysadmin', 'sysadmin', NULL, 'MTIzNDU2', NULL, NULL, 1, 1, 1629353956868, NULL, 'SYSTEM', NULL, NULL, NULL, 1629353956881);
-INSERT INTO `sys_user` VALUES (2, 'admin1', 'admin1', NULL, 'MTIzNDU2', NULL, NULL, 1, 1, 1629353956868, NULL, 'SYSTEM', NULL, NULL, NULL, 1629353956881);
+INSERT INTO `sys_user` VALUES (1, 'sysadmin', 'sysadmin', NULL, 'MTIzNDU2', NULL, NULL, NULL, 1, 1, 1629353956868, NULL, 'SYSTEM', NULL, NULL, NULL, 1629353956881);
+INSERT INTO `sys_user` VALUES (2, 'admin1', 'admin1', NULL, 'MTIzNDU2', null, 419897427273711616, 'MAN', 1, 1, 1629353956868, NULL, 'SYSTEM', NULL, NULL, NULL, 1629353956881);
 COMMIT;
 
 -- ----------------------------
@@ -1400,13 +1456,6 @@ CREATE TABLE `t_b_session` (
                                PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会话表';
 
--- ----------------------------
--- Records of t_b_session
--- ----------------------------
-BEGIN;
-INSERT INTO `t_b_session` VALUES ('f7bd71b338791254d3fa1767ee45a7c5', NULL, '1', '[系统管理员]', 'WEB', 'WEB', '1', '0:0:0:0:0:0:0:1', 'dfdmD_d8BrZp5ZwxR7UFI', 1690268121905, '0:0:0:0:0:0:0:1', NULL, 1690354521905, 'SYSTEM');
-COMMIT;
-
 -- ----------------------------
 -- Table structure for t_b_sop_info
 -- ----------------------------
@@ -1720,37 +1769,22 @@ CREATE TABLE `t_g_error` (
                              PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='全局异常错误信息表';
 
-
-------------------------------------------------------------------------------------------------------
---2023.8.7 增加菜单权限表数据--舒东辉
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (253, '服务档位删除', '/api/sys/level/delete', 'URL', 6, 2, 'AUTH', '92', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (254, '服务档位', '/api/sys/level/get', 'URL', 6, 3, 'AUTH', '90,91', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (255, '服务档位列表', '/api/sys/level/list', 'URL', 6, 4, 'AUTH', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (256, '服务档位列表', '/api/sys/level/query', 'URL', 6, 5, 'AUTH', '89', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (257, '服务档位修改', '/api/sys/level/update', 'URL', 6, 6, 'AUTH', '91', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (258, '客户新增', '/api/sys/custom/add', 'URL', 3, 1, 'AUTH', '79', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (259, '客户删除', '/api/sys/custom/delete', 'URL', 3, 2, 'AUTH', '78', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (260, '客户查询', '/api/sys/custom/get', 'URL', 3, 3, 'AUTH', '77,78', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (261, '客户批量导入', '/api/sys/custom/import', 'URL', 3, 4, 'AUTH', '80', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (262, '客户查询条件', '/api/sys/custom/query', 'URL', 3, 5, 'AUTH', '75', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (263, '客户修改', '/api/sys/custom/update', 'URL', 3, 6, 'AUTH', '77', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (264, '供应商新增', '/api/sys/supplier/add', 'URL', 4, 1, 'AUTH', '81', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (265, '供应商启用/禁用', '/api/sys/supplier/enable', 'URL', 4, 2, 'AUTH', '84', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (266, '供应商列表', '/api/sys/supplier/get', 'URL', 4, 3, 'AUTH', '81,83', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (267, '供应商列表', '/api/sys/supplier/list', 'URL', 4, 4, 'AUTH', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (268, '供应商列表', '/api/sys/supplier/query', 'URL', 4, 5, 'AUTH', '82', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (269, '供应商修改', '/api/sys/supplier/update', 'URL', 4, 6, 'AUTH', '83', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (270, '设备新增', '/api/sys/device/add', 'URL', 5, 1, 'AUTH', '87', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (271, '设备作废', '/api/sys/device/delete', 'URL', 5, 2, 'AUTH', '88', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (272, '设备作废', '/api/sys/device/disable', 'URL', 5, 3, 'AUTH', '88', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (273, '设备查询条件', '/api/sys/device/get', 'URL', 5, 4, 'AUTH', '86', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (274, '设备列表', '/api/sys/device/list', 'URL', 5, 5, 'AUTH', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (275, '设备查询条件', '/api/sys/device/query', 'URL', 5, 6, 'AUTH', '85,86', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (276, '设备新增', '/api/sys/device/update', 'URL', 5, 7, 'AUTH', '87', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (277, '考勤新增', '/api/sys/ding/group/add', 'URL', 7, 1, 'AUTH', '94', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (278, '考勤删除', '/api/sys/ding/group/delete', 'URL', 7, 2, 'AUTH', '96', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (279, '考勤查询', '/api/sys/ding/group/get', 'URL', 7, 3, 'AUTH', '94,95', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (280, '考勤查询', '/api/sys/ding/group/list', 'URL', 7, 4, 'AUTH', NULL, 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (281, '考勤查询条件', '/api/sys/ding/group/query', 'URL', 7, 5, 'AUTH', '106', 1, 1, 0);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (282, '考勤修改', '/api/sys/ding/group/update', 'URL', 7, 6, 'AUTH', '95', 1, 1, 0);
--------------------------------------------------------------------------------------
+-- ----------------------------
+-- Table structure for t_s_auth
+-- ----------------------------
+DROP TABLE IF EXISTS `t_s_auth`;
+CREATE TABLE `t_s_auth` (
+                            `id` bigint NOT NULL COMMENT '主键',
+                            `school_id` bigint DEFAULT NULL COMMENT '学校id',
+                            `access_key` varchar(255) DEFAULT NULL COMMENT 'accessKey',
+                            `access_secret` varchar(255) DEFAULT NULL COMMENT 'accessSecret',
+                            `description` text COMMENT '离线授权证书',
+                            `type` varchar(16) NOT NULL COMMENT '授权类型',
+                            `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                            `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                            `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                            `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                            `expire_time` bigint DEFAULT NULL COMMENT '过期时间',
+                            `file` mediumblob COMMENT '文件数据',
+                            PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='激活授权配置表';

+ 12 - 0
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -0,0 +1,12 @@
+-- 2023.8.7 日志管理表字段更改
+ALTER TABLE `sys_log` ADD COLUMN `user_id` bigint(0) NOT NULL COMMENT '用户id' AFTER `id`;
+
+ALTER TABLE `sys_log` ADD COLUMN `user_name` varchar(100) NULL DEFAULT NULL COMMENT '用户名称' AFTER `user_id`;
+
+ALTER TABLE `sys_log` ADD COLUMN `url` varchar(64) NULL DEFAULT NULL COMMENT '请求的url' AFTER `content`;
+
+ALTER TABLE `sys_log` ADD COLUMN `args` mediumtext NULL COMMENT '请求的参数' AFTER `url`;
+
+ALTER TABLE `sys_log` ADD COLUMN `run_time` bigint(0) NULL DEFAULT NULL COMMENT '请求的响应时间' AFTER `create_time`;
+
+ALTER TABLE `sys_log` ADD COLUMN `run_status` varchar(64) NULL DEFAULT NULL COMMENT '请求的结果' AFTER `run_time`;

+ 33 - 0
sop-business/src/main/resources/db/log/shudonghui_update_log.sql

@@ -0,0 +1,33 @@
+------------------------------------------------------------------------------------------------------
+--2023.8.7 增加菜单权限表数据--舒东辉
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (253, '服务档位删除', '/api/sys/level/delete', 'URL', 6, 2, 'AUTH', '92', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (254, '服务档位', '/api/sys/level/get', 'URL', 6, 3, 'AUTH', '90,91', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (255, '服务档位列表', '/api/sys/level/list', 'URL', 6, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (256, '服务档位列表', '/api/sys/level/query', 'URL', 6, 5, 'AUTH', '89', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (257, '服务档位修改', '/api/sys/level/update', 'URL', 6, 6, 'AUTH', '91', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (258, '客户新增', '/api/sys/custom/add', 'URL', 3, 1, 'AUTH', '79', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (259, '客户删除', '/api/sys/custom/delete', 'URL', 3, 2, 'AUTH', '78', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (260, '客户查询', '/api/sys/custom/get', 'URL', 3, 3, 'AUTH', '77,78', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (261, '客户批量导入', '/api/sys/custom/import', 'URL', 3, 4, 'AUTH', '80', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (262, '客户查询条件', '/api/sys/custom/query', 'URL', 3, 5, 'AUTH', '75', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (263, '客户修改', '/api/sys/custom/update', 'URL', 3, 6, 'AUTH', '77', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (264, '供应商新增', '/api/sys/supplier/add', 'URL', 4, 1, 'AUTH', '81', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (265, '供应商启用/禁用', '/api/sys/supplier/enable', 'URL', 4, 2, 'AUTH', '84', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (266, '供应商列表', '/api/sys/supplier/get', 'URL', 4, 3, 'AUTH', '81,83', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (267, '供应商列表', '/api/sys/supplier/list', 'URL', 4, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (268, '供应商列表', '/api/sys/supplier/query', 'URL', 4, 5, 'AUTH', '82', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (269, '供应商修改', '/api/sys/supplier/update', 'URL', 4, 6, 'AUTH', '83', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (270, '设备新增', '/api/sys/device/add', 'URL', 5, 1, 'AUTH', '87', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (271, '设备作废', '/api/sys/device/delete', 'URL', 5, 2, 'AUTH', '88', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (272, '设备作废', '/api/sys/device/disable', 'URL', 5, 3, 'AUTH', '88', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (273, '设备查询条件', '/api/sys/device/get', 'URL', 5, 4, 'AUTH', '86', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (274, '设备列表', '/api/sys/device/list', 'URL', 5, 5, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (275, '设备查询条件', '/api/sys/device/query', 'URL', 5, 6, 'AUTH', '85,86', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (276, '设备新增', '/api/sys/device/update', 'URL', 5, 7, 'AUTH', '87', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (277, '考勤新增', '/api/sys/ding/group/add', 'URL', 7, 1, 'AUTH', '94', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (278, '考勤删除', '/api/sys/ding/group/delete', 'URL', 7, 2, 'AUTH', '96', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (279, '考勤查询', '/api/sys/ding/group/get', 'URL', 7, 3, 'AUTH', '94,95', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (280, '考勤查询', '/api/sys/ding/group/list', 'URL', 7, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (281, '考勤查询条件', '/api/sys/ding/group/query', 'URL', 7, 5, 'AUTH', '106', 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (282, '考勤修改', '/api/sys/ding/group/update', 'URL', 7, 6, 'AUTH', '95', 1, 1, 0);
+-------------------------------------------------------------------------------------

+ 60 - 0
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -0,0 +1,60 @@
+--2023.8.7update
+ALTER TABLE sys_user ADD gender varchar(20) NULL COMMENT '性别,MAN:男,WOMAN:女';
+ALTER TABLE sys_user CHANGE gender gender varchar(20) NULL COMMENT '性别,MAN:男,WOMAN:女' AFTER org_id;
+ALTER TABLE sys_user CHANGE org_id org_id bigint NULL COMMENT '机构id' AFTER mobile_number;
+
+UPDATE sys_privilege
+SET name='人员档案导入', url='/api/admin/user/archives/import', `type`='URL', parent_id=33, `sequence`=1, property='AUTH', related=NULL, enable=1, default_auth=1, front_display=0
+WHERE id=70;
+UPDATE sys_privilege
+SET name='人员档案导出', url='/api/admin/user/archives/export', `type`='URL', parent_id=33, `sequence`=2, property='AUTH', related=NULL, enable=1, default_auth=1, front_display=0
+WHERE id=71;
+UPDATE sys_privilege
+SET name='任务管理查询', url='/api/admin/task/query', `type`='URL', parent_id=240, `sequence`=1, property='AUTH', related=NULL, enable=1, default_auth=1, front_display=0
+WHERE id=72;
+
+INSERT INTO `sys_privilege` VALUES (252, '用户查询', '/api/admin/user/list', 'URL', 15, 1, 'AUTH', '122', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (283, '用户新增/修改', '/api/admin/user/save', 'URL', 15, 2, 'AUTH', '120', 1, 1, 0);
+INSERT INTO `sys_privilege` VALUES (284, '用户启用/禁用', '/api/admin/user/enable', 'URL', 15, 3, 'AUTH', '121', 1, 1, 0);
+
+-- ----------------------------
+-- Table structure for t_s_auth
+-- ----------------------------
+DROP TABLE IF EXISTS `t_s_auth`;
+CREATE TABLE `t_s_auth` (
+                            `id` bigint NOT NULL COMMENT '主键',
+                            `school_id` bigint DEFAULT NULL COMMENT '学校id',
+                            `access_key` varchar(255) DEFAULT NULL COMMENT 'accessKey',
+                            `access_secret` varchar(255) DEFAULT NULL COMMENT 'accessSecret',
+                            `description` text COMMENT '离线授权证书',
+                            `type` varchar(16) NOT NULL COMMENT '授权类型',
+                            `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                            `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                            `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                            `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                            `expire_time` bigint DEFAULT NULL COMMENT '过期时间',
+                            `file` mediumblob COMMENT '文件数据',
+                            PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='激活授权配置表';
+
+-- ----------------------------
+-- Table structure for basic_school
+-- ----------------------------
+DROP TABLE IF EXISTS `basic_school`;
+CREATE TABLE `basic_school` (
+                                `id` bigint NOT NULL COMMENT '主键',
+                                `code` varchar(20) NOT NULL COMMENT '学校编码',
+                                `domain_name` varchar(20) DEFAULT NULL COMMENT '域名',
+                                `name` varchar(100) DEFAULT NULL COMMENT '学校名称',
+                                `enable` tinyint NOT NULL DEFAULT '1' COMMENT '是否启用,false:停用,true:启用',
+                                `access_key` varchar(50) DEFAULT NULL COMMENT '访问key',
+                                `access_secret` varchar(50) DEFAULT NULL COMMENT '访问秘钥',
+                                `remark` text COMMENT '备注',
+                                `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                                `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                                `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                                `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                                `logo` mediumtext COMMENT '学校logo',
+                                PRIMARY KEY (`id`) USING BTREE,
+                                UNIQUE KEY `code` (`code`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学校表';

+ 5 - 0
sop-business/src/main/resources/mapper/BasicSchoolMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.BasicSchoolMapper">
+
+</mapper>

+ 18 - 0
sop-business/src/main/resources/mapper/SysLogMapper.xml

@@ -2,4 +2,22 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.SysLogMapper">
 
+    <select id="page" resultType="com.qmth.sop.business.bean.result.SysLogResult">
+        SELECT
+            content, create_time AS createTime
+        FROM
+            sys_log
+        <where>
+            <if test="startTime != null">
+                AND create_time > #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND #{endTime} > create_time
+            </if>
+            <if test="content != null and content != ''">
+                AND content LIKE CONCAT('%',#{content},'%')
+            </if>
+        </where>
+        ORDER BY create_time DESC
+    </select>
 </mapper>

+ 14 - 0
sop-business/src/main/resources/mapper/SysRoleMapper.xml

@@ -2,4 +2,18 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.SysRoleMapper">
 
+    <select id="listRolesByUserId" resultType="com.qmth.sop.business.entity.SysRole">
+        SELECT distinct
+            a.id,
+            a.name,
+            a.type,
+            a.default_role,
+            a.enable
+        FROM
+            sys_role a
+                JOIN
+            sys_user_role b ON a.id = b.role_id
+        WHERE
+            b.user_id = #{userId}
+    </select>
 </mapper>

+ 70 - 0
sop-business/src/main/resources/mapper/SysUserMapper.xml

@@ -35,4 +35,74 @@
         so.id
         order by su.login_name
     </select>
+
+    <update id="updateVerifyCodeExpiredTime">
+        UPDATE basic_verify_code SET expire_time = create_time
+        <where>
+            <if test="mobileNumber != null and mobileNumber != ''">
+                and mobile_number = #{mobileNumber}
+            </if>
+            <if test="userId != null and userId != ''">
+                and user_id = #{userId}
+            </if>
+        </where>
+    </update>
+
+    <select id="findVerifyCodeByUser" resultType="com.qmth.sop.business.bean.dto.VerifyCodeCheckDto">
+        SELECT
+        id,
+        org_id AS orgId,
+        user_id AS userId,
+        mobile_number AS mobileNumber,
+        expire_time AS expireTime,
+        valid_period AS validPeriod,
+        verify_code AS verifyCode,
+        create_id AS createId,
+        create_time AS createTime,
+        update_id AS updateId,
+        update_time AS updateTime
+        FROM
+        basic_verify_code
+        <where>
+            <if test="userId != null and userId != ''">
+                AND user_id = #{userId}
+            </if>
+            <if test="mobileNumber != null and mobileNumber != ''">
+                AND mobile_number = #{mobileNumber}
+            </if>
+        </where>
+        ORDER BY update_time DESC
+    </select>
+
+    <select id="query" resultType="com.qmth.sop.business.bean.dto.UserDto">
+        SELECT
+        a.id,
+        a.login_name loginName,
+        a.real_name realName,
+        a.mobile_number mobileNumber,
+        a.gender,
+        a.enable,
+        a.remark,
+        a.org_id orgId,
+        b.name orgName
+        FROM sys_user a
+        join
+        sys_org b on a.org_id = b.id
+        <where>
+            <if test="userInfo != null and userInfo != ''">
+                and (a.login_name like concat('%', #{userInfo} , '%') or a.real_name like concat('%', #{userInfo} , '%') or a.mobile_number like concat('%', #{userInfo} , '%'))
+            </if>
+            <if test="orgId != null and orgId != ''">
+                and a.org_id = #{orgId}
+            </if>
+            <if test="roleId != null and roleId != ''">
+                and a.id in (select user_id from sys_user_role b where b.role_id = #{roleId})
+            </if>
+            <if test="enable != null and enable != '' or enable == 0">
+                and a.enable = #{enable}
+            </if>
+                and a.source = 'SYSTEM'
+        </where>
+        order by a.create_time desc
+    </select>
 </mapper>

+ 13 - 0
sop-business/src/main/resources/mapper/SysUserRoleMapper.xml

@@ -2,4 +2,17 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.SysUserRoleMapper">
 
+    <select id="listRoleByUserId" resultType="com.qmth.sop.business.entity.SysRole">
+        SELECT
+            *
+        FROM
+            sys_role a
+        WHERE
+            EXISTS( SELECT
+                        1
+                    FROM
+                        sys_user_role b
+                    WHERE
+                        a.id = b.role_id AND b.user_id = #{userId})
+    </select>
 </mapper>

+ 14 - 0
sop-business/src/main/resources/mapper/TSAuthMapper.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TSAuthMapper">
+
+    <select id="lastAuthInfo" resultType="com.qmth.sop.business.entity.TSAuth">
+        SELECT t.* FROM t_s_auth t
+        <where>
+            <if test="authEnum != null and authEnum != ''">
+                and t.type = #{authEnum}
+            </if>
+        </where>
+        limit 1;
+    </select>
+</mapper>

+ 4 - 4
sop-common/pom.xml

@@ -42,10 +42,10 @@
 <!--            <groupId>com.qmth.boot</groupId>-->
 <!--            <artifactId>tools-poi</artifactId>-->
 <!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>com.qmth.boot</groupId>-->
-<!--            <artifactId>core-solar</artifactId>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>com.qmth.boot</groupId>
+            <artifactId>core-solar</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>

+ 24 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -82,6 +82,7 @@ public class SystemConstant {
     public static final int PAGE_SIZE_MAX = 500;
     public static final int PAGE_NUMBER_MIN = 1;
     public static final String STATIC = "static";
+    public static final String CATALOG_LINK = "->";
 
     /**
      * 表达式
@@ -124,6 +125,7 @@ public class SystemConstant {
     public static final String PREFIX_URL_DEVICE = "/sys/device";
     public static final String PREFIX_URL_DING_GROUP = "/sys/ding/group";
     public static final String PREFIX_URL_SUPPLIER = "/sys/supplier";
+    public static final String PREFIX_URL_LOG = "/sys/log";
 
     /**
      * 缓存配置
@@ -139,6 +141,8 @@ public class SystemConstant {
     public static final String TABLE_PROP_CACHE = "table:prop:cache";
     public static final String ROLE_CACHE = "role:cache";
     public static final String USER_MENU_CACHE = "user:menu:cache";
+    public static final String SCHOOL_CACHE = "school:cache";
+    public static final String SCHOOL_CODE_CACHE = "school:code:cache";
 
     /**
      * 鉴权
@@ -147,6 +151,7 @@ public class SystemConstant {
     public static final String HEADER_TIME = "time";
     public static final String HEADER_PLATFORM = "platform";
     public static final String HEADER_DEVICE_ID = "deviceId";
+    public static final String CURRENT_PRIVILEGE_ID = "privilegeId";
     public static final String TOKEN = "token";
     public static final String SIGN = "sign";
     public static final String LOG_ERROR = "请求出错:{}";
@@ -278,4 +283,23 @@ public class SystemConstant {
         LocalDateTime newDateTime = nowTime.plus(duration);
         return newDateTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
     }
+
+    /**
+     * 模糊查询时调用以去除符号"%","_"特殊字符对查询结果的影响
+     *
+     * @param param 要校验的参数
+     * @return 转译后的参数
+     */
+    public static String translateSpecificSign(String param) {
+        if (param == null) {
+            return null;
+        }
+        if (param.contains("%")) {
+            param = param.replaceAll("%", "\\\\%");
+        }
+        if (param.contains("_")) {
+            param = param.replaceAll("_", "\\\\_");
+        }
+        return param;
+    }
 }

+ 3 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/AuthEnum.java

@@ -13,7 +13,9 @@ public enum AuthEnum {
 
     ON_LINE("在线激活"),
 
-    OFF_LINE("离线激活");
+    OFF_LINE("离线激活"),
+
+    NON_ACTIVATED("未激活");
 
     AuthEnum(String title) {
         this.title = title;

+ 4 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java

@@ -43,6 +43,8 @@ public enum ExceptionResultEnum {
 
     ORG_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000005, "没有机构数据"),
 
+    USER_NO_EXISTS(HttpStatus.INTERNAL_SERVER_ERROR, 5000006, "没有用户数据"),
+
     USER_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000009, "用户或密码不正确"),
 
     USER_ENABLE(HttpStatus.INTERNAL_SERVER_ERROR, 5000011, "用户已禁用"),
@@ -70,6 +72,8 @@ public enum ExceptionResultEnum {
 
     DEVICE_ID_INVALID(HttpStatus.UNAUTHORIZED, 4010002, "deviceId无效"),
 
+    PRIVILEGE_ID_INVALID(HttpStatus.UNAUTHORIZED, 4010002, "privilegeId无效"),
+
     TOKEN_INVALID(HttpStatus.UNAUTHORIZED, 4010003, "token无效"),
 
     TIME_INVALID(HttpStatus.UNAUTHORIZED, 4010004, "time无效"),

+ 20 - 6
sop-common/src/main/java/com/qmth/sop/common/enums/LogTypeEnum.java

@@ -8,18 +8,32 @@ package com.qmth.sop.common.enums;
  * @Date: 2022/1/24
  */
 public enum LogTypeEnum {
+    LOGIN("登录", true),
+    LOGOUT("退出", true),
+    EDIT("编辑", false),
+    ADD("新增", true),
+    DELETE("删除", true),
+    UPDATE("修改", true),
+    SEARCH("查询", true),
+    IMPORT("导入", true),
+    EXPORT("导出", true),
+    PUSH("推送", true),
+    PREVIEW("预览", true),
+    UN_KNOW("未知", false);
 
-    LOGIN("登录"),
+    private final String title;
+    private final boolean primary;
 
-    LOGOUT("退出");
-
-    private String title;
-
-    private LogTypeEnum(String title) {
+    LogTypeEnum(String title, boolean primary) {
         this.title = title;
+        this.primary = primary;
     }
 
     public String getTitle() {
         return title;
     }
+
+    public boolean isPrimary() {
+        return primary;
+    }
 }

+ 15 - 0
sop-common/src/main/java/com/qmth/sop/common/util/ServletUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.qmth.boot.core.enums.Platform;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.context.request.RequestContextHolder;
@@ -257,4 +258,18 @@ public class ServletUtil {
     public static Object getRequestHeaderOrgIdNotVaild() {
         return getRequest().getHeader(SystemConstant.ORG_ID);
     }
+
+    /**
+     * 获取当前请求的菜单ID
+     */
+    public static Long getCurrentPrivilegeId() {
+        try {
+            HttpServletRequest request = getRequest();
+            String currentPrivilegeId = request.getHeader(SystemConstant.CURRENT_PRIVILEGE_ID);
+            return StringUtils.isBlank(currentPrivilegeId) ? null : Long.valueOf(currentPrivilegeId);
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            throw ExceptionResultEnum.PRIVILEGE_ID_INVALID.exception();
+        }
+    }
 }

+ 19 - 0
sop-server/src/main/java/com/qmth/sop/server/api/BasicSchoolController.java

@@ -0,0 +1,19 @@
+package com.qmth.sop.server.api;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 学校表 前端控制器
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+@RestController
+@RequestMapping("/basic-school")
+public class BasicSchoolController {
+
+}

+ 9 - 4
sop-server/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -103,6 +103,7 @@ public class SysController {
                 throw ExceptionResultEnum.ERROR.exception("查出多个用户");
             }
             sysUser = sysUserList.get(0);
+            Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未查询到用户"));
 
             if (!Objects.equals(sysUser.getPassword(), login.getPassword())) {
                 throw ExceptionResultEnum.ERROR.exception("用户名或密码错误");
@@ -114,9 +115,6 @@ public class SysController {
             SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SMS_NORMAL_CODE);
             Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置万能短信验证码"));
 
-            if (!Objects.equals(sysConfig.getConfigValue().trim(), login.getCode().trim())) {
-
-            }
             sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, login.getMobileNumber()));
             if (CollectionUtils.isEmpty(sysUserList)) {
                 throw ExceptionResultEnum.ERROR.exception("用户不存在");
@@ -125,8 +123,15 @@ public class SysController {
                 throw ExceptionResultEnum.ERROR.exception("查出多个用户");
             }
             sysUser = sysUserList.get(0);
+            Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未查询到用户"));
+
+            // 校验验证码
+            sysUserService.checkSmsCode(sysUser.getId(), sysUser.getMobileNumber(), login.getCode());
+
+            if (!Objects.equals(sysConfig.getConfigValue().trim(), login.getCode().trim())) {
+                sysUserService.expiredVerifyCode(sysUser.getId(), sysUser.getMobileNumber());
+            }
         }
-        Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未查询到用户"));
         return ResultUtil.ok(sysUserService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM));
     }
 

+ 28 - 2
sop-server/src/main/java/com/qmth/sop/server/api/SysLogController.java

@@ -1,10 +1,22 @@
 package com.qmth.sop.server.api;
 
 
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.result.SysLogResult;
+import com.qmth.sop.business.service.SysLogService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.RequestMapping;
-
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
 /**
  * <p>
  * 系统日志 前端控制器
@@ -13,8 +25,22 @@ import org.springframework.web.bind.annotation.RestController;
  * @author wangliang
  * @since 2023-08-01
  */
+@Api(tags = "日志管理前端控制器")
 @RestController
-@RequestMapping("/sys-log")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_LOG)
 public class SysLogController {
+    @Resource
+    private SysLogService sysLogService;
+
+    @ApiOperation(value = "日志管理-查询")
+    @RequestMapping(value = "/page", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = SysLogResult.class)})
+    public Result findLogPage(@ApiParam(value = "起始时间") @RequestParam(required = false) Long startTime,
+                              @ApiParam(value = "截止时间") @RequestParam(required = false) Long endTime,
+                              @ApiParam(value = "内容") @RequestParam(required = false) String content,
+                              @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                              @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
 
+        return ResultUtil.ok(sysLogService.page(startTime, endTime, content, pageNumber, pageSize));
+    }
 }

+ 46 - 3
sop-server/src/main/java/com/qmth/sop/server/api/SysUserController.java

@@ -1,10 +1,22 @@
 package com.qmth.sop.server.api;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.dto.UserDto;
+import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.service.SysUserService;
 import com.qmth.sop.common.contant.SystemConstant;
-import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.security.NoSuchAlgorithmException;
 
 /**
  * <p>
@@ -19,4 +31,35 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_USER)
 public class SysUserController {
 
+    @Resource
+    SysUserService sysUserService;
+
+    @ApiOperation(value = "查询")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = UserDto.class)})
+    public Result list(@ApiParam(value = "登录名或真实姓名或手机号") @RequestParam(required = false) String userInfo,
+                       @ApiParam(value = "机构id") @RequestParam(required = false) Long orgId,
+                       @ApiParam(value = "角色id") @RequestParam(required = false) Long roleId,
+                       @ApiParam(value = "是否启用") @RequestParam(required = false) Boolean enable,
+                       @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                       @ApiParam(value = "页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        return ResultUtil.ok(sysUserService.query(new Page<>(pageNumber, pageSize), userInfo, orgId, roleId, enable));
+    }
+
+    @ApiOperation(value = "新增/修改")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result save(@Valid @RequestBody SysUser sysUser, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(sysUserService.saveUser(sysUser));
+    }
+
+    @ApiOperation(value = "启用/禁用")
+    @RequestMapping(value = "/enable", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result enable(@RequestBody SysUser sysUser) throws NoSuchAlgorithmException {
+        return ResultUtil.ok(sysUserService.enable(sysUser));
+    }
 }

+ 19 - 0
sop-server/src/main/java/com/qmth/sop/server/api/TSAuthController.java

@@ -0,0 +1,19 @@
+package com.qmth.sop.server.api;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 激活授权配置表 前端控制器
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-08-07
+ */
+@RestController
+@RequestMapping("/t-sauth")
+public class TSAuthController {
+
+}

+ 5 - 0
sop-server/src/main/java/com/qmth/sop/server/start/StartRunning.java

@@ -2,6 +2,7 @@ package com.qmth.sop.server.start;
 
 import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.service.SysConfigService;
+import com.qmth.sop.business.service.TSAuthService;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,11 +29,15 @@ public class StartRunning implements CommandLineRunner {
     @Resource
     ActivitiService activitiService;
 
+    @Resource
+    TSAuthService tsAuthService;
+
     @Override
     public void run(String... args) throws Exception {
         log.info("服务器启动时执行 start");
         sysConfigService.selectAll();
         activitiService.createDeployment(Arrays.asList(TFCustomTypeEnum.OFFICE_SOP_FLOW));
+        tsAuthService.appInfoInit();
         log.info("服务器启动时执行 end");
     }
 

+ 3 - 2
sop-server/src/main/resources/application.properties

@@ -84,7 +84,8 @@ spring.jackson.time-zone=GMT+8
 com.qmth.logging.root-level=info
 com.qmth.logging.file-path=/Users/king/Downloads/sop-server.log
 
-#com.qmth.solar.access-key=274f823e5f59410f8b3bb6edcd8e2b6e
-#com.qmth.solar.access-secret=y7AO6W0TOdTF8HpWBwGHbp3wfIHsmUKr
+com.qmth.solar.access-key=9ed64a57627845118913229ad578939b
+com.qmth.solar.access-secret=0qtqPS9S3DnjR043nuszsrUttl6ufqvc
+com.qmth.solar.app-code=sop
 
 com.qmth.sms.server=https://solar.qmth.com.cn