فهرست منبع

Merge branch 'feature/0317-bugfix'

Eric 2 سال پیش
والد
کامیت
397ba57d20

+ 30 - 29
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -1,32 +1,5 @@
 package com.yonge.cooleshow.auth.web.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-
-import javax.validation.Valid;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.dto.SysUserQueryInfo;
 import com.yonge.cooleshow.auth.api.dto.UpdatePasswordDto;
@@ -40,7 +13,6 @@ import com.yonge.cooleshow.auth.service.SysRoleService;
 import com.yonge.cooleshow.auth.service.SysUserRoleService;
 import com.yonge.cooleshow.auth.service.SysUserService;
 import com.yonge.cooleshow.auth.web.controller.queryInfo.RoleQueryInfo;
-import com.yonge.cooleshow.common.constant.CommonConstants;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -56,6 +28,31 @@ import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
 import com.yonge.toolset.utils.date.DateUtil;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import com.yonge.toolset.utils.idcard.IdcardValidator;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
 
 @RestController()
 @RequestMapping("user")
@@ -392,7 +389,11 @@ public class UserController extends BaseController {
             return failed("非法操作");
         }
 
-        String password = new BCryptPasswordEncoder().encode(CommonConstants.DEFULT_PASSWORD);
+        // 新密码规则:clx+手机号后四位
+        String newPassword = MessageFormat.format("clx{0}", sysUser.getPhone().substring(7));
+
+        // 生成重置默认密码
+        String password = new BCryptPasswordEncoder().encode(newPassword);
         sysUser.setPassword(password);
         sysUser.setUpdateTime(new Date());
         sysUserService.update(sysUser);

+ 26 - 20
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -41,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.text.MessageFormat;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -246,7 +247,6 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         studentResp.setSysUser(sysUser);
         if (Objects.isNull(studentVo)) {
 
-
             if (Objects.isNull(sysUser)) {
 
                 // 自动注册创建用户
@@ -259,24 +259,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
                 user.setUserType(ClientEnum.STUDENT.getCode());
                 sysUserMapper.insert(user);
 
-                studentResp.setSysUser(user);
-                String subjectId = null;
-                // 学生声部
-                if (!StringUtil.isEmpty(info.getSubjectName())) {
-                    Subject subject = subjectDao.getSubjectMatchByName(info.getSubjectName());
-                    if (Objects.nonNull(subject)) {
-                        subjectId = String.valueOf(subject.getId());
-                    }
-                }
-
-                // 添加学生帐号
-                Student student = new Student();
-                student.setUserId(user.getId());
-                student.setSubjectId(subjectId);
-                student.setUnionId(info.getUnionId());
-                student.setLockFlag(UserLockFlag.NORMAL);
-                student.setHideFlag(Optional.ofNullable(info.getLockFlag()).orElse(0));
-                save(student);
+                studentResp.username(user.getUsername()).userId(user.getId()).setSysUser(user);
 
                 // 更新标识
                 studentResp.setUpdateFlag(true);
@@ -284,7 +267,8 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 
                 com.yonge.cooleshow.biz.dal.entity.SysUser updateEntity = new com.yonge.cooleshow.biz.dal.entity.SysUser();
                 updateEntity.setId(sysUser.getId());
-                updateEntity.setDelFlag(Optional.ofNullable(info.getLockFlag()).orElse(0)); // 激活帐号
+                updateEntity.setUpdateTime(LocalDateTime.now());
+                //updateEntity.setDelFlag(Optional.ofNullable(info.getLockFlag()).orElse(0)); // 激活帐号
                 if (StringUtils.isBlank(sysUser.getUsername())) {
                     updateEntity.setUsername(info.getUsername());
                 }
@@ -295,11 +279,33 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 
                 Student student = lambdaQuery().eq(Student::getUserId, sysUser.getId()).one();
 
+                if (Objects.nonNull(student)) {
+                    // 重置学生隐藏状态
+                    info.setLockFlag(0);
+                }
                 // 更新学生关联帐号
                 updateStudentUnionStatus(info, studentResp, student);
 
             }
 
+            String subjectId = null;
+            // 学生声部
+            if (!StringUtil.isEmpty(info.getSubjectName())) {
+                Subject subject = subjectDao.getSubjectMatchByName(info.getSubjectName());
+                if (Objects.nonNull(subject)) {
+                    subjectId = String.valueOf(subject.getId());
+                }
+            }
+
+            // 添加学生帐号
+            Student student = new Student();
+            student.setUserId(studentResp.getUserId());
+            student.setSubjectId(subjectId);
+            student.setUnionId(info.getUnionId());
+            student.setLockFlag(UserLockFlag.NORMAL);
+            student.setHideFlag(Optional.ofNullable(info.getLockFlag()).orElse(0));
+            save(student);
+
         } else {
 
             studentResp.username(studentVo.getUsername()).userId(studentVo.getUserId());