Browse Source

完成接口 开发

wuweihao 3 years ago
parent
commit
8135ee859b
100 changed files with 6416 additions and 1 deletions
  1. 30 1
      README.md
  2. 32 0
      gis_admin/pom.xml
  3. 26 0
      gis_admin/src/main/java/com/gis/admin/controller/ApiController.java
  4. 149 0
      gis_admin/src/main/java/com/gis/admin/controller/ExceptionController.java
  5. 42 0
      gis_admin/src/main/java/com/gis/admin/controller/LogController.java
  6. 194 0
      gis_admin/src/main/java/com/gis/admin/controller/LoginController.java
  7. 60 0
      gis_admin/src/main/java/com/gis/admin/controller/SysResourceController.java
  8. 87 0
      gis_admin/src/main/java/com/gis/admin/controller/SysRoleController.java
  9. 94 0
      gis_admin/src/main/java/com/gis/admin/controller/SysUserController.java
  10. 102 0
      gis_admin/src/main/java/com/gis/admin/controller/WxLoginController.java
  11. 28 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/LoginDto.java
  12. 28 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/PasswordDto.java
  13. 56 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/RegisterDto.java
  14. 21 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/ResetPasswordDto.java
  15. 31 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/RoleDto.java
  16. 79 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/UserDto.java
  17. 65 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/UserWebDto.java
  18. 64 0
      gis_admin/src/main/java/com/gis/admin/entity/po/SysResourceEntity.java
  19. 52 0
      gis_admin/src/main/java/com/gis/admin/entity/po/SysRoleEntity.java
  20. 55 0
      gis_admin/src/main/java/com/gis/admin/entity/po/SysUserEntity.java
  21. 42 0
      gis_admin/src/main/java/com/gis/admin/entity/po/WxUserEntity.java
  22. 12 0
      gis_admin/src/main/java/com/gis/admin/entity/vo/RoleVo.java
  23. 52 0
      gis_admin/src/main/java/com/gis/admin/mapper/SysResourceMapper.java
  24. 57 0
      gis_admin/src/main/java/com/gis/admin/mapper/SysRoleMapper.java
  25. 39 0
      gis_admin/src/main/java/com/gis/admin/mapper/SysUserMapper.java
  26. 19 0
      gis_admin/src/main/java/com/gis/admin/mapper/WxUserMapper.java
  27. 35 0
      gis_admin/src/main/java/com/gis/admin/mapper/provider/SysRoleProvider.java
  28. 54 0
      gis_admin/src/main/java/com/gis/admin/mapper/provider/SysUserProvider.java
  29. 28 0
      gis_admin/src/main/java/com/gis/admin/service/SysResourceService.java
  30. 40 0
      gis_admin/src/main/java/com/gis/admin/service/SysRoleService.java
  31. 42 0
      gis_admin/src/main/java/com/gis/admin/service/SysUserService.java
  32. 22 0
      gis_admin/src/main/java/com/gis/admin/service/WxUserService.java
  33. 172 0
      gis_admin/src/main/java/com/gis/admin/service/impl/SysResourceServiceImpl.java
  34. 207 0
      gis_admin/src/main/java/com/gis/admin/service/impl/SysRoleServiceImpl.java
  35. 284 0
      gis_admin/src/main/java/com/gis/admin/service/impl/SysUserServiceImpl.java
  36. 29 0
      gis_admin/src/main/java/com/gis/admin/service/impl/WxUserServiceImpl.java
  37. 34 0
      gis_admin/src/main/java/com/gis/admin/shiro/JwtAuthenticationException.java
  38. 28 0
      gis_admin/src/main/java/com/gis/admin/shiro/JwtToken.java
  39. 271 0
      gis_admin/src/main/java/com/gis/admin/shiro/ShiroConfig.java
  40. 262 0
      gis_admin/src/main/java/com/gis/admin/shiro/ShiroRealm.java
  41. 76 0
      gis_admin/src/main/java/com/gis/admin/shiro/filters/CustomShiroFilterFactoryBean.java
  42. 149 0
      gis_admin/src/main/java/com/gis/admin/shiro/filters/JwtFilter.java
  43. 68 0
      gis_admin/src/main/java/com/gis/admin/shiro/filters/ResourceCheckFilter.java
  44. 107 0
      gis_admin/src/main/java/com/gis/admin/tree/SysResourceTreeUtil.java
  45. 51 0
      gis_admin/src/main/java/com/gis/admin/tree/vo/SysResourceTree.java
  46. 191 0
      gis_admin/src/main/resources/db/sys_admin.sql
  47. 27 0
      gis_admin/src/main/resources/db/资源表.csv
  48. 37 0
      gis_application/pom.xml
  49. 14 0
      gis_application/src/main/java/com/gis/GisApplication.java
  50. 83 0
      gis_application/src/main/resources/application-dev.properties
  51. 79 0
      gis_application/src/main/resources/application-pro.properties
  52. 75 0
      gis_application/src/main/resources/application-sit.properties
  53. 46 0
      gis_application/src/main/resources/application.properties
  54. BIN
      gis_application/src/main/resources/data/律道四期题目内容模板.xlsx
  55. 156 0
      gis_application/src/main/resources/logback-spring.xml
  56. 11 0
      gis_application/src/main/resources/sh/shutdown.sh
  57. 123 0
      gis_application/src/main/resources/sh/startJar.sh
  58. 11 0
      gis_application/src/main/resources/sh/startup.sh
  59. 26 0
      gis_cms/pom.xml
  60. 56 0
      gis_cms/src/main/java/com/gis/cms/controller/MyController.java
  61. 58 0
      gis_cms/src/main/java/com/gis/cms/controller/QuestionController.java
  62. 69 0
      gis_cms/src/main/java/com/gis/cms/controller/RoomController.java
  63. 40 0
      gis_cms/src/main/java/com/gis/cms/controller/TestController.java
  64. 20 0
      gis_cms/src/main/java/com/gis/cms/entity/dto/RoomDto.java
  65. 24 0
      gis_cms/src/main/java/com/gis/cms/entity/dto/RoomListDto.java
  66. 27 0
      gis_cms/src/main/java/com/gis/cms/entity/dto/ScoreDto.java
  67. 19 0
      gis_cms/src/main/java/com/gis/cms/entity/dto/SortPageDto.java
  68. 46 0
      gis_cms/src/main/java/com/gis/cms/entity/po/FileEntity.java
  69. 42 0
      gis_cms/src/main/java/com/gis/cms/entity/po/GameLogEntity.java
  70. 36 0
      gis_cms/src/main/java/com/gis/cms/entity/po/QuestionEntity.java
  71. 55 0
      gis_cms/src/main/java/com/gis/cms/entity/po/RoomEntity.java
  72. 24 0
      gis_cms/src/main/java/com/gis/cms/entity/vo/WxUserVo.java
  73. 35 0
      gis_cms/src/main/java/com/gis/cms/mapper/FileMapper.java
  74. 21 0
      gis_cms/src/main/java/com/gis/cms/mapper/GameLogMapper.java
  75. 24 0
      gis_cms/src/main/java/com/gis/cms/mapper/QuestionMapper.java
  76. 27 0
      gis_cms/src/main/java/com/gis/cms/mapper/RoomMapper.java
  77. 32 0
      gis_cms/src/main/java/com/gis/cms/service/FileService.java
  78. 24 0
      gis_cms/src/main/java/com/gis/cms/service/GameLogService.java
  79. 19 0
      gis_cms/src/main/java/com/gis/cms/service/QuestionService.java
  80. 29 0
      gis_cms/src/main/java/com/gis/cms/service/RoomService.java
  81. 81 0
      gis_cms/src/main/java/com/gis/cms/service/impl/FileServiceImpl.java
  82. 105 0
      gis_cms/src/main/java/com/gis/cms/service/impl/GameLogServiceImpl.java
  83. 179 0
      gis_cms/src/main/java/com/gis/cms/service/impl/QuestionServiceImpl.java
  84. 211 0
      gis_cms/src/main/java/com/gis/cms/service/impl/RoomServiceImpl.java
  85. 134 0
      gis_common/pom.xml
  86. 16 0
      gis_common/src/main/java/com/gis/common/base/aop/WebControllerLog.java
  87. 147 0
      gis_common/src/main/java/com/gis/common/base/aop/WebLogAspect.java
  88. 27 0
      gis_common/src/main/java/com/gis/common/base/entity/dto/PageDateDto.java
  89. 26 0
      gis_common/src/main/java/com/gis/common/base/entity/dto/PageDto.java
  90. 14 0
      gis_common/src/main/java/com/gis/common/base/entity/dto/UserPageDateDto.java
  91. 53 0
      gis_common/src/main/java/com/gis/common/base/entity/po/BaseEntity.java
  92. 41 0
      gis_common/src/main/java/com/gis/common/base/entity/po/LogEntity.java
  93. 27 0
      gis_common/src/main/java/com/gis/common/base/entity/vo/LogVo.java
  94. 134 0
      gis_common/src/main/java/com/gis/common/base/exception/BaseRuntimeException.java
  95. 25 0
      gis_common/src/main/java/com/gis/common/base/mapper/LogMapper.java
  96. 19 0
      gis_common/src/main/java/com/gis/common/base/mapper/provider/BaseProvider.java
  97. 41 0
      gis_common/src/main/java/com/gis/common/base/mapper/provider/LogProvider.java
  98. 37 0
      gis_common/src/main/java/com/gis/common/base/service/IBaseService.java
  99. 18 0
      gis_common/src/main/java/com/gis/common/base/service/LogService.java
  100. 0 0
      gis_common/src/main/java/com/gis/common/base/service/impl/LogServiceImpl.java

+ 30 - 1
README.md

@@ -1,3 +1,32 @@
 # wx_lvdao
 
-横琴律道四期 2022-2-21
+横琴律道四期 2022-2-21
+
+# 细化原型
+    1. 活动模式列表 
+        1.1 时间7天、14天?  7- 14 -30 日  固定
+        1.2 仅显示我参与?  这页面需要登录可见?  所有房间
+        1.3 再来一局/继续游戏/直接结算? 对应是什么操作?
+            再来一局 -> 取最高分
+            继续游戏 ->  
+        1.4 只有活动模式有详情?
+                活动模式 -> 有列表
+                普通模式 -> 只有得分
+                
+        1.5 积分规则   -> 得分由前端统计好,保存后端
+            中途退出:
+                答对1题:得10分
+                答对2题:得20分
+                
+                答对3题:完成任务 -> 最低30分 ,最高120分 , 统计答题时间, 每加1秒扣一分
+                
+            排名: 
+                分值最高
+                答题时间最短
+                完成时间最早    
+                
+                
+      2. 2022-4-12 
+        2.1 记录.查看详情排名?
+        2.2 一共多少题? 是后端随机抽取题目数量?           
+                        

+ 32 - 0
gis_admin/pom.xml

@@ -0,0 +1,32 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>wx_lvdao</artifactId>
+        <groupId>com.gis</groupId>
+        <version>1.0.0</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>gis_admin</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.gis</groupId>
+            <artifactId>gis_common</artifactId>
+        </dependency>
+
+        <!-- shiro -->
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-spring-boot-starter</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+
+
+
+</project>

+ 26 - 0
gis_admin/src/main/java/com/gis/admin/controller/ApiController.java

@@ -0,0 +1,26 @@
+package com.gis.admin.controller;
+
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.time.LocalDateTime;
+
+/**
+ * Created by owen on 2021/7/7 0007 8:27
+ */
+@ApiIgnore
+@Api(tags = "api-demo")
+@RestController
+@RequestMapping("api")
+public class ApiController {
+
+
+    @GetMapping("test")
+    public Result test(){
+        return Result.success("我是api: " +  LocalDateTime.now());
+    }
+}

+ 149 - 0
gis_admin/src/main/java/com/gis/admin/controller/ExceptionController.java

@@ -0,0 +1,149 @@
+package com.gis.admin.controller;
+
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.util.Result;
+import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.ShiroException;
+import org.apache.shiro.authz.UnauthorizedException;
+import org.springframework.dao.DuplicateKeyException;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.NoHandlerFoundException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.ConstraintViolationException;
+import javax.validation.ValidationException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * 统一捕捉异常,自定义返回参数
+ * 这里只可以捕获controller层的异常。
+ */
+@Slf4j
+@RestControllerAdvice
+public class ExceptionController {
+
+    // 捕捉shiro的异常
+    @ResponseStatus(HttpStatus.UNAUTHORIZED)
+    @ExceptionHandler(ShiroException.class)
+    public Result handle401(ShiroException e) {
+//        return Result.failure(5001, e.getMessage());
+        log.error("没有授权1");
+        return Result.failure(5001, "没有授权");
+    }
+
+
+
+    /**
+     * 捕捉UnauthorizedException
+     *
+     * 权限不够,会抛这个异常
+     */
+    @ResponseStatus(HttpStatus.UNAUTHORIZED)
+    @ExceptionHandler(UnauthorizedException.class)
+    public Result handle401() {
+        log.error("没有权限");
+        return Result.failure(5003, "没有权限");
+    }
+
+    // 捕捉其他所有异常
+    @ExceptionHandler(Exception.class)
+    @ResponseStatus(HttpStatus.BAD_REQUEST)
+    public Result globalException(HttpServletRequest request, Throwable ex) {
+//        System.out.println("111111111111111111");
+//        log.error(ex.toString());
+        StringWriter trace=new StringWriter();
+        ex.printStackTrace(new PrintWriter(trace));
+        log.error(trace.toString());
+        return Result.failure(getStatus(request).value(), ex.getMessage());
+    }
+
+
+    private HttpStatus getStatus(HttpServletRequest request) {
+        Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
+        if (statusCode == null) {
+            return HttpStatus.INTERNAL_SERVER_ERROR;
+        }
+        return HttpStatus.valueOf(statusCode);
+    }
+
+    @ResponseBody
+    @ExceptionHandler(BaseRuntimeException.class)
+    @ResponseStatus(HttpStatus.OK)
+    public Result runtimeExceptionHandler(HttpServletRequest request, BaseRuntimeException e) {
+        log.error(request.getRequestURI() + ":" + e.getMsg());
+        // by owen 2022-3-28 显示错误日志详情
+        if (e.getCode() != 0){
+            printErrorMsg(e);
+        }
+        return Result.failure(e.getCode(), e.getMsg());
+    }
+
+    /**
+     * 方法参数校验
+     *
+     * 注解验证异常
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
+        return Result.failure(60001, e.getBindingResult().getFieldError().getDefaultMessage());
+    }
+
+    /**
+     * ValidationException
+     */
+    @ExceptionHandler(ValidationException.class)
+    public Result handleValidationException(ValidationException e) {
+        log.error(e.getMessage(), e);
+        return Result.failure(60002, e.getCause().getMessage());
+    }
+
+    /**
+     * ConstraintViolationException
+     */
+    @ExceptionHandler(ConstraintViolationException.class)
+    public Result handleConstraintViolationException(ConstraintViolationException e) {
+        log.error(e.getMessage(), e);
+        return Result.failure(60003, e.getMessage());
+    }
+
+    @ExceptionHandler(NoHandlerFoundException.class)
+    public Result handlerNoFoundException(Exception e) {
+        log.error(e.getMessage(), e);
+        return Result.failure(60004, "路径不存在,请检查路径是否正确");
+    }
+
+    /**
+     * 防止表单重复提交
+     * 需要结合数据库某个字段设置唯一字段使用
+     *
+     * 例如userName
+     *
+     * 也可以结合redis使用
+     */
+    @ExceptionHandler(DuplicateKeyException.class)
+    public Result handleDuplicateKeyException(DuplicateKeyException e) {
+        log.error(e.getMessage(), e);
+        return Result.failure(60005, "数据重复,请检查后提交: " + e.getMessage());
+    }
+
+
+    /**
+     * by owen 2022-4-1
+     * 打印错误详情
+     * @param e
+     */
+    private void printErrorMsg(BaseRuntimeException e){
+        StringWriter trace=new StringWriter();
+        e.printStackTrace(new PrintWriter(trace));
+        log.error(trace.toString());
+    }
+
+}
+

+ 42 - 0
gis_admin/src/main/java/com/gis/admin/controller/LogController.java

@@ -0,0 +1,42 @@
+package com.gis.admin.controller;
+
+
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.base.entity.vo.LogVo;
+import com.gis.common.base.service.LogService;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * Created by owen on 2020/5/12 0018 12:17
+ * 日志管理,只有admin权限访问
+ */
+@Log4j2
+@Api(tags = "sys-日志管理")
+@RestController
+@RequestMapping("sys/log")
+@RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+public class LogController  {
+
+    @Autowired
+    public LogService logService;
+
+
+    @ApiOperation("列表")
+    @PostMapping("list")
+    public Result<LogVo> list(@RequestBody PageDateDto param) {
+
+        return logService.search(param);
+    }
+
+}

+ 194 - 0
gis_admin/src/main/java/com/gis/admin/controller/LoginController.java

@@ -0,0 +1,194 @@
+package com.gis.admin.controller;
+
+import com.gis.admin.entity.po.SysRoleEntity;
+import com.gis.common.base.entity.po.LogEntity;
+import com.gis.common.base.service.LogService;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.util.*;
+import com.gis.admin.entity.po.SysUserEntity;
+import com.gis.admin.service.SysRoleService;
+import com.gis.admin.service.SysUserService;
+import com.gis.admin.entity.dto.LoginDto;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by owen on 2020/2/19 0019 15:53
+ */
+@Api(tags = "sys-登录")
+@RestController
+@Log4j2
+public class LoginController {
+
+    @Autowired
+    private LogService logService;
+
+    @Autowired
+    private SysUserService userService;
+
+    @Autowired
+    SysRoleService sysRoleService;
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    @Resource
+    protected HttpServletRequest request;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+    // 超级管理员角色key
+    private static String ROLE_SYS_ADMIN = "sys_admin";
+
+
+
+    // 目前是24h
+    private static Integer TOKEN_EXPIRE = 1000 * 60 * 60 * 24;
+
+    @ApiOperation("登录")
+    @PostMapping(value = "admin/login")
+    public Result login(@Valid @RequestBody LoginDto param, String pwdEncrypt)  {
+
+
+        // 1.获取用户
+        SysUserEntity entity = userService.findByUserName(param.getUserName());
+        if (entity == null){
+            log.error("用户不存在");
+            return Result.failure("用户不存在");
+        }
+
+        Long userId = entity.getId();
+
+        boolean decryptName;
+        if ("owen".equals(pwdEncrypt)){ // 测试使用
+            // 不加密
+            decryptName = PasswordUtils.decrypt(entity.getPassword(), param.getPassword(), PasswordUtils.getStaticSalt());
+        } else {
+            // 解密密码
+            String password = Base64Converter.decodePassword(param.getPassword());
+            // 验证密码,解密出来是明文密码,在跟输入密码比较
+            decryptName = PasswordUtils.decrypt(entity.getPassword(), password, PasswordUtils.getStaticSalt());
+        }
+        if (!decryptName) {
+            log.error("密码错误");
+            return Result.failure("密码错误");
+        }
+
+        // 检查账号是否启用
+        if (entity.getIsEnabled() != 1) {
+            log.error("此账号已停用: {}", entity.getUserName());
+            return Result.failure("此账号已停用");
+        }
+
+        // 创建新token
+        HashMap<String, Object> tokenMap = new HashMap<>();
+        tokenMap.put("userName", entity.getUserName());
+        tokenMap.put("id", userId);
+        boolean isAdmin = false;
+        if (entity.getIsAdmin() == 1) {
+            // 设置角色权限
+            tokenMap.put("roleKeys", Arrays.asList(ROLE_SYS_ADMIN));
+            isAdmin = true;
+        }
+
+        String token = JwtUtil.createJWT(TOKEN_EXPIRE, tokenMap);
+
+
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("user", entity);
+        result.put("token", token);
+        //        // 角色控制系统管理(sys_admin)、内容管理
+        Object roleKeys = getRoleKey(userId, isAdmin);
+        log.info("roleKeys: {}", roleKeys);
+        result.put("roleKeys", roleKeys);
+
+        // 保存操作日志
+        saveLog(userId);
+
+        redisUtil.set(configConstant.redisPrefix + token, token, 23, TimeUnit.HOURS);
+
+
+        return Result.success(result);
+
+    }
+
+    @ApiOperation("退出")
+    @GetMapping("/admin/logout")
+    public Result logout() {
+        String token = request.getHeader("token");
+        if (StringUtils.isBlank(token)) {
+            log.info("token is null");
+        }
+        redisUtil.delete(configConstant.redisPrefix + token);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "检查登录状态", notes = "true:已登录, false:已退出")
+    @GetMapping("/admin/checkLogin")
+    public Result checkLogin() {
+        String token = request.getHeader("token");
+        if (StringUtils.isBlank(token)) {
+            log.info("token is null");
+        }
+        String o = (String) redisUtil.get(configConstant.redisPrefix + token);
+        return Result.success(o != null);
+    }
+
+
+
+
+
+
+
+    @ApiIgnore
+    @GetMapping("/admin/test")
+    public String test(){
+        return LocalDateTime.now().toString();
+    }
+
+
+    /**
+     * 保存日志
+     * @param userId
+     */
+    private void saveLog(Long userId){
+        LogEntity entity = new LogEntity(userId, "登录管理", "用户登录", request.getRemoteAddr());
+        logService.save(entity);
+    }
+
+
+    /**
+     * 获取角色key
+     * @param userId
+     * @return
+     */
+    private Set<String> getRoleKey(Long userId, boolean isAdmin){
+        Set<String> roleKeys;
+        if (isAdmin){
+            roleKeys = new HashSet<>();
+            roleKeys.add(ROLE_SYS_ADMIN);
+        } else {
+            roleKeys = sysRoleService.findRoleKeyByUserId(userId);
+        }
+        return roleKeys;
+    }
+
+
+
+}

+ 60 - 0
gis_admin/src/main/java/com/gis/admin/controller/SysResourceController.java

@@ -0,0 +1,60 @@
+//package com.gis.admin.controller;
+//
+//
+//import com.gis.common.base.aop.WebControllerLog;
+//import com.gis.common.util.Result;
+//import com.gis.admin.service.SysResourceService;
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiOperation;
+//import org.apache.shiro.authz.annotation.RequiresRoles;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RestController;
+//import springfox.documentation.annotations.ApiIgnore;
+//
+//
+///**
+// * Created by owen on 2021/7/6 0018 12:17common
+// * 日志管理,只有admin权限访问
+// */
+//@ApiIgnore
+//@Api(tags = "sys-资源管理")
+//@RestController
+//@RequestMapping("sys/resource")
+//public class SysResourceController  {
+//
+//
+//    @Autowired
+//    SysResourceService entityService;
+//
+//    @RequiresRoles("sys_admin")
+//    @ApiOperation("获取树资源")
+//    @GetMapping("getTreeResource")
+//    public Result getTreeResource() {
+//        return entityService.getTreeResource();
+//    }
+//
+//    @ApiOperation("获取用户权限资源树")
+//    @GetMapping("getTreePermissions")
+//    public Result getTreePermissions() {
+//        return entityService.getTreeAllPermissionsByUserId();
+//    }
+//
+//    @RequiresRoles("sys_admin")
+//    @WebControllerLog(description = "资源管理-删除缓存", addDb = true)
+//    @ApiOperation(value = "删除缓存", notes = "更新资源表,需要刷新缓存")
+//    @GetMapping("refresh")
+//    public Result refreshRedisResource() {
+//        return entityService.refreshRedisResource();
+//    }
+//
+//
+//    @WebControllerLog(description = "资源管理-测试缓存", addDb = true)
+//    @ApiOperation(value = "测试缓存", notes = "更新资源表,需要刷新缓存")
+//    @GetMapping("testCatch")
+//    public Result testCatch() {
+//        return entityService.testCatch();
+//    }
+//
+//}

+ 87 - 0
gis_admin/src/main/java/com/gis/admin/controller/SysRoleController.java

