重构用户角色类

This commit is contained in:
liuchengqian 2023-02-03 17:12:57 +08:00
parent 5ba0da6326
commit 80cf256e56
10 changed files with 56 additions and 67 deletions

View File

@ -1,10 +1,10 @@
package com.xkrs.common.account; package com.xkrs.common.account;
import com.xkrs.model.entity.SysAuthorityEntity; import com.xkrs.model.entity.SysAuthorityEntity;
import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.service.SysAuthorityService; import com.xkrs.service.SysAuthorityService;
import com.xkrs.service.SysRoleService; import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.service.SysUserService; import com.xkrs.straw.service.SysRoleService;
import com.xkrs.straw.service.SysUserService;
import com.xkrs.utils.DateTimeUtil; import com.xkrs.utils.DateTimeUtil;
import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;

View File

@ -3,7 +3,7 @@ package com.xkrs.common.account;
import com.xkrs.common.encapsulation.OutputEncapsulation; import com.xkrs.common.encapsulation.OutputEncapsulation;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.model.vo.SysUserVo; import com.xkrs.model.vo.SysUserVo;
import com.xkrs.service.SysUserService; import com.xkrs.straw.service.SysUserService;
import com.xkrs.utils.IpUtil; import com.xkrs.utils.IpUtil;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;

View File

@ -3,9 +3,7 @@ package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tool.TokenUtil; import com.xkrs.common.tool.TokenUtil;
import com.xkrs.dao.AgentOrgDao; import com.xkrs.dao.AgentOrgDao;
import com.xkrs.straw.dao.SysUserDao;
import com.xkrs.model.entity.AgentOrgEntity; import com.xkrs.model.entity.AgentOrgEntity;
import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.model.qo.SysUserQo; import com.xkrs.model.qo.SysUserQo;
import com.xkrs.model.qo.SysUserReceiveSmsQo; import com.xkrs.model.qo.SysUserReceiveSmsQo;
import com.xkrs.model.qo.SysUserRemarkQo; 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.validation.SysUserQoUpdate;
import com.xkrs.model.vo.SysUserVo; import com.xkrs.model.vo.SysUserVo;
import com.xkrs.service.RedisService; import com.xkrs.service.RedisService;
import com.xkrs.service.SysUserService;
import com.xkrs.sms.SMSHelper; 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.FirePointCodeUtils;
import com.xkrs.utils.ListUtils; import com.xkrs.utils.ListUtils;
import com.xkrs.utils.RandomUtil; import com.xkrs.utils.RandomUtil;

View File

