Forráskód Böngészése

功能开发已完成, 等待对接

wuweihao 3 éve
szülő
commit
1f87e8a522
100 módosított fájl, 6214 hozzáadás és 1 törlés
  1. 1 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. 43 0
      gis_admin/src/main/java/com/gis/admin/controller/LogController.java
  6. 187 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. 95 0
      gis_admin/src/main/java/com/gis/admin/controller/SysUserController.java
  10. 28 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/LoginDto.java
  11. 28 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/PasswordDto.java
  12. 56 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/RegisterDto.java
  13. 21 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/ResetPasswordDto.java
  14. 31 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/RoleDto.java
  15. 79 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/UserDto.java
  16. 65 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/UserWebDto.java
  17. 33 0
      gis_admin/src/main/java/com/gis/admin/entity/dto/WxUserDto.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. 12 0
      gis_admin/src/main/java/com/gis/admin/entity/vo/RoleVo.java
  22. 52 0
      gis_admin/src/main/java/com/gis/admin/mapper/SysResourceMapper.java
  23. 57 0
      gis_admin/src/main/java/com/gis/admin/mapper/SysRoleMapper.java
  24. 43 0
      gis_admin/src/main/java/com/gis/admin/mapper/SysUserMapper.java
  25. 35 0
      gis_admin/src/main/java/com/gis/admin/mapper/provider/SysRoleProvider.java
  26. 54 0
      gis_admin/src/main/java/com/gis/admin/mapper/provider/SysUserProvider.java
  27. 28 0
      gis_admin/src/main/java/com/gis/admin/service/SysResourceService.java
  28. 40 0
      gis_admin/src/main/java/com/gis/admin/service/SysRoleService.java
  29. 49 0
      gis_admin/src/main/java/com/gis/admin/service/SysUserService.java
  30. 172 0
      gis_admin/src/main/java/com/gis/admin/service/impl/SysResourceServiceImpl.java
  31. 200 0
      gis_admin/src/main/java/com/gis/admin/service/impl/SysRoleServiceImpl.java
  32. 310 0
      gis_admin/src/main/java/com/gis/admin/service/impl/SysUserServiceImpl.java
  33. 34 0
      gis_admin/src/main/java/com/gis/admin/shiro/JwtAuthenticationException.java
  34. 28 0
      gis_admin/src/main/java/com/gis/admin/shiro/JwtToken.java
  35. 271 0
      gis_admin/src/main/java/com/gis/admin/shiro/ShiroConfig.java
  36. 215 0
      gis_admin/src/main/java/com/gis/admin/shiro/ShiroRealm.java
  37. 76 0
      gis_admin/src/main/java/com/gis/admin/shiro/filters/CustomShiroFilterFactoryBean.java
  38. 149 0
      gis_admin/src/main/java/com/gis/admin/shiro/filters/JwtFilter.java
  39. 68 0
      gis_admin/src/main/java/com/gis/admin/shiro/filters/ResourceCheckFilter.java
  40. 107 0
      gis_admin/src/main/java/com/gis/admin/tree/SysResourceTreeUtil.java
  41. 51 0
      gis_admin/src/main/java/com/gis/admin/tree/vo/SysResourceTree.java
  42. 191 0
      gis_admin/src/main/resources/db/sys_admin.sql
  43. 27 0
      gis_admin/src/main/resources/db/资源表.csv
  44. 26 0
      gis_cms/pom.xml
  45. 66 0
      gis_cms/src/main/java/com/gis/cms/controller/ContentController.java
  46. 38 0
      gis_cms/src/main/java/com/gis/cms/controller/VillageController.java
  47. 46 0
      gis_cms/src/main/java/com/gis/cms/entity/dto/ContentDto.java
  48. 35 0
      gis_cms/src/main/java/com/gis/cms/entity/dto/FileDto.java
  49. 42 0
      gis_cms/src/main/java/com/gis/cms/entity/po/ContentEntity.java
  50. 46 0
      gis_cms/src/main/java/com/gis/cms/entity/po/FileEntity.java
  51. 36 0
      gis_cms/src/main/java/com/gis/cms/entity/po/MenuEntity.java
  52. 22 0
      gis_cms/src/main/java/com/gis/cms/entity/po/VillageEntity.java
  53. 50 0
      gis_cms/src/main/java/com/gis/cms/entity/vo/ContentVo.java
  54. 20 0
      gis_cms/src/main/java/com/gis/cms/entity/vo/FileVo.java
  55. 15 0
      gis_cms/src/main/java/com/gis/cms/mapper/ContentMapper.java
  56. 38 0
      gis_cms/src/main/java/com/gis/cms/mapper/FileMapper.java
  57. 15 0
      gis_cms/src/main/java/com/gis/cms/mapper/MenuMapper.java
  58. 14 0
      gis_cms/src/main/java/com/gis/cms/mapper/VillageMapper.java
  59. 22 0
      gis_cms/src/main/java/com/gis/cms/service/ContentService.java
  60. 34 0
      gis_cms/src/main/java/com/gis/cms/service/FileService.java
  61. 17 0
      gis_cms/src/main/java/com/gis/cms/service/MenuService.java
  62. 10 0
      gis_cms/src/main/java/com/gis/cms/service/VillageService.java
  63. 125 0
      gis_cms/src/main/java/com/gis/cms/service/impl/ContentServiceImpl.java
  64. 115 0
      gis_cms/src/main/java/com/gis/cms/service/impl/FileServiceImpl.java
  65. 72 0
      gis_cms/src/main/java/com/gis/cms/service/impl/MenuServiceImpl.java
  66. 16 0
      gis_cms/src/main/java/com/gis/cms/service/impl/VillageServiceImpl.java
  67. 80 0
      gis_cms/src/main/resources/sql/tb_menu.sql
  68. 130 0
      gis_common/pom.xml
  69. 16 0
      gis_common/src/main/java/com/gis/common/base/aop/WebControllerLog.java
  70. 147 0
      gis_common/src/main/java/com/gis/common/base/aop/WebLogAspect.java
  71. 27 0
      gis_common/src/main/java/com/gis/common/base/entity/dto/PageDateDto.java
  72. 26 0
      gis_common/src/main/java/com/gis/common/base/entity/dto/PageDto.java
  73. 14 0
      gis_common/src/main/java/com/gis/common/base/entity/dto/UserPageDateDto.java
  74. 49 0
      gis_common/src/main/java/com/gis/common/base/entity/po/BaseEntity.java
  75. 40 0
      gis_common/src/main/java/com/gis/common/base/entity/po/LogEntity.java
  76. 27 0
      gis_common/src/main/java/com/gis/common/base/entity/vo/LogVo.java
  77. 134 0
      gis_common/src/main/java/com/gis/common/base/exception/BaseRuntimeException.java
  78. 25 0
      gis_common/src/main/java/com/gis/common/base/mapper/LogMapper.java
  79. 19 0
      gis_common/src/main/java/com/gis/common/base/mapper/provider/BaseProvider.java
  80. 41 0
      gis_common/src/main/java/com/gis/common/base/mapper/provider/LogProvider.java
  81. 37 0
      gis_common/src/main/java/com/gis/common/base/service/IBaseService.java
  82. 18 0
      gis_common/src/main/java/com/gis/common/base/service/LogService.java
  83. 30 0
      gis_common/src/main/java/com/gis/common/base/service/impl/LogServiceImpl.java
  84. 71 0
      gis_common/src/main/java/com/gis/common/config/FastJson2JsonRedisSerializer.java
  85. 30 0
      gis_common/src/main/java/com/gis/common/config/MyBatisPlusMetaObjectHandler.java
  86. 30 0
      gis_common/src/main/java/com/gis/common/config/MybatisPlusConfig.java
  87. 79 0
      gis_common/src/main/java/com/gis/common/config/RedisConfig.java
  88. 95 0
      gis_common/src/main/java/com/gis/common/config/Swagger2.java
  89. 80 0
      gis_common/src/main/java/com/gis/common/config/WebMvcConfig.java
  90. 74 0
      gis_common/src/main/java/com/gis/common/constant/ConfigConstant.java
  91. 55 0
      gis_common/src/main/java/com/gis/common/constant/ErrorEnum.java
  92. 25 0
      gis_common/src/main/java/com/gis/common/constant/MsgCode.java
  93. 26 0
      gis_common/src/main/java/com/gis/common/constant/SysEnum.java
  94. 32 0
      gis_common/src/main/java/com/gis/common/constant/TypeCode.java
  95. 107 0
      gis_common/src/main/java/com/gis/common/util/Base64Converter.java
  96. 20 0
      gis_common/src/main/java/com/gis/common/util/BaseUtil.java
  97. 69 0
      gis_common/src/main/java/com/gis/common/util/DateUtils.java
  98. 65 0
      gis_common/src/main/java/com/gis/common/util/ExcelUtils.java
  99. 115 0
      gis_common/src/main/java/com/gis/common/util/FileUtils.java
  100. 0 0
      gis_common/src/main/java/com/gis/common/util/JwtUtil.java

