master:字典管理具体类型对应的明细数据功能;
parent
35bfc13f05
commit
50c97f9b0e
|
|
@ -1,16 +1,34 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.domain.vo.dictData.DictDataDeleteVO;
|
||||
import com.ruoyi.common.core.domain.vo.dictData.DictDataPageVO;
|
||||
import com.ruoyi.common.core.domain.vo.dictData.DictDataResVO;
|
||||
import com.ruoyi.common.core.domain.vo.dictData.DictDataVO;
|
||||
import com.ruoyi.common.core.domain.vo.dictType.DictTypePageResVO;
|
||||
import com.ruoyi.common.core.domain.vo.dictType.DictTypePageVO;
|
||||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataDeleteDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataPageDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataResDTO;
|
||||
import com.ruoyi.system.domain.dto.dictType.DictTypePageDTO;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -24,14 +42,107 @@ import java.util.List;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "字典数据明细")
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController extends BaseController {
|
||||
@Autowired
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
final ISysDictDataService dictDataService;
|
||||
final ISysDictTypeService dictTypeService;
|
||||
|
||||
/**
|
||||
* 新增字典明细类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@ApiOperation(value = "新增字典明细类型", httpMethod = "POST", response = R.class)
|
||||
@Log(title = "新增字典明细类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Integer> create(@Validated @RequestBody DictDataVO dataVO) {
|
||||
return R.ok(dictDataService.create(BeanUtil.toBean(dataVO, DictDataDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典明细类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@ApiOperation(value = "修改字典明细类型", httpMethod = "PUT", response = R.class)
|
||||
@Log(title = "修改字典明细类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Integer> update(@Validated @RequestBody DictDataVO dataVO) {
|
||||
return R.ok(dictDataService.update(BeanUtil.toBean(dataVO, DictDataDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典明细类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@ApiOperation(value = "删除字典明细类型", httpMethod = "PUT", response = R.class)
|
||||
@Log(title = "删除字典明细类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping()
|
||||
public R<Integer> delete(@Validated @RequestBody DictDataDeleteVO deleteVO) {
|
||||
return R.ok(dictDataService.delete(BeanUtil.toBean(deleteVO, DictDataDeleteDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典数据详细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@ApiOperation(value = "查询字典数据详细", httpMethod = "GET", response = R.class)
|
||||
@GetMapping(value = "/{dictDataId}")
|
||||
public R<DictDataResVO> getInfo(@PathVariable Long dictDataId) {
|
||||
return R.ok(BeanUtil.toBean(dictDataService.selectById(dictDataId), DictDataResVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
@ApiOperation(value = "根据字典类型查询字典数据信息", httpMethod = "GET", response = R.class)
|
||||
public R<List<DictDataResVO>> dictType(@PathVariable String dictType) {
|
||||
return R.ok(BeanUtil.copyToList(dictDataService.selectByDictType(dictType), DictDataResVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ===============================================================================================
|
||||
// ===============================================================================================
|
||||
// ===============================================================================================
|
||||
// ===============================================================================================
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
|
|
@ -53,54 +164,55 @@ public class SysDictDataController extends BaseController {
|
|||
/**
|
||||
* 查询字典数据详细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
/* @PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictCode) {
|
||||
return success(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
/* @GetMapping(value = "/type/{dictType}")
|
||||
public AjaxResult dictType(@PathVariable String dictType) {
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNull(data)) {
|
||||
data = new ArrayList<SysDictData>();
|
||||
}
|
||||
return success(data);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
/*@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setCreateBy(getUsername());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
/*@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setUpdateBy(getUsername());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
/*@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictCodes) {
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return success();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.domain.XktBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
|
@ -15,155 +19,56 @@ import javax.validation.constraints.Size;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysDictData extends BaseEntity {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysDictData extends XktBaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
|
||||
private Long dictCode;
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字典排序
|
||||
*/
|
||||
@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
|
||||
private Long dictSort;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Excel(name = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典键值
|
||||
*/
|
||||
@Excel(name = "字典键值")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 样式属性(其他样式扩展)
|
||||
*/
|
||||
private String cssClass;
|
||||
|
||||
/**
|
||||
* 表格字典样式
|
||||
*/
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 是否默认(Y是 N否)
|
||||
*/
|
||||
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
|
||||
private String isDefault;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
public Long getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public void setDictCode(Long dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public Long getDictSort() {
|
||||
return dictSort;
|
||||
}
|
||||
|
||||
public void setDictSort(Long dictSort) {
|
||||
this.dictSort = dictSort;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
public String getDictLabel() {
|
||||
return dictLabel;
|
||||
}
|
||||
|
||||
public void setDictLabel(String dictLabel) {
|
||||
this.dictLabel = dictLabel;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
public String getDictValue() {
|
||||
return dictValue;
|
||||
}
|
||||
|
||||
public void setDictValue(String dictValue) {
|
||||
this.dictValue = dictValue;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public void setCssClass(String cssClass) {
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
public String getListClass() {
|
||||
return listClass;
|
||||
}
|
||||
|
||||
public void setListClass(String listClass) {
|
||||
this.listClass = listClass;
|
||||
}
|
||||
|
||||
public boolean getDefault() {
|
||||
return UserConstants.YES.equals(this.isDefault);
|
||||
}
|
||||
|
||||
public String getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("dictCode", getDictCode())
|
||||
.append("id", getId())
|
||||
.append("dictSort", getDictSort())
|
||||
.append("dictLabel", getDictLabel())
|
||||
.append("dictValue", getDictValue())
|
||||
.append("dictType", getDictType())
|
||||
.append("cssClass", getCssClass())
|
||||
.append("listClass", getListClass())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("status", getStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.common.core.domain.vo.dictData;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("删除系统字典明细类型")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DictDataDeleteVO {
|
||||
|
||||
@NotNull(message = "字典明细主键列表不能为空")
|
||||
@ApiModelProperty(value = "字典明细主键列表")
|
||||
private List<Long> dictDataIdList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.common.core.domain.vo.dictData;
|
||||
|
||||
import com.ruoyi.common.core.domain.vo.BasePageVO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("字典明细类型分页查询入参")
|
||||
@Data
|
||||
public class DictDataPageVO extends BasePageVO {
|
||||
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.common.core.domain.vo.dictData;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("系统字典明细")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DictDataResVO {
|
||||
|
||||
@ApiModelProperty(value = "新增不传,编辑必传")
|
||||
private Long dictDataId;
|
||||
@ApiModelProperty(value = "字典排序")
|
||||
private Long dictSort;
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
@ApiModelProperty(value = "字典键值")
|
||||
private String dictValue;
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
@ApiModelProperty(name = "状态")
|
||||
private String status;
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.ruoyi.common.core.domain.vo.dictData;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("系统字典明细")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DictDataVO {
|
||||
|
||||
@ApiModelProperty(value = "新增不传,编辑必传")
|
||||
private Long dictDataId;
|
||||
@NotNull(message = "字典排序不能为空")
|
||||
@ApiModelProperty(value = "字典排序")
|
||||
private Long dictSort;
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 1, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 1, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictValue;
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 1, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictType;
|
||||
@ApiModelProperty(name = "状态")
|
||||
@NotBlank(message = "状态不能为空")
|
||||
private String status;
|
||||
@ApiModelProperty(name = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -33,5 +33,7 @@ public class DictTypeVO {
|
|||
private String dictType;
|
||||
@Size(min = 1, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
private String remark;
|
||||
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.ruoyi.system.domain.dto.dictData;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("系统字典明细")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DictDataDTO {
|
||||
|
||||
@ApiModelProperty(value = "新增不传,编辑必传")
|
||||
private Long dictDataId;
|
||||
@ApiModelProperty(value = "字典排序")
|
||||
private Long dictSort;
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
@ApiModelProperty(value = "字典键值")
|
||||
private String dictValue;
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
@ApiModelProperty(name = "状态")
|
||||
private String status;
|
||||
@ApiModelProperty(name = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.system.domain.dto.dictData;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("删除系统字典明细类型")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DictDataDeleteDTO {
|
||||
|
||||
@ApiModelProperty(value = "字典明细主键列表")
|
||||
private List<Long> dictDataIdList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.system.domain.dto.dictData;
|
||||
|
||||
import com.ruoyi.common.core.domain.vo.BasePageVO;
|
||||
import com.ruoyi.system.domain.dto.BasePageDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("字典明细类型分页查询入参")
|
||||
@Data
|
||||
public class DictDataPageDTO extends BasePageDTO {
|
||||
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.system.domain.dto.dictData;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("系统字典明细")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DictDataResDTO {
|
||||
|
||||
@ApiModelProperty(value = "新增不传,编辑必传")
|
||||
private Long dictDataId;
|
||||
@ApiModelProperty(value = "字典排序")
|
||||
private Long dictSort;
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
@ApiModelProperty(value = "字典键值")
|
||||
private String dictValue;
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
@ApiModelProperty(name = "状态")
|
||||
private String status;
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
|
@ -21,17 +21,13 @@ public class DictTypeDTO {
|
|||
|
||||
@ApiModelProperty(value = "字典主键, 新增不传 编辑必传")
|
||||
private Long dictId;
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Size(min = 1, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||
@ApiModelProperty(value = "字典名称")
|
||||
private String dictName;
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 1, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
@Size(min = 1, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
@ApiModelProperty(value = "字典描述")
|
||||
private String remark;
|
||||
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -10,7 +11,7 @@ import java.util.List;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysDictDataMapper {
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.domain.vo.dictData.DictDataResVO;
|
||||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataDeleteDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataPageDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataResDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -57,4 +63,15 @@ public interface ISysDictDataService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int updateDictData(SysDictData dictData);
|
||||
|
||||
Integer create(DictDataDTO dataDTO);
|
||||
|
||||
Integer update(DictDataDTO dataDTO);
|
||||
|
||||
Integer delete(DictDataDeleteDTO deleteDTO);
|
||||
|
||||
DictDataResDTO selectById(Long dictDataId);
|
||||
|
||||
List<DictDataResDTO> selectByDictType(String dictType);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,114 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataDeleteDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataPageDTO;
|
||||
import com.ruoyi.system.domain.dto.dictData.DictDataResDTO;
|
||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
final SysDictDataMapper dictDataMapper;
|
||||
|
||||
private final static String STATUS_NORMAL = "0";
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer create(DictDataDTO dataDTO) {
|
||||
SysDictData dictData = BeanUtil.toBean(dataDTO, SysDictData.class);
|
||||
dictData.setCreateBy(getUsername());
|
||||
return this.dictDataMapper.insert(dictData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer update(DictDataDTO dataDTO) {
|
||||
SysDictData dict = Optional.ofNullable(this.dictDataMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getId, dataDTO.getDictDataId()).eq(SysDictData::getDelFlag, Constants.UNDELETED)
|
||||
.eq(SysDictData::getStatus, dataDTO.getStatus())))
|
||||
.orElseThrow(() -> new ServiceException("字典数据不存在!", HttpStatus.ERROR));
|
||||
dict.setUpdateBy(getUsername());
|
||||
BeanUtil.copyProperties(dataDTO, dict);
|
||||
return this.dictDataMapper.updateById(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer delete(DictDataDeleteDTO deleteDTO) {
|
||||
List<SysDictData> dataList = Optional.ofNullable(this.dictDataMapper.selectList(new LambdaQueryWrapper<SysDictData>()
|
||||
.in(SysDictData::getId, deleteDTO.getDictDataIdList()).eq(SysDictData::getDelFlag, Constants.UNDELETED)))
|
||||
.orElseThrow(() -> new ServiceException("字典数据不存在!", HttpStatus.ERROR));
|
||||
dataList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||
return this.dictDataMapper.updateById(dataList).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public DictDataResDTO selectById(Long dictDataId) {
|
||||
SysDictData dictData = Optional.ofNullable(this.dictDataMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getId, dictDataId).eq(SysDictData::getDelFlag, Constants.UNDELETED)))
|
||||
.orElseThrow(() -> new ServiceException("字典数据不存在!", HttpStatus.ERROR));
|
||||
return BeanUtil.toBean(dictData, DictDataResDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<DictDataResDTO> selectByDictType(String dictType) {
|
||||
List<SysDictData> dataList = this.dictDataMapper.selectList(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, dictType).eq(SysDictData::getDelFlag, Constants.UNDELETED));
|
||||
return BeanUtil.copyToList(dataList, DictDataResDTO.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ===================================================================================================
|
||||
// ===================================================================================================
|
||||
// ===================================================================================================
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
|
|
@ -99,4 +190,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
|||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
|||
}
|
||||
SysDictType dict = Optional.ofNullable(this.dictTypeMapper.selectOne(new LambdaQueryWrapper<SysDictType>()
|
||||
.eq(SysDictType::getDictId, typeDTO.getDictId()).eq(SysDictType::getDelFlag, Constants.UNDELETED)
|
||||
.eq(SysDictType::getStatus, STATUS_NORMAL)))
|
||||
.eq(SysDictType::getStatus, typeDTO.getStatus())))
|
||||
.orElseThrow(() -> new ServiceException("字典类型不存在!", HttpStatus.ERROR));
|
||||
dict.setUpdateBy(getUsername());
|
||||
BeanUtil.copyProperties(typeDTO, dict);
|
||||
|
|
@ -125,8 +125,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
|||
@Transactional
|
||||
public Integer delete(DictTypeDeleteDTO deleteDTO) {
|
||||
List<SysDictType> dictList = Optional.ofNullable(this.dictTypeMapper.selectList(new LambdaQueryWrapper<SysDictType>()
|
||||
.in(SysDictType::getDictId, deleteDTO.getDictIdList()).eq(SysDictType::getDelFlag, Constants.UNDELETED)
|
||||
.eq(SysDictType::getStatus, STATUS_NORMAL)))
|
||||
.in(SysDictType::getDictId, deleteDTO.getDictIdList()).eq(SysDictType::getDelFlag, Constants.UNDELETED)))
|
||||
.orElseThrow(() -> new ServiceException("字典类型不存在!", HttpStatus.ERROR));
|
||||
dictList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||
return this.dictTypeMapper.updateById(dictList).size();
|
||||
|
|
@ -144,7 +143,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
|||
public Page<DictTypePageResVO> page(DictTypePageDTO pageDTO) {
|
||||
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
|
||||
LambdaQueryWrapper<SysDictType> queryWrapper = new LambdaQueryWrapper<SysDictType>()
|
||||
.eq(SysDictType::getStatus, STATUS_NORMAL).eq(SysDictType::getDelFlag, Constants.UNDELETED);
|
||||
.eq(SysDictType::getDelFlag, Constants.UNDELETED);
|
||||
if (StringUtils.isNotBlank(pageDTO.getDictName())) {
|
||||
queryWrapper.like(SysDictType::getDictName, pageDTO.getDictName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.ruoyi.system.mapper.SysDictDataMapper">
|
||||
|
||||
<resultMap type="SysDictData" id="SysDictDataResult">
|
||||
<id property="dictCode" column="dict_code" />
|
||||
<id property="id" column="id" />
|
||||
<result property="dictSort" column="dict_sort" />
|
||||
<result property="dictLabel" column="dict_label" />
|
||||
<result property="dictValue" column="dict_value" />
|
||||
<result property="dictType" column="dict_type" />
|
||||
<result property="cssClass" column="css_class" />
|
||||
<result property="listClass" column="list_class" />
|
||||
<result property="isDefault" column="is_default" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
|
|
@ -21,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectDictDataVo">
|
||||
select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark
|
||||
select id, dict_sort, dict_label, dict_value, dict_type, status, create_by, create_time, remark
|
||||
from sys_dict_data
|
||||
</sql>
|
||||
|
||||
|
|
@ -53,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where dict_code = #{dictCode}
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="countDictDataByType" resultType="Integer">
|
||||
|
|
@ -61,13 +58,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<delete id="deleteDictDataById" parameterType="Long">
|
||||
delete from sys_dict_data where dict_code = #{dictCode}
|
||||
delete from sys_dict_data where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDictDataByIds" parameterType="Long">
|
||||
delete from sys_dict_data where dict_code in
|
||||
<foreach collection="array" item="dictCode" open="(" separator="," close=")">
|
||||
#{dictCode}
|
||||
delete from sys_dict_data where id in
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
|
@ -78,15 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
<if test="cssClass != null">css_class = #{cssClass},</if>
|
||||
<if test="listClass != null">list_class = #{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dict_code = #{dictCode}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateDictDataType" parameterType="String">
|
||||
|
|
@ -99,9 +93,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value,</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
<if test="cssClass != null and cssClass != ''">css_class,</if>
|
||||
<if test="listClass != null and listClass != ''">list_class,</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
|
|
@ -111,9 +102,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
<if test="cssClass != null and cssClass != ''">#{cssClass},</if>
|
||||
<if test="listClass != null and listClass != ''">#{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">#{isDefault},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ insert into sys_dict_type values(10, '系统状态', 'sys_common_status', '0',
|
|||
drop table if exists sys_dict_data;
|
||||
create table sys_dict_data
|
||||
(
|
||||
dict_code bigint(20) not null auto_increment comment '字典编码',
|
||||
id bigint(20) not null auto_increment comment '字典编码',
|
||||
dict_sort int(4) default 0 comment '字典排序',
|
||||
dict_label varchar(100) default '' comment '字典标签',
|
||||
dict_value varchar(100) default '' comment '字典键值',
|
||||
|
|
|
|||
Loading…
Reference in New Issue