From 85e6dbf06fb076bf99ee732d7a4754fd55d0c4c0 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Mon, 6 Feb 2023 09:51:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=94=A8=E6=88=B7=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/CustomAuthenticationProvider.java | 4 +-- .../com/xkrs/service/SysAuthorityService.java | 4 +-- .../service/impl/SysAuthorityServiceImpl.java | 4 +-- .../xkrs/straw/dao/RelRoleAuthorityDao.java | 11 +------- .../com/xkrs/straw/dao/RelUserRoleDao.java | 3 --- .../com/xkrs/straw/dao/SysAuthorityDao.java | 10 ++----- .../model/entity/RelRoleAuthorityEntity.java | 25 ++++++++++------- .../straw/model/entity/RelUserRoleEntity.java | 26 +++++++++--------- .../model/entity/SysAuthorityEntity.java | 27 ++++++++++--------- 9 files changed, 53 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java index 7405795..728d767 100644 --- a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java +++ b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java @@ -88,8 +88,8 @@ public class CustomAuthenticationProvider implements AuthenticationProvider { if (encryptPassword.equals(userEntity.getPassword())) { // 设置权限列表 ArrayList permissions = new ArrayList<>(); - List integers = customAuthenticationProvider.sysAuthorityService.selectAuthorityByUserId(userEntity.getId()); - List permissionList = customAuthenticationProvider.sysAuthorityService.findAllByIdIn(integers); + List longs = customAuthenticationProvider.sysAuthorityService.selectAuthorityByUserId(userEntity.getId()); + List permissionList = customAuthenticationProvider.sysAuthorityService.findAllByIdIn(longs); for (SysAuthorityEntity sysAuthorityEntity : permissionList) { permissions.add(new GrantedAuthorityImpl(sysAuthorityEntity.getAuthorityName())); } diff --git a/src/main/java/com/xkrs/service/SysAuthorityService.java b/src/main/java/com/xkrs/service/SysAuthorityService.java index 072b3f4..55a3257 100644 --- a/src/main/java/com/xkrs/service/SysAuthorityService.java +++ b/src/main/java/com/xkrs/service/SysAuthorityService.java @@ -19,7 +19,7 @@ public interface SysAuthorityService { */ List getSysAuthorityListByUserName(String userName); - List findAllByIdIn(List id); + List findAllByIdIn(List id); - List selectAuthorityByUserId(Long userId); + List selectAuthorityByUserId(Long userId); } diff --git a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java index 0a31f0d..8b9d060 100644 --- a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java @@ -29,12 +29,12 @@ public class SysAuthorityServiceImpl implements SysAuthorityService { } @Override - public List findAllByIdIn(List id) { + public List findAllByIdIn(List id) { return sysAuthorityDao.findAllByIdIn(id); } @Override - public List selectAuthorityByUserId(Long userId) { + public List selectAuthorityByUserId(Long userId) { return relRoleAuthorityDao.selectAuthorityByUserId(userId); } } diff --git a/src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java b/src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java index b6f9592..ed2bd71 100644 --- a/src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java +++ b/src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java @@ -8,21 +8,12 @@ import org.springframework.data.repository.query.Param; import java.util.List; -/** - * @author XinYi Song - */ public interface RelRoleAuthorityDao extends JpaRepository, JpaSpecificationExecutor { /** * 根据userId查询出权限的id - * - * @param userId - * @return */ @Query(value = "select authority_id from rel_role_authority where user_id = ?", nativeQuery = true) - List selectAuthorityByUserId(@Param("userId") Long userId); - - @Query(value = "SELECT * FROM rel_role_authority WHERE authority_id = ?1", nativeQuery = true) - List selectByAuthorityId(Integer authorityId); + List selectAuthorityByUserId(@Param("userId") Long userId); } diff --git a/src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java b/src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java index 413b078..7d753c9 100644 --- a/src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java +++ b/src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java @@ -4,9 +4,6 @@ import com.xkrs.straw.model.entity.RelUserRoleEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -/** - * @author XinYi Song - */ public interface RelUserRoleDao extends JpaRepository, JpaSpecificationExecutor { } diff --git a/src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java b/src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java index e7540d2..fdf67f1 100644 --- a/src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java +++ b/src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java @@ -8,22 +8,16 @@ import org.springframework.data.repository.query.Param; import java.util.List; -public interface SysAuthorityDao extends JpaRepository, JpaSpecificationExecutor { +public interface SysAuthorityDao extends JpaRepository, JpaSpecificationExecutor { /** * 查询权限实体列表根据用户名 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) List selectByUserName(@Param("userName") String userName); /** * 根据id批量查询权限信息 - * - * @param id - * @return */ - List findAllByIdIn(List id); + List findAllByIdIn(List id); } diff --git a/src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java b/src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java index 99bca9c..342d8df 100644 --- a/src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java @@ -18,40 +18,40 @@ public class RelRoleAuthorityEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rel_role_authority_seq_gen") @SequenceGenerator(name = "rel_role_authority_seq_gen", sequenceName = "rel_role_authority_id_seq", allocationSize = 1) - private Integer id; + private Long id; @Column(nullable = false) - private Integer roleId; + private Long roleId; @Column(nullable = false) - private Integer authorityId; + private Long authorityId; private Long userId; public RelRoleAuthorityEntity() { } - public Integer getId() { + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } - public Integer getRoleId() { + public Long getRoleId() { return roleId; } - public void setRoleId(Integer roleId) { + public void setRoleId(Long roleId) { this.roleId = roleId; } - public Integer getAuthorityId() { + public Long getAuthorityId() { return authorityId; } - public void setAuthorityId(Integer authorityId) { + public void setAuthorityId(Long authorityId) { this.authorityId = authorityId; } @@ -65,6 +65,11 @@ public class RelRoleAuthorityEntity implements Serializable { @Override public String toString() { - return "RelRoleAuthorityEntity{" + "id=" + id + ", roleId=" + roleId + ", authorityId=" + authorityId + ", userId=" + userId + '}'; + return "RelRoleAuthorityEntity{" + + "id=" + id + + ", roleId=" + roleId + + ", authorityId=" + authorityId + + ", userId=" + userId + + '}'; } } diff --git a/src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java b/src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java index a7399fb..2727676 100644 --- a/src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java @@ -3,11 +3,6 @@ package com.xkrs.straw.model.entity; import javax.persistence.*; import java.io.Serializable; -/** - * RelUserRole 表实体类 - * - * @author tajochen - */ @Entity @Table(name = "rel_user_role") public class RelUserRoleEntity implements Serializable { @@ -18,19 +13,22 @@ public class RelUserRoleEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rel_user_role_seq_gen") @SequenceGenerator(name = "rel_user_role_seq_gen", sequenceName = "rel_user_role_id_seq", allocationSize = 1) - private Integer id; + private Long id; @Column(nullable = false) private Long userId; @Column(nullable = false) - private Integer roleId; + private Long roleId; - public Integer getId() { + public RelUserRoleEntity() { + } + + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } @@ -42,16 +40,20 @@ public class RelUserRoleEntity implements Serializable { this.userId = userId; } - public Integer getRoleId() { + public Long getRoleId() { return roleId; } - public void setRoleId(Integer roleId) { + public void setRoleId(Long roleId) { this.roleId = roleId; } @Override public String toString() { - return "RelUserRoleEntity{" + "id=" + id + ", userId=" + userId + ", roleId=" + roleId + '}'; + return "RelUserRoleEntity{" + + "id=" + id + + ", userId=" + userId + + ", roleId=" + roleId + + '}'; } } diff --git a/src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java b/src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java index d3eb157..4a81f44 100644 --- a/src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java @@ -3,11 +3,6 @@ package com.xkrs.straw.model.entity; import javax.persistence.*; import java.io.Serializable; -/** - * SysAuthority 表实体类 - * - * @author tajochen - */ @Entity @Table(name = "sys_authority") public class SysAuthorityEntity implements Serializable { @@ -18,7 +13,7 @@ public class SysAuthorityEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_authority_seq_gen") @SequenceGenerator(name = "sys_authority_seq_gen", sequenceName = "sys_authority_id_seq", allocationSize = 1) - private Integer id; + private Long id; @Column(length = 64, nullable = false, unique = true, columnDefinition = "varchar(64)") private String authorityName; @@ -29,11 +24,14 @@ public class SysAuthorityEntity implements Serializable { @Column(length = 128, columnDefinition = "varchar(128)") private String authorityDesc; - public Integer getId() { + public SysAuthorityEntity() { + } + + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } @@ -42,7 +40,7 @@ public class SysAuthorityEntity implements Serializable { } public void setAuthorityName(String authorityName) { - this.authorityName = authorityName == null ? null : authorityName.trim(); + this.authorityName = authorityName; } public String getAuthorityNameZh() { @@ -50,7 +48,7 @@ public class SysAuthorityEntity implements Serializable { } public void setAuthorityNameZh(String authorityNameZh) { - this.authorityNameZh = authorityNameZh == null ? null : authorityNameZh.trim(); + this.authorityNameZh = authorityNameZh; } public String getAuthorityDesc() { @@ -58,11 +56,16 @@ public class SysAuthorityEntity implements Serializable { } public void setAuthorityDesc(String authorityDesc) { - this.authorityDesc = authorityDesc == null ? null : authorityDesc.trim(); + this.authorityDesc = authorityDesc; } @Override public String toString() { - return "SysAuthorityEntity{" + "id=" + id + ", authorityName='" + authorityName + '\'' + ", authorityDesc='" + authorityDesc + '\'' + ", authorityNameZh='" + authorityNameZh + '\'' + '}'; + return "SysAuthorityEntity{" + + "id=" + id + + ", authorityName='" + authorityName + '\'' + + ", authorityNameZh='" + authorityNameZh + '\'' + + ", authorityDesc='" + authorityDesc + '\'' + + '}'; } }