+ 1 - 1
README.md

@@ -1,3 +1,3 @@
 # museum_jiangmen_village
 
-江门传统村落
+江门传统村落 2022-05-20

+ 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>museum_jiangmen_village</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());
+    }
+
+}
+

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

@@ -0,0 +1,43 @@
+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;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+/**
+ * Created by owen on 2020/5/12 0018 12:17
+ * 日志管理,只有admin权限访问
+ */
+@ApiIgnore
+@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);
+    }
+
+}

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

@@ -0,0 +1,187 @@
+package com.gis.admin.controller;
+
+import cn.hutool.core.util.StrUtil;
+import com.gis.admin.entity.po.SysRoleEntity;
+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.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.slf4j.Slf4j;
+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
+ */
+@Slf4j
+@Api(tags = "sys-登录")
+@RestController
+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());
+        BaseRuntimeException.isNull(entity, null, "用户不存在");
+
+        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());
+        }
+        BaseRuntimeException.isTrue(!decryptName, null, "密码错误");
+        // 检查账号是否启用
+        BaseRuntimeException.isTrue(entity.getIsEnabled() != 1, null, "此账号已停用:" + entity.getUserName());
+
+        // 创建新token
+        HashMap<String, Object> tokenMap = new HashMap<>();
+        tokenMap.put("userName", entity.getUserName());
+        tokenMap.put("id", userId);
+        int isAdmin = 0;
+        if (entity.getIsAdmin() == 1) {
+            // 设置角色权限
+            tokenMap.put("roleKeys", Arrays.asList(ROLE_SYS_ADMIN));
+            isAdmin = 1;
+
+        }
+        tokenMap.put("isAdmin", isAdmin);
+        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.setEx(configConstant.redisPrefix + token, token, 23, TimeUnit.HOURS);
+
+
+        return Result.success(result);
+
+    }
+
+    @ApiOperation("退出")
+    @GetMapping("/admin/logout")
+    public Result logout() {
+        String token = request.getHeader("token");
+        if (StrUtil.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 (StrUtil.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, int isAdmin){
+        Set<String> roleKeys;
+        if (isAdmin == 1){
+            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);
+//
+//    }
+//
+//
+//
+//
+//
+//}

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

@@ -0,0 +1,95 @@
+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;
+
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @ApiOperation("用户列表")
+    @PostMapping("list")
+    public Result<SysUserEntity> list(@RequestBody PageDateDto param) {
+        return userService.search(param);
+    }
+
+    @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);
+    }
+
+    @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);
+    }
+
+    @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);
+
+    }
+
+    @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);
+
+    }
+
+    @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);
+    }
+
+    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+    @WebControllerLog(description = "用户管理-授权项目",addDb = true)
+    @ApiOperation(value = "授权项目")
+    @GetMapping("/auth/{userId}")
+    public Result authProject(String projectIds, @PathVariable String userId) {
+        return userService.authProject(projectIds, userId);
+    }
+
+}
+

+ 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;
+
+
+
+
+}

+ 33 - 0
gis_admin/src/main/java/com/gis/admin/entity/dto/WxUserDto.java

@@ -0,0 +1,33 @@
+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 2022/4/26 0028 16:36
+ */
+@Data
+public class WxUserDto {
+
+    @NotBlank(message = "Id不能为空")
+    @ApiModelProperty(value = "id", required = true)
+    private String id;
+
+    @NotBlank(message = "昵称不能为空")
+    @ApiModelProperty(value = "昵称", required = true)
+    private String nickName;
+
+    @NotNull(message = "性别不能为空")
+    @ApiModelProperty(value = "性别 0:未知、1:男、2:女", required = true)
+    private Integer gender;
+
+    @NotBlank(message = "头像不能为空")
+    @ApiModelProperty(value = "头像", required = true)
+    private String avatarUrl;
+
+
+
+}

+ 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;
+
+
+
+
+
+}

+ 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);
+}

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

@@ -0,0 +1,43 @@
+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.apache.ibatis.annotations.Update;
+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);
+
+    @Update("update sys_user set project_ids = #{projectIds} , update_time = NOW() where is_delete=0 and id = #{userId} ")
+    void setProjectId(String projectIds, String userId);
+
+}

+ 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 cn.hutool.core.util.StrUtil;
+import com.gis.common.base.entity.dto.PageDto;
+import lombok.extern.log4j.Log4j2;
+
+
+/**
+ * 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 (!StrUtil.isAllBlank(searchKey)) {
+            searchKey = StrUtil.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 cn.hutool.core.util.StrUtil;
+import com.gis.common.base.entity.dto.UserPageDateDto;
+import lombok.extern.log4j.Log4j2;
+
+
+/**
+ * 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 (StrUtil.isNotBlank(param.getStartTime()) && StrUtil.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 (!StrUtil.isAllBlank(searchKey)) {
+            searchKey = StrUtil.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);
+}

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

@@ -0,0 +1,49 @@
+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);
+
+    SysUserEntity cacheByUserName(String userName);
+
+    SysUserEntity cacheById(Long userId);
+
+    /**项目授权*/
+    Result authProject(String projectIds, String userId);
+
+}

+ 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;
+//
+//    }
+//
+//}

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

@@ -0,0 +1,200 @@
+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.SysRoleService;
+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.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);
+    }
+
+
+}

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

@@ -0,0 +1,310 @@
+package com.gis.admin.service.impl;
+
+import cn.hutool.core.util.RandomUtil;
+import cn.hutool.core.util.StrUtil;
+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.impl.ServiceImpl;
+import com.gis.admin.entity.dto.ResetPasswordDto;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.constant.TypeCode;
+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.SysUserService;
+import lombok.extern.slf4j.Slf4j;
+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.concurrent.TimeUnit;
+
+
+/**
+ * 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;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+
+    /**重置密码redis key*/
+    final static String RESET_PASSWORD_KEY = "reset:password:";
+
+    /**redis 用户名*/
+    final static String USER_KEY = "user:";
+
+
+    @Override
+    public SysUserEntity findByUserName(String userName) {
+        return entityMapper.findByUserName(userName);
+    }
+
+    @Override
+    public SysUserEntity cacheByUserName(String userName) {
+        String userKey = TypeCode.USER_KEY + userName;
+        SysUserEntity entity;
+        if (redisUtil.hasKey(userKey)){
+            entity = redisUtil.getCacheObject(userKey);
+        } else {
+            entity = findByUserName(userName);
+            redisUtil.setCacheObject(userKey, entity, 1, TimeUnit.HOURS);
+        }
+        return entity;
+    }
+
+    @Override
+    public SysUserEntity cacheById(Long userId) {
+        SysUserEntity entity;
+        String userKey = USER_KEY + userId;
+        if (redisUtil.hasKey(userKey)){
+            entity =  redisUtil.getCacheObject(userKey);
+        } else {
+            entity = this.getById(userId);
+            redisUtil.setCacheObject(userKey, entity, 5, TimeUnit.MINUTES);
+        }
+        return entity;
+    }
+
+    @Override
+    public Result authProject(String projectIds, String userId) {
+        baseMapper.setProjectId(projectIds, userId);
+        String userKey = USER_KEY + userId;
+        redisUtil.delete(userKey);
+        return Result.success();
+    }
+
+
+
+
+
+
+
+    @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 (StrUtil.isNotBlank(startTime) || StrUtil.isNotBlank(endTime)){
+            wrapper.between(SysUserEntity::getCreateTime, startTime, endTime);
+        }
+
+        String searchKey = param.getSearchKey();
+        if (StrUtil.isNotBlank(searchKey)){
+            wrapper.like(SysUserEntity::getUserName, searchKey);
+        }
+
+        wrapper.orderByDesc(SysUserEntity::getCreateTime);
+
+        IPage<SysUserEntity> result = this.page(page, wrapper);
+
+        return Result.success(result);
+    }
+
+
+
+    @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);
+    }
+
+
+
+}

+ 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;
+//    }
+
+}

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

