|
|
@@ -11,6 +11,7 @@ import com.usoftchina.saas.auth.client.annotation.IgnoreAuth;
|
|
|
import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
+import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.exception.ExceptionCode;
|
|
|
import com.usoftchina.saas.page.PageDefault;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
@@ -18,6 +19,7 @@ import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import com.usoftchina.saas.utils.CollectionUtils;
|
|
|
import com.usoftchina.saas.utils.RegexpUtils;
|
|
|
import com.usoftchina.sso.api.SsoUserApi;
|
|
|
+import com.usoftchina.sso.dto.SsoCheckMobile;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -116,10 +118,20 @@ public class AccountController {
|
|
|
Account account = null;
|
|
|
// 根据手机号、邮箱、用户名片段判断是否已注册
|
|
|
boolean checked = accountService.findByUsernameOrMobileOrEmail(accountAddDTO.getUsername(), accountAddDTO.getMobile(), accountAddDTO.getEmail());
|
|
|
+ //不存在 ——> 保存 , 存在 ——> 更新
|
|
|
if (!checked) {
|
|
|
account = BeanMapper.map(accountAddDTO, Account.class);
|
|
|
account.setEnabled(true);
|
|
|
accountService.save(account);
|
|
|
+ }else{
|
|
|
+ Account accountTemp = accountService.findByMobile(accountAddDTO.getMobile());
|
|
|
+ if (accountTemp == null){
|
|
|
+ accountTemp = accountService.findByEmail(accountAddDTO.getEmail());
|
|
|
+ }
|
|
|
+ account = BeanMapper.map(accountAddDTO, Account.class);
|
|
|
+ account.setEnabled(true);
|
|
|
+ account.setId(accountTemp.getId());
|
|
|
+ accountService.updateByPrimaryKeySelective(account);
|
|
|
}
|
|
|
account = accountService.findByMobile(accountAddDTO.getMobile());
|
|
|
//绑定企业
|
|
|
@@ -137,7 +149,20 @@ public class AccountController {
|
|
|
*/
|
|
|
@GetMapping("/checkMobile")
|
|
|
public Result checkMobile(@RequestParam("mobile") String mobile){
|
|
|
- return Result.success(ssoUserApi.checkMobile(mobile));
|
|
|
+ SsoCheckMobile ssoCheckMobile = ssoUserApi.checkMobile(mobile);
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ if (ssoCheckMobile.isHasRegister()){
|
|
|
+ Account account = accountService.findByMobile(mobile);
|
|
|
+ if (account != null){
|
|
|
+ List<CompanyBaseVO> companyBaseVOList = companyService.findBaseByAccountId(account.getId());
|
|
|
+ for (CompanyBaseVO companyBaseVO : companyBaseVOList){
|
|
|
+ if (companyBaseVO.getId().equals(companyId)){
|
|
|
+ throw new BizException(ExceptionCode.USER_COMPANY_EXIST);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.success(ssoCheckMobile);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/checkEmail")
|