张涛 1 year ago
commit
35de9f48f1
100 changed files with 6133 additions and 0 deletions
  1. 35
    0
      .gitignore
  2. 155
    0
      application/pom.xml
  3. 29
    0
      application/src/main/java/com/lyg/YZApplication.java
  4. 139
    0
      application/src/main/java/com/lyg/application/controller/CustomerBirthdayController.java
  5. 142
    0
      application/src/main/java/com/lyg/application/controller/CustomerBirthdayManageController.java
  6. 120
    0
      application/src/main/java/com/lyg/application/controller/CustomerPingLogController.java
  7. 134
    0
      application/src/main/java/com/lyg/application/controller/UploadController.java
  8. 87
    0
      application/src/main/java/com/lyg/application/dao/UploadDataListener.java
  9. 62
    0
      application/src/main/java/com/lyg/application/dao/UploadDataListenerManage.java
  10. 32
    0
      application/src/main/java/com/lyg/application/dto/CustomerExcelDTO.java
  11. 35
    0
      application/src/main/java/com/lyg/application/dto/CustomerManageExcelDTO.java
  12. 50
    0
      application/src/main/java/com/lyg/application/entity/CustomerBirthday.java
  13. 38
    0
      application/src/main/java/com/lyg/application/entity/CustomerBirthdayManage.java
  14. 31
    0
      application/src/main/java/com/lyg/application/entity/CustomerPingLog.java
  15. 33
    0
      application/src/main/java/com/lyg/application/job/ProjectOrgDaily.java
  16. 27
    0
      application/src/main/java/com/lyg/application/mapper/CustomerBirthdayManageMapper.java
  17. 24
    0
      application/src/main/java/com/lyg/application/mapper/CustomerBirthdayMapper.java
  18. 15
    0
      application/src/main/java/com/lyg/application/mapper/CustomerPingLogMapper.java
  19. 23
    0
      application/src/main/java/com/lyg/application/service/CustomerBirthdayManageService.java
  20. 21
    0
      application/src/main/java/com/lyg/application/service/CustomerBirthdayService.java
  21. 13
    0
      application/src/main/java/com/lyg/application/service/CustomerPingLogService.java
  22. 62
    0
      application/src/main/java/com/lyg/application/service/impl/CustomerBirthdayManageServiceImpl.java
  23. 69
    0
      application/src/main/java/com/lyg/application/service/impl/CustomerBirthdayServiceImpl.java
  24. 25
    0
      application/src/main/java/com/lyg/application/service/impl/CustomerPingLogServiceImpl.java
  25. 29
    0
      application/src/main/java/com/lyg/application/util/CommMergeStrategy.java
  26. 15
    0
      application/src/main/java/com/lyg/application/vo/RankScoreVo.java
  27. 16
    0
      application/src/main/java/com/lyg/application/vo/RankVo.java
  28. 19
    0
      application/src/main/java/com/lyg/application/vo/ReportFreqVO.java
  29. 70
    0
      application/src/main/resources/application.yml
  30. 31
    0
      application/src/main/resources/mapper/CustomerBirthdayManageMapper.xml
  31. 17
    0
      application/src/main/resources/mapper/CustomerBirthdayMapper.xml
  32. 6
    0
      application/src/main/resources/mapper/CustomerPingLogMapper.xml
  33. 48
    0
      common/pom.xml
  34. 15
    0
      common/src/main/java/com/lyg/common/Constants.java
  35. 145
    0
      common/src/main/java/com/lyg/common/util/DateUtil.java
  36. 17
    0
      common/src/main/java/com/lyg/common/util/EncryptUtil.java
  37. 53
    0
      common/src/main/java/com/lyg/common/util/FileUtil.java
  38. 72
    0
      common/src/main/java/com/lyg/common/util/IpUtil.java
  39. 20
    0
      common/src/main/java/com/lyg/common/util/MyPropertySourceFactory.java
  40. 211
    0
      common/src/main/java/com/lyg/common/util/StringUtil.java
  41. 70
    0
      common/src/main/java/com/lyg/common/util/excel/CellWidthWriteHandler.java
  42. 40
    0
      common/src/main/java/com/lyg/common/util/excel/DateConverter.java
  43. 36
    0
      common/src/main/java/com/lyg/common/util/excel/DownloadExcel.java
  44. 78
    0
      common/src/main/java/com/lyg/common/util/excel/ExcelUtil.java
  45. 39
    0
      common/src/main/java/com/lyg/common/util/excel/LocalDateTimeConverter.java
  46. 40
    0
      common/src/main/java/com/lyg/common/util/excel/TimestampConverter.java
  47. 344
    0
      db/ddl.sql
  48. 116
    0
      framework/pom.xml
  49. 20
    0
      framework/src/main/java/com/lyg/framework/accesslimit/AccessLimit.java
  50. 77
    0
      framework/src/main/java/com/lyg/framework/accesslimit/AccessLimitInterceptor.java
  51. 25
    0
      framework/src/main/java/com/lyg/framework/accesslimit/IntercepterConfig.java
  52. 14
    0
      framework/src/main/java/com/lyg/framework/config/FilterConfig.java
  53. 31
    0
      framework/src/main/java/com/lyg/framework/config/LocalDateTimeSerializerConfig.java
  54. 24
    0
      framework/src/main/java/com/lyg/framework/config/SwaggerConfig.java
  55. 16
    0
      framework/src/main/java/com/lyg/framework/config/TenantConfig.java
  56. 11
    0
      framework/src/main/java/com/lyg/framework/config/_Config.java
  57. 42
    0
      framework/src/main/java/com/lyg/framework/exception/GlobalExceptionHandler.java
  58. 27
    0
      framework/src/main/java/com/lyg/framework/log/OpLog.java
  59. 108
    0
      framework/src/main/java/com/lyg/framework/log/OpLogAspect.java
  60. 69
    0
      framework/src/main/java/com/lyg/framework/mybatisplus/MyMetaObjectHandler.java
  61. 64
    0
      framework/src/main/java/com/lyg/framework/mybatisplus/MybatisPlusConfig.java
  62. 42
    0
      framework/src/main/java/com/lyg/framework/satoken/SaServletFilter2.java
  63. 50
    0
      framework/src/main/java/com/lyg/framework/satoken/SaTokenConfigure.java
  64. 15
    0
      framework/src/main/java/com/lyg/framework/satoken/SaTokenInterceptor.java
  65. 7
    0
      framework/src/main/java/com/lyg/framework/service/IOpLogService.java
  66. 35
    0
      framework/src/main/java/com/lyg/framework/service/IUserService.java
  67. 67
    0
      framework/src/main/resources/framework.yml
  68. 62
    0
      framework/src/main/resources/logback-spring.xml
  69. 316
    0
      mvnw
  70. 188
    0
      mvnw.cmd
  71. 38
    0
      pom.xml
  72. 38
    0
      system/pom.xml
  73. 122
    0
      system/src/main/java/com/lyg/system/controller/BaseController.java
  74. 69
    0
      system/src/main/java/com/lyg/system/controller/SysLogController.java
  75. 56
    0
      system/src/main/java/com/lyg/system/controller/SysMenuController.java
  76. 160
    0
      system/src/main/java/com/lyg/system/controller/SysOrgController.java
  77. 122
    0
      system/src/main/java/com/lyg/system/controller/SysPositionController.java
  78. 162
    0
      system/src/main/java/com/lyg/system/controller/SysRoleController.java
  79. 95
    0
      system/src/main/java/com/lyg/system/controller/SysRoleResourceController.java
  80. 207
    0
      system/src/main/java/com/lyg/system/controller/SysUserController.java
  81. 80
    0
      system/src/main/java/com/lyg/system/controller/SysUserRoleController.java
  82. 61
    0
      system/src/main/java/com/lyg/system/entity/SysLog.java
  83. 69
    0
      system/src/main/java/com/lyg/system/entity/SysMenu.java
  84. 82
    0
      system/src/main/java/com/lyg/system/entity/SysOrg.java
  85. 73
    0
      system/src/main/java/com/lyg/system/entity/SysPosition.java
  86. 62
    0
      system/src/main/java/com/lyg/system/entity/SysRole.java
  87. 48
    0
      system/src/main/java/com/lyg/system/entity/SysRoleResource.java
  88. 96
    0
      system/src/main/java/com/lyg/system/entity/SysUser.java
  89. 43
    0
      system/src/main/java/com/lyg/system/entity/SysUserRole.java
  90. 15
    0
      system/src/main/java/com/lyg/system/mapper/SysLogMapper.java
  91. 20
    0
      system/src/main/java/com/lyg/system/mapper/SysMenuMapper.java
  92. 24
    0
      system/src/main/java/com/lyg/system/mapper/SysOrgMapper.java
  93. 15
    0
      system/src/main/java/com/lyg/system/mapper/SysPositionMapper.java
  94. 23
    0
      system/src/main/java/com/lyg/system/mapper/SysRoleMapper.java
  95. 25
    0
      system/src/main/java/com/lyg/system/mapper/SysRoleResourceMapper.java
  96. 14
    0
      system/src/main/java/com/lyg/system/mapper/SysUserMapper.java
  97. 24
    0
      system/src/main/java/com/lyg/system/mapper/SysUserRoleMapper.java
  98. 20
    0
      system/src/main/java/com/lyg/system/service/IBaseService.java
  99. 12
    0
      system/src/main/java/com/lyg/system/service/SysLogService.java
  100. 0
    0
      system/src/main/java/com/lyg/system/service/SysMenuService.java

+ 35
- 0
.gitignore View File

@@ -0,0 +1,35 @@
1
+HELP.md
2
+target/
3
+!.mvn/wrapper/maven-wrapper.jar
4
+!**/src/main/**/target/
5
+!**/src/test/**/target/
6
+
7
+### STS ###
8
+.apt_generated
9
+.classpath
10
+.factorypath
11
+.project
12
+.settings
13
+.springBeans
14
+.sts4-cache
15
+
16
+### IntelliJ IDEA ###
17
+.idea
18
+*.iws
19
+*.iml
20
+*.ipr
21
+
22
+*.log
23
+
24
+### NetBeans ###
25
+/nbproject/private/
26
+/nbbuild/
27
+/dist/
28
+/nbdist/
29
+/.nb-gradle/
30
+build/
31
+!**/src/main/**/build/
32
+!**/src/test/**/build/
33
+
34
+### VS Code ###
35
+.vscode/

+ 155
- 0
application/pom.xml View File

@@ -0,0 +1,155 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <parent>
6
+        <artifactId>demo</artifactId>
7
+        <groupId>com.lyg</groupId>
8
+        <version>0.0.1</version>
9
+    </parent>
10
+    <modelVersion>4.0.0</modelVersion>
11
+
12
+    <artifactId>application</artifactId>
13
+
14
+    <properties>
15
+        <maven.compiler.source>8</maven.compiler.source>
16
+        <maven.compiler.target>8</maven.compiler.target>
17
+    </properties>
18
+
19
+    <dependencies>
20
+        <dependency>
21
+            <groupId>com.lyg</groupId>
22
+            <artifactId>common</artifactId>
23
+            <version>0.0.1</version>
24
+            <scope>compile</scope>
25
+        </dependency>
26
+        <dependency>
27
+            <groupId>com.lyg</groupId>
28
+            <artifactId>framework</artifactId>
29
+            <version>0.0.1</version>
30
+            <scope>compile</scope>
31
+        </dependency>
32
+        <dependency>
33
+            <groupId>com.lyg</groupId>
34
+            <artifactId>system</artifactId>
35
+            <version>0.0.1</version>
36
+            <scope>compile</scope>
37
+        </dependency>
38
+    </dependencies>
39
+
40
+    <build>
41
+        <plugins>
42
+
43
+            <!-- 只打包业务代码 -->
44
+            <plugin>
45
+                <groupId>org.springframework.boot</groupId>
46
+                <artifactId>spring-boot-maven-plugin</artifactId>
47
+                <configuration>
48
+                    <layout>ZIP</layout>
49
+                    <includeSystemScope>true</includeSystemScope>
50
+                    <mainClass>com.lyg.YZApplication</mainClass>
51
+                    <includes>
52
+                        <include>
53
+                            <groupId>com.lyg</groupId>
54
+                            <artifactId>common</artifactId>
55
+                        </include>
56
+                        <include>
57
+                            <groupId>com.lyg</groupId>
58
+                            <artifactId>framework</artifactId>
59
+                        </include>
60
+                        <include>
61
+                            <groupId>com.lyg</groupId>
62
+                            <artifactId>system</artifactId>
63
+                        </include>
64
+                    </includes>
65
+                    <excludes>
66
+                        <exclude>
67
+                            <groupId>org.projectlombok</groupId>
68
+                            <artifactId>lombok</artifactId>
69
+                        </exclude>
70
+                    </excludes>
71
+                </configuration>
72
+                <executions>
73
+                    <execution>
74
+                        <goals>
75
+                            <goal>repackage</goal>
76
+                        </goals>
77
+                    </execution>
78
+                </executions>
79
+            </plugin>
80
+
81
+            <!-- 跳过单元测试 -->
82
+            <plugin>
83
+                <groupId>org.apache.maven.plugins</groupId>
84
+                <artifactId>maven-surefire-plugin</artifactId>
85
+                <configuration>
86
+                    <skipTests>true</skipTests>
87
+                </configuration>
88
+            </plugin>
89
+
90
+            <!-- 第三方依赖包单独打包 -->
91
+            <plugin>
92
+                <groupId>org.apache.maven.plugins</groupId>
93
+                <artifactId>maven-dependency-plugin</artifactId>
94
+                <executions>
95
+                    <execution>
96
+                        <id>copy-dependencies</id>
97
+                        <phase>package</phase>
98
+                        <goals>
99
+                            <goal>copy-dependencies</goal>
100
+                        </goals>
101
+                        <configuration>
102
+                            <outputDirectory>target/lib</outputDirectory>
103
+                            <stripVersion>false</stripVersion>
104
+                            <!-- 不包含哪些jar包 -->
105
+                            <excludeGroupIds>
106
+                                <!-- 只排除业务模块相关的jar包,多个用英文逗号分割-->
107
+                                com.lyg
108
+                            </excludeGroupIds>
109
+                        </configuration>
110
+                    </execution>
111
+                </executions>
112
+            </plugin>
113
+
114
+            <!-- 把配置文件单独拷贝出来 -->
115
+            <plugin>
116
+                <groupId>org.apache.maven.plugins</groupId>
117
+                <artifactId>maven-resources-plugin</artifactId>
118
+                <executions>
119
+                    <execution>
120
+                        <id>copy-resources</id>
121
+                        <phase>package</phase>
122
+                        <goals>
123
+                            <goal>copy-resources</goal>
124
+                        </goals>
125
+                        <configuration>
126
+                            <outputDirectory>target/config</outputDirectory>
127
+                            <resources>
128
+                                <resource>
129
+                                    <directory>./src/main/resources</directory>
130
+                                </resource>
131
+                                <resource>
132
+                                    <directory>../framework/src/main/resources</directory>
133
+                                </resource>
134
+                            </resources>
135
+                        </configuration>
136
+                    </execution>
137
+                </executions>
138
+            </plugin>
139
+        </plugins>
140
+        <resources>
141
+            <resource>
142
+                <directory>./src/main/resources/</directory>
143
+                <includes>
144
+                    <include>**/**</include>
145
+                </includes>
146
+            </resource>
147
+            <resource>
148
+                <directory>../framework/src/main/resources/</directory>
149
+                <includes>
150
+                    <include>**/**</include>
151
+                </includes>
152
+            </resource>
153
+        </resources>
154
+    </build>
155
+</project>

+ 29
- 0
application/src/main/java/com/lyg/YZApplication.java View File

@@ -0,0 +1,29 @@
1
+package com.lyg;
2
+
3
+
4
+import com.lyg.common.util.MyPropertySourceFactory;
5
+import org.mybatis.spring.annotation.MapperScan;
6
+import org.springframework.boot.SpringApplication;
7
+import org.springframework.boot.autoconfigure.SpringBootApplication;
8
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
9
+import org.springframework.context.annotation.Configuration;
10
+import org.springframework.context.annotation.PropertySource;
11
+import org.springframework.scheduling.annotation.EnableAsync;
12
+import org.springframework.scheduling.annotation.EnableScheduling;
13
+import org.springframework.transaction.annotation.EnableTransactionManagement;
14
+
15
+@EnableAsync
16
+@EnableScheduling
17
+@EnableTransactionManagement
18
+@EnableConfigurationProperties
19
+@MapperScan({"com.lyg.**.mapper"})
20
+@SpringBootApplication(scanBasePackages = {"com.lyg"})
21
+//@PropertySource(value = {"framework.yml"}, factory = MyPropertySourceFactory.class)
22
+//@Configuration
23
+public class YZApplication {
24
+
25
+	public static void main(String[] args) {
26
+		SpringApplication.run(YZApplication.class, args);
27
+	}
28
+
29
+}

+ 139
- 0
application/src/main/java/com/lyg/application/controller/CustomerBirthdayController.java View File

@@ -0,0 +1,139 @@
1
+package com.lyg.application.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.application.entity.CustomerBirthday;
8
+import com.lyg.application.entity.CustomerBirthdayManage;
9
+import com.lyg.application.service.CustomerBirthdayService;
10
+import com.lyg.common.util.StringUtil;
11
+import com.lyg.framework.accesslimit.AccessLimit;
12
+import com.lyg.framework.log.OpLog;
13
+import com.lyg.system.controller.BaseController;
14
+import io.swagger.annotations.Api;
15
+import io.swagger.annotations.ApiOperation;
16
+import io.swagger.annotations.ApiParam;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.validation.annotation.Validated;
19
+import org.springframework.web.bind.annotation.*;
20
+
21
+import java.util.List;
22
+
23
+/**
24
+ * CustomerBirthday;(CustomerBirthday)表控制层
25
+ *
26
+ * @author : http://njyunzhi.com
27
+ * @date : 2024-1-29
28
+ */
29
+@Api(tags = "客户生日表对象功能接口")
30
+@RestController
31
+@RequestMapping("/")
32
+public class CustomerBirthdayController extends BaseController {
33
+
34
+    @Autowired
35
+    private CustomerBirthdayService customerBirthdayService;
36
+
37
+    /**
38
+     * 通过ID查询单条数据
39
+     *
40
+     * @param id 主键
41
+     * @return 实例对象
42
+     */
43
+    @OpLog(module = "CustomerBirthday", action = "查询单条数据", desc = "ID:{{#id}}")
44
+    @AccessLimit()
45
+    @ApiOperation("通过ID查询单条数据")
46
+    @GetMapping("/customerBir/{id}")
47
+    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
48
+        return SaResult.data(customerBirthdayService.getById(id));
49
+    }
50
+
51
+    /**
52
+     * 分页查询
53
+     *
54
+     * @param pageNum  当前页码
55
+     * @param pageSize 每页条数
56
+     * @return 查询结果
57
+     */
58
+    @OpLog(module = "CustomerBirthday", action = "分页列表查询")
59
+    @AccessLimit()
60
+    @ApiOperation("分页查询")
61
+    @GetMapping("/customerBir")
62
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
63
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
64
+//                         @ApiParam("身份证号") @RequestParam(value = "idNum", required = false) String idNum,
65
+                         @ApiParam("客户姓名") @RequestParam(value = "name", required = false) String name,
66
+                         @ApiParam("客户号") @RequestParam(value = "custId", required = false) String custId,
67
+                         @ApiParam("客户标志位辅助匹配客户经理") @RequestParam(value = "custClass", required = false) String custClass,
68
+                         @ApiParam("倒序排列") @RequestParam(value = "sortAsc", required = false) String sortAsc) throws Exception {
69
+
70
+        IPage<CustomerBirthday> pg = new Page<>(pageNum, pageSize);
71
+        QueryWrapper<CustomerBirthday> queryWrapper = new QueryWrapper<>();
72
+        queryWrapper.like(StringUtil.isNotEmpty(name), "name", name);
73
+        queryWrapper.like(StringUtil.isNotEmpty(custId), "cust_id", custId);
74
+        queryWrapper.like(StringUtil.isNotEmpty(custClass), "cust_class", custClass);
75
+        queryWrapper.orderByDesc("cust_id");
76
+        IPage<CustomerBirthday> result = customerBirthdayService.page(pg, queryWrapper);
77
+
78
+        return SaResult.data(result);
79
+    }
80
+
81
+    /**
82
+     * 新增数据
83
+     *
84
+     * @param customerBirthday 实例对象
85
+     * @return 实例对象
86
+     */
87
+    @OpLog(module = "CustomerBirthday", action = "新增数据")
88
+    @AccessLimit()
89
+    @ApiOperation("新增数据")
90
+    @PostMapping("/customerBir")
91
+    public SaResult add(@ApiParam("对象实体") @Validated @RequestBody CustomerBirthday customerBirthday) throws Exception {
92
+        String idNum = customerBirthday.getIdNum();
93
+
94
+        QueryWrapper<CustomerBirthday> queryWrapper = new QueryWrapper<>();
95
+        queryWrapper.eq("id_num", idNum);
96
+        List<CustomerBirthday> customerBirthdayList = customerBirthdayService.list(queryWrapper);
97
+
98
+        if (customerBirthdayList.size() >= 1) {
99
+            throw new Exception("请勿重复录入客户");
100
+        }
101
+
102
+        customerBirthdayService.save(customerBirthday);
103
+        return SaResult.data(customerBirthday);
104
+    }
105
+
106
+    /**
107
+     * 更新数据
108
+     *
109
+     * @param customerBirthday 实例对象
110
+     * @return 实例对象
111
+     */
112
+    @OpLog(module = "CustomerBirthday", action = "更新数据")
113
+    @AccessLimit()
114
+    @ApiOperation("更新数据")
115
+    @PutMapping("/customerBir/{id}")
116
+    public SaResult edit(@ApiParam("对象实体") @Validated @RequestBody CustomerBirthday customerBirthday,
117
+                         @ApiParam("对象ID") @PathVariable String id) throws Exception {
118
+        customerBirthday.setCustId(id);
119
+        customerBirthdayService.updateById(customerBirthday);
120
+        return SaResult.data(customerBirthday);
121
+    }
122
+
123
+    /**
124
+     * 通过主键删除数据
125
+     *
126
+     * @param id 主键
127
+     * @return 是否成功
128
+     */
129
+    @OpLog(module = "CustomerBirthday", action = "删除数据", desc = "ID:{{#id}}")
130
+    @AccessLimit()
131
+    @ApiOperation("通过主键删除数据")
132
+    @DeleteMapping("/customerBir/{id}")
133
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
134
+        customerBirthdayService.removeById(id);
135
+        return SaResult.data("success");
136
+    }
137
+
138
+
139
+}

+ 142
- 0
application/src/main/java/com/lyg/application/controller/CustomerBirthdayManageController.java View File

@@ -0,0 +1,142 @@
1
+package com.lyg.application.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.application.entity.CustomerBirthdayManage;
8
+import com.lyg.application.service.CustomerBirthdayManageService;
9
+import com.lyg.common.util.StringUtil;
10
+import com.lyg.framework.accesslimit.AccessLimit;
11
+import com.lyg.framework.log.OpLog;
12
+import com.lyg.system.controller.BaseController;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiOperation;
15
+import io.swagger.annotations.ApiParam;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.validation.annotation.Validated;
18
+import org.springframework.web.bind.annotation.*;
19
+
20
+import java.util.List;
21
+
22
+/**
23
+ * 客户生日维护经理表;(客户生日维护经理表)表控制层
24
+ *
25
+ * @author : http://njyunzhi.com
26
+ * @date : 2024-1-29
27
+ */
28
+@Api(tags = "客户生日维护经理表对象功能接口")
29
+@RestController
30
+@RequestMapping("/")
31
+public class CustomerBirthdayManageController extends BaseController {
32
+
33
+    @Autowired
34
+    private CustomerBirthdayManageService customerBirthdayManageService;
35
+
36
+    /**
37
+     * 通过ID查询单条数据
38
+     *
39
+     * @param phone 主键
40
+     * @return 实例对象
41
+     */
42
+    @OpLog(module = "客户生日维护经理表", action = "查询单条数据", desc = "ID:{{#id}}")
43
+    @AccessLimit()
44
+    @ApiOperation("通过ID查询单条数据")
45
+    @GetMapping("/customerBirManage/{phone}")
46
+    public SaResult queryById(@ApiParam("对象phone") @PathVariable String phone) throws Exception {
47
+
48
+        CustomerBirthdayManage customerBirthdayManage = customerBirthdayManageService.getByPhone(phone);
49
+
50
+
51
+        return SaResult.data(customerBirthdayManage);
52
+    }
53
+
54
+    /**
55
+     * 分页查询
56
+     *
57
+     * @param pageNum  当前页码
58
+     * @param pageSize 每页条数
59
+     * @return 查询结果
60
+     */
61
+    @OpLog(module = "客户生日维护经理表", action = "分页列表查询")
62
+    @AccessLimit()
63
+    @ApiOperation("分页查询")
64
+    @GetMapping("/customerBirManage")
65
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
66
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
67
+                         @ApiParam("手机号") @RequestParam(value = "phoneNo", required = false) Integer phoneNo,
68
+                         @ApiParam("员工姓名") @RequestParam(value = "name", required = false) String name,
69
+                         @ApiParam("客户标志位辅助匹配客户经理") @RequestParam(value = "custClass", required = false) String custClass,
70
+                         @ApiParam("正序排列") @RequestParam(value = "sortAsc", required = false) String sortAsc
71
+    ) throws Exception {
72
+
73
+        IPage<CustomerBirthdayManage> pg = new Page<>(pageNum, pageSize);
74
+        QueryWrapper<CustomerBirthdayManage> queryWrapper = new QueryWrapper<>();
75
+        queryWrapper.like(StringUtil.isNotEmpty(name), "name", name);
76
+        queryWrapper.like(StringUtil.isNotEmpty(custClass), "cust_class", custClass);
77
+        queryWrapper.like(StringUtil.isNotEmpty(String.valueOf(phoneNo)), "phone_no", phoneNo);
78
+        queryWrapper.orderByAsc(StringUtil.isNotEmpty(sortAsc), StringUtil.humpToLine(sortAsc));
79
+        IPage<CustomerBirthdayManage> result = customerBirthdayManageService.page(pg, queryWrapper);
80
+
81
+        return SaResult.data(result);
82
+    }
83
+
84
+    /**
85
+     * 新增数据
86
+     *
87
+     * @param customerBirthdayManage 实例对象
88
+     * @return 实例对象
89
+     */
90
+    @OpLog(module = "客户生日维护经理表", action = "新增数据")
91
+    @AccessLimit()
92
+    @ApiOperation("新增数据")
93
+    @PostMapping("/customerBirManage")
94
+    public SaResult add(@ApiParam("对象实体") @Validated @RequestBody CustomerBirthdayManage customerBirthdayManage) throws Exception {
95
+        Integer phone = customerBirthdayManage.getPhoneNo();
96
+        QueryWrapper<CustomerBirthdayManage> queryWrapper = new QueryWrapper<>();
97
+        queryWrapper.eq("phone_no", phone);
98
+        List<CustomerBirthdayManage> customerBirthdayManageList = customerBirthdayManageService.list(queryWrapper);
99
+
100
+        if (customerBirthdayManageList.size() >= 1) {
101
+            throw new Exception("请勿重复");
102
+        }
103
+
104
+
105
+        customerBirthdayManageService.save(customerBirthdayManage);
106
+        return SaResult.data(customerBirthdayManage);
107
+    }
108
+
109
+    /**
110
+     * 更新数据
111
+     *
112
+     * @param customerBirthdayManage 实例对象
113
+     * @return 实例对象
114
+     */
115
+    @OpLog(module = "客户生日维护经理表", action = "更新数据")
116
+    @AccessLimit()
117
+    @ApiOperation("更新数据")
118
+    @PutMapping("/customerBirManage/{phone}")
119
+    public SaResult edit(@ApiParam("对象实体") @Validated @RequestBody CustomerBirthdayManage customerBirthdayManage,
120
+                         @ApiParam("对象手机号") @PathVariable String phone) throws Exception {
121
+        QueryWrapper<CustomerBirthdayManage> queryWrapper = new QueryWrapper<>();
122
+        queryWrapper.eq("phone_no", phone);
123
+
124
+        customerBirthdayManageService.update(customerBirthdayManage, queryWrapper);
125
+        return SaResult.data(customerBirthdayManage);
126
+    }
127
+
128
+    /**
129
+     * 通过主键删除数据
130
+     *
131
+     * @param phone 主键
132
+     * @return 是否成功
133
+     */
134
+    @OpLog(module = "客户生日维护经理表", action = "删除数据", desc = "ID:{{#id}}")
135
+    @AccessLimit()
136
+    @ApiOperation("通过主键删除数据")
137
+    @DeleteMapping("/customerBirManage/{phone}")
138
+    public SaResult deleteById(@ApiParam("对象手机号") @PathVariable String phone) {
139
+        customerBirthdayManageService.removeByPhone(phone);
140
+        return SaResult.data("success");
141
+    }
142
+}

