删除swagger侵入式代码 , 删除demo
This commit is contained in:
@@ -23,11 +23,6 @@ public class SecurityConfiguration {
|
||||
|
||||
@Override
|
||||
public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
|
||||
// Swagger 接口文档
|
||||
registry.requestMatchers("/v3/api-docs/**").permitAll()
|
||||
.requestMatchers("/webjars/**").permitAll()
|
||||
.requestMatchers("/swagger-ui").permitAll()
|
||||
.requestMatchers("/swagger-ui/**").permitAll();
|
||||
// Spring Boot Actuator 的安全配置
|
||||
registry.requestMatchers("/actuator").permitAll()
|
||||
.requestMatchers("/actuator/**").permitAll();
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
||||
import static com.tashow.cloud.security.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
@@ -9,143 +13,126 @@ import com.tashow.cloud.infra.controller.admin.codegen.vo.CodegenCreateListReqVO
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.CodegenDetailRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.CodegenPreviewRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.CodegenUpdateReqVO;
|
||||
import com.tashow.cloud.infra.convert.codegen.CodegenConvert;
|
||||
import com.tashow.cloud.infra.dal.dataobject.codegen.CodegenColumnDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.codegen.CodegenTableDO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.table.CodegenTablePageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.table.CodegenTableRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.table.DatabaseTableRespVO;
|
||||
import com.tashow.cloud.infra.convert.codegen.CodegenConvert;
|
||||
import com.tashow.cloud.infra.dal.dataobject.codegen.CodegenColumnDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.codegen.CodegenTableDO;
|
||||
import com.tashow.cloud.infra.service.codegen.CodegenService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
||||
import static com.tashow.cloud.security.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 代码生成器")
|
||||
/** 管理后台 - 代码生成器 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/codegen")
|
||||
@Validated
|
||||
public class CodegenController {
|
||||
|
||||
@Resource
|
||||
private CodegenService codegenService;
|
||||
@Resource private CodegenService codegenService;
|
||||
|
||||
@GetMapping("/db/table/list")
|
||||
@Operation(summary = "获得数据库自带的表定义列表", description = "会过滤掉已经导入 Codegen 的表")
|
||||
@Parameters({
|
||||
@Parameter(name = "dataSourceConfigId", description = "数据源配置的编号", required = true, example = "1"),
|
||||
@Parameter(name = "name", description = "表名,模糊匹配", example = "yudao"),
|
||||
@Parameter(name = "comment", description = "描述,模糊匹配", example = "芋道")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<List<DatabaseTableRespVO>> getDatabaseTableList(
|
||||
@RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId,
|
||||
@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "comment", required = false) String comment) {
|
||||
return success(codegenService.getDatabaseTableList(dataSourceConfigId, name, comment));
|
||||
}
|
||||
/** 获得数据库自带的表定义列表", description = "会过滤掉已经导入 Codegen 的表 */
|
||||
@GetMapping("/db/table/list")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<List<DatabaseTableRespVO>> getDatabaseTableList(
|
||||
@RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId,
|
||||
@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "comment", required = false) String comment) {
|
||||
return success(codegenService.getDatabaseTableList(dataSourceConfigId, name, comment));
|
||||
}
|
||||
|
||||
@GetMapping("/table/list")
|
||||
@Operation(summary = "获得表定义列表")
|
||||
@Parameter(name = "dataSourceConfigId", description = "数据源配置的编号", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<List<CodegenTableRespVO>> getCodegenTableList(@RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId) {
|
||||
List<CodegenTableDO> list = codegenService.getCodegenTableList(dataSourceConfigId);
|
||||
return success(BeanUtils.toBean(list, CodegenTableRespVO.class));
|
||||
}
|
||||
/** 获得表定义列表 */
|
||||
@GetMapping("/table/list")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<List<CodegenTableRespVO>> getCodegenTableList(
|
||||
@RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId) {
|
||||
List<CodegenTableDO> list = codegenService.getCodegenTableList(dataSourceConfigId);
|
||||
return success(BeanUtils.toBean(list, CodegenTableRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/table/page")
|
||||
@Operation(summary = "获得表定义分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<PageResult<CodegenTableRespVO>> getCodegenTablePage(@Valid CodegenTablePageReqVO pageReqVO) {
|
||||
PageResult<CodegenTableDO> pageResult = codegenService.getCodegenTablePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CodegenTableRespVO.class));
|
||||
}
|
||||
/** 获得表定义分页 */
|
||||
@GetMapping("/table/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<PageResult<CodegenTableRespVO>> getCodegenTablePage(
|
||||
@Valid CodegenTablePageReqVO pageReqVO) {
|
||||
PageResult<CodegenTableDO> pageResult = codegenService.getCodegenTablePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CodegenTableRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@Operation(summary = "获得表和字段的明细")
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<CodegenDetailRespVO> getCodegenDetail(@RequestParam("tableId") Long tableId) {
|
||||
CodegenTableDO table = codegenService.getCodegenTable(tableId);
|
||||
List<CodegenColumnDO> columns = codegenService.getCodegenColumnListByTableId(tableId);
|
||||
// 拼装返回
|
||||
return success(CodegenConvert.INSTANCE.convert(table, columns));
|
||||
}
|
||||
/** 获得表和字段的明细 */
|
||||
@GetMapping("/detail")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:query')")
|
||||
public CommonResult<CodegenDetailRespVO> getCodegenDetail(@RequestParam("tableId") Long tableId) {
|
||||
CodegenTableDO table = codegenService.getCodegenTable(tableId);
|
||||
List<CodegenColumnDO> columns = codegenService.getCodegenColumnListByTableId(tableId);
|
||||
// 拼装返回
|
||||
return success(CodegenConvert.INSTANCE.convert(table, columns));
|
||||
}
|
||||
|
||||
@Operation(summary = "基于数据库的表结构,创建代码生成器的表和字段定义")
|
||||
@PostMapping("/create-list")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:create')")
|
||||
public CommonResult<List<Long>> createCodegenList(@Valid @RequestBody CodegenCreateListReqVO reqVO) {
|
||||
return success(codegenService.createCodegenList(getLoginUserId(), reqVO));
|
||||
}
|
||||
/** 基于数据库的表结构,创建代码生成器的表和字段定义 */
|
||||
@PostMapping("/create-list")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:create')")
|
||||
public CommonResult<List<Long>> createCodegenList(
|
||||
@Valid @RequestBody CodegenCreateListReqVO reqVO) {
|
||||
return success(codegenService.createCodegenList(getLoginUserId(), reqVO));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新数据库的表和字段定义")
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:update')")
|
||||
public CommonResult<Boolean> updateCodegen(@Valid @RequestBody CodegenUpdateReqVO updateReqVO) {
|
||||
codegenService.updateCodegen(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
/** 更新数据库的表和字段定义 */
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:update')")
|
||||
public CommonResult<Boolean> updateCodegen(@Valid @RequestBody CodegenUpdateReqVO updateReqVO) {
|
||||
codegenService.updateCodegen(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "基于数据库的表结构,同步数据库的表和字段定义")
|
||||
@PutMapping("/sync-from-db")
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:update')")
|
||||
public CommonResult<Boolean> syncCodegenFromDB(@RequestParam("tableId") Long tableId) {
|
||||
codegenService.syncCodegenFromDB(tableId);
|
||||
return success(true);
|
||||
}
|
||||
/** 基于数据库的表结构,同步数据库的表和字段定义 */
|
||||
@PutMapping("/sync-from-db")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:update')")
|
||||
public CommonResult<Boolean> syncCodegenFromDB(@RequestParam("tableId") Long tableId) {
|
||||
codegenService.syncCodegenFromDB(tableId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除数据库的表和字段定义")
|
||||
@DeleteMapping("/delete")
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:delete')")
|
||||
public CommonResult<Boolean> deleteCodegen(@RequestParam("tableId") Long tableId) {
|
||||
codegenService.deleteCodegen(tableId);
|
||||
return success(true);
|
||||
}
|
||||
/** 删除数据库的表和字段定义 */
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:delete')")
|
||||
public CommonResult<Boolean> deleteCodegen(@RequestParam("tableId") Long tableId) {
|
||||
codegenService.deleteCodegen(tableId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "预览生成代码")
|
||||
@GetMapping("/preview")
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:preview')")
|
||||
public CommonResult<List<CodegenPreviewRespVO>> previewCodegen(@RequestParam("tableId") Long tableId) {
|
||||
Map<String, String> codes = codegenService.generationCodes(tableId);
|
||||
return success(CodegenConvert.INSTANCE.convert(codes));
|
||||
}
|
||||
|
||||
@Operation(summary = "下载生成代码")
|
||||
@GetMapping("/download")
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:download')")
|
||||
public void downloadCodegen(@RequestParam("tableId") Long tableId,
|
||||
HttpServletResponse response) throws IOException {
|
||||
// 生成代码
|
||||
Map<String, String> codes = codegenService.generationCodes(tableId);
|
||||
// 构建 zip 包
|
||||
String[] paths = codes.keySet().toArray(new String[0]);
|
||||
ByteArrayInputStream[] ins = codes.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipUtil.zip(outputStream, paths, ins);
|
||||
// 输出
|
||||
writeAttachment(response, "codegen.zip", outputStream.toByteArray());
|
||||
}
|
||||
/** 预览生成代码 */
|
||||
@GetMapping("/preview")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:preview')")
|
||||
public CommonResult<List<CodegenPreviewRespVO>> previewCodegen(
|
||||
@RequestParam("tableId") Long tableId) {
|
||||
Map<String, String> codes = codegenService.generationCodes(tableId);
|
||||
return success(CodegenConvert.INSTANCE.convert(codes));
|
||||
}
|
||||
|
||||
/** 下载生成代码 */
|
||||
@GetMapping("/download")
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:download')")
|
||||
public void downloadCodegen(@RequestParam("tableId") Long tableId, HttpServletResponse response)
|
||||
throws IOException {
|
||||
// 生成代码
|
||||
Map<String, String> codes = codegenService.generationCodes(tableId);
|
||||
// 构建 zip 包
|
||||
String[] paths = codes.keySet().toArray(new String[0]);
|
||||
ByteArrayInputStream[] ins =
|
||||
codes.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipUtil.zip(outputStream, paths, ins);
|
||||
// 输出
|
||||
writeAttachment(response, "codegen.zip", outputStream.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 基于数据库的表结构,创建代码生成器的表和字段定义 Request VO")
|
||||
/** 管理后台 - 基于数据库的表结构,创建代码生成器的表和字段定义 Request VO */
|
||||
@Data
|
||||
public class CodegenCreateListReqVO {
|
||||
|
||||
@Schema(description = "数据源配置的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "数据源配置的编号不能为空")
|
||||
private Long dataSourceConfigId;
|
||||
|
||||
@Schema(description = "表名数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2, 3]")
|
||||
@NotNull(message = "表名数组不能为空")
|
||||
private List<String> tableNames;
|
||||
/** 数据源配置的编号" */
|
||||
@NotNull(message = "数据源配置的编号不能为空")
|
||||
private Long dataSourceConfigId;
|
||||
|
||||
/** 表名数组", example = "[1, 2, 3] */
|
||||
@NotNull(message = "表名数组不能为空")
|
||||
private List<String> tableNames;
|
||||
}
|
||||
|
||||
@@ -2,19 +2,16 @@ package com.tashow.cloud.infra.controller.admin.codegen.vo;
|
||||
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.column.CodegenColumnRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.table.CodegenTableRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成表和字段的明细 Response VO")
|
||||
/** 管理后台 - 代码生成表和字段的明细 Response VO */
|
||||
@Data
|
||||
public class CodegenDetailRespVO {
|
||||
|
||||
@Schema(description = "表定义")
|
||||
private CodegenTableRespVO table;
|
||||
|
||||
@Schema(description = "字段定义")
|
||||
private List<CodegenColumnRespVO> columns;
|
||||
/** 表定义 */
|
||||
private CodegenTableRespVO table;
|
||||
|
||||
/** 字段定义 */
|
||||
private List<CodegenColumnRespVO> columns;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成预览 Response VO,注意,每个文件都是一个该对象")
|
||||
/** 管理后台 - 代码生成预览 Response VO,注意,每个文件都是一个该对象 */
|
||||
@Data
|
||||
public class CodegenPreviewRespVO {
|
||||
|
||||
@Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED, example = "java/cn/iocoder/yudao/adminserver/modules/system/controller/test/SysTestDemoController.java")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "代码", requiredMode = Schema.RequiredMode.REQUIRED, example = "Hello World")
|
||||
private String code;
|
||||
/** 文件路径" */
|
||||
private String filePath;
|
||||
|
||||
/** 代码" */
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -2,23 +2,20 @@ package com.tashow.cloud.infra.controller.admin.codegen.vo;
|
||||
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.column.CodegenColumnSaveReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.codegen.vo.table.CodegenTableSaveReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成表和字段的修改 Request VO")
|
||||
/** 管理后台 - 代码生成表和字段的修改 Request VO */
|
||||
@Data
|
||||
public class CodegenUpdateReqVO {
|
||||
|
||||
@Valid // 校验内嵌的字段
|
||||
@NotNull(message = "表定义不能为空")
|
||||
private CodegenTableSaveReqVO table;
|
||||
|
||||
@Valid // 校验内嵌的字段
|
||||
@NotNull(message = "字段定义不能为空")
|
||||
private List<CodegenColumnSaveReqVO> columns;
|
||||
@Valid // 校验内嵌的字段
|
||||
@NotNull(message = "表定义不能为空")
|
||||
private CodegenTableSaveReqVO table;
|
||||
|
||||
@Valid // 校验内嵌的字段
|
||||
@NotNull(message = "字段定义不能为空")
|
||||
private List<CodegenColumnSaveReqVO> columns;
|
||||
}
|
||||
|
||||
@@ -1,69 +1,66 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo.column;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成字段定义 Response VO")
|
||||
/** 管理后台 - 代码生成字段定义 Response VO */
|
||||
@Data
|
||||
public class CodegenColumnRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
/** 编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "表编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long tableId;
|
||||
/** 表编号" */
|
||||
private Long tableId;
|
||||
|
||||
@Schema(description = "字段名", requiredMode = Schema.RequiredMode.REQUIRED, example = "user_age")
|
||||
private String columnName;
|
||||
/** 字段名" */
|
||||
private String columnName;
|
||||
|
||||
@Schema(description = "字段类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "int(11)")
|
||||
private String dataType;
|
||||
/** 字段类型" */
|
||||
private String dataType;
|
||||
|
||||
@Schema(description = "字段描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "年龄")
|
||||
private String columnComment;
|
||||
/** 字段描述", example = "年龄 */
|
||||
private String columnComment;
|
||||
|
||||
@Schema(description = "是否允许为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean nullable;
|
||||
/** 是否允许为空" */
|
||||
private Boolean nullable;
|
||||
|
||||
@Schema(description = "是否主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean primaryKey;
|
||||
/** 是否主键" */
|
||||
private Boolean primaryKey;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private Integer ordinalPosition;
|
||||
/** 排序" */
|
||||
private Integer ordinalPosition;
|
||||
|
||||
@Schema(description = "Java 属性类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "userAge")
|
||||
private String javaType;
|
||||
/** Java 属性类型" */
|
||||
private String javaType;
|
||||
|
||||
@Schema(description = "Java 属性名", requiredMode = Schema.RequiredMode.REQUIRED, example = "Integer")
|
||||
private String javaField;
|
||||
/** Java 属性名" */
|
||||
private String javaField;
|
||||
|
||||
@Schema(description = "字典类型", example = "sys_gender")
|
||||
private String dictType;
|
||||
/** 字典类型 */
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "数据示例", example = "1024")
|
||||
private String example;
|
||||
/** 数据示例 */
|
||||
private String example;
|
||||
|
||||
@Schema(description = "是否为 Create 创建操作的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean createOperation;
|
||||
/** 是否为 Create 创建操作的字段" */
|
||||
private Boolean createOperation;
|
||||
|
||||
@Schema(description = "是否为 Update 更新操作的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean updateOperation;
|
||||
/** 是否为 Update 更新操作的字段" */
|
||||
private Boolean updateOperation;
|
||||
|
||||
@Schema(description = "是否为 List 查询操作的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean listOperation;
|
||||
/** 是否为 List 查询操作的字段" */
|
||||
private Boolean listOperation;
|
||||
|
||||
@Schema(description = "List 查询操作的条件类型,参见 CodegenColumnListConditionEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "LIKE")
|
||||
private String listOperationCondition;
|
||||
/** List 查询操作的条件类型,参见 CodegenColumnListConditionEnum 枚举" */
|
||||
private String listOperationCondition;
|
||||
|
||||
@Schema(description = "是否为 List 查询操作的返回字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean listOperationResult;
|
||||
/** 是否为 List 查询操作的返回字段" */
|
||||
private Boolean listOperationResult;
|
||||
|
||||
@Schema(description = "显示类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "input")
|
||||
private String htmlType;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
/** 显示类型" */
|
||||
private String htmlType;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,81 +1,78 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo.column;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成字段定义创建/修改 Request VO")
|
||||
/** 管理后台 - 代码生成字段定义创建/修改 Request VO */
|
||||
@Data
|
||||
public class CodegenColumnSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
/** 编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "表编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "表编号不能为空")
|
||||
private Long tableId;
|
||||
/** 表编号" */
|
||||
@NotNull(message = "表编号不能为空")
|
||||
private Long tableId;
|
||||
|
||||
@Schema(description = "字段名", requiredMode = Schema.RequiredMode.REQUIRED, example = "user_age")
|
||||
@NotNull(message = "字段名不能为空")
|
||||
private String columnName;
|
||||
/** 字段名" */
|
||||
@NotNull(message = "字段名不能为空")
|
||||
private String columnName;
|
||||
|
||||
@Schema(description = "字段类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "int(11)")
|
||||
@NotNull(message = "字段类型不能为空")
|
||||
private String dataType;
|
||||
/** 字段类型" */
|
||||
@NotNull(message = "字段类型不能为空")
|
||||
private String dataType;
|
||||
|
||||
@Schema(description = "字段描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "年龄")
|
||||
@NotNull(message = "字段描述不能为空")
|
||||
private String columnComment;
|
||||
/** 字段描述", example = "年龄 */
|
||||
@NotNull(message = "字段描述不能为空")
|
||||
private String columnComment;
|
||||
|
||||
@Schema(description = "是否允许为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否允许为空不能为空")
|
||||
private Boolean nullable;
|
||||
/** 是否允许为空" */
|
||||
@NotNull(message = "是否允许为空不能为空")
|
||||
private Boolean nullable;
|
||||
|
||||
@Schema(description = "是否主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
@NotNull(message = "是否主键不能为空")
|
||||
private Boolean primaryKey;
|
||||
/** 是否主键" */
|
||||
@NotNull(message = "是否主键不能为空")
|
||||
private Boolean primaryKey;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer ordinalPosition;
|
||||
/** 排序" */
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer ordinalPosition;
|
||||
|
||||
@Schema(description = "Java 属性类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "userAge")
|
||||
@NotNull(message = "Java 属性类型不能为空")
|
||||
private String javaType;
|
||||
/** Java 属性类型" */
|
||||
@NotNull(message = "Java 属性类型不能为空")
|
||||
private String javaType;
|
||||
|
||||
@Schema(description = "Java 属性名", requiredMode = Schema.RequiredMode.REQUIRED, example = "Integer")
|
||||
@NotNull(message = "Java 属性名不能为空")
|
||||
private String javaField;
|
||||
/** Java 属性名" */
|
||||
@NotNull(message = "Java 属性名不能为空")
|
||||
private String javaField;
|
||||
|
||||
@Schema(description = "字典类型", example = "sys_gender")
|
||||
private String dictType;
|
||||
/** 字典类型 */
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "数据示例", example = "1024")
|
||||
private String example;
|
||||
/** 数据示例 */
|
||||
private String example;
|
||||
|
||||
@Schema(description = "是否为 Create 创建操作的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否为 Create 创建操作的字段不能为空")
|
||||
private Boolean createOperation;
|
||||
/** 是否为 Create 创建操作的字段" */
|
||||
@NotNull(message = "是否为 Create 创建操作的字段不能为空")
|
||||
private Boolean createOperation;
|
||||
|
||||
@Schema(description = "是否为 Update 更新操作的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
@NotNull(message = "是否为 Update 更新操作的字段不能为空")
|
||||
private Boolean updateOperation;
|
||||
/** 是否为 Update 更新操作的字段" */
|
||||
@NotNull(message = "是否为 Update 更新操作的字段不能为空")
|
||||
private Boolean updateOperation;
|
||||
|
||||
@Schema(description = "是否为 List 查询操作的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否为 List 查询操作的字段不能为空")
|
||||
private Boolean listOperation;
|
||||
/** 是否为 List 查询操作的字段" */
|
||||
@NotNull(message = "是否为 List 查询操作的字段不能为空")
|
||||
private Boolean listOperation;
|
||||
|
||||
@Schema(description = "List 查询操作的条件类型,参见 CodegenColumnListConditionEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "LIKE")
|
||||
@NotNull(message = "List 查询操作的条件类型不能为空")
|
||||
private String listOperationCondition;
|
||||
/** List 查询操作的条件类型,参见 CodegenColumnListConditionEnum 枚举" */
|
||||
@NotNull(message = "List 查询操作的条件类型不能为空")
|
||||
private String listOperationCondition;
|
||||
|
||||
@Schema(description = "是否为 List 查询操作的返回字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否为 List 查询操作的返回字段不能为空")
|
||||
private Boolean listOperationResult;
|
||||
|
||||
@Schema(description = "显示类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "input")
|
||||
@NotNull(message = "显示类型不能为空")
|
||||
private String htmlType;
|
||||
/** 是否为 List 查询操作的返回字段" */
|
||||
@NotNull(message = "是否为 List 查询操作的返回字段不能为空")
|
||||
private Boolean listOperationResult;
|
||||
|
||||
/** 显示类型" */
|
||||
@NotNull(message = "显示类型不能为空")
|
||||
private String htmlType;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo.table;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 表定义分页 Request VO")
|
||||
/** 管理后台 - 表定义分页 Request VO */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CodegenTablePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表名称,模糊匹配", example = "yudao")
|
||||
private String tableName;
|
||||
/** 表名称,模糊匹配 */
|
||||
private String tableName;
|
||||
|
||||
@Schema(description = "表描述,模糊匹配", example = "芋道")
|
||||
private String tableComment;
|
||||
/** 表描述,模糊匹配 */
|
||||
private String tableComment;
|
||||
|
||||
@Schema(description = "实体,模糊匹配", example = "Yudao")
|
||||
private String className;
|
||||
|
||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
/** 实体,模糊匹配 */
|
||||
private String className;
|
||||
|
||||
/** 创建时间 */
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo.table;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成表定义 Response VO")
|
||||
/** 管理后台 - 代码生成表定义 Response VO */
|
||||
@Data
|
||||
public class CodegenTableRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
/** 编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "生成场景,参见 CodegenSceneEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer scene;
|
||||
/** 生成场景,参见 CodegenSceneEnum 枚举" */
|
||||
private Integer scene;
|
||||
|
||||
@Schema(description = "表名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||
private String tableName;
|
||||
/** 表名称" */
|
||||
private String tableName;
|
||||
|
||||
@Schema(description = "表描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String tableComment;
|
||||
/** 表描述", example = "芋道 */
|
||||
private String tableComment;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "模块名", requiredMode = Schema.RequiredMode.REQUIRED, example = "system")
|
||||
private String moduleName;
|
||||
/** 模块名" */
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "业务名", requiredMode = Schema.RequiredMode.REQUIRED, example = "codegen")
|
||||
private String businessName;
|
||||
/** 业务名" */
|
||||
private String businessName;
|
||||
|
||||
@Schema(description = "类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "CodegenTable")
|
||||
private String className;
|
||||
/** 类名称" */
|
||||
private String className;
|
||||
|
||||
@Schema(description = "类描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码生成器的表定义")
|
||||
private String classComment;
|
||||
/** 类描述", example = "代码生成器的表定义 */
|
||||
private String classComment;
|
||||
|
||||
@Schema(description = "作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
private String author;
|
||||
/** 作者", example = "芋道源码 */
|
||||
private String author;
|
||||
|
||||
@Schema(description = "模板类型,参见 CodegenTemplateTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer templateType;
|
||||
/** 模板类型,参见 CodegenTemplateTypeEnum 枚举" */
|
||||
private Integer templateType;
|
||||
|
||||
@Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
|
||||
private Integer frontType;
|
||||
/** 前端类型,参见 CodegenFrontTypeEnum 枚举" */
|
||||
private Integer frontType;
|
||||
|
||||
@Schema(description = "父菜单编号", example = "1024")
|
||||
private Long parentMenuId;
|
||||
/** 父菜单编号 */
|
||||
private Long parentMenuId;
|
||||
|
||||
@Schema(description = "主表的编号", example = "2048")
|
||||
private Long masterTableId;
|
||||
@Schema(description = "子表关联主表的字段编号", example = "4096")
|
||||
private Long subJoinColumnId;
|
||||
@Schema(description = "主表与子表是否一对多", example = "4096")
|
||||
private Boolean subJoinMany;
|
||||
/** 主表的编号 */
|
||||
private Long masterTableId;
|
||||
|
||||
@Schema(description = "树表的父字段编号", example = "8192")
|
||||
private Long treeParentColumnId;
|
||||
@Schema(description = "树表的名字字段编号", example = "16384")
|
||||
private Long treeNameColumnId;
|
||||
/** 子表关联主表的字段编号 */
|
||||
private Long subJoinColumnId;
|
||||
|
||||
@Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer dataSourceConfigId;
|
||||
/** 主表与子表是否一对多 */
|
||||
private Boolean subJoinMany;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
/** 树表的父字段编号 */
|
||||
private Long treeParentColumnId;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime updateTime;
|
||||
/** 树表的名字字段编号 */
|
||||
private Long treeNameColumnId;
|
||||
|
||||
/** 主键编号" */
|
||||
private Integer dataSourceConfigId;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
@@ -1,104 +1,100 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo.table;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.tashow.cloud.infra.enums.codegen.CodegenSceneEnum;
|
||||
import com.tashow.cloud.infra.enums.codegen.CodegenTemplateTypeEnum;
|
||||
import com.tashow.cloud.infra.enums.codegen.CodegenSceneEnum;
|
||||
import com.tashow.cloud.infra.enums.codegen.CodegenTemplateTypeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.tashow.cloud.infra.enums.codegen.CodegenSceneEnum;
|
||||
import com.tashow.cloud.infra.enums.codegen.CodegenTemplateTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成表定义创建/修改 Response VO")
|
||||
/** 管理后台 - 代码生成表定义创建/修改 Response VO */
|
||||
@Data
|
||||
public class CodegenTableSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
/** 编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "生成场景,参见 CodegenSceneEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "导入类型不能为空")
|
||||
private Integer scene;
|
||||
/** 生成场景,参见 CodegenSceneEnum 枚举" */
|
||||
@NotNull(message = "导入类型不能为空")
|
||||
private Integer scene;
|
||||
|
||||
@Schema(description = "表名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||
@NotNull(message = "表名称不能为空")
|
||||
private String tableName;
|
||||
/** 表名称" */
|
||||
@NotNull(message = "表名称不能为空")
|
||||
private String tableName;
|
||||
|
||||
@Schema(description = "表描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@NotNull(message = "表描述不能为空")
|
||||
private String tableComment;
|
||||
/** 表描述", example = "芋道 */
|
||||
@NotNull(message = "表描述不能为空")
|
||||
private String tableComment;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "模块名", requiredMode = Schema.RequiredMode.REQUIRED, example = "system")
|
||||
@NotNull(message = "模块名不能为空")
|
||||
private String moduleName;
|
||||
/** 模块名" */
|
||||
@NotNull(message = "模块名不能为空")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "业务名", requiredMode = Schema.RequiredMode.REQUIRED, example = "codegen")
|
||||
@NotNull(message = "业务名不能为空")
|
||||
private String businessName;
|
||||
/** 业务名" */
|
||||
@NotNull(message = "业务名不能为空")
|
||||
private String businessName;
|
||||
|
||||
@Schema(description = "类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "CodegenTable")
|
||||
@NotNull(message = "类名称不能为空")
|
||||
private String className;
|
||||
/** 类名称" */
|
||||
@NotNull(message = "类名称不能为空")
|
||||
private String className;
|
||||
|
||||
@Schema(description = "类描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码生成器的表定义")
|
||||
@NotNull(message = "类描述不能为空")
|
||||
private String classComment;
|
||||
/** 类描述", example = "代码生成器的表定义 */
|
||||
@NotNull(message = "类描述不能为空")
|
||||
private String classComment;
|
||||
|
||||
@Schema(description = "作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
@NotNull(message = "作者不能为空")
|
||||
private String author;
|
||||
/** 作者", example = "芋道源码 */
|
||||
@NotNull(message = "作者不能为空")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "模板类型,参见 CodegenTemplateTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "模板类型不能为空")
|
||||
private Integer templateType;
|
||||
/** 模板类型,参见 CodegenTemplateTypeEnum 枚举" */
|
||||
@NotNull(message = "模板类型不能为空")
|
||||
private Integer templateType;
|
||||
|
||||
@Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
|
||||
@NotNull(message = "前端类型不能为空")
|
||||
private Integer frontType;
|
||||
/** 前端类型,参见 CodegenFrontTypeEnum 枚举" */
|
||||
@NotNull(message = "前端类型不能为空")
|
||||
private Integer frontType;
|
||||
|
||||
@Schema(description = "父菜单编号", example = "1024")
|
||||
private Long parentMenuId;
|
||||
/** 父菜单编号 */
|
||||
private Long parentMenuId;
|
||||
|
||||
@Schema(description = "主表的编号", example = "2048")
|
||||
private Long masterTableId;
|
||||
@Schema(description = "子表关联主表的字段编号", example = "4096")
|
||||
private Long subJoinColumnId;
|
||||
@Schema(description = "主表与子表是否一对多", example = "4096")
|
||||
private Boolean subJoinMany;
|
||||
/** 主表的编号 */
|
||||
private Long masterTableId;
|
||||
|
||||
@Schema(description = "树表的父字段编号", example = "8192")
|
||||
private Long treeParentColumnId;
|
||||
@Schema(description = "树表的名字字段编号", example = "16384")
|
||||
private Long treeNameColumnId;
|
||||
/** 子表关联主表的字段编号 */
|
||||
private Long subJoinColumnId;
|
||||
|
||||
@AssertTrue(message = "上级菜单不能为空,请前往 [修改生成配置 -> 生成信息] 界面,设置“上级菜单”字段")
|
||||
@JsonIgnore
|
||||
public boolean isParentMenuIdValid() {
|
||||
// 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的
|
||||
return ObjectUtil.notEqual(getScene(), CodegenSceneEnum.ADMIN.getScene())
|
||||
|| getParentMenuId() != null;
|
||||
}
|
||||
/** 主表与子表是否一对多 */
|
||||
private Boolean subJoinMany;
|
||||
|
||||
@AssertTrue(message = "关联的父表信息不全")
|
||||
@JsonIgnore
|
||||
public boolean isSubValid() {
|
||||
return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.SUB)
|
||||
|| (ObjectUtil.isAllNotEmpty(masterTableId, subJoinColumnId, subJoinMany));
|
||||
}
|
||||
/** 树表的父字段编号 */
|
||||
private Long treeParentColumnId;
|
||||
|
||||
@AssertTrue(message = "关联的树表信息不全")
|
||||
@JsonIgnore
|
||||
public boolean isTreeValid() {
|
||||
return ObjectUtil.notEqual(templateType, CodegenTemplateTypeEnum.TREE)
|
||||
|| (ObjectUtil.isAllNotEmpty(treeParentColumnId, treeNameColumnId));
|
||||
}
|
||||
/** 树表的名字字段编号 */
|
||||
private Long treeNameColumnId;
|
||||
|
||||
@AssertTrue(message = "上级菜单不能为空,请前往 [修改生成配置 -> 生成信息] 界面,设置“上级菜单”字段")
|
||||
@JsonIgnore
|
||||
public boolean isParentMenuIdValid() {
|
||||
// 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的
|
||||
return ObjectUtil.notEqual(getScene(), CodegenSceneEnum.ADMIN.getScene())
|
||||
|| getParentMenuId() != null;
|
||||
}
|
||||
|
||||
@AssertTrue(message = "关联的父表信息不全")
|
||||
@JsonIgnore
|
||||
public boolean isSubValid() {
|
||||
return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.SUB)
|
||||
|| (ObjectUtil.isAllNotEmpty(masterTableId, subJoinColumnId, subJoinMany));
|
||||
}
|
||||
|
||||
@AssertTrue(message = "关联的树表信息不全")
|
||||
@JsonIgnore
|
||||
public boolean isTreeValid() {
|
||||
return ObjectUtil.notEqual(templateType, CodegenTemplateTypeEnum.TREE)
|
||||
|| (ObjectUtil.isAllNotEmpty(treeParentColumnId, treeNameColumnId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.tashow.cloud.infra.controller.admin.codegen.vo.table;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 数据库的表定义 Response VO")
|
||||
/** 管理后台 - 数据库的表定义 Response VO */
|
||||
@Data
|
||||
public class DatabaseTableRespVO {
|
||||
|
||||
@Schema(description = "表名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "yuanma")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "表描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
private String comment;
|
||||
/** 表名称" */
|
||||
private String name;
|
||||
|
||||
/** 表描述", example = "芋道源码 */
|
||||
private String comment;
|
||||
}
|
||||
|
||||
@@ -1,109 +1,99 @@
|
||||
package com.tashow.cloud.infra.controller.admin.config;
|
||||
|
||||
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.excel.excel.core.util.ExcelUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import com.tashow.cloud.infra.convert.config.ConfigConvert;
|
||||
import com.tashow.cloud.infra.dal.dataobject.config.ConfigDO;
|
||||
import com.tashow.cloud.infra.service.config.ConfigService;
|
||||
import com.tashow.cloud.infra.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import com.tashow.cloud.infraapi.enums.ErrorCodeConstants;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 参数配置")
|
||||
/** 管理后台 - 参数配置 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/config")
|
||||
@Validated
|
||||
public class ConfigController {
|
||||
|
||||
@Resource
|
||||
private ConfigService configService;
|
||||
@Resource private ConfigService configService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:create')")
|
||||
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigSaveReqVO createReqVO) {
|
||||
return success(configService.createConfig(createReqVO));
|
||||
/** 创建参数配置 */
|
||||
@PostMapping("/create")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:create')")
|
||||
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigSaveReqVO createReqVO) {
|
||||
return success(configService.createConfig(createReqVO));
|
||||
}
|
||||
|
||||
/** 修改参数配置 */
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:update')")
|
||||
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigSaveReqVO updateReqVO) {
|
||||
configService.updateConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/** 删除参数配置 */
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:delete')")
|
||||
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
|
||||
configService.deleteConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/** 获得参数配置 */
|
||||
@GetMapping(value = "/get")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<ConfigRespVO> getConfig(@RequestParam("id") Long id) {
|
||||
return success(ConfigConvert.INSTANCE.convert(configService.getConfig(id)));
|
||||
}
|
||||
|
||||
/** 根据参数键名查询参数值", description = "不可见的配置,不允许返回给前端 */
|
||||
@GetMapping(value = "/get-value-by-key")
|
||||
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
|
||||
ConfigDO config = configService.getConfigByKey(key);
|
||||
if (config == null) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:update')")
|
||||
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigSaveReqVO updateReqVO) {
|
||||
configService.updateConfig(updateReqVO);
|
||||
return success(true);
|
||||
if (!config.getVisible()) {
|
||||
throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
|
||||
}
|
||||
return success(config.getValue());
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除参数配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:delete')")
|
||||
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
|
||||
configService.deleteConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get")
|
||||
@Operation(summary = "获得参数配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<ConfigRespVO> getConfig(@RequestParam("id") Long id) {
|
||||
return success(ConfigConvert.INSTANCE.convert(configService.getConfig(id)));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-value-by-key")
|
||||
@Operation(summary = "根据参数键名查询参数值", description = "不可见的配置,不允许返回给前端")
|
||||
@Parameter(name = "key", description = "参数键", required = true, example = "yunai.biz.username")
|
||||
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
|
||||
ConfigDO config = configService.getConfigByKey(key);
|
||||
if (config == null) {
|
||||
return success(null);
|
||||
}
|
||||
if (!config.getVisible()) {
|
||||
throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
|
||||
}
|
||||
return success(config.getValue());
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获取参数配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<ConfigDO> page = configService.getConfigPage(pageReqVO);
|
||||
return success(ConfigConvert.INSTANCE.convertPage(page));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "导出参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportConfig(ConfigPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ConfigDO> list = configService.getConfigPage(exportReqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(response, "参数配置.xls", "数据", ConfigRespVO.class,
|
||||
ConfigConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
/** 获取参数配置分页 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<ConfigDO> page = configService.getConfigPage(pageReqVO);
|
||||
return success(ConfigConvert.INSTANCE.convertPage(page));
|
||||
}
|
||||
|
||||
/** 导出参数配置 */
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportConfig(ConfigPageReqVO exportReqVO, HttpServletResponse response)
|
||||
throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ConfigDO> list = configService.getConfigPage(exportReqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(
|
||||
response, "参数配置.xls", "数据", ConfigRespVO.class, ConfigConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
package com.tashow.cloud.infra.controller.admin.config.vo;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置分页 Request VO")
|
||||
/** 管理后台 - 参数配置分页 Request VO */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "数据源名称,模糊匹配", example = "名称")
|
||||
private String name;
|
||||
/** 数据源名称,模糊匹配 */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名,模糊匹配", example = "yunai.db.username")
|
||||
private String key;
|
||||
/** 参数键名,模糊匹配 */
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数类型,参见 SysConfigTypeEnum 枚举", example = "1")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
/** 参数类型,参见 SysConfigTypeEnum 枚举 */
|
||||
private Integer type;
|
||||
|
||||
/** 创建时间 */
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
|
||||
@@ -1,56 +1,53 @@
|
||||
package com.tashow.cloud.infra.controller.admin.config.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import com.tashow.cloud.infraapi.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置信息 Response VO")
|
||||
/** 管理后台 - 参数配置信息 Response VO */
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ConfigRespVO {
|
||||
|
||||
@Schema(description = "参数配置序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("参数配置序号")
|
||||
private Long id;
|
||||
/** 参数配置序号" */
|
||||
@ExcelProperty("参数配置序号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "参数分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "biz")
|
||||
@ExcelProperty("参数分类")
|
||||
private String category;
|
||||
/** 参数分类" */
|
||||
@ExcelProperty("参数分类")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "参数名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "数据库名")
|
||||
@ExcelProperty("参数名称")
|
||||
private String name;
|
||||
/** 参数名称", example = "数据库名 */
|
||||
@ExcelProperty("参数名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yunai.db.username")
|
||||
@ExcelProperty("参数键名")
|
||||
private String key;
|
||||
/** 参数键名" */
|
||||
@ExcelProperty("参数键名")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("参数键值")
|
||||
private String value;
|
||||
/** 参数键值" */
|
||||
@ExcelProperty("参数键值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "参数类型,参见 SysConfigTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "参数类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||
private Integer type;
|
||||
/** 参数类型,参见 SysConfigTypeEnum 枚举" */
|
||||
@ExcelProperty(value = "参数类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@ExcelProperty(value = "是否可见", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean visible;
|
||||
/** 是否可见" */
|
||||
@ExcelProperty(value = "是否可见", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean visible;
|
||||
|
||||
@Schema(description = "备注", example = "备注一下很帅气!")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
/** 备注 */
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
/** 创建时间", example = "时间戳格式 */
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,45 +1,42 @@
|
||||
package com.tashow.cloud.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置创建/修改 Request VO")
|
||||
/** 管理后台 - 参数配置创建/修改 Request VO */
|
||||
@Data
|
||||
public class ConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "参数配置序号", example = "1024")
|
||||
private Long id;
|
||||
/** 参数配置序号 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "参数分组", requiredMode = Schema.RequiredMode.REQUIRED, example = "biz")
|
||||
@NotEmpty(message = "参数分组不能为空")
|
||||
@Size(max = 50, message = "参数名称不能超过 50 个字符")
|
||||
private String category;
|
||||
/** 参数分组" */
|
||||
@NotEmpty(message = "参数分组不能为空")
|
||||
@Size(max = 50, message = "参数名称不能超过 50 个字符")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "参数名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "数据库名")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
@Size(max = 100, message = "参数名称不能超过 100 个字符")
|
||||
private String name;
|
||||
/** 参数名称", example = "数据库名 */
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
@Size(max = 100, message = "参数名称不能超过 100 个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yunai.db.username")
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过 100 个字符")
|
||||
private String key;
|
||||
/** 参数键名" */
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过 100 个字符")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotBlank(message = "参数键值不能为空")
|
||||
@Size(max = 500, message = "参数键值长度不能超过 500 个字符")
|
||||
private String value;
|
||||
/** 参数键值" */
|
||||
@NotBlank(message = "参数键值不能为空")
|
||||
@Size(max = 500, message = "参数键值长度不能超过 500 个字符")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否可见不能为空")
|
||||
private Boolean visible;
|
||||
|
||||
@Schema(description = "备注", example = "备注一下很帅气!")
|
||||
private String remark;
|
||||
/** 是否可见" */
|
||||
@NotNull(message = "是否可见不能为空")
|
||||
private Boolean visible;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -1,73 +1,66 @@
|
||||
package com.tashow.cloud.infra.controller.admin.db;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.db.vo.DataSourceConfigRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import com.tashow.cloud.infra.service.db.DataSourceConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 数据源配置")
|
||||
/** 管理后台 - 数据源配置 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/data-source-config")
|
||||
@Validated
|
||||
public class DataSourceConfigController {
|
||||
|
||||
@Resource
|
||||
private DataSourceConfigService dataSourceConfigService;
|
||||
@Resource private DataSourceConfigService dataSourceConfigService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建数据源配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:create')")
|
||||
public CommonResult<Long> createDataSourceConfig(@Valid @RequestBody DataSourceConfigSaveReqVO createReqVO) {
|
||||
return success(dataSourceConfigService.createDataSourceConfig(createReqVO));
|
||||
}
|
||||
/** 创建数据源配置 */
|
||||
@PostMapping("/create")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:create')")
|
||||
public CommonResult<Long> createDataSourceConfig(
|
||||
@Valid @RequestBody DataSourceConfigSaveReqVO createReqVO) {
|
||||
return success(dataSourceConfigService.createDataSourceConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新数据源配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:update')")
|
||||
public CommonResult<Boolean> updateDataSourceConfig(@Valid @RequestBody DataSourceConfigSaveReqVO updateReqVO) {
|
||||
dataSourceConfigService.updateDataSourceConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
/** 更新数据源配置 */
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:update')")
|
||||
public CommonResult<Boolean> updateDataSourceConfig(
|
||||
@Valid @RequestBody DataSourceConfigSaveReqVO updateReqVO) {
|
||||
dataSourceConfigService.updateDataSourceConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除数据源配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:delete')")
|
||||
public CommonResult<Boolean> deleteDataSourceConfig(@RequestParam("id") Long id) {
|
||||
dataSourceConfigService.deleteDataSourceConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
/** 删除数据源配置 */
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:delete')")
|
||||
public CommonResult<Boolean> deleteDataSourceConfig(@RequestParam("id") Long id) {
|
||||
dataSourceConfigService.deleteDataSourceConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得数据源配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:query')")
|
||||
public CommonResult<DataSourceConfigRespVO> getDataSourceConfig(@RequestParam("id") Long id) {
|
||||
DataSourceConfigDO config = dataSourceConfigService.getDataSourceConfig(id);
|
||||
return success(BeanUtils.toBean(config, DataSourceConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得数据源配置列表")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:query')")
|
||||
public CommonResult<List<DataSourceConfigRespVO>> getDataSourceConfigList() {
|
||||
List<DataSourceConfigDO> list = dataSourceConfigService.getDataSourceConfigList();
|
||||
return success(BeanUtils.toBean(list, DataSourceConfigRespVO.class));
|
||||
}
|
||||
/** 获得数据源配置 */
|
||||
@GetMapping("/get")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:query')")
|
||||
public CommonResult<DataSourceConfigRespVO> getDataSourceConfig(@RequestParam("id") Long id) {
|
||||
DataSourceConfigDO config = dataSourceConfigService.getDataSourceConfig(id);
|
||||
return success(BeanUtils.toBean(config, DataSourceConfigRespVO.class));
|
||||
}
|
||||
|
||||
/** 获得数据源配置列表 */
|
||||
@GetMapping("/list")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:query')")
|
||||
public CommonResult<List<DataSourceConfigRespVO>> getDataSourceConfigList() {
|
||||
List<DataSourceConfigDO> list = dataSourceConfigService.getDataSourceConfigList();
|
||||
return success(BeanUtils.toBean(list, DataSourceConfigRespVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
package com.tashow.cloud.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 数据源配置 Response VO")
|
||||
/** 管理后台 - 数据源配置 Response VO */
|
||||
@Data
|
||||
public class DataSourceConfigRespVO {
|
||||
|
||||
@Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer id;
|
||||
/** 主键编号" */
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "数据源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
|
||||
private String name;
|
||||
/** 数据源名称" */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据源连接", requiredMode = Schema.RequiredMode.REQUIRED, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro")
|
||||
private String url;
|
||||
/** 数据源连接" */
|
||||
private String url;
|
||||
|
||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "root")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
/** 用户名" */
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
package com.tashow.cloud.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 数据源配置创建/修改 Request VO")
|
||||
/** 管理后台 - 数据源配置创建/修改 Request VO */
|
||||
@Data
|
||||
public class DataSourceConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "主键编号", example = "1024")
|
||||
private Long id;
|
||||
/** 主键编号 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "数据源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
|
||||
@NotNull(message = "数据源名称不能为空")
|
||||
private String name;
|
||||
/** 数据源名称" */
|
||||
@NotNull(message = "数据源名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据源连接", requiredMode = Schema.RequiredMode.REQUIRED, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro")
|
||||
@NotNull(message = "数据源连接不能为空")
|
||||
private String url;
|
||||
/** 数据源连接" */
|
||||
@NotNull(message = "数据源连接不能为空")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "root")
|
||||
@NotNull(message = "用户名不能为空")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@NotNull(message = "密码不能为空")
|
||||
private String password;
|
||||
/** 用户名" */
|
||||
@NotNull(message = "用户名不能为空")
|
||||
private String username;
|
||||
|
||||
/** 密码" */
|
||||
@NotNull(message = "密码不能为空")
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo01;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.excel.excel.core.util.ExcelUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactRespVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import com.tashow.cloud.infra.service.demo.demo01.Demo01ContactService;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 示例联系人")
|
||||
@RestController
|
||||
@RequestMapping("/infra/demo01-contact")
|
||||
@Validated
|
||||
public class Demo01ContactController {
|
||||
|
||||
@Resource
|
||||
private Demo01ContactService demo01ContactService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建示例联系人")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:create')")
|
||||
public CommonResult<Long> createDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO createReqVO) {
|
||||
return success(demo01ContactService.createDemo01Contact(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新示例联系人")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:update')")
|
||||
public CommonResult<Boolean> updateDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO updateReqVO) {
|
||||
demo01ContactService.updateDemo01Contact(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除示例联系人")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')")
|
||||
public CommonResult<Boolean> deleteDemo01Contact(@RequestParam("id") Long id) {
|
||||
demo01ContactService.deleteDemo01Contact(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得示例联系人")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:query')")
|
||||
public CommonResult<Demo01ContactRespVO> getDemo01Contact(@RequestParam("id") Long id) {
|
||||
Demo01ContactDO demo01Contact = demo01ContactService.getDemo01Contact(id);
|
||||
return success(BeanUtils.toBean(demo01Contact, Demo01ContactRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得示例联系人分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:query')")
|
||||
public CommonResult<PageResult<Demo01ContactRespVO>> getDemo01ContactPage(@Valid Demo01ContactPageReqVO pageReqVO) {
|
||||
PageResult<Demo01ContactDO> pageResult = demo01ContactService.getDemo01ContactPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, Demo01ContactRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出示例联系人 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo01ContactExcel(@Valid Demo01ContactPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<Demo01ContactDO> list = demo01ContactService.getDemo01ContactPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "示例联系人.xls", "数据", Demo01ContactRespVO.class,
|
||||
BeanUtils.toBean(list, Demo01ContactRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo01.vo;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 示例联系人分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class Demo01ContactPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", example = "1")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo01.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 示例联系人 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class Demo01ContactRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21555")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class)
|
||||
@DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生年", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("出生年")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
|
||||
@ExcelProperty("简介")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "头像")
|
||||
@ExcelProperty("头像")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo01.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 示例联系人新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo01ContactSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21555")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生年", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "出生年不能为空")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
|
||||
@NotEmpty(message = "简介不能为空")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo02;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.excel.excel.core.util.ExcelUtils;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
import com.tashow.cloud.infra.service.demo.demo02.Demo02CategoryService;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategoryRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 示例分类")
|
||||
@RestController
|
||||
@RequestMapping("/infra/demo02-category")
|
||||
@Validated
|
||||
public class Demo02CategoryController {
|
||||
|
||||
@Resource
|
||||
private Demo02CategoryService demo02CategoryService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建示例分类")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:create')")
|
||||
public CommonResult<Long> createDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO createReqVO) {
|
||||
return success(demo02CategoryService.createDemo02Category(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新示例分类")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:update')")
|
||||
public CommonResult<Boolean> updateDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO updateReqVO) {
|
||||
demo02CategoryService.updateDemo02Category(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除示例分类")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:delete')")
|
||||
public CommonResult<Boolean> deleteDemo02Category(@RequestParam("id") Long id) {
|
||||
demo02CategoryService.deleteDemo02Category(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得示例分类")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
|
||||
public CommonResult<Demo02CategoryRespVO> getDemo02Category(@RequestParam("id") Long id) {
|
||||
Demo02CategoryDO demo02Category = demo02CategoryService.getDemo02Category(id);
|
||||
return success(BeanUtils.toBean(demo02Category, Demo02CategoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得示例分类列表")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
|
||||
public CommonResult<List<Demo02CategoryRespVO>> getDemo02CategoryList(@Valid Demo02CategoryListReqVO listReqVO) {
|
||||
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
|
||||
return success(BeanUtils.toBean(list, Demo02CategoryRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出示例分类 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo02CategoryExcel(@Valid Demo02CategoryListReqVO listReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "示例分类.xls", "数据", Demo02CategoryRespVO.class,
|
||||
BeanUtils.toBean(list, Demo02CategoryRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo02.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 示例分类列表 Request VO")
|
||||
@Data
|
||||
public class Demo02CategoryListReqVO {
|
||||
|
||||
@Schema(description = "名字", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父级编号", example = "6080")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo02.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 示例分类 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class Demo02CategoryRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
|
||||
@ExcelProperty("父级编号")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo02.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 示例分类新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo02CategorySaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
|
||||
@NotNull(message = "父级编号不能为空")
|
||||
private Long parentId;
|
||||
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo03;
|
||||
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.excel.excel.core.util.ExcelUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import com.tashow.cloud.infra.service.demo.demo03.Demo03StudentService;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import com.tashow.cloud.infra.service.demo.demo03.Demo03StudentService;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import com.tashow.cloud.infra.service.demo.demo03.Demo03StudentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 学生")
|
||||
@RestController
|
||||
@RequestMapping("/infra/demo03-student")
|
||||
@Validated
|
||||
public class Demo03StudentController {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentService demo03StudentService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO createReqVO) {
|
||||
return success(demo03StudentService.createDemo03Student(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO updateReqVO) {
|
||||
demo03StudentService.updateDemo03Student(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除学生")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
|
||||
demo03StudentService.deleteDemo03Student(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得学生")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03StudentRespVO> getDemo03Student(@RequestParam("id") Long id) {
|
||||
Demo03StudentDO demo03Student = demo03StudentService.getDemo03Student(id);
|
||||
return success(BeanUtils.toBean(demo03Student, Demo03StudentRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得学生分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03StudentRespVO>> getDemo03StudentPage(@Valid Demo03StudentPageReqVO pageReqVO) {
|
||||
PageResult<Demo03StudentDO> pageResult = demo03StudentService.getDemo03StudentPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, Demo03StudentRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出学生 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo03StudentExcel(@Valid Demo03StudentPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<Demo03StudentDO> list = demo03StudentService.getDemo03StudentPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentRespVO.class,
|
||||
BeanUtils.toBean(list, Demo03StudentRespVO.class));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@GetMapping("/demo03-course/page")
|
||||
@Operation(summary = "获得学生课程分页")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03CourseDO>> getDemo03CoursePage(PageParam pageReqVO,
|
||||
@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03CoursePage(pageReqVO, studentId));
|
||||
}
|
||||
|
||||
@PostMapping("/demo03-course/create")
|
||||
@Operation(summary = "创建学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
|
||||
return success(demo03StudentService.createDemo03Course(demo03Course));
|
||||
}
|
||||
|
||||
@PutMapping("/demo03-course/update")
|
||||
@Operation(summary = "更新学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
|
||||
demo03StudentService.updateDemo03Course(demo03Course);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/demo03-course/delete")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Operation(summary = "删除学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Course(@RequestParam("id") Long id) {
|
||||
demo03StudentService.deleteDemo03Course(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/demo03-course/get")
|
||||
@Operation(summary = "获得学生课程")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03CourseDO> getDemo03Course(@RequestParam("id") Long id) {
|
||||
return success(demo03StudentService.getDemo03Course(id));
|
||||
}
|
||||
|
||||
@GetMapping("/demo03-course/list-by-student-id")
|
||||
@Operation(summary = "获得学生课程列表")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03CourseListByStudentId(studentId));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@GetMapping("/demo03-grade/page")
|
||||
@Operation(summary = "获得学生班级分页")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03GradeDO>> getDemo03GradePage(PageParam pageReqVO,
|
||||
@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03GradePage(pageReqVO, studentId));
|
||||
}
|
||||
|
||||
@PostMapping("/demo03-grade/create")
|
||||
@Operation(summary = "创建学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
|
||||
return success(demo03StudentService.createDemo03Grade(demo03Grade));
|
||||
}
|
||||
|
||||
@PutMapping("/demo03-grade/update")
|
||||
@Operation(summary = "更新学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
|
||||
demo03StudentService.updateDemo03Grade(demo03Grade);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/demo03-grade/delete")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Operation(summary = "删除学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("id") Long id) {
|
||||
demo03StudentService.deleteDemo03Grade(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/demo03-grade/get")
|
||||
@Operation(summary = "获得学生班级")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03GradeDO> getDemo03Grade(@RequestParam("id") Long id) {
|
||||
return success(demo03StudentService.getDemo03Grade(id));
|
||||
}
|
||||
|
||||
@GetMapping("/demo03-grade/get-by-student-id")
|
||||
@Operation(summary = "获得学生班级")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03GradeByStudentId(studentId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo03;
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo03.vo;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 学生分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class Demo03StudentPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "简介", example = "随便")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo03.vo;
|
||||
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 学生 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class Demo03StudentRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class)
|
||||
@DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("出生日期")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@ExcelProperty("简介")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.tashow.cloud.infra.controller.admin.demo.demo03.vo;
|
||||
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo03StudentSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "出生日期不能为空")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@NotEmpty(message = "简介不能为空")
|
||||
private String description;
|
||||
|
||||
|
||||
private List<Demo03CourseDO> demo03Courses;
|
||||
|
||||
private Demo03GradeDO demo03Grade;
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* 代码生成示例
|
||||
*
|
||||
* 1. demo01:单表(增删改查)
|
||||
* 2. demo02:单表(树形结构)
|
||||
* 3. demo03:主子表(标准模式)+ 主子表(ERP 模式)+ 主子表(内嵌模式)
|
||||
*/
|
||||
package com.tashow.cloud.infra.controller.admin.demo;
|
||||
@@ -1,92 +1,83 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
|
||||
import com.tashow.cloud.infra.service.file.FileConfigService;
|
||||
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigRespVO;
|
||||
import com.tashow.cloud.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
|
||||
import com.tashow.cloud.infra.service.file.FileConfigService;
|
||||
import com.tashow.cloud.infra.dal.dataobject.file.FileConfigDO;
|
||||
import com.tashow.cloud.infra.service.file.FileConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 文件配置")
|
||||
/** 管理后台 - 文件配置 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/file-config")
|
||||
@Validated
|
||||
public class FileConfigController {
|
||||
|
||||
@Resource
|
||||
private FileConfigService fileConfigService;
|
||||
@Resource private FileConfigService fileConfigService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文件配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:create')")
|
||||
public CommonResult<Long> createFileConfig(@Valid @RequestBody FileConfigSaveReqVO createReqVO) {
|
||||
return success(fileConfigService.createFileConfig(createReqVO));
|
||||
}
|
||||
/** 创建文件配置 */
|
||||
@PostMapping("/create")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:create')")
|
||||
public CommonResult<Long> createFileConfig(@Valid @RequestBody FileConfigSaveReqVO createReqVO) {
|
||||
return success(fileConfigService.createFileConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新文件配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
|
||||
public CommonResult<Boolean> updateFileConfig(@Valid @RequestBody FileConfigSaveReqVO updateReqVO) {
|
||||
fileConfigService.updateFileConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
/** 更新文件配置 */
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
|
||||
public CommonResult<Boolean> updateFileConfig(
|
||||
@Valid @RequestBody FileConfigSaveReqVO updateReqVO) {
|
||||
fileConfigService.updateFileConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-master")
|
||||
@Operation(summary = "更新文件配置为 Master")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
|
||||
public CommonResult<Boolean> updateFileConfigMaster(@RequestParam("id") Long id) {
|
||||
fileConfigService.updateFileConfigMaster(id);
|
||||
return success(true);
|
||||
}
|
||||
/** 更新文件配置为 Master */
|
||||
@PutMapping("/update-master")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
|
||||
public CommonResult<Boolean> updateFileConfigMaster(@RequestParam("id") Long id) {
|
||||
fileConfigService.updateFileConfigMaster(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除文件配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:delete')")
|
||||
public CommonResult<Boolean> deleteFileConfig(@RequestParam("id") Long id) {
|
||||
fileConfigService.deleteFileConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
/** 删除文件配置 */
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:delete')")
|
||||
public CommonResult<Boolean> deleteFileConfig(@RequestParam("id") Long id) {
|
||||
fileConfigService.deleteFileConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得文件配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<FileConfigRespVO> getFileConfig(@RequestParam("id") Long id) {
|
||||
FileConfigDO config = fileConfigService.getFileConfig(id);
|
||||
return success(BeanUtils.toBean(config, FileConfigRespVO.class));
|
||||
}
|
||||
/** 获得文件配置 */
|
||||
@GetMapping("/get")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<FileConfigRespVO> getFileConfig(@RequestParam("id") Long id) {
|
||||
FileConfigDO config = fileConfigService.getFileConfig(id);
|
||||
return success(BeanUtils.toBean(config, FileConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得文件配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<PageResult<FileConfigRespVO>> getFileConfigPage(@Valid FileConfigPageReqVO pageVO) {
|
||||
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, FileConfigRespVO.class));
|
||||
}
|
||||
/** 获得文件配置分页 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<PageResult<FileConfigRespVO>> getFileConfigPage(
|
||||
@Valid FileConfigPageReqVO pageVO) {
|
||||
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, FileConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/test")
|
||||
@Operation(summary = "测试文件配置是否正确")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<String> testFileConfig(@RequestParam("id") Long id) throws Exception {
|
||||
String url = fileConfigService.testFileConfig(id);
|
||||
return success(url);
|
||||
}
|
||||
/** 测试文件配置是否正确 */
|
||||
@GetMapping("/test")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<String> testFileConfig(@RequestParam("id") Long id) throws Exception {
|
||||
String url = fileConfigService.testFileConfig(id);
|
||||
return success(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
@@ -9,9 +12,6 @@ import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.file.vo.file.*;
|
||||
import com.tashow.cloud.infra.dal.dataobject.file.FileDO;
|
||||
import com.tashow.cloud.infra.service.file.FileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -24,79 +24,77 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
||||
|
||||
@Tag(name = "管理后台 - 文件存储")
|
||||
/** 管理后台 - 文件存储 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/file")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class FileController {
|
||||
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
@Resource private FileService fileService;
|
||||
|
||||
@PostMapping("/upload")
|
||||
@Operation(summary = "上传文件", description = "模式一:后端上传文件")
|
||||
public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
/** 上传文件", description = "模式一:后端上传文件 */
|
||||
@PostMapping("/upload")
|
||||
public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(
|
||||
fileService.createFile(
|
||||
file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
/** 获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器 */
|
||||
@GetMapping("/presigned-url")
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path)
|
||||
throws Exception {
|
||||
return success(fileService.getFilePresignedUrl(path));
|
||||
}
|
||||
|
||||
/** 创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件 */
|
||||
@PostMapping("/create")
|
||||
public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) {
|
||||
return success(fileService.createFile(createReqVO));
|
||||
}
|
||||
|
||||
/** 删除文件 */
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:delete')")
|
||||
public CommonResult<Boolean> deleteFile(@RequestParam("id") Long id) throws Exception {
|
||||
fileService.deleteFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/** 下载文件 */
|
||||
@GetMapping("/{configId}/get/**")
|
||||
@PermitAll
|
||||
public void getFileContent(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@PathVariable("configId") Long configId)
|
||||
throws Exception {
|
||||
// 获取请求的路径
|
||||
String path = StrUtil.subAfter(request.getRequestURI(), "/get/", false);
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
throw new IllegalArgumentException("结尾的 path 路径必须传递");
|
||||
}
|
||||
// 解码,解决中文路径的问题 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/807/
|
||||
path = URLUtil.decode(path);
|
||||
|
||||
@GetMapping("/presigned-url")
|
||||
@Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception {
|
||||
return success(fileService.getFilePresignedUrl(path));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件")
|
||||
public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) {
|
||||
return success(fileService.createFile(createReqVO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除文件")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:delete')")
|
||||
public CommonResult<Boolean> deleteFile(@RequestParam("id") Long id) throws Exception {
|
||||
fileService.deleteFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/{configId}/get/**")
|
||||
@PermitAll
|
||||
@Operation(summary = "下载文件")
|
||||
@Parameter(name = "configId", description = "配置编号", required = true)
|
||||
public void getFileContent(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@PathVariable("configId") Long configId) throws Exception {
|
||||
// 获取请求的路径
|
||||
String path = StrUtil.subAfter(request.getRequestURI(), "/get/", false);
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
throw new IllegalArgumentException("结尾的 path 路径必须传递");
|
||||
}
|
||||
// 解码,解决中文路径的问题 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/807/
|
||||
path = URLUtil.decode(path);
|
||||
|
||||
// 读取内容
|
||||
byte[] content = fileService.getFileContent(configId, path);
|
||||
if (content == null) {
|
||||
log.warn("[getFileContent][configId({}) path({}) 文件不存在]", configId, path);
|
||||
response.setStatus(HttpStatus.NOT_FOUND.value());
|
||||
return;
|
||||
}
|
||||
writeAttachment(response, path, content);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得文件分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
public CommonResult<PageResult<FileRespVO>> getFilePage(@Valid FilePageReqVO pageVO) {
|
||||
PageResult<FileDO> pageResult = fileService.getFilePage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, FileRespVO.class));
|
||||
// 读取内容
|
||||
byte[] content = fileService.getFileContent(configId, path);
|
||||
if (content == null) {
|
||||
log.warn("[getFileContent][configId({}) path({}) 文件不存在]", configId, path);
|
||||
response.setStatus(HttpStatus.NOT_FOUND.value());
|
||||
return;
|
||||
}
|
||||
writeAttachment(response, path, content);
|
||||
}
|
||||
|
||||
/** 获得文件分页 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
public CommonResult<PageResult<FileRespVO>> getFilePage(@Valid FilePageReqVO pageVO) {
|
||||
PageResult<FileDO> pageResult = fileService.getFilePage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, FileRespVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.config;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置分页 Request VO")
|
||||
/** 管理后台 - 文件配置分页 Request VO */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FileConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "配置名", example = "S3 - 阿里云")
|
||||
private String name;
|
||||
/** 配置名 */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储器", example = "1")
|
||||
private Integer storage;
|
||||
|
||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
/** 存储器 */
|
||||
private Integer storage;
|
||||
|
||||
/** 创建时间 */
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,31 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.config;
|
||||
|
||||
import com.tashow.cloud.infra.framework.file.core.client.FileClientConfig;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置 Response VO")
|
||||
/** 管理后台 - 文件配置 Response VO */
|
||||
@Data
|
||||
public class FileConfigRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
/** 编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置名", requiredMode = Schema.RequiredMode.REQUIRED, example = "S3 - 阿里云")
|
||||
private String name;
|
||||
/** 配置名" */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储器,参见 FileStorageEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer storage;
|
||||
/** 存储器,参见 FileStorageEnum 枚举类" */
|
||||
private Integer storage;
|
||||
|
||||
@Schema(description = "是否为主配置", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean master;
|
||||
/** 是否为主配置" */
|
||||
private Boolean master;
|
||||
|
||||
@Schema(description = "存储配置", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private FileClientConfig config;
|
||||
/** 存储配置 */
|
||||
private FileClientConfig config;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置创建/修改 Request VO")
|
||||
/** 管理后台 - 文件配置创建/修改 Request VO */
|
||||
@Data
|
||||
public class FileConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "1")
|
||||
private Long id;
|
||||
/** 编号 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置名", requiredMode = Schema.RequiredMode.REQUIRED, example = "S3 - 阿里云")
|
||||
@NotNull(message = "配置名不能为空")
|
||||
private String name;
|
||||
/** 配置名" */
|
||||
@NotNull(message = "配置名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储器,参见 FileStorageEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "存储器不能为空")
|
||||
private Integer storage;
|
||||
/** 存储器,参见 FileStorageEnum 枚举类" */
|
||||
@NotNull(message = "存储器不能为空")
|
||||
private Integer storage;
|
||||
|
||||
@Schema(description = "存储配置,配置是动态参数,所以使用 Map 接收", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "存储配置不能为空")
|
||||
private Map<String, Object> config;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
/** 存储配置,配置是动态参数,所以使用 Map 接收 */
|
||||
@NotNull(message = "存储配置不能为空")
|
||||
private Map<String, Object> config;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.file;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 文件创建 Request VO")
|
||||
/** 管理后台 - 文件创建 Request VO */
|
||||
@Data
|
||||
public class FileCreateReqVO {
|
||||
|
||||
@NotNull(message = "文件配置编号不能为空")
|
||||
@Schema(description = "文件配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11")
|
||||
private Long configId;
|
||||
@NotNull(message = "文件配置编号不能为空")
|
||||
/** 文件配置编号" */
|
||||
private Long configId;
|
||||
|
||||
@NotNull(message = "文件路径不能为空")
|
||||
@Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao.jpg")
|
||||
private String path;
|
||||
@NotNull(message = "文件路径不能为空")
|
||||
/** 文件路径" */
|
||||
private String path;
|
||||
|
||||
@NotNull(message = "原文件名不能为空")
|
||||
@Schema(description = "原文件名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao.jpg")
|
||||
private String name;
|
||||
@NotNull(message = "原文件名不能为空")
|
||||
/** 原文件名" */
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "文件 URL不能为空")
|
||||
@Schema(description = "文件 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/yudao.jpg")
|
||||
private String url;
|
||||
@NotNull(message = "文件 URL不能为空")
|
||||
/** 文件 URL" */
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件 MIME 类型", example = "application/octet-stream")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "文件大小", example = "2048", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer size;
|
||||
/** 文件 MIME 类型 */
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 文件大小", example = "2048
|
||||
*/
|
||||
private Integer size;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.file;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文件分页 Request VO")
|
||||
/** 管理后台 - 文件分页 Request VO */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FilePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "文件路径,模糊匹配", example = "yudao")
|
||||
private String path;
|
||||
/** 文件路径,模糊匹配 */
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件类型,模糊匹配", example = "jpg")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
/** 文件类型,模糊匹配 */
|
||||
private String type;
|
||||
|
||||
/** 创建时间 */
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.file;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "管理后台 - 文件预签名地址 Response VO")
|
||||
/** 管理后台 - 文件预签名地址 Response VO */
|
||||
@Data
|
||||
public class FilePresignedUrlRespVO {
|
||||
|
||||
@Schema(description = "配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11")
|
||||
private Long configId;
|
||||
/** 配置编号" */
|
||||
private Long configId;
|
||||
|
||||
@Schema(description = "文件上传 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://s3.cn-south-1.qiniucs.com/ruoyi-vue-pro/758d3a5387507358c7236de4c8f96de1c7f5097ff6a7722b34772fb7b76b140f.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=3TvrJ70gl2Gt6IBe7_IZT1F6i_k0iMuRtyEv4EyS%2F20240217%2Fcn-south-1%2Fs3%2Faws4_request&X-Amz-Date=20240217T123222Z&X-Amz-Expires=600&X-Amz-SignedHeaders=host&X-Amz-Signature=a29f33770ab79bf523ccd4034d0752ac545f3c2a3b17baa1eb4e280cfdccfda5")
|
||||
private String uploadUrl;
|
||||
|
||||
/**
|
||||
* 为什么要返回 url 字段?
|
||||
*
|
||||
* 前端上传完文件后,需要使用该 URL 进行访问
|
||||
*/
|
||||
@Schema(description = "文件访问 URL", requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
example = "https://test.yudao.iocoder.cn/758d3a5387507358c7236de4c8f96de1c7f5097ff6a7722b34772fb7b76b140f.png")
|
||||
private String url;
|
||||
/** 文件上传 URL" */
|
||||
private String uploadUrl;
|
||||
|
||||
/**
|
||||
* 文件访问 URL
|
||||
*
|
||||
* <p>前端上传完文件后,需要使用该 URL 进行访问
|
||||
*/
|
||||
private String url;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,33 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.file;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文件 Response VO,不返回 content 字段,太大")
|
||||
/** 管理后台 - 文件 Response VO,不返回 content 字段,太大 */
|
||||
@Data
|
||||
public class FileRespVO {
|
||||
|
||||
@Schema(description = "文件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
/** 文件编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11")
|
||||
private Long configId;
|
||||
/** 配置编号" */
|
||||
private Long configId;
|
||||
|
||||
@Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao.jpg")
|
||||
private String path;
|
||||
/** 文件路径" */
|
||||
private String path;
|
||||
|
||||
@Schema(description = "原文件名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao.jpg")
|
||||
private String name;
|
||||
/** 原文件名" */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/yudao.jpg")
|
||||
private String url;
|
||||
/** 文件 URL" */
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件MIME类型", example = "application/octet-stream")
|
||||
private String type;
|
||||
/** 文件MIME类型 */
|
||||
private String type;
|
||||
|
||||
@Schema(description = "文件大小", example = "2048", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer size;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
/** 文件大小", example = "2048 */
|
||||
private Integer size;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package com.tashow.cloud.infra.controller.admin.file.vo.file;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 上传文件 Request VO")
|
||||
/** 管理后台 - 上传文件 Request VO */
|
||||
@Data
|
||||
public class FileUploadReqVO {
|
||||
|
||||
@Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile file;
|
||||
|
||||
@Schema(description = "文件附件", example = "yudaoyuanma.png")
|
||||
private String path;
|
||||
/** 文件附件 */
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile file;
|
||||
|
||||
/** 文件附件 */
|
||||
private String path;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
package com.tashow.cloud.infra.controller.admin.job;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.error;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
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 static com.tashow.cloud.common.pojo.CommonResult.error;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 定时任务")
|
||||
/** 管理后台 - 定时任务 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/job")
|
||||
@Validated
|
||||
public class JobController {
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得定时任务分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<String> getJobPage() {
|
||||
return error(-1, "Cloud 版本使用 XXL-Job 作为定时任务!请参考 https://cloud.iocoder.cn/job/ 文档操作");
|
||||
}
|
||||
|
||||
/** 获得定时任务分页 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<String> getJobPage() {
|
||||
return error(-1, "Cloud 版本使用 XXL-Job 作为定时任务!请参考 https://cloud.iocoder.cn/job/ 文档操作");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.tashow.cloud.infra.controller.admin.logger;
|
||||
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
@@ -10,59 +12,49 @@ import com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessL
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import com.tashow.cloud.infra.service.logger.ApiAccessLogService;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import com.tashow.cloud.infra.service.logger.ApiAccessLogService;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import com.tashow.cloud.infra.service.logger.ApiAccessLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
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.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - API 访问日志")
|
||||
/** 管理后台 - API 访问日志 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/api-access-log")
|
||||
@Validated
|
||||
public class ApiAccessLogController {
|
||||
|
||||
@Resource
|
||||
private ApiAccessLogService apiAccessLogService;
|
||||
@Resource private ApiAccessLogService apiAccessLogService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得API 访问日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
|
||||
public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@Valid ApiAccessLogPageReqVO pageReqVO) {
|
||||
PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ApiAccessLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出API 访问日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportApiAccessLogExcel(@Valid ApiAccessLogPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", ApiAccessLogRespVO.class,
|
||||
BeanUtils.toBean(list, ApiAccessLogRespVO.class));
|
||||
}
|
||||
/** 获得API 访问日志分页 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
|
||||
public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(
|
||||
@Valid ApiAccessLogPageReqVO pageReqVO) {
|
||||
PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ApiAccessLogRespVO.class));
|
||||
}
|
||||
|
||||
/** 导出API 访问日志 Excel */
|
||||
@GetMapping("/export-excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportApiAccessLogExcel(
|
||||
@Valid ApiAccessLogPageReqVO exportReqVO, HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(
|
||||
response,
|
||||
"API 访问日志.xls",
|
||||
"数据",
|
||||
ApiAccessLogRespVO.class,
|
||||
BeanUtils.toBean(list, ApiAccessLogRespVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,68 @@
|
||||
package com.tashow.cloud.infra.controller.admin.logger;
|
||||
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.web.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.excel.excel.core.util.ExcelUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import com.tashow.cloud.infra.service.logger.ApiErrorLogService;
|
||||
import com.tashow.cloud.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - API 错误日志")
|
||||
/** 管理后台 - API 错误日志 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/api-error-log")
|
||||
@Validated
|
||||
public class ApiErrorLogController {
|
||||
|
||||
@Resource
|
||||
private ApiErrorLogService apiErrorLogService;
|
||||
@Resource private ApiErrorLogService apiErrorLogService;
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "更新 API 错误日志的状态")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024"),
|
||||
@Parameter(name = "processStatus", description = "处理状态", required = true, example = "1")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:update-status')")
|
||||
public CommonResult<Boolean> updateApiErrorLogProcess(@RequestParam("id") Long id,
|
||||
@RequestParam("processStatus") Integer processStatus) {
|
||||
apiErrorLogService.updateApiErrorLogProcess(id, processStatus, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
/** 更新 API 错误日志的状态 */
|
||||
@PutMapping("/update-status")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:update-status')")
|
||||
public CommonResult<Boolean> updateApiErrorLogProcess(
|
||||
@RequestParam("id") Long id, @RequestParam("processStatus") Integer processStatus) {
|
||||
apiErrorLogService.updateApiErrorLogProcess(id, processStatus, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得 API 错误日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:query')")
|
||||
public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@Valid ApiErrorLogPageReqVO pageReqVO) {
|
||||
PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ApiErrorLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出 API 错误日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportApiErrorLogExcel(@Valid ApiErrorLogPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "API 错误日志.xls", "数据", ApiErrorLogRespVO.class,
|
||||
BeanUtils.toBean(list, ApiErrorLogRespVO.class));
|
||||
}
|
||||
/** 获得 API 错误日志分页 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:query')")
|
||||
public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(
|
||||
@Valid ApiErrorLogPageReqVO pageReqVO) {
|
||||
PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ApiErrorLogRespVO.class));
|
||||
}
|
||||
|
||||
/** 导出 API 错误日志 Excel */
|
||||
@GetMapping("/export-excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportApiErrorLogExcel(
|
||||
@Valid ApiErrorLogPageReqVO exportReqVO, HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(
|
||||
response,
|
||||
"API 错误日志.xls",
|
||||
"数据",
|
||||
ApiErrorLogRespVO.class,
|
||||
BeanUtils.toBean(list, ApiErrorLogRespVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,39 @@
|
||||
package com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - API 访问日志分页 Request VO")
|
||||
/** 管理后台 - API 访问日志分页 Request VO */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiAccessLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
/** 用户编号 */
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
/** 用户类型 */
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
/** 应用名 */
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求地址,模糊匹配", example = "/xxx/yyy")
|
||||
private String requestUrl;
|
||||
/** 请求地址,模糊匹配 */
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "开始时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] beginTime;
|
||||
/** 开始时间 */
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] beginTime;
|
||||
|
||||
@Schema(description = "执行时长,大于等于,单位:毫秒", example = "100")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "结果码", example = "0")
|
||||
private Integer resultCode;
|
||||
/** 执行时长,大于等于,单位:毫秒 */
|
||||
private Integer duration;
|
||||
|
||||
/** 结果码 */
|
||||
private Integer resultCode;
|
||||
}
|
||||
|
||||
@@ -1,99 +1,96 @@
|
||||
package com.tashow.cloud.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import com.tashow.cloud.systemapi.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - API 访问日志 Response VO")
|
||||
/** 管理后台 - API 访问日志 Response VO */
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ApiAccessLogRespVO {
|
||||
|
||||
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
/** 日志主键" */
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
/** 链路追踪编号" */
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
/** 用户编号" */
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
/** 用户类型,参见 UserTypeEnum 枚举" */
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
/** 应用名" */
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
/** 请求方法名" */
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
/** 请求地址", example = "/xxx/yyy */
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "请求参数")
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
/** 请求参数 */
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "响应结果")
|
||||
@ExcelProperty("响应结果")
|
||||
private String responseBody;
|
||||
/** 响应结果 */
|
||||
@ExcelProperty("响应结果")
|
||||
private String responseBody;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
/** 用户 IP" */
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
/** 浏览器 UA" */
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "操作模块", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品模块")
|
||||
@ExcelProperty("操作模块")
|
||||
private String operateModule;
|
||||
/** 操作模块", example = "商品模块 */
|
||||
@ExcelProperty("操作模块")
|
||||
private String operateModule;
|
||||
|
||||
@Schema(description = "操作名", requiredMode = Schema.RequiredMode.REQUIRED, example = "创建商品")
|
||||
@ExcelProperty("操作名")
|
||||
private String operateName;
|
||||
/** 操作名", example = "创建商品 */
|
||||
@ExcelProperty("操作名")
|
||||
private String operateName;
|
||||
|
||||
@Schema(description = "操作分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "操作分类", converter = DictConvert.class)
|
||||
@DictFormat(com.tashow.cloud.infraapi.enums.DictTypeConstants.OPERATE_TYPE)
|
||||
private Integer operateType;
|
||||
/** 操作分类" */
|
||||
@ExcelProperty(value = "操作分类", converter = DictConvert.class)
|
||||
@DictFormat(com.tashow.cloud.infraapi.enums.DictTypeConstants.OPERATE_TYPE)
|
||||
private Integer operateType;
|
||||
|
||||
@Schema(description = "开始请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("开始请求时间")
|
||||
private LocalDateTime beginTime;
|
||||
/** 开始请求时间 */
|
||||
@ExcelProperty("开始请求时间")
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@Schema(description = "结束请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("结束请求时间")
|
||||
private LocalDateTime endTime;
|
||||
/** 结束请求时间 */
|
||||
@ExcelProperty("结束请求时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "执行时长", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
/** 执行时长" */
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "结果码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty("结果码")
|
||||
private Integer resultCode;
|
||||
/** 结果码" */
|
||||
@ExcelProperty("结果码")
|
||||
private Integer resultCode;
|
||||
|
||||
@Schema(description = "结果提示", example = "芋道源码,牛逼!")
|
||||
@ExcelProperty("结果提示")
|
||||
private String resultMsg;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
/** 结果提示 */
|
||||
@ExcelProperty("结果提示")
|
||||
private String resultMsg;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
package com.tashow.cloud.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - API 错误日志分页 Request VO")
|
||||
/** 管理后台 - API 错误日志分页 Request VO */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiErrorLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
/** 用户编号 */
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
/** 用户类型 */
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
/** 应用名 */
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求地址", example = "/xx/yy")
|
||||
private String requestUrl;
|
||||
/** 请求地址 */
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "异常发生时间")
|
||||
private LocalDateTime[] exceptionTime;
|
||||
|
||||
@Schema(description = "处理状态", example = "0")
|
||||
private Integer processStatus;
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
/** 异常发生时间 */
|
||||
private LocalDateTime[] exceptionTime;
|
||||
|
||||
/** 处理状态 */
|
||||
private Integer processStatus;
|
||||
}
|
||||
|
||||
@@ -1,113 +1,109 @@
|
||||
package com.tashow.cloud.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import com.tashow.cloud.infraapi.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.infraapi.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - API 错误日志 Response VO")
|
||||
/** 管理后台 - API 错误日志 Response VO */
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ApiErrorLogRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
/** 编号" */
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
/** 链路追踪编号" */
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
/** 用户编号" */
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(com.tashow.cloud.systemapi.enums.DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
/** 用户类型" */
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(com.tashow.cloud.systemapi.enums.DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
/** 应用名" */
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
/** 请求方法名" */
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xx/yy")
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
/** 请求地址", example = "/xx/yy */
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
/** 请求参数 */
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
/** 用户 IP" */
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
/** 浏览器 UA" */
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "异常发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生时间")
|
||||
private LocalDateTime exceptionTime;
|
||||
/** 异常发生时间 */
|
||||
@ExcelProperty("异常发生时间")
|
||||
private LocalDateTime exceptionTime;
|
||||
|
||||
@Schema(description = "异常名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常名")
|
||||
private String exceptionName;
|
||||
/** 异常名 */
|
||||
@ExcelProperty("异常名")
|
||||
private String exceptionName;
|
||||
|
||||
@Schema(description = "异常导致的消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常导致的消息")
|
||||
private String exceptionMessage;
|
||||
/** 异常导致的消息 */
|
||||
@ExcelProperty("异常导致的消息")
|
||||
private String exceptionMessage;
|
||||
|
||||
@Schema(description = "异常导致的根消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常导致的根消息")
|
||||
private String exceptionRootCauseMessage;
|
||||
/** 异常导致的根消息 */
|
||||
@ExcelProperty("异常导致的根消息")
|
||||
private String exceptionRootCauseMessage;
|
||||
|
||||
@Schema(description = "异常的栈轨迹", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常的栈轨迹")
|
||||
private String exceptionStackTrace;
|
||||
/** 异常的栈轨迹 */
|
||||
@ExcelProperty("异常的栈轨迹")
|
||||
private String exceptionStackTrace;
|
||||
|
||||
@Schema(description = "异常发生的类全名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的类全名")
|
||||
private String exceptionClassName;
|
||||
/** 异常发生的类全名 */
|
||||
@ExcelProperty("异常发生的类全名")
|
||||
private String exceptionClassName;
|
||||
|
||||
@Schema(description = "异常发生的类文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的类文件")
|
||||
private String exceptionFileName;
|
||||
/** 异常发生的类文件 */
|
||||
@ExcelProperty("异常发生的类文件")
|
||||
private String exceptionFileName;
|
||||
|
||||
@Schema(description = "异常发生的方法名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的方法名")
|
||||
private String exceptionMethodName;
|
||||
/** 异常发生的方法名 */
|
||||
@ExcelProperty("异常发生的方法名")
|
||||
private String exceptionMethodName;
|
||||
|
||||
@Schema(description = "异常发生的方法所在行", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的方法所在行")
|
||||
private Integer exceptionLineNumber;
|
||||
/** 异常发生的方法所在行 */
|
||||
@ExcelProperty("异常发生的方法所在行")
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
@Schema(description = "处理状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty(value = "处理状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
|
||||
private Integer processStatus;
|
||||
/** 处理状态" */
|
||||
@ExcelProperty(value = "处理状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
|
||||
private Integer processStatus;
|
||||
|
||||
@Schema(description = "处理时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("处理时间")
|
||||
private LocalDateTime processTime;
|
||||
/** 处理时间 */
|
||||
@ExcelProperty("处理时间")
|
||||
private LocalDateTime processTime;
|
||||
|
||||
@Schema(description = "处理用户编号", example = "233")
|
||||
@ExcelProperty("处理用户编号")
|
||||
private Integer processUserId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
/** 处理用户编号 */
|
||||
@ExcelProperty("处理用户编号")
|
||||
private Integer processUserId;
|
||||
|
||||
/** 创建时间 */
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.tashow.cloud.infra.controller.admin.redis;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.infra.controller.admin.redis.vo.RedisMonitorRespVO;
|
||||
import com.tashow.cloud.infra.convert.redis.RedisConvert;
|
||||
import com.tashow.cloud.infra.controller.admin.redis.vo.RedisMonitorRespVO;
|
||||
import com.tashow.cloud.infra.convert.redis.RedisConvert;
|
||||
import com.tashow.cloud.infra.controller.admin.redis.vo.RedisMonitorRespVO;
|
||||
import com.tashow.cloud.infra.convert.redis.RedisConvert;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Properties;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -17,31 +15,27 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - Redis 监控")
|
||||
/** 管理后台 - Redis 监控 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/redis")
|
||||
public class RedisController {
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@GetMapping("/get-monitor-info")
|
||||
@Operation(summary = "获得 Redis 监控信息")
|
||||
@PreAuthorize("@ss.hasPermission('infra:redis:get-monitor-info')")
|
||||
public CommonResult<RedisMonitorRespVO> getRedisMonitorInfo() {
|
||||
// 获得 Redis 统计信息
|
||||
Properties info = stringRedisTemplate.execute((RedisCallback<Properties>) RedisServerCommands::info);
|
||||
Long dbSize = stringRedisTemplate.execute(RedisServerCommands::dbSize);
|
||||
Properties commandStats = stringRedisTemplate.execute((
|
||||
RedisCallback<Properties>) connection -> connection.serverCommands().info("commandstats"));
|
||||
assert commandStats != null; // 断言,避免警告
|
||||
// 拼接结果返回
|
||||
return success(RedisConvert.INSTANCE.build(info, dbSize, commandStats));
|
||||
}
|
||||
@Resource private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
/** 获得 Redis 监控信息 */
|
||||
@GetMapping("/get-monitor-info")
|
||||
@PreAuthorize("@ss.hasPermission('infra:redis:get-monitor-info')")
|
||||
public CommonResult<RedisMonitorRespVO> getRedisMonitorInfo() {
|
||||
// 获得 Redis 统计信息
|
||||
Properties info =
|
||||
stringRedisTemplate.execute((RedisCallback<Properties>) RedisServerCommands::info);
|
||||
Long dbSize = stringRedisTemplate.execute(RedisServerCommands::dbSize);
|
||||
Properties commandStats =
|
||||
stringRedisTemplate.execute(
|
||||
(RedisCallback<Properties>)
|
||||
connection -> connection.serverCommands().info("commandstats"));
|
||||
assert commandStats != null; // 断言,避免警告
|
||||
// 拼接结果返回
|
||||
return success(RedisConvert.INSTANCE.build(info, dbSize, commandStats));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,38 @@
|
||||
package com.tashow.cloud.infra.controller.admin.redis.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@Schema(description = "管理后台 - Redis 监控信息 Response VO")
|
||||
/** 管理后台 - Redis 监控信息 Response VO */
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class RedisMonitorRespVO {
|
||||
|
||||
@Schema(description = "Redis info 指令结果,具体字段,查看 Redis 文档", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Properties info;
|
||||
private Properties info;
|
||||
|
||||
@Schema(description = "Redis key 数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long dbSize;
|
||||
/** Redis key 数量" */
|
||||
private Long dbSize;
|
||||
|
||||
@Schema(description = "CommandStat 数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<CommandStat> commandStats;
|
||||
/** CommandStat 数组 */
|
||||
private List<CommandStat> commandStats;
|
||||
|
||||
@Schema(description = "Redis 命令统计结果")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public static class CommandStat {
|
||||
/** Redis 命令统计结果 */
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public static class CommandStat {
|
||||
|
||||
@Schema(description = "Redis 命令", requiredMode = Schema.RequiredMode.REQUIRED, example = "get")
|
||||
private String command;
|
||||
/** Redis 命令" */
|
||||
private String command;
|
||||
|
||||
@Schema(description = "调用次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long calls;
|
||||
|
||||
@Schema(description = "消耗 CPU 秒数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
private Long usec;
|
||||
|
||||
}
|
||||
/** 调用次数" */
|
||||
private Long calls;
|
||||
|
||||
/** 消耗 CPU 秒数" */
|
||||
private Long usec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.tashow.cloud.infra.controller.app.file;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.infra.service.file.FileService;
|
||||
import com.tashow.cloud.infra.controller.admin.file.vo.file.FileCreateReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
|
||||
import com.tashow.cloud.infra.controller.app.file.vo.AppFileUploadReqVO;
|
||||
import com.tashow.cloud.infra.service.file.FileService;
|
||||
import com.tashow.cloud.infra.service.file.FileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -18,39 +16,38 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 文件存储")
|
||||
/** 用户 App - 文件存储 */
|
||||
@RestController
|
||||
@RequestMapping("/infra/file")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppFileController {
|
||||
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
@Resource private FileService fileService;
|
||||
|
||||
@PostMapping("/upload")
|
||||
@Operation(summary = "上传文件")
|
||||
@PermitAll
|
||||
public CommonResult<String> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
/** 上传文件 */
|
||||
@PostMapping("/upload")
|
||||
@PermitAll
|
||||
public CommonResult<String> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(
|
||||
fileService.createFile(
|
||||
file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@GetMapping("/presigned-url")
|
||||
@Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
|
||||
@PermitAll
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception {
|
||||
return success(fileService.getFilePresignedUrl(path));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件")
|
||||
@PermitAll
|
||||
public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) {
|
||||
return success(fileService.createFile(createReqVO));
|
||||
}
|
||||
/** 获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器 */
|
||||
@GetMapping("/presigned-url")
|
||||
@PermitAll
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path)
|
||||
throws Exception {
|
||||
return success(fileService.getFilePresignedUrl(path));
|
||||
}
|
||||
|
||||
/** 创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件 */
|
||||
@PostMapping("/create")
|
||||
@PermitAll
|
||||
public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) {
|
||||
return success(fileService.createFile(createReqVO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package com.tashow.cloud.infra.controller.app.file.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "用户 App - 上传文件 Request VO")
|
||||
/** 用户 App - 上传文件 Request VO */
|
||||
@Data
|
||||
public class AppFileUploadReqVO {
|
||||
|
||||
@Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile file;
|
||||
|
||||
@Schema(description = "文件附件", example = "yudaoyuanma.png")
|
||||
private String path;
|
||||
/** 文件附件 */
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile file;
|
||||
|
||||
/** 文件附件 */
|
||||
private String path;
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.tashow.cloud.infra.dal.mysql.demo.demo01;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 示例联系人 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo01ContactMapper extends BaseMapperX<Demo01ContactDO> {
|
||||
|
||||
default PageResult<Demo01ContactDO> selectPage(Demo01ContactPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo01ContactDO>()
|
||||
.likeIfPresent(Demo01ContactDO::getName, reqVO.getName())
|
||||
.eqIfPresent(Demo01ContactDO::getSex, reqVO.getSex())
|
||||
.betweenIfPresent(Demo01ContactDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(Demo01ContactDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.tashow.cloud.infra.dal.mysql.demo.demo02;
|
||||
|
||||
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 示例分类 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo02CategoryMapper extends BaseMapperX<Demo02CategoryDO> {
|
||||
|
||||
default List<Demo02CategoryDO> selectList(Demo02CategoryListReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<Demo02CategoryDO>()
|
||||
.likeIfPresent(Demo02CategoryDO::getName, reqVO.getName())
|
||||
.eqIfPresent(Demo02CategoryDO::getParentId, reqVO.getParentId())
|
||||
.betweenIfPresent(Demo02CategoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(Demo02CategoryDO::getId));
|
||||
}
|
||||
|
||||
default Demo02CategoryDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(Demo02CategoryDO::getParentId, parentId, Demo02CategoryDO::getName, name);
|
||||
}
|
||||
|
||||
default Long selectCountByParentId(Long parentId) {
|
||||
return selectCount(Demo02CategoryDO::getParentId, parentId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.tashow.cloud.infra.dal.mysql.demo.demo03;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生课程 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03CourseMapper extends BaseMapperX<Demo03CourseDO> {
|
||||
|
||||
default PageResult<Demo03CourseDO> selectPage(PageParam reqVO, Long studentId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03CourseDO>()
|
||||
.eq(Demo03CourseDO::getStudentId, studentId)
|
||||
.orderByDesc(Demo03CourseDO::getId));
|
||||
}
|
||||
|
||||
default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
|
||||
return selectList(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.tashow.cloud.infra.dal.mysql.demo.demo03;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 学生班级 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03GradeMapper extends BaseMapperX<Demo03GradeDO> {
|
||||
|
||||
default PageResult<Demo03GradeDO> selectPage(PageParam reqVO, Long studentId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03GradeDO>()
|
||||
.eq(Demo03GradeDO::getStudentId, studentId)
|
||||
.orderByDesc(Demo03GradeDO::getId));
|
||||
}
|
||||
|
||||
default Demo03GradeDO selectByStudentId(Long studentId) {
|
||||
return selectOne(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.tashow.cloud.infra.dal.mysql.demo.demo03;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
|
||||
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 学生 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03StudentMapper extends BaseMapperX<Demo03StudentDO> {
|
||||
|
||||
default PageResult<Demo03StudentDO> selectPage(Demo03StudentPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
|
||||
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
|
||||
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
|
||||
.eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
|
||||
.betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(Demo03StudentDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,11 +23,6 @@ public class SecurityConfiguration {
|
||||
|
||||
@Override
|
||||
public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
|
||||
// Swagger 接口文档
|
||||
registry.requestMatchers("/v3/api-docs/**").permitAll()
|
||||
.requestMatchers("/webjars/**").permitAll()
|
||||
.requestMatchers("/swagger-ui").permitAll()
|
||||
.requestMatchers("/swagger-ui/**").permitAll();
|
||||
// Spring Boot Actuator 的安全配置
|
||||
registry.requestMatchers("/actuator").permitAll()
|
||||
.requestMatchers("/actuator/**").permitAll();
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.tashow.cloud.infra.service.demo.demo01;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 示例联系人 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface Demo01ContactService {
|
||||
|
||||
/**
|
||||
* 创建示例联系人
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo01Contact(@Valid Demo01ContactSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新示例联系人
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemo01Contact(@Valid Demo01ContactSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除示例联系人
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo01Contact(Long id);
|
||||
|
||||
/**
|
||||
* 获得示例联系人
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 示例联系人
|
||||
*/
|
||||
Demo01ContactDO getDemo01Contact(Long id);
|
||||
|
||||
/**
|
||||
* 获得示例联系人分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 示例联系人分页
|
||||
*/
|
||||
PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.tashow.cloud.infra.service.demo.demo01;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import com.tashow.cloud.infra.dal.mysql.demo.demo01.Demo01ContactMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.DEMO01_CONTACT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 示例联系人 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class Demo01ContactServiceImpl implements Demo01ContactService {
|
||||
|
||||
@Resource
|
||||
private Demo01ContactMapper demo01ContactMapper;
|
||||
|
||||
@Override
|
||||
public Long createDemo01Contact(Demo01ContactSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
Demo01ContactDO demo01Contact = BeanUtils.toBean(createReqVO, Demo01ContactDO.class);
|
||||
demo01ContactMapper.insert(demo01Contact);
|
||||
// 返回
|
||||
return demo01Contact.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemo01Contact(Demo01ContactSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemo01ContactExists(updateReqVO.getId());
|
||||
// 更新
|
||||
Demo01ContactDO updateObj = BeanUtils.toBean(updateReqVO, Demo01ContactDO.class);
|
||||
demo01ContactMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo01Contact(Long id) {
|
||||
// 校验存在
|
||||
validateDemo01ContactExists(id);
|
||||
// 删除
|
||||
demo01ContactMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDemo01ContactExists(Long id) {
|
||||
if (demo01ContactMapper.selectById(id) == null) {
|
||||
throw exception(DEMO01_CONTACT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo01ContactDO getDemo01Contact(Long id) {
|
||||
return demo01ContactMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO) {
|
||||
return demo01ContactMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.tashow.cloud.infra.service.demo.demo02;
|
||||
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 示例分类 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface Demo02CategoryService {
|
||||
|
||||
/**
|
||||
* 创建示例分类
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo02Category(@Valid Demo02CategorySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新示例分类
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemo02Category(@Valid Demo02CategorySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除示例分类
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo02Category(Long id);
|
||||
|
||||
/**
|
||||
* 获得示例分类
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 示例分类
|
||||
*/
|
||||
Demo02CategoryDO getDemo02Category(Long id);
|
||||
|
||||
/**
|
||||
* 获得示例分类列表
|
||||
*
|
||||
* @param listReqVO 查询条件
|
||||
* @return 示例分类列表
|
||||
*/
|
||||
List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO);
|
||||
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package com.tashow.cloud.infra.service.demo.demo02;
|
||||
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
import com.tashow.cloud.infra.dal.mysql.demo.demo02.Demo02CategoryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 示例分类 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class Demo02CategoryServiceImpl implements Demo02CategoryService {
|
||||
|
||||
@Resource
|
||||
private Demo02CategoryMapper demo02CategoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createDemo02Category(Demo02CategorySaveReqVO createReqVO) {
|
||||
// 校验父级编号的有效性
|
||||
validateParentDemo02Category(null, createReqVO.getParentId());
|
||||
// 校验名字的唯一性
|
||||
validateDemo02CategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
|
||||
|
||||
// 插入
|
||||
Demo02CategoryDO demo02Category = BeanUtils.toBean(createReqVO, Demo02CategoryDO.class);
|
||||
demo02CategoryMapper.insert(demo02Category);
|
||||
// 返回
|
||||
return demo02Category.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemo02Category(Demo02CategorySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemo02CategoryExists(updateReqVO.getId());
|
||||
// 校验父级编号的有效性
|
||||
validateParentDemo02Category(updateReqVO.getId(), updateReqVO.getParentId());
|
||||
// 校验名字的唯一性
|
||||
validateDemo02CategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
|
||||
|
||||
// 更新
|
||||
Demo02CategoryDO updateObj = BeanUtils.toBean(updateReqVO, Demo02CategoryDO.class);
|
||||
demo02CategoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo02Category(Long id) {
|
||||
// 校验存在
|
||||
validateDemo02CategoryExists(id);
|
||||
// 校验是否有子示例分类
|
||||
if (demo02CategoryMapper.selectCountByParentId(id) > 0) {
|
||||
throw exception(DEMO02_CATEGORY_EXITS_CHILDREN);
|
||||
}
|
||||
// 删除
|
||||
demo02CategoryMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDemo02CategoryExists(Long id) {
|
||||
if (demo02CategoryMapper.selectById(id) == null) {
|
||||
throw exception(DEMO02_CATEGORY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateParentDemo02Category(Long id, Long parentId) {
|
||||
if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
|
||||
return;
|
||||
}
|
||||
// 1. 不能设置自己为父示例分类
|
||||
if (Objects.equals(id, parentId)) {
|
||||
throw exception(DEMO02_CATEGORY_PARENT_ERROR);
|
||||
}
|
||||
// 2. 父示例分类不存在
|
||||
Demo02CategoryDO parentDemo02Category = demo02CategoryMapper.selectById(parentId);
|
||||
if (parentDemo02Category == null) {
|
||||
throw exception(DEMO02_CATEGORY_PARENT_NOT_EXITS);
|
||||
}
|
||||
// 3. 递归校验父示例分类,如果父示例分类是自己的子示例分类,则报错,避免形成环路
|
||||
if (id == null) { // id 为空,说明新增,不需要考虑环路
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < Short.MAX_VALUE; i++) {
|
||||
// 3.1 校验环路
|
||||
parentId = parentDemo02Category.getParentId();
|
||||
if (Objects.equals(id, parentId)) {
|
||||
throw exception(DEMO02_CATEGORY_PARENT_IS_CHILD);
|
||||
}
|
||||
// 3.2 继续递归下一级父示例分类
|
||||
if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
|
||||
break;
|
||||
}
|
||||
parentDemo02Category = demo02CategoryMapper.selectById(parentId);
|
||||
if (parentDemo02Category == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDemo02CategoryNameUnique(Long id, Long parentId, String name) {
|
||||
Demo02CategoryDO demo02Category = demo02CategoryMapper.selectByParentIdAndName(parentId, name);
|
||||
if (demo02Category == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的示例分类
|
||||
if (id == null) {
|
||||
throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
|
||||
}
|
||||
if (!Objects.equals(demo02Category.getId(), id)) {
|
||||
throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo02CategoryDO getDemo02Category(Long id) {
|
||||
return demo02CategoryMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO) {
|
||||
return demo02CategoryMapper.selectList(listReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package com.tashow.cloud.infra.service.demo.demo03;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface Demo03StudentService {
|
||||
|
||||
/**
|
||||
* 创建学生
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo03Student(@Valid Demo03StudentSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新学生
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemo03Student(@Valid Demo03StudentSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 获得学生
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 学生
|
||||
*/
|
||||
Demo03StudentDO getDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 获得学生分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 学生分页
|
||||
*/
|
||||
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO);
|
||||
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
/**
|
||||
* 获得学生课程列表
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生课程列表
|
||||
*/
|
||||
List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
|
||||
|
||||
/**
|
||||
* 获得学生课程分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param studentId 学生编号
|
||||
* @return 学生课程分页
|
||||
*/
|
||||
PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId);
|
||||
|
||||
/**
|
||||
* 创建学生课程
|
||||
*
|
||||
* @param demo03Course 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo03Course(@Valid Demo03CourseDO demo03Course);
|
||||
|
||||
/**
|
||||
* 更新学生课程
|
||||
*
|
||||
* @param demo03Course 更新信息
|
||||
*/
|
||||
void updateDemo03Course(@Valid Demo03CourseDO demo03Course);
|
||||
|
||||
/**
|
||||
* 删除学生课程
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo03Course(Long id);
|
||||
|
||||
/**
|
||||
* 获得学生课程
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 学生课程
|
||||
*/
|
||||
Demo03CourseDO getDemo03Course(Long id);
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
/**
|
||||
* 获得学生班级
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生班级
|
||||
*/
|
||||
Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
|
||||
|
||||
/**
|
||||
* 获得学生班级分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param studentId 学生编号
|
||||
* @return 学生班级分页
|
||||
*/
|
||||
PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId);
|
||||
|
||||
/**
|
||||
* 创建学生班级
|
||||
*
|
||||
* @param demo03Grade 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo03Grade(@Valid Demo03GradeDO demo03Grade);
|
||||
|
||||
/**
|
||||
* 更新学生班级
|
||||
*
|
||||
* @param demo03Grade 更新信息
|
||||
*/
|
||||
void updateDemo03Grade(@Valid Demo03GradeDO demo03Grade);
|
||||
|
||||
/**
|
||||
* 删除学生班级
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo03Grade(Long id);
|
||||
|
||||
/**
|
||||
* 获得学生班级
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 学生班级
|
||||
*/
|
||||
Demo03GradeDO getDemo03Grade(Long id);
|
||||
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
package com.tashow.cloud.infra.service.demo.demo03;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import com.tashow.cloud.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import com.tashow.cloud.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import com.tashow.cloud.infra.dal.mysql.demo.demo03.Demo03CourseMapper;
|
||||
import com.tashow.cloud.infra.dal.mysql.demo.demo03.Demo03GradeMapper;
|
||||
import com.tashow.cloud.infra.dal.mysql.demo.demo03.Demo03StudentMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.tashow.cloud.infraapi.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 学生 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class Demo03StudentServiceImpl implements Demo03StudentService {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentMapper demo03StudentMapper;
|
||||
@Resource
|
||||
private Demo03CourseMapper demo03CourseMapper;
|
||||
@Resource
|
||||
private Demo03GradeMapper demo03GradeMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createDemo03Student(Demo03StudentSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
|
||||
demo03StudentMapper.insert(demo03Student);
|
||||
|
||||
// 插入子表
|
||||
createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
|
||||
createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
|
||||
// 返回
|
||||
return demo03Student.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDemo03Student(Demo03StudentSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(updateReqVO.getId());
|
||||
// 更新
|
||||
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
|
||||
demo03StudentMapper.updateById(updateObj);
|
||||
|
||||
// 更新子表
|
||||
updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
|
||||
updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDemo03Student(Long id) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(id);
|
||||
// 删除
|
||||
demo03StudentMapper.deleteById(id);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentId(id);
|
||||
deleteDemo03GradeByStudentId(id);
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(Long id) {
|
||||
if (demo03StudentMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03StudentDO getDemo03Student(Long id) {
|
||||
return demo03StudentMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO) {
|
||||
return demo03StudentMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@Override
|
||||
public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
|
||||
return demo03CourseMapper.selectListByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
if (list != null) {
|
||||
list.forEach(o -> o.setStudentId(studentId));
|
||||
}
|
||||
demo03CourseMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
deleteDemo03CourseByStudentId(studentId);
|
||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||
createDemo03CourseList(studentId, list);
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentId(Long studentId) {
|
||||
demo03CourseMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId) {
|
||||
return demo03CourseMapper.selectPage(pageReqVO, studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createDemo03Course(Demo03CourseDO demo03Course) {
|
||||
demo03CourseMapper.insert(demo03Course);
|
||||
return demo03Course.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemo03Course(Demo03CourseDO demo03Course) {
|
||||
demo03CourseMapper.updateById(demo03Course);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo03Course(Long id) {
|
||||
demo03CourseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03CourseDO getDemo03Course(Long id) {
|
||||
return demo03CourseMapper.selectById(id);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@Override
|
||||
public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
|
||||
return demo03GradeMapper.selectByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId);
|
||||
demo03GradeMapper.insert(demo03Grade);
|
||||
}
|
||||
|
||||
private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId);
|
||||
demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
|
||||
demo03GradeMapper.insertOrUpdate(demo03Grade);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentId(Long studentId) {
|
||||
demo03GradeMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId) {
|
||||
return demo03GradeMapper.selectPage(pageReqVO, studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createDemo03Grade(Demo03GradeDO demo03Grade) {
|
||||
// 校验是否已经存在
|
||||
if (demo03GradeMapper.selectByStudentId(demo03Grade.getStudentId()) != null) {
|
||||
throw exception(DEMO03_GRADE_EXISTS);
|
||||
}
|
||||
demo03GradeMapper.insert(demo03Grade);
|
||||
return demo03Grade.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemo03Grade(Demo03GradeDO demo03Grade) {
|
||||
// 校验存在
|
||||
validateDemo03GradeExists(demo03Grade.getId());
|
||||
// 更新
|
||||
demo03GradeMapper.updateById(demo03Grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo03Grade(Long id) {
|
||||
// 校验存在
|
||||
validateDemo03GradeExists(id);
|
||||
// 删除
|
||||
demo03GradeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03GradeDO getDemo03Grade(Long id) {
|
||||
return demo03GradeMapper.selectById(id);
|
||||
}
|
||||
|
||||
private void validateDemo03GradeExists(Long id) {
|
||||
if (demo03GradeMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_GRADE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,10 +5,6 @@ import ${jakartaPackage}.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
#if ($sceneEnum.scene == 1)import org.springframework.security.access.prepost.PreAuthorize;#end
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import ${jakartaPackage}.validation.constraints.*;
|
||||
import ${jakartaPackage}.validation.*;
|
||||
import ${jakartaPackage}.servlet.http.*;
|
||||
@@ -34,7 +30,9 @@ import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.bu
|
||||
#end
|
||||
import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
||||
|
||||
@Tag(name = "${sceneEnum.name} - ${table.classComment}")
|
||||
/**
|
||||
* ${sceneEnum.name} - ${table.classComment}
|
||||
*/
|
||||
@RestController
|
||||
##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写
|
||||
@RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}")
|
||||
@@ -44,8 +42,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
@Resource
|
||||
private ${table.className}Service ${classNameVar}Service;
|
||||
|
||||
/**
|
||||
* 创建${table.classComment}
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建${table.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
|
||||
#end
|
||||
@@ -53,8 +53,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新${table.classComment}
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新${table.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
|
||||
#end
|
||||
@@ -63,9 +65,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${table.classComment}
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除${table.classComment}")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
||||
#end
|
||||
@@ -74,9 +77,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得${table.classComment}
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得${table.classComment}")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
@@ -86,8 +90,11 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 )
|
||||
|
||||
/**
|
||||
* 获得${table.classComment}分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得${table.classComment}分页")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
@@ -98,8 +105,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
|
||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||
#else
|
||||
/**
|
||||
* 获得${table.classComment}列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得${table.classComment}列表")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
@@ -109,8 +118,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
}
|
||||
|
||||
#end
|
||||
/**
|
||||
* 导出${table.classComment} Excel
|
||||
*/
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出${table.classComment} Excel")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")
|
||||
#end
|
||||
@@ -149,9 +160,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
|
||||
## 情况一:MASTER_ERP 时,需要分查询页子表
|
||||
#if ( $table.templateType == 11 )
|
||||
/**
|
||||
* 获得${subTable.classComment}分页
|
||||
*/
|
||||
@GetMapping("/${subSimpleClassName_strikeCase}/page")
|
||||
@Operation(summary = "获得${subTable.classComment}分页")
|
||||
@Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
@@ -163,9 +175,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
## 情况二:非 MASTER_ERP 时,需要列表查询子表
|
||||
#else
|
||||
#if ( $subTable.subJoinMany )
|
||||
/**
|
||||
* 获得${subTable.classComment}列表
|
||||
*/
|
||||
@GetMapping("/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}")
|
||||
@Operation(summary = "获得${subTable.classComment}列表")
|
||||
@Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
@@ -174,9 +187,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* 获得${subTable.classComment}
|
||||
*/
|
||||
@GetMapping("/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}")
|
||||
@Operation(summary = "获得${subTable.classComment}")
|
||||
@Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
@@ -188,8 +202,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
#end
|
||||
## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作
|
||||
#if ( $table.templateType == 11 )
|
||||
/**
|
||||
* 创建${subTable.classComment}
|
||||
*/
|
||||
@PostMapping("/${subSimpleClassName_strikeCase}/create")
|
||||
@Operation(summary = "创建${subTable.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
|
||||
#end
|
||||
@@ -197,8 +213,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(${classNameVar}Service.create${subSimpleClassName}(${subClassNameVar}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新${subTable.classComment}
|
||||
*/
|
||||
@PutMapping("/${subSimpleClassName_strikeCase}/update")
|
||||
@Operation(summary = "更新${subTable.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
|
||||
#end
|
||||
@@ -207,9 +225,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${subTable.classComment}
|
||||
*/
|
||||
@DeleteMapping("/${subSimpleClassName_strikeCase}/delete")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Operation(summary = "删除${subTable.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
||||
#end
|
||||
@@ -218,9 +237,10 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得${subTable.classComment}
|
||||
*/
|
||||
@GetMapping("/${subSimpleClassName_strikeCase}/get")
|
||||
@Operation(summary = "获得${subTable.classComment}")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
|
||||
@@ -2,7 +2,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import ${PageParamClassName};
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.javaType} == "BigDecimal")
|
||||
@@ -22,18 +22,24 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#end
|
||||
## 字段模板
|
||||
#macro(columnTpl $prefix $prefixStr)
|
||||
@Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
/**
|
||||
* ${prefixStr}${column.columnComment}"#if ("$!column.example" != "
|
||||
*/, example = "${column.example}"#end)
|
||||
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
||||
#end
|
||||
|
||||
@Schema(description = "${sceneEnum.name} - ${table.classComment}列表 Request VO")
|
||||
/**
|
||||
* ${sceneEnum.name} - ${table.classComment}列表 Request VO
|
||||
*/
|
||||
@Data
|
||||
public class ${sceneEnum.prefixClass}${table.className}ListReqVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation})##查询操作
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||
@Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
/**
|
||||
* ${column.columnComment}"#if ("$!column.example" != "
|
||||
*/, example = "${column.example}"#end)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private ${column.javaType}[] ${column.javaField};
|
||||
#else##情况二,非 Between 的时间
|
||||
|
||||
@@ -2,7 +2,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import ${PageParamClassName};
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.javaType} == "BigDecimal")
|
||||
@@ -22,11 +22,15 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#end
|
||||
## 字段模板
|
||||
#macro(columnTpl $prefix $prefixStr)
|
||||
@Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
/**
|
||||
* ${prefixStr}${column.columnComment}"#if ("$!column.example" != "
|
||||
*/, example = "${column.example}"#end)
|
||||
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
||||
#end
|
||||
|
||||
@Schema(description = "${sceneEnum.name} - ${table.classComment}分页 Request VO")
|
||||
/**
|
||||
* ${sceneEnum.name} - ${table.classComment}分页 Request VO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@@ -35,7 +39,9 @@ public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PagePar
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation})##查询操作
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||
@Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
/**
|
||||
* ${column.columnComment}"#if ("$!column.example" != "
|
||||
*/, example = "${column.example}"#end)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private ${column.javaType}[] ${column.javaField};
|
||||
#else##情况二,非 Between 的时间
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
## 处理 BigDecimal 字段的引入
|
||||
@@ -28,7 +28,9 @@ import ${DictConvertClassName};
|
||||
#end
|
||||
#end
|
||||
|
||||
@Schema(description = "${sceneEnum.name} - ${table.classComment} Response VO")
|
||||
/**
|
||||
* ${sceneEnum.name} - ${table.classComment} Response VO
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ${sceneEnum.prefixClass}${table.className}RespVO {
|
||||
@@ -37,7 +39,9 @@ public class ${sceneEnum.prefixClass}${table.className}RespVO {
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperationResult})
|
||||
## 1. 处理 Swagger 注解
|
||||
@Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
/**
|
||||
* ${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != "
|
||||
*/, example = "${column.example}"#end)
|
||||
## 2. 处理 Excel 导出
|
||||
#if ("$!column.dictType" != "")##处理枚举值
|
||||
@ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import ${jakartaPackage}.validation.constraints.*;
|
||||
@@ -24,7 +24,9 @@ import java.time.LocalDateTime;
|
||||
import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO;
|
||||
#end
|
||||
|
||||
@Schema(description = "${sceneEnum.name} - ${table.classComment}新增/修改 Request VO")
|
||||
/**
|
||||
* ${sceneEnum.name} - ${table.classComment}新增/修改 Request VO
|
||||
*/
|
||||
@Data
|
||||
public class ${sceneEnum.prefixClass}${table.className}SaveReqVO {
|
||||
|
||||
@@ -32,7 +34,9 @@ public class ${sceneEnum.prefixClass}${table.className}SaveReqVO {
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.createOperation} || ${column.updateOperation})
|
||||
## 1. 处理 Swagger 注解
|
||||
@Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
/**
|
||||
* ${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != "
|
||||
*/, example = "${column.example}"#end)
|
||||
## 2. 处理 Validator 参数校验
|
||||
#if (!${column.nullable} && !${column.primaryKey})
|
||||
#if (${column.javaType} == 'String')
|
||||
@@ -51,11 +55,15 @@ public class ${sceneEnum.prefixClass}${table.className}SaveReqVO {
|
||||
#foreach ($subTable in $subTables)
|
||||
#set ($index = $foreach.count - 1)
|
||||
#if ( $subTable.subJoinMany)
|
||||
@Schema(description = "${subTable.classComment}列表")
|
||||
/**
|
||||
* ${subTable.classComment}列表
|
||||
*/
|
||||
private List<${subTable.className}DO> ${subClassNameVars.get($index)}s;
|
||||
|
||||
#else
|
||||
@Schema(description = "${subTable.classComment}")
|
||||
/**
|
||||
* ${subTable.classComment}
|
||||
*/
|
||||
private ${subTable.className}DO ${subClassNameVars.get($index)};
|
||||
|
||||
#end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.common.util.collection.CollectionUtils.convertSet;
|
||||
import static com.tashow.cloud.web.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
@@ -19,21 +23,20 @@ import com.tashow.cloud.system.convert.auth.AuthConvert;
|
||||
import com.tashow.cloud.system.dal.dataobject.permission.MenuDO;
|
||||
import com.tashow.cloud.system.dal.dataobject.permission.RoleDO;
|
||||
import com.tashow.cloud.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.tashow.cloud.systemapi.enums.logger.LoginLogTypeEnum;
|
||||
import com.tashow.cloud.system.service.auth.AdminAuthService;
|
||||
import com.tashow.cloud.system.service.permission.MenuService;
|
||||
import com.tashow.cloud.system.service.permission.PermissionService;
|
||||
import com.tashow.cloud.system.service.permission.RoleService;
|
||||
import com.tashow.cloud.system.service.social.SocialClientService;
|
||||
import com.tashow.cloud.system.service.user.AdminUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.systemapi.enums.logger.LoginLogTypeEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -43,142 +46,125 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.common.util.collection.CollectionUtils.convertSet;
|
||||
import static com.tashow.cloud.web.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 认证")
|
||||
/** 管理后台 - 认证 */
|
||||
@RestController
|
||||
@RequestMapping("/system/auth")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AuthController {
|
||||
|
||||
@Resource
|
||||
private AdminAuthService authService;
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
@Resource
|
||||
private SocialClientService socialClientService;
|
||||
@Resource private AdminAuthService authService;
|
||||
@Resource private AdminUserService userService;
|
||||
@Resource private RoleService roleService;
|
||||
@Resource private MenuService menuService;
|
||||
@Resource private PermissionService permissionService;
|
||||
@Resource private SocialClientService socialClientService;
|
||||
|
||||
@Resource
|
||||
private SecurityProperties securityProperties;
|
||||
@Resource private SecurityProperties securityProperties;
|
||||
|
||||
@PostMapping("/login")
|
||||
@PermitAll
|
||||
@Operation(summary = "使用账号密码登录")
|
||||
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
||||
return success(authService.login(reqVO));
|
||||
/** 使用账号密码登录 */
|
||||
@PostMapping("/login")
|
||||
@PermitAll
|
||||
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
||||
return success(authService.login(reqVO));
|
||||
}
|
||||
|
||||
/** 登出系统 */
|
||||
@PostMapping("/logout")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> logout(HttpServletRequest request) {
|
||||
String token =
|
||||
SecurityFrameworkUtils.obtainAuthorization(
|
||||
request, securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType());
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/** 刷新令牌 */
|
||||
@PostMapping("/refresh-token")
|
||||
@PermitAll
|
||||
public CommonResult<AuthLoginRespVO> refreshToken(
|
||||
@RequestParam("refreshToken") String refreshToken) {
|
||||
return success(authService.refreshToken(refreshToken));
|
||||
}
|
||||
|
||||
/** 获取登录用户的权限信息 */
|
||||
@GetMapping("/get-permission-info")
|
||||
public CommonResult<AuthPermissionInfoRespVO> getPermissionInfo() {
|
||||
// 1.1 获得用户信息
|
||||
AdminUserDO user = userService.getUser(getLoginUserId());
|
||||
if (user == null) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
@PermitAll
|
||||
@Operation(summary = "登出系统")
|
||||
public CommonResult<Boolean> logout(HttpServletRequest request) {
|
||||
String token = SecurityFrameworkUtils.obtainAuthorization(request,
|
||||
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType());
|
||||
}
|
||||
return success(true);
|
||||
// 1.2 获得角色列表
|
||||
Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(getLoginUserId());
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return success(
|
||||
AuthConvert.INSTANCE.convert(user, Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
List<RoleDO> roles = roleService.getRoleList(roleIds);
|
||||
roles.removeIf(
|
||||
role -> !CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())); // 移除禁用的角色
|
||||
|
||||
@PostMapping("/refresh-token")
|
||||
@PermitAll
|
||||
@Operation(summary = "刷新令牌")
|
||||
@Parameter(name = "refreshToken", description = "刷新令牌", required = true)
|
||||
public CommonResult<AuthLoginRespVO> refreshToken(@RequestParam("refreshToken") String refreshToken) {
|
||||
return success(authService.refreshToken(refreshToken));
|
||||
}
|
||||
// 1.3 获得菜单列表
|
||||
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
|
||||
List<MenuDO> menuList = menuService.getMenuList(menuIds);
|
||||
menuList = menuService.filterDisableMenus(menuList);
|
||||
|
||||
@GetMapping("/get-permission-info")
|
||||
@Operation(summary = "获取登录用户的权限信息")
|
||||
public CommonResult<AuthPermissionInfoRespVO> getPermissionInfo() {
|
||||
// 1.1 获得用户信息
|
||||
AdminUserDO user = userService.getUser(getLoginUserId());
|
||||
if (user == null) {
|
||||
return success(null);
|
||||
}
|
||||
// 2. 拼接结果返回
|
||||
return success(AuthConvert.INSTANCE.convert(user, roles, menuList));
|
||||
}
|
||||
|
||||
// 1.2 获得角色列表
|
||||
Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(getLoginUserId());
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return success(AuthConvert.INSTANCE.convert(user, Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
List<RoleDO> roles = roleService.getRoleList(roleIds);
|
||||
roles.removeIf(role -> !CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())); // 移除禁用的角色
|
||||
/** 注册用户 */
|
||||
@PostMapping("/register")
|
||||
@PermitAll
|
||||
public CommonResult<AuthLoginRespVO> register(
|
||||
@RequestBody @Valid AuthRegisterReqVO registerReqVO) {
|
||||
return success(authService.register(registerReqVO));
|
||||
}
|
||||
|
||||
// 1.3 获得菜单列表
|
||||
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
|
||||
List<MenuDO> menuList = menuService.getMenuList(menuIds);
|
||||
menuList = menuService.filterDisableMenus(menuList);
|
||||
// ========== 短信登录相关 ==========
|
||||
/** 使用短信验证码登录 */
|
||||
@PostMapping("/sms-login")
|
||||
@PermitAll
|
||||
public CommonResult<AuthLoginRespVO> smsLogin(@RequestBody @Valid AuthSmsLoginReqVO reqVO) {
|
||||
return success(authService.smsLogin(reqVO));
|
||||
}
|
||||
|
||||
// 2. 拼接结果返回
|
||||
return success(AuthConvert.INSTANCE.convert(user, roles, menuList));
|
||||
}
|
||||
/** 发送手机验证码 */
|
||||
@PostMapping("/send-sms-code")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> sendLoginSmsCode(@RequestBody @Valid AuthSmsSendReqVO reqVO) {
|
||||
authService.sendSmsCode(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
@PermitAll
|
||||
@Operation(summary = "注册用户")
|
||||
public CommonResult<AuthLoginRespVO> register(@RequestBody @Valid AuthRegisterReqVO registerReqVO) {
|
||||
return success(authService.register(registerReqVO));
|
||||
}
|
||||
/** 重置密码 */
|
||||
@PostMapping("/reset-password")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> resetPassword(@RequestBody @Valid AuthResetPasswordReqVO reqVO) {
|
||||
authService.resetPassword(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// ========== 短信登录相关 ==========
|
||||
|
||||
@PostMapping("/sms-login")
|
||||
@PermitAll
|
||||
@Operation(summary = "使用短信验证码登录")
|
||||
public CommonResult<AuthLoginRespVO> smsLogin(@RequestBody @Valid AuthSmsLoginReqVO reqVO) {
|
||||
return success(authService.smsLogin(reqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/send-sms-code")
|
||||
@PermitAll
|
||||
@Operation(summary = "发送手机验证码")
|
||||
public CommonResult<Boolean> sendLoginSmsCode(@RequestBody @Valid AuthSmsSendReqVO reqVO) {
|
||||
authService.sendSmsCode(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/reset-password")
|
||||
@PermitAll
|
||||
@Operation(summary = "重置密码")
|
||||
public CommonResult<Boolean> resetPassword(@RequestBody @Valid AuthResetPasswordReqVO reqVO) {
|
||||
authService.resetPassword(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// ========== 社交登录相关 ==========
|
||||
|
||||
@GetMapping("/social-auth-redirect")
|
||||
@PermitAll
|
||||
@Operation(summary = "社交授权的跳转")
|
||||
@Parameters({
|
||||
@Parameter(name = "type", description = "社交类型", required = true),
|
||||
@Parameter(name = "redirectUri", description = "回调路径")
|
||||
})
|
||||
public CommonResult<String> socialLogin(@RequestParam("type") Integer type,
|
||||
@RequestParam("redirectUri") String redirectUri) {
|
||||
return success(socialClientService.getAuthorizeUrl(
|
||||
type, UserTypeEnum.ADMIN.getValue(), redirectUri));
|
||||
}
|
||||
|
||||
@PostMapping("/social-login")
|
||||
@PermitAll
|
||||
@Operation(summary = "社交快捷登录,使用 code 授权码", description = "适合未登录的用户,但是社交账号已绑定用户")
|
||||
public CommonResult<AuthLoginRespVO> socialQuickLogin(@RequestBody @Valid AuthSocialLoginReqVO reqVO) {
|
||||
return success(authService.socialLogin(reqVO));
|
||||
}
|
||||
// ========== 社交登录相关 ==========
|
||||
/** 社交授权的跳转 */
|
||||
@GetMapping("/social-auth-redirect")
|
||||
@PermitAll
|
||||
public CommonResult<String> socialLogin(
|
||||
@RequestParam("type") Integer type, @RequestParam("redirectUri") String redirectUri) {
|
||||
return success(
|
||||
socialClientService.getAuthorizeUrl(type, UserTypeEnum.ADMIN.getValue(), redirectUri));
|
||||
}
|
||||
|
||||
/** 社交快捷登录,使用 code 授权码", description = "适合未登录的用户,但是社交账号已绑定用户 */
|
||||
@PostMapping("/social-login")
|
||||
@PermitAll
|
||||
public CommonResult<AuthLoginRespVO> socialQuickLogin(
|
||||
@RequestBody @Valid AuthSocialLoginReqVO reqVO) {
|
||||
return success(authService.socialLogin(reqVO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import com.tashow.cloud.systemapi.enums.social.SocialTypeEnum;
|
||||
import com.tashow.cloud.systemapi.enums.social.SocialTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
@@ -14,44 +12,43 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
@Schema(description = "管理后台 - 账号密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数")
|
||||
/** 管理后台 - 账号密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthLoginReqVO extends CaptchaVerificationReqVO {
|
||||
|
||||
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
|
||||
@NotEmpty(message = "登录账号不能为空")
|
||||
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
/** 账号" */
|
||||
@NotEmpty(message = "登录账号不能为空")
|
||||
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
/** 密码" */
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
// ========== 绑定社交登录时,需要传递如下参数 ==========
|
||||
// ========== 绑定社交登录时,需要传递如下参数 ==========
|
||||
|
||||
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
private Integer socialType;
|
||||
/** 社交平台的类型,参见 SocialTypeEnum 枚举值" */
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
private Integer socialType;
|
||||
|
||||
@Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private String socialCode;
|
||||
/** 授权码" */
|
||||
private String socialCode;
|
||||
|
||||
@Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62")
|
||||
private String socialState;
|
||||
/** state" */
|
||||
private String socialState;
|
||||
|
||||
@AssertTrue(message = "授权码不能为空")
|
||||
public boolean isSocialCodeValid() {
|
||||
return socialType == null || StrUtil.isNotEmpty(socialCode);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "授权 state 不能为空")
|
||||
public boolean isSocialState() {
|
||||
return socialType == null || StrUtil.isNotEmpty(socialState);
|
||||
}
|
||||
@AssertTrue(message = "授权码不能为空")
|
||||
public boolean isSocialCodeValid() {
|
||||
return socialType == null || StrUtil.isNotEmpty(socialCode);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "授权 state 不能为空")
|
||||
public boolean isSocialState() {
|
||||
return socialType == null || StrUtil.isNotEmpty(socialState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -8,23 +7,22 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 登录 Response VO")
|
||||
/** 管理后台 - 登录 Response VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthLoginRespVO {
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long userId;
|
||||
/** 用户编号" */
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "访问令牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "happy")
|
||||
private String accessToken;
|
||||
/** 访问令牌" */
|
||||
private String accessToken;
|
||||
|
||||
@Schema(description = "刷新令牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "nice")
|
||||
private String refreshToken;
|
||||
|
||||
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime expiresTime;
|
||||
/** 刷新令牌" */
|
||||
private String refreshToken;
|
||||
|
||||
/** 过期时间 */
|
||||
private LocalDateTime expiresTime;
|
||||
}
|
||||
|
||||
@@ -1,53 +1,48 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 登录用户的菜单信息 Response VO")
|
||||
/** 管理后台 - 登录用户的菜单信息 Response VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthMenuRespVO {
|
||||
|
||||
@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private Long id;
|
||||
/** 菜单名称", example = "芋道 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long parentId;
|
||||
/** 父菜单 ID" */
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
/** 菜单名称", example = "芋道 */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路由地址,仅菜单类型为菜单或者目录时,才需要传", example = "post")
|
||||
private String path;
|
||||
/** 路由地址,仅菜单类型为菜单或者目录时,才需要传 */
|
||||
private String path;
|
||||
|
||||
@Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index")
|
||||
private String component;
|
||||
/** 组件路径,仅菜单类型为菜单时,才需要传 */
|
||||
private String component;
|
||||
|
||||
@Schema(description = "组件名", example = "SystemUser")
|
||||
private String componentName;
|
||||
/** 组件名 */
|
||||
private String componentName;
|
||||
|
||||
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
|
||||
private String icon;
|
||||
/** 菜单图标,仅菜单类型为菜单或者目录时,才需要传 */
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean visible;
|
||||
/** 是否可见" */
|
||||
private Boolean visible;
|
||||
|
||||
@Schema(description = "是否缓存", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean keepAlive;
|
||||
/** 是否缓存" */
|
||||
private Boolean keepAlive;
|
||||
|
||||
@Schema(description = "是否总是显示", example = "false")
|
||||
private Boolean alwaysShow;
|
||||
|
||||
/**
|
||||
* 子路由
|
||||
*/
|
||||
private List<AuthMenuRespVO> children;
|
||||
/** 是否总是显示 */
|
||||
private Boolean alwaysShow;
|
||||
|
||||
/** 子路由 */
|
||||
private List<AuthMenuRespVO> children;
|
||||
}
|
||||
|
||||
@@ -1,96 +1,97 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 登录用户的权限信息 Response VO,额外包括用户信息和角色列表")
|
||||
/** 管理后台 - 登录用户的权限信息 Response VO,额外包括用户信息和角色列表 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthPermissionInfoRespVO {
|
||||
|
||||
@Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private UserVO user;
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private UserVO user;
|
||||
|
||||
@Schema(description = "角色标识数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Set<String> roles;
|
||||
/**
|
||||
* 角色标识数组
|
||||
*/
|
||||
private Set<String> roles;
|
||||
|
||||
@Schema(description = "操作权限数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Set<String> permissions;
|
||||
/**
|
||||
* 操作权限数组
|
||||
*/
|
||||
private Set<String> permissions;
|
||||
|
||||
@Schema(description = "菜单树", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<MenuVO> menus;
|
||||
/**
|
||||
* 菜单树
|
||||
*/
|
||||
private List<MenuVO> menus;
|
||||
|
||||
@Schema(description = "用户信息 VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class UserVO {
|
||||
/** 用户信息 VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class UserVO {
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
/** 用户编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
private String nickname;
|
||||
/** 用户昵称", example = "芋道源码 */
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.jpg")
|
||||
private String avatar;
|
||||
/** 用户头像" */
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
private Long deptId;
|
||||
/** 部门编号" */
|
||||
private Long deptId;
|
||||
}
|
||||
|
||||
}
|
||||
/** 管理后台 - 登录用户的菜单信息 Response VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class MenuVO {
|
||||
|
||||
@Schema(description = "管理后台 - 登录用户的菜单信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class MenuVO {
|
||||
/** 菜单名称", example = "芋道 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private Long id;
|
||||
/** 父菜单 ID" */
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long parentId;
|
||||
/** 菜单名称", example = "芋道 */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
/** 路由地址,仅菜单类型为菜单或者目录时,才需要传 */
|
||||
private String path;
|
||||
|
||||
@Schema(description = "路由地址,仅菜单类型为菜单或者目录时,才需要传", example = "post")
|
||||
private String path;
|
||||
/** 组件路径,仅菜单类型为菜单时,才需要传 */
|
||||
private String component;
|
||||
|
||||
@Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index")
|
||||
private String component;
|
||||
/** 组件名 */
|
||||
private String componentName;
|
||||
|
||||
@Schema(description = "组件名", example = "SystemUser")
|
||||
private String componentName;
|
||||
/** 菜单图标,仅菜单类型为菜单或者目录时,才需要传 */
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
|
||||
private String icon;
|
||||
/** 是否可见" */
|
||||
private Boolean visible;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean visible;
|
||||
/** 是否缓存" */
|
||||
private Boolean keepAlive;
|
||||
|
||||
@Schema(description = "是否缓存", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean keepAlive;
|
||||
|
||||
@Schema(description = "是否总是显示", example = "false")
|
||||
private Boolean alwaysShow;
|
||||
|
||||
/**
|
||||
* 子路由
|
||||
*/
|
||||
private List<MenuVO> children;
|
||||
|
||||
}
|
||||
/** 是否总是显示 */
|
||||
private Boolean alwaysShow;
|
||||
|
||||
/** 子路由 */
|
||||
private List<MenuVO> children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
@@ -9,23 +7,23 @@ import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
@Schema(description = "管理后台 - Register Request VO")
|
||||
/** 管理后台 - Register Request VO */
|
||||
@Data
|
||||
public class AuthRegisterReqVO extends CaptchaVerificationReqVO {
|
||||
|
||||
@Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
|
||||
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
|
||||
private String username;
|
||||
/** 用户账号" */
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
|
||||
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotBlank(message = "用户昵称不能为空")
|
||||
@Size(max = 30, message = "用户昵称长度不能超过 30 个字符")
|
||||
private String nickname;
|
||||
/** 用户昵称", example = "芋艿 */
|
||||
@NotBlank(message = "用户昵称不能为空")
|
||||
@Size(max = 30, message = "用户昵称长度不能超过 30 个字符")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
/** 密码" */
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import com.tashow.cloud.common.validation.Mobile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -9,24 +9,24 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
@Schema(description = "管理后台 - 短信重置账号密码 Request VO")
|
||||
/** 管理后台 - 短信重置账号密码 Request VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthResetPasswordReqVO {
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1234")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
/** 密码" */
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13312341234")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
/** 手机号" */
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "手机短信验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@NotEmpty(message = "手机手机短信验证码不能为空")
|
||||
private String code;
|
||||
/** 手机短信验证码" */
|
||||
@NotEmpty(message = "手机手机短信验证码不能为空")
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import com.tashow.cloud.common.validation.Mobile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 短信验证码的登录 Request VO")
|
||||
/** 管理后台 - 短信验证码的登录 Request VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthSmsLoginReqVO {
|
||||
|
||||
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "短信验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotEmpty(message = "验证码不能为空")
|
||||
private String code;
|
||||
/** 手机号" */
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
/** 短信验证码" */
|
||||
@NotEmpty(message = "验证码不能为空")
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import com.tashow.cloud.common.validation.Mobile;
|
||||
import com.tashow.cloud.systemapi.enums.sms.SmsSceneEnum;
|
||||
import com.tashow.cloud.systemapi.enums.sms.SmsSceneEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -12,21 +10,20 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 发送手机验证码 Request VO")
|
||||
/** 管理后台 - 发送手机验证码 Request VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthSmsSendReqVO extends CaptchaVerificationReqVO {
|
||||
|
||||
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "短信场景", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "发送场景不能为空")
|
||||
@InEnum(SmsSceneEnum.class)
|
||||
private Integer scene;
|
||||
/** 手机号" */
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
/** 短信场景" */
|
||||
@NotNull(message = "发送场景不能为空")
|
||||
@InEnum(SmsSceneEnum.class)
|
||||
private Integer scene;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import com.tashow.cloud.systemapi.enums.social.SocialTypeEnum;
|
||||
import com.tashow.cloud.systemapi.enums.social.SocialTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -11,24 +9,23 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 社交绑定登录 Request VO,使用 code 授权码 + 账号密码")
|
||||
/** 管理后台 - 社交绑定登录 Request VO,使用 code 授权码 + 账号密码 */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthSocialLoginReqVO {
|
||||
|
||||
@Schema(description = "社交平台的类型,参见 UserSocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
/** 社交平台的类型,参见 UserSocialTypeEnum 枚举值" */
|
||||
@InEnum(SocialTypeEnum.class)
|
||||
@NotNull(message = "社交平台的类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotEmpty(message = "授权码不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62")
|
||||
@NotEmpty(message = "state 不能为空")
|
||||
private String state;
|
||||
/** 授权码" */
|
||||
@NotEmpty(message = "授权码不能为空")
|
||||
private String code;
|
||||
|
||||
/** state" */
|
||||
@NotEmpty(message = "state 不能为空")
|
||||
private String state;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
package com.tashow.cloud.system.controller.admin.auth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 验证码 Request VO")
|
||||
/** 管理后台 - 验证码 Request VO */
|
||||
@Data
|
||||
public class CaptchaVerificationReqVO {
|
||||
|
||||
// ========== 图片验证码相关 ==========
|
||||
@Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==")
|
||||
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class)
|
||||
private String captchaVerification;
|
||||
// ========== 图片验证码相关 ==========
|
||||
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class)
|
||||
private String captchaVerification;
|
||||
|
||||
/**
|
||||
* 开启验证码的 Group
|
||||
*/
|
||||
public interface CodeEnableGroup {
|
||||
}
|
||||
/** 开启验证码的 Group */
|
||||
public interface CodeEnableGroup {}
|
||||
}
|
||||
|
||||
@@ -5,49 +5,44 @@ import com.tashow.cloud.common.util.servlet.ServletUtils;
|
||||
import com.xingyuv.captcha.model.common.ResponseModel;
|
||||
import com.xingyuv.captcha.model.vo.CaptchaVO;
|
||||
import com.xingyuv.captcha.service.CaptchaService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
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 jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@Tag(name = "管理后台 - 验证码")
|
||||
/** 管理后台 - 验证码 */
|
||||
@RestController("adminCaptchaController")
|
||||
@RequestMapping("/system/captcha")
|
||||
public class CaptchaController {
|
||||
|
||||
@Resource
|
||||
private CaptchaService captchaService;
|
||||
@Resource private CaptchaService captchaService;
|
||||
|
||||
@PostMapping({"/get"})
|
||||
@Operation(summary = "获得验证码")
|
||||
@PermitAll
|
||||
public ResponseModel get(@RequestBody CaptchaVO data, HttpServletRequest request) {
|
||||
assert request.getRemoteHost() != null;
|
||||
data.setBrowserInfo(getRemoteId(request));
|
||||
return captchaService.get(data);
|
||||
/** 获得验证码 */
|
||||
@PostMapping({"/get"})
|
||||
@PermitAll
|
||||
public ResponseModel get(@RequestBody CaptchaVO data, HttpServletRequest request) {
|
||||
assert request.getRemoteHost() != null;
|
||||
data.setBrowserInfo(getRemoteId(request));
|
||||
return captchaService.get(data);
|
||||
}
|
||||
|
||||
/** 校验验证码 */
|
||||
@PostMapping("/check")
|
||||
@PermitAll
|
||||
public ResponseModel check(@RequestBody CaptchaVO data, HttpServletRequest request) {
|
||||
data.setBrowserInfo(getRemoteId(request));
|
||||
return captchaService.check(data);
|
||||
}
|
||||
|
||||
public static String getRemoteId(HttpServletRequest request) {
|
||||
String ip = ServletUtils.getClientIP(request);
|
||||
String ua = request.getHeader("user-agent");
|
||||
if (StrUtil.isNotBlank(ip)) {
|
||||
return ip + ua;
|
||||
}
|
||||
|
||||
@PostMapping("/check")
|
||||
@Operation(summary = "校验验证码")
|
||||
@PermitAll
|
||||
public ResponseModel check(@RequestBody CaptchaVO data, HttpServletRequest request) {
|
||||
data.setBrowserInfo(getRemoteId(request));
|
||||
return captchaService.check(data);
|
||||
}
|
||||
|
||||
public static String getRemoteId(HttpServletRequest request) {
|
||||
String ip = ServletUtils.getClientIP(request);
|
||||
String ua = request.getHeader("user-agent");
|
||||
if (StrUtil.isNotBlank(ip)) {
|
||||
return ip + ua;
|
||||
}
|
||||
return request.getRemoteAddr() + ua;
|
||||
}
|
||||
|
||||
return request.getRemoteAddr() + ua;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.util.object.BeanUtils;
|
||||
@@ -9,76 +11,66 @@ import com.tashow.cloud.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
|
||||
import com.tashow.cloud.system.dal.dataobject.dept.DeptDO;
|
||||
import com.tashow.cloud.system.service.dept.DeptService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 部门")
|
||||
/** 管理后台 - 部门 */
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
@Validated
|
||||
public class DeptController {
|
||||
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
@Resource private DeptService deptService;
|
||||
|
||||
@PostMapping("create")
|
||||
@Operation(summary = "创建部门")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:create')")
|
||||
public CommonResult<Long> createDept(@Valid @RequestBody DeptSaveReqVO createReqVO) {
|
||||
Long deptId = deptService.createDept(createReqVO);
|
||||
return success(deptId);
|
||||
}
|
||||
/** 创建部门 */
|
||||
@PostMapping("create")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:create')")
|
||||
public CommonResult<Long> createDept(@Valid @RequestBody DeptSaveReqVO createReqVO) {
|
||||
Long deptId = deptService.createDept(createReqVO);
|
||||
return success(deptId);
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@Operation(summary = "更新部门")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:update')")
|
||||
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
|
||||
deptService.updateDept(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
/** 更新部门 */
|
||||
@PutMapping("update")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:update')")
|
||||
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
|
||||
deptService.updateDept(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("delete")
|
||||
@Operation(summary = "删除部门")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:delete')")
|
||||
public CommonResult<Boolean> deleteDept(@RequestParam("id") Long id) {
|
||||
deptService.deleteDept(id);
|
||||
return success(true);
|
||||
}
|
||||
/** 删除部门 */
|
||||
@DeleteMapping("delete")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:delete')")
|
||||
public CommonResult<Boolean> deleteDept(@RequestParam("id") Long id) {
|
||||
deptService.deleteDept(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取部门列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<List<DeptRespVO>> getDeptList(DeptListReqVO reqVO) {
|
||||
List<DeptDO> list = deptService.getDeptList(reqVO);
|
||||
return success(BeanUtils.toBean(list, DeptRespVO.class));
|
||||
}
|
||||
/** 获取部门列表 */
|
||||
@GetMapping("/list")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<List<DeptRespVO>> getDeptList(DeptListReqVO reqVO) {
|
||||
List<DeptDO> list = deptService.getDeptList(reqVO);
|
||||
return success(BeanUtils.toBean(list, DeptRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
||||
List<DeptDO> list = deptService.getDeptList(
|
||||
new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得部门信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<DeptRespVO> getDept(@RequestParam("id") Long id) {
|
||||
DeptDO dept = deptService.getDept(id);
|
||||
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
||||
}
|
||||
/** 获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项 */
|
||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
||||
List<DeptDO> list =
|
||||
deptService.getDeptList(new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
/** 获得部门信息 */
|
||||
@GetMapping("/get")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<DeptRespVO> getDept(@RequestParam("id") Long id) {
|
||||
DeptDO dept = deptService.getDept(id);
|
||||
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept;
|
||||
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
@@ -13,97 +15,87 @@ import com.tashow.cloud.system.controller.admin.dept.vo.post.PostSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dept.vo.post.PostSimpleRespVO;
|
||||
import com.tashow.cloud.system.dal.dataobject.dept.PostDO;
|
||||
import com.tashow.cloud.system.service.dept.PostService;
|
||||
import com.tashow.cloud.system.controller.admin.dept.vo.post.PostPageReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dept.vo.post.PostSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dept.vo.post.PostSimpleRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 岗位")
|
||||
/** 管理后台 - 岗位 */
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
@Validated
|
||||
public class PostController {
|
||||
|
||||
@Resource
|
||||
private PostService postService;
|
||||
@Resource private PostService postService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建岗位")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:create')")
|
||||
public CommonResult<Long> createPost(@Valid @RequestBody PostSaveReqVO createReqVO) {
|
||||
Long postId = postService.createPost(createReqVO);
|
||||
return success(postId);
|
||||
}
|
||||
/** 创建岗位 */
|
||||
@PostMapping("/create")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:create')")
|
||||
public CommonResult<Long> createPost(@Valid @RequestBody PostSaveReqVO createReqVO) {
|
||||
Long postId = postService.createPost(createReqVO);
|
||||
return success(postId);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改岗位")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:update')")
|
||||
public CommonResult<Boolean> updatePost(@Valid @RequestBody PostSaveReqVO updateReqVO) {
|
||||
postService.updatePost(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
/** 修改岗位 */
|
||||
@PutMapping("/update")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:update')")
|
||||
public CommonResult<Boolean> updatePost(@Valid @RequestBody PostSaveReqVO updateReqVO) {
|
||||
postService.updatePost(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除岗位")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:delete')")
|
||||
public CommonResult<Boolean> deletePost(@RequestParam("id") Long id) {
|
||||
postService.deletePost(id);
|
||||
return success(true);
|
||||
}
|
||||
/** 删除岗位 */
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:delete')")
|
||||
public CommonResult<Boolean> deletePost(@RequestParam("id") Long id) {
|
||||
postService.deletePost(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get")
|
||||
@Operation(summary = "获得岗位信息")
|
||||
@Parameter(name = "id", description = "岗位编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:query')")
|
||||
public CommonResult<PostRespVO> getPost(@RequestParam("id") Long id) {
|
||||
PostDO post = postService.getPost(id);
|
||||
return success(BeanUtils.toBean(post, PostRespVO.class));
|
||||
}
|
||||
/** 获得岗位信息 */
|
||||
@GetMapping(value = "/get")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:query')")
|
||||
public CommonResult<PostRespVO> getPost(@RequestParam("id") Long id) {
|
||||
PostDO post = postService.getPost(id);
|
||||
return success(BeanUtils.toBean(post, PostRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获取岗位全列表", description = "只包含被开启的岗位,主要用于前端的下拉选项")
|
||||
public CommonResult<List<PostSimpleRespVO>> getSimplePostList() {
|
||||
// 获得岗位列表,只要开启状态的
|
||||
List<PostDO> list = postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
|
||||
// 排序后,返回给前端
|
||||
list.sort(Comparator.comparing(PostDO::getSort));
|
||||
return success(BeanUtils.toBean(list, PostSimpleRespVO.class));
|
||||
}
|
||||
/** 获取岗位全列表", description = "只包含被开启的岗位,主要用于前端的下拉选项 */
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
public CommonResult<List<PostSimpleRespVO>> getSimplePostList() {
|
||||
// 获得岗位列表,只要开启状态的
|
||||
List<PostDO> list =
|
||||
postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
|
||||
// 排序后,返回给前端
|
||||
list.sort(Comparator.comparing(PostDO::getSort));
|
||||
return success(BeanUtils.toBean(list, PostSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得岗位分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:query')")
|
||||
public CommonResult<PageResult<PostRespVO>> getPostPage(@Validated PostPageReqVO pageReqVO) {
|
||||
PageResult<PostDO> pageResult = postService.getPostPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PostRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "岗位管理")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void export(HttpServletResponse response, @Validated PostPageReqVO reqVO) throws IOException {
|
||||
reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PostDO> list = postService.getPostPage(reqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(response, "岗位数据.xls", "岗位列表", PostRespVO.class,
|
||||
BeanUtils.toBean(list, PostRespVO.class));
|
||||
}
|
||||
/** 获得岗位分页列表 */
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:query')")
|
||||
public CommonResult<PageResult<PostRespVO>> getPostPage(@Validated PostPageReqVO pageReqVO) {
|
||||
PageResult<PostDO> pageResult = postService.getPostPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PostRespVO.class));
|
||||
}
|
||||
|
||||
/** 岗位管理 */
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('system:post:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void export(HttpServletResponse response, @Validated PostPageReqVO reqVO)
|
||||
throws IOException {
|
||||
reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PostDO> list = postService.getPostPage(reqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(
|
||||
response, "岗位数据.xls", "岗位列表", PostRespVO.class, BeanUtils.toBean(list, PostRespVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 部门列表 Request VO")
|
||||
/** 管理后台 - 部门列表 Request VO */
|
||||
@Data
|
||||
public class DeptListReqVO {
|
||||
|
||||
@Schema(description = "部门名称,模糊匹配", example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
private Integer status;
|
||||
/** 部门名称,模糊匹配 */
|
||||
private String name;
|
||||
|
||||
/** 展示状态,参见 CommonStatusEnum 枚举类 */
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -1,39 +1,37 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 部门信息 Response VO")
|
||||
/** 管理后台 - 部门信息 Response VO */
|
||||
@Data
|
||||
public class DeptRespVO {
|
||||
|
||||
@Schema(description = "部门编号", example = "1024")
|
||||
private Long id;
|
||||
/** 部门编号 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
/** 部门名称", example = "芋道 */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父部门 ID", example = "1024")
|
||||
private Long parentId;
|
||||
/** 父部门 ID */
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer sort;
|
||||
/** 显示顺序" */
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "2048")
|
||||
private Long leaderUserId;
|
||||
/** 负责人的用户编号 */
|
||||
private Long leaderUserId;
|
||||
|
||||
@Schema(description = "联系电话", example = "15601691000")
|
||||
private String phone;
|
||||
/** 联系电话 */
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "邮箱", example = "yudao@iocoder.cn")
|
||||
private String email;
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
/** 状态,见 CommonStatusEnum 枚举" */
|
||||
private Integer status;
|
||||
|
||||
/** 创建时间", example = "时间戳格式 */
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -2,47 +2,45 @@ package com.tashow.cloud.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 部门创建/修改 Request VO")
|
||||
/** 管理后台 - 部门创建/修改 Request VO */
|
||||
@Data
|
||||
public class DeptSaveReqVO {
|
||||
|
||||
@Schema(description = "部门编号", example = "1024")
|
||||
private Long id;
|
||||
/** 部门编号 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(max = 30, message = "部门名称长度不能超过 30 个字符")
|
||||
private String name;
|
||||
/** 部门名称", example = "芋道 */
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(max = 30, message = "部门名称长度不能超过 30 个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父部门 ID", example = "1024")
|
||||
private Long parentId;
|
||||
/** 父部门 ID */
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer sort;
|
||||
/** 显示顺序" */
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "2048")
|
||||
private Long leaderUserId;
|
||||
/** 负责人的用户编号 */
|
||||
private Long leaderUserId;
|
||||
|
||||
@Schema(description = "联系电话", example = "15601691000")
|
||||
@Size(max = 11, message = "联系电话长度不能超过11个字符")
|
||||
private String phone;
|
||||
/** 联系电话 */
|
||||
@Size(max = 11, message = "联系电话长度不能超过11个字符")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "邮箱", example = "yudao@iocoder.cn")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过 50 个字符")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
/** 邮箱 */
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过 50 个字符")
|
||||
private String email;
|
||||
|
||||
/** 状态,见 CommonStatusEnum 枚举" */
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 部门精简信息 Response VO")
|
||||
/** 管理后台 - 部门精简信息 Response VO */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeptSimpleRespVO {
|
||||
|
||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
/** 部门编号" */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父部门 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long parentId;
|
||||
/** 部门名称", example = "芋道 */
|
||||
private String name;
|
||||
|
||||
/** 父部门 ID" */
|
||||
private Long parentId;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept.vo.post;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位分页 Request VO")
|
||||
/**
|
||||
* 管理后台 - 岗位分页 Request VO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PostPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "岗位编码,模糊匹配", example = "yudao")
|
||||
/**
|
||||
* 岗位编码,模糊匹配
|
||||
*/
|
||||
private String code;
|
||||
|
||||
@Schema(description = "岗位名称,模糊匹配", example = "芋道")
|
||||
/**
|
||||
* 岗位名称,模糊匹配
|
||||
*/
|
||||
private String name;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
/**
|
||||
* 展示状态,参见 CommonStatusEnum 枚举类
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +1,59 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept.vo.post;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import com.tashow.cloud.systemapi.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.systemapi.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位信息 Response VO")
|
||||
/**
|
||||
* 管理后台 - 岗位信息 Response VO
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PostRespVO {
|
||||
|
||||
@Schema(description = "岗位序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
/**
|
||||
* 岗位序号"
|
||||
*/
|
||||
@ExcelProperty("岗位序号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小土豆")
|
||||
/**
|
||||
* 岗位名称", example = "小土豆
|
||||
*/
|
||||
@ExcelProperty("岗位名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "岗位编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||
/**
|
||||
* 岗位编码"
|
||||
*/
|
||||
@ExcelProperty("岗位编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
/**
|
||||
* 显示顺序"
|
||||
*/
|
||||
@ExcelProperty("岗位排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
/**
|
||||
* 状态,参见 CommonStatusEnum 枚举类"
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "快乐的备注")
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,38 +2,50 @@ package com.tashow.cloud.system.controller.admin.dept.vo.post;
|
||||
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位创建/修改 Request VO")
|
||||
/**
|
||||
* 管理后台 - 岗位创建/修改 Request VO
|
||||
*/
|
||||
@Data
|
||||
public class PostSaveReqVO {
|
||||
|
||||
@Schema(description = "岗位编号", example = "1024")
|
||||
/**
|
||||
* 岗位编号
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小土豆")
|
||||
/**
|
||||
* 岗位名称", example = "小土豆
|
||||
*/
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
@Size(max = 50, message = "岗位名称长度不能超过 50 个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "岗位编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||
/**
|
||||
* 岗位编码"
|
||||
*/
|
||||
@NotBlank(message = "岗位编码不能为空")
|
||||
@Size(max = 64, message = "岗位编码长度不能超过64个字符")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
/**
|
||||
* 显示顺序"
|
||||
*/
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
/**
|
||||
* 状态"
|
||||
*/
|
||||
@InEnum(CommonStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "快乐的备注")
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package com.tashow.cloud.system.controller.admin.dept.vo.post;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位信息的精简 Response VO")
|
||||
/**
|
||||
* 管理后台 - 岗位信息的精简 Response VO
|
||||
*/
|
||||
@Data
|
||||
public class PostSimpleRespVO {
|
||||
|
||||
@Schema(description = "岗位序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
/**
|
||||
* 岗位序号"
|
||||
*/
|
||||
@ExcelProperty("岗位序号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小土豆")
|
||||
/**
|
||||
* 岗位名称", example = "小土豆
|
||||
*/
|
||||
@ExcelProperty("岗位名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.tashow.cloud.system.controller.admin.dict;
|
||||
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
@@ -13,13 +12,7 @@ import com.tashow.cloud.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.tashow.cloud.system.dal.dataobject.dict.DictDataDO;
|
||||
import com.tashow.cloud.system.service.dict.DictDataService;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.data.DictDataPageReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.data.DictDataRespVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -30,10 +23,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 字典数据")
|
||||
/**
|
||||
* 管理后台 - 字典数据
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict-data")
|
||||
@Validated
|
||||
@@ -42,67 +37,85 @@ public class DictDataController {
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "新增字典数据")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
||||
public CommonResult<Long> createDictData(@Valid @RequestBody DictDataSaveReqVO createReqVO) {
|
||||
Long dictDataId = dictDataService.createDictData(createReqVO);
|
||||
return success(dictDataId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改字典数据")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
||||
public CommonResult<Boolean> updateDictData(@Valid @RequestBody DictDataSaveReqVO updateReqVO) {
|
||||
dictDataService.updateDictData(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除字典数据")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:delete')")
|
||||
public CommonResult<Boolean> deleteDictData(Long id) {
|
||||
dictDataService.deleteDictData(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地
|
||||
*/
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地")
|
||||
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<DictDataSimpleRespVO>> getSimpleDictDataList() {
|
||||
List<DictDataDO> list = dictDataService.getDictDataList(
|
||||
CommonStatusEnum.ENABLE.getStatus(), null);
|
||||
List<DictDataDO> list =
|
||||
dictDataService.getDictDataList(CommonStatusEnum.ENABLE.getStatus(), null);
|
||||
return success(BeanUtils.toBean(list, DictDataSimpleRespVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* /获得字典类型的分页列表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "/获得字典类型的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<PageResult<DictDataRespVO>> getDictTypePage(@Valid DictDataPageReqVO pageReqVO) {
|
||||
public CommonResult<PageResult<DictDataRespVO>> getDictTypePage(
|
||||
@Valid DictDataPageReqVO pageReqVO) {
|
||||
PageResult<DictDataDO> pageResult = dictDataService.getDictDataPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DictDataRespVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* /查询字典数据详细
|
||||
*/
|
||||
@GetMapping(value = "/get")
|
||||
@Operation(summary = "/查询字典数据详细")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<DictDataRespVO> getDictData(@RequestParam("id") Long id) {
|
||||
DictDataDO dictData = dictDataService.getDictData(id);
|
||||
return success(BeanUtils.toBean(dictData, DictDataRespVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出字典数据
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "导出字典数据")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void export(HttpServletResponse response, @Valid DictDataPageReqVO exportReqVO) throws IOException {
|
||||
public void export(HttpServletResponse response, @Valid DictDataPageReqVO exportReqVO)
|
||||
throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DictDataDO> list = dictDataService.getDictDataPage(exportReqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(response, "字典数据.xls", "数据", DictDataRespVO.class,
|
||||
ExcelUtils.write(
|
||||
response,
|
||||
"字典数据.xls",
|
||||
"数据",
|
||||
DictDataRespVO.class,
|
||||
BeanUtils.toBean(list, DictDataRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.tashow.cloud.system.controller.admin.dict;
|
||||
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.pojo.PageResult;
|
||||
@@ -12,13 +11,7 @@ import com.tashow.cloud.system.controller.admin.dict.vo.type.DictTypeSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
|
||||
import com.tashow.cloud.system.dal.dataobject.dict.DictTypeDO;
|
||||
import com.tashow.cloud.system.service.dict.DictTypeService;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.type.DictTypePageReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.type.DictTypeRespVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.type.DictTypeSaveReqVO;
|
||||
import com.tashow.cloud.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -29,10 +22,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.tashow.cloud.common.pojo.CommonResult.success;
|
||||
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 字典类型")
|
||||
/**
|
||||
* 管理后台 - 字典类型
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict-type")
|
||||
@Validated
|
||||
@@ -41,41 +36,50 @@ public class DictTypeController {
|
||||
@Resource
|
||||
private DictTypeService dictTypeService;
|
||||
|
||||
/**
|
||||
* 创建字典类型
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建字典类型")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
||||
public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeSaveReqVO createReqVO) {
|
||||
Long dictTypeId = dictTypeService.createDictType(createReqVO);
|
||||
return success(dictTypeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改字典类型")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
||||
public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeSaveReqVO updateReqVO) {
|
||||
dictTypeService.updateDictType(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除字典类型")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:delete')")
|
||||
public CommonResult<Boolean> deleteDictType(Long id) {
|
||||
dictTypeService.deleteDictType(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得字典类型的分页列表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得字典类型的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
||||
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(
|
||||
@Valid DictTypePageReqVO pageReqVO) {
|
||||
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
||||
}
|
||||
|
||||
@Operation(summary = "/查询字典类型详细")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
/**
|
||||
* /查询字典类型详细
|
||||
*/
|
||||
@GetMapping(value = "/get")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) {
|
||||
@@ -83,24 +87,32 @@ public class DictTypeController {
|
||||
return success(BeanUtils.toBean(dictType, DictTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获得全部字典类型列表", description = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项")
|
||||
/**
|
||||
* 获得全部字典类型列表", description = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项
|
||||
*/
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
public CommonResult<List<DictTypeSimpleRespVO>> getSimpleDictTypeList() {
|
||||
List<DictTypeDO> list = dictTypeService.getDictTypeList();
|
||||
return success(BeanUtils.toBean(list, DictTypeSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@Operation(summary = "导出数据类型")
|
||||
/**
|
||||
* 导出数据类型
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException {
|
||||
public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO)
|
||||
throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DictTypeDO> list = dictTypeService.getDictTypePage(exportReqVO).getList();
|
||||
// 导出
|
||||
ExcelUtils.write(response, "字典类型.xls", "数据", DictTypeRespVO.class,
|
||||
ExcelUtils.write(
|
||||
response,
|
||||
"字典类型.xls",
|
||||
"数据",
|
||||
DictTypeRespVO.class,
|
||||
BeanUtils.toBean(list, DictTypeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,26 +3,32 @@ package com.tashow.cloud.system.controller.admin.dict.vo.data;
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Schema(description = "管理后台 - 字典类型分页列表 Request VO")
|
||||
/**
|
||||
* 管理后台 - 字典类型分页列表 Request VO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DictDataPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "字典标签", example = "芋道")
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典类型,模糊匹配", example = "sys_common_sex")
|
||||
/**
|
||||
* 字典类型,模糊匹配
|
||||
*/
|
||||
@Size(max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
/**
|
||||
* 展示状态,参见 CommonStatusEnum 枚举类
|
||||
*/
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,56 +1,75 @@
|
||||
package com.tashow.cloud.system.controller.admin.dict.vo.data;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.excel.excel.core.annotations.DictFormat;
|
||||
import com.tashow.cloud.excel.excel.core.convert.DictConvert;
|
||||
import com.tashow.cloud.systemapi.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.tashow.cloud.systemapi.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 字典数据信息 Response VO")
|
||||
/**
|
||||
* 管理后台 - 字典数据信息 Response VO
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DictDataRespVO {
|
||||
|
||||
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
/**
|
||||
* 字典数据编号"
|
||||
*/
|
||||
@ExcelProperty("字典编码")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
/**
|
||||
* 显示顺序"
|
||||
*/
|
||||
@ExcelProperty("字典排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
/**
|
||||
* 字典标签", example = "芋道
|
||||
*/
|
||||
@ExcelProperty("字典标签")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder")
|
||||
/**
|
||||
* 字典值"
|
||||
*/
|
||||
@ExcelProperty("字典键值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex")
|
||||
/**
|
||||
* 字典类型"
|
||||
*/
|
||||
@ExcelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
/**
|
||||
* 状态,见 CommonStatusEnum 枚举"
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
/**
|
||||
* 颜色类型,default、primary、success、info、warning、danger
|
||||
*/
|
||||
private String colorType;
|
||||
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
/**
|
||||
* css 样式
|
||||
*/
|
||||
private String cssClass;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个角色")
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
/**
|
||||
* 创建时间", example = "时间戳格式
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,50 +2,48 @@ package com.tashow.cloud.system.controller.admin.dict.vo.data;
|
||||
|
||||
import com.tashow.cloud.common.enums.CommonStatusEnum;
|
||||
import com.tashow.cloud.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 字典数据创建/修改 Request VO")
|
||||
/** 管理后台 - 字典数据创建/修改 Request VO */
|
||||
@Data
|
||||
public class DictDataSaveReqVO {
|
||||
|
||||
@Schema(description = "字典数据编号", example = "1024")
|
||||
private Long id;
|
||||
/** 字典数据编号 */
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer sort;
|
||||
/** 显示顺序" */
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||
private String label;
|
||||
/** 字典标签", example = "芋道 */
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder")
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(max = 100, message = "字典键值长度不能超过100个字符")
|
||||
private String value;
|
||||
/** 字典值" */
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(max = 100, message = "字典键值长度不能超过100个字符")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex")
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(max = 100, message = "字典类型长度不能超过100个字符")
|
||||
private String dictType;
|
||||
/** 字典类型" */
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(max = 100, message = "字典类型长度不能超过100个字符")
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
/** 状态,见 CommonStatusEnum 枚举" */
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
private String colorType;
|
||||
/** 颜色类型,default、primary、success、info、warning、danger */
|
||||
private String colorType;
|
||||
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
private String cssClass;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个角色")
|
||||
private String remark;
|
||||
/** css 样式 */
|
||||
private String cssClass;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,35 @@
|
||||
package com.tashow.cloud.system.controller.admin.dict.vo.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 数据字典精简 Response VO")
|
||||
/**
|
||||
* 管理后台 - 数据字典精简 Response VO
|
||||
*/
|
||||
@Data
|
||||
public class DictDataSimpleRespVO {
|
||||
|
||||
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "gender")
|
||||
/**
|
||||
* 字典类型"
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "字典键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
/**
|
||||
* 字典键值"
|
||||
*/
|
||||
private String value;
|
||||
|
||||
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "男")
|
||||
/**
|
||||
* 字典标签", example = "男
|
||||
*/
|
||||
private String label;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
/**
|
||||
* 颜色类型,default、primary、success、info、warning、danger
|
||||
*/
|
||||
private String colorType;
|
||||
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
/**
|
||||
* css 样式
|
||||
*/
|
||||
private String cssClass;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
package com.tashow.cloud.system.controller.admin.dict.vo.type;
|
||||
|
||||
import com.tashow.cloud.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 字典类型分页列表 Request VO")
|
||||
/**
|
||||
* 管理后台 - 字典类型分页列表 Request VO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DictTypePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "字典类型名称,模糊匹配", example = "芋道")
|
||||
/**
|
||||
* 字典类型名称,模糊匹配
|
||||
*/
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字典类型,模糊匹配", example = "sys_common_sex")
|
||||
/**
|
||||
* 字典类型,模糊匹配
|
||||
*/
|
||||
@Size(max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
/**
|
||||
* 展示状态,参见 CommonStatusEnum 枚举类
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "创建时间")
|
||||
/** 创建时间 */
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user