Merge pull request !6 from 白书科技/feat-splitmodule20230804
This commit is contained in:
白书科技 2023-08-07 00:49:30 +00:00 committed by Gitee
commit acffce65ba
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
316 changed files with 2636 additions and 2765 deletions

60
playedu-api/pom.xml Normal file
View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>xyz.playedu</groupId>
<artifactId>playedu</artifactId>
<version>1.2</version>
</parent>
<artifactId>playedu-api</artifactId>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>xyz.playedu</groupId>
<artifactId>playedu-common</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>xyz.playedu</groupId>
<artifactId>playedu-system</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>xyz.playedu</groupId>
<artifactId>playedu-course</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>xyz.playedu</groupId>
<artifactId>playedu-resource</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<fork>true</fork> <!-- 如果没有该配置devtools不会生效 -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -15,16 +15,17 @@
*/
package xyz.playedu.api;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import xyz.playedu.api.config.UniqueNameGenerator;
import xyz.playedu.common.config.UniqueNameGeneratorConfig;
@SpringBootApplication
@EnableAsync
@ComponentScan(nameGenerator = UniqueNameGenerator.class)
@ComponentScan(basePackages = {"xyz.playedu"}, nameGenerator = UniqueNameGeneratorConfig.class)
@MapperScan("xyz.playedu.**.mapper")
public class PlayeduApiApplication {
public static void main(String[] args) {

View File

@ -25,11 +25,10 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import xyz.playedu.api.exception.LimitException;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.exception.ServiceException;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.common.exception.LimitException;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.common.types.JsonResponse;
import java.util.List;

View File

@ -24,23 +24,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.bus.BackendBus;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.*;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.api.service.AdminLogService;
import xyz.playedu.api.service.AdminUserService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.AdminLogPaginateFiler;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.bus.BackendBus;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.common.domain.AdminLog;
import xyz.playedu.common.service.AdminLogService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.AdminLogPaginateFiler;
import xyz.playedu.common.types.paginate.PaginationResult;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@Slf4j
@ -49,13 +45,11 @@ public class AdminLogController {
@Autowired private AdminLogService adminLogService;
@Autowired private AdminUserService adminUserService;
@Autowired private BackendBus backendBus;
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_LOG)
@BackendPermission(slug = BPermissionConstant.ADMIN_LOG)
@GetMapping("/index")
@Log(title = "管理员日志-列表", businessType = BusinessType.GET)
@Log(title = "管理员日志-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);

View File

@ -21,18 +21,18 @@ 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;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.domain.AdminPermission;
import xyz.playedu.common.domain.AdminRole;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.AdminRoleRequest;
import xyz.playedu.api.service.AdminPermissionService;
import xyz.playedu.api.service.AdminRoleService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.common.service.AdminPermissionService;
import xyz.playedu.common.service.AdminRoleService;
import xyz.playedu.common.types.JsonResponse;
import java.util.ArrayList;
import java.util.HashMap;
@ -50,15 +50,15 @@ public class AdminRoleController {
@Autowired private AdminPermissionService permissionService;
@GetMapping("/index")
@Log(title = "管理员角色-列表", businessType = BusinessType.GET)
@Log(title = "管理员角色-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index() {
List<AdminRole> data = roleService.list();
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@BackendPermission(slug = BPermissionConstant.ADMIN_ROLE)
@GetMapping("/create")
@Log(title = "管理员角色-新建", businessType = BusinessType.GET)
@Log(title = "管理员角色-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse create() {
List<AdminPermission> permissions = permissionService.listOrderBySortAsc();
@ -70,17 +70,17 @@ public class AdminRoleController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@BackendPermission(slug = BPermissionConstant.ADMIN_ROLE)
@PostMapping("/create")
@Log(title = "管理员角色-新建", businessType = BusinessType.INSERT)
@Log(title = "管理员角色-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(@RequestBody @Validated AdminRoleRequest request) {
roleService.createWithPermissionIds(request.getName(), request.getPermissionIds());
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@BackendPermission(slug = BPermissionConstant.ADMIN_ROLE)
@GetMapping("/{id}")
@Log(title = "管理员角色-编辑", businessType = BusinessType.GET)
@Log(title = "管理员角色-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
AdminRole role = roleService.findOrFail(id);
@ -112,9 +112,9 @@ public class AdminRoleController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@BackendPermission(slug = BPermissionConstant.ADMIN_ROLE)
@PutMapping("/{id}")
@Log(title = "管理员角色-编辑", businessType = BusinessType.UPDATE)
@Log(title = "管理员角色-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable(name = "id") Integer id, @RequestBody @Validated AdminRoleRequest request)
throws NotFoundException {
@ -128,9 +128,9 @@ public class AdminRoleController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_ROLE)
@BackendPermission(slug = BPermissionConstant.ADMIN_ROLE)
@DeleteMapping("/{id}")
@Log(title = "管理员角色-删除", businessType = BusinessType.DELETE)
@Log(title = "管理员角色-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) throws NotFoundException {
AdminRole role = roleService.findOrFail(id);

View File

@ -22,20 +22,20 @@ 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;
import xyz.playedu.api.exception.ServiceException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.domain.AdminRole;
import xyz.playedu.common.domain.AdminUser;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.AdminUserRequest;
import xyz.playedu.api.service.AdminRoleService;
import xyz.playedu.api.service.AdminUserService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.AdminUserPaginateFilter;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.common.service.AdminRoleService;
import xyz.playedu.common.service.AdminUserService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.AdminUserPaginateFilter;
import xyz.playedu.common.types.paginate.PaginationResult;
import java.util.HashMap;
import java.util.List;
@ -51,9 +51,9 @@ public class AdminUserController {
@Autowired private AdminRoleService roleService;
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_INDEX)
@BackendPermission(slug = BPermissionConstant.ADMIN_USER_INDEX)
@GetMapping("/index")
@Log(title = "管理员-列表", businessType = BusinessType.GET)
@Log(title = "管理员-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse Index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -84,9 +84,9 @@ public class AdminUserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@BackendPermission(slug = BPermissionConstant.ADMIN_USER_CUD)
@GetMapping("/create")
@Log(title = "管理员-新建", businessType = BusinessType.GET)
@Log(title = "管理员-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse create() {
List<AdminRole> roles = roleService.list();
@ -96,9 +96,9 @@ public class AdminUserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@BackendPermission(slug = BPermissionConstant.ADMIN_USER_CUD)
@PostMapping("/create")
@Log(title = "管理员-新建", businessType = BusinessType.INSERT)
@Log(title = "管理员-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(@RequestBody @Validated AdminUserRequest req)
throws ServiceException {
if (req.getPassword().length() == 0) {
@ -115,9 +115,9 @@ public class AdminUserController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@BackendPermission(slug = BPermissionConstant.ADMIN_USER_CUD)
@GetMapping("/{id}")
@Log(title = "管理员-编辑", businessType = BusinessType.GET)
@Log(title = "管理员-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
AdminUser adminUser = adminUserService.findOrFail(id);
List<Integer> roleIds = adminUserService.getRoleIdsByUserId(adminUser.getId());
@ -129,9 +129,9 @@ public class AdminUserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@BackendPermission(slug = BPermissionConstant.ADMIN_USER_CUD)
@PutMapping("/{id}")
@Log(title = "管理员-编辑", businessType = BusinessType.UPDATE)
@Log(title = "管理员-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable Integer id, @RequestBody @Validated AdminUserRequest req)
throws NotFoundException, ServiceException {
@ -146,9 +146,9 @@ public class AdminUserController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.ADMIN_USER_CUD)
@BackendPermission(slug = BPermissionConstant.ADMIN_USER_CUD)
@DeleteMapping("/{id}")
@Log(title = "管理员-删除", businessType = BusinessType.DELETE)
@Log(title = "管理员-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable Integer id) {
adminUserService.removeWithRoleIds(id);
return JsonResponse.success();

View File

@ -18,15 +18,15 @@ 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;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.constant.SystemConstant;
import xyz.playedu.common.domain.AppConfig;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.AppConfigRequest;
import xyz.playedu.api.service.AppConfigService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.common.service.AppConfigService;
import xyz.playedu.common.types.JsonResponse;
import java.util.ArrayList;
import java.util.HashMap;
@ -38,9 +38,9 @@ public class AppConfigController {
@Autowired private AppConfigService configService;
@BackendPermissionMiddleware(slug = BPermissionConstant.SYSTEM_CONFIG)
@BackendPermission(slug = BPermissionConstant.SYSTEM_CONFIG)
@GetMapping("")
@Log(title = "系统配置-读取", businessType = BusinessType.GET)
@Log(title = "系统配置-读取", businessType = BusinessTypeConstant.GET)
public JsonResponse index() {
List<AppConfig> configs = configService.allShow();
List<AppConfig> data = new ArrayList<>();
@ -53,9 +53,9 @@ public class AppConfigController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.SYSTEM_CONFIG)
@BackendPermission(slug = BPermissionConstant.SYSTEM_CONFIG)
@PutMapping("")
@Log(title = "系统配置-保存", businessType = BusinessType.UPDATE)
@Log(title = "系统配置-保存", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse save(@RequestBody AppConfigRequest req) {
HashMap<String, String> data = new HashMap<>();
req.getData()

View File

@ -22,18 +22,18 @@ import org.springframework.transaction.annotation.Transactional;
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.CourseAttachment;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.course.domain.CourseAttachment;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.CourseAttachmentMultiRequest;
import xyz.playedu.api.request.backend.CourseAttachmentRequest;
import xyz.playedu.api.request.backend.CourseAttachmentSortRequest;
import xyz.playedu.api.service.CourseAttachmentService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.course.service.CourseAttachmentService;
import xyz.playedu.common.types.JsonResponse;
import java.util.*;
@ -44,9 +44,9 @@ public class CourseAttachmentController {
@Autowired private CourseAttachmentService attachmentService;
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Log(title = "线上课-附件-新建", businessType = BusinessType.INSERT)
@Log(title = "线上课-附件-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseAttachmentRequest req)
@ -71,10 +71,10 @@ public class CourseAttachmentController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PostMapping("/create-batch")
@Transactional
@Log(title = "线上课-附件-批量新建", businessType = BusinessType.INSERT)
@Log(title = "线上课-附件-批量新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse storeMulti(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseAttachmentMultiRequest req) {
@ -109,9 +109,9 @@ public class CourseAttachmentController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-附件-编辑", businessType = BusinessType.GET)
@Log(title = "线上课-附件-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -120,9 +120,9 @@ public class CourseAttachmentController {
return JsonResponse.data(courseAttachment);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Log(title = "线上课-附件-编辑", businessType = BusinessType.UPDATE)
@Log(title = "线上课-附件-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id,
@ -133,9 +133,9 @@ public class CourseAttachmentController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-附件-删除", businessType = BusinessType.DELETE)
@Log(title = "线上课-附件-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -146,7 +146,7 @@ public class CourseAttachmentController {
}
@PutMapping("/update/sort")
@Log(title = "线上课-附件-排序调整", businessType = BusinessType.UPDATE)
@Log(title = "线上课-附件-排序调整", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse updateSort(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseAttachmentSortRequest req) {

View File

@ -21,13 +21,13 @@ import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.annotation.Log;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.*;
import xyz.playedu.api.service.*;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.CourseAttachmentDownloadLogPaginateFiler;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.CourseAttachmentDownloadLogPaginateFiler;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.course.domain.CourseAttachmentDownloadLog;
import xyz.playedu.course.service.CourseAttachmentDownloadLogService;
import java.util.*;
@ -39,7 +39,7 @@ public class CourseAttachmentDownloadLogController {
@Autowired private CourseAttachmentDownloadLogService courseAttachmentDownloadLogService;
@GetMapping("/index")
@Log(title = "学员下载课件记录-列表", businessType = BusinessType.GET)
@Log(title = "学员下载课件记录-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);

View File

@ -20,19 +20,19 @@ import org.springframework.context.ApplicationContext;
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.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.course.domain.CourseChapter;
import xyz.playedu.api.event.CourseChapterDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.CourseChapterRequest;
import xyz.playedu.api.request.backend.CourseChapterSortRequest;
import xyz.playedu.api.service.CourseChapterService;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.course.service.CourseChapterService;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.common.types.JsonResponse;
@RestController
@RequestMapping("/backend/v1/course/{courseId}/chapter")
@ -44,9 +44,9 @@ public class CourseChapterController {
@Autowired private ApplicationContext ctx;
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Log(title = "线上课-章节-新建", businessType = BusinessType.GET)
@Log(title = "线上课-章节-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse store(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseChapterRequest req) {
@ -54,9 +54,9 @@ public class CourseChapterController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-章节-编辑", businessType = BusinessType.GET)
@Log(title = "线上课-章节-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -65,9 +65,9 @@ public class CourseChapterController {
return JsonResponse.data(chapter);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Log(title = "线上课-章节-编辑", businessType = BusinessType.UPDATE)
@Log(title = "线上课-章节-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id,
@ -78,9 +78,9 @@ public class CourseChapterController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-章节-删除", businessType = BusinessType.DELETE)
@Log(title = "线上课-章节-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -97,7 +97,7 @@ public class CourseChapterController {
}
@PutMapping("/update/sort")
@Log(title = "线上课-章节-更新排序", businessType = BusinessType.UPDATE)
@Log(title = "线上课-章节-更新排序", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse updateSort(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseChapterSortRequest req) {

View File

@ -24,19 +24,28 @@ import org.springframework.transaction.annotation.Transactional;
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.*;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.api.event.CourseDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.CourseRequest;
import xyz.playedu.api.service.*;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.CoursePaginateFiler;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.common.service.*;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.CoursePaginateFiler;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.course.domain.Course;
import xyz.playedu.course.domain.CourseAttachment;
import xyz.playedu.course.domain.CourseChapter;
import xyz.playedu.course.domain.CourseHour;
import xyz.playedu.course.service.CourseAttachmentService;
import xyz.playedu.course.service.CourseChapterService;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.resource.domain.Resource;
import xyz.playedu.resource.service.ResourceService;
import java.text.ParseException;
import java.util.*;
@ -50,7 +59,7 @@ public class CourseController {
@Autowired private CourseService courseService;
@Autowired private ResourceCategoryService categoryService;
@Autowired private CategoryService categoryService;
@Autowired private CourseChapterService chapterService;
@ -65,7 +74,7 @@ public class CourseController {
@Autowired private ApplicationContext ctx;
@GetMapping("/index")
@Log(title = "线上课-列表", businessType = BusinessType.GET)
@Log(title = "线上课-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -100,7 +109,7 @@ public class CourseController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@GetMapping("/create")
public JsonResponse create() {
HashMap<String, Object> data = new HashMap<>();
@ -108,10 +117,10 @@ public class CourseController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Transactional
@Log(title = "线上课-新建", businessType = BusinessType.INSERT)
@Log(title = "线上课-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(@RequestBody @Validated CourseRequest req) throws ParseException {
if (req.getShortDesc().length() > 200) {
return JsonResponse.error("课程简短介绍不能超过200字");
@ -225,9 +234,9 @@ public class CourseController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-编辑", businessType = BusinessType.GET)
@Log(title = "线上课-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
Course course = courseService.findOrFail(id);
List<Integer> depIds = courseService.getDepIdsByCourseId(course.getId());
@ -262,10 +271,10 @@ public class CourseController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Transactional
@Log(title = "线上课-编辑", businessType = BusinessType.UPDATE)
@Log(title = "线上课-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable(name = "id") Integer id, @RequestBody @Validated CourseRequest req)
throws NotFoundException {
@ -282,9 +291,9 @@ public class CourseController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-删除", businessType = BusinessType.DELETE)
@Log(title = "线上课-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) {
courseService.removeById(id);
ctx.publishEvent(new CourseDestroyEvent(this, BCtx.getId(), id));

View File

@ -23,24 +23,24 @@ import org.springframework.transaction.annotation.Transactional;
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.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.course.domain.CourseChapter;
import xyz.playedu.course.domain.CourseHour;
import xyz.playedu.api.event.CourseHourCreatedEvent;
import xyz.playedu.api.event.CourseHourDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.CourseHourMultiRequest;
import xyz.playedu.api.request.backend.CourseHourRequest;
import xyz.playedu.api.request.backend.CourseHourSortRequest;
import xyz.playedu.api.service.CourseChapterService;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.SelectOption;
import xyz.playedu.course.service.CourseChapterService;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.SelectOption;
import java.util.*;
@ -60,9 +60,9 @@ public class CourseHourController {
@Autowired private ApplicationContext ctx;
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@GetMapping("/create")
@Log(title = "线上课-课时-新建", businessType = BusinessType.GET)
@Log(title = "线上课-课时-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse create(@PathVariable(name = "courseId") Integer courseId) {
// 课时类型
List<SelectOption<String>> typeItems = new ArrayList<>();
@ -84,9 +84,9 @@ public class CourseHourController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PostMapping("/create")
@Log(title = "线上课-课时-新建", businessType = BusinessType.INSERT)
@Log(title = "线上课-课时-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseHourRequest req)
@ -128,10 +128,10 @@ public class CourseHourController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PostMapping("/create-batch")
@Transactional
@Log(title = "线上课-课时-批量导入", businessType = BusinessType.INSERT)
@Log(title = "线上课-课时-批量导入", businessType = BusinessTypeConstant.INSERT)
public JsonResponse storeMulti(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseHourMultiRequest req) {
@ -180,9 +180,9 @@ public class CourseHourController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@GetMapping("/{id}")
@Log(title = "线上课-课时-编辑", businessType = BusinessType.GET)
@Log(title = "线上课-课时-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -191,9 +191,9 @@ public class CourseHourController {
return JsonResponse.data(courseHour);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@PutMapping("/{id}")
@Log(title = "线上课-课时-编辑", businessType = BusinessType.UPDATE)
@Log(title = "线上课-课时-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id,
@ -208,9 +208,9 @@ public class CourseHourController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE)
@BackendPermission(slug = BPermissionConstant.COURSE)
@DeleteMapping("/{id}")
@Log(title = "线上课-课时-删除", businessType = BusinessType.DELETE)
@Log(title = "线上课-课时-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@PathVariable(name = "id") Integer id)
@ -228,7 +228,7 @@ public class CourseHourController {
}
@PutMapping("/update/sort")
@Log(title = "线上课-课时-更新排序", businessType = BusinessType.UPDATE)
@Log(title = "线上课-课时-更新排序", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse updateSort(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseHourSortRequest req) {

View File

@ -24,19 +24,22 @@ 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.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.domain.User;
import xyz.playedu.course.domain.UserCourseRecord;
import xyz.playedu.api.event.UserCourseRecordDestroyEvent;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.CourseUserDestroyRequest;
import xyz.playedu.api.service.*;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.api.types.paginate.UserPaginateFilter;
import xyz.playedu.common.service.*;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.common.types.paginate.UserPaginateFilter;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.course.service.UserCourseHourRecordService;
import xyz.playedu.course.service.UserCourseRecordService;
import java.util.ArrayList;
import java.util.HashMap;
@ -65,10 +68,10 @@ public class CourseUserController {
@Autowired private ApplicationContext ctx;
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE_USER)
@BackendPermission(slug = BPermissionConstant.COURSE_USER)
@GetMapping("/index")
@SneakyThrows
@Log(title = "线上课-学习记录-列表", businessType = BusinessType.GET)
@Log(title = "线上课-学习记录-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index(
@PathVariable(name = "courseId") Integer courseId,
@RequestParam HashMap<String, Object> params) {
@ -141,9 +144,9 @@ public class CourseUserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE_USER_DESTROY)
@BackendPermission(slug = BPermissionConstant.COURSE_USER_DESTROY)
@PostMapping("/destroy")
@Log(title = "线上课-学习记录-删除", businessType = BusinessType.DELETE)
@Log(title = "线上课-学习记录-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(
@PathVariable(name = "courseId") Integer courseId,
@RequestBody @Validated CourseUserDestroyRequest req) {

View File

@ -20,14 +20,17 @@ 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;
import xyz.playedu.api.service.*;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.constant.SystemConstant;
import xyz.playedu.common.domain.User;
import xyz.playedu.course.domain.UserLearnDurationStats;
import xyz.playedu.common.service.*;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.course.service.UserLearnDurationStatsService;
import xyz.playedu.resource.service.ResourceService;
import java.util.ArrayList;
import java.util.HashMap;
@ -46,7 +49,7 @@ public class DashboardController {
@Autowired private AdminUserService adminUserService;
@Autowired private ResourceCategoryService resourceCategoryService;
@Autowired private CategoryService categoryService;
@Autowired private UserService userService;
@ -59,7 +62,7 @@ public class DashboardController {
@Autowired private UserLearnDurationStatsService userLearnDurationStatsService;
@GetMapping("/index")
@Log(title = "主面板", businessType = BusinessType.GET)
@Log(title = "主面板", businessType = BusinessTypeConstant.GET)
public JsonResponse index() {
HashMap<String, Object> data = new HashMap<>();
data.put("version", SystemConstant.VERSION);
@ -71,7 +74,7 @@ public class DashboardController {
data.put("course_total", courseService.total()); // 线上课数量
data.put("department_total", departmentService.total());
data.put("resource_category_total", resourceCategoryService.total());
data.put("resource_category_total", categoryService.total());
data.put("admin_user_total", adminUserService.total());
data.put(

View File

@ -23,25 +23,28 @@ import org.springframework.context.ApplicationContext;
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;
import xyz.playedu.api.domain.UserCourseRecord;
import xyz.playedu.api.request.backend.DepartmentParentRequest;
import xyz.playedu.api.request.backend.DepartmentRequest;
import xyz.playedu.api.request.backend.DepartmentSortRequest;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.course.domain.Course;
import xyz.playedu.common.domain.Department;
import xyz.playedu.common.domain.User;
import xyz.playedu.course.domain.UserCourseRecord;
import xyz.playedu.api.event.DepartmentDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.api.request.backend.*;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.api.service.DepartmentService;
import xyz.playedu.api.service.UserCourseRecordService;
import xyz.playedu.api.service.UserService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.api.types.paginate.UserPaginateFilter;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.course.service.CourseDepartmentService;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.common.service.DepartmentService;
import xyz.playedu.course.service.UserCourseRecordService;
import xyz.playedu.common.service.UserService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.common.types.paginate.UserPaginateFilter;
import java.util.*;
import java.util.stream.Collectors;
@ -53,6 +56,8 @@ public class DepartmentController {
@Autowired private DepartmentService departmentService;
@Autowired private CourseDepartmentService courseDepartmentService;
@Autowired private UserService userService;
@Autowired private CourseService courseService;
@ -62,7 +67,7 @@ public class DepartmentController {
@Autowired private ApplicationContext ctx;
@GetMapping("/index")
@Log(title = "部门-列表", businessType = BusinessType.GET)
@Log(title = "部门-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index() {
HashMap<String, Object> data = new HashMap<>();
data.put("departments", departmentService.groupByParent());
@ -72,42 +77,42 @@ public class DepartmentController {
}
@GetMapping("/departments")
@Log(title = "部门-全部部门", businessType = BusinessType.GET)
@Log(title = "部门-全部部门", businessType = BusinessTypeConstant.GET)
public JsonResponse index(
@RequestParam(name = "parent_id", defaultValue = "0") Integer parentId) {
List<Department> departments = departmentService.listByParentId(parentId);
return JsonResponse.data(departments);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@GetMapping("/create")
@Log(title = "部门-新建", businessType = BusinessType.GET)
@Log(title = "部门-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse create() {
HashMap<String, Object> data = new HashMap<>();
data.put("departments", departmentService.groupByParent());
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@PostMapping("/create")
@Log(title = "部门-新建", businessType = BusinessType.INSERT)
@Log(title = "部门-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(@RequestBody @Validated DepartmentRequest req)
throws NotFoundException {
departmentService.create(req.getName(), req.getParentId(), req.getSort());
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@GetMapping("/{id}")
@Log(title = "部门-编辑", businessType = BusinessType.GET)
@Log(title = "部门-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
Department department = departmentService.findOrFail(id);
return JsonResponse.data(department);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@PutMapping("/{id}")
@Log(title = "部门-编辑", businessType = BusinessType.UPDATE)
@Log(title = "部门-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(@PathVariable Integer id, @RequestBody DepartmentRequest req)
throws NotFoundException {
Department department = departmentService.findOrFail(id);
@ -115,11 +120,11 @@ public class DepartmentController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@GetMapping("/{id}/destroy")
@Log(title = "部门-批量删除", businessType = BusinessType.DELETE)
@Log(title = "部门-批量删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse preDestroy(@PathVariable Integer id) {
List<Integer> courseIds = departmentService.getCourseIdsByDepId(id);
List<Integer> courseIds = courseDepartmentService.getCourseIdsByDepId(id);
List<Integer> userIds = departmentService.getUserIdsByDepId(id);
HashMap<String, Object> data = new HashMap<>();
@ -156,9 +161,9 @@ public class DepartmentController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@DeleteMapping("/{id}")
@Log(title = "部门-删除", businessType = BusinessType.DELETE)
@Log(title = "部门-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
Department department = departmentService.findOrFail(id);
departmentService.destroy(department.getId());
@ -166,26 +171,26 @@ public class DepartmentController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@PutMapping("/update/sort")
@Log(title = "部门-更新排序", businessType = BusinessType.UPDATE)
@Log(title = "部门-更新排序", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse resort(@RequestBody @Validated DepartmentSortRequest req) {
departmentService.resetSort(req.getIds());
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_CUD)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_CUD)
@PutMapping("/update/parent")
@Log(title = "部门-更新父级", businessType = BusinessType.UPDATE)
@Log(title = "部门-更新父级", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse updateParent(@RequestBody @Validated DepartmentParentRequest req)
throws NotFoundException {
departmentService.changeParent(req.getId(), req.getParentId(), req.getIds());
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_USER_LEARN)
@BackendPermission(slug = BPermissionConstant.DEPARTMENT_USER_LEARN)
@GetMapping("/{id}/users")
@Log(title = "部门-学员", businessType = BusinessType.GET)
@Log(title = "部门-学员", businessType = BusinessTypeConstant.GET)
public JsonResponse users(
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);

View File

@ -20,25 +20,25 @@ import org.springframework.context.ApplicationContext;
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.config.PlayEduConfig;
import xyz.playedu.api.constant.BPermissionConstant;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.api.domain.AdminUser;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.bus.BackendBus;
import xyz.playedu.common.config.PlayEduConfig;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.domain.AdminUser;
import xyz.playedu.api.event.AdminUserLoginEvent;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.LoginRequest;
import xyz.playedu.api.request.backend.PasswordChangeRequest;
import xyz.playedu.api.service.AdminUserService;
import xyz.playedu.api.service.BackendAuthService;
import xyz.playedu.api.service.RateLimiterService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.util.HelperUtil;
import xyz.playedu.api.util.IpUtil;
import xyz.playedu.api.util.RedisUtil;
import xyz.playedu.api.util.RequestUtil;
import xyz.playedu.common.service.AdminUserService;
import xyz.playedu.common.service.BackendAuthService;
import xyz.playedu.common.service.RateLimiterService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.util.HelperUtil;
import xyz.playedu.common.util.IpUtil;
import xyz.playedu.common.util.RedisUtil;
import xyz.playedu.common.util.RequestUtil;
import java.util.HashMap;
@ -59,7 +59,7 @@ public class LoginController {
@Autowired private PlayEduConfig playEduConfig;
@PostMapping("/login")
@Log(title = "管理员-登录", businessType = BusinessType.LOGIN)
@Log(title = "管理员-登录", businessType = BusinessTypeConstant.LOGIN)
public JsonResponse login(@RequestBody @Validated LoginRequest loginRequest) {
AdminUser adminUser = adminUserService.findByEmail(loginRequest.email);
if (adminUser == null) {
@ -103,14 +103,14 @@ public class LoginController {
}
@PostMapping("/logout")
@Log(title = "管理员-登出", businessType = BusinessType.LOGOUT)
@Log(title = "管理员-登出", businessType = BusinessTypeConstant.LOGOUT)
public JsonResponse logout() {
authService.logout();
return JsonResponse.success("success");
}
@GetMapping("/detail")
@Log(title = "管理员-详情", businessType = BusinessType.GET)
@Log(title = "管理员-详情", businessType = BusinessTypeConstant.GET)
public JsonResponse detail() {
AdminUser user = BCtx.getAdminUser();
HashMap<String, Boolean> permissions = backendBus.adminUserPermissions(user.getId());
@ -122,9 +122,9 @@ public class LoginController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.PASSWORD_CHANGE)
@BackendPermission(slug = BPermissionConstant.PASSWORD_CHANGE)
@PutMapping("/password")
@Log(title = "管理员-密码修改", businessType = BusinessType.UPDATE)
@Log(title = "管理员-密码修改", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse changePassword(@RequestBody @Validated PasswordChangeRequest req) {
AdminUser user = BCtx.getAdminUser();
String password = HelperUtil.MD5(req.getOldPassword() + user.getSalt());

View File

@ -20,23 +20,25 @@ import org.springframework.context.ApplicationContext;
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.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.domain.Category;
import xyz.playedu.common.service.CategoryService;
import xyz.playedu.course.service.CourseCategoryService;
import xyz.playedu.resource.domain.Resource;
import xyz.playedu.api.event.ResourceCategoryDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.ResourceCategoryParentRequest;
import xyz.playedu.api.request.backend.ResourceCategoryRequest;
import xyz.playedu.api.request.backend.ResourceCategorySortRequest;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.api.service.ResourceCategoryService;
import xyz.playedu.api.service.ResourceService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.resource.service.ResourceCategoryService;
import xyz.playedu.resource.service.ResourceService;
import xyz.playedu.common.types.JsonResponse;
import java.util.*;
import java.util.stream.Collectors;
@ -50,16 +52,20 @@ import java.util.stream.Collectors;
@RequestMapping("/backend/v1/resource-category")
public class ResourceCategoryController {
@Autowired private ResourceCategoryService categoryService;
@Autowired private CategoryService categoryService;
@Autowired private CourseService courseService;
@Autowired private ResourceService resourceService;
@Autowired private ResourceCategoryService resourceCategoryService;
@Autowired private CourseCategoryService courseCategoryService;
@Autowired private ApplicationContext ctx;
@GetMapping("/index")
@Log(title = "资源-分类-列表", businessType = BusinessType.GET)
@Log(title = "资源-分类-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index() {
HashMap<String, Object> data = new HashMap<>();
data.put("categories", categoryService.groupByParent());
@ -67,54 +73,54 @@ public class ResourceCategoryController {
}
@GetMapping("/categories")
@Log(title = "资源-分类-全部分类", businessType = BusinessType.GET)
@Log(title = "资源-分类-全部分类", businessType = BusinessTypeConstant.GET)
public JsonResponse index(
@RequestParam(name = "parent_id", defaultValue = "0") Integer parentId) {
List<ResourceCategory> categories = categoryService.listByParentId(parentId);
List<Category> categories = categoryService.listByParentId(parentId);
return JsonResponse.data(categories);
}
@GetMapping("/create")
@Log(title = "资源-分类-新建", businessType = BusinessType.GET)
@Log(title = "资源-分类-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse create() {
HashMap<String, Object> data = new HashMap<>();
data.put("categories", categoryService.groupByParent());
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@BackendPermission(slug = BPermissionConstant.RESOURCE_CATEGORY)
@PostMapping("/create")
@Log(title = "资源-分类-新建", businessType = BusinessType.INSERT)
@Log(title = "资源-分类-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(@RequestBody @Validated ResourceCategoryRequest req)
throws NotFoundException {
categoryService.create(req.getName(), req.getParentId(), req.getSort());
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@BackendPermission(slug = BPermissionConstant.RESOURCE_CATEGORY)
@GetMapping("/{id}")
@Log(title = "资源-分类-编辑", businessType = BusinessType.GET)
@Log(title = "资源-分类-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
ResourceCategory category = categoryService.findOrFail(id);
Category category = categoryService.findOrFail(id);
return JsonResponse.data(category);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@BackendPermission(slug = BPermissionConstant.RESOURCE_CATEGORY)
@PutMapping("/{id}")
@Log(title = "资源-分类-编辑", businessType = BusinessType.UPDATE)
@Log(title = "资源-分类-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(@PathVariable Integer id, @RequestBody ResourceCategoryRequest req)
throws NotFoundException {
ResourceCategory category = categoryService.findOrFail(id);
Category category = categoryService.findOrFail(id);
categoryService.update(category, req.getName(), req.getParentId(), req.getSort());
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@BackendPermission(slug = BPermissionConstant.RESOURCE_CATEGORY)
@GetMapping("/{id}/destroy")
@Log(title = "资源-分类-批量删除", businessType = BusinessType.DELETE)
@Log(title = "资源-分类-批量删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse preDestroy(@PathVariable Integer id) {
List<Integer> courseIds = categoryService.getCourseIdsById(id);
List<Integer> rids = categoryService.getRidsById(id);
List<Integer> courseIds = courseCategoryService.getCourseIdsByCategoryId(id);
List<Integer> rids = resourceCategoryService.getRidsByCategoryId(id);
HashMap<String, Object> data = new HashMap<>();
data.put("children", categoryService.listByParentId(id));
@ -158,25 +164,25 @@ public class ResourceCategoryController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.RESOURCE_CATEGORY)
@BackendPermission(slug = BPermissionConstant.RESOURCE_CATEGORY)
@DeleteMapping("/{id}")
@Log(title = "资源-分类-删除", businessType = BusinessType.DELETE)
@Log(title = "资源-分类-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
ResourceCategory category = categoryService.findOrFail(id);
Category category = categoryService.findOrFail(id);
categoryService.deleteById(category.getId());
ctx.publishEvent(new ResourceCategoryDestroyEvent(this, BCtx.getId(), category.getId()));
return JsonResponse.success();
}
@PutMapping("/update/sort")
@Log(title = "资源-分类-更新排序", businessType = BusinessType.UPDATE)
@Log(title = "资源-分类-更新排序", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse resort(@RequestBody @Validated ResourceCategorySortRequest req) {
categoryService.resetSort(req.getIds());
return JsonResponse.success();
}
@PutMapping("/update/parent")
@Log(title = "资源-分类-更新父级", businessType = BusinessType.UPDATE)
@Log(title = "资源-分类-更新父级", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse updateParent(@RequestBody @Validated ResourceCategoryParentRequest req)
throws NotFoundException {
categoryService.changeParent(req.getId(), req.getParentId(), req.getIds());

View File

@ -23,25 +23,25 @@ import org.springframework.transaction.annotation.Transactional;
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;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.exception.ServiceException;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.bus.BackendBus;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.domain.AdminUser;
import xyz.playedu.resource.domain.Resource;
import xyz.playedu.resource.domain.ResourceVideo;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.api.request.backend.ResourceDestroyMultiRequest;
import xyz.playedu.api.request.backend.ResourceUpdateRequest;
import xyz.playedu.api.service.AdminUserService;
import xyz.playedu.api.service.MinioService;
import xyz.playedu.api.service.ResourceService;
import xyz.playedu.api.service.ResourceVideoService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.api.types.paginate.ResourcePaginateFilter;
import xyz.playedu.common.service.AdminUserService;
import xyz.playedu.common.service.MinioService;
import xyz.playedu.resource.service.ResourceService;
import xyz.playedu.resource.service.ResourceVideoService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.common.types.paginate.ResourcePaginateFilter;
import java.util.*;
import java.util.stream.Collectors;
@ -61,7 +61,7 @@ public class ResourceController {
@Autowired private BackendBus backendBus;
@GetMapping("/index")
@Log(title = "资源-列表", businessType = BusinessType.GET)
@Log(title = "资源-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -123,7 +123,7 @@ public class ResourceController {
@DeleteMapping("/{id}")
@Transactional
@SneakyThrows
@Log(title = "资源-删除", businessType = BusinessType.DELETE)
@Log(title = "资源-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) throws NotFoundException {
Resource resource = resourceService.findOrFail(id);
@ -146,7 +146,7 @@ public class ResourceController {
@PostMapping("/destroy-multi")
@SneakyThrows
@Log(title = "资源-批量列表", businessType = BusinessType.DELETE)
@Log(title = "资源-批量列表", businessType = BusinessTypeConstant.DELETE)
public JsonResponse multiDestroy(@RequestBody ResourceDestroyMultiRequest req) {
if (req.getIds() == null || req.getIds().size() == 0) {
return JsonResponse.error("请选择需要删除的资源");
@ -179,7 +179,7 @@ public class ResourceController {
@GetMapping("/{id}")
@SneakyThrows
@Log(title = "资源-编辑", businessType = BusinessType.GET)
@Log(title = "资源-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) {
Resource resource = resourceService.findOrFail(id);
@ -197,7 +197,7 @@ public class ResourceController {
@PutMapping("/{id}")
@SneakyThrows
@Log(title = "资源-编辑", businessType = BusinessType.UPDATE)
@Log(title = "资源-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@RequestBody @Validated ResourceUpdateRequest req,
@PathVariable(name = "id") Integer id) {

View File

@ -21,12 +21,12 @@ 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.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;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.constant.ConfigConstant;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.util.RequestUtil;
import java.util.ArrayList;
import java.util.HashMap;
@ -39,11 +39,11 @@ import java.util.Map;
public class SystemController {
@GetMapping("/config")
@Log(title = "其它-系统配置", businessType = BusinessType.GET)
@Log(title = "其它-系统配置", businessType = BusinessTypeConstant.GET)
public JsonResponse config() {
Map<String, String> configData = BCtx.getConfig();
String apiUrl = configData.get(CConfig.SYSTEM_API_URL);
String apiUrl = configData.get(ConfigConstant.SYSTEM_API_URL);
if (apiUrl == null || apiUrl.trim().length() == 0) {
apiUrl = RequestUtil.uriWithProtocol();
} else {
@ -54,18 +54,18 @@ public class SystemController {
HashMap<String, Object> data = new HashMap<>();
data.put(CConfig.SYSTEM_NAME, configData.get(CConfig.SYSTEM_NAME));
data.put(CConfig.SYSTEM_LOGO, configData.get(CConfig.SYSTEM_LOGO));
data.put(CConfig.SYSTEM_API_URL, apiUrl);
data.put(CConfig.SYSTEM_PC_URL, configData.get(CConfig.SYSTEM_PC_URL));
data.put(CConfig.SYSTEM_H5_URL, configData.get(CConfig.SYSTEM_H5_URL));
data.put(ConfigConstant.SYSTEM_NAME, configData.get(ConfigConstant.SYSTEM_NAME));
data.put(ConfigConstant.SYSTEM_LOGO, configData.get(ConfigConstant.SYSTEM_LOGO));
data.put(ConfigConstant.SYSTEM_API_URL, apiUrl);
data.put(ConfigConstant.SYSTEM_PC_URL, configData.get(ConfigConstant.SYSTEM_PC_URL));
data.put(ConfigConstant.SYSTEM_H5_URL, configData.get(ConfigConstant.SYSTEM_H5_URL));
// 学员的默认头像
String memberDefaultAvatar = configData.get(CConfig.MEMBER_DEFAULT_AVATAR);
String memberDefaultAvatar = configData.get(ConfigConstant.MEMBER_DEFAULT_AVATAR);
if (memberDefaultAvatar == null || memberDefaultAvatar.trim().length() == 0) {
data.put(CConfig.MEMBER_DEFAULT_AVATAR, apiUrl + "/images/default_avatar.png");
data.put(ConfigConstant.MEMBER_DEFAULT_AVATAR, apiUrl + "/images/default_avatar.png");
} else {
data.put(CConfig.MEMBER_DEFAULT_AVATAR, memberDefaultAvatar);
data.put(ConfigConstant.MEMBER_DEFAULT_AVATAR, memberDefaultAvatar);
}
// 内置的三个线上课封面

View File

@ -23,18 +23,18 @@ import org.springframework.validation.annotation.Validated;
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.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.resource.domain.Resource;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.api.request.backend.UploadFileMergeRequest;
import xyz.playedu.api.service.MinioService;
import xyz.playedu.api.service.ResourceService;
import xyz.playedu.api.service.UploadService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.util.HelperUtil;
import xyz.playedu.common.service.MinioService;
import xyz.playedu.resource.service.ResourceService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.util.HelperUtil;
import xyz.playedu.resource.service.UploadService;
import java.util.HashMap;
@ -49,7 +49,7 @@ public class UploadController {
@Autowired private ResourceService resourceService;
@PostMapping("/minio")
@Log(title = "上传-MinIO", businessType = BusinessType.UPLOAD)
@Log(title = "上传-MinIO", businessType = BusinessTypeConstant.UPLOAD)
public JsonResponse uploadMinio(
@RequestParam HashMap<String, Object> params, MultipartFile file)
throws ServiceException {
@ -59,7 +59,7 @@ public class UploadController {
}
@GetMapping("/minio/upload-id")
@Log(title = "上传-MinIO-uploadId", businessType = BusinessType.UPLOAD)
@Log(title = "上传-MinIO-uploadId", businessType = BusinessTypeConstant.UPLOAD)
public JsonResponse minioUploadId(@RequestParam HashMap<String, Object> params) {
String extension = MapUtils.getString(params, "extension");
if (extension == null || extension.trim().length() == 0) {
@ -83,7 +83,7 @@ public class UploadController {
}
@GetMapping("/minio/pre-sign-url")
@Log(title = "上传-MinIO-签名URL", businessType = BusinessType.UPLOAD)
@Log(title = "上传-MinIO-签名URL", businessType = BusinessTypeConstant.UPLOAD)
public JsonResponse minioPreSignUrl(@RequestParam HashMap<String, Object> params) {
String uploadId = MapUtils.getString(params, "upload_id");
Integer partNumber = MapUtils.getInteger(params, "part_number");
@ -98,7 +98,7 @@ public class UploadController {
}
@PostMapping("/minio/merge-file")
@Log(title = "上传-MinIO-文件合并", businessType = BusinessType.UPLOAD)
@Log(title = "上传-MinIO-文件合并", businessType = BusinessTypeConstant.UPLOAD)
public JsonResponse minioMergeFile(@RequestBody @Validated UploadFileMergeRequest req)
throws ServiceException {
String type = BackendConstant.RESOURCE_EXT_2_TYPE.get(req.getExtension());
@ -144,7 +144,7 @@ public class UploadController {
}
@GetMapping("/minio/merge")
@Log(title = "上传-MinIO-文件合并", businessType = BusinessType.UPLOAD)
@Log(title = "上传-MinIO-文件合并", businessType = BusinessTypeConstant.UPLOAD)
public JsonResponse minioMerge(@RequestParam HashMap<String, Object> params) {
String filename = MapUtils.getString(params, "filename");
String uploadId = MapUtils.getString(params, "upload_id");

View File

@ -28,29 +28,31 @@ import org.springframework.transaction.annotation.Transactional;
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.*;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.constant.ConfigConstant;
import xyz.playedu.common.constant.SystemConstant;
import xyz.playedu.common.domain.*;
import xyz.playedu.api.event.UserCourseHourRecordDestroyEvent;
import xyz.playedu.api.event.UserCourseRecordDestroyEvent;
import xyz.playedu.api.event.UserDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.api.request.backend.UserImportRequest;
import xyz.playedu.api.request.backend.UserRequest;
import xyz.playedu.api.service.*;
import xyz.playedu.api.service.internal.UserDepartmentService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
import xyz.playedu.api.types.paginate.UserCourseRecordPaginateFilter;
import xyz.playedu.api.types.paginate.UserPaginateFilter;
import xyz.playedu.api.util.HelperUtil;
import xyz.playedu.common.service.*;
import xyz.playedu.common.service.UserDepartmentService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.mapper.UserCourseHourRecordCourseCountMapper;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.common.types.paginate.UserCourseHourRecordPaginateFilter;
import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter;
import xyz.playedu.common.types.paginate.UserPaginateFilter;
import xyz.playedu.common.util.HelperUtil;
import xyz.playedu.course.domain.*;
import xyz.playedu.course.service.*;
import java.util.*;
import java.util.stream.Collectors;
@ -85,9 +87,9 @@ public class UserController {
@Autowired private ApplicationContext ctx;
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_INDEX)
@BackendPermission(slug = BPermissionConstant.USER_INDEX)
@GetMapping("/index")
@Log(title = "学员-列表", businessType = BusinessType.GET)
@Log(title = "学员-列表", businessType = BusinessTypeConstant.GET)
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
Integer size = MapUtils.getInteger(params, "size", 10);
@ -147,16 +149,16 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
@BackendPermission(slug = BPermissionConstant.USER_STORE)
@GetMapping("/create")
@Log(title = "学员-新建", businessType = BusinessType.GET)
@Log(title = "学员-新建", businessType = BusinessTypeConstant.GET)
public JsonResponse create() {
return JsonResponse.data(null);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
@BackendPermission(slug = BPermissionConstant.USER_STORE)
@PostMapping("/create")
@Log(title = "学员-新建", businessType = BusinessType.INSERT)
@Log(title = "学员-新建", businessType = BusinessTypeConstant.INSERT)
public JsonResponse store(@RequestBody @Validated UserRequest req) {
String email = req.getEmail();
if (userService.emailIsExists(email)) {
@ -176,9 +178,9 @@ public class UserController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_UPDATE)
@BackendPermission(slug = BPermissionConstant.USER_UPDATE)
@GetMapping("/{id}")
@Log(title = "学员-编辑", businessType = BusinessType.GET)
@Log(title = "学员-编辑", businessType = BusinessTypeConstant.GET)
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
User user = userService.findOrFail(id);
@ -191,10 +193,10 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_UPDATE)
@BackendPermission(slug = BPermissionConstant.USER_UPDATE)
@PutMapping("/{id}")
@Transactional
@Log(title = "学员-编辑", businessType = BusinessType.UPDATE)
@Log(title = "学员-编辑", businessType = BusinessTypeConstant.UPDATE)
public JsonResponse update(
@PathVariable(name = "id") Integer id, @RequestBody @Validated UserRequest req)
throws NotFoundException {
@ -216,9 +218,9 @@ public class UserController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_DESTROY)
@BackendPermission(slug = BPermissionConstant.USER_DESTROY)
@DeleteMapping("/{id}")
@Log(title = "学员-删除", businessType = BusinessType.DELETE)
@Log(title = "学员-删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroy(@PathVariable(name = "id") Integer id) throws NotFoundException {
User user = userService.findOrFail(id);
userService.removeById(user.getId());
@ -228,7 +230,7 @@ public class UserController {
@PostMapping("/store-batch")
@Transactional
@Log(title = "学员-批量导入", businessType = BusinessType.INSERT)
@Log(title = "学员-批量导入", businessType = BusinessTypeConstant.INSERT)
public JsonResponse batchStore(@RequestBody @Validated UserImportRequest req) {
List<UserImportRequest.UserItem> users = req.getUsers();
if (users.size() == 0) {
@ -242,7 +244,7 @@ public class UserController {
Integer startLine = req.getStartLine();
// 默认的学员头像
String defaultAvatar = BCtx.getConfig().get(CConfig.MEMBER_DEFAULT_AVATAR);
String defaultAvatar = BCtx.getConfig().get(ConfigConstant.MEMBER_DEFAULT_AVATAR);
List<String[]> errorLines = new ArrayList<>();
errorLines.add(new String[] {"错误行", "错误信息"}); // 错误表-表头
@ -390,10 +392,10 @@ public class UserController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@BackendPermission(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-hours")
@SneakyThrows
@Log(title = "学员-已学习课时列表", businessType = BusinessType.GET)
@Log(title = "学员-已学习课时列表", businessType = BusinessTypeConstant.GET)
public JsonResponse learnHours(
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
@ -427,9 +429,9 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@BackendPermission(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-courses")
@Log(title = "学员-已学习课程列表", businessType = BusinessType.GET)
@Log(title = "学员-已学习课程列表", businessType = BusinessTypeConstant.GET)
public JsonResponse latestLearnCourses(
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
Integer page = MapUtils.getInteger(params, "page", 1);
@ -463,9 +465,9 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@BackendPermission(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/all-courses")
@Log(title = "学员-课程", businessType = BusinessType.GET)
@Log(title = "学员-课程", businessType = BusinessTypeConstant.GET)
public JsonResponse allCourses(@PathVariable(name = "id") Integer id) {
// 读取学员关联的部门
List<Integer> depIds = userService.getDepIdsByUserId(id);
@ -525,10 +527,10 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@BackendPermission(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-course/{courseId}")
@SneakyThrows
@Log(title = "学员-单个课程的学习记录", businessType = BusinessType.GET)
@Log(title = "学员-单个课程的学习记录", businessType = BusinessTypeConstant.GET)
public JsonResponse learnCourseDetail(
@PathVariable(name = "id") Integer id,
@PathVariable(name = "courseId") Integer courseId) {
@ -547,10 +549,10 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
@BackendPermission(slug = BPermissionConstant.USER_LEARN)
@GetMapping("/{id}/learn-stats")
@SneakyThrows
@Log(title = "学员-学习统计", businessType = BusinessType.GET)
@Log(title = "学员-学习统计", businessType = BusinessTypeConstant.GET)
public JsonResponse learn(@PathVariable(name = "id") Integer id) {
// 最近一个月的每天学习时长
String todayStr = DateTime.now().toDateStr();
@ -595,10 +597,10 @@ public class UserController {
return JsonResponse.data(data);
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN_DESTROY)
@BackendPermission(slug = BPermissionConstant.USER_LEARN_DESTROY)
@DeleteMapping("/{id}/learn-course/{courseId}")
@SneakyThrows
@Log(title = "学员-线上课学习记录删除", businessType = BusinessType.DELETE)
@Log(title = "学员-线上课学习记录删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroyUserCourse(
@PathVariable(name = "id") Integer id,
@PathVariable(name = "courseId") Integer courseId) {
@ -607,10 +609,10 @@ public class UserController {
return JsonResponse.success();
}
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN_DESTROY)
@BackendPermission(slug = BPermissionConstant.USER_LEARN_DESTROY)
@DeleteMapping("/{id}/learn-course/{courseId}/hour/{hourId}")
@SneakyThrows
@Log(title = "学员-线上课课时学习记录删除", businessType = BusinessType.DELETE)
@Log(title = "学员-线上课课时学习记录删除", businessType = BusinessTypeConstant.DELETE)
public JsonResponse destroyUserHour(
@PathVariable(name = "id") Integer id,
@PathVariable(name = "courseId") Integer courseId,

View File

@ -20,9 +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.domain.ResourceCategory;
import xyz.playedu.api.service.ResourceCategoryService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.common.domain.Category;
import xyz.playedu.common.service.CategoryService;
import xyz.playedu.common.types.JsonResponse;
import java.util.HashMap;
import java.util.List;
@ -32,15 +32,15 @@ import java.util.stream.Collectors;
@RequestMapping("/api/v1/category")
public class CategoryController {
@Autowired private ResourceCategoryService resourceCategoryService;
@Autowired private CategoryService categoryService;
@GetMapping("/all")
public JsonResponse all() {
List<ResourceCategory> categories = resourceCategoryService.all();
List<Category> categories = categoryService.all();
HashMap<String, Object> data = new HashMap<>();
data.put(
"categories",
categories.stream().collect(Collectors.groupingBy(ResourceCategory::getParentId)));
categories.stream().collect(Collectors.groupingBy(Category::getParentId)));
return JsonResponse.data(data);
}
}

View File

@ -20,14 +20,15 @@ import lombok.SneakyThrows;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.api.FCtx;
import xyz.playedu.api.domain.*;
import xyz.playedu.api.service.*;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.CoursePaginateFiler;
import xyz.playedu.api.types.paginate.PaginationResult;
import xyz.playedu.api.util.IpUtil;
import xyz.playedu.common.context.FCtx;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.CoursePaginateFiler;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.common.util.IpUtil;
import xyz.playedu.course.domain.*;
import xyz.playedu.course.service.*;
import xyz.playedu.resource.domain.Resource;
import xyz.playedu.resource.service.ResourceService;
import java.util.Date;
import java.util.HashMap;

View File

@ -18,15 +18,15 @@ package xyz.playedu.api.controller.frontend;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.common.domain.Department;
import xyz.playedu.common.exception.NotFoundException;
import xyz.playedu.common.service.DepartmentService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.CoursePaginateFiler;
import xyz.playedu.common.types.paginate.PaginationResult;
import xyz.playedu.course.domain.Course;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.api.domain.Course;
import xyz.playedu.api.domain.Department;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.api.service.DepartmentService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.paginate.CoursePaginateFiler;
import xyz.playedu.api.types.paginate.PaginationResult;
import java.util.HashMap;
import java.util.stream.Collectors;

View File

@ -18,21 +18,28 @@ package xyz.playedu.api.controller.frontend;
import lombok.SneakyThrows;
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.FCtx;
import xyz.playedu.api.bus.UserBus;
import xyz.playedu.api.caches.CourseCache;
import xyz.playedu.api.caches.UserCanSeeCourseCache;
import xyz.playedu.api.domain.*;
import xyz.playedu.api.event.UserCourseHourFinishedEvent;
import xyz.playedu.api.event.UserLearnCourseUpdateEvent;
import xyz.playedu.course.bus.UserBus;
import xyz.playedu.course.caches.CourseCache;
import xyz.playedu.course.caches.UserCanSeeCourseCache;
import xyz.playedu.api.request.frontend.CourseHourRecordRequest;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.api.service.ResourceService;
import xyz.playedu.api.service.UserCourseHourRecordService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.util.RedisDistributedLock;
import xyz.playedu.common.context.FCtx;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.util.RedisDistributedLock;
import xyz.playedu.course.caches.UserLastLearnTimeCache;
import xyz.playedu.course.domain.Course;
import xyz.playedu.course.domain.CourseHour;
import xyz.playedu.course.domain.UserCourseHourRecord;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.course.service.CourseService;
import xyz.playedu.course.service.UserCourseHourRecordService;
import xyz.playedu.resource.domain.Resource;
import xyz.playedu.resource.service.ResourceService;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
@ -62,6 +69,10 @@ public class HourController {
@Autowired private RedisDistributedLock redisDistributedLock;
@Autowired private UserLastLearnTimeCache userLastLearnTimeCache;
@Autowired private ApplicationContext ctx;
@GetMapping("/{id}")
@SneakyThrows
public JsonResponse detail(
@ -124,11 +135,16 @@ public class HourController {
return JsonResponse.error("请稍后再试");
}
userCourseHourRecordService.storeOrUpdate(
FCtx.getId(), course.getId(), hour.getId(), duration, hour.getDuration());
// 此处未考虑上面代码执行失败释放锁
redisDistributedLock.releaseLock(lockKey);
try {
boolean isFinished = userCourseHourRecordService.storeOrUpdate(
FCtx.getId(), course.getId(), hour.getId(), duration, hour.getDuration());
if (isFinished) {
ctx.publishEvent(new UserCourseHourFinishedEvent(this, FCtx.getId(), courseId, hour.getId()));
}
} finally {
// 此处未考虑上面代码执行失败释放锁
redisDistributedLock.releaseLock(lockKey);
}
return JsonResponse.success();
}
@ -149,10 +165,25 @@ public class HourController {
return JsonResponse.error("请稍后再试");
}
userBus.userLearnDurationRecord(FCtx.getUser(), course, hour);
try {
Long curTime = System.currentTimeMillis();
// 此处未考虑上面代码执行失败释放锁
redisDistributedLock.releaseLock(lockKey);
// 最近一次学习时间
Long lastTime = userLastLearnTimeCache.get(FCtx.getId());
// 最大周期为10s+0.5s的网络延迟
if (lastTime == null || curTime - lastTime > 10500) {
lastTime = curTime - 10000;
}
userLastLearnTimeCache.put(FCtx.getId(), curTime);
ctx.publishEvent(
new UserLearnCourseUpdateEvent(
this, FCtx.getId(), course.getId(), hour.getId(), lastTime, curTime));
} finally {
// 此处未考虑上面代码执行失败释放锁
redisDistributedLock.releaseLock(lockKey);
}
return JsonResponse.success();
}

View File

@ -22,22 +22,22 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.playedu.api.FCtx;
import xyz.playedu.api.config.PlayEduConfig;
import xyz.playedu.api.domain.User;
import xyz.playedu.api.event.UserLoginEvent;
import xyz.playedu.api.event.UserLogoutEvent;
import xyz.playedu.api.exception.LimitException;
import xyz.playedu.api.request.frontend.LoginPasswordRequest;
import xyz.playedu.api.service.FrontendAuthService;
import xyz.playedu.api.service.RateLimiterService;
import xyz.playedu.api.service.UserService;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.util.HelperUtil;
import xyz.playedu.api.util.IpUtil;
import xyz.playedu.api.util.RedisUtil;
import xyz.playedu.api.util.RequestUtil;
import xyz.playedu.common.context.FCtx;
import xyz.playedu.common.config.PlayEduConfig;
import xyz.playedu.common.domain.User;
import xyz.playedu.common.exception.LimitException;
import xyz.playedu.common.service.FrontendAuthService;
import xyz.playedu.common.service.RateLimiterService;
import xyz.playedu.common.service.UserService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.util.HelperUtil;
import xyz.playedu.common.util.IpUtil;
import xyz.playedu.common.util.RedisUtil;
import xyz.playedu.common.util.RequestUtil;
import java.util.HashMap;

View File

@ -19,10 +19,10 @@ 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.common.constant.ConfigConstant;
import xyz.playedu.common.service.AppConfigService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.api.constant.CConfig;
import xyz.playedu.api.service.AppConfigService;
import xyz.playedu.api.types.JsonResponse;
import java.util.HashMap;
import java.util.Map;
@ -39,11 +39,11 @@ public class SystemController {
HashMap<String, String> data = new HashMap<>();
data.put("system-name", configs.get(CConfig.SYSTEM_NAME));
data.put("system-logo", configs.get(CConfig.SYSTEM_LOGO));
data.put("system-api-url", configs.get(CConfig.SYSTEM_API_URL));
data.put("system-pc-url", configs.get(CConfig.SYSTEM_PC_URL));
data.put("system-h5-url", configs.get(CConfig.SYSTEM_H5_URL));
data.put("system-name", configs.get(ConfigConstant.SYSTEM_NAME));
data.put("system-logo", configs.get(ConfigConstant.SYSTEM_LOGO));
data.put("system-api-url", configs.get(ConfigConstant.SYSTEM_API_URL));
data.put("system-pc-url", configs.get(ConfigConstant.SYSTEM_PC_URL));
data.put("system-h5-url", configs.get(ConfigConstant.SYSTEM_H5_URL));
data.put("system-pc-index-footer-msg", configs.get("system.pc_index_footer_msg"));
data.put("player-poster", configs.get("player.poster"));

View File

@ -22,17 +22,21 @@ 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.FCtx;
import xyz.playedu.api.constant.FrontendConstant;
import xyz.playedu.api.domain.*;
import xyz.playedu.api.exception.ServiceException;
import xyz.playedu.api.request.frontend.ChangePasswordRequest;
import xyz.playedu.api.service.*;
import xyz.playedu.api.types.JsonResponse;
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
import xyz.playedu.api.types.response.UserLatestLearn;
import xyz.playedu.api.util.PrivacyUtil;
import xyz.playedu.common.context.FCtx;
import xyz.playedu.common.constant.FrontendConstant;
import xyz.playedu.common.domain.Department;
import xyz.playedu.common.domain.User;
import xyz.playedu.common.domain.UserUploadImageLog;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.common.service.DepartmentService;
import xyz.playedu.common.service.UserService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.util.PrivacyUtil;
import xyz.playedu.course.domain.*;
import xyz.playedu.course.service.*;
import xyz.playedu.resource.service.UploadService;
import xyz.playedu.common.types.mapper.UserCourseHourRecordCourseCountMapper;
import java.util.*;
import java.util.stream.Collectors;

View File

@ -21,9 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.domain.AdminUser;
import xyz.playedu.common.domain.AdminUser;
import xyz.playedu.api.event.AdminUserLoginEvent;
import xyz.playedu.api.service.AdminUserService;
import xyz.playedu.common.service.AdminUserService;
@Component
@Slf4j

View File

@ -20,7 +20,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.CourseCategoryDestroyEvent;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.course.service.CourseService;
/**
* @Author 杭州白书科技有限公司

View File

@ -20,7 +20,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.CourseChapterDestroyEvent;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.course.service.CourseHourService;
/**
* @Author 杭州白书科技有限公司

View File

@ -20,11 +20,11 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.CourseDestroyEvent;
import xyz.playedu.api.service.CourseAttachmentService;
import xyz.playedu.api.service.CourseDepartmentService;
import xyz.playedu.api.service.UserCourseHourRecordService;
import xyz.playedu.api.service.UserCourseRecordService;
import xyz.playedu.api.service.internal.ResourceCourseCategoryService;
import xyz.playedu.course.service.CourseAttachmentService;
import xyz.playedu.course.service.CourseDepartmentService;
import xyz.playedu.course.service.UserCourseHourRecordService;
import xyz.playedu.course.service.UserCourseRecordService;
import xyz.playedu.course.service.CourseCategoryService;
/**
* @Author 杭州白书科技有限公司
@ -36,7 +36,7 @@ public class CourseDestroyListener {
@Autowired private CourseDepartmentService courseDepartmentService;
@Autowired private ResourceCourseCategoryService courseCategoryService;
@Autowired private CourseCategoryService courseCategoryService;
@Autowired private UserCourseRecordService userCourseRecordService;

View File

@ -20,8 +20,8 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.CourseHourCreatedEvent;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.course.service.CourseService;
/**
* @Author 杭州白书科技有限公司

View File

@ -20,8 +20,8 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.CourseHourDestroyEvent;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.service.CourseService;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.course.service.CourseService;
/**
* @Author 杭州白书科技有限公司

View File

@ -20,7 +20,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.DepartmentDestroyEvent;
import xyz.playedu.api.service.DepartmentService;
import xyz.playedu.common.service.DepartmentService;
/**
* @Author 杭州白书科技有限公司

View File

@ -20,9 +20,9 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserCourseHourFinishedEvent;
import xyz.playedu.api.service.CourseHourService;
import xyz.playedu.api.service.UserCourseHourRecordService;
import xyz.playedu.api.service.UserCourseRecordService;
import xyz.playedu.course.service.CourseHourService;
import xyz.playedu.course.service.UserCourseHourRecordService;
import xyz.playedu.course.service.UserCourseRecordService;
/**
* @Author 杭州白书科技有限公司

View File

@ -22,7 +22,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserCourseHourRecordDestroyEvent;
import xyz.playedu.api.service.UserCourseRecordService;
import xyz.playedu.course.service.UserCourseRecordService;
/**
* @Author 杭州白书科技有限公司

View File

@ -20,7 +20,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserCourseRecordDestroyEvent;
import xyz.playedu.api.service.UserCourseHourRecordService;
import xyz.playedu.course.service.UserCourseHourRecordService;
/**
* @Author 杭州白书科技有限公司

View File

@ -22,7 +22,12 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserDestroyEvent;
import xyz.playedu.api.service.*;
import xyz.playedu.common.service.UserLoginRecordService;
import xyz.playedu.common.service.UserService;
import xyz.playedu.course.service.UserCourseHourRecordService;
import xyz.playedu.course.service.UserCourseRecordService;
import xyz.playedu.course.service.UserLearnDurationRecordService;
import xyz.playedu.course.service.UserLearnDurationStatsService;
/**
* @Author 杭州白书科技有限公司

View File

@ -22,8 +22,8 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserLearnCourseUpdateEvent;
import xyz.playedu.api.service.UserLearnDurationRecordService;
import xyz.playedu.api.service.UserLearnDurationStatsService;
import xyz.playedu.course.service.UserLearnDurationRecordService;
import xyz.playedu.course.service.UserLearnDurationStatsService;
/**
* @Author 杭州白书科技有限公司

View File

@ -23,9 +23,9 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserLoginEvent;
import xyz.playedu.api.service.FrontendAuthService;
import xyz.playedu.api.service.UserLoginRecordService;
import xyz.playedu.api.util.IpUtil;
import xyz.playedu.common.service.FrontendAuthService;
import xyz.playedu.common.service.UserLoginRecordService;
import xyz.playedu.common.util.IpUtil;
import java.util.HashMap;

View File

@ -23,7 +23,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import xyz.playedu.api.event.UserLogoutEvent;
import xyz.playedu.api.service.UserLoginRecordService;
import xyz.playedu.common.service.UserLoginRecordService;
/**
* @Author 杭州白书科技有限公司

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

13
playedu-common/pom.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>xyz.playedu</groupId>
<artifactId>playedu</artifactId>
<version>1.2</version>
</parent>
<artifactId>playedu-common</artifactId>
</project>

View File

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.playedu.api.middleware;
package xyz.playedu.common.annotation;
import java.lang.annotation.*;
@Documented
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface BackendPermissionMiddleware {
public @interface BackendPermission {
String slug() default "";
}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.playedu.api.middleware;
package xyz.playedu.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.playedu.api.annotation;
package xyz.playedu.common.annotation;
import xyz.playedu.api.constant.BusinessType;
import xyz.playedu.common.constant.BusinessTypeConstant;
import java.lang.annotation.*;
@ -27,5 +27,5 @@ public @interface Log {
public String title() default "";
/** 功能 */
public BusinessType businessType() default BusinessType.OTHER;
public BusinessTypeConstant businessType() default BusinessTypeConstant.OTHER;
}

View File

@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.playedu.api.bus;
package xyz.playedu.common.bus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.playedu.api.BCtx;
import xyz.playedu.api.constant.BackendConstant;
import xyz.playedu.api.domain.AdminRole;
import xyz.playedu.api.service.AdminPermissionService;
import xyz.playedu.api.service.AdminRoleService;
import xyz.playedu.api.service.AdminUserService;
import xyz.playedu.api.util.PrivacyUtil;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.domain.AdminRole;
import xyz.playedu.common.service.AdminPermissionService;
import xyz.playedu.common.service.AdminRoleService;
import xyz.playedu.common.service.AdminUserService;
import xyz.playedu.common.util.PrivacyUtil;
import java.util.HashMap;
import java.util.List;

Some files were not shown because too many files have changed in this diff Show More