角色权限,项目启动报错处理

master
shijie 4 years ago
parent bf25ec2de9
commit 062963fbc0
  1. 24
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java
  2. 52
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java
  3. 21
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/PermissionDao.java
  4. 23
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/RolePermissionService.java
  5. 48
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/RolePermissionServiceImpl.java
  6. 6
      dq-financial-hrms-auth/src/main/resources/bootstrap.properties
  7. 30
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/PermissionDao.xml
  8. 8
      dq-financial-hrms/pom.xml
  9. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/config/IPageConfig.java
  10. 5
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java
  11. 27
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/RolePermissionResponse.java

@ -2,29 +2,17 @@ package com.daqing.financial.hrauth.config;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
/** /**
* 微信配置类 * 微信配置类
*/ */
@Configuration @Configuration
@PropertySource(value="classpath:bootstrap.properties")
@Data @Data
public class WeChatConfig { public class WeChatConfig {
/**
* 公众号appid
*/
//@Value("${wxpay.appid}")
//private String appId;
/**
* 公众号秘钥
*/
//@Value("${wxpay.appsecret}")
//private String appsecret;
/** /**
* 开放平台appid * 开放平台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"; 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;
}
} }

@ -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<PermissionEntity> list = permissionService.listWithTree();
return new ResponseResult<List<PermissionEntity>>().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<PageUtils>().SUCCESS(data);
}
}

@ -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<PermissionEntity> {
IPage<PermissionEntity> pageByCondition(Page page);
}

@ -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<PermissionEntity> {
List<PermissionEntity> listWithTree();
PageUtils queryPage(Integer page, Integer size);
}

@ -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<PermissionDao, PermissionEntity> implements RolePermissionService {
@Override
public List<PermissionEntity> 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<PermissionEntity> systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size));
return new PageUtils(systemLogVo);
}
private List<PermissionEntity> getPermissionTreeList(List<PermissionEntity> 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());
}
}

@ -28,10 +28,10 @@ spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
#微信开放平台配置 #微信开放平台配置
wxopen.appid=wx3b7bca679da34921 #wxopen.appid=wx3b7bca679da34921
wxopen.appsecret=c8de113c18052b4e2173d913511e486d #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) # 正式环境(prod)
#spring.application.name=dq-financial-hrms-auth #spring.application.name=dq-financial-hrms-auth

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.hrauth.dao.PermissionDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.PermissionEntity" id="permissionMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="url" column="url"/>
<result property="parentId" column="parent_id"/>
<result property="level" column="level"/>
<result property="menuOrNot" column="menu_or_not"/>
<result property="status" column="status"/>
<result property="sort" column="sort"/>
<result property="icon" column="icon"/>
<result property="createTime" column="create_time"/>
<result property="motifyTime" column="motify_time"/>
</resultMap>
<select id="pageByCondition" resultType="com.daqing.framework.domain.hrms.PermissionEntity">
select hr.`name`,hr.description,GROUP_CONCAT(hp.`name`separator '/')
FROM hrms_role_permission rp
LEFT JOIN hrms_role hr on hr.id = rp.role_id
LEFT JOIN hrms_permission hp on hp.id= rp.permission_id
GROUP BY rp.role_id
</select>
</mapper>

@ -25,11 +25,11 @@
<artifactId>dq-framework-common</artifactId> <artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency>--> </dependency>-->
<dependency> <!--<dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId> <artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>-->
<!-- <dependency> <!-- <dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-utils</artifactId> <artifactId>dq-framework-utils</artifactId>
@ -50,7 +50,7 @@
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
@ -60,7 +60,7 @@
<artifactId>junit-vintage-engine</artifactId> <artifactId>junit-vintage-engine</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>-->
<!-- <dependency> <!-- <dependency>
<groupId>org.springframework.security.oauth</groupId> <groupId>org.springframework.security.oauth</groupId>

@ -1,3 +1,4 @@
/*
package com.daqing.financial.hrms.config; package com.daqing.financial.hrms.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
@ -11,3 +12,4 @@ public class IPageConfig {
return new PaginationInterceptor(); return new PaginationInterceptor();
} }
} }
*/

@ -1,8 +1,5 @@
package com.daqing.financial.hrms.controller; package com.daqing.financial.hrms.controller;
import com.daqing.financial.hrauth.annotation.Log;
import com.daqing.financial.hrauth.enums.OperationType;
import com.daqing.financial.hrauth.enums.OperationUnit;
import com.daqing.financial.hrms.EmployeeControllerApi; import com.daqing.financial.hrms.EmployeeControllerApi;
import com.daqing.financial.hrms.service.EmployeeService; import com.daqing.financial.hrms.service.EmployeeService;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
@ -33,7 +30,7 @@ public class EmployeeController implements EmployeeControllerApi {
private EmployeeService employeeService; private EmployeeService employeeService;
@GetMapping("/list") @GetMapping("/list")
@Log(detail = "员工列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.INSERT) //@Log(detail = "员工列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.INSERT)
//@RequiresPermissions("hrms:employee:info") //@RequiresPermissions("hrms:employee:info")
public ResponseResult list(@RequestParam("page") Integer page, public ResponseResult list(@RequestParam("page") Integer page,
@RequestParam("size") Integer size, @RequestParam("size") Integer size,

@ -0,0 +1,27 @@
package com.daqing.framework.domain.hrms.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 记录菜单权限
*
* @author gongsj
* @email gongsj@gmail.com
* @date 2020-09-07 17:12:14
*/
@Data
@TableName("hrms_permission")
public class RolePermissionResponse implements Serializable {
private static final long serialVersionUID = 1L;
}
Loading…
Cancel
Save