diff --git a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java index ea0f8f3..7405795 100644 --- a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java +++ b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java @@ -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; diff --git a/src/main/java/com/xkrs/service/SysAuthorityService.java b/src/main/java/com/xkrs/service/SysAuthorityService.java index 7785eca..072b3f4 100644 --- a/src/main/java/com/xkrs/service/SysAuthorityService.java +++ b/src/main/java/com/xkrs/service/SysAuthorityService.java @@ -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; diff --git a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java index 34c74bf..0a31f0d 100644 --- a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java @@ -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; diff --git a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java b/src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java similarity index 91% rename from src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java rename to src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java index 637f0c1..b6f9592 100644 --- a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java +++ b/src/main/java/com/xkrs/straw/dao/RelRoleAuthorityDao.java @@ -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; diff --git a/src/main/java/com/xkrs/dao/RelUserRoleDao.java b/src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java similarity index 78% rename from src/main/java/com/xkrs/dao/RelUserRoleDao.java rename to src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java index ca164c4..413b078 100644 --- a/src/main/java/com/xkrs/dao/RelUserRoleDao.java +++ b/src/main/java/com/xkrs/straw/dao/RelUserRoleDao.java @@ -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; diff --git a/src/main/java/com/xkrs/dao/SysAuthorityDao.java b/src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java similarity index 56% rename from src/main/java/com/xkrs/dao/SysAuthorityDao.java rename to src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java index 34bcc6d..e7540d2 100644 --- a/src/main/java/com/xkrs/dao/SysAuthorityDao.java +++ b/src/main/java/com/xkrs/straw/dao/SysAuthorityDao.java @@ -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 { +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) + @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 */ diff --git a/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java b/src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java similarity index 97% rename from src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java rename to src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java index 78da329..99bca9c 100644 --- a/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/RelRoleAuthorityEntity.java @@ -1,4 +1,4 @@ -package com.xkrs.model.entity; +package com.xkrs.straw.model.entity; import javax.persistence.*; import java.io.Serializable; diff --git a/src/main/java/com/xkrs/model/entity/RelUserRoleEntity.java b/src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java similarity index 78% rename from src/main/java/com/xkrs/model/entity/RelUserRoleEntity.java rename to src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java index 2f77c81..a7399fb 100644 --- a/src/main/java/com/xkrs/model/entity/RelUserRoleEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/RelUserRoleEntity.java @@ -1,14 +1,15 @@ -package com.xkrs.model.entity; +package com.xkrs.straw.model.entity; import javax.persistence.*; import java.io.Serializable; /** * RelUserRole 表实体类 + * * @author tajochen */ @Entity -@Table(name="rel_user_role") +@Table(name = "rel_user_role") public class RelUserRoleEntity implements Serializable { /** @@ -16,7 +17,7 @@ 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) + @SequenceGenerator(name = "rel_user_role_seq_gen", sequenceName = "rel_user_role_id_seq", allocationSize = 1) private Integer id; @Column(nullable = false) @@ -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 + '}'; } } diff --git a/src/main/java/com/xkrs/model/entity/SysAuthorityEntity.java b/src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java similarity index 76% rename from src/main/java/com/xkrs/model/entity/SysAuthorityEntity.java rename to src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java index 080d0f6..d3eb157 100644 --- a/src/main/java/com/xkrs/model/entity/SysAuthorityEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/SysAuthorityEntity.java @@ -1,14 +1,15 @@ -package com.xkrs.model.entity; +package com.xkrs.straw.model.entity; import javax.persistence.*; import java.io.Serializable; /** * SysAuthority 表实体类 + * * @author tajochen */ @Entity -@Table(name="sys_authority") +@Table(name = "sys_authority") public class SysAuthorityEntity implements Serializable { /** @@ -16,10 +17,10 @@ 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) + @SequenceGenerator(name = "sys_authority_seq_gen", sequenceName = "sys_authority_id_seq", allocationSize = 1) private Integer id; - @Column(length = 64, nullable = false, unique = true,columnDefinition = "varchar(64)") + @Column(length = 64, nullable = false, unique = true, columnDefinition = "varchar(64)") private String authorityName; @Column(length = 64, columnDefinition = "varchar(64)") @@ -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 + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java index a31d796..f5fe1ef 100644 --- a/src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java @@ -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;