数据字典模块完成

This commit is contained in:
YunaiV
2020-07-15 08:48:24 +08:00
parent ac9d5f32f7
commit e1e42c0ce0
31 changed files with 993 additions and 299 deletions

View File

@@ -0,0 +1,80 @@
package cn.iocoder.mall.managementweb.controller.datadict;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictCreateDTO;
import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictUpdateDTO;
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictSimpleVO;
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictVO;
import cn.iocoder.mall.managementweb.manager.datadict.DataDictManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 数据字典 Controller
*/
@RestController
@RequestMapping("/data_dict")
@Api(tags = "数据字典")
@Validated
public class DataDictController {
@Autowired
private DataDictManager dataDictManager;
@PostMapping("/create")
@ApiOperation("创建数据字典")
public CommonResult<Integer> createDataDict(@Valid DataDictCreateDTO createDTO) {
return success(dataDictManager.createDataDict(createDTO));
}
@PostMapping("/update")
@ApiOperation("更新数据字典")
public CommonResult<Boolean> updateDataDict(@Valid DataDictUpdateDTO updateDTO) {
dataDictManager.updateDataDict(updateDTO);
return success(true);
}
@PostMapping("/delete")
@ApiOperation("删除数据字典")
@ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true)
public CommonResult<Boolean> deleteDataDict(@RequestParam("dataDictId") Integer dataDictId) {
dataDictManager.deleteDataDict(dataDictId);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得数据字典")
@ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true)
public CommonResult<DataDictVO> getDataDict(@RequestParam("dataDictId") Integer dataDictId) {
return success(dataDictManager.getDataDict(dataDictId));
}
@GetMapping("/list")
@ApiOperation("获得数据字典列表")
@ApiImplicitParam(name = "dataDictIds", value = "数据字典编号列表", required = true)
public CommonResult<List<DataDictVO>> listDataDicts(@RequestParam("dataDictIds") List<Integer> dataDictIds) {
return success(dataDictManager.listDataDicts(dataDictIds));
}
@GetMapping("/list-all")
@ApiOperation("获得全部数据字典列表")
public CommonResult<List<DataDictVO>> listDataDicts() {
return success(dataDictManager.listDataDicts());
}
@GetMapping("/list-all-simple")
@ApiOperation(value = "获得全部数据字典列表", notes = "一般用于管理后台缓存数据字典在本地")
public CommonResult<List<DataDictSimpleVO>> listSimpleDataDicts() {
return success(dataDictManager.listSimpleDataDicts());
}
}

View File

@@ -0,0 +1,29 @@
package cn.iocoder.mall.managementweb.controller.datadict.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("数据字典创建 DTO")
@Data
public class DataDictCreateDTO {
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
@ApiModelProperty(value = "小类数值", required = true, example = "1")
@NotEmpty(message = "小类数值不能为空")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
@NotEmpty(message = "展示名不能为空")
private String displayName;
@ApiModelProperty(value = "排序值", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
@ApiModelProperty(value = "备注", example = "性别 - 男(嗨)")
private String memo;
}

View File

@@ -0,0 +1,32 @@
package cn.iocoder.mall.managementweb.controller.datadict.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("数据字典更新 DTO")
@Data
public class DataDictUpdateDTO {
@ApiModelProperty(value = "编号", required = true, example = "1024")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
@ApiModelProperty(value = "小类数值", required = true, example = "1")
@NotEmpty(message = "小类数值不能为空")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
@NotEmpty(message = "展示名不能为空")
private String displayName;
@ApiModelProperty(value = "排序值", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
@ApiModelProperty(value = "备注", example = "性别 - 男(嗨)")
private String memo;
}

View File

@@ -0,0 +1,23 @@
package cn.iocoder.mall.managementweb.controller.datadict.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@ApiModel("数据字典精简 VO")
@Data
public class DataDictSimpleVO {
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
@ApiModelProperty(value = "小类数值", required = true, example = "1")
@NotEmpty(message = "小类数值不能为空")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
@NotEmpty(message = "展示名不能为空")
private String displayName;
}

View File

@@ -0,0 +1,34 @@
package cn.iocoder.mall.managementweb.controller.datadict.vo;
import lombok.*;
import io.swagger.annotations.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.*;
@ApiModel("数据字典 VO")
@Data
public class DataDictVO {
@ApiModelProperty(value = "编号", required = true, example = "1024")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
@NotEmpty(message = "大类枚举值不能为空")
private String enumValue;
@ApiModelProperty(value = "小类数值", required = true, example = "1")
@NotEmpty(message = "小类数值不能为空")
private String value;
@ApiModelProperty(value = "展示名", required = true, example = "")
@NotEmpty(message = "展示名不能为空")
private String displayName;
@ApiModelProperty(value = "排序值", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
@ApiModelProperty(value = "备注", example = "性别 - 男(嗨)")
private String memo;
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}