|
|
@@ -1,10 +1,12 @@
|
|
|
package com.uas.sso.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.uas.sso.AccountConfig;
|
|
|
import com.uas.sso.core.Status;
|
|
|
import com.uas.sso.dao.AppealDao;
|
|
|
import com.uas.sso.entity.Appeal;
|
|
|
import com.uas.sso.entity.User;
|
|
|
+import com.uas.sso.entity.UserAccount;
|
|
|
import com.uas.sso.entity.Userspace;
|
|
|
import com.uas.sso.exception.VisibleError;
|
|
|
import com.uas.sso.service.AppealService;
|
|
|
@@ -16,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @author wangmh
|
|
|
@@ -35,10 +38,22 @@ public class AppealServiceImpl implements AppealService {
|
|
|
private UserService userService;
|
|
|
|
|
|
@Override
|
|
|
- public void submitResetPwd(Appeal appeal, String password) {
|
|
|
+ public void submitResetPwd(String appId, Appeal appeal, String password) {
|
|
|
+ // 获取用户信息
|
|
|
+ String mobile = Optional.ofNullable(appeal.getMobile())
|
|
|
+ .map(value -> "".equals(value) ? null : value)
|
|
|
+ .orElseThrow(() -> new NullPointerException("手机号不能为空"));
|
|
|
+ User user = Optional.ofNullable(mobile)
|
|
|
+ .map(value -> userService.findByMobile(value))
|
|
|
+ .orElseThrow(() -> new IllegalArgumentException("该手机号未注册"));
|
|
|
+ appId = Optional.ofNullable(appId)
|
|
|
+ .map(value -> "".equals(value) ? AccountConfig.ACCOUNT_CENTER : value)
|
|
|
+ .orElse(AccountConfig.ACCOUNT_CENTER);
|
|
|
+
|
|
|
// 设置默认信息
|
|
|
appeal.setSubmitDate(new Timestamp(System.currentTimeMillis()));
|
|
|
- User user = userService.findOne(appeal.getSubmitterUU());
|
|
|
+ appeal.setSubmitterUU(user.getUserUU());
|
|
|
+ appeal.setFromApp(appId);
|
|
|
ModelMap data = new ModelMap();
|
|
|
data.put("password", password);
|
|
|
data.put("oldMobile", user.getMobile());
|
|
|
@@ -56,26 +71,39 @@ public class AppealServiceImpl implements AppealService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void submitChangeAdmin(Appeal appeal, Userspace userspace, Long spaceUU) {
|
|
|
- User newAdmin = userService.findByMobile(appeal.getMobile());
|
|
|
- // 设置企业信息
|
|
|
- userspace.setSpaceUU(spaceUU);
|
|
|
- Userspace oldSpace = userspaceService.findOne(spaceUU);
|
|
|
+ public void submitChangeAdmin(String appId, Appeal appeal, Userspace userspace) {
|
|
|
+ String spaceName = Optional.ofNullable(userspace)
|
|
|
+ .map(value -> value.getSpaceName())
|
|
|
+ .orElseThrow(() -> new NullPointerException("企业名称不能为空"));
|
|
|
+ Userspace oldSpace = Optional.ofNullable(spaceName)
|
|
|
+ .map(value -> userspaceService.findBySpaceName(value))
|
|
|
+ .orElseThrow(() -> new IllegalArgumentException("该企业未被注册,请确认"));
|
|
|
+ User newAdmin = Optional.ofNullable(appeal)
|
|
|
+ .map(Appeal::getMobile)
|
|
|
+ .map(value -> userService.findByMobile(value))
|
|
|
+ .orElse(null);
|
|
|
+ appId = Optional.ofNullable(appId)
|
|
|
+ .map(value -> "".equals(value) ? AccountConfig.ACCOUNT_CENTER : value)
|
|
|
+ .orElse(AccountConfig.ACCOUNT_CENTER);
|
|
|
+ userspace.setSpaceUU(oldSpace.getSpaceUU());
|
|
|
userspace.setAdmin(oldSpace.getAdmin());
|
|
|
|
|
|
// 设置默认信息
|
|
|
appeal.setSubmitDate(new Timestamp(System.currentTimeMillis()));
|
|
|
+ appeal.setFromApp(appId);
|
|
|
ModelMap data = new ModelMap(userspace);
|
|
|
- data.put("newAdminName", newAdmin == null ? appeal.getContactName() : newAdmin.getVipName());
|
|
|
- data.put("newAdminMobile", newAdmin == null ? appeal.getMobile() : newAdmin.getMobile());
|
|
|
- data.put("newAdminEmail", newAdmin == null ? appeal.getContactEmail() : newAdmin.getEmail());
|
|
|
+ data.put("newAdminName", Optional.ofNullable(newAdmin).map(User::getVipName).orElse(appeal.getContactName()));
|
|
|
+ data.put("newAdminMobile", Optional.ofNullable(newAdmin).map(User::getMobile).orElse(appeal.getMobile()));
|
|
|
+ data.put("newAdminEmail", Optional.ofNullable(newAdmin).map(User::getEmail).orElse(appeal.getContactEmail()));
|
|
|
appeal.setSubmitInfo(JSON.toJSONString(data));
|
|
|
appeal.setStatus((short) Status.TO_BE_CERTIFIED.getCode());
|
|
|
appeal.setType(Appeal.Type.CHANGE_ADMIN.getDesc());
|
|
|
- if (SystemSession.getUserAccount() != null) {
|
|
|
- appeal.setSubmitterUU(SystemSession.getUserAccount().getUserUU());
|
|
|
- appeal.setSubmitterName(SystemSession.getUserAccount().getVipName());
|
|
|
- }
|
|
|
+
|
|
|
+ // 如何登录,提交人信息改成登录用户
|
|
|
+ Optional.ofNullable(SystemSession.getUserAccount()).ifPresent(value -> {
|
|
|
+ appeal.setSubmitterUU(value.getUserUU());
|
|
|
+ appeal.setSubmitterName(value.getVipName());
|
|
|
+ });
|
|
|
|
|
|
// 保存申述信息
|
|
|
appealDao.save(appeal);
|
|
|
@@ -85,11 +113,9 @@ public class AppealServiceImpl implements AppealService {
|
|
|
@Override
|
|
|
public void submitValidAccount(Appeal appeal, String password) {
|
|
|
// 设置默认信息
|
|
|
- if (SystemSession.getUserAccount() == null) {
|
|
|
- throw new VisibleError("用户未登录");
|
|
|
- }
|
|
|
+ UserAccount userAccount = Optional.ofNullable(SystemSession.getUserAccount()).orElseThrow(() -> new VisibleError("用户未登录"));
|
|
|
appeal.setSubmitDate(new Timestamp(System.currentTimeMillis()));
|
|
|
- User user = userService.findOne(SystemSession.getUserAccount().getUserUU());
|
|
|
+ User user = userService.findOne(userAccount.getUserUU());
|
|
|
ModelMap data = new ModelMap();
|
|
|
data.put("password", password);
|
|
|
data.put("oldMobile", user.getMobile());
|
|
|
@@ -97,8 +123,8 @@ public class AppealServiceImpl implements AppealService {
|
|
|
appeal.setSubmitInfo(JSON.toJSONString(data));
|
|
|
appeal.setStatus((short) Status.TO_BE_CERTIFIED.getCode());
|
|
|
appeal.setType(Appeal.Type.VALID_ACCOUNT.getDesc());
|
|
|
- appeal.setSubmitterUU(SystemSession.getUserAccount().getUserUU());
|
|
|
- appeal.setSubmitterName(SystemSession.getUserAccount().getVipName());
|
|
|
+ appeal.setSubmitterUU(userAccount.getUserUU());
|
|
|
+ appeal.setSubmitterName(userAccount.getVipName());
|
|
|
|
|
|
// 保存申述信息
|
|
|
appealDao.save(appeal);
|