From 062963fbc02cb56b119c8c19fda7abb5450ab87c Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Mon, 12 Oct 2020 15:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90=EF=BC=8C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=AF=E5=8A=A8=E6=8A=A5=E9=94=99=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial/hrauth/config/WeChatConfig.java | 24 ++++----- .../controller/RolePermissionController.java | 52 +++++++++++++++++++ .../financial/hrauth/dao/PermissionDao.java | 21 ++++++++ .../hrauth/service/RolePermissionService.java | 23 ++++++++ .../impl/RolePermissionServiceImpl.java | 48 +++++++++++++++++ .../src/main/resources/bootstrap.properties | 6 +-- .../mapper/hrmsauth/PermissionDao.xml | 30 +++++++++++ dq-financial-hrms/pom.xml | 8 +-- .../financial/hrms/config/IPageConfig.java | 2 + .../hrms/controller/EmployeeController.java | 5 +- .../hrms/response/RolePermissionResponse.java | 27 ++++++++++ 11 files changed, 221 insertions(+), 25 deletions(-) create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/PermissionDao.java create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java create mode 100644 dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/PermissionDao.xml create mode 100644 dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/RolePermissionResponse.java diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java index d467eff5..a85d3cc6 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java @@ -2,29 +2,17 @@ package com.daqing.financial.hrauth.config; import lombok.Data; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; /** * 微信配置类 */ @Configuration -@PropertySource(value="classpath:bootstrap.properties") @Data public class WeChatConfig { - /** - * 公众号appid - */ - //@Value("${wxpay.appid}") - //private String appId; - - /** - * 公众号秘钥 - */ - //@Value("${wxpay.appsecret}") - //private String appsecret; - /** * 开放平台appid */ @@ -58,4 +46,12 @@ public class WeChatConfig { * 获取用户信息 */ private String OPEN_USER_INFO_URL ="https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN"; + + // 设置@Value注解取值不到忽略(不报错) + @Bean + public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() { + PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer(); + c.setIgnoreUnresolvablePlaceholders(true); + return c; + } } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java new file mode 100644 index 00000000..a01d419f --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java @@ -0,0 +1,52 @@ +package com.daqing.financial.hrauth.controller; + +import com.daqing.financial.hrauth.service.RolePermissionService; +import com.daqing.framework.domain.hrms.PermissionEntity; +import com.daqing.framework.model.response.ResponseResult; +import com.daqing.framework.utils.PageUtils; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * @auther River + * @date 2020/9/22 15:27 + */ +@RestController +@RequestMapping("/hrms/auth/permission") +@Api(tags = {"角色权限管理"}) +public class RolePermissionController { + + @Autowired + private RolePermissionService permissionService; + + /** + * 权限菜单树形列表展示 + * @return + */ + @GetMapping("/tree") + public ResponseResult tree() { + List list = permissionService.listWithTree(); + return new ResponseResult>().SUCCESS(list); + } + + /** + * 角色权限列表展示 + * @param page + * @param size + * @return + */ + @GetMapping("/rolePermissionList") + public ResponseResult rolePermissionList(@RequestParam("page") Integer page, + @RequestParam("size") Integer size) { + PageUtils data = permissionService.queryPage(page, size); + return new ResponseResult().SUCCESS(data); + } + +} diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/PermissionDao.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/PermissionDao.java new file mode 100644 index 00000000..a531126a --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/PermissionDao.java @@ -0,0 +1,21 @@ +package com.daqing.financial.hrauth.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.daqing.framework.domain.hrms.PermissionEntity; +import com.daqing.framework.domain.hrms.SystemLog; +import org.apache.ibatis.annotations.Mapper; + +/** + * 记录菜单权限 + * + * @author gongsj + * @email gongsj@gmail.com + * @date 2020-09-07 16:26:04 + */ +@Mapper +public interface PermissionDao extends BaseMapper { + IPage pageByCondition(Page page); + +} diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java new file mode 100644 index 00000000..1daecfdc --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java @@ -0,0 +1,23 @@ +package com.daqing.financial.hrauth.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.daqing.framework.domain.hrms.PermissionEntity; +import com.daqing.framework.utils.PageUtils; + +import java.util.List; + +/** + * 记录菜单权限 + * + * @author gongsj + * @email gongsj@gmail.com + * @date 2020-09-07 16:26:04 + */ +public interface RolePermissionService extends IService { + + List listWithTree(); + + PageUtils queryPage(Integer page, Integer size); + +} + diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java new file mode 100644 index 00000000..05adbeb7 --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java @@ -0,0 +1,48 @@ +package com.daqing.financial.hrauth.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.daqing.financial.hrauth.dao.PermissionDao; +import com.daqing.financial.hrauth.service.RolePermissionService; +import com.daqing.framework.domain.hrms.PermissionEntity; +import com.daqing.framework.domain.hrms.SystemLog; +import com.daqing.framework.utils.PageUtils; +import org.springframework.stereotype.Service; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + + +@Service("rolePermissionService") +public class RolePermissionServiceImpl extends ServiceImpl implements RolePermissionService { + + @Override + public List listWithTree() { + return getPermissionTreeList(this.list(), 0L); + } + + @Override + public PageUtils queryPage(Integer page, Integer size) { + //分页参数 + if (page <= 0) { + page = 1; + } + if (size <= 0) { + size = 10; + } + IPage systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size)); + + return new PageUtils(systemLogVo); + } + + private List getPermissionTreeList(List list, Long parentId) { + return list.stream() + .filter(item -> parentId.equals(item.getParentId())) + .peek(item -> item.setChildren(getPermissionTreeList(list, item.getId()))) + .sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) + .collect(Collectors.toList()); + } + +} \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/main/resources/bootstrap.properties b/dq-financial-hrms-auth/src/main/resources/bootstrap.properties index caddf3ab..c2f4dd2b 100644 --- a/dq-financial-hrms-auth/src/main/resources/bootstrap.properties +++ b/dq-financial-hrms-auth/src/main/resources/bootstrap.properties @@ -28,10 +28,10 @@ spring.redis.jedis.pool.max-idle=8 spring.redis.jedis.pool.min-idle=0 #微信开放平台配置 -wxopen.appid=wx3b7bca679da34921 -wxopen.appsecret=c8de113c18052b4e2173d913511e486d +#wxopen.appid=wx3b7bca679da34921 +#wxopen.appsecret=c8de113c18052b4e2173d913511e486d #回调地址 -wxopen.redirect_url=http://www.occupationlab.com/apiHrmsAuth/hrms/auth/userlogin/user/callback +#wxopen.redirect_url=http://www.occupationlab.com/apiHrmsAuth/hrms/auth/userlogin/user/callback # 正式环境(prod) #spring.application.name=dq-financial-hrms-auth diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/PermissionDao.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/PermissionDao.xml new file mode 100644 index 00000000..fb1ecb39 --- /dev/null +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/PermissionDao.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dq-financial-hrms/pom.xml b/dq-financial-hrms/pom.xml index 17b0e622..e65db31c 100644 --- a/dq-financial-hrms/pom.xml +++ b/dq-financial-hrms/pom.xml @@ -25,11 +25,11 @@ dq-framework-common 1.0-SNAPSHOT --> - +