diff --git a/basic-interface/src/main/java/ink/wgink/interfaces/department/IDepartmentUserBaseService.java b/basic-interface/src/main/java/ink/wgink/interfaces/department/IDepartmentUserBaseService.java index 0023ae3b..4023c2fe 100644 --- a/basic-interface/src/main/java/ink/wgink/interfaces/department/IDepartmentUserBaseService.java +++ b/basic-interface/src/main/java/ink/wgink/interfaces/department/IDepartmentUserBaseService.java @@ -24,7 +24,7 @@ public interface IDepartmentUserBaseService { * @param departmentId 部门ID * @return */ - List listUserIdByDepartmentId(String departmentId); + List listUserId(String departmentId); /** * 用户ID列表 @@ -32,7 +32,7 @@ public interface IDepartmentUserBaseService { * @param departmentIds 部门ID列表 * @return */ - List listUserIdByDepartmentIds(List departmentIds); + List listUserId(List departmentIds); /** * 用户列表 diff --git a/basic-interface/src/main/java/ink/wgink/interfaces/group/IGroupUserBaseService.java b/basic-interface/src/main/java/ink/wgink/interfaces/group/IGroupUserBaseService.java new file mode 100644 index 00000000..b903c435 --- /dev/null +++ b/basic-interface/src/main/java/ink/wgink/interfaces/group/IGroupUserBaseService.java @@ -0,0 +1,45 @@ +package ink.wgink.interfaces.group; + +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.group.GroupUserDTO; +import ink.wgink.pojo.result.SuccessResultList; + +import java.util.List; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: IGroupUserService + * @Description: 组用户 + * @Author: WangGeng + * @Date: 2021/1/24 13:00 + * @Version: 1.0 + **/ +public interface IGroupUserBaseService { + + /** + * 用户ID列表 + * + * @param groupId 用户组ID + * @return + */ + List listUserId(String groupId); + + /** + * 用户ID列表 + * + * @param groupIds 用户组ID列表 + * @return + */ + List listUserId(List groupIds); + + /** + * 分页用户组用户 + * + * @param groupId + * @param page + * @return + */ + SuccessResultList> listPage(String groupId, ListPage page); +} diff --git a/basic-interface/src/main/java/ink/wgink/interfaces/user/IGroupUserService.java b/basic-interface/src/main/java/ink/wgink/interfaces/user/IGroupUserService.java deleted file mode 100644 index 43f0d031..00000000 --- a/basic-interface/src/main/java/ink/wgink/interfaces/user/IGroupUserService.java +++ /dev/null @@ -1,17 +0,0 @@ -package ink.wgink.interfaces.user; - -/** - * When you feel like quitting. Think about why you started - * 当你想要放弃的时候,想想当初你为何开始 - * - * @ClassName: IGroupUserService - * @Description: 组用户 - * @Author: WangGeng - * @Date: 2021/1/24 13:00 - * @Version: 1.0 - **/ -public interface IGroupUserService { - - - -} diff --git a/basic-interface/src/main/java/ink/wgink/interfaces/user/IUserBaseService.java b/basic-interface/src/main/java/ink/wgink/interfaces/user/IUserBaseService.java index e8ce9e61..02e169d4 100644 --- a/basic-interface/src/main/java/ink/wgink/interfaces/user/IUserBaseService.java +++ b/basic-interface/src/main/java/ink/wgink/interfaces/user/IUserBaseService.java @@ -84,5 +84,5 @@ public interface IUserBaseService { * @param page * @return */ - SuccessResultList> listPageByExcludeUserIds(List excludeUserIds, ListPage page); + SuccessResultList> listPageByExcludeIds(List excludeUserIds, ListPage page); } diff --git a/basic-pojo/src/main/java/ink/wgink/pojo/dtos/group/GroupUserDTO.java b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/group/GroupUserDTO.java index 198389d1..5a5644aa 100644 --- a/basic-pojo/src/main/java/ink/wgink/pojo/dtos/group/GroupUserDTO.java +++ b/basic-pojo/src/main/java/ink/wgink/pojo/dtos/group/GroupUserDTO.java @@ -1,5 +1,6 @@ package ink.wgink.pojo.dtos.group; +import ink.wgink.pojo.dtos.user.UserDTO; import io.swagger.annotations.ApiModel; import java.io.Serializable; @@ -26,6 +27,21 @@ public class GroupUserDTO implements Serializable { private Integer userState; private String userAvatar; + public GroupUserDTO() { + + } + + public GroupUserDTO(UserDTO userDTO) { + this.userId = userDTO.getUserId(); + this.userUsername = userDTO.getUserUsername(); + this.userName = userDTO.getUserName(); + this.userPhone = userDTO.getUserPhone(); + this.userEmail = userDTO.getUserEmail(); + this.userType = userDTO.getUserType(); + this.userState = userDTO.getUserState(); + this.userAvatar = userDTO.getUserAvatar(); + } + public String getUserId() { return userId == null ? "" : userId.trim(); } diff --git a/common/pom.xml b/common/pom.xml index 3e52559e..9253e888 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -41,13 +41,6 @@ - - - com.alibaba - druid - - - com.github.pagehelper @@ -59,9 +52,22 @@ com.alibaba easyexcel + + + cglib + cglib + + + + + cglib + cglib + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index e88f2b47..0ff77686 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,8 @@ 5.2.8.RELEASE 2.3.3.RELEASE 1.2.24 - 2.0.5 + 2.2.7 + 3.2.3 5.1.47 1.0.31 5.1.1 @@ -49,7 +50,7 @@ 1.6 2.6.0 3.4 - 2.4 + 2.2 3.3 1.3.1 1.12 @@ -154,6 +155,14 @@ + + + cglib + cglib + ${cglib.version} + + + mysql diff --git a/service-department/src/main/java/ink/wgink/service/department/controller/api/DepartmentUserController.java b/service-department/src/main/java/ink/wgink/service/department/controller/api/DepartmentUserController.java index 6d17117e..33a67b9f 100644 --- a/service-department/src/main/java/ink/wgink/service/department/controller/api/DepartmentUserController.java +++ b/service-department/src/main/java/ink/wgink/service/department/controller/api/DepartmentUserController.java @@ -82,7 +82,7 @@ public class DepartmentUserController extends DefaultBaseController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listuseridbydepartmentid/{departmentId}") public List listUserIdByDepartmentId(@PathVariable("departmentId") String departmentId) { - return departmentUserService.listUserIdByDepartmentId(departmentId); + return departmentUserService.listUserId(departmentId); } } diff --git a/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentServiceImpl.java b/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentServiceImpl.java index ecf191a4..c2743ce5 100644 --- a/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentServiceImpl.java +++ b/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentServiceImpl.java @@ -449,7 +449,7 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart */ private List removeByIdReturnDeletedUserIds(String departmentId, String departmentName) { // 获取用户ID - List userIds = departmentUserService.listUserIdByDepartmentId(departmentId); + List userIds = departmentUserService.listUserId(departmentId); // 删除组织用户 departmentUserService.deleteByDepartmentIdAndUserIds(departmentId, departmentName, userIds); // 删除组织 diff --git a/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentUserServiceImpl.java b/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentUserServiceImpl.java index 9f802b24..0c9300d7 100644 --- a/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentUserServiceImpl.java +++ b/service-department/src/main/java/ink/wgink/service/department/service/impl/DepartmentUserServiceImpl.java @@ -114,14 +114,14 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe } @Override - public List listUserIdByDepartmentId(String departmentId) { + public List listUserId(String departmentId) { Map params = getHashMap(2); params.put("departmentId", departmentId); return departmentUserDao.listUserId(params); } @Override - public List listUserIdByDepartmentIds(List departmentIds) { + public List listUserId(List departmentIds) { Map params = getHashMap(2); params.put("departmentIds", departmentIds); return departmentUserDao.listUserId(params); @@ -131,9 +131,9 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe public SuccessResultList> listPage(String departmentId, ListPage page) { SuccessResultList> successResultList; if (StringUtils.equals(departmentId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) { - successResultList = listPageUserDTOByExcludeDepartmentId(page); + successResultList = listPageUserByExcludeDepartment(page); } else { - successResultList = listPageUserDTOByDepartmentId(departmentId, page); + successResultList = listPageUser(departmentId, page); } List userDTOs = successResultList.getRows(); List departmentUserDTOs = new ArrayList<>(); @@ -155,9 +155,9 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe * @param page * @return */ - private SuccessResultList> listPageUserDTOByExcludeDepartmentId(ListPage page) { - List hasDepartmentIdUserIds = listGroupUserId(new HashMap<>(0)); - return userBaseService.listPageByExcludeUserIds(hasDepartmentIdUserIds, page); + private SuccessResultList> listPageUserByExcludeDepartment(ListPage page) { + List hasDepartmentUserIds = listGroupUserId(new HashMap<>(0)); + return userBaseService.listPageByExcludeIds(hasDepartmentUserIds, page); } /** @@ -167,8 +167,8 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe * @param page * @return */ - private SuccessResultList> listPageUserDTOByDepartmentId(String departmentId, ListPage page) { - List userIds = listUserIdByDepartmentId(departmentId); + private SuccessResultList> listPageUser(String departmentId, ListPage page) { + List userIds = listUserId(departmentId); if (userIds.isEmpty()) { return new SuccessResultList<>(new ArrayList<>(), 1, 0L); } diff --git a/service-department/src/main/resources/mybatis/mapper/department-user-mapper.xml b/service-department/src/main/resources/mybatis/mapper/department-user-mapper.xml index b03551e5..83803a2c 100644 --- a/service-department/src/main/resources/mybatis/mapper/department-user-mapper.xml +++ b/service-department/src/main/resources/mybatis/mapper/department-user-mapper.xml @@ -14,7 +14,7 @@ PRIMARY KEY (`id`), KEY `user_id_idx` (`user_id`) USING BTREE, KEY `department_id_idx` (`department_id`) USING BTREE - ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/service-department/src/main/resources/templates/department/user/list.html b/service-department/src/main/resources/templates/department/user/list.html index 20306bc6..261fa7f3 100644 --- a/service-department/src/main/resources/templates/department/user/list.html +++ b/service-department/src/main/resources/templates/department/user/list.html @@ -221,9 +221,14 @@ onClose: function() { var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers; if(selectedUsers != null && selectedUsers.length > 0) { - var selectedUserIds = []; + var selectedUserIds = ''; + var ids = []; for (var i = 0, item; item = selectedUsers[i++];) { - selectedUserIds.push(item.userId); + if ('' != selectedUserIds) { + selectedUserIds += '_'; + } + selectedUserIds += item.userId; + ids.push(item.userId); } top.dialog.msg(top.dataMessage.update, { time: 0, @@ -232,7 +237,7 @@ top.dialog.close(index); var loadLayerIndex; top.restAjax.put(top.restAjax.path('api/department/user/update/{departmentId}', [departmentId]), { - ids: selectedUserIds + ids: ids }, null, function (code, data) { top.dialog.msg(top.dataMessage.updated); $('#selectedUserIds').val(selectedUserIds); diff --git a/service-group/pom.xml b/service-group/pom.xml index d6507550..c3fc8bd7 100644 --- a/service-group/pom.xml +++ b/service-group/pom.xml @@ -15,7 +15,7 @@ ink.wgink - common + service-user 1.0-SNAPSHOT diff --git a/service-group/src/main/java/ink/wgink/module/group/controller/api/GroupController.java b/service-group/src/main/java/ink/wgink/service/group/controller/api/GroupController.java similarity index 58% rename from service-group/src/main/java/ink/wgink/module/group/controller/api/GroupController.java rename to service-group/src/main/java/ink/wgink/service/group/controller/api/GroupController.java index 1b8ed6ab..bd49d87b 100644 --- a/service-group/src/main/java/ink/wgink/module/group/controller/api/GroupController.java +++ b/service-group/src/main/java/ink/wgink/service/group/controller/api/GroupController.java @@ -1,7 +1,7 @@ -package ink.wgink.module.group.controller.api; +package ink.wgink.service.group.controller.api; +import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; -import ink.wgink.exceptions.ParamsException; import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.ZTreeDTO; @@ -9,8 +9,9 @@ import ink.wgink.pojo.dtos.group.GroupDTO; import ink.wgink.pojo.result.ErrorResult; import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultList; -import ink.wgink.module.group.pojo.vos.GroupVO; -import ink.wgink.module.group.service.IGroupService; +import ink.wgink.pojo.vos.IdsVO; +import ink.wgink.service.group.pojo.vos.GroupVO; +import ink.wgink.service.group.service.IGroupService; import io.swagger.annotations.*; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -37,11 +38,11 @@ public class GroupController extends DefaultBaseController { @ApiOperation(value = "组新增", notes = "组新增接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("savegroup") + @PostMapping("save") + @CheckRequestBodyAnnotation public SuccessResult saveGroup(@RequestBody GroupVO groupVO) { - Map params = getParams(); - checkParams(groupVO, params); - return groupService.saveGroup(params); + groupService.save(groupVO); + return new SuccessResult(); } @ApiOperation(value = "组删除", notes = "通过id列表批量删除组接口") @@ -49,11 +50,10 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "ids", value = "组ID列表,用下划线分隔", paramType = "path", example = "1_2_3") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("removegroup/{ids}") + @DeleteMapping("remove/{ids}") public SuccessResult removeGroup(@PathVariable("ids") String ids) { - Map params = getParams(); - params.put("groupIds", ids); - return groupService.removeGroup(params); + groupService.remove(Arrays.asList(ids.split("\\_"))); + return new SuccessResult(); } @ApiOperation(value = "组修改", notes = "组修改接口") @@ -61,33 +61,11 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PutMapping("updategroup/{groupId}") - public SuccessResult updateGroup(@PathVariable("groupId") String groupId, @RequestBody GroupVO groupVO) { - Map params = getParams(); - params.put("groupId", groupId); - checkParams(groupVO, params); - return groupService.updateGroup(params); - } - - /** - * 参数校验 - * - * @param groupVO - * @param params - * @throws ParamsException - */ - private void checkParams(GroupVO groupVO, Map params) { - if (StringUtils.isBlank(groupVO.getGroupParentId())) { - throw new ParamsException("父ID不能为空"); - } - params.put("groupParentId", groupVO.getGroupParentId()); - - if (StringUtils.isBlank(groupVO.getGroupName())) { - throw new ParamsException("组名称不能为空"); - } - params.put("groupName", groupVO.getGroupName()); - - params.put("groupSummary", groupVO.getGroupSummary()); + @PutMapping("update/{groupId}") + @CheckRequestBodyAnnotation + public SuccessResult update(@PathVariable("groupId") String groupId, @RequestBody GroupVO groupVO) { + groupService.update(groupId, groupVO); + return new SuccessResult(); } @ApiOperation(value = "组列表", notes = "组列表接口") @@ -95,11 +73,9 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "groupParentId", value = "组上级ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listgroup/{groupParentId}") - public List listGroup(@PathVariable("groupParentId") String groupParentId) { - Map params = getParams(); - params.put("groupParentId", groupParentId); - return groupService.listGroupAllJson(params); + @GetMapping("listallbyparentid/{groupParentId}") + public List listAllByParentId(@PathVariable("groupParentId") String groupParentId) { + return groupService.listAllByParentId(groupParentId); } @ApiOperation(value = "组详情", notes = "组详情接口") @@ -107,11 +83,11 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("getgroup/{groupId}") - public GroupDTO getGroup(@PathVariable("groupId") String groupId) { + @GetMapping("get/{groupId}") + public GroupDTO get(@PathVariable("groupId") String groupId) { Map params = getParams(); params.put("groupId", groupId); - return groupService.getGroup(params); + return groupService.get(params); } @ApiOperation(value = "zTree列表", notes = "zTree列表接口") @@ -119,15 +95,15 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "id", value = "父ID", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listztreegroup") - public List listZTreeGroup() { + @GetMapping("listztree") + public List listZTree() { Map params = requestParams(); String groupParentId = "0"; - if (!StringUtils.isBlank(params.get("id") == null ? null : params.get("id").toString())) { - groupParentId = params.get("id").toString(); + if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) { + groupParentId = params.get(ISystemConstant.PARAMS_ID).toString(); } params.put("groupParentId", groupParentId); - return groupService.listZTreeGroup(params); + return groupService.listZTree(params); } @ApiOperation(value = "分页组列表", notes = "分页组列表接口") @@ -140,8 +116,8 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listpagegroup") - public SuccessResultList> listPageGroup(ListPage page) { + @GetMapping("listpage") + public SuccessResultList> listPage(ListPage page) { Map params = requestParams(); String groupParentId = "0"; if (!StringUtils.isBlank(params.get("parentId") == null ? null : params.get("parentId").toString())) { @@ -149,21 +125,7 @@ public class GroupController extends DefaultBaseController { } params.put("groupParentId", groupParentId); page.setParams(params); - return groupService.listPageGroups(page); - } - - @ApiOperation(value = "角色组删除", notes = "角色组删除接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"), - @ApiImplicitParam(name = "ids", value = "组ID列表,用下划线分隔", paramType = "path", example = "1_2_3") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("removerolegroup/{roleId}/{ids}") - public SuccessResult removeRoleGroup(@PathVariable("roleId") String roleId, @PathVariable("ids") String ids) { - Map params = getParams(); - params.put("roleId", roleId); - params.put("groupIds", ids); - return groupService.removeRoleGroup(params); + return groupService.listPage(page); } @ApiOperation(value = "通过ID列表获取组列表", notes = "通过ID列表获取用户组接口") @@ -171,11 +133,11 @@ public class GroupController extends DefaultBaseController { @ApiImplicitParam(name = "groupIds", value = "组ID列表,用下划线分隔,如:1_2_3", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listgroupbyids/{groupIds}") - public List listGroupByIds(@PathVariable("groupIds") String groupIds) { + @PostMapping("listbyids/{groupIds}") + public List listByIds(@RequestBody IdsVO idsVO) { Map params = getParams(); - params.put("groupIds", Arrays.asList(groupIds.split("_"))); - return groupService.listGroup(params); + params.put("groupIds", idsVO.getIds()); + return groupService.list(params); } } diff --git a/service-group/src/main/java/ink/wgink/service/group/controller/api/GroupUserController.java b/service-group/src/main/java/ink/wgink/service/group/controller/api/GroupUserController.java new file mode 100644 index 00000000..49589f10 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/controller/api/GroupUserController.java @@ -0,0 +1,50 @@ +package ink.wgink.service.group.controller.api; + +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.group.GroupUserDTO; +import ink.wgink.pojo.result.ErrorResult; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.service.group.service.IGroupUserService; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: GroupUserController + * @Description: 用户组用户 + * @Author: wanggeng + * @Date: 2021/2/16 11:31 上午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "组织部门用户") +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/group/user") +public class GroupUserController { + + @Autowired + private IGroupUserService groupUserService; + + @ApiOperation(value = "组人员列表", notes = "组人员列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path", dataType = "String"), + @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), + @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), + @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listpage/{groupId}") + public SuccessResultList> listPage(@PathVariable("groupId") String groupId, ListPage page) { + return groupUserService.listPage(groupId, page); + } + +} diff --git a/service-group/src/main/java/ink/wgink/service/group/controller/route/GroupRouteController.java b/service-group/src/main/java/ink/wgink/service/group/controller/route/GroupRouteController.java new file mode 100644 index 00000000..50471ce3 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/controller/route/GroupRouteController.java @@ -0,0 +1,44 @@ +package ink.wgink.service.group.controller.route; + +import ink.wgink.interfaces.consts.ISystemConstant; +import io.swagger.annotations.Api; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: GroupRouteController + * @Description: 用户组路由 + * @Author: wanggeng + * @Date: 2021/2/15 9:07 上午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "用户组路由接口") +@Controller +@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/group") +public class GroupRouteController { + + @GetMapping("save") + public ModelAndView save() { + return new ModelAndView("group/save"); + } + + @GetMapping("update") + public ModelAndView update() { + return new ModelAndView("group/update"); + } + + @GetMapping("list") + public ModelAndView list() { + return new ModelAndView("group/list"); + } + + @GetMapping("list-tree") + public ModelAndView listTree() { + return new ModelAndView("group/list-tree"); + } +} diff --git a/service-group/src/main/java/ink/wgink/service/group/controller/route/GroupUserRouteController.java b/service-group/src/main/java/ink/wgink/service/group/controller/route/GroupUserRouteController.java new file mode 100644 index 00000000..e9c69d46 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/controller/route/GroupUserRouteController.java @@ -0,0 +1,30 @@ +package ink.wgink.service.group.controller.route; + +import ink.wgink.interfaces.consts.ISystemConstant; +import io.swagger.annotations.Api; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: GroupUserRouteController + * @Description: 用户组用户路由 + * @Author: wanggeng + * @Date: 2021/2/16 11:45 上午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "用户组路由接口") +@Controller +@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/group/user") +public class GroupUserRouteController { + + @GetMapping("list") + public ModelAndView list() { + return new ModelAndView("group/user/list"); + } + +} diff --git a/service-group/src/main/java/ink/wgink/module/group/dao/IGroupDao.java b/service-group/src/main/java/ink/wgink/service/group/dao/IGroupDao.java similarity index 64% rename from service-group/src/main/java/ink/wgink/module/group/dao/IGroupDao.java rename to service-group/src/main/java/ink/wgink/service/group/dao/IGroupDao.java index a69040ae..f7e8de7e 100644 --- a/service-group/src/main/java/ink/wgink/module/group/dao/IGroupDao.java +++ b/service-group/src/main/java/ink/wgink/service/group/dao/IGroupDao.java @@ -1,4 +1,4 @@ -package ink.wgink.module.group.dao; +package ink.wgink.service.group.dao; import ink.wgink.exceptions.RemoveException; import ink.wgink.exceptions.SaveException; @@ -7,7 +7,7 @@ import ink.wgink.exceptions.UpdateException; import ink.wgink.pojo.bos.GroupBO; import ink.wgink.pojo.dtos.ZTreeDTO; import ink.wgink.pojo.dtos.group.GroupDTO; -import ink.wgink.module.group.pojo.pos.GroupPO; +import ink.wgink.service.group.pojo.pos.GroupPO; import org.springframework.stereotype.Repository; import java.util.List; @@ -23,13 +23,20 @@ import java.util.Map; @Repository public interface IGroupDao { + /** + * 建表 + * + * @throws UpdateException + */ + void createTable() throws UpdateException; + /** * 新增组 * * @param params * @throws SaveException */ - void saveGroup(Map params) throws SaveException; + void save(Map params) throws SaveException; /** * 删除组 @@ -37,7 +44,7 @@ public interface IGroupDao { * @param params * @throws RemoveException */ - void removeGroup(Map params) throws RemoveException; + void remove(Map params) throws RemoveException; /** * 修改组 @@ -45,7 +52,7 @@ public interface IGroupDao { * @param params * @throws UpdateException */ - void updateGroup(Map params) throws UpdateException; + void update(Map params) throws UpdateException; /** * 组列表 @@ -54,7 +61,7 @@ public interface IGroupDao { * @return * @throws SearchException */ - List listGroups(Map params) throws SearchException; + List list(Map params) throws SearchException; /** * 组详情 @@ -90,7 +97,7 @@ public interface IGroupDao { * @return * @throws SearchException */ - List listZTreeGroups(Map params) throws SearchException; + List listZTree(Map params) throws SearchException; /** * 子列表个数 @@ -101,28 +108,4 @@ public interface IGroupDao { */ Integer countByParentId(String id) throws SearchException; - /** - * 删除角色组 - * - * @param params - * @throws RemoveException - */ - void removeRoleGroup(Map params) throws RemoveException; - - /** - * 添加角色组 - * - * @param params - * @throws SaveException - */ - void saveRoleGroup(Map params) throws SaveException; - - /** - * 通过用户获取用户组 - * - * @param params - * @return - * @throws SearchException - */ - List listGroupBOByUser(Map params) throws SearchException; } diff --git a/service-group/src/main/java/ink/wgink/service/group/dao/IGroupUserDao.java b/service-group/src/main/java/ink/wgink/service/group/dao/IGroupUserDao.java new file mode 100644 index 00000000..61f90976 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/dao/IGroupUserDao.java @@ -0,0 +1,47 @@ +package ink.wgink.service.group.dao; + +import ink.wgink.exceptions.SearchException; +import ink.wgink.exceptions.UpdateException; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: IGroupUserDao + * @Description: 用户组用户 + * @Author: wanggeng + * @Date: 2021/2/16 12:07 下午 + * @Version: 1.0 + */ +@Repository +public interface IGroupUserDao { + + /** + * 建表 + * + * @throws UpdateException + */ + void createTable() throws UpdateException; + + /** + * 用户ID列表 + * + * @param params + * @return + * @throws SearchException + */ + List listUserId(Map params) throws SearchException; + + /** + * 用户ID列表 + * + * @param params + * @return + * @throws SearchException + */ + List listGroupUserId(Map params) throws SearchException; +} diff --git a/service-group/src/main/java/ink/wgink/module/group/pojo/pos/GroupPO.java b/service-group/src/main/java/ink/wgink/service/group/pojo/pos/GroupPO.java similarity index 96% rename from service-group/src/main/java/ink/wgink/module/group/pojo/pos/GroupPO.java rename to service-group/src/main/java/ink/wgink/service/group/pojo/pos/GroupPO.java index 8475b877..c69249c8 100644 --- a/service-group/src/main/java/ink/wgink/module/group/pojo/pos/GroupPO.java +++ b/service-group/src/main/java/ink/wgink/service/group/pojo/pos/GroupPO.java @@ -1,4 +1,4 @@ -package ink.wgink.module.group.pojo.pos; +package ink.wgink.service.group.pojo.pos; /** * @ClassName: GroupDTO diff --git a/service-group/src/main/java/ink/wgink/module/group/pojo/vos/GroupVO.java b/service-group/src/main/java/ink/wgink/service/group/pojo/vos/GroupVO.java similarity index 89% rename from service-group/src/main/java/ink/wgink/module/group/pojo/vos/GroupVO.java rename to service-group/src/main/java/ink/wgink/service/group/pojo/vos/GroupVO.java index fa9e897b..3ec1fe6e 100644 --- a/service-group/src/main/java/ink/wgink/module/group/pojo/vos/GroupVO.java +++ b/service-group/src/main/java/ink/wgink/service/group/pojo/vos/GroupVO.java @@ -1,5 +1,6 @@ -package ink.wgink.module.group.pojo.vos; +package ink.wgink.service.group.pojo.vos; +import ink.wgink.annotation.CheckEmptyAnnotation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -14,8 +15,10 @@ import io.swagger.annotations.ApiModelProperty; public class GroupVO { @ApiModelProperty(name = "groupParentId", value = "组上级ID") + @CheckEmptyAnnotation(name = "组上级ID") private String groupParentId; @ApiModelProperty(name = "groupName", value = "组名称") + @CheckEmptyAnnotation(name = "组名称") private String groupName; @ApiModelProperty(name = "groupSummary", value = "组说明") private String groupSummary; diff --git a/service-group/src/main/java/ink/wgink/module/group/service/IGroupService.java b/service-group/src/main/java/ink/wgink/service/group/service/IGroupService.java similarity index 51% rename from service-group/src/main/java/ink/wgink/module/group/service/IGroupService.java rename to service-group/src/main/java/ink/wgink/service/group/service/IGroupService.java index 0f5817df..36a02caf 100644 --- a/service-group/src/main/java/ink/wgink/module/group/service/IGroupService.java +++ b/service-group/src/main/java/ink/wgink/service/group/service/IGroupService.java @@ -1,4 +1,4 @@ -package ink.wgink.module.group.service; +package ink.wgink.service.group.service; import ink.wgink.interfaces.group.IGroupBaseService; import ink.wgink.pojo.ListPage; @@ -7,6 +7,7 @@ import ink.wgink.pojo.dtos.ZTreeDTO; import ink.wgink.pojo.dtos.group.GroupDTO; import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.service.group.pojo.vos.GroupVO; import java.util.List; import java.util.Map; @@ -26,7 +27,7 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - SuccessResult saveGroup(Map params); + void save(GroupVO groupVO); /** * 删除组 @@ -34,7 +35,7 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - SuccessResult removeGroup(Map params); + void remove(List ids); /** * 修改组 @@ -42,15 +43,15 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - SuccessResult updateGroup(Map params); + void update(String groupId, GroupVO groupVO); /** * 全部组JSON列表 * - * @param params + * @param groupParentId * @return */ - List listGroupAllJson(Map params); + List listAllByParentId(String groupParentId); /** * 组列表,递归获取全部内容 @@ -58,7 +59,7 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - List listGroupsAll(Map params); + List listAll(Map params); /** * 组详情 @@ -66,7 +67,7 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - GroupDTO getGroup(Map params); + GroupDTO get(Map params); /** * 组zTree列表 @@ -74,7 +75,7 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - List listZTreeGroup(Map params); + List listZTree(Map params); /** * 组EasyUI列表 @@ -82,34 +83,7 @@ public interface IGroupService extends IGroupBaseService { * @param page * @return */ - SuccessResultList> listPageGroups(ListPage page); - - /** - * 更新角色组列表 - * - * @param params - * @return - * @throws RemoveException - * @throws SaveException - */ - SuccessResult updateRoleGroup(Map params); - - /** - * 删除角色组 - * - * @param params - * @return - * @throws RemoveException - */ - SuccessResult removeRoleGroup(Map params); - - /** - * 通过用户获取用户组 - * - * @param params - * @return - */ - List listGroupBOByUser(Map params); + SuccessResultList> listPage(ListPage page); /** * 组列表 @@ -117,5 +91,5 @@ public interface IGroupService extends IGroupBaseService { * @param params * @return */ - List listGroup(Map params); + List list(Map params); } diff --git a/service-group/src/main/java/ink/wgink/service/group/service/IGroupUserService.java b/service-group/src/main/java/ink/wgink/service/group/service/IGroupUserService.java new file mode 100644 index 00000000..948022b7 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/service/IGroupUserService.java @@ -0,0 +1,16 @@ +package ink.wgink.service.group.service; + +import ink.wgink.interfaces.group.IGroupUserBaseService; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: IGroupUserService + * @Description: 用户组用户 + * @Author: wanggeng + * @Date: 2021/2/16 11:32 上午 + * @Version: 1.0 + */ +public interface IGroupUserService extends IGroupUserBaseService { +} diff --git a/service-group/src/main/java/ink/wgink/module/group/service/impl/GroupServiceImpl.java b/service-group/src/main/java/ink/wgink/service/group/service/impl/GroupServiceImpl.java similarity index 51% rename from service-group/src/main/java/ink/wgink/module/group/service/impl/GroupServiceImpl.java rename to service-group/src/main/java/ink/wgink/service/group/service/impl/GroupServiceImpl.java index e39dcdde..66860e7a 100644 --- a/service-group/src/main/java/ink/wgink/module/group/service/impl/GroupServiceImpl.java +++ b/service-group/src/main/java/ink/wgink/service/group/service/impl/GroupServiceImpl.java @@ -1,22 +1,21 @@ -package ink.wgink.module.group.service.impl; +package ink.wgink.service.group.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; -import ink.wgink.pojo.bos.GroupBO; import ink.wgink.pojo.dtos.ZTreeDTO; import ink.wgink.pojo.dtos.group.GroupDTO; -import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultList; -import ink.wgink.module.group.dao.IGroupDao; -import ink.wgink.module.group.service.IGroupService; +import ink.wgink.service.group.dao.IGroupDao; +import ink.wgink.service.group.pojo.vos.GroupVO; +import ink.wgink.service.group.service.IGroupService; import ink.wgink.util.UUIDUtil; -import org.apache.commons.lang3.StringUtils; +import ink.wgink.util.map.HashMapUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -34,10 +33,11 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic private IGroupDao groupDao; @Override - public SuccessResult saveGroup(Map params) { + public void save(GroupVO groupVO) { String parentCode = null; + Map params = HashMapUtil.beanToMap(groupVO); String groupParentId = params.get("groupParentId").toString(); - if (!"0".equals(groupParentId)) { + if (!ISystemConstant.TREE_ROOT_ID.equals(groupParentId)) { params.put("groupId", groupParentId); GroupDTO groupDTO = groupDao.getGroup(params); parentCode = groupDTO.getGroupCode(); @@ -46,45 +46,46 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic params.put("groupCode", groupCode); params.put("groupId", UUIDUtil.getUUID()); setSaveInfo(params); - groupDao.saveGroup(params); - return new SuccessResult(); + groupDao.save(params); } @Override - public SuccessResult removeGroup(Map params) { - params.put("groupIds", Arrays.asList(params.get("groupIds").toString().split("_"))); + public void remove(List ids) { + Map params = getHashMap(2); + params.put("groupIds", ids); setUpdateInfo(params); - groupDao.removeGroup(params); - return new SuccessResult(); + groupDao.remove(params); } @Override - public SuccessResult updateGroup(Map params) { + public void update(String groupId, GroupVO groupVO) { + Map params = HashMapUtil.beanToMap(groupVO); setUpdateInfo(params); - groupDao.updateGroup(params); - return new SuccessResult(); + groupDao.update(params); } @Override - public List listGroupAllJson(Map params) { - return listGroupsAll(params); + public List listAllByParentId(String groupParentId) { + Map params = getHashMap(2); + params.put("groupParentId", groupParentId); + return listAll(params); } @Override - public List listGroupsAll(Map params) { - List groupDTOs = groupDao.listGroups(params); + public List listAll(Map params) { + List groupDTOs = list(params); listSubGroups(groupDTOs, params); return groupDTOs; } @Override - public GroupDTO getGroup(Map params) { + public GroupDTO get(Map params) { return groupDao.getGroup(params); } @Override - public List listZTreeGroup(Map params) { - List zTreeDTOs = groupDao.listZTreeGroups(params); + public List listZTree(Map params) { + List zTreeDTOs = groupDao.listZTree(params); for (ZTreeDTO zTreeDTO : zTreeDTOs) { Integer subCount = groupDao.countByParentId(zTreeDTO.getId()); setZTreeInfo(zTreeDTO, subCount); @@ -93,42 +94,16 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic } @Override - public SuccessResultList> listPageGroups(ListPage page) { + public SuccessResultList> listPage(ListPage page) { PageHelper.startPage(page.getPage(), page.getRows()); - List groupDTOs = groupDao.listGroups(page.getParams()); + List groupDTOs = list(page.getParams()); PageInfo pageInfo = new PageInfo<>(groupDTOs); return new SuccessResultList<>(groupDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); } @Override - public SuccessResult updateRoleGroup(Map params) { - groupDao.removeRoleGroup(params); - if (!StringUtils.isBlank(params.get("selectedGroupIds") == null ? null : params.get("selectedGroupIds").toString())) { - String[] selectedUserIds = params.get("selectedGroupIds").toString().split("_"); - params.remove("selectedGroupIds"); - for (String userId : selectedUserIds) { - params.put("groupId", userId); - groupDao.saveRoleGroup(params); - } - } - return new SuccessResult(); - } - - @Override - public SuccessResult removeRoleGroup(Map params) { - params.put("groupIds", Arrays.asList(params.get("groupIds").toString().split("_"))); - groupDao.removeRoleGroup(params); - return new SuccessResult(); - } - - @Override - public List listGroupBOByUser(Map params) { - return groupDao.listGroupBOByUser(params); - } - - @Override - public List listGroup(Map params) { - return groupDao.listGroups(params); + public List list(Map params) { + return groupDao.list(params); } /** @@ -140,7 +115,7 @@ public class GroupServiceImpl extends DefaultBaseService implements IGroupServic private void listSubGroups(List groupDTOs, Map params) { for (GroupDTO groupDTO : groupDTOs) { params.put("groupParentId", groupDTO.getGroupId()); - List subGroupDTOs = groupDao.listGroups(params); + List subGroupDTOs = list(params); groupDTO.setSubGroups(subGroupDTOs); listSubGroups(subGroupDTOs, params); } diff --git a/service-group/src/main/java/ink/wgink/service/group/service/impl/GroupUserServiceImpl.java b/service-group/src/main/java/ink/wgink/service/group/service/impl/GroupUserServiceImpl.java new file mode 100644 index 00000000..9f7b8330 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/service/impl/GroupUserServiceImpl.java @@ -0,0 +1,101 @@ +package ink.wgink.service.group.service.impl; + +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.interfaces.user.IUserBaseService; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.group.GroupUserDTO; +import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.service.group.dao.IGroupUserDao; +import ink.wgink.service.group.service.IGroupUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: GroupUserServiceImpl + * @Description: 用户组用户 + * @Author: wanggeng + * @Date: 2021/2/16 11:32 上午 + * @Version: 1.0 + */ +@Service +public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUserService { + + @Autowired + private IGroupUserDao groupUserDao; + @Autowired + private IUserBaseService userBaseService; + + @Override + public List listUserId(String groupId) { + Map params = getHashMap(2); + params.put("groupId", groupId); + return groupUserDao.listUserId(params); + } + + @Override + public List listUserId(List groupIds) { + Map params = getHashMap(2); + params.put("groupIds", groupIds); + return groupUserDao.listUserId(params); + } + + @Override + public SuccessResultList> listPage(String groupId, ListPage page) { + SuccessResultList> successResultList; + if (StringUtils.equals(groupId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) { + successResultList = listPageUserDTOByExcludeGroup(page); + } else { + successResultList = listPageUser(groupId, page); + } + List userDTOs = successResultList.getRows(); + List groupUserDTOs = new ArrayList<>(); + for (UserDTO userDTO : userDTOs) { + GroupUserDTO groupUserDTO = new GroupUserDTO(userDTO); + groupUserDTOs.add(groupUserDTO); + } + return new SuccessResultList<>(groupUserDTOs, successResultList.getPage(), successResultList.getTotal()); + } + + + private List listGroupUserId(Map params) { + return groupUserDao.listGroupUserId(params); + } + + /** + * 没有用户组的用户分页列表 + * + * @param page + * @return + */ + private SuccessResultList> listPageUserDTOByExcludeGroup(ListPage page) { + List hasGroupUserIds = listGroupUserId(new HashMap<>(0)); + return userBaseService.listPageByExcludeIds(hasGroupUserIds, page); + } + + /** + * 用户组的用户分页列表 + * + * @param groupId 用户组ID + * @param page + * @return + */ + private SuccessResultList> listPageUser(String groupId, ListPage page) { + List userIds = listUserId(groupId); + if (userIds.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + return userBaseService.listPageByIds(userIds, page); + } + +} diff --git a/service-group/src/main/java/ink/wgink/service/group/startup/ServiceGroupStartUp.java b/service-group/src/main/java/ink/wgink/service/group/startup/ServiceGroupStartUp.java new file mode 100644 index 00000000..6080b221 --- /dev/null +++ b/service-group/src/main/java/ink/wgink/service/group/startup/ServiceGroupStartUp.java @@ -0,0 +1,44 @@ +package ink.wgink.service.group.startup; + +import ink.wgink.service.group.dao.IGroupDao; +import ink.wgink.service.group.dao.IGroupUserDao; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: ServiceGroupStartUp + * @Description: 用户组启动 + * @Author: wanggeng + * @Date: 2021/2/15 9:11 上午 + * @Version: 1.0 + */ +@Component +public class ServiceGroupStartUp implements ApplicationRunner { + + private static final Logger LOG = LoggerFactory.getLogger(ServiceGroupStartUp.class); + + @Autowired + private IGroupDao groupDao; + @Autowired + private IGroupUserDao groupUserDao; + + @Override + public void run(ApplicationArguments args) throws Exception { + initTable(); + } + + private void initTable() { + LOG.debug("创建 sys_group 表"); + groupDao.createTable(); + + LOG.debug("创建 sys_group_user 表"); + groupUserDao.createTable(); + } +} diff --git a/service-group/src/main/resources/mybatis/mapper/group-mapper.xml b/service-group/src/main/resources/mybatis/mapper/group-mapper.xml index 09432d19..644b07eb 100644 --- a/service-group/src/main/resources/mybatis/mapper/group-mapper.xml +++ b/service-group/src/main/resources/mybatis/mapper/group-mapper.xml @@ -1,6 +1,6 @@ - + @@ -11,7 +11,7 @@ - + @@ -31,97 +31,26 @@ - - - - - - - - - - - - INSERT INTO sys_role_group( - group_id, - role_id - ) VALUES( - #{groupId}, - #{roleId} - ) - - - - - delete from - sys_role_group - where - 1 = 1 - - AND - role_id = #{roleId} - - - AND - group_id = #{groupId} - - - AND - group_id IN - - #{groupIds[${index}]} - - - - - - + + + CREATE TABLE IF NOT EXISTS `sys_group` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `group_id` char(36) NOT NULL, + `group_parent_id` char(36) DEFAULT '0' COMMENT '组上级ID', + `group_name` varchar(255) DEFAULT NULL COMMENT '组名称', + `group_summary` varchar(255) DEFAULT NULL COMMENT '组说明', + `group_code` varchar(255) DEFAULT NULL COMMENT '组编码', + `creator` char(36) DEFAULT NULL, + `gmt_create` datetime DEFAULT NULL, + `modifier` char(36) DEFAULT NULL, + `gmt_modified` datetime DEFAULT NULL, + `is_delete` int(2) DEFAULT '0', + PRIMARY KEY (`id`,`group_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + - + INSERT INTO sys_group( group_id, group_parent_id, @@ -148,7 +77,7 @@ - + UPDATE sys_group SET @@ -163,7 +92,7 @@ - + UPDATE sys_group SET @@ -183,7 +112,7 @@ - SELECT * FROM @@ -197,7 +126,7 @@ - SELECT * FROM @@ -304,24 +233,4 @@ LIMIT 0, 1 - - - \ No newline at end of file diff --git a/service-group/src/main/resources/mybatis/mapper/group-user-mapper.xml b/service-group/src/main/resources/mybatis/mapper/group-user-mapper.xml new file mode 100644 index 00000000..db824406 --- /dev/null +++ b/service-group/src/main/resources/mybatis/mapper/group-user-mapper.xml @@ -0,0 +1,51 @@ + + + + + + + + + CREATE TABLE IF NOT EXISTS `sys_group_user` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `group_id` char(36) NOT NULL COMMENT '组ID', + `user_id` char(36) NOT NULL, + PRIMARY KEY (`id`), + KEY `user_id_idx` (`user_id`) USING BTREE, + KEY `group_id_idx` (`group_id`) USING BTREE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + + + + + + + + + \ No newline at end of file diff --git a/service-group/src/main/resources/templates/group/list-tree.html b/service-group/src/main/resources/templates/group/list-tree.html index 02defedf..0304ec3b 100644 --- a/service-group/src/main/resources/templates/group/list-tree.html +++ b/service-group/src/main/resources/templates/group/list-tree.html @@ -1,7 +1,7 @@ - + - + @@ -49,7 +49,7 @@ // 初始化IFrame function initIFrame() { - $('#listContent').attr('src', top.restAjax.path('route/system/group/list.html?parentId={parentId}', [parentId])); + $('#listContent').attr('src', top.restAjax.path('route/group/list?parentId={parentId}', [parentId])); } // 初始化大小 function initSize() { @@ -68,7 +68,7 @@ enable: true, autoLoad: false, type: 'get', - url: top.restAjax.path('api/group/listztreegroup', []), + url: top.restAjax.path('api/group/listztree', []), autoParam: ['id'], otherParam: {}, dataFilter: function (treeId, parentNode, childNodes) { diff --git a/service-group/src/main/resources/templates/group/list.html b/service-group/src/main/resources/templates/group/list.html index 05bc4757..0a7fb8b6 100644 --- a/service-group/src/main/resources/templates/group/list.html +++ b/service-group/src/main/resources/templates/group/list.html @@ -1,7 +1,7 @@ - + - + @@ -57,13 +57,14 @@ var admin = layui.admin; var laydate = layui.laydate; var parentId = top.restAjax.params(window.location.href).parentId; + var tableUrl = 'api/group/listpage?parentId={parentId}'; // 初始化表格 function initTable() { table.render({ elem: '#dataTable', id: 'dataTable', - url: top.restAjax.path('api/group/listpagegroup?parentId={parentId}', [parentId]), + url: top.restAjax.path(tableUrl, [parentId]), width: admin.screen() > 1 ? '100%' : '', height: $win.height() - 60, limit: 20, @@ -73,18 +74,20 @@ pageName: 'page', limitName: 'rows' }, - cols: [[ - {type:'checkbox', fixed: 'left'}, - {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'}, - {field:'users', width:100, title: '人员列表', align:'center', - templet: function(item) { - return ''; - } - }, - {field:'groupName', width:170, title: '组名称', align:'center',}, - {field:'groupSummary', width:170, title: '组说明', align:'center',}, - {field:'groupCode', width:170, title: '组编码', align:'center',}, - ]], + cols: [ + [ + {type:'checkbox', fixed: 'left'}, + {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'}, + {field:'users', width:100, title: '人员列表', align:'center', + templet: function(item) { + return ''; + } + }, + {field:'groupName', width:170, title: '组名称', align:'center',}, + {field:'groupSummary', width:170, title: '组说明', align:'center',}, + {field:'groupCode', width:170, title: '组编码', align:'center',} + ] + ], page: true, parseData: function(data) { return { @@ -99,7 +102,7 @@ // 重载表格 function reloadTable(currentPage) { table.reload('dataTable', { - url: top.restAjax.path('api/group/listpagegroup?parentId={parentId}', [parentId]), + url: top.restAjax.path(tableUrl, [parentId]), where: { keywords: $('#keywords').val(), }, @@ -109,10 +112,6 @@ height: $win.height() - 60, }); } - function refreshTable() { - parent.common.refreshTree('leftTree'); - reloadTable(); - } // 初始化日期 function initDate() {} // 删除 @@ -124,10 +123,10 @@ yes: function (index) { top.dialog.close(index); var layIndex; - top.restAjax.delete(top.restAjax.path('api/group/removegroup/{ids}', [ids]), {}, null, function (code, data) { - top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000}, function () { - refreshTable(); - }); + top.restAjax.delete(top.restAjax.path('api/group/remove/{ids}', [ids]), {}, null, function (code, data) { + top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000}); + parent.common.refreshTree('leftTree'); + reloadTable(); }, function (code, data) { top.dialog.msg(data.msg); }, function () { @@ -162,9 +161,9 @@ area: ['100%', '100%'], shadeClose: true, anim: 2, - content: top.restAjax.path('route/system/group/save.html?groupParentId={parentId}', [parentId]), + content: top.restAjax.path('route/group/save?groupParentId={parentId}', [parentId]), end: function() { - refreshTable(); + reloadTable(); } }); } else if(layEvent === 'update') { @@ -180,9 +179,9 @@ area: ['100%', '100%'], shadeClose: true, anim: 2, - content: top.restAjax.path('route/system/group/update.html?groupId={groupId}', [checkDatas[0].groupId]), + content: top.restAjax.path('route/group/update?groupId={groupId}', [checkDatas[0].groupId]), end: function() { - refreshTable(); + reloadTable(); } }); } @@ -206,7 +205,7 @@ var layEvent = obj.event; if(layEvent === 'userEvent') { top.dialog.open({ - url: top.restAjax.path('route/system/user/list-group-user.html?groupId={groupId}', [data.groupId]), + url: top.restAjax.path('route/group/user/list?groupId={groupId}', [data.groupId]), title: '用户组用户列表', width: '800px', height: '500px', diff --git a/service-group/src/main/resources/templates/group/save.html b/service-group/src/main/resources/templates/group/save.html index 9f01d30c..cdb4a817 100644 --- a/service-group/src/main/resources/templates/group/save.html +++ b/service-group/src/main/resources/templates/group/save.html @@ -1,7 +1,7 @@ - + - + @@ -79,7 +79,7 @@ return; } var loadLayerIndex; - top.restAjax.get(top.restAjax.path('api/group/getgroup/{groupParentId}', [groupParentId]), {}, null, function(code, data) { + top.restAjax.get(top.restAjax.path('api/group/get/{groupParentId}', [groupParentId]), {}, null, function(code, data) { form.val('dataForm', { groupParentName: data.groupName }); @@ -99,7 +99,8 @@ top.dialog.confirm(top.dataMessage.commit, function(index) { top.dialog.close(index); var loadLayerIndex; - top.restAjax.post(top.restAjax.path('api/group/savegroup', []), formData.field, null, function(code, data) { + top.restAjax.post(top.restAjax.path('api/group/save', []), formData.field, null, function(code, data) { + parent.parent.common.refreshTree('leftTree'); var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, { time: 0, btn: [top.dataMessage.button.yes, top.dataMessage.button.no], diff --git a/service-group/src/main/resources/templates/group/select-group.html b/service-group/src/main/resources/templates/group/select-group.html deleted file mode 100644 index 1657536e..00000000 --- a/service-group/src/main/resources/templates/group/select-group.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - - - - \ No newline at end of file diff --git a/service-group/src/main/resources/templates/group/update.html b/service-group/src/main/resources/templates/group/update.html index d8afdc24..ee72910a 100644 --- a/service-group/src/main/resources/templates/group/update.html +++ b/service-group/src/main/resources/templates/group/update.html @@ -1,7 +1,7 @@ - + - + @@ -69,7 +69,7 @@ // 初始化 function initData() { var loadLayerIndex; - top.restAjax.get(top.restAjax.path('api/group/getgroup/{groupId}', [groupId]), {}, null, function(code, data) { + top.restAjax.get(top.restAjax.path('api/group/get/{groupId}', [groupId]), {}, null, function(code, data) { form.val('dataForm', { groupParentName: data.groupParentName == '' ? '根节点' : data.groupParentName, groupParentId: data.groupParentId, @@ -92,7 +92,8 @@ top.dialog.confirm(top.dataMessage.commit, function(index) { top.dialog.close(index); var loadLayerIndex; - top.restAjax.put(top.restAjax.path('api/group/updategroup/{groupId}', [groupId]), formData.field, null, function(code, data) { + top.restAjax.put(top.restAjax.path('api/group/update/{groupId}', [groupId]), formData.field, null, function(code, data) { + parent.parent.common.refreshTree('leftTree'); var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, { time: 0, btn: [top.dataMessage.button.yes, top.dataMessage.button.no], diff --git a/service-group/src/main/resources/templates/group/list-role-group.html b/service-group/src/main/resources/templates/group/user/list.html similarity index 64% rename from service-group/src/main/resources/templates/group/list-role-group.html rename to service-group/src/main/resources/templates/group/user/list.html index c32d1aeb..124a9e9b 100644 --- a/service-group/src/main/resources/templates/group/list-role-group.html +++ b/service-group/src/main/resources/templates/group/user/list.html @@ -1,11 +1,11 @@ - + - + - + @@ -42,7 +42,7 @@ - + diff --git a/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java b/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java index 967d1f22..3d967baa 100644 --- a/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java +++ b/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java @@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.exceptions.SearchException; +import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.ZTreeDTO; import ink.wgink.pojo.dtos.menu.MenuDTO; @@ -119,7 +120,7 @@ public class MenuServiceImpl extends DefaultBaseService implements IMenuService Map params = HashMapUtil.beanToMap(menuVO); String parentCode = null; String menuParentId = params.get("menuParentId").toString(); - if (!"0".equals(menuParentId)) { + if (!ISystemConstant.TREE_ROOT_ID.equals(menuParentId)) { params.put("menuId", menuParentId); MenuDTO menuDTO = menuDao.get(params); parentCode = menuDTO.getMenuCode(); diff --git a/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java b/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java index d1c7de0c..307297dc 100644 --- a/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java +++ b/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java @@ -223,7 +223,8 @@ public class ServiceMenuStartUp implements ApplicationRunner { menuId = menuDTO.getMenuId(); } initUserManage(params, menuId); - initMenuDepartment(params, menuId); + initDepartmentManage(params, menuId); + initGroupManage(params, menuId); } /** @@ -256,7 +257,13 @@ public class ServiceMenuStartUp implements ApplicationRunner { } } - private void initMenuDepartment(Map params, String menuParentId) { + /** + * 组织机构管理 + * + * @param params + * @param menuParentId + */ + private void initDepartmentManage(Map params, String menuParentId) { LOG.debug("初始化菜单:组织机构管理"); if (departmentCheckService == null) { return; @@ -280,15 +287,40 @@ public class ServiceMenuStartUp implements ApplicationRunner { } } - private void initMenuGroup() { + /** + * 用户组管理 + * + * @param params + * @param menuParentId + */ + private void initGroupManage(Map params, String menuParentId) { LOG.debug("初始化菜单:用户组管理"); - LOG.debug("初始化菜单:职位管理"); - LOG.debug("初始化菜单:权限管理"); - LOG.debug("初始化菜单:角色管理"); + if (departmentCheckService == null) { + return; + } + params.remove("menuId"); + params.put("menuCode", "000100020003"); + MenuDTO menuDTO = menuDao.getSimple(params); + String menuId = UUIDUtil.getUUID(); + if (menuDTO == null) { + params.put("menuId", menuId); + params.put("menuParentId", menuParentId); + params.put("menuName", "用户组管理"); + params.put("menuSummary", "用户组管理"); + params.put("menuUrl", "/route/group/list-tree"); + params.put("menuType", "1"); + params.put("menuIcon", "fa-icon-color-white fa fa-users"); + params.put("menuOrder", "3"); + params.put("menuStatus", "0"); + params.put("openType", "1"); + menuDao.save(params); + } } private void initMenuPosition() { - + LOG.debug("初始化菜单:职位管理"); + LOG.debug("初始化菜单:权限管理"); + LOG.debug("初始化菜单:角色管理"); } private void initMenuPermission() { diff --git a/service-role/src/main/java/ink/wgink/service/role/service/impl/RoleServiceImpl.java b/service-role/src/main/java/ink/wgink/service/role/service/impl/RoleServiceImpl.java index 56414e67..b734e333 100644 --- a/service-role/src/main/java/ink/wgink/service/role/service/impl/RoleServiceImpl.java +++ b/service-role/src/main/java/ink/wgink/service/role/service/impl/RoleServiceImpl.java @@ -387,7 +387,7 @@ public class RoleServiceImpl extends DefaultBaseService implements IRoleService for (DepartmentBO departmentBO : departmentBOs) { departmentIds.add(departmentBO.getDepartmentId()); } - return departmentUserService.listUserIdByDepartmentIds(departmentIds); + return departmentUserService.listUserId(departmentIds); } @Override diff --git a/service-user/src/main/java/ink/wgink/service/user/service/impl/UserServiceImpl.java b/service-user/src/main/java/ink/wgink/service/user/service/impl/UserServiceImpl.java index 74134f72..1d796373 100644 --- a/service-user/src/main/java/ink/wgink/service/user/service/impl/UserServiceImpl.java +++ b/service-user/src/main/java/ink/wgink/service/user/service/impl/UserServiceImpl.java @@ -254,7 +254,7 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService } @Override - public SuccessResultList> listPageByExcludeUserIds(List excludeUserIds, ListPage page) { + public SuccessResultList> listPageByExcludeIds(List excludeUserIds, ListPage page) { page.getParams().put("excludeUserIds", excludeUserIds); return listPage(page); } diff --git a/service-user/src/main/resources/templates/user/save.html b/service-user/src/main/resources/templates/user/save.html index b0d7aa28..61420451 100644 --- a/service-user/src/main/resources/templates/user/save.html +++ b/service-user/src/main/resources/templates/user/save.html @@ -146,14 +146,14 @@ $('#avatarImage').on('click', function() { top.dialog.open({ - url: 'route/file/uploadimage/v2?fileId='+ $('#userAvatar').val(), + url: 'route/file/uploadimage?fileId='+ $('#userAvatar').val(), title: '上传头像', width: '800px', height: '470px', onClose: function() { var uploadImage = top.dialog.dialogData.uploadImage; if(typeof(uploadImage) != 'undefined' && null != uploadImage && '' != uploadImage) { - $('#avatarImage').attr('src', 'route/file/downloadfile/false/' + uploadImage); + $('#avatarImage').attr('src', 'route/file/download/false/' + uploadImage); $('#userAvatar').val(uploadImage); } } diff --git a/service-user/src/main/resources/templates/user/update.html b/service-user/src/main/resources/templates/user/update.html index 43ca8748..bdc8d92a 100644 --- a/service-user/src/main/resources/templates/user/update.html +++ b/service-user/src/main/resources/templates/user/update.html @@ -120,7 +120,7 @@ }); form.render(null, 'dataForm'); if($('#userAvatar').val() != '') { - $('#avatarImage').attr('src', 'route/file/downloadfile/false/' + $('#userAvatar').val()); + $('#avatarImage').attr('src', 'route/file/download/true/' + $('#userAvatar').val()); } else { $('#userAvatar').val($('#userAvatar').val()); } @@ -176,14 +176,14 @@ $('#avatarImage').on('click', function() { top.dialog.open({ - url: 'route/file/uploadimage/v2?fileId='+ $('#userAvatar').val(), + url: 'route/file/uploadimage?fileId='+ $('#userAvatar').val(), title: '上传头像', width: '800px', height: '470px', onClose: function() { var uploadImage = top.dialog.dialogData.uploadImage; if(typeof(uploadImage) != 'undefined' && null != uploadImage && '' != uploadImage) { - $('#avatarImage').attr('src', 'route/file/downloadfile/false/' + uploadImage); + $('#avatarImage').attr('src', 'route/file/download/true/' + uploadImage); $('#userAvatar').val(uploadImage); } }