diff --git a/db/2pigxx.sql b/db/2pigxx.sql index b1a8b70b8..53bbd9e97 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -753,6 +753,9 @@ CREATE TABLE `sys_user` ( `salt` varchar(255) DEFAULT NULL, `phone` varchar(20) DEFAULT NULL, `avatar` varchar(255) DEFAULT NULL, + `nickname` varchar(64) DEFAULT NULL COMMENT '拓展字段:昵称', + `name` varchar(64) DEFAULT NULL COMMENT '拓展字段:姓名', + `email` varchar(128) DEFAULT NULL COMMENT '拓展字段:邮箱', `dept_id` int(11) DEFAULT NULL COMMENT '部门ID', `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', @@ -764,9 +767,6 @@ CREATE TABLE `sys_user` ( `gitee_login` varchar(100) DEFAULT NULL COMMENT '码云 标识', `osc_id` varchar(100) DEFAULT NULL COMMENT '开源中国 标识', `tenant_id` int(11) NOT NULL DEFAULT '0' COMMENT '所属租户', - `nickname` varchar(255) DEFAULT NULL COMMENT '拓展字段:昵称', - `name` varchar(64) DEFAULT NULL COMMENT '拓展字段:姓名', - `email` varchar(255) DEFAULT NULL COMMENT '拓展字段:邮箱', PRIMARY KEY (`user_id`) USING BTREE, KEY `user_wx_openid` (`wx_openid`) USING BTREE, KEY `user_qq_openid` (`qq_openid`) USING BTREE, @@ -777,7 +777,7 @@ CREATE TABLE `sys_user` ( -- Records of sys_user -- ---------------------------- BEGIN; -INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$IVzj1Wd.ZQdOIWdb1htQjexU94uoNeuk1crlQ9ExVupPi0Iy1uv.C', '', '17034642888', '/admin/sys-file/lengleng/c5a85e0770cd4fe78bc14b63b3bd05ae.jpg', 1, '2018-04-20 07:15:18', '2019-11-02 22:12:11', '0', '0', 'o_0FT0uyg_H1vVy2H0JpSwlVGhWQ', 'oBxPy5E-v82xWGsfzZVzkD3wEX64', NULL, 'log4j', '2303656', 1,NULL,NULL,NULL); +INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$IVzj1Wd.ZQdOIWdb1htQjexU94uoNeuk1crlQ9ExVupPi0Iy1uv.C', '', '17034642888', '/admin/sys-file/lengleng/c5a85e0770cd4fe78bc14b63b3bd05ae.jpg',NULL,NULL,NULL, 1, '2018-04-20 07:15:18', '2019-11-02 22:12:11', '0', '0', 'o_0FT0uyg_H1vVy2H0JpSwlVGhWQ', 'oBxPy5E-v82xWGsfzZVzkD3wEX64', NULL, 'log4j', '2303656', 1); COMMIT; -- ---------------------------- diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxUserAuthenticationConverter.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxUserAuthenticationConverter.java index 4a7a9e9e7..49babbb70 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxUserAuthenticationConverter.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxUserAuthenticationConverter.java @@ -62,7 +62,6 @@ public class PigxUserAuthenticationConverter implements UserAuthenticationConver /** * Extract information about the user to be used in an access token (i.e. for resource * servers). - * * @param authentication an authentication representing a user * @return a map of key values representing the unique information about the user */ @@ -79,7 +78,6 @@ public class PigxUserAuthenticationConverter implements UserAuthenticationConver /** * Inverse of {@link #convertUserAuthentication(Authentication)}. Extracts an * Authentication from a map. - * * @param responseMap a map of user information * @return an Authentication representing the user or null if there is none */ @@ -98,7 +96,7 @@ public class PigxUserAuthenticationConverter implements UserAuthenticationConver Integer tenantId = MapUtil.getInt(map, SecurityConstants.DETAILS_TENANT_ID); String phone = MapUtil.getStr(map, SecurityConstants.DETAILS_PHONE); String avatar = MapUtil.getStr(map, SecurityConstants.DETAILS_AVATAR); - PigxUser user = new PigxUser(nickname, name, email, id, deptId, phone, avatar, tenantId, username, N_A, + PigxUser user = new PigxUser(id, username, deptId, phone, avatar, nickname, name, email, tenantId, N_A, true, true, true, true, authorities); return new UsernamePasswordAuthenticationToken(user, N_A, authorities); } @@ -124,7 +122,7 @@ public class PigxUserAuthenticationConverter implements UserAuthenticationConver log.warn("请求头中的租户ID({})和用户的租户ID({})不一致", headerValue, userValue); // TODO: 不要提示租户ID不对,可能被穷举 throw new PigxAuth2Exception(PigxSecurityMessageSourceUtil.getAccessor().getMessage( - "AbstractUserDetailsAuthenticationProvider.badTenantId", new Object[]{headerValue}, + "AbstractUserDetailsAuthenticationProvider.badTenantId", new Object[] { headerValue }, "Bad tenant ID")); } } diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUser.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUser.java index be852ad08..a2f268c79 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUser.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUser.java @@ -106,12 +106,12 @@ public class PigxUser extends User { * a parameter or as an element in the GrantedAuthority collection */ @JsonCreator - public PigxUser(@JsonProperty("nickname") String nickname, @JsonProperty("name") String name, - @JsonProperty("email") String email, @JsonProperty("id") Integer id, @JsonProperty("deptId") Integer deptId, - @JsonProperty("phone") String phone, @JsonProperty("avatar") String avatar, - @JsonProperty("tenantId") Integer tenantId, @JsonProperty("username") String username, - @JsonProperty("password") String password, @JsonProperty("enabled") boolean enabled, - @JsonProperty("accountNonExpired") boolean accountNonExpired, + public PigxUser(@JsonProperty("id") Integer id, @JsonProperty("username") String username, + @JsonProperty("deptId") Integer deptId, @JsonProperty("phone") String phone, + @JsonProperty("avatar") String avatar, @JsonProperty("nickname") String nickname, + @JsonProperty("name") String name, @JsonProperty("email") String email, + @JsonProperty("tenantId") Integer tenantId, @JsonProperty("password") String password, + @JsonProperty("enabled") boolean enabled, @JsonProperty("accountNonExpired") boolean accountNonExpired, @JsonProperty("credentialsNonExpired") boolean credentialsNonExpired, @JsonProperty("accountNonLocked") boolean accountNonLocked, @JsonProperty("authorities") Collection authorities) { diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java index fedcb2b79..72ecd56af 100644 --- a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/service/PigxUserDetailsServiceImpl.java @@ -113,8 +113,8 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService { boolean enabled = StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL); // 构造security用户 - return new PigxUser(user.getNickname(), user.getName(), user.getEmail(), user.getUserId(), user.getDeptId(), - user.getPhone(), user.getAvatar(), user.getTenantId(), user.getUsername(), + return new PigxUser(user.getUserId(), user.getUsername(), user.getDeptId(), user.getPhone(), user.getAvatar(), + user.getNickname(), user.getName(), user.getEmail(), user.getTenantId(), SecurityConstants.BCRYPT + user.getPassword(), enabled, true, true, !CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java index ba4403726..4373cf6c2 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java @@ -300,7 +300,7 @@ public class SysUserServiceImpl extends ServiceImpl impl if (CollUtil.isNotEmpty(errorMessageList)) { return R.failed(errorMessageList); } - return R.ok(); + return R.ok(null, "用户导入成功,默认密码为手机号"); } /** diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/file/user.xlsx b/pigx-upms/pigx-upms-biz/src/main/resources/file/user.xlsx index 40cf429c8..764935442 100644 Binary files a/pigx-upms/pigx-upms-biz/src/main/resources/file/user.xlsx and b/pigx-upms/pigx-upms-biz/src/main/resources/file/user.xlsx differ