字典功能代码提交
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
package com.njcn.gather;
|
package com.njcn.gather;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
//import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
//@MapperScan("com.njcn.**.mapper")
|
@MapperScan("com.njcn.**.mapper")
|
||||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||||
public class EntranceApplication {
|
public class EntranceApplication {
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,43 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: entrance
|
name: entrance
|
||||||
|
datasource:
|
||||||
|
druid:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||||
|
username: root
|
||||||
|
password: njcnpqs
|
||||||
|
#初始化建立物理连接的个数、最小、最大连接数
|
||||||
|
initial-size: 5
|
||||||
|
min-idle: 5
|
||||||
|
max-active: 50
|
||||||
|
#获取连接最大等待时间,单位毫秒
|
||||||
|
max-wait: 60000
|
||||||
|
#链接保持空间而不被驱逐的最长时间,单位毫秒
|
||||||
|
min-evictable-idle-time-millis: 300000
|
||||||
|
validation-query: select 1
|
||||||
|
test-while-idle: true
|
||||||
|
test-on-borrow: false
|
||||||
|
test-on-return: false
|
||||||
|
pool-prepared-statements: true
|
||||||
|
max-pool-prepared-statement-per-connection-size: 20
|
||||||
|
|
||||||
|
#mybatis配置信息
|
||||||
|
mybatis-plus:
|
||||||
|
mapper-locations: classpath*:com/njcn/**/mapping/*.xml
|
||||||
|
#别名扫描
|
||||||
|
type-aliases-package: com.njcn.gather.system.dictionary.pojo.po
|
||||||
|
configuration:
|
||||||
|
#驼峰命名
|
||||||
|
map-underscore-to-camel-case: true
|
||||||
|
#配置sql日志输出
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
#关闭日志输出
|
||||||
|
#log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
|
global-config:
|
||||||
|
db-config:
|
||||||
|
#指定主键生成策略
|
||||||
|
id-type: assign_uuid
|
||||||
|
|
||||||
log:
|
log:
|
||||||
homeDir: D:\logs
|
homeDir: D:\logs
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>-->
|
<dependency>
|
||||||
<!-- <groupId>com.njcn</groupId>-->
|
<groupId>com.njcn</groupId>
|
||||||
<!-- <artifactId>mybatis-plus</artifactId>-->
|
<artifactId>mybatis-plus</artifactId>
|
||||||
<!-- <version>0.0.1</version>-->
|
<version>0.0.1</version>
|
||||||
<!-- </dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
|
|||||||
@@ -0,0 +1,155 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||||
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "字典数据操作")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dictData")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DictDataController extends BaseController {
|
||||||
|
|
||||||
|
private final IDictDataService dictDataService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型id分页查询字典数据
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/getTypeIdData")
|
||||||
|
@ApiOperation("根据字典类型id查询字典数据")
|
||||||
|
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||||
|
public HttpResult<Page<DictData>> getTypeIdData(@RequestBody @Validated DictDataParam.DicTypeIdQueryParam queryParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("list");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||||
|
Page<DictData> result = dictDataService.getTypeIdData(queryParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典数据
|
||||||
|
*
|
||||||
|
* @param dictDataParam 字典数据
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("新增字典数据")
|
||||||
|
@ApiImplicitParam(name = "dictDataParam", value = "字典数据", required = true)
|
||||||
|
public HttpResult<Object> add(@RequestBody @Validated DictDataParam dictDataParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, dictDataParam);
|
||||||
|
boolean result = dictDataService.addDictData(dictDataParam);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典数据
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/update")
|
||||||
|
@ApiOperation("修改字典数据")
|
||||||
|
@ApiImplicitParam(name = "updateParam", value = "字典数据", required = true)
|
||||||
|
public HttpResult<Object> update(@RequestBody @Validated DictDataParam.DictDataUpdateParam updateParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("update");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, updateParam);
|
||||||
|
boolean result = dictDataService.updateDictData(updateParam);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除字典数据
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@ApiOperation("删除字典数据")
|
||||||
|
@ApiImplicitParam(name = "ids", value = "字典索引", required = true, dataTypeClass = List.class)
|
||||||
|
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||||
|
String methodDescribe = getMethodDescribe("delete");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||||
|
boolean result = dictDataService.deleteDictData(ids);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/getDicDataById")
|
||||||
|
@ApiOperation("根据字典id查询字典数据")
|
||||||
|
@ApiImplicitParam(name = "dicIndex", value = "查询参数", required = true)
|
||||||
|
public HttpResult<DictData> getDicDataById(@RequestParam("dicIndex") String dicIndex) {
|
||||||
|
String methodDescribe = getMethodDescribe("getDicDataById");
|
||||||
|
DictData result = dictDataService.getDicDataById(dicIndex);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/getDicDataByCode")
|
||||||
|
@ApiOperation("根据字典code查询字典数据")
|
||||||
|
@ApiImplicitParam(name = "code", value = "查询参数", required = true)
|
||||||
|
public HttpResult<DictData> getDicDataByCode(@RequestParam("code") String code) {
|
||||||
|
String methodDescribe = getMethodDescribe("getDicDataByCode");
|
||||||
|
DictData result = dictDataService.getDicDataByCode(code);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有字典数据基础信息
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/dictDataCache")
|
||||||
|
@ApiOperation("获取所有字典数据缓存到前端")
|
||||||
|
public HttpResult<List<SimpleTreeDTO>> dictDataCache() {
|
||||||
|
String methodDescribe = getMethodDescribe("dictDataCache");
|
||||||
|
LogUtil.njcnDebug(log, "{},获取所有字典数据缓存到前端", methodDescribe);
|
||||||
|
List<SimpleTreeDTO> dictData = dictDataService.dictDataCache();
|
||||||
|
if (CollectionUtil.isNotEmpty(dictData)) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dictData, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||||
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "字典类型表操作")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dictType")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DictTypeController extends BaseController {
|
||||||
|
|
||||||
|
private final IDictTypeService dictTypeService;
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/list")
|
||||||
|
@ApiOperation("查询字典类型")
|
||||||
|
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||||
|
public HttpResult<Page<DictType>> list(@RequestBody @Validated DictTypeParam.DictTypeQueryParam queryParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("list");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||||
|
Page<DictType> result = dictTypeService.listDictTypes(queryParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/listAll")
|
||||||
|
@ApiOperation("查询所有字典类型数据")
|
||||||
|
public HttpResult<List<DictType>> listAll() {
|
||||||
|
String methodDescribe = getMethodDescribe("listAll");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
|
List<DictType> dictTypeList = dictTypeService.list(new LambdaQueryWrapper<DictType>().eq(DictType::getState, DataStateEnum.ENABLE.getCode()));
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dictTypeList, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("新增字典类型")
|
||||||
|
@ApiImplicitParam(name = "dictTypeParam", value = "字典类型数据", required = true)
|
||||||
|
public HttpResult<Object> add(@RequestBody @Validated DictTypeParam dictTypeParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典类型数据为:{}", methodDescribe, dictTypeParam);
|
||||||
|
boolean result = dictTypeService.addDictType(dictTypeParam);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/update")
|
||||||
|
@ApiOperation("修改字典类型")
|
||||||
|
@ApiImplicitParam(name = "updateParam", value = "字典类型数据", required = true)
|
||||||
|
public HttpResult<Object> update(@RequestBody @Validated DictTypeParam.DictTypeUpdateParam updateParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("update");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典类型数据为:{}", methodDescribe, updateParam);
|
||||||
|
boolean result = dictTypeService.updateDictType(updateParam);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@ApiOperation("删除字典类型")
|
||||||
|
@ApiImplicitParam(name = "ids", value = "字典索引", required = true)
|
||||||
|
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||||
|
String methodDescribe = getMethodDescribe("delete");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||||
|
boolean result = dictTypeService.deleteDictType(ids);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
public interface DictDataMapper extends MPJBaseMapper<DictData> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
public interface DictTypeMapper extends MPJBaseMapper<DictType> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.gather.system.dictionary.mapper.DictDataMapper">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.gather.system.dictionary.mapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2024/10/30 14:46
|
||||||
|
*/
|
||||||
|
public interface SystemValidMessage {
|
||||||
|
|
||||||
|
|
||||||
|
String MISS_PREFIX="字段不能为空,请检查";
|
||||||
|
|
||||||
|
|
||||||
|
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||||
|
|
||||||
|
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
||||||
|
|
||||||
|
String DICT_TYPE_ID_NOT_BLANK = "typeId不能为空,请检查typeId参数";
|
||||||
|
|
||||||
|
String DICT_TYPE_ID_FORMAT_ERROR = "typeId格式错误,请检查typeId参数";
|
||||||
|
|
||||||
|
String NAME_NOT_BLANK = "名称不能为空,请检查name参数";
|
||||||
|
|
||||||
|
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
|
||||||
|
|
||||||
|
String INDUSTRY_NOT_BLANK = "行业不能为空,请检查industry参数";
|
||||||
|
String INDUSTRY_FORMAT_ERROR = "行业格式错误,请检查industry参数";
|
||||||
|
String ADDR_NOT_BLANK = "所属区域不能为空,请检查addr参数";
|
||||||
|
|
||||||
|
String CODE_NOT_BLANK = "编号不能为空,请检查code参数";
|
||||||
|
|
||||||
|
String CODE_FORMAT_ERROR = "编号格式错误,请检查code参数";
|
||||||
|
|
||||||
|
String SORT_NOT_NULL = "排序不能为空,请检查sort参数";
|
||||||
|
|
||||||
|
String SORT_FORMAT_ERROR = "排序格式错误,请检查sort参数";
|
||||||
|
|
||||||
|
String OPEN_LEVEL_NOT_NULL = "开启等级不能为空,请检查openLevel参数";
|
||||||
|
|
||||||
|
String OPEN_LEVEL_FORMAT_ERROR = "开启等级格式错误,请检查openLevel参数";
|
||||||
|
|
||||||
|
String OPEN_DESCRIBE_NOT_NULL = "开启描述不能为空,请检查openDescribe参数";
|
||||||
|
|
||||||
|
String OPEN_DESCRIBE_FORMAT_ERROR = "开启描述格式错误,请检查openDescribe参数";
|
||||||
|
|
||||||
|
String AREA_NOT_BLANK = "行政区域不能为空,请检查area参数";
|
||||||
|
|
||||||
|
String AREA_FORMAT_ERROR = "行政区域格式错误,请检查area参数";
|
||||||
|
|
||||||
|
String PID_NOT_BLANK = "父节点不能为空,请检查pid参数";
|
||||||
|
|
||||||
|
String PID_FORMAT_ERROR = "父节点格式错误,请检查pid参数";
|
||||||
|
|
||||||
|
String COLOR_NOT_BLANK = "主题色不能为空,请检查color参数";
|
||||||
|
|
||||||
|
String COLOR_FORMAT_ERROR = "主题色格式错误,请检查color参数";
|
||||||
|
|
||||||
|
String LOGO_NOT_BLANK = "iconUrl不能为空,请检查iconUrl参数";
|
||||||
|
|
||||||
|
String FAVICON_NOT_BLANK = "faviconUrl不能为空,请检查faviconUrl参数";
|
||||||
|
|
||||||
|
String REMARK_NOT_BLANK = "描述不能为空,请检查remark参数";
|
||||||
|
|
||||||
|
String REMARK_FORMAT_ERROR = "描述格式错误,请检查remark参数";
|
||||||
|
|
||||||
|
String PARAM_FORMAT_ERROR = "参数值非法";
|
||||||
|
|
||||||
|
String IP_FORMAT_ERROR = "IP格式非法";
|
||||||
|
|
||||||
|
String DEVICE_VERSION_NOT_BLANK = "装置版本json文件不能为空,请检查deviceVersionFile参数";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2024/10/30 15:52
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DictDataCache implements Serializable {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private int sort;
|
||||||
|
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
private String typeCode;
|
||||||
|
|
||||||
|
private Integer algoDescribe;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2021年12月20日 09:56
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum SystemResponseEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统模块异常响应码的范围:
|
||||||
|
* A00350 ~ A00449
|
||||||
|
*/
|
||||||
|
SYSTEM_COMMON_ERROR("A00350","系统模块异常"),
|
||||||
|
DICT_TYPE_NAME_REPEAT("A00351", "字典类型名称重复"),
|
||||||
|
DICT_DATA_NAME_REPEAT("A00352", "字典数据名称重复"),
|
||||||
|
AREA_CODE_REPEAT("A00353","行政区域编码重复"),
|
||||||
|
LOAD_TYPE_EMPTY("A00354","用能负荷数据为空"),
|
||||||
|
LINE_MARK_EMPTY("A00355","字典监测点评分等级数据为空"),
|
||||||
|
VOLTAGE_EMPTY("A00356","查询字典电压等级数据为空"),
|
||||||
|
|
||||||
|
INTERFERENCE_EMPTY("A00356","查询字典干扰源类型数据为空"),
|
||||||
|
BUSINESS_EMPTY("A00356","查询字典行业类型数据为空"),
|
||||||
|
SYSTEM_TYPE_EMPTY("A00356","查询字典系统类型数据为空"),
|
||||||
|
DEV_TYPE_EMPTY("A00357","查询字典设备类型数据为空"),
|
||||||
|
MANUFACTURER("A00358","查询字典终端厂家数据为空"),
|
||||||
|
DEV_VARIETY("A00359","查询字典终端类型数据为空"),
|
||||||
|
|
||||||
|
/*pms*/
|
||||||
|
LINE_TYPE_VARIETY_EMPTY("A00360","查询字典监测点类型数据为空"),
|
||||||
|
LINE_STATE_EMPTY("A00361","查询字典监测点状态为空"),
|
||||||
|
LINE_TYPE_EMPTY("A00362","查询字典监测点类型状态为空"),
|
||||||
|
POTENTIAL_TYPE_EMPTY("A00363","查询字典电压互感器类型为空"),
|
||||||
|
Neutral_Mode_EMPTY("A00364","查询字典中性点接地方式为空"),
|
||||||
|
MONITOR_TAG_EMPTY("A00365","查询字典监测点标签类型为空"),
|
||||||
|
MONITORY_TYPE_EMPTY("A00366","查询字典监测对象类型为空"),
|
||||||
|
TERMINAL_WIRING_EMPTY("A00367","查询字典监测终端接线方式为空"),
|
||||||
|
MONITOR_TYPE_EMPTY("A00368","查询字典监测点类别为空"),
|
||||||
|
ACTIVATED_STATE("A00369","必须存在一个已激活的系统类型"),
|
||||||
|
ADVANCE_REASON("A00370","查询字典暂降原因为空"),
|
||||||
|
EFFECT_STATUS_EMPTY("A00370","查询字典实施状态为空"),
|
||||||
|
|
||||||
|
EVENT_REPORT_REPEAT("A00361","暂态报告模板重复"),
|
||||||
|
NOT_EXISTED("A00361", "您查询的该条记录不存在"),
|
||||||
|
TIMER_NO_CLASS("A00361", "请检查定时任务是否添加"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务执行类不存在
|
||||||
|
*/
|
||||||
|
TIMER_NOT_EXISTED("A00361", "定时任务执行类不存在"),
|
||||||
|
EXE_EMPTY_PARAM("A00361", "请检查定时器的id,定时器cron表达式,定时任务是否为空!"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审计日志模块异常响应
|
||||||
|
*/
|
||||||
|
NOT_FIND_FILE("A0300", "文件未备份或者备份文件为空,请先备份文件"),
|
||||||
|
LOG_EXCEPTION("A0301", "导入旧日志文件异常"),
|
||||||
|
LOG_EXCEPTION_TIME("A0302", "导入旧日志文件异常:缺少时间范围"),
|
||||||
|
DELETE_DATA("A0303", "导入旧日志文件异常:删除数据失败"),
|
||||||
|
MULTIPLE_CLICKS_LOG_FILE_WRITER("A0304", "当前文件备份数据未结束,请勿多次点击"),
|
||||||
|
MULTIPLE_CLICKS_RECOVER_LOG_FILE("A0303", "当前文件恢复数据未结束,请勿多次点击")
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
SystemResponseEnum(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.param;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.constant.SystemValidMessage;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2021年12月17日 15:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DictDataParam {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("字典类型id")
|
||||||
|
@NotBlank(message = SystemValidMessage.DICT_TYPE_ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DICT_TYPE_ID_FORMAT_ERROR)
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("编码")
|
||||||
|
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("排序")
|
||||||
|
@NotNull(message = SystemValidMessage.SORT_NOT_NULL)
|
||||||
|
@Min(value = 0, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||||
|
@Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("事件等级:0-普通;1-中等;2-严重(默认为0)")
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
@ApiModelProperty("与高级算法内部Id描述对应")
|
||||||
|
private Integer algoDescribe;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("字典值,用于记录字典的计算值如10kV记录为 10")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新操作实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DictDataUpdateParam extends DictDataParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表Id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||||
|
private String id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DictDataQueryParam extends BaseParam {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型id分页查询字典数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DicTypeIdQueryParam extends BaseParam {
|
||||||
|
@ApiModelProperty("字典类型id")
|
||||||
|
@NotBlank(message = SystemValidMessage.DICT_TYPE_ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DICT_TYPE_ID_FORMAT_ERROR)
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.param;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.constant.SystemValidMessage;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0
|
||||||
|
* @data 2024/10/30 14:39
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DictTypeParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("编码")
|
||||||
|
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.ALL_CHAR_1_20, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("排序")
|
||||||
|
@NotNull(message = SystemValidMessage.SORT_NOT_NULL)
|
||||||
|
@Min(value = 0, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||||
|
@Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("开启等级:0-不开启;1-开启,默认不开启")
|
||||||
|
@NotNull(message = SystemValidMessage.OPEN_LEVEL_NOT_NULL)
|
||||||
|
@Min(value = 0, message = SystemValidMessage.OPEN_LEVEL_FORMAT_ERROR)
|
||||||
|
@Max(value = 1, message = SystemValidMessage.OPEN_LEVEL_FORMAT_ERROR)
|
||||||
|
private Integer openLevel;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("开启算法描述:0-不开启;1-开启,默认不开启")
|
||||||
|
@NotNull(message = SystemValidMessage.OPEN_DESCRIBE_NOT_NULL)
|
||||||
|
@Min(value = 0, message = SystemValidMessage.OPEN_DESCRIBE_FORMAT_ERROR)
|
||||||
|
@Max(value = 1, message = SystemValidMessage.OPEN_DESCRIBE_FORMAT_ERROR)
|
||||||
|
private Integer openDescribe;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("描述")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新操作实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DictTypeUpdateParam extends DictTypeParam {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DictTypeQueryParam extends BaseParam {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_dict_data")
|
||||||
|
public class DictData extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据表Id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型表Id
|
||||||
|
*/
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件等级:0-普通;1-中等;2-严重(默认为0)
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 与高级算法内部Id描述对应;
|
||||||
|
*/
|
||||||
|
private Integer algoDescribe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目前只用于表示电压等级数值
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态:0-删除 1-正常
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_dict_type")
|
||||||
|
public class DictType extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型表Id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启等级:0-不开启;1-开启,默认不开启
|
||||||
|
*/
|
||||||
|
private Integer openLevel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启描述:0-不开启;1-开启,默认不开启
|
||||||
|
*/
|
||||||
|
private Integer openDescribe;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态:0-删除 1-正常
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
public interface IDictDataService extends IService<DictData> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型id查询字典信息
|
||||||
|
* @param queryParam 查询参数
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
Page<DictData> getTypeIdData(DictDataParam.DicTypeIdQueryParam queryParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据字典
|
||||||
|
* @param dictDataParam 字典数据
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean addDictData(DictDataParam dictDataParam);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新字典数据
|
||||||
|
* @param updateParam 字典数据
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean updateDictData(DictDataParam.DictDataUpdateParam updateParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量逻辑删除字典数据
|
||||||
|
* @param ids 字典id集合
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean deleteDictData(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典id获取字典数据
|
||||||
|
* @param dicIndex 查询参数
|
||||||
|
* @return 根据字典id查询字典数据
|
||||||
|
*/
|
||||||
|
DictData getDicDataById(String dicIndex);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典code获取字典数据
|
||||||
|
* @param code 字典code
|
||||||
|
* @return 根据字典code查询字典数据
|
||||||
|
*/
|
||||||
|
DictData getDicDataByCode(String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有字典数据基础信息
|
||||||
|
* @return 返回所有字典数据
|
||||||
|
*/
|
||||||
|
List<SimpleTreeDTO> dictDataCache();
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||||
|
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
public interface IDictTypeService extends IService<DictType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据前台传递参数,分页查询字典类型数据
|
||||||
|
* @param queryParam 查询参数
|
||||||
|
* @return 字典列表
|
||||||
|
*/
|
||||||
|
Page<DictType> listDictTypes(DictTypeParam.DictTypeQueryParam queryParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型数据
|
||||||
|
*
|
||||||
|
* @param dictTypeParam 字典类型数据
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean addDictType(DictTypeParam dictTypeParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*
|
||||||
|
* @param updateParam 字典类型数据
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean updateDictType(DictTypeParam.DictTypeUpdateParam updateParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量逻辑删除字典类型数据
|
||||||
|
* @param ids id集合
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean deleteDictType(List<String> ids);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||||
|
import com.njcn.gather.system.dictionary.mapper.DictDataMapper;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.dto.DictDataCache;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.enums.SystemResponseEnum;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
|
import com.njcn.web.factory.PageFactory;
|
||||||
|
import com.njcn.web.pojo.dto.SimpleDTO;
|
||||||
|
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements IDictDataService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<DictData> getTypeIdData(DictDataParam.DicTypeIdQueryParam queryParam) {
|
||||||
|
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotNull(queryParam)) {
|
||||||
|
//查询条件待补充,曹泽辉根据页面实际情况调整 todo...
|
||||||
|
|
||||||
|
//排序
|
||||||
|
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||||
|
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||||
|
} else {
|
||||||
|
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||||
|
queryWrapper.orderBy(true, true, "sys_dict_data.sort");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryWrapper.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode())
|
||||||
|
.eq("sys_dict_data.type_id", queryParam.getTypeId());
|
||||||
|
//初始化分页数据
|
||||||
|
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addDictData(DictDataParam dictDataParam) {
|
||||||
|
checkDicDataName(dictDataParam, false);
|
||||||
|
DictData dictData = new DictData();
|
||||||
|
BeanUtil.copyProperties(dictDataParam, dictData);
|
||||||
|
//默认为正常状态
|
||||||
|
dictData.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
return this.save(dictData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateDictData(DictDataParam.DictDataUpdateParam updateParam) {
|
||||||
|
checkDicDataName(updateParam, true);
|
||||||
|
DictData dictData = new DictData();
|
||||||
|
BeanUtil.copyProperties(updateParam, dictData);
|
||||||
|
return this.updateById(dictData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDictData(List<String> ids) {
|
||||||
|
return this.lambdaUpdate()
|
||||||
|
.set(DictData::getState, DataStateEnum.DELETED.getCode())
|
||||||
|
.in(DictData::getId, ids)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DictData getDicDataById(String dicIndex) {
|
||||||
|
return this.baseMapper.selectById(dicIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DictData getDicDataByCode(String code) {
|
||||||
|
LambdaQueryWrapper<DictData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(DictData::getCode,code)
|
||||||
|
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
return this.baseMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SimpleTreeDTO> dictDataCache() {
|
||||||
|
MPJLambdaWrapper<DictData> dictTypeWrapper = new MPJLambdaWrapper<DictData>()
|
||||||
|
.selectAll(DictData.class)
|
||||||
|
.selectAs(DictType::getId, DictDataCache::getTypeId)
|
||||||
|
.selectAs(DictType::getName,DictDataCache::getTypeName)
|
||||||
|
.selectAs(DictType::getCode,DictDataCache::getTypeCode)
|
||||||
|
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId);
|
||||||
|
List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class,dictTypeWrapper);
|
||||||
|
|
||||||
|
Map<Object, List<DictDataCache>> dictDataCacheMap = allDictData.stream()
|
||||||
|
.collect(Collectors.groupingBy(DictDataCache::getTypeId));
|
||||||
|
return dictDataCacheMap.keySet().stream().map(typeId -> {
|
||||||
|
SimpleTreeDTO simpleTreeDTO = new SimpleTreeDTO();
|
||||||
|
List<DictDataCache> dictDataCaches = dictDataCacheMap.get(typeId);
|
||||||
|
List<SimpleDTO> simpleDTOList = dictDataCaches.stream().map(dictDataCache -> {
|
||||||
|
simpleTreeDTO.setCode(dictDataCache.getTypeCode());
|
||||||
|
simpleTreeDTO.setId(dictDataCache.getTypeId());
|
||||||
|
simpleTreeDTO.setName(dictDataCache.getTypeName());
|
||||||
|
SimpleDTO simpleDTO = new SimpleDTO();
|
||||||
|
simpleDTO.setCode(dictDataCache.getCode());
|
||||||
|
simpleDTO.setId(dictDataCache.getId());
|
||||||
|
simpleDTO.setName(dictDataCache.getName());
|
||||||
|
simpleDTO.setSort(dictDataCache.getSort());
|
||||||
|
simpleDTO.setValue(dictDataCache.getValue());
|
||||||
|
simpleDTO.setAlgoDescribe(dictDataCache.getAlgoDescribe());
|
||||||
|
return simpleDTO;
|
||||||
|
}).sorted(Comparator.comparing(SimpleDTO::getSort)).collect(Collectors.toList());
|
||||||
|
simpleTreeDTO.setChildren(simpleDTOList);
|
||||||
|
return simpleTreeDTO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数,检查是否存在相同名称的字典类型
|
||||||
|
*/
|
||||||
|
private void checkDicDataName(DictDataParam dictDataParam, boolean isExcludeSelf) {
|
||||||
|
LambdaQueryWrapper<DictData> dictDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
dictDataLambdaQueryWrapper
|
||||||
|
.eq(DictData::getName, dictDataParam.getName())
|
||||||
|
.eq(DictData::getTypeId, dictDataParam.getTypeId())
|
||||||
|
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
//更新的时候,需排除当前记录
|
||||||
|
if (isExcludeSelf) {
|
||||||
|
if (dictDataParam instanceof DictDataParam.DictDataUpdateParam) {
|
||||||
|
dictDataLambdaQueryWrapper.ne(DictData::getId, ((DictDataParam.DictDataUpdateParam) dictDataParam).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int countByAccount = this.count(dictDataLambdaQueryWrapper);
|
||||||
|
//大于等于1个则表示重复
|
||||||
|
if (countByAccount >= 1) {
|
||||||
|
throw new BusinessException(SystemResponseEnum.DICT_DATA_NAME_REPEAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package com.njcn.gather.system.dictionary.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||||
|
import com.njcn.gather.system.dictionary.mapper.DictTypeMapper;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.enums.SystemResponseEnum;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||||
|
import com.njcn.web.factory.PageFactory;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2021-12-13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements IDictTypeService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<DictType> listDictTypes(DictTypeParam.DictTypeQueryParam queryParam) {
|
||||||
|
QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotNull(queryParam)) {
|
||||||
|
//查询条件待补充,曹泽辉根据页面实际情况调整 todo...
|
||||||
|
|
||||||
|
|
||||||
|
//排序
|
||||||
|
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||||
|
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||||
|
} else {
|
||||||
|
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||||
|
queryWrapper.orderBy(true, true, "sys_dict_type.sort");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryWrapper.ne("sys_dict_type.state", DataStateEnum.DELETED.getCode());
|
||||||
|
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addDictType(DictTypeParam dictTypeParam) {
|
||||||
|
checkDicTypeName(dictTypeParam, false);
|
||||||
|
DictType dictType = new DictType();
|
||||||
|
BeanUtil.copyProperties(dictTypeParam, dictType);
|
||||||
|
//默认为正常状态
|
||||||
|
dictType.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
return this.save(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateDictType(DictTypeParam.DictTypeUpdateParam updateParam) {
|
||||||
|
checkDicTypeName(updateParam, true);
|
||||||
|
DictType dictType = new DictType();
|
||||||
|
BeanUtil.copyProperties(updateParam, dictType);
|
||||||
|
return this.updateById(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDictType(List<String> ids) {
|
||||||
|
return this.lambdaUpdate()
|
||||||
|
.set(DictType::getState, DataStateEnum.DELETED.getCode())
|
||||||
|
.in(DictType::getId, ids)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数,检查是否存在相同名称的字典类型
|
||||||
|
*/
|
||||||
|
private void checkDicTypeName(DictTypeParam dictTypeParam, boolean isExcludeSelf) {
|
||||||
|
LambdaQueryWrapper<DictType> dictTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
dictTypeLambdaQueryWrapper
|
||||||
|
.eq(DictType::getName, dictTypeParam.getName())
|
||||||
|
.eq(DictType::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
//更新的时候,需排除当前记录
|
||||||
|
if (isExcludeSelf) {
|
||||||
|
if (dictTypeParam instanceof DictTypeParam.DictTypeUpdateParam) {
|
||||||
|
dictTypeLambdaQueryWrapper.ne(DictType::getId, ((DictTypeParam.DictTypeUpdateParam) dictTypeParam).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int countByAccount = this.count(dictTypeLambdaQueryWrapper);
|
||||||
|
//大于等于1个则表示重复
|
||||||
|
if (countByAccount >= 1) {
|
||||||
|
throw new BusinessException(SystemResponseEnum.DICT_TYPE_NAME_REPEAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user