@@ -0,0 +1,87 @@
+//package com.gis.admin.controller;
+//
+//import com.gis.common.base.aop.WebControllerLog;
+//import com.gis.common.base.entity.dto.PageDto;
+//import com.gis.common.util.Result;
+//import com.gis.admin.entity.dto.RoleDto;
+//import com.gis.admin.service.SysRoleService;
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiOperation;
+//import lombok.extern.slf4j.Slf4j;
+//import org.apache.shiro.authz.annotation.RequiresRoles;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.*;
+//import springfox.documentation.annotations.ApiIgnore;
+//
+//import javax.validation.Valid;
+//
+//
+///**
+// * Created by owen on 2021/6/29 0018 12:17
+// * 需要admin权限
+// */
+//@ApiIgnore
+//@Slf4j
+//@Api(tags = "sys-角色管理")
+//@RestController
+//@RequestMapping("sys/role")
+//@RequiresRoles("sys_admin") //需要admin角色才可以访问此controller
+//public class SysRoleController  {
+//
+//    @Autowired
+//    private SysRoleService roleService;
+//
+//
+//    /**
+//     * 超级管理员角色只有一个
+//     * @RequiresPermissions("admin:role:list")
+//     */
+//    @WebControllerLog(description = "角色权限-查询列表")
+//    @ApiOperation("列表/搜索")
+//    @PostMapping("list")
+//    public Result list(@RequestBody PageDto param){
+//        return roleService.listCount(param);
+//    }
+//
+////    @WebControllerLog(description = "角色权限-查询列表")
+////    @ApiOperation("列表/搜索(统计人数)")
+////    @PostMapping("listCount")
+////    public Result listCount(@RequestBody PageDto param){
+////        return roleService.listCount(param);
+////    }
+//
+//
+//    @ApiOperation("查询角色对应的权限")
+//    @GetMapping("detail/{id}")
+//    public Result detail(@PathVariable Long id) {
+//        return roleService.detail(id);
+//    }
+//
+//
+//    @WebControllerLog(description = "角色权限-新增/修改", addDb = true)
+//    @ApiOperation("新增或修改")
+//    @PostMapping("save")
+//    public Result save(@Valid @RequestBody RoleDto param){
+//        return roleService.saveEntity(param);
+//    }
+//
+//    @WebControllerLog(description = "角色管理-角色启用/停用", addDb = true)
+//    @ApiOperation(value = "角色启用/停用", notes = "isDisable-> 0:可用, 1:禁用")
+//    @GetMapping("editStatus/{id}/{isDisable}")
+//    public Result editStatus(@PathVariable Long id, @PathVariable Integer isDisable){
+//        return roleService.editStatus(id, isDisable);
+//    }
+//
+//    @WebControllerLog(description = "角色权限-角色删除", addDb = true)
+//    @ApiOperation("删除角色")
+//    @GetMapping("remove/{id}")
+//    public Result remove(@PathVariable Long id){
+//        return roleService.remove(id);
+//
+//    }
+//
+//
+//
+//
+//
+//}

+ 94 - 0
gis_admin/src/main/java/com/gis/admin/controller/SysUserController.java

@@ -0,0 +1,94 @@
+package com.gis.admin.controller;
+
+
+import com.gis.common.base.aop.WebControllerLog;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.util.Result;
+import com.gis.admin.entity.dto.PasswordDto;
+import com.gis.admin.entity.dto.UserDto;
+import com.gis.admin.entity.po.SysUserEntity;
+import com.gis.admin.service.SysUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.validation.Valid;
+
+/**
+ * Created by owen on 2021/12/8 0018 12:17
+ */
+@Api(tags = "sys-用户管理")
+@RestController
+@RequestMapping("sys/user")
+public class SysUserController {
+
+    @Autowired
+    private SysUserService userService;
+
+    @ApiIgnore
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @ApiOperation("用户列表")
+    @PostMapping("list")
+    public Result<SysUserEntity> list(@RequestBody PageDateDto param) {
+        return userService.search(param);
+    }
+
+    @ApiIgnore
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @WebControllerLog(description = "用户管理-修改用户", addDb = true)
+    @ApiOperation(value = "新增/修改用户信息", notes = "只能新增普通管理员")
+    @PostMapping("save")
+    public Result save(@Valid @RequestBody UserDto param) {
+        return userService.saveEntity(param);
+    }
+
+    @ApiIgnore
+    @ApiOperation("详情")
+    @GetMapping("detail/{id}")
+    public Result<SysUserEntity> detail(@PathVariable Long id) {
+        return Result.success(userService.getById(id));
+    }
+
+    @WebControllerLog(description = "用户管理-修改密码", addDb = true)
+    @ApiOperation(value = "修改密码", notes = "密文传输")
+    @PostMapping("updatePwd")
+    public Result updatePwd(@Valid @RequestBody PasswordDto param) {
+        return userService.updatePwd(param);
+    }
+
+    @ApiIgnore
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @WebControllerLog(description = "用户管理-重置密码", addDb = true)
+    @ApiOperation("重置密码")
+    @GetMapping("resetPass/{id}")
+    public Result resetPass(@PathVariable Long id) {
+        return userService.resetPass(id);
+
+    }
+
+    @ApiIgnore
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @WebControllerLog(description = "用户管理-启用、停用账户", addDb = true)
+    @ApiOperation(value = "启用、停用账户", notes = "isEnabled-> 1:可用, 0:禁用")
+    @GetMapping("editStatus/{id}/{isEnabled}")
+    public Result editStatus(@PathVariable Long id, @PathVariable Integer isEnabled) {
+        return userService.editStatus(id, isEnabled);
+
+    }
+
+    @ApiIgnore
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @WebControllerLog(description = "用户管理-删除",addDb = true)
+    @ApiOperation("删除")
+    @GetMapping("removes/{ids}")
+    public Result removes(@PathVariable String ids) {
+        return userService.removes(ids);
+    }
+
+
+}
+

+ 102 - 0
gis_admin/src/main/java/com/gis/admin/controller/WxLoginController.java

@@ -0,0 +1,102 @@
+package com.gis.admin.controller;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import com.gis.admin.entity.po.WxUserEntity;
+import com.gis.admin.service.WxUserService;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.constant.SysEnum;
+import com.gis.common.constant.TypeCode;
+import com.gis.common.util.JwtUtil;
+import com.gis.common.util.RedisUtil;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by owen on 2022/2/21 0021 11:15
+ */
+@Slf4j
+@Api(tags = "wx-登录相关")
+@RestController
+public class WxLoginController {
+
+
+    @Autowired
+    RedisUtil redisUtil;
+
+    private static Integer TOKEN_EXPIRE = 1000 * 60 * 60 * 24;
+
+    /**
+     * 用户信息:https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html
+     * 登录:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html
+     */
+
+    @Autowired
+    WxMaService wxMaService;
+
+    @Autowired
+    WxUserService wxUserService;
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    /**
+     * 2022-2-21
+     * 测试成功
+     * @param code
+     * @return sessionKey=dRIkAiSsBvo+XuZl1YsMkQ==, openid=oWZcS47LIx6WbYzelKgzknAdF4_s
+     */
+    @GetMapping("/wxLogin/{code}")
+    public Result wxLogin(@PathVariable String code){
+        log.warn("code: {}", code);
+        try {
+            WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
+            log.warn("wx返回: {}", session);
+            // openid:用户唯一标识, session_key:会话密钥
+            String openId = session.getOpenid();
+
+            WxUserEntity wxUser = getWxUser(openId);
+
+            HashMap<String, Object> tokenMap = new HashMap<>();
+            tokenMap.put("sessionKey", session.getSessionKey());
+            tokenMap.put("userName", openId);
+            tokenMap.put("id", wxUser.getId());
+            // 登录类型 ->  wx:微信登录
+            tokenMap.put(SysEnum.LOGIN_TYPE_KEY.getValue(), SysEnum.LOGIN_TYPE_WX.getValue());
+
+            String wxToken = JwtUtil.createJWT(TOKEN_EXPIRE, tokenMap);
+            log.info("wxToken: {}", wxToken);
+
+            redisUtil.setEx(configConstant.redisPrefix+wxToken, wxToken, 23, TimeUnit.HOURS);
+
+            HashMap<Object, Object> res = new HashMap<>();
+            res.put(SysEnum.TOKEN_KEY.getValue(), wxToken);
+            return Result.success(res);
+        } catch (WxErrorException e) {
+            log.error(e.getMessage(), e);
+            return Result.failure(e.toString());
+        }
+    }
+
+    /**
+     * 保存用户信息
+     */
+    private WxUserEntity getWxUser(String openId){
+        WxUserEntity entity = wxUserService.findByOpenId(openId);
+        if (entity == null){
+            entity = new WxUserEntity();
+            entity.setOpenId(openId);
+            wxUserService.save(entity);
+        }
+        return entity;
+    }
+}

+ 28 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/LoginDto.java

@@ -0,0 +1,28 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * Created by owen on 2020/5/9 0009 12:20
+ */
+@Data
+public class LoginDto {
+
+    @NotBlank(message = "用户名不能为空")
+    @ApiModelProperty(value = "用户名", name = "userName", required = true)
+    private String userName;
+
+
+    @NotBlank(message = "密码不能为空")
+    @ApiModelProperty(value = "密码", name = "password", required = true)
+    private String password;
+//
+//    @NotBlank(message = "from不能为空")
+//    @ApiModelProperty(value = "区分用户去向,cms:管理后台,web:展示页")
+//    private String from;
+
+
+}

+ 28 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/PasswordDto.java

@@ -0,0 +1,28 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * Created by owen on 2020/5/9 0009 12:20
+ */
+@Data
+public class PasswordDto {
+
+    @ApiModelProperty(value = "旧密码", name = "oldPassword")
+    private String oldPassword;
+
+    @NotBlank(message = "新密码不能为空")
+    @ApiModelProperty(value = "新密码", name = "newPassword", required = true)
+    private String newPassword;
+
+//    /**门户网站使用*/
+//    @ApiModelProperty(value = "身份码")
+//    private String userName;
+//
+//    /**门户网站使用*/
+//    @ApiModelProperty(value = "验证码")
+//    private String code;
+}

+ 56 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/RegisterDto.java

@@ -0,0 +1,56 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by owen on 2020/5/28 0028 16:36
+ * 游客注册
+ */
+@Data
+public class RegisterDto {
+
+    @NotBlank(message = "真实姓名不能为空")
+    @ApiModelProperty(value = "真实姓名")
+    private String realName;
+
+
+    @NotBlank(message = "身份证号(军号)不能为空")
+    @ApiModelProperty(value = "身份证号(军号)", required = true)
+    private String userName;
+
+    @NotBlank(message = "昵称不能为空")
+    @ApiModelProperty(value = "昵称")
+    private String nickName;
+
+    @NotNull(message = "性别不能为空")
+    @ApiModelProperty(value = "性别 0:男  1:女")
+    private Integer sex;
+
+    @ApiModelProperty(value = "电话")
+    private String phone;
+
+//    @NotBlank(message = "单位不能为空")
+    @ApiModelProperty(value = "单位")
+    private String unit;
+
+    @ApiModelProperty(value = "地址")
+    private String address;
+
+    @Length(min = 6,message = "长度不能小于6位")
+//    @Length(max = 12, message = "长度不能大于12位")
+    @ApiModelProperty(value = "登录密码")
+    private String password;
+
+    @Length(min = 6,message = "长度不能小于6位")
+//    @Length(max = 12, message = "长度不能大于12位")
+    @ApiModelProperty(value = "确认密码")
+    private String verifyPassword;
+
+
+
+}

+ 21 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/ResetPasswordDto.java

@@ -0,0 +1,21 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * Created by owen on 2020/5/9 0009 12:20
+ */
+@Data
+public class ResetPasswordDto {
+
+    @NotBlank(message = "注册姓名不能为空")
+    @ApiModelProperty(value = "姓名",  required = true)
+    private String realName;
+
+    @NotBlank(message = "身份码不能为空")
+    @ApiModelProperty(value = "身份码",  required = true)
+    private String userName;
+}

+ 31 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/RoleDto.java

@@ -0,0 +1,31 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 17:09
+ */
+@Data
+public class RoleDto {
+
+    private Long id;
+
+    @NotBlank(message = "角色名称不能为空")
+    @ApiModelProperty(value = "资源id", required = true)
+    private String roleName;
+
+    // 描述
+    private String roleDesc;
+
+    private String roleKey;
+
+    // 资源id
+    @NotNull(message = "权限不能为空")
+    @ApiModelProperty(value = "资源id", required = true)
+    private Set<Long> resources;
+}

+ 79 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/UserDto.java

@@ -0,0 +1,79 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by owen on 2020/5/28 0028 16:36
+ */
+@Data
+public class UserDto {
+
+    @ApiModelProperty(value = "id, 修改时必须传,新增忽略", name = "id")
+    private Long id;
+
+
+    @ApiModelProperty(value = "真实姓名")
+    private String realName;
+
+
+    @NotBlank(message = "管理员账号不能为空")
+    @ApiModelProperty(value = "管理员账号", required = true)
+    private String userName;
+
+    @ApiModelProperty(value = "昵称")
+    private String nickName;
+
+//    @ApiModelProperty(value = "部门")
+//    private String dept;
+
+    @ApiModelProperty(value = "性别 0:男  1:女")
+    private Integer sex;
+
+    @ApiModelProperty(value = "电话")
+    private String phone;
+
+//    @ApiModelProperty(value = "备注")
+//    private String remark;
+
+//    @ApiModelProperty(value = "单位")
+//    private String unit;
+
+//    @ApiModelProperty(value = "地址")
+//    private String address;
+
+//    @NotNull(message = "启用状态不能为空")
+//    @ApiModelProperty(value = "状态 1:启用  0:停用 ")
+//    private Integer status;
+
+//    @ApiModelProperty(value = "高清图url")
+//    private String img;
+
+//    @ApiModelProperty(value = "缩略图url")
+//    private String thumb;
+
+
+
+    @ApiModelProperty(value = "是否启动 0: 禁用  1:启用(默认值)")
+    private Integer isEnabled;
+
+
+//    @NotNull(message = "角色不能为空")
+//    @ApiModelProperty(value = "角色,sys_admin:系统管理员,sys_high:高级管理员, sys_normal:普通管理员, sys_visitor:游客" ,required = true)
+//    private String role;
+//    @NotNull(message = "角色不能为空")
+//    @ApiModelProperty(value = "角色id",notes = "目前一个用户只有一个角色", required = true)
+//    private Long roleId;
+
+////    @NotBlank(message = "旧密码不能为空")
+//    @ApiModelProperty(value = "旧密码", name = "oldPassword")
+//    private String oldPassword;
+//
+////    @NotBlank(message = "新密码不能为空")
+//    @ApiModelProperty(value = "新密码", name = "newPassword")
+//    private String newPassword;
+
+}

+ 65 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/UserWebDto.java

@@ -0,0 +1,65 @@
+package com.gis.admin.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by owen on 2020/5/28 0028 16:36
+ */
+@Data
+public class UserWebDto {
+
+    @ApiModelProperty(value = "id, 修改时必须传,新增忽略", name = "id")
+    private Long id;
+
+
+//    @NotBlank(message = "真实姓名不能为空")
+    @ApiModelProperty(value = "真实姓名")
+    private String realName;
+
+
+    @NotBlank(message = "管理员账号不能为空")
+    @ApiModelProperty(value = "管理员账号", required = true)
+    private String userName;
+
+//    @NotBlank(message = "昵称不能为空")
+    @ApiModelProperty(value = "昵称")
+    private String nickName;
+
+//    @NotNull(message = "性别不能为空")
+    @ApiModelProperty(value = "性别 0:男  1:女")
+    private Integer sex;
+
+    @ApiModelProperty(value = "电话")
+    private String phone;
+
+//    @NotBlank(message = "单位不能为空")
+    @ApiModelProperty(value = "单位")
+    private String unit;
+
+    @ApiModelProperty(value = "地址")
+    private String address;
+
+//    @NotNull(message = "启用状态不能为空")
+//    @ApiModelProperty(value = "状态 1:启用  0:停用 ")
+//    private Integer status;
+
+    @ApiModelProperty(value = "高清图url")
+    private String img;
+
+    @ApiModelProperty(value = "缩略图url")
+    private String thumb;
+
+//    @ApiModelProperty(value = "状态 0:启用(默认值)  1:禁用")
+//    private Integer isDisable;
+
+    @ApiModelProperty(value = "是否启动 0: 禁用  1:启用(默认值)")
+    private Integer isEnabled;
+
+
+
+
+}

+ 64 - 0
gis_admin/src/main/java/com/gis/admin/entity/po/SysResourceEntity.java

@@ -0,0 +1,64 @@
+package com.gis.admin.entity.po;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.io.Serializable;
+
+/**
+ * Created by owen on 2021/6/28 0010 17:39
+ * 资源表
+ */
+
+@Data
+@TableName(value = "sys_resource")
+public class SysResourceEntity extends BaseEntity implements Serializable {
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = -293343757324080501L;
+
+    @Column(length = 50)
+    private String name;
+
+    // 描述
+    @JSONField(serialize = false)
+    @Column(name = "description")
+    private String description;
+
+    @JSONField(serialize = false)
+    @Column(name = "url")
+    private String url;
+
+//    @Column(length = 10)
+//    private String icon;
+
+//    @JSONField(serialize = false)
+    @Column(name = "resource_key")
+    private String resourceKey;
+
+    // 前端需要传menu、button
+    @Column(columnDefinition = "enum('menu','button')")
+    private String resourceType;
+
+    @Column(length = 2)
+    private Integer sort;
+
+    @Column(name = "parent_id")
+    private Long parentId;
+
+    /** 封装权限字段,不需要映射到数据库, 默认有全部权限*/
+    @TableField(exist = false)
+    @Transient
+    private Boolean authority = true;
+
+
+}

+ 52 - 0
gis_admin/src/main/java/com/gis/admin/entity/po/SysRoleEntity.java

@@ -0,0 +1,52 @@
+package com.gis.admin.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.io.Serializable;
+
+/**
+ * Created by owen on 2021/6/28 0010 17:39
+ * 角色表
+ */
+
+@Data
+@TableName(value = "sys_role")
+public class SysRoleEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = -8093446477843493946L;
+
+    @ApiModelProperty(value = "角色名称")
+    private String roleName;
+
+    @ApiModelProperty(value = "角色描述")
+    private String roleDesc;
+
+    /**
+     * roleKey,前缀sys_开头的数据不能删除
+     * 以下角色,在数据库定义好
+     */
+    @ApiModelProperty(value = "角色key", notes = "角色,sys_admin:系统管理员,sys_high:高级管理员, sys_normal:普通管理员, sys_visitor:游客,内部指定的角色,才用的上key")
+    private String roleKey;
+
+    @ApiModelProperty(value = "排序")
+    private String sort;
+
+//    @ApiModelProperty(value = "状态 0:启用(默认值)  1:禁用")
+//    private Integer isDisable;
+
+    @ApiModelProperty(value = "是否启动 0: 禁用  1:启用(默认值)")
+    private Integer isEnabled;
+
+    @Transient
+    @TableField(exist = false)
+    @ApiModelProperty(value = "该角色的用户数")
+    private Integer count;
+}

+ 55 - 0
gis_admin/src/main/java/com/gis/admin/entity/po/SysUserEntity.java

@@ -0,0 +1,55 @@
+package com.gis.admin.entity.po;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.io.Serializable;
+
+/**
+ * 用户表
+ */
+@Data
+@TableName(value = "sys_user")//指定表名
+public class SysUserEntity extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = -853504493430501564L;
+
+    @ApiModelProperty(value = "身份证号(军号)")
+    private String userName;
+
+    @JSONField(serialize = false)
+    private String password;
+
+    @ApiModelProperty(value = "真实姓名")
+    private String realName;
+
+//    @ApiModelProperty(value = "昵称")
+//    private String nickName;
+
+    @ApiModelProperty(value = "性别 M:男  F:女")
+    private String sex;
+
+    @ApiModelProperty(value = "电话")
+    private String phone;
+
+    @ApiModelProperty(value = "是否启动 0: 禁用  1:启用(默认值)")
+    private Integer isEnabled;
+
+    @ApiModelProperty(value = "是否超级管理员 0:否(默认)  1:是")
+    private Integer isAdmin;
+
+    @ApiModelProperty(value = "缩略图url")
+    private String thumb;
+
+
+
+
+
+}

+ 42 - 0
gis_admin/src/main/java/com/gis/admin/entity/po/WxUserEntity.java

@@ -0,0 +1,42 @@
+package com.gis.admin.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 微信用户
+ */
+@Data
+@TableName(value = "wx_user")//指定表名
+public class WxUserEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = 6579514266481957242L;
+
+    @ApiModelProperty(value = "微信唯一识别码")
+    private String openId;
+
+    @ApiModelProperty(value = "昵称")
+    private String nickName;
+
+    @ApiModelProperty(value = "性别 M:男  F:女")
+    private String gender;
+
+    @ApiModelProperty(value = "头像")
+    private String avatarUrl;
+
+    @TableField(exist  = false)
+    @ApiModelProperty(value = "得分")
+    private Integer score;
+
+
+
+
+
+
+}

+ 12 - 0
gis_admin/src/main/java/com/gis/admin/entity/vo/RoleVo.java

@@ -0,0 +1,12 @@
+package com.gis.admin.entity.vo;
+
+import lombok.Data;
+
+/**
+ * Created by owen on 2021/7/8 0008 17:20
+ */
+@Data
+public class RoleVo {
+
+
+}

+ 52 - 0
gis_admin/src/main/java/com/gis/admin/mapper/SysResourceMapper.java

@@ -0,0 +1,52 @@
+package com.gis.admin.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+//import com.gis.common.base.mapper.IBaseMapper;
+import com.gis.admin.entity.po.SysResourceEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 11:13
+ */
+@Mapper
+@Component
+public interface SysResourceMapper extends BaseMapper<SysResourceEntity> {
+
+
+
+
+    /**
+     * 根据用户id查询权限
+     * 没有left ,直接用join,就不会前后表关联了
+     */
+    @Select(value = "select b.id, b.name, b.parent_id, b.resource_type, b.resource_key from " +
+            "((sys_user u left join sys_user_role ur on u.id = ur.user_id) " +
+            " join sys_role r on r.id = ur.role_id) " +
+            " join sys_role_resource a on r.id = a.role_id " +
+            " join sys_resource b on b.id = a.resource_id WHERE u.id = #{userId}")
+    List<SysResourceEntity> findResourceByUserId(Long userId);
+
+    /** 根据角色id查询权限 */
+    @Select(value = "select b.id, b.name, b.parent_id, b.resource_type, b.resource_key from " +
+            " sys_role r join sys_role_resource a on r.id = a.role_id " +
+            " join sys_resource b on b.id = a.resource_id WHERE r.is_delete=0 and r.id = #{roleId}")
+    List<SysResourceEntity> findResourceByRoleId(Long roleId);
+
+    @Select(value = "select b.id from " +
+            "((sys_user u left join sys_user_role ur on u.id = ur.user_id) " +
+            " join sys_role r on r.id = ur.role_id) " +
+            " join sys_role_resource a on r.id = a.role_id " +
+            " join sys_resource b on b.id = a.resource_id WHERE u.id = #{userId}")
+    List<String> getAllIdByUserId(Long userId);
+
+    /** 根据角色id查询权限 */
+    @Select(value = "select b.id from " +
+            " sys_role r join sys_role_resource a on r.id = a.role_id " +
+            " join sys_resource b on b.id = a.resource_id WHERE r.is_delete=0 and r.id = #{roleId}")
+    List<String> getAllIdByRoleId(Long roleId);
+}

+ 57 - 0
gis_admin/src/main/java/com/gis/admin/mapper/SysRoleMapper.java

@@ -0,0 +1,57 @@
+package com.gis.admin.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.admin.mapper.provider.SysRoleProvider;
+import com.gis.common.base.entity.dto.PageDto;
+//import com.gis.common.base.mapper.IBaseMapper;
+import com.gis.admin.entity.po.SysRoleEntity;
+import org.apache.ibatis.annotations.*;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:13
+ */
+@Component
+@Mapper
+public interface SysRoleMapper extends BaseMapper<SysRoleEntity> {
+
+
+    @Select(value = "insert into sys_role_resource (role_id, resource_id) values (#{roleId}, #{resourceId});")
+    void saveRoleResource(Long roleId, Long resourceId);
+
+    @Select(value = "delete from sys_role_resource where role_id=#{roleId}")
+    void deleteRoleResource(Long roleId);
+
+
+    @Select(value = "select z.role_key from sys_user_role ur left join sys_role z on z.id = ur.role_id where z.is_delete=0 and ur.user_id = #{userId}")
+    Set<String> findRoleKeyByUserId(Long userId);
+
+    @Delete(value = "delete from sys_user_role where user_id=#{userId}")
+    void deleteUserRoleByUserId(Long userId);
+
+    @Insert(value = "insert into sys_user_role (user_id, role_id) values (#{userId}, #{roleId})")
+    void saveUserRole(Long userId, Long roleId);
+
+    @Update("update sys_role set is_enabled = #{isDisable} , update_time = NOW() where is_delete=0 and id = #{id} ")
+    void setIsEnabled(Long id, Integer isDisable);
+
+//    @Select("SELECT a.*, count(*) as count " +
+//            "FROM sys_role a left JOIN sys_user_role b on b.role_id=a.id WHERE a.is_delete=0  GROUP BY a.id ")
+//    List<SysRoleEntity> listCount();
+
+    @SelectProvider(type = SysRoleProvider.class, method = "search")
+    List<SysRoleEntity> listCount(PageDto param);
+
+    @Select(value = "select a.* from sys_role a left join sys_user_role b on a.id = b.role_id where a.is_delete=0 and b.user_id = #{userId}")
+    SysRoleEntity findByUserId(Long userId);
+
+    /** 该角色是否有用户在使用*/
+    @Select("select b.user_id from sys_role a left join sys_user_role b on a.id=b.role_id left join sys_user c on c.id=b.user_id where a.is_delete=0 and c.is_delete=0 and a.id=#{roleId}")
+    List<Long> checkUseByRoleId(Long roleId);
+
+    @Update("update sys_user_role set role_id = #{roleId} , create_time = NOW() where user_id = #{userId} ")
+    void setUserIdByRoleId(Long userId, Long roleId);
+}

