Browse Source

init: init project step4: biz code support

shc 1 year ago
parent
commit
80bafeb5be

+ 74 - 60
hnqz-auth/src/main/java/com/qunzhixinxi/hnqz/auth/service/HnqzUserDetailsServiceImpl.java

@@ -1,4 +1,3 @@
-
 package com.qunzhixinxi.hnqz.auth.service;
 package com.qunzhixinxi.hnqz.auth.service;
 
 
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ArrayUtil;
@@ -38,73 +37,88 @@ import java.util.Set;
 @AllArgsConstructor
 @AllArgsConstructor
 public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
 public class HnqzUserDetailsServiceImpl implements HnqzUserDetailsService {
 
 
-	private final RemoteUserService remoteUserService;
+    private final RemoteUserService remoteUserService;
 
 
-	private final CacheManager cacheManager;
+    private final CacheManager cacheManager;
 
 
-	/**
-	 * 用户密码登录
-	 *
-	 * @param username 用户名
-	 * @return
-	 * @throws UsernameNotFoundException
-	 */
-	@Override
-	@SneakyThrows
-	public UserDetails loadUserByUsername(String username) {
-		String u1 = username.endsWith("@mp") ? username.split("@")[0] : username;
+    /**
+     * 用户密码登录
+     *
+     * @param username 用户名
+     * @return
+     * @throws UsernameNotFoundException
+     */
+    @Override
+    @SneakyThrows
+    public UserDetails loadUserByUsername(String username) {
+        String u1 = username.endsWith("@mp") ? username.split("@")[0] : username;
 
 
-		Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
-		if (cache != null && cache.get(u1) != null) {
-			return (HnqzUser) cache.get(u1).get();
-		}
+        Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
+        if (cache != null && cache.get(u1) != null) {
+            return (HnqzUser) cache.get(u1).get();
+        }
 
 
-		R<UserInfo> result = remoteUserService.info(username, SecurityConstants.FROM_IN);
-		UserDetails userDetails = getUserDetails(result);
-		cache.put(username, userDetails);
-		return userDetails;
-	}
+        R<UserInfo> result = remoteUserService.info(username, SecurityConstants.FROM_IN);
+        UserDetails userDetails = getUserDetails(result);
+        cache.put(username, userDetails);
+        return userDetails;
+    }
 
 
-	/**
-	 * 根据社交登录code 登录
-	 * @param inStr TYPE@CODE
-	 * @return UserDetails
-	 * @throws UsernameNotFoundException
-	 */
-	@Override
-	@SneakyThrows
-	public UserDetails loadUserBySocial(String inStr) {
-		return getUserDetails(remoteUserService.social(inStr, SecurityConstants.FROM_IN));
-	}
+    /**
+     * 根据社交登录code 登录
+     *
+     * @param inStr TYPE@CODE
+     * @return UserDetails
+     * @throws UsernameNotFoundException
+     */
+    @Override
+    @SneakyThrows
+    public UserDetails loadUserBySocial(String inStr) {
+        return getUserDetails(remoteUserService.social(inStr, SecurityConstants.FROM_IN));
+    }
 
 
-	/**
-	 * 构建userdetails
-	 * @param result 用户信息
-	 * @return
-	 */
-	private UserDetails getUserDetails(R<UserInfo> result) {
-		if (result == null || result.getData() == null) {
-			throw new UsernameNotFoundException("用户不存在");
-		}
+    /**
+     * 构建userdetails
+     *
+     * @param result 用户信息
+     * @return
+     */
+    private UserDetails getUserDetails(R<UserInfo> result) {
+        if (result == null || result.getData() == null) {
+            throw new UsernameNotFoundException("用户不存在");
+        }
 
 
-		UserInfo info = result.getData();
-		Set<String> dbAuthsSet = new HashSet<>();
-		if (ArrayUtil.isNotEmpty(info.getRoles())) {
-			// 获取角色
-			Arrays.stream(info.getRoles()).forEach(roleId -> dbAuthsSet.add(SecurityConstants.ROLE + roleId));
-			// 获取资源
-			dbAuthsSet.addAll(Arrays.asList(info.getPermissions()));
+        UserInfo info = result.getData();
+        Set<String> dbAuthsSet = new HashSet<>();
+        if (ArrayUtil.isNotEmpty(info.getRoles())) {
+            // 获取角色
+            Arrays.stream(info.getRoles()).forEach(roleId -> dbAuthsSet.add(SecurityConstants.ROLE + roleId));
+            // 获取资源
+            dbAuthsSet.addAll(Arrays.asList(info.getPermissions()));
 
 
-		}
-		Collection<? extends GrantedAuthority> authorities = AuthorityUtils
-				.createAuthorityList(dbAuthsSet.toArray(new String[0]));
-		SysUser user = info.getSysUser();
-		boolean enabled = StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL);
-		// 构造security用户
+        }
+        Collection<? extends GrantedAuthority> authorities = AuthorityUtils
+                .createAuthorityList(dbAuthsSet.toArray(new String[0]));
+        SysUser user = info.getSysUser();
+        boolean enabled = StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL);
+        // 构造security用户
 
 
-		return new HnqzUser(user.getUserId(), user.getDeptId(), user.getPhone(), user.getAvatar(), user.getTenantId(),
-				user.getUsername(), SecurityConstants.BCRYPT + user.getPassword(), enabled, true, true,
-				!CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities,user.getPlatId(),user.getDrugEntId(),info.getRoles());
-	}
+        return new HnqzUser(user.getUserId(),
+                user.getDeptId(),
+                user.getPhone(),
+                user.getAvatar(),
+                user.getTenantId(),
+                user.getUsername(),
+                SecurityConstants.BCRYPT + user.getPassword(),
+                enabled,
+                true,
+                true,
+                !CommonConstants.STATUS_LOCK.equals(user.getLockFlag()),
+                authorities,
+                user.getPlatId(),
+                user.getDrugEntId(),
+                info.getRoles(),
+                user.getRealname());
+    }
 
 
 }
 }

+ 3 - 1
hnqz-common/hnqz-common-security/src/main/java/com/qunzhixinxi/hnqz/common/security/component/HnqzUserAuthenticationConverter.java

@@ -66,6 +66,7 @@ public class HnqzUserAuthenticationConverter implements UserAuthenticationConver
             Map<String, ?> map = MapUtil.get(responseMap, SecurityConstants.DETAILS_USER, Map.class);
             Map<String, ?> map = MapUtil.get(responseMap, SecurityConstants.DETAILS_USER, Map.class);
             validateTenantId(map);
             validateTenantId(map);
             String username = MapUtil.getStr(map, SecurityConstants.DETAILS_USERNAME);
             String username = MapUtil.getStr(map, SecurityConstants.DETAILS_USERNAME);
+            String realName = MapUtil.getStr(map, "realname");
             Integer id = MapUtil.getInt(map, SecurityConstants.DETAILS_USER_ID);
             Integer id = MapUtil.getInt(map, SecurityConstants.DETAILS_USER_ID);
             Integer deptId = MapUtil.getInt(map, SecurityConstants.DETAILS_DEPT_ID);
             Integer deptId = MapUtil.getInt(map, SecurityConstants.DETAILS_DEPT_ID);
             Integer tenantId = MapUtil.getInt(map, SecurityConstants.DETAILS_TENANT_ID);
             Integer tenantId = MapUtil.getInt(map, SecurityConstants.DETAILS_TENANT_ID);
@@ -74,8 +75,9 @@ public class HnqzUserAuthenticationConverter implements UserAuthenticationConver
             String platId = MapUtil.getStr(map, SecurityConstants.USERINFO_PLAT_ID);
             String platId = MapUtil.getStr(map, SecurityConstants.USERINFO_PLAT_ID);
             Integer drugEntId = MapUtil.getInt(map, SecurityConstants.USERINFO_DRUG_ENT_ID);
             Integer drugEntId = MapUtil.getInt(map, SecurityConstants.USERINFO_DRUG_ENT_ID);
 
 
+
             HnqzUser user = new HnqzUser(id, deptId, phone, avatar, tenantId, username, N_A, true, true, true, true,
             HnqzUser user = new HnqzUser(id, deptId, phone, avatar, tenantId, username, N_A, true, true, true, true,
-                    authorities, platId, drugEntId, null);
+                    authorities, platId, drugEntId, null, realName);
             return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
             return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
         }
         }
         return null;
         return null;

+ 8 - 2
hnqz-common/hnqz-common-security/src/main/java/com/qunzhixinxi/hnqz/common/security/service/HnqzUser.java

@@ -27,6 +27,11 @@ public class HnqzUser extends User {
      */
      */
     private final Integer deptId;
     private final Integer deptId;
 
 
+    /**
+     * 真实名称
+     */
+    private final String realName;
+
     /**
     /**
      * 手机号
      * 手机号
      */
      */
@@ -65,6 +70,7 @@ public class HnqzUser extends User {
      * @param id                    用户ID
      * @param id                    用户ID
      * @param deptId                部门ID
      * @param deptId                部门ID
      * @param tenantId              租户ID
      * @param tenantId              租户ID
+     * @param realName              真实名称
      * @param username              the username presented to the
      * @param username              the username presented to the
      *                              <code>DaoAuthenticationProvider</code>
      *                              <code>DaoAuthenticationProvider</code>
      * @param password              the password that should be presented to the
      * @param password              the password that should be presented to the
@@ -82,17 +88,17 @@ public class HnqzUser extends User {
     public HnqzUser(Integer id, Integer deptId, String phone, String avatar, Integer tenantId, String username,
     public HnqzUser(Integer id, Integer deptId, String phone, String avatar, Integer tenantId, String username,
                     String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired,
                     String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired,
                     boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, String platId,
                     boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, String platId,
-					Integer drugEntId, Integer[] roles) {
+                    Integer drugEntId, Integer[] roles, String realName) {
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
         this.id = id;
         this.id = id;
         this.deptId = deptId;
         this.deptId = deptId;
         this.phone = phone;
         this.phone = phone;
         this.avatar = avatar;
         this.avatar = avatar;
         this.tenantId = tenantId;
         this.tenantId = tenantId;
-
         this.platId = platId;
         this.platId = platId;
         this.drugEntId = drugEntId;
         this.drugEntId = drugEntId;
         this.roles = roles;
         this.roles = roles;
+        this.realName = realName;
     }
     }
 
 
 }
 }

File diff suppressed because it is too large
+ 506 - 488
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/ApiController.java


+ 1 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysUserServiceImpl.java

@@ -605,7 +605,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
      * 通过查用户的全部信息
      * 通过查用户的全部信息
      *
      *
      * @param sysUser 用户
      * @param sysUser 用户
-     * @return
+     * @return UserInfo
      */
      */
     @Override
     @Override
     public UserInfo findUserInfo(SysUser sysUser) {
     public UserInfo findUserInfo(SysUser sysUser) {

+ 0 - 5
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysUserMapper.xml

@@ -114,7 +114,6 @@
         u.salt,
         u.salt,
         u.phone,
         u.phone,
         u.id_card_number,
         u.id_card_number,
-        u.bank_card_number,
         u.avatar,
         u.avatar,
         u.wx_openid,
         u.wx_openid,
         u.qq_openid,
         u.qq_openid,
@@ -155,7 +154,6 @@
         u.salt,
         u.salt,
         u.phone,
         u.phone,
         u.id_card_number,
         u.id_card_number,
-        u.bank_card_number,
         u.avatar,
         u.avatar,
         u.wx_openid,
         u.wx_openid,
         u.qq_openid,
         u.qq_openid,
@@ -178,9 +176,6 @@
         u.temp5,
         u.temp5,
         u.plat_id,
         u.plat_id,
         u.drug_ent_id,
         u.drug_ent_id,
-        u.cert_status,
-        u.rlj_cert_status,
-        u.cert_remark,
         u.w1,
         u.w1,
         r.role_id,
         r.role_id,
         r.role_name,
         r.role_name,

Some files were not shown because too many files changed in this diff