Commit cef5b63dabe69e0f15d092b20688f67f33410712

Authored by “谢茂盛”
1 parent d927c459

init: 启动项目

Showing 60 changed files with 3019 additions and 1230 deletions

Too many changes to show.

To preserve performance only 60 of 143 files are displayed.

@@ -2,19 +2,17 @@ @@ -2,19 +2,17 @@
2 <project xmlns="http://maven.apache.org/POM/4.0.0" 2 <project xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5 - <modelVersion>4.0.0</modelVersion>  
6 -  
7 - <groupId>com.order.erp</groupId>  
8 - <artifactId>order-erp-services</artifactId>  
9 - <packaging>pom</packaging>  
10 - <version>1.0-SNAPSHOT</version>  
11 -  
12 <parent> 5 <parent>
13 <groupId>org.springframework.boot</groupId> 6 <groupId>org.springframework.boot</groupId>
14 <artifactId>spring-boot-starter-parent</artifactId> 7 <artifactId>spring-boot-starter-parent</artifactId>
15 <version>2.2.5.RELEASE</version> 8 <version>2.2.5.RELEASE</version>
16 <relativePath/> <!-- lookup parent from repository --> 9 <relativePath/> <!-- lookup parent from repository -->
17 </parent> 10 </parent>
  11 + <modelVersion>4.0.0</modelVersion>
  12 +
  13 + <groupId>com.order.erp</groupId>
  14 + <artifactId>order-erp</artifactId>
  15 + <version>1.0-SNAPSHOT</version>
18 16
19 <properties> 17 <properties>
20 <maven-compiler-plugin>3.7.0</maven-compiler-plugin> 18 <maven-compiler-plugin>3.7.0</maven-compiler-plugin>
@@ -34,6 +32,7 @@ @@ -34,6 +32,7 @@
34 <poi-ooxml.version>3.17</poi-ooxml.version> 32 <poi-ooxml.version>3.17</poi-ooxml.version>
35 <commons-csv.version>1.6</commons-csv.version> 33 <commons-csv.version>1.6</commons-csv.version>
36 <commons-lang3.version>3.8.1</commons-lang3.version> 34 <commons-lang3.version>3.8.1</commons-lang3.version>
  35 + <commons-pool2.version>2.11.1</commons-pool2.version>
37 <ip2region.version>1.7.2</ip2region.version> 36 <ip2region.version>1.7.2</ip2region.version>
38 <userAgentUtils.version>1.20</userAgentUtils.version> 37 <userAgentUtils.version>1.20</userAgentUtils.version>
39 <swagger.version>2.9.2</swagger.version> 38 <swagger.version>2.9.2</swagger.version>
@@ -45,208 +44,203 @@ @@ -45,208 +44,203 @@
45 <jjwt.version>0.10.6</jjwt.version> 44 <jjwt.version>0.10.6</jjwt.version>
46 </properties> 45 </properties>
47 46
48 - <dependencyManagement>  
49 - <dependencies>  
50 - <dependency>  
51 - <groupId>org.springframework.boot</groupId>  
52 - <artifactId>spring-boot-starter-web</artifactId>  
53 - <version>2.2.5.RELEASE</version>  
54 - <exclusions>  
55 - <exclusion>  
56 - <groupId>org.springframework.boot</groupId>  
57 - <artifactId>spring-boot-starter-logging</artifactId>  
58 - </exclusion>  
59 - </exclusions>  
60 - </dependency> 47 + <dependencies>
  48 + <dependency>
  49 + <groupId>org.springframework.boot</groupId>
  50 + <artifactId>spring-boot-starter-web</artifactId>
  51 + <version>2.2.5.RELEASE</version>
  52 + <exclusions>
  53 + <exclusion>
  54 + <groupId>org.springframework.boot</groupId>
  55 + <artifactId>spring-boot-starter-logging</artifactId>
  56 + </exclusion>
  57 + </exclusions>
  58 + </dependency>
61 59
62 - <!-- Lombok 依赖-->  
63 - <dependency>  
64 - <groupId>org.projectlombok</groupId>  
65 - <artifactId>lombok</artifactId>  
66 - <version>${lombok.version}</version>  
67 - <optional>true</optional>  
68 - </dependency> 60 + <!-- Lombok 依赖-->
  61 + <dependency>
  62 + <groupId>org.projectlombok</groupId>
  63 + <artifactId>lombok</artifactId>
  64 + <version>${lombok.version}</version>
  65 + <optional>true</optional>
  66 + </dependency>
  67 + <dependency>
  68 + <groupId>org.springframework.boot</groupId>
  69 + <artifactId>spring-boot-starter-aop</artifactId>
  70 + <version>${springboot.version}</version>
  71 + </dependency>
  72 + <dependency>
  73 + <groupId>org.springframework.boot</groupId>
  74 + <artifactId>spring-boot-starter-test</artifactId>
  75 + <version>${springboot.version}</version>
  76 + <scope>test</scope>
  77 + </dependency>
69 78
70 - <dependency>  
71 - <groupId>org.springframework.boot</groupId>  
72 - <artifactId>spring-boot-starter-test</artifactId>  
73 - <version>${springboot.version}</version>  
74 - </dependency> 79 + <dependency>
  80 + <groupId>com.baomidou</groupId>
  81 + <artifactId>mybatis-plus-boot-starter</artifactId>
  82 + <version>${baomidou.version}</version>
  83 + </dependency>
  84 + <!-- <dependency>-->
  85 + <!-- <groupId>com.baomidou</groupId>-->
  86 + <!-- <artifactId>dynamic-datasource-spring-boot-starter</artifactId>-->
  87 + <!-- </dependency>-->
  88 + <dependency>
  89 + <groupId>mysql</groupId>
  90 + <artifactId>mysql-connector-java</artifactId>
  91 + <version>${mysql-connector.version}</version>
  92 + </dependency>
  93 + <dependency>
  94 + <groupId>com.alibaba</groupId>
  95 + <artifactId>druid-spring-boot-starter</artifactId>
  96 + <version>${druid.version}</version>
  97 + </dependency>
75 98
76 - <dependency>  
77 - <groupId>com.baomidou</groupId>  
78 - <artifactId>mybatis-plus-boot-starter</artifactId>  
79 - <version>${baomidou.version}</version>  
80 - </dependency>  
81 - <dependency>  
82 - <groupId>cn.hutool</groupId>  
83 - <artifactId>hutool-crypto</artifactId>  
84 - <version>${hutool-crypto.version}</version>  
85 - </dependency>  
86 - <dependency>  
87 - <groupId>mysql</groupId>  
88 - <artifactId>mysql-connector-java</artifactId>  
89 - <version>${mysql-connector.version}</version>  
90 - </dependency>  
91 - <dependency>  
92 - <groupId>com.alibaba</groupId>  
93 - <artifactId>druid-spring-boot-starter</artifactId>  
94 - <version>${druid.version}</version>  
95 - </dependency> 99 + <dependency>
  100 + <groupId>org.springframework.boot</groupId>
  101 + <artifactId>spring-boot-starter-log4j2</artifactId>
  102 + <version>${springboot.version}</version>
  103 + </dependency>
  104 + <dependency>
  105 + <groupId>org.springframework.boot</groupId>
  106 + <artifactId>spring-boot-starter-security</artifactId>
  107 + <version>${springboot.version}</version>
  108 + </dependency>
96 109
97 - <dependency>  
98 - <groupId>org.springframework.boot</groupId>  
99 - <artifactId>spring-boot-starter-log4j2</artifactId>  
100 - <version>${springboot.version}</version>  
101 - </dependency>  
102 - <dependency>  
103 - <groupId>org.springframework.boot</groupId>  
104 - <artifactId>spring-boot-starter-security</artifactId>  
105 - <version>${springboot.version}</version>  
106 - </dependency>  
107 - <!-- email -->  
108 - <dependency>  
109 - <groupId>org.springframework.boot</groupId>  
110 - <artifactId>spring-boot-starter-mail</artifactId>  
111 - <version>${springboot.version}</version>  
112 - </dependency>  
113 - <!-- freemarker 模版 -->  
114 - <dependency>  
115 - <groupId>org.springframework.boot</groupId>  
116 - <artifactId>spring-boot-starter-freemarker</artifactId>  
117 - <version>${springboot.version}</version>  
118 - </dependency>  
119 - <!-- aop -->  
120 - <dependency>  
121 - <groupId>org.springframework.boot</groupId>  
122 - <artifactId>spring-boot-starter-aop</artifactId>  
123 - <version>${springboot.version}</version>  
124 - </dependency>  
125 - <dependency>  
126 - <groupId>com.alibaba</groupId>  
127 - <artifactId>fastjson</artifactId>  
128 - <version>${fastjson.version}</version>  
129 - </dependency> 110 + <!--jwt-->
  111 + <dependency>
  112 + <groupId>io.jsonwebtoken</groupId>
  113 + <artifactId>jjwt-api</artifactId>
  114 + <version>${jjwt.version}</version>
  115 + </dependency>
  116 + <dependency>
  117 + <groupId>io.jsonwebtoken</groupId>
  118 + <artifactId>jjwt-impl</artifactId>
  119 + <version>${jjwt.version}</version>
  120 + </dependency>
  121 + <dependency>
  122 + <groupId>io.jsonwebtoken</groupId>
  123 + <artifactId>jjwt-jackson</artifactId>
  124 + <version>${jjwt.version}</version>
  125 + </dependency>
130 126
131 - <dependency>  
132 - <groupId>org.springframework.boot</groupId>  
133 - <artifactId>spring-boot-starter-data-redis</artifactId>  
134 - <version>${springboot.version}</version>  
135 - </dependency>  
136 127
137 - <!-- RESTful APIs swagger2 -->  
138 - <dependency>  
139 - <groupId>io.springfox</groupId>  
140 - <artifactId>springfox-swagger2</artifactId>  
141 - <version>${swagger.version}</version>  
142 - <exclusions>  
143 - <exclusion>  
144 - <groupId>io.swagger</groupId>  
145 - <artifactId>swagger-annotations</artifactId>  
146 - </exclusion>  
147 - <exclusion>  
148 - <groupId>io.swagger</groupId>  
149 - <artifactId>swagger-models</artifactId>  
150 - </exclusion>  
151 - </exclusions>  
152 - </dependency>  
153 - <dependency>  
154 - <groupId>io.springfox</groupId>  
155 - <artifactId>springfox-swagger-ui</artifactId>  
156 - <version>${swagger.version}</version>  
157 - </dependency>  
158 - <dependency>  
159 - <groupId>io.swagger</groupId>  
160 - <artifactId>swagger-annotations</artifactId>  
161 - <version>${swagger-annotations.version}</version>  
162 - </dependency>  
163 - <dependency>  
164 - <groupId>io.swagger</groupId>  
165 - <artifactId>swagger-models</artifactId>  
166 - <version>${swagger-models.version}</version>  
167 - </dependency> 128 + <dependency>
  129 + <groupId>com.alibaba</groupId>
  130 + <artifactId>fastjson</artifactId>
  131 + <version>${fastjson.version}</version>
  132 + </dependency>
168 133
169 - <!--工具包-->  
170 - <dependency>  
171 - <groupId>cn.hutool</groupId>  
172 - <artifactId>hutool-all</artifactId>  
173 - <version>${hutool-all.version}</version>  
174 - </dependency>  
175 - <dependency>  
176 - <groupId>org.apache.poi</groupId>  
177 - <artifactId>poi</artifactId>  
178 - <version>${poi.version}</version>  
179 - </dependency>  
180 - <dependency>  
181 - <groupId>org.apache.poi</groupId>  
182 - <artifactId>poi-ooxml</artifactId>  
183 - <version>${poi-ooxml.version}</version>  
184 - </dependency>  
185 - <dependency>  
186 - <groupId>org.apache.commons</groupId>  
187 - <artifactId>commons-csv</artifactId>  
188 - <version>${commons-csv.version}</version>  
189 - </dependency>  
190 - <dependency>  
191 - <groupId>org.apache.commons</groupId>  
192 - <artifactId>commons-lang3</artifactId>  
193 - <version>${commons-lang3.version}</version>  
194 - </dependency>  
195 - <!--https://gitee.com/lionsoul/ip2region/tree/v1.4-release/-->  
196 - <dependency>  
197 - <groupId>org.lionsoul</groupId>  
198 - <artifactId>ip2region</artifactId>  
199 - <version>${ip2region.version}</version>  
200 - </dependency>  
201 - <dependency>  
202 - <groupId>eu.bitwalker</groupId>  
203 - <artifactId>UserAgentUtils</artifactId>  
204 - <version>${userAgentUtils.version}</version>  
205 - </dependency>  
206 - <dependency>  
207 - <groupId>joda-time</groupId>  
208 - <artifactId>joda-time</artifactId>  
209 - <version>${joda-time.version}</version>  
210 - </dependency>  
211 - <dependency>  
212 - <groupId>com.google.guava</groupId>  
213 - <artifactId>guava</artifactId>  
214 - <version>${guava.version}</version>  
215 - </dependency> 134 + <dependency>
  135 + <groupId>cn.hutool</groupId>
  136 + <artifactId>hutool-crypto</artifactId>
  137 + <version>${hutool-crypto.version}</version>
  138 + </dependency>
216 139
217 - <dependency>  
218 - <groupId>com.github.whvcse</groupId>  
219 - <artifactId>easy-captcha</artifactId>  
220 - <version>${easy-captcha.version}</version>  
221 - </dependency> 140 + <dependency>
  141 + <groupId>org.springframework.boot</groupId>
  142 + <artifactId>spring-boot-starter-data-redis</artifactId>
  143 + <version>${springboot.version}</version>
  144 + </dependency>
222 145
223 - <!--短信服务-->  
224 - <dependency>  
225 - <groupId>com.aliyun</groupId>  
226 - <artifactId>aliyun-java-sdk-core</artifactId>  
227 - <version>${aliyun-java-sdk-core.version}</version>  
228 - </dependency> 146 + <dependency>
  147 + <groupId>org.apache.commons</groupId>
  148 + <artifactId>commons-pool2</artifactId>
  149 + <version>${commons-pool2.version}</version>
  150 + </dependency>
229 151
230 - <!--jwt-->  
231 - <dependency>  
232 - <groupId>io.jsonwebtoken</groupId>  
233 - <artifactId>jjwt-api</artifactId>  
234 - <version>${jjwt.version}</version>  
235 - </dependency>  
236 - <dependency>  
237 - <groupId>io.jsonwebtoken</groupId>  
238 - <artifactId>jjwt-impl</artifactId>  
239 - <version>${jjwt.version}</version>  
240 - </dependency>  
241 - <dependency>  
242 - <groupId>io.jsonwebtoken</groupId>  
243 - <artifactId>jjwt-jackson</artifactId>  
244 - <version>${jjwt.version}</version>  
245 - </dependency>  
246 152
247 - </dependencies>  
248 - </dependencyManagement> 153 + <dependency>
  154 + <groupId>org.apache.commons</groupId>
  155 + <artifactId>commons-lang3</artifactId>
  156 + <version>${commons-lang3.version}</version>
  157 + </dependency>
  158 + <dependency>
  159 + <groupId>org.lionsoul</groupId>
  160 + <artifactId>ip2region</artifactId>
  161 + <version>${ip2region.version}</version>
  162 + </dependency>
  163 + <dependency>
  164 + <groupId>eu.bitwalker</groupId>
  165 + <artifactId>UserAgentUtils</artifactId>
  166 + <version>${userAgentUtils.version}</version>
  167 + </dependency>
  168 + <!-- RESTful APIs swagger2 -->
  169 + <dependency>
  170 + <groupId>io.springfox</groupId>
  171 + <artifactId>springfox-swagger2</artifactId>
  172 + <version>${swagger.version}</version>
  173 + <exclusions>
  174 + <exclusion>
  175 + <groupId>io.swagger</groupId>
  176 + <artifactId>swagger-annotations</artifactId>
  177 + </exclusion>
  178 + <exclusion>
  179 + <groupId>io.swagger</groupId>
  180 + <artifactId>swagger-models</artifactId>
  181 + </exclusion>
  182 + </exclusions>
  183 + </dependency>
  184 + <dependency>
  185 + <groupId>io.springfox</groupId>
  186 + <artifactId>springfox-swagger-ui</artifactId>
  187 + <version>${swagger.version}</version>
  188 + </dependency>
  189 + <dependency>
  190 + <groupId>io.swagger</groupId>
  191 + <artifactId>swagger-annotations</artifactId>
  192 + <version>${swagger-annotations.version}</version>
  193 + </dependency>
  194 + <dependency>
  195 + <groupId>io.swagger</groupId>
  196 + <artifactId>swagger-models</artifactId>
  197 + <version>${swagger-models.version}</version>
  198 + </dependency>
  199 + <!--工具包-->
  200 + <dependency>
  201 + <groupId>cn.hutool</groupId>
  202 + <artifactId>hutool-all</artifactId>
  203 + <version>${hutool-all.version}</version>
  204 + </dependency>
  205 + <dependency>
  206 + <groupId>org.apache.poi</groupId>
  207 + <artifactId>poi</artifactId>
  208 + <version>${poi.version}</version>
  209 + </dependency>
  210 + <dependency>
  211 + <groupId>org.apache.poi</groupId>
  212 + <artifactId>poi-ooxml</artifactId>
  213 + <version>${poi-ooxml.version}</version>
  214 + </dependency>
  215 + <dependency>
  216 + <groupId>org.apache.commons</groupId>
  217 + <artifactId>commons-csv</artifactId>
  218 + <version>${commons-csv.version}</version>
  219 + </dependency>
  220 + <dependency>
  221 + <groupId>joda-time</groupId>
  222 + <artifactId>joda-time</artifactId>
  223 + <version>${joda-time.version}</version>
  224 + </dependency>
  225 + <dependency>
  226 + <groupId>com.google.guava</groupId>
  227 + <artifactId>guava</artifactId>
  228 + <version>${guava.version}</version>
  229 + </dependency>
249 230
  231 + <dependency>
  232 + <groupId>com.github.whvcse</groupId>
  233 + <artifactId>easy-captcha</artifactId>
  234 + <version>${easy-captcha.version}</version>
  235 + </dependency>
  236 +
  237 + <!--短信服务-->
  238 + <dependency>
  239 + <groupId>com.aliyun</groupId>
  240 + <artifactId>aliyun-java-sdk-core</artifactId>
  241 + <version>${aliyun-java-sdk-core.version}</version>
  242 + </dependency>
  243 + </dependencies>