+ 120
- 0
application/src/main/java/com/lyg/application/controller/CustomerPingLogController.java View File

@@ -0,0 +1,120 @@
1
+package com.lyg.application.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.application.entity.CustomerPingLog;
8
+import com.lyg.application.service.CustomerPingLogService;
9
+import com.lyg.common.util.StringUtil;
10
+import com.lyg.framework.accesslimit.AccessLimit;
11
+import com.lyg.framework.log.OpLog;
12
+import com.lyg.system.controller.BaseController;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiOperation;
15
+import io.swagger.annotations.ApiParam;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.validation.annotation.Validated;
18
+import org.springframework.web.bind.annotation.*;
19
+
20
+/**
21
+ * CustomerPingLog;(CustomerPingLog)表控制层
22
+ *
23
+ * @author : http://njyunzhi.com
24
+ * @date : 2024-1-29
25
+ */
26
+@Api(tags = "营销维护客户发送日志对象功能接口")
27
+@RestController
28
+@RequestMapping("/")
29
+public class CustomerPingLogController extends BaseController {
30
+
31
+    @Autowired
32
+    private CustomerPingLogService customerPingLogService;
33
+
34
+    /**
35
+     * 通过ID查询单条数据
36
+     *
37
+     * @param id 主键
38
+     * @return 实例对象
39
+     */
40
+    @OpLog(module = "CustomerPingLog", action = "查询单条数据", desc = "ID:{{#id}}")
41
+    @AccessLimit()
42
+    @ApiOperation("通过ID查询单条数据")
43
+    @GetMapping("/customerPingLog/{id}")
44
+    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
45
+        return SaResult.data(customerPingLogService.getById(id));
46
+    }
47
+
48
+    /**
49
+     * 分页查询
50
+     *
51
+     * @param pageNum  当前页码
52
+     * @param pageSize 每页条数
53
+     * @return 查询结果
54
+     */
55
+    @OpLog(module = "CustomerPingLog", action = "分页列表查询")
56
+    @AccessLimit()
57
+    @ApiOperation("分页查询")
58
+    @GetMapping("/customerPingLog")
59
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
60
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
61
+                         @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
62
+                         @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
63
+                         @ApiParam("倒序排列") @RequestParam(value = "sortDesc", required = false) String sortDesc) throws Exception {
64
+
65
+        IPage<CustomerPingLog> pg = new Page<>(pageNum, pageSize);
66
+        QueryWrapper<CustomerPingLog> queryWrapper = new QueryWrapper<>();
67
+        queryWrapper.ge(StringUtil.isNotEmpty(startDate), "TO_CHAR(rksj,'YYYY-MM-DD')", startDate).le(StringUtil.isNotEmpty(endDate), "TO_CHAR(rksj,'YYYY-MM-DD')", endDate);
68
+        queryWrapper.orderByDesc("rksj");
69
+        IPage<CustomerPingLog> result = customerPingLogService.page(pg, queryWrapper);
70
+
71
+        return SaResult.data(result);
72
+    }
73
+
74
+    /**
75
+     * 新增数据
76
+     *
77
+     * @param CustomerPingLog 实例对象
78
+     * @return 实例对象
79
+     */
80
+    @OpLog(module = "CustomerPingLog", action = "新增数据")
81
+    @AccessLimit()
82
+    @ApiOperation("新增数据")
83
+    @PostMapping("/CustomerPingLog")
84
+    public SaResult add(@ApiParam("对象实体") @Validated @RequestBody CustomerPingLog CustomerPingLog) throws Exception {
85
+        customerPingLogService.save(CustomerPingLog);
86
+        return SaResult.data(CustomerPingLog);
87
+    }
88
+
89
+    /**
90
+     * 更新数据
91
+     *
92
+     * @param CustomerPingLog 实例对象
93
+     * @return 实例对象
94
+     */
95
+    @OpLog(module = "CustomerPingLog", action = "更新数据")
96
+    @AccessLimit()
97
+    @ApiOperation("更新数据")
98
+    @PutMapping("/customerPingLog/{id}")
99
+    public SaResult edit(@ApiParam("对象实体") @Validated @RequestBody CustomerPingLog CustomerPingLog,
100
+                         @ApiParam("对象ID") @PathVariable String id) throws Exception {
101
+//        CustomerPingLog.setUndefinedId(id);
102
+        customerPingLogService.updateById(CustomerPingLog);
103
+        return SaResult.data(CustomerPingLog);
104
+    }
105
+
106
+    /**
107
+     * 通过主键删除数据
108
+     *
109
+     * @param id 主键
110
+     * @return 是否成功
111
+     */
112
+    @OpLog(module = "CustomerPingLog", action = "删除数据", desc = "ID:{{#id}}")
113
+    @AccessLimit()
114
+    @ApiOperation("通过主键删除数据")
115
+    @DeleteMapping("/customerPingLog/{id}")
116
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
117
+        customerPingLogService.removeById(id);
118
+        return SaResult.data("success");
119
+    }
120
+}

+ 134
- 0
application/src/main/java/com/lyg/application/controller/UploadController.java View File

@@ -0,0 +1,134 @@
1
+package com.lyg.application.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.alibaba.excel.EasyExcel;
5
+import com.lyg.application.dao.UploadDataListener;
6
+import com.lyg.application.dao.UploadDataListenerManage;
7
+import com.lyg.application.dto.CustomerExcelDTO;
8
+import com.lyg.application.dto.CustomerManageExcelDTO;
9
+import com.lyg.application.service.CustomerBirthdayManageService;
10
+import com.lyg.application.service.CustomerBirthdayService;
11
+import com.lyg.framework.accesslimit.AccessLimit;
12
+import com.lyg.framework.log.OpLog;
13
+import com.lyg.system.controller.BaseController;
14
+import io.swagger.annotations.Api;
15
+import io.swagger.annotations.ApiOperation;
16
+import io.swagger.annotations.ApiParam;
17
+import lombok.SneakyThrows;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.transaction.annotation.Transactional;
20
+import org.springframework.web.bind.annotation.*;
21
+import org.springframework.web.multipart.MultipartFile;
22
+
23
+import javax.servlet.http.HttpServletResponse;
24
+import java.io.File;
25
+import java.io.IOException;
26
+import java.io.InputStream;
27
+import java.util.HashMap;
28
+import java.util.Map;
29
+
30
+
31
+/**
32
+ * 客户生日维护经理表;(客户生日维护经理表)表控制层
33
+ *
34
+ * @author : http://njyunzhi.com
35
+ * @date : 2024-1-29
36
+ */
37
+@Api(tags = "上传")
38
+@RestController
39
+@RequestMapping("/")
40
+@ResponseBody
41
+public class UploadController extends BaseController {
42
+
43
+
44
+    @Autowired
45
+    private CustomerBirthdayService customerBirthdayService;
46
+    @Autowired
47
+    private CustomerBirthdayManageService customerBirthdayManageService;
48
+//    @Autowired
49
+//    private CustomerBirthDAO customerBirthDAO;
50
+//
51
+//
52
+//    @Autowired
53
+//    private CustomerBirthManageDAO customerBirthManageDAO;
54
+
55
+
56
+    @AccessLimit()
57
+    @ApiOperation("上传文件")
58
+    @PostMapping("/upload")
59
+    public SaResult upload(@ApiParam("文件") @RequestParam("file") MultipartFile file) throws IOException {
60
+        if (file.isEmpty()) {//检查文件是否为空
61
+            throw new IllegalArgumentException("文件不能为空");
62
+
63
+        }
64
+        try {
65
+            InputStream inputStream = file.getInputStream();
66
+            EasyExcel.read(inputStream, CustomerExcelDTO.class, new UploadDataListener(customerBirthdayService)).sheet(0).doReadSync();
67
+            return SaResult.data("操作成功");
68
+        } catch (Exception e) {
69
+            e.printStackTrace();
70
+            return SaResult.error("读取文件失败: " + e.getMessage());
71
+        }
72
+
73
+
74
+    }
75
+
76
+
77
+    @AccessLimit()
78
+    @ApiOperation("上传文件")
79
+    @PostMapping("/uploadManage")
80
+
81
+    public SaResult uploadManage(@ApiParam("文件") @RequestParam("file") MultipartFile file) throws IOException {
82
+        if (file.isEmpty()) {//检查文件是否为空
83
+            new Exception("文件不能为空");
84
+        }
85
+        try {
86
+            EasyExcel.read(file.getInputStream(), CustomerManageExcelDTO.class, new UploadDataListenerManage(customerBirthdayManageService)).sheet().doRead();
87
+            return SaResult.data("操作成功");
88
+        } catch (Exception e) {
89
+            e.printStackTrace();
90
+            return SaResult.error("读取文件失败: " + e.getMessage());
91
+        }
92
+
93
+    }
94
+
95
+
96
+    @OpLog(module = "CustomerBirthday", action = "客户生日表模板下载")
97
+    @AccessLimit()
98
+    @ApiOperation("CustomerBirthday")
99
+    @GetMapping(value = "/downloadBirth")
100
+    public SaResult downloadBirth(HttpServletResponse response) throws IOException {
101
+        Map<String, Object> params = new HashMap<>();
102
+        String fileName = "CustomerBirthday.xlsx";
103
+
104
+        File file = new File("application/src/main/resources/" + fileName);
105
+
106
+        params.put("fileName", fileName);
107
+        params.put("file", file);
108
+        return SaResult.data(params);
109
+
110
+
111
+    }
112
+
113
+    @OpLog(module = "客户生日维护经理表", action = "客户生日维护经理表模板下载")
114
+    @AccessLimit()
115
+    @ApiOperation("客户生日维护经理表")
116
+    @GetMapping(value = "/downloadBirManage")
117
+    public SaResult downloadBirManage(HttpServletResponse response) {
118
+//        Map<String, Object> params = new HashMap<>();
119
+//
120
+//        String fileName = "/客户生日维护经理表.xlsx";
121
+//        File file = null;
122
+//        try {
123
+//            file = DownloadExcel.download(response, fileName);
124
+//
125
+//        } catch (Exception e) {
126
+//            e.printStackTrace();
127
+//        }
128
+//        params.put("fileName", fileName);
129
+//        params.put("file", file);
130
+        return SaResult.data("");
131
+    }
132
+
133
+
134
+}

+ 87
- 0
application/src/main/java/com/lyg/application/dao/UploadDataListener.java View File

@@ -0,0 +1,87 @@
1
+package com.lyg.application.dao;
2
+
3
+import com.alibaba.excel.context.AnalysisContext;
4
+import com.alibaba.excel.read.listener.ReadListener;
5
+import com.lyg.application.dto.CustomerExcelDTO;
6
+import com.lyg.application.service.CustomerBirthdayService;
7
+import lombok.extern.slf4j.Slf4j;
8
+import org.springframework.transaction.annotation.Transactional;
9
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
10
+
11
+import java.time.LocalDate;
12
+import java.time.format.DateTimeFormatter;
13
+import java.time.format.DateTimeParseException;
14
+import java.time.temporal.ChronoField;
15
+import java.util.ArrayList;
16
+import java.util.List;
17
+
18
+@Slf4j
19
+public class UploadDataListener implements ReadListener<CustomerExcelDTO> {
20
+
21
+
22
+    private static final int BATCH_COUNT = 10;
23
+    private final List<CustomerExcelDTO> dataList = new ArrayList<>();
24
+
25
+
26
+    private final CustomerBirthdayService customerBirthdayService;
27
+
28
+
29
+    public UploadDataListener(CustomerBirthdayService customerBirthdayService) {
30
+        this.customerBirthdayService = customerBirthdayService;
31
+    }
32
+
33
+    @Override
34
+    public void invoke(CustomerExcelDTO data, AnalysisContext context) {
35
+        log.info("解析到一条数据:{}", data);
36
+        if (data == null) {
37
+            throw new RuntimeException("excel读取失败");
38
+        }
39
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
40
+        String dateString = data.getBirth();
41
+//        try {
42
+            LocalDate date = LocalDate.parse(dateString, formatter);
43
+            // 检查日期是否有效
44
+            int month = date.get(ChronoField.MONTH_OF_YEAR);
45
+            int day = date.get(ChronoField.DAY_OF_MONTH);
46
+            if (month < 1 || month > 12 || day < 1 || day > date.lengthOfMonth()) {
47
+//            log.error("日期错误: {}", dateString);
48
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
49
+                throw new RuntimeException("日期错误");
50
+            }
51
+
52
+            if (data.getIdNum() == null||data.getName() == null||data.getCustId() == null||data.getBirth() == null) {
53
+                throw new RuntimeException("请输入完整信息!");
54
+            }
55
+//            if () {
56
+//                throw new RuntimeException("请输入姓名!");
57
+//            }
58
+//            if () {
59
+//                throw new RuntimeException("请输入客户号!");
60
+//            }
61
+//
62
+//            if (data.getBirth() == null) {
63
+//                throw new RuntimeException("请输入出生日期!");
64
+//            }
65
+            dataList.add(data);
66
+            saveData();
67
+//        } catch (DateTimeParseException e) {
68
+//            // 日期格式错误,抛出异常
69
+//            throw new RuntimeException("解析错误");
70
+//        }
71
+    }
72
+
73
+    @Override
74
+//    @Transactional(rollbackFor = Exception.class)
75
+    public void doAfterAllAnalysed(AnalysisContext context) {
76
+        saveData();
77
+        log.info("所有数据解析完成!");
78
+    }
79
+
80
+    //    @Transactional(rollbackFor = Exception.class)
81
+    public void saveData() {
82
+        if (!dataList.isEmpty()) {
83
+            customerBirthdayService.saveBatch(dataList);
84
+            dataList.clear();
85
+        }
86
+    }
87
+}

+ 62
- 0
application/src/main/java/com/lyg/application/dao/UploadDataListenerManage.java View File

@@ -0,0 +1,62 @@
1
+package com.lyg.application.dao;
2
+
3
+import com.alibaba.excel.context.AnalysisContext;
4
+import com.alibaba.excel.read.listener.ReadListener;
5
+import com.lyg.application.dto.CustomerManageExcelDTO;
6
+import com.lyg.application.service.CustomerBirthdayManageService;
7
+import lombok.extern.slf4j.Slf4j;
8
+import org.springframework.transaction.annotation.Transactional;
9
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
10
+
11
+import java.time.format.DateTimeParseException;
12
+import java.util.ArrayList;
13
+import java.util.List;
14
+
15
+@Slf4j
16
+public class UploadDataListenerManage implements ReadListener<CustomerManageExcelDTO> {
17
+
18
+    private static final int BATCH_COUNT = 10;
19
+    private final List<CustomerManageExcelDTO> dataList = new ArrayList<>();
20
+
21
+    //
22
+    private final CustomerBirthdayManageService customerBirthdayManageService;
23
+
24
+    public UploadDataListenerManage(CustomerBirthdayManageService customerBirthdayManageService) {
25
+        this.customerBirthdayManageService = customerBirthdayManageService;
26
+    }
27
+
28
+    @Override
29
+    public void invoke(CustomerManageExcelDTO data, AnalysisContext context) {
30
+//
31
+        log.info("解析到一条数据:{}", data);
32
+        if (data == null) {
33
+            throw new RuntimeException("excel读取失败");
34
+        }
35
+
36
+            if (data.getPhoneNo() == null||data.getName() == null) {
37
+                throw new RuntimeException("请输入完整信息!");
38
+            }
39
+
40
+            dataList.add(data);
41
+//            saveData();
42
+//        } catch (DateTimeParseException e) {
43
+//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
44
+//            throw new RuntimeException("数据异常");
45
+//        }
46
+
47
+    }
48
+
49
+
50
+    @Override
51
+    public void doAfterAllAnalysed(AnalysisContext context) {
52
+        saveData();
53
+        log.info("所有数据解析完成!");
54
+    }
55
+
56
+    public void saveData() {
57
+        if (!dataList.isEmpty()) {
58
+            customerBirthdayManageService.saveBatchManage(dataList);
59
+            dataList.clear();
60
+        }
61
+    }
62
+}

+ 32
- 0
application/src/main/java/com/lyg/application/dto/CustomerExcelDTO.java View File

@@ -0,0 +1,32 @@
1
+package com.lyg.application.dto;
2
+
3
+
4
+import com.alibaba.excel.annotation.ExcelProperty;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import org.springframework.stereotype.Repository;
8
+
9
+@Data
10
+@Repository
11
+
12
+public class CustomerExcelDTO  {
13
+
14
+    @ApiModelProperty(name = "客户号", notes = "")
15
+//    @TableId(value = "cust_id", type = IdType.ASSIGN_UUID)
16
+    private String custId;
17
+    @ExcelProperty(value = "姓名", index = 1)
18
+    private String name;
19
+
20
+    @ExcelProperty(value = "身份证号", index = 2)
21
+    private String idNum;
22
+
23
+    @ExcelProperty(value = "归属机构号", index = 3)
24
+    private String brNo;
25
+
26
+    @ExcelProperty(value = "生日", index = 4)
27
+    private String birth;
28
+
29
+    @ExcelProperty(value = "客户标志位辅助匹配客户经理", index = 5)
30
+    private Integer custClass;
31
+
32
+}

+ 35
- 0
application/src/main/java/com/lyg/application/dto/CustomerManageExcelDTO.java View File

@@ -0,0 +1,35 @@
1
+package com.lyg.application.dto;
2
+
3
+
4
+import com.alibaba.excel.annotation.ExcelProperty;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import org.springframework.stereotype.Repository;
8
+
9
+import javax.validation.constraints.NotBlank;
10
+
11
+@Data
12
+@Repository
13
+public class CustomerManageExcelDTO {
14
+
15
+
16
+    @ExcelProperty(value = "归属机构", index = 0)
17
+    @ApiModelProperty(name = "归属机构", notes = "")
18
+    private String brNo;
19
+
20
+
21
+    @ExcelProperty(value = "员工姓名", index = 1)
22
+    @NotBlank(message = "员工姓名")
23
+    @ApiModelProperty(name = "员工姓名", notes = "")
24
+    private String name;
25
+
26
+    @ExcelProperty(value = "员工手机号", index = 2)
27
+    @ApiModelProperty(name = "员工手机号", notes = "")
28
+    private Integer phoneNo;
29
+
30
+    @ExcelProperty(value = "客户标志位辅助匹配客户经理", index = 3)
31
+    @ApiModelProperty(name = "客户标志位辅助匹配客户经理", notes = "")
32
+    private Integer custClass;
33
+
34
+
35
+}

+ 50
- 0
application/src/main/java/com/lyg/application/entity/CustomerBirthday.java View File

@@ -0,0 +1,50 @@
1
+package com.lyg.application.entity;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+import javax.validation.constraints.NotBlank;
14
+import java.io.Serializable;
15
+
16
+/**
17
+ * CustomerBirthday;
18
+ *
19
+ * @author : http://www.chiner.pro
20
+ * @date : 2024-1-29
21
+ */
22
+@Data
23
+@EqualsAndHashCode()
24
+@Accessors(chain = true)
25
+@ApiModel(value = "CustomerBirthday", description = "")
26
+@TableName("客户生日表")
27
+public class CustomerBirthday implements Serializable, Cloneable {
28
+
29
+    @ApiModelProperty(name = "客户号", notes = "")
30
+    @TableId(value = "cust_id", type = IdType.ASSIGN_UUID)
31
+    private String custId;
32
+
33
+    @NotBlank(message = "姓名不能为空")
34
+    @ApiModelProperty(name = "姓名", notes = "")
35
+    private String name;
36
+
37
+    @ApiModelProperty(name = "身份证号", notes = "")
38
+    private String idNum;
39
+
40
+    @ApiModelProperty(name = "归属机构号", notes = "")
41
+    private String brNo;
42
+
43
+    @ApiModelProperty(name = "生日", notes = "")
44
+    private String birth;
45
+
46
+    @ApiModelProperty(name = "客户标志位辅助匹配客户经理", notes = "")
47
+    private Integer custClass;
48
+
49
+
50
+}

+ 38
- 0
application/src/main/java/com/lyg/application/entity/CustomerBirthdayManage.java View File

@@ -0,0 +1,38 @@
1
+package com.lyg.application.entity;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import com.baomidou.mybatisplus.annotation.*;
6
+import java.io.Serializable;
7
+import java.time.LocalDateTime;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+import javax.validation.constraints.NotBlank;
12
+
13
+ /**
14
+ * 客户生日维护经理表;
15
+ * @author : http://www.chiner.pro
16
+ * @date : 2024-1-29
17
+ */
18
+@Data
19
+@EqualsAndHashCode(callSuper = false)
20
+@Accessors(chain = true)
21
+@ApiModel(value = "客户生日维护经理表",description = "")
22
+@TableName("客户生日维护经理表")
23
+public class CustomerBirthdayManage implements Serializable,Cloneable{
24
+    
25
+    @ApiModelProperty(name = "归属机构",notes = "")
26
+    private String brNo ;
27
+    
28
+    @NotBlank(message = "员工姓名不能为空")
29
+    @ApiModelProperty(name = "员工姓名",notes = "")
30
+    private String name ;
31
+    
32
+    @ApiModelProperty(name = "员工手机号",notes = "")
33
+    private Integer phoneNo ;
34
+    
35
+    @ApiModelProperty(name = "客户标志位辅助匹配客户经理",notes = "")
36
+    private Integer custClass ;
37
+
38
+}

+ 31
- 0
application/src/main/java/com/lyg/application/entity/CustomerPingLog.java View File

@@ -0,0 +1,31 @@
1
+package com.lyg.application.entity;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import com.baomidou.mybatisplus.annotation.*;
6
+import java.io.Serializable;
7
+import java.time.LocalDateTime;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+import javax.validation.constraints.NotBlank;
12
+
13
+ /**
14
+ * CustomerPingLog;
15
+ * @author : http://www.chiner.pro
16
+ * @date : 2024-1-29
17
+ */
18
+@Data
19
+@EqualsAndHashCode(callSuper = false)
20
+@Accessors(chain = true)
21
+@ApiModel(value = "CustomerPingLog",description = "")
22
+@TableName("营销维护客户发送日志")
23
+public class CustomerPingLog implements Serializable,Cloneable{
24
+    
25
+    @ApiModelProperty(name = "日志内容,成功返回发送报文,错误返回错误代码",notes = "")
26
+    private String log ;
27
+    
28
+    @ApiModelProperty(name = "日期",notes = "")
29
+    private LocalDateTime rksj ;
30
+
31
+}

+ 33
- 0
application/src/main/java/com/lyg/application/job/ProjectOrgDaily.java View File

@@ -0,0 +1,33 @@
1
+//package com.lyg.application.job;
2
+//
3
+//
4
+//import com.lyg.application.mapper.TsProjectOrgDailyMapper;
5
+//import com.lyg.common.util.DateUtil;
6
+//import lombok.extern.slf4j.Slf4j;
7
+//import org.springframework.beans.factory.annotation.Autowired;
8
+//import org.springframework.scheduling.annotation.Scheduled;
9
+//import org.springframework.stereotype.Component;
10
+//
11
+//@Slf4j
12
+//@Component
13
+//public class ProjectOrgDaily {
14
+//
15
+//    @Autowired
16
+//    TsProjectOrgDailyMapper tsProjectOrgDailyMapper;
17
+//
18
+//    // 每天晚上 11 点执行
19
+//    @Scheduled(cron = "0 0 23 * * ?")
20
+//    public void calcScore() {
21
+//        log.info("开始统计日结数据...");
22
+//        String today = DateUtil.today();
23
+//
24
+//        try {
25
+//            tsProjectOrgDailyMapper.callProcess(today);
26
+//
27
+//            log.info("统计日结数据成功结束");
28
+//        } catch (Exception e) {
29
+//            log.error(e.getMessage());
30
+//            e.printStackTrace();
31
+//        }
32
+//    }
33
+//}

+ 27
- 0
application/src/main/java/com/lyg/application/mapper/CustomerBirthdayManageMapper.java View File

@@ -0,0 +1,27 @@
1
+package com.lyg.application.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.application.dto.CustomerManageExcelDTO;
5
+import com.lyg.application.entity.CustomerBirthdayManage;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * 客户生日维护经理表;(客户生日维护经理表)表数据库访问层
13
+ *
14
+ * @author : http://njyunzhi.com
15
+ * @date : 2024-1-29
16
+ */
17
+@Mapper
18
+public interface CustomerBirthdayManageMapper extends BaseMapper<CustomerBirthdayManage> {
19
+
20
+    CustomerBirthdayManage getByPhone(@Param("phone") String phone);
21
+
22
+    void removeByPhone(@Param("phone") String phone);
23
+
24
+    void saveBatchManage(@Param("ele") CustomerManageExcelDTO ele);
25
+
26
+    void insertBatch(@Param("list") List<CustomerManageExcelDTO> customerManageExcelDTOList);
27
+}

+ 24
- 0
application/src/main/java/com/lyg/application/mapper/CustomerBirthdayMapper.java View File

@@ -0,0 +1,24 @@
1
+package com.lyg.application.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.application.dto.CustomerExcelDTO;
5
+import com.lyg.application.entity.CustomerBirthday;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * CustomerBirthday;(CustomerBirthday)表数据库访问层
13
+ *
14
+ * @author : http://njyunzhi.com
15
+ * @date : 2024-1-29
16
+ */
17
+@Mapper
18
+public interface CustomerBirthdayMapper extends BaseMapper<CustomerBirthday> {
19
+
20
+    void insertBatch(@Param("list") List<CustomerExcelDTO> customerExcelDTOArrayList);
21
+
22
+    void saveBatch(@Param("ele") CustomerExcelDTO ele);
23
+
24
+}

+ 15
- 0
application/src/main/java/com/lyg/application/mapper/CustomerPingLogMapper.java View File

@@ -0,0 +1,15 @@
1
+package com.lyg.application.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.application.entity.CustomerPingLog;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * CustomerPingLog;(CustomerPingLog)表数据库访问层
9
+ * @author : http://njyunzhi.com
10
+ * @date : 2024-1-29
11
+ */
12
+@Mapper
13
+public interface CustomerPingLogMapper extends BaseMapper<CustomerPingLog>{
14
+    
15
+}

+ 23
- 0
application/src/main/java/com/lyg/application/service/CustomerBirthdayManageService.java View File

@@ -0,0 +1,23 @@
1
+package com.lyg.application.service;
2
+
3
+import com.lyg.application.dto.CustomerManageExcelDTO;
4
+import com.lyg.application.entity.CustomerBirthdayManage;
5
+import com.lyg.system.service.IBaseService;
6
+import org.springframework.transaction.annotation.Transactional;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * 客户生日维护经理表;(客户生日维护经理表)表服务接口
12
+ *
13
+ * @author : http://njyunzhi.com
14
+ * @date : 2024-1-29
15
+ */
16
+public interface CustomerBirthdayManageService extends IBaseService<CustomerBirthdayManage> {
17
+
18
+    CustomerBirthdayManage getByPhone(String phone);
19
+
20
+    void removeByPhone(String phone);
21
+
22
+    void saveBatchManage(List<CustomerManageExcelDTO> dataList) ;
23
+}

+ 21
- 0
application/src/main/java/com/lyg/application/service/CustomerBirthdayService.java View File

@@ -0,0 +1,21 @@
1
+package com.lyg.application.service;
2
+
3
+import com.lyg.application.dto.CustomerExcelDTO;
4
+import com.lyg.application.entity.CustomerBirthday;
5
+import com.lyg.system.service.IBaseService;
6
+import org.springframework.web.multipart.MultipartFile;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * CustomerBirthday;(CustomerBirthday)表服务接口
12
+ * @author : http://njyunzhi.com
13
+ * @date : 2024-1-29
14
+ */
15
+public interface CustomerBirthdayService extends IBaseService<CustomerBirthday> {
16
+
17
+ void batchInsert(List<CustomerBirthday> dataList);
18
+ void saveUser(MultipartFile file);
19
+
20
+ void saveBatch(List<CustomerExcelDTO> dataList) ;
21
+}

+ 13
- 0
application/src/main/java/com/lyg/application/service/CustomerPingLogService.java View File

@@ -0,0 +1,13 @@
1
+package com.lyg.application.service;
2
+
3
+import com.lyg.application.entity.CustomerPingLog;
4
+import com.lyg.system.service.IBaseService;
5
+
6
+ /**
7
+ * CustomerPingLog;(CustomerPingLog)表服务接口
8
+ * @author : http://njyunzhi.com
9
+ * @date : 2024-1-29
10
+ */
11
+public interface CustomerPingLogService extends IBaseService<CustomerPingLog> {
12
+    
13
+}

+ 62
- 0
application/src/main/java/com/lyg/application/service/impl/CustomerBirthdayManageServiceImpl.java View File

