From ddd95ec5128103f6edc20f4dbd0eca279fd81b14 Mon Sep 17 00:00:00 2001 From: wangziqi Date: Sat, 1 Aug 2026 15:00:32 +0800 Subject: [PATCH] feat(education): add subject and content-entry reference lists for UI selects --- .../EducationReferenceController.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 yudao-module-education/src/main/java/cn/iocoder/yudao/module/education/controller/admin/reference/EducationReferenceController.java diff --git a/yudao-module-education/src/main/java/cn/iocoder/yudao/module/education/controller/admin/reference/EducationReferenceController.java b/yudao-module-education/src/main/java/cn/iocoder/yudao/module/education/controller/admin/reference/EducationReferenceController.java new file mode 100644 index 00000000..daaf0a84 --- /dev/null +++ b/yudao-module-education/src/main/java/cn/iocoder/yudao/module/education/controller/admin/reference/EducationReferenceController.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.education.controller.admin.reference; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import cn.iocoder.yudao.module.education.dal.dataobject.catalog.ContentEntryDO; +import cn.iocoder.yudao.module.education.dal.dataobject.catalog.SubjectDO; +import cn.iocoder.yudao.module.education.dal.mysql.catalog.ContentEntryMapper; +import cn.iocoder.yudao.module.education.dal.mysql.catalog.SubjectMapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 管理后台 - 教育引用数据(供前端下拉选择使用) + */ +@Tag(name = "管理后台 - 教育引用数据") +@RestController +@RequestMapping("/education") +@Validated +@ConditionalOnProperty(prefix = "yudao.education", name = "enabled", havingValue = "true") +public class EducationReferenceController { + + private final SubjectMapper subjectMapper; + private final ContentEntryMapper contentEntryMapper; + + public EducationReferenceController(SubjectMapper subjectMapper, ContentEntryMapper contentEntryMapper) { + this.subjectMapper = subjectMapper; + this.contentEntryMapper = contentEntryMapper; + } + + public record SimpleRespVO(Long id, String name) { + } + + @GetMapping("/subjects/simple-list") + @Operation(summary = "学科下拉列表") + @PreAuthorize("@ss.hasPermission('education:category:query')") + public CommonResult> getSubjectSimpleList() { + Long tenantId = TenantContextHolder.getRequiredTenantId(); + return success(subjectMapper.selectActiveList(tenantId, null, null, null, null, null) + .stream().map(subject -> new SimpleRespVO(subject.getId(), subject.getName())).toList()); + } + + @GetMapping("/content-entries/simple-list") + @Operation(summary = "内容入口下拉列表") + @PreAuthorize("@ss.hasPermission('education:content-node:query')") + public CommonResult> getContentEntrySimpleList() { + Long tenantId = TenantContextHolder.getRequiredTenantId(); + return success(contentEntryMapper.selectActiveList(tenantId, null, null, false) + .stream().map(entry -> new SimpleRespVO(entry.getId(), entry.getName())).toList()); + } +}