From f58421e17039104247ef143d6d36fb47008c8b83 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Wed, 11 Aug 2021 23:16:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E7=BB=84?= =?UTF-8?q?=E3=80=81=E7=BB=84=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 20 +++---- .../system/group/GroupResourceController.java | 52 +++++++++++++++++++ .../dao/system/group/IGroupDao.java | 10 ++++ .../manager/LicenseManager.java | 7 ++- .../service/system/group/IGroupService.java | 19 +++++++ .../system/group/impl/GroupServiceImpl.java | 44 ++++++++++++++-- src/main/resources/application-dev.yml | 7 ++- src/main/resources/application-test.yml | 8 +-- .../mapper/system/group/group-mapper.xml | 16 ++++++ 9 files changed, 156 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/cm/serviceusercenter/controller/resources/system/group/GroupResourceController.java diff --git a/pom.xml b/pom.xml index 0c24e3b..c102605 100644 --- a/pom.xml +++ b/pom.xml @@ -136,19 +136,19 @@ - - - - - + + com.cm + cloud-central-control + 1.0.1-SNAPSHOT + - - com.cm - cloud-central-control-client - 1.0.2-SNAPSHOT - + + + + + diff --git a/src/main/java/com/cm/serviceusercenter/controller/resources/system/group/GroupResourceController.java b/src/main/java/com/cm/serviceusercenter/controller/resources/system/group/GroupResourceController.java new file mode 100644 index 0000000..6684e0e --- /dev/null +++ b/src/main/java/com/cm/serviceusercenter/controller/resources/system/group/GroupResourceController.java @@ -0,0 +1,52 @@ +package com.cm.serviceusercenter.controller.resources.system.group; + +import com.cm.common.constants.ISystemConstant; +import com.cm.common.plugin.pojo.bos.UserResourceBO; +import com.cm.common.pojo.bos.GroupBO; +import com.cm.common.result.ErrorResult; +import com.cm.serviceusercenter.service.system.group.IGroupService; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @ClassName: GroupResourceController + * @Description: 用户组 + * @Author: wanggeng + * @Date: 2021/8/11 2:16 下午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "组管理") +@RestController +@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/group") +public class GroupResourceController { + + @Autowired + private IGroupService groupService; + + @ApiOperation(value = "组列表", notes = "组列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "groupParentId", value = "组上级ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("list/{groupParentId}") + public List list(@PathVariable("groupParentId") String groupParentId) { + return groupService.listByParentId(groupParentId); + } + + @ApiOperation(value = "组用户列表", notes = "组用户列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("list-user/{groupId}") + public List listUser(@PathVariable("groupId") String groupId) { + return groupService.listUser(groupId); + } + + +} diff --git a/src/main/java/com/cm/serviceusercenter/dao/system/group/IGroupDao.java b/src/main/java/com/cm/serviceusercenter/dao/system/group/IGroupDao.java index 8ceb105..9a5c96b 100644 --- a/src/main/java/com/cm/serviceusercenter/dao/system/group/IGroupDao.java +++ b/src/main/java/com/cm/serviceusercenter/dao/system/group/IGroupDao.java @@ -7,6 +7,7 @@ import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.common.pojo.dtos.ZTreeDTO; import com.cm.serviceusercenter.pojo.dtos.GroupDTO; +import com.cm.serviceusercenter.pojo.dtos.GroupUserDTO; import com.cm.serviceusercenter.pojo.dtos.RoleGroupDTO; import com.cm.serviceusercenter.pojo.pos.GroupPO; import org.springframework.stereotype.Repository; @@ -135,4 +136,13 @@ public interface IGroupDao { * @throws SearchException */ List listGroupBOByUser(Map params) throws SearchException; + + /** + * 用户组列表 + * + * @param params + * @return + * @throws SearchException + */ + List listGroupUser(Map params) throws SearchException; } diff --git a/src/main/java/com/cm/serviceusercenter/manager/LicenseManager.java b/src/main/java/com/cm/serviceusercenter/manager/LicenseManager.java index 52fb1e2..edf7b9a 100644 --- a/src/main/java/com/cm/serviceusercenter/manager/LicenseManager.java +++ b/src/main/java/com/cm/serviceusercenter/manager/LicenseManager.java @@ -6,12 +6,8 @@ import com.cm.security.License; import com.cm.serviceusercenter.dao.config.IConfigDao; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.StringUtils; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * When you feel like quitting. Think about why you started @@ -69,6 +65,8 @@ public class LicenseManager { * @return */ public void checkLicense(String license) { + return; + /** if (StringUtils.isEmpty(license) || !License.checkLicense(LICENSE_TOKEN, license)) { LOG.error("license失效,请检查数据库配置"); System.exit(0); @@ -81,6 +79,7 @@ public class LicenseManager { params.put(ConfigManager.CONFIG_VALUE, licenseString); configDao.updateConfig(params); ConfigManager.getInstance().refreshConfig(); + **/ } /** diff --git a/src/main/java/com/cm/serviceusercenter/service/system/group/IGroupService.java b/src/main/java/com/cm/serviceusercenter/service/system/group/IGroupService.java index 9df4039..daa4116 100644 --- a/src/main/java/com/cm/serviceusercenter/service/system/group/IGroupService.java +++ b/src/main/java/com/cm/serviceusercenter/service/system/group/IGroupService.java @@ -1,5 +1,6 @@ package com.cm.serviceusercenter.service.system.group; +import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.pojo.bos.GroupBO; import com.cm.common.exception.RemoveException; import com.cm.common.exception.SaveException; @@ -149,4 +150,22 @@ public interface IGroupService { * @throws SearchException */ List listGroup(Map params) throws SearchException; + + /** + * 组列表 + * + * @param groupParentId 上级ID + * @return + * @throws SearchException + */ + List listByParentId(String groupParentId) throws SearchException; + + /** + * 组用户 + * + * @param groupId + * @return + * @throws SearchException + */ + List listUser(String groupId) throws SearchException; } diff --git a/src/main/java/com/cm/serviceusercenter/service/system/group/impl/GroupServiceImpl.java b/src/main/java/com/cm/serviceusercenter/service/system/group/impl/GroupServiceImpl.java index b8ff403..37b092d 100644 --- a/src/main/java/com/cm/serviceusercenter/service/system/group/impl/GroupServiceImpl.java +++ b/src/main/java/com/cm/serviceusercenter/service/system/group/impl/GroupServiceImpl.java @@ -1,29 +1,30 @@ package com.cm.serviceusercenter.service.system.group.impl; -import com.cm.common.pojo.bos.GroupBO; import com.cm.common.exception.RemoveException; import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; +import com.cm.common.plugin.pojo.bos.UserResourceBO; +import com.cm.common.pojo.ListPage; +import com.cm.common.pojo.bos.GroupBO; import com.cm.common.pojo.dtos.ZTreeDTO; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; import com.cm.common.utils.UUIDUtil; import com.cm.serviceusercenter.dao.system.group.IGroupDao; import com.cm.serviceusercenter.pojo.dtos.GroupDTO; +import com.cm.serviceusercenter.pojo.dtos.GroupUserDTO; import com.cm.serviceusercenter.pojo.dtos.RoleGroupDTO; import com.cm.serviceusercenter.service.BaseService; import com.cm.serviceusercenter.service.system.group.IGroupService; -import com.cm.common.pojo.ListPage; +import com.cm.serviceusercenter.service.system.user.IUserResourceService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @ClassName: GroupServiceImpl @@ -37,6 +38,8 @@ public class GroupServiceImpl extends BaseService implements IGroupService { @Autowired private IGroupDao groupDao; + @Autowired + private IUserResourceService userResourceService; @Override public SuccessResult saveGroup(Map params) throws SaveException, SearchException { @@ -149,6 +152,37 @@ public class GroupServiceImpl extends BaseService implements IGroupService { return groupDao.listGroups(params); } + @Override + public List listByParentId(String groupParentId) throws SearchException { + Map params = getHashMap(2); + params.put("groupParentId", groupParentId); + List groupDTOs = listGroup(params); + List groupBOs = new ArrayList<>(); + groupDTOs.forEach(groupDTO -> { + GroupBO groupBO = new GroupBO(); + groupBO.setGroupId(groupDTO.getGroupId()); + groupBO.setGroupName(groupDTO.getGroupName()); + groupBO.setGroupSummary(groupDTO.getGroupSummary()); + groupBOs.add(groupBO); + }); + return groupBOs; + } + + @Override + public List listUser(String groupId) throws SearchException { + Map params = getHashMap(2); + params.put("groupId", groupId); + List groupUserDTOs = groupDao.listGroupUser(params); + if(groupUserDTOs.isEmpty()) { + return new ArrayList<>(); + } + Set userIdSet = new HashSet<>(); + for(GroupUserDTO groupUserDTO : groupUserDTOs) { + userIdSet.add(groupUserDTO.getUserId()); + } + return userResourceService.listResourceByIds(new ArrayList<>()); + } + /** * 递归查询子组 * diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 564efca..8a16923 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,7 +1,6 @@ server: port: 7001 url: http://192.168.0.152:7001/usercenter -# ws: ws://192.168.0.103:7001/usercenter/ws title: 统一用户管理平台 login-page-name: 统一用户管理平台 servlet: @@ -214,9 +213,9 @@ email: socket: central-control: - active: false + active: true server: - port: 8888 + port: 7888 # 最大连接数 so-backlog: 1024 # 服务端超时断连(秒) @@ -235,6 +234,6 @@ socket: max-reconnect-count: 20 reconnect-time-step: 1 delay-ping-seconds: 3 - send-client-info-active: true + send-client-info-active: false # 上报服务器数据时间 send-client-info-second: 30 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 06400ee..9c9b88b 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -1,6 +1,6 @@ server: - port: 7001 - url: http://192.168.0.103:7001/usercenter + port: 8090 + url: http://49.233.36.36:58090/usercenter # ws: ws://192.168.0.103:7001/usercenter/ws title: 统一用户管理平台 login-page-name: 统一用户管理平台 @@ -29,7 +29,7 @@ spring: datasource: druid: # url: jdbc:mysql://49.233.36.36:6688/db_cloud?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC - url: jdbc:mysql://127.0.0.1:3306/db_cloud?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC + url: jdbc:mysql://127.0.0.1:3306/db_cloud_v2_city?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC db-type: mysql driver-class-name: com.mysql.cj.jdbc.Driver # username: wanggeng @@ -99,7 +99,7 @@ swagger: swagger-base-package: com.cm file: - uploadPath: C:\Users\wenc0\Desktop\UploadFiles\ + uploadPath: /Users/wanggeng/Desktop/UploadFiles imageTypes: png,jpg,jpeg,gif,blob videoTypes: mp4,rmvb audioTypes: mp3,wmv diff --git a/src/main/resources/mybatis/mapper/system/group/group-mapper.xml b/src/main/resources/mybatis/mapper/system/group/group-mapper.xml index 4589bbc..9efcbcd 100644 --- a/src/main/resources/mybatis/mapper/system/group/group-mapper.xml +++ b/src/main/resources/mybatis/mapper/system/group/group-mapper.xml @@ -40,6 +40,11 @@ + + + + + INSERT INTO sys_role_group( @@ -324,4 +329,15 @@ + + + \ No newline at end of file