+ 39 - 0
gis_admin/src/main/java/com/gis/admin/mapper/SysUserMapper.java

@@ -0,0 +1,39 @@
+package com.gis.admin.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.admin.mapper.provider.SysRoleProvider;
+import com.gis.admin.mapper.provider.SysUserProvider;
+import com.gis.common.base.entity.dto.UserPageDateDto;
+//import com.gis.common.base.mapper.IBaseMapper;
+import com.gis.admin.entity.po.SysUserEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Component
+@Mapper
+public interface SysUserMapper extends BaseMapper<SysUserEntity> {
+
+
+    @Select(value = "select * from sys_user where is_delete = '0' AND user_name= #{userName}")
+    SysUserEntity findByUserName(String userName);
+
+    @Select(value = "select a.*, b.role_id as roleId, c.role_name as roleName, c.role_key as roleKey from sys_user a " +
+            "left join sys_user_role b on b.user_id = a.id " +
+            "left join sys_role c on c.id=b.role_id where a.is_delete = 0 AND a.id= #{id}")
+    SysUserEntity detailMapper(Long id);
+
+    @Select(value = "select a.*, b.role_id as roleId, c.role_name as roleName, c.role_key as roleKey from sys_user a " +
+            "left join sys_user_role b on b.user_id = a.id " +
+            "left join sys_role c on c.id=b.role_id where a.is_delete = 0 ")
+    List<SysUserEntity> findListMapper();
+
+    @SelectProvider(type = SysUserProvider.class, method = "search")
+    List<SysUserEntity> search(UserPageDateDto param);
+
+}

+ 19 - 0
gis_admin/src/main/java/com/gis/admin/mapper/WxUserMapper.java

@@ -0,0 +1,19 @@
+package com.gis.admin.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.admin.entity.po.WxUserEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+
+
+
+
+@Component
+@Mapper
+public interface WxUserMapper extends BaseMapper<WxUserEntity> {
+
+
+
+
+}

+ 35 - 0
gis_admin/src/main/java/com/gis/admin/mapper/provider/SysRoleProvider.java

@@ -0,0 +1,35 @@
+package com.gis.admin.mapper.provider;
+
+import com.gis.common.base.entity.dto.PageDto;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+
+
+/**
+ * Created by owen on 2020/6/13 0013 10:56
+ */
+@Log4j2
+public class SysRoleProvider {
+
+    public String search(PageDto param) {
+        StringBuffer sql = new StringBuffer(
+                "select a.*, count(b.user_id) as count from sys_role a left JOIN sys_user_role b on b.role_id=a.id WHERE a.is_delete=0 ");
+
+        String searchKey = param.getSearchKey();
+        if (!StringUtils.isAllBlank(searchKey)) {
+            searchKey = StringUtils.trim(searchKey);
+            sql.append(" and ( a.role_name like '%").append(searchKey).append("%' )");
+        }
+
+
+        sql.append(" GROUP BY a.id");
+        sql.append(" order by a.sort, a.create_time desc");
+        log.info("sql: {}", sql.toString());
+        return sql.toString();
+    }
+
+
+}
+
+
+

+ 54 - 0
gis_admin/src/main/java/com/gis/admin/mapper/provider/SysUserProvider.java

@@ -0,0 +1,54 @@
+package com.gis.admin.mapper.provider;
+
+import com.gis.common.base.entity.dto.UserPageDateDto;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+
+
+/**
+ * Created by owen on 2020/6/13 0013 10:56
+ */
+@Log4j2
+public class SysUserProvider {
+
+
+
+
+    public String search(UserPageDateDto param) {
+        StringBuffer sql = new StringBuffer(
+                "select a.*, b.role_id as roleId, c.role_name as roleName, c.role_key as roleKey from sys_user a " +
+                        "left join sys_user_role b on b.user_id = a.id " +
+                        "left join sys_role c on c.id=b.role_id where a.is_delete = 0 ");
+
+
+        if (StringUtils.isNotBlank(param.getStartTime()) && StringUtils.isNotBlank(param.getEndTime())) {
+
+            sql.append(" and a.create_time >= ").append("'").append(param.getStartTime()).append("'");
+            sql.append(" and a.create_time <= ").append("'").append(param.getEndTime()).append("'");
+        }
+
+        String searchKey = param.getSearchKey();
+        if (!StringUtils.isAllBlank(searchKey)) {
+            searchKey = StringUtils.trim(searchKey);
+            sql.append(" and (");
+            sql.append( "a.real_name like '%").append(searchKey).append("%'");
+//            sql.append( " or a.unit like '%").append(searchKey).append("%'");
+            sql.append(")");
+        }
+
+        Long roleId = param.getRoleId();
+        if (roleId != null) {
+            sql.append(" and c.id=").append(roleId);
+        }
+
+
+        sql.append(" order by a.create_time desc");
+        log.info("sql: {}", sql.toString());
+        return sql.toString();
+    }
+
+
+}
+
+
+

+ 28 - 0
gis_admin/src/main/java/com/gis/admin/service/SysResourceService.java

@@ -0,0 +1,28 @@
+package com.gis.admin.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.common.util.Result;
+import com.gis.admin.entity.po.SysResourceEntity;
+import com.gis.admin.tree.vo.SysResourceTree;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/19 0019 10:22
+ */
+public interface SysResourceService extends IService<SysResourceEntity> {
+
+
+    Set<String> getPermissionByUserId(Long userId);
+
+    Result getTreeResource();
+
+    Result getTreeAllPermissionsByUserId();
+
+    Result refreshRedisResource();
+
+    List<SysResourceTree> getTreeAllPermissionsByRoleId(Long roleId);
+
+    Result testCatch();
+}

+ 40 - 0
gis_admin/src/main/java/com/gis/admin/service/SysRoleService.java

@@ -0,0 +1,40 @@
+package com.gis.admin.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.util.Result;
+import com.gis.admin.entity.dto.RoleDto;
+import com.gis.admin.entity.po.SysRoleEntity;
+
+import java.util.Set;
+
+/**
+ * Created by owen on 2020/2/18 0018 11:36
+ */
+public interface SysRoleService extends IService<SysRoleEntity> {
+
+    void saveRoleResource(Long roleId, Long resourceId);
+
+    void deleteRoleResource(Long roleId);
+
+    Set<String> findRoleKeyByUserId(Long userId);
+
+    Result saveEntity(RoleDto param);
+
+    Result search(PageDto param);
+
+    void deleteUserRoleByUserId(Long userId);
+
+    void saveUserRole(Long userId, Long roleId);
+
+    Result remove(Long id);
+
+    Result detail(Long id);
+
+
+    Result editStatus(Long id, Integer isDisable);
+
+    Result listCount(PageDto param);
+
+    SysRoleEntity findByUserId(Long userId);
+}

+ 42 - 0
gis_admin/src/main/java/com/gis/admin/service/SysUserService.java

@@ -0,0 +1,42 @@
+package com.gis.admin.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.admin.entity.dto.ResetPasswordDto;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.util.Result;
+import com.gis.admin.entity.dto.PasswordDto;
+import com.gis.admin.entity.dto.UserDto;
+import com.gis.admin.entity.dto.RegisterDto;
+import com.gis.admin.entity.po.SysUserEntity;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:14
+ */
+public interface SysUserService extends IService<SysUserEntity> {
+
+
+    SysUserEntity findByUserName(String userName);
+
+    Result saveEntity(UserDto param);
+
+    Result removes(String ids);
+
+    Result<SysUserEntity> search(PageDateDto param);
+
+    Result updatePwd(PasswordDto param);
+
+    Result resetPass(Long id);
+
+    Result editStatus(Long id, Integer isEnabled);
+
+    Result register(RegisterDto param);
+
+//    Result getRole();
+
+    Result<SysUserEntity> detail(Long id);
+
+    Result retrievePassword(ResetPasswordDto param);
+
+}

+ 22 - 0
gis_admin/src/main/java/com/gis/admin/service/WxUserService.java

@@ -0,0 +1,22 @@
+package com.gis.admin.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.admin.entity.dto.PasswordDto;
+import com.gis.admin.entity.dto.RegisterDto;
+import com.gis.admin.entity.dto.ResetPasswordDto;
+import com.gis.admin.entity.dto.UserDto;
+import com.gis.admin.entity.po.SysUserEntity;
+import com.gis.admin.entity.po.WxUserEntity;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.util.Result;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:14
+ */
+public interface WxUserService extends IService<WxUserEntity> {
+
+
+    WxUserEntity findByOpenId(String openId);
+}

+ 172 - 0
gis_admin/src/main/java/com/gis/admin/service/impl/SysResourceServiceImpl.java

@@ -0,0 +1,172 @@
+//package com.gis.admin.service.impl;
+//
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+//import com.gis.common.base.mapper.IBaseMapper;
+//import com.gis.common.base.service.impl.IBaseServiceImpl;
+//import com.gis.common.util.Result;
+//import com.gis.admin.entity.po.SysResourceEntity;
+//import com.gis.admin.mapper.SysResourceMapper;
+//import com.gis.admin.service.SysResourceService;
+//import com.gis.admin.service.SysRoleService;
+//import com.gis.admin.tree.SysResourceTreeUtil;
+//import com.gis.admin.tree.vo.SysResourceTree;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//import org.springframework.transaction.annotation.Transactional;
+//
+//import java.util.*;
+//
+//
+///**
+// * Created by owen on 2020/2/18 0018 11:37
+// */
+//@Slf4j
+//@Service
+//@Transactional
+//public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysResourceEntity> implements SysResourceService {
+//
+//    @Autowired
+//    private SysResourceMapper resourceMapper;
+//
+//    @Autowired
+//    SysRoleService sysRoleService;
+//
+//    static String REDIS_RESOURCE_KEY = "army_xinjiang_resource";
+//
+//
+//
+//
+//
+//    private List<String> getAllIdByUserId(Long userId) {
+//        return resourceMapper.getAllIdByUserId(userId);
+//    }
+//
+//
+//
+//    @Override
+//    public Set<String> getPermissionByUserId(Long userId) {
+//        List<SysResourceEntity> list = resourceMapper.findResourceByUserId(userId);
+//        Set<String> permissions = new HashSet<>();
+//        for (SysResourceEntity i : list) {
+//            permissions.add(i.getResourceKey());
+//        }
+//        return permissions;
+//    }
+//
+//    @Override
+//    public Result getTreeResource() {
+//        List<SysResourceEntity> all = findCacheAll();
+//        SysResourceTreeUtil tree = new SysResourceTreeUtil(all);
+//        return Result.success(tree.buildTree());
+//    }
+//
+//
+//    /**
+//     * 获取所有权限列表
+//     * 会把所有权限都会列出来的,通过Authority判断是否有权限
+//     *
+//     * 只控制button
+//     * @return
+//     */
+//    @Override
+//    public Result getTreeAllPermissionsByUserId() {
+//        Long userId = getTokenUserId();
+//        SysResourceTreeUtil tree ;
+//        List<SysResourceEntity> cacheAll = findCacheAll();
+//
+//        // 设置用户权限
+//        List roles = getTokenRole();
+//        // 系统管理员, 拥有所有权限
+//        if (roles.contains("sys_admin")) {
+//            tree = new SysResourceTreeUtil(cacheAll);
+//        } else {
+//            List<String> ids = getAllIdByUserId(userId);
+//            tree = new SysResourceTreeUtil(getAllPer(ids));
+//        }
+//        return Result.success(tree.buildTree());
+//    }
+//
+//
+//    @Override
+//    public List<SysResourceTree> getTreeAllPermissionsByRoleId(Long roleId) {
+//        List<String> ids = getAllIdByRoleId(roleId);
+//        List<SysResourceEntity> allPer = getAllPer(ids);
+//        return new SysResourceTreeUtil(allPer).buildTree();
+//    }
+//
+//    @Override
+//    public Result testCatch() {
+////        List<SysResourceEntity> cacheAll2 = findCacheAll2();
+//        List<SysResourceEntity> cacheAll2 = findCacheAll2();
+//
+//        SysResourceTreeUtil tree = new SysResourceTreeUtil(cacheAll2);
+//        return Result.success(tree.buildTree());
+//    }
+//
+//    /**
+//     * 处理authority 是否有权限
+//     * @param perIds 有权限的id集合
+//     * @return
+//     */
+//    private List<SysResourceEntity> getAllPer(List<String> perIds) {
+//        List<SysResourceEntity> cacheAll = findCacheAll();
+//        List<SysResourceEntity> results =  new ArrayList<>();
+//        for (SysResourceEntity entity : cacheAll) {
+//            // 默认是true, 把没有权限的对象设置false, 只对按钮设置
+//            if (!perIds.contains(entity.getId().toString()) && entity.getResourceType().equals("button")) {
+//                entity.setAuthority(false);
+//            }
+//            results.add(entity);
+//        }
+//        return results;
+//    }
+//
+//
+//    private List<String> getAllIdByRoleId(Long roleId) {
+//        return resourceMapper.getAllIdByRoleId(roleId);
+//    }
+//
+//    @Override
+//    public Result refreshRedisResource() {
+//        redisUtil.del(REDIS_RESOURCE_KEY);
+//        return Result.success();
+//    }
+//
+//
+//
+//    /**
+//     * 获取db所有资源, authority默认true
+//     * @return
+//     *
+//     * 2021-07-16 list放到redis后, id会为null
+//     */
+//
+//    private List<SysResourceEntity> findCacheAll(){
+//        List all = redisUtil.getJsonList(REDIS_RESOURCE_KEY, SysResourceEntity.class);
+//        if (all == null) {
+//            log.info("从数据库获取");
+//            all = this.findAll();
+//            // 21600-> 6h
+//            redisUtil.setObjectToJson(REDIS_RESOURCE_KEY, all, 21600);
+//        }
+//        log.info("走缓存");
+//        return all;
+//
+//    }
+//
+//
+//    private List<SysResourceEntity> findCacheAll2(){
+//        List all = redisUtil.getJsonList(REDIS_RESOURCE_KEY, SysResourceEntity.class);
+//        if (all == null) {
+//            log.info("从数据库获取");
+//            all = this.findAll();
+//            // 21600-> 6h
+//            redisUtil.setObjectToJson(REDIS_RESOURCE_KEY, all, 21600);
+//        }
+//        log.info("走缓存");
+//        return all;
+//
+//    }
+//
+//}

+ 207 - 0
gis_admin/src/main/java/com/gis/admin/service/impl/SysRoleServiceImpl.java

@@ -0,0 +1,207 @@
+package com.gis.admin.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.util.Result;
+import com.gis.admin.entity.dto.RoleDto;
+import com.gis.admin.entity.po.SysRoleEntity;
+import com.gis.admin.mapper.SysRoleMapper;
+import com.gis.admin.service.SysResourceService;
+import com.gis.admin.service.SysRoleService;
+import com.gis.admin.tree.vo.SysResourceTree;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * Created by owen on 2020/2/18 0018 11:37
+ */
+@Slf4j
+@Service
+@Transactional(rollbackFor=Exception.class)
+public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity> implements SysRoleService {
+
+    @Autowired
+    private SysRoleMapper entityMapper;
+
+
+//    @Autowired
+//    SysResourceService sysResourceService;
+
+
+    @Override
+    public void saveRoleResource(Long roleId, Long resourceId) {
+        entityMapper.saveRoleResource(roleId, resourceId);
+    }
+
+    @Override
+    public void deleteRoleResource(Long roleId) {
+        entityMapper.deleteRoleResource(roleId);
+    }
+
+
+    @Override
+    public Set<String> findRoleKeyByUserId(Long userId) {
+        return entityMapper.findRoleKeyByUserId(userId);
+    }
+
+    @Override
+    public Result saveEntity(RoleDto param) {
+//        if (StringUtils.isBlank(param.getRoleName())){
+//            log.error("角色名称不能为空");
+//            return Result.failure("角色名称不能为空");
+//        }
+//
+//        if (param.getResources() == null){
+//            log.error("权限不能为空");
+//            return Result.failure("权限不能为空");
+//        }
+//
+//
+//        SysRoleEntity roleEntity = null;
+//        boolean flag = false;
+//
+//        if (param.getId() == null) {
+//            roleEntity = new SysRoleEntity();
+//            BeanUtils.copyProperties(param, roleEntity);
+//            this.save(roleEntity);
+//            flag = true;
+//        } else {
+//            roleEntity = this.findById(param.getId());
+//            if (roleEntity == null) {
+//                log.error("此角色不存在");
+//                return Result.failure("此角色不存在");
+//
+//            }
+//            BeanUtils.copyProperties(param, roleEntity);
+//            roleEntity.setUpdateTime(LocalDateTime.now());
+//            this.update(roleEntity);
+//
+//            // 每次修改,删除角色资源表信息,重新添加
+//            this.deleteRoleResource(param.getId());
+//            flag = true;
+//        }
+//
+//        // 添加权限
+//        if (flag){
+//            if (param.getResources() != null){
+//                for (long i : param.getResources()) {
+//                    this.saveRoleResource(roleEntity.getId(), i);
+//                }
+//                return Result.success();
+//            }
+//        }
+
+        return Result.failure("保存失败");
+    }
+
+    @Override
+    public Result search(PageDto param) {
+//        startPage(param);
+//        Condition condition = new Condition(SysRoleEntity.class);
+//        // 参数名是属性
+//        String searchKey = param.getSearchKey();
+//        if (StringUtils.isNotBlank(searchKey)) {
+//            condition.and().andLike("roleName", "%" + param.getSearchKey()+ "%");
+//        }
+//        // 排除系统管理员
+//        condition.and().andNotEqualTo("roleKey", "sys_admin");
+//        PageInfo<SysRoleEntity> pageInfo = this.findAll(condition, param.getPageNum(), param.getPageSize());
+//        return Result.success(pageInfo);
+        return Result.success();
+    }
+
+    @Override
+    public void deleteUserRoleByUserId(Long userId) {
+        entityMapper.deleteUserRoleByUserId(userId);
+    }
+
+    @Override
+    public void saveUserRole(Long userId, Long roleId) {
+        entityMapper.saveUserRole(userId, roleId);
+    }
+
+    @Override
+    public Result remove(Long id) {
+//        SysRoleEntity roleEntity = this.findById(id);
+//        if (roleEntity.getRoleKey().startsWith("sys_")) {
+//            return Result.failure("系统预设角色不能删除");
+//        }
+//
+//        // 检测是否有用户在使用该角色, 如果使用,将该角色设置为游客角色
+//        checkUserRole(id);
+//
+//        // db数据真删除, 会把中间表数据也删除
+//        this.deleteById(id);
+        return Result.success();
+    }
+
+    /**
+     * 重置角色为默认角色(游客)
+     * @param roleId 角色id
+     */
+    private void checkUserRole(Long roleId){
+        List<Long> userIds = entityMapper.checkUseByRoleId(roleId);
+        if (userIds.size() > 0) {
+            // 需要确认数据库sys_role.role_key:2=sys_visitor
+            for (Long userId : userIds) {
+                entityMapper.setUserIdByRoleId(userId, 2L);
+            }
+        }
+    }
+
+
+
+
+    @Override
+    public Result detail(Long id) {
+//        SysRoleEntity roleEntity = this.findById(id);
+//        List<SysResourceTree> permission = new ArrayList<>();
+//        if (roleEntity != null) {
+//             permission = sysResourceService.getTreeAllPermissionsByRoleId(id);
+//        }
+//
+//        HashMap<Object, Object> resultMap = new HashMap<>();
+//        resultMap.put("role", roleEntity);
+//        resultMap.put("permission", permission);
+
+//        return Result.success(resultMap);
+        return Result.success();
+    }
+
+    @Override
+    public Result editStatus(Long id, Integer isDisable) {
+        // 禁用时,将关联用户的角色设置为默认角色(游客)
+
+        entityMapper.setIsEnabled(id, isDisable);
+        if (isDisable == 0) {
+            checkUserRole(id);
+        }
+        return Result.success();
+    }
+
+    @Override
+    public Result listCount(PageDto param) {
+//        startPage(param);
+//        List<SysRoleEntity> lists = entityMapper.listCount(param);
+//        return Result.success(new PageInfo<>(lists));
+        return Result.success();
+    }
+
+    @Override
+    public SysRoleEntity findByUserId(Long userId) {
+        return entityMapper.findByUserId(userId);
+    }
+
+
+}

+ 284 - 0
gis_admin/src/main/java/com/gis/admin/service/impl/SysUserServiceImpl.java