@@ -0,0 +1,62 @@
1
+package com.lyg.application.service.impl;
2
+
3
+import com.baomidou.dynamic.datasource.annotation.DS;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.lyg.application.dto.CustomerManageExcelDTO;
6
+import com.lyg.application.entity.CustomerBirthdayManage;
7
+import com.lyg.application.mapper.CustomerBirthdayManageMapper;
8
+import com.lyg.application.service.CustomerBirthdayManageService;
9
+import com.lyg.system.service.impl.BaseServiceImpl;
10
+import org.springframework.stereotype.Service;
11
+import org.springframework.transaction.annotation.Transactional;
12
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
13
+
14
+import java.util.ArrayList;
15
+import java.util.List;
16
+
17
+/**
18
+ * 客户生日维护经理表;(客户生日维护经理表)表服务实现类
19
+ *
20
+ * @author : http://www.chiner.pro
21
+ * @date : 2024-1-29
22
+ */
23
+@Service
24
+@DS("db_2")
25
+public class CustomerBirthdayManageServiceImpl extends BaseServiceImpl<CustomerBirthdayManageMapper, CustomerBirthdayManage> implements CustomerBirthdayManageService {
26
+
27
+    @Override
28
+    public CustomerBirthdayManage getByPhone(String phone) {
29
+        return baseMapper.getByPhone(phone);
30
+    }
31
+
32
+    @Override
33
+    public void removeByPhone(String phone) {
34
+        baseMapper.removeByPhone(phone);
35
+
36
+    }
37
+
38
+    @Override
39
+    @Transactional(rollbackFor = Exception.class)
40
+    public void saveBatchManage(List<CustomerManageExcelDTO> dataList) {
41
+        if (dataList.isEmpty()) {
42
+            return;
43
+        }
44
+        QueryWrapper<CustomerBirthdayManage> queryWrapper = new QueryWrapper<>();
45
+
46
+
47
+//        List<CustomerManageExcelDTO> customerManageExcelDTOList = new ArrayList<>();
48
+
49
+
50
+        for (CustomerManageExcelDTO ele : dataList) {
51
+            Integer phoneNo = ele.getPhoneNo();
52
+            queryWrapper.eq("phone_no", phoneNo);
53
+            List<CustomerBirthdayManage> customerBirthdayManageList = baseMapper.selectList(queryWrapper);
54
+            if (customerBirthdayManageList.size() >= 1) {
55
+                throw new RuntimeException("请勿重复录入");
56
+            }
57
+            baseMapper.saveBatchManage(ele);
58
+        }
59
+
60
+    }
61
+
62
+}

+ 69
- 0
application/src/main/java/com/lyg/application/service/impl/CustomerBirthdayServiceImpl.java View File

@@ -0,0 +1,69 @@
1
+package com.lyg.application.service.impl;
2
+
3
+import com.baomidou.dynamic.datasource.annotation.DS;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.lyg.application.dto.CustomerExcelDTO;
6
+import com.lyg.application.dto.CustomerManageExcelDTO;
7
+import com.lyg.application.entity.CustomerBirthday;
8
+import com.lyg.application.mapper.CustomerBirthdayMapper;
9
+import com.lyg.application.service.CustomerBirthdayService;
10
+import com.lyg.system.service.impl.BaseServiceImpl;
11
+import lombok.SneakyThrows;
12
+import org.apache.ibatis.annotations.Param;
13
+import org.springframework.stereotype.Service;
14
+import org.springframework.transaction.annotation.Transactional;
15
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
16
+import org.springframework.web.multipart.MultipartFile;
17
+
18
+import java.io.BufferedInputStream;
19
+import java.io.InputStream;
20
+import java.util.ArrayList;
21
+import java.util.List;
22
+
23
+/**
24
+ * CustomerBirthday;(CustomerBirthday)表服务实现类
25
+ *
26
+ * @author : http://www.chiner.pro
27
+ * @date : 2024-1-29
28
+ */
29
+@Service
30
+@DS("db_2")
31
+public class CustomerBirthdayServiceImpl extends BaseServiceImpl<CustomerBirthdayMapper, CustomerBirthday> implements CustomerBirthdayService {
32
+
33
+    @Override
34
+    public void batchInsert(List<CustomerBirthday> dataList) {
35
+        saveBatch(dataList);
36
+    }
37
+
38
+    @SneakyThrows
39
+    @Override
40
+    public void saveUser(MultipartFile file) {
41
+        InputStream inputStream = new BufferedInputStream(file.getInputStream());
42
+    }
43
+
44
+    @Override
45
+    @Transactional(rollbackFor = Exception.class)
46
+    public void saveBatch(List<CustomerExcelDTO> dataList)  {
47
+        if (dataList.isEmpty()) {
48
+            return;
49
+        }
50
+        QueryWrapper<CustomerBirthday> queryWrapper = new QueryWrapper<>();
51
+
52
+//        List<CustomerExcelDTO> customerExcelDTOArrayList = new ArrayList<>();
53
+
54
+
55
+        for (CustomerExcelDTO ele : dataList) {
56
+            String idNum = ele.getIdNum();
57
+            queryWrapper.eq("id_num", idNum);
58
+            List<CustomerBirthday> customerBirthdayList = baseMapper.selectList(queryWrapper);
59
+            if (customerBirthdayList.size() >= 1) {
60
+                throw new RuntimeException("请勿重复录入客户");
61
+            }
62
+
63
+            baseMapper.saveBatch(ele);
64
+        }
65
+
66
+    }
67
+
68
+
69
+}

+ 25
- 0
application/src/main/java/com/lyg/application/service/impl/CustomerPingLogServiceImpl.java View File

@@ -0,0 +1,25 @@
1
+package com.lyg.application.service.impl;
2
+
3
+import com.baomidou.dynamic.datasource.annotation.DS;
4
+import com.lyg.application.entity.CustomerPingLog;
5
+import com.lyg.system.service.impl.BaseServiceImpl;
6
+import org.springframework.stereotype.Service;
7
+import com.lyg.application.mapper.CustomerPingLogMapper;
8
+import com.lyg.application.service.CustomerPingLogService;
9
+
10
+ /**
11
+ * CustomerPingLog;(CustomerPingLog)表服务实现类
12
+ * @author : http://www.chiner.pro
13
+ * @date : 2024-1-29
14
+ */
15
+@Service
16
+@DS("db_2")
17
+public class CustomerPingLogServiceImpl extends BaseServiceImpl<CustomerPingLogMapper, CustomerPingLog> implements CustomerPingLogService {
18
+
19
+    int i = 0;
20
+
21
+    public void  add() {
22
+        i += 1;
23
+
24
+    }
25
+}

+ 29
- 0
application/src/main/java/com/lyg/application/util/CommMergeStrategy.java View File

@@ -0,0 +1,29 @@
1
+package com.lyg.application.util;
2
+
3
+import com.alibaba.excel.metadata.Head;
4
+import com.alibaba.excel.write.merge.AbstractMergeStrategy;
5
+import org.apache.poi.ss.usermodel.Cell;
6
+import org.apache.poi.ss.usermodel.CellStyle;
7
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
8
+import org.apache.poi.ss.usermodel.Sheet;
9
+import org.apache.poi.ss.util.CellRangeAddress;
10
+
11
+public class CommMergeStrategy extends AbstractMergeStrategy {
12
+
13
+    CellRangeAddress cellRangeAddress;
14
+
15
+    public CommMergeStrategy(CellRangeAddress cellRangeAddress) {
16
+        this.cellRangeAddress = cellRangeAddress;
17
+    }
18
+
19
+    @Override
20
+    protected void merge(Sheet sheet, Cell cell, Head head, Integer integer) {
21
+        if (cell.getRowIndex() == cellRangeAddress.getFirstRow() && cell.getColumnIndex() == cellRangeAddress.getFirstColumn()) {
22
+            // 文字居中
23
+            CellStyle style = cell.getCellStyle();
24
+            style.setAlignment(HorizontalAlignment.CENTER);
25
+            // 合并单元格
26
+            sheet.addMergedRegionUnsafe(cellRangeAddress);
27
+        }
28
+    }
29
+}

+ 15
- 0
application/src/main/java/com/lyg/application/vo/RankScoreVo.java View File

@@ -0,0 +1,15 @@
1
+package com.lyg.application.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import lombok.Data;
5
+
6
+@Data
7
+@ApiModel("积分")
8
+public class RankScoreVo {
9
+    private String projectId;
10
+    private String itemId;
11
+    private String orgId;
12
+    private String name;
13
+    private Double value;
14
+
15
+}

+ 16
- 0
application/src/main/java/com/lyg/application/vo/RankVo.java View File

@@ -0,0 +1,16 @@
1
+package com.lyg.application.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+
7
+@Data
8
+@ApiModel("排行榜")
9
+public class RankVo {
10
+
11
+    @ApiModelProperty("指标名称")
12
+    String name;
13
+
14
+    @ApiModelProperty("指标值")
15
+    Double value;
16
+}

+ 19
- 0
application/src/main/java/com/lyg/application/vo/ReportFreqVO.java View File

@@ -0,0 +1,19 @@
1
+//package com.lyg.application.vo;
2
+//
3
+//import com.alibaba.excel.annotation.ExcelIgnore;
4
+//import com.alibaba.excel.annotation.ExcelProperty;
5
+//import com.lyg.application.entity.TaProjectReport;
6
+//import io.swagger.annotations.ApiModelProperty;
7
+//import lombok.Data;
8
+//
9
+//@Data
10
+//public class ReportFreqVO extends TaProjectReport {
11
+//
12
+////    @ApiModelProperty(name = "上报时间",notes = "")
13
+//    @ExcelProperty(value = "日期", index = 6)
14
+//    private String bizDate ;
15
+//
16
+////    @ApiModelProperty(name = "积分",notes = "")
17
+//    @ExcelProperty(value = "积分", index = 5)
18
+//    private Double score ;
19
+//}

+ 70
- 0
application/src/main/resources/application.yml View File

@@ -0,0 +1,70 @@
1
+
2
+# 端口
3
+server:
4
+  port: 9010
5
+  servlet:
6
+    context-path: /api
7
+
8
+logging:
9
+  level:
10
+    root: info
11
+    web: trace
12
+
13
+spring:
14
+  mvc:
15
+    pathmatch:
16
+      matching-strategy: ANT_PATH_MATCHER
17
+  servlet:
18
+    multipart:
19
+      max-file-size: 1024MB
20
+      max-request-size: 1024MB
21
+  datasource:
22
+    url: jdbc:oracle:thin:@192.168.89.10:1521:orcl
23
+    username: job_waring
24
+    password: job_waring@ABCD1234
25
+    driver-class-name: oracle.jdbc.OracleDriver
26
+    hikari:
27
+      maximum-pool-size: 3
28
+
29
+  # 配置 Redis 连接
30
+  redis:
31
+    # Redis数据库索引
32
+    database: 3
33
+    # Redis服务器地址
34
+    host: 192.168.89.10
35
+    # Redis服务器连接端口
36
+    port: 6379
37
+    # Redis服务器连接密码(默认为空)
38
+    password: yansen@123
39
+    # 连接超时时间
40
+    timeout: 10s
41
+    lettuce:
42
+      pool:
43
+        # 连接池最大连接数
44
+        max-active: 200
45
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
46
+        max-wait: -1ms
47
+        # 连接池中的最大空闲连接
48
+        max-idle: 10
49
+        # 连接池中的最小空闲连接
50
+        min-idle: 0
51
+
52
+
53
+###
54
+yz:
55
+  appid: maintenance
56
+  upload:
57
+    path: E:\work\public-upload
58
+  sso:
59
+    host: 127.0.0.1
60
+    port: 9001
61
+  filter:
62
+    annList:
63
+      - "/swagger-ui/**"
64
+      - "/swagger-resources/**"
65
+      - "/v2/**"
66
+      - "/static/**"
67
+      - "/h5/**"
68
+      - "/sysUser/current"
69
+#  excel-tpl-path: E:\work\Java+web\17填报系统\performance-reporting-service\application\src\main\resources\
70
+

+ 31
- 0
application/src/main/resources/mapper/CustomerBirthdayManageMapper.xml View File

@@ -0,0 +1,31 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.lyg.application.mapper.CustomerBirthdayManageMapper">
5
+    <insert id="saveBatchManage">
6
+        INSERT INTO "客户生日维护经理表" (BR_NO, NAME, PHONE_NO, CUST_CLASS)
7
+        VALUES (#{ele.brNo},#{ele.name}, #{ele.phoneNo},#{ele.custClass})
8
+    </insert>
9
+<!--    <insert id="insertBatch" parameterType="java.util.List">-->
10
+<!--        INSERT INTO "客户生日维护经理表" (BR_NO, NAME, PHONE_NO, CUST_CLASS)-->
11
+<!--        VALUES-->
12
+<!--        <foreach collection="list" item="item" separator="">-->
13
+<!--            (#{item.brNo},#{item.name},#{item.phoneNo},#{item.custClass})-->
14
+<!--        </foreach>-->
15
+<!--    </insert>-->
16
+
17
+    <delete id="removeByPhone">
18
+        DELETE "客户生日维护经理表" b
19
+        WHERE
20
+        b.PHONE_NO =#{phone}
21
+    </delete>
22
+
23
+    <select id="getByPhone" resultType="com.lyg.application.entity.CustomerBirthdayManage">
24
+        SELECT
25
+        *
26
+        FROM
27
+        "客户生日维护经理表" b
28
+        WHERE
29
+        b.PHONE_NO =#{phone}
30
+    </select>
31
+</mapper>

+ 17
- 0
application/src/main/resources/mapper/CustomerBirthdayMapper.xml View File

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.lyg.application.mapper.CustomerBirthdayMapper">
5
+
6
+    <insert id="saveBatch">
7
+        INSERT INTO "客户生日表" (CUST_ID, NAME, ID_NUM, BR_NO, BIRTH, CUST_CLASS)
8
+        VALUES (#{ele.custId}, #{ele.name}, #{ele.idNum}, #{ele.brNo}, #{ele.birth}, #{ele.custClass})
9
+    </insert>
10
+    <insert id="insertBatch" parameterType="java.util.List">
11
+        INSERT INTO "客户生日表" (CUST_ID, NAME, ID_NUM, BR_NO, BIRTH, CUST_CLASS)
12
+        VALUES
13
+        <foreach collection="list" item="item" separator=",">
14
+            (#{item.custId}, #{item.name}, #{item.idNum}, #{item.brNo}, #{item.birth}, #{item.custClass})
15
+        </foreach>
16
+    </insert>
17
+</mapper>

+ 6
- 0
application/src/main/resources/mapper/CustomerPingLogMapper.xml View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.lyg.application.mapper.CustomerPingLogMapper">
5
+    
6
+</mapper>

+ 48
- 0
common/pom.xml View File

@@ -0,0 +1,48 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <parent>
6
+        <artifactId>demo</artifactId>
7
+        <groupId>com.lyg</groupId>
8
+        <version>0.0.1</version>
9
+    </parent>
10
+    <modelVersion>4.0.0</modelVersion>
11
+
12
+    <artifactId>common</artifactId>
13
+
14
+    <properties>
15
+        <maven.compiler.source>8</maven.compiler.source>
16
+        <maven.compiler.target>8</maven.compiler.target>
17
+    </properties>
18
+
19
+
20
+    <dependencies>
21
+        <dependency>
22
+            <groupId>org.springframework.boot</groupId>
23
+            <artifactId>spring-boot-starter-web</artifactId>
24
+        </dependency>
25
+        <dependency>
26
+            <groupId>org.springframework.boot</groupId>
27
+            <artifactId>spring-boot-starter-validation</artifactId>
28
+        </dependency>
29
+
30
+        <dependency>
31
+            <groupId>org.projectlombok</groupId>
32
+            <artifactId>lombok</artifactId>
33
+            <optional>true</optional>
34
+        </dependency>
35
+
36
+        <dependency>
37
+            <groupId>com.alibaba</groupId>
38
+            <artifactId>easyexcel</artifactId>
39
+            <version>${easyexcel.version}</version>
40
+        </dependency>
41
+        <dependency>
42
+            <groupId>com.baomidou</groupId>
43
+            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
44
+            <version>${dynamic.version}</version>
45
+        </dependency>
46
+
47
+    </dependencies>
48
+</project>

+ 15
- 0
common/src/main/java/com/lyg/common/Constants.java View File

@@ -0,0 +1,15 @@
1
+package com.lyg.common;
2
+
3
+public class Constants {
4
+    public final static String ROOT_ID = "1";    // 超级管理员ID
5
+    public final static String ROOT_TREE = "-1";  // 树根
6
+    public final static String ROOT_ORG = "1";   // 顶级机构
7
+
8
+    public final static int STATUS_DELETE = -1;
9
+    public final static int STATUS_READY = 0;
10
+    public final static int STATUS_NORMAL = 1;
11
+
12
+    // 东海特殊规则
13
+    public final static String SPECIAL_RULE_DH = "donghai";
14
+
15
+}

+ 145
- 0
common/src/main/java/com/lyg/common/util/DateUtil.java View File

@@ -0,0 +1,145 @@
1
+package com.lyg.common.util;
2
+
3
+import java.text.ParseException;
4
+import java.text.SimpleDateFormat;
5
+import java.time.Duration;
6
+import java.time.Instant;
7
+import java.time.LocalDateTime;
8
+import java.time.ZoneId;
9
+import java.time.format.DateTimeFormatter;
10
+import java.util.Date;
11
+import java.util.regex.Pattern;
12
+
13
+public class DateUtil {
14
+
15
+    public static String toString(LocalDateTime dt, String pattern) {
16
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
17
+        return dt.format(formatter);
18
+    }
19
+
20
+    public static LocalDateTime date2LocalDateTime(Date date) {
21
+        Instant instant = date.toInstant();
22
+        ZoneId zone = ZoneId.systemDefault();
23
+        return LocalDateTime.ofInstant(instant, zone);
24
+    }
25
+
26
+    public static boolean sameDay(LocalDateTime d1, LocalDateTime d2) {
27
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
28
+        return d1.format(formatter).equals(d2.format(formatter));
29
+    }
30
+
31
+    public static String cutSecond(LocalDateTime dt) {
32
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
33
+        return dt.format(formatter);
34
+    }
35
+
36
+    public static String today() {
37
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
38
+        return LocalDateTime.now().format(formatter);
39
+    }
40
+
41
+    public static String todayCompact() {
42
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
43
+        return LocalDateTime.now().format(formatter);
44
+    }
45
+
46
+    public static String localDateTimeToString(LocalDateTime d) {
47
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
48
+        return d.format(formatter);
49
+    }
50
+
51
+    public static LocalDateTime fromString(String str, String formatter) {
52
+        DateTimeFormatter df = DateTimeFormatter.ofPattern(formatter);
53
+
54
+        return LocalDateTime.parse(str, df);
55
+    }
56
+
57
+    public static LocalDateTime day2LocalDateime(String day) {
58
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
59
+        return LocalDateTime.parse(day + " 00:00:00", df);
60
+    }
61
+
62
+    public static LocalDateTime dayToLocalDateime(String day) {
63
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
64
+        return LocalDateTime.parse(day, df);
65
+    }
66
+
67
+    public static boolean checkTimeRange(LocalDateTime start, LocalDateTime end, LocalDateTime dt) {
68
+        if (dt == null) {
69
+            dt = LocalDateTime.now();
70
+        }
71
+
72
+        if (dt.isAfter(start) && dt.isBefore(end)) {
73
+            return true;
74
+        }
75
+        return false;
76
+    }
77
+
78
+    /**
79
+     * 当前时间是否早于指定时间
80
+     *
81
+     * @param target
82
+     * @return
83
+     */
84
+    public static boolean isBefore(String target) {
85
+        LocalDateTime dt = LocalDateTime.now();
86
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
87
+        LocalDateTime targetTime = LocalDateTime.parse(target, df);
88
+        if (dt.isBefore(targetTime)) {
89
+            return true;
90
+        }
91
+        return false;
92
+    }
93
+
94
+    /**
95
+     * 当前时间是否晚于指定时间
96
+     *
97
+     * @param target
98
+     * @return
99
+     */
100
+    public static boolean isAfter(String target) {
101
+        LocalDateTime dt = LocalDateTime.now();
102
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
103
+        LocalDateTime targetTime = LocalDateTime.parse(target, df);
104
+        if (dt.isAfter(targetTime)) {
105
+            return true;
106
+        }
107
+        return false;
108
+    }
109
+
110
+    /**
111
+     * 获取时间差
112
+     *
113
+     * @param dt1
114
+     * @param dt2 目标时间
115
+     * @return
116
+     */
117
+    public static String diffTime(LocalDateTime dt1, LocalDateTime dt2) {
118
+        Duration duration = Duration.between(dt1, dt2);
119
+        long minutes = duration.toMinutes();
120
+        int hours = (int) Math.floor(minutes / 60);
121
+        int minute = (int) minutes % 60;
122
+        int day = (int) Math.floor(hours / 24);
123
+        int hour = hours % 24;
124
+
125
+        return day + "天" + hour + "小时" + minute + "分钟";
126
+    }
127
+
128
+    public static LocalDateTime timeToLocalDateTime(String target){
129
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
130
+        return LocalDateTime.parse(target, df);
131
+    }
132
+
133
+    public static LocalDateTime now() {
134
+        return LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
135
+    }
136
+
137
+    public static boolean isDayStr(String str) {
138
+        return Pattern.matches("^\\d{4}-\\d{2}-\\d{2}$", str);
139
+    }
140
+
141
+    public static Date day2Date(String str) throws ParseException {
142
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
143
+        return df.parse(str);
144
+    }
145
+}

+ 17
- 0
common/src/main/java/com/lyg/common/util/EncryptUtil.java View File

@@ -0,0 +1,17 @@
1
+package com.lyg.common.util;
2
+
3
+import org.springframework.util.DigestUtils;
4
+
5
+public class EncryptUtil {
6
+
7
+    public static String md5(String str, String ...slats) {
8
+        String slat = "";
9
+        if (null != slats && slats.length > 0) {
10
+            slat = slats[0];
11
+        }
12
+
13
+        String base = str + slat;
14
+        String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
15
+        return md5;
16
+    }
17
+}

+ 53
- 0
common/src/main/java/com/lyg/common/util/FileUtil.java View File

@@ -0,0 +1,53 @@
1
+package com.lyg.common.util;
2
+
3
+import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.stereotype.Component;
5
+
6
+import java.io.File;
7
+import java.time.LocalDateTime;
8
+import java.time.format.DateTimeFormatter;
9
+
10
+@Component
11
+public class FileUtil {
12
+
13
+    @Value("${yz.upload.path}")
14
+    String uploadPath;
15
+
16
+    public String getUploadPath() {
17
+        File tmp = new File(uploadPath);
18
+        if (!tmp.exists()) {
19
+            tmp.mkdir();
20
+        }
21
+
22
+        return uploadPath;
23
+    }
24
+
25
+    public String getMonth() {
26
+        LocalDateTime now = LocalDateTime.now();
27
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
28
+        return now.format(formatter);
29
+    }
30
+
31
+    // 保存文件
32
+    public String saveFile(File file, String fileName) throws Exception {
33
+        String uploadRootPath = getUploadPath();
34
+        String monthStr = getMonth();
35
+
36
+        // 上传目录
37
+        String upPath = String.format("%s/%s", uploadRootPath, monthStr);
38
+        File tmp = new File(upPath);
39
+        if (!tmp.exists()) {
40
+            tmp.mkdir();
41
+        }
42
+
43
+        String newFileName = String.format("%d-%s", System.currentTimeMillis(), fileName);
44
+        String newFilePath = String.format("%s/%s", upPath, newFileName);
45
+        if (!file.renameTo(new File(newFilePath))) {
46
+            throw new Exception("保存文件失败");
47
+        };
48
+
49
+        // 返回值 去掉根目录
50
+        return String.format("%s/%s", monthStr, newFileName);
51
+    }
52
+
53
+}

+ 72
- 0
common/src/main/java/com/lyg/common/util/IpUtil.java View File

@@ -0,0 +1,72 @@
1
+package com.lyg.common.util;
2
+
3
+import javax.servlet.http.HttpServletRequest;
4
+import java.net.InetAddress;
5
+import java.net.UnknownHostException;
6
+
7
+public class IpUtil {
8
+
9
+    private static final String IP_UTILS_FLAG = ",";
10
+    private static final String UNKNOWN = "unknown";
11
+    private static final String LOCALHOST_IP = "0:0:0:0:0:0:0:1";
12
+    private static final String LOCALHOST_IP1 = "127.0.0.1";
13
+
14
+    /**
15
+     * 获取IP公网地址
16
+     * <p>
17
+     * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
18
+     * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
19
+     */
20
+    public static String getIpAddr(HttpServletRequest request) {
21
+        String ip = null;
22
+        try {
23
+            //以下两个获取在k8s中,将真实的客户端IP,放到了x-Original-Forwarded-For。而将WAF的回源地址放到了 x-Forwarded-For了。
24
+            ip = request.getHeader("X-Original-Forwarded-For");
25
+            if (isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
26
+                ip = request.getHeader("X-Forwarded-For");
27
+            }
28
+            //获取nginx等代理的ip
29
+            if (isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
30
+                ip = request.getHeader("x-forwarded-for");
31
+            }
32
+            if (isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
33
+                ip = request.getHeader("Proxy-Client-IP");
34
+            }
35
+            if (isEmpty(ip) || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
36
+                ip = request.getHeader("WL-Proxy-Client-IP");
37
+            }
38
+            if (isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
39
+                ip = request.getHeader("HTTP_CLIENT_IP");
40
+            }
41
+            if (isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
42
+                ip = request.getHeader("HTTP_X_FORWARDED_FOR");
43
+            }
44
+            //兼容k8s集群获取ip
45
+            if (isEmpty(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
46
+                ip = request.getRemoteAddr();
47
+                if (LOCALHOST_IP1.equalsIgnoreCase(ip) || LOCALHOST_IP.equalsIgnoreCase(ip)) {
48
+                    //根据网卡取本机配置的IP
49
+                    InetAddress iNet = null;
50
+                    try {
51
+                        iNet = InetAddress.getLocalHost();
52
+                    } catch (UnknownHostException e) {
53
+                        e.printStackTrace();
54
+                    }
55
+                    ip = iNet.getHostAddress();
56
+                }
57
+            }
58
+        } catch (Exception e) {
59
+            e.printStackTrace();
60
+        }
61
+        //使用代理,则获取第一个IP地址
62
+        if (!isEmpty(ip) && ip.indexOf(IP_UTILS_FLAG) > 0) {
63
+            ip = ip.substring(0, ip.indexOf(IP_UTILS_FLAG));
64
+        }
65
+
66
+        return ip;
67
+    }
68
+
69
+    public static boolean isEmpty(String s) {
70
+        return s == null || "".equals(s.trim());
71
+    }
72
+}

+ 20
- 0
common/src/main/java/com/lyg/common/util/MyPropertySourceFactory.java View File

@@ -0,0 +1,20 @@
1
+package com.lyg.common.util;
2
+
3
+import org.springframework.boot.env.YamlPropertySourceLoader;
4
+import org.springframework.core.env.PropertySource;
5
+import org.springframework.core.io.support.EncodedResource;
6
+import org.springframework.core.io.support.PropertySourceFactory;
7
+
8
+import java.io.IOException;
9
+
10
+/**
11
+ * 自定义读取 yml 配置文件
12
+ * 使用方式 @PropertySource
13
+ */
14
+public class MyPropertySourceFactory implements PropertySourceFactory {
15
+
16
+    @Override
17
+    public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
18
+        return new YamlPropertySourceLoader().load(name, resource.getResource()).get(0);
19
+    }
20
+}

+ 211
- 0
common/src/main/java/com/lyg/common/util/StringUtil.java View File

@@ -0,0 +1,211 @@
1
+package com.lyg.common.util;
2
+
3
+import java.io.UnsupportedEncodingException;
4
+import java.net.URLDecoder;
5
+import java.net.URLEncoder;
6
+import java.util.*;
7
+import java.util.regex.Matcher;
8
+import java.util.regex.Pattern;
9
+
10
+public class StringUtil {
11
+    private static Pattern humpPattern = Pattern.compile("[A-Z]");
12
+
13
+    public static boolean isEmpty(String str) {
14
+        return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
15
+    }
16
+
17
+    public static boolean isNotEmpty(String str) {
18
+        return !isEmpty(str);
19
+    }
20
+
21
+    public static String trim(String src, String...st) {
22
+        if (null == src) return src;
23
+        if (null == st || st.length == 0) return src.trim();
24
+
25
+        String start = st[0];
26
+        if (!src.startsWith(start)) {
27
+            return src;
28
+        }
29
+
30
+        return src.substring(start.length());
31
+    }
32
+
33
+    public static String UUID() {
34
+        return UUID.randomUUID().toString().replaceAll("-", "");
35
+    }
36
+
37
+    public static String trimEnd(String src, String str) {
38
+        if (null == src || null == str) {
39
+            return src;
40
+        }
41
+
42
+        if (src.endsWith(str)) {
43
+            return src.substring(0, src.length() - str.length());
44
+        }
45
+
46
+        return src;
47
+    }
48
+
49
+    public static String ifNull(String src, String defaultVal) {
50
+        return isEmpty(src) ? defaultVal : src;
51
+    }
52
+
53
+    public static String random(int length) {
54
+        String str="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
55
+        Random random = new Random();
56
+        StringBuffer sb = new StringBuffer();
57
+        for(int i=0;i<length;i++){
58
+            int number=random.nextInt(62);
59
+            sb.append(str.charAt(number));
60
+        }
61
+        return sb.toString();
62
+    }
63
+
64
+    public static String urlEncode(String str) {
65
+        if (isEmpty(str)) return str;
66
+
67
+        try {
68
+            return URLEncoder.encode(str, "UTF-8");
69
+        } catch (UnsupportedEncodingException e) {
70
+            e.printStackTrace();
71
+            return str;
72
+        }
73
+    }
74
+
75
+    public static String urlDecode(String str) {
76
+        if (isEmpty(str)) return str;
77
+
78
+        try {
79
+            return URLDecoder.decode(str, "UTF-8");
80
+        } catch (UnsupportedEncodingException e) {
81
+            e.printStackTrace();
82
+            return str;
83
+        }
84
+    }
85
+
86
+    public static String encodeURIComponent(String str) {
87
+        String result = urlEncode(str);
88
+
89
+        return result.replaceAll("\\+", "%20")
90
+                .replaceAll("\\%21", "!")
91
+                .replaceAll("\\%27", "'")
92
+                .replaceAll("\\%28", "(")
93
+                .replaceAll("\\%29", ")")
94
+                .replaceAll("\\%7E", "~");
95
+    }
96
+
97
+    public static String humpToLine(String str) {
98
+        if (null == str || "".equals(str)) return "";
99
+
100
+        Matcher matcher = humpPattern.matcher(str);
101
+        StringBuffer sb = new StringBuffer();
102
+        while (matcher.find()) {
103
+            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
104
+        }
105
+        matcher.appendTail(sb);
106
+        return sb.toString();
107
+    }
108
+
109
+    public static String strToUnicode(String str) {
110
+        char[] chars = str.toCharArray();
111
+        String returnStr = "";
112
+        for (int i = 0; i < chars.length; i++) {
113
+            returnStr += "\\u" + Integer.toString(chars[i], 16);
114
+        }
115
+        return returnStr;
116
+    }
117
+
118
+    public static String repeat(String src, int len) {
119
+        if (null == src) {
120
+            return null;
121
+        }
122
+
123
+        if (len <= 0) {
124
+            return src;
125
+        }
126
+
127
+        String res = "";
128
+        for (int i = 0; i < len; i ++) {
129
+            res += src;
130
+        }
131
+
132
+        return res;
133
+    }
134
+
135
+    public static String lpad(String src, String padStr, int len) {
136
+        if (null == src) {
137
+            return null;
138
+        }
139
+
140
+        if (len <= 0 || src.length() >= len) {
141
+            return src;
142
+        }
143
+
144
+        if (null == padStr) {
145
+            padStr = "";
146
+        }
147
+
148
+        int padLen = len - src.length();
149
+        String prefix = repeat(padStr, padLen);
150
+        prefix = prefix.substring(0, padLen);
151
+        return prefix + src;
152
+    }
153
+
154
+    /**
155
+     * 解析 QueryString
156
+     * @param queryStr
157
+     * @return
158
+     */
159
+    public static Map<String, String> parseQueryString(String queryStr) {
160
+        if (isEmpty(queryStr)) {
161
+            return null;
162
+        }
163
+        Map<String, String> result = new HashMap<String, String>();
164
+
165
+        String[] fields = queryStr.split("&");
166
+        for (String field : fields) {
167
+            String[] pairs = field.split("=");
168
+            if (2 != pairs.length) {
169
+                continue;
170
+            }
171
+
172
+            try {
173
+                String key = URLDecoder.decode(pairs[0].trim(), "UTF-8");
174
+                String val = URLDecoder.decode(pairs[1].trim(), "UTF-8");
175
+
176
+                result.put(key, val);
177
+            } catch (UnsupportedEncodingException e) {
178
+                e.printStackTrace();
179
+            }
180
+        }
181
+
182
+        return result;
183
+    }
184
+
185
+    /**
186
+     * Map 转 QueryString
187
+     * @param params
188
+     * @return
189
+     */
190
+    public static String buildQueryString(Map<String, Object> params) {
191
+        if (null == params) {
192
+            return null;
193
+        }
194
+
195
+        List<String> lst = new ArrayList<>();
196
+        for (Map.Entry<String, Object> entry : params.entrySet()) {
197
+            String key = urlEncode(entry.getKey());
198
+            Object o = entry.getValue();
199
+            if (null == o) {
200
+                continue;
201
+            }
202
+            String val = o.toString();
203
+            if (isEmpty(val)) {
204
+                continue;
205
+            }
206
+            String queryStr = key + "=" + urlEncode(val);
207
+            lst.add(queryStr);
208
+        }
209
+        return String.join("&", lst);
210
+    }
211
+}

+ 70
- 0
common/src/main/java/com/lyg/common/util/excel/CellWidthWriteHandler.java View File

@@ -0,0 +1,70 @@
1
+package com.lyg.common.util.excel;
2
+
3
+import com.alibaba.excel.enums.CellDataTypeEnum;
4
+import com.alibaba.excel.metadata.Head;
5
+import com.alibaba.excel.metadata.data.CellData;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
8
+import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
9
+import org.apache.poi.ss.usermodel.Cell;
10
+import org.springframework.util.CollectionUtils;
11
+
12
+import java.util.HashMap;
13
+import java.util.List;
14
+import java.util.Map;
15
+
16
+public class CellWidthWriteHandler extends AbstractColumnWidthStyleStrategy {
17
+    private static final int MAX_COLUMN_WIDTH = 255;
18
+    private  Map<Integer, Map<Integer, Integer>> CACHE = new HashMap(8);
19
+
20
+    public void CustomCellWriteHandler() {
21
+    }
22
+
23
+    protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
24
+        boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList);
25
+        if (needSetWidth) {
26
+            Map<Integer, Integer> maxColumnWidthMap = (Map)CACHE.get(writeSheetHolder.getSheetNo());
27
+            if (maxColumnWidthMap == null) {
28
+                maxColumnWidthMap = new HashMap(16);
29
+                CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
30
+            }
31
+
32
+            Integer columnWidth = this.dataLength(cellDataList, cell, isHead);
33
+            if (columnWidth >= 0) {
34
+                if (columnWidth > MAX_COLUMN_WIDTH) {
35
+                    columnWidth = MAX_COLUMN_WIDTH;
36
+                }
37
+
38
+                Integer maxColumnWidth = (Integer)((Map)maxColumnWidthMap).get(cell.getColumnIndex());
39
+                if (maxColumnWidth == null || columnWidth > maxColumnWidth) {
40
+                    ((Map)maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth);
41
+                    writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 384); // 256 * 1.5
42
+                }
43
+
44
+            }
45
+        }
46
+    }
47
+
48
+    private Integer dataLength(List<WriteCellData<?>> cellDataList, Cell cell, Boolean isHead) {
49
+        if (isHead) {
50
+            return cell.getStringCellValue().getBytes().length;
51
+        } else {
52
+            CellData cellData = (CellData)cellDataList.get(0);
53
+            CellDataTypeEnum type = cellData.getType();
54
+            if (type == null) {
55
+                return -1;
56
+            } else {
57
+                switch(type) {
58
+                    case STRING:
59
+                        return cellData.getStringValue().getBytes().length;
60
+                    case BOOLEAN:
61
+                        return cellData.getBooleanValue().toString().getBytes().length;
62
+                    case NUMBER:
63
+                        return cellData.getNumberValue().toString().getBytes().length;
64
+                    default:
65
+                        return -1;
66
+                }
67
+            }
68
+        }
69
+    }
70
+}

+ 40
- 0
common/src/main/java/com/lyg/common/util/excel/DateConverter.java View File

@@ -0,0 +1,40 @@
1
+package com.lyg.common.util.excel;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+
9
+import java.text.SimpleDateFormat;
10
+import java.util.Date;
11
+
12
+public class DateConverter implements Converter<Date> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return Date.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.STRING;
21
+    }
22
+
23
+    /**
24
+     * 写 Excel
25
+     * @param value
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        if (null == value) return null;
34
+
35
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
36
+        String val = dateFormat.format(value);
37
+
38
+        return new WriteCellData(val);
39
+    }
40
+}

+ 36
- 0
common/src/main/java/com/lyg/common/util/excel/DownloadExcel.java View File

@@ -0,0 +1,36 @@
1
+//package com.lyg.common.util.excel;
2
+//
3
+//
4
+//import com.alibaba.excel.EasyExcel;
5
+//import org.springframework.core.io.ClassPathResource;
6
+//import org.springframework.util.ResourceUtils;
7
+//
8
+//import javax.servlet.http.HttpServletResponse;
9
+//import java.io.*;
10
+//import java.net.URLEncoder;
11
+//
12
+//public class DownloadExcel {
13
+//
14
+//    public static File download(HttpServletResponse response, String fileName) throws Exception {
15
+//
16
+//        try {
17
+//
18
+//////            ClassPathResource classPathResource = new ClassPathResource(fileName);
19
+////            File file = ResourceUtils.getFile("classpath:"+fileName);
20
+////
21
+////            return file;
22
+//
23
+//            response.setContentType("application/vnd.ms-excel");
24
+//            response.setCharacterEncoding("utf-8");
25
+//            // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
26
+////            String fileName = URLEncoder.encode("测试", "UTF-8");
27
+//            response.setHeader("Content-disposition", "attachment;filename=" + fileName );
28
+//            EasyExcel.write(response.getOutputStream(), DownloadData.class).sheet("模板").doWrite(data());
29
+//        } catch (Exception e) {
30
+//            throw new Exception("下载模版失败!!!" + e.getMessage());
31
+//        }
32
+//
33
+//    }
34
+//
35
+//
36
+//}

+ 78
- 0
common/src/main/java/com/lyg/common/util/excel/ExcelUtil.java View File

@@ -0,0 +1,78 @@
1
+package com.lyg.common.util.excel;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.ExcelWriter;
5
+import com.alibaba.excel.write.builder.ExcelWriterBuilder;
6
+import com.alibaba.excel.write.metadata.WriteSheet;
7
+import com.lyg.common.util.StringUtil;
8
+
9
+import javax.servlet.http.HttpServletResponse;
10
+import java.io.File;
11
+import java.io.IOException;
12
+import java.util.ArrayList;
13
+import java.util.List;
14
+import java.util.Map;
15
+
16
+public class ExcelUtil {
17
+
18
+    public static void formatResponse(HttpServletResponse response, String fileName) {
19
+        response.setContentType("application/vnd.ms-excel");
20
+        response.setCharacterEncoding("utf-8");
21
+        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
22
+        response.setHeader("Content-Disposition", "attachment;filename="+ StringUtil.urlEncode(fileName)+".xlsx");
23
+    }
24
+
25
+    /**
26
+     * 发送 excel 到客户端
27
+     * 暂时只支持单 sheet 页
28
+     * @param response
29
+     * @param data
30
+     * @param fileName
31
+     * @throws IOException
32
+     */
33
+    public static void flush(HttpServletResponse response, Class dataClass, List data, String fileName) throws IOException {
34
+        formatResponse(response, fileName);
35
+        EasyExcel.write(response.getOutputStream(), dataClass).sheet("sheet1").doWrite(data);
36
+    }
37
+
38
+    public static void flush(HttpServletResponse response, List<List<Map<String, Object>>> data, List<List<String>> customHead, String fileName) throws IOException {
39
+        formatResponse(response, fileName);
40
+
41
+        boolean noCustomHeads = null == customHead || customHead.size() == 0;
42
+
43
+        List<List<String>> head = new ArrayList<>();
44
+        List<List<Object>> contents = new ArrayList<>();
45
+        if (null != data && data.size() > 0) {
46
+            int row = 0;
47
+            for (List<Map<String, Object>> fields: data) {
48
+
49
+                List<Object> item = new ArrayList<>();
50
+                for (Map<String, Object> field: fields) {
51
+                    if (row == 0 && noCustomHeads) {
52
+                        List<String> keys = new ArrayList<>();
53
+                        keys.add(field.get("name").toString());
54
+                        head.add(keys);
55
+                    }
56
+
57
+                    item.add(field.get("value"));
58
+                }
59
+
60
+                contents.add(item);
61
+                row += 1;
62
+            }
63
+        }
64
+
65
+        ExcelWriterBuilder writerBuilder = EasyExcel.write(response.getOutputStream());
66
+        if (noCustomHeads) {
67
+            writerBuilder.head(head);
68
+        } else {
69
+            writerBuilder.head(customHead);
70
+        }
71
+
72
+        writerBuilder.registerWriteHandler(new CellWidthWriteHandler())
73
+                .sheet("sheet")
74
+                .registerConverter(new TimestampConverter())
75
+                .registerConverter(new DateConverter())
76
+                .doWrite(contents);
77
+    }
78
+}

