mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-24 03:29:29 +08:00
优化
This commit is contained in:
@@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.domain.CourseChapter;
|
||||
import xyz.playedu.api.event.CourseChapterDestroyEvent;
|
||||
@@ -63,7 +63,7 @@ public class CourseChapterController {
|
||||
return JsonResponse.error("当前章节下面存在课时无法删除");
|
||||
}
|
||||
chapterService.removeById(chapter.getId());
|
||||
ctx.publishEvent(new CourseChapterDestroyEvent(this, PlayEduBCtx.getAdminUserID(), chapter.getCourseId(), chapter.getId()));
|
||||
ctx.publishEvent(new CourseChapterDestroyEvent(this, BCtx.getAdminUserID(), chapter.getCourseId(), chapter.getId()));
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.domain.*;
|
||||
import xyz.playedu.api.event.CourseDestroyEvent;
|
||||
@@ -191,7 +191,7 @@ public class CourseController {
|
||||
@DeleteMapping("/{id}")
|
||||
public JsonResponse destroy(@PathVariable(name = "id") Integer id) {
|
||||
courseService.removeById(id);
|
||||
ctx.publishEvent(new CourseDestroyEvent(this, PlayEduBCtx.getAdminUserID(), id));
|
||||
ctx.publishEvent(new CourseDestroyEvent(this, BCtx.getAdminUserID(), id));
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.CourseChapter;
|
||||
@@ -87,7 +87,7 @@ public class CourseHourController {
|
||||
}
|
||||
|
||||
CourseHour courseHour = hourService.create(courseId, chapterId, req.getSort(), req.getTitle(), type, req.getRid(), req.getDuration());
|
||||
ctx.publishEvent(new CourseHourCreatedEvent(this, PlayEduBCtx.getAdminUserID(), courseHour.getCourseId(), courseHour.getChapterId(), courseHour.getId()));
|
||||
ctx.publishEvent(new CourseHourCreatedEvent(this, BCtx.getAdminUserID(), courseHour.getCourseId(), courseHour.getChapterId(), courseHour.getId()));
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CourseHourController {
|
||||
|
||||
// 只需要发布一次event就可以了
|
||||
CourseHour firstHour = hours.get(0);
|
||||
ctx.publishEvent(new CourseHourCreatedEvent(this, PlayEduBCtx.getAdminUserID(), firstHour.getCourseId(), firstHour.getChapterId(), firstHour.getId()));
|
||||
ctx.publishEvent(new CourseHourCreatedEvent(this, BCtx.getAdminUserID(), firstHour.getCourseId(), firstHour.getChapterId(), firstHour.getId()));
|
||||
|
||||
return JsonResponse.success();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class CourseHourController {
|
||||
public JsonResponse destroy(@PathVariable(name = "courseId") Integer courseId, @PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
||||
hourService.removeById(courseHour.getId());
|
||||
ctx.publishEvent(new CourseHourDestroyEvent(this, PlayEduBCtx.getAdminUserID(), courseHour.getCourseId(), courseHour.getChapterId(), courseHour.getId()));
|
||||
ctx.publishEvent(new CourseHourDestroyEvent(this, BCtx.getAdminUserID(), courseHour.getCourseId(), courseHour.getChapterId(), courseHour.getId()));
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.event.DepartmentDestroyEvent;
|
||||
@@ -117,7 +117,7 @@ public class DepartmentController {
|
||||
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
|
||||
Department department = departmentService.findOrFail(id);
|
||||
departmentService.deleteById(department.getId());
|
||||
ctx.publishEvent(new DepartmentDestroyEvent(this, PlayEduBCtx.getAdminUserID(), department.getId()));
|
||||
ctx.publishEvent(new DepartmentDestroyEvent(this, BCtx.getAdminUserID(), department.getId()));
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.bus.BackendBus;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
import xyz.playedu.api.domain.AdminUser;
|
||||
@@ -74,7 +74,7 @@ public class LoginController {
|
||||
|
||||
@GetMapping("/detail")
|
||||
public JsonResponse detail() {
|
||||
AdminUser user = PlayEduBCtx.getAdminUser();
|
||||
AdminUser user = BCtx.getAdminUser();
|
||||
HashMap<String, Boolean> permissions = backendBus.adminUserPermissions(user.getId());
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
@@ -86,7 +86,7 @@ public class LoginController {
|
||||
|
||||
@PutMapping("/password")
|
||||
public JsonResponse changePassword(@RequestBody @Validated PasswordChangeRequest req) {
|
||||
AdminUser user = PlayEduBCtx.getAdminUser();
|
||||
AdminUser user = BCtx.getAdminUser();
|
||||
String password = HelperUtil.MD5(req.getOldPassword() + user.getSalt());
|
||||
if (!password.equals(user.getPassword())) {
|
||||
return JsonResponse.error("原密码不正确");
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.Resource;
|
||||
@@ -124,7 +124,7 @@ public class ResourceCategoryController {
|
||||
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
|
||||
ResourceCategory category = categoryService.findOrFail(id);
|
||||
categoryService.deleteById(category.getId());
|
||||
ctx.publishEvent(new ResourceCategoryDestroyEvent(this, PlayEduBCtx.getAdminUserID(), category.getId()));
|
||||
ctx.publishEvent(new ResourceCategoryDestroyEvent(this, BCtx.getAdminUserID(), category.getId()));
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.bus.BackendBus;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
@@ -70,7 +70,7 @@ public class ResourceController {
|
||||
filter.setName(name);
|
||||
|
||||
if (!backendBus.isSuperAdmin()) {// 非超管只能读取它自己上传的资源
|
||||
filter.setAdminId(PlayEduBCtx.getAdminUserID());
|
||||
filter.setAdminId(BCtx.getAdminUserID());
|
||||
}
|
||||
|
||||
PaginationResult<Resource> result = resourceService.paginate(page, size, filter);
|
||||
|
||||
@@ -4,7 +4,7 @@ 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.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.service.ImageCaptchaService;
|
||||
import xyz.playedu.api.types.ImageCaptchaResult;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
@@ -33,7 +33,7 @@ public class SystemController {
|
||||
|
||||
@GetMapping("/config")
|
||||
public JsonResponse config() {
|
||||
Map<String, String> data = PlayEduBCtx.getConfig();
|
||||
Map<String, String> data = BCtx.getConfig();
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.Resource;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
@@ -40,7 +40,7 @@ public class UploadController {
|
||||
@PostMapping("/minio")
|
||||
public JsonResponse uploadMinio(@RequestParam HashMap<String, Object> params, MultipartFile file) throws ServiceException {
|
||||
String categoryIds = MapUtils.getString(params, "category_ids");
|
||||
Resource res = uploadService.storeMinio(PlayEduBCtx.getAdminUserID(), file, categoryIds);
|
||||
Resource res = uploadService.storeMinio(BCtx.getAdminUserID(), file, categoryIds);
|
||||
return JsonResponse.data(res);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class UploadController {
|
||||
|
||||
// 视频素材保存
|
||||
Resource videoResource = resourceService.create(
|
||||
PlayEduBCtx.getAdminUserID(),
|
||||
BCtx.getAdminUserID(),
|
||||
req.getCategoryIds(),
|
||||
type,
|
||||
req.getOriginalFilename(),
|
||||
@@ -104,7 +104,7 @@ public class UploadController {
|
||||
url
|
||||
);
|
||||
// 视频封面素材保存
|
||||
Resource posterResource = uploadService.storeBase64Image(PlayEduBCtx.getAdminUserID(), req.getPoster(), null);
|
||||
Resource posterResource = uploadService.storeBase64Image(BCtx.getAdminUserID(), req.getPoster(), null);
|
||||
// 视频的封面素材改为[隐藏 && 属于视频的子素材]
|
||||
resourceService.changeParentId(posterResource.getId(), videoResource.getId());
|
||||
// 视频信息
|
||||
|
||||
Reference in New Issue
Block a user