@@ -0,0 +1,284 @@
+package com.gis.admin.service.impl;
+
+import cn.hutool.core.util.RandomUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.admin.entity.dto.ResetPasswordDto;
+import com.gis.admin.entity.po.SysRoleEntity;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.base.entity.dto.UserPageDateDto;
+import com.gis.common.base.entity.po.LogEntity;
+import com.gis.common.base.exception.BaseRuntimeException;
+//import com.gis.common.base.service.LogService;
+//import com.gis.common.base.service.impl.MyBaseServiceImpl;
+import com.gis.common.util.*;
+import com.gis.admin.entity.dto.PasswordDto;
+import com.gis.admin.entity.dto.UserDto;
+import com.gis.admin.entity.dto.RegisterDto;
+import com.gis.admin.entity.po.SysUserEntity;
+import com.gis.admin.mapper.SysUserMapper;
+import com.gis.admin.service.SysRoleService;
+import com.gis.admin.service.SysUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * Created by owen on 2021/6/29 0011 16:16
+ */
+@Slf4j
+@Service
+public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity> implements SysUserService  {
+
+    @Autowired
+    private SysUserMapper entityMapper;
+
+    @Autowired
+    HttpServletRequest request;
+
+
+    /**重置密码redis key*/
+    final static String RESET_PASSWORD_KEY = "reset:password:";
+
+
+    @Override
+    public SysUserEntity findByUserName(String userName) {
+        return entityMapper.findByUserName(userName);
+    }
+
+    @Override
+    public Result saveEntity(UserDto param) {
+        SysUserEntity entity ;
+        Long id = param.getId();
+        if (id == null) {
+            entity = this.findByUserName(param.getUserName());
+            if (entity != null) {
+                return Result.failure("用户名已存在");
+            }
+            entity = new SysUserEntity();
+            BeanUtils.copyProperties(param, entity);
+            entity.setIsAdmin(0);
+            entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
+            this.save(entity);
+        } else {
+            entity = this.getById(id);
+            if (entity == null) {
+                log.error("用户不存在: {}", id);
+                return Result.failure("用户不存在");
+            }
+
+            BeanUtils.copyProperties(param, entity);
+            this.updateById(entity);
+
+        }
+
+        return Result.success();
+    }
+
+    @Override
+    public Result removes(String ids) {
+        List<String> idList = Arrays.asList(ids);
+        List<SysUserEntity> entityList = this.listByIds(idList);
+        for (SysUserEntity entity: entityList) {
+            Integer isAdmin = entity.getIsAdmin();
+            if (isAdmin == 1) {
+                log.error("管理员账户不能删除 {}", entity.getId());
+                return Result.failure("管理员账户不能删除");
+            }
+//            entity.setIsDelete(1);
+//            entity.setUpdateTime(LocalDateTime.now());
+//            this.update(entity);
+        }
+        this.removeByIds(idList);
+
+        return Result.success();
+    }
+
+    @Override
+    public Result<SysUserEntity> search(PageDateDto param) {
+        BaseUtil.startPage(param);
+
+        IPage<SysUserEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
+        LambdaQueryWrapper<SysUserEntity> wrapper = new LambdaQueryWrapper<>();
+
+//            wrapper.eq(SysUserEntity::getIsEnabled, 1);
+
+
+        String startTime = param.getStartTime();
+        String endTime = param.getEndTime();
+        if (StringUtils.isNotBlank(startTime) || StringUtils.isNotBlank(endTime)){
+            wrapper.between(SysUserEntity::getCreateTime, startTime, endTime);
+        }
+
+        String searchKey = param.getSearchKey();
+        if (StringUtils.isNotBlank(searchKey)){
+            wrapper.like(SysUserEntity::getUserName, searchKey);
+        }
+
+        wrapper.orderByDesc(SysUserEntity::getCreateTime);
+
+        IPage<SysUserEntity> result = this.page(page, wrapper);
+
+        return Result.success(result);
+    }
+
+
+    private void updatePassword(PasswordDto param) {
+//        SysUserEntity user = this.findByUserName(JwtUtil.getUsername(getToken()));
+//
+//        // 验证原密码
+//        Boolean isBoolean = PasswordUtils.decrypt(user.getPassword(), param.getOldPassword(), PasswordUtils.getStaticSalt());
+//        if (!isBoolean) {
+//            log.error("原始密码错误");
+//            throw new BaseRuntimeException("原始密码错误");
+//        }
+//
+//        user.setPassword(PasswordUtils.encrypt(user.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
+//        user.setUpdateTime(LocalDateTime.now());
+//        this.update(user);
+    }
+
+    @Override
+    public Result updatePwd(PasswordDto param) {
+        // 密码加密了,需要解密
+        String newPassword = Base64Converter.decodePassword(param.getNewPassword());
+        String oldPassword = Base64Converter.decodePassword(param.getOldPassword());
+        param.setNewPassword(newPassword);
+        param.setOldPassword(oldPassword);
+        SysUserEntity user = this.findByUserName(JwtUtil.getUsername(request.getHeader("token")));
+        updatePwd(param, user, true);
+//        updatePassword(param);
+        return Result.success();
+    }
+
+    private void updatePwd(PasswordDto param, SysUserEntity user, boolean flag){
+
+        if (flag){
+            // 验证原密码
+            Boolean isBoolean = PasswordUtils.decrypt(user.getPassword(), param.getOldPassword(), PasswordUtils.getStaticSalt());
+            if (!isBoolean) {
+                log.error("原始密码错误");
+                throw new BaseRuntimeException("原始密码错误");
+            }
+        }
+
+        user.setPassword(PasswordUtils.encrypt(user.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
+        user.setUpdateTime(LocalDateTime.now());
+//        this.saveOrUpdate(user);
+        this.updateById(user);
+    }
+
+    @Override
+    public Result resetPass(Long id) {
+        SysUserEntity user = this.getById(id);
+
+        if (user == null) {
+            log.error("用户不存在: {}", id);
+            return Result.failure("用户不存在");
+        }
+
+        user.setPassword(PasswordUtils.encrypt(user.getUserName(), "123456", PasswordUtils.getStaticSalt()));
+        user.setUpdateTime(LocalDateTime.now());
+        this.updateById(user);
+        return Result.success();
+    }
+
+    @Override
+    public Result editStatus(Long id, Integer isEnabled) {
+
+        SysUserEntity user = this.getById(id);
+        if (user == null) {
+            log.error("用户不存在: {}", id);
+            return Result.failure("用户不存在");
+        }
+
+        if (user.getIsAdmin() == 1) {
+            log.error("管理员账户不能停用/注销: {}", id);
+            return Result.failure("管理员账户不能停用/注销");
+        }
+
+        user.setIsEnabled(isEnabled);
+        user.setUpdateTime(LocalDateTime.now());
+        this.updateById(user);
+        return Result.success();
+    }
+
+    @Override
+    public Result register(RegisterDto param) {
+        if (!param.getPassword().equals(param.getVerifyPassword())) {
+            log.error("确认密码不一致");
+            return Result.failure("确认密码不一致");
+        }
+
+        SysUserEntity entity = this.findByUserName(param.getUserName());
+        if (entity != null) {
+            log.error("该身份码已注册: {}", param.getUserName());
+            return Result.failure("该身份码已注册");
+        }
+
+        entity = new SysUserEntity();
+        BeanUtils.copyProperties(param, entity);
+
+        entity.setPassword(PasswordUtils.encrypt(param.getUserName(), param.getPassword(), PasswordUtils.getStaticSalt()));
+        // 默认启用
+        entity.setIsEnabled(1);
+        this.save(entity);
+
+        // 设置默认角色, 2:sys_visitor游客角色
+        Long userId = entity.getId();
+//        sysRoleService.saveUserRole(userId, Long.valueOf("2"));
+
+        // 保存操作日志
+//        logService.save(new LogEntity(userId,"用户注册","新增用户", request.getRemoteAddr()));
+        return Result.success();
+    }
+
+
+
+    @Override
+    public Result<SysUserEntity> detail(Long id) {
+        SysUserEntity user = this.getById(id);
+        return Result.success(user);
+    }
+
+    /**
+     * 不正确返回空
+     * 正确返回 code
+     * @param param
+     * @return
+     */
+    @Override
+    public Result retrievePassword(ResetPasswordDto param) {
+        String userName = param.getUserName();
+        SysUserEntity entity = entityMapper.findByUserName(param.getUserName());
+        if (entity == null) {
+            return Result.success(false);
+        }
+
+        if (!param.getRealName().equals(entity.getRealName())) {
+            return Result.success(false);
+        }
+
+        String redisKey = RESET_PASSWORD_KEY + userName;
+        String code = RandomUtil.randomString(9);
+
+        // code 有效期5分钟
+//        redisUtil.set(redisKey, code , 300);
+        return Result.success((Object) code);
+    }
+
+
+
+}

+ 29 - 0
gis_admin/src/main/java/com/gis/admin/service/impl/WxUserServiceImpl.java

@@ -0,0 +1,29 @@
+package com.gis.admin.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.admin.entity.po.WxUserEntity;
+import com.gis.admin.mapper.WxUserMapper;
+import com.gis.admin.service.WxUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+
+
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:16
+ */
+@Slf4j
+@Service
+public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUserEntity> implements WxUserService {
+
+
+    @Override
+    public WxUserEntity findByOpenId(String openId) {
+        LambdaQueryWrapper<WxUserEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(WxUserEntity::getOpenId, openId);
+        return getBaseMapper().selectOne(wrapper);
+    }
+}

+ 34 - 0
gis_admin/src/main/java/com/gis/admin/shiro/JwtAuthenticationException.java

@@ -0,0 +1,34 @@
+package com.gis.admin.shiro;
+
+import org.apache.shiro.ShiroException;
+
+public class JwtAuthenticationException extends ShiroException {
+
+    private static final long serialVersionUID = 2899335020273674736L;
+
+    private int code;
+
+    private String msg;
+
+    public JwtAuthenticationException(int code, String msg){
+        super(msg);
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 28 - 0
gis_admin/src/main/java/com/gis/admin/shiro/JwtToken.java

@@ -0,0 +1,28 @@
+package com.gis.admin.shiro;
+ 
+import org.apache.shiro.authc.AuthenticationToken;
+
+/**
+ * @Author Scott
+ * @create 2018-07-12 15:19
+ * @desc
+ **/
+public class JwtToken implements AuthenticationToken {
+	
+	private static final long serialVersionUID = 1L;
+	private String token;
+ 
+    public JwtToken(String token) {
+        this.token = token;
+    }
+ 
+    @Override
+    public Object getPrincipal() {
+        return token;
+    }
+ 
+    @Override
+    public Object getCredentials() {
+        return token;
+    }
+}

+ 271 - 0
gis_admin/src/main/java/com/gis/admin/shiro/ShiroConfig.java

@@ -0,0 +1,271 @@
+package com.gis.admin.shiro;
+
+import com.gis.admin.shiro.filters.CustomShiroFilterFactoryBean;
+import com.gis.admin.shiro.filters.JwtFilter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
+import org.apache.shiro.mgt.DefaultSubjectDAO;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.spring.LifecycleBeanPostProcessor;
+import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.core.env.Environment;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+
+import javax.annotation.Resource;
+import javax.servlet.Filter;
+import java.util.*;
+
+/**
+ * @author: Scott
+ * @date: 2018/2/7
+ * @description: shiro 配置类
+ */
+
+@Slf4j
+@Configuration
+public class ShiroConfig {
+
+//    @Value("${jeecg.shiro.excludeUrls}")
+//    private String excludeUrls;
+    @Resource
+    LettuceConnectionFactory lettuceConnectionFactory;
+    @Autowired
+    private Environment env;
+
+
+    /**
+     * Filter Chain定义说明
+     *
+     * 1、一个URL可以配置多个Filter,使用逗号分隔
+     * 2、当设置多个过滤器时,全部验证通过,才视为通过
+     * 3、部分过滤器可指定参数,如perms,roles
+     */
+    @Bean("shiroFilter")
+    public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
+        CustomShiroFilterFactoryBean shiroFilterFactoryBean = new CustomShiroFilterFactoryBean();
+        shiroFilterFactoryBean.setSecurityManager(securityManager);
+        // 拦截器
+        Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
+//        if(oConvertUtils.isNotEmpty(excludeUrls)){
+//            String[] permissionUrl = excludeUrls.split(",");
+//            for(String url : permissionUrl){
+//                filterChainDefinitionMap.put(url,"anon");
+//            }
+//        }
+        // 配置不会被拦截的链接 顺序判断
+//        filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录
+////        filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
+////        filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
+////        filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
+////        filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
+////        filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
+////        filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
+////        filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
+////        filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
+////        filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
+////        filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
+////        filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
+////        filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
+////        filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
+////        filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
+////        filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
+////        filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
+////        filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
+////        filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
+
+        // 不拦截
+        filterChainDefinitionMap.put("/login", "anon");
+        filterChainDefinitionMap.put("/logout", "anon");
+        filterChainDefinitionMap.put("/admin", "anon");
+        filterChainDefinitionMap.put("/admin/login", "anon");
+        filterChainDefinitionMap.put("/test/**", "anon");
+        filterChainDefinitionMap.put("/api/**", "anon");
+        filterChainDefinitionMap.put("/web/**", "anon");
+
+        filterChainDefinitionMap.put("/", "anon");
+        filterChainDefinitionMap.put("/doc.html", "anon");
+        filterChainDefinitionMap.put("/doc.html#/**", "anon");
+        filterChainDefinitionMap.put("/**/*.js", "anon");
+        filterChainDefinitionMap.put("/**/*.css", "anon");
+        filterChainDefinitionMap.put("/**/*.html", "anon");
+        filterChainDefinitionMap.put("/**/*.svg", "anon");
+        filterChainDefinitionMap.put("/**/*.pdf", "anon");
+        filterChainDefinitionMap.put("/**/*.jpg", "anon");
+        filterChainDefinitionMap.put("/**/*.png", "anon");
+        filterChainDefinitionMap.put("/**/*.ico", "anon");
+//        filterChainDefinitionMap.put("/**/*.mp4", "anon");
+
+        filterChainDefinitionMap.put("/**/*.ttf", "anon");
+        filterChainDefinitionMap.put("/**/*.woff", "anon");
+        filterChainDefinitionMap.put("/**/*.woff2", "anon");
+
+        // swagger 不拦截
+        filterChainDefinitionMap.put("/druid/**", "anon");
+        filterChainDefinitionMap.put("/swagger-ui.html", "anon");
+        filterChainDefinitionMap.put("/swagger**/**", "anon");
+        filterChainDefinitionMap.put("/swagger-resources/**", "anon");
+        filterChainDefinitionMap.put("/webjars/**", "anon");
+        filterChainDefinitionMap.put("/v2/**", "anon");
+
+
+        // update-begin--Author:sunjianlei Date:20210510 for:排除消息通告查看详情页面(用于第三方APP)
+        filterChainDefinitionMap.put("/sys/annountCement/show/**", "anon");
+        // update-end--Author:sunjianlei Date:20210510 for:排除消息通告查看详情页面(用于第三方APP)
+
+        //积木报表排除
+        filterChainDefinitionMap.put("/jmreport/**", "anon");
+        filterChainDefinitionMap.put("/**/*.js.map", "anon");
+        filterChainDefinitionMap.put("/**/*.css.map", "anon");
+        //大屏设计器排除
+        filterChainDefinitionMap.put("/bigscreen/**", "anon");
+
+        //测试示例
+        filterChainDefinitionMap.put("/test/bigScreen/**", "anon"); //大屏模板例子
+        //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
+        //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
+        //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
+
+        //websocket排除
+        filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告
+        filterChainDefinitionMap.put("/newsWebsocket/**", "anon");//CMS模块
+        filterChainDefinitionMap.put("/vxeSocket/**", "anon");//JVxeTable无痕刷新示例
+
+
+        //性能监控  TODO 存在安全漏洞泄露TOEKN(durid连接池也有)
+        filterChainDefinitionMap.put("/actuator/**", "anon");
+
+        // 添加自己的过滤器并且取名为jwt
+        Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
+        //如果cloudServer为空 则说明是单体 需要加载跨域配置
+        Object cloudServer = env.getProperty("");
+        filterMap.put("jwt", new JwtFilter(cloudServer==null));
+        shiroFilterFactoryBean.setFilters(filterMap);
+        // <!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边
+//        filterChainDefinitionMap.put("/**", "jwt");
+        filterChainDefinitionMap.put("/sys/**", "jwt");
+        filterChainDefinitionMap.put("/cms/**", "jwt");
+
+        // 未授权界面返回JSON
+        shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
+        shiroFilterFactoryBean.setLoginUrl("/sys/common/403");
+        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
+        return shiroFilterFactoryBean;
+    }
+
+    @Bean("securityManager")
+    public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
+        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
+        securityManager.setRealm(myRealm);
+
+        /*
+         * 关闭shiro自带的session,详情见文档
+         * http://shiro.apache.org/session-management.html#SessionManagement-
+         * StatelessApplications%28Sessionless%29
+         */
+        DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
+        DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
+        defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
+        subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
+        securityManager.setSubjectDAO(subjectDAO);
+        //自定义缓存实现,使用redis
+//        securityManager.setCacheManager(redisCacheManager());
+        return securityManager;
+    }
+
+    /**
+     * 下面的代码是添加注解支持
+     * @return
+     */
+    @Bean
+    @DependsOn("lifecycleBeanPostProcessor")
+    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
+        DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
+        defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
+        /**
+         * 解决重复代理问题 github#994
+         * 添加前缀判断 不匹配 任何Advisor
+         */
+        defaultAdvisorAutoProxyCreator.setUsePrefix(true);
+        defaultAdvisorAutoProxyCreator.setAdvisorBeanNamePrefix("_no_advisor");
+        return defaultAdvisorAutoProxyCreator;
+    }
+
+    @Bean
+    public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
+        return new LifecycleBeanPostProcessor();
+    }
+
+    @Bean
+    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
+        AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
+        advisor.setSecurityManager(securityManager);
+        return advisor;
+    }
+
+    /**
+     * cacheManager 缓存 redis实现
+     * 使用的是shiro-redis开源插件
+     *
+     * @return
+     */
+//    public RedisCacheManager redisCacheManager() {
+//        log.info("===============(1)创建缓存管理器RedisCacheManager");
+//        RedisCacheManager redisCacheManager = new RedisCacheManager();
+//        redisCacheManager.setRedisManager(redisManager());
+//        //redis中针对不同用户缓存(此处的id需要对应user实体中的id字段,用于唯一标识)
+//        redisCacheManager.setPrincipalIdFieldName("id");
+//        //用户权限信息缓存时间
+//        redisCacheManager.setExpire(200000);
+//        return redisCacheManager;
+//    }
+
+    /**
+     * 配置shiro redisManager
+     * 使用的是shiro-redis开源插件
+     *
+     * @return
+     */
+//    @Bean
+//    public IRedisManager redisManager() {
+//        log.info("===============(2)创建RedisManager,连接Redis..");
+//        IRedisManager manager;
+//        // redis 单机支持,在集群为空,或者集群无机器时候使用 add by jzyadmin@163.com
+//        if (lettuceConnectionFactory.getClusterConfiguration() == null || lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().isEmpty()) {
+//            RedisManager redisManager = new RedisManager();
+//            redisManager.setHost(lettuceConnectionFactory.getHostName());
+//            redisManager.setPort(lettuceConnectionFactory.getPort());
+//            redisManager.setDatabase(lettuceConnectionFactory.getDatabase());
+//            redisManager.setTimeout(0);
+//            if (!StringUtils.isEmpty(lettuceConnectionFactory.getPassword())) {
+//                redisManager.setPassword(lettuceConnectionFactory.getPassword());
+//            }
+//            manager = redisManager;
+//        }else{
+//            // redis集群支持,优先使用集群配置
+//            RedisClusterManager redisManager = new RedisClusterManager();
+//            Set<HostAndPort> portSet = new HashSet<>();
+//            lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().forEach(node -> portSet.add(new HostAndPort(node.getHost() , node.getPort())));
+//            //update-begin--Author:scott Date:20210531 for:修改集群模式下未设置redis密码的bug issues/I3QNIC
+//            if (oConvertUtils.isNotEmpty(lettuceConnectionFactory.getPassword())) {
+//                JedisCluster jedisCluster = new JedisCluster(portSet, 2000, 2000, 5,
+//                    lettuceConnectionFactory.getPassword(), new GenericObjectPoolConfig());
+//                redisManager.setPassword(lettuceConnectionFactory.getPassword());
+//                redisManager.setJedisCluster(jedisCluster);
+//            } else {
+//                JedisCluster jedisCluster = new JedisCluster(portSet);
+//                redisManager.setJedisCluster(jedisCluster);
+//            }
+//            //update-end--Author:scott Date:20210531 for:修改集群模式下未设置redis密码的bug issues/I3QNIC
+//            manager = redisManager;
+//        }
+//        return manager;
+//    }
+
+}

+ 262 - 0
gis_admin/src/main/java/com/gis/admin/shiro/ShiroRealm.java

@@ -0,0 +1,262 @@
+package com.gis.admin.shiro;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.gis.admin.entity.po.WxUserEntity;
+import com.gis.admin.service.WxUserService;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.constant.SysEnum;
+import com.gis.common.constant.TypeCode;
+import com.gis.common.util.JwtUtil;
+import com.gis.admin.entity.po.SysUserEntity;
+import com.gis.admin.service.SysUserService;
+import com.gis.common.util.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
+import org.apache.shiro.realm.AuthorizingRealm;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * @Description: 用户登录鉴权和获取用户授权
+ * @Author: owen
+ * @Date: 2021-07-07
+ * @Version: 1.1
+ */
+@Component
+@Slf4j
+public class ShiroRealm extends AuthorizingRealm {
+
+    @Resource
+    HttpServletRequest request;
+
+
+    @Autowired
+    SysUserService sysUserService;
+
+    @Autowired
+    WxUserService wxUserService;
+
+
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+
+    /**
+     * 必须重写此方法,不然Shiro会报错
+     */
+    @Override
+    public boolean supports(AuthenticationToken token) {
+        return token instanceof JwtToken;
+    }
+
+    /**
+     * 权限信息认证(包括角色以及权限)是用户访问controller的时候才进行验证(redis存储的此处权限信息)
+     * 触发检测用户权限时才会调用此方法,例如checkRole,checkPermission
+     *
+     * 只有当需要检测用户权限的时候才会调用此方法,例如checkRole,checkPermission之类的
+     *
+     * @param principals 身份信息
+     * @return AuthorizationInfo 权限信息
+     */
+    @Override
+    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+        Long userId = null;
+
+        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
+
+        String token = request.getHeader(SysEnum.TOKEN_KEY.getValue());
+        if (StringUtils.isNotBlank(token)){
+            String loginType = JwtUtil.getLoginType(token);
+            if (SysEnum.LOGIN_TYPE_CMS.getValue().equals(loginType)){
+                List userRole = JwtUtil.getRoleKeys(token);
+                // list to set 添加角色sys_admin
+                if (CollectionUtil.isNotEmpty(userRole)){
+                    info.setRoles(new HashSet<>(userRole));
+                }
+            }
+
+        }
+
+//        // 设置用户拥有的权限集合,比如“sys:role:add,sys:user:add”
+//        Set<String> permissions = sysResourceService.getPermissionByUserId(userId);
+//        info.addStringPermissions(permissions);
+//        log.info("===============Shiro权限认证成功==============");
+        return info;
+    }
+
+    /**
+     * 默认使用此方法进行用户名正确与否验证,错误抛出异常即可。
+     *
+     * 用户信息认证是在用户进行登录的时候进行验证(不存redis)
+     * 也就是说验证用户输入的账号和密码是否正确,错误抛出异常
+     *
+     * @param auth 用户登录的账号密码信息
+     * @return 返回封装了用户信息的 AuthenticationInfo 实例
+     * @throws AuthenticationException
+     */
+    @Override
+    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
+        String token = (String) auth.getCredentials();
+        if (token == null) {
+            throw new JwtAuthenticationException(5001, "header token is null");
+        }
+        String loginType = JwtUtil.getLoginType(token);
+        Object authData;
+        if (SysEnum.LOGIN_TYPE_CMS.getValue().equals(loginType)){
+            // 校验token有效性
+            SysUserEntity sysUserEntity = this.checkUserTokenIsEffect(token);
+            authData = sysUserEntity;
+        } else {
+            WxUserEntity wxUserEntity = this.checkWxUserTokenIsEffect(token);
+            authData = wxUserEntity;
+        }
+
+
+        return new SimpleAuthenticationInfo(authData, token, getName());
+    }
+
+
+
+
+    /**
+     * 校验token的有效性
+     *
+     * @param token
+     */
+    private SysUserEntity checkUserTokenIsEffect(String token) throws AuthenticationException {
+        // 解密获得username,用于和数据库进行对比
+        String username = JwtUtil.getUsername(token);
+        if (username == null) {
+            throw new JwtAuthenticationException(5001, "token invalid");
+        }
+
+        String redisToken = (String)redisUtil.get(configConstant.redisPrefix + token);
+
+        if (!token.equals(redisToken)) {
+            log.error("redis token is null");
+            throw new JwtAuthenticationException(5001, "redis token is null");
+
+        }
+        // 查询用户信息
+        if (! JwtUtil.isVerify(token, username)) {
+            log.error("error token username or password");
+            throw new JwtAuthenticationException(5001, "token invalid");
+        }
+
+        SysUserEntity userEntity = sysUserService.findByUserName(username);
+        if (userEntity == null) {
+            log.error("error token userEntity");
+            throw new JwtAuthenticationException(5001, "User didn't existed!");
+        }
+
+        return userEntity;
+    }
+
+
+
+//    @Override
+//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
+////        log.debug("===============Shiro身份认证开始============doGetAuthenticationInfo==========");
+//        String token = (String) auth.getCredentials();
+////        log.info("token: {}", token);
+//        if (token == null) {
+//            throw new JwtAuthenticationException(5001, "header token is null");
+//        }
+//        // 校验token有效性
+//        WxUserEntity wxUserEntity = this.checkUserTokenIsEffect(token);
+//        return new SimpleAuthenticationInfo(wxUserEntity, token, getName());
+//    }
+
+    private WxUserEntity checkWxUserTokenIsEffect(String token) throws AuthenticationException {
+        // 解密获得username,用于和数据库进行对比
+        String wxOpenId = JwtUtil.getWxOpenId(token);
+        if (wxOpenId == null) {
+            throw new JwtAuthenticationException(5001, "token invalid");
+        }
+
+        // redis取回来的带有字符传符合
+        String redisToken = (String)redisUtil.get(configConstant.redisPrefix + token);
+
+        if (!token.equals(redisToken)) {
+            log.error("redis token is null");
+            throw new JwtAuthenticationException(5001, "redis token is null");
+
+        }
+        // 查询用户信息
+        if (! JwtUtil.isVerify(token, wxOpenId, "userName")) {
+            log.error("error token username or password");
+            throw new JwtAuthenticationException(5001, "token invalid");
+        }
+
+        WxUserEntity wxUserEntity = wxUserService.findByOpenId(wxOpenId);
+        if (wxUserEntity == null) {
+            log.error("error token userEntity");
+            throw new JwtAuthenticationException(5001, "User didn't existed!");
+        }
+
+        return wxUserEntity;
+    }
+
+    /**
+     * JWTToken刷新生命周期 (实现: 用户在线操作不掉线功能)
+     * 1、登录成功后将用户的JWT生成的Token作为k、v存储到cache缓存里面(这时候k、v值一样),缓存有效期设置为Jwt有效时间的2倍
+     * 2、当该用户再次请求时,通过JWTFilter层层校验之后会进入到doGetAuthenticationInfo进行身份验证
+     * 3、当该用户这次请求jwt生成的token值已经超时,但该token对应cache中的k还是存在,则表示该用户一直在操作只是JWT的token失效了,程序会给token对应的k映射的v值重新生成JWTToken并覆盖v值,该缓存生命周期重新计算
+     * 4、当该用户这次请求jwt在生成的token值已经超时,并在cache中不存在对应的k,则表示该用户账户空闲超时,返回用户信息已失效,请重新登录。
+     * 注意: 前端请求Header中设置Authorization保持不变,校验有效性以缓存中的token为准。
+     *       用户过期时间 = Jwt有效时间 * 2。
+     *
+     * @param userName
+     * @param passWord
+     * @return
+     */
+//    public boolean jwtTokenRefresh(String token, String userName, String passWord) {
+//        String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token));
+//        if (oConvertUtils.isNotEmpty(cacheToken)) {
+//            // 校验token有效性
+//            if (!JwtUtil.verify(cacheToken, userName, passWord)) {
+//                String newAuthorization = JwtUtil.sign(userName, passWord);
+//                // 设置超时时间
+//                redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
+//                redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME *2 / 1000);
+//                log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
+//            }
+//            //update-begin--Author:scott  Date:20191005  for:解决每次请求,都重写redis中 token缓存问题
+////			else {
+////				// 设置超时时间
+////				redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken);
+////				redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
+////			}
+//            //update-end--Author:scott  Date:20191005   for:解决每次请求,都重写redis中 token缓存问题
+//            return true;
+//        }
+//        return false;
+//    }
+
+    /**
+     * 清除当前用户的权限认证缓存
+     *
+     * @param principals 权限信息
+     */
+    @Override
+    public void clearCache(PrincipalCollection principals) {
+        super.clearCache(principals);
+    }
+
+}

