c5c67ee1 by 荆蔚杰

不动产登记档案系统

0 parents
1 .idea
2 *.iml
3 .classpath
4 .factorypath
5 .project
6 .settings
7 .DS_Store
8 target
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5 <modelVersion>4.0.0</modelVersion>
6
7 <groupId>com.pashanhoo</groupId>
8 <artifactId>archive-system</artifactId>
9 <version>1.0-SNAPSHOT</version>
10
11 <dependencies>
12 <!-- -->
13 <dependency>
14 <groupId>com.fasterxml.jackson.core</groupId>
15 <artifactId>jackson-databind</artifactId>
16 <version>${fasterxml.jackson.version}</version>
17 </dependency>
18
19 <dependency>
20 <groupId>com.fasterxml.jackson.core</groupId>
21 <artifactId>jackson-core</artifactId>
22 <version>${fasterxml.jackson.version}</version>
23 </dependency>
24 <dependency>
25 <groupId>org.springframework.boot</groupId>
26 <artifactId>spring-boot</artifactId>
27 <version>${org.spring.boot.version}</version>
28 </dependency>
29 <dependency>
30 <groupId>org.freemarker</groupId>
31 <artifactId>freemarker</artifactId>
32 <version>2.3.29</version>
33 </dependency>
34 <dependency>
35 <groupId>junit</groupId>
36 <artifactId>junit</artifactId>
37 <version>4.12</version>
38 </dependency>
39 <dependency>
40 <groupId>org.slf4j</groupId>
41 <artifactId>slf4j-api</artifactId>
42 <version>1.7.29</version>
43 </dependency>
44
45 <dependency>
46 <groupId>com.baomidou</groupId>
47 <artifactId>mybatis-plus-boot-starter</artifactId>
48 <version>3.1.2</version>
49 </dependency>
50 <dependency>
51 <groupId>com.baomidou</groupId>
52 <artifactId>mybatis-plus-generator</artifactId>
53 <version>3.3.2</version>
54 </dependency>
55
56 <dependency>
57 <groupId>org.springframework</groupId>
58 <artifactId>spring-web</artifactId>
59 <version>${org.springframework.version}</version>
60 </dependency>
61 <dependency>
62 <groupId>org.springframework.boot</groupId>
63 <artifactId>spring-boot-starter-web</artifactId>
64 <version>${org.spring.boot.version}</version>
65 </dependency>
66
67 <!--<dependency>-->
68 <!-- <groupId>org.springframework.session</groupId>-->
69 <!-- <artifactId>spring-session-data-redis</artifactId>-->
70 <!-- <version>${org.spring.session.version}</version>-->
71 <!--</dependency>-->
72 <!--&lt;!&ndash; 引入Redis依赖 &ndash;&gt;-->
73 <!--<dependency>-->
74 <!-- <groupId>org.springframework.boot</groupId>-->
75 <!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
76 <!-- <version>${org.spring.boot.version}</version>-->
77 <!--</dependency>-->
78 <!--<dependency>-->
79 <!-- <groupId>redis.clients</groupId>-->
80 <!-- <artifactId>jedis</artifactId>-->
81 <!-- <version>2.9.3</version>-->
82 <!--</dependency>-->
83 <!--<dependency>-->
84 <!-- <groupId>org.springframework.session</groupId>-->
85 <!-- <artifactId>spring-session</artifactId>-->
86 <!-- <version>1.0.2.RELEASE</version>-->
87 <!--</dependency>-->
88 <dependency>
89 <groupId>io.lettuce</groupId>
90 <artifactId>lettuce-core</artifactId>
91 <version>5.2.0.RELEASE</version>
92 </dependency>
93 <dependency>
94 <groupId>org.springframework.boot</groupId>
95 <artifactId>spring-boot-starter-test</artifactId>
96 <version>2.1.12.RELEASE</version>
97 </dependency>
98
99 <!-- Swagger API文档 -->
100 <dependency>
101 <groupId>io.springfox</groupId>
102 <artifactId>springfox-swagger2</artifactId>
103 <version>${springfox.swagger2.version}</version>
104 </dependency>
105 <dependency>
106 <groupId>io.springfox</groupId>
107 <artifactId>springfox-swagger-ui</artifactId>
108 <version>${springfox.swagger2.version}</version>
109 <exclusions>
110 <exclusion>
111 <groupId>io.swagger</groupId>
112 <artifactId>swagger-models</artifactId>
113 </exclusion>
114 </exclusions>
115 </dependency>
116 <dependency>
117 <groupId>io.swagger</groupId>
118 <artifactId>swagger-models</artifactId>
119 <version>1.5.21</version>
120 </dependency>
121
122 <dependency>
123 <groupId>com.spring4all</groupId>
124 <artifactId>swagger-spring-boot-starter</artifactId>
125 <version>1.9.1.RELEASE</version>
126 </dependency>
127
128 <dependency>
129 <groupId>org.projectlombok</groupId>
130 <artifactId>lombok</artifactId>
131 <optional>true</optional>
132 <version>1.18.8</version>
133 </dependency>
134
135 <dependency>
136 <groupId>io.swagger</groupId>
137 <artifactId>swagger-annotations</artifactId>
138 <version>1.5.13</version>
139 <scope>compile</scope>
140 </dependency>
141
142 <dependency>
143 <groupId>com.google.guava</groupId>
144 <artifactId>guava</artifactId>
145 <version>20.0</version>
146 <scope>compile</scope>
147 </dependency>
148 <dependency>
149 <groupId>commons-collections</groupId>
150 <artifactId>commons-collections</artifactId>
151 <version>3.2.2</version>
152 </dependency>
153 <dependency>
154 <groupId>commons-codec</groupId>
155 <artifactId>commons-codec</artifactId>
156 <version>1.10</version>
157 </dependency>
158 <dependency>
159 <groupId>commons-beanutils</groupId>
160 <artifactId>commons-beanutils</artifactId>
161 <version>1.9.3</version>
162 </dependency>
163 <dependency>
164 <groupId>javax.validation</groupId>
165 <artifactId>validation-api</artifactId>
166 <version>2.0.1.Final</version>
167 </dependency>
168 <dependency>
169 <groupId>org.hibernate</groupId>
170 <artifactId>hibernate-validator</artifactId>
171 <version>5.2.4.Final</version>
172 </dependency>
173
174 <dependency>
175 <groupId>com.github.pagehelper</groupId>
176 <artifactId>pagehelper-spring-boot-starter</artifactId>
177 <version>1.2.5</version>
178 </dependency>
179 <dependency>
180 <groupId>org.springframework.boot</groupId>
181 <artifactId>spring-boot-starter-aop</artifactId>
182 <version>${org.spring.boot.version}</version>
183 </dependency>
184 <dependency>
185 <groupId>org.aspectj</groupId>
186 <artifactId>aspectjweaver</artifactId>
187 <version>1.9.4</version>
188 </dependency>
189 <dependency>
190 <groupId>com.alibaba</groupId>
191 <artifactId>fastjson</artifactId>
192 <version>1.2.60</version>
193 </dependency>
194 <dependency>
195 <groupId>org.springframework.data</groupId>
196 <artifactId>spring-data-redis</artifactId>
197 <version>2.1.10.RELEASE</version>
198 <scope>compile</scope>
199 </dependency>
200
201 <dependency>
202 <groupId>com.baomidou</groupId>
203 <artifactId>mybatis-plus-annotation</artifactId>
204 <version>3.3.2</version>
205 <scope>compile</scope>
206 </dependency>
207 <dependency>
208 <groupId>com.baomidou</groupId>
209 <artifactId>mybatis-plus-core</artifactId>
210 <version>3.3.2</version>
211 <scope>compile</scope>
212 </dependency>
213 <dependency>
214 <groupId>org.mapstruct</groupId>
215 <artifactId>mapstruct-jdk8</artifactId>
216 <version>${mapstruct.version}</version>
217 </dependency>
218 <dependency>
219 <groupId>org.mapstruct</groupId>
220 <artifactId>mapstruct-processor</artifactId>
221 <version>${mapstruct.version}</version>
222 </dependency>
223 <!--<dependency>-->
224 <!-- <groupId>polaris</groupId>-->
225 <!-- <artifactId>polaris-fileattachment</artifactId>-->
226 <!-- <version>1.0</version>-->
227 <!-- <scope>compile</scope>-->
228 <!--</dependency>-->
229 <dependency>
230 <groupId>io.minio</groupId>
231 <artifactId>minio</artifactId>
232 <version>6.0.11</version>
233 </dependency>
234
235 <dependency>
236 <groupId>com.google.zxing</groupId>
237 <artifactId>core</artifactId>
238 <version>3.4.1</version>
239 </dependency>
240
241 <dependency>
242 <groupId>com.oracle</groupId>
243 <artifactId>ojdbc6</artifactId>
244 <version>${oracle.version}</version>
245 </dependency>
246
247 <dependency>
248 <groupId>cn.hutool</groupId>
249 <artifactId>hutool-all</artifactId>
250 <version>5.6.0</version>
251 </dependency>
252 </dependencies>
253
254 <build>
255 <plugins>
256 <plugin>
257 <groupId>org.springframework.boot</groupId>
258 <artifactId>spring-boot-maven-plugin</artifactId>
259 <executions>
260 <execution>
261 <goals>
262 <goal>repackage</goal>
263 </goals>
264 </execution>
265 </executions>
266 </plugin>
267 <plugin>
268 <groupId>org.apache.maven.plugins</groupId>
269 <artifactId>maven-surefire-plugin</artifactId>
270 <version>2.22.2</version>
271 <configuration>
272 <skip>true</skip>
273 </configuration>
274 </plugin>
275 </plugins>
276
277 <resources>
278 <resource>
279 <directory>src/main/resources</directory>
280 <excludes>
281 <!--使用通配符,当然可以定义多个exclude标签进行排除-->
282 <exclude>application*.yml</exclude>
283 </excludes>
284 </resource>
285
286 <!--根据激活条件引入打包所需的配置和文件-->
287 <resource>
288 <directory>src/main/resources</directory>
289 <!--引入所需环境的配置文件-->
290 <filtering>true</filtering>
291 <includes>
292 <include>application.yml</include>
293 <!--根据maven选择环境导入配置文件-->
294 <include>application-${profile.active}.yml</include>
295 </includes>
296 </resource>
297 </resources>
298 </build>
299
300 <profiles>
301 <profile>
302 <!--不同环境的唯一id-->
303 <id>dev</id>
304 <activation>
305 <activeByDefault>true</activeByDefault>
306 </activation>
307 <properties>
308 <profile.active>dev</profile.active>
309 </properties>
310 </profile>
311
312 <!--生产环境-->
313 <profile>
314 <id>prod</id>
315 <properties>
316 <profile.active>prod</profile.active>
317 </properties>
318 </profile>
319 </profiles>
320
321 <properties>
322 <maven.compiler.source>11</maven.compiler.source>
323 <maven.compiler.target>11</maven.compiler.target>
324 <oracle.version>11.2.0.4</oracle.version>
325 <geotools.version>24-SNAPSHOT</geotools.version>
326 <org.springframework.version>5.1.8.RELEASE</org.springframework.version>
327 <org.spring.boot.version>2.1.8.RELEASE</org.spring.boot.version>
328 <org.spring.amqp>2.2.2.RELEASE</org.spring.amqp>
329 <org.spring.security.version>5.1.6.RELEASE</org.spring.security.version>
330 <!--<org.spring.session.version>2.1.4.RELEASE</org.spring.session.version>-->
331 <fasterxml.jackson.version>2.10.0</fasterxml.jackson.version>
332 <maven-deploy-plugin_version>2.8.2</maven-deploy-plugin_version>
333 <mybatis-plus.version>3.1.2</mybatis-plus.version>
334 <springfox.spring.web.version>2.9.2</springfox.spring.web.version>
335 <springfox.swagger2.version>2.9.2</springfox.swagger2.version>
336 <mapstruct.version>1.3.0.Final</mapstruct.version>
337 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
338 <maven.compiler.source>11</maven.compiler.source>
339 <maven.compiler.target>11</maven.compiler.target>
340 </properties>
341
342 </project>
1 package com.pashanhoo;
2
3 import org.mybatis.spring.annotation.MapperScan;
4 import org.springframework.boot.SpringApplication;
5 import org.springframework.boot.autoconfigure.SpringBootApplication;
6 import org.springframework.transaction.annotation.EnableTransactionManagement;
7
8 @SpringBootApplication(scanBasePackages={"com.pashanhoo"})
9 @EnableTransactionManagement
10 @MapperScan(basePackages = {"com.pashanhoo.**.mapper"})
11 public class Application {
12 public static void main(String[] args) {
13 SpringApplication app = new SpringApplication(Application.class);
14 app.run(args);
15 }
16 }
1 package com.pashanhoo;
2
3 import io.swagger.annotations.Api;
4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration;
6 import springfox.documentation.builders.ApiInfoBuilder;
7 import springfox.documentation.builders.PathSelectors;
8 import springfox.documentation.builders.RequestHandlerSelectors;
9 import springfox.documentation.service.ApiInfo;
10 import springfox.documentation.spi.DocumentationType;
11 import springfox.documentation.spring.web.plugins.Docket;
12 import springfox.documentation.swagger2.annotations.EnableSwagger2;
13
14 /**
15 * swagger配置类
16 */
17 @Configuration
18 @EnableSwagger2
19 public class SwaggerConfig {
20 @Bean
21 public Docket createRestApi() {
22 return new Docket(DocumentationType.SWAGGER_2)
23 .apiInfo(apiInfo())
24 .select()
25 // 为当前包路径
26 // .apis(RequestHandlerSelectors.basePackage("com.pashanhoo"))
27 .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
28 .paths(PathSelectors.any())
29 .build();
30 }
31
32 // 构建 api文档的详细信息函数,注意这里的注解引用的是哪个
33 private ApiInfo apiInfo() {
34 return new ApiInfoBuilder()
35 // 页面标题
36 .title("档案系统 接口文档")
37 // 版本号
38 .version("1.0")
39 // 描述
40 .description("API 描述")
41 .build();
42 }
43
44 }
1 package com.pashanhoo.common;
2
3 public interface CommonConstant {
4
5 /**
6 * 新增校验报错状态
7 */
8 Integer CHECK_ERROR_2002=2002;
9 /**
10 * {@code 500 Server Error} (HTTP/1.0 - RFC 1945)
11 */
12 Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
13 /**
14 * {@code 200 OK} (HTTP/1.0 - RFC 1945)
15 */
16 Integer SC_OK_200 = 200;
17
18 /**
19 * {@code 200 OK} (HTTP/1.0 - RFC 1945)
20 */
21 Integer SC_INFO_206 = 206;
22
23 /**
24 * {@code 200 OK} (HTTP/1.0 - RFC 1945)
25 */
26 Integer SC_INFO_210 = 210;
27
28 /**
29 * 字典信息缓存
30 */
31 String SYS_DICT_NAME = "sys:dict:name:";
32
33 /**
34 * 字典信息缓存
35 */
36 String SYS_DICT_ID = "sys:dict:id:";
37
38 /**
39 * 字典信息单条
40 */
41 String SYS_DICT_ALL = "sys:dict:all:";
42
43 /**
44 * 字典信息缓存
45 */
46 String SYS_DICT_CODE = "sys:dict:code:";
47
48 /**
49 * 菜单列表
50 */
51 String MENU_TREE = "sys:menu:";
52
53
54 }
1 package com.pashanhoo.common;
2
3 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
4 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data;
6
7 @Data
8 public class PageInfo {
9 @ApiModelProperty(name = "currentPage",value = "页码")
10 private Integer currentPage = 1;
11
12 @ApiModelProperty(name = "pageSize",value = "每页个数")
13 private Integer pageSize = 10;
14
15 @ApiModelProperty(name = "sortField",value = "排序字段" )
16 private String sortField;
17
18 @ApiModelProperty(name = "sortOrder",value = "升序(asc)或降序(desc)")
19 private String sortOrder;
20
21 public void defaultFillPageProp(String sortField, String sortOrder) {
22 if(StringUtils.isBlank(this.sortField)) {
23 this.sortField = sortField;
24 this.sortOrder = sortOrder;
25 }
26 }
27 }
1 package com.pashanhoo.common;
2
3 import com.fasterxml.jackson.annotation.JsonInclude;
4 import io.swagger.annotations.ApiModel;
5 import io.swagger.annotations.ApiModelProperty;
6
7 import java.io.Serializable;
8
9 @ApiModel(value = "接口返回对象", description = "接口返回对象")
10 @JsonInclude
11 public class Result<T> implements Serializable {
12
13 private static final long serialVersionUID = 1L;
14
15 /**
16 * 成功标志
17 */
18 @ApiModelProperty(value = "成功标志")
19 private boolean success = true;
20
21 /**
22 * 返回处理消息
23 */
24 @ApiModelProperty(value = "返回处理消息")
25 private String message = "操作成功!";
26
27 /**
28 * 返回代码
29 */
30 @ApiModelProperty(value = "返回代码")
31 private Integer code = 0;
32
33 /**
34 * 返回数据对象 data
35 */
36 @ApiModelProperty(value = "返回数据对象")
37 private T result;
38
39 /**
40 * 时间戳
41 */
42 @ApiModelProperty(value = "时间戳")
43 private long timestamp = System.currentTimeMillis();
44
45 public Result() {
46
47 }
48
49 public Result<T> success(String message) {
50 this.message = message;
51 this.code = CommonConstant.SC_OK_200;
52 this.success = true;
53 return this;
54 }
55
56
57 public static Result<Object> ok() {
58 Result<Object> r = new Result<Object>();
59 r.setSuccess(true);
60 r.setCode(CommonConstant.SC_OK_200);
61 r.setMessage("成功");
62 return r;
63 }
64
65 public static Result<Object> ok(String msg) {
66 Result<Object> r = new Result<Object>();
67 r.setSuccess(true);
68 r.setCode(CommonConstant.SC_OK_200);
69 r.setMessage(msg);
70 return r;
71 }
72
73 public static <T> Result<T> ok(T data) {
74 Result<T> r = new Result<T>();
75 r.setSuccess(true);
76 r.setCode(CommonConstant.SC_OK_200);
77 r.setResult(data);
78 return r;
79 }
80
81 public static Result<String> content(String data) {
82 Result<String> r = new Result<String>();
83 r.setSuccess(true);
84 r.setCode(CommonConstant.SC_OK_200);
85 r.setResult(data);
86 return r;
87 }
88 public static Result<Object> info(Object data) {
89 Result<Object> r = new Result<Object>();
90 r.setSuccess(false);
91 r.setCode(CommonConstant.SC_INFO_206);
92 r.setResult(data);
93 return r;
94 }
95
96 public static Result<Object> exception(String data) {
97 Result<Object> r = new Result<Object>();
98 r.setSuccess(false);
99 r.setCode(CommonConstant.SC_INFO_210);
100 r.setMessage(data);
101 return r;
102 }
103
104 public static <T> Result<T> ok(T data, String msg) {
105 Result<T> r = new Result<T>();
106 r.setSuccess(true);
107 r.setMessage(msg);
108 r.setCode(CommonConstant.SC_OK_200);
109 r.setResult(data);
110 return r;
111 }
112
113 public static Result<String> error(String msg) {
114 return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
115 }
116 public static Result<String> checkError(String msg) {
117 return error(CommonConstant.CHECK_ERROR_2002, msg);
118 }
119
120 public static Result<String> error(int code, String msg) {
121 Result<String> r = new Result<String>();
122 r.setCode(code);
123 r.setMessage(msg);
124 r.setSuccess(false);
125 return r;
126 }
127
128 public static <T> Result<T> error(String message, T data) {
129 Result<T> r = new Result<T>();
130 r.setMessage(message);
131 r.setResult(data);
132 r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
133 r.setSuccess(false);
134 return r;
135 }
136
137 public Result<T> error500(String message) {
138 this.message = message;
139 this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
140 this.success = false;
141 return this;
142 }
143
144 // /**
145 // * 无权限访问返回结果
146 // */
147 // public static Result<String> noauth(String msg) {
148 // return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg);
149 // }
150
151 public static long getSerialVersionUID() {
152 return serialVersionUID;
153 }
154
155 public boolean getSuccess() {
156 return success;
157 }
158
159 public void setSuccess(boolean success) {
160 this.success = success;
161 }
162
163 public String getMessage() {
164 return message;
165 }
166
167 public void setMessage(String message) {
168 this.message = message;
169 }
170
171 public Integer getCode() {
172 return code;
173 }
174
175 public void setCode(Integer code) {
176 this.code = code;
177 }
178
179 public T getResult() {
180 return result;
181 }
182
183 public void setResult(T result) {
184 this.result = result;
185 }
186
187 public long getTimestamp() {
188 return timestamp;
189 }
190
191 public void setTimestamp(long timestamp) {
192 this.timestamp = timestamp;
193 }
194
195 }
1 package com.pashanhoo.common.util;
2
3 import com.baomidou.mybatisplus.annotation.DbType;
4 import com.baomidou.mybatisplus.annotation.IdType;
5 import com.baomidou.mybatisplus.generator.AutoGenerator;
6 import com.baomidou.mybatisplus.generator.config.*;
7 import com.baomidou.mybatisplus.generator.config.rules.DateType;
8 import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
9 import com.pashanhoo.common.util.mybatisplus.MyFreemarkerTemplateEngine;
10
11
12 /**
13 * 代码自动生成器
14 */
15 public class CodeGenerator {
16 public static void main(String[] args) {
17 // 需要构建一个 代码自动生成器 对象
18 AutoGenerator mpg = new AutoGenerator();
19 // 配置策略
20 // 1、全局配置
21 GlobalConfig gc = new GlobalConfig();
22 String projectPath = System.getProperty("user.dir");
23 gc.setOutputDir(projectPath + "/src/main/java");
24 gc.setAuthor("");
25 gc.setOpen(false);
26 // 是否覆盖
27 gc.setFileOverride(false);
28 // 去Service的I前缀
29 // gc.setEntityName("%sDO");
30 gc.setServiceName("%sService");
31 gc.setServiceImplName("%sServiceImpl");
32 gc.setControllerName("%sController");
33 gc.setDateType(DateType.ONLY_DATE);
34
35 gc.setIdType(IdType.UUID);
36 // gc.setSwagger2(true); 实体属性 Swagger2 注解
37 mpg.setGlobalConfig(gc);
38 //2、设置数据源
39 DataSourceConfig dsc = new DataSourceConfig();
40 dsc.setUrl("jdbc:oracle:thin:@192.168.2.218:1521:orcl");
41 dsc.setDriverName("oracle.jdbc.driver.OracleDriver");
42 dsc.setUsername("bdcdjsb");
43 dsc.setPassword("bdcdjsb");
44 dsc.setDbType(DbType.ORACLE);
45 mpg.setDataSource(dsc);
46 //3、包的配置
47 PackageConfig pc = new PackageConfig();
48 //TODO
49 pc.setModuleName("system");
50 pc.setParent("com");
51 pc.setEntity("entity");
52 pc.setMapper("mapper");
53 pc.setService("service");
54 pc.setController("controller");
55 mpg.setPackageInfo(pc);
56
57 // 配置模板
58 TemplateConfig templateConfig = new TemplateConfig();
59
60 // 配置自定义输出模板
61 //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
62 templateConfig.setEntity("templates/entity2.java");
63 templateConfig.setMapper("templates/mapper2.java");
64 templateConfig.setService("templates/service2.java");
65 templateConfig.setServiceImpl("templates/serviceImpl2.java");
66 templateConfig.setController("templates/controller2.java");
67 templateConfig.setXml("templates/mapper2.xml");
68
69 mpg.setTemplate(templateConfig);
70
71 //4、策略配置
72 StrategyConfig strategy = new StrategyConfig();
73 // 设置要映射的表名
74 strategy.setInclude("DJF_DJ_SJ");
75 strategy.setNaming(NamingStrategy.underline_to_camel);
76 strategy.setColumnNaming(NamingStrategy.underline_to_camel);
77 // 自动lombok;
78 strategy.setEntityLombokModel(true);
79 mpg.setStrategy(strategy);
80
81 //设置Freemarker模板引擎
82 mpg.setTemplateEngine(new MyFreemarkerTemplateEngine());
83
84 mpg.execute(); //执行
85 }
86 }
1 package com.pashanhoo.common.util;
2
3 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
4 import com.google.common.collect.ArrayListMultimap;
5 import com.google.common.collect.Lists;
6 import com.google.common.collect.Multimap;
7 import org.apache.commons.collections.CollectionUtils;
8
9 import java.lang.reflect.InvocationTargetException;
10 import java.lang.reflect.Method;
11 import java.util.Collections;
12 import java.util.Comparator;
13 import java.util.List;
14
15 public class TreeUtil {
16
17 /**
18 * 比较规则
19 */
20 private static Comparator comparator;
21
22 /**
23 * 树节点Class类型
24 */
25 private static Class<?> treeNodeClass;
26
27 /**
28 * 主键的get方法对应的Method对象
29 */
30 private static Method getKeyMethod;
31
32 /**
33 * 获取父节点id的get方法对应的Method对象
34 */
35 private static Method getParentIdMethod;
36
37 /**
38 * 设置子元素对应的方法的Method对象
39 */
40 private static Method setChildrenMethod;
41
42 /**
43 * @param comparator
44 * @param treeNodeClass
45 * @param key 首字母大写的主键字段名称
46 */
47 public static void setRule(Comparator comparator, Class<?> treeNodeClass, String key) {
48 TreeUtil.comparator = comparator;
49 TreeUtil.treeNodeClass = treeNodeClass;
50 try {
51 TreeUtil.getKeyMethod = treeNodeClass.getMethod("get" + key);
52 TreeUtil.getParentIdMethod = treeNodeClass.getMethod("getParentId");
53 TreeUtil.setChildrenMethod = treeNodeClass.getMethod("setChildren", List.class);
54 } catch (NoSuchMethodException e) {
55 e.printStackTrace();
56 }
57
58 }
59
60 /**
61 * 将符合条件的List转为Tree
62 *
63 * @param
64 * @param rootId
65 * @return
66 */
67
68 public static <TreeNode> List<TreeNode> listToTree(List<TreeNode> treeNodes, String rootId) {
69 if (CollectionUtils.isEmpty(treeNodes)) {
70 return Lists.newArrayList();
71 }
72
73 //parent -> [data1, data2 ...]
74 Multimap<String, TreeNode> parentMap = ArrayListMultimap.create();
75 //记录parentMap
76 List<TreeNode> rootList = Lists.newArrayList();
77
78 for (TreeNode treeNode : treeNodes) {
79 String parentId = null;
80 try {
81 parentId = (String) getParentIdMethod.invoke(treeNode);
82 } catch (IllegalAccessException e) {
83 e.printStackTrace();
84 } catch (InvocationTargetException e) {
85 e.printStackTrace();
86 }
87
88 parentMap.put(parentId, treeNode);
89
90 //从根节点的下一级构造树
91
92 //rootId为null,从最顶部构造整棵树
93 if (rootId == null) {
94 if (parentId == null) {
95 rootList.add(treeNode);
96 }
97 }
98 if (StringUtils.isNotBlank(parentId) && parentId.equals(rootId)) {
99 rootList.add(treeNode);
100 }
101 }
102
103 // 对树节点进行排序
104 Collections.sort(rootList, comparator);
105
106 // 递归生成树
107 transformTree(rootList, parentMap);
108 return rootList;
109 }
110
111 private static <TreeNode> void transformTree(List<TreeNode> treeNodeList, Multimap<String, TreeNode> parentMap) {
112 for (int i = 0; i < treeNodeList.size(); i++) {
113 // 遍历该层的每个元素
114 TreeNode treeNode = treeNodeList.get(i);
115 //获取当前节点下一层节点的List数据
116 List<TreeNode> tempList = null;
117 try {
118 tempList = (List<TreeNode>) parentMap.get((String) getKeyMethod.invoke(treeNode));
119 } catch (IllegalAccessException e) {
120 e.printStackTrace();
121 } catch (InvocationTargetException e) {
122 e.printStackTrace();
123 }
124 if (CollectionUtils.isNotEmpty(tempList)) {
125 //首先排序下一层节点
126 Collections.sort(tempList, comparator);
127 //将下一层节点数据设置为当前节点的Children数据
128 try {
129 setChildrenMethod.invoke(treeNode, tempList);
130 } catch (IllegalAccessException e) {
131 e.printStackTrace();
132 } catch (InvocationTargetException e) {
133 e.printStackTrace();
134 }
135 // 进入到下一层处理
136 transformTree(tempList, parentMap);
137 }
138 }
139
140 }
141 }
1 package com.pashanhoo.common.util.mybatisplus;
2
3 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
4 import com.baomidou.mybatisplus.generator.InjectionConfig;
5 import com.baomidou.mybatisplus.generator.config.ConstVal;
6 import com.baomidou.mybatisplus.generator.config.FileOutConfig;
7 import com.baomidou.mybatisplus.generator.config.TemplateConfig;
8 import com.baomidou.mybatisplus.generator.config.po.TableField;
9 import com.baomidou.mybatisplus.generator.config.po.TableInfo;
10 import com.baomidou.mybatisplus.generator.config.rules.FileType;
11 import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
12
13 import java.io.File;
14 import java.util.*;
15
16 public abstract class AbstractTemplateEngineLocal extends AbstractTemplateEngine {
17
18 private void fitAddEntityRequest(List<TableField> tableFields, TableInfo tableInfo) {
19 for(Iterator<TableField> it = tableFields.iterator(); it.hasNext();){
20 TableField tableField =it.next();
21 if(tableField.isKeyIdentityFlag() || "ADDTIME".equals(tableField.getName()) || "EDITTIME".equals(tableField.getName())) {
22 it.remove();
23 }
24 }
25
26 Set<String> importPacks = tableInfo.getImportPackages();
27 for(Iterator<String> it = importPacks.iterator(); it.hasNext();){
28 String importPack = it.next();
29 if(importPack.indexOf("baomidou") > 0){
30 it.remove();
31 }
32 }
33
34 }
35
36 private void fillEntityProp(Map<String, Object> objectMap) {
37 TableInfo tableInfo = (TableInfo) objectMap.get("table");
38 int addFieldFillPacCount = 0;
39 for(TableField tableField : tableInfo.getFields()) {
40 tableField.setConvert(true);
41 if("ADDTIME".equals(tableField.getName())) {
42 tableField.setFill("INSERT");
43 if(addFieldFillPacCount == 0) {
44 tableInfo.getImportPackages().add("com.baomidou.mybatisplus.annotation.FieldFill");
45 addFieldFillPacCount++;
46 }
47 }
48 if("UPDATETIME".equals(tableField.getName())) {
49 tableField.setFill("INSERT_UPDATE");
50 }
51 }
52
53 }
54
55 /**
56 * list深度拷贝
57 * @param list
58 * @return
59 */
60 public List copyList(List list) {
61 //list深度拷贝
62 List<Integer> newList = new ArrayList<>();
63 org.apache.commons.collections.CollectionUtils.addAll(newList, new Object[list.size()]);
64 Collections.copy(newList, list);
65 return newList;
66 }
67
68 /**
69 * 输出 java xml 文件
70 */
71 @Override
72 public AbstractTemplateEngine batchOutput() {
73 try {
74 List<TableInfo> tableInfoList = getConfigBuilder().getTableInfoList();
75 for (TableInfo tableInfo : tableInfoList) {
76 Map<String, Object> objectMap = getObjectMap(tableInfo);
77 Map<String, String> pathInfo = getConfigBuilder().getPathInfo();
78 TemplateConfig template = getConfigBuilder().getTemplate();
79 // 自定义内容
80 InjectionConfig injectionConfig = getConfigBuilder().getInjectionConfig();
81 if (null != injectionConfig) {
82 injectionConfig.initTableMap(tableInfo);
83 objectMap.put("cfg", injectionConfig.getMap());
84 List<FileOutConfig> focList = injectionConfig.getFileOutConfigList();
85 if (CollectionUtils.isNotEmpty(focList)) {
86 for (FileOutConfig foc : focList) {
87 if (isCreate(FileType.OTHER, foc.outputFile(tableInfo))) {
88 writer(objectMap, foc.getTemplatePath(), foc.outputFile(tableInfo));
89 }
90 }
91 }
92 }
93 // Mp.java
94 String entityName = tableInfo.getEntityName();
95 List<TableField> originalTableFieldList = tableInfo.getFields();
96 if (null != entityName && null != pathInfo.get(ConstVal.ENTITY_PATH)) {
97 fillEntityProp(objectMap);
98 String entityFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + "DO" + suffixJavaOrKt()), entityName) ;
99 if (isCreate(FileType.ENTITY, entityFile)) {
100 writer(objectMap, templateFilePath(template.getEntity(getConfigBuilder().getGlobalConfig().isKotlin())), entityFile);
101 }
102
103 List<TableField> originalTableFields = tableInfo.getFields();
104 List<TableField> addEntityTableFieldList = copyList(tableInfo.getFields());
105 fitAddEntityRequest(addEntityTableFieldList, tableInfo);
106 tableInfo.setFields(addEntityTableFieldList);
107
108 //向ObjectMap中添加首字母小写的实体对象名
109 String entity = (String) objectMap.get("entity");
110 objectMap.put("lowerEntity", entity.toLowerCase());
111
112 //AddEntityRequest.java
113 fitAddEntityRequest(tableInfo.getFields(), tableInfo);
114 String addEntityRequestFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), "Add" + entityName + "Request");
115 if (isCreate(FileType.ENTITY, addEntityRequestFile)) {
116 writer(objectMap, "templates/AddEntityRequest.java.ftl", addEntityRequestFile);
117 }
118
119 //UpdateEntityRequest.java
120 fitAddEntityRequest(tableInfo.getFields(), tableInfo);
121 String updateEntityRequestFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), "Update" + entityName + "Request");
122 if (isCreate(FileType.ENTITY, updateEntityRequestFile)) {
123 writer(objectMap, "templates/UpdateEntityRequest.java.ftl", updateEntityRequestFile);
124 }
125
126
127 //EntitySearchRequest.java
128 String entitySearchRequestFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), entityName + "SearchRequest");
129 if (isCreate(FileType.ENTITY, entitySearchRequestFile)) {
130 writer(objectMap, "templates/EntitySearchRequest.java.ftl", entitySearchRequestFile);
131 }
132
133 tableInfo.setFields(originalTableFields);
134 //EntityListVO.java
135 String entityListVOFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), entityName + "ListVO");
136 if (isCreate(FileType.ENTITY, entityListVOFile)) {
137 writer(objectMap, "templates/EntityListVO.java.ftl", entityListVOFile);
138 }
139
140 //EntityDetailVO.java
141 String entityDetailVOFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), entityName + "DetailVO");
142 if (isCreate(FileType.ENTITY, entityDetailVOFile)) {
143 writer(objectMap, "templates/EntityDetailVO.java.ftl", entityDetailVOFile);
144 }
145 }
146
147 //converter.java
148 String entityConverterFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), entityName + "Converter");
149 if (isCreate(FileType.ENTITY, entityConverterFile)) {
150 writer(objectMap, "templates/entityConverter.java.ftl", entityConverterFile);
151 }
152
153 // MpMapper.java
154 if (null != tableInfo.getMapperName() && null != pathInfo.get(ConstVal.MAPPER_PATH)) {
155 String mapperFile = String.format((pathInfo.get(ConstVal.MAPPER_PATH) + File.separator + tableInfo.getMapperName() + suffixJavaOrKt()), entityName);
156 if (isCreate(FileType.MAPPER, mapperFile)) {
157 writer(objectMap, templateFilePath(template.getMapper()), mapperFile);
158 }
159 }
160 // MpMapper.xml
161 if (null != tableInfo.getXmlName() && null != pathInfo.get(ConstVal.XML_PATH)) {
162 String xmlFile = String.format((pathInfo.get(ConstVal.XML_PATH) + File.separator + tableInfo.getXmlName() + ConstVal.XML_SUFFIX), entityName);
163 if (isCreate(FileType.XML, xmlFile)) {
164 writer(objectMap, templateFilePath(template.getXml()), xmlFile);
165 }
166 }
167
168 // IMpService.java
169 if (null != tableInfo.getServiceName() && null != pathInfo.get(ConstVal.SERVICE_PATH)) {
170 String serviceFile = String.format((pathInfo.get(ConstVal.SERVICE_PATH) + File.separator + tableInfo.getServiceName() + suffixJavaOrKt()), entityName);
171 if (isCreate(FileType.SERVICE, serviceFile)) {
172 writer(objectMap, templateFilePath(template.getService()), serviceFile);
173 }
174 }
175 // MpServiceImpl.java
176 if (null != tableInfo.getServiceImplName() && null != pathInfo.get(ConstVal.SERVICE_IMPL_PATH)) {
177 String implFile = String.format((pathInfo.get(ConstVal.SERVICE_IMPL_PATH) + File.separator + tableInfo.getServiceImplName() + suffixJavaOrKt()), entityName);
178 if (isCreate(FileType.SERVICE_IMPL, implFile)) {
179 writer(objectMap, templateFilePath(template.getServiceImpl()), implFile);
180 }
181 }
182 // MpController.java
183 if (null != tableInfo.getControllerName() && null != pathInfo.get(ConstVal.CONTROLLER_PATH)) {
184 String controllerFile = String.format((pathInfo.get(ConstVal.CONTROLLER_PATH) + File.separator + tableInfo.getControllerName() + suffixJavaOrKt()), entityName);
185 if (isCreate(FileType.CONTROLLER, controllerFile)) {
186 writer(objectMap, templateFilePath(template.getController()), controllerFile);
187 }
188 }
189 }
190 } catch (Exception e) {
191 logger.error("无法创建文件,请检查配置信息!", e);
192 }
193 return this;
194 }
195
196 }
1 package com.pashanhoo.common.util.mybatisplus;
2
3 import com.baomidou.mybatisplus.core.toolkit.StringPool;
4 import com.baomidou.mybatisplus.generator.config.ConstVal;
5 import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
6 import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
7 import freemarker.template.Configuration;
8 import freemarker.template.Template;
9
10 import java.io.FileOutputStream;
11 import java.io.OutputStreamWriter;
12 import java.util.Map;
13
14 public class MyFreemarkerTemplateEngine extends AbstractTemplateEngineLocal {
15
16 private Configuration configuration;
17
18 @Override
19 public MyFreemarkerTemplateEngine init(ConfigBuilder configBuilder) {
20 super.init(configBuilder);
21 configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
22 configuration.setDefaultEncoding(ConstVal.UTF8);
23 configuration.setClassForTemplateLoading(FreemarkerTemplateEngine.class, StringPool.SLASH);
24 return this;
25 }
26
27
28 @Override
29 public void writer(Map<String, Object> objectMap, String templatePath, String outputFile) throws Exception {
30 Template template = configuration.getTemplate(templatePath);
31 try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile)) {
32 template.process(objectMap, new OutputStreamWriter(fileOutputStream, ConstVal.UTF8));
33 }
34 logger.debug("模板:" + templatePath + "; 文件:" + outputFile);
35 }
36
37
38 @Override
39 public String templateFilePath(String filePath) {
40 return filePath + ".ftl";
41 }
42
43 }
1 package com.pashanhoo.config;
2
3 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration;
6
7 @Configuration
8 public class MybatisPlusConfig {
9 /**
10 * 分页插件
11 */
12 @Bean
13 public PaginationInterceptor paginationInterceptor() {
14 return new PaginationInterceptor();
15 }
16
17 }
1 package com.pashanhoo.dictionary.controller;
2
3 import com.github.pagehelper.PageInfo;
4 import com.pashanhoo.common.Result;
5 import com.pashanhoo.common.util.TreeUtil;
6 import com.pashanhoo.dictionary.model.dto.SysDict;
7 import com.pashanhoo.dictionary.model.vo.EditDictVo;
8 import com.pashanhoo.dictionary.model.vo.GetSysDictParentVo;
9 import com.pashanhoo.dictionary.model.vo.SysDictVo;
10 import com.pashanhoo.dictionary.service.SysDictService;
11 import io.swagger.annotations.Api;
12 import io.swagger.annotations.ApiOperation;
13 import io.swagger.annotations.ApiParam;
14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.web.bind.annotation.*;
16
17 import java.util.Comparator;
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 @Api(tags = "字典表")
23 @RestController
24 @RequestMapping("/SysDict")
25 public class SysDictController {
26
27
28 @Autowired
29 SysDictService sysDictService;
30
31 @ApiOperation("获取字典表父级集合")
32 @PostMapping("getSysDictParent")
33 public Result<PageInfo<GetSysDictParentVo>> getSysDictParent(@RequestBody SysDictVo request) {
34 return Result.ok(sysDictService.getSysDictParent(request));
35 }
36
37 @ApiOperation("编辑界面获取指定字典编码子集")
38 @GetMapping("getSysDictByTypeId")
39 public Result<List<SysDict>> getSysDictByTypeId(@ApiParam("类型ID") @RequestParam String typeId) {
40 List<SysDict> dicts = sysDictService.getSysDictByTypeId(typeId);
41 TreeUtil.setRule((o1, o2) -> 0, SysDict.class,"DictId");
42 List<SysDict> tree = TreeUtil.listToTree(dicts, typeId);
43 return Result.ok(tree);
44 }
45
46 @ApiOperation("编辑")
47 @PostMapping("editSysDictByTypeId")
48 public Result editSysDictByTypeId(@RequestBody EditDictVo request) {
49 int row = sysDictService.editSysDict(request);
50 if (row != 0) {
51 return Result.ok("修改成功");
52 } else {
53 return Result.ok("修改失败");
54 }
55 }
56
57 @ApiOperation("返回json")
58 @GetMapping("getJson")
59 public Result getJson() {
60 List<SysDict> dicts = sysDictService.selectAll();
61 TreeUtil.setRule(new Comparator<SysDict>() {
62 @Override
63 public int compare(SysDict o1, SysDict o2) {
64 if (o1.getSort() == null) {
65 o1.setSort((short) 0);
66 }
67 if (o2.getSort() == null) {
68 o2.setSort((short) 0);
69 }
70 return o1.getSort() - o2.getSort();
71 }
72 }, SysDict.class, "DictId");
73 List<SysDict> tree = TreeUtil.listToTree(dicts, null);
74
75 Map<String, List<SysDict>> map = new HashMap<>();
76 for (SysDict SYSDICT : tree) {
77 map.put(SYSDICT.getDcode(), SYSDICT.getChildren());
78 }
79 return Result.ok(map);
80 }
81 }
1 package com.pashanhoo.dictionary.dao;
2
3 import com.pashanhoo.dictionary.model.dto.SysDict;
4 import com.pashanhoo.dictionary.model.vo.GetSysDictParentVo;
5 import com.pashanhoo.dictionary.model.vo.SysDictVo;
6 import org.apache.ibatis.annotations.Mapper;
7 import org.apache.ibatis.annotations.Param;
8
9 import java.util.List;
10
11 @Mapper
12 public interface SysDictMapper {
13 /**
14 * delete by primary key
15 *
16 * @param dictid primaryKey
17 * @return deleteCount
18 */
19 int deleteByPrimaryKey(String dictid);
20
21 /**
22 * insert record to table
23 *
24 * @param record the record
25 * @return insert count
26 */
27 int insert(SysDict record);
28
29 /**
30 * insert record to table selective
31 *
32 * @param record the record
33 * @return insert count
34 */
35 int insertSelective(SysDict record);
36
37 /**
38 * select by primary key
39 *
40 * @param dictid primary key
41 * @return object by primary key
42 */
43 SysDict selectByPrimaryKey(String dictid);
44
45 /**
46 * update record selective
47 *
48 * @param record the updated record
49 * @return update count
50 */
51 int updateByPrimaryKeySelective(SysDict record);
52
53 /**
54 * update record
55 *
56 * @param record the updated record
57 * @return update count
58 */
59 int updateByPrimaryKey(SysDict record);
60
61 int updateBatch(List<SysDict> list);
62
63 int updateBatchSelective(List<SysDict> list);
64
65 int batchInsert(@Param("list") List<SysDict> list);
66
67 List<GetSysDictParentVo> getSysDictParent(@Param("request") SysDictVo request);
68
69 List<SysDict> getSysDictByTypeId(@Param("typeId") String typeId);
70
71 int deleteListByPrimaryKey(@Param("dictWithoutParent") List<SysDict> dictWithoutParent);
72
73 List<SysDict> selectAll();
74
75 int deleteByTypeId(@Param("typeid") String typeid);
76 }
1 package com.pashanhoo.dictionary.model.dto;
2
3 import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data;
6
7 import java.io.Serializable;
8 import java.util.List;
9
10 /**
11 * 字典表
12 */
13 @ApiModel(value = "extraction-model-SysDict")
14 @Data
15 public class SysDict implements Serializable {
16 /**
17 * 字典主键
18 */
19 @ApiModelProperty(value = "字典主键")
20 private String dictId;
21
22 /**
23 * 父级ID
24 */
25 @ApiModelProperty(value = "父级ID")
26 private String parentId;
27
28 /**
29 * 字典编码
30 */
31 @ApiModelProperty(value = "字典编码")
32 private String dcode;
33
34 /**
35 * 字典名称
36 */
37 @ApiModelProperty(value = "字典名称")
38 private String dname;
39
40 /**
41 * 排序号
42 */
43 @ApiModelProperty(value = "排序号")
44 private Short sort;
45
46 /**
47 * 是否树形
48 */
49 @ApiModelProperty(value = "是否树形")
50 private String isTree;
51
52 /**
53 * 类型ID
54 */
55 @ApiModelProperty(value = "类型ID")
56 private String typeId;
57
58 private List<SysDict> children;
59
60 private static final long serialVersionUID = 1L;
61 }
1 package com.pashanhoo.dictionary.model.vo;
2
3 import com.pashanhoo.dictionary.model.dto.SysDict;
4 import io.swagger.annotations.ApiModel;
5 import lombok.Data;
6 import lombok.EqualsAndHashCode;
7
8 import java.util.List;
9
10 @Data
11 @ApiModel("字典表编辑请求实体")
12 @EqualsAndHashCode(callSuper = false)
13 public class EditDictVo {
14
15 List<SysDict> editDicts;
16 }
1 package com.pashanhoo.dictionary.model.vo;
2
3 import com.pashanhoo.dictionary.model.dto.SysDict;
4 import io.swagger.annotations.ApiModel;
5 import io.swagger.annotations.ApiModelProperty;
6 import lombok.Data;
7 import lombok.EqualsAndHashCode;
8
9 import java.util.List;
10
11 @Data
12 @ApiModel("获取字典表父级集合实体")
13 @EqualsAndHashCode(callSuper = false)
14 public class GetSysDictParentVo {
15
16 /**
17 * 字典主键
18 */
19 @ApiModelProperty(value = "字典主键")
20 private String dictId;
21
22 /**
23 * 父级ID
24 */
25 @ApiModelProperty(value = "父级ID")
26 private String parentId;
27
28 /**
29 * 字典编码
30 */
31 @ApiModelProperty(value = "字典编码")
32 private String dcode;
33
34 /**
35 * 字典名称
36 */
37 @ApiModelProperty(value = "字典名称")
38 private String dname;
39
40 /**
41 * 排序号
42 */
43 @ApiModelProperty(value = "排序号")
44 private Short sort;
45
46 /**
47 * 是否树形
48 */
49 @ApiModelProperty(value = "是否树形")
50 private String isTree;
51
52 /**
53 * 类型ID
54 */
55 @ApiModelProperty(value = "类型ID")
56 private String typeId;
57
58 /**
59 * 序号
60 */
61 @ApiModelProperty(value = "序号")
62 private Integer rowNum;
63
64 private List<SysDict> children;
65
66 private static final long serialVersionUID = 1L;
67 }
1 package com.pashanhoo.dictionary.model.vo;
2
3 import com.pashanhoo.common.PageInfo;
4 import io.swagger.annotations.ApiModel;
5 import io.swagger.annotations.ApiModelProperty;
6 import lombok.Data;
7 import lombok.EqualsAndHashCode;
8
9 import java.io.Serializable;
10
11 @Data
12 @ApiModel("字典表请求实体")
13 @EqualsAndHashCode(callSuper = false)
14 public class SysDictVo extends PageInfo implements Serializable {
15
16 /**
17 * 字典编码
18 */
19 @ApiModelProperty(value = "字典编码")
20 private String dcode;
21
22 /**
23 * 字典名称
24 */
25 @ApiModelProperty(value = "字典名称")
26 private String dname;
27
28 /**
29 * 类型ID
30 */
31 @ApiModelProperty(value = "类型ID")
32 private String typeId;
33 }
1 package com.pashanhoo.dictionary.service;
2
3 import com.github.pagehelper.PageInfo;
4 import com.pashanhoo.dictionary.model.dto.SysDict;
5 import com.pashanhoo.dictionary.model.vo.EditDictVo;
6 import com.pashanhoo.dictionary.model.vo.GetSysDictParentVo;
7 import com.pashanhoo.dictionary.model.vo.SysDictVo;
8
9 import java.util.List;
10
11 public interface SysDictService {
12
13 /**
14 * 删除
15 * @param dictid
16 * @return
17 */
18 int deleteByPrimaryKey(String dictid);
19
20 /**
21 * 插入
22 * @param record
23 * @return
24 */
25 int insert(SysDict record);
26
27 /**
28 * 插入
29 * @param record
30 * @return
31 */
32 int insertSelective(SysDict record);
33
34 /**
35 * 查询
36 * @param dictid
37 * @return
38 */
39 SysDict selectByPrimaryKey(String dictid);
40
41 /**
42 * 更新
43 * @param record
44 * @return
45 */
46 int updateByPrimaryKeySelective(SysDict record);
47
48 /**
49 * 更新
50 * @param record
51 * @return
52 */
53 int updateByPrimaryKey(SysDict record);
54
55 /**
56 * 批量更新
57 * @param list
58 * @return
59 */
60 int updateBatch(List<SysDict> list);
61
62 /**
63 * 批量更新
64 * @param list
65 * @return
66 */
67 int updateBatchSelective(List<SysDict> list);
68
69 /**
70 * 批量插入
71 * @param list
72 * @return
73 */
74 int batchInsert(List<SysDict> list);
75
76 /**
77 * 获取父级字典表
78 * @param request
79 * @return
80 */
81 PageInfo<GetSysDictParentVo> getSysDictParent(SysDictVo request);
82
83 /**
84 * 根据typeId查询
85 * @param typeId
86 * @return
87 */
88 List<SysDict> getSysDictByTypeId(String typeId);
89
90 /**
91 * 编辑字典表
92 * @param request
93 * @return
94 */
95 int editSysDict(EditDictVo request);
96
97 /**
98 * 查询全部
99 * @return
100 */
101 List<SysDict> selectAll();
102
103 }
1 package com.pashanhoo.dictionary.service.impl;
2
3 import com.github.pagehelper.PageHelper;
4 import com.github.pagehelper.PageInfo;
5 import com.pashanhoo.dictionary.dao.SysDictMapper;
6 import com.pashanhoo.dictionary.model.dto.SysDict;
7 import com.pashanhoo.dictionary.model.vo.EditDictVo;
8 import com.pashanhoo.dictionary.model.vo.GetSysDictParentVo;
9 import com.pashanhoo.dictionary.model.vo.SysDictVo;
10 import com.pashanhoo.dictionary.service.SysDictService;
11 import org.springframework.stereotype.Service;
12 import org.springframework.transaction.annotation.Transactional;
13
14 import javax.annotation.Resource;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.stream.Collectors;
18
19 @Service
20 public class SysDictServiceImpl implements SysDictService {
21
22 @Resource
23 private SysDictMapper sysDictMapper;
24
25 /**
26 * 查询
27 * @param dictid
28 * @return
29 */
30 @Override
31 public int deleteByPrimaryKey(String dictid) {
32 return sysDictMapper.deleteByPrimaryKey(dictid);
33 }
34
35 /**
36 * 插入
37 * @param record
38 * @return
39 */
40 @Override
41 public int insert(SysDict record) {
42 return sysDictMapper.insert(record);
43 }
44
45 /**
46 * 插入
47 * @param record
48 * @return
49 */
50 @Override
51 public int insertSelective(SysDict record) {
52 return sysDictMapper.insertSelective(record);
53 }
54
55 /**
56 * 查询
57 * @param dictid
58 * @return
59 */
60 @Override
61 public SysDict selectByPrimaryKey(String dictid) {
62 return sysDictMapper.selectByPrimaryKey(dictid);
63 }
64
65 /**
66 * 更新
67 * @param record
68 * @return
69 */
70 @Override
71 public int updateByPrimaryKeySelective(SysDict record) {
72 return sysDictMapper.updateByPrimaryKeySelective(record);
73 }
74
75 /**
76 * 更新
77 * @param record
78 * @return
79 */
80 @Override
81 public int updateByPrimaryKey(SysDict record) {
82 return sysDictMapper.updateByPrimaryKey(record);
83 }
84
85 /**
86 * 批量更新
87 * @param list
88 * @return
89 */
90 @Override
91 public int updateBatch(List<SysDict> list) {
92 return sysDictMapper.updateBatch(list);
93 }
94
95 /**
96 * 批量更新
97 * @param list
98 * @return
99 */
100 @Override
101 public int updateBatchSelective(List<SysDict> list) {
102 return sysDictMapper.updateBatchSelective(list);
103 }
104
105 /**
106 * 批量插入
107 * @param list
108 * @return
109 */
110 @Override
111 public int batchInsert(List<SysDict> list) {
112 return sysDictMapper.batchInsert(list);
113 }
114
115 /**
116 * 获取父级字典表
117 * @param request
118 * @return
119 */
120 @Override
121 public PageInfo<GetSysDictParentVo> getSysDictParent(SysDictVo request) {
122 PageHelper.startPage(request.getCurrentPage(), request.getPageSize());
123 List<GetSysDictParentVo> list = sysDictMapper.getSysDictParent(request);
124 return new PageInfo<>(list);
125 }
126
127 /**
128 * 根据typeId查询字典表
129 * @param typeId
130 * @return
131 */
132 @Override
133 public List<SysDict> getSysDictByTypeId(String typeId) {
134 return sysDictMapper.getSysDictByTypeId(typeId);
135 }
136
137 /**
138 * root节点只做更新,子节点全部删除再批量插入
139 * @param request
140 * @return
141 */
142 @Override
143 @Transactional(rollbackFor = Exception.class)
144 public int editSysDict(EditDictVo request) {
145 List<SysDict> editDicts = request.getEditDicts();
146 List<SysDict> parent = editDicts.stream().filter(item -> item.getParentId() == null).collect(Collectors.toList());
147 sysDictMapper.updateByPrimaryKey(parent.get(0));
148
149 List<SysDict> dictWithoutParent = editDicts.stream().filter(item -> item.getParentId() != null).collect(Collectors.toList());
150 List<SysDict> result = new ArrayList<>();
151 //递归所有子集
152 List<SysDict> resultList = getAllSysDict(dictWithoutParent,result);
153
154 //删除除了根目录的所有子集
155 sysDictMapper.deleteByTypeId(resultList.get(0).getTypeId());
156 return sysDictMapper.batchInsert(resultList);
157 }
158
159 /**
160 * 查询所有字典表
161 * @return
162 */
163 @Override
164 public List<SysDict> selectAll() {
165 return sysDictMapper.selectAll();
166 }
167
168
169 private List<SysDict> getAllSysDict(List<SysDict> dicts, List<SysDict> result) {
170
171 for (SysDict SYSDICT : dicts) {
172 List<SysDict> children = SYSDICT.getChildren();
173 result.add(SYSDICT);
174 if (children != null) {
175 getAllSysDict(children, result);
176 }
177 }
178
179 return result;
180 }
181
182 }
1 server:
2 port: 8866
3 servlet:
4 session:
5 timeout: 43200
6
7 spring:
8 servlet:
9 multipart:
10 maxFileSize: 10MB
11 maxRequestSize: 10MB
12 application:
13 name: archive-system
14 profiles:
15 active: dev
16 jackson:
17 time-zone: GMT+8
18 date-format: yyyy-MM-dd HH:mm:ss
19 default-property-inclusion: non_null
20 datasource:
21 driver-class-name: oracle.jdbc.driver.OracleDriver
22 username: bdcdjsb
23 password: bdcdjsb
24 url: jdbc:oracle:thin:@192.168.2.218:1521:orcl
25
26 mybatis-plus:
27 mapper-locations: classpath:mapper/**/*.xml
28 typeAliasesPackage: archive
29 global-config:
30 #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
31 id-type: 2
32 #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
33 field-strategy: 1
34 #驼峰下划线转换
35 db-column-underline: true
36 #刷新mapper 调试神器
37 refresh-mapper: true
38 #数据库大写下划线转换
39 #capital-mode: true
40 #序列接口实现类配置
41 #key-generator: com.baomidou.springboot.xxx
42 #逻辑删除配置
43 logic-delete-value: -1
44 logic-not-delete-0: 0
45 #自定义填充策略接口实现
46 #meta-object-handler: com.baomidou.springboot.xxx
47 #自定义SQL注入器
48 # sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
49 configuration:
50 map-underscore-to-camel-case: true
51 cache-enabled: false
52 call-setters-on-nulls: true
53 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
54
55 management:
56 endpoints:
57 web:
58 exposure:
59 include: "*"
60
61 logging:
62 level:
63 rent:
64 mapper: debug
65 config: "classpath:logback-spring.xml"
66
67 #app:
68 # attachment[0]:
69 # name: S1
70 # type: minIO
71 # params:
72 # type: http://
73 # bucket: archiveSystem
74 # host: 192.168.2.218
75 # port: 9000
76 # user: minioadmin
77 # password: minioadmin
1 spring:
2 profiles:
3 active: @profile.active@
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
3 <!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
4 <!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
5 <!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
6 <configuration scan="true" scanPeriod="10 seconds">
7
8 <!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
9
10 <contextName>logback</contextName>
11 <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
12 <property name="log.path" value="/home/project/logs" />
13
14 <!-- 彩色日志 -->
15 <!-- 彩色日志依赖的渲染类 -->
16 <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
17 <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
18 <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
19 <!-- 彩色日志格式 -->
20 <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
21
22
23 <!--输出到控制台-->
24 <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
25 <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
26 <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
27 <level>debug</level>
28 </filter>
29 <encoder>
30 <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
31 <!-- 设置字符集 -->
32 <charset>UTF-8</charset>
33 </encoder>
34 </appender>
35
36
37 <!--输出到文件-->
38
39 <!-- 时间滚动输出 level为 DEBUG 日志 -->
40 <!-- <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
41 <!-- &lt;!&ndash; 正在记录的日志文件的路径及文件名 &ndash;&gt;-->
42 <!-- <file>${log.path}/log_debug.log</file>-->
43 <!-- &lt;!&ndash;日志文件输出格式&ndash;&gt;-->
44 <!-- <encoder>-->
45 <!-- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>-->
46 <!-- <charset>UTF-8</charset> &lt;!&ndash; 设置字符集 &ndash;&gt;-->
47 <!-- </encoder>-->
48 <!-- &lt;!&ndash; 日志记录器的滚动策略,按日期,按大小记录 &ndash;&gt;-->
49 <!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
50 <!-- &lt;!&ndash; 日志归档 &ndash;&gt;-->
51 <!-- <fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
52 <!-- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
53 <!-- <maxFileSize>100MB</maxFileSize>-->
54 <!-- </timeBasedFileNamingAndTriggeringPolicy>-->
55 <!-- &lt;!&ndash;日志文件保留天数&ndash;&gt;-->
56 <!-- <maxHistory>15</maxHistory>-->
57 <!-- </rollingPolicy>-->
58 <!-- &lt;!&ndash; 此日志文件只记录debug级别的 &ndash;&gt;-->
59 <!-- <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
60 <!-- <level>debug</level>-->
61 <!-- <onMatch>ACCEPT</onMatch>-->
62 <!-- <onMismatch>DENY</onMismatch>-->
63 <!-- </filter>-->
64 <!-- </appender>-->
65
66 <!-- 时间滚动输出 level为 INFO 日志 -->
67 <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
68 <!-- 正在记录的日志文件的路径及文件名 -->
69 <file>${log.path}/log_info.log</file>
70 <!--日志文件输出格式-->
71 <encoder>
72 <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
73 <charset>UTF-8</charset>
74 </encoder>
75 <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
76 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
77 <!-- 每天日志归档路径以及格式 -->
78 <fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
79 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
80 <maxFileSize>100MB</maxFileSize>
81 </timeBasedFileNamingAndTriggeringPolicy>
82 <!--日志文件保留天数-->
83 <maxHistory>15</maxHistory>
84 </rollingPolicy>
85 <!-- 此日志文件只记录info级别的 -->
86 <filter class="ch.qos.logback.classic.filter.LevelFilter">
87 <level>info</level>
88 <onMatch>ACCEPT</onMatch>
89 <onMismatch>DENY</onMismatch>
90 </filter>
91 </appender>
92
93 <!-- 时间滚动输出 level为 WARN 日志 -->
94 <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
95 <!-- 正在记录的日志文件的路径及文件名 -->
96 <file>${log.path}/log_warn.log</file>
97 <!--日志文件输出格式-->
98 <encoder>
99 <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
100 <charset>UTF-8</charset> <!-- 此处设置字符集 -->
101 </encoder>
102 <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
103 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
104 <fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
105 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
106 <maxFileSize>100MB</maxFileSize>
107 </timeBasedFileNamingAndTriggeringPolicy>
108 <!--日志文件保留天数-->
109 <maxHistory>15</maxHistory>
110 </rollingPolicy>
111 <!-- 此日志文件只记录warn级别的 -->
112 <filter class="ch.qos.logback.classic.filter.LevelFilter">
113 <level>warn</level>
114 <onMatch>ACCEPT</onMatch>
115 <onMismatch>DENY</onMismatch>
116 </filter>
117 </appender>
118 <logger name="house.platform.mapper" level="DEBUG" />
119
120 <!-- 时间滚动输出 level为 ERROR 日志 -->
121 <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
122 <!-- 正在记录的日志文件的路径及文件名 -->
123 <file>${log.path}/log_error.log</file>
124 <!--日志文件输出格式-->
125 <encoder>
126 <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
127 <charset>UTF-8</charset> <!-- 此处设置字符集 -->
128 </encoder>
129 <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
130 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
131 <fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
132 <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
133 <maxFileSize>100MB</maxFileSize>
134 </timeBasedFileNamingAndTriggeringPolicy>
135 <!--日志文件保留天数-->
136 <maxHistory>15</maxHistory>
137 </rollingPolicy>
138 <!-- 此日志文件只记录ERROR级别的 -->
139 <filter class="ch.qos.logback.classic.filter.LevelFilter">
140 <level>ERROR</level>
141 <onMatch>ACCEPT</onMatch>
142 <onMismatch>DENY</onMismatch>
143 </filter>
144 </appender>
145
146 <!--
147 <logger>用来设置某一个包或者具体的某一个类的日志打印级别、
148 以及指定<appender>。<logger>仅有一个name属性,
149 一个可选的level和一个可选的addtivity属性。
150 name:用来指定受此logger约束的某一个包或者具体的某一个类。
151 level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
152 还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
153 如果未设置此属性,那么当前logger将会继承上级的级别。
154 addtivity:是否向上级logger传递打印信息。默认是true。
155 -->
156 <!--<logger name="org.springframework.web" level="info"/>-->
157 <!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
158 <!--
159 使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
160 第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
161 第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
162 -->
163
164
165 <!--
166 root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
167 level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
168 不能设置为INHERITED或者同义词NULL。默认是DEBUG
169 可以包含零个或多个元素,标识这个appender将会添加到这个logger。
170 -->
171
172 <!--开发环境:打印控制台-->
173 <springProfile name="dev">
174 <logger name="com.house" level="info"/>
175 </springProfile>
176
177 <root level="INFO">
178 <appender-ref ref="CONSOLE" />
179 <!-- <appender-ref ref="DEBUG_FILE" />-->
180 <appender-ref ref="INFO_FILE" />
181 <appender-ref ref="WARN_FILE" />
182 <appender-ref ref="ERROR_FILE" />
183 </root>
184
185 <!--生产环境:输出到文件-->
186 <!--<springProfile name="pro">-->
187 <!--<root level="info">-->
188 <!--<appender-ref ref="CONSOLE" />-->
189 <!--<appender-ref ref="DEBUG_FILE" />-->
190 <!--<appender-ref ref="INFO_FILE" />-->
191 <!--<appender-ref ref="ERROR_FILE" />-->
192 <!--<appender-ref ref="WARN_FILE" />-->
193 <!--</root>-->
194 <!--</springProfile>-->
195
196 </configuration>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="com.pashanhoo.dictionary.dao.SysDictMapper">
4 <resultMap id="BaseResultMap" type="com.pashanhoo.dictionary.model.dto.SysDict">
5 <!--@mbg.generated-->
6 <!--@Table SYS_DICT-->
7 <id column="DICTID" jdbcType="VARCHAR" property="dictId"/>
8 <result column="PARENTID" jdbcType="VARCHAR" property="parentId"/>
9 <result column="DCODE" jdbcType="VARCHAR" property="dcode"/>
10 <result column="DNAME" jdbcType="VARCHAR" property="dname"/>
11 <result column="SORT" jdbcType="DECIMAL" property="sort"/>
12 <result column="ISTREE" jdbcType="CHAR" property="isTree"/>
13 <result column="TYPEID" jdbcType="VARCHAR" property="typeId"/>
14 </resultMap>
15 <sql id="Base_Column_List">
16 <!--@mbg.generated-->
17 DICTID, PARENTID, DCODE, DNAME, SORT, ISTREE, TYPEID
18 </sql>
19 <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
20 <!--@mbg.generated-->
21 select
22 <include refid="Base_Column_List"/>
23 from SYS_DICT
24 where DICTID = #{dictid,jdbcType=VARCHAR}
25 </select>
26 <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
27 <!--@mbg.generated-->
28 delete
29 from SYS_DICT
30 where DICTID = #{dictid,jdbcType=VARCHAR}
31 </delete>
32 <insert id="insert" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
33 <!--@mbg.generated-->
34 insert into SYS_DICT (DICTID, PARENTID, DCODE,
35 DNAME, SORT, ISTREE, TYPEID)
36 values (#{dictId,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{dcode,jdbcType=VARCHAR},
37 #{dname,jdbcType=VARCHAR}, #{sort,jdbcType=DECIMAL}, #{isTree,jdbcType=CHAR},
38 #{typeId,jdbcType=VARCHAR})
39 </insert>
40 <insert id="insertSelective" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
41 <!--@mbg.generated-->
42 insert into SYS_DICT
43 <trim prefix="(" suffix=")" suffixOverrides=",">
44 <if test="dictId != null">
45 DICTID,
46 </if>
47 <if test="parentId != null">
48 PARENTID,
49 </if>
50 <if test="dcode != null">
51 DCODE,
52 </if>
53 <if test="dname != null">
54 DNAME,
55 </if>
56 <if test="sort != null">
57 SORT,
58 </if>
59 <if test="isTree != null">
60 ISTREE,
61 </if>
62 <if test="typeId != null">
63 TYPEID,
64 </if>
65 </trim>
66 <trim prefix="values (" suffix=")" suffixOverrides=",">
67 <if test="dictId != null">
68 #{dictId,jdbcType=VARCHAR},
69 </if>
70 <if test="parentId != null">
71 #{parentId,jdbcType=VARCHAR},
72 </if>
73 <if test="dcode != null">
74 #{dcode,jdbcType=VARCHAR},
75 </if>
76 <if test="dname != null">
77 #{dname,jdbcType=VARCHAR},
78 </if>
79 <if test="sort != null">
80 #{sort,jdbcType=DECIMAL},
81 </if>
82 <if test="isTree != null">
83 #{isTree,jdbcType=CHAR},
84 </if>
85 <if test="typeId != null">
86 #{typeId,jdbcType=VARCHAR},
87 </if>
88 </trim>
89 </insert>
90 <update id="updateByPrimaryKeySelective" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
91 <!--@mbg.generated-->
92 update SYS_DICT
93 <set>
94 <if test="parentId != null">
95 PARENTID = #{parentId,jdbcType=VARCHAR},
96 </if>
97 <if test="dcode != null">
98 DCODE = #{dcode,jdbcType=VARCHAR},
99 </if>
100 <if test="dname != null">
101 DNAME = #{dname,jdbcType=VARCHAR},
102 </if>
103 <if test="sort != null">
104 SORT = #{sort,jdbcType=DECIMAL},
105 </if>
106 <if test="isTree != null">
107 ISTREE = #{isTree,jdbcType=CHAR},
108 </if>
109 <if test="typeId != null">
110 TYPEID = #{typeId,jdbcType=VARCHAR},
111 </if>
112 </set>
113 where DICTID = #{dictId,jdbcType=VARCHAR}
114 </update>
115 <update id="updateByPrimaryKey" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
116 <!--@mbg.generated-->
117 update SYS_DICT
118 set PARENTID = #{parentId,jdbcType=VARCHAR},
119 DCODE = #{dcode,jdbcType=VARCHAR},
120 DNAME = #{dname,jdbcType=VARCHAR},
121 SORT = #{sort,jdbcType=DECIMAL},
122 ISTREE = #{isTree,jdbcType=CHAR},
123 TYPEID = #{typeId,jdbcType=VARCHAR}
124 where DICTID = #{dictId,jdbcType=VARCHAR}
125 </update>
126 <update id="updateBatch" parameterType="java.util.List">
127 <!--@mbg.generated-->
128 update SYS_DICT
129 <trim prefix="set" suffixOverrides=",">
130 <trim prefix="PARENTID = case" suffix="end,">
131 <foreach collection="list" index="index" item="item">
132 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.parentId,jdbcType=VARCHAR}
133 </foreach>
134 </trim>
135 <trim prefix="DCODE = case" suffix="end,">
136 <foreach collection="list" index="index" item="item">
137 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dcode,jdbcType=VARCHAR}
138 </foreach>
139 </trim>
140 <trim prefix="DNAME = case" suffix="end,">
141 <foreach collection="list" index="index" item="item">
142 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dname,jdbcType=VARCHAR}
143 </foreach>
144 </trim>
145 <trim prefix="SORT = case" suffix="end,">
146 <foreach collection="list" index="index" item="item">
147 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.sort,jdbcType=DECIMAL}
148 </foreach>
149 </trim>
150 <trim prefix="ISTREE = case" suffix="end,">
151 <foreach collection="list" index="index" item="item">
152 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.isTree,jdbcType=CHAR}
153 </foreach>
154 </trim>
155 <trim prefix="TYPEID = case" suffix="end,">
156 <foreach collection="list" index="index" item="item">
157 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.typeId,jdbcType=VARCHAR}
158 </foreach>
159 </trim>
160 </trim>
161 where DICTID in
162 <foreach close=")" collection="list" item="item" open="(" separator=", ">
163 #{item.dictId,jdbcType=VARCHAR}
164 </foreach>
165 </update>
166 <update id="updateBatchSelective" parameterType="java.util.List">
167 <!--@mbg.generated-->
168 update SYS_DICT
169 <trim prefix="set" suffixOverrides=",">
170 <trim prefix="PARENTID = case" suffix="end,">
171 <foreach collection="list" index="index" item="item">
172 <if test="item.parentId != null">
173 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.parentId,jdbcType=VARCHAR}
174 </if>
175 </foreach>
176 </trim>
177 <trim prefix="DCODE = case" suffix="end,">
178 <foreach collection="list" index="index" item="item">
179 <if test="item.dcode != null">
180 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dcode,jdbcType=VARCHAR}
181 </if>
182 </foreach>
183 </trim>
184 <trim prefix="DNAME = case" suffix="end,">
185 <foreach collection="list" index="index" item="item">
186 <if test="item.dname != null">
187 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dname,jdbcType=VARCHAR}
188 </if>
189 </foreach>
190 </trim>
191 <trim prefix="SORT = case" suffix="end,">
192 <foreach collection="list" index="index" item="item">
193 <if test="item.sort != null">
194 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.sort,jdbcType=DECIMAL}
195 </if>
196 </foreach>
197 </trim>
198 <trim prefix="ISTREE = case" suffix="end,">
199 <foreach collection="list" index="index" item="item">
200 <if test="item.isTree != null">
201 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.isTree,jdbcType=CHAR}
202 </if>
203 </foreach>
204 </trim>
205 <trim prefix="TYPEID = case" suffix="end,">
206 <foreach collection="list" index="index" item="item">
207 <if test="item.typeId != null">
208 when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.typeId,jdbcType=VARCHAR}
209 </if>
210 </foreach>
211 </trim>
212 </trim>
213 where DICTID in
214 <foreach close=")" collection="list" item="item" open="(" separator=", ">
215 #{item.dictId,jdbcType=VARCHAR}
216 </foreach>
217 </update>
218 <insert id="batchInsert" parameterType="map">
219 <!--@mbg.generated-->
220 insert into SYS_DICT
221 (DICTID, PARENTID, DCODE, DNAME, SORT, ISTREE, TYPEID)
222
223 <foreach collection="list" item="item" index="index" separator="union all">
224 (select #{item.dictId,jdbcType=VARCHAR},
225 #{item.parentId,jdbcType=VARCHAR},
226 #{item.dcode,jdbcType=VARCHAR},
227 #{item.dname,jdbcType=VARCHAR},
228 #{item.sort,jdbcType=DECIMAL},
229 #{item.isTree,jdbcType=CHAR},
230 #{item.typeId,jdbcType=VARCHAR}
231 from dual)
232 </foreach>
233 </insert>
234
235 <select id="getSysDictParent" resultType="com.pashanhoo.dictionary.model.vo.GetSysDictParentVo">
236 select rownum,SD.*
237 from SYS_DICT SD
238 <where>
239 PARENTID is null
240 <if test="request.dcode != null and request.dcode != ''">
241 and DCODE like '%'||#{request.dcode,jdbcType=VARCHAR}||'%'
242 </if>
243 <if test="request.dname != null and request.dname != ''">
244 and DNAME like '%'||#{request.dname,jdbcType=VARCHAR}||'%'
245 </if>
246 </where>
247 </select>
248
249 <select id="getSysDictByTypeId" resultMap="BaseResultMap">
250 select *
251 from SYS_DICT
252 where TYPEID = #{typeId,jdbcType=VARCHAR}
253 and PARENTID is not null
254 </select>
255
256 <delete id="deleteListByPrimaryKey">
257 delete
258 from SYS_DICT
259 where
260 DICTID in
261 <foreach collection="dictWithoutParent" index="index" item="item" open="(" close=")" separator=",">
262 #{item.dictId,jdbcType=VARCHAR}
263 </foreach>
264 </delete>
265
266 <select id="selectAll" resultMap="BaseResultMap">
267 select *
268 from SYS_DICT
269 </select>
270
271 <delete id="deleteByTypeId">
272 delete from SYS_DICT where TYPEID = #{typeid,jdbcType=VARCHAR} and PARENTID is not null
273 </delete>
274 </mapper>