@@ -0,0 +1,215 @@
+package com.gis.admin.shiro;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.constant.SysEnum;
+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.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
+    ConfigConstant configConstant;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+
+    /**
+     * 必须重写此方法,不然Shiro会报错
+     */
+    @Override
+    public boolean supports(AuthenticationToken token) {
+        return token instanceof JwtToken;
+    }
+
+    /**
+     * 权限信息认证(包括角色以及权限)是用户访问controller的时候才进行验证(redis存储的此处权限信息)
+     * 触发检测用户权限时才会调用此方法,例如checkRole,checkPermission
+     * <p>
+     * 只有当需要检测用户权限的时候才会调用此方法,例如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 (StrUtil.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;
+    }
+
+    /**
+     * 默认使用此方法进行用户名正确与否验证,错误抛出异常即可。
+     * <p>
+     * 用户信息认证是在用户进行登录的时候进行验证(不存redis)
+     * 也就是说验证用户输入的账号和密码是否正确,错误抛出异常
+     *
+     * @param auth 用户登录的账号密码信息
+     * @return 返回封装了用户信息的 AuthenticationInfo 实例
+     * @throws AuthenticationException
+     */
+    @Override
+    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
+        log.info("run doGetAuthenticationInfo");
+        String token = (String) auth.getCredentials();
+        if (token == null) {
+            throw new JwtAuthenticationException(5001, "header token is null");
+        }
+        // 校验token有效性
+        SysUserEntity sysUserEntity = this.checkUserTokenIsEffect(token);
+
+        return new SimpleAuthenticationInfo(sysUserEntity, 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 = redisUtil.getCacheObject(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.cacheById(JwtUtil.getUserId(token));
+        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());
+//    }
+
+
+    /**
+     * 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

+ 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>museum_jiangmen_village</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>

+ 66 - 0
gis_cms/src/main/java/com/gis/cms/controller/ContentController.java

@@ -0,0 +1,66 @@
+package com.gis.cms.controller;
+
+import com.gis.cms.entity.dto.ContentDto;
+import com.gis.cms.entity.dto.FileDto;
+import com.gis.cms.service.ContentService;
+import com.gis.cms.service.FileService;
+import com.gis.cms.service.MenuService;
+import com.gis.cms.service.VillageService;
+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.validation.Valid;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:51
+ */
+@Api(tags = "内容管理")
+@RestController
+@RequestMapping("/cms/content")
+public class ContentController {
+
+
+    @Autowired
+    ContentService contentService;
+
+    @Autowired
+    FileService fileService;
+
+    @ApiOperation(value = "列表")
+    @GetMapping("/list/{villageId}/{menuId}")
+    public Result getList(@PathVariable Long villageId, @PathVariable Long menuId){
+        return contentService.getList(villageId, menuId);
+    }
+
+
+    @ApiOperation(value = "新增|编辑")
+    @PostMapping("/saveEntity")
+    public Result saveEntity(@Valid @RequestBody ContentDto param){
+        return contentService.saveEntity(param);
+    }
+
+
+
+    @ApiOperation(value = "删除")
+    @PostMapping("/removes/{ids}")
+    public Result removes(@PathVariable String ids){
+        return contentService.removes(ids);
+    }
+
+    @ApiOperation(value = "文件-上传", notes = "视频用原名保存, 上传避免覆盖(同一个目录里:村落+菜单)")
+    @PostMapping("/upload")
+    public Result upload(@Valid FileDto param){
+        return contentService.upload(param);
+    }
+
+    @ApiOperation(value = "文件-删除", notes = "文件id")
+    @PostMapping("/delFile/{fileIds}")
+    public Result delFile(@PathVariable String fileIds){
+        return fileService.delFile(fileIds);
+    }
+
+}

+ 38 - 0
gis_cms/src/main/java/com/gis/cms/controller/VillageController.java

@@ -0,0 +1,38 @@
+package com.gis.cms.controller;
+
+import com.gis.cms.service.MenuService;
+import com.gis.cms.service.VillageService;
+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.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:51
+ */
+@Api(tags = "村落管理")
+@RestController
+@RequestMapping("/cms/village")
+public class VillageController {
+
+    @Autowired
+    MenuService menuService;
+
+    @Autowired
+    VillageService entityService;
+
+    @ApiOperation(value = "获取菜单树")
+    @GetMapping("/getTreeMenu")
+    public Result getTreeMenu(){
+        return menuService.getTreeMenu();
+    }
+
+    @ApiOperation(value = "列表")
+    @GetMapping("/list")
+    public Result list(){
+        return Result.success(entityService.list());
+    }
+}

+ 46 - 0
gis_cms/src/main/java/com/gis/cms/entity/dto/ContentDto.java

@@ -0,0 +1,46 @@
+package com.gis.cms.entity.dto;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:40
+ * 内容表
+ *
+ */
+@Data
+public class ContentDto  implements Serializable {
+
+    private static final long serialVersionUID = 207559379757916274L;
+    @ApiModelProperty(value = "对象ID")
+    private Long id;
+
+    @ApiModelProperty(value = "内容")
+    private String content;
+
+    @ApiModelProperty(value = "图片id")
+    private String imgIds;
+
+    @ApiModelProperty(value = "视频id")
+    private String videoIds;
+
+    @ApiModelProperty(value = "json内容")
+    private String contentJson;
+
+    @NotNull(message = "村落Id不能为空")
+    @ApiModelProperty(value = "村落Id", required = true)
+    private Long villageId;
+
+    @NotNull(message = "菜单Id不能为空")
+    @ApiModelProperty(value = "菜单Id", required = true)
+    private Long menuId;
+
+
+}

+ 35 - 0
gis_cms/src/main/java/com/gis/cms/entity/dto/FileDto.java

@@ -0,0 +1,35 @@
+package com.gis.cms.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:40
+ * 内容表
+ *
+ */
+@Data
+public class FileDto {
+
+    @NotBlank(message = "类型不能为空")
+    @ApiModelProperty(value = "类型:img|video", required = true)
+    private String type;
+
+    @ApiModelProperty(value = "文件")
+    private MultipartFile file;
+
+    @NotNull(message = "村落Id不能为空")
+    @ApiModelProperty(value = "村落Id", required = true)
+    private Long villageId;
+
+    @NotNull(message = "菜单Id不能为空")
+    @ApiModelProperty(value = "菜单Id", required = true)
+    private Long menuId;
+
+
+}

+ 42 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/ContentEntity.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.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:40
+ * 内容表
+ *
+ */
+@Data
+@TableName(value = "tb_content")
+public class ContentEntity extends BaseEntity implements Serializable {
+    private static final long serialVersionUID = 8557779421138259993L;
+
+    @ApiModelProperty(value = "内容")
+    private String content;
+
+    /**mysql set 最大64个值*/
+    @ApiModelProperty(value = "图片id")
+    private String imgIds;
+
+    @ApiModelProperty(value = "视频id")
+    private String videoIds;
+
+    @ApiModelProperty(value = "json内容")
+    private String contentJson;
+
+    @ApiModelProperty(value = "村落Id")
+    private Long villageId;
+
+    @ApiModelProperty(value = "菜单Id")
+    private Long menuId;
+
+
+}

+ 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;
+
+
+
+
+
+
+}

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

@@ -0,0 +1,36 @@
+package com.gis.cms.entity.po;
+
+import com.alibaba.fastjson.annotation.JSONField;
+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.Column;
+import java.io.Serializable;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:40
+ * 村落
+ *
+ */
+@Data
+@TableName(value = "tb_menu")
+public class MenuEntity extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 457278413834931441L;
+
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    // 前端需要传menu、button
+    @ApiModelProperty(value = "类型")
+    @Column(columnDefinition = "enum('menu','button')")
+    private String resourceType;
+
+    @ApiModelProperty(value = "排序")
+    private Integer sort;
+
+    @ApiModelProperty(value = "父级Id")
+    private Long parentId;
+}

+ 22 - 0
gis_cms/src/main/java/com/gis/cms/entity/po/VillageEntity.java

@@ -0,0 +1,22 @@
+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/5/19 0019 15:40
+ * 村落
+ *
+ */
+@Data
+@TableName(value = "tb_village")
+public class VillageEntity extends BaseEntity implements Serializable {
+    private static final long serialVersionUID = 8557779421138259993L;
+
+    @ApiModelProperty(value = "名称")
+    private String name;
+}

+ 50 - 0
gis_cms/src/main/java/com/gis/cms/entity/vo/ContentVo.java

@@ -0,0 +1,50 @@
+package com.gis.cms.entity.vo;
+
+import com.gis.cms.entity.po.FileEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:40
+ * 内容表
+ *
+ */
+@Data
+public class ContentVo implements Serializable {
+
+    private static final long serialVersionUID = 207559379757916274L;
+    @ApiModelProperty(value = "对象ID")
+    private Long id;
+
+    @ApiModelProperty(value = "内容")
+    private String content;
+
+    @ApiModelProperty(value = "图片id")
+    private String imgIds;
+
+    @ApiModelProperty(value = "视频id")
+    private String videoIds;
+
+    @ApiModelProperty(value = "json内容")
+    private String contentJson;
+
+    @ApiModelProperty(value = "村落Id")
+    private Long villageId;
+
+    @ApiModelProperty(value = "菜单Id")
+    private Long menuId;
+
+    @ApiModelProperty(value = "图片")
+    private List<FileVo> images;
+
+    @ApiModelProperty(value = "视频")
+    private List<FileVo> videos;
+
+
+
+}

+ 20 - 0
gis_cms/src/main/java/com/gis/cms/entity/vo/FileVo.java

