From 80cf256e568750f61c3194fc80feff916ee31029 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 3 Feb 2023 17:12:57 +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 | 6 +-- .../xkrs/common/account/JwtLoginFilter.java | 2 +- .../xkrs/controller/SysUserController.java | 6 +-- .../com/xkrs/{ => straw}/dao/SysRoleDao.java | 14 +++--- .../java/com/xkrs/straw/dao/SysUserDao.java | 9 +--- .../model/entity/SysRoleEntity.java | 45 +++++++++---------- .../{ => straw}/service/SysRoleService.java | 6 +-- .../{ => straw}/service/SysUserService.java | 6 +-- .../service/impl/SysRoleServiceImpl.java | 13 +++--- .../service/impl/SysUserServiceImpl.java | 16 ++++--- 10 files changed, 56 insertions(+), 67 deletions(-) rename src/main/java/com/xkrs/{ => straw}/dao/SysRoleDao.java (86%) rename src/main/java/com/xkrs/{ => straw}/model/entity/SysRoleEntity.java (59%) rename src/main/java/com/xkrs/{ => straw}/service/SysRoleService.java (74%) rename src/main/java/com/xkrs/{ => straw}/service/SysUserService.java (98%) rename src/main/java/com/xkrs/{ => straw}/service/impl/SysRoleServiceImpl.java (56%) rename src/main/java/com/xkrs/{ => straw}/service/impl/SysUserServiceImpl.java (97%) diff --git a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java index 8ec7180..ea0f8f3 100644 --- a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java +++ b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java @@ -1,10 +1,10 @@ package com.xkrs.common.account; import com.xkrs.model.entity.SysAuthorityEntity; -import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.service.SysAuthorityService; -import com.xkrs.service.SysRoleService; -import com.xkrs.service.SysUserService; +import com.xkrs.straw.model.entity.SysUserEntity; +import com.xkrs.straw.service.SysRoleService; +import com.xkrs.straw.service.SysUserService; import com.xkrs.utils.DateTimeUtil; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.BadCredentialsException; diff --git a/src/main/java/com/xkrs/common/account/JwtLoginFilter.java b/src/main/java/com/xkrs/common/account/JwtLoginFilter.java index f70318c..8aa7b5c 100644 --- a/src/main/java/com/xkrs/common/account/JwtLoginFilter.java +++ b/src/main/java/com/xkrs/common/account/JwtLoginFilter.java @@ -3,7 +3,7 @@ package com.xkrs.common.account; import com.xkrs.common.encapsulation.OutputEncapsulation; import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.model.vo.SysUserVo; -import com.xkrs.service.SysUserService; +import com.xkrs.straw.service.SysUserService; import com.xkrs.utils.IpUtil; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.security.authentication.AuthenticationManager; diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 6e93afe..7587844 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -3,9 +3,7 @@ package com.xkrs.controller; import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.tool.TokenUtil; import com.xkrs.dao.AgentOrgDao; -import com.xkrs.straw.dao.SysUserDao; import com.xkrs.model.entity.AgentOrgEntity; -import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.model.qo.SysUserQo; import com.xkrs.model.qo.SysUserReceiveSmsQo; import com.xkrs.model.qo.SysUserRemarkQo; @@ -14,8 +12,10 @@ import com.xkrs.model.validation.SysUserQoInsert; import com.xkrs.model.validation.SysUserQoUpdate; import com.xkrs.model.vo.SysUserVo; import com.xkrs.service.RedisService; -import com.xkrs.service.SysUserService; import com.xkrs.sms.SMSHelper; +import com.xkrs.straw.dao.SysUserDao; +import com.xkrs.straw.model.entity.SysUserEntity; +import com.xkrs.straw.service.SysUserService; import com.xkrs.utils.FirePointCodeUtils; import com.xkrs.utils.ListUtils; import com.xkrs.utils.RandomUtil; diff --git a/src/main/java/com/xkrs/dao/SysRoleDao.java b/src/main/java/com/xkrs/straw/dao/SysRoleDao.java similarity index 86% rename from src/main/java/com/xkrs/dao/SysRoleDao.java rename to src/main/java/com/xkrs/straw/dao/SysRoleDao.java index 3424eb4..2fa9b43 100644 --- a/src/main/java/com/xkrs/dao/SysRoleDao.java +++ b/src/main/java/com/xkrs/straw/dao/SysRoleDao.java @@ -1,19 +1,17 @@ -package com.xkrs.dao; +package com.xkrs.straw.dao; -import com.xkrs.model.entity.SysRoleEntity; +import com.xkrs.straw.model.entity.SysRoleEntity; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Component; import java.util.List; -/** - * SysRoleDao - * - * @author tajochen - */ -public interface SysRoleDao extends JpaRepository { +@Component +public interface SysRoleDao extends JpaRepository, JpaSpecificationExecutor { /** * 查询用户角色列表根据用户id diff --git a/src/main/java/com/xkrs/straw/dao/SysUserDao.java b/src/main/java/com/xkrs/straw/dao/SysUserDao.java index 1bcd5ab..9d105ee 100644 --- a/src/main/java/com/xkrs/straw/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/straw/dao/SysUserDao.java @@ -1,7 +1,7 @@ package com.xkrs.straw.dao; -import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.model.vo.SysUserVo; +import com.xkrs.straw.model.entity.SysUserEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; @@ -10,11 +10,6 @@ import org.springframework.data.repository.query.Param; import java.util.List; -/** - * SysUserDao - * - * @author tajochen - */ public interface SysUserDao extends JpaRepository, JpaSpecificationExecutor { @Modifying(clearAutomatically = true) @@ -58,7 +53,7 @@ public interface SysUserDao extends JpaRepository, JpaSpeci */ @Modifying @Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true) - int softDeleteGeneralUserById(@Param("id") Long id); + void softDeleteGeneralUserById(@Param("id") Long id); /** * 删除系统用户(危险操作!) diff --git a/src/main/java/com/xkrs/model/entity/SysRoleEntity.java b/src/main/java/com/xkrs/straw/model/entity/SysRoleEntity.java similarity index 59% rename from src/main/java/com/xkrs/model/entity/SysRoleEntity.java rename to src/main/java/com/xkrs/straw/model/entity/SysRoleEntity.java index 32bd4c5..2fe7dfd 100644 --- a/src/main/java/com/xkrs/model/entity/SysRoleEntity.java +++ b/src/main/java/com/xkrs/straw/model/entity/SysRoleEntity.java @@ -1,14 +1,13 @@ -package com.xkrs.model.entity; +package com.xkrs.straw.model.entity; import javax.persistence.*; import java.io.Serializable; /** * SysRole 表实体类 - * @author tajochen */ @Entity -@Table(name="sys_role") +@Table(name = "sys_role") public class SysRoleEntity implements Serializable { /** @@ -16,10 +15,10 @@ public class SysRoleEntity implements Serializable { */ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_role_seq_gen") - @SequenceGenerator(name = "sys_role_seq_gen", sequenceName = "sys_role_id_seq",allocationSize = 1) - private Integer id; + @SequenceGenerator(name = "sys_role_seq_gen", sequenceName = "sys_role_id_seq", allocationSize = 1) + private Long id; - @Column(length = 32, nullable = false, unique = true,columnDefinition = "varchar(32)") + @Column(length = 32, nullable = false, unique = true, columnDefinition = "varchar(32)") private String roleName; @Column(length = 32, columnDefinition = "varchar(32)") @@ -28,11 +27,14 @@ public class SysRoleEntity implements Serializable { @Column(length = 64, columnDefinition = "varchar(64)") private String roleDesc; - public Integer getId() { + public SysRoleEntity() { + } + + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } @@ -41,15 +43,7 @@ public class SysRoleEntity implements Serializable { } public void setRoleName(String roleName) { - this.roleName = roleName == null ? null : roleName.trim(); - } - - public String getRoleDesc() { - return roleDesc; - } - - public void setRoleDesc(String roleDesc) { - this.roleDesc = roleDesc == null ? null : roleDesc.trim(); + this.roleName = roleName; } public String getRoleNameZh() { @@ -57,16 +51,19 @@ public class SysRoleEntity implements Serializable { } public void setRoleNameZh(String roleNameZh) { - this.roleNameZh = roleNameZh == null ? null : roleNameZh.trim(); + this.roleNameZh = roleNameZh; + } + + public String getRoleDesc() { + return roleDesc; + } + + public void setRoleDesc(String roleDesc) { + this.roleDesc = roleDesc; } @Override public String toString() { - return "SysRoleEntity{" + - "id=" + id + - ", roleName='" + roleName + '\'' + - ", roleNameZh='" + roleNameZh + '\'' + - ", roleDesc='" + roleDesc + '\'' + - '}'; + return "SysRoleEntity{" + "id=" + id + ", roleName='" + roleName + '\'' + ", roleNameZh='" + roleNameZh + '\'' + ", roleDesc='" + roleDesc + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/service/SysRoleService.java b/src/main/java/com/xkrs/straw/service/SysRoleService.java similarity index 74% rename from src/main/java/com/xkrs/service/SysRoleService.java rename to src/main/java/com/xkrs/straw/service/SysRoleService.java index b3149eb..2d03dca 100644 --- a/src/main/java/com/xkrs/service/SysRoleService.java +++ b/src/main/java/com/xkrs/straw/service/SysRoleService.java @@ -1,17 +1,17 @@ -package com.xkrs.service; +package com.xkrs.straw.service; -import com.xkrs.model.entity.SysRoleEntity; +import com.xkrs.straw.model.entity.SysRoleEntity; import java.util.List; /** * 系统角色服务接口 - * @author tajochen */ public interface SysRoleService { /** * 获取角色实体列表根据用户名 + * * @param userName * @return */ diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/straw/service/SysUserService.java similarity index 98% rename from src/main/java/com/xkrs/service/SysUserService.java rename to src/main/java/com/xkrs/straw/service/SysUserService.java index 03dacab..8b7f904 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/straw/service/SysUserService.java @@ -1,16 +1,14 @@ -package com.xkrs.service; +package com.xkrs.straw.service; -import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.model.qo.SysUserQo; import com.xkrs.model.vo.SysUserVo; +import com.xkrs.straw.model.entity.SysUserEntity; import javax.servlet.http.HttpServletRequest; import java.util.List; /** * 系统用户服务接口 - * - * @author tajochen */ public interface SysUserService { diff --git a/src/main/java/com/xkrs/service/impl/SysRoleServiceImpl.java b/src/main/java/com/xkrs/straw/service/impl/SysRoleServiceImpl.java similarity index 56% rename from src/main/java/com/xkrs/service/impl/SysRoleServiceImpl.java rename to src/main/java/com/xkrs/straw/service/impl/SysRoleServiceImpl.java index 59f430a..54b7698 100644 --- a/src/main/java/com/xkrs/service/impl/SysRoleServiceImpl.java +++ b/src/main/java/com/xkrs/straw/service/impl/SysRoleServiceImpl.java @@ -1,10 +1,8 @@ -package com.xkrs.service.impl; +package com.xkrs.straw.service.impl; -import com.xkrs.dao.SysRoleDao; -import com.xkrs.model.entity.SysRoleEntity; -import com.xkrs.service.SysRoleService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.xkrs.straw.dao.SysRoleDao; +import com.xkrs.straw.model.entity.SysRoleEntity; +import com.xkrs.straw.service.SysRoleService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -12,7 +10,6 @@ import java.util.List; /** * 系统角色服务实现 - * @author tajochen */ @Service public class SysRoleServiceImpl implements SysRoleService { @@ -22,6 +19,6 @@ public class SysRoleServiceImpl implements SysRoleService { @Override public List getSysRoleListByUserName(String userName) { - return sysRoleDao.selectByUserName(userName); + return sysRoleDao.selectByUserName(userName); } } diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java similarity index 97% rename from src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java rename to src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java index 4bca2d4..a31d796 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/straw/service/impl/SysUserServiceImpl.java @@ -1,14 +1,20 @@ -package com.xkrs.service.impl; +package com.xkrs.straw.service.impl; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.*; -import com.xkrs.model.entity.*; +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.service.SysUserService; +import com.xkrs.straw.dao.SysRoleDao; import com.xkrs.straw.dao.SysUserDao; +import com.xkrs.straw.model.entity.SysRoleEntity; import com.xkrs.straw.model.entity.SysUserEntity; +import com.xkrs.straw.service.SysUserService; import com.xkrs.utils.DateTimeUtil; import org.apache.http.util.TextUtils; import org.springframework.context.i18n.LocaleContextHolder; @@ -29,8 +35,6 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256; /** * 系统用户服务实现 - * - * @author tajochen */ @Service public class SysUserServiceImpl implements SysUserService {