增加查询字典接口
This commit is contained in:
@ -0,0 +1,39 @@
|
||||
package com.sczx.store.controller;
|
||||
|
||||
|
||||
import com.sczx.store.common.Result;
|
||||
import com.sczx.store.dto.SysDictDataDTO;
|
||||
import com.sczx.store.service.SysDataService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典数据表
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-07-27 21:39:33
|
||||
*/
|
||||
@Api(value = "系统数据接口", tags = "系统数据")
|
||||
@RestController
|
||||
@RequestMapping("/sys")
|
||||
public class SysDataController {
|
||||
|
||||
@Autowired
|
||||
private SysDataService sysDataService;
|
||||
|
||||
@ApiOperation(value = "根据字典key查询字典数据")
|
||||
@GetMapping("/listDictDataByDicType")
|
||||
public Result<List<SysDictDataDTO>> listDictDataByDicType(@RequestParam(name = "dicType") String dicType){
|
||||
|
||||
return Result.ok(sysDataService.listDictDataByDicType(dicType));
|
||||
}
|
||||
}
|
||||
16
src/main/java/com/sczx/store/convert/SysDictDataConvert.java
Normal file
16
src/main/java/com/sczx/store/convert/SysDictDataConvert.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.convert;
|
||||
|
||||
import com.sczx.store.dto.SysDictDataDTO;
|
||||
import com.sczx.store.po.SysDictDataPO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysDictDataConvert {
|
||||
SysDictDataConvert INSTANCE = Mappers.getMapper(SysDictDataConvert.class);
|
||||
SysDictDataPO dtoToPO(SysDictDataDTO dto);
|
||||
SysDictDataDTO poToDTO(SysDictDataPO po);
|
||||
List<SysDictDataDTO> posToDtos(List<SysDictDataPO> pos);
|
||||
}
|
||||
22
src/main/java/com/sczx/store/dto/SysDictDataDTO.java
Normal file
22
src/main/java/com/sczx/store/dto/SysDictDataDTO.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.sczx.store.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel(value = "SysDictDataDTO对象", description = "字典数据传输对象")
|
||||
@Data
|
||||
public class SysDictDataDTO {
|
||||
|
||||
@ApiModelProperty("字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
@ApiModelProperty("字典键值")
|
||||
private String dictValue;
|
||||
|
||||
@ApiModelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@ApiModelProperty("状态(0正常 1停用)")
|
||||
private String status;
|
||||
}
|
||||
16
src/main/java/com/sczx/store/mapper/SysDictDataMapper.java
Normal file
16
src/main/java/com/sczx/store/mapper/SysDictDataMapper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.mapper;
|
||||
|
||||
import com.sczx.store.po.SysDictDataPO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典数据表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-07-27 21:39:33
|
||||
*/
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictDataPO> {
|
||||
|
||||
}
|
||||
74
src/main/java/com/sczx/store/po/SysDictDataPO.java
Normal file
74
src/main/java/com/sczx/store/po/SysDictDataPO.java
Normal file
@ -0,0 +1,74 @@
|
||||
package com.sczx.store.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典数据表
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-07-27 21:39:33
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_dict_data")
|
||||
@ApiModel(value = "SysDictDataPO对象", description = "字典数据表")
|
||||
public class SysDictDataPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("字典编码")
|
||||
@TableId(value = "dict_code", type = IdType.AUTO)
|
||||
private Long dictCode;
|
||||
|
||||
@ApiModelProperty("字典排序")
|
||||
private Integer dictSort;
|
||||
|
||||
@ApiModelProperty("字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
@ApiModelProperty("字典键值")
|
||||
private String dictValue;
|
||||
|
||||
@ApiModelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@ApiModelProperty("样式属性(其他样式扩展)")
|
||||
private String cssClass;
|
||||
|
||||
@ApiModelProperty("表格回显样式")
|
||||
private String listClass;
|
||||
|
||||
@ApiModelProperty("是否默认(Y是 N否)")
|
||||
private String isDefault;
|
||||
|
||||
@ApiModelProperty("状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty("更新者")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
16
src/main/java/com/sczx/store/repository/SysDictDataRepo.java
Normal file
16
src/main/java/com/sczx/store/repository/SysDictDataRepo.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.repository;
|
||||
|
||||
import com.sczx.store.po.SysDictDataPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-07-27 21:39:33
|
||||
*/
|
||||
public interface SysDictDataRepo extends IService<SysDictDataPO> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.sczx.store.repository.impl;
|
||||
|
||||
import com.sczx.store.po.SysDictDataPO;
|
||||
import com.sczx.store.mapper.SysDictDataMapper;
|
||||
import com.sczx.store.repository.SysDictDataRepo;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-07-27 21:39:33
|
||||
*/
|
||||
@Service
|
||||
public class SysDictDataRepoImpl extends ServiceImpl<SysDictDataMapper, SysDictDataPO> implements SysDictDataRepo {
|
||||
|
||||
}
|
||||
15
src/main/java/com/sczx/store/service/SysDataService.java
Normal file
15
src/main/java/com/sczx/store/service/SysDataService.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.sczx.store.service;
|
||||
|
||||
import com.sczx.store.dto.SysDictDataDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysDataService {
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
* @param dicType
|
||||
* @return
|
||||
*/
|
||||
List<SysDictDataDTO> listDictDataByDicType(String dicType);
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.sczx.store.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.sczx.store.convert.SysDictDataConvert;
|
||||
import com.sczx.store.dto.SysDictDataDTO;
|
||||
import com.sczx.store.po.SysDictDataPO;
|
||||
import com.sczx.store.repository.SysDictDataRepo;
|
||||
import com.sczx.store.service.SysDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysDataServiceImpl implements SysDataService {
|
||||
|
||||
@Autowired
|
||||
private SysDictDataRepo sysDictDataRepo;
|
||||
|
||||
@Override
|
||||
public List<SysDictDataDTO> listDictDataByDicType(String dicType) {
|
||||
LambdaQueryWrapper<SysDictDataPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysDictDataPO::getDictType, dicType);
|
||||
List<SysDictDataPO> sysDictDataPOList = sysDictDataRepo.list(wrapper);
|
||||
|
||||
return SysDictDataConvert.INSTANCE.posToDtos(sysDictDataPOList);
|
||||
}
|
||||
}
|
||||
5
src/main/resources/mapper/SysDictDataMapper.xml
Normal file
5
src/main/resources/mapper/SysDictDataMapper.xml
Normal file
@ -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.sczx.store.mapper.SysDictDataMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user