Browse Source

1.问题修改

yuanliang 2 năm trước cách đây
mục cha
commit
90fbf53c5d

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

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.StudentDao;
 import com.yonge.cooleshow.biz.dal.dao.SubjectDao;
@@ -47,6 +48,7 @@ import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -441,6 +443,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
             sysUser.setGender(studentInfo.getGender());
             sysUser.setUserType("STUDENT");
             sysUser.setBirthdate(studentInfo.getBirthdate());
+
+            String newPassword = MessageFormat.format("klx{0}", studentInfo.getPhone().substring(7));
+            String password = new BCryptPasswordEncoder().encode(newPassword);
+            sysUser.setPassword(password);
             sysUserMapper.insert(sysUser);
         }
         return sysUser;

+ 5 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/StudentWrapper.java

@@ -91,7 +91,7 @@ public class StudentWrapper {
         @ApiModelProperty("id")
         private Long id;
 
-        @ApiModelProperty("机构ID")
+        @ApiModelProperty("所属机构,开放接口必填")
         private Long tenantId;
 
         @ApiModelProperty("姓名")
@@ -106,10 +106,13 @@ public class StudentWrapper {
         @ApiModelProperty("手机号码")
         private String phone;
 
+        @ApiModelProperty("头像")
+        private String avatar;
+
         @ApiModelProperty("声部,多个用逗号隔开")
         private String subjectId;
 
-        @ApiModelProperty("是否绑定机构,0:解绑,1:不解绑")
+        @ApiModelProperty("是否解绑")
         private Boolean bindTenant;
 
     }

+ 3 - 3
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/StudentController.java

@@ -7,7 +7,6 @@ import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.service.StudentService;
-import com.yonge.cooleshow.biz.dal.service.SysUserService;
 import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
 import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
@@ -29,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 @RestController
@@ -38,7 +38,7 @@ public class StudentController extends BaseController {
     @Autowired
     private StudentService studentService;
 
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
 
     @Autowired
@@ -80,8 +80,8 @@ public class StudentController extends BaseController {
     @ApiOperation(value = "新增/修改", notes = "传入Student")
     public HttpResponseResult<Boolean> save(
             @Validated @RequestBody com.yonge.cooleshow.tenant.vo.StudentVo.Student student) {
-        TenantInfo tenantInfo = getTenantInfo();
         StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
+        TenantInfo tenantInfo = getTenantInfo();
         studentInfo.setTenantId(tenantInfo.getId());
         studentService.save(studentInfo);
         return succeed();

+ 3 - 2
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenStudentController.java

@@ -7,6 +7,7 @@ import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.tenant.vo.StudentVo;
 import com.yonge.toolset.base.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -29,8 +30,7 @@ public class OpenStudentController extends BaseController {
 
     @PostMapping("/save")
     @ApiOperation(value = "新增/修改", notes = "传入Student")
-    public HttpResponseResult<Boolean> save(
-            @Validated @RequestBody com.yonge.cooleshow.tenant.vo.StudentVo.Student student) {
+    public HttpResponseResult<Boolean> save(@Validated @RequestBody StudentVo.Student student) {
         Long tenantId = student.getTenantId();
         if (tenantId == null) {
             throw new BizException("未指定机构");
@@ -39,6 +39,7 @@ public class OpenStudentController extends BaseController {
         if (tenantInfo == null) {
             throw new BizException("机构不存在");
         }
+        student.setId(null);
         StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
         studentInfo.setTenantId(tenantInfo.getId());
         studentService.save(studentInfo);

+ 6 - 3
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/StudentVo.java

@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
-import java.util.Date;
+import java.time.LocalDate;
 
 @ApiModel("学生入参模型")
 @Data
@@ -27,15 +27,18 @@ public class StudentVo {
 
         @ApiModelProperty("性别。0:女 1:男")
         @NotNull
-        private Boolean gender;
+        private Integer gender;
 
         @ApiModelProperty("生日")
-        private Date birthdate;
+        private LocalDate birthdate;
 
         @ApiModelProperty("手机号码")
         @NotNull
         private String phone;
 
+        @ApiModelProperty("头像")
+        private String avatar;
+
         @ApiModelProperty("声部,多个用逗号隔开")
         private String subjectId;