重构用户角色类
This commit is contained in:
parent
80cf256e56
commit
acd127babd
@ -1,7 +1,7 @@
|
||||
package com.xkrs.common.account;
|
||||
|
||||
import com.xkrs.model.entity.SysAuthorityEntity;
|
||||
import com.xkrs.service.SysAuthorityService;
|
||||
import com.xkrs.straw.model.entity.SysAuthorityEntity;
|
||||
import com.xkrs.straw.model.entity.SysUserEntity;
|
||||
import com.xkrs.straw.service.SysRoleService;
|
||||
import com.xkrs.straw.service.SysUserService;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.xkrs.service;
|
||||
|
||||
import com.xkrs.model.entity.SysAuthorityEntity;
|
||||
import com.xkrs.straw.model.entity.SysAuthorityEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.xkrs.service.impl;
|
||||
|
||||
import com.xkrs.dao.RelRoleAuthorityDao;
|
||||
import com.xkrs.dao.SysAuthorityDao;
|
||||
import com.xkrs.model.entity.SysAuthorityEntity;
|
||||
import com.xkrs.service.SysAuthorityService;
|
||||
import com.xkrs.straw.dao.RelRoleAuthorityDao;
|
||||
import com.xkrs.straw.dao.SysAuthorityDao;
|
||||
import com.xkrs.straw.model.entity.SysAuthorityEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.xkrs.dao;
|
||||
package com.xkrs.straw.dao;
|
||||
|
||||
import com.xkrs.model.entity.RelRoleAuthorityEntity;
|
||||
import com.xkrs.straw.model.entity.RelRoleAuthorityEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
@ -1,6 +1,6 @@
|
||||
package com.xkrs.dao;
|
||||
package com.xkrs.straw.dao;
|
||||
|
||||
import com.xkrs.model.entity.RelUserRoleEntity;
|
||||
import com.xkrs.straw.model.entity.RelUserRoleEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
@ -1,30 +1,27 @@
|
||||
package com.xkrs.dao;
|
||||
package com.xkrs.straw.dao;
|
||||
|
||||
import com.xkrs.model.entity.SysAuthorityEntity;
|
||||
import com.xkrs.straw.model.entity.SysAuthorityEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SysAuthorityDao
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface SysAuthorityDao extends JpaRepository<SysAuthorityEntity,Integer> {
|
||||
public interface SysAuthorityDao extends JpaRepository<SysAuthorityEntity, Integer>, JpaSpecificationExecutor<SysAuthorityEntity> {
|
||||
|
||||
/**
|
||||
* 查询权限实体列表根据用户名 Object[]
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户实体
|
||||
*/
|
||||
@Query(value = "SELECT a.id, a.authority_name, a.authority_name_zh, a.authority_desc " +
|
||||
"FROM sys_authority a,rel_role_authority ra,sys_role r WHERE r.id = ra.role_id AND ra.authority_id = a.id AND r.id " +
|
||||
"IN (SELECT r.id FROM sys_user u,sys_role r,rel_user_role ur " +
|
||||
" WHERE u.user_name = :userName AND u.id = ur.user_id AND ur.role_id = r.id)", nativeQuery = true)
|
||||
@Query(value = "SELECT a.id, a.authority_name, a.authority_name_zh, a.authority_desc FROM sys_authority a,rel_role_authority ra,sys_role r WHERE r.id = ra.role_id AND ra.authority_id = a.id AND r.id IN (SELECT r.id FROM sys_user u,sys_role r,rel_user_role ur WHERE u.user_name = :userName AND u.id = ur.user_id AND ur.role_id = r.id)", nativeQuery = true)
|
||||
List<SysAuthorityEntity> selectByUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 根据id批量查询权限信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.xkrs.model.entity;
|
||||
package com.xkrs.straw.model.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
@ -1,10 +1,11 @@
|
||||
package com.xkrs.model.entity;
|
||||
package com.xkrs.straw.model.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* RelUserRole 表实体类
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
@Entity
|
||||
@ -51,10 +52,6 @@ public class RelUserRoleEntity implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RelUserRoleEntity{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", roleId=" + roleId +
|
||||
'}';
|
||||
return "RelUserRoleEntity{" + "id=" + id + ", userId=" + userId + ", roleId=" + roleId + '}';
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package com.xkrs.model.entity;
|
||||
package com.xkrs.straw.model.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SysAuthority 表实体类
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
@Entity
|
||||
@ -62,11 +63,6 @@ public class SysAuthorityEntity implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysAuthorityEntity{" +
|
||||
"id=" + id +
|
||||
", authorityName='" + authorityName + '\'' +
|
||||
", authorityDesc='" + authorityDesc + '\'' +
|
||||
", authorityNameZh='" + authorityNameZh + '\'' +
|
||||
'}';
|
||||
return "SysAuthorityEntity{" + "id=" + id + ", authorityName='" + authorityName + '\'' + ", authorityDesc='" + authorityDesc + '\'' + ", authorityNameZh='" + authorityNameZh + '\'' + '}';
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package com.xkrs.straw.service.impl;
|
||||
|
||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.dao.RelRoleAuthorityDao;
|
||||
import com.xkrs.dao.RelUserRoleDao;
|
||||
import com.xkrs.dao.StreetDao;
|
||||
import com.xkrs.model.entity.RelRoleAuthorityEntity;
|
||||
import com.xkrs.model.entity.RelUserRoleEntity;
|
||||
import com.xkrs.model.entity.StreetEntity;
|
||||
import com.xkrs.model.qo.SysUserQo;
|
||||
import com.xkrs.model.vo.SysUserVo;
|
||||
import com.xkrs.service.RedisService;
|
||||
import com.xkrs.straw.dao.RelRoleAuthorityDao;
|
||||
import com.xkrs.straw.dao.RelUserRoleDao;
|
||||
import com.xkrs.straw.dao.SysRoleDao;
|
||||
import com.xkrs.straw.dao.SysUserDao;
|
||||
import com.xkrs.straw.model.entity.RelRoleAuthorityEntity;
|
||||
import com.xkrs.straw.model.entity.RelUserRoleEntity;
|
||||
import com.xkrs.straw.model.entity.SysRoleEntity;
|
||||
import com.xkrs.straw.model.entity.SysUserEntity;
|
||||
import com.xkrs.straw.service.SysUserService;
|
||||
|
Loading…
Reference in New Issue
Block a user