+ 39
- 0
common/src/main/java/com/lyg/common/util/excel/LocalDateTimeConverter.java View File

@@ -0,0 +1,39 @@
1
+package com.lyg.common.util.excel;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+import com.lyg.common.util.DateUtil;
9
+
10
+import java.time.LocalDateTime;
11
+
12
+public class LocalDateTimeConverter implements Converter<LocalDateTime> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return LocalDateTime.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.STRING;
21
+    }
22
+
23
+    /**
24
+     * 写 Excel
25
+     * @param value
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public WriteCellData<?> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        if (null == value) return null;
34
+
35
+        String val = DateUtil.toString(value, "yyyy-MM-dd HH:mm:ss");
36
+
37
+        return new WriteCellData(val);
38
+    }
39
+}

+ 40
- 0
common/src/main/java/com/lyg/common/util/excel/TimestampConverter.java View File

@@ -0,0 +1,40 @@
1
+package com.lyg.common.util.excel;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+
9
+import java.sql.Timestamp;
10
+import java.text.SimpleDateFormat;
11
+
12
+public class TimestampConverter implements Converter<Timestamp> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return Timestamp.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.STRING;
21
+    }
22
+
23
+    /**
24
+     * 写 Excel
25
+     * @param value
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public WriteCellData<?> convertToExcelData(Timestamp value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        if (null == value) return null;
34
+
35
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
36
+        String val = dateFormat.format(value);
37
+
38
+        return new WriteCellData(val);
39
+    }
40
+}

+ 344
- 0
db/ddl.sql View File

@@ -0,0 +1,344 @@
1
+CREATE TABLE sys_org(
2
+                        org_id VARCHAR2(32) NOT NULL,
3
+                        org_code VARCHAR2(64),
4
+                        name VARCHAR2(90),
5
+                        parent_id VARCHAR2(32),
6
+                        sort_no INT,
7
+                        status INT DEFAULT  1,
8
+                        create_user VARCHAR2(32),
9
+                        create_date DATE DEFAULT  SYSDATE,
10
+                        update_user VARCHAR2(32),
11
+                        update_date DATE,
12
+                        deleted INT DEFAULT  0,
13
+                        PRIMARY KEY (org_id)
14
+);
15
+
16
+COMMENT ON TABLE sys_org IS '单位表';
17
+COMMENT ON COLUMN sys_org.org_id IS '机构ID';
18
+COMMENT ON COLUMN sys_org.org_code IS '机构编码';
19
+COMMENT ON COLUMN sys_org.name IS '机构名称';
20
+COMMENT ON COLUMN sys_org.parent_id IS '上级单位;-1为根级目录';
21
+COMMENT ON COLUMN sys_org.sort_no IS '排序';
22
+COMMENT ON COLUMN sys_org.status IS '状态';
23
+COMMENT ON COLUMN sys_org.create_user IS '创建人';
24
+COMMENT ON COLUMN sys_org.create_date IS '创建时间';
25
+COMMENT ON COLUMN sys_org.update_user IS '更新人';
26
+COMMENT ON COLUMN sys_org.update_date IS '更新时间';
27
+COMMENT ON COLUMN sys_org.deleted IS '删除标志;1删除';
28
+
29
+CREATE TABLE sys_position(
30
+                             position_id VARCHAR2(32) NOT NULL,
31
+                             name VARCHAR2(90),
32
+                             org_id VARCHAR2(32),
33
+                             dept_id VARCHAR2(32),
34
+                             sort_num INT,
35
+                             status INT DEFAULT  1,
36
+                             create_user VARCHAR2(32),
37
+                             create_date DATE DEFAULT  SYSDATE,
38
+                             update_user VARCHAR2(32),
39
+                             update_date DATE,
40
+                             deleted INT DEFAULT  0,
41
+                             PRIMARY KEY (position_id)
42
+);
43
+
44
+COMMENT ON TABLE sys_position IS '岗位表';
45
+COMMENT ON COLUMN sys_position.position_id IS '岗位ID';
46
+COMMENT ON COLUMN sys_position.name IS '岗位名称';
47
+COMMENT ON COLUMN sys_position.org_id IS '所属单位';
48
+COMMENT ON COLUMN sys_position.dept_id IS '所属部门';
49
+COMMENT ON COLUMN sys_position.sort_num IS '排序';
50
+COMMENT ON COLUMN sys_position.status IS '状态';
51
+COMMENT ON COLUMN sys_position.create_user IS '创建人';
52
+COMMENT ON COLUMN sys_position.create_date IS '创建时间';
53
+COMMENT ON COLUMN sys_position.update_user IS '更新人';
54
+COMMENT ON COLUMN sys_position.update_date IS '更新时间';
55
+COMMENT ON COLUMN sys_position.deleted IS '删除标志;1删除';
56
+
57
+CREATE TABLE sys_user(
58
+                         user_id VARCHAR2(32) NOT NULL,
59
+                         name VARCHAR2(90),
60
+                         avatar VARCHAR2(900),
61
+                         phone VARCHAR2(20),
62
+                         hx_id VARCHAR2(128),
63
+                         position_id VARCHAR2(32),
64
+                         org_id VARCHAR2(32),
65
+                         org_name VARCHAR2(90),
66
+                         status INT DEFAULT  1,
67
+                         create_user VARCHAR2(32),
68
+                         create_date DATE DEFAULT  SYSDATE,
69
+                         update_user VARCHAR2(32),
70
+                         update_date DATE,
71
+                         deleted INT DEFAULT  0,
72
+                         PRIMARY KEY (user_id)
73
+);
74
+
75
+COMMENT ON TABLE sys_user IS '用户表';
76
+COMMENT ON COLUMN sys_user.user_id IS '用户ID';
77
+COMMENT ON COLUMN sys_user.name IS '用户名称';
78
+COMMENT ON COLUMN sys_user.avatar IS '头像';
79
+COMMENT ON COLUMN sys_user.phone IS '手机';
80
+COMMENT ON COLUMN sys_user.hx_id IS '行信ID';
81
+COMMENT ON COLUMN sys_user.position_id IS '岗位ID';
82
+COMMENT ON COLUMN sys_user.org_id IS '机构ID';
83
+COMMENT ON COLUMN sys_user.org_name IS '机构名称';
84
+COMMENT ON COLUMN sys_user.status IS '状态';
85
+COMMENT ON COLUMN sys_user.create_user IS '创建人';
86
+COMMENT ON COLUMN sys_user.create_date IS '创建时间';
87
+COMMENT ON COLUMN sys_user.update_user IS '更新人';
88
+COMMENT ON COLUMN sys_user.update_date IS '更新时间';
89
+COMMENT ON COLUMN sys_user.deleted IS '删除标志;1删除';
90
+
91
+CREATE TABLE sys_role(
92
+                         role_id VARCHAR2(32) NOT NULL,
93
+                         name VARCHAR2(90),
94
+                         status INT DEFAULT  1,
95
+                         create_user VARCHAR2(32),
96
+                         create_date DATE DEFAULT  SYSDATE,
97
+                         update_user VARCHAR2(32),
98
+                         update_date DATE,
99
+                         deleted INT DEFAULT  0,
100
+                         PRIMARY KEY (role_id)
101
+);
102
+
103
+COMMENT ON TABLE sys_role IS '系统角色';
104
+COMMENT ON COLUMN sys_role.role_id IS '角色ID';
105
+COMMENT ON COLUMN sys_role.name IS '角色名称';
106
+COMMENT ON COLUMN sys_role.status IS '状态';
107
+COMMENT ON COLUMN sys_role.create_user IS '创建人';
108
+COMMENT ON COLUMN sys_role.create_date IS '创建时间';
109
+COMMENT ON COLUMN sys_role.update_user IS '更新人';
110
+COMMENT ON COLUMN sys_role.update_date IS '更新时间';
111
+COMMENT ON COLUMN sys_role.deleted IS '删除标志;1删除';
112
+
113
+CREATE TABLE sys_user_role(
114
+                              id VARCHAR2(32) NOT NULL,
115
+                              role_id VARCHAR2(32),
116
+                              user_id VARCHAR2(32),
117
+                              PRIMARY KEY (id)
118
+);
119
+
120
+COMMENT ON TABLE sys_user_role IS '角色授权';
121
+COMMENT ON COLUMN sys_user_role.id IS 'id';
122
+COMMENT ON COLUMN sys_user_role.role_id IS '角色ID';
123
+COMMENT ON COLUMN sys_user_role.user_id IS '用户ID';
124
+
125
+CREATE TABLE sys_tenant(
126
+                           tenant_id VARCHAR2(32) NOT NULL,
127
+                           name VARCHAR2(90),
128
+                           sort_no INT DEFAULT  1,
129
+                           status INT DEFAULT  1,
130
+                           create_user VARCHAR2(32),
131
+                           create_date DATE DEFAULT  SYSDATE,
132
+                           update_user VARCHAR2(32),
133
+                           update_date DATE,
134
+                           deleted INT DEFAULT  0,
135
+                           PRIMARY KEY (tenant_id)
136
+);
137
+
138
+COMMENT ON TABLE sys_tenant IS '租户表';
139
+COMMENT ON COLUMN sys_tenant.tenant_id IS '租户ID';
140
+COMMENT ON COLUMN sys_tenant.name IS '租户名称';
141
+COMMENT ON COLUMN sys_tenant.sort_no IS '排序';
142
+COMMENT ON COLUMN sys_tenant.status IS '状态';
143
+COMMENT ON COLUMN sys_tenant.create_user IS '创建人';
144
+COMMENT ON COLUMN sys_tenant.create_date IS '创建时间';
145
+COMMENT ON COLUMN sys_tenant.update_user IS '更新人';
146
+COMMENT ON COLUMN sys_tenant.update_date IS '更新时间';
147
+COMMENT ON COLUMN sys_tenant.deleted IS '删除标志;1删除';
148
+
149
+CREATE TABLE ta_user_tenant(
150
+                               id VARCHAR2(32) NOT NULL,
151
+                               user_id VARCHAR2(32),
152
+                               tenant_id VARCHAR2(32),
153
+                               update_user VARCHAR2(32),
154
+                               update_date DATE,
155
+                               deleted INT DEFAULT  0,
156
+                               PRIMARY KEY (id)
157
+);
158
+
159
+COMMENT ON TABLE ta_user_tenant IS '用户分组';
160
+COMMENT ON COLUMN ta_user_tenant.id IS 'ID';
161
+COMMENT ON COLUMN ta_user_tenant.user_id IS '用户ID';
162
+COMMENT ON COLUMN ta_user_tenant.tenant_id IS '租户ID';
163
+COMMENT ON COLUMN ta_user_tenant.update_user IS '更新人';
164
+COMMENT ON COLUMN ta_user_tenant.update_date IS '更新时间';
165
+COMMENT ON COLUMN ta_user_tenant.deleted IS '删除标志;1删除';
166
+
167
+CREATE TABLE ta_project(
168
+                           project_id VARCHAR2(32) NOT NULL,
169
+                           name VARCHAR2(128),
170
+                           icon VARCHAR2(255),
171
+                           description VARCHAR2(255),
172
+                           status INT DEFAULT  1,
173
+                           tenant_id VARCHAR2(32),
174
+                           deleted INT DEFAULT  0,
175
+                           create_user VARCHAR2(32),
176
+                           create_date DATE DEFAULT  SYSDATE,
177
+                           update_user VARCHAR2(32),
178
+                           update_date DATE,
179
+                           PRIMARY KEY (project_id)
180
+);
181
+
182
+COMMENT ON TABLE ta_project IS '项目表';
183
+COMMENT ON COLUMN ta_project.project_id IS '项目ID';
184
+COMMENT ON COLUMN ta_project.name IS '项目名称';
185
+COMMENT ON COLUMN ta_project.icon IS '项目图标';
186
+COMMENT ON COLUMN ta_project.description IS '描述';
187
+COMMENT ON COLUMN ta_project.status IS '状态';
188
+COMMENT ON COLUMN ta_project.tenant_id IS '租户号';
189
+COMMENT ON COLUMN ta_project.deleted IS '删除标志';
190
+COMMENT ON COLUMN ta_project.create_user IS '创建人';
191
+COMMENT ON COLUMN ta_project.create_date IS '创建时间';
192
+COMMENT ON COLUMN ta_project.update_user IS '更新人';
193
+COMMENT ON COLUMN ta_project.update_date IS '更新时间';
194
+
195
+CREATE TABLE ta_project_org(
196
+                               id VARCHAR2(32) NOT NULL,
197
+                               project_id VARCHAR2(32),
198
+                               org_id VARCHAR2(32),
199
+                               PRIMARY KEY (id)
200
+);
201
+
202
+COMMENT ON TABLE ta_project_org IS '项目参与部门';
203
+COMMENT ON COLUMN ta_project_org.id IS 'ID';
204
+COMMENT ON COLUMN ta_project_org.project_id IS '项目ID';
205
+COMMENT ON COLUMN ta_project_org.org_id IS '部门ID';
206
+
207
+CREATE TABLE ta_project_item(
208
+                                item_id VARCHAR2(32) NOT NULL,
209
+                                name VARCHAR2(255),
210
+                                icon VARCHAR2(255),
211
+                                project_id VARCHAR2(32),
212
+                                score DECIMAL(6,2) DEFAULT  0.0,
213
+                                sort INT DEFAULT  0,
214
+                                status INT DEFAULT  1,
215
+                                tenant_id VARCHAR2(32),
216
+                                deleted INT DEFAULT  0,
217
+                                create_user VARCHAR2(32),
218
+                                create_date DATE DEFAULT  SYSDATE,
219
+                                update_user VARCHAR2(32),
220
+                                update_date DATE,
221
+                                PRIMARY KEY (item_id)
222
+);
223
+
224
+COMMENT ON TABLE ta_project_item IS '项目内容';
225
+COMMENT ON COLUMN ta_project_item.item_id IS '内容ID';
226
+COMMENT ON COLUMN ta_project_item.name IS '内容名称';
227
+COMMENT ON COLUMN ta_project_item.icon IS '内容图标';
228
+COMMENT ON COLUMN ta_project_item.project_id IS '项目ID';
229
+COMMENT ON COLUMN ta_project_item.score IS '积分';
230
+COMMENT ON COLUMN ta_project_item.sort IS '序号';
231
+COMMENT ON COLUMN ta_project_item.status IS '状态';
232
+COMMENT ON COLUMN ta_project_item.tenant_id IS '租户号';
233
+COMMENT ON COLUMN ta_project_item.deleted IS '删除标志';
234
+COMMENT ON COLUMN ta_project_item.create_user IS '创建人';
235
+COMMENT ON COLUMN ta_project_item.create_date IS '创建时间';
236
+COMMENT ON COLUMN ta_project_item.update_user IS '更新人';
237
+COMMENT ON COLUMN ta_project_item.update_date IS '更新时间';
238
+
239
+CREATE TABLE ta_project_report(
240
+                                  data_id VARCHAR2(32) NOT NULL,
241
+                                  project_id VARCHAR2(32),
242
+                                  project_name VARCHAR2(255),
243
+                                  project_icon VARCHAR2(255),
244
+                                  item_id VARCHAR2(32),
245
+                                  item_name VARCHAR2(255),
246
+                                  item_icon VARCHAR2(255),
247
+                                  item_sort INT DEFAULT  0,
248
+                                  score_value DECIMAL(6,2) DEFAULT  0.0,
249
+                                  status INT DEFAULT  1,
250
+                                  org_id VARCHAR2(32),
251
+                                  org_name VARCHAR2(255),
252
+                                  tenant_id VARCHAR2(32),
253
+                                  deleted INT DEFAULT  0,
254
+                                  create_user VARCHAR2(32),
255
+                                  create_date DATE DEFAULT  SYSDATE,
256
+                                  update_user VARCHAR2(32),
257
+                                  update_date DATE,
258
+                                  PRIMARY KEY (data_id)
259
+);
260
+
261
+COMMENT ON TABLE ta_project_report IS '项目填报';
262
+COMMENT ON COLUMN ta_project_report.data_id IS '数据ID';
263
+COMMENT ON COLUMN ta_project_report.project_id IS '项目ID';
264
+COMMENT ON COLUMN ta_project_report.project_name IS '项目名称';
265
+COMMENT ON COLUMN ta_project_report.project_icon IS '项目图标';
266
+COMMENT ON COLUMN ta_project_report.item_id IS '内容ID';
267
+COMMENT ON COLUMN ta_project_report.item_name IS '内容名称';
268
+COMMENT ON COLUMN ta_project_report.item_icon IS '内容图标';
269
+COMMENT ON COLUMN ta_project_report.item_sort IS '内容序号';
270
+COMMENT ON COLUMN ta_project_report.score_value IS '填报值';
271
+COMMENT ON COLUMN ta_project_report.status IS '状态';
272
+COMMENT ON COLUMN ta_project_report.org_id IS '所属部门';
273
+COMMENT ON COLUMN ta_project_report.org_name IS '部门名称';
274
+COMMENT ON COLUMN ta_project_report.tenant_id IS '租户号';
275
+COMMENT ON COLUMN ta_project_report.deleted IS '删除标志';
276
+COMMENT ON COLUMN ta_project_report.create_user IS '创建人';
277
+COMMENT ON COLUMN ta_project_report.create_date IS '创建时间';
278
+COMMENT ON COLUMN ta_project_report.update_user IS '更新人';
279
+COMMENT ON COLUMN ta_project_report.update_date IS '更新时间';
280
+
281
+CREATE TABLE sys_log(
282
+                        log_id VARCHAR2(32) NOT NULL,
283
+                        login_id VARCHAR2(255),
284
+                        user_name VARCHAR2(255),
285
+                        module_name VARCHAR2(255),
286
+                        action VARCHAR2(900),
287
+                        client_type VARCHAR2(128),
288
+                        uri VARCHAR2(900),
289
+                        description VARCHAR2(900),
290
+                        ip VARCHAR2(255),
291
+                        ua VARCHAR2(2000),
292
+                        create_date DATE DEFAULT  SYSDATE,
293
+                        PRIMARY KEY (log_id)
294
+);
295
+
296
+COMMENT ON TABLE sys_log IS '系统日志';
297
+COMMENT ON COLUMN sys_log.log_id IS '日志ID';
298
+COMMENT ON COLUMN sys_log.login_id IS '登录ID';
299
+COMMENT ON COLUMN sys_log.user_name IS '用户名';
300
+COMMENT ON COLUMN sys_log.module_name IS '模块名称';
301
+COMMENT ON COLUMN sys_log.action IS '操作内容';
302
+COMMENT ON COLUMN sys_log.client_type IS '客户端';
303
+COMMENT ON COLUMN sys_log.uri IS '访问地址';
304
+COMMENT ON COLUMN sys_log.description IS '具体操作';
305
+COMMENT ON COLUMN sys_log.ip IS '用户ID';
306
+COMMENT ON COLUMN sys_log.ua IS 'User Agent';
307
+COMMENT ON COLUMN sys_log.create_date IS '操作时间';
308
+
309
+CREATE TABLE sys_menu(
310
+                         menu_id VARCHAR2(32) NOT NULL,
311
+                         name VARCHAR2(90),
312
+                         menu_code VARCHAR2(32),
313
+                         parent_id VARCHAR2(32),
314
+                         sort_no INT,
315
+                         status INT DEFAULT  1,
316
+                         create_user VARCHAR2(32),
317
+                         create_date DATE DEFAULT  SYSDATE,
318
+                         PRIMARY KEY (menu_id)
319
+);
320
+
321
+COMMENT ON TABLE sys_menu IS '菜单表';
322
+COMMENT ON COLUMN sys_menu.menu_id IS '菜单ID';
323
+COMMENT ON COLUMN sys_menu.name IS '菜单名称';
324
+COMMENT ON COLUMN sys_menu.menu_code IS '菜单编码';
325
+COMMENT ON COLUMN sys_menu.parent_id IS '上级ID';
326
+COMMENT ON COLUMN sys_menu.sort_no IS '排序';
327
+COMMENT ON COLUMN sys_menu.status IS '状态';
328
+COMMENT ON COLUMN sys_menu.create_user IS '创建人';
329
+COMMENT ON COLUMN sys_menu.create_date IS '创建时间';
330
+
331
+CREATE TABLE sys_role_resource(
332
+                                  id VARCHAR2(32) NOT NULL,
333
+                                  role_id VARCHAR2(32),
334
+                                  resource_id VARCHAR2(32),
335
+                                  resource_type VARCHAR2(32),
336
+                                  PRIMARY KEY (id)
337
+);
338
+
339
+COMMENT ON TABLE sys_role_resource IS '角色资源';
340
+COMMENT ON COLUMN sys_role_resource.id IS 'id';
341
+COMMENT ON COLUMN sys_role_resource.role_id IS '角色ID';
342
+COMMENT ON COLUMN sys_role_resource.resource_id IS '资源ID';
343
+COMMENT ON COLUMN sys_role_resource.resource_type IS '资源类型';
344
+

+ 116
- 0
framework/pom.xml View File

@@ -0,0 +1,116 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <parent>
5
+        <artifactId>demo</artifactId>
6
+        <groupId>com.lyg</groupId>
7
+        <version>0.0.1</version>
8
+    </parent>
9
+    <modelVersion>4.0.0</modelVersion>
10
+
11
+    <artifactId>framework</artifactId>
12
+
13
+    <dependencies>
14
+        <dependency>
15
+            <groupId>com.lyg</groupId>
16
+            <artifactId>common</artifactId>
17
+            <version>0.0.1</version>
18
+            <scope>compile</scope>
19
+        </dependency>
20
+        <dependency>
21
+            <groupId>org.projectlombok</groupId>
22
+            <artifactId>lombok</artifactId>
23
+        </dependency>
24
+
25
+        <dependency>
26
+            <groupId>org.springframework.boot</groupId>
27
+            <artifactId>spring-boot-configuration-processor</artifactId>
28
+            <optional>true</optional>
29
+        </dependency>
30
+
31
+        <dependency>
32
+            <groupId>org.springframework.boot</groupId>
33
+            <artifactId>spring-boot-starter-aop</artifactId>
34
+        </dependency>
35
+
36
+        <!-- oracle -->
37
+        <dependency>
38
+            <groupId>com.oracle.database.jdbc</groupId>
39
+            <artifactId>ojdbc8</artifactId>
40
+            <scope>runtime</scope>
41
+        </dependency>
42
+        <!-- https://mvnrepository.com/artifact/com.oracle.database.nls/orai18n -->
43
+        <!-- gbk 字符支持 -->
44
+        <dependency>
45
+            <groupId>com.oracle.database.nls</groupId>
46
+            <artifactId>orai18n</artifactId>
47
+            <version>${orai18n.version}</version>
48
+        </dependency>
49
+
50
+
51
+        <!-- Sa-Token 权限认证, 在线文档:https://sa-token.cc/ -->
52
+        <dependency>
53
+            <groupId>cn.dev33</groupId>
54
+            <artifactId>sa-token-spring-boot-starter</artifactId>
55
+            <version>${sa-token.version}</version>
56
+        </dependency>
57
+
58
+        <!-- Sa-Token 插件:整合SSO -->
59
+        <dependency>
60
+            <groupId>cn.dev33</groupId>
61
+            <artifactId>sa-token-sso</artifactId>
62
+            <version>${sa-token.version}</version>
63
+        </dependency>
64
+
65
+        <!-- Sa-Token 整合redis (使用jackson序列化方式) -->
66
+        <dependency>
67
+            <groupId>cn.dev33</groupId>
68
+            <artifactId>sa-token-dao-redis-jackson</artifactId>
69
+            <version>${sa-token.version}</version>
70
+        </dependency>
71
+
72
+        <!-- 提供Redis连接池 -->
73
+        <dependency>
74
+            <groupId>org.apache.commons</groupId>
75
+            <artifactId>commons-pool2</artifactId>
76
+        </dependency>
77
+
78
+        <!-- Http请求工具 -->
79
+        <dependency>
80
+            <groupId>com.dtflys.forest</groupId>
81
+            <artifactId>forest-spring-boot-starter</artifactId>
82
+            <version>${forest.version}</version>
83
+        </dependency>
84
+
85
+        <!--mybatis-plus start-->
86
+        <dependency>
87
+            <groupId>com.baomidou</groupId>
88
+            <artifactId>mybatis-plus-boot-starter</artifactId>
89
+            <version>${mybatis-plus.version}</version>
90
+        </dependency>
91
+        <!--mybatis-plus end-->
92
+
93
+        <!-- hutool -->
94
+        <dependency>
95
+            <groupId>cn.hutool</groupId>
96
+            <artifactId>hutool-json</artifactId>
97
+            <version>${hutool.version}</version>
98
+        </dependency>
99
+
100
+        <!--swagger start-->
101
+        <dependency>
102
+            <groupId>io.springfox</groupId>
103
+            <artifactId>springfox-boot-starter</artifactId>
104
+            <version>${swagger.version}</version>
105
+        </dependency>
106
+        <!--swagger end-->
107
+
108
+    </dependencies>
109
+
110
+    <properties>
111
+        <maven.compiler.source>8</maven.compiler.source>
112
+        <maven.compiler.target>8</maven.compiler.target>
113
+    </properties>
114
+
115
+
116
+</project>

+ 20
- 0
framework/src/main/java/com/lyg/framework/accesslimit/AccessLimit.java View File

@@ -0,0 +1,20 @@
1
+package com.lyg.framework.accesslimit;
2
+
3
+import java.lang.annotation.*;
4
+
5
+@Inherited
6
+@Documented
7
+@Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD})
8
+@Retention(RetentionPolicy.RUNTIME)
9
+public @interface AccessLimit {
10
+
11
+    /**
12
+     * 指定 second 时间内 API请求次数
13
+     */
14
+    int maxCount() default 999;
15
+
16
+    /**
17
+     * 请求次数的指定时间范围 秒数(redis数据过期时间)
18
+     */
19
+    int second() default 60;
20
+}

+ 77
- 0
framework/src/main/java/com/lyg/framework/accesslimit/AccessLimitInterceptor.java View File

@@ -0,0 +1,77 @@
1
+package com.lyg.framework.accesslimit;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+//import com.lyg.common.util.IpUtil;
5
+//import com.lyg.framework.util.RedisTool;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.springframework.stereotype.Component;
8
+import org.springframework.web.method.HandlerMethod;
9
+import org.springframework.web.servlet.HandlerInterceptor;
10
+
11
+import javax.servlet.http.HttpServletRequest;
12
+import javax.servlet.http.HttpServletResponse;
13
+import java.io.IOException;
14
+import java.lang.reflect.Method;
15
+
16
+@Slf4j
17
+@Component
18
+public class AccessLimitInterceptor implements HandlerInterceptor {
19
+
20
+    @Override
21
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
22
+//        try {// Handler 是否为 HandlerMethod 实例
23
+//            if (handler instanceof HandlerMethod) {
24
+//                // 强转
25
+//                HandlerMethod handlerMethod = (HandlerMethod) handler;
26
+//                // 获取方法
27
+//                Method method = handlerMethod.getMethod();
28
+//                // 是否有AccessLimit注解
29
+//                if (!method.isAnnotationPresent(AccessLimit.class)) {
30
+//                    return true;
31
+//                }
32
+//                // 获取注解内容信息
33
+//                AccessLimit accessLimit = method.getAnnotation(AccessLimit.class);
34
+//                if (accessLimit == null) {
35
+//                    return true;
36
+//                }
37
+//                int seconds = accessLimit.second();
38
+//                int maxCount = accessLimit.maxCount();
39
+//
40
+//                // 存储key
41
+//                String ip = IpUtil.getIpAddr(request);
42
+//                String key = ip + ":" + request.getRequestURI();
43
+//
44
+//                // 已经访问的次数
45
+//                Integer count = (Integer) RedisTool.get(key);
46
+////                System.out.println("已经访问的次数:" + count);
47
+//                if (null == count || -1 == count) {
48
+//                    RedisTool.set(key, 1, seconds);
49
+//                    return true;
50
+//                }
51
+//
52
+//                if (count < maxCount) {
53
+//                    count += 1;
54
+//                    RedisTool.update(key, count);
55
+//                    return true;
56
+//                }
57
+//
58
+//                SaResult result = new SaResult().setCode(500).setMsg("请求过于频繁请稍后再试");
59
+//                sendJSON(result, response);
60
+//                return false;
61
+//            }
62
+//
63
+//            return true;
64
+//        } catch (Exception e) {
65
+//            e.printStackTrace();
66
+//            return false;
67
+//        }
68
+
69
+        return true;
70
+    }
71
+
72
+    private void sendJSON(SaResult result, HttpServletResponse response) throws IOException {
73
+        response.setCharacterEncoding("UTF-8");
74
+        response.setContentType("application/json");
75
+        response.getWriter().append(result.toString());
76
+    }
77
+}

+ 25
- 0
framework/src/main/java/com/lyg/framework/accesslimit/IntercepterConfig.java View File

@@ -0,0 +1,25 @@
1
+package com.lyg.framework.accesslimit;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.beans.factory.annotation.Value;
5
+import org.springframework.context.annotation.Configuration;
6
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
7
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8
+
9
+@Configuration
10
+public class IntercepterConfig implements WebMvcConfigurer {
11
+
12
+    @Autowired
13
+    private AccessLimitInterceptor accessLimitInterceptor;
14
+
15
+    @Value("${access-limit.enabled}")
16
+    Boolean enabled;
17
+
18
+    @Override
19
+    public void addInterceptors(InterceptorRegistry registry) {
20
+        if (null != enabled && enabled) {
21
+            registry.addInterceptor(accessLimitInterceptor)
22
+                    .addPathPatterns("/**");
23
+        }
24
+    }
25
+}

+ 14
- 0
framework/src/main/java/com/lyg/framework/config/FilterConfig.java View File

@@ -0,0 +1,14 @@
1
+package com.lyg.framework.config;
2
+
3
+import lombok.Data;
4
+import org.springframework.boot.context.properties.ConfigurationProperties;
5
+import org.springframework.stereotype.Component;
6
+
7
+import java.util.List;
8
+
9
+@Data
10
+@Component
11
+@ConfigurationProperties(prefix = "yz.filter")
12
+public class FilterConfig {
13
+    List<String> annList;
14
+}

+ 31
- 0
framework/src/main/java/com/lyg/framework/config/LocalDateTimeSerializerConfig.java View File

@@ -0,0 +1,31 @@
1
+package com.lyg.framework.config;
2
+
3
+import com.fasterxml.jackson.databind.ObjectMapper;
4
+import com.fasterxml.jackson.databind.SerializationFeature;
5
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
6
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
7
+import org.springframework.beans.factory.annotation.Value;
8
+import org.springframework.context.annotation.Bean;
9
+import org.springframework.context.annotation.Configuration;
10
+import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
11
+
12
+import java.time.LocalDateTime;
13
+import java.time.format.DateTimeFormatter;
14
+
15
+// 解决 request body 不能接收 日期问题
16
+
17
+@Configuration
18
+public class LocalDateTimeSerializerConfig {
19
+
20
+    @Value("${spring.jackson.date-format}")
21
+    private String pattern;
22
+
23
+    @Bean
24
+    public ObjectMapper serializingObjectMapper() {
25
+        JavaTimeModule module = new JavaTimeModule();
26
+        LocalDateTimeDeserializer dateTimeDeserializer = new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(pattern));
27
+        module.addDeserializer(LocalDateTime.class, dateTimeDeserializer);
28
+        return Jackson2ObjectMapperBuilder.json().modules(module)
29
+                .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
30
+    }
31
+}

+ 24
- 0
framework/src/main/java/com/lyg/framework/config/SwaggerConfig.java View File

@@ -0,0 +1,24 @@
1
+package com.lyg.framework.config;
2
+
3
+import io.swagger.annotations.Api;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+import springfox.documentation.builders.PathSelectors;
7
+import springfox.documentation.builders.RequestHandlerSelectors;
8
+import springfox.documentation.spi.DocumentationType;
9
+import springfox.documentation.spring.web.plugins.Docket;
10
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
11
+
12
+@Configuration
13
+@EnableSwagger2
14
+public class SwaggerConfig {
15
+    @Bean
16
+    public Docket docket() {
17
+        return new Docket(DocumentationType.SWAGGER_2)
18
+                .select()
19
+                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
20
+                .paths(PathSelectors.any())
21
+                .build();
22
+
23
+    }
24
+}

+ 16
- 0
framework/src/main/java/com/lyg/framework/config/TenantConfig.java View File

@@ -0,0 +1,16 @@
1
+package com.lyg.framework.config;
2
+
3
+import lombok.Data;
4
+import org.springframework.boot.context.properties.ConfigurationProperties;
5
+import org.springframework.stereotype.Component;
6
+
7
+import java.util.List;
8
+
9
+@Data
10
+@Component
11
+@ConfigurationProperties(prefix = "tenant")
12
+public class TenantConfig {
13
+    Boolean enabled;
14
+    String defaultId;
15
+    List<String> whiteList;
16
+}

+ 11
- 0
framework/src/main/java/com/lyg/framework/config/_Config.java View File

@@ -0,0 +1,11 @@
1
+package com.lyg.framework.config;
2
+
3
+import com.lyg.common.util.MyPropertySourceFactory;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.context.annotation.PropertySource;
6
+
7
+@PropertySource(value = {"framework.yml"}, factory = MyPropertySourceFactory.class)
8
+@Configuration
9
+public class _Config {
10
+    // 目的加载配置文件
11
+}

+ 42
- 0
framework/src/main/java/com/lyg/framework/exception/GlobalExceptionHandler.java View File

@@ -0,0 +1,42 @@
1
+package com.lyg.framework.exception;
2
+
3
+import cn.dev33.satoken.exception.SaTokenException;
4
+import cn.dev33.satoken.util.SaResult;
5
+import lombok.extern.slf4j.Slf4j;
6
+import org.springframework.validation.ObjectError;
7
+import org.springframework.web.bind.MethodArgumentNotValidException;
8
+import org.springframework.web.bind.annotation.ExceptionHandler;
9
+import org.springframework.web.bind.annotation.ResponseBody;
10
+import org.springframework.web.bind.annotation.RestControllerAdvice;
11
+
12
+import java.util.List;
13
+
14
+@Slf4j
15
+@RestControllerAdvice
16
+public class GlobalExceptionHandler {
17
+
18
+    @ResponseBody
19
+    @ExceptionHandler(SaTokenException.class)
20
+    public SaResult handleSaTokenException(Exception e){
21
+        e.printStackTrace();
22
+        return SaResult.error(e.getMessage());
23
+    }
24
+
25
+    @ResponseBody
26
+    @ExceptionHandler(Exception.class)
27
+    public SaResult handleException(Exception e){
28
+        e.printStackTrace();
29
+        return SaResult.error(e.getMessage());
30
+    }
31
+
32
+    @ResponseBody
33
+    @ExceptionHandler(MethodArgumentNotValidException.class)
34
+    public SaResult handleValidException(MethodArgumentNotValidException e) {
35
+        e.printStackTrace();
36
+
37
+        List<ObjectError> allErrors = e.getBindingResult().getAllErrors();
38
+        ObjectError err = allErrors.get(0);
39
+
40
+        return SaResult.error(err.getDefaultMessage());
41
+    }
42
+}

+ 27
- 0
framework/src/main/java/com/lyg/framework/log/OpLog.java View File

@@ -0,0 +1,27 @@
1
+package com.lyg.framework.log;
2
+
3
+import java.lang.annotation.*;
4
+
5
+@Target({ ElementType.METHOD })
6
+@Retention(RetentionPolicy.RUNTIME)
7
+@Documented
8
+public @interface OpLog {
9
+
10
+    /**
11
+     * 模块
12
+     * @return
13
+     */
14
+    String module() default "";
15
+
16
+    /**
17
+     * 动作
18
+     * @return
19
+     */
20
+    String action() default "";
21
+
22
+    /**
23
+     * 详细描述
24
+     * @return
25
+     */
26
+    String desc() default "";
27
+}

+ 108
- 0
framework/src/main/java/com/lyg/framework/log/OpLogAspect.java View File

@@ -0,0 +1,108 @@
1
+package com.lyg.framework.log;
2
+
3
+import com.lyg.common.util.IpUtil;
4
+import com.lyg.framework.service.IOpLogService;
5
+import com.lyg.framework.service.IUserService;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.aspectj.lang.JoinPoint;
8
+import org.aspectj.lang.annotation.AfterReturning;
9
+import org.aspectj.lang.annotation.Aspect;
10
+import org.aspectj.lang.annotation.Pointcut;
11
+import org.aspectj.lang.reflect.MethodSignature;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.core.DefaultParameterNameDiscoverer;
14
+import org.springframework.expression.EvaluationContext;
15
+import org.springframework.expression.Expression;
16
+import org.springframework.expression.common.TemplateParserContext;
17
+import org.springframework.expression.spel.standard.SpelExpressionParser;
18
+import org.springframework.expression.spel.support.StandardEvaluationContext;
19
+import org.springframework.stereotype.Component;
20
+
21
+import javax.servlet.http.HttpServletRequest;
22
+import java.lang.reflect.Method;
23
+import java.util.HashMap;
24
+import java.util.Map;
25
+
26
+@Aspect
27
+@Component
28
+@Slf4j
29
+public class OpLogAspect {
30
+
31
+    @Autowired
32
+    IOpLogService opLogService;
33
+
34
+    @Autowired
35
+    IUserService userService;
36
+
37
+    @Autowired
38
+    HttpServletRequest request;
39
+
40
+    /**
41
+     * 用于SpEL表达式解析.
42
+     */
43
+    private static SpelExpressionParser parser = new SpelExpressionParser();
44
+    /**
45
+     * 用于获取方法参数定义名字.  能根据你传入的方法 获取该方法的参数名
46
+     */
47
+    private static DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer();
48
+    // 需要被SpEl解析的模板前缀和后缀 {{ expression  }}
49
+    private static final TemplateParserContext TEMPLATE_PARSER_CONTEXT = new TemplateParserContext("{{", "}}");
50
+
51
+    /**
52
+     * 切点
53
+     */
54
+    @Pointcut("@annotation(com.lyg.framework.log.OpLog)")
55
+    public void opLogPointCut() {}
56
+
57
+    @AfterReturning(value = "opLogPointCut()", returning = "jsonResult")
58
+    public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) {
59
+        try {
60
+            Object user = request.getAttribute("user");
61
+            String ip = IpUtil.getIpAddr(request);
62
+            String ua = request.getHeader("User-Agent");
63
+//            String tenantId = (String) request.getAttribute("tenantId");
64
+
65
+            Map<String, Object> data = new HashMap<>();
66
+            data.put("uri", request.getRequestURI());
67
+            data.put("ip", ip);
68
+            data.put("ua", ua);
69
+            data.put("user", user);
70
+            //
71
+            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
72
+            Method method = methodSignature.getMethod();
73
+            OpLog opLog = method.getAnnotation(OpLog.class);
74
+            if (opLog != null) {
75
+                data.put("module", opLog.module());
76
+                data.put("action", opLog.action());
77
+                if (null != opLog.desc() && !"".equals(opLog.desc())) {
78
+                    data.put("desc", generateKeyBySpEL(opLog.desc(), joinPoint));
79
+                }
80
+            }
81
+
82
+            opLogService.save(data);
83
+        } catch (Exception e) {
84
+            e.printStackTrace();
85
+        }
86
+    }
87
+
88
+    private String generateKeyBySpEL(String spELString, JoinPoint joinPoint) {
89
+        // 通过joinPoint获取被注解方法
90
+        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
91
+        Method method = methodSignature.getMethod();
92
+        // 使用spring的DefaultParameterNameDiscoverer获取方法形参名数组
93
+        String[] paramNames = nameDiscoverer.getParameterNames(method);
94
+        // 解析过后的Spring表达式对象
95
+        Expression expression = parser.parseExpression(spELString, TEMPLATE_PARSER_CONTEXT);
96
+        // spring的表达式上下文对象
97
+        EvaluationContext context = new StandardEvaluationContext();
98
+        // 通过joinPoint获取被注解方法的形参
99
+        Object[] args = joinPoint.getArgs();
100
+        // 给上下文赋值
101
+        for (int i = 0; i < args.length; i++) {
102
+            context.setVariable(paramNames[i], args[i]);
103
+        }
104
+        // 表达式从上下文中计算出实际参数值
105
+        return expression.getValue(context).toString();
106
+    }
107
+
108
+}

+ 69
- 0
framework/src/main/java/com/lyg/framework/mybatisplus/MyMetaObjectHandler.java View File

@@ -0,0 +1,69 @@
1
+package com.lyg.framework.mybatisplus;
2
+
3
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
4
+import com.lyg.framework.service.IUserService;
5
+import lombok.extern.slf4j.Slf4j;
6
+import org.apache.ibatis.reflection.MetaObject;
7
+import org.springframework.stereotype.Component;
8
+
9
+import javax.annotation.Resource;
10
+import javax.servlet.http.HttpServletRequest;
11
+import java.time.LocalDateTime;
12
+
13
+@Slf4j
14
+@Component
15
+public class MyMetaObjectHandler implements MetaObjectHandler {
16
+
17
+    @Resource
18
+    HttpServletRequest request;
19
+
20
+    @Resource
21
+    IUserService userService;
22
+
23
+
24
+    @Override
25
+    public void insertFill(MetaObject metaObject) {
26
+//        String loginType = (String) request.getAttribute("loginType");
27
+
28
+        try {
29
+            Object user = request.getAttribute("user");
30
+            String tenantId = (String) request.getAttribute("tenantId");
31
+            String userId = userService.getUserIdBy(user);
32
+
33
+            this.strictInsertFill(metaObject, "createDate", LocalDateTime::now, LocalDateTime.class);
34
+            this.strictInsertFill(metaObject, "updateDate", LocalDateTime::now, LocalDateTime.class);
35
+
36
+            if (user != null) {
37
+                this.strictInsertFill(metaObject, "createUser", () -> userId, String.class);
38
+                this.strictInsertFill(metaObject, "updateUser", () -> userId, String.class);
39
+            }
40
+            if (null != tenantId) {
41
+                this.strictInsertFill(metaObject, "tenantId", () -> tenantId, String.class);
42
+            }
43
+
44
+            this.strictInsertFill(metaObject, "deleted", () -> 0, Integer.class);
45
+//            metaObject.setValue("deleted",0);
46
+        } catch (Exception e) {
47
+            e.printStackTrace();
48
+        }
49
+    }
50
+
51
+    @Override
52
+    public void updateFill(MetaObject metaObject) {
53
+//        String loginType = (String) request.getAttribute("loginType");
54
+
55
+        try {
56
+            Object user = request.getAttribute("user");
57
+//            String tenantId = (String) request.getAttribute("tenantId");
58
+            String userId = userService.getUserIdBy(user);
59
+            String userName = userService.getUserNameBy(user);
60
+
61
+            this.strictInsertFill(metaObject, "updateDate", LocalDateTime::now, LocalDateTime.class);
62
+            if (user != null) {
63
+                this.strictInsertFill(metaObject, "updateUser", () -> userId, String.class);
64
+            }
65
+        } catch (Exception e) {
66
+            e.printStackTrace();
67
+        }
68
+    }
69
+}

+ 64
- 0
framework/src/main/java/com/lyg/framework/mybatisplus/MybatisPlusConfig.java View File

@@ -0,0 +1,64 @@
1
+package com.lyg.framework.mybatisplus;
2
+
3
+import com.baomidou.mybatisplus.annotation.DbType;
4
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
5
+import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
6
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
7
+import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
8
+import com.lyg.common.util.MyPropertySourceFactory;
9
+import com.lyg.framework.config.TenantConfig;
10
+import net.sf.jsqlparser.expression.Expression;
11
+import net.sf.jsqlparser.expression.StringValue;
12
+import org.springframework.context.annotation.Bean;
13
+import org.springframework.context.annotation.Configuration;
14
+import org.springframework.context.annotation.PropertySource;
15
+
16
+import javax.annotation.Resource;
17
+import javax.servlet.http.HttpServletRequest;
18
+
19
+//@PropertySource(value = {"framework.yml"}, factory = MyPropertySourceFactory.class)
20
+@Configuration
21
+public class MybatisPlusConfig {
22
+    @Resource
23
+    HttpServletRequest request;
24
+
25
+    @Resource
26
+    TenantConfig tenantConfig;
27
+
28
+    @Bean
29
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
30
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
31
+
32
+        // 分页插件
33
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.ORACLE));
34
+
35
+        if (tenantConfig.getEnabled()) {
36
+            // 多租户插件
37
+            interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new TenantLineHandler() {
38
+                @Override
39
+                public Expression getTenantId() {
40
+                    // request 中的 tenantId 是在 sa-token 中设置的
41
+                    String tenantId = (String) request.getAttribute("tenantId");
42
+                    return new StringValue(tenantId == null ? tenantConfig.getDefaultId() : tenantId);
43
+                }
44
+
45
+                @Override
46
+                public String getTenantIdColumn() {
47
+                    return "tenant_id";
48
+                }
49
+
50
+                // 设置不用添加租户查询条件的表
51
+                @Override
52
+                public boolean ignoreTable(String tableName) {
53
+                    return tenantConfig.getWhiteList().contains(tableName);
54
+                }
55
+            }));
56
+        }
57
+
58
+        return interceptor;
59
+    }
60
+
61
+
62
+
63
+
64
+}

+ 42
- 0
framework/src/main/java/com/lyg/framework/satoken/SaServletFilter2.java View File

