1、新增字典表的查询 2、修改source_system的查询到查询字典表,防止初始没有数据
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package com.realtime.protection.configuration.entity.dict;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
@Data
|
||||||
|
public class SysDictData {
|
||||||
|
@JsonProperty("dict_label")
|
||||||
|
@Schema(description = "字典标签")
|
||||||
|
private String dictLabel;
|
||||||
|
|
||||||
|
@JsonProperty("dict_value")
|
||||||
|
@Schema(description = "字典值")
|
||||||
|
private String dictValue;
|
||||||
|
|
||||||
|
@JsonProperty("dict_type")
|
||||||
|
@Schema(description = "字典类型")
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
@JsonProperty("dict_remark")
|
||||||
|
@Schema(description = "字典备注")
|
||||||
|
private String dictRemark;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.realtime.protection.server.dictionary;
|
||||||
|
|
||||||
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dict")
|
||||||
|
public class DictController {
|
||||||
|
|
||||||
|
private final DictService dictService;
|
||||||
|
|
||||||
|
public DictController(DictService dictService) {
|
||||||
|
this.dictService = dictService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型查询字典数据信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/type/{dictType}")
|
||||||
|
public ResponseResult dictType(@PathVariable String dictType) {
|
||||||
|
return ResponseResult.ok()
|
||||||
|
.setData("dictData", dictService.selectDictDataByType(dictType));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.realtime.protection.server.dictionary;
|
||||||
|
|
||||||
|
import com.realtime.protection.configuration.entity.dict.SysDictData;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DictMapper {
|
||||||
|
List<SysDictData> selectDictDataByType(String dictType);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.realtime.protection.server.dictionary;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.realtime.protection.configuration.entity.dict.SysDictData;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@DS("mysql")
|
||||||
|
public class DictService {
|
||||||
|
private final DictMapper dictMapper;
|
||||||
|
|
||||||
|
public DictService(DictMapper dictMapper) {
|
||||||
|
this.dictMapper = dictMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||||
|
return dictMapper.selectDictDataByType(dictType);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/main/resources/mappers/DictMapper.xml
Normal file
19
src/main/resources/mappers/DictMapper.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?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.realtime.protection.server.dictionary.DictMapper">
|
||||||
|
|
||||||
|
<resultMap id="DictMap" type="com.realtime.protection.configuration.entity.dict.SysDictData">
|
||||||
|
<result column="dict_type" property="dictType"/>
|
||||||
|
<result column="dict_value" property="dictValue"/>
|
||||||
|
<result column="dict_label" property="dictLabel"/>
|
||||||
|
<result column="remark" property="dictRemark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectDictDataByType" resultMap="DictMap">
|
||||||
|
select dict_type, dict_value, dict_label, remark
|
||||||
|
from t_dict_data
|
||||||
|
where dict_type = #{dictType} and status = 0
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -142,7 +142,9 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="querySourceSystem" resultType="java.lang.String">
|
<select id="querySourceSystem" resultType="java.lang.String">
|
||||||
SELECT DISTINCT strategy_template_source_system FROM t_strategy_template
|
SELECT DISTINCT dict_label
|
||||||
|
FROM t_dict_data
|
||||||
|
WHERE dict_type = 'source_system' and status = 0
|
||||||
</select>
|
</select>
|
||||||
<select id="queryEventName" resultType="java.lang.String">
|
<select id="queryEventName" resultType="java.lang.String">
|
||||||
SELECT DISTINCT strategy_template_name
|
SELECT DISTINCT strategy_template_name
|
||||||
|
|||||||
Reference in New Issue
Block a user