c5c67ee1 by 荆蔚杰

不动产登记档案系统

0 parents
1 .idea
2 *.iml
3 .classpath
4 .factorypath
5 .project
6 .settings
7 .DS_Store
8 target
This diff is collapsed. Click to expand it.
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.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@