@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
package com.cloud.kicc.system.service.impl ;
import cn.hutool.core.lang.Validator ;
import cn.hutool.core.map.MapUtil ;
import cn.hutool.core.text.CharSequenceUtil ;
import cn.hutool.core.util.ArrayUtil ;
import cn.hutool.core.util.ObjectUtil ;
@ -76,7 +77,7 @@ public class AppServiceImpl implements AppService {
@@ -76,7 +77,7 @@ public class AppServiceImpl implements AppService {
@DSTransactional
public SsoUser phoneRegister ( String phone , String captcha , String identityProvider ) {
// 设置不区分大小写,全部以小写验证
Validator . validateMobile ( phone , "手机号码不合法" ) ;
/ * Validator . validateMobile ( phone , "手机号码不合法" ) ;
String code = captcha . toLowerCase ( ) ;
if ( CharSequenceUtil . isBlank ( code ) ) {
throw new ValidateCodeException ( "验证码不能为空" ) ;
@ -107,47 +108,64 @@ public class AppServiceImpl implements AppService {
@@ -107,47 +108,64 @@ public class AppServiceImpl implements AppService {
. eq ( SsoUser : : getIdentityProvider , identityProvider ) ) ;
if ( ! findSsoUser . isEmpty ( ) ) {
return findSsoUser . get ( 0 ) ;
}
} * /
// 修改扩展用户信息
SsoUser ssoUser = new SsoUser ( ) ;
/ * SsoUser ssoUser = new SsoUser ( ) ;
ssoUser . setUserName ( phone ) ;
ssoUser . setNickName ( phone ) ;
ssoUser . setPassword ( new BCryptPasswordEncoder ( ) . encode ( initPassword ) ) ;
ssoUser . setPhone ( phone ) ;
ssoUser . setIdentityProvider ( identityProvider ) ;
ssoUser . setTenantId ( initTenantId ) ;
ssoUser . setCreateById ( kiccUser . getUsername ( ) ) ;
ssoUser . setCreateByName ( kiccUser . getId ( ) ) ;
iSsoUserService . save ( ssoUser ) ;
ssoUser . setCreateById ( kiccUser . getId ( ) ) ;
ssoUser . setCreateByName ( kiccUser . getUsername ( ) ) ;
iSsoUserService . save ( ssoUser ) ; * /
User user = new User ( ) ;
/ * User user = new User ( ) ;
user . setCasUserId ( ssoUser . getId ( ) ) ;
user . setDeptId ( dept . getDeptId ( ) ) ;
user . setDeptName ( dept . getName ( ) ) ;
user . setUserType ( initUserType ) ;
user . setTenantId ( initTenantId ) ;
user . setCreateById ( kiccUser . getUsername ( ) ) ;
user . setCreateByName ( kiccUser . getId ( ) ) ;
userService . save ( user ) ;
user . setCreateById ( kiccUser . getId ( ) ) ;
user . setCreateByName ( kiccUser . getUsername ( ) ) ;
userService . save ( user ) ; * /
// 处理角色授权
String [ ] roles = initRoleIds . split ( "," ) ;
/ * String [ ] roles = initRoleIds . split ( "," ) ;
userRoleService . saveBatch ( Arrays . stream ( roles ) . map ( roleId - > {
UserRole ur = new UserRole ( ) ;
ur . setUserId ( user . getId ( ) ) ;
ur . setRoleId ( roleId ) ;
ur . setTenantId ( initTenantId ) ;
return ur ;
} ) . collect ( Collectors . toList ( ) ) ) ;
} ) . collect ( Collectors . toList ( ) ) ) ; * /
String initDeptId = configService . getValueByKey ( "app.init.deptId" ) ;
Dept dept = deptService . getById ( initDeptId ) ;
Optional . ofNullable ( dept ) . orElseThrow ( ( ) - > new CheckedException ( "当前部门无效请重新在参数管理中配置!" ) ) ;
String execAdminUserId = configService . getValueByKey ( "app.exec.admin.userId" ) ;
KiccUser kiccUser = userService . getUserById ( execAdminUserId ) ;
Optional . ofNullable ( kiccUser ) . orElseThrow ( ( ) - > new CheckedException ( "当前系统管理执行用户无效请重新在参数管理中配置!" ) ) ;
String initUserType = configService . getValueByKey ( "app.init.normal.userType" ) ;
String initTenantId = configService . getValueByKey ( "app.init.tenantId" ) ;
String initRoleIds = configService . getValueByKey ( "app.init.roleIds" ) ;
String initPassword = configService . getValueByKey ( "appid.password" ) ;
// 创建系统中的用户强制关联内部企业
List < User > enterpriseUserList = userService . list ( Wrappers . < User > lambdaQuery ( ) . in ( User : : getUserType , UserTypeEnum . INTERNAL_USER . getValue ( ) ) ) ;
remotePushConcernFanService . bindConcernEnterpriseUser ( user . getId ( ) , enterpriseUserList ) ;
remotePushConcernFanService . bindConcernEnterpriseUser ( MapUtil . < String , Object > builder ( )
. put ( "userId" , "1739937413576310785" )
. put ( "execUserId" , kiccUser . getId ( ) )
. put ( "execUserName" , kiccUser . getUsername ( ) )
. put ( "tenantId" , initTenantId )
. build ( ) , enterpriseUserList ) ;
// 处理原密码给到APP自动一键登陆
ssoUser . setPassword ( initPassword ) ;
return ssoUser ;
//ssoUser.setPassword(initPassword);
return new SsoUser ( ) ;
}