Pārlūkot izejas kodu

1.添加解绑申请接口

yuanliang 2 gadi atpakaļ
vecāks
revīzija
1724bc0d61

+ 27 - 1
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/TenantUnbindRecordController.java

@@ -4,10 +4,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.SysArea;
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.entity.TenantUnbindRecord;
 import com.yonge.cooleshow.biz.dal.service.EmployeeService;
+import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.SysAreaService;
+import com.yonge.cooleshow.biz.dal.service.TeacherService;
 import com.yonge.cooleshow.biz.dal.service.TenantUnbindRecordService;
 import com.yonge.cooleshow.biz.dal.vo.EmployeeVo;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantUnbindRecordWrapper;
@@ -52,6 +57,12 @@ public class TenantUnbindRecordController extends BaseController {
     @Autowired
     private EmployeeService employeeService;
 
+    @Autowired
+    private StudentService studentService;
+
+    @Autowired
+    private TeacherService teacherService;
+
 
     @ApiOperation(value = "查询分页", notes = "机构解绑申请记录- 传入 TenantUnbindRecordVo.TenantUnbindRecordQuery")
     @PostMapping("/page")
@@ -85,7 +96,8 @@ public class TenantUnbindRecordController extends BaseController {
     @ApiOperation(value = "审核")
     @PostMapping("/audit")
     public HttpResponseResult<Boolean> audit(@RequestBody TenantUnbindRecordWrapper.Audio audio) {
-        if (sysUserFeignService.queryUserInfo() == null) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
             throw new BizException("请登录");
         }
         EmployeeVo employeeVo = employeeService.detail(sysUserFeignService.queryUserInfo().getId());
@@ -106,6 +118,20 @@ public class TenantUnbindRecordController extends BaseController {
         if (!update) {
             throw new BizException("审核失败,请刷新后重试");
         }
+
+        if (audio.getStatus()) {
+            TenantUnbindRecord unbindRecord = tenantUnbindRecordService.getById(audio.getId());
+            String userType = unbindRecord.getUserType();
+            if ("STUDENT".equals(userType)) {
+                studentService.lambdaUpdate()
+                        .set(Student::getTenantId, -1L)
+                        .eq(Student::getUserId, unbindRecord.getUserId()).update();
+            } else if ("TEACHER".equals(userType)) {
+                teacherService.lambdaUpdate()
+                        .set(Teacher::getTenantId, -1L)
+                        .eq(Teacher::getUserId, unbindRecord.getUserId()).update();
+            }
+        }
         return succeed();
     }
 

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/StudentWrapper.java

@@ -113,4 +113,15 @@ public class StudentWrapper {
         private Boolean bindTenant;
 
     }
+
+    @Data
+    @ApiModel("解绑机构")
+    public static class UnbindTenant{
+
+        @ApiModelProperty("短信验证码")
+        private String code;
+
+        @ApiModelProperty("解绑原因")
+        private String unbindReason;
+    }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantUnbindRecordWrapper.java

@@ -154,7 +154,7 @@ public class TenantUnbindRecordWrapper {
         @ApiModelProperty("审核记录的ID")
         private Long id;
 
-        @ApiModelProperty("审核状态")
+        @ApiModelProperty("审核状态,true:通过,false:驳回")
         private Boolean status;
 
         @ApiModelProperty("审核理由")

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/teacher/TeacherWrapper.java

@@ -94,4 +94,15 @@ public class TeacherWrapper {
         @ApiModelProperty("结算方式")
         private ESettlementFrom settlementFrom;
     }
+
+    @Data
+    @ApiModel("解绑机构")
+    public static class UnbindTenant{
+
+        @ApiModelProperty("短信验证码")
+        private String code;
+
+        @ApiModelProperty("解绑原因")
+        private String unbindReason;
+    }
 }

+ 63 - 12
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentController.java

@@ -5,28 +5,36 @@ import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.search.QueryMyFollowSearch;
+import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
+import com.yonge.cooleshow.biz.dal.entity.TenantUnbindRecord;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.service.SmsCodeService;
+import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.SysUserService;
-import com.yonge.cooleshow.biz.dal.vo.StudentVo;
-import com.yonge.toolset.base.exception.BizException;
-import com.yonge.toolset.mybatis.support.PageUtil;
+import com.yonge.cooleshow.biz.dal.service.TenantUnbindRecordService;
 import com.yonge.cooleshow.biz.dal.vo.MyFollow;
 import com.yonge.cooleshow.biz.dal.vo.StudentHomeVo;
+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.toolset.base.page.PageInfo;
 import com.yonge.toolset.base.util.StringUtil;
-import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
+import com.yonge.toolset.mybatis.support.PageUtil;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
-import com.yonge.toolset.utils.idcard.IdcardValidator;
-import io.swagger.annotations.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
-
-import com.yonge.cooleshow.biz.dal.entity.Student;
-import com.yonge.cooleshow.biz.dal.service.StudentService;
+import org.springframework.web.bind.annotation.GetMapping;
+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.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
 import java.util.List;
@@ -43,10 +51,16 @@ public class StudentController extends BaseController {
     @Autowired
     private SysUserService sysUserService;
 
+    @Autowired
+    private TenantUnbindRecordService tenantUnbindRecordService;
+
+    @Autowired
+    private SmsCodeService smsCodeService;
+
 
     @ApiOperation(value = "查询指定学员信息")
     @GetMapping("/queryUserById")
-    public HttpResponseResult<StudentVo> queryUserById(String rongCloudUserId) {
+    public HttpResponseResult<com.yonge.cooleshow.biz.dal.vo.StudentVo> queryUserById(String rongCloudUserId) {
 
         if (StringUtil.isEmpty(rongCloudUserId)) {
             return failed("用户信息获取失败");
@@ -130,9 +144,46 @@ public class StudentController extends BaseController {
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        IdcardInfoExtractor idcardInfoExtractor = sysUserService.updateUserCard(realNameAuthDto, user,ClientEnum.STUDENT);
+        IdcardInfoExtractor idcardInfoExtractor = sysUserService.updateUserCard(realNameAuthDto, user,
+                ClientEnum.STUDENT);
         return succeed(idcardInfoExtractor);
     }
 
+    @PostMapping("/unbindTenant")
+    @ApiOperation(value = "解绑机构申请")
+    public HttpResponseResult<Boolean> unbindTenant(@RequestBody StudentWrapper.UnbindTenant unbindTenant) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        if (StringUtils.isEmpty(unbindTenant.getCode())) {
+            return failed("验证码不能为空");
+        }
+        boolean validCode = smsCodeService.verifyValidCode(user.getPhone(), unbindTenant.getCode(), "");
+        if (validCode) {
+            return failed("验证码错误");
+        }
+        if (user.getTenantId() == null || user.getTenantId() == -1) {
+            return failed("非机构用户不需要解绑");
+        }
+
+        TenantUnbindRecord one = tenantUnbindRecordService.lambdaQuery()
+                .eq(TenantUnbindRecord::getTenantId, user.getTenantId())
+                .eq(TenantUnbindRecord::getUserType, "STUDENT")
+                .eq(TenantUnbindRecord::getUserId, user.getId())
+                .eq(TenantUnbindRecord::getStatus, "DOING")
+                .last("limit 1").one();
+        if (one != null) {
+            return failed("请勿重复申请");
+        }
+        TenantUnbindRecord tenantUnbindRecord = new TenantUnbindRecord();
+        tenantUnbindRecord.setTenantId(user.getTenantId());
+        tenantUnbindRecord.setUserId(user.getId());
+        tenantUnbindRecord.setUserType("STUDENT");
+        tenantUnbindRecord.setUnbindReason(unbindTenant.getUnbindReason());
+        tenantUnbindRecord.setStatus("DOING");
+        tenantUnbindRecordService.save(tenantUnbindRecord);
+        return succeed();
+    }
 
 }

+ 49 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherController.java

@@ -2,8 +2,13 @@ package com.yonge.cooleshow.teacher.controller;
 
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
+import com.yonge.cooleshow.biz.dal.entity.TenantUnbindRecord;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.service.SmsCodeService;
 import com.yonge.cooleshow.biz.dal.service.SysUserService;
+import com.yonge.cooleshow.biz.dal.service.TenantUnbindRecordService;
+import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -11,6 +16,7 @@ import io.swagger.annotations.ApiParam;
 
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
@@ -45,6 +51,12 @@ public class TeacherController extends BaseController {
     @Autowired
     private SysUserService sysUserService;
 
+    @Autowired
+    private SmsCodeService smsCodeService;
+
+    @Autowired
+    private TenantUnbindRecordService tenantUnbindRecordService;
+
     @ApiOperation(value = "我的-查询教师基本信息")
     @GetMapping("/queryUserInfo")
     public HttpResponseResult<TeacherHomeVo> queryUserInfo() {
@@ -172,4 +184,41 @@ public class TeacherController extends BaseController {
         IdcardInfoExtractor idcardInfoExtractor = sysUserService.updateUserCard(realNameAuthDto, user, ClientEnum.TEACHER);
         return succeed(idcardInfoExtractor);
     }
+
+    @PostMapping("/unbindTenant")
+    @ApiOperation(value = "解绑机构申请")
+    public HttpResponseResult<Boolean> unbindTenant(@RequestBody TeacherWrapper.UnbindTenant unbindTenant) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        if (StringUtils.isEmpty(unbindTenant.getCode())) {
+            return failed("验证码不能为空");
+        }
+        boolean validCode = smsCodeService.verifyValidCode(user.getPhone(), unbindTenant.getCode(), "");
+        if (validCode) {
+            return failed("验证码错误");
+        }
+        if (user.getTenantId() == null || user.getTenantId() == -1) {
+            return failed("非机构用户不需要解绑");
+        }
+
+        TenantUnbindRecord one = tenantUnbindRecordService.lambdaQuery()
+                .eq(TenantUnbindRecord::getTenantId, user.getTenantId())
+                .eq(TenantUnbindRecord::getUserType, "TEACHER")
+                .eq(TenantUnbindRecord::getUserId, user.getId())
+                .eq(TenantUnbindRecord::getStatus, "DOING")
+                .last("limit 1").one();
+        if (one != null) {
+            return failed("请勿重复申请");
+        }
+        TenantUnbindRecord tenantUnbindRecord = new TenantUnbindRecord();
+        tenantUnbindRecord.setTenantId(user.getTenantId());
+        tenantUnbindRecord.setUserId(user.getId());
+        tenantUnbindRecord.setUserType("TEACHER");
+        tenantUnbindRecord.setUnbindReason(unbindTenant.getUnbindReason());
+        tenantUnbindRecord.setStatus("DOING");
+        tenantUnbindRecordService.save(tenantUnbindRecord);
+        return succeed();
+    }
 }