resolve conflcit

This commit is contained in:
none 2023-07-29 09:39:10 +08:00
parent b9623983c7
commit ae13fa0201
19 changed files with 127 additions and 29 deletions

View File

@ -35,5 +35,8 @@ public enum BusinessType {
LOGIN,
/** 退出登录 */
LOGOUT
LOGOUT,
/** 上传 */
UPLOAD
}

View File

@ -21,8 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.AdminPermission;
import xyz.playedu.api.domain.AdminRole;
import xyz.playedu.api.exception.NotFoundException;
@ -48,6 +50,7 @@ public class AdminRoleController {
@Autowired private AdminPermissionService permissionService;
@GetMapping("/index")
@Log(title = "管理员角色-列表", businessType = BusinessType.GET)
public JsonResponse index() {
List<AdminRole> data = roleService.list();
return JsonResponse.data(data);
@ -55,6 +58,7 @@ public class AdminRoleController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@GetMapping("/create")
@Log(title = "管理员角色-新建", businessType = BusinessType.GET)
public JsonResponse create() {
List<AdminPermission> permissions = permissionService.listOrderBySortAsc();
@ -68,6 +72,7 @@ public class AdminRoleController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@PostMapping("/create")
@Log(title = "管理员角色-新建", businessType = BusinessType.INSERT)
public JsonResponse store(@RequestBody @Validated AdminRoleRequest request) {
roleService.createWithPermissionIds(request.getName(), request.getPermissionIds());
return JsonResponse.success();
@ -75,6 +80,7 @@ public class AdminRoleController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@GetMapping("/{id}")
@Log(title = "管理员角色-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
AdminRole role = roleService.findOrFail(id);
@ -108,6 +114,7 @@ public class AdminRoleController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@PutMapping("/{id}")
@Log(title = "管理员角色-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@PathVariable(name = "id") Integer id, @RequestBody @Validated AdminRoleRequest request)
throws NotFoundException {
@ -123,6 +130,7 @@ public class AdminRoleController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@DeleteMapping("/{id}")
@Log(title = "管理员角色-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) throws NotFoundException {
AdminRole role = roleService.findOrFail(id);

View File

@ -22,7 +22,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.AdminRole;
import xyz.playedu.api.domain.AdminUser;
import xyz.playedu.api.exception.NotFoundException;
@ -51,6 +53,7 @@ public class AdminUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_INDEX)
@GetMapping("/index")
@Log(title = "管理员-列表", businessType = BusinessType.GET)
public JsonResponse Index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -83,6 +86,7 @@ public class AdminUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@GetMapping("/create")
@Log(title = "管理员-新建", businessType = BusinessType.GET)
public JsonResponse create() {
List<AdminRole> roles = roleService.list();
@ -94,9 +98,10 @@ public class AdminUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@PostMapping("/create")
@Log(title = "管理员-新建", businessType = BusinessType.INSERT)
public JsonResponse store(@RequestBody @Validated AdminUserRequest req)
throws ServiceException {
if (req.getPassword() == null || req.getPassword().length() == 0) {
if (req.getPassword().length() == 0) {
return JsonResponse.error("请输入密码");
}
@ -112,6 +117,7 @@ public class AdminUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@GetMapping("/{id}")
@Log(title = "管理员-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
AdminUser adminUser = adminUserService.findOrFail(id);
List<Integer> roleIds = adminUserService.getRoleIdsByUserId(adminUser.getId());
@ -125,6 +131,7 @@ public class AdminUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@PutMapping("/{id}")
@Log(title = "管理员-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@PathVariable Integer id, @RequestBody @Validated AdminUserRequest req)
throws NotFoundException, ServiceException {
@ -141,6 +148,7 @@ public class AdminUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@DeleteMapping("/{id}")
@Log(title = "管理员-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable Integer id) {
adminUserService.removeWithRoleIds(id);
return JsonResponse.success();

View File

@ -18,7 +18,9 @@ package xyz.playedu.api.controller.backend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.constant.SystemConstant;
import xyz.playedu.api.domain.AppConfig;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
@ -30,11 +32,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @Author 杭州白书科技有限公司
*
* @create 2023/3/9 11:14
*/
@RestController
@RequestMapping("/backend/v1/app-config")
public class AppConfigController {
@ -43,6 +40,7 @@ public class AppConfigController {
@BackendPermissionMiddleware(slug = BPermissionConstant.SYSTEM_CONFIG)
@GetMapping("")
@Log(title = "系统配置-读取", businessType = BusinessType.GET)
public JsonResponse index() {
List<AppConfig> configs = configService.allShow();
List<AppConfig> data = new ArrayList<>();
@ -57,6 +55,7 @@ public class AppConfigController {
@BackendPermissionMiddleware(slug = BPermissionConstant.SYSTEM_CONFIG)
@PutMapping("")
@Log(title = "系统配置-保存", businessType = BusinessType.UPDATE)
public JsonResponse save(@RequestBody AppConfigRequest req) {
HashMap<String, String> data = new HashMap<>();
req.getData()

View File

@ -21,7 +21,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.CourseChapter;
import xyz.playedu.api.event.CourseChapterDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
@ -32,11 +34,6 @@ import xyz.playedu.api.service.CourseChapterService;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.types.JsonResponse;
/**
* @Author 杭州白书科技有限公司
*
* @create 2023/2/26 17:28
*/
@RestController
@RequestMapping("/backend/v1/course/{courseId}/chapter")
public class CourseChapterController {
@ -49,6 +46,7 @@ public class CourseChapterController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Log(title = "线上课-章节-新建", businessType = BusinessType.GET)
public JsonResponse store(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseChapterRequest req) {
@ -58,6 +56,7 @@ public class CourseChapterController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-章节-编辑", businessType = BusinessType.GET)
public JsonResponse edit(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -68,6 +67,7 @@ public class CourseChapterController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Log(title = "线上课-章节-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id,
@ -80,6 +80,7 @@ public class CourseChapterController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-章节-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -96,6 +97,7 @@ public class CourseChapterController {
}
@PutMapping("/update/sort")
@Log(title = "线上课-章节-更新排序", businessType = BusinessType.UPDATE)
public JsonResponse updateSort(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseChapterSortRequest req) {

View File

@ -25,7 +25,10 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.*;
import xyz.playedu.api.event.CourseDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
@ -62,6 +65,7 @@ public class CourseController {
@Autowired private ApplicationContext ctx;
@GetMapping("/index")
@Log(title = "线上课-列表", businessType = BusinessType.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -107,6 +111,7 @@ public class CourseController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Transactional
@Log(title = "线上课-新建", businessType = BusinessType.INSERT)
public JsonResponse store(@RequestBody @Validated CourseRequest req) throws ParseException {
if (req.getShortDesc().length() > 200) {
return JsonResponse.error("课程简短介绍不能超过200字");
@ -222,6 +227,7 @@ public class CourseController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
Course course = courseService.findOrFail(id);
List<Integer> depIds = courseService.getDepIdsByCourseId(course.getId());
@ -248,6 +254,7 @@ public class CourseController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Transactional
@Log(title = "线上课-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@PathVariable(name = "id") Integer id, @RequestBody @Validated CourseRequest req)
throws NotFoundException {
@ -266,6 +273,7 @@ public class CourseController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) {
courseService.removeById(id);
ctx.publishEvent(new CourseDestroyEvent(this, BCtx.getId(), id));

View File

@ -24,8 +24,10 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.CourseChapter;
import xyz.playedu.api.domain.CourseHour;
import xyz.playedu.api.event.CourseHourCreatedEvent;
@ -60,6 +62,7 @@ public class CourseHourController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@GetMapping("/create")
@Log(title = "线上课-课时-新建", businessType = BusinessType.GET)
public JsonResponse create(@PathVariable(name = "courseId") Integer courseId) {
// 课时类型
List<SelectOption<String>> typeItems = new ArrayList<>();
@ -83,6 +86,7 @@ public class CourseHourController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Log(title = "线上课-课时-新建", businessType = BusinessType.INSERT)
public JsonResponse store(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseHourRequest req)
@ -127,6 +131,7 @@ public class CourseHourController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PostMapping("/create-batch")
@Transactional
@Log(title = "线上课-课时-批量导入", businessType = BusinessType.INSERT)
public JsonResponse storeMulti(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseHourMultiRequest req) {
@ -177,6 +182,7 @@ public class CourseHourController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-课时-编辑", businessType = BusinessType.GET)
public JsonResponse edit(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -187,6 +193,7 @@ public class CourseHourController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Log(title = "线上课-课时-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id,
@ -203,6 +210,7 @@ public class CourseHourController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-课时-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -220,6 +228,7 @@ public class CourseHourController {
}
@PutMapping("/update/sort")
@Log(title = "线上课-课时-更新排序", businessType = BusinessType.UPDATE)
public JsonResponse updateSort(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseHourSortRequest req) {

View File

@ -24,7 +24,9 @@ import org.springframework.context.ApplicationContext;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.User;
import xyz.playedu.api.domain.UserCourseRecord;
import xyz.playedu.api.event.UserCourseRecordDestroyEvent;
@ -66,6 +68,7 @@ public class CourseUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE_USER)
@GetMapping("/index")
@SneakyThrows
@Log(title = "线上课-学习记录-列表", businessType = BusinessType.GET)
public JsonResponse index(
@PathVariable(name = "courseId") Integer courseId,
@RequestParam HashMap<String, Object> params) {
@ -140,6 +143,7 @@ public class CourseUserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE_USER_DESTROY)
@PostMapping("/destroy")
@Log(title = "线上课-学习记录-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseUserDestroyRequest req) {

View File

@ -20,7 +20,9 @@ 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.annotation.Log;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.constant.SystemConstant;
import xyz.playedu.api.domain.User;
import xyz.playedu.api.domain.UserLearnDurationStats;
@ -57,6 +59,7 @@ public class DashboardController {
@Autowired private UserLearnDurationStatsService userLearnDurationStatsService;
@GetMapping("/index")
@Log(title = "主面板", businessType = BusinessType.GET)
public JsonResponse index() {
HashMap<String, Object> data = new HashMap<>();
data.put("version", SystemConstant.VERSION);

View File

@ -24,7 +24,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.Course;
import xyz.playedu.api.domain.Department;
import xyz.playedu.api.domain.User;
@ -60,6 +62,7 @@ public class DepartmentController {
@Autowired private ApplicationContext ctx;
@GetMapping("/index")
@Log(title = "部门-列表", businessType = BusinessType.GET)
public JsonResponse index() {
HashMap<String, Object> data = new HashMap<>();
data.put("departments", departmentService.groupByParent());
@ -69,6 +72,7 @@ public class DepartmentController {
}
@GetMapping("/departments")
@Log(title = "部门-全部部门", businessType = BusinessType.GET)
public JsonResponse index(
@RequestParam(name = "parent_id", defaultValue = "0") Integer parentId) {
List<Department> departments = departmentService.listByParentId(parentId);
@ -77,6 +81,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@GetMapping("/create")
@Log(title = "部门-新建", businessType = BusinessType.GET)
public JsonResponse create() {
HashMap<String, Object> data = new HashMap<>();
data.put("departments", departmentService.groupByParent());
@ -85,6 +90,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@PostMapping("/create")
@Log(title = "部门-新建", businessType = BusinessType.INSERT)
public JsonResponse store(@RequestBody @Validated DepartmentRequest req)
throws NotFoundException {
departmentService.create(req.getName(), req.getParentId(), req.getSort());
@ -93,6 +99,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@GetMapping("/{id}")
@Log(title = "部门-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
Department department = departmentService.findOrFail(id);
return JsonResponse.data(department);
@ -100,6 +107,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@PutMapping("/{id}")
@Log(title = "部门-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(@PathVariable Integer id, @RequestBody DepartmentRequest req)
throws NotFoundException {
Department department = departmentService.findOrFail(id);
@ -109,6 +117,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@GetMapping("/{id}/destroy")
@Log(title = "部门-批量删除", businessType = BusinessType.DELETE)
public JsonResponse preDestroy(@PathVariable Integer id) {
List<Integer> courseIds = departmentService.getCourseIdsByDepId(id);
List<Integer> userIds = departmentService.getUserIdsByDepId(id);
@ -149,6 +158,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@DeleteMapping("/{id}")
@Log(title = "部门-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
Department department = departmentService.findOrFail(id);
departmentService.destroy(department.getId());
@ -158,6 +168,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@PutMapping("/update/sort")
@Log(title = "部门-更新排序", businessType = BusinessType.UPDATE)
public JsonResponse resort(@RequestBody @Validated DepartmentSortRequest req) {
departmentService.resetSort(req.getIds());
return JsonResponse.success();
@ -165,6 +176,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@PutMapping("/update/parent")
@Log(title = "部门-更新父级", businessType = BusinessType.UPDATE)
public JsonResponse updateParent(@RequestBody @Validated DepartmentParentRequest req)
throws NotFoundException {
departmentService.changeParent(req.getId(), req.getParentId(), req.getIds());
@ -173,6 +185,7 @@ public class DepartmentController {
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_USER_LEARN)
@GetMapping("/{id}/users")
@Log(title = "部门-学员", businessType = BusinessType.GET)
public JsonResponse users(
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);

View File

@ -21,8 +21,10 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.Resource;
import xyz.playedu.api.domain.ResourceCategory;
import xyz.playedu.api.event.ResourceCategoryDestroyEvent;
@ -57,6 +59,7 @@ public class ResourceCategoryController {
@Autowired private ApplicationContext ctx;
@GetMapping("/index")
@Log(title = "资源-分类-列表", businessType = BusinessType.GET)
public JsonResponse index() {
HashMap<String, Object> data = new HashMap<>();
data.put("categories", categoryService.groupByParent());
@ -64,6 +67,7 @@ public class ResourceCategoryController {
}
@GetMapping("/categories")
@Log(title = "资源-分类-全部分类", businessType = BusinessType.GET)
public JsonResponse index(
@RequestParam(name = "parent_id", defaultValue = "0") Integer parentId) {
List<ResourceCategory> categories = categoryService.listByParentId(parentId);
@ -71,6 +75,7 @@ public class ResourceCategoryController {
}
@GetMapping("/create")
@Log(title = "资源-分类-新建", businessType = BusinessType.GET)
public JsonResponse create() {
HashMap<String, Object> data = new HashMap<>();
data.put("categories", categoryService.groupByParent());
@ -79,6 +84,7 @@ public class ResourceCategoryController {
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@PostMapping("/create")
@Log(title = "资源-分类-新建", businessType = BusinessType.INSERT)
public JsonResponse store(@RequestBody @Validated ResourceCategoryRequest req)
throws NotFoundException {
categoryService.create(req.getName(), req.getParentId(), req.getSort());
@ -87,6 +93,7 @@ public class ResourceCategoryController {
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@GetMapping("/{id}")
@Log(title = "资源-分类-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
ResourceCategory category = categoryService.findOrFail(id);
return JsonResponse.data(category);
@ -94,6 +101,7 @@ public class ResourceCategoryController {
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@PutMapping("/{id}")
@Log(title = "资源-分类-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(@PathVariable Integer id, @RequestBody ResourceCategoryRequest req)
throws NotFoundException {
ResourceCategory category = categoryService.findOrFail(id);
@ -103,6 +111,7 @@ public class ResourceCategoryController {
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@GetMapping("/{id}/destroy")
@Log(title = "资源-分类-批量删除", businessType = BusinessType.DELETE)
public JsonResponse preDestroy(@PathVariable Integer id) {
List<Integer> courseIds = categoryService.getCourseIdsById(id);
List<Integer> rids = categoryService.getRidsById(id);
@ -151,6 +160,7 @@ public class ResourceCategoryController {
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@DeleteMapping("/{id}")
@Log(title = "资源-分类-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
ResourceCategory category = categoryService.findOrFail(id);
categoryService.deleteById(category.getId());
@ -159,12 +169,14 @@ public class ResourceCategoryController {
}
@PutMapping("/update/sort")
@Log(title = "资源-分类-更新排序", businessType = BusinessType.UPDATE)
public JsonResponse resort(@RequestBody @Validated ResourceCategorySortRequest req) {
categoryService.resetSort(req.getIds());
return JsonResponse.success();
}
@PutMapping("/update/parent")
@Log(title = "资源-分类-更新父级", businessType = BusinessType.UPDATE)
public JsonResponse updateParent(@RequestBody @Validated ResourceCategoryParentRequest req)
throws NotFoundException {
categoryService.changeParent(req.getId(), req.getParentId(), req.getIds());

View File

@ -24,8 +24,10 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.bus.BackendBus;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.AdminUser;
import xyz.playedu.api.domain.Resource;
import xyz.playedu.api.domain.ResourceVideo;
@ -59,6 +61,7 @@ public class ResourceController {
@Autowired private BackendBus backendBus;
@GetMapping("/index")
@Log(title = "资源-列表", businessType = BusinessType.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -120,6 +123,7 @@ public class ResourceController {
@DeleteMapping("/{id}")
@Transactional
@SneakyThrows
@Log(title = "资源-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) throws NotFoundException {
Resource resource = resourceService.findOrFail(id);
@ -142,6 +146,7 @@ public class ResourceController {
@PostMapping("/destroy-multi")
@SneakyThrows
@Log(title = "资源-批量列表", businessType = BusinessType.DELETE)
public JsonResponse multiDestroy(@RequestBody ResourceDestroyMultiRequest req) {
if (req.getIds() == null || req.getIds().size() == 0) {
return JsonResponse.error("请选择需要删除的资源");
@ -174,6 +179,7 @@ public class ResourceController {
@GetMapping("/{id}")
@SneakyThrows
@Log(title = "资源-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) {
Resource resource = resourceService.findOrFail(id);
@ -191,6 +197,7 @@ public class ResourceController {
@PutMapping("/{id}")
@SneakyThrows
@Log(title = "资源-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@RequestBody @Validated ResourceUpdateRequest req,
@PathVariable(name = "id") Integer id) {

View File

@ -22,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.constant.CConfig;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.util.RequestUtil;
@ -37,6 +39,7 @@ import java.util.Map;
public class SystemController {
@GetMapping("/config")
@Log(title = "其它-系统配置", businessType = BusinessType.GET)
public JsonResponse config() {
Map<String, String> configData = BCtx.getConfig();

View File

@ -24,7 +24,9 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.Resource;
import xyz.playedu.api.exception.ServiceException;
import xyz.playedu.api.request.backend.UploadFileMergeRequest;
@ -47,6 +49,7 @@ public class UploadController {
@Autowired private ResourceService resourceService;
@PostMapping("/minio")
@Log(title = "上传-MinIO", businessType = BusinessType.UPLOAD)
public JsonResponse uploadMinio(
@RequestParam HashMap<String, Object> params, MultipartFile file)
throws ServiceException {
@ -56,6 +59,7 @@ public class UploadController {
}
@GetMapping("/minio/upload-id")
@Log(title = "上传-MinIO-uploadId", businessType = BusinessType.UPLOAD)
public JsonResponse minioUploadId(@RequestParam HashMap<String, Object> params) {
String extension = MapUtils.getString(params, "extension");
if (extension == null || extension.trim().length() == 0) {
@ -79,6 +83,7 @@ public class UploadController {
}
@GetMapping("/minio/pre-sign-url")
@Log(title = "上传-MinIO-签名URL", businessType = BusinessType.UPLOAD)
public JsonResponse minioPreSignUrl(@RequestParam HashMap<String, Object> params) {
String uploadId = MapUtils.getString(params, "upload_id");
Integer partNumber = MapUtils.getInteger(params, "part_number");
@ -93,6 +98,7 @@ public class UploadController {
}
@PostMapping("/minio/merge-file")
@Log(title = "上传-MinIO-文件合并", businessType = BusinessType.UPLOAD)
public JsonResponse minioMergeFile(@RequestBody @Validated UploadFileMergeRequest req)
throws ServiceException {
String type = BackendConstant.RESOURCE_EXT_2_TYPE.get(req.getExtension());
@ -138,6 +144,7 @@ public class UploadController {
}
@GetMapping("/minio/merge")
@Log(title = "上传-MinIO-文件合并", businessType = BusinessType.UPLOAD)
public JsonResponse minioMerge(@RequestParam HashMap<String, Object> params) {
String filename = MapUtils.getString(params, "filename");
String uploadId = MapUtils.getString(params, "upload_id");

View File

@ -29,7 +29,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.constant.CConfig;
import xyz.playedu.api.constant.SystemConstant;
import xyz.playedu.api.domain.*;
@ -85,6 +87,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_INDEX)
@GetMapping("/index")
@Log(title = "学员-列表", businessType = BusinessType.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -146,12 +149,14 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
@GetMapping("/create")
@Log(title = "学员-新建", businessType = BusinessType.GET)
public JsonResponse create() {
return JsonResponse.data(null);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
@PostMapping("/create")
@Log(title = "学员-新建", businessType = BusinessType.INSERT)
public JsonResponse store(@RequestBody @Validated UserRequest req) {
String email = req.getEmail();
if (userService.emailIsExists(email)) {
@ -173,6 +178,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_UPDATE)
@GetMapping("/{id}")
@Log(title = "学员-编辑", businessType = BusinessType.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
User user = userService.findOrFail(id);
@ -188,6 +194,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_UPDATE)
@PutMapping("/{id}")
@Transactional
@Log(title = "学员-编辑", businessType = BusinessType.UPDATE)
public JsonResponse update(
@PathVariable(name = "id") Integer id, @RequestBody @Validated UserRequest req)
throws NotFoundException {
@ -211,6 +218,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_DESTROY)
@DeleteMapping("/{id}")
@Log(title = "学员-删除", businessType = BusinessType.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) throws NotFoundException {
User user = userService.findOrFail(id);
userService.removeById(user.getId());
@ -220,6 +228,7 @@ public class UserController {
@PostMapping("/store-batch")
@Transactional
@Log(title = "学员-批量导入", businessType = BusinessType.INSERT)
public JsonResponse batchStore(@RequestBody @Validated UserImportRequest req) {
List<UserImportRequest.UserItem> users = req.getUsers();
if (users.size() == 0) {
@ -384,6 +393,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-hours")
@SneakyThrows
@Log(title = "学员-已学习课时列表", businessType = BusinessType.GET)
public JsonResponse learnHours(
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
@ -419,6 +429,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-courses")
@Log(title = "学员-已学习课程列表", businessType = BusinessType.GET)
public JsonResponse latestLearnCourses(
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
@ -454,6 +465,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/all-courses")
@Log(title = "学员-课程", businessType = BusinessType.GET)
public JsonResponse allCourses(@PathVariable(name = "id") Integer id) {
// 读取学员关联的部门
List<Integer> depIds = userService.getDepIdsByUserId(id);
@ -516,6 +528,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-course/{courseId}")
@SneakyThrows
@Log(title = "学员-单个课程的学习记录", businessType = BusinessType.GET)
public JsonResponse learnCourseDetail(
@PathVariable(name = "id") Integer id,
@PathVariable(name = "courseId") Integer courseId) {
@ -537,6 +550,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-stats")
@SneakyThrows
@Log(title = "学员-学习统计", businessType = BusinessType.GET)
public JsonResponse learn(@PathVariable(name = "id") Integer id) {
// 最近一个月的每天学习时长
String todayStr = DateTime.now().toDateStr();
@ -584,6 +598,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN_DESTROY)
@DeleteMapping("/{id}/learn-course/{courseId}")
@SneakyThrows
@Log(title = "学员-线上课学习记录删除", businessType = BusinessType.DELETE)
public JsonResponse destroyUserCourse(
@PathVariable(name = "id") Integer id,
@PathVariable(name = "courseId") Integer courseId) {
@ -595,6 +610,7 @@ public class UserController {
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN_DESTROY)
@DeleteMapping("/{id}/learn-course/{courseId}/hour/{hourId}")
@SneakyThrows
@Log(title = "学员-线上课课时学习记录删除", businessType = BusinessType.DELETE)
public JsonResponse destroyUserHour(
@PathVariable(name = "id") Integer id,
@PathVariable(name = "courseId") Integer courseId,

View File

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.io.Serializable;

View File

@ -16,7 +16,9 @@
package xyz.playedu.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import xyz.playedu.api.domain.CourseAttachment;
@Mapper

View File

@ -16,6 +16,7 @@
package xyz.playedu.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import xyz.playedu.api.domain.CourseAttachment;
import xyz.playedu.api.exception.NotFoundException;
@ -29,12 +30,7 @@ public interface CourseAttachmentService extends IService<CourseAttachment> {
List<CourseAttachment> getAttachmentsByCourseId(Integer courseId);
CourseAttachment create(
Integer courseId,
Integer sort,
String title,
String type,
Integer rid);
CourseAttachment create(Integer courseId, Integer sort, String title, String type, Integer rid);
Integer getCountByCourseId(Integer courseId);

View File

@ -16,7 +16,9 @@
package xyz.playedu.api.service.impl.internal;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import xyz.playedu.api.domain.CourseAttachment;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.mapper.CourseAttachmentMapper;
@ -27,12 +29,14 @@ import java.util.Date;
import java.util.List;
@Service
public class CourseAttachmentServiceImpl extends ServiceImpl<CourseAttachmentMapper, CourseAttachment>
public class CourseAttachmentServiceImpl
extends ServiceImpl<CourseAttachmentMapper, CourseAttachment>
implements CourseAttachmentService {
@Override
public CourseAttachment findOrFail(Integer id, Integer courseId) throws NotFoundException {
CourseAttachment attachment = getOne(query().getWrapper().eq("id", id).eq("course_id", courseId));
CourseAttachment attachment =
getOne(query().getWrapper().eq("id", id).eq("course_id", courseId));
if (attachment == null) {
throw new NotFoundException("附件不存在");
}
@ -40,10 +44,7 @@ public class CourseAttachmentServiceImpl extends ServiceImpl<CourseAttachmentMap
}
@Override
public void update(
CourseAttachment courseAttachment,
Integer sort,
String title) {
public void update(CourseAttachment courseAttachment, Integer sort, String title) {
CourseAttachment attachment = new CourseAttachment();
attachment.setId(courseAttachment.getId());
attachment.setSort(sort);
@ -59,11 +60,7 @@ public class CourseAttachmentServiceImpl extends ServiceImpl<CourseAttachmentMap
@Override
public CourseAttachment create(
Integer courseId,
Integer sort,
String title,
String type,
Integer rid) {
Integer courseId, Integer sort, String title, String type, Integer rid) {
CourseAttachment attachment = new CourseAttachment();
attachment.setCourseId(courseId);
attachment.setSort(sort);