From 42f8eb491be2aebcff4c0439096b9980f2415939 Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Thu, 18 Apr 2024 14:44:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E6=96=87=E8=A7=A3=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SysContentClassificationController.java | 17 +++++++++++++---- .../controller/SysContentLabelController.java | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/huoran/iasf/controller/SysContentClassificationController.java b/src/main/java/com/huoran/iasf/controller/SysContentClassificationController.java index 9c9778d..2a37e93 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentClassificationController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentClassificationController.java @@ -24,6 +24,9 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import javax.validation.Valid; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.List; @@ -67,8 +70,9 @@ public class SysContentClassificationController { @Decrypt @ApiOperation(value = "分类校验判重", response = SysContentClassification.class) public R checkForHeavy( - @RequestBody CheckForHeavy checkForHeavy) { - + @RequestBody CheckForHeavy checkForHeavy) throws UnsupportedEncodingException { + String name = URLDecoder.decode(checkForHeavy.getClassificationName(), StandardCharsets.UTF_8.toString()); + checkForHeavy.setClassificationName(name); QueryWrapper queryWrapper = new QueryWrapper().eq("site_id", checkForHeavy.getSiteId()). eq("classification_name", checkForHeavy.getClassificationName()); @@ -88,7 +92,10 @@ public class SysContentClassificationController { @PostMapping("/save") @Decrypt @ApiOperation(value = "新增", response = SysContentClassification.class) - public R save(@RequestBody @Valid @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) { + public R save(@RequestBody @Valid @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) throws UnsupportedEncodingException { + String name = URLDecoder.decode(sysContentClassification.getClassificationName(), StandardCharsets.UTF_8.toString()); + sysContentClassification.setClassificationName(name); + boolean addState = service.save(sysContentClassification); return addState ? R.success() : R.fail("新增失败"); } @@ -97,7 +104,9 @@ public class SysContentClassificationController { @PostMapping("/update") @Decrypt @ApiOperation(value = "修改", response = SysContentClassification.class) - public R update(@RequestBody @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) { + public R update(@RequestBody @ApiParam(name = "文章所属分类对象", value = "传入json格式", required = true) SysContentClassification sysContentClassification) throws UnsupportedEncodingException { + String name = URLDecoder.decode(sysContentClassification.getClassificationName(), StandardCharsets.UTF_8.toString()); + sysContentClassification.setClassificationName(name); boolean updateState = service.updateById(sysContentClassification); return updateState ? R.success() : R.fail("编辑失败"); } diff --git a/src/main/java/com/huoran/iasf/controller/SysContentLabelController.java b/src/main/java/com/huoran/iasf/controller/SysContentLabelController.java index fdb24cb..3fdf42b 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentLabelController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentLabelController.java @@ -21,6 +21,9 @@ import org.springframework.web.bind.annotation.RequestParam; import io.swagger.annotations.ApiOperation; import javax.validation.Valid; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.List; @@ -63,7 +66,9 @@ public class SysContentLabelController { @PostMapping("/save") @Decrypt @ApiOperation(value = "新增", response = SysContentLabel.class) - public R save(@RequestBody @Valid @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) { + public R save(@RequestBody @Valid @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) throws UnsupportedEncodingException { + String name = URLDecoder.decode(sysContentLabel.getLabelName(), StandardCharsets.UTF_8.toString()); + sysContentLabel.setLabelName(name); boolean addState = service.save(sysContentLabel); return addState ? R.success() : R.fail("新增失败"); } @@ -73,8 +78,9 @@ public class SysContentLabelController { @Decrypt @ApiOperation(value = "标签校验判重", response = SysContentLabel.class) public R checkForHeavy( - @RequestBody LabelCheckForHeavy labelCheckForHeavy) { - + @RequestBody LabelCheckForHeavy labelCheckForHeavy) throws UnsupportedEncodingException { + String name = URLDecoder.decode(labelCheckForHeavy.getLabelName(), StandardCharsets.UTF_8.toString()); + labelCheckForHeavy.setLabelName(name); QueryWrapper queryWrapper = new QueryWrapper(). eq("site_id", labelCheckForHeavy.getSiteId()).eq("label_name", labelCheckForHeavy.getLabelName()); @@ -94,7 +100,9 @@ public class SysContentLabelController { @PostMapping("/update") @Decrypt @ApiOperation(value = "修改", response = SysContentLabel.class) - public R update(@RequestBody @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) { + public R update(@RequestBody @ApiParam(name = "文章主题标签对象", value = "传入json格式", required = true) SysContentLabel sysContentLabel) throws UnsupportedEncodingException { + String name = URLDecoder.decode(sysContentLabel.getLabelName(), StandardCharsets.UTF_8.toString()); + sysContentLabel.setLabelName(name); boolean updateState = service.updateById(sysContentLabel); return updateState ? R.success() : R.fail("编辑失败"); }