@@ -0,0 +1,42 @@
1
+package com.lyg.framework.satoken;
2
+
3
+import cn.dev33.satoken.stp.StpUtil;
4
+import com.lyg.framework.service.IUserService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.core.annotation.Order;
7
+import org.springframework.stereotype.Component;
8
+
9
+import javax.servlet.*;
10
+import java.io.IOException;
11
+
12
+/**
13
+ * 比 SaServletFilter 的排序大即可
14
+     * SaServletFilter 的默认排序是负数
15
+ * 主要作用附加当前用户信息
16
+ */
17
+@Order(1)
18
+@Component
19
+public class SaServletFilter2 implements Filter {
20
+
21
+    @Autowired
22
+    IUserService userService;
23
+
24
+    @Override
25
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
26
+        // 只有登录之后才行
27
+        if (StpUtil.isLogin()) {
28
+            appendUser(servletRequest);
29
+        }
30
+
31
+        //
32
+        filterChain.doFilter(servletRequest, servletResponse);
33
+    }
34
+
35
+    private void appendUser(ServletRequest request) {
36
+        Object user = userService.getUserBy(StpUtil.getLoginId());
37
+        if (null != user) {
38
+            request.setAttribute("user", user);
39
+        }
40
+        request.setAttribute("tenantId", userService.getTenantIdBy(user));
41
+    }
42
+}

+ 50
- 0
framework/src/main/java/com/lyg/framework/satoken/SaTokenConfigure.java View File

@@ -0,0 +1,50 @@
1
+package com.lyg.framework.satoken;
2
+
3
+import cn.dev33.satoken.context.SaHolder;
4
+import cn.dev33.satoken.exception.SaTokenException;
5
+import cn.dev33.satoken.filter.SaServletFilter;
6
+import cn.dev33.satoken.router.SaHttpMethod;
7
+import cn.dev33.satoken.router.SaRouter;
8
+import cn.dev33.satoken.stp.StpUtil;
9
+import cn.dev33.satoken.util.SaResult;
10
+import com.lyg.framework.config.FilterConfig;
11
+import org.springframework.context.annotation.Bean;
12
+import org.springframework.context.annotation.Configuration;
13
+
14
+import javax.annotation.Resource;
15
+
16
+@Configuration
17
+public class SaTokenConfigure {
18
+
19
+    @Resource
20
+    FilterConfig filterConfig;
21
+
22
+    @Bean
23
+    public SaServletFilter getSaServletFilter() {
24
+        SaServletFilter saServletFilter = new SaServletFilter();
25
+        saServletFilter.addInclude("/**");
26
+        saServletFilter.addExclude(filterConfig.getAnnList().toArray(new String[0]));
27
+        saServletFilter.setAuth(auth -> {
28
+            // OPTIONS 请求不校验, 主要是为了解决跨域问题
29
+            SaRouter.notMatch(SaHttpMethod.OPTIONS).check(r -> {
30
+                // 平台账户或者租户必须登录一个
31
+                if (!StpUtil.isLogin()) {
32
+                    throw new SaTokenException("请登录后再访问接口");
33
+                }
34
+            });
35
+        });
36
+
37
+        saServletFilter.setError(err -> {
38
+            SaHolder.getResponse().setHeader("Content-Type", "application/json;charset=UTF-8");
39
+            SaHolder.getResponse().setStatus(200);
40
+            return SaResult.error(err.getMessage()).setCode(401);
41
+        });
42
+
43
+        return saServletFilter;
44
+    }
45
+
46
+    @Bean
47
+    public SaServletFilter2 getSaServletFilter2() {
48
+        return new SaServletFilter2();
49
+    }
50
+}

+ 15
- 0
framework/src/main/java/com/lyg/framework/satoken/SaTokenInterceptor.java View File

@@ -0,0 +1,15 @@
1
+package com.lyg.framework.satoken;
2
+
3
+import cn.dev33.satoken.interceptor.SaInterceptor;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
6
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7
+
8
+@Configuration
9
+public class SaTokenInterceptor implements WebMvcConfigurer {
10
+    @Override
11
+    public void addInterceptors(InterceptorRegistry registry) {
12
+        // 注册 Sa-Token 拦截器,打开注解式鉴权功能
13
+        registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**");
14
+    }
15
+}

+ 7
- 0
framework/src/main/java/com/lyg/framework/service/IOpLogService.java View File

@@ -0,0 +1,7 @@
1
+package com.lyg.framework.service;
2
+
3
+import java.util.Map;
4
+
5
+public interface IOpLogService {
6
+    void save(Map data);
7
+}

+ 35
- 0
framework/src/main/java/com/lyg/framework/service/IUserService.java View File

@@ -0,0 +1,35 @@
1
+package com.lyg.framework.service;
2
+
3
+/**
4
+ * 人员接口
5
+ */
6
+
7
+public interface IUserService {
8
+    /**
9
+     * 依据登录ID查询当前登录用户
10
+     * @param loginId
11
+     * @return
12
+     */
13
+    Object getUserBy(Object loginId);
14
+
15
+    /**
16
+     * 返回 user 所属租户
17
+     * @param user
18
+     * @return
19
+     */
20
+    String getTenantIdBy(Object user);
21
+
22
+    /**
23
+     * 返回 userId
24
+     * @param user
25
+     * @return
26
+     */
27
+    String getUserIdBy(Object user);
28
+
29
+    /**
30
+     * 返回 userName
31
+     * @param user
32
+     * @return
33
+     */
34
+    String getUserNameBy(Object user);
35
+}

+ 67
- 0
framework/src/main/resources/framework.yml View File

@@ -0,0 +1,67 @@
1
+spring:
2
+  mvc:
3
+    log-request-details: true
4
+    pathmatch:
5
+      matching-strategy: ANT_PATH_MATCHER
6
+  jackson:
7
+    date-format: yyyy-MM-dd HH:mm:ss
8
+    time-zone: GMT+8
9
+  servlet:
10
+    multipart:
11
+      max-file-size: 1024MB
12
+      max-request-size: 1024MB
13
+
14
+### swagger
15
+springfox:
16
+  documentation:
17
+    auto-startup: true
18
+
19
+###
20
+mybatis-plus:
21
+  configuration:
22
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
23
+    call-setters-on-nulls: true
24
+  global-config:
25
+    db-config:
26
+      logic-delete-field: deleted # 全局逻辑删除的实体字段名(since 3.3.0)
27
+      logic-delete-value: 1 # 逻辑已删除值(默认为 1)
28
+      logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
29
+  mapper-locations: classpath*:mapper/**/*.xml
30
+  type-aliases-package: com.lyg.*.entity
31
+
32
+###
33
+tenant:
34
+  # 默认不启用
35
+  enabled: false
36
+  # no-tenantId
37
+  default-id: 7f16d7c4544041649fc20e39839582cc
38
+  # 不启用租户系统的表
39
+  white-list:
40
+    - sys_role_resource
41
+    - sys_user_role
42
+    - sys_role_auth
43
+    - sys_role_auth_custom
44
+
45
+###
46
+access-limit:
47
+  enabled: false
48
+
49
+sa-token:
50
+  # jwt秘钥
51
+  jwt-secret-key: d4d778d279cf11ed9b1d525400e8554f
52
+  # token名称 (同时也是cookie名称)
53
+  token-name: Authorization
54
+  # token有效期,单位s 默认30天, -1代表永不过期
55
+  timeout: 2592000
56
+  # token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
57
+  activity-timeout: -1
58
+  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
59
+  is-concurrent: true
60
+  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
61
+  is-share: true
62
+  # token风格
63
+  token-style: uuid
64
+  # 是否输出操作日志
65
+  is-log: false
66
+  # 是否尝试从 cookie 里读取 Token
67
+  is-read-cookie: false

+ 62
- 0
framework/src/main/resources/logback-spring.xml View File

@@ -0,0 +1,62 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<configuration debug="true">
3
+
4
+    <!-- 日志文件的存储地址 -->
5
+    <property name="LOG_PATH" value="./logs" />
6
+
7
+    <!-- 控制台输出 -->
8
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
9
+        <encoder>
10
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) --- [%15.15(%thread)] %cyan(%-40.40(%logger{40})) : %msg%n</pattern>
11
+            <charset>UTF-8</charset>
12
+        </encoder>
13
+    </appender>
14
+
15
+    <!-- 文件输出 INFO -->
16
+    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
17
+        <!-- 文件名称 -->
18
+        <file>${LOG_PATH}/admin-info.log</file>
19
+
20
+        <!-- 滚动规则 -->
21
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
22
+            <!-- 每天生成代码 -->
23
+            <fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}.%i.admin-info.log</fileNamePattern>
24
+            <!-- 日志文件保留天数, 0 不删除 -->
25
+            <maxHistory>0</maxHistory>
26
+            <maxFileSize>500MB</maxFileSize>
27
+        </rollingPolicy>
28
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
29
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level ${PID:-} --- [%t] %logger{50} - %msg%n</pattern>
30
+            <charset>UTF-8</charset>
31
+        </encoder>
32
+    </appender>
33
+
34
+    <!-- 文件输出 ERROR -->
35
+    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
36
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
37
+            <level>ERROR</level>
38
+        </filter>
39
+
40
+        <!-- 文件名称 -->
41
+        <file>${LOG_PATH}/admin-error.log</file>
42
+
43
+        <!-- 滚动规则 -->s
44
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
45
+            <!-- 每天生成代码 -->
46
+            <fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}.%i.admin-error.log</fileNamePattern>
47
+            <!-- 日志文件保留天数, 0 不删除 -->
48
+            <maxHistory>0</maxHistory>
49
+            <maxFileSize>500MB</maxFileSize>
50
+        </rollingPolicy>
51
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
52
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level ${PID:-} --- [%t] %logger{50} - %msg%n</pattern>
53
+            <charset>UTF-8</charset>
54
+        </encoder>
55
+    </appender>
56
+
57
+    <root level="INFO">
58
+        <appender-ref ref="STDOUT" />
59
+        <appender-ref ref="INFO_FILE" />
60
+        <appender-ref ref="ERROR_FILE" />
61
+    </root>
62
+</configuration>

+ 316
- 0
mvnw View File

@@ -0,0 +1,316 @@
1
+#!/bin/sh
2
+# ----------------------------------------------------------------------------
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+#    https://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+# KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+# ----------------------------------------------------------------------------
20
+
21
+# ----------------------------------------------------------------------------
22
+# Maven Start Up Batch script
23
+#
24
+# Required ENV vars:
25
+# ------------------
26
+#   JAVA_HOME - location of a JDK home dir
27
+#
28
+# Optional ENV vars
29
+# -----------------
30
+#   M2_HOME - location of maven2's installed home dir
31
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
32
+#     e.g. to debug Maven itself, use
33
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35
+# ----------------------------------------------------------------------------
36
+
37
+if [ -z "$MAVEN_SKIP_RC" ] ; then
38
+
39
+  if [ -f /usr/local/etc/mavenrc ] ; then
40
+    . /usr/local/etc/mavenrc
41
+  fi
42
+
43
+  if [ -f /etc/mavenrc ] ; then
44
+    . /etc/mavenrc
45
+  fi
46
+
47
+  if [ -f "$HOME/.mavenrc" ] ; then
48
+    . "$HOME/.mavenrc"
49
+  fi
50
+
51
+fi
52
+
53
+# OS specific support.  $var _must_ be set to either true or false.
54
+cygwin=false;
55
+darwin=false;
56
+mingw=false
57
+case "`uname`" in
58
+  CYGWIN*) cygwin=true ;;
59
+  MINGW*) mingw=true;;
60
+  Darwin*) darwin=true
61
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63
+    if [ -z "$JAVA_HOME" ]; then
64
+      if [ -x "/usr/libexec/java_home" ]; then
65
+        export JAVA_HOME="`/usr/libexec/java_home`"
66
+      else
67
+        export JAVA_HOME="/Library/Java/Home"
68
+      fi
69
+    fi
70
+    ;;
71
+esac
72
+
73
+if [ -z "$JAVA_HOME" ] ; then
74
+  if [ -r /etc/gentoo-release ] ; then
75
+    JAVA_HOME=`java-config --jre-home`
76
+  fi
77
+fi
78
+
79
+if [ -z "$M2_HOME" ] ; then
80
+  ## resolve links - $0 may be a link to maven's home
81
+  PRG="$0"
82
+
83
+  # need this for relative symlinks
84
+  while [ -h "$PRG" ] ; do
85
+    ls=`ls -ld "$PRG"`
86
+    link=`expr "$ls" : '.*-> \(.*\)$'`
87
+    if expr "$link" : '/.*' > /dev/null; then
88
+      PRG="$link"
89
+    else
90
+      PRG="`dirname "$PRG"`/$link"
91
+    fi
92
+  done
93
+
94
+  saveddir=`pwd`
95
+
96
+  M2_HOME=`dirname "$PRG"`/..
97
+
98
+  # make it fully qualified
99
+  M2_HOME=`cd "$M2_HOME" && pwd`
100
+
101
+  cd "$saveddir"
102
+  # echo Using m2 at $M2_HOME
103
+fi
104
+
105
+# For Cygwin, ensure paths are in UNIX format before anything is touched
106
+if $cygwin ; then
107
+  [ -n "$M2_HOME" ] &&
108
+    M2_HOME=`cygpath --unix "$M2_HOME"`
109
+  [ -n "$JAVA_HOME" ] &&
110
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
111
+  [ -n "$CLASSPATH" ] &&
112
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
113
+fi
114
+
115
+# For Mingw, ensure paths are in UNIX format before anything is touched
116
+if $mingw ; then
117
+  [ -n "$M2_HOME" ] &&
118
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
119
+  [ -n "$JAVA_HOME" ] &&
120
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
121
+fi
122
+
123
+if [ -z "$JAVA_HOME" ]; then
124
+  javaExecutable="`which javac`"
125
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
126
+    # readlink(1) is not available as standard on Solaris 10.
127
+    readLink=`which readlink`
128
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
129
+      if $darwin ; then
130
+        javaHome="`dirname \"$javaExecutable\"`"
131
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
132
+      else
133
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
134
+      fi
135
+      javaHome="`dirname \"$javaExecutable\"`"
136
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
137
+      JAVA_HOME="$javaHome"
138
+      export JAVA_HOME
139
+    fi
140
+  fi
141
+fi
142
+
143
+if [ -z "$JAVACMD" ] ; then
144
+  if [ -n "$JAVA_HOME"  ] ; then
145
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
146
+      # IBM's JDK on AIX uses strange locations for the executables
147
+      JAVACMD="$JAVA_HOME/jre/sh/java"
148
+    else
149
+      JAVACMD="$JAVA_HOME/bin/java"
150
+    fi
151
+  else
152
+    JAVACMD="`\\unset -f command; \\command -v java`"
153
+  fi
154
+fi
155
+
156
+if [ ! -x "$JAVACMD" ] ; then
157
+  echo "Error: JAVA_HOME is not defined correctly." >&2
158
+  echo "  We cannot execute $JAVACMD" >&2
159
+  exit 1
160
+fi
161
+
162
+if [ -z "$JAVA_HOME" ] ; then
163
+  echo "Warning: JAVA_HOME environment variable is not set."
164
+fi
165
+
166
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
167
+
168
+# traverses directory structure from process work directory to filesystem root
169
+# first directory with .mvn subdirectory is considered project base directory
170
+find_maven_basedir() {
171
+
172
+  if [ -z "$1" ]
173
+  then
174
+    echo "Path not specified to find_maven_basedir"
175
+    return 1
176
+  fi
177
+
178
+  basedir="$1"
179
+  wdir="$1"
180
+  while [ "$wdir" != '/' ] ; do
181
+    if [ -d "$wdir"/.mvn ] ; then
182
+      basedir=$wdir
183
+      break
184
+    fi
185
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
186
+    if [ -d "${wdir}" ]; then
187
+      wdir=`cd "$wdir/.."; pwd`
188
+    fi
189
+    # end of workaround
190
+  done
191
+  echo "${basedir}"
192
+}
193
+
194
+# concatenates all lines of a file
195
+concat_lines() {
196
+  if [ -f "$1" ]; then
197
+    echo "$(tr -s '\n' ' ' < "$1")"
198
+  fi
199
+}
200
+
201
+BASE_DIR=`find_maven_basedir "$(pwd)"`
202
+if [ -z "$BASE_DIR" ]; then
203
+  exit 1;
204
+fi
205
+
206
+##########################################################################################
207
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
208
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
209
+##########################################################################################
210
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
211
+    if [ "$MVNW_VERBOSE" = true ]; then
212
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
213
+    fi
214
+else
215
+    if [ "$MVNW_VERBOSE" = true ]; then
216
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
217
+    fi
218
+    if [ -n "$MVNW_REPOURL" ]; then
219
+      jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
220
+    else
221
+      jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
222
+    fi
223
+    while IFS="=" read key value; do
224
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
225
+      esac
226
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
227
+    if [ "$MVNW_VERBOSE" = true ]; then
228
+      echo "Downloading from: $jarUrl"
229
+    fi
230
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
231
+    if $cygwin; then
232
+      wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
233
+    fi
234
+
235
+    if command -v wget > /dev/null; then
236
+        if [ "$MVNW_VERBOSE" = true ]; then
237
+          echo "Found wget ... using wget"
238
+        fi
239
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
240
+            wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241
+        else
242
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
243
+        fi
244
+    elif command -v curl > /dev/null; then
245
+        if [ "$MVNW_VERBOSE" = true ]; then
246
+          echo "Found curl ... using curl"
247
+        fi
248
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
249
+            curl -o "$wrapperJarPath" "$jarUrl" -f
250
+        else
251
+            curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
252
+        fi
253
+
254
+    else
255
+        if [ "$MVNW_VERBOSE" = true ]; then
256
+          echo "Falling back to using Java to download"
257
+        fi
258
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
259
+        # For Cygwin, switch paths to Windows format before running javac
260
+        if $cygwin; then
261
+          javaClass=`cygpath --path --windows "$javaClass"`
262
+        fi
263
+        if [ -e "$javaClass" ]; then
264
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
265
+                if [ "$MVNW_VERBOSE" = true ]; then
266
+                  echo " - Compiling MavenWrapperDownloader.java ..."
267
+                fi
268
+                # Compiling the Java class
269
+                ("$JAVA_HOME/bin/javac" "$javaClass")
270
+            fi
271
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
272
+                # Running the downloader
273
+                if [ "$MVNW_VERBOSE" = true ]; then
274
+                  echo " - Running MavenWrapperDownloader.java ..."
275
+                fi
276
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
277
+            fi
278
+        fi
279
+    fi
280
+fi
281
+##########################################################################################
282
+# End of extension
283
+##########################################################################################
284
+
285
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
286
+if [ "$MVNW_VERBOSE" = true ]; then
287
+  echo $MAVEN_PROJECTBASEDIR
288
+fi
289
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
290
+
291
+# For Cygwin, switch paths to Windows format before running java
292
+if $cygwin; then
293
+  [ -n "$M2_HOME" ] &&
294
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
295
+  [ -n "$JAVA_HOME" ] &&
296
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
297
+  [ -n "$CLASSPATH" ] &&
298
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
299
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
300
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
301
+fi
302
+
303
+# Provide a "standardized" way to retrieve the CLI args that will
304
+# work with both Windows and non-Windows executions.
305
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
306
+export MAVEN_CMD_LINE_ARGS
307
+
308
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309
+
310
+exec "$JAVACMD" \
311
+  $MAVEN_OPTS \
312
+  $MAVEN_DEBUG_OPTS \
313
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
314
+  "-Dmaven.home=${M2_HOME}" \
315
+  "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 188
- 0
mvnw.cmd View File

@@ -0,0 +1,188 @@
1
+@REM ----------------------------------------------------------------------------
2
+@REM Licensed to the Apache Software Foundation (ASF) under one
3
+@REM or more contributor license agreements.  See the NOTICE file
4
+@REM distributed with this work for additional information
5
+@REM regarding copyright ownership.  The ASF licenses this file
6
+@REM to you under the Apache License, Version 2.0 (the
7
+@REM "License"); you may not use this file except in compliance
8
+@REM with the License.  You may obtain a copy of the License at
9
+@REM
10
+@REM    https://www.apache.org/licenses/LICENSE-2.0
11
+@REM
12
+@REM Unless required by applicable law or agreed to in writing,
13
+@REM software distributed under the License is distributed on an
14
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+@REM KIND, either express or implied.  See the License for the
16
+@REM specific language governing permissions and limitations
17
+@REM under the License.
18
+@REM ----------------------------------------------------------------------------
19
+
20
+@REM ----------------------------------------------------------------------------
21
+@REM Maven Start Up Batch script
22
+@REM
23
+@REM Required ENV vars:
24
+@REM JAVA_HOME - location of a JDK home dir
25
+@REM
26
+@REM Optional ENV vars
27
+@REM M2_HOME - location of maven2's installed home dir
28
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31
+@REM     e.g. to debug Maven itself, use
32
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34
+@REM ----------------------------------------------------------------------------
35
+
36
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37
+@echo off
38
+@REM set title of command window
39
+title %0
40
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
42
+
43
+@REM set %HOME% to equivalent of $HOME
44
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45
+
46
+@REM Execute a user defined script before this one
47
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
49
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51
+:skipRcPre
52
+
53
+@setlocal
54
+
55
+set ERROR_CODE=0
56
+
57
+@REM To isolate internal variables from possible post scripts, we use another setlocal
58
+@setlocal
59
+
60
+@REM ==== START VALIDATION ====
61
+if not "%JAVA_HOME%" == "" goto OkJHome
62
+
63
+echo.
64
+echo Error: JAVA_HOME not found in your environment. >&2
65
+echo Please set the JAVA_HOME variable in your environment to match the >&2
66
+echo location of your Java installation. >&2
67
+echo.
68
+goto error
69
+
70
+:OkJHome
71
+if exist "%JAVA_HOME%\bin\java.exe" goto init
72
+
73
+echo.
74
+echo Error: JAVA_HOME is set to an invalid directory. >&2
75
+echo JAVA_HOME = "%JAVA_HOME%" >&2
76
+echo Please set the JAVA_HOME variable in your environment to match the >&2
77
+echo location of your Java installation. >&2
78
+echo.
79
+goto error
80
+
81
+@REM ==== END VALIDATION ====
82
+
83
+:init
84
+
85
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86
+@REM Fallback to current working directory if not found.
87
+
88
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90
+
91
+set EXEC_DIR=%CD%
92
+set WDIR=%EXEC_DIR%
93
+:findBaseDir
94
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
95
+cd ..
96
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
97
+set WDIR=%CD%
98
+goto findBaseDir
99
+
100
+:baseDirFound
101
+set MAVEN_PROJECTBASEDIR=%WDIR%
102
+cd "%EXEC_DIR%"
103
+goto endDetectBaseDir
104
+
105
+:baseDirNotFound
106
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107
+cd "%EXEC_DIR%"
108
+
109
+:endDetectBaseDir
110
+
111
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112
+
113
+@setlocal EnableExtensions EnableDelayedExpansion
114
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116
+
117
+:endReadAdditionalConfig
118
+
119
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122
+
123
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124
+
125
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127
+)
128
+
129
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131
+if exist %WRAPPER_JAR% (
132
+    if "%MVNW_VERBOSE%" == "true" (
133
+        echo Found %WRAPPER_JAR%
134
+    )
135
+) else (
136
+    if not "%MVNW_REPOURL%" == "" (
137
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138
+    )
139
+    if "%MVNW_VERBOSE%" == "true" (
140
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
141
+        echo Downloading from: %DOWNLOAD_URL%
142
+    )
143
+
144
+    powershell -Command "&{"^
145
+		"$webclient = new-object System.Net.WebClient;"^
146
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148
+		"}"^
149
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150
+		"}"
151
+    if "%MVNW_VERBOSE%" == "true" (
152
+        echo Finished downloading %WRAPPER_JAR%
153
+    )
154
+)
155
+@REM End of extension
156
+
157
+@REM Provide a "standardized" way to retrieve the CLI args that will
158
+@REM work with both Windows and non-Windows executions.
159
+set MAVEN_CMD_LINE_ARGS=%*
160
+
161
+%MAVEN_JAVA_EXE% ^
162
+  %JVM_CONFIG_MAVEN_PROPS% ^
163
+  %MAVEN_OPTS% ^
164
+  %MAVEN_DEBUG_OPTS% ^
165
+  -classpath %WRAPPER_JAR% ^
166
+  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167
+  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168
+if ERRORLEVEL 1 goto error
169
+goto end
170
+
171
+:error
172
+set ERROR_CODE=1
173
+
174
+:end
175
+@endlocal & set ERROR_CODE=%ERROR_CODE%
176
+
177
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
179
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181
+:skipRcPost
182
+
183
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
185
+
186
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187
+
188
+cmd /C exit /B %ERROR_CODE%

+ 38
- 0
pom.xml View File

@@ -0,0 +1,38 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+	<modelVersion>4.0.0</modelVersion>
5
+    <packaging>pom</packaging>
6
+    <modules>
7
+		<module>application</module>
8
+        <module>system</module>
9
+        <module>common</module>
10
+		<module>framework</module>
11
+	</modules>
12
+    <parent>
13
+		<groupId>org.springframework.boot</groupId>
14
+		<artifactId>spring-boot-starter-parent</artifactId>
15
+		<version>2.7.9</version>
16
+		<relativePath/> <!-- lookup parent from repository -->
17
+	</parent>
18
+
19
+	<groupId>com.lyg</groupId>
20
+	<artifactId>demo</artifactId>
21
+	<version>0.0.1</version>
22
+	<name>demo</name>
23
+	<description>Demo project for Spring Boot</description>
24
+
25
+	<properties>
26
+		<java.version>1.8</java.version>
27
+		<sa-token.version>1.34.0</sa-token.version>
28
+		<orai18n.version>21.8.0.0</orai18n.version>
29
+		<forest.version>1.5.26</forest.version>
30
+		<mybatis-plus.version>3.5.1</mybatis-plus.version>
31
+		<swagger.version>3.0.0</swagger.version>
32
+		<hutool.version>5.8.11</hutool.version>
33
+		<easyexcel.version>3.1.3</easyexcel.version>
34
+		<dynamic.version>3.0.0</dynamic.version>
35
+
36
+	</properties>
37
+
38
+</project>

+ 38
- 0
system/pom.xml View File

@@ -0,0 +1,38 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <parent>
6
+        <artifactId>demo</artifactId>
7
+        <groupId>com.lyg</groupId>
8
+        <version>0.0.1</version>
9
+    </parent>
10
+    <modelVersion>4.0.0</modelVersion>
11
+
12
+    <artifactId>system</artifactId>
13
+
14
+    <dependencies>
15
+        <dependency>
16
+            <groupId>com.lyg</groupId>
17
+            <artifactId>common</artifactId>
18
+            <version>0.0.1</version>
19
+            <scope>compile</scope>
20
+        </dependency>
21
+        <dependency>
22
+            <groupId>com.lyg</groupId>
23
+            <artifactId>framework</artifactId>
24
+            <version>0.0.1</version>
25
+            <scope>compile</scope>
26
+        </dependency>
27
+        <dependency>
28
+            <groupId>org.projectlombok</groupId>
29
+            <artifactId>lombok</artifactId>
30
+        </dependency>
31
+    </dependencies>
32
+
33
+    <properties>
34
+        <maven.compiler.source>8</maven.compiler.source>
35
+        <maven.compiler.target>8</maven.compiler.target>
36
+    </properties>
37
+
38
+</project>

+ 122
- 0
system/src/main/java/com/lyg/system/controller/BaseController.java View File

