fix: 处理request body string多了引号的问题

This commit is contained in:
CaptainB 2024-01-30 11:16:50 +08:00 committed by 刘瑞斌
parent 9653799413
commit 685e7891c0
1 changed files with 3 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.sdk.util.CommonBeanFactory;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -30,6 +31,8 @@ public class LicenseController {
@RequiresPermissions(value= {PermissionConstants.SYSTEM_AUTH_READ, PermissionConstants.SYSTEM_AUTH_READ_UPDATE}, logical = Logical.OR) @RequiresPermissions(value= {PermissionConstants.SYSTEM_AUTH_READ, PermissionConstants.SYSTEM_AUTH_READ_UPDATE}, logical = Logical.OR)
public LicenseDTO addLicense(@RequestBody String licenseCode) { public LicenseDTO addLicense(@RequestBody String licenseCode) {
LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class); LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class);
// 前端传入的JSON会被加上双引号需要去掉
licenseCode = StringUtils.strip(licenseCode, "\"");
if (licenseService != null) { if (licenseService != null) {
return licenseService.addLicense(licenseCode, SessionUtils.getUserId()); return licenseService.addLicense(licenseCode, SessionUtils.getUserId());
} }