|
|
@@ -30,12 +30,15 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.persistence.criteria.*;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import static javafx.scene.input.KeyCode.Q;
|
|
|
+
|
|
|
/**
|
|
|
* 用户service实现类
|
|
|
*
|
|
|
@@ -543,6 +546,49 @@ public class UserServiceImpl implements UserService {
|
|
|
userRecordDao.save(userRecord);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public User updateUser(@NotNull Long userUU, User newUser) {
|
|
|
+ User oldUser = userDao.findOne(userUU);
|
|
|
+ if (oldUser == null) {
|
|
|
+ throw new VisibleError("未找到用户信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改手机号
|
|
|
+ if (!StringUtils.isEmpty(newUser.getMobile()) && !newUser.getMobile().equals(oldUser.getMobile())) {
|
|
|
+ if (mobileHasRegistered(newUser.getMobile())) {
|
|
|
+ throw new VisibleError("手机号已被注册");
|
|
|
+ }
|
|
|
+ if (!newUser.getMobile().matches(Const.REGEXP_MOBILE_CONTINENT)) {
|
|
|
+ throw new VisibleError("请输入正确的手机号");
|
|
|
+ }
|
|
|
+ oldUser.setMobile(newUser.getMobile());
|
|
|
+ oldUser.setMobileValidCode((short) Status.NOT_APPLYING.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改邮箱
|
|
|
+ if (!StringUtils.isEmpty(newUser.getEmail()) && !newUser.getEmail().equals(oldUser.getEmail())) {
|
|
|
+ if (emailHasRegistered(newUser.getEmail())) {
|
|
|
+ throw new VisibleError("邮箱已被注册");
|
|
|
+ }
|
|
|
+ if (!newUser.getEmail().matches(Const.REGEXP_EMAIL)) {
|
|
|
+ throw new VisibleError("请输入正确的邮箱");
|
|
|
+ }
|
|
|
+ oldUser.setEmail(newUser.getEmail());
|
|
|
+ oldUser.setEmailValidCode((short) Status.NOT_APPLYING.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改用户名
|
|
|
+ if (!StringUtils.isEmpty(newUser.getVipName())) {
|
|
|
+ oldUser.setVipName(newUser.getVipName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存用户信息
|
|
|
+ oldUser = userDao.save(oldUser);
|
|
|
+
|
|
|
+ oldUser = syncUserInfo(oldUser, null, "(接口调用)修改用户信息");
|
|
|
+ return oldUser;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 同步用户信息到各个应用
|
|
|
* @param userUU 用户uu号
|