diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt index 5d14167..f682fd3 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.controller.tool import io.swagger.v3.oas.annotations.Operation import jakarta.validation.Valid +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.entity.common.ResponseCode @@ -11,38 +12,100 @@ import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam import top.fatweb.oxygen.api.service.tool.IToolBaseService import top.fatweb.oxygen.api.vo.tool.ToolBaseVo +/** + * Tool base management controller + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IToolBaseService + */ @BaseController(path = ["/system/tool/base"], name = "工具基板管理", description = "工具基板管理相关接口") class BaseController( private val toolBaseService: IToolBaseService ) { + /** + * Get tool base by ID + * + * @param id Tool base ID + * @return Response object includes tool base information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see ToolBaseVo + */ @Operation(summary = "获取单个基板") @GetMapping("/{id}") + @PreAuthorize("hasAnyAuthority('system:tool:query:base')") fun getOne(@PathVariable id: Long): ResponseResult = ResponseResult.databaseSuccess(data = toolBaseService.getOne(id)) + /** + * Get tool base list + * + * @return Response object includes tool base list + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see ToolBaseVo + */ @Operation(summary = "获取基板") @GetMapping + @PreAuthorize("hasAnyAuthority('system:tool:query:base', 'system:tool:add:template', 'system:tool:modify:template')") fun get(): ResponseResult> = ResponseResult.databaseSuccess(data = toolBaseService.get()) + /** + * Add tool base + * + * @param toolBaseAddParam Add tool base parameters + * @return Response object includes tool base information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBaseAddParam + * @see ResponseResult + * @see ToolBaseVo + */ @Operation(summary = "新增基板") @PostMapping + @PreAuthorize("hasAnyAuthority('system:tool:add:base')") fun add(@RequestBody @Valid toolBaseAddParam: ToolBaseAddParam): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_INSERT_SUCCESS, data = toolBaseService.add(toolBaseAddParam) ) + /** + * Update tool base + * + * @param toolBaseUpdateParam Update tool base parameters + * @return Response object includes tool base information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBaseUpdateParam + * @see ResponseResult + * @see ToolBaseVo + */ @Operation(summary = "更新基板") @PutMapping + @PreAuthorize("hasAnyAuthority('system:tool:modify:base')") fun update(@RequestBody @Valid toolBaseUpdateParam: ToolBaseUpdateParam): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_UPDATE_SUCCESS, data = toolBaseService.update(toolBaseUpdateParam) ) + /** + * Delete tool base by ID + * + * @param id Tool base ID + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + */ @Operation(summary = "删除基板") @DeleteMapping("/{id}") + @PreAuthorize("hasAnyAuthority('system:tool:delete:base')") fun delete(@PathVariable id: Long): ResponseResult = if (toolBaseService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt index 504e3d1..2a79f65 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.controller.tool import io.swagger.v3.oas.annotations.Operation import jakarta.validation.Valid +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.entity.common.ResponseCode @@ -11,7 +12,6 @@ import top.fatweb.oxygen.api.param.tool.ToolCategoryUpdateParam import top.fatweb.oxygen.api.service.tool.IToolCategoryService import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo - /** * Tool category management controller * @@ -22,34 +22,89 @@ import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo class CategoryController( private val toolCategoryService: IToolCategoryService ) { + /** + * Get tool category by ID + * + * @param id Tool category ID + * @return Response object includes tool template information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see ToolCategoryVo + */ @Operation(summary = "获取单个类别") @GetMapping("/{id}") + @PreAuthorize("hasAnyAuthority('system:tool:query:category')") fun getOne(@PathVariable id: Long): ResponseResult = ResponseResult.databaseSuccess(data = toolCategoryService.getOne(id)) + /** + * Get tool category list + * + * @return Response object includes tool template list + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see ToolCategoryVo + */ @Operation(summary = "获取类别") @GetMapping + @PreAuthorize("hasAnyAuthority('system:tool:query:category')") fun get(): ResponseResult> = ResponseResult.databaseSuccess(data = toolCategoryService.get()) + /** + * Add tool category + * + * @param toolCategoryAddParam Add tool category parameters + * @return Response object includes tool category information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryAddParam + * @see ResponseResult + * @see ToolCategoryVo + */ @Operation(summary = "新增类别") @PostMapping + @PreAuthorize("hasAnyAuthority('system:tool:add:category')") fun add(@RequestBody @Valid toolCategoryAddParam: ToolCategoryAddParam): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_INSERT_SUCCESS, data = toolCategoryService.add(toolCategoryAddParam) ) + /** + * Update tool category + * + * @param toolCategoryUpdateParam Update tool category parameters + * @return Response object includes tool category information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryUpdateParam + * @see ResponseResult + * @see ToolCategoryVo + */ @Operation(summary = "更新类别") @PutMapping + @PreAuthorize("hasAnyAuthority('system:tool:modify:category')") fun update(@RequestBody @Valid toolCategoryUpdateParam: ToolCategoryUpdateParam): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_UPDATE_SUCCESS, data = toolCategoryService.update(toolCategoryUpdateParam) ) + /** + * Delete tool category + * + * @param id Tool category ID + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + */ @Operation(summary = "删除类别") @DeleteMapping("/{id}") + @PreAuthorize("hasAnyAuthority('system:tool:delete:category')") fun delete(@PathVariable id: Long): ResponseResult = if (toolCategoryService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt index 2067c58..ab7fe7e 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.controller.tool import io.swagger.v3.oas.annotations.Operation import jakarta.validation.Valid +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.entity.common.ResponseCode @@ -11,38 +12,100 @@ import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam import top.fatweb.oxygen.api.service.tool.IToolTemplateService import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo +/** + * Tool template management controller + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IToolTemplateService + */ @BaseController(path = ["/system/tool/template"], name = "工具模板管理", description = "工具模板管理相关接口") class TemplateController( private val toolTemplateService: IToolTemplateService ) { + /** + * Get tool template by ID + * + * @param id Tool template ID + * @return Response object includes tool template information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see ToolTemplateVo + */ @Operation(summary = "获取单个模板") @GetMapping("/{id}") + @PreAuthorize("hasAnyAuthority('system:tool:query:template')") fun getOne(@PathVariable id: Long): ResponseResult = ResponseResult.databaseSuccess(data = toolTemplateService.getOne(id)) + /** + * Get tool template list + * + * @return Response object includes tool template list + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see ToolTemplateVo + */ @Operation(summary = "获取模板") @GetMapping + @PreAuthorize("hasAnyAuthority('system:tool:query:template')") fun get(): ResponseResult> = ResponseResult.databaseSuccess(data = toolTemplateService.get()) + /** + * Add tool template + * + * @param toolTemplateAddParam Add tool template parameters + * @return Response object includes tool template information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplateAddParam + * @see ResponseResult + * @see ToolTemplateVo + */ @Operation(summary = "添加模板") @PostMapping + @PreAuthorize("hasAnyAuthority('system:tool:add:template')") fun add(@RequestBody @Valid toolTemplateAddParam: ToolTemplateAddParam): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_INSERT_SUCCESS, data = toolTemplateService.add(toolTemplateAddParam) ) + /** + * Update tool template + * + * @param toolTemplateUpdateParam Update tool template parameters + * @return Response object includes tool template information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplateUpdateParam + * @see ResponseResult + * @see ToolTemplateVo + */ @Operation(summary = "更新模板") @PutMapping + @PreAuthorize("hasAnyAuthority('system:tool:modify:template')") fun update(@RequestBody @Valid toolTemplateUpdateParam: ToolTemplateUpdateParam): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_UPDATE_SUCCESS, data = toolTemplateService.update(toolTemplateUpdateParam) ) + /** + * Delete tool template + * + * @param id Tool template ID + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + */ @Operation(summary = "删除模板") @DeleteMapping("/{id}") + @PreAuthorize("hasAnyAuthority('system:tool:delete:template')") fun delete(@PathVariable id: Long): ResponseResult = if (toolTemplateService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolBaseConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolBaseConverter.kt index b91e267..03cada4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolBaseConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolBaseConverter.kt @@ -4,7 +4,23 @@ import top.fatweb.oxygen.api.entity.tool.ToolBase import top.fatweb.oxygen.api.vo.tool.ToolBaseVo import top.fatweb.oxygen.api.vo.tool.ToolDataVo +/** + * Tool base converter + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ object ToolBaseConverter { + /** + * Convert ToolBase object into ToolBaseVo object + * + * @param toolBase ToolBase object + * @return ToolBaseVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBase + * @see ToolBaseVo + */ fun toolBaseToToolBaseVo(toolBase: ToolBase) = ToolBaseVo( id = toolBase.id, name = toolBase.name, @@ -16,6 +32,16 @@ object ToolBaseConverter { enable = toolBase.enable == 1 ) + /** + * Convert ToolBase object into ToolBaseVo object by get list + * + * @param toolBase ToolBase object + * @return ToolBaseVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBase + * @see ToolBaseVo + */ fun toolBaseToToolBaseVoByGetList(toolBase: ToolBase) = ToolBaseVo( id = toolBase.id, name = toolBase.name, diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolCategoryConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolCategoryConverter.kt index aa8a41c..f01feb8 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolCategoryConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolCategoryConverter.kt @@ -5,7 +5,23 @@ import top.fatweb.oxygen.api.param.tool.ToolCategoryAddParam import top.fatweb.oxygen.api.param.tool.ToolCategoryUpdateParam import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo +/** + * Tool category converter + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ object ToolCategoryConverter { + /** + * Convert ToolCategory object into ToolCategoryVo object + * + * @param toolCategory ToolCategory object + * @return ToolCategoryVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategory + * @see ToolCategoryVo + */ fun toolCategoryToToolCategoryVo(toolCategory: ToolCategory) = ToolCategoryVo( id = toolCategory.id, name = toolCategory.name, @@ -14,11 +30,31 @@ object ToolCategoryConverter { updateTime = toolCategory.updateTime ) + /** + * Convert ToolCategoryAddParam object into ToolCategory object + * + * @param toolCategoryAddParam ToolCategoryAddParam object + * @return ToolCateGory object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryAddParam + * @see ToolCategory + */ fun toolCategoryAddParamToToolCategory(toolCategoryAddParam: ToolCategoryAddParam) = ToolCategory().apply { name = toolCategoryAddParam.name enable = if (toolCategoryAddParam.enable) 1 else 0 } + /** + * Convert ToolCategoryUpdateParam object into ToolCategory object + * + * @param toolCategoryUpdateParam ToolCategoryUpdateParam object + * @return ToolCategory object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryUpdateParam + * @see ToolCategory + */ fun toolCategoryUpdateParamToToolCategory(toolCategoryUpdateParam: ToolCategoryUpdateParam) = ToolCategory().apply { id = toolCategoryUpdateParam.id name = toolCategoryUpdateParam.name diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt index 92cc185..d490e11 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt @@ -4,7 +4,23 @@ import top.fatweb.oxygen.api.converter.permission.UserInfoConverter import top.fatweb.oxygen.api.entity.tool.Tool import top.fatweb.oxygen.api.vo.tool.ToolVo +/** + * Tool converter + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ object ToolConverter { + /** + * Convert Tool object into ToolVo object + * + * @param tool Tool object + * @return ToolVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Tool + * @see ToolVo + */ fun toolToToolVo(tool: Tool) = ToolVo( id = tool.id, name = tool.name, diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolDataConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolDataConverter.kt index bd978b0..117752d 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolDataConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolDataConverter.kt @@ -3,7 +3,23 @@ package top.fatweb.oxygen.api.converter.tool import top.fatweb.oxygen.api.entity.tool.ToolData import top.fatweb.oxygen.api.vo.tool.ToolDataVo +/** + * Tool data converter + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ object ToolDataConverter { + /** + * Convert ToolData object into ToolDataVo object + * + * @param toolData ToolData object + * @return ToolDataVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolData + * @see ToolDataVo + */ fun toolDataToToolDataVo(toolData: ToolData) = ToolDataVo( id = toolData.id, data = toolData.data, diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolTemplateConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolTemplateConverter.kt index 3244ed7..37c93fa 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolTemplateConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolTemplateConverter.kt @@ -3,7 +3,23 @@ package top.fatweb.oxygen.api.converter.tool import top.fatweb.oxygen.api.entity.tool.ToolTemplate import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo +/** + * Tool template converter + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ object ToolTemplateConverter { + /** + * Convert ToolTemplate object into ToolTemplateVo object + * + * @param toolTemplate ToolTemplate object + * @return ToolTemplateVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplate + * @see ToolTemplateVo + */ fun toolTemplateToToolTemplateVo(toolTemplate: ToolTemplate) = ToolTemplateVo( id = toolTemplate.id, name = toolTemplate.name, diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt index b0962b9..773aa51 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt @@ -1,14 +1,31 @@ package top.fatweb.oxygen.api.param.tool +import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +/** + * Add tool base parameters + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ data class ToolBaseAddParam( + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") val name: String?, - val source: String = "", - - val dist: String = "", - + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true") val enable: Boolean = true ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt index cbd1918..83f4cc3 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt @@ -1,16 +1,58 @@ package top.fatweb.oxygen.api.param.tool +import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +/** + * Update tool base parameters + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ data class ToolBaseUpdateParam( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "ID", required = true) @field: NotNull(message = "ID can not be null") val id: Long?, + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称") val name: String?, + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "源码") val source: String?, + /** + * Dist + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "产物") val dist: String?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用", allowableValues = ["true", "false"]) val enable: Boolean? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt index 7e8bc39..657bb98 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt @@ -1,10 +1,31 @@ package top.fatweb.oxygen.api.param.tool +import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +/** + * Add tool category parameters + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ data class ToolCategoryAddParam( + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") val name: String?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true") val enable: Boolean = true ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt index 4fca7ec..84496b3 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt @@ -1,14 +1,40 @@ package top.fatweb.oxygen.api.param.tool -import jakarta.validation.constraints.NotBlank +import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +/** + * Update tool category parameters + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ data class ToolCategoryUpdateParam( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "ID", required = true) @field: NotNull(message = "ID can not be null") val id: Long?, - @field: NotBlank(message = "Name can not be blank") + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称") val name: String?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用", allowableValues = ["true", "false"]) val enable: Boolean? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt index f1d8a66..44fa42d 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt @@ -1,16 +1,42 @@ package top.fatweb.oxygen.api.param.tool +import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull +/** + * Add tool template parameters + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ data class ToolTemplateAddParam( + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") val name: String?, + /** + * Base ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "Base ID", required = true) @field: NotNull(message = "BaseId can not be null") val baseId: Long? = null, - val source: String = "", - + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true") val enable: Boolean = true ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt index a158999..a06672b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt @@ -1,16 +1,58 @@ package top.fatweb.oxygen.api.param.tool +import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +/** + * Update tool template parameters + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ data class ToolTemplateUpdateParam( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "ID", required = true) @field: NotNull(message = "ID can not be null") val id: Long?, + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称") val name: String?, + /** + * Base ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "Base ID") val baseId: Long?, + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "源码") val source: String?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用", allowableValues = ["true", "false"]) val enable: Boolean? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolBaseService.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolBaseService.kt index f4e9fbb..5bd0966 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolBaseService.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolBaseService.kt @@ -15,13 +15,58 @@ import top.fatweb.oxygen.api.vo.tool.ToolBaseVo * @see ToolBase */ interface IToolBaseService : IService { + /** + * Get tool base by ID + * + * @param id ID + * @return ToolBaseVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBaseVo + */ fun getOne(id: Long): ToolBaseVo + /** + * Get tool base in list + * + * @return List of ToolBaseVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBaseVo + */ fun get(): List + /** + * Add tool base + * + * @param toolBaseAddParam Add tool base parameters + * @return ToolBaseVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBaseAddParam + * @see ToolBaseVo + */ fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo + /** + * Update tool base + * + * @param toolBaseUpdateParam Update tool base parameters + * @return ToolBaseVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolBaseUpdateParam + * @see ToolBaseVo + */ fun update(toolBaseUpdateParam: ToolBaseUpdateParam): ToolBaseVo + /** + * Delete tool base + * + * @param id ID + * @return Result + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ fun delete(id: Long): Boolean } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolCategoryService.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolCategoryService.kt index 4f70553..7b2e3a5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolCategoryService.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolCategoryService.kt @@ -15,13 +15,58 @@ import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo * @see ToolCategory */ interface IToolCategoryService : IService { + /** + * Get tool category by ID + * + * @param id ID + * @return ToolCategoryVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryVo + */ fun getOne(id: Long): ToolCategoryVo + /** + * Get tool category in list + * + * @return List of ToolCategoryVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryVo + */ fun get(): List + /** + * Add tool category + * + * @param toolCategoryAddParam Add tool category parameters + * @return ToolCategoryVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryAddParam + * @see ToolCategoryVo + */ fun add(toolCategoryAddParam: ToolCategoryAddParam): ToolCategoryVo + /** + * Update tool category + * + * @param toolCategoryUpdateParam Update tool category parameters + * @return ToolCategoryVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolCategoryUpdateParam + * @see ToolCategoryVo + */ fun update(toolCategoryUpdateParam: ToolCategoryUpdateParam): ToolCategoryVo + /** + * Delete tool category + * + * @param id ID + * @return Result + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ fun delete(id: Long): Boolean } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolTemplateService.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolTemplateService.kt index 7d29168..1cb3d54 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolTemplateService.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolTemplateService.kt @@ -15,13 +15,58 @@ import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo * @see ToolTemplate */ interface IToolTemplateService : IService { + /** + * Get tool template by ID + * + * @param id ID + * @return ToolTemplateVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplateVo + */ fun getOne(id: Long): ToolTemplateVo + /** + * Get tool template in list + * + * @return List of ToolTemplateVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplateVo + */ fun get(): List + /** + * Add tool template + * + * @param toolTemplateAddParam Add tool template parameters + * @return ToolTemplateVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplateAddParam + * @see ToolTemplateVo + */ fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo + /** + * Update tool template + * + * @param toolTemplateUpdateParam Update tool template parameters + * @return ToolTemplateVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ToolTemplateUpdateParam + * @see ToolTemplateVo + */ fun update(toolTemplateUpdateParam: ToolTemplateUpdateParam): ToolTemplateVo + /** + * Delete tool template + * + * @param id ID + * @return Result + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ fun delete(id: Long): Boolean } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolBaseServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolBaseServiceImpl.kt index ce921c7..278dda4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolBaseServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolBaseServiceImpl.kt @@ -35,8 +35,8 @@ class ToolBaseServiceImpl( @Transactional override fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo { - val newSource = ToolData().apply { data = toolBaseAddParam.source } - val newDist = ToolData().apply { data = toolBaseAddParam.dist } + val newSource = ToolData().apply { data = "" } + val newDist = ToolData().apply { data = "" } toolDataService.save(newSource) toolDataService.save(newDist) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolTemplateServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolTemplateServiceImpl.kt index 116f9fd..47706bf 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolTemplateServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolTemplateServiceImpl.kt @@ -41,7 +41,7 @@ class ToolTemplateServiceImpl( override fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo { toolBaseService.getOne(toolTemplateAddParam.baseId!!) - val newSource = ToolData().apply { data = toolTemplateAddParam.source } + val newSource = ToolData().apply { data = "" } toolDataService.save(newSource) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt index 5c0681a..954dcb0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt @@ -2,23 +2,88 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import io.swagger.v3.oas.annotations.media.Schema import java.time.LocalDateTime +/** + * Tool base value object + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@Schema(description = "工具基板返回参数") data class ToolBaseVo( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ @JsonSerialize(using = ToStringSerializer::class) val id: Long?, + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称") val name: String?, + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "源码") val source: ToolDataVo?, + /** + * Dist + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "产物") val dist: ToolDataVo?, + /** + * Compiled + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "已编译") val compiled: Boolean?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用") val enable: Boolean?, + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "创建时间", example = "1900-01-01T00:00:00.000Z") val createTime: LocalDateTime?, + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z") val updateTime: LocalDateTime? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolCategoryVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolCategoryVo.kt index 2c1d3a1..3be4db8 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolCategoryVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolCategoryVo.kt @@ -2,17 +2,61 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import io.swagger.v3.oas.annotations.media.Schema import java.time.LocalDateTime +/** + * Tool base value object + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@Schema(description = "工具类别返回参数") data class ToolCategoryVo( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ @JsonSerialize(using = ToStringSerializer::class) val id: Long?, + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称") val name: String?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用") val enable: Boolean?, + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "创建时间", example = "1900-01-01T00:00:00.000Z") val createTime: LocalDateTime?, + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z") val updateTime: LocalDateTime? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolDataVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolDataVo.kt index dde38e5..309dbf4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolDataVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolDataVo.kt @@ -2,15 +2,52 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import io.swagger.v3.oas.annotations.media.Schema import java.time.LocalDateTime +/** + * Tool data value object + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@Schema(description = "工具数据返回参数") data class ToolDataVo( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ @JsonSerialize(using = ToStringSerializer::class) val id: Long?, + /** + * Data + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "数据") val data: String?, + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "创建时间", example = "1900-01-01T00:00:00.000Z") val createTime: LocalDateTime?, + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z") val updateTime: LocalDateTime? ) \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt index ae9c5f9..90b71d5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt @@ -2,21 +2,79 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import io.swagger.v3.oas.annotations.media.Schema import java.time.LocalDateTime +/** + * Tool template value object + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@Schema(description = "工具模板返回参数") data class ToolTemplateVo( + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ @JsonSerialize(using = ToStringSerializer::class) val id: Long?, + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "名称") val name: String?, + /** + * Base + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "基板") val base: ToolBaseVo?, + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "源码") val source: ToolDataVo?, + /** + * Enable + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "启用") val enable: Boolean?, + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "创建时间", example = "1900-01-01T00:00:00.000Z") val createTime: LocalDateTime?, + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z") val updateTime: LocalDateTime? ) \ No newline at end of file diff --git a/src/main/resources/db/migration/master/V1_0_0_240115__Add_table_'t_b_tool_main'.sql b/src/main/resources/db/migration/master/V1_0_0_240115__Add_table_'t_b_tool_main'.sql index 9e31827..45b96e6 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240115__Add_table_'t_b_tool_main'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240115__Add_table_'t_b_tool_main'.sql @@ -10,7 +10,7 @@ create table if not exists t_b_tool_main author_id bigint not null comment '作者 ID', ver varchar(20) not null comment '版本', privately int not null default 0 comment '私有', - keywords varchar(500) not null comment '关键字', + keywords varchar(500) not null comment '关键字', source_id bigint not null comment '源码 ID', dist_id bigint not null comment '产物 ID', publish int not null default 0 comment '发布', @@ -19,5 +19,5 @@ create table if not exists t_b_tool_main update_time datetime not null default (utc_timestamp()) comment '修改时间', deleted bigint not null default 0, version int not null default 0, - constraint t_b_tool_main_unique_tool_id unique (tool_id, author_id, deleted) + constraint t_b_tool_main_unique_tool_id unique (tool_id, author_id, ver, deleted) ) comment '工具-主表'; \ No newline at end of file