|
|
@@ -108,30 +108,25 @@ public class AccountController {
|
|
|
/**
|
|
|
* SAAS手动添加账户,并默认绑定当前公司
|
|
|
*
|
|
|
- * @param accountCopyDTO
|
|
|
+ * @param accountAddDTO
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/register/add")
|
|
|
- public Result AddAccount(@RequestBody AccountCopyDTO accountCopyDTO) {
|
|
|
- // 判断是否已注册
|
|
|
- Account account = accountService.findByUsername(accountCopyDTO.getUsername());
|
|
|
- if (null != account) {
|
|
|
- return Result.error(ExceptionCode.USER_NAME_EXIST);
|
|
|
- }
|
|
|
- account = accountService.findByMobile(accountCopyDTO.getMobile());
|
|
|
- if (null != account) {
|
|
|
- return Result.error(ExceptionCode.USER_MOBILE_EXIST);
|
|
|
- }
|
|
|
- account = accountService.findByEmail(accountCopyDTO.getEmail());
|
|
|
- if (null != account) {
|
|
|
- return Result.error(ExceptionCode.USER_EMAIL_EXIST);
|
|
|
+ public Result AddAccount(@RequestBody AccountAddDTO accountAddDTO) {
|
|
|
+ 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);
|
|
|
}
|
|
|
-
|
|
|
- account = BeanMapper.map(accountCopyDTO, Account.class);
|
|
|
- account.setEnabled(true);
|
|
|
- accountService.save(account);
|
|
|
+ account = accountService.findByMobile(accountAddDTO.getMobile());
|
|
|
//绑定企业
|
|
|
accountService.bindCompany(account.getId(), BaseContextHolder.getCompanyId());
|
|
|
+ //绑定角色
|
|
|
+ accountService.bindRoles(account.getId(), accountAddDTO.getRoleIds());
|
|
|
+ accountService.clearCache(account.getId());
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
@@ -418,6 +413,10 @@ public class AccountController {
|
|
|
@PostMapping("/enable")
|
|
|
public Result enableAccount(@RequestParam long accountId) {
|
|
|
accountService.enable(accountId);
|
|
|
+ //同步到优软云
|
|
|
+ Long userUU = accountService.findByPrimaryKey(accountId).getUu();
|
|
|
+ Long companyUU = companyService.findByPrimaryKey(BaseContextHolder.getCompanyId()).getUu();
|
|
|
+ String result = ssoUserApi.bind("bind", "trade-app", userUU, companyUU);
|
|
|
accountService.clearCache(accountId);
|
|
|
return Result.success();
|
|
|
}
|