@ -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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
/** @Component
* SysRoleDao public interface SysRoleDao extends JpaRepository<SysRoleEntity, Long>, JpaSpecificationExecutor<SysRoleEntity> {
*
* @author tajochen
*/
public interface SysRoleDao extends JpaRepository<SysRoleEntity, Integer> {
/** /**
* 查询用户角色列表根据用户id * 查询用户角色列表根据用户id

View File

@ -1,7 +1,7 @@
package com.xkrs.straw.dao; package com.xkrs.straw.dao;
import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.model.vo.SysUserVo; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
@ -10,11 +10,6 @@ import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
/**
* SysUserDao
*
* @author tajochen
*/
public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpecificationExecutor<SysUserEntity> { public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpecificationExecutor<SysUserEntity> {
@Modifying(clearAutomatically = true) @Modifying(clearAutomatically = true)
@ -58,7 +53,7 @@ public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpeci
*/ */
@Modifying @Modifying
@Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true) @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);
/** /**
* 删除系统用户危险操作 * 删除系统用户危险操作

View File

@ -1,14 +1,13 @@
package com.xkrs.model.entity; package com.xkrs.straw.model.entity;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
/** /**
* SysRole 表实体类 * SysRole 表实体类
* @author tajochen
*/ */
@Entity @Entity
@Table(name="sys_role") @Table(name = "sys_role")
public class SysRoleEntity implements Serializable { public class SysRoleEntity implements Serializable {
/** /**
@ -16,10 +15,10 @@ public class SysRoleEntity implements Serializable {
*/ */
@Id @Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_role_seq_gen") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_role_seq_gen")
@SequenceGenerator(name = "sys_role_seq_gen", sequenceName = "sys_role_id_seq",allocationSize = 1) @SequenceGenerator(name = "sys_role_seq_gen", sequenceName = "sys_role_id_seq", allocationSize = 1)
private Integer id; 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; private String roleName;
@Column(length = 32, columnDefinition = "varchar(32)") @Column(length = 32, columnDefinition = "varchar(32)")
@ -28,11 +27,14 @@ public class SysRoleEntity implements Serializable {
@Column(length = 64, columnDefinition = "varchar(64)") @Column(length = 64, columnDefinition = "varchar(64)")
private String roleDesc; private String roleDesc;
public Integer getId() { public SysRoleEntity() {
}
public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
@ -41,15 +43,7 @@ public class SysRoleEntity implements Serializable {
} }
public void setRoleName(String roleName) { public void setRoleName(String roleName) {
this.roleName = roleName == null ? null : roleName.trim(); this.roleName = roleName;
}
public String getRoleDesc() {
return roleDesc;
}
public void setRoleDesc(String roleDesc) {
this.roleDesc = roleDesc == null ? null : roleDesc.trim();
} }
public String getRoleNameZh() { public String getRoleNameZh() {
@ -57,16 +51,19 @@ public class SysRoleEntity implements Serializable {
} }
public void setRoleNameZh(String roleNameZh) { 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 @Override
public String toString() { public String toString() {
return "SysRoleEntity{" + return "SysRoleEntity{" + "id=" + id + ", roleName='" + roleName + '\'' + ", roleNameZh='" + roleNameZh + '\'' + ", roleDesc='" + roleDesc + '\'' + '}';
"id=" + id +
", roleName='" + roleName + '\'' +
", roleNameZh='" + roleNameZh + '\'' +
", roleDesc='" + roleDesc + '\'' +
'}';
} }
} }

View File

@ -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; import java.util.List;
/** /**
* 系统角色服务接口 * 系统角色服务接口
* @author tajochen
*/ */
public interface SysRoleService { public interface SysRoleService {
/** /**
* 获取角色实体列表根据用户名 * 获取角色实体列表根据用户名
*
* @param userName * @param userName
* @return * @return
*/ */

View File

@ -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.qo.SysUserQo;
import com.xkrs.model.vo.SysUserVo; import com.xkrs.model.vo.SysUserVo;
import com.xkrs.straw.model.entity.SysUserEntity;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
/** /**
* 系统用户服务接口 * 系统用户服务接口
*
* @author tajochen
*/ */
public interface SysUserService { public interface SysUserService {

View File

@ -1,10 +1,8 @@
package com.xkrs.service.impl; package com.xkrs.straw.service.impl;
import com.xkrs.dao.SysRoleDao; import com.xkrs.straw.dao.SysRoleDao;
import com.xkrs.model.entity.SysRoleEntity; import com.xkrs.straw.model.entity.SysRoleEntity;
import com.xkrs.service.SysRoleService; import com.xkrs.straw.service.SysRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -12,7 +10,6 @@ import java.util.List;
/** /**
* 系统角色服务实现 * 系统角色服务实现
* @author tajochen
*/ */
@Service @Service
public class SysRoleServiceImpl implements SysRoleService { public class SysRoleServiceImpl implements SysRoleService {

View File

@ -1,14 +1,20 @@
package com.xkrs.service.impl; package com.xkrs.straw.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.*; import com.xkrs.dao.RelRoleAuthorityDao;
import com.xkrs.model.entity.*; 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.qo.SysUserQo;
import com.xkrs.model.vo.SysUserVo; import com.xkrs.model.vo.SysUserVo;
import com.xkrs.service.RedisService; 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.dao.SysUserDao;
import com.xkrs.straw.model.entity.SysRoleEntity;
import com.xkrs.straw.model.entity.SysUserEntity; import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.straw.service.SysUserService;
import com.xkrs.utils.DateTimeUtil; import com.xkrs.utils.DateTimeUtil;
import org.apache.http.util.TextUtils; import org.apache.http.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
@ -29,8 +35,6 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256;
/** /**
* 系统用户服务实现 * 系统用户服务实现
*
* @author tajochen
*/ */
@Service @Service
public class SysUserServiceImpl implements SysUserService { public class SysUserServiceImpl implements SysUserService {