@@ -0,0 +1,20 @@
+package com.gis.cms.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2022/5/20 0020 11:38
+ */
+@Data
+public class FileVo {
+
+    @ApiModelProperty(value = "对象ID")
+    private Long id;
+
+    @ApiModelProperty(value = "名称" )
+    private String name;
+
+    @ApiModelProperty(value = "文件地址")
+    private String filePath;
+}

+ 15 - 0
gis_cms/src/main/java/com/gis/cms/mapper/ContentMapper.java

@@ -0,0 +1,15 @@
+package com.gis.cms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.ContentEntity;
+import com.gis.cms.entity.po.MenuEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:47
+ */
+@Component
+@Mapper
+public interface ContentMapper extends BaseMapper<ContentEntity> {
+}

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

@@ -0,0 +1,38 @@
+package com.gis.cms.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.FileEntity;
+import com.gis.cms.entity.vo.FileVo;
+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.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);
+
+    @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);
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    List<FileVo> findByIds(String sql);
+}

+ 15 - 0
gis_cms/src/main/java/com/gis/cms/mapper/MenuMapper.java

@@ -0,0 +1,15 @@
+package com.gis.cms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.MenuEntity;
+import com.gis.cms.entity.po.VillageEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:47
+ */
+@Component
+@Mapper
+public interface MenuMapper extends BaseMapper<MenuEntity> {
+}

+ 14 - 0
gis_cms/src/main/java/com/gis/cms/mapper/VillageMapper.java

@@ -0,0 +1,14 @@
+package com.gis.cms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.cms.entity.po.VillageEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:47
+ */
+@Component
+@Mapper
+public interface VillageMapper extends BaseMapper<VillageEntity> {
+}

+ 22 - 0
gis_cms/src/main/java/com/gis/cms/service/ContentService.java

@@ -0,0 +1,22 @@
+package com.gis.cms.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.dto.ContentDto;
+import com.gis.cms.entity.dto.FileDto;
+import com.gis.cms.entity.po.ContentEntity;
+import com.gis.cms.entity.po.MenuEntity;
+import com.gis.common.util.Result;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:48
+ */
+public interface ContentService extends IService<ContentEntity> {
+
+    Result getList(Long villageId, Long menuId);
+
+    Result saveEntity(ContentDto param);
+
+    Result upload(FileDto param);
+
+    Result removes(String ids);
+}

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

@@ -0,0 +1,34 @@
+package com.gis.cms.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.po.FileEntity;
+import com.gis.cms.entity.vo.FileVo;
+import com.gis.common.util.Result;
+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);
+
+    List<FileEntity> findByModuleId(Long moduleId, String module);
+
+    Map<String, Object> upload(MultipartFile file, String dir);
+
+    void bindingModuleId(Long moduleId, String ids, String module);
+
+    List<FileVo> findByIds(String ids);
+
+    /**文件真删除*/
+    Result delFile(String ids);
+}

+ 17 - 0
gis_cms/src/main/java/com/gis/cms/service/MenuService.java

@@ -0,0 +1,17 @@
+package com.gis.cms.service;
+
+import cn.hutool.core.lang.tree.Tree;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.po.MenuEntity;
+import com.gis.cms.entity.po.VillageEntity;
+import com.gis.common.util.Result;
+
+import java.util.List;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:48
+ */
+public interface MenuService extends IService<MenuEntity> {
+
+    Result getTreeMenu();
+}

+ 10 - 0
gis_cms/src/main/java/com/gis/cms/service/VillageService.java

@@ -0,0 +1,10 @@
+package com.gis.cms.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.cms.entity.po.VillageEntity;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:48
+ */
+public interface VillageService extends IService<VillageEntity> {
+}

+ 125 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/ContentServiceImpl.java

@@ -0,0 +1,125 @@
+package com.gis.cms.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+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.cms.entity.dto.ContentDto;
+import com.gis.cms.entity.dto.FileDto;
+import com.gis.cms.entity.po.ContentEntity;
+import com.gis.cms.entity.po.FileEntity;
+import com.gis.cms.entity.vo.ContentVo;
+import com.gis.cms.mapper.ContentMapper;
+import com.gis.cms.service.ContentService;
+import com.gis.cms.service.FileService;
+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.FileUtils;
+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 javax.validation.constraints.NotBlank;
+import java.util.*;
+
+
+/**
+ * Created by owen on 2022/5/19 0019 15:49
+ */
+@Slf4j
+@Service
+public class ContentServiceImpl extends ServiceImpl<ContentMapper, ContentEntity> implements ContentService {
+
+    @Autowired
+    FileService fileService;
+
+    @Autowired
+    IBaseService baseService;
+
+    @Autowired
+    FileUtils fileUtils;
+
+    /**
+     * 模块类型
+     */
+    static final String MODULE_CONTENT = "content";
+
+    @Override
+    public Result getList(Long villageId, Long menuId) {
+        LambdaQueryWrapper<ContentEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ContentEntity::getVillageId, villageId);
+        wrapper.eq(ContentEntity::getMenuId, menuId);
+        List<ContentEntity> list = this.list(wrapper);
+        ContentVo contentVo = null;
+        ArrayList<ContentVo> res = new ArrayList<>();
+        for (ContentEntity entity : list) {
+            contentVo = new ContentVo();
+            BeanUtils.copyProperties(entity, contentVo);
+            contentVo.setImages(fileService.findByIds(entity.getImgIds()));
+            contentVo.setVideos(fileService.findByIds(entity.getVideoIds()));
+            res.add(contentVo);
+        }
+        return Result.success(res);
+    }
+
+    @Override
+    public Result saveEntity(ContentDto param) {
+        Long id = param.getId();
+        ContentEntity entity;
+        if (id == null) {
+            entity = new ContentEntity();
+            BeanUtils.copyProperties(param, entity);
+            entity.setCreatorId(baseService.getUserId());
+            this.save(entity);
+        } else {
+            entity = this.getById(id);
+            BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
+            BeanUtils.copyProperties(param, entity);
+            this.updateById(entity);
+        }
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result upload(FileDto param) {
+
+        boolean isPingYing = false;
+        String type = param.getType();
+        if ("video".equals(type)){
+            isPingYing = true;
+        }
+        String dir = "/" + param.getVillageId() + "_" + param.getMenuId() + "/" + type;
+        Map<String, Object> map = fileUtils.uploadMap(param.getFile(), dir, isPingYing);
+
+        FileEntity entity = new FileEntity();
+        entity.setName((String)map.get("fileName"));
+        entity.setFilePath((String)map.get("filePath"));
+        fileService.save(entity);
+        map.put("id", entity.getId());
+
+        return Result.success(map);
+    }
+
+    @Override
+    public Result removes(String ids) {
+        if (StrUtil.isBlank(ids)){
+            return Result.success();
+        }
+
+        List<String> idList = Arrays.asList(ids);
+
+        List<ContentEntity> all = this.listByIds(idList);
+        String dirPath;
+        // 真删除文件
+        for (ContentEntity entity : all) {
+            dirPath = "/" + entity.getVillageId() + "_" + entity.getMenuId();
+            fileUtils.del(dirPath);
+        }
+        this.removeByIds(idList);
+
+        return Result.success();
+    }
+}

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

@@ -0,0 +1,115 @@
+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.cms.entity.po.FileEntity;
+import com.gis.cms.entity.vo.FileVo;
+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 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.Arrays;
+import java.util.Collections;
+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 (StrUtil.isBlank(fileIds)) {
+            return;
+        }
+        // 去除特殊符号,防止sql注入
+        fileIds = RegexUtil.specificSymbol(fileIds);
+        // 去除特殊符号,防止sql注入
+        getBaseMapper().bindingModuleId(fileIds, moduleId, module);
+    }
+
+    @Override
+    public List<FileVo> findByIds(String ids) {
+        if (StrUtil.isBlank(ids)){
+            return null;
+        }
+
+        String sql = StrUtil.format("select id, name, file_path from tb_file where is_delete=0 and id in ({})", ids);
+        List<FileVo> list =  baseMapper.findByIds(sql);
+        return list;
+    }
+
+    @Override
+    public Result delFile(String ids) {
+        if (StrUtil.isBlank(ids)){
+            return Result.success();
+        }
+
+        List<String> idList = Collections.singletonList(ids);
+        List<FileEntity> list = this.listByIds(idList);
+        // 真删除
+        for (FileEntity entity : list) {
+            fileUtils.del(entity.getFilePath());
+        }
+
+        this.removeByIds(idList);
+
+        return Result.success();
+    }
+
+}

+ 72 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/MenuServiceImpl.java

@@ -0,0 +1,72 @@
+package com.gis.cms.service.impl;
+
+import cn.hutool.core.lang.tree.Tree;
+import cn.hutool.core.lang.tree.TreeNodeConfig;
+import cn.hutool.core.lang.tree.TreeUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.cms.entity.po.MenuEntity;
+import com.gis.cms.mapper.MenuMapper;
+import com.gis.cms.service.MenuService;
+import com.gis.common.util.RedisUtil;
+import com.gis.common.util.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:49
+ */
+@Slf4j
+@Service
+public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> implements MenuService {
+
+    /**菜单key*/
+    static final String MENU_KEY = "menuKey";
+
+    @Autowired
+    RedisUtil redisUtil;
+
+
+    @Override
+    public Result getTreeMenu() {
+        List<Tree<String>> treeNodes;
+        if (redisUtil.hasKey(MENU_KEY)) {
+
+            treeNodes = redisUtil.getCacheObject(MENU_KEY);
+            return Result.success(treeNodes);
+        }
+
+        //配置
+        TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
+        // 自定义属性名
+        treeNodeConfig.setWeightKey("sort"); // 权重排序字段 默认为weight
+        treeNodeConfig.setIdKey("id"); // 默认为id可以不设置
+        treeNodeConfig.setNameKey("name"); // 节点名对应名称 默认为name
+        treeNodeConfig.setParentIdKey("parentId"); // 父节点 默认为parentId
+        treeNodeConfig.setChildrenKey("children"); // 子点 默认为children
+        treeNodeConfig.setDeep(2); // 可以配置递归深度 从0开始计算 默认此配置为空,即不限制
+        //数据源
+        List<MenuEntity> nodeList = this.list();
+        //转换器 "0" - 最顶层父id值 一般为0之类  nodeList – 源数据集合
+        treeNodes = TreeUtil.build(nodeList, "0", treeNodeConfig,
+                // treeNode – 源数据实体
+                // tree – 树节点实体
+                (treeNode, tree) -> {
+                    tree.setId(treeNode.getId().toString());
+                    Long parentId = treeNode.getParentId();
+                    if (parentId != null){
+                        tree.setParentId(parentId.toString());
+                    }
+                    tree.setWeight(treeNode.getSort());
+                    tree.setName(treeNode.getName());
+                    // 扩展属性 ...
+//                    tree.putExtra("children", new ArrayList<>());
+
+                });
+            redisUtil.setCacheObject(MENU_KEY, treeNodes, 5, TimeUnit.MINUTES);
+        return Result.success(treeNodes);
+    }
+}

+ 16 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/VillageServiceImpl.java

@@ -0,0 +1,16 @@
+package com.gis.cms.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.cms.entity.po.VillageEntity;
+import com.gis.cms.mapper.VillageMapper;
+import com.gis.cms.service.VillageService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by owen on 2022/5/19 0019 15:49
+ */
+@Slf4j
+@Service
+public class VillageServiceImpl extends ServiceImpl<VillageMapper, VillageEntity> implements VillageService {
+}

+ 80 - 0
gis_cms/src/main/resources/sql/tb_menu.sql

@@ -0,0 +1,80 @@
+/*
+ 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         : museum_jiangmen_village
+
+ Target Server Type    : MySQL
+ Target Server Version : 50733
+ File Encoding         : 65001
+
+ Date: 19/05/2022 17:25:52
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for tb_menu
+-- ----------------------------
+DROP TABLE IF EXISTS `tb_menu`;
+CREATE TABLE `tb_menu`  (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
+  `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) 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 '资源类型',
+  `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:删除',
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `FKf5ra2gn0xedeida2op8097sr5`(`parent_id`) USING BTREE,
+  CONSTRAINT `tb_menu_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `tb_menu` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
+) ENGINE = InnoDB AUTO_INCREMENT = 6003 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单表' ROW_FORMAT = DYNAMIC;
+
+-- ----------------------------
+-- Records of tb_menu
+-- ----------------------------
+INSERT INTO `tb_menu` VALUES (1000, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '历史文化', 'menu', 1000, NULL, 0);
+INSERT INTO `tb_menu` VALUES (1001, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '建村历史', 'menu', 1001, 1000, 0);
+INSERT INTO `tb_menu` VALUES (1002, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '历史人物', 'menu', 1002, 1000, 0);
+INSERT INTO `tb_menu` VALUES (1003, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '历史事件', 'menu', 1003, 1000, 0);
+INSERT INTO `tb_menu` VALUES (1004, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '族谱家训', 'menu', 1004, 1000, 0);
+INSERT INTO `tb_menu` VALUES (1005, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '口述史', 'menu', 1005, 1000, 0);
+INSERT INTO `tb_menu` VALUES (1006, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '视频集', 'menu', 1006, 1000, 0);
+INSERT INTO `tb_menu` VALUES (2000, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '环境格局', 'menu', 2000, NULL, 0);
+INSERT INTO `tb_menu` VALUES (2001, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '村落选址', 'menu', 2001, 2000, 0);
+INSERT INTO `tb_menu` VALUES (2002, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '村落格局', 'menu', 2002, 2000, 0);
+INSERT INTO `tb_menu` VALUES (2003, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '建村智慧', 'menu', 2003, 2000, 0);
+INSERT INTO `tb_menu` VALUES (2004, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '自然环境', 'menu', 2004, 2000, 0);
+INSERT INTO `tb_menu` VALUES (2005, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '风景名胜', 'menu', 2005, 2000, 0);
+INSERT INTO `tb_menu` VALUES (2006, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '文物古迹', 'menu', 2006, 2000, 0);
+INSERT INTO `tb_menu` VALUES (2007, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '历史环境要素', 'menu', 2007, 2000, 0);
+INSERT INTO `tb_menu` VALUES (3000, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '传统建筑', 'menu', 3000, NULL, 0);
+INSERT INTO `tb_menu` VALUES (3001, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '建筑信息', 'menu', 3001, 3000, 0);
+INSERT INTO `tb_menu` VALUES (3002, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '村落风貌', 'menu', 3002, 3000, 0);
+INSERT INTO `tb_menu` VALUES (3003, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '视频集', 'menu', 3003, 3000, 0);
+INSERT INTO `tb_menu` VALUES (4000, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '民俗文化', 'menu', 4000, NULL, 0);
+INSERT INTO `tb_menu` VALUES (4001, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '节日活动', 'menu', 4001, 4000, 0);
+INSERT INTO `tb_menu` VALUES (4002, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '祭祀崇礼', 'menu', 4002, 4000, 0);
+INSERT INTO `tb_menu` VALUES (4003, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '婚丧嫁娶', 'menu', 4003, 4000, 0);
+INSERT INTO `tb_menu` VALUES (4004, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '地方方言', 'menu', 4004, 4000, 0);
+INSERT INTO `tb_menu` VALUES (4005, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '特色文化', 'menu', 4005, 4000, 0);
+INSERT INTO `tb_menu` VALUES (4006, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '视频集', 'menu', 4006, 4000, 0);
+INSERT INTO `tb_menu` VALUES (5000, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '美食物产', 'menu', 5000, NULL, 0);
+INSERT INTO `tb_menu` VALUES (5001, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '特色物产', 'menu', 5001, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5002, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '商业集市', 'menu', 5002, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5003, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '生产工艺', 'menu', 5003, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5004, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '服装服饰', 'menu', 5004, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5005, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '美味美食', 'menu', 5005, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5006, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '运输工具', 'menu', 5006, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5007, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '村规民约', 'menu', 5007, 5000, 0);
+INSERT INTO `tb_menu` VALUES (5008, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '视频集', 'menu', 5008, 5000, 0);
+INSERT INTO `tb_menu` VALUES (6000, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '旅游导览', 'menu', 6000, NULL, 0);
+INSERT INTO `tb_menu` VALUES (6001, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '入村路线', 'menu', 6001, 6000, 0);
+INSERT INTO `tb_menu` VALUES (6002, '2021-07-21 10:05:26', '2021-07-21 10:05:26', '村内导览', 'menu', 6002, 6000, 0);
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 130 - 0
gis_common/pom.xml

@@ -0,0 +1,130 @@
+<?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>museum_jiangmen_village</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>
+
+
+
+    </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 cn.hutool.core.util.StrUtil;
+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.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 (StrUtil.isBlank(token)) {
+            return;
+        }
+
+        Long userId = null;
+        if (StrUtil.isNotBlank(token)) {
+            userId = JwtUtil.getUserId(token);
+        }
+
+        // 日志保存db
+        if (addDb) {
+            if (StrUtil.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;
+}

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

@@ -0,0 +1,49 @@
+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 = "创建时间")
+    private LocalDateTime createTime;
+
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @ApiModelProperty(value = "修改时间")
+    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;
+}

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

@@ -0,0 +1,40 @@
+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
+@TableName("sys_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 isTrue(boolean obj, ErrorEnum errorEnum){
+        if (obj){
+            getExc(errorEnum.code(), errorEnum.message());
+        }
+    }
+
+    /**
+     *
+     * @param obj 存在抛异常
+     * @param code 允许为null
+     * @param msg
+     */
+    public static void isTrue(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 sqlStr){
+        log.info("sqlStr: {}", sqlStr);
+        return sqlStr;
+    }
+
+
+
+}

