1.字典接口调整
This commit is contained in:
parent
a01f765e8d
commit
a0c5fdcb5f
|
@ -0,0 +1,61 @@
|
|||
package com.dite.znpt.domain.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.dite.znpt.domain.AuditableEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典表实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("dict")
|
||||
@ApiModel(value="DictEntity对象", description="字典表")
|
||||
public class DictEntity extends AuditableEntity implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -52191875430786367L;
|
||||
|
||||
@ExcelProperty("字典id")
|
||||
@ApiModelProperty("字典id")
|
||||
@TableId(value = "dict_id", type = IdType.ASSIGN_ID)
|
||||
private String dictId;
|
||||
|
||||
@ExcelProperty("字典类型")
|
||||
@ApiModelProperty("字典类型")
|
||||
@TableField("dict_type")
|
||||
private String dictType;
|
||||
|
||||
@ExcelProperty("字典名称")
|
||||
@ApiModelProperty("字典名称")
|
||||
@TableField("dict_name")
|
||||
private String dictName;
|
||||
|
||||
@ExcelProperty("父级id")
|
||||
@ApiModelProperty("父级id")
|
||||
@TableField("parent_id")
|
||||
private Long parentId;
|
||||
|
||||
@ExcelProperty("字典排序")
|
||||
@ApiModelProperty("字典排序")
|
||||
@TableField("sort_order")
|
||||
private Integer sortOrder;
|
||||
|
||||
@ExcelProperty("是否字典终值")
|
||||
@ApiModelProperty("是否字典终值")
|
||||
@TableField("final_state")
|
||||
private Integer finalState;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典请求实体
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("字典列表请求实体")
|
||||
public class DictListReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 243104747131701229L;
|
||||
|
||||
@ApiModelProperty("字典Id")
|
||||
private String dictId;
|
||||
|
||||
@ApiModelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@ApiModelProperty("字典名称")
|
||||
private String dictName;
|
||||
|
||||
@ApiModelProperty("父级id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("字典排序")
|
||||
private Integer sortOrder;
|
||||
|
||||
@ApiModelProperty("是否字典终值")
|
||||
private Integer finalState;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.dite.znpt.util.ValidationGroup;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典表请求类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="Dict请求对象", description="字典表")
|
||||
public class DictReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 104440023555693334L;
|
||||
|
||||
@ApiModelProperty("字典id")
|
||||
private String dictId;
|
||||
|
||||
@NotBlank(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, message = "字典类型不能为空")
|
||||
@Size(max = 20, groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, message = "字典类型长度不能超过20")
|
||||
@ApiModelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@NotBlank(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, message = "字典名称不能为空")
|
||||
@Size(max = 50, groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, message = "字典名称长度不能超过50")
|
||||
@ApiModelProperty("字典名称")
|
||||
private String dictName;
|
||||
|
||||
@ApiModelProperty("父级id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("字典排序")
|
||||
private Integer sortOrder;
|
||||
|
||||
@ApiModelProperty("是否字典终值")
|
||||
private Integer finalState;
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.dite.znpt.domain.entity.DictEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典响应实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("字典响应实体")
|
||||
public class DictResp extends DictEntity {
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.dite.znpt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dite.znpt.domain.entity.CombinedDictEntity;
|
||||
import com.dite.znpt.domain.vo.CombinedDictListReq;
|
||||
import com.dite.znpt.domain.vo.CombinedDictResp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
* @Description: 字典表数据库访问层
|
||||
*/
|
||||
public interface CombinedDictMapper extends BaseMapper<CombinedDictEntity> {
|
||||
List<CombinedDictResp> queryBySelective(CombinedDictListReq combinedDictReq);
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.dite.znpt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dite.znpt.domain.entity.DictEntity;
|
||||
import com.dite.znpt.domain.vo.DictListReq;
|
||||
import com.dite.znpt.domain.vo.DictResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典表数据库访问层
|
||||
*/
|
||||
public interface DictMapper extends BaseMapper<DictEntity> {
|
||||
List<DictResp> queryBySelective(DictListReq dictReq);
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
package com.dite.znpt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dite.znpt.domain.entity.CombinedDictEntity;
|
||||
import com.dite.znpt.domain.vo.CombinedDictListReq;
|
||||
import com.dite.znpt.domain.vo.CombinedDictResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
* @Description: 字典表服务接口
|
||||
*/
|
||||
public interface CombinedDictService extends IService<CombinedDictEntity> {
|
||||
|
||||
/**
|
||||
* 功能描述:查询字典列表
|
||||
*
|
||||
* @param combinedDictReq 字典
|
||||
* @return {@link List }<{@link CombinedDictEntity }>
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
List<CombinedDictResp> selectList(CombinedDictListReq combinedDictReq);
|
||||
|
||||
/**
|
||||
* 功能描述:查询单条字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @return {@link CombinedDictResp }
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
CombinedDictResp selectById(String dictId);
|
||||
|
||||
/**
|
||||
* 功能描述:新增字典
|
||||
*
|
||||
* @param combinedDict 字典
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
void saveData(CombinedDictEntity combinedDict);
|
||||
|
||||
/**
|
||||
* 功能描述:更新字典
|
||||
*
|
||||
* @param combinedDict 字典
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
void updateData(CombinedDictEntity combinedDict);
|
||||
|
||||
/**
|
||||
* 功能描述:删除字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
void deleteById(String dictId);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.dite.znpt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dite.znpt.domain.entity.DictEntity;
|
||||
import com.dite.znpt.domain.vo.DictListReq;
|
||||
import com.dite.znpt.domain.vo.DictReq;
|
||||
import com.dite.znpt.domain.vo.DictResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典表服务接口
|
||||
*/
|
||||
public interface DictService extends IService<DictEntity> {
|
||||
|
||||
/**
|
||||
* 功能描述:查询字典列表
|
||||
*
|
||||
* @param dictReq 字典
|
||||
* @return {@link List }<{@link DictResp }>
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
List<DictResp> selectList(DictListReq dictReq);
|
||||
|
||||
/**
|
||||
* 功能描述:查询单条字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @return {@link DictResp }
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
DictResp selectById(String dictId);
|
||||
|
||||
/**
|
||||
* 功能描述:新增字典
|
||||
*
|
||||
* @param dictReq 字典
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
void saveData(DictReq dictReq);
|
||||
|
||||
/**
|
||||
* 功能描述:更新字典
|
||||
*
|
||||
* @param dictReq 字典
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
void updateData(DictReq dictReq);
|
||||
|
||||
/**
|
||||
* 功能描述:删除字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
void deleteById(String dictId);
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
package com.dite.znpt.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.domain.entity.CombinedDictEntity;
|
||||
import com.dite.znpt.domain.vo.CombinedDictListReq;
|
||||
import com.dite.znpt.domain.vo.CombinedDictResp;
|
||||
import com.dite.znpt.service.CombinedDictService;
|
||||
import com.dite.znpt.mapper.CombinedDictMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.dite.znpt.util.PageUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
* @Description: 字典表服务实现类
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CombinedDictServiceImpl extends ServiceImpl<CombinedDictMapper, CombinedDictEntity> implements CombinedDictService {
|
||||
|
||||
/**
|
||||
* 功能描述:查询字典列表
|
||||
*
|
||||
* @param combinedDictReq 字典信息
|
||||
* @return {@link List }<{@link CombinedDictResp }>
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
@Override
|
||||
public List<CombinedDictResp> selectList(CombinedDictListReq combinedDictReq) {
|
||||
PageUtil.startPage();
|
||||
List<CombinedDictResp> combinedDictList= this.baseMapper.queryBySelective(combinedDictReq);
|
||||
combinedDictList.forEach(resp -> {
|
||||
|
||||
});
|
||||
return combinedDictList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:查询单条字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @return {@link CombinedDictResp }
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
@Override
|
||||
public CombinedDictResp selectById(String dictId) {
|
||||
CombinedDictListReq combinedDictReq = new CombinedDictListReq();
|
||||
combinedDictReq.setDictId(dictId);
|
||||
|
||||
List<CombinedDictResp> list = selectList(combinedDictReq);
|
||||
return CollUtil.isNotEmpty(list) ? CollUtil.getFirst(list) : new CombinedDictResp();
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:新增字典
|
||||
*
|
||||
* @param combinedDict 字典
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
@Override
|
||||
public void saveData(CombinedDictEntity combinedDict) {
|
||||
// todo 校验
|
||||
save(combinedDict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:更新字典
|
||||
*
|
||||
* @param combinedDict 字典
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
@Override
|
||||
public void updateData(CombinedDictEntity combinedDict) {
|
||||
// todo 校验
|
||||
updateById(combinedDict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:删除字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
**/
|
||||
@Override
|
||||
public void deleteById(String dictId) {
|
||||
// todo 校验
|
||||
removeById(dictId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package com.dite.znpt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.domain.entity.DictEntity;
|
||||
import com.dite.znpt.domain.vo.DictListReq;
|
||||
import com.dite.znpt.domain.vo.DictReq;
|
||||
import com.dite.znpt.domain.vo.DictResp;
|
||||
import com.dite.znpt.mapper.DictMapper;
|
||||
import com.dite.znpt.service.DictService;
|
||||
import com.dite.znpt.util.PageUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
* @Description: 字典表服务实现类
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictServiceImpl extends ServiceImpl<DictMapper, DictEntity> implements DictService {
|
||||
|
||||
/**
|
||||
* 功能描述:查询字典列表
|
||||
*
|
||||
* @param dictReq 字典信息
|
||||
* @return {@link List }<{@link DictResp }>
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
@Override
|
||||
public List<DictResp> selectList(DictListReq dictReq) {
|
||||
PageUtil.startPage();
|
||||
List<DictResp> dictList= this.baseMapper.queryBySelective(dictReq);
|
||||
dictList.forEach(resp -> {
|
||||
|
||||
});
|
||||
return dictList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:查询单条字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @return {@link DictResp }
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
@Override
|
||||
public DictResp selectById(String dictId) {
|
||||
DictListReq dictReq = new DictListReq();
|
||||
dictReq.setDictId(dictId);
|
||||
|
||||
List<DictResp> list = selectList(dictReq);
|
||||
return list.isEmpty() ? CollUtil.getFirst(list) : new DictResp();
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:新增字典
|
||||
*
|
||||
* @param dictReq 字典
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
@Override
|
||||
public void saveData(DictReq dictReq) {
|
||||
// todo 校验
|
||||
DictEntity entity = BeanUtil.copyProperties(dictReq, DictEntity.class);
|
||||
save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:更新字典
|
||||
*
|
||||
* @param dictReq 字典
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
@Override
|
||||
public void updateData(DictReq dictReq) {
|
||||
// todo 校验
|
||||
DictEntity entity = BeanUtil.copyProperties(dictReq, DictEntity.class);
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:删除字典
|
||||
*
|
||||
* @param dictId 字典Id
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:38
|
||||
**/
|
||||
@Override
|
||||
public void deleteById(String dictId) {
|
||||
// todo 校验
|
||||
removeById(dictId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +1,37 @@
|
|||
<?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.dite.znpt.mapper.CombinedDictMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
a.dict_id, a.dict_type, a.dict_name, a.parent_id,
|
||||
a.sort_order, a.final_state
|
||||
</sql>
|
||||
|
||||
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.CombinedDictResp">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from combined_dict a
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
# and (a.TODO like concat('%', #{keyword,jdbcType=VARCHAR}, '%') or a.TODO like concat('%', #{keyword,jdbcType=VARCHAR}, '%'))
|
||||
</if>
|
||||
<if test="dictId != null and dictId != ''">
|
||||
and a.dict_id like concat ('%', #{dictId}, '%')
|
||||
</if>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
and a.dict_type like concat ('%', #{dictType}, '%')
|
||||
</if>
|
||||
<if test="dictName != null and dictName != ''">
|
||||
and a.dict_name like concat ('%', #{dictName}, '%')
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
and a.parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="sortOrder != null">
|
||||
and a.sort_order = #{sortOrder}
|
||||
</if>
|
||||
<if test="finalState != null">
|
||||
and a.final_state = #{finalState}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
<?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.dite.znpt.mapper.DictMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
a.dict_id, a.dict_type, a.dict_name, a.parent_id,
|
||||
a.sort_order, a.final_state, a.create_time, a.create_by,
|
||||
a.update_time, a.update_by
|
||||
</sql>
|
||||
|
||||
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.DictResp">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from dict a
|
||||
<where>
|
||||
<if test="dictId != null and dictId != ''">
|
||||
and a.dict_id like concat ('%', #{dictId}, '%')
|
||||
</if>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
and a.dict_type like concat ('%', #{dictType}, '%')
|
||||
</if>
|
||||
<if test="dictName != null and dictName != ''">
|
||||
and a.dict_name like concat ('%', #{dictName}, '%')
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
and a.parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="sortOrder != null">
|
||||
and a.sort_order = #{sortOrder}
|
||||
</if>
|
||||
<if test="finalState != null">
|
||||
and a.final_state = #{finalState}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
|
||||
import com.dite.znpt.constant.Constants;
|
||||
import com.dite.znpt.domain.vo.CombinedDictListReq;
|
||||
import com.dite.znpt.domain.vo.CombinedDictResp;
|
||||
import com.dite.znpt.domain.entity.CombinedDictEntity;
|
||||
import com.dite.znpt.service.CombinedDictService;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
|
||||
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/04/11 23:17
|
||||
*/
|
||||
@Api(tags = "字典")
|
||||
@RestController
|
||||
@RequestMapping("/combined-dict")
|
||||
public class CombinedDictController {
|
||||
@Resource
|
||||
private CombinedDictService combinedDictService;
|
||||
|
||||
@ApiOperation(value = "获取字典列表", httpMethod = "GET")
|
||||
@GetMapping("/list")
|
||||
public PageResult<CombinedDictResp> list(CombinedDictListReq combinedDictReq) {
|
||||
return PageResult.ok(combinedDictService.selectList(combinedDictReq));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据字典Id获取详细信息", httpMethod = "GET")
|
||||
@GetMapping("/{dictId}")
|
||||
public Result<CombinedDictResp> getInfo(@PathVariable String dictId) {
|
||||
return Result.ok(combinedDictService.selectById(dictId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增字典", httpMethod = "POST")
|
||||
@PostMapping
|
||||
public Result<Object> add(@RequestBody CombinedDictEntity combinedDict) {
|
||||
combinedDictService.saveData(combinedDict);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改字典", httpMethod = "PUT")
|
||||
@PutMapping
|
||||
public Result<Object> edit(@RequestBody CombinedDictEntity combinedDict) {
|
||||
combinedDictService.updateData(combinedDict);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除字典", httpMethod = "DELETE")
|
||||
@DeleteMapping("/{dictId}")
|
||||
public Result<Object> remove(@PathVariable String dictId) {
|
||||
combinedDictService.deleteById(dictId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出字典", httpMethod = "GET")
|
||||
@GetMapping("/export")
|
||||
@ResponseExcel(name = "字典")
|
||||
public List<CombinedDictResp> export(CombinedDictListReq combinedDictReq) {
|
||||
return combinedDictService.selectList(combinedDictReq);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导入字典", httpMethod = "POST")
|
||||
@PostMapping("/import")
|
||||
public Result<Object> importData(@RequestExcel List<CombinedDictEntity> dataList, BindingResult bindingResult) {
|
||||
// JSR 303 校验通用校验获取失败的数据
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
if (errorMessageList != null && !errorMessageList.isEmpty()) {
|
||||
return Result.error(Constants.SERVICE_EXCEPTION, "导入失败");
|
||||
}
|
||||
return Result.okM("导入"+dataList.size()+"条数据");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.vo.DictListReq;
|
||||
import com.dite.znpt.domain.vo.DictReq;
|
||||
import com.dite.znpt.domain.vo.DictResp;
|
||||
import com.dite.znpt.service.DictService;
|
||||
import com.dite.znpt.util.ValidationGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/30 11:39
|
||||
*/
|
||||
@Api(tags = "字典")
|
||||
@RestController
|
||||
@RequestMapping("/dict")
|
||||
public class DictController {
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
|
||||
@ApiOperation(value = "获取字典列表", httpMethod = "GET")
|
||||
@GetMapping("/list")
|
||||
public PageResult<DictResp> list(DictListReq dictReq) {
|
||||
return PageResult.ok(dictService.selectList(dictReq));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据字典Id获取详细信息", httpMethod = "GET")
|
||||
@GetMapping("/{dictId}")
|
||||
public Result<DictResp> getInfo(@PathVariable String dictId) {
|
||||
return Result.ok(dictService.selectById(dictId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增字典", httpMethod = "POST")
|
||||
@PostMapping
|
||||
public Result<Object> add(@Validated(ValidationGroup.Insert.class) @RequestBody DictReq dictReq) {
|
||||
dictService.saveData(dictReq);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改字典", httpMethod = "PUT")
|
||||
@PutMapping
|
||||
public Result<Object> edit(@Validated(ValidationGroup.Update.class) @RequestBody DictReq dictReq) {
|
||||
dictService.updateData(dictReq);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除字典", httpMethod = "DELETE")
|
||||
@DeleteMapping("/{dictId}")
|
||||
public Result<Object> remove(@PathVariable String dictId) {
|
||||
dictService.deleteById(dictId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue