展示区域编辑重复校验
This commit is contained in:
+19
-9
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.tag.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
@@ -120,15 +121,24 @@ public class OnlCgformAreaController extends JeroController<OnlCgformArea, IOnlC
|
||||
@RequiresPermissions("area:edit")
|
||||
public Result<?> edit(@Validated @RequestBody OnlCgformArea onlCgformArea) {
|
||||
// TODO 编辑的时候不考虑ID?不试试现在还能编辑成功?
|
||||
int count=onlCgformAreaService.queryExitAreaName(onlCgformArea);
|
||||
if (count > 0) {
|
||||
//中英切换提示语
|
||||
// TODO Cut属性一定能拿到?拿不到的时候显示中文还是英文?现在对吗?测试了吗?
|
||||
if(CutEnum.CN.getValue().equals(onlCgformArea.getCut())) {
|
||||
return Result.error("同一所属模块下,展示区域名称不能重复!");
|
||||
}else{
|
||||
return Result.error("Under the same module, the display area name cannot be duplicate!");
|
||||
}
|
||||
|
||||
QueryWrapper<OnlCgformArea> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.eq("show_area", onlCgformArea.getShowArea()).eq("is_model", onlCgformArea.getIsModel());
|
||||
List<OnlCgformArea> existAreaList=onlCgformAreaService.list(queryWrapper);
|
||||
if(!existAreaList.isEmpty()){//有同名数据
|
||||
if(existAreaList.get(0).getId().equals(onlCgformArea.getId())) {//已存在同名的数据,就是正在编辑的这个
|
||||
onlCgformAreaService.editById(onlCgformArea);
|
||||
return Result.OK("编辑成功!");
|
||||
}else {
|
||||
//中英切换提示语
|
||||
// TODO Cut属性一定能拿到?拿不到的时候显示中文还是英文?现在对吗?测试了吗?
|
||||
if (CutEnum.CN.getValue().equals(onlCgformArea.getCut())) {
|
||||
|
||||
return Result.error("同一所属模块下,展示区域名称不能重复!");
|
||||
} else {
|
||||
return Result.error("Under the same module, the display area name cannot be duplicate!");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
onlCgformAreaService.editById(onlCgformArea);
|
||||
return Result.OK("编辑成功!");
|
||||
|
||||
Reference in New Issue
Block a user