+ 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 cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.gis.common.base.entity.dto.PageDateDto;
+import lombok.extern.slf4j.Slf4j;
+
+
+/**
+ * Created by owen on 2020/5/13.
+ */
+@Slf4j
+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 sys_log z left join sys_user u on z.user_id = u.id where z.is_delete = '0' ");
+
+
+        if(StrUtil.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(!StrUtil.isAllBlank(searchKey)){
+            searchKey = StrUtil.trim(searchKey);
+            sql.append(" and (");
+            sql.append("  u.user_name 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);
+}

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

@@ -0,0 +1,30 @@
+package com.gis.common.base.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.common.base.mapper.LogMapper;
+import com.gis.common.base.service.LogService;
+import com.gis.common.base.entity.dto.PageDateDto;
+import com.gis.common.base.entity.po.LogEntity;
+import com.gis.common.util.BaseUtil;
+import com.gis.common.util.Result;
+import org.springframework.stereotype.Service;
+
+
+
+/**
+ * Created by owen on 2020/5/12 0011 16:16
+ */
+@Service
+public class LogServiceImpl extends ServiceImpl<LogMapper, LogEntity> implements LogService {
+
+
+    @Override
+    public Result search(PageDateDto param) {
+        BaseUtil.startPage(param);
+        IPage<LogEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
+
+        return Result.success((getBaseMapper().search(param, page)));
+    }
+}

+ 71 - 0
gis_common/src/main/java/com/gis/common/config/FastJson2JsonRedisSerializer.java

@@ -0,0 +1,71 @@
+package com.gis.common.config;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+import com.alibaba.fastjson.parser.ParserConfig;
+import org.springframework.util.Assert;
+import java.nio.charset.Charset;
+
+/**
+ * Redis使用FastJson序列化
+ * 
+ * @author fdkk
+ */
+public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
+{
+    @SuppressWarnings("unused")
+    private ObjectMapper objectMapper = new ObjectMapper();
+
+    public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+
+    private Class<T> clazz;
+
+    static
+    {
+        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
+    }
+
+    public FastJson2JsonRedisSerializer(Class<T> clazz)
+    {
+        super();
+        this.clazz = clazz;
+    }
+
+    @Override
+    public byte[] serialize(T t) throws SerializationException
+    {
+        if (t == null)
+        {
+            return new byte[0];
+        }
+        return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
+    }
+
+    @Override
+    public T deserialize(byte[] bytes) throws SerializationException
+    {
+        if (bytes == null || bytes.length <= 0)
+        {
+            return null;
+        }
+        String str = new String(bytes, DEFAULT_CHARSET);
+
+        return JSON.parseObject(str, clazz);
+    }
+
+    public void setObjectMapper(ObjectMapper objectMapper)
+    {
+        Assert.notNull(objectMapper, "'objectMapper' must not be null");
+        this.objectMapper = objectMapper;
+    }
+
+    protected JavaType getJavaType(Class<?> clazz)
+    {
+        return TypeFactory.defaultInstance().constructType(clazz);
+    }
+}

+ 30 - 0
gis_common/src/main/java/com/gis/common/config/MyBatisPlusMetaObjectHandler.java

@@ -0,0 +1,30 @@
+package com.gis.common.config;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+
+/**
+ * Created by owen on 2021/11/23 0023 18:01
+ * MyBatisPlus 自动填充时间
+ */
+@Component
+@Slf4j
+public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler {
+
+    @Override
+    public void insertFill(MetaObject metaObject) {
+        log.info("start insert field....");
+        this.setFieldValByName("createTime", LocalDateTime.now(),metaObject);
+        this.setFieldValByName("updateTime", LocalDateTime.now(),metaObject);
+    }
+
+    @Override
+    public void updateFill(MetaObject metaObject) {
+        this.setFieldValByName("updateTime", LocalDateTime.now(),metaObject);
+    }
+
+}

+ 30 - 0
gis_common/src/main/java/com/gis/common/config/MybatisPlusConfig.java

@@ -0,0 +1,30 @@
+package com.gis.common.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created by owen on 2021/11/12 0012 17:20
+ */
+@Configuration
+public class MybatisPlusConfig {
+    /**
+     * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
+     */
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
+        paginationInnerInterceptor.setDbType(DbType.MYSQL);
+        paginationInnerInterceptor.setOverflow(true);
+        interceptor.addInnerInterceptor(paginationInnerInterceptor); // 分页插件
+        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); // 全表的删除或更新操作,就会终止该操作
+        return interceptor;
+    }
+
+
+}

+ 79 - 0
gis_common/src/main/java/com/gis/common/config/RedisConfig.java

@@ -0,0 +1,79 @@
+package com.gis.common.config;
+
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.script.DefaultRedisScript;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+
+/**
+ * redis配置
+ * 
+ * @author fdkk
+ */
+@Configuration
+@EnableCaching
+public class RedisConfig extends CachingConfigurerSupport
+{
+    @Bean
+    @SuppressWarnings(value = { "unchecked", "rawtypes" })
+    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
+    {
+        RedisTemplate<Object, Object> template = new RedisTemplate<>();
+        template.setConnectionFactory(connectionFactory);
+
+        FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
+
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
+        serializer.setObjectMapper(mapper);
+
+        // 使用StringRedisSerializer来序列化和反序列化redis的key值
+        template.setKeySerializer(new StringRedisSerializer());
+        template.setValueSerializer(serializer);
+
+        // Hash的key也采用StringRedisSerializer的序列化方式
+        template.setHashKeySerializer(new StringRedisSerializer());
+        template.setHashValueSerializer(serializer);
+
+        template.afterPropertiesSet();
+        return template;
+    }
+
+    @Bean
+    public DefaultRedisScript<Long> limitScript()
+    {
+        DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();
+        redisScript.setScriptText(limitScriptText());
+        redisScript.setResultType(Long.class);
+        return redisScript;
+    }
+
+    /**
+     * 限流脚本
+     */
+    private String limitScriptText()
+    {
+        return "local key = KEYS[1]\n" +
+                "local count = tonumber(ARGV[1])\n" +
+                "local time = tonumber(ARGV[2])\n" +
+                "local current = redis.call('get', key);\n" +
+                "if current and tonumber(current) > count then\n" +
+                "    return tonumber(current);\n" +
+                "end\n" +
+                "current = redis.call('incr', key)\n" +
+                "if tonumber(current) == 1 then\n" +
+                "    redis.call('expire', key, time)\n" +
+                "end\n" +
+                "return tonumber(current);";
+    }
+}

+ 95 - 0
gis_common/src/main/java/com/gis/common/config/Swagger2.java

@@ -0,0 +1,95 @@
+package com.gis.common.config;
+
+import com.gis.common.constant.ConfigConstant;
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.ApiKey;
+import springfox.documentation.service.AuthorizationScope;
+import springfox.documentation.service.SecurityReference;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by owen on 2020/2/18
+ *
+ * 集成Swagger有3步:
+ * 1.pom.xml添加依赖
+ * 2.添加Swagger2.class
+ * 3.Application.class 加上注解@EnableSwagger2 表示开启Swagger
+ * 4.http://localhost:8080/doc.html#/
+ *
+ * 2.9.2 不需要字启动类配置注解
+ */
+@Slf4j
+@Configuration
+@EnableSwagger2
+@EnableKnife4j
+public class Swagger2 {
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage(configConstant.swaggerPackage))
+                .paths(PathSelectors.any())
+                .build()
+                //添加登录认证,可以使用token
+                .securityContexts(securityContexts())
+                .securitySchemes(securitySchemes())
+                ;
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title(configConstant.swaggerTitle)
+                .description(configConstant.swaggerDescription)
+                .version(configConstant.swaggerVersion)
+                .build();
+    }
+
+    private List<ApiKey> securitySchemes() {
+        //设置请求头信息
+        List<ApiKey> result = new ArrayList<>();
+        ApiKey apiKey = new ApiKey("Authorization", "token", "header");
+        result.add(apiKey);
+        return result;
+
+    }
+
+
+    private List<SecurityContext> securityContexts() {
+
+        SecurityContext context = SecurityContext.builder()
+                .securityReferences(defaultAuth())
+                .build();
+
+        return Lists.newArrayList(context);
+
+    }
+
+    private List<SecurityReference> defaultAuth() {
+        List<SecurityReference> result = new ArrayList<>();
+        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
+        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
+        authorizationScopes[0] = authorizationScope;
+        result.add(new SecurityReference("Authorization", authorizationScopes));
+        return result;
+    }
+}

+ 80 - 0
gis_common/src/main/java/com/gis/common/config/WebMvcConfig.java

@@ -0,0 +1,80 @@
+package com.gis.common.config;
+
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import com.gis.common.constant.ConfigConstant;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by owen on 2020/2/18 0018 12:01
+ */
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    /**
+     * 配置全局跨域
+     * 开发、测试环境开启跨域, 正式环境不开启
+     */
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        String active = configConstant.active;
+        if ("dev".equals(active) || "sit".equals(active)){
+            registry.addMapping("/**")
+                    .allowedOrigins("*")
+                    .allowCredentials(true)
+                    .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS")
+                    .maxAge(3600);
+        }
+
+    }
+
+
+
+    /**
+     * fastJson相关设置
+     * Dto包含json,需要配置不然会异常
+     * @return
+     */
+    @Bean
+    public HttpMessageConverters customConverters() {
+
+        FastJsonHttpMessageConverter fastJson = new FastJsonHttpMessageConverter();
+        // 创建FastJson信息转换对象
+        FastJsonConfig fastJsonConfig = new FastJsonConfig();
+
+
+        // 设置全程返回时间
+        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 设置返回值为null是时输出,不写的话,null 字段 不返回。也可以设置返回空串, 可以同时设置多个
+        fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
+
+        fastJson.setFastJsonConfig(fastJsonConfig);
+
+        //3、中文乱码解决方案
+        List<MediaType> mediaTypeList = new ArrayList<>();
+        mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
+        mediaTypeList.add(MediaType.valueOf("text/html;charset=UTF-8"));
+
+        //4、将转换规则应用于转换对象
+        fastJson.setSupportedMediaTypes(mediaTypeList);
+
+        return new HttpMessageConverters(fastJson);
+    }
+
+
+
+
+}

+ 74 - 0
gis_common/src/main/java/com/gis/common/constant/ConfigConstant.java

@@ -0,0 +1,74 @@
+package com.gis.common.constant;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by owen on 2020/12/31 0031 14:22
+ *
+ * 全局动态参数
+ */
+@Component
+public class ConfigConstant {
+
+    /** 服务器文件地址*/
+    @Value("${server.file.path}")
+    public  String serverBasePath;
+
+    @Value("${server.file.allow}")
+    public String serverFileFallow;
+
+//    @Value("${server.domain}")
+//    public String serverDomain;
+
+    /**redis token前缀*/
+    @Value("${redis.prefix}")
+    public  String redisPrefix;
+
+    /**环境配置*/
+    @Value("${spring.profiles.active}")
+    public String active;
+
+
+//    @Value("${project.en}")
+//    public String projectEn;
+
+
+
+//    @Value("${oss.point}")
+//    public  String ossPoint;
+//
+//    @Value("${oss.key}")
+//    public  String ossKey;
+//
+//    @Value("${oss.secrecy}")
+//    public  String ossSecrecy;
+//
+//    @Value("${oss.bucket}")
+//    public  String ossBucket;
+//
+//    @Value("${oss.file.path}")
+//    public  String ossBasePath;
+
+
+
+
+    @Value("${swagger.package}")
+    public  String swaggerPackage;
+
+    @Value("${swagger.title}")
+    public  String swaggerTitle;
+
+    @Value("${swagger.description}")
+    public  String swaggerDescription;
+
+    @Value("${swagger.version}")
+    public  String swaggerVersion;
+
+
+
+
+
+
+
+}

+ 55 - 0
gis_common/src/main/java/com/gis/common/constant/ErrorEnum.java

