中文转义

master
cheney 9 months ago
parent f80f84a13b
commit 302a1d999a
  1. 4
      src/main/java/com/huoran/iasf/common/config/WebMvcConfigurer.java
  2. 13
      src/main/java/com/huoran/iasf/controller/DeptController.java
  3. 10
      src/main/java/com/huoran/iasf/controller/RoleController.java
  4. 8
      src/main/java/com/huoran/iasf/controller/SysContentController.java
  5. 14
      src/main/java/com/huoran/iasf/controller/UserController.java
  6. 24
      src/main/java/com/huoran/iasf/controller/UserGroupController.java
  7. 8
      src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java

@ -48,8 +48,10 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
CorsConfiguration corsConfiguration = new CorsConfiguration(); CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedHeader("*"); // 允许任何头 corsConfiguration.addAllowedHeader("*"); // 允许任何头
// corsConfiguration.addAllowedOrigin("*"); // 允许任何头 // corsConfiguration.addAllowedOrigin("*"); // 允许任何头
corsConfiguration.addAllowedOrigin("*.iasf.ac.cn"); //允许信任域名 corsConfiguration.addAllowedOrigin("https://new.iasf.ac.cn"); //允许信任域名
corsConfiguration.addAllowedOrigin("https://www.iasf.ac.cn"); //允许信任域名
corsConfiguration.addAllowedOrigin("http://192.168.31.125:8088"); //允许信任域名 corsConfiguration.addAllowedOrigin("http://192.168.31.125:8088"); //允许信任域名
corsConfiguration.addAllowedOrigin("http://192.168.31.125:8089"); //允许信任域名
corsConfiguration.addAllowedOrigin("http://10.10.11.7"); //允许信任域名 corsConfiguration.addAllowedOrigin("http://10.10.11.7"); //允许信任域名
corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等) corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等)
return corsConfiguration; return corsConfiguration;

@ -17,6 +17,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
/** /**
* 部门管理 * 部门管理
@ -37,7 +40,10 @@ public class DeptController {
@ApiOperation(value = "新增组织接口") @ApiOperation(value = "新增组织接口")
@LogAnnotation(title = "机构管理", action = "新增组织") @LogAnnotation(title = "机构管理", action = "新增组织")
@RequiresPermissions("sys:dept:add") @RequiresPermissions("sys:dept:add")
public R addDept(@RequestBody @Valid SysDept vo) { public R addDept(@RequestBody @Valid SysDept vo) throws UnsupportedEncodingException {
//中文转码
String name = URLDecoder.decode(vo.getName(), StandardCharsets.UTF_8.toString());
vo.setName(name);
boolean ok = deptService.checkDeptRepeat(vo); boolean ok = deptService.checkDeptRepeat(vo);
if (ok) { if (ok) {
return R.fail("同级下已存在相同的名称:" + vo.getName()); return R.fail("同级下已存在相同的名称:" + vo.getName());
@ -61,10 +67,13 @@ public class DeptController {
@ApiOperation(value = "更新组织信息接口") @ApiOperation(value = "更新组织信息接口")
@LogAnnotation(title = "机构管理", action = "更新组织信息") @LogAnnotation(title = "机构管理", action = "更新组织信息")
@RequiresPermissions("sys:dept:update") @RequiresPermissions("sys:dept:update")
public R updateDept(@RequestBody SysDept vo) { public R updateDept(@RequestBody SysDept vo) throws UnsupportedEncodingException {
if (StringUtils.isEmpty(vo.getId())) { if (StringUtils.isEmpty(vo.getId())) {
return R.fail("id不能为空"); return R.fail("id不能为空");
} }
//中文转码
String name = URLDecoder.decode(vo.getName(), StandardCharsets.UTF_8.toString());
vo.setName(name);
boolean ok = deptService.checkDeptRepeat(vo); boolean ok = deptService.checkDeptRepeat(vo);
if (ok) { if (ok) {
return R.fail("同级下已存在相同的名称:" + vo.getName()); return R.fail("同级下已存在相同的名称:" + vo.getName());

@ -23,6 +23,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -45,7 +48,6 @@ public class RoleController {
@Resource @Resource
private HttpSessionService httpSessionService; private HttpSessionService httpSessionService;
@NoRepeatSubmit @NoRepeatSubmit
@Decrypt
@PostMapping("/addRole") @PostMapping("/addRole")
@ApiOperation(value = "新增角色接口") @ApiOperation(value = "新增角色接口")
@LogAnnotation(title = "角色管理", action = "新增角色") @LogAnnotation(title = "角色管理", action = "新增角色")
@ -81,7 +83,6 @@ public class RoleController {
@PostMapping("/updateRole") @PostMapping("/updateRole")
@ApiOperation(value = "更新角色信息接口") @ApiOperation(value = "更新角色信息接口")
@Decrypt
@LogAnnotation(title = "角色管理", action = "更新角色信息") @LogAnnotation(title = "角色管理", action = "更新角色信息")
@RequiresPermissions("sys:role:update") @RequiresPermissions("sys:role:update")
public R updateDept(@RequestBody SysRole vo) { public R updateDept(@RequestBody SysRole vo) {
@ -123,7 +124,10 @@ public class RoleController {
@LogAnnotation(title = "角色管理", action = "分页获取角色信息") @LogAnnotation(title = "角色管理", action = "分页获取角色信息")
@RequiresPermissions("sys:role:list") @RequiresPermissions("sys:role:list")
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public R pageInfo(@RequestBody SysRole vo) { public R pageInfo(@RequestBody SysRole vo) throws UnsupportedEncodingException {
//中文转码
String name = URLDecoder.decode(vo.getName(), StandardCharsets.UTF_8.toString());
vo.setName(name);
LambdaQueryWrapper<SysRole> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<SysRole> queryWrapper = Wrappers.lambdaQuery();
if (!StringUtils.isEmpty(vo.getName())) { if (!StringUtils.isEmpty(vo.getName())) {
queryWrapper.like(SysRole::getName, vo.getName()); queryWrapper.like(SysRole::getName, vo.getName());

@ -34,6 +34,9 @@ import com.huoran.iasf.service.SysContentService;
import com.huoran.iasf.entity.SysContent; import com.huoran.iasf.entity.SysContent;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -168,7 +171,10 @@ public class SysContentController {
@PostMapping("/newlyPublishedArticles") @PostMapping("/newlyPublishedArticles")
@Decrypt @Decrypt
@ApiOperation(value = "站点最新发布的文章", response = PageContentReqVO.class) @ApiOperation(value = "站点最新发布的文章", response = PageContentReqVO.class)
public R newlyPublishedArticles(@Valid @RequestBody PageContentReqVO content) { public R newlyPublishedArticles(@Valid @RequestBody PageContentReqVO content) throws UnsupportedEncodingException {
//中文转码
String title = URLDecoder.decode(content.getTitle(), StandardCharsets.UTF_8.toString());
content.setTitle(title);
return service.newlyPublishedArticles(content); return service.newlyPublishedArticles(content);
} }

@ -34,6 +34,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -77,7 +80,11 @@ public class UserController {
@LogAnnotation(title = "用户管理", action = "更新用户信息") @LogAnnotation(title = "用户管理", action = "更新用户信息")
@Decrypt @Decrypt
@RequiresPermissions("sys:user:update") @RequiresPermissions("sys:user:update")
public R updateUserInfo(@RequestBody SysUser vo) { public R updateUserInfo(@RequestBody SysUser vo) throws UnsupportedEncodingException {
//中文转码
String username = URLDecoder.decode(vo.getUsername(), StandardCharsets.UTF_8.toString());
vo.setUsername(username);
if (StringUtils.isEmpty(vo.getId())) { if (StringUtils.isEmpty(vo.getId())) {
return R.fail("id不能为空"); return R.fail("id不能为空");
} }
@ -100,7 +107,10 @@ public class UserController {
@RequiresPermissions("sys:user:list") @RequiresPermissions("sys:user:list")
@Decrypt @Decrypt
@LogAnnotation(title = "用户管理", action = "分页获取用户列表") @LogAnnotation(title = "用户管理", action = "分页获取用户列表")
public R pageInfo(@RequestBody UserListReq userListReq) { public R pageInfo(@RequestBody UserListReq userListReq) throws UnsupportedEncodingException {
//中文转码
String key = URLDecoder.decode(userListReq.getKeyWord(), StandardCharsets.UTF_8.toString());
userListReq.setKeyWord(key);
return userService.pageInfo(userListReq); return userService.pageInfo(userListReq);
} }

@ -20,6 +20,10 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
/** /**
@ -43,7 +47,10 @@ public class UserGroupController {
@ApiOperation(value = "新增用户组") @ApiOperation(value = "新增用户组")
@LogAnnotation(title = "用户组管理", action = "新增用户组") @LogAnnotation(title = "用户组管理", action = "新增用户组")
@RequiresPermissions("sys:userGroup:add") @RequiresPermissions("sys:userGroup:add")
public R addUserGroup(@RequestBody @Valid UserGroup userGroup) { public R addUserGroup(@RequestBody @Valid UserGroup userGroup) throws UnsupportedEncodingException {
//中文转码
String groupName = URLDecoder.decode(userGroup.getGroupName(), StandardCharsets.UTF_8.toString());
userGroup.setGroupName(groupName);
UserGroup one = userGroupService.getOne(new QueryWrapper<UserGroup>(). UserGroup one = userGroupService.getOne(new QueryWrapper<UserGroup>().
eq("group_name", userGroup.getGroupName())); eq("group_name", userGroup.getGroupName()));
if (ObjectUtil.isNotNull(one)){ if (ObjectUtil.isNotNull(one)){
@ -58,7 +65,7 @@ public class UserGroupController {
@ApiOperation(value = "删除用户组") @ApiOperation(value = "删除用户组")
@LogAnnotation(title = "用户组管理", action = "删除用户组") @LogAnnotation(title = "用户组管理", action = "删除用户组")
@RequiresPermissions("sys:userGroup:deleted") @RequiresPermissions("sys:userGroup:deleted")
public R deleted(@RequestBody String id) { public R deleted(@RequestBody Integer id) {
userGroupService.removeById(id); userGroupService.removeById(id);
return R.success(); return R.success();
} }
@ -68,10 +75,13 @@ public class UserGroupController {
@ApiOperation(value = "更新用户组信息") @ApiOperation(value = "更新用户组信息")
@LogAnnotation(title = "用户组管理", action = "更新用户组信息") @LogAnnotation(title = "用户组管理", action = "更新用户组信息")
@RequiresPermissions("sys:userGroup:update") @RequiresPermissions("sys:userGroup:update")
public R updateUserGroup(@RequestBody UserGroup userGroup) { public R updateUserGroup(@RequestBody UserGroup userGroup) throws UnsupportedEncodingException {
if (StringUtils.isEmpty(userGroup.getId())) { if (StringUtils.isEmpty(userGroup.getId())) {
return R.fail("id不能为空"); return R.fail("id不能为空");
} }
//中文转码
String groupName = URLDecoder.decode(userGroup.getGroupName(), StandardCharsets.UTF_8.toString());
userGroup.setGroupName(groupName);
QueryWrapper<UserGroup> queryWrapper = new QueryWrapper<>(); QueryWrapper<UserGroup> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("group_name", userGroup.getGroupName()); queryWrapper.eq("group_name", userGroup.getGroupName());
queryWrapper.last(" and id != " + userGroup.getId()); queryWrapper.last(" and id != " + userGroup.getId());
@ -97,10 +107,12 @@ public class UserGroupController {
@ApiOperation(value = "用户组列表") @ApiOperation(value = "用户组列表")
@LogAnnotation(title = "用户组管理", action = "获取所有用户组机构") @LogAnnotation(title = "用户组管理", action = "获取所有用户组机构")
@RequiresPermissions("sys:userGroup:list") @RequiresPermissions("sys:userGroup:list")
public R getUserGroupAll(@RequestBody UserGroup userGroup) { public R getUserGroupAll(@RequestBody UserGroup userGroup) throws UnsupportedEncodingException {
//中文转码
String groupName = URLDecoder.decode(userGroup.getGroupName(), StandardCharsets.UTF_8.toString());
LambdaQueryWrapper<UserGroup> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<UserGroup> queryWrapper = Wrappers.lambdaQuery();
if (!StringUtils.isEmpty(userGroup.getGroupName())) { if (!StringUtils.isEmpty(groupName)) {
queryWrapper.like(UserGroup::getGroupName, userGroup.getGroupName()); queryWrapper.like(UserGroup::getGroupName, groupName);
} }
queryWrapper.orderByDesc(UserGroup::getCreateTime); queryWrapper.orderByDesc(UserGroup::getCreateTime);
IPage<SysFilesEntity> iPage = userGroupService.page(userGroup.getQueryPage(),queryWrapper); IPage<SysFilesEntity> iPage = userGroupService.page(userGroup.getQueryPage(),queryWrapper);

@ -122,14 +122,12 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
if (null == sysDept) { if (null == sysDept) {
throw new BusinessException(BaseResponseCode.DATA_ERROR); throw new BusinessException(BaseResponseCode.DATA_ERROR);
} }
List<Object> deptIds = sysDeptMapper.selectObjs(Wrappers.<SysDept>lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode())); // List<Object> deptIds = sysDeptMapper.selectObjs(Wrappers.<SysDept>lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode()));
if (deptIds!=null&&deptIds.size()>0){ List<UserDept> list = userDeptMapper.selectList(Wrappers.<UserDept>lambdaQuery().in(UserDept::getDeptId, id));
List<UserDept> list = userDeptMapper.selectList(Wrappers.<UserDept>lambdaQuery().in(UserDept::getDeptId, deptIds));
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT); throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT);
} }
}else {
//查询是否有子级部门 //查询是否有子级部门
QueryWrapper<SysDept> deptQueryWrapper = new QueryWrapper<>(); QueryWrapper<SysDept> deptQueryWrapper = new QueryWrapper<>();
deptQueryWrapper.eq("pid",sysDept.getId()); deptQueryWrapper.eq("pid",sysDept.getId());
@ -137,7 +135,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
if (sysDepts!=null&& sysDepts.size()>0){ if (sysDepts!=null&& sysDepts.size()>0){
throw new BusinessException(BaseResponseCode.DELETE_SUB_DEPARTMENTS_FIRST); throw new BusinessException(BaseResponseCode.DELETE_SUB_DEPARTMENTS_FIRST);
} }
}
sysDeptMapper.deleteById(id); sysDeptMapper.deleteById(id);
} }

Loading…
Cancel
Save