数据字典测试完成~

This commit is contained in:
YunaiV 2019-03-03 13:13:07 +08:00
parent 8089319f64
commit eddec34e5d
4 changed files with 34 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO;
import cn.iocoder.mall.admin.api.dto.DataDictAddDTO;
import cn.iocoder.mall.admin.api.dto.DataDictUpdateDTO;
import cn.iocoder.mall.admin.application.convert.DataDictConvert;
import cn.iocoder.mall.admin.application.vo.DataDictVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
@ -54,4 +55,32 @@ public class DataDictController {
return DataDictConvert.INSTANCE.convert2(result);
}
@PostMapping("/update")
@ApiOperation(value = "更新数据字典")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "100"),
@ApiImplicitParam(name = "value", value = "小类数值", required = true, example = "1"),
@ApiImplicitParam(name = "displayName", value = "展示名", required = true, example = ""),
@ApiImplicitParam(name = "sort", required = true, value = "排序值", defaultValue = "10"),
@ApiImplicitParam(name = "memo", value = "备注", example = "你猜我猜不猜"),
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("value") String value,
@RequestParam("displayName") String displayName,
@RequestParam("sort") Integer sort,
@RequestParam(value = "memo", required = false) String memo) {
// 创建 DataDictAddDTO 对象
DataDictUpdateDTO dataDictUpdateDTO = new DataDictUpdateDTO().setId(id).setValue(value).setDisplayName(displayName)
.setSort(sort).setMemo(memo);
// 更新数据字典
return dataDictService.updateDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictUpdateDTO);
}
@PostMapping("/delete")
@ApiOperation(value = "删除数据字典")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "100")
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
return dataDictService.deleteDataDict(AdminSecurityContextHolder.getContext().getAdminId(), id);
}
}

View File

@ -17,7 +17,7 @@ public class DataDictVO {
@ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "备注", example = "你猜")
private Integer memo;
private String memo;
public Integer getId() {
return id;
@ -64,11 +64,11 @@ public class DataDictVO {
return this;
}
public Integer getMemo() {
public String getMemo() {
return memo;
}
public DataDictVO setMemo(Integer memo) {
public DataDictVO setMemo(String memo) {
this.memo = memo;
return this;
}

View File

@ -41,7 +41,7 @@ public enum AdminErrorCodeEnum {
// ========== 数据字典模块 1002005000 ==========
DATA_DICT_EXISTS(1002005000, "该数据字典已经存在"),
DATA_DICT_NOT_EXISTS(1002005001, "该数据字典已经存在"),
DATA_DICT_NOT_EXISTS(1002005001, "该数据字典存在"),
;

View File

@ -57,7 +57,7 @@ public class DataDictServiceImpl implements DataDictService {
}
// 校验数据字典重复
DataDictDO duplicateDataDict = dataDictMapper.selectByEnumValueAndValue(existsDataDict.getEnumValue(), dataDictUpdateDTO.getValue());
if (duplicateDataDict != null && duplicateDataDict.getId().equals(dataDictUpdateDTO.getId())) {
if (duplicateDataDict != null && !duplicateDataDict.getId().equals(dataDictUpdateDTO.getId())) {
return ServiceExceptionUtil.error(AdminErrorCodeEnum.DATA_DICT_EXISTS.getCode());
}
// 更新到数据库