+ 76 - 0
gis_admin/src/main/java/com/gis/admin/shiro/filters/CustomShiroFilterFactoryBean.java

@@ -0,0 +1,76 @@
+package com.gis.admin.shiro.filters;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
+import org.apache.shiro.web.filter.InvalidRequestFilter;
+import org.apache.shiro.web.filter.mgt.DefaultFilter;
+import org.apache.shiro.web.filter.mgt.FilterChainManager;
+import org.apache.shiro.web.filter.mgt.FilterChainResolver;
+import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;
+import org.apache.shiro.web.mgt.WebSecurityManager;
+import org.apache.shiro.web.servlet.AbstractShiroFilter;
+import org.springframework.beans.factory.BeanInitializationException;
+
+import javax.servlet.Filter;
+import java.util.Map;
+
+/**
+ * 自定义ShiroFilterFactoryBean解决资源中文路径问题
+ */
+@Slf4j
+public class CustomShiroFilterFactoryBean extends ShiroFilterFactoryBean {
+    @Override
+    public Class getObjectType() {
+        return MySpringShiroFilter.class;
+    }
+
+    @Override
+    protected AbstractShiroFilter createInstance() throws Exception {
+
+        SecurityManager securityManager = getSecurityManager();
+        if (securityManager == null) {
+            String msg = "SecurityManager property must be set.";
+            throw new BeanInitializationException(msg);
+        }
+
+        if (!(securityManager instanceof WebSecurityManager)) {
+            String msg = "The security manager does not implement the WebSecurityManager interface.";
+            throw new BeanInitializationException(msg);
+        }
+
+        FilterChainManager manager = createFilterChainManager();
+        //Expose the constructed FilterChainManager by first wrapping it in a
+        // FilterChainResolver implementation. The AbstractShiroFilter implementations
+        // do not know about FilterChainManagers - only resolvers:
+        PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
+        chainResolver.setFilterChainManager(manager);
+
+        Map<String, Filter> filterMap = manager.getFilters();
+        Filter invalidRequestFilter = filterMap.get(DefaultFilter.invalidRequest.name());
+        if (invalidRequestFilter instanceof InvalidRequestFilter) {
+            //此处是关键,设置false跳过URL携带中文400,servletPath中文校验bug
+            ((InvalidRequestFilter) invalidRequestFilter).setBlockNonAscii(false);
+        }
+        //Now create a concrete ShiroFilter instance and apply the acquired SecurityManager and built
+        //FilterChainResolver.  It doesn't matter that the instance is an anonymous inner class
+        //here - we're just using it because it is a concrete AbstractShiroFilter instance that accepts
+        //injection of the SecurityManager and FilterChainResolver:
+        return new MySpringShiroFilter((WebSecurityManager) securityManager, chainResolver);
+    }
+
+    private static final class MySpringShiroFilter extends AbstractShiroFilter {
+        protected MySpringShiroFilter(WebSecurityManager webSecurityManager, FilterChainResolver resolver) {
+            if (webSecurityManager == null) {
+                throw new IllegalArgumentException("WebSecurityManager property cannot be null.");
+            } else {
+                this.setSecurityManager(webSecurityManager);
+                if (resolver != null) {
+                    this.setFilterChainResolver(resolver);
+                }
+
+            }
+        }
+    }
+
+}

+ 149 - 0
gis_admin/src/main/java/com/gis/admin/shiro/filters/JwtFilter.java

@@ -0,0 +1,149 @@
+package com.gis.admin.shiro.filters;
+
+import com.alibaba.fastjson.JSONObject;
+import com.gis.admin.shiro.JwtAuthenticationException;
+import com.gis.admin.shiro.JwtToken;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.time.LocalDateTime;
+
+/**
+ * @Description: 鉴权登录拦截器
+ * @Author: Scott
+ * @Date: 2018/10/7
+ **/
+@Slf4j
+public class JwtFilter extends BasicHttpAuthenticationFilter {
+
+    private boolean allowOrigin = true;
+
+    public JwtFilter(){}
+    public JwtFilter(boolean allowOrigin){
+        this.allowOrigin = allowOrigin;
+    }
+
+    /**
+     * 执行登录认证
+     *
+     * @param request
+     * @param response
+     * @param mappedValue
+     * @return
+     */
+    @Override
+    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
+        try {
+            executeLogin(request, response);
+            return true;
+        } catch (Exception e) {
+//            throw new AuthenticationException("Token失效,请重新登录", e);
+            exceptionMsg(e, response);
+
+        }
+        // 前端没有响应,接收不到异常
+        return false;
+    }
+
+    /**
+     *
+     */
+    @Override
+    protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        String token = httpServletRequest.getHeader("token");
+        // update-begin--Author:lvdandan Date:20210105 for:JT-355 OA聊天添加token验证,获取token参数
+        if(token == null){
+            token = httpServletRequest.getParameter("token");
+        }
+        // update-end--Author:lvdandan Date:20210105 for:JT-355 OA聊天添加token验证,获取token参数
+
+        JwtToken jwtToken = new JwtToken(token);
+        // 提交给realm进行登入,如果错误他会抛出异常并被捕获
+        getSubject(request, response).login(jwtToken);
+        // 如果没有抛出异常则代表登入成功,返回true
+        return true;
+    }
+
+    /**
+     * 对跨域提供支持
+     */
+    @Override
+    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+        if(allowOrigin){
+            httpServletResponse.setHeader("Access-control-Allow-Origin", httpServletRequest.getHeader("Origin"));
+            httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
+            httpServletResponse.setHeader("Access-Control-Allow-Headers", httpServletRequest.getHeader("Access-Control-Request-Headers"));
+            //update-begin-author:scott date:20200907 for:issues/I1TAAP 前后端分离,shiro过滤器配置引起的跨域问题
+            // 是否允许发送Cookie,默认Cookie不包括在CORS请求之中。设为true时,表示服务器允许Cookie包含在请求中。
+            httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true");
+            //update-end-author:scott date:20200907 for:issues/I1TAAP 前后端分离,shiro过滤器配置引起的跨域问题
+        }
+        // 跨域时会首先发送一个option请求,这里我们给option请求直接返回正常状态
+        if (httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name())) {
+            httpServletResponse.setStatus(HttpStatus.OK.value());
+            return false;
+        }
+        //update-begin-author:taoyan date:20200708 for:多租户用到
+//        String tenant_id = httpServletRequest.getHeader(CommonConstant.TENANT_ID);
+//        TenantContext.setTenant(tenant_id);
+        //update-end-author:taoyan date:20200708 for:多租户用到
+        return super.preHandle(request, response);
+    }
+
+    /**
+     * 封装异常信息
+     */
+    private void exceptionMsg(Exception e, ServletResponse response) {
+        // 认证出现异常,传递错误信息msg
+        String msg = e.getMessage();
+        // 获取应用异常(该Cause是导致抛出此throwable(异常)的throwable(异常))
+        Throwable throwable = e.getCause();
+        JSONObject jsonObject = new JSONObject();
+        if (throwable instanceof JwtAuthenticationException) {
+            jsonObject.put("code", ((JwtAuthenticationException) throwable).getCode());
+            jsonObject.put("msg", ((JwtAuthenticationException) throwable).getMsg());
+        } else {
+            log.error(msg);
+            jsonObject.put("code", 5002);
+            jsonObject.put("msg", "token invalid");
+
+        }
+        jsonObject.put("timestamp", LocalDateTime.now());
+        // 直接返回Response信息
+        this.writeResponse(response, jsonObject);
+
+    }
+
+    /**
+     * 无需转发,直接返回Response信息
+     *
+     */
+    private void writeResponse(ServletResponse response, JSONObject msg) {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        ServletOutputStream outputStream = null;
+        try {
+            outputStream = response.getOutputStream();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        assert outputStream != null;
+        PrintWriter printWriter = new PrintWriter(outputStream, true);
+        printWriter.write(msg.toString());//直接将json输出到页面
+        printWriter.flush();
+        printWriter.close();
+
+    }
+}

+ 68 - 0
gis_admin/src/main/java/com/gis/admin/shiro/filters/ResourceCheckFilter.java

@@ -0,0 +1,68 @@
+package com.gis.admin.shiro.filters;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.web.filter.AccessControlFilter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @Author Scott
+ * @create 2019-02-01 15:56
+ * @desc 鉴权请求URL访问权限拦截器
+ */
+@Slf4j
+public class ResourceCheckFilter extends AccessControlFilter {
+
+    private String errorUrl;
+
+    public String getErrorUrl() {
+        return errorUrl;
+    }
+
+    public void setErrorUrl(String errorUrl) {
+        this.errorUrl = errorUrl;
+    }
+
+    /**
+     * 表示是否允许访问 ,如果允许访问返回true,否则false;
+     *
+     * @param servletRequest
+     * @param servletResponse
+     * @param o               表示写在拦截器中括号里面的字符串 mappedValue 就是 [urls] 配置中拦截器参数部分
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected boolean isAccessAllowed(ServletRequest servletRequest, ServletResponse servletResponse, Object o) throws Exception {
+        Subject subject = getSubject(servletRequest, servletResponse);
+        String url = getPathWithinApplication(servletRequest);
+        log.info("当前用户正在访问的 url => " + url);
+        return subject.isPermitted(url);
+    }
+
+    /**
+     * onAccessDenied:表示当访问拒绝时是否已经处理了; 如果返回 true 表示需要继续处理; 如果返回 false
+     * 表示该拦截器实例已经处理了,将直接返回即可。
+     *
+     * @param servletRequest
+     * @param servletResponse
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
+        log.info("当 isAccessAllowed 返回 false 的时候,才会执行 method onAccessDenied ");
+
+        HttpServletRequest request = (HttpServletRequest) servletRequest;
+        HttpServletResponse response = (HttpServletResponse) servletResponse;
+        response.sendRedirect(request.getContextPath() + this.errorUrl);
+
+        // 返回 false 表示已经处理,例如页面跳转啥的,表示不在走以下的拦截器了(如果还有配置的话)
+        return false;
+    }
+
+}

+ 107 - 0
gis_admin/src/main/java/com/gis/admin/tree/SysResourceTreeUtil.java

@@ -0,0 +1,107 @@
+package com.gis.admin.tree;
+
+import com.gis.admin.entity.po.SysResourceEntity;
+import com.gis.admin.tree.vo.SysResourceTree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SysResourceTreeUtil {
+
+    private List<SysResourceTree> resultNodes = new ArrayList<SysResourceTree>();//树形结构排序之后list内容
+
+    private List<SysResourceTree> nodes = new ArrayList<SysResourceTree>();
+    //传入list参数
+
+    public SysResourceTreeUtil(List<SysResourceEntity> nodesList) {//通过构造函数初始化
+        for (SysResourceEntity n : nodesList) {
+            SysResourceTree treeGrid = new SysResourceTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+//            treeGrid.setIcon(n.getIcon());
+            treeGrid.setUrl(n.getUrl());
+            treeGrid.setResourceKey(n.getResourceKey());
+            treeGrid.setResourceType(n.getResourceType());
+
+            if (n.getAuthority() != null){
+                treeGrid.setAuthority(n.getAuthority());
+            }
+
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+    }
+
+    public SysResourceTreeUtil() {
+    }
+
+    /**
+     * 构建树形结构list
+     *
+     * @return 返回树形结构List列表
+     */
+    public List<SysResourceTree> buildTree() {
+        for (SysResourceTree node : nodes) {
+            Long id = node.getParentId();
+            if (id == null) {//通过循环一级节点 就可以通过递归获取二级以下节点
+                resultNodes.add(node);//添加一级节点
+                node.setLevel(1);
+                build(node, node.getLevel());//递归获取二级、三级、。。。节点
+            }
+        }
+        return resultNodes;
+    }
+
+    /**
+     * 递归循环子节点
+     *
+     * @param node 当前节点
+     */
+    private void build(SysResourceTree node, int level) {
+        List<SysResourceTree> children = getChildren(node);
+        if (!children.isEmpty()) {//如果存在子节点
+            node.setChildren(children);
+//        	level++;
+            for (SysResourceTree child : children) {//将子节点遍历加入返回值中
+        		child.setLevel(level);
+                build(child, child.getLevel());
+            }
+        }
+    }
+
+    /**
+     * @param node
+     * @return 返回
+     */
+    private List<SysResourceTree> getChildren(SysResourceTree node) {
+        List<SysResourceTree> children = new ArrayList<SysResourceTree>();
+        Long id = node.getId();
+        for (SysResourceTree child : nodes) {
+            if (id.equals(child.getParentId())) {//如果id等于父id
+                children.add(child);//将该节点加入循环列表中
+            }
+        }
+        return children;
+    }
+
+    public List<SysResourceTree> buildTree(List<SysResourceEntity> all, List<SysResourceEntity> in) {
+        for (SysResourceEntity n : all) {
+            SysResourceTree treeGrid = new SysResourceTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+            for (SysResourceEntity nin : in) {
+                if (nin.getId().equals(n.getId())) {
+                    treeGrid.setChecked(true);
+                }
+            }
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+        return buildTree();
+    }
+
+}

+ 51 - 0
gis_admin/src/main/java/com/gis/admin/tree/vo/SysResourceTree.java

@@ -0,0 +1,51 @@
+package com.gis.admin.tree.vo;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SysResourceTree {
+
+    private Long id;
+
+    private String name;
+
+    private Long parentId;
+
+    @JSONField(serialize = false)
+    private boolean checked = false;
+
+    @JSONField(serialize = false)
+    private boolean spread = false;
+
+    @JSONField(serialize = false)
+    private String isHeader = "0";
+
+    @JSONField(serialize = false)
+    private String url;
+
+    @JSONField(serialize = false)
+    private String icon;
+
+    @JSONField(serialize = false)
+    private String resourceKey;
+
+//    @JSONField(serialize = false)
+    private String resourceType;
+
+    @JSONField(serialize = false)
+    private String order = "1";
+
+    // 子菜单/或按钮
+    private List<SysResourceTree> children;
+
+    @JSONField(serialize = false)
+    private int level;
+
+    // 默认都没有权限
+    private boolean authority ;
+
+
+}

+ 191 - 0
gis_admin/src/main/resources/db/sys_admin.sql

@@ -0,0 +1,191 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server         : 8.135.106.227_项目_sit
+ Source Server Type    : MySQL
+ Source Server Version : 50733
+ Source Host           : 8.135.106.227:3306
+ Source Schema         : sys_admin
+
+ Target Server Type    : MySQL
+ Target Server Version : 50733
+ File Encoding         : 65001
+
+ Date: 07/07/2021 18:19:00
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for sys_resource
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_resource`;
+CREATE TABLE `sys_resource`  (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源名称',
+  `resource_type` enum('menu','button') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源类型',
+  `resource_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源key',
+  `sort` int(6) NULL DEFAULT NULL COMMENT '排序',
+  `parent_id` bigint(20) NULL DEFAULT NULL COMMENT '父资源id',
+  `is_delete` int(1) NULL DEFAULT 0 COMMENT '是否删除,0:可用, 1:删除',
+  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源地址',
+  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源描述',
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `FKf5ra2gn0xedeida2op8097sr5`(`parent_id`) USING BTREE,
+  CONSTRAINT `FKf5ra2gn0xedeida2op8097sr5` FOREIGN KEY (`parent_id`) REFERENCES `sys_resource` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE = InnoDB AUTO_INCREMENT = 237 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '资源表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_resource
+-- ----------------------------
+INSERT INTO `sys_resource` VALUES (100, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '史馆场景管理', 'menu', 'scene', 100, NULL, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (101, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '查看', 'button', 'scene:detail', 101, 100, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (102, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '编辑', 'button', 'scene:edit', 102, 100, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (103, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '删除', 'button', 'scene:remove', 103, 100, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (200, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '精品典藏管理', 'menu', 'goods', 200, NULL, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (210, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '模型管理', 'menu', 'goods:model', 210, 200, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (211, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '提交', 'button', 'goods:model:edit', 211, 210, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (212, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '编辑', 'button', 'goods:model:edit', 212, 210, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (213, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '删除', 'button', 'goods:model:remove', 213, 210, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (214, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '审核', 'button', 'goods:model:audit', 214, 210, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (215, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '查看', 'button', 'goods:model:detail', 215, 210, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (216, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '是否显示', 'button', 'goods:model:display', 216, 210, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (220, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '视频管理', 'menu', 'goods:video', 220, 200, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (221, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '提交', 'button', 'goods:video:edit', 221, 220, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (222, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '编辑', 'button', 'goods:video:edit', 222, 220, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (223, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '删除', 'button', 'goods:video:remove', 223, 220, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (224, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '审核', 'button', 'goods:video:audit', 224, 220, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (225, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '查看', 'button', 'goods:video:detail', 225, 220, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (226, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '是否显示', 'button', 'goods:video:display', 226, 220, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (230, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '图片管理', 'menu', 'goods:img', 230, 200, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (231, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '提交', 'button', 'goods:img:edit', 231, 230, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (232, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '编辑', 'button', 'goods:img:edit', 232, 230, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (233, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '删除', 'button', 'goods:img:remove', 233, 230, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (234, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '审核', 'button', 'goods:img:audit', 234, 230, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (235, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '查看', 'button', 'goods:img:detail', 235, 230, 0, NULL, NULL);
+INSERT INTO `sys_resource` VALUES (236, '2021-07-05 15:49:29', '2021-07-05 15:49:29', '是否显示', 'button', 'goods:img:display', 236, 230, 0, NULL, NULL);
+
+-- ----------------------------
+-- Table structure for sys_role
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_role`;
+CREATE TABLE `sys_role`  (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+  `role_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色描述',
+  `role_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色名',
+  `role_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '角色key,0:未定义角色(默认值)',
+  `sort` int(3) NULL DEFAULT NULL COMMENT '排序',
+  `is_delete` int(1) NULL DEFAULT 0 COMMENT '是否删除,0:可用, 1:删除',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_role
+-- ----------------------------
+INSERT INTO `sys_role` VALUES (1, '2021-06-28 17:31:38', '2021-06-28 17:31:38', '拥有所有权限', '超级管理员', 'sys_admin', 1, 0);
+INSERT INTO `sys_role` VALUES (20, '2021-06-29 10:52:00', '2021-06-29 10:52:00', '测试权限', '测试角色1-admin', '0', NULL, 0);
+
+-- ----------------------------
+-- Table structure for sys_role_resource
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_role_resource`;
+CREATE TABLE `sys_role_resource`  (
+  `role_id` bigint(20) NOT NULL COMMENT '角色表id',
+  `resource_id` bigint(20) NOT NULL COMMENT '资源表id',
+  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`role_id`, `resource_id`) USING BTREE,
+  INDEX `FK868kc8iic48ilv5npa80ut6qo`(`resource_id`) USING BTREE,
+  CONSTRAINT `sys_role_resource_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `sys_role_resource_ibfk_2` FOREIGN KEY (`resource_id`) REFERENCES `sys_resource` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色资源关系表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_role_resource
+-- ----------------------------
+INSERT INTO `sys_role_resource` VALUES (20, 101, '2021-07-06 16:07:08');
+INSERT INTO `sys_role_resource` VALUES (20, 102, '2021-07-06 16:07:15');
+INSERT INTO `sys_role_resource` VALUES (20, 103, '2021-07-06 16:07:22');
+
+-- ----------------------------
+-- Table structure for sys_user
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_user`;
+CREATE TABLE `sys_user`  (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `is_delete` int(1) NULL DEFAULT 0 COMMENT '状态,0:激活,1:禁用',
+  `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
+  `real_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名',
+  `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号,用户号',
+  `nick_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '昵称',
+  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
+  `sex` tinyint(4) NULL DEFAULT NULL COMMENT '性别, 0:男, 1:女',
+  `status` int(11) NULL DEFAULT NULL COMMENT '状态 0:启用  1:停用',
+  `view_count` int(11) NULL DEFAULT 0 COMMENT '登录次数',
+  `phone` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号',
+  `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '登录密码',
+  `role` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色,sys_admin:系统管理员,sys_high:高级管理员, sys_normal, sys_visitor:游客',
+  `thumb` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '缩略图url',
+  `unit` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_user
+-- ----------------------------
+INSERT INTO `sys_user` VALUES (1, '2020-04-13 08:57:41', 0, '2021-06-04 14:44:50', '超级管理员', 'admin', '系统管理员', '38@qq.com', 0, 1, 0, '15012345678', 'c44b01947c9e6e3f', 'sys_admin', '/data/media/thumb_20210416_083830938.jpg', '洪兴');
+INSERT INTO `sys_user` VALUES (2, '2021-05-19 10:44:59', 0, '2021-05-19 10:44:59', '', 'admin2', '', NULL, 0, 1, 0, '', '9ad4418857d43064', 'sys_admin', '', NULL);
+INSERT INTO `sys_user` VALUES (3, '2021-05-20 10:03:01', 0, '2021-06-11 12:00:43', '', 'owen', 'owen', NULL, 0, 1, 0, '', '57eaf7d9dde69c9b', 'sys_admin', '', NULL);
+INSERT INTO `sys_user` VALUES (4, '2021-06-11 11:48:14', 1, '2021-06-11 12:05:40', NULL, '测试普通用户账号001', '测试普通用户账号001', NULL, NULL, 0, 0, '13800138000', '13f0d6d25a83f9ad0063eed5567ff6faf1dd46cdcb61666a54ade1af4f3254bb', 'sys_normal', '', NULL);
+INSERT INTO `sys_user` VALUES (5, '2021-06-11 11:56:11', 0, '2021-06-11 12:00:20', NULL, 'testAdmin', 'testAdmin', NULL, NULL, 1, 0, '13800138000', '4a9776bceff9c1bb82c584e3a825c2ca', 'sys_admin', '', NULL);
+INSERT INTO `sys_user` VALUES (6, '2021-06-11 12:06:20', 0, '2021-06-11 12:06:20', NULL, 'user', 'user', NULL, NULL, 1, 0, '13800138000', '4a4858a9a6266662', 'sys_normal', '', NULL);
+
+-- ----------------------------
+-- Table structure for sys_user_role
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_user_role`;
+CREATE TABLE `sys_user_role`  (
+  `user_id` bigint(20) NOT NULL COMMENT '用户表id',
+  `role_id` bigint(20) NOT NULL COMMENT '角色表id',
+  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  PRIMARY KEY (`user_id`, `role_id`) USING BTREE,
+  INDEX `role_id`(`role_id`) USING BTREE,
+  CONSTRAINT `sys_user_role_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `sys_user_role_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户角色关系表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_user_role
+-- ----------------------------
+INSERT INTO `sys_user_role` VALUES (1, 1, '2021-06-29 11:32:05');
+INSERT INTO `sys_user_role` VALUES (3, 20, '2021-07-06 16:06:40');
+
+-- ----------------------------
+-- Table structure for tb_log
+-- ----------------------------
+DROP TABLE IF EXISTS `tb_log`;
+CREATE TABLE `tb_log`  (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT,
+  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
+  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
+  `user_id` bigint(50) NULL DEFAULT NULL COMMENT '用户id',
+  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作类型',
+  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作详情',
+  `is_delete` int(1) NULL DEFAULT 0,
+  `ip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'ip地址',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 502 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of tb_log
+-- ----------------------------
+INSERT INTO `tb_log` VALUES (462, '2021-06-23 16:49:50', '2021-06-23 16:49:50', 1, '精品典藏', '新增/修改', 0, '127.0.0.1');
+INSERT INTO `tb_log` VALUES (463, '2021-06-23 16:50:43', '2021-06-23 16:50:43', 1, '精品典藏', '新增/修改', 0, '127.0.0.1');
+INSERT INTO `tb_log` VALUES (464, '2021-06-23 16:52:48', '2021-06-23 16:52:48', 1, '精品典藏', '新增/修改', 0, '127.0.0.1');
+INSERT INTO `tb_log` VALUES (465, '2021-06-23 16:58:20', '2021-06-23 16:58:20', 1, '精品典藏', '图片置顶', 0, '127.0.0.1');
+INSERT INTO `tb_log` VALUES (466, '2021-06-24 09:55:59', '2021-06-24 09:55:59', 1, '烈士管理', '新增/修改', 0, '127.0.0.1');

+ 27 - 0
gis_admin/src/main/resources/db/资源表.csv

@@ -0,0 +1,27 @@
+id,name,resource_type,resource_key,sort,parent_id
+100,史馆场景管理,menu,scene,100,
+101,查看,button,scene:detail,101,100
+102,编辑,button,scene:edit,102,100
+103,删除,button,scene:remove,103,100
+200,精品典藏管理,menu,goods,200,
+210,模型管理,menu,goods:model,210,200
+211,提交,button,goods:model:edit,211,210
+212,编辑,button,goods:model:edit,212,210
+213,删除,button,goods:model:remove,213,210
+214,审核,button,goods:model:audit,214,210
+215,查看,button,goods:model:detail,215,210
+216,是否显示,button,goods:model:display,216,210
+220,视频管理,menu,goods:video,220,200
+221,提交,button,goods:video:edit,221,220
+222,编辑,button,goods:video:edit,222,220
+223,删除,button,goods:video:remove,223,220
+224,审核,button,goods:video:audit,224,220
+225,查看,button,goods:video:detail,225,220
+226,是否显示,button,goods:video:display,226,220
+230,图片管理,menu,goods:img,230,200
+231,提交,button,goods:img:edit,231,230
+232,编辑,button,goods:img:edit,232,230
+233,删除,button,goods:img:remove,233,230
+234,审核,button,goods:img:audit,234,230
+235,查看,button,goods:img:detail,235,230
+236,是否显示,button,goods:img:display,236,230

+ 37 - 0
gis_application/pom.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>wx_lvdao</artifactId>
+        <groupId>com.gis</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>gis_application</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.gis</groupId>
+            <artifactId>gis_admin</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.gis</groupId>
+            <artifactId>gis_cms</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+        <finalName>${parent.artifactId}</finalName>
+    </build>
+</project>

+ 14 - 0
gis_application/src/main/java/com/gis/GisApplication.java

@@ -0,0 +1,14 @@
+package com.gis;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+public class GisApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(GisApplication.class, args);
+    }
+
+}

+ 83 - 0
gis_application/src/main/resources/application-dev.properties

@@ -0,0 +1,83 @@
+
+#DB
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.druid.username=root
+spring.datasource.druid.url=jdbc:mysql://8.135.106.227:3306/${project.en}?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.password=4dkk2021testproject%
+
+
+# \u521D\u59CB\u8FDE\u63A5\u6570
+spring.datasource.druid.initial-size=5
+# \u6700\u5C0F\u8FDE\u63A5\u6C60\u6570\u91CF
+spring.datasource.druid.min-idle=10
+# \u6700\u5927\u8FDE\u63A5\u6C60\u6570\u91CF
+spring.datasource.druid.max-active=20
+# \u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4
+spring.datasource.druid.max-wait=60000
+# \u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95ED\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.time-between-eviction-runs-millis=60000
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.min-evictable-idle-time-millis=30000
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5927\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.max-evictable-idle-time-millis=90000
+# \u914D\u7F6E\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548
+spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
+spring.datasource.druid.test-while-idle=true
+spring.datasource.druid.test-on-borrow=false
+spring.datasource.druid.test-on-return=false
+spring.datasource.druid.web-stat-filter.enabled=true
+spring.datasource.druid.stat-view-servlet.enabled=true
+
+
+# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
+spring.redis.database=0
+spring.redis.host=127.0.0.1
+spring.redis.port=6379
+spring.redis.password=
+# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
+spring.redis.timeout=3000ms
+# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F8\u3002
+spring.redis.jedis.pool.max-idle=8
+#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F0\u3002
+spring.redis.jedis.pool.min-idle=0
+# \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
+spring.redis.jedis.pool.max-active=8
+# \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
+spring.redis.jedis.pool.max-wait=-1ms
+
+
+#log
+logging.file.path=E:/log/${project.en}_log
+logging.config=classpath:logback-spring.xml
+logging.level.com.gis=debug
+#logging.level.com.gis=info
+
+# file info
+server.file.path=E:\\data\\${project.en}_data
+
+# url info
+spring.mvc.static-path-pattern=/**
+### \u5339\u914D\u8DEF\u5F84\uFF0C \u6CE8\u610Ffile\u540E\u9762\u7684/ \uFF0Cwindows:\\  , linxu:\u5168\u8DEF\u5F84, \u4E0D\u9700\u8981\u7279\u522B\u52A0\u659C\u6760
+spring.resources.static-locations=file:\\${server.file.path}
+
+# swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8
+swagger.package=com.gis
+swagger.title=${project.sc}-dev
+swagger.description=${swagger.title}
+swagger.version=1.0
+
+# \u5FAE\u4FE1\u5C0F\u7A0B\u5E8F
+#\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684appid
+wx.miniapp.configs.appid=wx3047d1704b092c5e
+#\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684Secret
+wx.miniapp.configs.secret=0173b22d521cfa8b15a68ec795e4c52d
+wx.miniapp.configs.token=\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u6D88\u606F\u670D\u52A1\u5668\u914D\u7F6E\u7684token
+wx.miniapp.configs.aesKey=\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u6D88\u606F\u670D\u52A1\u5668\u914D\u7F6E\u7684EncodingAESKey
+wx.miniapp.configs.msgDataFormat=JSON
+
+
+
+
+
+

+ 79 - 0
gis_application/src/main/resources/application-pro.properties

@@ -0,0 +1,79 @@
+
+#DB
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.druid.username=root
+spring.datasource.druid.url=jdbc:mysql://pengcheng-mysql:3306/${project.en}?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.password=4dkk2021testproject%
+
+
+# \u521D\u59CB\u8FDE\u63A5\u6570
+spring.datasource.druid.initial-size=5
+# \u6700\u5C0F\u8FDE\u63A5\u6C60\u6570\u91CF
+spring.datasource.druid.min-idle=10
+# \u6700\u5927\u8FDE\u63A5\u6C60\u6570\u91CF
+spring.datasource.druid.max-active=20
+# \u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4
+spring.datasource.druid.max-wait=60000
+# \u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95ED\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.time-between-eviction-runs-millis=60000
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.min-evictable-idle-time-millis=30000
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5927\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.max-evictable-idle-time-millis=90000
+# \u914D\u7F6E\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548
+spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
+spring.datasource.druid.test-while-idle=true
+spring.datasource.druid.test-on-borrow=false
+spring.datasource.druid.test-on-return=false
+spring.datasource.druid.web-stat-filter.enabled=true
+spring.datasource.druid.stat-view-servlet.enabled=true
+
+
+# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
+spring.redis.database=0
+spring.redis.host=pengcheng-redis
+spring.redis.port=6379
+spring.redis.password=
+# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
+spring.redis.timeout=3000ms
+# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F8\u3002
+spring.redis.jedis.pool.max-idle=8
+#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F0\u3002
+spring.redis.jedis.pool.min-idle=0
+# \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
+spring.redis.jedis.pool.max-active=8
+# \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
+spring.redis.jedis.pool.max-wait=-1ms
+
+
+#log
+logging.file.path=/root/log/${project.en}_log
+logging.config=classpath:logback-spring.xml
+logging.level.com.gis=debug
+
+# file info
+server.file.path=/root/data/${project.en}_data
+#\u8BBF\u95EE\u57DF\u540D+\u7AEF\u53E3
+server.domain=
+
+#
+spring.mvc.static-path-pattern=/**
+### \u5339\u914D\u8DEF\u5F84\uFF0C \u6CE8\u610Ffile\u540E\u9762\u7684/ \uFF0Cwindows:\\  , linxu:\u5168\u8DEF\u5F84, \u4E0D\u9700\u8981\u7279\u522B\u52A0\u659C\u6760
+spring.resources.static-locations=file:${server.file.path}
+
+# swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8
+
+
+swagger.package=com.gis
+swagger.title=${project.sc}-sit
+swagger.description=${swagger.title}
+swagger.version=1.0
+
+#swagger login
+knife4j.basic.enable=true
+knife4j.basic.username=owen
+knife4j.basic.password=owen
+
+
+

+ 75 - 0
gis_application/src/main/resources/application-sit.properties

@@ -0,0 +1,75 @@
+
+#DB
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.druid.username=root
+spring.datasource.druid.url=jdbc:mysql://8.135.106.227:3306/${project.en}?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.password=4dkk2021testproject%
+
+
+# \u521D\u59CB\u8FDE\u63A5\u6570
+spring.datasource.druid.initial-size=5
+# \u6700\u5C0F\u8FDE\u63A5\u6C60\u6570\u91CF
+spring.datasource.druid.min-idle=10
+# \u6700\u5927\u8FDE\u63A5\u6C60\u6570\u91CF
+spring.datasource.druid.max-active=20
+# \u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4
+spring.datasource.druid.max-wait=60000
+# \u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95ED\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.time-between-eviction-runs-millis=60000
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.min-evictable-idle-time-millis=30000
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5927\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
+spring.datasource.druid.max-evictable-idle-time-millis=90000
+# \u914D\u7F6E\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548
+spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
+spring.datasource.druid.test-while-idle=true
+spring.datasource.druid.test-on-borrow=false
+spring.datasource.druid.test-on-return=false
+spring.datasource.druid.web-stat-filter.enabled=true
+spring.datasource.druid.stat-view-servlet.enabled=true
+
+
+# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
+spring.redis.database=0
+spring.redis.host=127.0.0.1
+spring.redis.port=6379
+spring.redis.password=
+# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
+spring.redis.timeout=3000ms
+# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F8\u3002
+spring.redis.jedis.pool.max-idle=8
+#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F0\u3002
+spring.redis.jedis.pool.min-idle=0
+# \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
+spring.redis.jedis.pool.max-active=8
+# \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
+spring.redis.jedis.pool.max-wait=-1ms
+
+
+#log
+logging.file.path=D:/log/${project.en}_log
+logging.config=classpath:logback-spring.xml
+logging.level.com.gis=debug
+
+# file info
+server.file.path=D:/data/${project.en}_data
+
+
+
+#
+spring.mvc.static-path-pattern=/**
+### \u5339\u914D\u8DEF\u5F84\uFF0C \u6CE8\u610Ffile\u540E\u9762\u7684/ \uFF0Cwindows:\\  , linxu:\u5168\u8DEF\u5F84, \u4E0D\u9700\u8981\u7279\u522B\u52A0\u659C\u6760
+spring.resources.static-locations=file:\\${server.file.path}
+
+# swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8
+swagger.package=com.gis
+swagger.title=${project.sc}-sit
+swagger.description=${swagger.title}
+swagger.version=1.0
+
+
+
+
+
+

+ 46 - 0
gis_application/src/main/resources/application.properties

@@ -0,0 +1,46 @@
+server.port=8005
+
+spring.profiles.active=dev
+
+# \u9879\u76EE\u540D\u79F0
+project.en=wx_lvdao
+project.sc=\u6A2A\u7434\u5F8B\u9053\u56DB\u671F-\u5FAE\u4FE1
+# redis token \u524D\u7F00
+redis.prefix=${project.en}:
+
+# \u5141\u8BB8\u4E0A\u4F20\u6587\u4EF6\u540E\u7F00
+server.file.allow=.jpg,.gif,.png,.ico,.bmp,.jpeg,.zip,.zp,.rar,.mp3,.mp4,.avi,.mov,.flv,.3gp,.rmvb,.4dage,.wav,.wma,.m4a,.obj,.pdf,.audio,.ppt,.pptx,.xls,.xlsx,.doc,.docx,.txt
+
+
+
+# \u8BBF\u95EE\u9759\u6001\u8D44\u6E90\u8BBE\u7F6E
+spring.resources.static-locations=classpath:templates/,classpath:static/,classpath:web/
+
+#\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F
+spring.servlet.multipart.enabled=true
+spring.servlet.multipart.max-file-size=2048MB
+spring.servlet.multipart.max-request-size=2048MB
+
+
+#\u5F00\u542Fsql\u65E5\u5FD7
+mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+# \u8BE5\u914D\u7F6E\u5C31\u662F\u5C06\u5E26\u6709\u4E0B\u5212\u7EBF\u7684\u8868\u5B57\u6BB5\u6620\u5C04\u4E3A\u9A7C\u5CF0\u683C\u5F0F\u7684\u5B9E\u4F53\u7C7B\u5C5E\u6027
+mybatis-plus.configuration.map-underscore-to-camel-case=true
+mybatis-plus.configuration.call-setters-on-nulls=true
+# \u903B\u8F91\u5220\u9664\u8BBE\u7F6E
+mybatis-plus.global-config.db-config.logic-delete-value=1
+mybatis-plus.global-config.db-config.logic-not-delete-value=0
+mybatis-plus.global-config.db-config.logic-delete-field = isDelete
+mybatis-plus.mapper-locations=classpath*:/mybatis/mappers/**.xml
+
+
+
+
+
+
+
+
+
+
+
+

BIN
gis_application/src/main/resources/data/律道四期题目内容模板.xlsx


+ 156 - 0
gis_application/src/main/resources/logback-spring.xml

@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <property name="LOG_MAX_HISTORY" value="180"/>
+    <springProperty scope="context" name="LOG_PATH" source="logging.path"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
+            <pattern>${LOG_PATH}/%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{TRACE_ID} %-5level %logger{50} - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+    </appender>
+    <!-- 按照每天生成日志文件:主项目日志 -->
+    <appender name="file.all" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 追加日志到原文件结尾 -->
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 -->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{TRACE_ID} %-5level %logger{500} - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+    </appender>
+
+    <!--info日志统一输出到这里-->
+    <appender name="file.info" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 每小时生成日志文件 -->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/info/console-info.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{TRACE_ID} %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录info级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--错误日志统一输出到这里-->
+    <appender name="file.error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名-->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/error/console-error.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{TRACE_ID} %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录error级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--warn日志统一输出到这里-->
+    <appender name="file.warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 按小时生成日志-->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/warn/console-warn.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- 除按日志记录之外,还配置了日志文件不能超过10M(默认),若超过10M,日志文件会以索引0开始, -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{TRACE_ID} %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录warn级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>WARN</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--debug级别日志统一输出到这里-->
+    <appender name="file.debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <Prudent>true</Prudent>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名 按小时生成日志-->
+            <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}/debug/console-debug.%d{yyyy-MM-dd-HH}.%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
+            <!-- 除按日志记录之外,还配置了日志文件不能超过5M,若超过5M,日志文件会以索引0开始,命名日志文件,例如console-debug.2018-08-24-09.1.log -->
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %method 方法名  %L 行数 %msg:日志消息,%n是换行符-->
+            <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %X{TRACE_ID} %-5level %logger{56}.%method:%L - %msg%n</pattern>
+            <!--<charset>utf-8</charset>-->
+        </encoder>
+        <!-- 此日志文件只记录debug级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>DEBUG</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY </onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
+    <appender name="file.async" class="ch.qos.logback.classic.AsyncAppender">
+        <discardingThreshold>0</discardingThreshold>
+        <queueSize>256</queueSize>
+        <includeCallerData>true</includeCallerData>
+        <appender-ref ref="file.all" />
+    </appender>
+
+    <!--  日志输出级别 -->
+    <!-- TRACE\DEBUG\INFO\WARN\ERROR\FATAL\OFF -->
+    <root level="INFO">
+        <appender-ref ref="console" />
+        <appender-ref ref="file.async"/>
+        <appender-ref ref="file.error" />
+        <appender-ref ref="file.info" />
+        <appender-ref ref="file.debug" />
+        <appender-ref ref="file.warn" />
+    </root>
+
+</configuration>

+ 11 - 0
gis_application/src/main/resources/sh/shutdown.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+RESOURCE_NAME=army_chongqing_college.jar
+   Pid=`awk '{print $1}' tpid`
+
+if [ ${Pid} ]; then
+kill -9 $Pid
+echo 'Kill Process!'
+else
+echo 'Stop failed!'
+fi
+

+ 123 - 0
gis_application/src/main/resources/sh/startJar.sh

@@ -0,0 +1,123 @@
+APP_NAME=
+APP_DEBUG=
+
+usage() {
+    echo "case: sh run.sh [start|stop|restart|status]"
+    echo "请类似这样执行 ./*.sh start   or  ./*sh restart"
+    exit 1
+}
+
+checkEnv(){
+      if [ -z "${APP_NAME}" ] || [ -z "${APP_DEBUG}" ]; then #判断pid是否为空
+           if [[ $1 = 'prod' ]];   then
+                        echo "prod start"
+                        APP_NAME=changeing-prod.jar
+                        APP_DEBUG=5526
+                      elif  [[ $1 = 'uat' ]] ; then
+                        echo "uat start"
+                        APP_NAME=changeing-uat.jar
+                        APP_DEBUG=5520
+                      elif  [[ $1 = 'devuat' ]] ; then
+                        echo "devuat start"
+                        APP_NAME=changeing-devuat.jar
+                        APP_DEBUG=5526
+                      else
+                        echo "没有设置环境"
+            fi
+     # else
+         #    echo "已经设置-${APP_NAME}-${APP_DEBUG}"
+     fi
+}
+
+# 判断当前服务是否已经启动的函数
+is_exist(){
+    checkEnv $1
+    pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' ` #根据ps 命令查询当前服务的进程号 赋值给pid"
+    if [ -z "${pid}" ]; then #判断pid是否为空
+        echo "pid 不存在"
+        return 1
+    else
+        echo "pid 存在"
+        return 0
+    fi
+}
+
+
+start(){
+    checkEnv $1
+    is_exist
+    if [ $? -eq "0" ]; then    # [$? -eq "0"] 说明pid不等于空 说明服务正在运行中,将进程号打印出来
+        echo "${APP_NAME} running. pid=${pid}"
+    else
+        nohup java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${APP_DEBUG} $APP_NAME > logs.log 2>error.log &  # 说明pid为空
+        # 执行java -jar 命令启动服务
+        echo "${APP_NAME} started启动"
+    fi
+}
+
+
+stop(){
+    echo "执行 stop 方法"
+    checkEnv $1
+    is_exist
+    if [ $? -eq "0" ]; then    # [$? -eq "0"] 说明pid不等于空 说明服务正在运行中,将进程号杀死
+        kill -9 $pid
+        echo "${pid} stopped-停止"
+    else
+        echo "${APP_NAME} 没有运行"
+    fi
+}
+
+
+status(){
+    echo "执行 status 方法"
+    checkEnv $1
+    is_exist
+    if [ $? -eq "0" ]; then
+        echo "${APP_NAME} running-启动. Pid is ${pid}"
+    else
+        echo "${APP_NAME} 没有运行"
+    fi
+}
+
+
+# 重启命令其实就是先执行关闭命令 再执行重启命令
+restart(){
+        echo "执行 restart 方法"
+        checkEnv $1
+        is_exist
+        if [ $? -eq "0" ]; then    # [$? -eq "0"] 说明pid不等于空 说明服务正在运行中,将进程号杀死
+            kill -9 $pid
+            echo "${pid} stopped-停止"
+        else
+            echo "${APP_NAME} 没有运行"
+        fi
+        sleep 5
+        is_exist
+        if [ $? -eq "0" ]; then    # [$? -eq "0"] 说明pid不等于空 说明服务正在运行中,将进程号打印出来
+            echo "${APP_NAME} running. pid=${pid}"
+        else
+            nohup java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${APP_DEBUG} $APP_NAME > logs.log 2>error.log &  # 说明pid为空 执行java -jar 命令启动服务
+            echo "${APP_NAME} started启动"
+        fi
+}
+
+
+# 这里的$1 取的是当前输入命令 的第二个参数 ./start.sh start
+case "$1" in
+    "start")
+        start $2
+        ;;
+    "stop")
+        stop $2
+        ;;
+    "status")
+        status $2
+        ;;
+    "restart")
+        restart $2
+        ;;
+    *)
+    usage
+    ;;
+esac

+ 11 - 0
gis_application/src/main/resources/sh/startup.sh

@@ -0,0 +1,11 @@
+#!/bin/sh
+RESOURCE_NAME=army_chongqing_college.jar
+APP_DEBUG=5005
+rm -f tpid
+nohup java -jar -Xmx3072M -Xms512M ./$RESOURCE_NAME --spring.profiles.active=sit --server.port=8005 & echo $! > tpid
+echo Start Success!
+
+
+
+
+

+ 26 - 0
gis_cms/pom.xml

@@ -0,0 +1,26 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>wx_lvdao</artifactId>
+        <groupId>com.gis</groupId>
+        <version>1.0.0</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>gis_cms</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.gis</groupId>
+            <artifactId>gis_admin</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+
+
+
+</project>

+ 56 - 0
gis_cms/src/main/java/com/gis/cms/controller/MyController.java

@@ -0,0 +1,56 @@
+package com.gis.cms.controller;
+
+import com.gis.cms.entity.dto.RoomDto;
+import com.gis.cms.entity.dto.RoomListDto;
+import com.gis.cms.entity.dto.ScoreDto;
+import com.gis.cms.service.GameLogService;
+import com.gis.cms.service.RoomService;
+import com.gis.common.base.aop.WebControllerLog;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * Created by owen on 2022/2/22 0008 9:54
+ */
+@Api(tags = "我的管理")
+@RestController
+@RequestMapping("/cms/my")
+public class MyController {
+
+    @Autowired
+    GameLogService entityService;
+
+
+    @ApiOperation(value = "记录列表", notes = "时间:yyyy-MM-dd 天")
+    @PostMapping("/list")
+    public Result list(String date) {
+        return entityService.list(date);
+    }
+
+
+    @ApiOperation("详情(房间用户排名)")
+    @GetMapping("/detail/{roomId}")
+    public Result detail(@PathVariable Long roomId) {
+        return entityService.detail(roomId);
+    }
+
+
+    @WebControllerLog(description = "我的-保存得分", addDb = true)
+    @ApiOperation(value = "保存得分")
+    @GetMapping("/saveScore")
+    public Result saveScore(@Valid @RequestBody ScoreDto param) {
+        return entityService.saveScore(param);
+    }
+
+
+
+
+
+
+
+}

+ 58 - 0
gis_cms/src/main/java/com/gis/cms/controller/QuestionController.java

@@ -0,0 +1,58 @@
+package com.gis.cms.controller;
+
+import com.gis.cms.entity.dto.ScoreDto;
+import com.gis.cms.entity.po.QuestionEntity;
+import com.gis.cms.service.GameLogService;
+import com.gis.cms.service.QuestionService;
+import com.gis.common.base.aop.WebControllerLog;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.transaction.Transactional;
+import javax.validation.Valid;
+
+/**
+ * Created by owen on 2022/2/22 0008 9:54
+ */
+@Api(tags = "问题管理")
+@RestController
+@RequestMapping("/cms/question")
+public class QuestionController {
+
+    @Autowired
+    QuestionService entityService;
+
+
+    @Transactional
+    @ApiOperation(value = "导入题目", notes = "excel格式后缀必须为xlsx")
+    @PostMapping("/uploadExcel")
+    public Result uploadExcel(MultipartFile file) {
+        return entityService.uploadExcel(file);
+    }
+
+
+    @ApiOperation(value = "随机获取题目", notes = "type:题目类型,1 2 3, num:题目数量")
+    @GetMapping("/list/{type}/{num}")
+    public Result<QuestionEntity> list(@PathVariable Integer type, @PathVariable Integer num) {
+        return entityService.list(type, num);
+    }
+
+
+//    @WebControllerLog(description = "我的-保存得分", addDb = true)
+//    @ApiOperation(value = "保存得分")
+//    @GetMapping("/saveScore")
+//    public Result saveScore(@Valid @RequestBody ScoreDto param) {
+//        return entityService.saveScore(param);
+//    }
+
+
+
+
+
+
+
+}

+ 69 - 0
gis_cms/src/main/java/com/gis/cms/controller/RoomController.java

@@ -0,0 +1,69 @@
+package com.gis.cms.controller;
+
+import com.gis.cms.entity.dto.RoomDto;
+import com.gis.cms.entity.dto.RoomListDto;
+import com.gis.cms.entity.dto.ScoreDto;
+import com.gis.cms.service.GameLogService;
+import com.gis.cms.service.RoomService;
+import com.gis.common.base.aop.WebControllerLog;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * Created by owen on 2022/2/22 0008 9:54
+ */
+@Api(tags = "房间管理")
+@RestController
+@RequestMapping("/cms/room")
+public class RoomController {
+
+    @Autowired
+    RoomService entityService;
+
+    @ApiOperation(value = "列表", notes = "时间:7/14/30 天")
+    @PostMapping("/list")
+    public Result list(@RequestBody RoomListDto param) {
+        return entityService.search(param);
+    }
+
+    @ApiOperation("删除")
+    @GetMapping("/remove/{id}")
+    public Result remove(@PathVariable Long id) {
+        return Result.success(entityService.removeById(id));
+    }
+
+    @WebControllerLog(description = "房间管理-新增/编辑", addDb = true)
+    @ApiOperation(value = "新增/编辑")
+    @PostMapping("/save")
+    public Result save(@Valid @RequestBody RoomDto param) {
+        return entityService.saveEntity(param);
+    }
+
+
+    @ApiOperation("详情")
+    @GetMapping("/detail/{id}")
+    public Result detail(@PathVariable Long id) {
+        return entityService.detail(id);
+    }
+
+    @WebControllerLog(description = "房间管理-加入房间", addDb = true)
+    @ApiOperation(value = "加入房间", notes = "使用房间创建者id, 这里不一定知道房间号")
+    @GetMapping("/join/{code}/{creatorId}")
+    public Result join(@PathVariable String code, @PathVariable Long creatorId) {
+        return entityService.join(code, creatorId);
+    }
+
+
+
+
+
+
+
+
+
+}

+ 40 - 0
gis_cms/src/main/java/com/gis/cms/controller/TestController.java

@@ -0,0 +1,40 @@
+package com.gis.cms.controller;
+
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.gis.cms.entity.po.RoomEntity;
+import com.gis.cms.service.RoomService;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDateTime;
+
+/**
+ * Created by owen on 2022/2/23 0023 11:30
+ */
+@Slf4j
+@Api(tags = "test-测试相关")
+@RestController
+@RequestMapping("test")
+public class TestController {
+
+    @Autowired
+    RoomService roomService;
+
+    @GetMapping("updateWrapper/{status}")
+    public Result updateWrapper(@PathVariable Integer status){
+        LambdaUpdateWrapper<RoomEntity> ew = new LambdaUpdateWrapper<>();
+        ew.set(RoomEntity::getStatus, 0)
+                .eq(RoomEntity::getStatus,status)
+                .le(RoomEntity::getEndTime, LocalDateTime.now()); // le: 小于等于<= 当前时间
+
+        roomService.update(ew);
+
+        return Result.success();
+    }
+}

+ 20 - 0
gis_cms/src/main/java/com/gis/cms/entity/dto/RoomDto.java

@@ -0,0 +1,20 @@
+package com.gis.cms.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotBlank;
+
+
+/**
+ * Created by owen on 2022/2/22 0022 15:39
+ */
+public class RoomDto {
+
+    @NotBlank(message = "口令不能为空")
+    @ApiModelProperty(value = "口令", required = true)
+    private String code;
+
+    @NotBlank(message = "结束时间不能为空")
+    @ApiModelProperty(value = "结束时间, yyyy-mm-dd hh:mm", required = true)
+    private String endTime;
+}

+ 24 - 0
gis_cms/src/main/java/com/gis/cms/entity/dto/RoomListDto.java

@@ -0,0 +1,24 @@
+package com.gis.cms.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+
+/**
+ * Created by owen on 2022/2/22 0022 15:39
+ */
+@Data
+public class RoomListDto {
+
+    @NotBlank(message = "时间不能为空")
+    @ApiModelProperty(value = "时间,7/14/30 天", required = true)
+    private Integer date;
+
+    @ApiModelProperty(value = "是否结束, 1:已结束")
+    private Integer isClose;
+
+    @ApiModelProperty(value = "是否参与, 1:我参与")
+    private Integer isJoin;
+}

+ 27 - 0
gis_cms/src/main/java/com/gis/cms/entity/dto/ScoreDto.java

@@ -0,0 +1,27 @@
+package com.gis.cms.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+
+/**
+ * Created by owen on 2022/2/22 0022 15:39
+ * 得分
+ */
+@Data
+public class ScoreDto {
+
+    @ApiModelProperty(value = "房间id(为空代表普通模式)")
+    private Long roomId;
+
+    @NotBlank(message = "得分不能为空")
+    @ApiModelProperty(value = "得分", required = true)
+    private String score;
+
+    @NotNull(message = "耗时不能为空")
+    @ApiModelProperty(value = "耗时,单位秒", required = true)
+    private Integer time;
+}

+ 19 - 0
gis_cms/src/main/java/com/gis/cms/entity/dto/SortPageDto.java

@@ -0,0 +1,19 @@
+package com.gis.cms.entity.dto;
+
+import com.gis.common.base.entity.dto.PageDateDto;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2021/12/28 0008 14:34
+ */
+@Data
+public class SortPageDto extends PageDateDto {
+
+    @ApiModelProperty(value = "排序类型:0:发布时间, 1:序号")
+    private Integer sortType;
+
+    @ApiModelProperty(value = "显示:0:不显示,1:显示", notes = "后端使用")
+    private Integer display;
+
+}

+ 46 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/FileEntity.java

@@ -0,0 +1,46 @@
+package com.gis.cms.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Table;
+
+/**
+ * Created by owen on 2021/4/20 0010 17:39
+ * 文件表
+ */
+@Data
+@TableName(value = "tb_file")
+public class FileEntity extends BaseEntity {
+
+    @ApiModelProperty(value = "名称" )
+    private String name;
+
+    @ApiModelProperty(value = "模块:goods:文物")
+    private String module;
+
+
+    @ApiModelProperty(value = "文件地址")
+    private String filePath;
+//
+//    @ApiModelProperty(value = "文件名")
+//    private String fileName;
+
+
+//    @ApiModelProperty(value = "ossURL")
+//    private String ossUrl;
+
+    @ApiModelProperty(value = "封面, 1:是, 0:否")
+    private Integer isIndex;
+
+    @ApiModelProperty(value = "模块id")
+    private Long moduleId;
+
+
+
+
+
+
+}

+ 42 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/GameLogEntity.java

@@ -0,0 +1,42 @@
+package com.gis.cms.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 游戏记录表
+ */
+@Data
+@TableName(value = "tb_game_log")
+public class GameLogEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = 5607470635760371372L;
+
+    @ApiModelProperty(value = "模式, 活动:activity , 普通:general")
+    private String type;
+
+    @ApiModelProperty(value = "得分")
+    private Integer score;
+
+//    @ApiModelProperty(value = "用户id(参与该房间用户)")
+//    private Long userId;
+
+    @ApiModelProperty(value = "房间id")
+    private Long roomId;
+
+    @ApiModelProperty(value = "耗时:单位秒")
+    private Integer time;
+
+
+
+
+
+
+
+}

+ 36 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/QuestionEntity.java

@@ -0,0 +1,36 @@
+package com.gis.cms.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Created by owen on 2022/4/12 0012 15:06
+ */
+@Data
+@TableName(value = "tb_question")
+public class QuestionEntity extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = -8341343348218066942L;
+
+    @ApiModelProperty(value = "题目" )
+    private String question;
+
+    @ApiModelProperty(value = "答案" )
+    private String answer;
+
+    @ApiModelProperty(value = "正确答案" )
+    private String correct;
+
+    @ApiModelProperty(value = "图片" )
+    private String img;
+
+    @ApiModelProperty(value = "排序" )
+    private Integer sort;
+
+    @ApiModelProperty(value = "题目类型" )
+    private Integer type;
+}

+ 55 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/RoomEntity.java

@@ -0,0 +1,55 @@
+package com.gis.cms.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 房间表
+ */
+@Data
+@TableName(value = "tb_room")
+public class RoomEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = 5607470635760371372L;
+
+    @ApiModelProperty(value = "口令")
+    private String code;
+
+    @ApiModelProperty(value = "结束时间")
+    private LocalDateTime endTime;
+
+    @ApiModelProperty(value = "状态:1:结束, 0:进行中")
+    private Integer status;
+
+    @TableField(exist  = false)
+    @ApiModelProperty(value = "参与者")
+    private Integer count;
+
+    @TableField(exist  = false)
+    @ApiModelProperty(value = "总分")
+    private Integer scoreTotal;
+
+    @TableField(exist  = false)
+    @ApiModelProperty(value = "状态:1:结束, 0:进行中")
+    private Integer statusVo;
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 24 - 0
gis_cms/src/main/java/com/gis/cms/entity/vo/WxUserVo.java

@@ -0,0 +1,24 @@
+package com.gis.cms.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2022/2/24 0024 20:26
+ */
+@Data
+public class WxUserVo {
+
+    @ApiModelProperty(value = "得分")
+    private Integer score;
+
+    @ApiModelProperty(value = "用户id")
+    private Long creatorId;
+
+    @ApiModelProperty(value = "微信昵称")
+    private String nickName;
+
+    @ApiModelProperty(value = "耗时")
+    private Integer time;
+
+}

+ 35 - 0
gis_cms/src/main/java/com/gis/cms/mapper/FileMapper.java

@@ -0,0 +1,35 @@
+package com.gis.cms.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.FileEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Component
+@Mapper
+public interface FileMapper extends BaseMapper<FileEntity> {
+
+    @Update("update tb_file set is_index = 1 , update_time = NOW() where is_delete = 0 and id = #{fileId} ")
+    void indexEnabled(Long fileId);
+
+    @Update("update tb_file set is_index = 0 , update_time = NOW() where is_delete = 0 and is_index = 1 and module = #{module} and module_id = #{moduleId}")
+    void indexDisable(Long moduleId, String module);
+
+//    @Update("update tb_file set module_id = #{moduleId} , update_time = NOW() where is_delete = 0 and module = #{module} and id in ( ${fileIds} )")
+//    void addModuleIdToFile(String fileIds, Long moduleId, String module);
+
+    @Select("select * from tb_file where is_delete = 0 and is_index = 1 and module = #{module} and module_id = #{moduleId} limit 1")
+    List<FileEntity> findIndexByModule(Long moduleId, String module);
+
+    @Select("select * from tb_file where is_delete = 0 and module = #{module} and module_id = #{moduleId} ")
+    List<FileEntity> findByModuleId(Long moduleId, String module);
+
+    @Update("update tb_file set module_id = #{moduleId} , update_time = NOW() where is_delete = 0 and module = #{module} and id in ( ${fileIds} )")
+    void bindingModuleId(String fileIds, Long moduleId, String module);
+}

+ 21 - 0
gis_cms/src/main/java/com/gis/cms/mapper/GameLogMapper.java

@@ -0,0 +1,21 @@
+package com.gis.cms.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.GameLogEntity;
+import com.gis.cms.entity.po.RoomEntity;
+import com.gis.cms.entity.vo.WxUserVo;
+import com.gis.common.base.mapper.provider.BaseProvider;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+@Mapper
+public interface GameLogMapper extends BaseMapper<GameLogEntity> {
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    Integer sumSql(String sqlStr);
+}

+ 24 - 0
gis_cms/src/main/java/com/gis/cms/mapper/QuestionMapper.java

@@ -0,0 +1,24 @@
+package com.gis.cms.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.GameLogEntity;
+import com.gis.cms.entity.po.QuestionEntity;
+import com.gis.common.base.mapper.provider.BaseProvider;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+@Mapper
+public interface QuestionMapper extends BaseMapper<QuestionEntity> {
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    void truncateTable(String sqlStr);
+
+    @Select("select id from tb_question where is_delete=0 and type=#{type}")
+    List<Long> getIdsByType(Integer type);
+}

+ 27 - 0
gis_cms/src/main/java/com/gis/cms/mapper/RoomMapper.java

@@ -0,0 +1,27 @@
+package com.gis.cms.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.RoomEntity;
+import com.gis.cms.entity.vo.WxUserVo;
+import com.gis.common.base.mapper.provider.BaseProvider;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+@Mapper
+public interface RoomMapper extends BaseMapper<RoomEntity> {
+
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    List<RoomEntity> selectList(String sql);
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    RoomEntity selectEntity(String toString);
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    List<WxUserVo> selectWxUserVo(String toString);
+}

+ 32 - 0
gis_cms/src/main/java/com/gis/cms/service/FileService.java

@@ -0,0 +1,32 @@
+package com.gis.cms.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.po.FileEntity;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:14
+ */
+public interface FileService extends IService<FileEntity> {
+
+
+    void indexDisable(Long moduleId, String module);
+
+    void indexEnabled(Long fileId);
+
+//    void addModuleIdToFile(String fileIds, Long moduleId, String module);
+
+//    List<FileEntity> findIndexByModule(Long moduleId, String module);
+
+
+    List<FileEntity> findByModuleId(Long moduleId, String module);
+
+    Map<String, Object> upload(MultipartFile file, String dir);
+
+    void bindingModuleId(Long moduleId, String ids, String module);
+}

+ 24 - 0
gis_cms/src/main/java/com/gis/cms/service/GameLogService.java

@@ -0,0 +1,24 @@
+package com.gis.cms.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.dto.RoomDto;
+import com.gis.cms.entity.dto.RoomListDto;
+import com.gis.cms.entity.dto.ScoreDto;
+import com.gis.cms.entity.po.GameLogEntity;
+import com.gis.cms.entity.po.RoomEntity;
+import com.gis.common.util.Result;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:14
+ */
+public interface GameLogService extends IService<GameLogEntity> {
+
+
+    Result saveScore(ScoreDto param);
+
+    Result list(String date);
+
+    Result detail(Long roomId);
+}

+ 19 - 0
gis_cms/src/main/java/com/gis/cms/service/QuestionService.java

@@ -0,0 +1,19 @@
+package com.gis.cms.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.po.QuestionEntity;
+import com.gis.common.util.Result;
+import org.springframework.web.multipart.MultipartFile;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:14
+ */
+public interface QuestionService extends IService<QuestionEntity> {
+
+
+    Result uploadExcel(MultipartFile date);
+
+    Result<QuestionEntity> list(Integer type, int num);
+}

+ 29 - 0
gis_cms/src/main/java/com/gis/cms/service/RoomService.java

@@ -0,0 +1,29 @@
+package com.gis.cms.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.dto.RoomDto;
+import com.gis.cms.entity.dto.RoomListDto;
+import com.gis.cms.entity.po.RoomEntity;
+import com.gis.cms.entity.vo.WxUserVo;
+import com.gis.common.util.Result;
+
+import java.util.List;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:14
+ */
+public interface RoomService extends IService<RoomEntity> {
+
+
+    Result saveEntity(RoomDto param);
+
+    Result join(String code, Long creatorId);
+
+    Result search(RoomListDto param);
+
+    Result detail(Long id);
+
+    List<WxUserVo> ranking(Long roomId);
+}

+ 81 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/FileServiceImpl.java

@@ -0,0 +1,81 @@
+package com.gis.cms.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.cms.entity.po.FileEntity;
+import com.gis.cms.mapper.FileMapper;
+import com.gis.cms.service.FileService;
+import com.gis.common.util.FileUtils;
+import com.gis.common.util.RegexUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Created by owen on 2021/6/21 0011 16:16
+ */
+@Slf4j
+@Service
+public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntity> implements FileService {
+
+
+
+    @Autowired
+    FileUtils fileUtils;
+
+
+    @Override
+    public void indexDisable(Long moduleId, String module) {
+        getBaseMapper().indexDisable(moduleId, module);
+
+    }
+
+    @Override
+    public void indexEnabled(Long fileId) {
+        getBaseMapper().indexEnabled(fileId);
+    }
+
+//    @Override
+//    public void addModuleIdToFile(String fileIds, Long moduleId, String module) {
+//        if (StringUtils.isBlank(fileIds)) {
+//            return;
+//        }
+//        // 去除特殊符号,防止sql注入
+//        fileIds = RegexUtil.specificSymbol(fileIds);
+//        getBaseMapper().addModuleIdToFile(fileIds, moduleId, module);
+//    }
+
+//    @Override
+//    public List<FileEntity> findIndexByModule(Long moduleId, String module) {
+//        return getBaseMapper().findIndexByModule(moduleId, module);
+//    }
+
+    @Override
+    public List<FileEntity> findByModuleId(Long moduleId, String module) {
+        return getBaseMapper().findByModuleId(moduleId, module);
+    }
+
+
+    @Override
+    public Map<String, Object>  upload(MultipartFile file, String dir) {
+        Map<String, Object> map = fileUtils.uploadMap(file, dir, false);
+        return map;
+    }
+
+    @Override
+    public void bindingModuleId(Long moduleId, String fileIds, String module) {
+        if (StringUtils.isBlank(fileIds)) {
+            return;
+        }
+        // 去除特殊符号,防止sql注入
+        fileIds = RegexUtil.specificSymbol(fileIds);
+        // 去除特殊符号,防止sql注入
+        getBaseMapper().bindingModuleId(fileIds, moduleId, module);
+    }
+
+}

+ 105 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/GameLogServiceImpl.java

@@ -0,0 +1,105 @@
+package com.gis.cms.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.admin.entity.po.WxUserEntity;
+import com.gis.admin.service.WxUserService;
+import com.gis.cms.entity.dto.ScoreDto;
+import com.gis.cms.entity.po.GameLogEntity;
+import com.gis.cms.mapper.GameLogMapper;
+import com.gis.cms.service.GameLogService;
+import com.gis.cms.service.RoomService;
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.base.service.IBaseService;
+import com.gis.common.constant.ErrorEnum;
+import com.gis.common.util.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:16
+ */
+@Slf4j
+@Service
+public class GameLogServiceImpl extends ServiceImpl<GameLogMapper, GameLogEntity> implements GameLogService {
+
+    @Autowired
+    WxUserService wxUserService;
+
+    @Autowired
+    IBaseService iBaseService;
+
+    @Autowired
+    RoomService roomService;
+
+    @Override
+    public Result saveScore(ScoreDto param) {
+        Long roomId = param.getRoomId();
+        // 模式, 活动:activity , 普通:general
+        String type = "activity";
+        if (roomId == null){
+            type = "general";
+        }
+        GameLogEntity entity = new GameLogEntity();
+        BeanUtils.copyProperties(param, entity);
+        entity.setType(type);
+        entity.setCreatorId(iBaseService.getUserId());
+        this.save(entity);
+        return Result.success();
+    }
+
+    @Override
+    public Result list(String date) {
+        Long userId = iBaseService.getUserId();
+        HashMap<Object, Object> map = new HashMap<>();
+        map.put("user", getWxUser(userId));
+        map.put("list", getList(date, userId));
+        return Result.success(map);
+    }
+
+    @Override
+    public Result detail(Long roomId) {
+        Long userId = iBaseService.getUserId();
+        HashMap<Object, Object> map = new HashMap<>();
+        map.put("user", getWxUser(userId));
+        map.put("ranking", roomService.ranking(roomId));
+
+        return Result.success(map);
+    }
+
+    private WxUserEntity getWxUser(Long userId){
+        WxUserEntity entity = wxUserService.getById(userId);
+        BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
+        // 统计得分
+        entity.setScore(countScore(userId));
+        return entity;
+    }
+
+    // 统计得分
+    private Integer countScore(Long userId){
+        String sqlStr = StrUtil.format("select sum(score) from tb_game_log where is_delete=0 and creator_id={}", userId);
+        return getBaseMapper().sumSql(sqlStr);
+    }
+
+    private List<GameLogEntity>  getList(String date, Long userId){
+            LambdaQueryWrapper<GameLogEntity> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(GameLogEntity::getCreatorId, userId);
+            if (StringUtils.isNotBlank(date)){
+                // 写入拼接sql
+                wrapper.apply(StrUtil.format("DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT('{}' , '%Y%m' )", date));
+            }
+            wrapper.orderByDesc(GameLogEntity::getCreateTime);
+            return this.list(wrapper);
+
+    }
+
+
+}

+ 179 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/QuestionServiceImpl.java

@@ -0,0 +1,179 @@
+package com.gis.cms.service.impl;
+
+import cn.hutool.core.util.RandomUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.cms.entity.po.QuestionEntity;
+import com.gis.cms.mapper.QuestionMapper;
+import com.gis.cms.service.QuestionService;
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.base.service.IBaseService;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.util.ExcelUtils;
+import com.gis.common.util.FileUtils;
+import com.gis.common.util.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.*;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:16
+ */
+@Slf4j
+@Service
+public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, QuestionEntity> implements QuestionService {
+
+    @Autowired
+    IBaseService iBaseService;
+
+    @Autowired
+    FileUtils fileUtils;
+
+    @Autowired
+    ConfigConstant configConstant;
+
+
+    @Override
+    public Result uploadExcel(MultipartFile file) {
+        Map<String, Object> uploadMap = fileUtils.uploadMap(file, "/excel", false);
+        List<QuestionEntity> list = parseExcel(uploadMap.get("filePath").toString());
+
+        // 清空问题表
+        getBaseMapper().truncateTable("TRUNCATE tb_question");
+        log.info("清空旧数据完成");
+        this.saveBatch(list);
+        log.info("问题更新完成");
+
+        return Result.success();
+    }
+
+    @Override
+    public Result<QuestionEntity> list(Integer type, int size) {
+        // 获取所有题目id
+        List<Long> ids = getIdsByType(type);
+
+        BaseRuntimeException.isExist(size> ids.size(), null, "请求数量大于题库数量");
+        //要随机取的元素个数
+        Random random = new Random();
+
+        // 定义一个跟all一样长的数字,默认为false, 用来防重的
+        boolean r[]=new boolean[ids.size()];
+
+        // 记录结果数量
+        int n = 0;
+
+        // 结果集
+        List<QuestionEntity> result = new ArrayList<>();
+        // 题目集合
+        HashMap<Object, Object> questionMap = findByType(type);
+        while (true) {
+            int temp = random.nextInt(ids.size());
+            if (n >= size) {
+                break;
+            }
+            if(!r[temp]){
+
+                result.add((QuestionEntity)questionMap.get(ids.get(temp)));
+                // System.out.println("得到的第" + n +"个随du机数为:" + temp + " rTemp:"+r[temp] );
+                n ++;
+                // 修改下标值
+                r[temp] = true;
+            }
+
+        }
+        return Result.success(result);
+    }
+
+
+    private List<Long> getIdsByType(Integer type){
+        return getBaseMapper().getIdsByType(type);
+    }
+
+    private  HashMap<Object, Object> findByType(Integer type){
+        LambdaQueryWrapper<QuestionEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(QuestionEntity::getType, type);
+        List<QuestionEntity> list = this.list(wrapper);
+        HashMap<Object, Object> result = new HashMap<>();
+        for (QuestionEntity entity : list) {
+            result.put(entity.getId(), entity);
+        }
+        return result;
+    }
+
+    /**
+     * 解决excel数据并保存数据库
+     *
+     * @param filePath 相对路径
+     * @return
+     */
+    private List<QuestionEntity> parseExcel(String filePath) {
+        // 读取excel数据
+        String excelPath = configConstant.serverBasePath + filePath;
+        // 读取每一行
+        List<List<Object>> rows = ExcelUtils.readExcel(excelPath);
+        QuestionEntity question ;
+
+        List<String> standard = Arrays.asList("A", "B", "C", "D");
+
+
+        ArrayList<QuestionEntity> result = new ArrayList<>();
+        for (int i = 1; i < rows.size(); i++) {
+            question = new QuestionEntity();
+            List<Object> row = rows.get(i);
+
+            String correct =(String) row.get(3);
+            correct = correct.toUpperCase();
+            if (!standard.contains(correct)){
+                String errorMsg = StrUtil.format("第{}行答案选项有误, 错误值为:{}", i, correct);
+                log.error(errorMsg);
+                BaseRuntimeException.getExc(null, errorMsg);
+            }
+            JSONObject answerMapper = answerMapper(row, correct);
+            // 加密后的正确答案
+            String correctStr = answerMapper.getString("correct");
+            // 删除临时值
+            answerMapper.remove("correct");
+
+            question.setType(Integer.valueOf(row.get(0).toString()));
+            question.setImg((String)row.get(1));
+            question.setQuestion((String)row.get(2));
+            question.setCorrect(correctStr);
+            question.setAnswer(answerMapper.toJSONString());
+            result.add(question);
+
+        }
+        log.info("excel数据解析完成");
+        return result;
+
+        
+    }
+
+    // 存ABCD key使用
+    private JSONObject answerMapper(List<Object> row, String correct){
+        JSONObject baseMap = new JSONObject();
+        baseMap.put("A",  RandomUtil.randomString(8));
+        baseMap.put("B",  RandomUtil.randomString(8));
+        baseMap.put("C",  RandomUtil.randomString(8));
+        baseMap.put("D",  RandomUtil.randomString(8));
+
+        JSONObject answerMap = new JSONObject();
+        String answerA = (String)row.get(4);
+        String answerB = (String)row.get(5);
+        String answerC = (String)row.get(6);
+        String answerD = (String)row.get(7);
+        answerMap.put(baseMap.getString("A"), answerA);
+        answerMap.put(baseMap.getString("B"), answerB);
+        answerMap.put(baseMap.getString("C"), answerC);
+        answerMap.put(baseMap.getString("D"), answerD);
+        answerMap.put("correct", baseMap.get(correct));
+        return answerMap;
+    }
+}

+ 211 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/RoomServiceImpl.java

@@ -0,0 +1,211 @@
+package com.gis.cms.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.cms.entity.dto.RoomDto;
+import com.gis.cms.entity.dto.RoomListDto;
+import com.gis.cms.entity.po.GameLogEntity;
+import com.gis.cms.entity.po.RoomEntity;
+import com.gis.cms.entity.vo.WxUserVo;
+import com.gis.cms.mapper.RoomMapper;
+import com.gis.cms.service.GameLogService;
+import com.gis.cms.service.RoomService;
+import com.gis.common.base.service.IBaseService;
+import com.gis.common.util.RedisUtil;
+import com.gis.common.util.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * Created by owen on 2022/2/22 0011 16:16
+ */
+@Slf4j
+@Service
+public class RoomServiceImpl extends ServiceImpl<RoomMapper, RoomEntity> implements RoomService {
+
+
+
+    @Autowired
+    IBaseService baseUtil;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+    @Autowired
+    GameLogService gameLogService;
+
+
+
+    /**redis 房间key*/
+    final static String ROOM_STATUS_KEY = "room:status";
+
+
+    @Override
+    public Result saveEntity(RoomDto param) {
+        RoomEntity entity = new RoomEntity();
+        BeanUtils.copyProperties(param, entity);
+        entity.setStatus(0);  // 新建默认进行中, 0:进行中
+        entity.setCreatorId(baseUtil.getUserId());
+        this.save(entity);
+        return Result.success();
+    }
+
+    @Override
+    public Result join(String code, Long creatorId) {
+        RoomEntity roomEntity = findByCode(code, creatorId);
+        if (roomEntity==null){
+            log.error("该房间号不存在: {}", code);
+            return Result.failure("该房间不存在: " + code );
+        }
+
+//        // 加入房间记录
+//        GameLogEntity entity = new GameLogEntity();
+//        entity.setRoomId(roomEntity.getId());
+//        entity.setType("activity");
+//        entity.setUserId(baseUtil.getUserId());
+//        // 需要知道谁创建
+//        entity.setCreatorId(creatorId);
+//        gameLogService.save(entity);
+        return Result.success(roomEntity);
+    }
+
+    @Override
+    public Result search(RoomListDto param) {
+        // 每次请求接口前更新房间状态,使用redis, 缓存30分钟更新一次房间状态
+        checkRoomStatus();
+        // 获取用户房间列表
+        return Result.success(countByCreatorIdAndDate(param));
+    }
+
+    @Override
+    public Result detail(Long id) {
+        // 房间总分
+        RoomEntity roomEntity = countTotalByRoomId(id);
+        // 房间用户排名
+        List<WxUserVo> users = ranking(id);
+        HashMap<Object, Object> result = new HashMap<>();
+        result.put("room", roomEntity);
+        result.put("ranking", users);
+
+        return Result.success(result);
+    }
+
+    // 房间用户排名
+    @Override
+    public List<WxUserVo> ranking(Long roomId) {
+        StringBuffer sql = new StringBuffer();
+        sql.append("select a.score, a.creator_id ,a.time, b.nick_name from tb_game_log a left join wx_user b on b.id=a.creator_id");
+        sql.append(" where a.is_delete=0 and a.type='activity' ");
+
+        if (roomId != null){
+            sql.append(StrUtil.format(" and a.room_id={}", roomId));
+        }
+
+        sql.append(" ORDER BY a.score desc ");
+        return getBaseMapper().selectWxUserVo(sql.toString());
+    }
+
+    // 房间总分
+    private RoomEntity countTotalByRoomId(Long roomId){
+        StringBuffer sql = new StringBuffer();
+        sql.append("select a.*, sum(b.score) scoreTotal, count(b.id) count from tb_room a left join tb_game_log b on b.room_id=a.id");
+        sql.append(" where a.is_delete=0 and b.is_delete=0 and  b.type='activity'");
+
+        if (roomId != null){
+            sql.append(StrUtil.format(" and a.id={}", roomId));
+        }
+        return getBaseMapper().selectEntity(sql.toString());
+    }
+
+
+//    private List<RoomEntity> countByCreatorIdAndDate(RoomListDto param){
+//        Long creatorId = baseUtil.getUserId();
+//        StringBuffer sql = new StringBuffer();
+//        sql.append("select a.id, a.create_time, a.name, a.creator_id, a.end_time, a.code, b.count, IF(end_time < NOW(),0,1) as status from tb_room a LEFT JOIN ");
+//        sql.append(StrUtil.format("(select COUNT(id) as count, room_id from tb_game_log WHERE is_delete=0 " +
+//                "and type='activity' and creator_id={} GROUP BY room_id) b ", creatorId));
+//        sql.append(StrUtil.format("on b.room_id=a.id WHERE a.is_delete=0 and a.creator_id={} ", creatorId));
+//        // 格式化日期需要使用yyyy-mm-dd , 没有日会异常
+//        sql.append(StrUtil.format(" and a.create_time > {}", beforeDate(param.getDate())));
+//        sql.append(" ORDER BY a.create_time desc");
+//
+//        return getBaseMapper().selectEntitys(sql.toString());
+//    }
+
+    private List<RoomEntity> countByCreatorIdAndDate(RoomListDto param){
+        Long creatorId = baseUtil.getUserId();
+        StringBuffer sql = new StringBuffer();
+        sql.append("select a.*,b.count  from ");
+
+        sql.append("(select *, IF(end_time < NOW(),1,0) statusVo from tb_room where is_delete=0");
+        if (param.getIsClose() == 1){
+            sql.append(" and status=1 ");
+        }
+
+        if (param.getIsJoin() == 1){
+            sql.append(" and creator_id=").append(creatorId);
+        }
+        sql.append(" and create_time >= '").append(beforeDate(param.getDate())).append("') a");
+
+        sql.append(" left join (select COUNT(id) as count, room_id from tb_game_log WHERE is_delete=0 and type='activity'");
+
+        sql.append(" GROUP BY room_id) b on b.room_id=a.id ");
+
+        sql.append(" ORDER BY a.create_time desc");
+
+        return getBaseMapper().selectList(sql.toString());
+    }
+
+    private RoomEntity findByCode(String code, Long creatorId){
+        LambdaQueryWrapper<RoomEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(RoomEntity::getCode, code);
+        wrapper.eq(RoomEntity::getCreatorId, creatorId);
+        return getBaseMapper().selectOne(wrapper);
+
+    }
+
+    // 获取最近时间日期
+    private LocalDate beforeDate(Integer num){
+        return LocalDate.now().minusDays(num);
+    }
+
+    /**
+     * 检查感觉状态
+     */
+    private void checkRoomStatus(){
+
+        if (redisUtil.hasKey(ROOM_STATUS_KEY)){
+            return;
+        }
+
+        // 更新房间状态
+        setStatus(1);
+        // 30分钟
+        redisUtil.setEx(ROOM_STATUS_KEY, ROOM_STATUS_KEY, 30, TimeUnit.MINUTES);
+    }
+
+    /**
+     * 修改房间状态
+     * @param status
+     */
+    private void setStatus(Integer status){
+        LambdaUpdateWrapper<RoomEntity> ew = new LambdaUpdateWrapper<>();
+        ew.set(RoomEntity::getStatus, status)
+                .eq(RoomEntity::getStatus,0)
+                .le(RoomEntity::getEndTime, LocalDateTime.now()); // le: 小于等于<= 当前时间
+
+        this.update(ew);
+
+    }
+}

+ 134 - 0
gis_common/pom.xml

@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>wx_lvdao</artifactId>
+        <groupId>com.gis</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>gis_common</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!--springboot-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <!-- JPA -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!--springboot中的redis依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+
+        <!-- mysql -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <!--阿里数据库连接池 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+        </dependency>
+
+        <!-- knife4j aip 包-->
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+        </dependency>
+
+        <!-- 工具类 -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+
+        <!-- 中文转拼音 -->
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+        </dependency>
+
+        <!--excel 依赖工具包, hutool需要用的-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+        </dependency>
+
+        <!-- 二维码 -->
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+
+
+
+
+        <!-- jwt -->
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+
+        <!-- WxJava 微信小程序:weixin-java-miniapp -->
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-miniapp</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>

+ 16 - 0
gis_common/src/main/java/com/gis/common/base/aop/WebControllerLog.java

@@ -0,0 +1,16 @@
+package com.gis.common.base.aop;
+
+import java.lang.annotation.*;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface WebControllerLog {
+    String description() default "";
+
+    //是否加入数据库
+    boolean addDb() default false;
+}

+ 147 - 0
gis_common/src/main/java/com/gis/common/base/aop/WebLogAspect.java

@@ -0,0 +1,147 @@
+package com.gis.common.base.aop;
+
+import com.gis.common.base.entity.po.LogEntity;
+import com.gis.common.base.service.LogService;
+import com.gis.common.util.JwtUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by owen on 2020/2/25 0025 9:24
+ *
+ * 日志aop
+ */
+@Slf4j
+@Aspect
+@Component
+public class WebLogAspect {
+
+    @Resource
+    private HttpServletRequest request;
+
+    @Autowired
+    LogService logService;
+
+    private long startTime ;
+
+
+
+    @Pointcut("execution(* com.gis.*.controller.*.*(..))")//切入点描述 这个是controller包的切入点
+    public void controllerLog(){}//签名,可以理解成这个切入点的一个名称
+
+    @Before("controllerLog()") //在切入点的方法run之前要干的
+    public void logBeforeController(JoinPoint joinPoint) throws Exception {
+        startTime = System.currentTimeMillis();
+
+        // 设置链路id, 在logback-spring.xml里用
+        MDC.put("TRACE_ID", startTime+"");
+
+        // 记录下请求内容
+        String remoteAddr = request.getRemoteAddr();
+        log.warn("start : {}, {}, uuid: {}" , request.getMethod(), request.getRequestURI(), startTime);
+        log.info("request IP:{}" , remoteAddr);
+        log.info("request Args : {}" , Arrays.toString(joinPoint.getArgs()));
+
+
+
+        Map<String, Object> controllerLog = getControllerLog(joinPoint);
+        if (controllerLog.size() == 0) {
+            return;
+        }
+
+        String description = (String)controllerLog.get("description");
+        boolean addDb = (boolean)controllerLog.get("addDb");
+        log.info("request description:{}, addDb:{}", description, addDb);
+
+        // 获取token
+        String token = request.getHeader("token");
+        if (StringUtils.isBlank(token)) {
+            return;
+        }
+
+        Long userId = null;
+        if (StringUtils.isNotBlank(token)) {
+            userId = JwtUtil.getUserId(token);
+        }
+
+        // 日志保存db
+        if (addDb) {
+            if (StringUtils.isNotBlank(description)) {
+                // 保存数据库
+                List<String> detail = getDetail(description);
+            logService.save(new LogEntity(userId, detail.get(0), detail.get(1), remoteAddr));
+            }
+
+        }
+
+
+        //下面这个getSignature().getDeclaringTypeName()是获取包+类名的   然后后面的joinPoint.getSignature.getName()获取了方法名
+//        log.info("request Class_Method : {}" , joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
+
+
+
+    }
+
+
+    //使用@AfterReturning在切入点return内容之后切入内容(可以用来对处理返回值做一些加工处理)
+    @AfterReturning(returning = "ret", pointcut = "controllerLog()")
+    public void doAfterReturning(Object ret) throws Throwable {
+        // 处理完请求,返回内容
+        log.warn("end: {}, {}, uuid: {},  响应耗时:{} ms", request.getMethod(), request.getRequestURI(), startTime, (System.currentTimeMillis() - startTime));
+    }
+
+    /**
+     * 获取注解中对方法的描述信息 用于Controller层注解
+     *
+     * @param joinPoint
+     *            切点
+     * @return 方法描述
+     * @throws Exception
+     */
+    private static Map<String, Object> getControllerLog(JoinPoint joinPoint) throws Exception {
+        String targetName = joinPoint.getTarget().getClass().getName();
+        String methodName = joinPoint.getSignature().getName();
+        Object[] arguments = joinPoint.getArgs();
+        Class targetClass = Class.forName(targetName);
+        Method[] methods = targetClass.getMethods();
+        Map<String, Object> result = new HashMap<>();
+        for (Method method : methods) {
+            if (method.getName().equals(methodName)) {
+                Class[] clazzs = method.getParameterTypes();
+                if (clazzs.length == arguments.length) {
+                    WebControllerLog annotation = method.getAnnotation(WebControllerLog.class);
+                    if (annotation != null) {
+                        String description = annotation.description();
+                        boolean addDb = annotation.addDb();
+                        result.put("description", description);
+                        result.put("addDb", addDb);
+                        break;
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+    private static List<String> getDetail(String str){
+        String[] split = str.split("-");
+        return Arrays.asList(split);
+    }
+
+}

+ 27 - 0
gis_common/src/main/java/com/gis/common/base/entity/dto/PageDateDto.java

@@ -0,0 +1,27 @@
+package com.gis.common.base.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * Created by Owen on 2019/10/28 0028 12:24
+ * 有时间
+ */
+@Data
+public class PageDateDto extends PageDto {
+
+    /**
+     * 开始时间
+     * 需要用字符串接收
+     */
+    @ApiModelProperty(value = "开始时间", name = "startTime")
+    private String startTime;
+
+
+    @ApiModelProperty(value = "结束时间", name = "endTime")
+    private String endTime;
+
+
+
+}

+ 26 - 0
gis_common/src/main/java/com/gis/common/base/entity/dto/PageDto.java

@@ -0,0 +1,26 @@
+package com.gis.common.base.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * Created by Owen on 2019/10/28 0028 12:24
+ */
+@Data
+public class PageDto {
+
+
+    @ApiModelProperty(value = "起始页码,默认1为第一页", name = "pageNum")
+    private Integer pageNum;
+
+    @ApiModelProperty(value = "每页数量", name = "pageSize")
+    private Integer pageSize;
+
+    @ApiModelProperty(value = "搜索条件", name = "searchKey")
+    private String searchKey;
+
+
+
+
+}

+ 14 - 0
gis_common/src/main/java/com/gis/common/base/entity/dto/UserPageDateDto.java

@@ -0,0 +1,14 @@
+package com.gis.common.base.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2021/8/19 0019 20:36
+ */
+@Data
+public class UserPageDateDto extends PageDateDto {
+
+    @ApiModelProperty(value = "角色id")
+    private Long roleId;
+}

+ 53 - 0
gis_common/src/main/java/com/gis/common/base/entity/po/BaseEntity.java

@@ -0,0 +1,53 @@
+package com.gis.common.base.entity.po;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.time.LocalDateTime;
+
+@Data
+@MappedSuperclass
+public abstract class BaseEntity {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)  //tk.mybatis id自增
+    @TableId(type = IdType.AUTO)  // mybatis-plus id自增
+    @Column(name = "id")
+    @ApiModelProperty(value = "对象ID")
+    private Long id;
+
+    @TableField(fill = FieldFill.INSERT)
+    @ApiModelProperty(value = "创建时间")
+//    @Temporal(TemporalType.TIMESTAMP)
+//    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @ApiModelProperty(value = "修改时间")
+//    @Temporal(TemporalType.TIMESTAMP)
+//    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+
+    /**
+     * 用来批量操作的
+     * 0代表未删除 , 1代表已经删除,默认写0
+     * 需要使用对象类型
+     */
+    @JsonIgnore
+    @JSONField(serialize = false)
+    private Integer isDelete;
+
+    @TableField(exist  = false)
+    @ApiModelProperty(value = "创建者名")
+    private String creatorName;
+
+    @ApiModelProperty(value = "创建者id")
+    private Long creatorId;
+}

+ 41 - 0
gis_common/src/main/java/com/gis/common/base/entity/po/LogEntity.java

@@ -0,0 +1,41 @@
+package com.gis.common.base.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * 收集日志实体类
+ */
+@NoArgsConstructor                 //无参构造
+@AllArgsConstructor                //有参构造
+@Data
+//@Table(name = "tb_log")
+@TableName("tb_log")
+public class LogEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = -3394791736156714542L;
+
+    /**
+     * 操作者用户id
+     */
+    private Long userId;
+
+    /**
+     * 操作类型
+     */
+    private String type;
+
+    /**
+     * 操作记录
+     */
+    private String description;
+
+    /** ip */
+    private String ip;
+}

+ 27 - 0
gis_common/src/main/java/com/gis/common/base/entity/vo/LogVo.java

@@ -0,0 +1,27 @@
+package com.gis.common.base.entity.vo;
+
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2020/5/12.
+ */
+@Data
+public class LogVo extends BaseEntity {
+
+
+    @ApiModelProperty(value = "操作者账号")
+    private String userName;
+
+    @ApiModelProperty(value = "操作类型")
+    private String type;
+
+    @ApiModelProperty(value = "操作记录")
+    private String description;
+
+    @ApiModelProperty(value = "ip地址")
+    private String ip;
+
+
+}

+ 134 - 0
gis_common/src/main/java/com/gis/common/base/exception/BaseRuntimeException.java

@@ -0,0 +1,134 @@
+package com.gis.common.base.exception;
+
+import cn.hutool.core.util.StrUtil;
+import com.gis.common.constant.ErrorEnum;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
+public class BaseRuntimeException extends RuntimeException{
+
+    private static final long serialVersionUID = -1518945670203783450L;
+    private Integer code;
+    private String msg;
+
+    public BaseRuntimeException(String msg){
+        super(msg);
+        this.code = -1;
+        this.msg = msg;
+    }
+
+    /**
+     *
+     * @param code 允许为null
+     * @param msg
+     */
+    public BaseRuntimeException(Integer code, String msg){
+        super(msg);
+        this.code = code == null? -1 : code;
+        this.msg = msg;
+    }
+
+    public BaseRuntimeException(ErrorEnum errorEnum){
+        this.code = errorEnum.code();
+        this.msg = errorEnum.message();
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+
+    public static void isNull(Object obj, Integer code, String msg){
+        if (obj == null){
+            getExc(code, msg);
+        }
+    }
+
+    public static void isBlank(Object obj, Integer code, String msg){
+        if (obj == null){
+            getExc(code, msg);
+        }
+
+        if (obj instanceof String && StrUtil.isBlank(obj.toString())){
+            getExc(code, msg);
+        }
+
+    }
+
+    public static void isNull(Object obj, ErrorEnum errorEnum){
+        if (obj == null){
+            getExc(errorEnum.code(), errorEnum.message());
+        }
+    }
+
+    public static void isBlank(Object obj, ErrorEnum errorEnum){
+        Integer code = errorEnum.code();
+        String msg = errorEnum.message();
+        if (obj == null){
+            getExc(code, msg);
+        }
+
+        if (obj instanceof String && StrUtil.isBlank(obj.toString())){
+            getExc(code, msg);
+        }
+
+    }
+
+    /**
+     *
+     * @param obj true 存在抛异常
+     * @param errorEnum
+     */
+    public static void isExist(boolean obj, ErrorEnum errorEnum){
+        if (obj){
+            getExc(errorEnum.code(), errorEnum.message());
+        }
+    }
+
+    /**
+     *
+     * @param obj 存在抛异常
+     * @param code 允许为null
+     * @param msg
+     */
+    public static void isExist(boolean obj, Integer code, String msg){
+        if (obj){
+            getExc(code, msg);
+        }
+    }
+
+    public static void  getExc(Integer code, String msg){
+        throw new BaseRuntimeException(code, msg);
+    }
+
+    /**
+     *
+     * @param obj 集合
+     * @param errorEnum
+     */
+    public static void isEmpty(List obj, ErrorEnum errorEnum){
+        if (CollectionUtils.isEmpty(obj)){
+            getExc(errorEnum.code(), errorEnum.message());
+        }
+    }
+
+    public static void isEmpty(List obj, Integer code, String msg){
+        if (CollectionUtils.isEmpty(obj)){
+            getExc(code, msg);
+        }
+    }
+
+}

+ 25 - 0
gis_common/src/main/java/com/gis/common/base/mapper/LogMapper.java

@@ -0,0 +1,25 @@
+package com.gis.common.base.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.base.entity.po.LogEntity;
+import com.gis.common.base.entity.vo.LogVo;
+import com.gis.common.base.mapper.provider.LogProvider;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Mapper
+public interface LogMapper extends BaseMapper<LogEntity> {
+
+    /**
+     * 注意日期,需要传字符串类型
+     */
+    @SelectProvider(type = LogProvider.class, method = "findBySearchKey")
+    Page<LogVo> search(PageDateDto param, IPage<LogEntity> page);
+}

+ 19 - 0
gis_common/src/main/java/com/gis/common/base/mapper/provider/BaseProvider.java

@@ -0,0 +1,19 @@
+package com.gis.common.base.mapper.provider;
+
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Created by owen on 2022/2/9.
+ */
+@Slf4j
+public class BaseProvider {
+
+    public String selectSql(String sql){
+        log.info("sqlStr: {}", sql);
+        return sql;
+    }
+
+
+
+}

+ 41 - 0
gis_common/src/main/java/com/gis/common/base/mapper/provider/LogProvider.java

@@ -0,0 +1,41 @@
+package com.gis.common.base.mapper.provider;
+
+import com.gis.common.base.entity.dto.PageDateDto;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+
+
+/**
+ * Created by owen on 2020/5/13.
+ */
+@Log4j2
+public class LogProvider {
+
+    public String findBySearchKey(PageDateDto param){
+        StringBuffer sql = new StringBuffer(
+                "select z.type, z.description, z.create_time, z.ip, u.user_name from tb_log z left join sys_user u on z.user_id = u.id where z.is_delete = '0' ");
+
+
+        if(StringUtils.isNotBlank(param.getStartTime()) && StringUtils.isNotBlank(param.getEndTime())){
+
+            sql.append(" and z.create_time >= ").append("'").append(param.getStartTime()).append("'");
+            sql.append(" and z.create_time <= ").append("'").append(param.getEndTime()).append("'");
+        }
+
+        String searchKey = param.getSearchKey();
+        if(!StringUtils.isAllBlank(searchKey)){
+            searchKey = StringUtils.trim(searchKey);
+            sql.append(" and (");
+            sql.append("  u.user_name like '%").append(searchKey).append("%'");
+//            sql.append(" or ( z.description like '%").append(searchKey).append("%' )");
+            sql.append(" )");
+        }
+
+        sql.append(" order by z.create_time desc");
+        log.info("sql: {}", sql.toString());
+        return sql.toString();
+    }
+
+
+
+}

+ 37 - 0
gis_common/src/main/java/com/gis/common/base/service/IBaseService.java

@@ -0,0 +1,37 @@
+package com.gis.common.base.service;
+
+import com.gis.common.constant.SysEnum;
+import com.gis.common.util.JwtUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Created by owen on 2021/12/29 0029 14:12
+ */
+@Component
+public class IBaseService {
+
+    @Autowired
+    HttpServletRequest request;
+
+
+
+    public String getToken(){
+        return request.getHeader(SysEnum.TOKEN_KEY.getValue());
+    }
+
+    /**登录用户id*/
+    public Long getUserId(){
+       return JwtUtil.getUserId(getToken());
+    }
+
+    /**登录类型*/
+    public String getLoginType(){
+        return JwtUtil.getLoginType(getToken());
+    }
+
+
+
+}

+ 18 - 0
gis_common/src/main/java/com/gis/common/base/service/LogService.java

@@ -0,0 +1,18 @@
+package com.gis.common.base.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.base.entity.po.LogEntity;
+import com.gis.common.util.Result;
+
+
+
+/**
+ * Created by owen on 2020/5/12 0011 16:14
+ */
+public interface LogService extends IService<LogEntity> {
+
+
+    Result search(PageDateDto param);
+}

+ 0 - 0
gis_common/src/main/java/com/gis/common/base/service/impl/LogServiceImpl.java


Some files were not shown because too many files changed in this diff