中文解码问题处理

master
cheney 7 months ago
parent 7ffa1b4e1f
commit 42f8eb491b
  1. 17
      src/main/java/com/huoran/iasf/controller/SysContentClassificationController.java
  2. 16
      src/main/java/com/huoran/iasf/controller/SysContentLabelController.java

@ -24,6 +24,9 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
@ -67,8 +70,9 @@ public class SysContentClassificationController {
@Decrypt @Decrypt
@ApiOperation(value = "分类校验判重", response = SysContentClassification.class) @ApiOperation(value = "分类校验判重", response = SysContentClassification.class)
public R checkForHeavy( 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<SysContentClassification> queryWrapper = new QueryWrapper<SysContentClassification>().eq("site_id", checkForHeavy.getSiteId()). QueryWrapper<SysContentClassification> queryWrapper = new QueryWrapper<SysContentClassification>().eq("site_id", checkForHeavy.getSiteId()).
eq("classification_name", checkForHeavy.getClassificationName()); eq("classification_name", checkForHeavy.getClassificationName());
@ -88,7 +92,10 @@ public class SysContentClassificationController {
@PostMapping("/save") @PostMapping("/save")
@Decrypt @Decrypt
@ApiOperation(value = "新增", response = SysContentClassification.class) @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); boolean addState = service.save(sysContentClassification);
return addState ? R.success() : R.fail("新增失败"); return addState ? R.success() : R.fail("新增失败");
} }
@ -97,7 +104,9 @@ public class SysContentClassificationController {
@PostMapping("/update") @PostMapping("/update")
@Decrypt @Decrypt
@ApiOperation(value = "修改", response = SysContentClassification.class) @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); boolean updateState = service.updateById(sysContentClassification);
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }

@ -21,6 +21,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
@ -63,7 +66,9 @@ public class SysContentLabelController {
@PostMapping("/save") @PostMapping("/save")
@Decrypt @Decrypt
@ApiOperation(value = "新增", response = SysContentLabel.class) @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); boolean addState = service.save(sysContentLabel);
return addState ? R.success() : R.fail("新增失败"); return addState ? R.success() : R.fail("新增失败");
} }
@ -73,8 +78,9 @@ public class SysContentLabelController {
@Decrypt @Decrypt
@ApiOperation(value = "标签校验判重", response = SysContentLabel.class) @ApiOperation(value = "标签校验判重", response = SysContentLabel.class)
public R checkForHeavy( 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<SysContentLabel> queryWrapper = new QueryWrapper<SysContentLabel>(). QueryWrapper<SysContentLabel> queryWrapper = new QueryWrapper<SysContentLabel>().
eq("site_id", labelCheckForHeavy.getSiteId()).eq("label_name", labelCheckForHeavy.getLabelName()); eq("site_id", labelCheckForHeavy.getSiteId()).eq("label_name", labelCheckForHeavy.getLabelName());
@ -94,7 +100,9 @@ public class SysContentLabelController {
@PostMapping("/update") @PostMapping("/update")
@Decrypt @Decrypt
@ApiOperation(value = "修改", response = SysContentLabel.class) @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); boolean updateState = service.updateById(sysContentLabel);
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }

Loading…
Cancel
Save