mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-25 12:22:03 +08:00
学员修改密码api
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package xyz.playedu.api.controller.frontend;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import xyz.playedu.api.service.AppConfigService;
|
||||
import xyz.playedu.api.service.ImageCaptchaService;
|
||||
import xyz.playedu.api.types.ImageCaptchaResult;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/3/13 11:26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/system")
|
||||
public class SystemController {
|
||||
|
||||
@Autowired
|
||||
private AppConfigService appConfigService;
|
||||
|
||||
@Autowired
|
||||
private ImageCaptchaService imageCaptchaService;
|
||||
|
||||
@GetMapping("/config")
|
||||
public JsonResponse config() {
|
||||
Map<String, String> data = appConfigService.keyValues();
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@GetMapping("/image-captcha")
|
||||
public JsonResponse imageCaptcha() throws IOException {
|
||||
ImageCaptchaResult imageCaptchaResult = imageCaptchaService.generate();
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("key", imageCaptchaResult.getKey());
|
||||
data.put("image", imageCaptchaResult.getImage());
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package xyz.playedu.api.controller.frontend;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduFContext;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
import xyz.playedu.api.request.frontend.ChangePasswordRequest;
|
||||
import xyz.playedu.api.service.UserService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -13,13 +17,17 @@ import xyz.playedu.api.types.JsonResponse;
|
||||
@RequestMapping("/api/v1/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/detail")
|
||||
public JsonResponse detail() {
|
||||
return JsonResponse.data(null);
|
||||
}
|
||||
|
||||
@PutMapping("/password")
|
||||
public JsonResponse changePassword(@RequestBody @Validated ChangePasswordRequest req) {
|
||||
public JsonResponse changePassword(@RequestBody @Validated ChangePasswordRequest req) throws ServiceException {
|
||||
userService.passwordChange(PlayEduFContext.getUser(), req.getOldPassword(), req.getNewPassword());
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user