feat(education): add module application shell
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.education.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 教育模块配置属性
|
||||
*
|
||||
* @author 恭学教育
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "yudao.education")
|
||||
@Validated
|
||||
@Data
|
||||
public class EducationProperties {
|
||||
|
||||
/**
|
||||
* 是否启用教育模块
|
||||
*/
|
||||
private boolean enabled = false;
|
||||
|
||||
/**
|
||||
* 教育模块版本号
|
||||
*/
|
||||
private String version = "1.0.0";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.education.controller.admin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.education.config.EducationProperties;
|
||||
import cn.iocoder.yudao.module.education.controller.admin.vo.EducationCapabilityRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
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 EducationCapabilityController {
|
||||
|
||||
@Resource
|
||||
private EducationProperties educationProperties;
|
||||
|
||||
@GetMapping("/capability")
|
||||
@Operation(summary = "获得教育模块能力信息")
|
||||
@PreAuthorize("@ss.hasPermission('education:capability')")
|
||||
public CommonResult<EducationCapabilityRespVO> getCapability() {
|
||||
EducationCapabilityRespVO resp = EducationCapabilityRespVO.builder()
|
||||
.module("education")
|
||||
.enabled(educationProperties.isEnabled())
|
||||
.version(educationProperties.getVersion())
|
||||
.capabilities(List.of("shell"))
|
||||
.build();
|
||||
return success(resp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.education.controller.admin.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 教育模块能力信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EducationCapabilityRespVO {
|
||||
|
||||
@Schema(description = "模块名称", example = "education")
|
||||
private String module;
|
||||
|
||||
@Schema(description = "是否启用", example = "true")
|
||||
private boolean enabled;
|
||||
|
||||
@Schema(description = "模块版本", example = "1.0.0")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "支持的能力列表")
|
||||
private List<String> capabilities;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.education.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* Education 错误码枚举类
|
||||
* <p>
|
||||
* education 系统,使用 1-005-000-000 段
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 通用模块 1-005-001-000 ==========
|
||||
ErrorCode EDUCATION_DISABLED = new ErrorCode(1_005_001_000, "教育模块未启用,请联系管理员");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.education.framework.web.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
|
||||
import cn.iocoder.yudao.module.education.config.EducationProperties;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* education 模块的 web 组件的 Configuration
|
||||
*
|
||||
* @author 恭学教育
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(EducationProperties.class)
|
||||
public class EducationWebConfiguration {
|
||||
|
||||
/**
|
||||
* education 模块的 API 分组
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "yudao.education", name = "enabled", havingValue = "true")
|
||||
public GroupedOpenApi educationGroupedOpenApi() {
|
||||
return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("education");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 属于 education 模块的 web 封装
|
||||
*/
|
||||
package cn.iocoder.yudao.module.education.framework.web;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* education 模块,我们放教育业务。
|
||||
* 例如说:课程、练习、题库、考试等等
|
||||
*
|
||||
* 1. Controller URL:以 /education/ 开头,避免和其它 Module 冲突
|
||||
* 2. DataObject 表名:以 education_ 开头,方便在数据库中区分
|
||||
*/
|
||||
package cn.iocoder.yudao.module.education;
|
||||
Reference in New Issue
Block a user