feat: 字典模型初版
parent
e77f61975d
commit
bd595bc65d
|
@ -0,0 +1,59 @@
|
||||||
|
package com.muyu.data.source.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据对象 DictionaryData
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* on 2024/4/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DictionaryData {
|
||||||
|
|
||||||
|
/**字典数据id*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**字典数据标签*/
|
||||||
|
private String dictionaryLabel;
|
||||||
|
|
||||||
|
/**字典数据值*/
|
||||||
|
private String dictionaryValue;
|
||||||
|
|
||||||
|
/**字典类型*/
|
||||||
|
private String dictionaryType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**字典数据状态*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**创建人*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**创建时间*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**更新人*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**更新时间*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**备注*/
|
||||||
|
private String remark;
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.muyu.data.source.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型对象 DictionaryType
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* on 2024/4/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DictionaryType {
|
||||||
|
|
||||||
|
/**字典类型ID*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**资产结构ID*/
|
||||||
|
private Integer structureId;
|
||||||
|
|
||||||
|
/**字典名称*/
|
||||||
|
private String dictionaryName;
|
||||||
|
|
||||||
|
/**字典类型*/
|
||||||
|
private String dictionaryType;
|
||||||
|
|
||||||
|
/**字典状态(0正常 1停用)*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**创建者*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**创建时间*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**更新者*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**更新时间*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**备注*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**字典数据对象*/
|
||||||
|
private List<DictionaryData> dictionaryDataList;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.data.source.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.DictionaryData;
|
||||||
|
import com.muyu.data.source.domain.DictionaryType;
|
||||||
|
import com.muyu.data.source.service.DictionaryService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典对象控制层 DictionaryController
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* on 2024/4/29
|
||||||
|
*/
|
||||||
|
@Api(tags = "数据源")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dict")
|
||||||
|
public class DictionaryController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
|
@GetMapping("/findDictionaryByStructureId")
|
||||||
|
public Result<List<DictionaryType>> findDictionaryByStructureId(Integer id) {
|
||||||
|
return dictionaryService.findDictionaryByStructureId(id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.data.source.mapper;
|
||||||
|
|
||||||
|
import com.muyu.data.source.domain.DictionaryData;
|
||||||
|
import com.muyu.data.source.domain.DictionaryType;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DictionaryMapper
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* on 2024/4/29
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DictionaryMapper {
|
||||||
|
List<DictionaryType> selectDictionaryByStructureId(Integer id);
|
||||||
|
|
||||||
|
List<DictionaryData> selectDictionaryDataByType(@Param("dictionaryType") String dictionaryType);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.muyu.data.source.service;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.DictionaryData;
|
||||||
|
import com.muyu.data.source.domain.DictionaryType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典业务层 DictionaryService
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* on 2024/4/29
|
||||||
|
*/
|
||||||
|
public interface DictionaryService {
|
||||||
|
Result<List<DictionaryType>> findDictionaryByStructureId(Integer id);
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
||||||
LambdaQueryWrapper<DataSource> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DataSource> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ObjUtils.notNull(dataSource.getAccessSourceName())){
|
if (ObjUtils.notNull(dataSource.getAccessSourceName())){
|
||||||
queryWrapper.like(DataSource::getAccessSourceName, dataSource.getAccessSourceName());
|
queryWrapper.like(DataSource::getAccessSourceName, dataSource.getAccessSourceName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.muyu.data.source.service.impl;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.DictionaryData;
|
||||||
|
import com.muyu.data.source.domain.DictionaryType;
|
||||||
|
import com.muyu.data.source.mapper.DictionaryMapper;
|
||||||
|
import com.muyu.data.source.service.DictionaryService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典业务实现层 DictionaryServiceImpl
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* on 2024/4/29
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class DictionaryServiceImpl implements DictionaryService {
|
||||||
|
@Autowired
|
||||||
|
private DictionaryMapper dictionaryMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<DictionaryType>> findDictionaryByStructureId(Integer id) {
|
||||||
|
|
||||||
|
List<DictionaryType> dictionaryTypeList = dictionaryMapper.selectDictionaryByStructureId(id);
|
||||||
|
|
||||||
|
List<DictionaryType> list = dictionaryTypeList.stream()
|
||||||
|
.map(dictionaryType -> {
|
||||||
|
List<DictionaryData> dictionaryDataList = dictionaryMapper.selectDictionaryDataByType(dictionaryType.getDictionaryType());
|
||||||
|
DictionaryType build = DictionaryType.builder()
|
||||||
|
.dictionaryDataList(dictionaryDataList)
|
||||||
|
.dictionaryType(dictionaryType.getDictionaryType())
|
||||||
|
.dictionaryName(dictionaryType.getDictionaryName())
|
||||||
|
.dictionaryDataList(dictionaryDataList)
|
||||||
|
.status(dictionaryType.getStatus())
|
||||||
|
.remark(dictionaryType.getRemark())
|
||||||
|
.createBy(dictionaryType.getCreateBy())
|
||||||
|
.createTime(dictionaryType.getCreateTime())
|
||||||
|
.updateBy(dictionaryType.getUpdateBy())
|
||||||
|
.updateTime(dictionaryType.getUpdateTime())
|
||||||
|
.build();
|
||||||
|
return build;
|
||||||
|
}).toList();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?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.muyu.data.source.mapper.DictionaryMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectDictionaryByStructureId" resultType="com.muyu.data.source.domain.DictionaryType">
|
||||||
|
select * from dictionary_type where structure_id = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="selectDictionaryDataByType" resultType="com.muyu.data.source.domain.DictionaryData">
|
||||||
|
select * from dictionary_data where dictionary_type = #{dictionaryType}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue