diff --git a/src/main/java/com/huoran/iasf/common/config/WebMvcConfigurer.java b/src/main/java/com/huoran/iasf/common/config/WebMvcConfigurer.java index 9ebd7a2..26a5556 100644 --- a/src/main/java/com/huoran/iasf/common/config/WebMvcConfigurer.java +++ b/src/main/java/com/huoran/iasf/common/config/WebMvcConfigurer.java @@ -48,8 +48,10 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport { CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedHeader("*"); // 允许任何头 // 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:8089"); //允许信任域名 corsConfiguration.addAllowedOrigin("http://10.10.11.7"); //允许信任域名 corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等) return corsConfiguration; diff --git a/src/main/java/com/huoran/iasf/controller/DeptController.java b/src/main/java/com/huoran/iasf/controller/DeptController.java index fbafe3b..2088e07 100644 --- a/src/main/java/com/huoran/iasf/controller/DeptController.java +++ b/src/main/java/com/huoran/iasf/controller/DeptController.java @@ -17,6 +17,9 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; 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 = "新增组织接口") @LogAnnotation(title = "机构管理", action = "新增组织") @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); if (ok) { return R.fail("同级下已存在相同的名称:" + vo.getName()); @@ -61,10 +67,13 @@ public class DeptController { @ApiOperation(value = "更新组织信息接口") @LogAnnotation(title = "机构管理", action = "更新组织信息") @RequiresPermissions("sys:dept:update") - public R updateDept(@RequestBody SysDept vo) { + public R updateDept(@RequestBody SysDept vo) throws UnsupportedEncodingException { if (StringUtils.isEmpty(vo.getId())) { return R.fail("id不能为空"); } + //中文转码 + String name = URLDecoder.decode(vo.getName(), StandardCharsets.UTF_8.toString()); + vo.setName(name); boolean ok = deptService.checkDeptRepeat(vo); if (ok) { return R.fail("同级下已存在相同的名称:" + vo.getName()); diff --git a/src/main/java/com/huoran/iasf/controller/RoleController.java b/src/main/java/com/huoran/iasf/controller/RoleController.java index ddd1cdd..d29dbac 100644 --- a/src/main/java/com/huoran/iasf/controller/RoleController.java +++ b/src/main/java/com/huoran/iasf/controller/RoleController.java @@ -23,6 +23,9 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -45,7 +48,6 @@ public class RoleController { @Resource private HttpSessionService httpSessionService; @NoRepeatSubmit - @Decrypt @PostMapping("/addRole") @ApiOperation(value = "新增角色接口") @LogAnnotation(title = "角色管理", action = "新增角色") @@ -81,7 +83,6 @@ public class RoleController { @PostMapping("/updateRole") @ApiOperation(value = "更新角色信息接口") - @Decrypt @LogAnnotation(title = "角色管理", action = "更新角色信息") @RequiresPermissions("sys:role:update") public R updateDept(@RequestBody SysRole vo) { @@ -123,7 +124,10 @@ public class RoleController { @LogAnnotation(title = "角色管理", action = "分页获取角色信息") @RequiresPermissions("sys:role:list") @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 queryWrapper = Wrappers.lambdaQuery(); if (!StringUtils.isEmpty(vo.getName())) { queryWrapper.like(SysRole::getName, vo.getName()); diff --git a/src/main/java/com/huoran/iasf/controller/SysContentController.java b/src/main/java/com/huoran/iasf/controller/SysContentController.java index 549cddd..8581d45 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentController.java @@ -34,6 +34,9 @@ import com.huoran.iasf.service.SysContentService; import com.huoran.iasf.entity.SysContent; import javax.validation.Valid; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -168,7 +171,10 @@ public class SysContentController { @PostMapping("/newlyPublishedArticles") @Decrypt @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); } diff --git a/src/main/java/com/huoran/iasf/controller/UserController.java b/src/main/java/com/huoran/iasf/controller/UserController.java index 9c830e3..0e1f76f 100644 --- a/src/main/java/com/huoran/iasf/controller/UserController.java +++ b/src/main/java/com/huoran/iasf/controller/UserController.java @@ -34,6 +34,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; @@ -77,7 +80,11 @@ public class UserController { @LogAnnotation(title = "用户管理", action = "更新用户信息") @Decrypt @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())) { return R.fail("id不能为空"); } @@ -100,7 +107,10 @@ public class UserController { @RequiresPermissions("sys:user:list") @Decrypt @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); } diff --git a/src/main/java/com/huoran/iasf/controller/UserGroupController.java b/src/main/java/com/huoran/iasf/controller/UserGroupController.java index 4c57f6c..33a6c6a 100644 --- a/src/main/java/com/huoran/iasf/controller/UserGroupController.java +++ b/src/main/java/com/huoran/iasf/controller/UserGroupController.java @@ -20,6 +20,10 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; 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; /** @@ -43,7 +47,10 @@ public class UserGroupController { @ApiOperation(value = "新增用户组") @LogAnnotation(title = "用户组管理", action = "新增用户组") @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(). eq("group_name", userGroup.getGroupName())); if (ObjectUtil.isNotNull(one)){ @@ -58,7 +65,7 @@ public class UserGroupController { @ApiOperation(value = "删除用户组") @LogAnnotation(title = "用户组管理", action = "删除用户组") @RequiresPermissions("sys:userGroup:deleted") - public R deleted(@RequestBody String id) { + public R deleted(@RequestBody Integer id) { userGroupService.removeById(id); return R.success(); } @@ -68,10 +75,13 @@ public class UserGroupController { @ApiOperation(value = "更新用户组信息") @LogAnnotation(title = "用户组管理", action = "更新用户组信息") @RequiresPermissions("sys:userGroup:update") - public R updateUserGroup(@RequestBody UserGroup userGroup) { + public R updateUserGroup(@RequestBody UserGroup userGroup) throws UnsupportedEncodingException { if (StringUtils.isEmpty(userGroup.getId())) { return R.fail("id不能为空"); } + //中文转码 + String groupName = URLDecoder.decode(userGroup.getGroupName(), StandardCharsets.UTF_8.toString()); + userGroup.setGroupName(groupName); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("group_name", userGroup.getGroupName()); queryWrapper.last(" and id != " + userGroup.getId()); @@ -97,10 +107,12 @@ public class UserGroupController { @ApiOperation(value = "用户组列表") @LogAnnotation(title = "用户组管理", action = "获取所有用户组机构") @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 queryWrapper = Wrappers.lambdaQuery(); - if (!StringUtils.isEmpty(userGroup.getGroupName())) { - queryWrapper.like(UserGroup::getGroupName, userGroup.getGroupName()); + if (!StringUtils.isEmpty(groupName)) { + queryWrapper.like(UserGroup::getGroupName, groupName); } queryWrapper.orderByDesc(UserGroup::getCreateTime); IPage iPage = userGroupService.page(userGroup.getQueryPage(),queryWrapper); diff --git a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java index f0c49a4..bc5b928 100644 --- a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java @@ -122,22 +122,20 @@ public class DeptServiceImpl extends ServiceImpl impleme if (null == sysDept) { throw new BusinessException(BaseResponseCode.DATA_ERROR); } - List deptIds = sysDeptMapper.selectObjs(Wrappers.lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode())); +// List deptIds = sysDeptMapper.selectObjs(Wrappers.lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode())); - if (deptIds!=null&&deptIds.size()>0){ - List list = userDeptMapper.selectList(Wrappers.lambdaQuery().in(UserDept::getDeptId, deptIds)); - if (!CollectionUtils.isEmpty(list)) { - throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT); - } - }else { - //查询是否有子级部门 - QueryWrapper deptQueryWrapper = new QueryWrapper<>(); - deptQueryWrapper.eq("pid",sysDept.getId()); - List sysDepts = sysDeptMapper.selectList(deptQueryWrapper); - if (sysDepts!=null&& sysDepts.size()>0){ - throw new BusinessException(BaseResponseCode.DELETE_SUB_DEPARTMENTS_FIRST); - } + List list = userDeptMapper.selectList(Wrappers.lambdaQuery().in(UserDept::getDeptId, id)); + if (!CollectionUtils.isEmpty(list)) { + throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT); } + //查询是否有子级部门 + QueryWrapper deptQueryWrapper = new QueryWrapper<>(); + deptQueryWrapper.eq("pid",sysDept.getId()); + List sysDepts = sysDeptMapper.selectList(deptQueryWrapper); + if (sysDepts!=null&& sysDepts.size()>0){ + throw new BusinessException(BaseResponseCode.DELETE_SUB_DEPARTMENTS_FIRST); + } + sysDeptMapper.deleteById(id); }