@@ -0,0 +1,55 @@
+package com.gis.common.constant;
+
+/**
+ * Created by owen on 2022/3/10 0010 14:47
+ *
+ *
+ * #1000~1999 区间表示参数错误
+ * #2000~2999 区间表示用户错误
+ * #3000~3999 区间表示接口异常
+ */
+public enum ErrorEnum {
+
+    FAILURE_SYS_2001(2001, "对象不存在"),
+
+    FAILURE_CODE_3001(3001, "缺少必要参数"),
+    FAILURE_CODE_3002(3002, "访问异常!"),
+    FAILURE_CODE_3003(3003, "非法访问!"),
+    FAILURE_CODE_3004(3004, "用户未登录"),
+    FAILURE_CODE_3005(3005, "验证码已过期"),
+    FAILURE_CODE_3006(3006, "验证码错误"),
+    FAILURE_CODE_3007(3007, "昵称已存在"),
+    FAILURE_CODE_3008(3008, "该手机已被注册"),
+    FAILURE_CODE_3009(3009, "两次输入的密码不一致"),
+    FAILURE_CODE_3010(3010, "昵称长度错误"),
+    FAILURE_CODE_3011(3011, "密码需要包含英文大小写、数字,长度8-16字符"),
+    FAILURE_CODE_3012(3012, "昵称包含敏感词"),
+    FAILURE_CODE_3013(3013, "手机号码格式错误"),
+    FAILURE_CODE_3014(3014, "账号或密码不正确"),
+    FAILURE_CODE_3015(3015, "用户不存在"),
+    FAILURE_CODE_3016(3016, "登录失败,账号无权访问"),
+    FAILURE_CODE_3017(3017, "空文件"),
+    FAILURE_CODE_3018(3018, "需要上传或使用的文件不存在"),
+
+    ;
+
+    private Integer code;
+    private String message;
+
+    private ErrorEnum(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public Integer code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public String formatMessage(Object... args){
+        return String.format(message, args);
+    }
+}

+ 25 - 0
gis_common/src/main/java/com/gis/common/constant/MsgCode.java

@@ -0,0 +1,25 @@
+package com.gis.common.constant;
+
+/**
+ * Created by owen on 2021/6/1 0001 16:45
+ */
+public class MsgCode {
+
+    /** 对象不存在*/
+    public static final Integer e3001 = 3001;
+
+    /** 数据量超长*/
+    public static final Integer e3002 = 3002;
+
+    /** 空目录*/
+    public static final Integer e3003 = 3003;
+
+    /** 状态非法*/
+    public static final Integer e3004 = 3004;
+
+    /** 验证码失效*/
+    public static final Integer e3005 = 3005;
+
+    /** 该臧品在使用中*/
+    public static final Integer e3006 = 3006;
+}

+ 26 - 0
gis_common/src/main/java/com/gis/common/constant/SysEnum.java

@@ -0,0 +1,26 @@
+package com.gis.common.constant;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Created by owen on 2022/4/12 0010 14:47
+ * 系统枚举
+ */
+@Getter
+@AllArgsConstructor
+public enum SysEnum {
+
+    LOGIN_TYPE_KEY("loginType", "登录类型Key"),
+    LOGIN_TYPE_WX("wx", "微信登录"),
+    LOGIN_TYPE_CMS("cms", "管理后台登录"),
+
+    TOKEN_KEY("token", "token key"),
+
+    ;
+
+    private String value;
+    private String msg;
+
+
+}

+ 32 - 0
gis_common/src/main/java/com/gis/common/constant/TypeCode.java

@@ -0,0 +1,32 @@
+package com.gis.common.constant;
+
+/**
+ * Created by owen on 2021/12/09 0014 8:56
+ */
+public class TypeCode {
+
+
+
+    // 工地监控
+    public static final String MODULE_SITE = "site";
+
+    // 安防管理
+    public static final String MODULE_SECURITY = "security";
+
+    // 无人机巡检
+    public static final String MODULE_AERIAL = "aerial";
+
+    /**redis wxToken 前缀*/
+    public static final String REDIS_LOGIN_WXTOKEN = "wxToken:";
+
+    /**redis wx用户 前缀*/
+    public static  final String WX_USER_KEY = "wx:user_";
+
+    /**redis 用户 */
+    public static  final String USER_KEY = "user_";
+
+
+
+
+
+}

+ 107 - 0
gis_common/src/main/java/com/gis/common/util/Base64Converter.java

@@ -0,0 +1,107 @@
+package com.gis.common.util;
+
+import org.junit.Test;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+
+/**
+ * Created by Hb_zzZ on 2020/4/17.
+ */
+public class Base64Converter {
+
+    final static Base64.Encoder encoder = Base64.getEncoder();
+    final static Base64.Decoder decoder = Base64.getDecoder();
+
+    /**
+     * 给字符串加密
+     * @param text
+     * @return
+     */
+    public static String encode(String text) {
+        byte[] textByte = new byte[0];
+        try {
+            textByte = text.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        String encodedText = encoder.encodeToString(textByte);
+        return encodedText;
+    }
+
+    /**
+     * 将加密后的字符串进行解密
+     * @param encodedText
+     * @return
+     */
+    public static String decode(String encodedText) {
+        String text = null;
+        try {
+            text = new String(decoder.decode(encodedText), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return text;
+    }
+
+    /**
+     * 根据逻辑截取加密后的密码
+     * @param text
+     * @return
+     */
+    public static String subText(String text){
+        //去掉前8位字符串
+        text = text.substring(8);
+        //去掉后8位字符串
+        text = text.substring(0, text.length() - 8);
+        //最后两个字符串换到前面,并且去掉剩下的后8位字符串
+        String result = text.substring(text.length() - 2) + text.substring(0, text.length() - 10);
+        return result;
+    }
+
+    public static void main(String[] args) throws UnsupportedEncodingException {
+
+//        String username = "Miracle Luna";
+//        String password = "AUPhhlhkExMTExMTExMQ==tGC1irnLMTLF9V7HLh";
+        String password = "1UxELRpIExMTExcWG627AcMTQBIN2mog";
+
+        password = password.substring(8);
+        System.out.println(password);
+        password = password.substring(0, password.length() - 8);
+        System.out.println(password);
+        String key = password.substring(password.length() - 2) + password.substring(0, password.length() - 10);
+        System.out.println(key);
+
+
+        // 加密
+//        System.out.println("====  [加密后] 用户名/密码  =====");
+//        System.out.println(Base64Converter.encode(username));
+//        System.out.println(Base64Converter.encode(password));
+
+        // 解密
+        System.out.println("\n====  [解密后] 用户名/密码  =====");
+//        System.out.println(Base64Converter.decode(Base64Converter.encode(username)));
+        System.out.println(Base64Converter.decode(key));
+    }
+
+
+    @Test
+    public void test(){
+        String password = "Ie233eCnIzNDU2ltskQTN0MTmMK8XMNV";
+        System.out.println(decodePassword(password));
+    }
+
+
+    /**
+     *
+     *
+     * 将加密后的字符串进行解密
+     * @param ciphertext 密文
+     * @return 明文
+     */
+    public static String decodePassword(String ciphertext){
+        String key = subText(ciphertext);
+        return decode(key);
+
+    }
+}

+ 20 - 0
gis_common/src/main/java/com/gis/common/util/BaseUtil.java

@@ -0,0 +1,20 @@
+package com.gis.common.util;
+
+import com.gis.common.base.entity.dto.PageDto;
+
+/**
+ * Created by owen on 2021/12/7 0007 16:21
+ */
+public class BaseUtil {
+
+    public static void startPage(PageDto param){
+        Integer pageNum = param.getPageNum();
+        Integer pageSize = param.getPageSize();
+        if (pageNum == null || pageNum <= 0) {
+            param.setPageNum(0);
+        }
+        if (pageSize == null || pageSize <= 0) {
+            param.setPageSize(10);
+        }
+    }
+}

+ 69 - 0
gis_common/src/main/java/com/gis/common/util/DateUtils.java

@@ -0,0 +1,69 @@
+package com.gis.common.util;
+
+import cn.hutool.core.date.DateUtil;
+import org.junit.Test;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * Created by owen on 2022/4/8 0008 14:32
+ */
+public class DateUtils extends DateUtil {
+
+    private static String YYYY_MM = "yyyy-MM";
+
+    private static String YYYYMM = "yyyyMM";
+
+    private static String YYYY_MM_DD = "yyyy-MM-dd";
+
+    private static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
+
+
+    private static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+
+    private static String YYYYMMDD_HHMMSSSSS = "yyyyMMdd_HHmmssSSS";
+
+    private static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+
+
+    /**
+     * 获取当前月
+     * @return
+     */
+    public static String getMonth(){
+        return format(LocalDateTime.now(), YYYYMM);
+    }
+
+    /**
+     * 获取当前月份的前几个月
+     * @param month
+     * @return
+     */
+    public static String minusMonths(int month){
+        return format(LocalDateTime.now().minusMonths(month), YYYYMM);
+    }
+
+    /**
+     * 获取当前时间戳
+     * @return
+     */
+    public static String getDateTime(){
+        return format(LocalDateTime.now(), YYYYMMDD_HHMMSSSSS);
+    }
+
+
+    /**
+     * 字符串转LocalDateTime
+     * @param time 字符串
+     * @return LocalDateTime
+     */
+    public static LocalDateTime srtToLocalDateTime(String time){
+        return LocalDateTime.parse(time, DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM));
+    }
+
+    @Test
+    public void test(){
+        System.out.println(srtToLocalDateTime("2022-02-16 12:26"));
+    }
+}

+ 65 - 0
gis_common/src/main/java/com/gis/common/util/ExcelUtils.java

@@ -0,0 +1,65 @@
+package com.gis.common.util;
+
+import cn.hutool.poi.excel.ExcelReader;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
+import com.gis.common.base.exception.BaseRuntimeException;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by owen on 2022/2/8 0008 15:50
+ */
+@Slf4j
+public class ExcelUtils {
+
+    /**
+     * 写
+     * @param rows 每行数据
+     * @param savePath 保存地址 xxx.xlsx
+     * @param rowTitle 标题
+     */
+    public static void createExcel(List rows, String savePath, Map<String, String> rowTitle) {
+        log.info("rows size: {}", rows.size());
+//        log.info("savePath: {}", savePath);
+        ExcelWriter writer = ExcelUtil.getWriter(savePath);
+
+        //自定义标题别名
+        if (rowTitle != null) {
+            for (Map.Entry<String, String> a : rowTitle.entrySet()) {
+                writer.addHeaderAlias(a.getKey(), a.getValue());
+            }
+        }
+
+        // 一次性写出内容,使用默认样式,强制输出标题
+        writer.write(rows, true);
+        // 关闭writer,释放内存
+        writer.close();
+        log.info("excel完成:" +  savePath);
+
+    }
+
+
+    /**
+     * 读取每一行
+     */
+    public static List<List<Object>> readExcel(String filePath) {
+        log.info("文件地址: {}", filePath);
+//        filePath = filePath.toLowerCase();
+        if (!filePath.endsWith(".xlsx")){
+            throw new BaseRuntimeException("非法文件");
+        }
+        // 默认读第一个sheet
+        ExcelReader reader = ExcelUtil.getReader(filePath);
+        // 读取Excel中所有行和列,都用列表表示
+        List<List<Object>> read = reader.read();
+
+        log.info("读取excel完成" );
+        return read;
+
+    }
+
+
+}

+ 115 - 0
gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -0,0 +1,115 @@
+package com.gis.common.util;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.constant.ConfigConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * Created by owen on 2020/5/12 0012 17:21
+ */
+@Slf4j
+@Component
+public class FileUtils {
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    // 确保同一时间上传文件的唯一性
+    private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger();
+
+    public boolean checkFile(MultipartFile file) {
+        //设置允许上传文件类型
+        String suffixList = configConstant.serverFileFallow;
+        // 获取文件后缀
+        if(file == null){
+            log.error("文件流为空不可上传");
+            return false;
+        }
+        String fileName = file.getOriginalFilename();
+        String suffix = fileName.substring(fileName.lastIndexOf(".")
+                + 1, fileName.length());
+        if (suffixList.contains(suffix.trim().toLowerCase())) {
+            log.info("无非法参数可以放行!!!");
+            return true;
+        }
+        log.error("存在非法参数不能放行!请核对上传文件格式,重新刷新页面再次上传!输入文件后缀: {}", suffix);
+        return false;
+    }
+
+
+    /**
+     *
+     * @param file
+     * @param isPinYinRename false:时间戳重命名, true:用拼音重名文件
+     * @param savePath 保存地址(前面有斜杠, 后面没有),没有文件名
+     * @return 文件名
+     */
+    public String upload(MultipartFile file, String savePath, boolean isPinYinRename) {
+
+        // 检查非法文件上传
+        boolean checkFile = this.checkFile(file);
+        if (!checkFile) {
+            throw new BaseRuntimeException("上传文件格式有误, 请重新上传");
+        }
+
+        // 文件目录
+        String fileName = file.getOriginalFilename();
+        String newName;
+        if (isPinYinRename){
+             newName = RegexUtil.getPinyinName(fileName);
+        } else {
+//            String suffix = StrUtil.substringAfterLast(fileName, ".");
+            String suffix = StrUtil.subAfter(fileName, ".", true);
+            newName =  DateUtils.getDateTime() + ATOMIC_INTEGER.incrementAndGet() + "." + suffix;
+        }
+
+        savePath = configConstant.serverBasePath + savePath + "/" + newName;
+        log.info("保存文件地址:{}", savePath);
+
+        try {
+            FileUtil.writeFromStream(file.getInputStream(), savePath);
+
+            return newName;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @param file
+     * @param isPinYinRename false:时间戳重命名, true:用拼音重名文件
+     * @param savePath 保存地址(前面有斜杠, 后面没有),没有文件名
+     * @return map
+     */
+    public Map<String, Object> uploadMap(MultipartFile file, String savePath, boolean isPinYinRename) {
+        String newName = this.upload(file, savePath, isPinYinRename);
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("fileName", file.getOriginalFilename());
+        result.put("filePath", savePath + "/" + newName);
+        return result;
+
+    }
+
+    /**
+     * 真删除文件
+     * @param path 参数是相对地址
+     */
+    public void del(String path){
+        String delPath = configConstant.serverBasePath + path;
+        FileUtil.del(delPath);
+        log.info("真删除文件: {}", delPath);
+    }
+
+}

+ 0 - 0
gis_common/src/main/java/com/gis/common/util/JwtUtil.java


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott