瀏覽代碼

1.添加声部开放接口

yuanliang 1 年之前
父節點
當前提交
847d63caa5

+ 16 - 1
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenStudentController.java

@@ -5,6 +5,8 @@ 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.enums.MessageTypeEnum;
+import com.yonge.cooleshow.biz.dal.service.SmsCodeService;
 import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
@@ -14,6 +16,7 @@ import com.yonge.cooleshow.tenant.vo.StudentVo;
 import com.yonge.toolset.base.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -36,9 +39,20 @@ public class OpenStudentController extends BaseController {
     @Resource
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private SmsCodeService smsCodeService;
+
     @PostMapping("/save")
     @ApiOperation(value = "新增/修改", notes = "传入Student,换绑时按照返回错误码5004判断,是否需要换绑,updateTenant=true表示换绑")
     public HttpResponseResult<Boolean> save(@Validated @RequestBody StudentVo.Student student) {
+        String code = student.getCode();
+        if (StringUtils.isEmpty(code)) {
+            throw new BizException("验证码不能为空");
+        }
+        if (!smsCodeService.verifyValidCode(student.getPhone(), code,
+                MessageTypeEnum.SMS_VERIFY_CODE_REGISTER.getCode())) {
+            throw new BizException("验证码错误");
+        }
         Long tenantId = student.getTenantId();
         if (tenantId == null) {
             throw new BizException("未指定机构");
@@ -64,7 +78,8 @@ public class OpenStudentController extends BaseController {
             if (one != null) {
                 if (one.getTenantId().equals(-1L)) {
                     throw new BizException("该手机号已经注册为平台学生");
-                } else if (!one.getTenantId().equals(tenantId) && !student.getUpdateTenant()) {
+                } else if (!one.getTenantId().equals(tenantId) && (student.getUpdateTenant() == null ||
+                        !student.getUpdateTenant())) {
                     throw new BizException(5004, "该手机号已经注册为其他平台学生");
                 }
             }

+ 39 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenSubjectController.java

@@ -0,0 +1,39 @@
+package com.yonge.cooleshow.tenant.controller.open;
+
+import com.yonge.cooleshow.biz.dal.entity.Subject;
+import com.yonge.cooleshow.biz.dal.queryInfo.SubjectQueryInfo;
+import com.yonge.cooleshow.biz.dal.service.SubjectService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.base.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+@RequestMapping("/open/subject")
+@Api(tags = "声部服务")
+@RestController
+public class OpenSubjectController extends BaseController {
+
+	@Autowired
+	private SubjectService subjectService;
+
+	@ApiOperation(value = "根据声部编号查询声部")
+	@GetMapping("/get/{id}")
+	public Object get(@ApiParam(value = "声部编号", required = true) @PathVariable("id") Long id) {
+		return succeed(subjectService.get(id));
+	}
+
+	@ApiOperation(value = "分页查询声部树状列表")
+	@PostMapping("/queryPageTree")
+	public HttpResponseResult<PageInfo<Subject>> queryPageTree(@RequestBody SubjectQueryInfo queryInfo) {
+		return succeed(subjectService.queryPageTree(queryInfo));
+	}
+}

+ 1 - 1
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenSysAreaController.java

@@ -1,4 +1,4 @@
-package com.yonge.cooleshow.tenant.controller;
+package com.yonge.cooleshow.tenant.controller.open;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;

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

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
 import java.time.LocalDate;
 
 @ApiModel("学生入参模型")
@@ -13,7 +14,7 @@ public class StudentVo {
 
     @Data
     @ApiModel("添加/修改学生")
-    public static class Student{
+    public static class Student {
 
         @ApiModelProperty("id")
         private Long id;
@@ -33,7 +34,7 @@ public class StudentVo {
         private LocalDate birthdate;
 
         @ApiModelProperty("手机号码")
-        @NotNull
+        @Pattern(regexp = "^1\\d{10}$", message = "请输入正确的手机号码")
         private String phone;
 
         @ApiModelProperty("头像")
@@ -44,5 +45,8 @@ public class StudentVo {
 
         @ApiModelProperty("是否换绑机构,开放接口使用参数")
         private Boolean updateTenant;
+
+        @ApiModelProperty("短信验证码")
+        private String code;
     }
 }