mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-26 04:39:26 +08:00
added: 学员,我的课程
This commit is contained in:
@@ -21,7 +21,6 @@ import xyz.playedu.api.util.HelperUtil;
|
||||
import xyz.playedu.api.util.IpUtil;
|
||||
import xyz.playedu.api.util.RequestUtil;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
@@ -53,10 +52,13 @@ public class LoginController {
|
||||
|
||||
User user = userService.find(email);
|
||||
if (user == null) {
|
||||
return JsonResponse.error("邮箱未注册");
|
||||
return JsonResponse.error("邮箱或密码错误");
|
||||
}
|
||||
if (!HelperUtil.MD5(req.getPassword() + user.getSalt()).equals(user.getPassword())) {
|
||||
return JsonResponse.error("密码错误");
|
||||
return JsonResponse.error("邮箱或密码错误");
|
||||
}
|
||||
if (user.getIsLock() == 1) {
|
||||
return JsonResponse.error("当前学员已锁定无法登录");
|
||||
}
|
||||
|
||||
JwtToken token = jwtService.generate(user.getId(), RequestUtil.url(), SystemConstant.JWT_PRV_USER);
|
||||
|
||||
@@ -3,15 +3,18 @@ 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.PlayEduFCtx;
|
||||
import xyz.playedu.api.domain.Course;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.domain.User;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
import xyz.playedu.api.request.frontend.ChangePasswordRequest;
|
||||
import xyz.playedu.api.service.CourseService;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
import xyz.playedu.api.service.UserService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,9 +32,12 @@ public class UserController {
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@GetMapping("/detail")
|
||||
public JsonResponse detail() {
|
||||
User user = PlayEduFContext.getUser();
|
||||
User user = PlayEduFCtx.getUser();
|
||||
List<Department> departments = departmentService.listByIds(userService.getDepIdsByUserId(user.getId()));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
@@ -43,9 +49,28 @@ public class UserController {
|
||||
|
||||
@PutMapping("/password")
|
||||
public JsonResponse changePassword(@RequestBody @Validated ChangePasswordRequest req) throws ServiceException {
|
||||
userService.passwordChange(PlayEduFContext.getUser(), req.getOldPassword(), req.getNewPassword());
|
||||
userService.passwordChange(PlayEduFCtx.getUser(), req.getOldPassword(), req.getNewPassword());
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
@GetMapping("/courses")
|
||||
public JsonResponse courses() {
|
||||
// 公开课
|
||||
List<Course> openCourses = courseService.openCoursesAndShow(200);
|
||||
|
||||
// 部门课
|
||||
List<Course> depCourses = new ArrayList<>();
|
||||
List<Integer> userJoinDepIds = userService.getDepIdsByUserId(PlayEduFCtx.getUserId());
|
||||
if (userJoinDepIds != null && userJoinDepIds.size() > 0) {
|
||||
depCourses = courseService.depCoursesAndShow(userJoinDepIds);
|
||||
}
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("open", openCourses);
|
||||
data.put("department", depCourses);
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user