feat: 实现邮箱绑定与解绑功能
- 实现邮箱绑定接口,支持通过验证码绑定邮箱 - 实现邮箱解绑接口,支持用户解绑已绑定的邮箱 - 添加BindEmailRequest DTO用于邮箱绑定请求 - 完善Swagger文档注解,提升API文档可读性 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package cn.meowrain.aioj.backend.userservice.controller;
|
||||
|
||||
import cn.meowrain.aioj.backend.framework.core.utils.ContextHolderUtils;
|
||||
import cn.meowrain.aioj.backend.framework.core.web.Result;
|
||||
import cn.meowrain.aioj.backend.framework.core.web.Results;
|
||||
import cn.meowrain.aioj.backend.userservice.dto.req.BindEmailRequest;
|
||||
import cn.meowrain.aioj.backend.userservice.dto.req.EmailSendCodeRequestDTO;
|
||||
import cn.meowrain.aioj.backend.userservice.dto.req.UserRegisterRequestDTO;
|
||||
import cn.meowrain.aioj.backend.userservice.dto.resp.UserAuthRespDTO;
|
||||
@@ -53,6 +55,7 @@ public class UserController {
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
@Operation(summary = "发送验证码", description = "根据用户注册的邮箱发送验证码")
|
||||
@GetMapping("/email/send-code")
|
||||
public Result<Void> getVerifyCode(@Parameter(description = "邮箱信息", required = true)
|
||||
@Valid @RequestParam EmailSendCodeRequestDTO request) {
|
||||
@@ -62,16 +65,27 @@ public class UserController {
|
||||
|
||||
/**
|
||||
* 绑定邮箱
|
||||
*
|
||||
* @param request 邮箱绑定请求体
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "绑定邮箱", description = "根据用户注册的邮箱绑定邮箱")
|
||||
@PostMapping("/email/bind")
|
||||
public Result<Void> bindEmail(@RequestBody String email) {
|
||||
// TODO: 待实现
|
||||
return null;
|
||||
public Result<Void> bindEmail(@RequestBody BindEmailRequest request) {
|
||||
userService.bindEmail(request.getEmail(), request.getCode());
|
||||
return Results.success(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑邮箱
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "解绑邮箱", description = "根据用户注册的邮箱解绑邮箱")
|
||||
@PostMapping("/email/unbind")
|
||||
public Result<Void> unbindEmail() {
|
||||
// TODO: 待实现
|
||||
return null;
|
||||
public Result<Void> unbindEmail(@RequestBody String email) {
|
||||
userService.unbindEmail(ContextHolderUtils.getCurrentUserId());
|
||||
return Results.success(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.meowrain.aioj.backend.userservice.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 邮箱绑定请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "邮箱绑定请求体")
|
||||
public class BindEmailRequest {
|
||||
@Schema(description = "邮箱",example = "123@qq.com")
|
||||
private String email;
|
||||
@Schema(description = "验证码",example = "123456")
|
||||
private String code;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.meowrain.aioj.backend.userservice.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
@@ -8,8 +9,10 @@ import lombok.Data;
|
||||
* 用户注册的邮箱 请求对象
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户注册的邮箱 请求对象")
|
||||
public class EmailSendCodeRequestDTO {
|
||||
@NotNull
|
||||
@Email
|
||||
@Schema(description = "邮箱",example = "123@qq.com")
|
||||
String email;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user