mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-11 06:57:12 +08:00
refactor: 公告类型适配字典数据
1.新增 <dict-tag> 自定义组件,用于回显字典标签 2.重构 useDict 方法,支持查询字典数据 3.优化部分字典相关数据类型
This commit is contained in:
@@ -16,7 +16,12 @@
|
||||
|
||||
package top.charles7c.cnadmin.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
||||
import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
||||
|
||||
/**
|
||||
@@ -25,4 +30,14 @@ import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
public interface DictItemMapper extends BaseMapper<DictItemDO> {}
|
||||
public interface DictItemMapper extends BaseMapper<DictItemDO> {
|
||||
|
||||
/**
|
||||
* 根据字典编码查询
|
||||
*
|
||||
* @param dictCode
|
||||
* 字典编码
|
||||
* @return 字典项列表
|
||||
*/
|
||||
List<LabelValueVO> listByDictCode(@Param("dictCode") String dictCode);
|
||||
}
|
@@ -23,7 +23,6 @@ import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
|
||||
|
||||
/**
|
||||
* 公告实体
|
||||
@@ -50,7 +49,7 @@ public class AnnouncementDO extends BaseDO {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private AnnouncementTypeEnum type;
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 生效时间
|
||||
|
@@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseRequest;
|
||||
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
|
||||
|
||||
/**
|
||||
* 创建或修改公告信息
|
||||
@@ -57,11 +56,11 @@ public class AnnouncementRequest extends BaseRequest {
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* 类型(取值于字典 announcement_type)
|
||||
*/
|
||||
@Schema(description = "类型", type = "Integer", allowableValues = {"1", "2", "3"}, example = "1")
|
||||
@NotNull(message = "类型非法")
|
||||
private AnnouncementTypeEnum type;
|
||||
@Schema(description = "类型(取值于字典 announcement_type)", example = "1")
|
||||
@NotBlank(message = "类型不能为空")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 生效时间
|
||||
|
@@ -26,8 +26,6 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDetailVO;
|
||||
import top.charles7c.cnadmin.common.config.easyexcel.ExcelBaseEnumConverter;
|
||||
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
|
||||
|
||||
/**
|
||||
* 公告详情信息
|
||||
@@ -57,11 +55,11 @@ public class AnnouncementDetailVO extends BaseDetailVO {
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* 类型(取值于字典 announcement_type)
|
||||
*/
|
||||
@Schema(description = "类型", type = "Integer", allowableValues = {"1", "2", "3"}, example = "1")
|
||||
@ExcelProperty(value = "类型", converter = ExcelBaseEnumConverter.class)
|
||||
private AnnouncementTypeEnum type;
|
||||
@Schema(description = "类型(取值于字典 announcement_type)", example = "1")
|
||||
@ExcelProperty(value = "类型")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 生效时间
|
||||
|
@@ -23,7 +23,6 @@ import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseVO;
|
||||
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
|
||||
|
||||
/**
|
||||
* 公告信息
|
||||
@@ -44,10 +43,10 @@ public class AnnouncementVO extends BaseVO {
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* 类型(取值于字典 announcement_type)
|
||||
*/
|
||||
@Schema(description = "类型", type = "Integer", allowableValues = {"1", "2", "3"}, example = "1")
|
||||
private AnnouncementTypeEnum type;
|
||||
@Schema(description = "类型(取值于字典 announcement_type)", example = "1")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 生效时间
|
||||
|
@@ -19,6 +19,7 @@ package top.charles7c.cnadmin.system.service;
|
||||
import java.util.List;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseService;
|
||||
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
||||
import top.charles7c.cnadmin.system.model.query.DictItemQuery;
|
||||
import top.charles7c.cnadmin.system.model.request.DictItemRequest;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictItemDetailVO;
|
||||
@@ -41,6 +42,15 @@ public interface DictItemService extends BaseService<DictItemVO, DictItemDetailV
|
||||
*/
|
||||
List<DictItemDetailVO> listByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 根据字典编码查询
|
||||
*
|
||||
* @param dictCode
|
||||
* 字典编码
|
||||
* @return 字典项列表
|
||||
*/
|
||||
List<LabelValueVO> listByDictCode(String dictCode);
|
||||
|
||||
/**
|
||||
* 根据字典 ID 列表删除
|
||||
*
|
||||
|
@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseServiceImpl;
|
||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
||||
import top.charles7c.cnadmin.system.mapper.DictItemMapper;
|
||||
import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
||||
@@ -73,6 +74,11 @@ public class DictItemServiceImpl
|
||||
return detailList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LabelValueVO> listByDictCode(String dictCode) {
|
||||
return baseMapper.listByDictCode(dictCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByDictIds(List<Long> dictIds) {
|
||||
baseMapper.lambdaUpdate().in(DictItemDO::getDictId, dictIds).remove();
|
||||
|
@@ -0,0 +1,11 @@
|
||||
<?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="top.charles7c.cnadmin.system.mapper.DictItemMapper">
|
||||
<select id="listByDictCode" resultType="top.charles7c.cnadmin.common.model.vo.LabelValueVO">
|
||||
SELECT t1.`label`, t1.`value`, t1.`color`
|
||||
FROM `sys_dict_item` AS t1
|
||||
LEFT JOIN `sys_dict` AS t2 ON t1.`dict_id` = t2.`id`
|
||||
WHERE t2.`code` = #{dictCode}
|
||||
ORDER BY t1.`sort` ASC
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user