250 <build> 244 <build>
251 <finalName>order-erp.service-1.0-SNAPSHOT</finalName> 245 <finalName>order-erp.service-1.0-SNAPSHOT</finalName>
252 <plugins> 246 <plugins>
@@ -265,5 +259,4 @@ @@ -265,5 +259,4 @@
265 259
266 </plugins> 260 </plugins>
267 </build> 261 </build>
268 -  
269 </project> 262 </project>
270 \ No newline at end of file 263 \ No newline at end of file
sql/init.sql 0 → 100644
  1 +# 部门表
  2 +CREATE TABLE `admin_dept` (
  3 + `id` bigint NOT NULL AUTO_INCREMENT,
  4 + `pid` bigint(20) DEFAULT NULL COMMENT '上级部门',
  5 + `sub_count` int(5) DEFAULT '0' COMMENT '子部门数目',
  6 + `name` varchar(255) NOT NULL COMMENT '名称',
  7 + `dept_sort` int(5) DEFAULT '999' COMMENT '排序',
  8 + `enable_flag` INT NOT NULL COMMENT '是否可用 10-可用 20-删除',
  9 + `create_time` DATETIME NOT NULL COMMENT '创建时间',
  10 + `create_by` varchar(64) NOT NULL COMMENT '创建人',
  11 + `modify_time` DATETIME DEFAULT NULL COMMENT '修改时间',
  12 + `modify_by` varchar(64) DEFAULT NULL COMMENT '修改人',
  13 + `version` INT DEFAULT NULL COMMENT '版本号--乐观锁预留字段',
  14 + PRIMARY KEY (`id`)
  15 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='部门表';
  16 +
  17 +
  18 +# 岗位表
  19 +CREATE TABLE `admin_job` (
  20 + `id` bigint NOT NULL AUTO_INCREMENT,
  21 + `name` varchar(64) NOT NULL COMMENT '岗位名称',
  22 + `sort` INT NOT NULL COMMENT '排序字段',
  23 + `enable_flag` INT NOT NULL COMMENT '是否可用 10-可用 20-删除',
  24 + `create_time` DATETIME NOT NULL COMMENT '创建时间',
  25 + `create_by` varchar(64) NOT NULL COMMENT '创建人',
  26 + `modify_time` DATETIME DEFAULT NULL COMMENT '修改时间',
  27 + `modify_by` varchar(64) DEFAULT NULL COMMENT '修改人',
  28 + `version` INT DEFAULT NULL COMMENT '版本号--乐观锁预留字段',
  29 + PRIMARY KEY (`id`)
  30 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='岗位表';
  31 +
  32 +
  33 +# 菜单表
  34 +CREATE TABLE `admin_menu` (
  35 + `id` bigint NOT NULL AUTO_INCREMENT,
  36 + `pid` bigint(20) DEFAULT NULL COMMENT '上级菜单ID',
  37 + `sub_count` int(5) DEFAULT '0' COMMENT '子菜单数目',
  38 + `type` int(11) DEFAULT NULL COMMENT '菜单类型',
  39 + `title` varchar(255) DEFAULT NULL COMMENT '菜单标题',
  40 + `name` varchar(255) DEFAULT NULL COMMENT '组件名称',
  41 + `component` varchar(255) DEFAULT NULL COMMENT '组件',
  42 + `menu_sort` int(5) DEFAULT NULL COMMENT '排序',
  43 + `icon` varchar(255) DEFAULT NULL COMMENT '图标',
  44 + `path` varchar(255) DEFAULT NULL COMMENT '链接地址',
  45 + `i_frame` bit(1) DEFAULT NULL COMMENT '是否外链',
  46 + `cache` bit(1) DEFAULT b'0' COMMENT '缓存',
  47 + `hidden` bit(1) DEFAULT b'0' COMMENT '隐藏',
  48 + `permission` varchar(255) DEFAULT NULL COMMENT '权限',
  49 + `enable_flag` INT NOT NULL COMMENT '是否可用 10-可用 20-删除',
  50 + `create_time` DATETIME NOT NULL COMMENT '创建时间',
  51 + `create_by` varchar(64) NOT NULL COMMENT '创建人',
  52 + `modify_time` DATETIME DEFAULT NULL COMMENT '修改时间',
  53 + `modify_by` varchar(64) DEFAULT NULL COMMENT '修改人',
  54 + `version` INT DEFAULT NULL COMMENT '版本号--乐观锁预留字段',
  55 + PRIMARY KEY (`menu_id`) USING BTREE,
  56 + UNIQUE KEY `uniq_title` (`title`),
  57 + UNIQUE KEY `uniq_name` (`name`),
  58 + KEY `inx_pid` (`pid`)
  59 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
  60 +
  61 +
  62 +# 角色表
  63 +CREATE TABLE `admin_role` (
  64 + `id` bigint NOT NULL AUTO_INCREMENT,
  65 + `name` varchar(255) NOT NULL COMMENT '名称',
  66 + `level` int(255) DEFAULT NULL COMMENT '角色级别',
  67 + `description` varchar(255) DEFAULT NULL COMMENT '描述',
  68 + `data_scope` varchar(255) DEFAULT NULL COMMENT '数据权限',
  69 + `enable_flag` INT NOT NULL COMMENT '是否可用 10-可用 20-删除',
  70 + `create_time` DATETIME NOT NULL COMMENT '创建时间',
  71 + `create_by` varchar(64) NOT NULL COMMENT '创建人',
  72 + `modify_time` DATETIME DEFAULT NULL COMMENT '修改时间',
  73 + `modify_by` varchar(64) DEFAULT NULL COMMENT '修改人',
  74 + `version` INT DEFAULT NULL COMMENT '版本号--乐观锁预留字段',
  75 + PRIMARY KEY (`id`)
  76 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
  77 +
  78 +
  79 +# 角色-部门表
  80 +CREATE TABLE `admin_role_dept` (
  81 + `id` bigint NOT NULL AUTO_INCREMENT,
  82 + `role_id` bigint NOT NULL COMMENT '角色id',
  83 + `dept_id` bigint NOT NULL COMMENT '部门id',
  84 + UNIQUE KEY (`role_id`,`dept_id`)
  85 + PRIMARY KEY (`id`)
  86 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色-部门表';
  87 +
  88 +
  89 +# 角色-菜单表
  90 +CREATE TABLE `admin_role_menu` (
  91 + `id` bigint NOT NULL AUTO_INCREMENT,
  92 + `role_id` bigint NOT NULL COMMENT '角色id',
  93 + `menu_id` bigint NOT NULL COMMENT '菜单id',
  94 + UNIQUE KEY (`role_id`,`menu_id`)
  95 + PRIMARY KEY (`id`)
  96 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色-菜单表';
  97 +
  98 +
  99 +# 用户表
  100 +CREATE TABLE `admin_user` (
  101 + `id` bigint NOT NULL AUTO_INCREMENT,
  102 + `dept_id` bigint(20) DEFAULT NULL COMMENT '部门名称',
  103 + `user_name` varchar(255) DEFAULT NULL COMMENT '用户名',
  104 + `nick_name` varchar(255) DEFAULT NULL COMMENT '昵称',
  105 + `gender` varchar(2) DEFAULT NULL COMMENT '性别',
  106 + `phone` varchar(255) DEFAULT NULL COMMENT '手机号码',
  107 + `email` varchar(255) DEFAULT NULL COMMENT '邮箱',
  108 + `avatar_name` varchar(255) DEFAULT NULL COMMENT '头像地址',
  109 + `avatar_path` varchar(255) DEFAULT NULL COMMENT '头像真实路径',
  110 + `password` varchar(255) DEFAULT NULL COMMENT '密码',
  111 + `is_admin` bit(1) DEFAULT b'0' COMMENT '是否为admin账号',
  112 + `pwd_reset_time` DATETIME DEFAULT NULL COMMENT '修改密码的时间',
  113 + `enable_flag` INT NOT NULL COMMENT '是否可用 10-可用 20-删除',
  114 + `create_time` DATETIME NOT NULL COMMENT '创建时间',
  115 + `create_by` varchar(64) NOT NULL COMMENT '创建人',
  116 + `modify_time` DATETIME DEFAULT NULL COMMENT '修改时间',
  117 + `modify_by` varchar(64) DEFAULT NULL COMMENT '修改人',
  118 + `version` INT DEFAULT NULL COMMENT '版本号--乐观锁预留字段',
  119 + UNIQUE KEY `uniq_username` (`username`),
  120 + UNIQUE KEY `uniq_phone` (`phone`),
  121 + UNIQUE KEY `uniq_email` (`email`),
  122 + PRIMARY KEY (`id`)
  123 +
  124 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
  125 +
  126 +
  127 +# 用户-岗位表
  128 +CREATE TABLE `admin_user_job` (
  129 + `id` bigint NOT NULL AUTO_INCREMENT,
  130 + `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  131 + `job_id` bigint(20) NOT NULL COMMENT '岗位ID',
  132 + UNIQUE KEY (`user_id`,`job_id`)
  133 + PRIMARY KEY (`id`)
  134 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户-岗位表';
  135 +
  136 +
  137 +# 用户角色表
  138 +CREATE TABLE `admin_user_role` (
  139 + `id` bigint NOT NULL AUTO_INCREMENT,
  140 + `user_id` bigint NOT NULL COMMENT '用户id',
  141 + `role_id` bigint NOT NULL COMMENT '角色id',
  142 + UNIQUE KEY (`user_id`,`role_id`)
  143 + PRIMARY KEY (`id`)
  144 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色表';
  145 +
  146 +
  147 +# 字典表
  148 +CREATE TABLE `dictionary` (
  149 + `id` bigint NOT NULL AUTO_INCREMENT,
  150 + `dict_code` varchar(64) not NULL COMMENT '字典编码',
  151 + `dict_name` varchar(64) not null COMMENT '名称',
  152 + `dict_value` varchar(64) not null COMMENT '值',
  153 + `remark` varchar(64) default null COMMENT '备注',
  154 + `sort` INT default 0 COMMENT '排序字段',
  155 + `enable_flag` INT NOT NULL COMMENT '是否可用 10-可用 20-删除',
  156 + `create_time` DATETIME NOT NULL COMMENT '创建时间',
  157 + `create_by` varchar(64) NOT NULL COMMENT '创建人',
  158 + `modify_time` DATETIME DEFAULT NULL COMMENT '修改时间',
  159 + `modify_by` varchar(64) DEFAULT NULL COMMENT '修改人',
  160 + `version` INT DEFAULT NULL COMMENT '版本号--乐观锁预留字段',
  161 + PRIMARY KEY (`id`)
  162 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典表';
0 \ No newline at end of file 163 \ No newline at end of file
src/main/java/com/order/erp/AdminApplication.java
@@ -3,8 +3,8 @@ package com.order.erp; @@ -3,8 +3,8 @@ package com.order.erp;
3 import com.baomidou.mybatisplus.annotation.DbType; 3 import com.baomidou.mybatisplus.annotation.DbType;
4 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 4 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
5 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 5 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
6 -import com.canrd.shop.common.directory.Path;  
7 -import com.canrd.shop.common.utils.SpringContextHolder; 6 +import com.order.erp.common.directory.Path;
  7 +import com.order.erp.common.utils.SpringContextHolder;
8 import org.mybatis.spring.annotation.MapperScan; 8 import org.mybatis.spring.annotation.MapperScan;
9 import org.springframework.boot.SpringApplication; 9 import org.springframework.boot.SpringApplication;
10 import org.springframework.boot.autoconfigure.SpringBootApplication; 10 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -20,8 +20,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -20,8 +20,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
20 * @version: 1.0 20 * @version: 1.0
21 */ 21 */
22 @EnableAsync 22 @EnableAsync
23 -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.canrd.shop"})  
24 -@MapperScan("com.canrd.shop.**.mapper") 23 +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.order.erp"})
  24 +@MapperScan("com.order.erp.**.mapper")
25 @EnableTransactionManagement 25 @EnableTransactionManagement
26 public class AdminApplication { 26 public class AdminApplication {
27 27
src/main/java/com/order/erp/common/constant/ServerResult.java
@@ -18,11 +18,11 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -18,11 +18,11 @@ public class ServerResult&lt;T&gt; implements Serializable {
18 /** 18 /**
19 * 返回的状态码 19 * 返回的状态码
20 */ 20 */
21 - private int result = ServerResultCode.SUCCESS.getErrorCode(); 21 + private int result = com.canrd.shop.common.constant.ServerResultCode.SUCCESS.getErrorCode();
22 /** 22 /**
23 * 返回的消息 23 * 返回的消息
24 */ 24 */
25 - private String message = ServerResultCode.SUCCESS.getErrorDesc(); 25 + private String message = com.canrd.shop.common.constant.ServerResultCode.SUCCESS.getErrorDesc();
26 /** 26 /**
27 * 返回的数据实体 27 * 返回的数据实体
28 */ 28 */
@@ -56,7 +56,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -56,7 +56,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
56 return this; 56 return this;
57 } 57 }
58 58
59 - public ServerResult setResult(ServerResultCode serverResultCode) { 59 + public ServerResult setResult(com.canrd.shop.common.constant.ServerResultCode serverResultCode) {
60 this.result = serverResultCode.getErrorCode(); 60 this.result = serverResultCode.getErrorCode();
61 this.message = serverResultCode.getErrorDesc(); 61 this.message = serverResultCode.getErrorDesc();
62 return this; 62 return this;
@@ -88,21 +88,21 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -88,21 +88,21 @@ public class ServerResult&lt;T&gt; implements Serializable {
88 88
89 public static <T> ServerResult<T> success() { 89 public static <T> ServerResult<T> success() {
90 return new ServerResult() 90 return new ServerResult()
91 - .setResult(ServerResultCode.SUCCESS)  
92 - .setMessage(ServerResultCode.SUCCESS.getErrorDesc())  
93 - .setData(defaultResult(ServerResultCode.SUCCESS)); 91 + .setResult(com.canrd.shop.common.constant.ServerResultCode.SUCCESS)
  92 + .setMessage(com.canrd.shop.common.constant.ServerResultCode.SUCCESS.getErrorDesc())
  93 + .setData(defaultResult(com.canrd.shop.common.constant.ServerResultCode.SUCCESS));
94 } 94 }
95 95
96 public static <T> ServerResult<T> success(T data) { 96 public static <T> ServerResult<T> success(T data) {
97 return new ServerResult() 97 return new ServerResult()
98 - .setResult(ServerResultCode.SUCCESS)  
99 - .setMessage(ServerResultCode.SUCCESS.getErrorDesc()) 98 + .setResult(com.canrd.shop.common.constant.ServerResultCode.SUCCESS)
  99 + .setMessage(com.canrd.shop.common.constant.ServerResultCode.SUCCESS.getErrorDesc())
100 .setData(data); 100 .setData(data);
101 } 101 }
102 102
103 public static <T> ServerResult<T> success(T data, String message) { 103 public static <T> ServerResult<T> success(T data, String message) {
104 return new ServerResult() 104 return new ServerResult()
105 - .setResult(ServerResultCode.SUCCESS) 105 + .setResult(com.canrd.shop.common.constant.ServerResultCode.SUCCESS)
106 .setMessage(message) 106 .setMessage(message)
107 .setData(data); 107 .setData(data);
108 } 108 }
@@ -114,7 +114,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -114,7 +114,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
114 */ 114 */
115 public static <T> ServerResult<T> fail(String message) { 115 public static <T> ServerResult<T> fail(String message) {
116 return new ServerResult() 116 return new ServerResult()
117 - .setResult(ServerResultCode.FAIL) 117 + .setResult(com.canrd.shop.common.constant.ServerResultCode.FAIL)
118 .setMessage(message) 118 .setMessage(message)
119 .setData(defaultResult(Constant.RESULT_FAIL)); 119 .setData(defaultResult(Constant.RESULT_FAIL));
120 } 120 }
@@ -126,7 +126,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -126,7 +126,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
126 * @param <T> 126 * @param <T>
127 * @return 127 * @return
128 */ 128 */
129 - public static <T> ServerResult<T> fail(T data, ServerResultCode serverResultCode) { 129 + public static <T> ServerResult<T> fail(T data, com.canrd.shop.common.constant.ServerResultCode serverResultCode) {
130 return new ServerResult() 130 return new ServerResult()
131 .setData(data) 131 .setData(data)
132 .setResult(serverResultCode) 132 .setResult(serverResultCode)
@@ -152,7 +152,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -152,7 +152,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
152 * @author dengbin 152 * @author dengbin
153 * @date 2020/9/12 153 * @date 2020/9/12
154 */ 154 */
155 - public static <T> ServerResult<T> fail(ServerResultCode serverResultCode, String msg) { 155 + public static <T> ServerResult<T> fail(com.canrd.shop.common.constant.ServerResultCode serverResultCode, String msg) {
156 return new ServerResult() 156 return new ServerResult()
157 .setResult(serverResultCode) 157 .setResult(serverResultCode)
158 .setMessage(msg) 158 .setMessage(msg)
@@ -165,7 +165,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -165,7 +165,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
165 * @author dengbin 165 * @author dengbin
166 * @date 2020/9/12 166 * @date 2020/9/12
167 */ 167 */
168 - public static <T> ServerResult<T> fail(ServerResultCode serverResultCode) { 168 + public static <T> ServerResult<T> fail(com.canrd.shop.common.constant.ServerResultCode serverResultCode) {
169 return new ServerResult() 169 return new ServerResult()
170 .setResult(serverResultCode) 170 .setResult(serverResultCode)
171 .setMessage(serverResultCode.getErrorDesc()) 171 .setMessage(serverResultCode.getErrorDesc())
@@ -188,8 +188,8 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -188,8 +188,8 @@ public class ServerResult&lt;T&gt; implements Serializable {
188 188
189 public static <T> ServerResult<T> fail() { 189 public static <T> ServerResult<T> fail() {
190 return new ServerResult() 190 return new ServerResult()
191 - .setResult(ServerResultCode.FAIL.getErrorCode())  
192 - .setMessage(ServerResultCode.FAIL.getErrorDesc()) 191 + .setResult(com.canrd.shop.common.constant.ServerResultCode.FAIL.getErrorCode())
  192 + .setMessage(com.canrd.shop.common.constant.ServerResultCode.FAIL.getErrorDesc())
193 .setData(defaultResult(Constant.RESULT_FAIL)); 193 .setData(defaultResult(Constant.RESULT_FAIL));
194 } 194 }
195 195
@@ -199,7 +199,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -199,7 +199,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
199 * @author dengbin 199 * @author dengbin
200 * @date 2020/9/12 200 * @date 2020/9/12
201 */ 201 */
202 - public ServerResult failEnum(ServerResultCode serverResultCode) { 202 + public ServerResult failEnum(com.canrd.shop.common.constant.ServerResultCode serverResultCode) {
203 setResult(serverResultCode); 203 setResult(serverResultCode);
204 setMessage(serverResultCode.getErrorDesc()); 204 setMessage(serverResultCode.getErrorDesc());
205 return this; 205 return this;
@@ -218,7 +218,7 @@ public class ServerResult&lt;T&gt; implements Serializable { @@ -218,7 +218,7 @@ public class ServerResult&lt;T&gt; implements Serializable {
218 * @return 结果 ture or false 218 * @return 结果 ture or false
219 */ 219 */
220 public boolean checkSuccess() { 220 public boolean checkSuccess() {
221 - return result == ServerResultCode.SUCCESS.getErrorCode(); 221 + return result == com.canrd.shop.common.constant.ServerResultCode.SUCCESS.getErrorCode();
222 } 222 }
223 223
224 public boolean checkNotSuccess() { 224 public boolean checkNotSuccess() {
src/main/java/com/order/erp/common/constant/ServerResultCode.java
1 -package com.order.erp.common.constant; 1 +package com.canrd.shop.common.constant;
2 2
3 3
4 -import com.canrd.shop.common.exception.ErrorInfo; 4 +import com.order.erp.common.exception.ErrorInfo;
5 import lombok.Setter; 5 import lombok.Setter;
6 6
7 7
@@ -14,6 +14,8 @@ public enum ServerResultCode implements ErrorInfo { @@ -14,6 +14,8 @@ public enum ServerResultCode implements ErrorInfo {
14 FAIL(1000, "系统内部错误,请联系业务系统运维管理员"), 14 FAIL(1000, "系统内部错误,请联系业务系统运维管理员"),
15 FIlE_UPLOAD_TOO_LARGE(1051, "上传文件太大,图片文件一般小于2兆"), 15 FIlE_UPLOAD_TOO_LARGE(1051, "上传文件太大,图片文件一般小于2兆"),
16 16
  17 + UNAUTHORIZED(401, "登录状态过期"),
  18 +
17 //空指针异常 19 //空指针异常
18 NULL_POINT(1001, "空指针异常"), 20 NULL_POINT(1001, "空指针异常"),
19 21
@@ -24,6 +26,10 @@ public enum ServerResultCode implements ErrorInfo { @@ -24,6 +26,10 @@ public enum ServerResultCode implements ErrorInfo {
24 PARAM_ERROR(1005, "入参为空"), 26 PARAM_ERROR(1005, "入参为空"),
25 EMPTY_RESULT(1006, "数据不存在"), 27 EMPTY_RESULT(1006, "数据不存在"),
26 EMPTY_LIST(1007, "查询结果为空"), 28 EMPTY_LIST(1007, "查询结果为空"),
  29 + IMG_CAPTCHA_ERROR(1008, "图片验证码错误"),
  30 + IMG_CAPTCHA_EXPIRE_ERROR(1009, "图片验证码不存在或已过期"),
  31 + SMS_CAPTCHA_ERROR(1010, "短信验证码错误"),
  32 + SMS_CAPTCHA_EXPIRE_ERROR(1011, "短信验证码不存在或已过期"),
27 33
28 //认证授权异常 34 //认证授权异常
29 UNAUTHENTICATION(401, "未登录"), 35 UNAUTHENTICATION(401, "未登录"),
@@ -31,10 +37,28 @@ public enum ServerResultCode implements ErrorInfo { @@ -31,10 +37,28 @@ public enum ServerResultCode implements ErrorInfo {
31 37
32 //用户 38 //用户
33 USER_NOT_EXIT(20001, "用户不存在"), 39 USER_NOT_EXIT(20001, "用户不存在"),
  40 + USER_UN_ENABLE(20002, "用户未激活"),
34 41
35 42
36 // 公司 43 // 公司
37 COMPANY_NOT_EXIT(30001, "公司不存在"), 44 COMPANY_NOT_EXIT(30001, "公司不存在"),
  45 +
  46 + // 短信
  47 + SMS_SEND_OVER_LIMIT_ERROR(40001, "发送频次过高,请一分钟后再发送"),
  48 + EMAIL_SEND_OVER_LIMIT_ERROR(40002, "发送频次过高(一天最多修改三次),请第二天后再发送"),
  49 +
  50 + // 会员
  51 + MEMBER_PHONE_REGISTER_ERROR(50001, "手机已经被注册使用!"),
  52 + MEMBER_AGREE_AGREEMENT_CHOOSE_ERROR(50002, "必须同意注册协议才可进行注册操作!"),
  53 + MEMBER_CONFIRM_PASSWORD_ERROR(50003, "两次密码输入不一致!"),
  54 + MEMBER_LOGIN_PHONE_ERROR(50004, "手机号没有注册,请注册后登录!"),
  55 + MEMBER_LOGIN_LOCKED_TIME_ERROR(50005, "账号被锁定,请稍后再试试!"),
  56 + MEMBER_RECOVER_PASSWORD_ERROR(50006, "对不起,此密码找回链接已失效!"),
  57 + MEMBER_RECOVER_PASSWORD_EXPIRE_ERROR(50007, "对不起,此密码找回链接已过期!"),
  58 +
  59 + //产品
  60 + PRODUCT_NOT_EXIST_ERROR(60001, "此商品已下架!"),
  61 + PRODUCT_NOT_MORE_STORE_ERROR(60002, "添加购物车失败,商品库存不足!"),
38 ; 62 ;
39 63
40 64
src/main/java/com/order/erp/common/directory/Path.java
1 package com.order.erp.common.directory; 1 package com.order.erp.common.directory;
2 2
3 3
4 -import com.canrd.shop.common.constant.Constant; 4 +import com.order.erp.common.constant.Constant;
5 5
6 /** 6 /**
7 * @author xms 7 * @author xms
src/main/java/com/order/erp/common/exception/BusinessException.java
1 package com.order.erp.common.exception; 1 package com.order.erp.common.exception;
2 2
3 -import com.canrd.shop.common.constant.ServerResult;  
4 import com.canrd.shop.common.constant.ServerResultCode; 3 import com.canrd.shop.common.constant.ServerResultCode;
  4 +import com.order.erp.common.constant.ServerResult;
5 import lombok.Getter; 5 import lombok.Getter;
6 import lombok.Setter; 6 import lombok.Setter;
7 import lombok.extern.slf4j.Slf4j; 7 import lombok.extern.slf4j.Slf4j;
src/main/java/com/order/erp/common/exception/BusinessExceptionHandlerAdvice.java
1 package com.order.erp.common.exception; 1 package com.order.erp.common.exception;
2 2
3 -import com.canrd.shop.common.constant.ServerResult;  
4 import com.canrd.shop.common.constant.ServerResultCode; 3 import com.canrd.shop.common.constant.ServerResultCode;
  4 +import com.order.erp.common.constant.ServerResult;
5 import org.springframework.core.annotation.Order; 5 import org.springframework.core.annotation.Order;
6 import org.springframework.http.HttpStatus; 6 import org.springframework.http.HttpStatus;
7 import org.springframework.http.ResponseEntity; 7 import org.springframework.http.ResponseEntity;
src/main/java/com/order/erp/common/exception/handler/GlobalExceptionHandler.java
1 package com.order.erp.common.exception.handler; 1 package com.order.erp.common.exception.handler;
2 2
3 3
4 -import com.canrd.shop.common.constant.ServerResult;  
5 import com.canrd.shop.common.constant.ServerResultCode; 4 import com.canrd.shop.common.constant.ServerResultCode;
6 -import com.canrd.shop.common.exception.BadRequestException;  
7 -import com.canrd.shop.common.exception.BusinessException;  
8 -import com.canrd.shop.common.exception.EntityExistException;  
9 -import com.canrd.shop.common.exception.EntityNotFoundException;  
10 -import com.canrd.shop.common.utils.ThrowableUtil; 5 +import com.order.erp.common.constant.ServerResult;
  6 +import com.order.erp.common.exception.BusinessException;
  7 +import com.order.erp.common.exception.EntityExistException;
  8 +import com.order.erp.common.exception.EntityNotFoundException;
  9 +import com.order.erp.common.utils.ThrowableUtil;
11 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
12 import org.springframework.http.HttpStatus; 11 import org.springframework.http.HttpStatus;
13 import org.springframework.http.ResponseEntity; 12 import org.springframework.http.ResponseEntity;
@@ -72,11 +71,11 @@ public class GlobalExceptionHandler { @@ -72,11 +71,11 @@ public class GlobalExceptionHandler {
72 * @param e 71 * @param e
73 * @return 72 * @return
74 */ 73 */
75 - @ExceptionHandler(value = BadRequestException.class)  
76 - public ResponseEntity<ServerResult> badRequestException(BadRequestException e) { 74 + @ExceptionHandler(value = BusinessException.class)
  75 + public ResponseEntity<ServerResult> badRequestException(BusinessException e) {
77 // 打印堆栈信息 76 // 打印堆栈信息
78 log.error(ThrowableUtil.getStackTrace(e)); 77 log.error(ThrowableUtil.getStackTrace(e));
79 - return buildResponseEntity(ServerResult.fail(e.getStatus(), e.getMessage())); 78 + return buildResponseEntity(ServerResult.fail(e.getErrorCode(), e.getMessage()));
80 } 79 }
81 80
82 /** 81 /**
src/main/java/com/order/erp/common/jsr303/ListValueConstraintValidator.java
1 package com.order.erp.common.jsr303; 1 package com.order.erp.common.jsr303;
2 2
3 3
4 -import com.canrd.shop.common.jsr303.annotation.ListIntValue; 4 +import com.order.erp.common.jsr303.annotation.ListIntValue;
5 5
6 import javax.validation.ConstraintValidator; 6 import javax.validation.ConstraintValidator;
7 import javax.validation.ConstraintValidatorContext; 7 import javax.validation.ConstraintValidatorContext;
src/main/java/com/order/erp/common/jsr303/annotation/ListIntValue.java
1 package com.order.erp.common.jsr303.annotation; 1 package com.order.erp.common.jsr303.annotation;
2 2
3 3
4 -import com.canrd.shop.common.jsr303.ListValueConstraintValidator; 4 +import com.order.erp.common.jsr303.ListValueConstraintValidator;
5 5
6 import javax.validation.Constraint; 6 import javax.validation.Constraint;
7 import javax.validation.Payload; 7 import javax.validation.Payload;
8 import java.lang.annotation.*; 8 import java.lang.annotation.*;
9 9
10 /** 10 /**
11 - * @author fanzhenyu  
12 * @date 2023-01-15 11 * @date 2023-01-15
13 */ 12 */
14 @Constraint(validatedBy = {ListValueConstraintValidator.class}) 13 @Constraint(validatedBy = {ListValueConstraintValidator.class})
src/main/java/com/order/erp/common/utils/DateUtils.java 0 → 100644
  1 +package com.order.erp.common.utils;
  2 +
  3 +
  4 +import java.text.DateFormat;
  5 +import java.text.ParseException;
  6 +import java.text.SimpleDateFormat;
  7 +import java.time.*;
  8 +import java.time.format.DateTimeFormatter;
  9 +import java.time.temporal.ChronoField;
  10 +import java.time.temporal.TemporalAdjusters;
  11 +import java.util.Date;
  12 +import java.util.Locale;
  13 +import java.util.TimeZone;
  14 +
  15 +/**
  16 + * @Auther: dengbin
  17 + * @Date: 2020/9/1
  18 + * 基于Java8的时间工具类
  19 + */
  20 +public class DateUtils {
  21 + /**
  22 + * 例如:2018-12-28
  23 + */
  24 + public static final String DATE = "yyyy-MM-dd";
  25 + /**
  26 + * 例如:2018.12.28
  27 + */
  28 + public static final String DATE_WITH_POINT = "yyyy.MM.dd";
  29 + /**
  30 + * 例如:2018-12-28 10:00:00
  31 + */
  32 + public static final String DATE_TIME = "yyyy-MM-dd HH:mm:ss";
  33 + /**
  34 + * 例如:2018-12-28 10:00:00:215
  35 + */
  36 + public static final String DATE_TIME_MS = "yyyy-MM-dd HH:mm:ss.SSS";
  37 + /**
  38 + * 例如:10:00:00
  39 + */
  40 + public static final String TIME = "HHmmss";
  41 + /**
  42 + * 例如:10:00:00
  43 + */
  44 + public static final String TIME_HAVE_SECOND = "HH:mm:ss";
  45 + /**
  46 + * 例如:10:00
  47 + */
  48 + public static final String TIME_WITHOUT_SECOND = "HH:mm";
  49 +
  50 + /**
  51 + * 例如:2018-12-28 10:00
  52 + */
  53 + public static final String DATE_TIME_WITHOUT_SECONDS = "yyyy-MM-dd HH:mm";
  54 +
  55 + /**
  56 + * 例如 2020/04/16 12:23:0
  57 + */
  58 + public static final String DATE_TIME_WITHOUT_SECONDS_OTHER = "yyyy/MM/dd HH:mm:ss";
  59 +
  60 + /**
  61 + * 例如:2020年04月23日 10:00
  62 + */
  63 + public static final String DATE_CHINESE_TIME = "yyyy年MM月dd日 HH:mm";
  64 +
  65 + /**
  66 + * 例如:20181228100000215
  67 + */
  68 + public static final String MAX_DATE = "9999-12-31 59:59:59";
  69 +
  70 + /**
  71 + * 例如:20210822082134
  72 + */
  73 + public static final String DATE_TIME_HMS = "yyyyMMddHHmmssSSS";
  74 +
  75 + public static final String YYMMDD = "yyyyMMdd";
  76 +
  77 + public static final String YMMDD = "yyMMdd";
  78 +
  79 + public static final String YYMMDDHHMMSS = "yyMMddHHmmss";
  80 +
  81 + public static final String MONTH_TIME = "MM-dd HH:mm:ss";
  82 +
  83 + public static LocalDateTime getCurrentTime() {
  84 + LocalDateTime now = LocalDateTime.now();
  85 + return now;
  86 + }
  87 +
  88 + public static Date getNextDay() {
  89 + LocalDateTime now = LocalDateTime.now();
  90 + LocalDateTime tomorrow = now.minusDays(-1);
  91 + return Date.from(tomorrow.atZone(ZoneId.systemDefault()).toInstant());
  92 + }
  93 +
  94 + public static Date getAppointDay(Integer count) {
  95 + LocalDateTime now = LocalDateTime.now();
  96 + LocalDateTime tomorrow = now.minusDays(count);
  97 + return Date.from(tomorrow.atZone(ZoneId.systemDefault()).toInstant());
  98 + }
  99 +
  100 + /**
  101 + * 获取年
  102 + *
  103 + * @return 年
  104 + */
  105 + public static int getYear() {
  106 + LocalDateTime localDateTime = LocalDateTime.now();
  107 + return localDateTime.get(ChronoField.YEAR);
  108 + }
  109 +
  110 + /**
  111 + * 获取月份
  112 + *
  113 + * @return 月份
  114 + */
  115 + public static int getMonth() {
  116 + LocalDateTime localDateTime = LocalDateTime.now();
  117 + return localDateTime.get(ChronoField.MONTH_OF_YEAR);
  118 + }
  119 +
  120 + /**
  121 + * 获取某月的第几天
  122 + *
  123 + * @return 几号
  124 + */
  125 + public static int getMonthOfDay() {
  126 + LocalDateTime localDateTime = LocalDateTime.now();
  127 + return localDateTime.get(ChronoField.DAY_OF_MONTH);
  128 + }
  129 +
  130 + /**
  131 + * 格式化日期为字符串
  132 + *
  133 + * @param date date
  134 + * @param pattern 格式
  135 + * @return 日期字符串
  136 + */
  137 + public static String formatOrElseBlank(Date date, String pattern) {
  138 + if (date == null || pattern == null) {
  139 + return "";
  140 + }
  141 + Instant instant = date.toInstant();
  142 +
  143 + LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
  144 +
  145 + return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
  146 + }
  147 +
  148 + /**
  149 + * 格式化日期为字符串
  150 + *
  151 + * @param date date
  152 + * @param pattern 格式
  153 + * @return 日期字符串
  154 + */
  155 + public static String format(Date date, String pattern) {
  156 +
  157 + Instant instant = date.toInstant();
  158 +
  159 + LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
  160 +
  161 + return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
  162 + }
  163 +
  164 + public static String formatNow(String pattern) {
  165 + LocalDateTime localDateTime = LocalDateTime.now();
  166 +
  167 + return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
  168 + }
  169 +
  170 +
  171 + public static String format(LocalDateTime date, String pattern) {
  172 + return date.format(DateTimeFormatter.ofPattern(pattern));
  173 + }
  174 +
  175 + public static String format(LocalDate date, String pattern) {
  176 + return date.format(DateTimeFormatter.ofPattern(pattern));
  177 + }
  178 +
  179 + /**
  180 + * 解析字符串日期为LocalDateTime
  181 + *
  182 + * @param dateStr 日期字符串
  183 + * @param pattern 格式
  184 + * @return Date
  185 + */
  186 + public static LocalDateTime parse(String dateStr, String pattern) {
  187 + return LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern(pattern));
  188 + }
  189 +
  190 + /**
  191 + * 解析字符串日期为LocalDateTime
  192 + *
  193 + * @param dateStr 日期字符串
  194 + * @param pattern 格式
  195 + * @return Date
  196 + */
  197 + public static LocalDateTime parseStrByPattern(String dateStr, String pattern) {
  198 + try {
  199 + return parse(dateStr, pattern);
  200 + } catch (Exception e) {
  201 + return getCurrentTime();
  202 + }
  203 + }
  204 +
  205 + /**
  206 + * 解析字符串日期为LocalDate
  207 + *
  208 + * @param dateStr
  209 + * @param pattern
  210 + * @return
  211 + */
  212 + public static LocalDate parseDate(String dateStr, String pattern) {
  213 + return LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(pattern));
  214 + }
  215 +
  216 + /**
  217 + * @param dateTimeStr
  218 + * @param prePattern
  219 + * @param expectPattern
  220 + * @return
  221 + */
  222 + public static String format(String dateTimeStr, String prePattern, String expectPattern) {
  223 + LocalDateTime localDateTime = parseDate(dateTimeStr, prePattern).atStartOfDay();
  224 + return localDateTime.format(DateTimeFormatter.ofPattern(expectPattern));
  225 + }
  226 +
  227 + /**
  228 + * String -> Date
  229 + *
  230 + * @param date
  231 + * @return
  232 + */
  233 + public static Date parseStringToDate(String date, String pattern) {
  234 + SimpleDateFormat sdf = new SimpleDateFormat(pattern);
  235 + try {
  236 + return sdf.parse(date);
  237 + } catch (ParseException e) {
  238 + return null;
  239 + }
  240 + }
  241 +
  242 + /**
  243 + * 为Date增加分钟,减传负数
  244 + *
  245 + * @param date 日期
  246 + * @param plusMinutes 要增加的分钟数
  247 + * @return 新的日期
  248 + */
  249 + public static Date addMinutes(Date date, Long plusMinutes) {
  250 + LocalDateTime dateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
  251 + LocalDateTime newDateTime = dateTime.plusMinutes(plusMinutes);
  252 + return Date.from(newDateTime.atZone(ZoneId.systemDefault()).toInstant());
  253 + }
  254 +
  255 + /**
  256 + * 增加时间
  257 + *
  258 + * @param date date
  259 + * @param hour 要增加的小时数
  260 + * @return new date
  261 + */
  262 + public static Date addHour(Date date, Long hour) {
  263 + LocalDateTime dateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
  264 + LocalDateTime localDateTime = dateTime.plusHours(hour);
  265 + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
  266 + }
  267 +
  268 + /**
  269 + * @return 返回当天的起始时间
  270 + */
  271 + public static Date getStartTime() {
  272 +
  273 + LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
  274 + return localDateTime2Date(now);
  275 + }
  276 +
  277 +
  278 + /**
  279 + * @return 返回当天的结束时间
  280 + */
  281 + public static Date getEndTime() {
  282 + LocalDateTime now = LocalDateTime.now().withHour(23).withMinute(59).withSecond(59).withNano(999999999);
  283 + return localDateTime2Date(now);
  284 + }
  285 +
  286 + /**
  287 + * @return 获取入参当天结束时间
  288 + */
  289 + public static LocalDateTime getEndTime(LocalDate localDate) {
  290 + return localDate.atTime(23, 59, 59, 999999999);
  291 + }
  292 +
  293 + /**
  294 + * 减月份
  295 + *
  296 + * @param monthsToSubtract 月份
  297 + * @return Date
  298 + */
  299 + public static Date minusMonths(long monthsToSubtract) {
  300 + LocalDate localDate = LocalDate.now().minusMonths(monthsToSubtract);
  301 +
  302 + return localDate2Date(localDate);
  303 + }
  304 +
  305 + /**
  306 + * LocalDate类型转为Date
  307 + *
  308 + * @param localDate LocalDate object
  309 + * @return Date object
  310 + */
  311 + public static Date localDate2Date(LocalDate localDate) {
  312 +
  313 + ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
  314 +
  315 + return Date.from(zonedDateTime.toInstant());
  316 + }
  317 +
  318 + /**
  319 + * Date类型转为LocalDateTime
  320 + *
  321 + * @param date Date object
  322 + * @return localDate LocalDateTime
  323 + */
  324 + public static LocalDateTime date2LocalDateTime(Date date) {
  325 +
  326 + Instant instant = date.toInstant();
  327 + ZoneId zoneId = ZoneId.systemDefault();
  328 + LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
  329 + return localDateTime;
  330 + }
  331 +
  332 +
  333 + /**
  334 + * LocalDateTime类型转为Date
  335 + *
  336 + * @param localDateTime LocalDateTime object
  337 + * @return Date object
  338 + */
  339 + public static Date localDateTime2Date(LocalDateTime localDateTime) {
  340 + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
  341 + }
  342 +
  343 + /**
  344 + * 查询当前年的第一天
  345 + *
  346 + * @param pattern 格式,默认格式yyyyMMdd
  347 + * @return 20190101
  348 + */
  349 + public static String getFirstDayOfCurrentYear(String pattern) {
  350 + LocalDateTime localDateTime = LocalDateTime.now().withMonth(1).withDayOfMonth(1);
  351 +
  352 + if (StringUtils.isEmpty(pattern)) {
  353 + pattern = "yyyyMMdd";
  354 + }
  355 +
  356 + return format(localDateTime2Date(localDateTime), pattern);
  357 + }
  358 +
  359 + /**
  360 + * 查询前一年最后一个月第一天
  361 + *
  362 + * @param pattern 格式,默认格式yyyyMMdd
  363 + * @return 20190101
  364 + */
  365 + public static String getLastMonthFirstDayOfPreviousYear(String pattern) {
  366 + LocalDateTime localDateTime = LocalDateTime.now().minusYears(1L).withMonth(12).withDayOfMonth(1);
  367 +
  368 + if (StringUtils.isEmpty(pattern)) {
  369 + pattern = "yyyyMMdd";
  370 + }
  371 +
  372 + return format(localDateTime2Date(localDateTime), pattern);
  373 + }
  374 +
  375 + /**
  376 + * 查询前一年最后一个月第一天
  377 + *
  378 + * @param pattern 格式,默认格式yyyyMMdd
  379 + * @return 20190101
  380 + */
  381 + public static String getLastMonthLastDayOfPreviousYear(String pattern) {
  382 + LocalDateTime localDateTime = LocalDateTime.now().minusYears(1L).with(TemporalAdjusters.lastDayOfYear());
  383 +
  384 + if (StringUtils.isEmpty(pattern)) {
  385 + pattern = "yyyyMMdd";
  386 + }
  387 +
  388 + return format(localDateTime2Date(localDateTime), pattern);
  389 + }
  390 +
  391 + /**
  392 + * 获取当前日期
  393 + *
  394 + * @param pattern 格式,默认格式yyyyMMdd
  395 + * @return 20190101
  396 + */
  397 + public static String getCurrentDay(String pattern) {
  398 + LocalDateTime localDateTime = LocalDateTime.now();
  399 +
  400 + if (StringUtils.isEmpty(pattern)) {
  401 + pattern = "yyyyMMdd";
  402 + }
  403 +
  404 + return format(localDateTime2Date(localDateTime), pattern);
  405 + }
  406 +
  407 + public static String getTransitionTime(LocalDateTime time, String pattern) {
  408 + if (StringUtils.isEmpty(pattern)) {
  409 + pattern = "yyyyMMdd";
  410 + }
  411 + return format(localDateTime2Date(time), pattern);
  412 + }
  413 +
  414 +
  415 + /**
  416 + * 用于判断两个时间段有没有重合, 重合: true,未重合: false
  417 + *
  418 + * @param aStartTime
  419 + * @param aEndTime
  420 + * @param bStartTime
  421 + * @param bEndTime
  422 + * @return
  423 + * @author A80068
  424 + */
  425 + public static boolean judgeTimeSlotCoincidence(LocalDateTime aStartTime, LocalDateTime aEndTime, LocalDateTime bStartTime, LocalDateTime bEndTime) {
  426 + /**
  427 + * 旧版
  428 + */
  429 + //boolean flag;
  430 + //if(aStartTime.isAfter(bStartTime)){
  431 + // if (aStartTime.isBefore(bEndTime) || aStartTime.isEqual(bEndTime)){
  432 + // flag = true;
  433 + // }else{
  434 + // flag = false;
  435 + // }
  436 + //}else if(aStartTime.isBefore(bStartTime)){
  437 + // if(aEndTime.isAfter(bStartTime) || aEndTime.isEqual(bStartTime)){
  438 + // flag = true;
  439 + // }else{
  440 + // flag = false;
  441 + // }
  442 + //}else{
  443 + // flag = true;
  444 + //}
  445 + //return flag;
  446 + /**
  447 + * 优化版
  448 + */
  449 + boolean flag = false;
  450 + if ((aStartTime.isBefore(bEndTime) || aStartTime.isEqual(bEndTime))) {
  451 + if ((aEndTime.isAfter(bStartTime)) || aEndTime.isEqual(bStartTime)) {
  452 + flag = true;
  453 + }
  454 + }
  455 + return flag;
  456 + }
  457 +
  458 + /**
  459 + * @param aStartTimeStr
  460 + * @param aEndTimeStr
  461 + * @param bStartTimeStr
  462 + * @param bEndTimeStr
  463 + * @return
  464 + * @author A80068
  465 + */
  466 + public static boolean judgeTimeSlotCoincidenceString(String aStartTimeStr, String aEndTimeStr, String bStartTimeStr, String bEndTimeStr) {
  467 +
  468 + LocalDateTime aStartTime = parse(aStartTimeStr, DATE_TIME);
  469 + LocalDateTime aEndTime = parse(aEndTimeStr, DATE_TIME);
  470 + LocalDateTime bStartTime = parse(bStartTimeStr, DATE_TIME);
  471 + LocalDateTime bEndTime = parse(bEndTimeStr, DATE_TIME);
  472 +
  473 + return judgeTimeSlotCoincidence(aStartTime, aEndTime, bStartTime, bEndTime);
  474 + }
  475 +
  476 + /**
  477 + * @param strGMT
  478 + * @return
  479 + * @throws ParseException
  480 + * @throws ParseException
  481 + */
  482 + public static Date getCST(String strGMT) throws ParseException, ParseException {
  483 + DateFormat df = new SimpleDateFormat("EEE, d-MMM-yyyy HH:mm:ss z", Locale.ENGLISH);
  484 + return df.parse(strGMT);
  485 + }
  486 +
  487 + /**
  488 + * @param dateCST
  489 + * @return
  490 + */
  491 + public static Date getGMT(Date dateCST) throws ParseException {
  492 + DateFormat df = new SimpleDateFormat("EEE, d-MMM-yyyy HH:mm:ss z", Locale.ENGLISH);
  493 + df.setTimeZone(TimeZone.getTimeZone("GMT")); // modify Time Zone.
  494 + return df.parse(df.format(dateCST));
  495 + }
  496 +
  497 + /**
  498 + * LocalDateTime转化为cron表达式
  499 + *
  500 + * @param dateTime
  501 + * @return
  502 + */
  503 + public static String dateToCron(LocalDateTime dateTime) {
  504 + if (dateTime == null) {
  505 + return "";
  506 + }
  507 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ss mm HH dd MM ? yyyy");
  508 + return formatter.format(dateTime);
  509 + }
  510 +
  511 + /**
  512 + * cron表达式转为LocalDateTime
  513 + *
  514 + * @param cron
  515 + * @return
  516 + */
  517 + public static LocalDateTime cronToDate(String cron) {
  518 + if (StringUtils.isNotBlank(cron)) {
  519 + return null;
  520 + }
  521 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ss mm HH dd MM ? yyyy");
  522 + return LocalDateTime.parse(cron, formatter);
  523 + }
  524 +
  525 + public static String timeToString(long time) {
  526 + DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  527 + return ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()));
  528 + }
  529 +
  530 + public static String timeToString(String time) {
  531 + try {
  532 + return timeToString(Long.parseLong(time));
  533 + } catch (Exception e) {
  534 + }
  535 + return time;
  536 + }
  537 +
  538 + /**
  539 + * 比较时间大小
  540 + *
  541 + * @param date1
  542 + * @param date2
  543 + * @return
  544 + */
  545 + public static int compareDate(Date date1, Date date2) {
  546 + if (date1 == null || date2 == null) {
  547 + return -2;
  548 + }
  549 + if (date1.getTime() < date2.getTime()) {
  550 + return -1;
  551 + } else if (date1.getTime() > date2.getTime()) {
  552 + return 1;
  553 + }
  554 + return 0;
  555 + }
  556 +
  557 + /**
  558 + * 判斷两个时间是否在同一分钟
  559 + */
  560 + public static boolean isMinuteIdentical(LocalDateTime date1, LocalDateTime date2) {
  561 + return date1.getYear() == date2.getYear() && date1.getMonth() == date2.getMonth() && date1.getMinute() == date2.getMinute();
  562 + }
  563 +
  564 + /**
  565 + * 时区
  566 + */
  567 + public static class Zone {
  568 + public static final String GMT8 = "GMT+8";
  569 + }
  570 +}
src/main/java/com/order/erp/common/utils/ImgCaptchaUtils.java 0 → 100644
  1 +package com.order.erp.common.utils;
  2 +
  3 +import cn.hutool.core.util.IdUtil;
  4 +import com.order.erp.common.exception.BusinessException;
  5 +import com.order.erp.security.config.SecurityProperties;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.beans.factory.annotation.Value;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import javax.annotation.Resource;
  11 +import java.util.concurrent.TimeUnit;
  12 +
  13 +
  14 +@Slf4j
  15 +@Service
  16 +public class ImgCaptchaUtils {
  17 +
  18 + @Resource
  19 + private SecurityProperties properties;
  20 +
  21 + @Resource
  22 + private RedisUtil redisUtil;
  23 +
  24 + @Value("${loginCode.expiration}")
  25 + private Long expiration;
  26 +
  27 + /**
  28 + * @param imgCaptchaCode
  29 + * @param imgCaptchaUuid
  30 + */
  31 + public void validateImgCaptcha(String imgCaptchaCode, String imgCaptchaUuid) {
  32 + // 查询验证码
  33 + String code = redisUtil.get(imgCaptchaUuid);
  34 + // 清除验证码
  35 + redisUtil.delete(imgCaptchaUuid);
  36 + if (StringUtils.isBlank(code)) {
  37 + throw new BusinessException(com.canrd.shop.common.constant.ServerResultCode.IMG_CAPTCHA_EXPIRE_ERROR);
  38 + }
  39 + if (StringUtils.isBlank(imgCaptchaCode) || !imgCaptchaCode.equalsIgnoreCase(code)) {
  40 + throw new BusinessException(com.canrd.shop.common.constant.ServerResultCode.IMG_CAPTCHA_ERROR);
  41 + }
  42 + }
  43 +
  44 + /**
  45 + * @param imgCaptchaCode
  46 + * @return
  47 + */
  48 + public String setImgCaptcha4uuid(String imgCaptchaCode) {
  49 + String uuid = properties.getCodeKey() + IdUtil.simpleUUID();
  50 + // 保存
  51 + redisUtil.set(uuid, imgCaptchaCode, expiration, TimeUnit.MINUTES);
  52 + return uuid;
  53 + }
  54 +
  55 +}
src/main/java/com/order/erp/common/utils/PageUtils.java
@@ -2,7 +2,7 @@ package com.order.erp.common.utils; @@ -2,7 +2,7 @@ package com.order.erp.common.utils;
2 2
3 import com.baomidou.mybatisplus.core.metadata.IPage; 3 import com.baomidou.mybatisplus.core.metadata.IPage;
4 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 -import com.canrd.shop.domain.vo.BasePageVO; 5 +import com.order.erp.domain.vo.BasePageVO;
6 import org.springframework.util.CollectionUtils; 6 import org.springframework.util.CollectionUtils;
7 7
8 import java.io.Serializable; 8 import java.io.Serializable;
src/main/java/com/order/erp/common/utils/RedisUtil.java 0 → 100644
  1 +package com.order.erp.common.utils;
  2 +
  3 +import lombok.extern.slf4j.Slf4j;
  4 +import org.springframework.data.redis.connection.DataType;
  5 +import org.springframework.data.redis.core.*;
  6 +import org.springframework.stereotype.Repository;
  7 +
  8 +import javax.annotation.Resource;
  9 +import java.util.*;
  10 +import java.util.concurrent.TimeUnit;
  11 +import java.util.stream.Collectors;
  12 +
  13 +/**
  14 + * @Date: 2020/9/1
  15 + */
  16 +@Slf4j
  17 +@Repository("redisUtil")
  18 +public class RedisUtil {
  19 +
  20 + @Resource(name = "stringRedisTemplate")
  21 + private StringRedisTemplate redisTemplate;
  22 +
  23 +
  24 + /* -------------------key相关操作--------------------- */
  25 +
  26 + /**
  27 + * 删除key
  28 + *
  29 + * @param key key key
  30 + */
  31 + public void delete(String key) {
  32 + redisTemplate.delete(key);
  33 + }
  34 +
  35 + /**
  36 + * 批量删除key
  37 + *
  38 + * @param keys keys
  39 + */
  40 + public void delete(Collection<String> keys) {
  41 + redisTemplate.delete(keys);
  42 + }
  43 +
  44 + /**
  45 + * 序列化key
  46 + *
  47 + * @param key key
  48 + * @return
  49 + */
  50 + public byte[] dump(String key) {
  51 + return redisTemplate.dump(key);
  52 + }
  53 +
  54 + /**
  55 + * 是否存在key
  56 + *
  57 + * @param key key
  58 + * @return
  59 + */
  60 + public Boolean hasKey(String key) {
  61 + return redisTemplate.hasKey(key);
  62 + }
  63 +
  64 + /**
  65 + * 设置过期时间
  66 + *
  67 + * @param key key
  68 + * @param timeout
  69 + * @param unit
  70 + * @return
  71 + */
  72 + public Boolean expire(String key, long timeout, TimeUnit unit) {
  73 + return redisTemplate.expire(key, timeout, unit);
  74 + }
  75 +
  76 + /**
  77 + * 设置过期时间
  78 + *
  79 + * @param key key
  80 + * @param date
  81 + * @return
  82 + */
  83 + public Boolean expireAt(String key, Date date) {
  84 + return redisTemplate.expireAt(key, date);
  85 + }
  86 +
  87 + /**
  88 + * 查找匹配的key
  89 + *
  90 + * @param pattern
  91 + * @return
  92 + */
  93 + public Set<String> keys(String pattern) {
  94 + return redisTemplate.keys(pattern);
  95 + }
  96 +
  97 + /**
  98 + * 将当前数据库的 key 移动到给定的数据库 db 当中
  99 + *
  100 + * @param key key
  101 + * @param dbIndex
  102 + * @return
  103 + */
  104 + public Boolean move(String key, int dbIndex) {
  105 + return redisTemplate.move(key, dbIndex);
  106 + }
  107 +
  108 + /**
  109 + * 移除 key 的过期时间,key 将持久保持
  110 + *
  111 + * @param key key
  112 + * @return
  113 + */
  114 + public Boolean persist(String key) {
  115 + return redisTemplate.persist(key);
  116 + }
  117 +
  118 + /**
  119 + * 返回 key 的剩余的过期时间
  120 + *
  121 + * @param key key
  122 + * @param unit
  123 + * @return
  124 + */
  125 + public Long getExpire(String key, TimeUnit unit) {
  126 + return redisTemplate.getExpire(key, unit);
  127 + }
  128 +
  129 + /**
  130 + * 返回 key 的剩余的过期时间
  131 + *
  132 + * @param key key
  133 + * @return
  134 + */
  135 + public Long getExpire(String key) {
  136 + return redisTemplate.getExpire(key);
  137 + }
  138 +
  139 + /**
  140 + * 从当前数据库中随机返回一个 key
  141 + *
  142 + * @return
  143 + */
  144 + public String randomKey() {
  145 + return redisTemplate.randomKey();
  146 + }
  147 +
  148 + /**
  149 + * 修改 key 的名称
  150 + *
  151 + * @param oldKey
  152 + * @param newKey
  153 + */
  154 + public void rename(String oldKey, String newKey) {
  155 + redisTemplate.rename(oldKey, newKey);
  156 + }
  157 +
  158 + /**
  159 + * 仅当 newkey 不存在时,将 oldKey 改名为 newkey
  160 + *
  161 + * @param oldKey
  162 + * @param newKey
  163 + * @return
  164 + */
  165 + public Boolean renameIfAbsent(String oldKey, String newKey) {
  166 + return redisTemplate.renameIfAbsent(oldKey, newKey);
  167 + }
  168 +
  169 + /**
  170 + * 返回 key 所储存的值的类型
  171 + *
  172 + * @param key key
  173 + * @return
  174 + */
  175 + public DataType type(String key) {
  176 + return redisTemplate.type(key);
  177 + }
  178 +
  179 + /**
  180 + * -------------------string相关操作---------------------
  181 + *//*
  182 +
  183 + /**
  184 + * 设置指定 key 的值
  185 + * @param key key
  186 + * @param value val
  187 + */
  188 + public void set(String key, String value) {
  189 + redisTemplate.opsForValue().set(key, value);
  190 + }
  191 +
  192 + /**
  193 + * 设置缓存,指定有效时间
  194 + * 时间单位为 秒
  195 + *
  196 + * @param key
  197 + * @param value
  198 + * @param expireTime
  199 + */
  200 + public void set(String key, String value, Long expireTime) {
  201 + redisTemplate.opsForValue().set(key, value, expireTime, TimeUnit.SECONDS);
  202 + }
  203 +
  204 + /**
  205 + * 设置缓存,指定有效时间
  206 + * 时间单位 自定义
  207 + *
  208 + * @param key
  209 + * @param value
  210 + * @param expireTime
  211 + * @param timeUnit
  212 + */
  213 + public void set(String key, String value, Long expireTime, TimeUnit timeUnit) {
  214 + redisTemplate.opsForValue().set(key, value, expireTime, timeUnit);
  215 + }
  216 +
  217 + /**
  218 + * 获取指定 key 的值
  219 + *
  220 + * @param key key
  221 + * @return
  222 + */
  223 + public String get(String key) {
  224 + return redisTemplate.opsForValue().get(key);
  225 + }
  226 +
  227 + /**
  228 + * 返回 key 中字符串值的子字符
  229 + *
  230 + * @param key key
  231 + * @param start
  232 + * @param end
  233 + * @return
  234 + */
  235 + public String getRange(String key, long start, long end) {
  236 + return redisTemplate.opsForValue().get(key, start, end);
  237 + }
  238 +
  239 + /**
  240 + * 将给定 key 的值设为 value ,并返回 key 的旧值(old value)
  241 + *
  242 + * @param key key
  243 + * @param value val
  244 + * @return
  245 + */
  246 + public String getAndSet(String key, String value) {
  247 + return redisTemplate.opsForValue().getAndSet(key, value);
  248 + }
  249 +
  250 + /**
  251 + * 对 key 所储存的字符串值,获取指定偏移量上的位(bit)
  252 + *
  253 + * @param key key
  254 + * @param offset
  255 + * @return
  256 + */
  257 + public Boolean getBit(String key, long offset) {
  258 + return redisTemplate.opsForValue().getBit(key, offset);
  259 + }
  260 +
  261 + /**
  262 + * 批量获取
  263 + *
  264 + * @param keys keys
  265 + * @return 多个key的value
  266 + */
  267 + public List<String> multiGet(Collection<String> keys) {
  268 + return redisTemplate.opsForValue().multiGet(keys);
  269 + }
  270 +
  271 + public List<String> multiGetPip(Collection<String> keys) {
  272 + return redisTemplate.executePipelined((RedisCallback<String>) connection -> {
  273 + keys.forEach(a -> connection.get(a.getBytes()));
  274 + return null;
  275 + }).stream()
  276 + .filter(Objects::nonNull)
  277 + .map(Object::toString)
  278 + .collect(Collectors.toList());
  279 + }
  280 +
  281 + /**
  282 + * 设置ASCII码, 字符串'a'的ASCII码是97, 转为二进制是'01100001', 此方法是将二进制第offset位值变为value
  283 + *
  284 + * @param key key
  285 + * @param offset 偏移
  286 + * @param value val
  287 + */
  288 + public Boolean setBit(String key, long offset, boolean value) {
  289 + return redisTemplate.opsForValue().setBit(key, offset, value);
  290 + }
  291 +
  292 + /**
  293 + * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
  294 + *
  295 + * @param key key
  296 + * @param value val
  297 + * @param timeout 过期时间
  298 + * @param unit 时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
  299 + * 秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
  300 + */
  301 + public void setEx(String key, String value, long timeout, TimeUnit unit) {
  302 + redisTemplate.opsForValue().set(key, value, timeout, unit);
  303 + }
  304 +
  305 + /**
  306 + * 只有在 key 不存在时设置 key 的值
  307 + *
  308 + * @param key key
  309 + * @param value val
  310 + * @return 之前已经存在返回false, 不存在返回true
  311 + */
  312 + public Boolean setIfAbsent(String key, String value) {
  313 + return redisTemplate.opsForValue().setIfAbsent(key, value);
  314 + }
  315 +
  316 +
  317 + /**
  318 + * 用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始
  319 + *
  320 + * @param key key
  321 + * @param value val
  322 + * @param offset 从指定位置开始覆写
  323 + */
  324 + public void setRange(String key, String value, long offset) {
  325 + redisTemplate.opsForValue().set(key, value, offset);
  326 + }
  327 +
  328 + /**
  329 + * 获取字符串的长度
  330 + *
  331 + * @param key key
  332 + */
  333 + public Long size(String key) {
  334 + return redisTemplate.opsForValue().size(key);
  335 + }
  336 +
  337 + /**
  338 + * 批量添加
  339 + */
  340 + public void multiSet(Map<String, String> maps) {
  341 + redisTemplate.opsForValue().multiSet(maps);
  342 + }
  343 +
  344 + /**
  345 + * 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
  346 + *
  347 + * @return 之前已经存在返回false, 不存在返回true
  348 + */
  349 + public Boolean multiSetIfAbsent(Map<String, String> maps) {
  350 + return redisTemplate.opsForValue().multiSetIfAbsent(maps);
  351 + }
  352 +
  353 + /**
  354 + * 增加(自增长), 负数则为自减
  355 + *
  356 + * @param key key
  357 + * @param increment 步长
  358 + */
  359 + public Long incrBy(String key, long increment) {
  360 + return redisTemplate.opsForValue().increment(key, increment);
  361 + }
  362 +
  363 + /**
  364 + * @param key key
  365 + * @param increment 步长
  366 + */
  367 + public Double incrByFloat(String key, double increment) {
  368 + return redisTemplate.opsForValue().increment(key, increment);
  369 + }
  370 +
  371 + /**
  372 + * 增加(自增长), 负数则为自减
  373 + *
  374 + * @param key key redisKey
  375 + * @param decrement 步长
  376 + */
  377 + public Long decreByLong(String key, long decrement) {
  378 + return redisTemplate.opsForValue().decrement(key, decrement);
  379 + }
  380 +
  381 + /**
  382 + * @param key key redisKey
  383 + */
  384 + public Long decreBy(String key) {
  385 + return redisTemplate.opsForValue().decrement(key);
  386 + }
  387 +
  388 + /**
  389 + * 追加到末尾
  390 + *
  391 + * @param key key
  392 + * @param value val
  393 + * @return
  394 + */
  395 + public Integer append(String key, String value) {
  396 + return redisTemplate.opsForValue().append(key, value);
  397 + }
  398 +
  399 + /** -------------------hash相关操作------------------------- */
  400 +
  401 + /**
  402 + * 获取存储在哈希表中指定字段的值
  403 + *
  404 + * @param key key
  405 + * @param field
  406 + * @return
  407 + */
  408 + public Object hGet(String key, String field) {
  409 + return redisTemplate.opsForHash().get(key, field);
  410 + }
  411 +
  412 + /**
  413 + * 获取所有给定字段的值
  414 + *
  415 + * @param key key
  416 + * @return
  417 + */
  418 + public Map<Object, Object> hGetAll(String key) {
  419 + return redisTemplate.opsForHash().entries(key);
  420 + }
  421 +
  422 + /**
  423 + * 获取所有给定字段的值
  424 + *
  425 + * @param key key
  426 + * @param fields
  427 + * @return
  428 + */
  429 + public List<Object> hMultiGet(String key, Collection<Object> fields) {
  430 + return redisTemplate.opsForHash().multiGet(key, fields);
  431 + }
  432 +
  433 + public void hPut(String key, String hashKey, String value) {
  434 + redisTemplate.opsForHash().put(key, hashKey, value);
  435 + }
  436 +
  437 + public void hPutAll(String key, Map<String, String> maps) {
  438 + redisTemplate.opsForHash().putAll(key, maps);
  439 + }
  440 +
  441 + /**
  442 + * 仅当hashKey不存在时才设置
  443 + *
  444 + * @param key key
  445 + * @param hashKey
  446 + * @param value val
  447 + * @return
  448 + */
  449 + public Boolean hPutIfAbsent(String key, String hashKey, String value) {
  450 + return redisTemplate.opsForHash().putIfAbsent(key, hashKey, value);
  451 + }
  452 +
  453 + /**
  454 + * 删除一个或多个哈希表字段
  455 + *
  456 + * @param key key
  457 + * @param fields
  458 + * @return
  459 + */
  460 + public Long hDelete(String key, Object... fields) {
  461 + return redisTemplate.opsForHash().delete(key, fields);
  462 + }
  463 +
  464 + /**
  465 + * 查看哈希表 key 中,指定的字段是否存在
  466 + *
  467 + * @param key key
  468 + * @param field
  469 + * @return
  470 + */
  471 + public Boolean hExists(String key, String field) {
  472 + return redisTemplate.opsForHash().hasKey(key, field);
  473 + }
  474 +
  475 + /**
  476 + * 为哈希表 key 中的指定字段的整数值加上增量 increment
  477 + *
  478 + * @param key key
  479 + * @param field
  480 + * @param increment
  481 + * @return
  482 + */
  483 + public Long hIncrBy(String key, Object field, long increment) {
  484 + return redisTemplate.opsForHash().increment(key, field, increment);
  485 + }
  486 +
  487 + /**
  488 + * 为哈希表 key 中的指定字段的整数值加上增量 increment
  489 + *
  490 + * @param key key
  491 + * @param field
  492 + * @param delta
  493 + * @return
  494 + */
  495 + public Double hIncrByFloat(String key, Object field, double delta) {
  496 + return redisTemplate.opsForHash().increment(key, field, delta);
  497 + }
  498 +
  499 + /**
  500 + * 获取所有哈希表中的字段
  501 + *
  502 + * @param key key
  503 + * @return
  504 + */
  505 + public Set<Object> hKeys(String key) {
  506 + return redisTemplate.opsForHash().keys(key);
  507 + }
  508 +
  509 + /**
  510 + * 获取哈希表中字段的数量
  511 + *
  512 + * @param key key
  513 + * @return
  514 + */
  515 + public Long hSize(String key) {
  516 + return redisTemplate.opsForHash().size(key);
  517 + }
  518 +
  519 + /**
  520 + * 获取哈希表中所有值
  521 + *
  522 + * @param key key
  523 + * @return
  524 + */
  525 + public List<Object> hValues(String key) {
  526 + return redisTemplate.opsForHash().values(key);
  527 + }
  528 +
  529 + /**
  530 + * 迭代哈希表中的键值对
  531 + *
  532 + * @param key key
  533 + * @param options
  534 + * @return
  535 + */
  536 + public Cursor<Map.Entry<Object, Object>> hScan(String key, ScanOptions options) {
  537 + return redisTemplate.opsForHash().scan(key, options);
  538 + }
  539 +
  540 + /** ------------------------list相关操作---------------------------- */
  541 +
  542 + /**
  543 + * 通过索引获取列表中的元素
  544 + *
  545 + * @param key key
  546 + * @param index
  547 + * @return
  548 + */
  549 + public String lIndex(String key, long index) {
  550 + return redisTemplate.opsForList().index(key, index);
  551 + }
  552 +
  553 + /**
  554 + * 获取列表指定范围内的元素
  555 + *
  556 + * @param key key
  557 + * @param start 开始位置, 0是开始位置
  558 + * @param end 结束位置, -1返回所有
  559 + * @return
  560 + */
  561 + public List<String> lRange(String key, long start, long end) {
  562 + return redisTemplate.opsForList().range(key, start, end);
  563 + }
  564 +
  565 + /**
  566 + * 存储在list头部
  567 + *
  568 + * @param key key
  569 + * @param value val
  570 + * @return
  571 + */
  572 + public Long lLeftPush(String key, String value) {
  573 + return redisTemplate.opsForList().leftPush(key, value);
  574 + }
  575 +
  576 + /**
  577 + * @param key key
  578 + * @param value val
  579 + * @return
  580 + */
  581 + public Long lLeftPushAll(String key, String... value) {
  582 + return redisTemplate.opsForList().leftPushAll(key, value);
  583 + }
  584 +
  585 + /**
  586 + * @param key key
  587 + * @param value val
  588 + * @return
  589 + */
  590 + public Long lLeftPushAll(String key, Collection<String> value) {
  591 + return redisTemplate.opsForList().leftPushAll(key, value);
  592 + }
  593 +
  594 + /**
  595 + * 当list存在的时候才加入
  596 + *
  597 + * @param key key
  598 + * @param value val
  599 + * @return
  600 + */
  601 + public Long lLeftPushIfPresent(String key, String value) {
  602 + return redisTemplate.opsForList().leftPushIfPresent(key, value);
  603 + }
  604 +
  605 + /**
  606 + * 如果pivot存在,再pivot前面添加
  607 + *
  608 + * @param key key
  609 + * @param pivot
  610 + * @param value val
  611 + * @return
  612 + */
  613 + public Long lLeftPush(String key, String pivot, String value) {
  614 + return redisTemplate.opsForList().leftPush(key, pivot, value);
  615 + }
  616 +
  617 + /**
  618 + * @param key key
  619 + * @param value val
  620 + * @return
  621 + */
  622 + public Long lRightPush(String key, String value) {
  623 + return redisTemplate.opsForList().rightPush(key, value);
  624 + }
  625 +
  626 + /**
  627 + * @param key key
  628 + * @param value val
  629 + * @return
  630 + */
  631 + public Long lRightPushAll(String key, String... value) {
  632 + return redisTemplate.opsForList().rightPushAll(key, value);
  633 + }
  634 +
  635 + /**
  636 + * @param key key
  637 + * @param value val
  638 + * @return
  639 + */
  640 + public Long lRightPushAll(String key, Collection<String> value) {
  641 + return redisTemplate.opsForList().rightPushAll(key, value);
  642 + }
  643 +
  644 + /**
  645 + * 为已存在的列表添加值
  646 + *
  647 + * @param key key
  648 + * @param value val
  649 + * @return
  650 + */
  651 + public Long lRightPushIfPresent(String key, String value) {
  652 + return redisTemplate.opsForList().rightPushIfPresent(key, value);
  653 + }
  654 +
  655 + /**
  656 + * 在pivot元素的右边添加值
  657 + *
  658 + * @param key key
  659 + * @param pivot
  660 + * @param value val
  661 + * @return
  662 + */
  663 + public Long lRightPush(String key, String pivot, String value) {
  664 + return redisTemplate.opsForList().rightPush(key, pivot, value);
  665 + }
  666 +
  667 + /**
  668 + * 通过索引设置列表元素的值
  669 + *
  670 + * @param key key
  671 + * @param index 位置
  672 + * @param value val
  673 + */
  674 + public void lSet(String key, long index, String value) {
  675 + redisTemplate.opsForList().set(key, index, value);
  676 + }
  677 +
  678 + /**
  679 + * 移出并获取列表的第一个元素
  680 + *
  681 + * @param key key
  682 + * @return 删除的元素
  683 + */
  684 + public String lLeftPop(String key) {
  685 + return redisTemplate.opsForList().leftPop(key);
  686 + }
  687 +
  688 + /**
  689 + * 移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
  690 + *
  691 + * @param key key
  692 + * @param timeout 等待时间
  693 + * @param unit 时间单位
  694 + * @return
  695 + */
  696 + public String lbLeftPop(String key, long timeout, TimeUnit unit) {
  697 + return redisTemplate.opsForList().leftPop(key, timeout, unit);
  698 + }
  699 +
  700 + /**
  701 + * 移除并获取列表最后一个元素
  702 + *
  703 + * @param key key
  704 + * @return 删除的元素
  705 + */
  706 + public String lRightPop(String key) {
  707 + return redisTemplate.opsForList().rightPop(key);
  708 + }
  709 +
  710 + /**
  711 + * 移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
  712 + *
  713 + * @param key key
  714 + * @param timeout 等待时间
  715 + * @param unit 时间单位
  716 + * @return
  717 + */
  718 + public String lbRightPop(String key, long timeout, TimeUnit unit) {
  719 + return redisTemplate.opsForList().rightPop(key, timeout, unit);
  720 + }
  721 +
  722 + /**
  723 + * 移除列表的最后一个元素,并将该元素添加到另一个列表并返回
  724 + *
  725 + * @param sourceKey
  726 + * @param destinationKey
  727 + * @return
  728 + */
  729 + public String lRightPopAndLeftPush(String sourceKey, String destinationKey) {
  730 + return redisTemplate.opsForList().rightPopAndLeftPush(sourceKey, destinationKey);
  731 + }
  732 +
  733 + /**
  734 + * 从列表中弹出一个值,将弹出的元素插入到另外一个列表中并返回它; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
  735 + *
  736 + * @param sourceKey
  737 + * @param destinationKey
  738 + * @param timeout
  739 + * @param unit
  740 + * @return
  741 + */
  742 + public String lbRightPopAndLeftPush(String sourceKey, String destinationKey,
  743 + long timeout, TimeUnit unit) {
  744 + return redisTemplate.opsForList().rightPopAndLeftPush(sourceKey, destinationKey, timeout, unit);
  745 + }
  746 +
  747 + /**
  748 + * 删除集合中值等于value得元素
  749 + *
  750 + * @param key key
  751 + * @param index index=0, 删除所有值等于value的元素; index>0, 从头部开始删除第一个值等于value的元素;
  752 + * index<0, 从尾部开始删除第一个值等于value的元素;
  753 + * @param value val
  754 + * @return
  755 + */
  756 + public Long lRemove(String key, long index, String value) {
  757 + return redisTemplate.opsForList().remove(key, index, value);
  758 + }
  759 +
  760 + /**
  761 + * 裁剪list
  762 + *
  763 + * @param key key
  764 + * @param start
  765 + * @param end
  766 + */
  767 + public void lTrim(String key, long start, long end) {
  768 + redisTemplate.opsForList().trim(key, start, end);
  769 + }
  770 +
  771 + /**
  772 + * 获取列表长度
  773 + *
  774 + * @param key key
  775 + * @return
  776 + */
  777 + public Long lLen(String key) {
  778 + return redisTemplate.opsForList().size(key);
  779 + }
  780 +
  781 + /** --------------------set相关操作-------------------------- */
  782 +
  783 + /**
  784 + * set添加元素
  785 + *
  786 + * @param key key
  787 + * @param values vals
  788 + * @return
  789 + */
  790 + public Long sAdd(String key, String... values) {
  791 + return redisTemplate.opsForSet().add(key, values);
  792 + }
  793 +
  794 + /**
  795 + * set移除元素
  796 + *
  797 + * @param key key
  798 + * @param values vals
  799 + * @return
  800 + */
  801 + public Long sRemove(String key, Object... values) {
  802 + return redisTemplate.opsForSet().remove(key, values);
  803 + }
  804 +
  805 + /**
  806 + * 移除并返回集合的一个随机元素
  807 + *
  808 + * @param key key
  809 + * @return
  810 + */
  811 + public String sPop(String key) {
  812 + return redisTemplate.opsForSet().pop(key);
  813 + }
  814 +
  815 + /**
  816 + * 移除并返回集合的多个随机元素
  817 + *
  818 + * @param key key
  819 + * @return
  820 + */
  821 + public List<String> sPop(String key, int count) {
  822 + return redisTemplate.opsForSet().pop(key, count);
  823 + }
  824 +
  825 + /**
  826 + * 将元素value从一个集合移到另一个集合
  827 + *
  828 + * @param key key
  829 + * @param value val
  830 + * @param destKey
  831 + * @return
  832 + */
  833 + public Boolean sMove(String key, String value, String destKey) {
  834 + return redisTemplate.opsForSet().move(key, value, destKey);
  835 + }
  836 +
  837 + /**
  838 + * 获取集合的大小
  839 + *
  840 + * @param key key
  841 + * @return
  842 + */
  843 + public Long sSize(String key) {
  844 + return redisTemplate.opsForSet().size(key);
  845 + }
  846 +
  847 + /**
  848 + * 判断集合是否包含value
  849 + *
  850 + * @param key key
  851 + * @param value val
  852 + * @return
  853 + */
  854 + public Boolean sIsMember(String key, Object value) {
  855 + return redisTemplate.opsForSet().isMember(key, value);
  856 + }
  857 +
  858 + /**
  859 + * 获取两个集合的交集
  860 + *
  861 + * @param key key
  862 + * @param otherKey
  863 + * @return
  864 + */
  865 + public Set<String> sIntersect(String key, String otherKey) {
  866 + return redisTemplate.opsForSet().intersect(key, otherKey);
  867 + }
  868 +
  869 + /**
  870 + * 获取key集合与多个集合的交集
  871 + *
  872 + * @param key key
  873 + * @param otherKeys
  874 + * @return
  875 + */
  876 + public Set<String> sIntersect(String key, Collection<String> otherKeys) {
  877 + return redisTemplate.opsForSet().intersect(key, otherKeys);
  878 + }
  879 +
  880 + /**
  881 + * key集合与otherKey集合的交集存储到destKey集合中
  882 + *
  883 + * @param key key
  884 + * @param otherKey
  885 + * @param destKey
  886 + * @return
  887 + */
  888 + public Long sIntersectAndStore(String key, String otherKey, String destKey) {
  889 + return redisTemplate.opsForSet().intersectAndStore(key, otherKey, destKey);
  890 + }
  891 +
  892 + /**
  893 + * key集合与多个集合的交集存储到destKey集合中
  894 + *
  895 + * @param key key
  896 + * @param otherKeys
  897 + * @param destKey
  898 + * @return
  899 + */
  900 + public Long sIntersectAndStore(String key, Collection<String> otherKeys, String destKey) {
  901 + return redisTemplate.opsForSet().intersectAndStore(key, otherKeys, destKey);
  902 + }
  903 +
  904 + /**
  905 + * 获取两个集合的并集
  906 + *
  907 + * @param key key
  908 + * @param otherKeys
  909 + * @return
  910 + */
  911 + public Set<String> sUnion(String key, String otherKeys) {
  912 + return redisTemplate.opsForSet().union(key, otherKeys);
  913 + }
  914 +
  915 + /**
  916 + * 获取key集合与多个集合的并集
  917 + *
  918 + * @param key key
  919 + * @param otherKeys
  920 + * @return
  921 + */
  922 + public Set<String> sUnion(String key, Collection<String> otherKeys) {
  923 + return redisTemplate.opsForSet().union(key, otherKeys);
  924 + }
  925 +
  926 + /**
  927 + * key集合与otherKey集合的并集存储到destKey中
  928 + *
  929 + * @param key key
  930 + * @param otherKey
  931 + * @param destKey
  932 + * @return
  933 + */
  934 + public Long sUnionAndStore(String key, String otherKey, String destKey) {
  935 + return redisTemplate.opsForSet().unionAndStore(key, otherKey, destKey);
  936 + }
  937 +
  938 + /**
  939 + * key集合与多个集合的并集存储到destKey中
  940 + *
  941 + * @param key key
  942 + * @param otherKeys
  943 + * @param destKey
  944 + * @return
  945 + */
  946 + public Long sUnionAndStore(String key, Collection<String> otherKeys, String destKey) {
  947 + return redisTemplate.opsForSet().unionAndStore(key, otherKeys, destKey);
  948 + }
  949 +
  950 + /**
  951 + * 获取两个集合的差集
  952 + *
  953 + * @param key key
  954 + * @param otherKey
  955 + * @return
  956 + */
  957 + public Set<String> sDifference(String key, String otherKey) {
  958 + return redisTemplate.opsForSet().difference(key, otherKey);
  959 + }
  960 +
  961 + /**
  962 + * 获取key集合与多个集合的差集
  963 + *
  964 + * @param key key
  965 + * @param otherKeys
  966 + * @return
  967 + */
  968 + public Set<String> sDifference(String key, Collection<String> otherKeys) {
  969 + return redisTemplate.opsForSet().difference(key, otherKeys);
  970 + }
  971 +
  972 + /**
  973 + * key集合与otherKey集合的差集存储到destKey中
  974 + *
  975 + * @param key key
  976 + * @param otherKey
  977 + * @param destKey
  978 + * @return
  979 + */
  980 + public Long sDifference(String key, String otherKey, String destKey) {
  981 + return redisTemplate.opsForSet().differenceAndStore(key, otherKey, destKey);
  982 + }
  983 +
  984 + /**
  985 + * key集合与多个集合的差集存储到destKey中
  986 + *
  987 + * @param key key
  988 + * @param otherKeys
  989 + * @param destKey
  990 + * @return
  991 + */
  992 + public Long sDifference(String key, Collection<String> otherKeys, String destKey) {
  993 + return redisTemplate.opsForSet().differenceAndStore(key, otherKeys, destKey);
  994 + }
  995 +
  996 + /**
  997 + * 获取集合所有元素
  998 + *
  999 + * @param key key
  1000 + * @param
  1001 + * @param
  1002 + * @return
  1003 + */
  1004 + public Set<String> setMembers(String key) {
  1005 + return redisTemplate.opsForSet().members(key);
  1006 + }
  1007 +
  1008 + /**
  1009 + * 随机获取集合中的一个元素
  1010 + *
  1011 + * @param key key
  1012 + * @return
  1013 + */
  1014 + public String sRandomMember(String key) {
  1015 + return redisTemplate.opsForSet().randomMember(key);
  1016 + }
  1017 +
  1018 + /**
  1019 + * 随机获取集合中count个元素
  1020 + *
  1021 + * @param key key
  1022 + * @param count
  1023 + * @return
  1024 + */
  1025 + public List<String> sRandomMembers(String key, long count) {
  1026 + return redisTemplate.opsForSet().randomMembers(key, count);
  1027 + }
  1028 +
  1029 + /**
  1030 + * 随机获取集合中count个元素并且去除重复的
  1031 + *
  1032 + * @param key key
  1033 + * @param count
  1034 + * @return
  1035 + */
  1036 + public Set<String> sDistinctRandomMembers(String key, long count) {
  1037 + return redisTemplate.opsForSet().distinctRandomMembers(key, count);
  1038 + }
  1039 +
  1040 + /**
  1041 + * @param key key
  1042 + * @param options
  1043 + * @return
  1044 + */
  1045 + public Cursor<String> sScan(String key, ScanOptions options) {
  1046 + return redisTemplate.opsForSet().scan(key, options);
  1047 + }
  1048 +
  1049 + /**------------------zSet相关操作--------------------------------*/
  1050 +
  1051 + /**
  1052 + * 添加元素,有序集合是按照元素的score值由小到大排列
  1053 + *
  1054 + * @param key key
  1055 + * @param value val
  1056 + * @param score
  1057 + * @return
  1058 + */
  1059 + public Boolean zAdd(String key, String value, double score) {
  1060 + return redisTemplate.opsForZSet().add(key, value, score);
  1061 + }
  1062 +
  1063 + /**
  1064 + * @param key key
  1065 + * @param values val
  1066 + * @return
  1067 + */
  1068 + public Long zAdd(String key, Set<ZSetOperations.TypedTuple<String>> values) {
  1069 + return redisTemplate.opsForZSet().add(key, values);
  1070 + }
  1071 +
  1072 + /**
  1073 + * @param key key
  1074 + * @param values val
  1075 + * @return 已删除元素的数量
  1076 + */
  1077 + public Long zRemove(String key, Object... values) {
  1078 + return redisTemplate.opsForZSet().remove(key, values);
  1079 + }
  1080 +
  1081 + /**
  1082 + * 增加元素的score值,并返回增加后的值
  1083 + *
  1084 + * @param key key
  1085 + * @param value val
  1086 + * @param delta 分数值
  1087 + * @return 增加后的值
  1088 + */
  1089 + public Double zIncrementScore(String key, String value, double delta) {
  1090 + return redisTemplate.opsForZSet().incrementScore(key, value, delta);
  1091 + }
  1092 +
  1093 + /**
  1094 + * 返回元素在集合的排名,有序集合是按照元素的score值由小到大排列
  1095 + *
  1096 + * @param key key
  1097 + * @param value val
  1098 + * @return 0表示第一位
  1099 + */
  1100 + public Long zRank(String key, Object value) {
  1101 + return redisTemplate.opsForZSet().rank(key, value);
  1102 +
  1103 + }
  1104 +
  1105 + /**
  1106 + * 返回元素在集合的排名,按元素的score值由大到小排列
  1107 + *
  1108 + * @param key key
  1109 + * @param value val
  1110 + */
  1111 + public Long zReverseRank(String key, Object value) {
  1112 + return redisTemplate.opsForZSet().reverseRank(key, value);
  1113 + }
  1114 +
  1115 + /**
  1116 + * 获取集合的元素, 从小到大排序
  1117 + *
  1118 + * @param key key
  1119 + * @param start 开始位置
  1120 + * @param end 结束位置, -1查询所有
  1121 + */
  1122 + public Set<String> zRange(String key, long start, long end) {
  1123 + return redisTemplate.opsForZSet().range(key, start, end);
  1124 + }
  1125 +
  1126 + /**
  1127 + * 获取集合元素, 并且把score值也获取
  1128 + *
  1129 + * @param key key
  1130 + * @param start
  1131 + * @param end
  1132 + * @return
  1133 + */
  1134 + public Set<ZSetOperations.TypedTuple<String>> zRangeWithScores(String key, long start, long end) {
  1135 + return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
  1136 + }
  1137 +
  1138 + /**
  1139 + * 根据Score值查询集合元素
  1140 + *
  1141 + * @param key key
  1142 + * @param min 最小值
  1143 + * @param max 最大值
  1144 + * @return
  1145 + */
  1146 + public Set<String> zRangeByScore(String key, double min, double max) {
  1147 + return redisTemplate.opsForZSet().rangeByScore(key, min, max);
  1148 + }
  1149 +
  1150 + /**
  1151 + * 根据Score值查询集合元素, 从小到大排序
  1152 + *
  1153 + * @param key key
  1154 + * @param min 最小值
  1155 + * @param max 最大值
  1156 + * @return
  1157 + */
  1158 + public Set<ZSetOperations.TypedTuple<String>> zRangeByScoreWithScores(String key,
  1159 + double min, double max) {
  1160 + return redisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max);
  1161 + }
  1162 +
  1163 + /**
  1164 + * @param key key
  1165 + * @param min
  1166 + * @param max
  1167 + * @param start
  1168 + * @param end
  1169 + * @return
  1170 + */
  1171 + public Set<ZSetOperations.TypedTuple<String>> zRangeByScoreWithScores(String key, double min, double max, long start, long end) {
  1172 + return redisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max, start, end);
  1173 + }
  1174 +
  1175 + /**
  1176 + * 获取集合的元素, 从大到小排序
  1177 + *
  1178 + * @param key key
  1179 + * @param start
  1180 + * @param end
  1181 + * @return
  1182 + */
  1183 + public Set<String> zReverseRange(String key, long start, long end) {
  1184 + return redisTemplate.opsForZSet().reverseRange(key, start, end);
  1185 + }
  1186 +
  1187 + /**
  1188 + * 获取集合的元素, 从大到小排序, 并返回score值
  1189 + *
  1190 + * @param key key
  1191 + * @param start
  1192 + * @param end
  1193 + * @return
  1194 + */
  1195 + public Set<ZSetOperations.TypedTuple<String>> zReverseRangeWithScores(String key,
  1196 + long start, long end) {
  1197 + return redisTemplate.opsForZSet().reverseRangeWithScores(key, start, end);
  1198 + }
  1199 +
  1200 + /**
  1201 + * 根据Score值查询集合元素, 从大到小排序
  1202 + *
  1203 + * @param key key
  1204 + * @param min
  1205 + * @param max
  1206 + * @return
  1207 + */
  1208 + public Set<String> zReverseRangeByScore(String key, double min, double max) {
  1209 + return redisTemplate.opsForZSet().reverseRangeByScore(key, min, max);
  1210 + }
  1211 +
  1212 + /**
  1213 + * 根据Score值查询集合元素, 从大到小排序
  1214 + *
  1215 + * @param key key
  1216 + * @param min
  1217 + * @param max
  1218 + * @return
  1219 + */
  1220 + public Set<ZSetOperations.TypedTuple<String>> zReverseRangeByScoreWithScores(String key, double min, double max) {
  1221 + return redisTemplate.opsForZSet().reverseRangeByScoreWithScores(key, min, max);
  1222 + }
  1223 +
  1224 + /**
  1225 + * @param key key
  1226 + * @param min
  1227 + * @param max
  1228 + * @param start
  1229 + * @param end
  1230 + * @return
  1231 + */
  1232 + public Set<String> zReverseRangeByScore(String key, double min,
  1233 + double max, long start, long end) {
  1234 + return redisTemplate.opsForZSet().reverseRangeByScore(key, min, max, start, end);
  1235 + }
  1236 +
  1237 + /**
  1238 + * 根据score值获取集合元素数量
  1239 + *
  1240 + * @param key key
  1241 + * @param min
  1242 + * @param max
  1243 + * @return
  1244 + */
  1245 + public Long zCount(String key, double min, double max) {
  1246 + return redisTemplate.opsForZSet().count(key, min, max);
  1247 + }
  1248 +
  1249 + /**
  1250 + * 获取集合大小
  1251 + *
  1252 + * @param key key
  1253 + * @return
  1254 + */
  1255 + public Long zSize(String key) {
  1256 + return redisTemplate.opsForZSet().size(key);
  1257 + }
  1258 +
  1259 + /**
  1260 + * 获取集合大小
  1261 + *
  1262 + * @param key key
  1263 + * @return
  1264 + */
  1265 + public Long zzCard(String key) {
  1266 + return redisTemplate.opsForZSet().zCard(key);
  1267 + }
  1268 +
  1269 + /**
  1270 + * 获取集合中value元素的score值
  1271 + *
  1272 + * @param key key
  1273 + * @param value val
  1274 + * @return
  1275 + */
  1276 + public Double zScore(String key, Object value) {
  1277 + return redisTemplate.opsForZSet().score(key, value);
  1278 + }
  1279 +
  1280 + /**
  1281 + * 移除指定索引位置的成员
  1282 + *
  1283 + * @param key key
  1284 + * @param start
  1285 + * @param end
  1286 + * @return
  1287 + */
  1288 + public Long zRemoveRange(String key, long start, long end) {
  1289 + return redisTemplate.opsForZSet().removeRange(key, start, end);
  1290 + }
  1291 +
  1292 + /**
  1293 + * 根据指定的score值的范围来移除成员
  1294 + *
  1295 + * @param key key
  1296 + * @param min
  1297 + * @param max
  1298 + * @return
  1299 + */
  1300 + public Long zRemoveRangeByScore(String key, double min, double max) {
  1301 + return redisTemplate.opsForZSet().removeRangeByScore(key, min, max);
  1302 + }
  1303 +
  1304 + /**
  1305 + * 获取key和otherKey的并集并存储在destKey中
  1306 + *
  1307 + * @param key key
  1308 + * @param otherKey
  1309 + * @param destKey
  1310 + * @return
  1311 + */
  1312 + public Long zUnionAndStore(String key, String otherKey, String destKey) {
  1313 + return redisTemplate.opsForZSet().unionAndStore(key, otherKey, destKey);
  1314 + }
  1315 +
  1316 + /**
  1317 + * @param key key
  1318 + * @param otherKeys
  1319 + * @param destKey
  1320 + * @return
  1321 + */
  1322 + public Long zUnionAndStore(String key, Collection<String> otherKeys, String destKey) {
  1323 + return redisTemplate.opsForZSet().unionAndStore(key, otherKeys, destKey);
  1324 + }
  1325 +
  1326 + /**
  1327 + * 交集
  1328 + *
  1329 + * @param key key
  1330 + * @param otherKey
  1331 + * @param destKey
  1332 + * @return
  1333 + */
  1334 + public Long zIntersectAndStore(String key, String otherKey, String destKey) {
  1335 + return redisTemplate.opsForZSet().intersectAndStore(key, otherKey, destKey);
  1336 + }
  1337 +
  1338 + /**
  1339 + * 交集
  1340 + *
  1341 + * @param key key
  1342 + * @param otherKeys
  1343 + * @param destKey
  1344 + * @return
  1345 + */
  1346 + public Long zIntersectAndStore(String key, Collection<String> otherKeys, String destKey) {
  1347 + return redisTemplate.opsForZSet().intersectAndStore(key, otherKeys, destKey);
  1348 + }
  1349 +
  1350 + /**
  1351 + * @param key key
  1352 + * @param options
  1353 + * @return
  1354 + */
  1355 + public Cursor<ZSetOperations.TypedTuple<String>> zScan(String key, ScanOptions options) {
  1356 + return redisTemplate.opsForZSet().scan(key, options);
  1357 + }
  1358 +
  1359 + /* -------------------锁相关操作--------------------- */
  1360 +
  1361 +
  1362 + /**
  1363 + * 获得锁
  1364 + */
  1365 + public boolean getLock(String lockId, String value, long millisecond) {
  1366 + Boolean success = redisTemplate.opsForValue().setIfAbsent(lockId, value, millisecond, TimeUnit.MILLISECONDS);
  1367 + return success != null && success;
  1368 + }
  1369 +
  1370 + /**
  1371 + * 获得锁,并自旋,返回
  1372 + */
  1373 + public boolean getLock(String lockId, String value, long millisecond, long timeout) {
  1374 + long start = System.currentTimeMillis();
  1375 + do {
  1376 + boolean success = getLock(lockId, value, millisecond);
  1377 + if (success) {
  1378 + return true;
  1379 + }
  1380 + try {
  1381 + Thread.sleep(100);
  1382 + } catch (InterruptedException e) {
  1383 + e.printStackTrace();
  1384 + }
  1385 + } while (System.currentTimeMillis() - start < timeout);
  1386 + return false;
  1387 + }
  1388 +
  1389 + /**
  1390 + * 释放锁
  1391 + */
  1392 + public void releaseLock(String id, String lockValue) {
  1393 + if (StringUtils.isNotEmpty(lockValue) && lockValue.equals(this.get(id))) {
  1394 + log.debug("RedisUtil releaseLock, key: {}, value: {}", id, lockValue);
  1395 + redisTemplate.delete(id);
  1396 + }
  1397 + }
  1398 +
  1399 + /* -------------------HyperLogLog相关操作--------------------- */
  1400 +
  1401 + /**
  1402 + * HyperLogLog 添加元素
  1403 + * <p> key不存在则新增
  1404 + *
  1405 + * @param key key
  1406 + * @param value value集合
  1407 + * @return true表示加入成功
  1408 + * @author A80080
  1409 + * @createDate 2021/3/26
  1410 + */
  1411 + public boolean pfAdd(String key, String... value) {
  1412 + return redisTemplate.opsForHyperLogLog().add(key, value) == 1;
  1413 + }
  1414 +
  1415 + /**
  1416 + * HyperLogLog 统计key中元素个数
  1417 + * <p> key 不存在则返回0
  1418 + *
  1419 + * @param key key
  1420 + * @return key中数据大小(基数统计存在误差)
  1421 + * @author A80080
  1422 + * @createDate 2021/3/26
  1423 + */
  1424 + public Long pfCount(String key) {
  1425 + return redisTemplate.opsForHyperLogLog().size(key);
  1426 + }
  1427 +
  1428 + /**
  1429 + * 合并HyperLogLog key,并统计新key元素个数
  1430 + * <p>不删除参与合并的key; 新key不存在则新增,
  1431 + *
  1432 + * @param destination 合并后的key名称
  1433 + * @param sourceKeys 参与合并的key
  1434 + * @return 合并后的key元素个数
  1435 + * @author A80080
  1436 + * @createDate 2021/3/26
  1437 + */
  1438 + public Long pfMerge(String destination, String... sourceKeys) {
  1439 + return redisTemplate.opsForHyperLogLog().union(destination, sourceKeys);
  1440 + }
  1441 +
  1442 +
  1443 +}
0 \ No newline at end of file 1444 \ No newline at end of file
src/main/java/com/order/erp/common/utils/RequestStringUtils.java
1 package com.order.erp.common.utils; 1 package com.order.erp.common.utils;
2 2
3 import cn.hutool.core.io.resource.ClassPathResource; 3 import cn.hutool.core.io.resource.ClassPathResource;
4 -import com.canrd.shop.common.constant.ElAdminConstant; 4 +import com.order.erp.common.constant.ElAdminConstant;
5 import eu.bitwalker.useragentutils.Browser; 5 import eu.bitwalker.useragentutils.Browser;
6 import eu.bitwalker.useragentutils.UserAgent; 6 import eu.bitwalker.useragentutils.UserAgent;
7 import org.lionsoul.ip2region.DataBlock; 7 import org.lionsoul.ip2region.DataBlock;
src/main/java/com/order/erp/common/utils/ServletUtils.java
1 package com.order.erp.common.utils; 1 package com.order.erp.common.utils;
2 2
3 -import com.canrd.shop.common.constant.ServerResult; 3 +import com.order.erp.common.constant.ServerResult;
4 import lombok.extern.slf4j.Slf4j; 4 import lombok.extern.slf4j.Slf4j;
5 import org.springframework.http.HttpStatus; 5 import org.springframework.http.HttpStatus;
6 6
@@ -14,31 +14,27 @@ import java.io.IOException; @@ -14,31 +14,27 @@ import java.io.IOException;
14 public class ServletUtils { 14 public class ServletUtils {
15 15
16 16
17 - public static void renderServerResult(HttpServletResponse response, ServerResult serverResult, HttpStatus httpStatus)  
18 - {  
19 - try  
20 - { 17 + public static void renderServerResult(HttpServletResponse response, ServerResult serverResult, HttpStatus httpStatus) {
  18 + try {
21 response.setStatus(httpStatus.value()); 19 response.setStatus(httpStatus.value());
22 response.setContentType("application/json"); 20 response.setContentType("application/json");
23 response.setCharacterEncoding("utf-8"); 21 response.setCharacterEncoding("utf-8");
24 response.getWriter().print(JsonUtil.toJsonString(serverResult)); 22 response.getWriter().print(JsonUtil.toJsonString(serverResult));
25 - }  
26 - catch (IOException e)  
27 - {  
28 - log.error("ServletUtils#renderServerResult:",e); 23 + } catch (IOException e) {
  24 + log.error("ServletUtils#renderServerResult:", e);
29 } 25 }
30 } 26 }
31 27
32 28
33 - public static void renderExcelFileNotFound(HttpServletResponse response){ 29 + public static void renderExcelFileNotFound(HttpServletResponse response) {
34 try { 30 try {
35 response.setStatus(404); 31 response.setStatus(404);
36 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); 32 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
37 //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 33 //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
38 response.setHeader("Content-Disposition", "attachment;filename=file.xlsx"); 34 response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
39 - response.sendError(HttpStatus.NOT_FOUND.value(),"下载失败,资源不存在");  
40 - }catch (IOException e){  
41 - log.error("ServletUtils#renderWithResourceNotFound:",e); 35 + response.sendError(HttpStatus.NOT_FOUND.value(), "下载失败,资源不存在");
  36 + } catch (IOException e) {
  37 + log.error("ServletUtils#renderWithResourceNotFound:", e);
42 } 38 }
43 } 39 }
44 } 40 }
src/main/java/com/order/erp/common/utils/SmsUtils.java 0 → 100644
  1 +package com.order.erp.common.utils;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.aliyuncs.CommonRequest;
  5 +import com.aliyuncs.CommonResponse;
  6 +import com.aliyuncs.DefaultAcsClient;
  7 +import com.aliyuncs.IAcsClient;
  8 +import com.aliyuncs.http.MethodType;
  9 +import com.aliyuncs.profile.DefaultProfile;
  10 +import com.canrd.shop.common.constant.ServerResultCode;
  11 +import com.google.common.collect.Maps;
  12 +import com.order.erp.common.constant.Constant;
  13 +import com.order.erp.common.constant.ServerResult;
  14 +import com.order.erp.common.exception.BusinessException;
  15 +import com.order.erp.domain.vo.CaptchaMessageVO;
  16 +import lombok.extern.slf4j.Slf4j;
  17 +import org.springframework.beans.factory.annotation.Value;
  18 +import org.springframework.stereotype.Service;
  19 +
  20 +import javax.annotation.Resource;
  21 +import java.time.LocalDateTime;
  22 +import java.util.*;
  23 +import java.util.concurrent.TimeUnit;
  24 +
  25 +
  26 +@Slf4j
  27 +@Service
  28 +public class SmsUtils {
  29 +
  30 +
  31 + @Value("${outsys.sms.regionId}")
  32 + private String regionId;
  33 +
  34 + @Value("${outsys.sms.accessKeyId}")
  35 + private String accessKeyId;
  36 +
  37 + @Value("${outsys.sms.secret}")
  38 + private String secret;
  39 +
  40 + @Value("${outsys.sms.domain}")
  41 + private String domain;
  42 +
  43 + @Value("${outsys.sms.version}")
  44 + private String version;
  45 +
  46 + @Value("${outsys.sms.action}")
  47 + private String action;
  48 +
  49 + @Value("${outsys.sms.signName}")
  50 + private String signName;
  51 +
  52 + @Value("${outsys.sms.templateCode}")
  53 + private String templateCode;
  54 +
  55 + @Resource
  56 + private RedisUtil redisUtil;
  57 +
  58 + @Resource
  59 + private ImgCaptchaUtils imgCaptchaUtils;
  60 +
  61 + /**
  62 + * 短信验证码前缀 + 手机号码
  63 + * 1分钟有效
  64 + */
  65 + private static String SMS_CODE_KEY_PRE = "SMS_CODE_%s";
  66 +
  67 +
  68 + /**
  69 + * 发送短信验证码
  70 + *
  71 + * @param captchaMessageVO
  72 + * @return
  73 + */
  74 + public ServerResult sendCaptchaCode(CaptchaMessageVO captchaMessageVO) {
  75 + String phone = captchaMessageVO.getPhone();
  76 +
  77 + imgCaptchaUtils.validateImgCaptcha(captchaMessageVO.getImgCaptchaCode(), captchaMessageVO.getImgCaptchaUuid());
  78 +
  79 + if (checkLimitMobileSendCount(phone)) {
  80 + return ServerResult.fail(ServerResultCode.SMS_SEND_OVER_LIMIT_ERROR);
  81 + }
  82 + String captchaCode = getCaptchaCode(phone);
  83 + ServerResult serverResult = send(buildSmsMessageVO(phone, captchaCode));
  84 + if (serverResult.checkNotSuccess()) {
  85 + return serverResult;
  86 + }
  87 + setSmsCaptchaCode(phone, captchaCode);
  88 + return serverResult;
  89 + }
  90 +
  91 + /**
  92 + * 获取发送的短信验证码
  93 + *
  94 + * @param phone
  95 + * @param captchaCode
  96 + * @return
  97 + */
  98 + private void setSmsCaptchaCode(String phone, String captchaCode) {
  99 + redisUtil.set(String.format(SMS_CODE_KEY_PRE, phone), captchaCode, 1L, TimeUnit.MINUTES);
  100 + }
  101 +
  102 + /**
  103 + * 获取发送的短信验证码
  104 + *
  105 + * @param phone
  106 + * @return
  107 + */
  108 + private String getSmsCaptchaCode(String phone) {
  109 + return redisUtil.get(String.format(SMS_CODE_KEY_PRE, phone));
  110 + }
  111 +
  112 + /**
  113 + * @param phone
  114 + */
  115 + private void deleteSmsCaptchaCode(String phone) {
  116 + redisUtil.delete(String.format(SMS_CODE_KEY_PRE, phone));
  117 + }
  118 +
  119 + /**
  120 + * @param phone
  121 + * @param smsCaptchaCode
  122 + */
  123 + public void validateSmsCaptcha(String phone, String smsCaptchaCode) {
  124 + // 查询验证码
  125 + String code = getSmsCaptchaCode(phone);
  126 + // 清除验证码
  127 + deleteSmsCaptchaCode(phone);
  128 + if (StringUtils.isBlank(code)) {
  129 + throw new BusinessException(ServerResultCode.SMS_CAPTCHA_ERROR);
  130 + }
  131 + if (StringUtils.isBlank(smsCaptchaCode) || !smsCaptchaCode.equalsIgnoreCase(code)) {
  132 + throw new BusinessException(ServerResultCode.SMS_CAPTCHA_EXPIRE_ERROR);
  133 + }
  134 + }
  135 +
  136 + /**
  137 + * @param phone
  138 + * @param smsCaptchaCode
  139 + */
  140 + public boolean validateSmsCaptchaV2(String phone, String smsCaptchaCode) {
  141 + // 查询验证码
  142 + String code = getSmsCaptchaCode(phone);
  143 + // 清除验证码
  144 + deleteSmsCaptchaCode(phone);
  145 + if (StringUtils.isBlank(code)) {
  146 + return false;
  147 + }
  148 + if (StringUtils.isBlank(smsCaptchaCode) || !smsCaptchaCode.equalsIgnoreCase(code)) {
  149 + return false;
  150 + }
  151 + return true;
  152 + }
  153 +
  154 + /**
  155 + * @param phone
  156 + * @param captchaCode
  157 + * @return
  158 + */
  159 + private CommonRequest buildSmsMessageVO(String phone, String captchaCode) {
  160 + CommonRequest request = new CommonRequest();
  161 + request.setMethod(MethodType.POST);
  162 + request.setDomain(domain);
  163 + request.setVersion(version);
  164 + request.setAction(action);
  165 + request.putQueryParameter("RegionId", regionId);
  166 + StringBuilder builder = new StringBuilder();
  167 + int index = 0;
  168 + List<String> phoneNumbers = Arrays.asList(phone);
  169 + for (String phoneNumber : phoneNumbers) {
  170 + builder.append(phoneNumber + ((index++ < phoneNumbers.size() - 1) ? "," : ""));
  171 + }
  172 + request.putQueryParameter("PhoneNumbers", builder.toString());
  173 + request.putQueryParameter("SignName", signName);
  174 + request.putQueryParameter("TemplateCode", templateCode);
  175 + Map<String, String> templateParam = Maps.newHashMap();
  176 + templateParam.put("code", captchaCode);
  177 + String templateParamJson = JSONObject.toJSONString(templateParam);
  178 + request.putQueryParameter("TemplateParam", templateParamJson);
  179 + log.info("开始发送短信,手机号 {},captchaCode:{}", phone, captchaCode);
  180 + return request;
  181 + }
  182 +
  183 +
  184 + /**
  185 + * 限制一分钟最多发送两次短信
  186 + *
  187 + * @param mobile
  188 + * @return
  189 + */
  190 + private boolean checkLimitMobileSendCount(String mobile) {
  191 + String dateTime = DateUtils.format(LocalDateTime.now(), DateUtils.DATE_TIME_WITHOUT_SECONDS);
  192 +
  193 + String key = "msg:" + mobile + Constant.COLON_CHARACTER + dateTime;
  194 +
  195 + Long count = redisUtil.incrBy(key, Constant.ONE);
  196 + return Objects.nonNull(count) && count > Constant.TWO ? true : false;
  197 + }
  198 +
  199 + /**
  200 + * 生成验证码
  201 + *
  202 + * @param phone
  203 + * @return
  204 + */
  205 + public String getCaptchaCode(String phone) {
  206 + String src = phone + DateUtils.format(new Date(), DateUtils.YYMMDDHHMMSS);
  207 + String code = Math.abs(src.hashCode()) + "";
  208 + if (code.length() >= 4) {
  209 + return code.substring(code.length() - 4, code.length());
  210 + } else {
  211 + StringBuilder buf = new StringBuilder(code);
  212 + while (buf.length() < 4) {
  213 + buf.insert(0, "0");
  214 + }
  215 + return buf.toString();
  216 + }
  217 + }
  218 +
  219 +
  220 + /**
  221 + * @param request
  222 + * @return
  223 + */
  224 + public ServerResult send(CommonRequest request) {
  225 + DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, secret);
  226 + IAcsClient client = new DefaultAcsClient(profile);
  227 +
  228 + try {
  229 + CommonResponse response = client.getCommonResponse(request);
  230 + log.info("短信发送,结果 {}", response.getData());
  231 + } catch (Exception e) {
  232 + log.error("短信发送异常:", e);
  233 + return ServerResult.fail("短信发送异常:" + e);
  234 + }
  235 +
  236 + return ServerResult.success();
  237 + }
  238 +
  239 +}
src/main/java/com/order/erp/common/utils/StringUtils.java
1 package com.order.erp.common.utils; 1 package com.order.erp.common.utils;
2 2
3 -import com.canrd.shop.common.constant.Constant; 3 +import com.order.erp.common.constant.Constant;
4 import lombok.extern.slf4j.Slf4j; 4 import lombok.extern.slf4j.Slf4j;
5 import org.springframework.util.CollectionUtils; 5 import org.springframework.util.CollectionUtils;
6 6
src/main/java/com/order/erp/common/utils/ThrowableUtil.java
1 package com.order.erp.common.utils; 1 package com.order.erp.common.utils;
2 2
3 3
4 -import com.canrd.shop.common.exception.BadRequestException; 4 +import com.order.erp.common.exception.BusinessException;
5 5
6 import javax.validation.ConstraintViolationException; 6 import javax.validation.ConstraintViolationException;
7 import java.io.PrintWriter; 7 import java.io.PrintWriter;
@@ -29,9 +29,9 @@ public class ThrowableUtil { @@ -29,9 +29,9 @@ public class ThrowableUtil {
29 t = t.getCause(); 29 t = t.getCause();
30 } 30 }
31 if (t != null) { 31 if (t != null) {
32 - throw new BadRequestException(msg); 32 + throw new BusinessException(msg);
33 } 33 }
34 assert false; 34 assert false;
35 - throw new BadRequestException("删除失败:" + t.getMessage()); 35 + throw new BusinessException("删除失败:" + t.getMessage());
36 } 36 }
37 } 37 }
src/main/java/com/order/erp/controller/CaptchaController.java 0 → 100644
  1 +package com.order.erp.controller;
  2 +
  3 +import com.order.erp.common.annotation.AnonymousAccess;
  4 +import com.order.erp.common.constant.ServerResult;
  5 +import com.order.erp.common.utils.ImgCaptchaUtils;
  6 +import com.order.erp.common.utils.SmsUtils;
  7 +import com.order.erp.domain.vo.CaptchaMessageVO;
  8 +import com.wf.captcha.ArithmeticCaptcha;
  9 +import org.springframework.validation.annotation.Validated;
  10 +import org.springframework.web.bind.annotation.PostMapping;
  11 +import org.springframework.web.bind.annotation.RequestBody;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import javax.annotation.Resource;
  16 +import java.util.HashMap;
  17 +import java.util.Map;
  18 +
  19 +/**
  20 + * (Member)验证码
  21 + *
  22 + * @author makejava
  23 + * @since 2023-08-22 17:02:39
  24 + */
  25 +@RestController
  26 +@RequestMapping("/order/erp/captcha")
  27 +public class CaptchaController {
  28 +
  29 + @Resource
  30 + private SmsUtils smsUtils;
  31 +
  32 + @Resource
  33 + private ImgCaptchaUtils imgCaptchaUtils;
  34 +
  35 + /**
  36 + * 获取验证码
  37 + *
  38 + * @param msgVo 查询条件
  39 + * @return 查询结果
  40 + */
  41 + @AnonymousAccess
  42 + @PostMapping("/send_captcha_code")
  43 + public ServerResult sendCaptchaCode(@RequestBody @Validated CaptchaMessageVO msgVo) {
  44 + return smsUtils.sendCaptchaCode(msgVo);
  45 + }
  46 +
  47 + /**
  48 + * 获取图片验证码
  49 + *
  50 + * @return 查询结果
  51 + */
  52 + @AnonymousAccess
  53 + @PostMapping("/get_img_captcha_code")
  54 + public ServerResult getImgCaptchaCode() {
  55 + // 算术类型 https://gitee.com/whvse/EasyCaptcha
  56 + ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36);
  57 + // 几位数运算,默认是两位
  58 + captcha.setLen(2);
  59 + // 获取运算的结果
  60 + String result = captcha.text();
  61 + String uuid = imgCaptchaUtils.setImgCaptcha4uuid(result);
  62 + // 验证码信息
  63 + Map<String, Object> imgResult = new HashMap<String, Object>(2) {{
  64 + put("img", captcha.toBase64());
  65 + put("uuid", uuid);
  66 + }};
  67 + return ServerResult.success(imgResult);
  68 + }
  69 +}
  70 +
src/main/java/com/order/erp/controller/TestController.java deleted 100644 → 0
1 -package com.order.erp.controller;  
2 -  
3 -import com.canrd.shop.common.annotation.AnonymousAccess;  
4 -import com.canrd.shop.common.constant.ServerResult;  
5 -import com.canrd.shop.domain.vo.TestQueryVO;  
6 -import com.canrd.shop.domain.vo.TestVO;  
7 -import com.canrd.shop.service.TestService;  
8 -import lombok.extern.slf4j.Slf4j;  
9 -import org.springframework.web.bind.annotation.PostMapping;  
10 -import org.springframework.web.bind.annotation.RequestBody;  
11 -import org.springframework.web.bind.annotation.RequestMapping;  
12 -import org.springframework.web.bind.annotation.RestController;  
13 -  
14 -import javax.annotation.Resource;  
15 -  
16 -/**  
17 - * @projectName: canrd-services  
18 - * @package: com.canrd.shop.controller  
19 - * @className: TestController  
20 - * @author: xms  
21 - * @description: TODO  
22 - * @date: 2023/3/29 18:53  
23 - * @version: 1.0  
24 - */  
25 -  
26 -@RestController  
27 -@RequestMapping("/admin/shop/test")  
28 -@Slf4j  
29 -public class TestController {  
30 -  
31 - @Resource  
32 - private TestService testService;  
33 -  
34 - /**  
35 - * @param queryVO  
36 - * @return  
37 - */  
38 - @AnonymousAccess  
39 - @PostMapping("/demo")  
40 - public ServerResult demo(@RequestBody TestQueryVO queryVO) {  
41 - log.info("查询用户列表:{}", queryVO);  
42 - return ServerResult.success(testService.pageList(queryVO));  
43 - }  
44 -  
45 -  
46 - /**  
47 - * @param testVO  
48 - * @return  
49 - */  
50 - @PostMapping("/add")  
51 - public ServerResult add(@RequestBody TestVO testVO) {  
52 - log.info("新增用户列表:{}", testVO);  
53 - testService.add(testVO);  
54 - return ServerResult.success();  
55 - }  
56 -}  
src/main/java/com/order/erp/domain/dto/CompanyDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.NoArgsConstructor;  
8 -import lombok.experimental.SuperBuilder;  
9 -  
10 -import java.io.Serializable;  
11 -  
12 -/**  
13 - * @author: xms  
14 - * @description: 公司  
15 - * @date: 2023/3/30 15:36  
16 - * @version: 1.0  
17 - */  
18 -  
19 -@Data  
20 -@EqualsAndHashCode(callSuper = true)  
21 -@SuperBuilder(toBuilder = true)  
22 -@AllArgsConstructor  
23 -@NoArgsConstructor  
24 -@TableName("company")  
25 -public class CompanyDO extends BaseDO implements Serializable {  
26 -  
27 - private Long id;  
28 -  
29 - /**  
30 - * 公司编码  
31 - */  
32 - private String code;  
33 -  
34 - /**  
35 - * 公司名称  
36 - */  
37 - private String name;  
38 -}  
src/main/java/com/order/erp/domain/dto/DeptDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableField;  
4 -import com.baomidou.mybatisplus.annotation.TableName;  
5 -import com.fasterxml.jackson.annotation.JsonIgnore;  
6 -import lombok.AllArgsConstructor;  
7 -import lombok.Data;  
8 -import lombok.EqualsAndHashCode;  
9 -import lombok.NoArgsConstructor;  
10 -import lombok.experimental.SuperBuilder;  
11 -  
12 -import javax.validation.constraints.NotBlank;  
13 -import javax.validation.constraints.NotNull;  
14 -import java.io.Serializable;  
15 -import java.util.Set;  
16 -  
17 -/**  
18 - * @author: xms  
19 - * @description: 部门  
20 - * @date: 2023/3/30 15:41  
21 - * @version: 1.0  
22 - */  
23 -  
24 -@Data  
25 -@EqualsAndHashCode(callSuper = true)  
26 -@SuperBuilder(toBuilder = true)  
27 -@AllArgsConstructor  
28 -@NoArgsConstructor  
29 -@TableName("dept")  
30 -public class DeptDO extends BaseDO implements Serializable {  
31 -  
32 - /**  
33 - * 自增id  
34 - */  
35 - private Long id;  
36 -  
37 - @NotBlank  
38 - private String name;  
39 -  
40 - @NotNull  
41 - private Long pid;  
42 -  
43 - @JsonIgnore  
44 - @TableField(exist = false)  
45 - private Set<RoleDO> roles;  
46 -}  
src/main/java/com/order/erp/domain/dto/DictDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.NoArgsConstructor;  
8 -import lombok.experimental.SuperBuilder;  
9 -  
10 -import javax.validation.constraints.NotBlank;  
11 -import java.io.Serializable;  
12 -  
13 -/**  
14 - * @author: xms  
15 - * @description: 字典  
16 - * @date: 2023/3/30 16:44  
17 - * @version: 1.0  
18 - */  
19 -  
20 -@Data  
21 -@EqualsAndHashCode(callSuper = true)  
22 -@SuperBuilder(toBuilder = true)  
23 -@AllArgsConstructor  
24 -@NoArgsConstructor  
25 -@TableName("dict")  
26 -public class DictDO extends BaseDO implements Serializable {  
27 -  
28 - private Long id;  
29 -  
30 - @NotBlank  
31 - private String name;  
32 -  
33 - private String remark;  
34 -}  
src/main/java/com/order/erp/domain/dto/DictDetailDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.NoArgsConstructor;  
8 -import lombok.experimental.SuperBuilder;  
9 -  
10 -import java.io.Serializable;  
11 -  
12 -/**  
13 - * @author: xms  
14 - * @description: 字典  
15 - * @date: 2023/3/30 16:44  
16 - * @version: 1.0  
17 - */  
18 -  
19 -@Data  
20 -@EqualsAndHashCode(callSuper = true)  
21 -@SuperBuilder(toBuilder = true)  
22 -@AllArgsConstructor  
23 -@NoArgsConstructor  
24 -@TableName("dict_detail")  
25 -public class DictDetailDO extends BaseDO implements Serializable {  
26 -  
27 - private Long id;  
28 -  
29 - /**  
30 - * 字典标签  
31 - */  
32 - private String label;  
33 -  
34 - /**  
35 - * 字典值  
36 - */  
37 - private String value;  
38 -  
39 - /**  
40 - * 排序  
41 - */  
42 - private String sort = "999";  
43 -  
44 - /**  
45 - * 字典id  
46 - */  
47 - private Long dictId;  
48 -}  
src/main/java/com/order/erp/domain/dto/JobDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.NoArgsConstructor;  
8 -import lombok.experimental.SuperBuilder;  
9 -  
10 -import javax.validation.constraints.NotBlank;  
11 -import javax.validation.constraints.NotNull;  
12 -import java.io.Serializable;  
13 -  
14 -/**  
15 - * @author: xms  
16 - * @description: 岗位  
17 - * @date: 2023/3/30 15:57  
18 - * @version: 1.0  
19 - */  
20 -  
21 -@Data  
22 -@EqualsAndHashCode(callSuper = true)  
23 -@SuperBuilder(toBuilder = true)  
24 -@AllArgsConstructor  
25 -@NoArgsConstructor  
26 -@TableName("job")  
27 -public class JobDO extends BaseDO implements Serializable {  
28 -  
29 - /**  
30 - * 自增id  
31 - */  
32 - private Long id;  
33 -  
34 - /**  
35 - * 岗位名称  
36 - */  
37 - @NotBlank  
38 - private String name;  
39 -  
40 - /**  
41 - * 排序  
42 - */  
43 - @NotNull  
44 - private Long sort;  
45 -  
46 - /**  
47 - * 部门id  
48 - */  
49 - private Long deptId;  
50 -  
51 -}  
src/main/java/com/order/erp/domain/dto/MenuDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableField;  
4 -import com.baomidou.mybatisplus.annotation.TableName;  
5 -import com.fasterxml.jackson.annotation.JsonIgnore;  
6 -import lombok.AllArgsConstructor;  
7 -import lombok.Data;  
8 -import lombok.EqualsAndHashCode;  
9 -import lombok.NoArgsConstructor;  
10 -import lombok.experimental.SuperBuilder;  
11 -  
12 -import javax.validation.constraints.NotBlank;  
13 -import java.io.Serializable;  
14 -import java.util.Set;  
15 -  
16 -/**  
17 - * @author: xms  
18 - * @description: 菜单  
19 - * @date: 2023/3/30 16:29  
20 - * @version: 1.0  
21 - */  
22 -  
23 -@Data  
24 -@EqualsAndHashCode(callSuper = true)  
25 -@SuperBuilder(toBuilder = true)  
26 -@AllArgsConstructor  
27 -@NoArgsConstructor  
28 -@TableName("menu")  
29 -public class MenuDO extends BaseDO implements Serializable {  
30 -  
31 - /**  
32 - * id  
33 - */  
34 - private Long id;  
35 -  
36 - @NotBlank  
37 - private String name;  
38 -  
39 - /**  
40 - * 排序  
41 - */  
42 - private Long sort = 999L;  
43 -  
44 - /**  
45 - * 菜单路径  
46 - */  
47 - private String path;  
48 -  
49 - /**  
50 - *  
51 - */  
52 - private String component;  
53 -  
54 - /**  
55 - * 类型,目录、菜单、按钮  
56 - */  
57 - private Integer type;  
58 -  
59 - /**  
60 - * 权限  
61 - */  
62 - private String permission;  
63 -  
64 - /**  
65 - *  
66 - */  
67 - private String componentName;  
68 -  
69 - /**  
70 - *  
71 - */  
72 - private String icon;  
73 -  
74 -  
75 - private Boolean cache;  
76 -  
77 -  
78 - private Boolean hidden;  
79 -  
80 - /**  
81 - * 上级菜单ID  
82 - */  
83 - private Long pid;  
84 -  
85 - /**  
86 - * 是否为外链 true/false  
87 - */  
88 - private Boolean iFrame;  
89 -  
90 - @JsonIgnore  
91 - @TableField(exist = false)  
92 - private Set<RoleDO> roles;  
93 -}  
src/main/java/com/order/erp/domain/dto/RoleDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableField;  
4 -import com.baomidou.mybatisplus.annotation.TableName;  
5 -import com.fasterxml.jackson.annotation.JsonIgnore;  
6 -import lombok.AllArgsConstructor;  
7 -import lombok.Data;  
8 -import lombok.EqualsAndHashCode;  
9 -import lombok.NoArgsConstructor;  
10 -import lombok.experimental.SuperBuilder;  
11 -  
12 -import javax.validation.constraints.NotBlank;  
13 -import java.io.Serializable;  
14 -import java.util.Set;  
15 -  
16 -/**  
17 - * @projectName: canrd-services  
18 - * @package: com.canrd.shop.domain.com.canrd.shop.template.dto  
19 - * @className: RoleDO  
20 - * @author: xms  
21 - * @description: 角色  
22 - * @date: 2023/3/30 15:46  
23 - * @version: 1.0  
24 - */  
25 -  
26 -@Data  
27 -@EqualsAndHashCode(callSuper = true)  
28 -@SuperBuilder(toBuilder = true)  
29 -@AllArgsConstructor  
30 -@NoArgsConstructor  
31 -@TableName("role")  
32 -public class RoleDO extends BaseDO implements Serializable {  
33 -  
34 - /**  
35 - * 自增id  
36 - */  
37 - private Long id;  
38 -  
39 - @NotBlank  
40 - private String name;  
41 -  
42 - /**  
43 - * 数据权限类型 全部 、 本级 、 自定义  
44 - */  
45 - private String dataScope = "本级";  
46 -  
47 - /**  
48 - * 数值越小,级别越大  
49 - */  
50 - private Integer level = 3;  
51 -  
52 - private String remark;  
53 -  
54 - /**  
55 - * 权限  
56 - */  
57 - private String permission;  
58 -  
59 - @JsonIgnore  
60 - @TableField(exist = false)  
61 - private Set<UserDO> users;  
62 -  
63 - @JsonIgnore  
64 - @TableField(exist = false)  
65 - private Set<MenuDO> menus;  
66 -  
67 - @JsonIgnore  
68 - @TableField(exist = false)  
69 - private Set<DeptDO> depts;  
70 -  
71 -}  
src/main/java/com/order/erp/domain/dto/RolesDeptsDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -  
4 -import com.baomidou.mybatisplus.annotation.TableName;  
5 -import lombok.*;  
6 -import lombok.experimental.SuperBuilder;  
7 -  
8 -import java.io.Serializable;  
9 -  
10 -/**  
11 - * (RolesDepts)实体类  
12 - *  
13 - * @author xms  
14 - * @since 2023-03-30 18:36:30  
15 - */  
16 -@TableName("roles_depts")  
17 -@Data  
18 -@AllArgsConstructor  
19 -@ToString  
20 -@NoArgsConstructor  
21 -@EqualsAndHashCode(callSuper = false)  
22 -@SuperBuilder  
23 -public class RolesDeptsDO extends BaseDO implements Serializable {  
24 - private static final long serialVersionUID = -65106150541644917L;  
25 -  
26 - private Long roleId;  
27 -  
28 - private Long deptId;  
29 -  
30 -}  
src/main/java/com/order/erp/domain/dto/RolesMenusDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -  
4 -import com.baomidou.mybatisplus.annotation.TableName;  
5 -import lombok.*;  
6 -import lombok.experimental.SuperBuilder;  
7 -  
8 -import java.io.Serializable;  
9 -  
10 -/**  
11 - * (RolesMenus)实体类  
12 - *  
13 - * @author xms  
14 - * @since 2023-03-30 18:40:57  
15 - */  
16 -@TableName("roles_menus")  
17 -@Data  
18 -@AllArgsConstructor  
19 -@ToString  
20 -@NoArgsConstructor  
21 -@EqualsAndHashCode(callSuper = false)  
22 -@SuperBuilder  
23 -public class RolesMenusDO extends BaseDO implements Serializable {  
24 - private static final long serialVersionUID = 709202570835132264L;  
25 -  
26 - private Long roleId;  
27 -  
28 - private Long menuId;  
29 -  
30 -}  
src/main/java/com/order/erp/domain/dto/TestDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.NoArgsConstructor;  
8 -import lombok.experimental.SuperBuilder;  
9 -  
10 -import java.io.Serializable;  
11 -  
12 -/**  
13 - * @projectName: overtime-services  
14 - * @className: HelloDO  
15 - * @author: xms  
16 - * @description: TODO  
17 - * @date: 2023/1/11 15:51  
18 - * @version: 1.0  
19 - */  
20 -@Data  
21 -@EqualsAndHashCode(callSuper = true)  
22 -@SuperBuilder(toBuilder = true)  
23 -@AllArgsConstructor  
24 -@NoArgsConstructor  
25 -@TableName("hello")  
26 -public class TestDO extends BaseDO implements Serializable {  
27 - /**  
28 - * 自增主键  
29 - */  
30 - private Long id;  
31 -  
32 - /**  
33 - * 账号  
34 - */  
35 - private String username;  
36 -  
37 - /**  
38 - * 姓名  
39 - */  
40 - private String realName;  
41 -  
42 - /**  
43 - * 联系方式  
44 - */  
45 - private String phone;  
46 -  
47 - /**  
48 - * 邮箱  
49 - */  
50 - private String mail;  
51 -  
52 - /**  
53 - * 密码  
54 - */  
55 - private String password;  
56 -  
57 - /**  
58 - * 所属部门  
59 - */  
60 - private String department;  
61 -  
62 - /**  
63 - * 状态,1启用,2禁用,3锁定  
64 - */  
65 - private Integer state;  
66 -}  
src/main/java/com/order/erp/domain/dto/UserDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.NoArgsConstructor;  
8 -import lombok.experimental.SuperBuilder;  
9 -  
10 -import javax.validation.constraints.Email;  
11 -import javax.validation.constraints.NotBlank;  
12 -import java.io.Serializable;  
13 -import java.time.LocalDateTime;  
14 -  
15 -/**  
16 - * @projectName: canrd-services  
17 - * @package: com.canrd.shop.domain.com.canrd.shop.template.dto  
18 - * @className: UserDO  
19 - * @author: xms  
20 - * @description: TODO  
21 - * @date: 2023/3/30 15:50  
22 - * @version: 1.0  
23 - */  
24 -  
25 -@Data  
26 -@EqualsAndHashCode(callSuper = true)  
27 -@SuperBuilder(toBuilder = true)  
28 -@AllArgsConstructor  
29 -@NoArgsConstructor  
30 -@TableName("admin_user")  
31 -public class UserDO extends BaseDO implements Serializable {  
32 -  
33 - /**  
34 - * 自动id  
35 - */  
36 - private Long id;  
37 -  
38 - @NotBlank  
39 - private String username;  
40 -  
41 - /**  
42 - * 用户昵称  
43 - */  
44 - @NotBlank  
45 - private String nickName;  
46 -  
47 - /**  
48 - * 性别  
49 - */  
50 - private String sex;  
51 -  
52 - /**  
53 - * 工作性质  
54 - */  
55 - @NotBlank  
56 - private String workerType;  
57 -  
58 - @NotBlank  
59 - private Long userAvatarId;  
60 -  
61 - @Email  
62 - private String email;  
63 -  
64 - @NotBlank  
65 - private String phone;  
66 -  
67 -  
68 - private String password;  
69 -  
70 - private LocalDateTime lastPasswordResetTime;  
71 -  
72 - /**  
73 - * 公司id  
74 - */  
75 - private Long companyId;  
76 -  
77 - /**  
78 - * 岗位id  
79 - */  
80 - private Long jobId;  
81 -  
82 - /**  
83 - * 部门id  
84 - */  
85 - private Long deptId;  
86 -}  
src/main/java/com/order/erp/domain/dto/UsersRolesDO.java deleted 100644 → 0
1 -package com.order.erp.domain.dto;  
2 -  
3 -  
4 -import com.baomidou.mybatisplus.annotation.TableName;  
5 -import lombok.*;  
6 -import lombok.experimental.SuperBuilder;  
7 -  
8 -import java.io.Serializable;  
9 -  
10 -/**  
11 - * (UsersRoles)实体类  
12 - *  
13 - * @author makejava  
14 - * @since 2023-03-30 18:43:10  
15 - */  
16 -@TableName("users_roles")  
17 -@Data  
18 -@AllArgsConstructor  
19 -@ToString  
20 -@NoArgsConstructor  
21 -@EqualsAndHashCode(callSuper = false)  
22 -@SuperBuilder  
23 -public class UsersRolesDO extends BaseDO implements Serializable {  
24 - private static final long serialVersionUID = 320304139834762987L;  
25 -  
26 - private Long userId;  
27 -  
28 - private Long roleId;  
29 -  
30 -}  
src/main/java/com/order/erp/domain/dto/admin/AdminDeptDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
3 import com.baomidou.mybatisplus.annotation.TableName; 3 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO; 4 +import com.order.erp.domain.dto.BaseDO;
5 import lombok.*; 5 import lombok.*;
6 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
7 7
@@ -23,13 +23,25 @@ import java.io.Serializable; @@ -23,13 +23,25 @@ import java.io.Serializable;
23 public class AdminDeptDO extends BaseDO implements Serializable { 23 public class AdminDeptDO extends BaseDO implements Serializable {
24 24
25 private Long id; 25 private Long id;
  26 +
26 /** 27 /**
27 * 岗位名称 28 * 岗位名称
28 */ 29 */
29 private String name; 30 private String name;
  31 +
30 /** 32 /**
31 - * pid 33 + * 上级部门
32 */ 34 */
33 private Long pid; 35 private Long pid;
34 36
  37 + /**
  38 + * 子部门数目
  39 + */
  40 + private Integer subCount;
  41 +
  42 + /**
  43 + * 排序
  44 + */
  45 + private Integer deptSort;
  46 +
35 } 47 }
src/main/java/com/order/erp/domain/dto/admin/AdminJobDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
3 import com.baomidou.mybatisplus.annotation.TableName; 3 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO; 4 +import com.order.erp.domain.dto.BaseDO;
5 import lombok.*; 5 import lombok.*;
6 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
7 7
@@ -21,15 +21,15 @@ import java.io.Serializable; @@ -21,15 +21,15 @@ import java.io.Serializable;
21 @EqualsAndHashCode(callSuper = false) 21 @EqualsAndHashCode(callSuper = false)
22 @SuperBuilder 22 @SuperBuilder
23 public class AdminJobDO extends BaseDO implements Serializable { 23 public class AdminJobDO extends BaseDO implements Serializable {
24 - 24 +
25 private Long id; 25 private Long id;
26 - /** 26 + /**
27 * 岗位名称 27 * 岗位名称
28 */ 28 */
29 private String name; 29 private String name;
30 - /** 30 + /**
31 * 排序字段 31 * 排序字段
32 */ 32 */
33 private Integer sort; 33 private Integer sort;
34 - 34 +
35 } 35 }
src/main/java/com/order/erp/domain/dto/admin/AdminMenuDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
3 import com.baomidou.mybatisplus.annotation.TableName; 3 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO; 4 +import com.order.erp.domain.dto.BaseDO;
5 import lombok.*; 5 import lombok.*;
6 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
7 7
@@ -24,44 +24,69 @@ public class AdminMenuDO extends BaseDO implements Serializable { @@ -24,44 +24,69 @@ public class AdminMenuDO extends BaseDO implements Serializable {
24 24
25 private Long id; 25 private Long id;
26 /** 26 /**
27 - * 父级id 27 + * 上级菜单ID
28 */ 28 */
29 private Long pid; 29 private Long pid;
  30 +
30 /** 31 /**
31 - * 菜单名称 32 + * 子菜单数目
32 */ 33 */
33 - private String name; 34 + private Integer subCount;
  35 +
34 /** 36 /**
35 - * 路径 37 + * 类型,目录、菜单、按钮
36 */ 38 */
37 - private String path; 39 + private Integer type;
  40 +
  41 + /**
  42 + * 菜单标题
  43 + */
  44 + private String title;
  45 +
  46 + /**
  47 + * 菜单名称
  48 + */
  49 + private String name;
  50 +
38 /** 51 /**
39 * 组件 52 * 组件
40 */ 53 */
41 private String component; 54 private String component;
  55 +
42 /** 56 /**
43 - * 权限 57 + * 排序
44 */ 58 */
45 - private String permission; 59 + private Integer menuSort;
  60 +
46 /** 61 /**
47 * 图标 62 * 图标
48 */ 63 */
49 private String icon; 64 private String icon;
  65 +
50 /** 66 /**
51 - * 类型,目录、菜单、按钮 67 + * 路径
52 */ 68 */
53 - private Integer type; 69 + private String path;
  70 +
  71 + /**
  72 + * 是否为外链 0:否,1:是
  73 + */
  74 + private Integer iFrame;
  75 +
54 /** 76 /**
55 * cache 77 * cache
56 */ 78 */
57 private Integer cache; 79 private Integer cache;
  80 +
58 /** 81 /**
59 - * 是否隐藏 82 + * 权限
60 */ 83 */
61 - private Integer hidden; 84 + private String permission;
  85 +
62 /** 86 /**
63 - * 是否为外链 0:否,1:是 87 + * 是否隐藏
64 */ 88 */
65 - private Integer iFrame; 89 + private Integer hidden;
  90 +
66 91
67 } 92 }
src/main/java/com/order/erp/domain/dto/admin/AdminRoleDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
3 import com.baomidou.mybatisplus.annotation.TableName; 3 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO; 4 +import com.order.erp.domain.dto.BaseDO;
5 import lombok.*; 5 import lombok.*;
6 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
7 7
@@ -27,21 +27,21 @@ public class AdminRoleDO extends BaseDO implements Serializable { @@ -27,21 +27,21 @@ public class AdminRoleDO extends BaseDO implements Serializable {
27 * 角色名称 27 * 角色名称
28 */ 28 */
29 private String name; 29 private String name;
  30 +
30 /** 31 /**
31 - * 备注  
32 - */  
33 - private String remark;  
34 - /**  
35 - * 权限 32 + * 数值越小,级别越大
36 */ 33 */
37 - private String permission; 34 + private Integer level;
  35 +
38 /** 36 /**
39 * 数据权限类型 全部 、 本级 、 自定义 37 * 数据权限类型 全部 、 本级 、 自定义
40 */ 38 */
41 private String dataScope; 39 private String dataScope;
  40 +
42 /** 41 /**
43 - * 数值越小,级别越大 42 + * 描述
44 */ 43 */
45 - private Integer level; 44 + private String description;
  45 +
46 46
47 } 47 }
src/main/java/com/order/erp/domain/dto/admin/AdminRoleDeptDO.java
@@ -2,7 +2,6 @@ package com.order.erp.domain.dto.admin; @@ -2,7 +2,6 @@ package com.order.erp.domain.dto.admin;
2 2
3 3
4 import com.baomidou.mybatisplus.annotation.TableName; 4 import com.baomidou.mybatisplus.annotation.TableName;
5 -import com.canrd.shop.domain.dto.BaseDO;  
6 import lombok.*; 5 import lombok.*;
7 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
8 7
@@ -21,7 +20,7 @@ import java.io.Serializable; @@ -21,7 +20,7 @@ import java.io.Serializable;
21 @NoArgsConstructor 20 @NoArgsConstructor
22 @EqualsAndHashCode(callSuper = false) 21 @EqualsAndHashCode(callSuper = false)
23 @SuperBuilder 22 @SuperBuilder
24 -public class AdminRoleDeptDO extends BaseDO implements Serializable { 23 +public class AdminRoleDeptDO implements Serializable {
25 24
26 private Long id; 25 private Long id;
27 /** 26 /**
src/main/java/com/order/erp/domain/dto/admin/AdminCompanyDO.java renamed to src/main/java/com/order/erp/domain/dto/admin/AdminRoleMenuDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
  3 +
3 import com.baomidou.mybatisplus.annotation.TableName; 4 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO;  
5 import lombok.*; 5 import lombok.*;
6 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
7 7
8 import java.io.Serializable; 8 import java.io.Serializable;
9 9
10 /** 10 /**
11 - * 公司表(AdminCompany)实体类 11 + * 角色-菜单表(AdminRoleDept)实体类
12 * 12 *
13 * @author makejava 13 * @author makejava
14 - * @since 2023-08-30 17:51:44 14 + * @since 2023-08-30 17:51:48
15 */ 15 */
16 -@TableName("admin_company") 16 +@TableName("admin_role_menu")
17 @Data 17 @Data
18 @AllArgsConstructor 18 @AllArgsConstructor
19 @ToString 19 @ToString
20 @NoArgsConstructor 20 @NoArgsConstructor
21 @EqualsAndHashCode(callSuper = false) 21 @EqualsAndHashCode(callSuper = false)
22 @SuperBuilder 22 @SuperBuilder
23 -public class AdminCompanyDO extends BaseDO implements Serializable { 23 +public class AdminRoleMenuDO implements Serializable {
24 24
25 private Long id; 25 private Long id;
26 /** 26 /**
27 - * 公司编码 27 + * 菜单id
28 */ 28 */
29 - private String code; 29 + private Long menuId;
30 /** 30 /**
31 - * 公司名称 31 + * 角色id
32 */ 32 */
33 - private String name; 33 + private Long roleId;
34 34
35 } 35 }
src/main/java/com/order/erp/domain/dto/admin/AdminUserDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
  3 +import com.baomidou.mybatisplus.annotation.FieldFill;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
3 import com.baomidou.mybatisplus.annotation.TableName; 5 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO; 6 +import com.order.erp.domain.dto.BaseDO;
5 import lombok.*; 7 import lombok.*;
6 import lombok.experimental.SuperBuilder; 8 import lombok.experimental.SuperBuilder;
  9 +import org.apache.ibatis.type.LocalDateTimeTypeHandler;
7 10
8 import java.io.Serializable; 11 import java.io.Serializable;
  12 +import java.time.LocalDateTime;
9 13
10 /** 14 /**
11 * 用户表(AdminUser)实体类 15 * 用户表(AdminUser)实体类
@@ -23,33 +27,61 @@ import java.io.Serializable; @@ -23,33 +27,61 @@ import java.io.Serializable;
23 public class AdminUserDO extends BaseDO implements Serializable { 27 public class AdminUserDO extends BaseDO implements Serializable {
24 28
25 private Long id; 29 private Long id;
  30 +
  31 + /**
  32 + * 部门id
  33 + */
  34 + private Long deptId;
  35 +
26 /** 36 /**
27 * 用户名称 37 * 用户名称
28 */ 38 */
29 private String userName; 39 private String userName;
  40 +
30 /** 41 /**
31 * 用户昵称 42 * 用户昵称
32 */ 43 */
33 private String nickName; 44 private String nickName;
  45 +
34 /** 46 /**
35 * 性别 47 * 性别
36 */ 48 */
37 - private String sex; 49 + private String gender;
  50 +
38 /** 51 /**
39 - * 工作性质 52 + * 手机号码
40 */ 53 */
41 - private String workerType; 54 + private String phone;
  55 +
42 /** 56 /**
43 * 邮箱 57 * 邮箱
44 */ 58 */
45 private String email; 59 private String email;
  60 +
46 /** 61 /**
47 - * 手机号 62 + * 头像地址
48 */ 63 */
49 - private String phone; 64 + private String avatarName;
  65 +
  66 + /**
  67 + * 头像真实路径
  68 + */
  69 + private String avatarPath;
  70 +
50 /** 71 /**
51 * 密码 72 * 密码
52 */ 73 */
53 private String password; 74 private String password;
54 75
  76 + /**
  77 + * 是否为admin账号
  78 + */
  79 + private Boolean isAdmin;
  80 +
  81 + /**
  82 + * 修改密码的时间
  83 + */
  84 + @TableField(fill = FieldFill.INSERT_UPDATE, typeHandler = LocalDateTimeTypeHandler.class)
  85 + private LocalDateTime passResetTime;
  86 +
55 } 87 }
src/main/java/com/order/erp/domain/vo/admin/AdminCompanyVO.java renamed to src/main/java/com/order/erp/domain/dto/admin/AdminUserJobDO.java
1 -package com.order.erp.domain.vo.admin; 1 +package com.order.erp.domain.dto.admin;
2 2
  3 +
  4 +import com.baomidou.mybatisplus.annotation.TableName;
3 import lombok.*; 5 import lombok.*;
4 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
5 7
6 import java.io.Serializable; 8 import java.io.Serializable;
7 9
8 /** 10 /**
9 - * 公司表(AdminCompany)实体类 11 + * 用户-岗位(AdminUserJobDO)实体类
10 * 12 *
11 * @author makejava 13 * @author makejava
12 - * @since 2023-08-30 17:51:45 14 + * @since 2023-08-30 17:51:48
13 */ 15 */
  16 +@TableName("admin_user_job")
14 @Data 17 @Data
15 @AllArgsConstructor 18 @AllArgsConstructor
16 @ToString 19 @ToString
17 @NoArgsConstructor 20 @NoArgsConstructor
18 @EqualsAndHashCode(callSuper = false) 21 @EqualsAndHashCode(callSuper = false)
19 @SuperBuilder 22 @SuperBuilder
20 -public class AdminCompanyVO implements Serializable {  
21 - private static final long serialVersionUID = -11641315094136694L; 23 +public class AdminUserJobDO implements Serializable {
22 24
23 private Long id; 25 private Long id;
24 /** 26 /**
25 - * 公司编码 27 + * 用户殴打
26 */ 28 */
27 - private String code; 29 + private Long userId;
28 /** 30 /**
29 - * 公司名称 31 + * 岗位id
30 */ 32 */
31 - private String name;  
32 - 33 + private Long jobId;
33 34
34 } 35 }
src/main/java/com/order/erp/domain/dto/admin/AdminUserRoleDO.java
@@ -2,7 +2,6 @@ package com.order.erp.domain.dto.admin; @@ -2,7 +2,6 @@ package com.order.erp.domain.dto.admin;
2 2
3 3
4 import com.baomidou.mybatisplus.annotation.TableName; 4 import com.baomidou.mybatisplus.annotation.TableName;
5 -import com.canrd.shop.domain.dto.BaseDO;  
6 import lombok.*; 5 import lombok.*;
7 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
8 7
@@ -21,7 +20,7 @@ import java.io.Serializable; @@ -21,7 +20,7 @@ import java.io.Serializable;
21 @NoArgsConstructor 20 @NoArgsConstructor
22 @EqualsAndHashCode(callSuper = false) 21 @EqualsAndHashCode(callSuper = false)
23 @SuperBuilder 22 @SuperBuilder
24 -public class AdminUserRoleDO extends BaseDO implements Serializable { 23 +public class AdminUserRoleDO implements Serializable {
25 24
26 private Long id; 25 private Long id;
27 /** 26 /**
src/main/java/com/order/erp/domain/dto/admin/DictionaryDO.java
1 package com.order.erp.domain.dto.admin; 1 package com.order.erp.domain.dto.admin;
2 2
3 import com.baomidou.mybatisplus.annotation.TableName; 3 import com.baomidou.mybatisplus.annotation.TableName;
4 -import com.canrd.shop.domain.dto.BaseDO; 4 +import com.order.erp.domain.dto.BaseDO;
5 import lombok.*; 5 import lombok.*;
6 import lombok.experimental.SuperBuilder; 6 import lombok.experimental.SuperBuilder;
7 7
src/main/java/com/order/erp/domain/vo/BasePageVO.java
1 package com.order.erp.domain.vo; 1 package com.order.erp.domain.vo;
2 2
3 -import com.canrd.shop.common.constant.Constant;  
4 -import com.canrd.shop.common.jsr303.OperateGroup;  
5 import com.fasterxml.jackson.annotation.JsonInclude; 3 import com.fasterxml.jackson.annotation.JsonInclude;
  4 +import com.order.erp.common.constant.Constant;
  5 +import com.order.erp.common.jsr303.OperateGroup;
6 import lombok.AllArgsConstructor; 6 import lombok.AllArgsConstructor;
7 import lombok.Data; 7 import lombok.Data;
8 import lombok.NoArgsConstructor; 8 import lombok.NoArgsConstructor;
src/main/java/com/order/erp/domain/vo/RolesDeptsVO.java renamed to src/main/java/com/order/erp/domain/vo/CaptchaMessageVO.java
1 package com.order.erp.domain.vo; 1 package com.order.erp.domain.vo;
2 2
3 -  
4 import lombok.*; 3 import lombok.*;
5 import lombok.experimental.SuperBuilder; 4 import lombok.experimental.SuperBuilder;
6 5
  6 +import javax.validation.constraints.NotBlank;
7 import java.io.Serializable; 7 import java.io.Serializable;
8 8
9 /** 9 /**
10 - * (RolesDepts)实体类 10 + * (Member)验证码
11 * 11 *
12 * @author xms 12 * @author xms
13 - * @since 2023-03-30 18:36:33 13 + * @since 2023-08-22 17:02:39
14 */ 14 */
15 @Data 15 @Data
16 @AllArgsConstructor 16 @AllArgsConstructor
@@ -18,12 +18,31 @@ import java.io.Serializable; @@ -18,12 +18,31 @@ import java.io.Serializable;
18 @NoArgsConstructor 18 @NoArgsConstructor
19 @EqualsAndHashCode(callSuper = false) 19 @EqualsAndHashCode(callSuper = false)
20 @SuperBuilder 20 @SuperBuilder
21 -public class RolesDeptsVO implements Serializable {  
22 - private static final long serialVersionUID = 791414890840757026L;  
23 -  
24 - private Long roleId;  
25 -  
26 - private Long deptId;  
27 - 21 +public class CaptchaMessageVO extends BasePageVO implements Serializable {
  22 + private static final long serialVersionUID = -98570856671998407L;
  23 +
  24 + /**
  25 + * 类型:register
  26 + */
  27 + private String type;
  28 +
  29 + /**
  30 + * 手机号码
  31 + */
  32 + @NotBlank(message = "手机号码不能为空!")
  33 + private String phone;
  34 +
  35 + /**
  36 + * 图片验证码
  37 + */
  38 + @NotBlank(message = "图片验证码不能为空!")
  39 + private String imgCaptchaCode;
  40 +
  41 + /**
  42 + * 图片验证码标识
  43 + */
  44 + @NotBlank(message = "图片验证码标识不能为空!")
  45 + private String imgCaptchaUuid;
28 46
29 } 47 }
  48 +
src/main/java/com/order/erp/domain/vo/CompanySmallVO.java deleted 100644 → 0
1 -package com.order.erp.domain.vo;  
2 -  
3 -import lombok.Data;  
4 -  
5 -import java.io.Serializable;  
6 -  
7 -  
8 -@Data  
9 -public class CompanySmallVO implements Serializable {  
10 -  
11 - private Long id;  
12 -  
13 - private String name;  
14 -  
15 - private String code;  
16 -}  
17 \ No newline at end of file 0 \ No newline at end of file
src/main/java/com/order/erp/domain/vo/CompanyVO.java deleted 100644 → 0
1 -package com.order.erp.domain.vo;  
2 -  
3 -import lombok.Data;  
4 -  
5 -import java.io.Serializable;  
6 -import java.sql.Timestamp;  
7 -  
8 -  
9 -@Data  
10 -public class CompanyVO implements Serializable {  
11 -  
12 - private Long id;  
13 -  
14 - private String code;  
15 -  
16 - private String name;  
17 -  
18 - private Boolean enabled;  
19 -  
20 - private Timestamp createTime;  
21 -  
22 - public String getLabel() {  
23 - return name;  
24 - }  
25 -}  
26 \ No newline at end of file 0 \ No newline at end of file
src/main/java/com/order/erp/domain/vo/EmailVO.java 0 → 100644
  1 +package com.order.erp.domain.vo;
  2 +
  3 +import lombok.*;
  4 +import lombok.experimental.SuperBuilder;
  5 +
  6 +import java.io.Serializable;
  7 +import java.util.HashMap;
  8 +
  9 +/**
  10 + * @author xms
  11 + * @since 2023-06-03
  12 + */
  13 +
  14 +@Data
  15 +@AllArgsConstructor
  16 +@ToString
  17 +@NoArgsConstructor
  18 +@EqualsAndHashCode(callSuper = false)
  19 +@SuperBuilder
  20 +public class EmailVO implements Serializable {
  21 +
  22 + /**
  23 + * 接收方邮件
  24 + */
  25 + private String[] email;
  26 +
  27 + /**
  28 + * 主题
  29 + */
  30 + private String subject;
  31 +
  32 + /**
  33 + * 邮件内容
  34 + */
  35 + private String content;
  36 +
  37 + /**
  38 + * 模板
  39 + */
  40 + private String template;
  41 +
  42 + /**
  43 + * 自定义参数
  44 + */
  45 + private HashMap<String, String> kvMap;
  46 +}
src/main/java/com/order/erp/domain/vo/RolesMenusVO.java deleted 100644 → 0
1 -package com.order.erp.domain.vo;  
2 -  
3 -import lombok.*;  
4 -import lombok.experimental.SuperBuilder;  
5 -  
6 -import java.io.Serializable;  
7 -  
8 -/**  
9 - * (RolesMenus)实体类  
10 - *  
11 - * @author makejava  
12 - * @since 2023-03-30 18:40:59  
13 - */  
14 -@Data  
15 -@AllArgsConstructor  
16 -@ToString  
17 -@NoArgsConstructor  
18 -@EqualsAndHashCode(callSuper = false)  
19 -@SuperBuilder  
20 -public class RolesMenusVO implements Serializable {  
21 - private static final long serialVersionUID = -56152641918380485L;  
22 -  
23 - private Long roleId;  
24 -  
25 - private Long menuId;  
26 -  
27 -  
28 -}  
src/main/java/com/order/erp/domain/vo/TestVO.java deleted 100644 → 0
1 -package com.order.erp.domain.vo;  
2 -  
3 -  
4 -import com.canrd.shop.common.constant.Constant;  
5 -import com.canrd.shop.common.jsr303.OperateGroup;  
6 -import lombok.Data;  
7 -import org.hibernate.validator.constraints.Length;  
8 -  
9 -import javax.validation.constraints.NotNull;  
10 -import javax.validation.constraints.Pattern;  
11 -import java.io.Serializable;  
12 -  
13 -/**  
14 - * @projectName: overtime-services  
15 - * @className: HelloQueryVO  
16 - * @author: xms  
17 - * @description: TODO  
18 - * @date: 2023/1/11 16:01  
19 - * @version: 1.0  
20 - */  
21 -@Data  
22 -public class TestVO implements Serializable {  
23 - /**  
24 - * 自增主键  
25 - */  
26 - @NotNull(message = "ID不能为空", groups = {OperateGroup.Update.class})  
27 - private Long id;  
28 -  
29 - /**  
30 - * 账号  
31 - */  
32 - @NotNull(message = "账号不能为空", groups = {OperateGroup.Save.class})  
33 - @Length(min = 1, max = 15, message = "请填写1~15位英文+数字的有效账号", groups = {OperateGroup.Save.class})  
34 - @Pattern(regexp = Constant.EN_NUM_REGEXP, message = "请填写英文+数字的有效账号", groups = {OperateGroup.Save.class})  
35 - private String userName;  
36 -  
37 - /**  
38 - * 姓名  
39 - */  
40 - @NotNull(message = "姓名不能为空", groups = {OperateGroup.Save.class, OperateGroup.Update.class})  
41 - @Length(max = 30, message = "名字过长", groups = {OperateGroup.Save.class, OperateGroup.Update.class})  
42 - private String realName;  
43 -  
44 - /**  
45 - * 联系方式  
46 - */  
47 - private String phone;  
48 -  
49 - /**  
50 - * 邮箱  
51 - */  
52 - private String mail;  
53 -  
54 - /**  
55 - * 所属部门  
56 - */  
57 - private String department;  
58 -  
59 - /**  
60 - * 状态,1启用,2禁用  
61 - */  
62 - private String state;  
63 - /**  
64 - * 创建时间  
65 - */  
66 - private String createTime;  
67 -  
68 - /**  
69 - * 创建人  
70 - */  
71 - private String createBy;  
72 - /**  
73 - * 修改时间  
74 - */  
75 - private String modifyTime;  
76 -  
77 - /**  
78 - * 修改人  
79 - */  
80 - private String modifyBy;  
81 -  
82 - private String roles;  
83 -  
84 - private String dataPermission;  
85 -}  
src/main/java/com/order/erp/domain/vo/UserVO.java
1 package com.order.erp.domain.vo; 1 package com.order.erp.domain.vo;
2 2
3 import com.fasterxml.jackson.annotation.JsonIgnore; 3 import com.fasterxml.jackson.annotation.JsonIgnore;
  4 +import com.order.erp.domain.vo.admin.DeptSmallVO;
  5 +import com.order.erp.domain.vo.admin.JobSmallVO;
  6 +import com.order.erp.domain.vo.admin.RoleSmallVO;
4 import io.swagger.annotations.ApiModelProperty; 7 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 8 import lombok.Data;
6 9
@@ -43,7 +46,6 @@ public class UserVO implements Serializable { @@ -43,7 +46,6 @@ public class UserVO implements Serializable {
43 @ApiModelProperty(hidden = true) 46 @ApiModelProperty(hidden = true)
44 private Set<RoleSmallVO> roles; 47 private Set<RoleSmallVO> roles;
45 48
46 - private CompanySmallVO company;  
47 49
48 @ApiModelProperty(hidden = true) 50 @ApiModelProperty(hidden = true)
49 private JobSmallVO job; 51 private JobSmallVO job;
src/main/java/com/order/erp/domain/vo/UsersRolesVO.java deleted 100644 → 0
1 -package com.order.erp.domain.vo;  
2 -  
3 -  
4 -import lombok.*;  
5 -import lombok.experimental.SuperBuilder;  
6 -  
7 -import java.io.Serializable;  
8 -  
9 -/**  
10 - * (UsersRoles)实体类  
11 - *  
12 - * @author makejava  
13 - * @since 2023-03-30 18:43:10  
14 - */  
15 -@Data  
16 -@AllArgsConstructor  
17 -@ToString  
18 -@NoArgsConstructor  
19 -@EqualsAndHashCode(callSuper = false)  
20 -@SuperBuilder  
21 -public class UsersRolesVO implements Serializable {  
22 - private static final long serialVersionUID = -41891129366026088L;  
23 -  
24 - private Long userId;  
25 -  
26 - private Long roleId;  
27 -  
28 -  
29 -}  
src/main/java/com/order/erp/domain/vo/VisitsVO.java deleted 100644 → 0
1 -package com.order.erp.domain.vo;  
2 -  
3 -import lombok.*;  
4 -import lombok.experimental.SuperBuilder;  
5 -  
6 -import java.io.Serializable;  
7 -  
8 -/**  
9 - * (Visits)实体类  
10 - *  
11 - * @author makejava  
12 - * @since 2023-03-30 18:42:35  
13 - */  
14 -@Data  
15 -@AllArgsConstructor  
16 -@ToString  
17 -@NoArgsConstructor  
18 -@EqualsAndHashCode(callSuper = false)  
19 -@SuperBuilder  
20 -public class VisitsVO implements Serializable {  
21 - private static final long serialVersionUID = -90062665287384516L;  
22 -  
23 - private Long id;  
24 -  
25 - private String date;  
26 -  
27 - private Long ipCounts;  
28 -  
29 - private Long pvCounts;  
30 -  
31 - private String weekDay;  
32 -  
33 -  
34 -}  
src/main/java/com/order/erp/domain/vo/admin/AdminCompanyQueryVO.java
1 package com.order.erp.domain.vo.admin; 1 package com.order.erp.domain.vo.admin;
2 2
3 -import com.canrd.shop.domain.vo.BasePageVO; 3 +import com.order.erp.domain.vo.BasePageVO;
4 import lombok.*; 4 import lombok.*;
5 import lombok.experimental.SuperBuilder; 5 import lombok.experimental.SuperBuilder;
6 6
src/main/java/com/order/erp/domain/vo/admin/AdminDeptQueryVO.java
1 package com.order.erp.domain.vo.admin; 1 package com.order.erp.domain.vo.admin;
2 2
3 -import com.canrd.shop.domain.vo.BasePageVO; 3 +import com.order.erp.domain.vo.BasePageVO;
4 import lombok.*; 4 import lombok.*;
5 import lombok.experimental.SuperBuilder; 5 import lombok.experimental.SuperBuilder;
6 6
src/main/java/com/order/erp/domain/vo/admin/AdminJobQueryVO.java
1 package com.order.erp.domain.vo.admin; 1 package com.order.erp.domain.vo.admin;
2 2
3 -import com.canrd.shop.domain.vo.BasePageVO; 3 +import com.order.erp.domain.vo.BasePageVO;
4 import lombok.*; 4 import lombok.*;
5 import lombok.experimental.SuperBuilder; 5 import lombok.experimental.SuperBuilder;
6 6
src/main/java/com/order/erp/domain/vo/admin/AdminMenuQueryVO.java
1 package com.order.erp.domain.vo.admin; 1 package com.order.erp.domain.vo.admin;
2 2
3 -import com.canrd.shop.domain.vo.BasePageVO; 3 +import com.order.erp.domain.vo.BasePageVO;
4 import lombok.*; 4 import lombok.*;
5 import lombok.experimental.SuperBuilder; 5 import lombok.experimental.SuperBuilder;
6 6
src/main/java/com/order/erp/domain/vo/admin/AdminRoleDeptQueryVO.java
1 package com.order.erp.domain.vo.admin; 1 package com.order.erp.domain.vo.admin;
2 2
3 -import com.canrd.shop.domain.vo.BasePageVO; 3 +import com.order.erp.domain.vo.BasePageVO;
4 import lombok.*; 4 import lombok.*;
5 import lombok.experimental.SuperBuilder; 5 import lombok.experimental.SuperBuilder;
6 6
src/main/java/com/order/erp/domain/vo/admin/AdminRoleQueryVO.java
1 package com.order.erp.domain.vo.admin; 1 package com.order.erp.domain.vo.admin;
2 2
3 -import com.canrd.shop.domain.vo.BasePageVO; 3 +import com.order.erp.domain.vo.BasePageVO;
4 import lombok.*; 4 import lombok.*;
5 import lombok.experimental.SuperBuilder; 5 import lombok.experimental.SuperBuilder;
6 6