wip: 字典重构临时提交
This commit is contained in:
@@ -89,10 +89,10 @@ INSERT INTO `sys_dict` VALUES (1,'性别','gender',1,NULL,'2019-12-06 19:03:32',
|
|||||||
INSERT INTO `sys_dict` VALUES (2,'通知类型','notice_type',1,NULL,'2024-09-01 17:23:48','2024-09-01 17:23:54',0);
|
INSERT INTO `sys_dict` VALUES (2,'通知类型','notice_type',1,NULL,'2024-09-01 17:23:48','2024-09-01 17:23:54',0);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_dict_item
|
-- Table structure for sys_dict_data
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `sys_dict_item`;
|
DROP TABLE IF EXISTS `sys_dict_data`;
|
||||||
CREATE TABLE `sys_dict_item` (
|
CREATE TABLE `sys_dict_data` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
`dict_id` bigint NULL DEFAULT NULL COMMENT '字典ID',
|
`dict_id` bigint NULL DEFAULT NULL COMMENT '字典ID',
|
||||||
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项名称',
|
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '字典项名称',
|
||||||
@@ -106,13 +106,13 @@ CREATE TABLE `sys_dict_item` (
|
|||||||
) ENGINE = InnoDB AUTO_INCREMENT = 70 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典数据表' ROW_FORMAT = DYNAMIC;
|
) ENGINE = InnoDB AUTO_INCREMENT = 70 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典数据表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_dict_item
|
-- Records of sys_dict_data
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `sys_dict_item` VALUES (1, 1, '男', '1', 1, 1, NULL, '2019-05-05 13:07:52', '2022-06-12 23:20:39');
|
INSERT INTO `sys_dict_data` VALUES (1, 1, '男', '1', 1, 1, NULL, '2019-05-05 13:07:52', '2022-06-12 23:20:39');
|
||||||
INSERT INTO `sys_dict_item` VALUES (2, 1, '女', '2', 1, 2, NULL, '2019-04-19 11:33:00', '2019-07-02 14:23:05');
|
INSERT INTO `sys_dict_data` VALUES (2, 1, '女', '2', 1, 2, NULL, '2019-04-19 11:33:00', '2019-07-02 14:23:05');
|
||||||
INSERT INTO `sys_dict_item` VALUES (3, 1, '保密', '0', 1, 3, NULL, '2020-10-17 08:09:31', '2020-10-17 08:09:31');
|
INSERT INTO `sys_dict_data` VALUES (3, 1, '保密', '0', 1, 3, NULL, '2020-10-17 08:09:31', '2020-10-17 08:09:31');
|
||||||
INSERT INTO `sys_dict_item` VALUES (4, 2,'系统通知','1',1, 1, NULL,'2020-10-17 08:09:31', '2020-10-17 08:09:31');
|
INSERT INTO `sys_dict_data` VALUES (4, 2,'系统通知','1',1, 1, NULL,'2020-10-17 08:09:31', '2020-10-17 08:09:31');
|
||||||
INSERT INTO `sys_dict_item` VALUES (5, 2,'通知消息','2',1, 2, NULL,'2020-10-17 08:09:31', '2020-10-17 08:09:31');
|
INSERT INTO `sys_dict_data` VALUES (5, 2,'通知消息','2',1, 2, NULL,'2020-10-17 08:09:31', '2020-10-17 08:09:31');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_log
|
-- Table structure for sys_log
|
||||||
|
|||||||
@@ -93,10 +93,10 @@ INSERT INTO `sys_dict` VALUES (3, '通知级别', 'notice_level', 1, NULL, now()
|
|||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_dict_item
|
-- Table structure for sys_dict_data
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `sys_dict_item`;
|
DROP TABLE IF EXISTS `sys_dict_data`;
|
||||||
CREATE TABLE `sys_dict_item` (
|
CREATE TABLE `sys_dict_data` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
`dict_code` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典编码',
|
`dict_code` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典编码',
|
||||||
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '字典项名称',
|
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '字典项名称',
|
||||||
@@ -110,20 +110,20 @@ CREATE TABLE `sys_dict_item` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='字典数据表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='字典数据表';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of sys_dict_item
|
-- Records of sys_dict_data
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `sys_dict_item` VALUES (1, 'gender', '男', '1', 1, 1, NULL, now(), now());
|
INSERT INTO `sys_dict_data` VALUES (1, 'gender', '男', '1', 1, 1, NULL, now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (2, 'gender', '女', '2', 1, 2, NULL, now(), now());
|
INSERT INTO `sys_dict_data` VALUES (2, 'gender', '女', '2', 1, 2, NULL, now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (3, 'gender', '保密', '0', 1, 3, NULL, now(), now());
|
INSERT INTO `sys_dict_data` VALUES (3, 'gender', '保密', '0', 1, 3, NULL, now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (4, 'notice_type', '系统升级', '1', 1, 1, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (4, 'notice_type', '系统升级', '1', 1, 1, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (5, 'notice_type', '系统维护', '2', 1, 2, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (5, 'notice_type', '系统维护', '2', 1, 2, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (6, 'notice_type', '安全警告', '3', 1, 3, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (6, 'notice_type', '安全警告', '3', 1, 3, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (7, 'notice_type', '假期通知', '4', 1, 4, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (7, 'notice_type', '假期通知', '4', 1, 4, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (8, 'notice_type', '公司新闻', '5', 1, 5, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (8, 'notice_type', '公司新闻', '5', 1, 5, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (9, 'notice_type', '其他', '99', 1, 99, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (9, 'notice_type', '其他', '99', 1, 99, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (10, 'notice_level', 'L', '低', 1, 1, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (10, 'notice_level', 'L', '低', 1, 1, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (11, 'notice_level', 'M', '中', 1, 2, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (11, 'notice_level', 'M', '中', 1, 2, '', now(), now());
|
||||||
INSERT INTO `sys_dict_item` VALUES (12, 'notice_level', 'H', '高', 1, 3, '', now(), now());
|
INSERT INTO `sys_dict_data` VALUES (12, 'notice_level', 'H', '高', 1, 3, '', now(), now());
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for sys_log
|
-- Table structure for sys_log
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.youlai.boot.common.model.Option;
|
|||||||
import com.youlai.boot.common.result.PageResult;
|
import com.youlai.boot.common.result.PageResult;
|
||||||
import com.youlai.boot.common.result.Result;
|
import com.youlai.boot.common.result.Result;
|
||||||
import com.youlai.boot.system.model.form.DictDataForm;
|
import com.youlai.boot.system.model.form.DictDataForm;
|
||||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
import com.youlai.boot.system.model.query.DictDataPageQuery;
|
||||||
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
||||||
import com.youlai.boot.system.service.DictDataService;
|
import com.youlai.boot.system.service.DictDataService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -39,7 +39,7 @@ public class DictDataController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Log( value = "字典数据分页列表",module = LogModuleEnum.DICT)
|
@Log( value = "字典数据分页列表",module = LogModuleEnum.DICT)
|
||||||
public PageResult<DictDataPageVO> getDictDataPage(
|
public PageResult<DictDataPageVO> getDictDataPage(
|
||||||
DictPageQuery queryParams
|
DictDataPageQuery queryParams
|
||||||
) {
|
) {
|
||||||
Page<DictDataPageVO> result = dictDataService.getDictDataPage(queryParams);
|
Page<DictDataPageVO> result = dictDataService.getDictDataPage(queryParams);
|
||||||
return PageResult.success(result);
|
return PageResult.success(result);
|
||||||
@@ -86,10 +86,10 @@ public class DictDataController {
|
|||||||
|
|
||||||
@Operation(summary = "字典数据列表")
|
@Operation(summary = "字典数据列表")
|
||||||
@GetMapping("/{dictCode}/options")
|
@GetMapping("/{dictCode}/options")
|
||||||
public Result<List<Option>> getDictDataList(
|
public Result<List<Option<String>>> getDictDataList(
|
||||||
@Parameter(description = "字典编码") @PathVariable String dictCode
|
@Parameter(description = "字典编码") @PathVariable String dictCode
|
||||||
) {
|
) {
|
||||||
List<Option> options = dictDataService.getDictDataList(dictCode);
|
List<Option<String>> options = dictDataService.getDictDataList(dictCode);
|
||||||
return Result.success(options);
|
return Result.success(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.youlai.boot.system.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.youlai.boot.common.model.Option;
|
||||||
import com.youlai.boot.system.model.entity.DictData;
|
import com.youlai.boot.system.model.entity.DictData;
|
||||||
|
import com.youlai.boot.system.model.query.DictDataPageQuery;
|
||||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||||
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@@ -16,7 +18,15 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface DictDataMapper extends BaseMapper<DictData> {
|
public interface DictDataMapper extends BaseMapper<DictData> {
|
||||||
|
|
||||||
Page<DictDataPageVO> getDictDataPage(Page<DictDataPageVO> page, DictPageQuery queryParams);
|
/**
|
||||||
|
* 字典数据分页列表
|
||||||
|
*/
|
||||||
|
Page<DictDataPageVO> getDictDataPage(Page<DictDataPageVO> page, DictDataPageQuery queryParams);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典编码获取字典数据列表
|
||||||
|
*/
|
||||||
|
Option listDictDataByDictCode(String dictCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class Dict extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 字典编码
|
* 字典编码
|
||||||
*/
|
*/
|
||||||
private String code;
|
private String dictCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典名称
|
* 字典名称
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class DictForm {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "字典名称",example = "性别")
|
@Schema(description = "字典名称",example = "性别")
|
||||||
private String dictName;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "字典编码", example ="gender")
|
@Schema(description = "字典编码", example ="gender")
|
||||||
private String dictCode;
|
private String dictCode;
|
||||||
@@ -32,5 +32,4 @@ public class DictForm {
|
|||||||
@Range(min = 0, max = 1, message = "字典状态不正确")
|
@Range(min = 0, max = 1, message = "字典状态不正确")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ public class DictDataPageVO {
|
|||||||
@Schema(description = "字典编码")
|
@Schema(description = "字典编码")
|
||||||
private String dictCode;
|
private String dictCode;
|
||||||
|
|
||||||
@Schema(description = "字典数据值")
|
@Schema(description = "字典标签")
|
||||||
private String value;
|
|
||||||
|
|
||||||
@Schema(description = "字典数据标签")
|
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
@Schema(description = "字典值")
|
||||||
|
private String value;
|
||||||
|
|
||||||
@Schema(description = "排序")
|
@Schema(description = "排序")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class DictPageVO {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "字典名称")
|
@Schema(description = "字典名称")
|
||||||
private String dictName;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "字典编码")
|
@Schema(description = "字典编码")
|
||||||
private String dictCode;
|
private String dictCode;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.youlai.boot.common.model.Option;
|
|||||||
import com.youlai.boot.system.model.entity.DictData;
|
import com.youlai.boot.system.model.entity.DictData;
|
||||||
import com.youlai.boot.system.model.form.DictDataForm;
|
import com.youlai.boot.system.model.form.DictDataForm;
|
||||||
import com.youlai.boot.system.model.form.DictForm;
|
import com.youlai.boot.system.model.form.DictForm;
|
||||||
|
import com.youlai.boot.system.model.query.DictDataPageQuery;
|
||||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||||
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ public interface DictDataService extends IService<DictData> {
|
|||||||
* @param queryParams
|
* @param queryParams
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Page<DictDataPageVO> getDictDataPage(DictPageQuery queryParams);
|
Page<DictDataPageVO> getDictDataPage(DictDataPageQuery queryParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字典数据表单
|
* 获取字典数据表单
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.youlai.boot.system.converter.DictDataConverter;
|
|||||||
import com.youlai.boot.system.mapper.DictDataMapper;
|
import com.youlai.boot.system.mapper.DictDataMapper;
|
||||||
import com.youlai.boot.system.model.entity.DictData;
|
import com.youlai.boot.system.model.entity.DictData;
|
||||||
import com.youlai.boot.system.model.form.DictDataForm;
|
import com.youlai.boot.system.model.form.DictDataForm;
|
||||||
|
import com.youlai.boot.system.model.query.DictDataPageQuery;
|
||||||
import com.youlai.boot.system.model.query.DictPageQuery;
|
import com.youlai.boot.system.model.query.DictPageQuery;
|
||||||
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
import com.youlai.boot.system.model.vo.DictDataPageVO;
|
||||||
import com.youlai.boot.system.service.DictDataService;
|
import com.youlai.boot.system.service.DictDataService;
|
||||||
@@ -36,7 +37,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<DictDataPageVO> getDictDataPage(DictPageQuery queryParams) {
|
public Page<DictDataPageVO> getDictDataPage(DictDataPageQuery queryParams) {
|
||||||
int pageNum = queryParams.getPageNum();
|
int pageNum = queryParams.getPageNum();
|
||||||
int pageSize = queryParams.getPageSize();
|
int pageSize = queryParams.getPageSize();
|
||||||
Page<DictDataPageVO> page = new Page<>(pageNum, pageSize);
|
Page<DictDataPageVO> page = new Page<>(pageNum, pageSize);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典业务实现类
|
* 数据字典业务实现类
|
||||||
@@ -65,10 +64,10 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
Dict entity = dictConverter.toEntity(dictForm);
|
Dict entity = dictConverter.toEntity(dictForm);
|
||||||
|
|
||||||
// 校验 code 是否唯一
|
// 校验 code 是否唯一
|
||||||
String dictCode = entity.getCode();
|
String dictCode = entity.getDictCode();
|
||||||
|
|
||||||
long count = this.count(new LambdaQueryWrapper<Dict>()
|
long count = this.count(new LambdaQueryWrapper<Dict>()
|
||||||
.eq(Dict::getCode, dictCode)
|
.eq(Dict::getDictCode, dictCode)
|
||||||
);
|
);
|
||||||
Assert.isTrue(count == 0, "字典编码已存在");
|
Assert.isTrue(count == 0, "字典编码已存在");
|
||||||
|
|
||||||
@@ -103,9 +102,9 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
Dict entity = dictConverter.toEntity(dictForm);
|
Dict entity = dictConverter.toEntity(dictForm);
|
||||||
|
|
||||||
// 校验 code 是否唯一
|
// 校验 code 是否唯一
|
||||||
String dictCode = entity.getCode();
|
String dictCode = entity.getDictCode();
|
||||||
long count = this.count(new LambdaQueryWrapper<Dict>()
|
long count = this.count(new LambdaQueryWrapper<Dict>()
|
||||||
.eq(Dict::getCode, dictCode)
|
.eq(Dict::getDictCode, dictCode)
|
||||||
.ne(Dict::getId, id)
|
.ne(Dict::getId, id)
|
||||||
);
|
);
|
||||||
if(count>0){
|
if(count>0){
|
||||||
@@ -137,7 +136,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
if (removeResult) {
|
if (removeResult) {
|
||||||
dictDataService.remove(
|
dictDataService.remove(
|
||||||
new LambdaQueryWrapper<DictData>()
|
new LambdaQueryWrapper<DictData>()
|
||||||
.eq(DictData::getDictCode, dict.getCode())
|
.eq(DictData::getDictCode, dict.getDictCode())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +153,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
public List<Option<Long>> listDictItemsByCode(String code) {
|
public List<Option<Long>> listDictItemsByCode(String code) {
|
||||||
// 根据字典编码获取字典ID
|
// 根据字典编码获取字典ID
|
||||||
Dict dict = this.getOne(new LambdaQueryWrapper<Dict>()
|
Dict dict = this.getOne(new LambdaQueryWrapper<Dict>()
|
||||||
.eq(Dict::getCode, code)
|
.eq(Dict::getDictCode, code)
|
||||||
.select(Dict::getId)
|
.select(Dict::getId)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
@@ -166,7 +165,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
// 获取字典项
|
// 获取字典项
|
||||||
List<DictData> dictData = dictDataService.list(
|
List<DictData> dictData = dictDataService.list(
|
||||||
new LambdaQueryWrapper<DictData>()
|
new LambdaQueryWrapper<DictData>()
|
||||||
.eq(DictData::getDictCode, dict.getCode())
|
.eq(DictData::getDictCode, dict.getDictCode())
|
||||||
);
|
);
|
||||||
|
|
||||||
// 转换为 Option
|
// 转换为 Option
|
||||||
@@ -180,9 +179,9 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
public List<Option<String>> getDictList() {
|
public List<Option<String>> getDictList() {
|
||||||
return this.list(new LambdaQueryWrapper<Dict>()
|
return this.list(new LambdaQueryWrapper<Dict>()
|
||||||
.eq(Dict::getStatus, 1)
|
.eq(Dict::getStatus, 1)
|
||||||
.select(Dict::getName, Dict::getCode)
|
.select(Dict::getName, Dict::getDictCode)
|
||||||
).stream()
|
).stream()
|
||||||
.map(dict -> new Option<>(dict.getCode(), dict.getName()))
|
.map(dict -> new Option<>(dict.getDictCode(), dict.getName()))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,30 +4,13 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.youlai.boot.system.mapper.DictDataMapper">
|
<mapper namespace="com.youlai.boot.system.mapper.DictDataMapper">
|
||||||
|
|
||||||
<!-- 根据字典编码获取字典列表 -->
|
|
||||||
<select id="getDictItemsByCode" resultType="com.youlai.boot.system.model.vo.DictPageVO$DictItem">
|
|
||||||
SELECT
|
|
||||||
id,
|
|
||||||
`name`,
|
|
||||||
value,
|
|
||||||
sort,
|
|
||||||
status
|
|
||||||
FROM
|
|
||||||
sys_dict_item
|
|
||||||
<where>
|
|
||||||
dict_code = #{dictCode}
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
sort ASC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 获取字典数据分页列表 -->
|
<!-- 获取字典数据分页列表 -->
|
||||||
<select id="getDictDataPage" resultType="com.youlai.boot.system.model.vo.DictDataPageVO">
|
<select id="getDictDataPage" resultType="com.youlai.boot.system.model.vo.DictDataPageVO">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
dict_code,
|
dict_code,
|
||||||
value,
|
|
||||||
label,
|
label,
|
||||||
|
value,
|
||||||
sort,
|
sort,
|
||||||
status
|
status
|
||||||
FROM
|
FROM
|
||||||
@@ -44,9 +27,20 @@
|
|||||||
AND dict_code = #{queryParams.dictCode}
|
AND dict_code = #{queryParams.dictCode}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据字典编码获取字典数据列表 -->
|
||||||
|
<select id="listDictDataByDictCode" resultType="com.youlai.boot.common.model.Option">
|
||||||
|
SELECT
|
||||||
|
value,
|
||||||
|
label
|
||||||
|
FROM
|
||||||
|
sys_dict_data
|
||||||
|
<where>
|
||||||
|
dict_code = #{dictCode}
|
||||||
|
</where>
|
||||||
|
ORDER BY
|
||||||
|
sort ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -3,20 +3,12 @@
|
|||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.youlai.boot.system.mapper.DictMapper">
|
<mapper namespace="com.youlai.boot.system.mapper.DictMapper">
|
||||||
|
|
||||||
<!-- 字典映射 -->
|
|
||||||
<resultMap id="DictMap" type="com.youlai.boot.system.model.vo.DictPageVO">
|
|
||||||
<collection property="dictData"
|
|
||||||
column="{dictCode=code}"
|
|
||||||
select="com.youlai.boot.system.mapper.DictDataMapper.getDictItemsByCode">
|
|
||||||
</collection>
|
|
||||||
</resultMap>
|
|
||||||
<!-- 字典分页列表 -->
|
<!-- 字典分页列表 -->
|
||||||
<select id="getDictPage" resultMap="DictMap">
|
<select id="getDictPage" resultType="com.youlai.boot.system.model.vo.DictPageVO">
|
||||||
SELECT
|
SELECT
|
||||||
t1.id,
|
t1.id,
|
||||||
t1.name,
|
t1.name,
|
||||||
t1.code,
|
t1.dict_code,
|
||||||
t1.status
|
t1.status
|
||||||
FROM
|
FROM
|
||||||
sys_dict t1
|
sys_dict t1
|
||||||
@@ -25,7 +17,8 @@
|
|||||||
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
||||||
AND (
|
AND (
|
||||||
t1.name LIKE CONCAT('%',#{queryParams.keywords},'%')
|
t1.name LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
OR t1.code LIKE CONCAT('%',#{queryParams.keywords},'%')
|
OR
|
||||||
|
t1.dict_code LIKE CONCAT('%',#{queryParams.keywords},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
FROM
|
FROM
|
||||||
sys_notice t1
|
sys_notice t1
|
||||||
LEFT JOIN sys_user t2 ON t2.id = t1.publisher_id
|
LEFT JOIN sys_user t2 ON t2.id = t1.publisher_id
|
||||||
LEFT JOIN sys_dict_item t3 ON t1.type = t3.value AND t3.dict_code = 'notice_type'
|
LEFT JOIN sys_dict_data t3 ON t1.type = t3.value AND t3.dict_code = 'notice_type'
|
||||||
LEFT JOIN sys_dict_item t4 ON t1.level = t4.value AND t4.dict_code = 'notice_level'
|
LEFT JOIN sys_dict_data t4 ON t1.level = t4.value AND t4.dict_code = 'notice_level'
|
||||||
WHERE
|
WHERE
|
||||||
t1.is_deleted = 0
|
t1.is_deleted = 0
|
||||||
<if test="queryParams.title != null and queryParams.title != ''">
|
<if test="queryParams.title != null and queryParams.title != ''">
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
sys_user_notice t1
|
sys_user_notice t1
|
||||||
INNER JOIN sys_notice t2 ON t1.notice_id = t2.id AND t2.publish_status = 1
|
INNER JOIN sys_notice t2 ON t1.notice_id = t2.id AND t2.publish_status = 1
|
||||||
LEFT JOIN sys_user t3 ON t2.publisher_id = t3.id
|
LEFT JOIN sys_user t3 ON t2.publisher_id = t3.id
|
||||||
LEFT JOIN sys_dict_item t4 ON t2.type = t4.value AND t4.dict_code = 'notice_type'
|
LEFT JOIN sys_dict_data t4 ON t2.type = t4.value AND t4.dict_code = 'notice_type'
|
||||||
LEFT JOIN sys_dict_item t5 ON t2.level = t5.value AND t5.dict_code = 'notice_level'
|
LEFT JOIN sys_dict_data t5 ON t2.level = t5.value AND t5.dict_code = 'notice_level'
|
||||||
WHERE
|
WHERE
|
||||||
t1.user_id = #{queryParams.userId} AND t1.is_deleted = 0 AND t2.is_deleted = 0
|
t1.user_id = #{queryParams.userId} AND t1.is_deleted = 0 AND t2.is_deleted = 0
|
||||||
<if test="queryParams.title != null and queryParams.title != ''">
|
<if test="queryParams.title != null and queryParams.title != ''">
|
||||||
|
|||||||
Reference in New Issue
Block a user