记得上下班打卡 | git大法好,push需谨慎

Commit 71d2d59e authored by zhanggb's avatar zhanggb

~ADMIN:标签管理:+校验;

parent a52faff3
...@@ -92,7 +92,8 @@ public class GoblinSelfCategoryAdminController extends BaseController { ...@@ -92,7 +92,8 @@ public class GoblinSelfCategoryAdminController extends BaseController {
@PostMapping("addSave") @PostMapping("addSave")
@ResponseBody @ResponseBody
public AjaxResult addSave(GoblinSelfGoodsCategory selfGoodsCategory) { public AjaxResult addSave(GoblinSelfGoodsCategory selfGoodsCategory) {
if (StringUtils.isBlank(selfGoodsCategory.getName())) { String name = selfGoodsCategory.getName();
if (StringUtils.isBlank(name)) {
return AjaxResult.warn("分类名称不能为空"); return AjaxResult.warn("分类名称不能为空");
} }
String grade = selfGoodsCategory.getGrade(); String grade = selfGoodsCategory.getGrade();
...@@ -127,6 +128,12 @@ public class GoblinSelfCategoryAdminController extends BaseController { ...@@ -127,6 +128,12 @@ public class GoblinSelfCategoryAdminController extends BaseController {
default: default:
return AjaxResult.warn("分类层级无效"); return AjaxResult.warn("分类层级无效");
} }
queryWrapper.clear();
queryWrapper.eq(GoblinSelfGoodsCategory::getDelFlg, "0");
queryWrapper.eq(GoblinSelfGoodsCategory::getName, name.trim());
if (goblinSelfGoodsCategoryService.count(queryWrapper) > 0) {
return AjaxResult.warn("分类名称重复,请核实");
}
selfGoodsCategory.setCateId(IDGenerator.nextMilliId2()); selfGoodsCategory.setCateId(IDGenerator.nextMilliId2());
selfGoodsCategory.setDelFlg("0"); selfGoodsCategory.setDelFlg("0");
......
...@@ -24,6 +24,7 @@ import org.springframework.stereotype.Controller; ...@@ -24,6 +24,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Api(tags = "音乐人标签库") @Api(tags = "音乐人标签库")
...@@ -92,10 +93,24 @@ public class GoblinSelfExtagAdminController extends BaseController { ...@@ -92,10 +93,24 @@ public class GoblinSelfExtagAdminController extends BaseController {
@PostMapping("addSave") @PostMapping("addSave")
@ResponseBody @ResponseBody
public AjaxResult addSave(String tagName, String tagPic, String tagType) { public AjaxResult addSave(String tagName, String tagPic, String tagType) {
if (StringUtils.isBlank(tagName) || StringUtils.isBlank(tagPic) || StringUtils.isBlank(tagType)) {
return AjaxResult.warn("参数有误,请核实");
}
if (Arrays.asList("1", "2", "3", "4").contains(tagType)) {
return AjaxResult.warn("无效参数:标签类型");
}
LambdaQueryWrapper<GoblinSelfTag> queryWrapper = Wrappers.lambdaQuery(GoblinSelfTag.class);
queryWrapper.eq(GoblinSelfTag::getDelFlg, "0");
queryWrapper.eq(GoblinSelfTag::getTagBelong, "1");
queryWrapper.eq(GoblinSelfTag::getTagName, tagName.trim());
if (goblinSelfTagService.count(queryWrapper) > 0) {
return AjaxResult.warn("标签名称重复,请核实");
}
GoblinSelfTag selfTag = new GoblinSelfTag(); GoblinSelfTag selfTag = new GoblinSelfTag();
selfTag.setTagId(IDGenerator.nextMilliId2()); selfTag.setTagId(IDGenerator.nextMilliId2());
selfTag.setTagName(tagName); selfTag.setTagName(tagName.trim());
selfTag.setTagPic(tagPic); selfTag.setTagPic(tagPic);
selfTag.setTagType(tagType); selfTag.setTagType(tagType);
selfTag.setTagBelong(tagBelong); selfTag.setTagBelong(tagBelong);
......
...@@ -88,10 +88,21 @@ public class GoblinSelfTagAdminController extends BaseController { ...@@ -88,10 +88,21 @@ public class GoblinSelfTagAdminController extends BaseController {
@PostMapping("addSave") @PostMapping("addSave")
@ResponseBody @ResponseBody
public AjaxResult addSave(String tagName, String tagPic) { public AjaxResult addSave(String tagName, String tagPic) {
if (StringUtils.isBlank(tagName) || StringUtils.isBlank(tagPic)) {
return AjaxResult.warn("参数有误,请核实");
}
LambdaQueryWrapper<GoblinSelfTag> queryWrapper = Wrappers.lambdaQuery(GoblinSelfTag.class);
queryWrapper.eq(GoblinSelfTag::getDelFlg, "0");
queryWrapper.eq(GoblinSelfTag::getTagBelong, "0");
queryWrapper.eq(GoblinSelfTag::getTagName, tagName.trim());
if (goblinSelfTagService.count(queryWrapper) > 0) {
return AjaxResult.warn("标签名称重复,请核实");
}
GoblinSelfTag selfTag = new GoblinSelfTag(); GoblinSelfTag selfTag = new GoblinSelfTag();
selfTag.setTagId(IDGenerator.nextMilliId2()); selfTag.setTagId(IDGenerator.nextMilliId2());
selfTag.setTagName(tagName); selfTag.setTagName(tagName.trim());
selfTag.setTagPic(tagPic); selfTag.setTagPic(tagPic);
selfTag.setTagType("0"); selfTag.setTagType("0");
selfTag.setDelFlg("0"); selfTag.setDelFlg("0");
...@@ -107,8 +118,21 @@ public class GoblinSelfTagAdminController extends BaseController { ...@@ -107,8 +118,21 @@ public class GoblinSelfTagAdminController extends BaseController {
@PostMapping("editSave") @PostMapping("editSave")
@ResponseBody @ResponseBody
public AjaxResult editSave(GoblinSelfTag selfTag) { public AjaxResult editSave(GoblinSelfTag selfTag) {
if (StringUtils.isBlank(selfTag.getTagName()) || StringUtils.isBlank(selfTag.getTagPic())) {
return AjaxResult.warn("参数有误,请核实");
}
selfTag.setTagName(selfTag.getTagName().trim());
LambdaQueryWrapper<GoblinSelfTag> queryWrapper = Wrappers.lambdaQuery(GoblinSelfTag.class);
queryWrapper.eq(GoblinSelfTag::getDelFlg, "0");
queryWrapper.eq(GoblinSelfTag::getTagBelong, "0");
queryWrapper.eq(GoblinSelfTag::getTagName, selfTag.getTagName());
if (goblinSelfTagService.count(queryWrapper) > 0) {
return AjaxResult.warn("标签名称重复,请核实");
}
selfTag.setTagBelong(tagBelong); selfTag.setTagBelong(tagBelong);
// TODO: 2022/1/13 zhanggb valid selfTag.setTagType("0");
return toAjax(goblinSelfTagService.editSave(selfTag)); return toAjax(goblinSelfTagService.editSave(selfTag));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment