Browse Source

1.接口同步更新

yuanliang 1 year ago
parent
commit
9a077b2dcb

+ 17 - 3
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/StudentController.java

@@ -33,6 +33,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -206,16 +207,29 @@ public class StudentController extends BaseController {
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        if (user.getTenantId() == null || user.getTenantId() == -1L) {
-            return failed("非机构用户不允许更换机构");
-        }
 
         Student student = studentService.getById(user.getId());
         if (student == null) {
             return failed("未查询到学生的信息");
         }
 
+        if (student.getTenantId() == null || student.getTenantId() == -1L) {
+            return failed("非机构用户不允许更换机构");
+        }
+
         studentService.updateTenant(student, updateTenant.getTenantId());
         return succeed();
     }
+
+
+    @PostMapping("/add")
+    @ApiOperation(value = "新增", notes = "传入Student")
+    public HttpResponseResult<Boolean> add(@Validated @RequestBody StudentWrapper.Student student) {
+        SysUser sysUser = sysUserFeignService.queryUserByMobile(student.getPhone());
+        if (sysUser != null && sysUser.getUserType().contains(ClientEnum.STUDENT.getCode())) {
+            throw new BizException("学生账号已经存在");
+        }
+        studentService.addStudent(student);
+        return succeed();
+    }
 }

+ 7 - 17
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenStudentController.java

@@ -80,8 +80,7 @@ public class OpenStudentController extends BaseController {
         if (StringUtils.isEmpty(code)) {
             throw new BizException("验证码不能为空");
         }
-        if (!smsCodeService.verifyValidCode(student.getPhone(), code,
-                MessageTypeEnum.SMS_VERIFY_CODE_REGISTER.getCode())) {
+        if (!smsCodeService.verifyValidCode(student.getPhone(), code, "REGISTER")) {
             throw new BizException("验证码错误");
         }
         Long tenantId = student.getTenantId();
@@ -109,10 +108,10 @@ public class OpenStudentController extends BaseController {
                 if (one.getTenantId().equals(-1L)) {
                     throw new BizException("该手机号已经注册为平台学生");
                 }
-//                if (one.getTenantId().equals(tenantId)) {
-//                    //已经注册当前机构,请勿重复注册
-//                    throw new BizException(5004, tenantInfo.getName());
-//                }
+                if (one.getTenantId().equals(tenantId)) {
+                    //已经注册当前机构,请勿重复注册
+                    throw new BizException("已经注册当前机构,请勿重复注册");
+                }
                 // 转到其他机构
                 if ((!Objects.equals(student.getTenantId(), one.getTenantId()))) {
                     if(student.getUpdateTenant() == null || Boolean.FALSE.equals(student.getUpdateTenant())){
@@ -134,6 +133,8 @@ public class OpenStudentController extends BaseController {
                                 log.error("学生注册,切换机构退群失败:{}", e.getMessage());
                             }
                         });
+                        // 删除好友
+                        imUserFriendService.delFriendByTenantId(tenantId, one.getUserId());
                     }
                 }
 
@@ -145,17 +146,6 @@ public class OpenStudentController extends BaseController {
             student.setId(studentId);
         }
 
-        // 配置头像
-        String avatar = student.getAvatar();
-        if (StringUtils.isEmpty(avatar)) {
-            if (student.getGender().equals(1)) {
-                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_BOY);
-            } else {
-                avatar = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD_GIRL);
-            }
-            student.setAvatar(avatar);
-        }
-
         StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
         studentInfo.setTenantId(tenantInfo.getId());