@@ -0,0 +1,122 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.stp.StpUtil;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.lyg.common.Constants;
6
+import com.lyg.common.util.StringUtil;
7
+import com.lyg.system.entity.SysUser;
8
+import com.lyg.system.service.SysUserService;
9
+import com.lyg.system.service.request.Fetch;
10
+import org.apache.poi.ss.formula.functions.T;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Component;
13
+
14
+import javax.annotation.Resource;
15
+import javax.servlet.http.HttpServletRequest;
16
+import java.time.LocalDateTime;
17
+import java.util.List;
18
+
19
+@Component
20
+public class BaseController {
21
+
22
+    @Autowired
23
+    protected SysUserService sysUserService;
24
+    @Autowired
25
+    protected Fetch fetch;
26
+    @Resource
27
+    HttpServletRequest request;
28
+
29
+    /**
30
+     * 获取当前用户
31
+     *
32
+     * @return
33
+     * @throws Exception
34
+     */
35
+    public SysUser currentUser() throws Exception {
36
+        String loginId = StpUtil.getLoginIdAsString();
37
+        if (StringUtil.isEmpty(loginId)) {
38
+            throw new Exception("请先登录");
39
+        }
40
+        sysUserService.getById(loginId);
41
+
42
+        SysUser user = sysUserService.getById(loginId);
43
+
44
+        // 如果是管理员
45
+        if (Constants.ROOT_ID.equals(loginId)) {
46
+            if (null == user) {
47
+                user = new SysUser();
48
+                user.setUserId(Constants.ROOT_ID);
49
+                user.setName("超级管理员");
50
+                user.setStatus(Constants.STATUS_NORMAL);
51
+                user.setCreateUser("system");
52
+                user.setCreateDate(LocalDateTime.now());
53
+                user.setUpdateUser("system");
54
+                user.setUpdateDate(LocalDateTime.now());
55
+                sysUserService.save(user);
56
+            }
57
+        }
58
+
59
+        if (user == null || user.getStatus() == Constants.STATUS_DELETE) {
60
+            return null;
61
+        }
62
+
63
+        return user;
64
+    }
65
+
66
+    /**
67
+     * 获取行信端当前用户
68
+     *
69
+     * @return
70
+     * @throws Exception
71
+     */
72
+    public SysUser currentHxUser() throws Exception {
73
+        SysUser sysUser = (SysUser) request.getAttribute("user");
74
+        if (null == sysUser) {
75
+            throw new Exception("未发现 EHR 账号");
76
+        }
77
+        return sysUser;
78
+    }
79
+
80
+
81
+//    /**
82
+//     * 获取 行信端 当前用户
83
+//     * @return
84
+//     * @throws Exception
85
+//     */
86
+//    public SysUser currentHxUser() throws Exception {
87
+//        String ehr = request.getParameter("ehr");
88
+//        if (StringUtil.isEmpty(ehr)) {
89
+//            ehr = request.getParameter("hxId");
90
+//        }
91
+//
92
+//        if (StringUtil.isEmpty(ehr)) {
93
+//            throw new Exception("未发现 EHR 账号");
94
+//        }
95
+//
96
+//        SysUser user = sysUserService.getByHxId(ehr);
97
+//        if (user != null) {
98
+//            return user;
99
+//        }
100
+//
101
+//        Map<String, Object> map = new HashMap<>();
102
+//        map.put("hxId", ehr);
103
+//
104
+//        String dtStr = fetch.get("/api/sso/loginH5", map).exec();
105
+//        JSONObject data = JSONUtil.parseObj(dtStr);
106
+//        JSONObject userJSON = data.getJSONObject("user");
107
+//
108
+//        user = new SysUser();
109
+//        user.setUserId(userJSON.getStr("userId"));
110
+//        user.setName(userJSON.getStr("name"));
111
+//        user.setAvatar(userJSON.getStr("avatar"));
112
+//        user.setPhone(userJSON.getStr("phone"));
113
+//        user.setStatus(userJSON.getInt("status"));
114
+//        user.setHxId(ehr);
115
+//
116
+//        return user;
117
+//    }
118
+
119
+
120
+
121
+
122
+}

+ 69
- 0
system/src/main/java/com/lyg/system/controller/SysLogController.java View File

@@ -0,0 +1,69 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.common.util.DateUtil;
8
+import com.lyg.common.util.StringUtil;
9
+import com.lyg.system.entity.SysLog;
10
+import com.lyg.system.service.SysLogService;
11
+import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.web.bind.annotation.GetMapping;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestParam;
18
+import org.springframework.web.bind.annotation.RestController;
19
+
20
+import java.time.LocalDateTime;
21
+
22
+/**
23
+ * 日志表;(sys_log)表控制层
24
+ *
25
+ * @author : http://njyunzhi.com
26
+ * @date : 2023-2-5
27
+ */
28
+@Api(tags = "日志表对象功能接口")
29
+@RestController
30
+@RequestMapping("/")
31
+public class SysLogController extends BaseController {
32
+
33
+    @Autowired
34
+    private SysLogService sysLogService;
35
+
36
+    /**
37
+     * 分页查询
38
+     *
39
+     * @param pageNum  当前页码
40
+     * @param pageSize 每页条数
41
+     * @return 查询结果
42
+     */
43
+    @ApiOperation("分页查询")
44
+    @GetMapping("/sysLog")
45
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
46
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
47
+                         @ApiParam("开始日期") @RequestParam(value = "startDate", required = false) String startDate,
48
+                         @ApiParam("结束日期") @RequestParam(value = "endDate", required = false) String endDate,
49
+                         @ApiParam("模块") @RequestParam(value = "moduleName", required = false) String moduleName,
50
+                         @ApiParam("操作人") @RequestParam(value = "userName", required = false) String userName) throws Exception {
51
+
52
+        LocalDateTime start = null;
53
+        LocalDateTime end = null;
54
+        if (StringUtil.isNotEmpty(startDate)) {
55
+            start = DateUtil.day2LocalDateime(startDate);
56
+            end = DateUtil.day2LocalDateime(endDate).withHour(23).withMinute(59).withSecond(59);
57
+        }
58
+
59
+        IPage<SysLog> pg = new Page<>(pageNum, pageSize);
60
+        QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>();
61
+        queryWrapper.like(StringUtil.isNotEmpty(moduleName), "module_name", moduleName);
62
+        queryWrapper.like(StringUtil.isNotEmpty(userName), "user_name", userName);
63
+        queryWrapper.between(null != start, "create_date", start, end);
64
+        queryWrapper.orderByDesc("create_date");
65
+        IPage<SysLog> result = sysLogService.page(pg, queryWrapper);
66
+
67
+        return SaResult.data(result);
68
+    }
69
+}

+ 56
- 0
system/src/main/java/com/lyg/system/controller/SysMenuController.java View File

@@ -0,0 +1,56 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.common.Constants;
8
+import com.lyg.system.entity.SysMenu;
9
+import com.lyg.framework.log.OpLog;
10
+import com.lyg.system.service.SysMenuService;
11
+import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.web.bind.annotation.GetMapping;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestParam;
18
+import org.springframework.web.bind.annotation.RestController;
19
+
20
+/**
21
+ * 菜单表;(sys_menu)表控制层
22
+ *
23
+ * @author : http://njyunzhi.com
24
+ * @date : 2023-2-5
25
+ */
26
+@Api(tags = "菜单表对象功能接口")
27
+@RestController
28
+@RequestMapping("/")
29
+public class SysMenuController extends BaseController {
30
+
31
+    @Autowired
32
+    private SysMenuService sysMenuService;
33
+
34
+    /**
35
+     * 分页查询
36
+     *
37
+     * @param pageNum  当前页码
38
+     * @param pageSize 每页条数
39
+     * @return 查询结果
40
+     */
41
+    @OpLog(module = "菜单管理", action = "查询列表")
42
+    @ApiOperation("分页查询")
43
+    @GetMapping("/sysMenu")
44
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
45
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
46
+
47
+        IPage<SysMenu> pg = new Page<>(pageNum, pageSize);
48
+        QueryWrapper<SysMenu> queryWrapper = new QueryWrapper<>();
49
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
50
+        queryWrapper.orderByAsc("sort_no");
51
+
52
+        IPage<SysMenu> result = sysMenuService.page(pg, queryWrapper);
53
+
54
+        return SaResult.data(result);
55
+    }
56
+}

+ 160
- 0
system/src/main/java/com/lyg/system/controller/SysOrgController.java View File

@@ -0,0 +1,160 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.common.Constants;
8
+import com.lyg.common.util.StringUtil;
9
+import com.lyg.system.entity.SysOrg;
10
+import com.lyg.system.entity.SysUser;
11
+import com.lyg.framework.log.OpLog;
12
+import com.lyg.system.service.SysOrgService;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiOperation;
15
+import io.swagger.annotations.ApiParam;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.web.bind.annotation.*;
18
+
19
+/**
20
+ * 机构表;(sys_org)表控制层
21
+ *
22
+ * @author : http://njyunzhi.com
23
+ * @date : 2023-1-27
24
+ */
25
+@Api(tags = "机构表对象功能接口")
26
+@RestController
27
+@RequestMapping("/")
28
+public class SysOrgController extends BaseController {
29
+
30
+    @Autowired
31
+    private SysOrgService sysOrgService;
32
+
33
+    /**
34
+     * 通过ID查询单条数据
35
+     *
36
+     * @param id 主键
37
+     * @return 实例对象
38
+     */
39
+    @OpLog(module = "机构管理", action = "查询详情")
40
+    @ApiOperation("通过ID查询单条数据")
41
+    @GetMapping("/sysOrg/{id}")
42
+    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
43
+        return SaResult.data(sysOrgService.getById(id));
44
+    }
45
+
46
+    /**
47
+     * 分页查询
48
+     *
49
+     * @param pageNum  当前页码
50
+     * @param pageSize 每页条数
51
+     * @return 查询结果
52
+     */
53
+    @OpLog(module = "机构管理", action = "查询列表")
54
+    @ApiOperation("分页查询")
55
+    @GetMapping("/sysOrg")
56
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
57
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
58
+                         @ApiParam("机构名称") @RequestParam(value = "name", required = false) String name) throws Exception {
59
+
60
+        IPage<SysOrg> pg = new Page<>(pageNum, pageSize);
61
+        QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.like(!StringUtil.isEmpty(name),"name", name);
63
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
64
+        queryWrapper.orderByDesc("sort_no");
65
+        IPage<SysOrg> result = sysOrgService.page(pg, queryWrapper);
66
+
67
+        return SaResult.data(result);
68
+    }
69
+
70
+    /**
71
+     * 新增数据
72
+     *
73
+     * @param sysOrg 实例对象
74
+     * @return 实例对象
75
+     */
76
+    @OpLog(module = "机构管理", action = "新增数据")
77
+    @ApiOperation("新增数据")
78
+    @PostMapping("/sysOrg")
79
+    public SaResult add(@ApiParam("对象实体") @RequestBody SysOrg sysOrg) throws Exception {
80
+        if (StringUtil.isEmpty(sysOrg.getParentId())) {
81
+            return SaResult.error("未找到父级机构");
82
+        }
83
+
84
+        if (StringUtil.isEmpty(sysOrg.getName())) {
85
+            return SaResult.error("机构名称未填写");
86
+        }
87
+
88
+        long count = sysOrgService.countBy("name", sysOrg.getName(), true);
89
+        if (count > 0) {
90
+            return SaResult.error("机构名称重复");
91
+        }
92
+
93
+        SysUser user = currentUser();
94
+
95
+        sysOrgService.createNew(sysOrg, user);
96
+        return SaResult.data(sysOrg);
97
+    }
98
+
99
+    /**
100
+     * 更新数据
101
+     *
102
+     * @param sysOrg 实例对象
103
+     * @return 实例对象
104
+     */
105
+    @OpLog(module = "机构管理", action = "更新数据")
106
+    @ApiOperation("更新数据")
107
+    @PutMapping("/sysOrg/{id}")
108
+    public SaResult edit(@ApiParam("对象实体") @RequestBody SysOrg sysOrg,
109
+                         @ApiParam("对象ID") @PathVariable String id) throws Exception {
110
+//        if (!StpUtil.hasPermission("org."+id)) {
111
+//            return SaResult.error("暂无权限");
112
+//        }
113
+
114
+        if (StringUtil.isEmpty(sysOrg.getParentId())) {
115
+            return SaResult.error("未找到父级机构");
116
+        }
117
+
118
+        if (StringUtil.isEmpty(sysOrg.getName())) {
119
+            return SaResult.error("机构名称未填写");
120
+        }
121
+
122
+        SysOrg exists = sysOrgService.getByButNot("name", sysOrg.getName(), "org_id", id, true);
123
+        if (null != exists) {
124
+            return SaResult.error("名称已存在");
125
+        }
126
+
127
+        sysOrg.setOrgId(id);
128
+        sysOrgService.updateData(sysOrg);
129
+        return SaResult.data(sysOrg);
130
+    }
131
+
132
+    /**
133
+     * 通过主键删除数据
134
+     *
135
+     * @param id 主键
136
+     * @return 是否成功
137
+     */
138
+    @OpLog(module = "机构管理", action = "删除数据")
139
+    @ApiOperation("通过主键删除数据")
140
+    @DeleteMapping("/sysOrg/{id}")
141
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
142
+        SysOrg sysOrg = sysOrgService.getById(id);
143
+        if (sysOrg == null || Constants.STATUS_DELETE == sysOrg.getStatus()) {
144
+            return SaResult.ok("数据已删除");
145
+        }
146
+
147
+        long count = sysUserService.countBy("org_id", id, true);
148
+        if (count > 0) {
149
+            return SaResult.error("请先删除当前机构下所有用户");
150
+        }
151
+
152
+        count = sysOrgService.countBy("parent_id", id, true);
153
+        if (count > 0) {
154
+            return SaResult.error("请先删除当前机构下所有子机构");
155
+        }
156
+
157
+        sysOrgService.removeLogicById(id);
158
+        return SaResult.ok("success");
159
+    }
160
+}

+ 122
- 0
system/src/main/java/com/lyg/system/controller/SysPositionController.java View File

@@ -0,0 +1,122 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.common.Constants;
8
+import com.lyg.common.util.StringUtil;
9
+import com.lyg.system.entity.SysPosition;
10
+import com.lyg.framework.log.OpLog;
11
+import com.lyg.system.service.SysPositionService;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiOperation;
14
+import io.swagger.annotations.ApiParam;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.web.bind.annotation.*;
17
+
18
+/**
19
+ * 岗位表;(sys_position)表控制层
20
+ * @author : http://njyunzhi.com
21
+ * @date : 2023-1-27
22
+ */
23
+@Api(tags = "岗位表对象功能接口")
24
+@RestController
25
+@RequestMapping("/")
26
+public class SysPositionController extends BaseController {
27
+    
28
+    @Autowired
29
+    public SysPositionService sysPositionService;
30
+
31
+    
32
+    /** 
33
+     * 通过ID查询单条数据 
34
+     *
35
+     * @param id 主键
36
+     * @return 实例对象
37
+     */
38
+    @OpLog(module = "岗位管理", action = "查询详情")
39
+    @ApiOperation("通过ID查询单条数据")
40
+    @GetMapping("/sysPosition/{id}")
41
+    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
42
+        return SaResult.data(sysPositionService.getById(id));
43
+    }
44
+    
45
+    /** 
46
+     * 分页查询
47
+     *
48
+     * @param pageNum 当前页码
49
+     * @param pageSize 每页条数
50
+     * @return 查询结果
51
+     */
52
+    @OpLog(module = "岗位管理", action = "查询列表")
53
+    @ApiOperation("分页查询")
54
+    @GetMapping("/sysPosition")
55
+    public SaResult list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56
+                         @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
57
+                         @ApiParam("机构") @RequestParam(value ="orgId", required = false) String orgId,
58
+                         @ApiParam("名称") @RequestParam(value ="name", required = false) String name) throws Exception {
59
+
60
+        IPage<SysPosition> pg = new Page<>(pageNum, pageSize);
61
+        QueryWrapper<SysPosition> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.eq(!StringUtil.isEmpty(orgId), "org_id", orgId);
63
+        queryWrapper.like(!StringUtil.isEmpty(name), "name", name);
64
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
65
+        queryWrapper.orderByDesc("create_date");
66
+        IPage<SysPosition> result = sysPositionService.page(pg, queryWrapper);
67
+        
68
+        return SaResult.data(result);
69
+    }
70
+    
71
+    /** 
72
+     * 新增数据
73
+     *
74
+     * @param sysPosition 实例对象
75
+     * @return 实例对象
76
+     */
77
+    @OpLog(module = "岗位管理", action = "新增数据")
78
+    @ApiOperation("新增数据")
79
+    @PostMapping("/sysPosition")
80
+    public SaResult add(@ApiParam("对象实体") @RequestBody SysPosition sysPosition) throws Exception {
81
+        if (StringUtil.isEmpty(sysPosition.getOrgId())) {
82
+            return SaResult.error("未设置所属部门");
83
+        }
84
+
85
+        sysPositionService.save(sysPosition);
86
+        return SaResult.data(sysPositionService.getById(sysPosition.getPositionId()));
87
+    }
88
+    
89
+    /** 
90
+     * 更新数据
91
+     *
92
+     * @param sysPosition 实例对象
93
+     * @return 实例对象
94
+     */
95
+    @OpLog(module = "岗位管理", action = "更新数据")
96
+    @ApiOperation("更新数据")
97
+    @PutMapping("/sysPosition/{id}")
98
+    public SaResult edit(@ApiParam("对象实体") @RequestBody SysPosition sysPosition,
99
+                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
100
+        if (StringUtil.isEmpty(sysPosition.getOrgId())) {
101
+            return SaResult.error("未设置所属部门");
102
+        }
103
+
104
+        sysPosition.setPositionId(id);
105
+        sysPositionService.updateById(sysPosition);
106
+        return SaResult.data(sysPosition);
107
+    }
108
+    
109
+    /** 
110
+     * 通过主键删除数据
111
+     *
112
+     * @param id 主键
113
+     * @return 是否成功
114
+     */
115
+    @OpLog(module = "岗位管理", action = "删除数据")
116
+    @ApiOperation("通过主键删除数据")
117
+    @DeleteMapping("/sysPosition/{id}")
118
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id){
119
+        sysPositionService.removeLogicById(id);
120
+        return SaResult.ok("success");
121
+    }
122
+}

+ 162
- 0
system/src/main/java/com/lyg/system/controller/SysRoleController.java View File

@@ -0,0 +1,162 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.common.Constants;
8
+import com.lyg.common.util.StringUtil;
9
+import com.lyg.system.entity.SysRole;
10
+import com.lyg.system.entity.SysRoleResource;
11
+import com.lyg.framework.log.OpLog;
12
+import com.lyg.system.service.SysRoleResourceService;
13
+import com.lyg.system.service.SysRoleService;
14
+import com.lyg.system.service.SysUserRoleService;
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import io.swagger.annotations.ApiParam;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.web.bind.annotation.*;
20
+
21
+import java.time.LocalDateTime;
22
+import java.util.List;
23
+
24
+/**
25
+ * 系统角色;(sys_role)表控制层
26
+ *
27
+ * @author : http://njyunzhi.com
28
+ * @date : 2023-2-5
29
+ */
30
+@Api(tags = "系统角色对象功能接口")
31
+@RestController
32
+@RequestMapping("/")
33
+public class SysRoleController extends BaseController {
34
+
35
+    @Autowired
36
+    private SysRoleService sysRoleService;
37
+
38
+    @Autowired
39
+    private SysUserRoleService sysUserRoleService;
40
+
41
+    @Autowired
42
+    private SysRoleResourceService sysRoleResourceService;
43
+
44
+    /**
45
+     * 通过ID查询单条数据
46
+     *
47
+     * @param id 主键
48
+     * @return 实例对象
49
+     */
50
+    @OpLog(module = "角色管理", action = "查询详情")
51
+    @ApiOperation("通过ID查询单条数据")
52
+    @GetMapping("/sysRole/{id}")
53
+    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
54
+        return SaResult.data(sysRoleService.getById(id));
55
+    }
56
+
57
+    /**
58
+     * 分页查询
59
+     *
60
+     * @param pageNum  当前页码
61
+     * @param pageSize 每页条数
62
+     * @return 查询结果
63
+     */
64
+    @OpLog(module = "角色管理", action = "查询列表")
65
+    @ApiOperation("分页查询")
66
+    @GetMapping("/sysRole")
67
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
68
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
69
+
70
+        IPage<SysRole> pg = new Page<>(pageNum, pageSize);
71
+
72
+        QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
73
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
74
+        queryWrapper.orderByAsc("name");
75
+        IPage<SysRole> result = sysRoleService.page(pg, queryWrapper);
76
+
77
+        return SaResult.data(result);
78
+    }
79
+
80
+    /**
81
+     * 新增数据
82
+     *
83
+     * @param sysRole 实例对象
84
+     * @return 实例对象
85
+     */
86
+    @OpLog(module = "角色管理", action = "新增数据")
87
+    @ApiOperation("新增数据")
88
+    @PostMapping("/sysRole")
89
+    public SaResult add(@ApiParam("对象实体") @RequestBody SysRole sysRole) throws Exception {
90
+        sysRole.setRoleId(null);
91
+
92
+        if (StringUtil.isEmpty(sysRole.getName())) {
93
+            return SaResult.error("角色名称不能为空");
94
+        }
95
+
96
+        sysRole.setCreateUser(currentUser().getUserId());
97
+        sysRole.setStatus(Constants.STATUS_NORMAL);
98
+        sysRole.setCreateDate(LocalDateTime.now());
99
+        sysRoleService.save(sysRole);
100
+        return SaResult.data(sysRoleService.getById(sysRole.getRoleId()));
101
+    }
102
+
103
+    /**
104
+     * 更新数据
105
+     *
106
+     * @param sysRole 实例对象
107
+     * @return 实例对象
108
+     */
109
+    @OpLog(module = "角色管理", action = "更新数据")
110
+    @ApiOperation("更新数据")
111
+    @PutMapping("/sysRole/{id}")
112
+    public SaResult edit(@ApiParam("对象实体") @RequestBody SysRole sysRole,
113
+                         @ApiParam("对象ID") @PathVariable String id) throws Exception {
114
+
115
+        if (StringUtil.isEmpty(sysRole.getName())) {
116
+            return SaResult.error("角色名称不能为空");
117
+        }
118
+
119
+        sysRole.setRoleId(id);
120
+        sysRoleService.updateById(sysRole);
121
+        return SaResult.data(sysRole);
122
+    }
123
+
124
+    /**
125
+     * 授权资源
126
+     *
127
+     * @param roleId            角色ID
128
+     * @param roleResourcesList 授权列表
129
+     * @return 实例对象
130
+     */
131
+    @OpLog(module = "角色管理", action = "授权资源")
132
+    @ApiOperation("新增数据, 包含编辑")
133
+    @PostMapping("/role/{roleId}/resources")
134
+    public SaResult authResource(@ApiParam("角色ID") @PathVariable String roleId,
135
+                                 @ApiParam("授权列表") @RequestBody List<SysRoleResource> roleResourcesList) throws Exception {
136
+        if (null == roleResourcesList) {
137
+            return SaResult.error("未找到授权对象");
138
+        }
139
+
140
+        sysRoleResourceService.mergeData(roleId, roleResourcesList);
141
+        return SaResult.data(roleResourcesList);
142
+    }
143
+
144
+    /**
145
+     * 通过主键删除数据
146
+     *
147
+     * @param id 主键
148
+     * @return 是否成功
149
+     */
150
+    @OpLog(module = "角色管理", action = "删除数据")
151
+    @ApiOperation("通过主键删除数据")
152
+    @DeleteMapping("/sysRole/{id}")
153
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
154
+        long count = sysUserRoleService.countBy("role_id", id, false);
155
+        if (count > 0) {
156
+            return SaResult.error("请先取消所有用户授权");
157
+        }
158
+
159
+        sysRoleService.removeById(id);
160
+        return SaResult.ok("success");
161
+    }
162
+}

+ 95
- 0
system/src/main/java/com/lyg/system/controller/SysRoleResourceController.java View File

@@ -0,0 +1,95 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.lyg.system.entity.SysRoleResource;
8
+import com.lyg.framework.log.OpLog;
9
+import com.lyg.system.service.SysRoleResourceService;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.*;
15
+
16
+import java.util.List;
17
+
18
+ /**
19
+ * 角色资源;(sys_role_resource)表控制层
20
+ * @author : http://njyunzhi.com
21
+ * @date : 2023-2-5
22
+ */
23
+@Api(tags = "角色资源对象功能接口")
24
+@RestController
25
+@RequestMapping("/")
26
+public class SysRoleResourceController extends BaseController {
27
+
28
+    @Autowired
29
+    public SysRoleResourceService sysRoleResourceService;
30
+
31
+//    /**
32
+//     * 通过ID查询单条数据
33
+//     *
34
+//     * @param id 主键
35
+//     * @return 实例对象
36
+//     */
37
+//    @ApiOperation("通过ID查询单条数据")
38
+//    @GetMapping("/sysRoleResource/{id}")
39
+//    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
40
+//        return SaResult.data(sysRoleResourceService.getById(id));
41
+//    }
42
+//
43
+    /**
44
+     * 列表
45
+     *
46
+     * @param pageNum 当前页码
47
+     * @param pageSize 每页条数
48
+     * @return 查询结果
49
+     */
50
+    @OpLog(module = "角色资源", action = "查询列表")
51
+    @ApiOperation("列表")
52
+    @GetMapping("/sysRoleResource")
53
+    public SaResult listApp(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54
+                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
55
+                            @ApiParam("角色ID") @RequestParam(value ="roleId") String roleId,
56
+                            @ApiParam("资源类型") @RequestParam(value ="resourceType") String resourceType) throws Exception {
57
+
58
+        IPage<SysRoleResource> pg = new Page<>(pageNum, pageSize);
59
+        QueryWrapper<SysRoleResource> queryWrapper = new QueryWrapper<>();
60
+        queryWrapper.eq("role_id", roleId);
61
+        queryWrapper.eq("resource_type", resourceType);
62
+        IPage<SysRoleResource> result = sysRoleResourceService.page(pg, queryWrapper);
63
+
64
+        return SaResult.data(result);
65
+    }
66
+
67
+    /**
68
+     * 新增数据
69
+     *
70
+     * @param roleResourcesList 授权列表
71
+     * @return 实例对象
72
+     */
73
+    @OpLog(module = "角色资源", action = "新增数据")
74
+    @ApiOperation("新增数据")
75
+    @PostMapping("/sysRoleResource")
76
+    public SaResult add(@ApiParam("授权列表") @RequestBody List<SysRoleResource> roleResourcesList,
77
+                        @ApiParam("角色ID") @RequestParam("roleId") String roleId) throws Exception {
78
+        sysRoleResourceService.mergeData(roleId, roleResourcesList);
79
+        return SaResult.data(roleResourcesList);
80
+    }
81
+
82
+    /**
83
+     * 通过主键删除数据
84
+     *
85
+     * @param id 主键
86
+     * @return 是否成功
87
+     */
88
+    @OpLog(module = "角色资源", action = "删除数据")
89
+    @ApiOperation("通过主键删除数据")
90
+    @DeleteMapping("/sysRoleApp/{id}")
91
+    public SaResult deleteRoleAppById(@ApiParam("对象ID") @PathVariable String id){
92
+        sysRoleResourceService.removeById(id);
93
+        return SaResult.ok("success");
94
+    }
95
+}

+ 207
- 0
system/src/main/java/com/lyg/system/controller/SysUserController.java View File

