提交 54fc675e 编写于 作者: zhouweidong's avatar zhouweidong

转接sysUser

上级 73bdf4b6
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.uaa.service.impl.SysUserServiceImpl;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@Service
@Primary
public class SysUserExService extends SysUserServiceImpl {
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
}
...@@ -8,7 +8,10 @@ import cn.ibizlab.core.uaa.extensions.domain.PermissionType; ...@@ -8,7 +8,10 @@ import cn.ibizlab.core.uaa.extensions.domain.PermissionType;
import cn.ibizlab.core.uaa.extensions.helper.DingTalkHelper; import cn.ibizlab.core.uaa.extensions.helper.DingTalkHelper;
import cn.ibizlab.core.uaa.filter.SysRolePermissionSearchContext; import cn.ibizlab.core.uaa.filter.SysRolePermissionSearchContext;
import cn.ibizlab.core.uaa.filter.SysUserSearchContext; import cn.ibizlab.core.uaa.filter.SysUserSearchContext;
import cn.ibizlab.core.uaa.service.*; import cn.ibizlab.core.uaa.service.ISysPSSystemService;
import cn.ibizlab.core.uaa.service.ISysRolePermissionService;
import cn.ibizlab.core.uaa.service.ISysUserRoleService;
import cn.ibizlab.core.uaa.service.ISysUserService;
import cn.ibizlab.util.domain.Token; import cn.ibizlab.util.domain.Token;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.security.AuthTokenUtil; import cn.ibizlab.util.security.AuthTokenUtil;
...@@ -27,8 +30,6 @@ import org.springframework.cache.annotation.CachePut; ...@@ -27,8 +30,6 @@ import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching; import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -36,6 +37,7 @@ import org.springframework.util.AlternativeJdkIdGenerator; ...@@ -36,6 +37,7 @@ import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -44,7 +46,6 @@ import java.security.KeyPair; ...@@ -44,7 +46,6 @@ import java.security.KeyPair;
import java.security.KeyPairGenerator; import java.security.KeyPairGenerator;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.PublicKey; import java.security.PublicKey;
import java.sql.Wrapper;
import java.util.*; import java.util.*;
@Service @Service
...@@ -409,7 +410,7 @@ public class UAACoreService { ...@@ -409,7 +410,7 @@ public class UAACoreService {
@Autowired @Autowired
private ISysUserService userService;; private ISysUserService userService;
@Cacheable( value="ibzuaa-model",key = "'catalog:SysOperator'") @Cacheable( value="ibzuaa-model",key = "'catalog:SysOperator'")
public JSONObject getOptions(String catalog) { public JSONObject getOptions(String catalog) {
......
package cn.ibizlab.core.uaa.extensions.service; package cn.ibizlab.core.uaa.extensions.service;
import cn.ibizlab.core.uaa.domain.SysOpenAccess; import cn.ibizlab.core.uaa.domain.SysOpenAccess;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.service.ISysOpenAccessService; import cn.ibizlab.core.uaa.service.ISysOpenAccessService;
import cn.ibizlab.core.uaa.service.ISysUserAuthService; import cn.ibizlab.core.uaa.service.ISysUserAuthService;
import cn.ibizlab.util.domain.IBZUSER; import cn.ibizlab.core.uaa.service.ISysUserService;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.errors.InternalServerErrorException; import cn.ibizlab.util.errors.InternalServerErrorException;
import cn.ibizlab.util.security.AuthenticationUser; import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.service.AuthenticationUserService; import cn.ibizlab.util.service.AuthenticationUserService;
import cn.ibizlab.util.service.IBZUSERService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dingtalk.api.DefaultDingTalkClient; import com.dingtalk.api.DefaultDingTalkClient;
...@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils; ...@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
public class UserDingtalkRegisterService { public class UserDingtalkRegisterService {
@Autowired @Autowired
private IBZUSERService ibzuserService; private ISysUserService sysUserService;
@Autowired @Autowired
private AuthenticationUserService authenticationUserService; private AuthenticationUserService authenticationUserService;
...@@ -88,7 +88,7 @@ public class UserDingtalkRegisterService { ...@@ -88,7 +88,7 @@ public class UserDingtalkRegisterService {
String userId = response.getUserid(); String userId = response.getUserid();
//先按userid或者username查 //先按userid或者username查
IBZUSER user = ibzuserService.getOne(Wrappers.<IBZUSER>lambdaQuery().eq(IBZUSER::getUserid,userId).or().eq(IBZUSER::getUsername,userId),false); SysUser user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserid,userId).or().eq(SysUser::getUsername,userId),false);
if(user==null) if(user==null)
{ {
...@@ -96,7 +96,7 @@ public class UserDingtalkRegisterService { ...@@ -96,7 +96,7 @@ public class UserDingtalkRegisterService {
SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"dingtalk").eq(SysUserAuth::getIdentifier, userId),false); SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"dingtalk").eq(SysUserAuth::getIdentifier, userId),false);
// 该钉钉用户注册过账号,登录系统 // 该钉钉用户注册过账号,登录系统
if (userAuth!=null) { if (userAuth!=null) {
user = ibzuserService.getById(userAuth.getUserid()); user = sysUserService.getById(userAuth.getUserid());
if(user==null) if(user==null)
throw new BadRequestAlertException("未找到"+userId+"对应系统用户","UserDingtalkRegisterService",""); throw new BadRequestAlertException("未找到"+userId+"对应系统用户","UserDingtalkRegisterService","");
...@@ -138,12 +138,12 @@ public class UserDingtalkRegisterService { ...@@ -138,12 +138,12 @@ public class UserDingtalkRegisterService {
.and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, response.getUserInfo().getOpenid()).or().eq(SysUserAuth::getIdentifier, response.getUserInfo().getUnionid()) .and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, response.getUserInfo().getOpenid()).or().eq(SysUserAuth::getIdentifier, response.getUserInfo().getUnionid())
),false); ),false);
IBZUSER user = null; SysUser user = null;
// 该钉钉用户注册过账号,登录系统 // 该钉钉用户注册过账号,登录系统
if (userAuth!=null) { if (userAuth!=null) {
user = ibzuserService.getById(userAuth.getUserid()); user = sysUserService.getById(userAuth.getUserid());
if (user == null) if (user == null)
user = ibzuserService.getOne(Wrappers.<IBZUSER>lambdaQuery().eq(IBZUSER::getUserid,response.getUserInfo().getOpenid()).or().eq(IBZUSER::getUsername,response.getUserInfo().getOpenid()),false); user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserid,response.getUserInfo().getOpenid()).or().eq(SysUser::getUsername,response.getUserInfo().getOpenid()),false);
if(user!=null) if(user!=null)
{ {
......
package cn.ibizlab.core.uaa.extensions.service; package cn.ibizlab.core.uaa.extensions.service;
import cn.ibizlab.core.uaa.domain.SysOpenAccess; import cn.ibizlab.core.uaa.domain.SysOpenAccess;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.service.ISysOpenAccessService; import cn.ibizlab.core.uaa.service.ISysOpenAccessService;
import cn.ibizlab.core.uaa.service.ISysUserAuthService; import cn.ibizlab.core.uaa.service.ISysUserAuthService;
import cn.ibizlab.util.domain.IBZUSER; import cn.ibizlab.core.uaa.service.ISysUserService;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.errors.InternalServerErrorException; import cn.ibizlab.util.errors.InternalServerErrorException;
import cn.ibizlab.util.helper.HttpUtils; import cn.ibizlab.util.helper.HttpUtils;
import cn.ibizlab.util.service.IBZUSERService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -16,8 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,8 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.UnsupportedEncodingException;
/** /**
* 实体[IBZUSER] QQ用户注册接口实现 * 实体[IBZUSER] QQ用户注册接口实现
*/ */
...@@ -26,11 +24,11 @@ import java.io.UnsupportedEncodingException; ...@@ -26,11 +24,11 @@ import java.io.UnsupportedEncodingException;
public class UserQQRegisterService { public class UserQQRegisterService {
@Autowired @Autowired
private IBZUSERService ibzuserService; private ISysUserService sysUserService;
@Autowired @Autowired
private ISysUserAuthService sysUserAuthService; private ISysUserAuthService sysUserAuthService;
@Autowired @Autowired
private ISysOpenAccessService sysOpenAccessService; private ISysOpenAccessService sysOpenAccessService;
...@@ -111,12 +109,12 @@ public class UserQQRegisterService { ...@@ -111,12 +109,12 @@ public class UserQQRegisterService {
returnObj.put("openid",openid); returnObj.put("openid",openid);
SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"qq").eq(SysUserAuth::getIdentifier, openid),false); SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"qq").eq(SysUserAuth::getIdentifier, openid),false);
IBZUSER user = null; SysUser user = null;
// 该qq用户注册过账号,登录系统 // 该qq用户注册过账号,登录系统
if (userAuth!=null) { if (userAuth!=null) {
user = ibzuserService.getById(userAuth.getUserid()); user = sysUserService.getById(userAuth.getUserid());
if (user == null) if (user == null)
user = ibzuserService.getOne(Wrappers.<IBZUSER>lambdaQuery().eq(IBZUSER::getUserid,openid).or().eq(IBZUSER::getUsername,openid),false); user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserid,openid).or().eq(SysUser::getUsername,openid),false);
if(user!=null) if(user!=null)
{ {
......
package cn.ibizlab.core.uaa.extensions.service; package cn.ibizlab.core.uaa.extensions.service;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.service.ISysUserAuthService; import cn.ibizlab.core.uaa.service.ISysUserAuthService;
import cn.ibizlab.util.domain.IBZUSER; import cn.ibizlab.core.uaa.service.ISysUserService;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.service.IBZUSERService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,12 +13,6 @@ import org.springframework.stereotype.Service; ...@@ -15,12 +13,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.sql.Wrapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
* 实体[IBZUSER] 用户注册接口实现 * 实体[IBZUSER] 用户注册接口实现
*/ */
...@@ -29,7 +21,7 @@ import java.util.UUID; ...@@ -29,7 +21,7 @@ import java.util.UUID;
public class UserRegisterService { public class UserRegisterService {
@Autowired @Autowired
private IBZUSERService ibzuserService; private ISysUserService sysUserService;
@Autowired @Autowired
private ISysUserAuthService sysUserAuthService; private ISysUserAuthService sysUserAuthService;
...@@ -38,12 +30,12 @@ public class UserRegisterService { ...@@ -38,12 +30,12 @@ public class UserRegisterService {
private int pwencrymode; private int pwencrymode;
public IBZUSER toRegister(IBZUSER account) public SysUser toRegister(SysUser account)
{ {
return toRegister(account,null); return toRegister(account,null);
} }
public IBZUSER toRegister(IBZUSER account, SysUserAuth sysUserAuth) { public SysUser toRegister(SysUser account, SysUserAuth sysUserAuth) {
String domains = account.getDomains(); String domains = account.getDomains();
String loginname = account.getLoginname(); String loginname = account.getLoginname();
...@@ -68,8 +60,8 @@ public class UserRegisterService { ...@@ -68,8 +60,8 @@ public class UserRegisterService {
String username = loginname+(StringUtils.isEmpty(domains)?"":("|"+domains)); String username = loginname+(StringUtils.isEmpty(domains)?"":("|"+domains));
IBZUSER existedUser = ibzuserService.getOne(Wrappers.<IBZUSER>lambdaQuery().eq(IBZUSER::getLoginname,loginname) SysUser existedUser = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getLoginname,loginname)
.eq((!StringUtils.isEmpty(domains)),IBZUSER::getDomains,domains),false); .eq((!StringUtils.isEmpty(domains)),SysUser::getDomains,domains),false);
if(existedUser!=null) if(existedUser!=null)
...@@ -100,7 +92,7 @@ public class UserRegisterService { ...@@ -100,7 +92,7 @@ public class UserRegisterService {
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes()); password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
account.setPassword(password); account.setPassword(password);
account.setUserid(username); account.setUserid(username);
ibzuserService.save(account); sysUserService.save(account);
} }
if(sysUserAuth!=null) if(sysUserAuth!=null)
......
package cn.ibizlab.core.uaa.extensions.service; package cn.ibizlab.core.uaa.extensions.service;
import cn.ibizlab.core.uaa.domain.SysOpenAccess; import cn.ibizlab.core.uaa.domain.SysOpenAccess;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.service.ISysOpenAccessService; import cn.ibizlab.core.uaa.service.ISysOpenAccessService;
import cn.ibizlab.core.uaa.service.ISysUserAuthService; import cn.ibizlab.core.uaa.service.ISysUserAuthService;
import cn.ibizlab.util.domain.IBZUSER; import cn.ibizlab.core.uaa.service.ISysUserService;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.errors.InternalServerErrorException; import cn.ibizlab.util.errors.InternalServerErrorException;
import cn.ibizlab.util.helper.HttpUtils; import cn.ibizlab.util.helper.HttpUtils;
import cn.ibizlab.util.service.IBZUSERService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.request.OapiSnsGetuserinfoBycodeRequest;
import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
/** /**
* 实体[IBZUSER] 微信用户注册接口实现 * 实体[IBZUSER] 微信用户注册接口实现
*/ */
...@@ -31,11 +24,11 @@ import java.sql.Timestamp; ...@@ -31,11 +24,11 @@ import java.sql.Timestamp;
public class UserWechatRegisterService { public class UserWechatRegisterService {
@Autowired @Autowired
private IBZUSERService ibzuserService; private ISysUserService sysUserService;
@Autowired @Autowired
private ISysUserAuthService sysUserAuthService; private ISysUserAuthService sysUserAuthService;
@Autowired @Autowired
private ISysOpenAccessService sysOpenAccessService; private ISysOpenAccessService sysOpenAccessService;
...@@ -90,12 +83,12 @@ public class UserWechatRegisterService { ...@@ -90,12 +83,12 @@ public class UserWechatRegisterService {
.and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, openid).or().eq(SysUserAuth::getIdentifier, unionid) .and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, openid).or().eq(SysUserAuth::getIdentifier, unionid)
),false); ),false);
IBZUSER user = null; SysUser user = null;
// 该wechat用户注册过账号,登录系统 // 该wechat用户注册过账号,登录系统
if (userAuth!=null) { if (userAuth!=null) {
user = ibzuserService.getById(userAuth.getUserid()); user = sysUserService.getById(userAuth.getUserid());
if (user == null) if (user == null)
user = ibzuserService.getOne(Wrappers.<IBZUSER>lambdaQuery().eq(IBZUSER::getUserid,openid).or().eq(IBZUSER::getUsername,openid),false); user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserid,openid).or().eq(SysUser::getUsername,openid),false);
if(user!=null) if(user!=null)
{ {
......
package cn.ibizlab.api.rest.extensions; package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.uaa.domain.SysOpenAccess; import cn.ibizlab.core.uaa.domain.SysOpenAccess;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.extensions.service.UserDingtalkRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserDingtalkRegisterService;
import cn.ibizlab.core.uaa.extensions.service.UserRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserRegisterService;
...@@ -33,8 +34,6 @@ public class UserDingtalkRegisterResource { ...@@ -33,8 +34,6 @@ public class UserDingtalkRegisterResource {
@Autowired @Autowired
private UserRegisterService userRegisterService; private UserRegisterService userRegisterService;
@Autowired @Autowired
private IBZUSERService ibzuserService;
@Autowired
private ISysUserAuthService sysUserAuthService; private ISysUserAuthService sysUserAuthService;
@Autowired @Autowired
private AuthTokenUtil jwtTokenUtil; private AuthTokenUtil jwtTokenUtil;
...@@ -127,24 +126,24 @@ public class UserDingtalkRegisterResource { ...@@ -127,24 +126,24 @@ public class UserDingtalkRegisterResource {
throw new BadRequestAlertException("钉钉信息openid为空", "UserDingtalkRegisterResource", ""); throw new BadRequestAlertException("钉钉信息openid为空", "UserDingtalkRegisterResource", "");
// 钉钉用户注册 // 钉钉用户注册
IBZUSER ibzuser = new IBZUSER(); SysUser sysUser = new SysUser();
ibzuser.setPassword(password); sysUser.setPassword(password);
ibzuser.setLoginname(loginname); sysUser.setLoginname(loginname);
ibzuser.setPersonname(StringUtils.isEmpty(personname)?nickname:personname); sysUser.setPersonname(StringUtils.isEmpty(personname)?nickname:personname);
ibzuser.setNickname(nickname); sysUser.setNickname(nickname);
ibzuser.setPhone(phone); sysUser.setPhone(phone);
ibzuser.setEmail(email); sysUser.setEmail(email);
ibzuser.setDomains(domains); sysUser.setDomains(domains);
SysUserAuth userAuth = new SysUserAuth(); SysUserAuth userAuth = new SysUserAuth();
userAuth.setIdentifier(openid); userAuth.setIdentifier(openid);
userAuth.setIdentityType("dingtalk"); userAuth.setIdentityType("dingtalk");
userRegisterService.toRegister(ibzuser,userAuth); userRegisterService.toRegister(sysUser,userAuth);
// 生成登录token信息 // 生成登录token信息
userDetailsService.resetByUsername(ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomains())?"":("|"+ibzuser.getDomains()))); userDetailsService.resetByUsername(sysUser.getLoginname()+(StringUtils.isEmpty(sysUser.getDomains())?"":("|"+sysUser.getDomains())));
AuthenticationUser user = userDetailsService.loadUserByUsername(ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomains())?"":("|"+ibzuser.getDomains()))); AuthenticationUser user = userDetailsService.loadUserByUsername(sysUser.getLoginname()+(StringUtils.isEmpty(sysUser.getDomains())?"":("|"+sysUser.getDomains())));
final String token = jwtTokenUtil.generateToken(user); final String token = jwtTokenUtil.generateToken(user);
AuthenticationUser user2 = new AuthenticationUser(); AuthenticationUser user2 = new AuthenticationUser();
CachedBeanCopier.copy(user, user2); CachedBeanCopier.copy(user, user2);
......
package cn.ibizlab.api.rest.extensions; package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.uaa.domain.SysOpenAccess; import cn.ibizlab.core.uaa.domain.SysOpenAccess;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.extensions.service.UserQQRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserQQRegisterService;
import cn.ibizlab.core.uaa.extensions.service.UserRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserRegisterService;
...@@ -126,24 +127,24 @@ public class UserQQRegisterResource { ...@@ -126,24 +127,24 @@ public class UserQQRegisterResource {
throw new BadRequestAlertException("QQ信息openid为空", "UserQQRegisterResource", ""); throw new BadRequestAlertException("QQ信息openid为空", "UserQQRegisterResource", "");
// qq用户注册 // qq用户注册
IBZUSER ibzuser = new IBZUSER(); SysUser sysUser = new SysUser();
ibzuser.setPassword(password); sysUser.setPassword(password);
ibzuser.setLoginname(loginname); sysUser.setLoginname(loginname);
ibzuser.setPersonname(StringUtils.isEmpty(personname)?nickname:personname); sysUser.setPersonname(StringUtils.isEmpty(personname)?nickname:personname);
ibzuser.setNickname(nickname); sysUser.setNickname(nickname);
ibzuser.setPhone(phone); sysUser.setPhone(phone);
ibzuser.setEmail(email); sysUser.setEmail(email);
ibzuser.setDomains(domains); sysUser.setDomains(domains);
SysUserAuth userAuth = new SysUserAuth(); SysUserAuth userAuth = new SysUserAuth();
userAuth.setIdentifier(openid); userAuth.setIdentifier(openid);
userAuth.setIdentityType("qq"); userAuth.setIdentityType("qq");
userRegisterService.toRegister(ibzuser,userAuth); userRegisterService.toRegister(sysUser,userAuth);
// 生成登录token信息 // 生成登录token信息
userDetailsService.resetByUsername(ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomains())?"":("|"+ibzuser.getDomains()))); userDetailsService.resetByUsername(sysUser.getLoginname()+(StringUtils.isEmpty(sysUser.getDomains())?"":("|"+sysUser.getDomains())));
AuthenticationUser user = userDetailsService.loadUserByUsername(ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomains())?"":("|"+ibzuser.getDomains()))); AuthenticationUser user = userDetailsService.loadUserByUsername(sysUser.getLoginname()+(StringUtils.isEmpty(sysUser.getDomains())?"":("|"+sysUser.getDomains())));
final String token = jwtTokenUtil.generateToken(user); final String token = jwtTokenUtil.generateToken(user);
AuthenticationUser user2 = new AuthenticationUser(); AuthenticationUser user2 = new AuthenticationUser();
CachedBeanCopier.copy(user, user2); CachedBeanCopier.copy(user, user2);
......
package cn.ibizlab.api.rest.extensions; package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.extensions.service.UserRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserRegisterService;
import cn.ibizlab.util.domain.IBZUSER; import cn.ibizlab.util.domain.IBZUSER;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -18,7 +19,7 @@ public class UserRegisterResource { ...@@ -18,7 +19,7 @@ public class UserRegisterResource {
private UserRegisterService userRegisterService; private UserRegisterService userRegisterService;
@PostMapping(value = "/uaa/register") @PostMapping(value = "/uaa/register")
public ResponseEntity<JSONObject> register(@RequestBody IBZUSER ibzuser) { public ResponseEntity<JSONObject> register(@RequestBody SysUser ibzuser) {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
// 响应结果 // 响应结果
......
package cn.ibizlab.api.rest.extensions; package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.uaa.domain.SysOpenAccess; import cn.ibizlab.core.uaa.domain.SysOpenAccess;
import cn.ibizlab.core.uaa.domain.SysUser;
import cn.ibizlab.core.uaa.domain.SysUserAuth; import cn.ibizlab.core.uaa.domain.SysUserAuth;
import cn.ibizlab.core.uaa.extensions.service.UserRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserRegisterService;
import cn.ibizlab.core.uaa.extensions.service.UserWechatRegisterService; import cn.ibizlab.core.uaa.extensions.service.UserWechatRegisterService;
...@@ -34,8 +35,6 @@ public class UserWechatRegisterResource { ...@@ -34,8 +35,6 @@ public class UserWechatRegisterResource {
@Autowired @Autowired
private UserRegisterService userRegisterService; private UserRegisterService userRegisterService;
@Autowired @Autowired
private IBZUSERService ibzuserService;
@Autowired
private ISysUserAuthService sysUserAuthService; private ISysUserAuthService sysUserAuthService;
@Autowired @Autowired
private AuthTokenUtil jwtTokenUtil; private AuthTokenUtil jwtTokenUtil;
...@@ -128,24 +127,24 @@ public class UserWechatRegisterResource { ...@@ -128,24 +127,24 @@ public class UserWechatRegisterResource {
throw new BadRequestAlertException("微信信息openid为空", "UserWechatRegisterResource", ""); throw new BadRequestAlertException("微信信息openid为空", "UserWechatRegisterResource", "");
// 微信用户注册 // 微信用户注册
IBZUSER ibzuser = new IBZUSER(); SysUser sysUser = new SysUser();
ibzuser.setPassword(password); sysUser.setPassword(password);
ibzuser.setLoginname(loginname); sysUser.setLoginname(loginname);
ibzuser.setPersonname(StringUtils.isEmpty(personname)?nickname:personname); sysUser.setPersonname(StringUtils.isEmpty(personname)?nickname:personname);
ibzuser.setNickname(nickname); sysUser.setNickname(nickname);
ibzuser.setPhone(phone); sysUser.setPhone(phone);
ibzuser.setEmail(email); sysUser.setEmail(email);
ibzuser.setDomains(domains); sysUser.setDomains(domains);
SysUserAuth userAuth = new SysUserAuth(); SysUserAuth userAuth = new SysUserAuth();
userAuth.setIdentifier(openid); userAuth.setIdentifier(openid);
userAuth.setIdentityType("wechat"); userAuth.setIdentityType("wechat");
userRegisterService.toRegister(ibzuser,userAuth); userRegisterService.toRegister(sysUser,userAuth);
// 生成登录token信息 // 生成登录token信息
userDetailsService.resetByUsername(ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomains())?"":("|"+ibzuser.getDomains()))); userDetailsService.resetByUsername(sysUser.getLoginname()+(StringUtils.isEmpty(sysUser.getDomains())?"":("|"+sysUser.getDomains())));
AuthenticationUser user = userDetailsService.loadUserByUsername(ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomains())?"":("|"+ibzuser.getDomains()))); AuthenticationUser user = userDetailsService.loadUserByUsername(sysUser.getLoginname()+(StringUtils.isEmpty(sysUser.getDomains())?"":("|"+sysUser.getDomains())));
final String token = jwtTokenUtil.generateToken(user); final String token = jwtTokenUtil.generateToken(user);
AuthenticationUser user2 = new AuthenticationUser(); AuthenticationUser user2 = new AuthenticationUser();
CachedBeanCopier.copy(user, user2); CachedBeanCopier.copy(user, user2);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册