|
|
|
@ -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<UserGroup>(). |
|
|
|
|
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<UserGroup> 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<UserGroup> 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<SysFilesEntity> iPage = userGroupService.page(userGroup.getQueryPage(),queryWrapper); |
|
|
|
|