@@ -0,0 +1,207 @@
1
+package com.lyg.system.controller;
2
+
3
+import cn.dev33.satoken.sso.SaSsoProcessor;
4
+import cn.dev33.satoken.stp.StpUtil;
5
+import cn.dev33.satoken.util.SaResult;
6
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7
+import com.baomidou.mybatisplus.core.metadata.IPage;
8
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
9
+import com.lyg.common.Constants;
10
+import com.lyg.common.util.StringUtil;
11
+import com.lyg.system.entity.SysUser;
12
+import com.lyg.framework.log.OpLog;
13
+import com.lyg.system.service.SysMenuService;
14
+import com.lyg.system.service.SysRoleService;
15
+import com.lyg.system.service.SysUserRoleService;
16
+import io.swagger.annotations.Api;
17
+import io.swagger.annotations.ApiOperation;
18
+import io.swagger.annotations.ApiParam;
19
+import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.web.bind.annotation.*;
21
+
22
+import java.util.HashMap;
23
+import java.util.Map;
24
+
25
+/**
26
+ * 用户表;(sys_user)表控制层
27
+ *
28
+ * @author : http://njyunzhi.com
29
+ * @date : 2023-1-27
30
+ */
31
+@Api(tags = "用户表对象功能接口")
32
+@RestController
33
+@RequestMapping("/")
34
+public class SysUserController extends BaseController {
35
+
36
+    @Autowired
37
+    SysRoleService sysRoleService;
38
+
39
+    @Autowired
40
+    SysUserRoleService sysUserRoleService;
41
+
42
+    @Autowired
43
+    SysMenuService sysMenuService;
44
+
45
+
46
+    /**
47
+     * 通过ID查询单条数据
48
+     *
49
+     * @param id 主键
50
+     * @return 实例对象
51
+     */
52
+    @OpLog(module = "人员管理", action = "查询详情")
53
+    @ApiOperation("通过ID查询单条数据")
54
+    @GetMapping("/sysUser/{id}")
55
+    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
56
+        SysUser sysUser = sysUserService.getById(id);
57
+        if (null == sysUser || sysUser.getStatus() == Constants.STATUS_DELETE) {
58
+            return SaResult.error("用户不存在");
59
+        }
60
+
61
+        sysUser.setRolesList(sysRoleService.getByUser(id));
62
+        sysUser.setMenuList(sysMenuService.getByUser(id));
63
+        return SaResult.data(sysUser);
64
+    }
65
+
66
+
67
+    /**
68
+     * 查询当前人员
69
+     *
70
+     * @param
71
+     * @return 实例对象
72
+     */
73
+    @ApiOperation("查询当前人员")
74
+    @GetMapping("/sysUser/current")
75
+    public SaResult current(@ApiParam("sso ticket") @RequestParam(value = "ticket", required = false) String ticket,
76
+                            @ApiParam("sso ticket") @RequestParam(value = "appid", required = false) String appid) throws Exception {
77
+        Map<String, Object> res = new HashMap<>();
78
+        Boolean isLogin= StpUtil.isLogin();
79
+        if (!isLogin) {
80
+
81
+            if (!StringUtil.isEmpty(ticket)) {
82
+                // 如果是 SSO 登录
83
+                Object loginId = SaSsoProcessor.instance.checkTicket(ticket, "/sysUser/current");
84
+                if(loginId != null) {
85
+                    StpUtil.login(loginId, appid);
86
+                    res.put("token", StpUtil.getTokenValue());
87
+                } else {
88
+                    return SaResult.error("无效 Ticket").setCode(401);
89
+                }
90
+            } else {
91
+                return SaResult.error("请先登录").setCode(401);
92
+            }
93
+        }
94
+
95
+        SysUser sysUser = currentUser();
96
+
97
+        sysUser.setRolesList(sysRoleService.getByUser(sysUser.getUserId()));
98
+        sysUser.setMenuList(sysMenuService.getByUser(sysUser.getUserId()));
99
+
100
+        res.put("user", sysUser);
101
+        return SaResult.data(res);
102
+    }
103
+
104
+
105
+//    /**
106
+//     * 获取行信端当前人员
107
+//     *
108
+//     * @param
109
+//     * @return 实例对象
110
+//     */
111
+//    @ApiOperation("获取行信端当前人员")
112
+//    @GetMapping("/h5/sysUser/current")
113
+//    public SaResult hxCurrent() throws Exception {
114
+//        SysUser sysUser = currentHxUser();
115
+//
116
+//        return SaResult.data(sysUser);
117
+//    }
118
+
119
+
120
+    /**
121
+     * 分页查询
122
+     *
123
+     * @param pageNum  当前页码
124
+     * @param pageSize 每页条数
125
+     * @return 查询结果
126
+     */
127
+    @OpLog(module = "人员管理", action = "查询列表")
128
+    @ApiOperation("分页查询")
129
+    @GetMapping("/sysUser")
130
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
131
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
132
+                         @ApiParam("姓名") @RequestParam(value = "name", required = false) String name,
133
+                         @ApiParam("机构") @RequestParam(value = "orgId", required = false) String orgId,
134
+                         @ApiParam("岗位ID") @RequestParam(value = "positionId", required = false) String positionId,
135
+                         @ApiParam("手机号") @RequestParam(value = "phone", required = false) String phone) throws Exception {
136
+
137
+        IPage<SysUser> pg = new Page<>(pageNum, pageSize);
138
+        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
139
+        queryWrapper.like(!StringUtil.isEmpty(name), "name", name);
140
+        queryWrapper.eq(!StringUtil.isEmpty(orgId), "org_id", orgId);
141
+        queryWrapper.eq(!StringUtil.isEmpty(positionId), "position_id", positionId);
142
+        queryWrapper.like(!StringUtil.isEmpty(phone), "phone", phone);
143
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
144
+        queryWrapper.ne("user_id", Constants.ROOT_ID);
145
+        queryWrapper.orderByDesc("create_date");
146
+        IPage<SysUser> result = sysUserService.page(pg, queryWrapper);
147
+
148
+        return SaResult.data(result);
149
+    }
150
+
151
+    /**
152
+     * 新增数据
153
+     *
154
+     * @param sysUser 实例对象
155
+     * @return 实例对象
156
+     */
157
+    @OpLog(module = "人员管理", action = "新增数据")
158
+    @ApiOperation("新增数据")
159
+    @PostMapping("/sysUser")
160
+    public SaResult add(@ApiParam("对象实体") @RequestBody SysUser sysUser) throws Exception {
161
+        if (StringUtil.isEmpty(sysUser.getOrgId())) {
162
+            return SaResult.error("请设置所属机构");
163
+        }
164
+
165
+        sysUserService.mergeData(sysUser);
166
+        return SaResult.data(sysUserService.getById(sysUser.getUserId()));
167
+    }
168
+
169
+     /**
170
+      * 更新状态
171
+      *
172
+      * @param id 实例ID
173
+      * @return 实例对象
174
+      */
175
+     @OpLog(module = "人员管理", action = "更新状态")
176
+     @ApiOperation("更新状态")
177
+     @PutMapping("/sysUser/{id}/status")
178
+     public SaResult edit(@ApiParam("对象ID") @PathVariable String id,
179
+                              @ApiParam("页码") @RequestParam(value = "status") Integer status) throws Exception {
180
+
181
+         SysUser sysUser = sysUserService.getById(id);
182
+         sysUser.setStatus(status);
183
+
184
+         sysUserService.updateById(sysUser);
185
+         return SaResult.data(sysUser);
186
+     }
187
+
188
+    /**
189
+     * 通过主键删除数据
190
+     *
191
+     * @param id 主键
192
+     * @return 是否成功
193
+     */
194
+    @OpLog(module = "人员管理", action = "删除数据")
195
+    @ApiOperation("通过主键删除数据")
196
+    @DeleteMapping("/sysUser/{id}")
197
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id){
198
+        sysUserService.removeLogicById(id);
199
+
200
+        // 授权角色
201
+        sysUserRoleService.removeByMap(new HashMap<String, Object>(){{
202
+            put("user_id", id);
203
+        }});
204
+
205
+        return SaResult.ok("success");
206
+    }
207
+}

+ 80
- 0
system/src/main/java/com/lyg/system/controller/SysUserRoleController.java View File

@@ -0,0 +1,80 @@
1
+package com.lyg.system.controller;
2
+
3
+import com.lyg.system.service.SysUserRoleService;
4
+import io.swagger.annotations.Api;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.*;
7
+
8
+/**
9
+ * 角色授权;(sys_user_role)表控制层
10
+ *
11
+ * @author : http://njyunzhi.com
12
+ * @date : 2023-2-5
13
+ */
14
+@Api(tags = "角色授权对象功能接口")
15
+@RestController
16
+@RequestMapping("/")
17
+public class SysUserRoleController extends BaseController {
18
+
19
+    @Autowired
20
+    private SysUserRoleService sysUserRoleService;
21
+
22
+//    /**
23
+//     * 通过ID查询单条数据
24
+//     *
25
+//     * @param id 主键
26
+//     * @return 实例对象
27
+//     */
28
+//    @ApiOperation("通过ID查询单条数据")
29
+//    @GetMapping("/sysUserRole/{id}")
30
+//    public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
31
+//        return SaResult.data(sysUserRoleService.getById(id));
32
+//    }
33
+//
34
+//    /**
35
+//     * 分页查询
36
+//     *
37
+//     * @param pageNum  当前页码
38
+//     * @param pageSize 每页条数
39
+//     * @return 查询结果
40
+//     */
41
+//    @ApiOperation("分页查询")
42
+//    @GetMapping("/sysUserRole")
43
+//    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
44
+//                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
45
+//                         @ApiParam("用户ID") @RequestParam(value = "roleId") String roleId) throws Exception {
46
+//
47
+//        IPage<SysUserRole> pg = new Page<>(pageNum, pageSize);
48
+//        QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
49
+//        queryWrapper.eq("role_id", roleId);
50
+//        IPage<SysUserRole> result = sysUserRoleService.page(pg, queryWrapper);
51
+//
52
+//        return SaResult.data(result);
53
+//    }
54
+//
55
+//    /**
56
+//     * 新增数据
57
+//     *
58
+//     * @param sysUserRole 实例对象
59
+//     * @return 实例对象
60
+//     */
61
+//    @ApiOperation("新增数据")
62
+//    @PostMapping("/sysUserRole")
63
+//    public SaResult add(@ApiParam("对象实体") @RequestBody SysUserRole sysUserRole) throws Exception {
64
+//        sysUserRoleService.save(sysUserRole);
65
+//        return SaResult.data(sysUserRoleService.getById(sysUserRole.getId()));
66
+//    }
67
+//
68
+//    /**
69
+//     * 通过主键删除数据
70
+//     *
71
+//     * @param id 主键
72
+//     * @return 是否成功
73
+//     */
74
+//    @ApiOperation("通过主键删除数据")
75
+//    @DeleteMapping("/sysUserRole/{id}")
76
+//    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
77
+//        sysUserRoleService.removeLogicById(id);
78
+//        return SaResult.ok("success");
79
+//    }
80
+}

+ 61
- 0
system/src/main/java/com/lyg/system/entity/SysLog.java View File

@@ -0,0 +1,61 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
15
+/**
16
+* 系统日志;
17
+* @author : http://www.chiner.pro
18
+* @date : 2023-3-21
19
+*/
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value = "系统日志",description = "")
24
+@TableName("sys_log")
25
+public class SysLog implements Serializable,Cloneable{
26
+   /** 日志ID */
27
+   @ApiModelProperty(name = "日志ID",notes = "")
28
+   @TableId(value = "log_id", type = IdType.ASSIGN_UUID)
29
+   private String logId ;
30
+   /** 登录ID */
31
+   @ApiModelProperty(name = "登录ID",notes = "")
32
+   private String loginId ;
33
+   /** 用户名 */
34
+   @ApiModelProperty(name = "用户名",notes = "")
35
+   private String userName ;
36
+   /** 客户端 */
37
+   @ApiModelProperty(name = "客户端",notes = "")
38
+   private String clientType ;
39
+   /** 模块名称 */
40
+   @ApiModelProperty(name = "模块名称",notes = "")
41
+   private String moduleName ;
42
+   /** 操作内容 */
43
+   @ApiModelProperty(name = "操作内容",notes = "")
44
+   private String action ;
45
+   /** 访问地址 */
46
+   @ApiModelProperty(name = "访问地址",notes = "")
47
+   private String uri ;
48
+   /** 具体操作 */
49
+   @ApiModelProperty(name = "具体操作",notes = "")
50
+   private String description ;
51
+   /** 用户IP */
52
+   @ApiModelProperty(name = "用户IP",notes = "")
53
+   private String ip ;
54
+   /** User Agent */
55
+   @ApiModelProperty(name = "User Agent",notes = "")
56
+   private String ua ;
57
+   /** 操作时间 */
58
+   @ApiModelProperty(name = "操作时间",notes = "")
59
+   private LocalDateTime createDate ;
60
+
61
+}

+ 69
- 0
system/src/main/java/com/lyg/system/entity/SysMenu.java View File

@@ -0,0 +1,69 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
15
+/**
16
+ * 菜单表;
17
+ *
18
+ * @author : http://www.chiner.pro
19
+ * @date : 2023-2-5
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value = "菜单表", description = "")
25
+@TableName("sys_menu")
26
+public class SysMenu implements Serializable, Cloneable {
27
+    /**
28
+     * 菜单ID
29
+     */
30
+    @ApiModelProperty(name = "菜单ID", notes = "")
31
+    @TableId(value = "menu_id", type = IdType.ASSIGN_UUID)
32
+    private String menuId;
33
+    /**
34
+     * 菜单名称
35
+     */
36
+    @ApiModelProperty(name = "菜单名称", notes = "")
37
+    private String name;
38
+    /**
39
+     * 菜单编码
40
+     */
41
+    @ApiModelProperty(name = "菜单编码", notes = "")
42
+    private String menuCode;
43
+    /**
44
+     * 上级ID
45
+     */
46
+    @ApiModelProperty(name = "上级ID", notes = "")
47
+    private String parentId;
48
+    /**
49
+     * 排序
50
+     */
51
+    @ApiModelProperty(name = "排序", notes = "")
52
+    private Integer sortNo;
53
+    /**
54
+     * 状态
55
+     */
56
+    @ApiModelProperty(name = "状态", notes = "")
57
+    private Integer status;
58
+    /**
59
+     * 创建人
60
+     */
61
+    @ApiModelProperty(name = "创建人", notes = "")
62
+    private String createUser;
63
+    /**
64
+     * 创建时间
65
+     */
66
+    @ApiModelProperty(name = "创建时间", notes = "")
67
+    private LocalDateTime createDate;
68
+
69
+}

+ 82
- 0
system/src/main/java/com/lyg/system/entity/SysOrg.java View File

@@ -0,0 +1,82 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.*;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+import org.apache.ibatis.type.JdbcType;
10
+
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
14
+/**
15
+ * 机构表;
16
+ *
17
+ * @author : http://www.chiner.pro
18
+ * @date : 2023-1-27
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value = "机构表", description = "")
24
+@TableName("sys_org")
25
+public class SysOrg implements Serializable, Cloneable {
26
+    /**
27
+     * 机构ID
28
+     */
29
+    @ApiModelProperty(name = "机构ID", notes = "")
30
+    @TableId(value = "org_id", type = IdType.ASSIGN_UUID)
31
+    private String orgId;
32
+    /**
33
+     * 机构编码
34
+     */
35
+    @ApiModelProperty(name = "机构编码", notes = "")
36
+    private String orgCode;
37
+
38
+    /**
39
+     * 机构名称
40
+     */
41
+    @ApiModelProperty(name = "部门名称", notes = "")
42
+    private String name;
43
+    /**
44
+     * 上级部门;-1为根级目录
45
+     */
46
+    @ApiModelProperty(name = "上级机构", notes = "-1为根级目录")
47
+    private String parentId;
48
+
49
+    @ApiModelProperty(name = "7天全班",notes = "")
50
+    private Integer isSeven ;
51
+    /**
52
+     * 排序
53
+     */
54
+    @ApiModelProperty(name = "排序", notes = "")
55
+    private Integer sortNo;
56
+    /**
57
+     * 状态
58
+     */
59
+    @ApiModelProperty(name = "状态", notes = "")
60
+    private Integer status;
61
+
62
+    @ApiModelProperty(name = "创建人",notes = "")
63
+    @TableField(fill = FieldFill.INSERT)
64
+    private String createUser ;
65
+
66
+    @ApiModelProperty(name = "创建时间",notes = "")
67
+    @TableField(fill = FieldFill.INSERT)
68
+    private LocalDateTime createDate ;
69
+
70
+    @ApiModelProperty(name = "更新人",notes = "")
71
+    @TableField(fill = FieldFill.INSERT_UPDATE)
72
+    private String updateUser ;
73
+
74
+    @ApiModelProperty(name = "更新时间",notes = "")
75
+    @TableField(fill = FieldFill.INSERT_UPDATE)
76
+    private LocalDateTime updateDate ;
77
+
78
+    @ApiModelProperty(name = "删除标志",notes = "1删除")
79
+    @TableField(fill = FieldFill.INSERT)
80
+    private Integer deleted ;
81
+
82
+}

+ 73
- 0
system/src/main/java/com/lyg/system/entity/SysPosition.java View File

@@ -0,0 +1,73 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.*;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+import java.io.Serializable;
11
+import java.time.LocalDateTime;
12
+
13
+/**
14
+ * 岗位表;
15
+ *
16
+ * @author : http://www.chiner.pro
17
+ * @date : 2023-1-27
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@ApiModel(value = "岗位表", description = "")
23
+@TableName("sys_position")
24
+public class SysPosition implements Serializable, Cloneable {
25
+    /**
26
+     * 岗位ID
27
+     */
28
+    @ApiModelProperty(name = "岗位ID", notes = "")
29
+    @TableId(value = "position_id", type = IdType.ASSIGN_UUID)
30
+    private String positionId;
31
+    /**
32
+     * 岗位名称
33
+     */
34
+    @ApiModelProperty(name = "岗位名称", notes = "")
35
+    private String name;
36
+    /**
37
+     * 所属单位
38
+     */
39
+    @ApiModelProperty(name = "所属单位", notes = "")
40
+    private String orgId;
41
+    /**
42
+     * 排序
43
+     */
44
+    @ApiModelProperty(name = "排序", notes = "")
45
+    private Integer sortNum;
46
+    /**
47
+     * 状态
48
+     */
49
+    @ApiModelProperty(name = "状态", notes = "")
50
+    private Integer status;
51
+
52
+
53
+    @ApiModelProperty(name = "创建人",notes = "")
54
+    @TableField(fill = FieldFill.INSERT)
55
+    private String createUser ;
56
+
57
+    @ApiModelProperty(name = "创建时间",notes = "")
58
+    @TableField(fill = FieldFill.INSERT)
59
+    private LocalDateTime createDate ;
60
+
61
+    @ApiModelProperty(name = "更新人",notes = "")
62
+    @TableField(fill = FieldFill.INSERT_UPDATE)
63
+    private String updateUser ;
64
+
65
+    @ApiModelProperty(name = "更新时间",notes = "")
66
+    @TableField(fill = FieldFill.INSERT_UPDATE)
67
+    private LocalDateTime updateDate ;
68
+
69
+    @ApiModelProperty(name = "删除标志",notes = "1删除")
70
+    @TableField(fill = FieldFill.INSERT)
71
+    private Integer deleted ;
72
+
73
+}

+ 62
- 0
system/src/main/java/com/lyg/system/entity/SysRole.java View File

@@ -0,0 +1,62 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.*;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+import java.io.Serializable;
11
+import java.time.LocalDateTime;
12
+
13
+/**
14
+ * 系统角色;
15
+ *
16
+ * @author : http://www.chiner.pro
17
+ * @date : 2023-2-5
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@ApiModel(value = "系统角色", description = "")
23
+@TableName("sys_role")
24
+public class SysRole implements Serializable, Cloneable {
25
+    /**
26
+     * 角色ID
27
+     */
28
+    @ApiModelProperty(name = "角色ID", notes = "")
29
+    @TableId(value = "role_id", type = IdType.ASSIGN_UUID)
30
+    private String roleId;
31
+    /**
32
+     * 角色名称
33
+     */
34
+    @ApiModelProperty(name = "角色名称", notes = "")
35
+    private String name;
36
+    /**
37
+     * 状态
38
+     */
39
+    @ApiModelProperty(name = "状态", notes = "")
40
+    private Integer status;
41
+
42
+    @ApiModelProperty(name = "创建人",notes = "")
43
+    @TableField(fill = FieldFill.INSERT)
44
+    private String createUser ;
45
+
46
+    @ApiModelProperty(name = "创建时间",notes = "")
47
+    @TableField(fill = FieldFill.INSERT)
48
+    private LocalDateTime createDate ;
49
+
50
+    @ApiModelProperty(name = "更新人",notes = "")
51
+    @TableField(fill = FieldFill.INSERT_UPDATE)
52
+    private String updateUser ;
53
+
54
+    @ApiModelProperty(name = "更新时间",notes = "")
55
+    @TableField(fill = FieldFill.INSERT_UPDATE)
56
+    private LocalDateTime updateDate ;
57
+
58
+    @ApiModelProperty(name = "删除标志",notes = "1删除")
59
+    @TableField(fill = FieldFill.INSERT)
60
+    private Integer deleted ;
61
+
62
+}

+ 48
- 0
system/src/main/java/com/lyg/system/entity/SysRoleResource.java View File

@@ -0,0 +1,48 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+
14
+/**
15
+ * 角色资源;
16
+ *
17
+ * @author : http://www.chiner.pro
18
+ * @date : 2023-2-5
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value = "角色资源", description = "")
24
+@TableName("sys_role_resource")
25
+public class SysRoleResource implements Serializable, Cloneable {
26
+    /**
27
+     * id
28
+     */
29
+    @ApiModelProperty(name = "id", notes = "")
30
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
31
+    private String id;
32
+    /**
33
+     * 角色ID
34
+     */
35
+    @ApiModelProperty(name = "角色ID", notes = "")
36
+    private String roleId;
37
+    /**
38
+     * 资源ID
39
+     */
40
+    @ApiModelProperty(name = "资源ID", notes = "")
41
+    private String resourceId;
42
+    /**
43
+     * 资源类型
44
+     */
45
+    @ApiModelProperty(name = "资源类型", notes = "")
46
+    private String resourceType;
47
+
48
+}

+ 96
- 0
system/src/main/java/com/lyg/system/entity/SysUser.java View File

@@ -0,0 +1,96 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.*;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+import java.io.Serializable;
11
+import java.time.LocalDateTime;
12
+import java.util.List;
13
+
14
+/**
15
+ * 用户表;
16
+ *
17
+ * @author : http://www.chiner.pro
18
+ * @date : 2023-1-27
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value = "用户表", description = "")
24
+@TableName("sys_user")
25
+public class SysUser implements Serializable, Cloneable {
26
+    /**
27
+     * 用户ID
28
+     */
29
+    @ApiModelProperty(name = "用户ID", notes = "")
30
+    @TableId(value = "user_id", type = IdType.ASSIGN_UUID)
31
+    private String userId;
32
+    /**
33
+     * 用户名称
34
+     */
35
+    @ApiModelProperty(name = "用户名称", notes = "")
36
+    private String name;
37
+    /**
38
+     * 头像
39
+     */
40
+    @ApiModelProperty(name = "头像", notes = "")
41
+    private String avatar;
42
+    /**
43
+     * 手机
44
+     */
45
+    @ApiModelProperty(name = "手机", notes = "")
46
+    private String phone;
47
+    /**
48
+     * 行信ID
49
+     */
50
+    @ApiModelProperty(name = "行信ID", notes = "")
51
+    private String hxId;
52
+    /**
53
+     * 岗位ID
54
+     */
55
+    @ApiModelProperty(name = "岗位ID", notes = "")
56
+    private String positionId;
57
+    /**
58
+     * 机构ID
59
+     */
60
+    @ApiModelProperty(name = "机构ID", notes = "")
61
+    private String orgId;
62
+    /**
63
+     * 状态
64
+     */
65
+    @ApiModelProperty(name = "状态", notes = "")
66
+    private Integer status;
67
+
68
+
69
+    @ApiModelProperty(name = "创建人",notes = "")
70
+    @TableField(fill = FieldFill.INSERT)
71
+    private String createUser ;
72
+
73
+    @ApiModelProperty(name = "创建时间",notes = "")
74
+    @TableField(fill = FieldFill.INSERT)
75
+    private LocalDateTime createDate ;
76
+
77
+    @ApiModelProperty(name = "更新人",notes = "")
78
+    @TableField(fill = FieldFill.INSERT_UPDATE)
79
+    private String updateUser ;
80
+
81
+    @ApiModelProperty(name = "更新时间",notes = "")
82
+    @TableField(fill = FieldFill.INSERT_UPDATE)
83
+    private LocalDateTime updateDate ;
84
+
85
+    @ApiModelProperty(name = "删除标志",notes = "1删除")
86
+    @TableField(fill = FieldFill.INSERT)
87
+    private Integer deleted ;
88
+
89
+    @ApiModelProperty(name = "角色列表", notes = "")
90
+    @TableField(exist = false)
91
+    List<SysRole> rolesList;
92
+
93
+    @ApiModelProperty(name = "菜单列表", notes = "")
94
+    @TableField(exist = false)
95
+    List<SysMenu> menuList;
96
+}

+ 43
- 0
system/src/main/java/com/lyg/system/entity/SysUserRole.java View File

@@ -0,0 +1,43 @@
1
+package com.lyg.system.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+
14
+/**
15
+ * 角色授权;
16
+ *
17
+ * @author : http://www.chiner.pro
18
+ * @date : 2023-2-5
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value = "角色授权", description = "")
24
+@TableName("sys_user_role")
25
+public class SysUserRole implements Serializable, Cloneable {
26
+    /**
27
+     * id
28
+     */
29
+    @ApiModelProperty(name = "id", notes = "")
30
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
31
+    private String id;
32
+    /**
33
+     * 角色ID
34
+     */
35
+    @ApiModelProperty(name = "角色ID", notes = "")
36
+    private String roleId;
37
+    /**
38
+     * 用户ID
39
+     */
40
+    @ApiModelProperty(name = "用户ID", notes = "")
41
+    private String userId;
42
+
43
+}

+ 15
- 0
system/src/main/java/com/lyg/system/mapper/SysLogMapper.java View File

@@ -0,0 +1,15 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysLog;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+* 系统日志;(sys_log)表数据库访问层
9
+* @author : http://njyunzhi.com
10
+* @date : 2023-3-21
11
+*/
12
+@Mapper
13
+public interface SysLogMapper extends BaseMapper<SysLog>{
14
+
15
+}

+ 20
- 0
system/src/main/java/com/lyg/system/mapper/SysMenuMapper.java View File

@@ -0,0 +1,20 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysMenu;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * 菜单表;(sys_menu)表数据库访问层
12
+ *
13
+ * @author : http://njyunzhi.com
14
+ * @date : 2023-2-5
15
+ */
16
+@Mapper
17
+public interface SysMenuMapper extends BaseMapper<SysMenu> {
18
+
19
+    List<SysMenu> getByUser(@Param("userId") String userId);
20
+}

+ 24
- 0
system/src/main/java/com/lyg/system/mapper/SysOrgMapper.java View File

@@ -0,0 +1,24 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysOrg;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * 机构表;(sys_org)表数据库访问层
12
+ *
13
+ * @author : http://njyunzhi.com
14
+ * @date : 2023-1-27
15
+ */
16
+@Mapper
17
+public interface SysOrgMapper extends BaseMapper<SysOrg> {
18
+
19
+    List<SysOrg> getListByUser(@Param("userId") String userId);
20
+
21
+    String getMaxCode(@Param("parentId") String parentId);
22
+
23
+    long changeOrgCode(@Param("from") String from, @Param("to") String to);
24
+}

+ 15
- 0
system/src/main/java/com/lyg/system/mapper/SysPositionMapper.java View File

@@ -0,0 +1,15 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysPosition;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * 岗位表;(sys_position)表数据库访问层
9
+ * @author : http://njyunzhi.com
10
+ * @date : 2023-1-27
11
+ */
12
+@Mapper
13
+public interface SysPositionMapper  extends BaseMapper<SysPosition> {
14
+
15
+}

+ 23
- 0
system/src/main/java/com/lyg/system/mapper/SysRoleMapper.java View File

@@ -0,0 +1,23 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.lyg.system.entity.SysRole;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * 系统角色;(sys_role)表数据库访问层
13
+ *
14
+ * @author : http://njyunzhi.com
15
+ * @date : 2023-2-5
16
+ */
17
+@Mapper
18
+public interface SysRoleMapper extends BaseMapper<SysRole> {
19
+
20
+    List<SysRole> getByUser(@Param("userId") String userId);
21
+
22
+    IPage<SysRole> getPageBy(IPage<SysRole> pg, @Param("userId") String userId);
23
+}

+ 25
- 0
system/src/main/java/com/lyg/system/mapper/SysRoleResourceMapper.java View File

@@ -0,0 +1,25 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysRoleResource;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * 角色资源;(sys_role_resource)表数据库访问层
12
+ *
13
+ * @author : http://njyunzhi.com
14
+ * @date : 2023-2-5
15
+ */
16
+@Mapper
17
+public interface SysRoleResourceMapper extends BaseMapper<SysRoleResource> {
18
+
19
+    SysRoleResource getByRoleAndResource(@Param("roleId") String roleId,
20
+                                         @Param("resourceId") String resourceId,
21
+                                         @Param("resourceType") String resourceType);
22
+
23
+    int deleteNotIn(@Param("roleId") String roleId, @Param("idList") List<String> idList);
24
+
25
+}

+ 14
- 0
system/src/main/java/com/lyg/system/mapper/SysUserMapper.java View File

@@ -0,0 +1,14 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysUser;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * 用户表;(sys_user)表数据库访问层
9
+ * @author : http://njyunzhi.com
10
+ * @date : 2023-1-27
11
+ */
12
+@Mapper
13
+public interface SysUserMapper  extends BaseMapper<SysUser>{
14
+}

+ 24
- 0
system/src/main/java/com/lyg/system/mapper/SysUserRoleMapper.java View File

@@ -0,0 +1,24 @@
1
+package com.lyg.system.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysUserRole;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * 角色授权;(sys_user_role)表数据库访问层
12
+ * @author : http://njyunzhi.com
13
+ * @date : 2023-2-5
14
+ */
15
+@Mapper
16
+public interface SysUserRoleMapper  extends BaseMapper<SysUserRole> {
17
+
18
+    SysUserRole getByUserAndRole(@Param("userId") String userId, @Param("roleId") String roleId);
19
+
20
+    int deleteNotIn(@Param("userId") String userId, @Param("idList") List<String> idList);
21
+
22
+    List<String> getRoleList(@Param("userId") String userId);
23
+
24
+}

+ 20
- 0
system/src/main/java/com/lyg/system/service/IBaseService.java View File

@@ -0,0 +1,20 @@
1
+package com.lyg.system.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+
5
+import java.io.Serializable;
6
+
7
+public interface IBaseService<T> extends IService<T> {
8
+    /**
9
+     * 逻辑删除
10
+     * @param id
11
+     * @return
12
+     */
13
+    boolean removeLogicById(Serializable id);
14
+
15
+    long countBy(String column, Object value, boolean notDelete);
16
+
17
+    T getByButNot(String column, Object value, String col, Object val, boolean notDelete);
18
+
19
+    T getExistBy(String column, Object value, boolean normal, boolean notDelete);
20
+}

+ 12
- 0
system/src/main/java/com/lyg/system/service/SysLogService.java View File

@@ -0,0 +1,12 @@
1
+package com.lyg.system.service;
2
+
3
+import com.lyg.system.entity.SysLog;
4
+
5
+/**
6
+* 系统日志;(sys_log)表服务接口
7
+* @author : http://njyunzhi.com
8
+* @date : 2023-3-21
9
+*/
10
+public interface SysLogService extends IBaseService<SysLog> {
11
+
12
+}

+ 0
- 0
system/src/main/java/com/lyg/system/service/SysMenuService.java View File


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