|
@@ -1,6 +1,9 @@
|
|
package com.yonge.cooleshow.tenant.controller.open;
|
|
package com.yonge.cooleshow.tenant.controller.open;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+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.TenantInfo;
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
@@ -18,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/open/student")
|
|
@RequestMapping("/open/student")
|
|
@Api(value = "学生表", tags = "学生表")
|
|
@Api(value = "学生表", tags = "学生表")
|
|
@@ -28,8 +33,11 @@ public class OpenStudentController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private TenantInfoService tenantInfoService;
|
|
private TenantInfoService tenantInfoService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
+
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
- @ApiOperation(value = "新增/修改", notes = "传入Student")
|
|
|
|
|
|
+ @ApiOperation(value = "新增/修改", notes = "传入Student,换绑时按照返回错误码5004判断,是否需要换绑,updateTenant=true表示换绑")
|
|
public HttpResponseResult<Boolean> save(@Validated @RequestBody StudentVo.Student student) {
|
|
public HttpResponseResult<Boolean> save(@Validated @RequestBody StudentVo.Student student) {
|
|
Long tenantId = student.getTenantId();
|
|
Long tenantId = student.getTenantId();
|
|
if (tenantId == null) {
|
|
if (tenantId == null) {
|
|
@@ -39,7 +47,31 @@ public class OpenStudentController extends BaseController {
|
|
if (tenantInfo == null) {
|
|
if (tenantInfo == null) {
|
|
throw new BizException("机构不存在");
|
|
throw new BizException("机构不存在");
|
|
}
|
|
}
|
|
- student.setId(null);
|
|
|
|
|
|
+ Long studentId = student.getId();
|
|
|
|
+
|
|
|
|
+ if (studentId == null) {
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserByMobile(student.getPhone());
|
|
|
|
+ if (sysUser != null) {
|
|
|
|
+ studentId = sysUser.getId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (studentId != null) {
|
|
|
|
+ Student one = studentService.lambdaQuery()
|
|
|
|
+ .eq(Student::getUserId, studentId)
|
|
|
|
+ .eq(Student::getHideFlag, 0)
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (one != null) {
|
|
|
|
+ if (one.getTenantId().equals(-1L)) {
|
|
|
|
+ throw new BizException("该手机号已经注册为平台学生");
|
|
|
|
+ } else if (!one.getTenantId().equals(tenantId) && !student.getUpdateTenant()) {
|
|
|
|
+ throw new BizException(5004, "该手机号已经注册为其他平台学生");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ student.setId(studentId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
|
|
StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
|
|
studentInfo.setTenantId(tenantInfo.getId());
|
|
studentInfo.setTenantId(tenantInfo.getId());
|
|
studentService.save(studentInfo);
|
|
studentService.save(studentInfo);
|