diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/common/ToolController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/common/ToolController.kt deleted file mode 100644 index e759d7e..0000000 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/common/ToolController.kt +++ /dev/null @@ -1,5 +0,0 @@ -package top.fatweb.oxygen.api.controller.common - - -class ToolController { -} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt index 8da32a9..451a7d5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt @@ -25,6 +25,7 @@ import top.fatweb.oxygen.api.vo.system.SensitiveWordVo * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 * @see ISettingsService + * @see ISensitiveWordService */ @BaseController(path = ["/system/settings"], name = "系统设置", description = "系统设置相关接口") class SettingsController( 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 new file mode 100644 index 0000000..d7d95b7 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt @@ -0,0 +1,50 @@ +package top.fatweb.oxygen.api.controller.tool + +import io.swagger.v3.oas.annotations.Operation +import jakarta.validation.Valid +import org.springframework.web.bind.annotation.* +import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.entity.common.ResponseCode +import top.fatweb.oxygen.api.entity.common.ResponseResult +import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam +import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam +import top.fatweb.oxygen.api.service.tool.IToolBaseService +import top.fatweb.oxygen.api.vo.tool.ToolBaseVo + +@BaseController(path = ["/system/tool/base"], name = "工具基板管理", description = "工具基板管理相关接口") +class BaseController( + private val toolBaseService: IToolBaseService +) { + @Operation(summary = "获取单个基板") + @GetMapping("/{id}") + fun getOne(@PathVariable id: Long): ResponseResult = + toolBaseService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) } + ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) } + + @Operation(summary = "获取基板") + @GetMapping + fun get(): ResponseResult> = + ResponseResult.databaseSuccess(data = toolBaseService.get()) + + @Operation(summary = "新增基板") + @PostMapping + fun add(@RequestBody @Valid toolBaseAddParam: ToolBaseAddParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_INSERT_SUCCESS, + data = toolBaseService.add(toolBaseAddParam) + ) + + @Operation(summary = "更新基板") + @PutMapping + fun update(@RequestBody @Valid toolBaseUpdateParam: ToolBaseUpdateParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_UPDATE_SUCCESS, + data = toolBaseService.update(toolBaseUpdateParam) + ) + + @Operation(summary = "删除基板") + @DeleteMapping("/{id}") + fun delete(@PathVariable id: Long): ResponseResult = + if (toolBaseService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) + else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED) +} \ No newline at end of file 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 new file mode 100644 index 0000000..09ef95f --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt @@ -0,0 +1,57 @@ +package top.fatweb.oxygen.api.controller.tool + +import io.swagger.v3.oas.annotations.Operation +import jakarta.validation.Valid +import org.springframework.web.bind.annotation.* +import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.entity.common.ResponseCode +import top.fatweb.oxygen.api.entity.common.ResponseResult +import top.fatweb.oxygen.api.param.tool.ToolCategoryAddParam +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 + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@BaseController(path = ["/system/tool/category"], name = "工具类别管理", description = "工具列别管理相关接口") +class CategoryController( + private val toolCategoryService: IToolCategoryService +) { + @Operation(summary = "获取单个类别") + @GetMapping("/{id}") + fun getOne(@PathVariable id: Long): ResponseResult = + toolCategoryService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) } + ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) } + + @Operation(summary = "获取类别") + @GetMapping + fun get(): ResponseResult> = + ResponseResult.databaseSuccess(data = toolCategoryService.get()) + + @Operation(summary = "新增类别") + @PostMapping + fun add(@RequestBody @Valid toolCategoryAddParam: ToolCategoryAddParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_INSERT_SUCCESS, + data = toolCategoryService.add(toolCategoryAddParam) + ) + + @Operation(summary = "更新类别") + @PutMapping + fun update(@RequestBody @Valid toolCategoryUpdateParam: ToolCategoryUpdateParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_UPDATE_SUCCESS, + data = toolCategoryService.update(toolCategoryUpdateParam) + ) + + @Operation(summary = "删除类别") + @DeleteMapping("/{id}") + fun delete(@PathVariable id: Long): ResponseResult = + if (toolCategoryService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) + else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED) +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt new file mode 100644 index 0000000..8027b4b --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt @@ -0,0 +1,56 @@ +package top.fatweb.oxygen.api.controller.tool + +import io.swagger.v3.oas.annotations.Operation +import jakarta.validation.Valid +import org.springframework.web.bind.annotation.* +import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.entity.common.ResponseCode +import top.fatweb.oxygen.api.entity.common.ResponseResult +import top.fatweb.oxygen.api.param.tool.ToolAddParam +import top.fatweb.oxygen.api.param.tool.ToolUpdateParam +import top.fatweb.oxygen.api.service.tool.IToolService +import top.fatweb.oxygen.api.vo.tool.ToolVo + +/** + * Tool management controller + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@BaseController(path = ["/tool"], name = "工具管理", description = "工具管理相关接口") +class EditController( + private val toolService: IToolService +) { + @Operation(summary = "获取单个工具") + @GetMapping("/{id}") + fun getOne(@PathVariable id: Long): ResponseResult = + toolService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) } + ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) } + + @Operation(summary = "获取工具") + @GetMapping + fun get(): ResponseResult> = + ResponseResult.databaseSuccess(data = toolService.get()) + + @Operation(summary = "新增工具") + @PostMapping + fun add(@RequestBody @Valid toolAddParam: ToolAddParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_INSERT_SUCCESS, + data = toolService.add(toolAddParam) + ) + + @Operation(summary = "更新工具") + @PutMapping + fun update(@RequestBody @Valid toolUpdateParam: ToolUpdateParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_UPDATE_SUCCESS, + data = toolService.update(toolUpdateParam) + ) + + @Operation(summary = "删除工具") + @DeleteMapping("/{id}") + fun delete(@PathVariable id: Long): ResponseResult = + if (toolService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) + else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED) +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt new file mode 100644 index 0000000..1db647c --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt @@ -0,0 +1,50 @@ +package top.fatweb.oxygen.api.controller.tool + +import io.swagger.v3.oas.annotations.Operation +import jakarta.validation.Valid +import org.springframework.web.bind.annotation.* +import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.entity.common.ResponseCode +import top.fatweb.oxygen.api.entity.common.ResponseResult +import top.fatweb.oxygen.api.param.tool.ToolAddParam +import top.fatweb.oxygen.api.param.tool.ToolUpdateParam +import top.fatweb.oxygen.api.service.tool.IToolService +import top.fatweb.oxygen.api.vo.tool.ToolVo + +@BaseController(path = ["/system/tool"], name = "工具管理", description = "工具管理相关接口") +class ManagementController( + private val toolService: IToolService +) { + @Operation(summary = "获取单个工具") + @GetMapping("/{id}") + fun getOne(@PathVariable id: Long): ResponseResult = + toolService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) } + ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) } + + @Operation(summary = "获取工具") + @GetMapping + fun get(): ResponseResult> = + ResponseResult.databaseSuccess(data = toolService.get()) + + @Operation(summary = "新增工具") + @PostMapping + fun add(@RequestBody @Valid toolAddParam: ToolAddParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_INSERT_SUCCESS, + data = toolService.add(toolAddParam) + ) + + @Operation(summary = "更新工具") + @PutMapping + fun update(@RequestBody @Valid toolUpdateParam: ToolUpdateParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_UPDATE_SUCCESS, + data = toolService.update(toolUpdateParam) + ) + + @Operation(summary = "删除工具") + @DeleteMapping("/{id}") + fun delete(@PathVariable id: Long): ResponseResult = + if (toolService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) + else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED) +} \ No newline at end of file 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 new file mode 100644 index 0000000..e9eb154 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt @@ -0,0 +1,50 @@ +package top.fatweb.oxygen.api.controller.tool + +import io.swagger.v3.oas.annotations.Operation +import jakarta.validation.Valid +import org.springframework.web.bind.annotation.* +import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.entity.common.ResponseCode +import top.fatweb.oxygen.api.entity.common.ResponseResult +import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam +import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam +import top.fatweb.oxygen.api.service.tool.IToolTemplateService +import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo + +@BaseController(path = ["/system/tool/template"], name = "工具模板管理", description = "工具模板管理相关接口") +class TemplateController( + private val toolTemplateService: IToolTemplateService +) { + @Operation(summary = "获取单个模板") + @GetMapping("/{id}") + fun getOne(@PathVariable id: Long): ResponseResult = + toolTemplateService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) } + ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) } + + @Operation(summary = "获取模板") + @GetMapping + fun get(): ResponseResult> = + ResponseResult.databaseSuccess(data = toolTemplateService.get()) + + @Operation(summary = "添加模板") + @PostMapping + fun add(@RequestBody @Valid toolTemplateAddParam: ToolTemplateAddParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_INSERT_SUCCESS, + data = toolTemplateService.add(toolTemplateAddParam) + ) + + @Operation(summary = "更新模板") + @PutMapping + fun update(@RequestBody @Valid toolTemplateUpdateParam: ToolTemplateUpdateParam): ResponseResult = + ResponseResult.databaseSuccess( + ResponseCode.DATABASE_UPDATE_SUCCESS, + data = toolTemplateService.update(toolTemplateUpdateParam) + ) + + @Operation(summary = "删除模板") + @DeleteMapping("/{id}") + fun delete(@PathVariable id: Long): ResponseResult = + if (toolTemplateService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) + else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED) +} \ No newline at end of file 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 new file mode 100644 index 0000000..d9b3333 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolBaseConverter.kt @@ -0,0 +1,16 @@ +package top.fatweb.oxygen.api.converter.tool + +import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam +import top.fatweb.oxygen.api.vo.tool.ToolBaseVo + +object ToolBaseConverter { + fun toolBaseToToolBaseVo(toolBase: ToolBase) = ToolBaseVo( + id = toolBase.id, + name = toolBase.name, + source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo), + dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo), + createTime = toolBase.createTime, + updateTime = toolBase.updateTime + ) +} \ No newline at end of file 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 new file mode 100644 index 0000000..aa8a41c --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolCategoryConverter.kt @@ -0,0 +1,27 @@ +package top.fatweb.oxygen.api.converter.tool + +import top.fatweb.oxygen.api.entity.tool.ToolCategory +import top.fatweb.oxygen.api.param.tool.ToolCategoryAddParam +import top.fatweb.oxygen.api.param.tool.ToolCategoryUpdateParam +import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo + +object ToolCategoryConverter { + fun toolCategoryToToolCategoryVo(toolCategory: ToolCategory) = ToolCategoryVo( + id = toolCategory.id, + name = toolCategory.name, + enable = toolCategory.enable == 1, + createTime = toolCategory.createTime, + updateTime = toolCategory.updateTime + ) + + fun toolCategoryAddParamToToolCategory(toolCategoryAddParam: ToolCategoryAddParam) = ToolCategory().apply { + name = toolCategoryAddParam.name + enable = if (toolCategoryAddParam.enable) 1 else 0 + } + + fun toolCategoryUpdateParamToToolCategory(toolCategoryUpdateParam: ToolCategoryUpdateParam) = ToolCategory().apply { + id = toolCategoryUpdateParam.id + name = toolCategoryUpdateParam.name + enable = toolCategoryUpdateParam.enable?. let { if (it) 1 else 0 } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..92cc185 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt @@ -0,0 +1,26 @@ +package top.fatweb.oxygen.api.converter.tool + +import top.fatweb.oxygen.api.converter.permission.UserInfoConverter +import top.fatweb.oxygen.api.entity.tool.Tool +import top.fatweb.oxygen.api.vo.tool.ToolVo + +object ToolConverter { + fun toolToToolVo(tool: Tool) = ToolVo( + id = tool.id, + name = tool.name, + toolId = tool.toolId, + description = tool.description, + baseId = tool.baseId, + author = tool.author?.let(UserInfoConverter::userInfoToUserInfoVo), + ver = tool.ver, + privately = tool.privately == 1, + keywords = tool.keywords, + categories = tool.categories?.map(ToolCategoryConverter::toolCategoryToToolCategoryVo), + source = tool.source?.let(ToolDataConverter::toolDataToToolDataVo), + dist = tool.dist?.let(ToolDataConverter::toolDataToToolDataVo), + publish = tool.publish == 1, + review = tool.review, + createTime = tool.createTime, + updateTime = tool.updateTime + ) +} \ No newline at end of file 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 new file mode 100644 index 0000000..bd978b0 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolDataConverter.kt @@ -0,0 +1,13 @@ +package top.fatweb.oxygen.api.converter.tool + +import top.fatweb.oxygen.api.entity.tool.ToolData +import top.fatweb.oxygen.api.vo.tool.ToolDataVo + +object ToolDataConverter { + fun toolDataToToolDataVo(toolData: ToolData) = ToolDataVo( + id = toolData.id, + data = toolData.data, + createTime = toolData.createTime, + updateTime = toolData.updateTime + ) +} \ No newline at end of file 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 new file mode 100644 index 0000000..3a665e9 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolTemplateConverter.kt @@ -0,0 +1,17 @@ +package top.fatweb.oxygen.api.converter.tool + +import top.fatweb.oxygen.api.entity.tool.ToolTemplate +import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo + +object ToolTemplateConverter { + fun toolTemplateToToolTemplateVo(toolTemplate: ToolTemplate) = ToolTemplateVo( + id = toolTemplate.id, + name = toolTemplate.name, + ver = toolTemplate.ver, + baseId = toolTemplate.baseId, + source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo), + dist = toolTemplate.dist?.let(ToolDataConverter::toolDataToToolDataVo), + createTime = toolTemplate.createTime, + updateTime = toolTemplate.updateTime + ) +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt index c9178fd..36aa2a6 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt @@ -2,6 +2,8 @@ package top.fatweb.oxygen.api.entity.tool import com.baomidou.mybatisplus.annotation.* import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler +import top.fatweb.oxygen.api.entity.permission.UserInfo +import java.time.LocalDateTime /** * Tool entity @@ -48,13 +50,22 @@ class Tool { var description: String? = null /** - * Author + * Base ID * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ - @TableField("author") - var author: Long? = null + @TableField("base_id") + var baseId: Long? = null + + /** + * Author ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("author_id") + var authorId: Long? = null /** * Version of tool @@ -75,30 +86,31 @@ class Tool { var privately: Int? = null /** - * Keyword + * Keywords * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ - @TableField("keyword", typeHandler = JacksonTypeHandler::class) - var keyword: List? = null + @TableField("keywords", typeHandler = JacksonTypeHandler::class) + var keywords: List? = null /** - * Source code + * Source code ID * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ - @TableField("source") - var source: Long? = null + @TableField("source_id") + var sourceId: Long? = null /** - * Compile product + * Compile product ID * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ - var dist: Long? = null + @TableField("dist_id") + var distId: Long? = null /** * Publish @@ -106,6 +118,7 @@ class Tool { * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @TableField("publish") var publish: Int? = null /** @@ -114,8 +127,29 @@ class Tool { * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @TableField("review") var review: Int? = null + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("create_time", fill = FieldFill.INSERT) + var createTime: LocalDateTime? = null + + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("update_time", fill = FieldFill.INSERT_UPDATE) + var updateTime: LocalDateTime? = null + /** * Deleted * @@ -136,7 +170,43 @@ class Tool { @Version var version: Int? = null + /** + * Author + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var author: UserInfo? = null + + /** + * Categories + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var categories: List? = null + + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var source: ToolData? = null + + /** + * Dist + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var dist: ToolData? = null + override fun toString(): String { - return "Tool(id=$id, name=$name, toolId=$toolId, description=$description, author=$author, ver=$ver, privately=$privately, keyword=$keyword, source=$source, dist=$dist, publish=$publish, review=$review, deleted=$deleted, version=$version)" + return "Tool(id=$id, name=$name, toolId=$toolId, description=$description, baseId=$baseId, authorId=$authorId, ver=$ver, privately=$privately, keywords=$keywords, sourceId=$sourceId, distId=$distId, publish=$publish, review=$review, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, author=$author, categories=$categories, source=$source, dist=$dist)" } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt new file mode 100644 index 0000000..ba9b5b5 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt @@ -0,0 +1,111 @@ +package top.fatweb.oxygen.api.entity.tool + +import com.baomidou.mybatisplus.annotation.* +import java.time.LocalDateTime + +/** + * Tool base entity + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@TableName("t_b_tool_base") +class ToolBase { + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableId("id") + var id: Long? = null + + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("name") + var name: String? = null + + /** + * Source ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("source_id") + var sourceId: Long? = null + + /** + * Dist ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("dist_id") + var distId: Long? = null + + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("create_time", fill = FieldFill.INSERT) + var createTime: LocalDateTime? = null + + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("update_time", fill = FieldFill.INSERT_UPDATE) + var updateTime: LocalDateTime? = null + + /** + * Deleted + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + /** + * Version + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("version") + @Version + var version: Int? = null + + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var source: ToolData? = null + + /** + * Dist + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var dist: ToolData? = null + + override fun toString(): String { + return "ToolBase(id=$id, name=$name, sourceId=$sourceId, distId=$distId, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, dist=$dist)" + } +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolCategory.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolCategory.kt index e441685..f111e1d 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolCategory.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolCategory.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.entity.tool import com.baomidou.mybatisplus.annotation.* +import java.time.LocalDateTime /** * Tool category entity @@ -37,6 +38,26 @@ class ToolCategory { @TableField("enable") var enable: Int? = null + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("create_time", fill = FieldFill.INSERT) + var createTime: LocalDateTime? = null + + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("update_time", fill = FieldFill.INSERT_UPDATE) + var updateTime: LocalDateTime? = null + /** * Deleted * @@ -58,6 +79,6 @@ class ToolCategory { var version: Int? = null override fun toString(): String { - return "ToolCategory(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version)" + return "ToolCategory(id=$id, name=$name, enable=$enable, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version)" } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolData.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolData.kt index 84430c8..d576b23 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolData.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolData.kt @@ -1,8 +1,7 @@ package top.fatweb.oxygen.api.entity.tool -import com.baomidou.mybatisplus.annotation.TableField -import com.baomidou.mybatisplus.annotation.TableId -import com.baomidou.mybatisplus.annotation.TableName +import com.baomidou.mybatisplus.annotation.* +import java.time.LocalDateTime /** * Tool data entity @@ -30,7 +29,47 @@ class ToolData { @TableField("data") var data: String? = null + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("create_time", fill = FieldFill.INSERT) + var createTime: LocalDateTime? = null + + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("update_time", fill = FieldFill.INSERT_UPDATE) + var updateTime: LocalDateTime? = null + + /** + * Deleted + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + /** + * Version + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("version") + @Version + var version: Int? = null + override fun toString(): String { - return "ToolData(id=$id, data=$data)" + return "ToolData(id=$id, data=$data, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version)" } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt new file mode 100644 index 0000000..7d47149 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt @@ -0,0 +1,129 @@ +package top.fatweb.oxygen.api.entity.tool + +import com.baomidou.mybatisplus.annotation.* +import java.time.LocalDateTime + +/** + * Tool template entity + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +@TableName("t_b_tool_template") +class ToolTemplate { + /** + * ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableId("id") + var id: Long? = null + + /** + * Name + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("name") + var name: String? = null + + /** + * ver + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("ver") + var ver: String? = null + + /** + * Base ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("base_id") + var baseId: Long? = null + + /** + * Source ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("source_id") + var sourceId: Long? = null + + /** + * Dist ID + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("dist_id") + var distId: Long? = null + + /** + * Create time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("create_time", fill = FieldFill.INSERT) + var createTime: LocalDateTime? = null + + /** + * Update time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("update_time", fill = FieldFill.INSERT_UPDATE) + var updateTime: LocalDateTime? = null + + /** + * Deleted + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + /** + * Version + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("version") + @Version + var version: Int? = null + + /** + * Source + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var source: ToolData? = null + + /** + * Dist + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField(exist = false) + var dist: ToolData? = null + + override fun toString(): String { + return "ToolTemplate(id=$id, name=$name, ver=$ver, baseId=$baseId, sourceId=$sourceId, distId=$distId, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version)" + } +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/exception/ToolHasPublish.kt b/src/main/kotlin/top/fatweb/oxygen/api/exception/ToolHasPublish.kt new file mode 100644 index 0000000..72998c2 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/exception/ToolHasPublish.kt @@ -0,0 +1,3 @@ +package top.fatweb.oxygen.api.exception + +class ToolHasPublish : RuntimeException("The tool has been published and cannot be modified") \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolBaseMapper.kt b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolBaseMapper.kt new file mode 100644 index 0000000..d79f84d --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolBaseMapper.kt @@ -0,0 +1,21 @@ +package top.fatweb.oxygen.api.mapper.tool + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import org.apache.ibatis.annotations.Param +import top.fatweb.oxygen.api.entity.tool.ToolBase + +/** + * Tool base mapper + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see BaseMapper + * @see ToolBase + */ +@Mapper +interface ToolBaseMapper : BaseMapper { + fun selectOne(@Param("id") id: Long): ToolBase? + + fun selectList(): List +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolMapper.kt b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolMapper.kt index 77dd30a..ac7caed 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolMapper.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolMapper.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.mapper.tool import com.baomidou.mybatisplus.core.mapper.BaseMapper import org.apache.ibatis.annotations.Mapper +import org.apache.ibatis.annotations.Param import top.fatweb.oxygen.api.entity.tool.Tool /** @@ -13,4 +14,8 @@ import top.fatweb.oxygen.api.entity.tool.Tool * @see Tool */ @Mapper -interface ToolMapper : BaseMapper \ No newline at end of file +interface ToolMapper : BaseMapper { + fun selectOne(@Param("id") id: Long): Tool? + + fun selectList(): List +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolTemplateMapper.kt b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolTemplateMapper.kt new file mode 100644 index 0000000..a11ce86 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/ToolTemplateMapper.kt @@ -0,0 +1,21 @@ +package top.fatweb.oxygen.api.mapper.tool + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import org.apache.ibatis.annotations.Param +import top.fatweb.oxygen.api.entity.tool.ToolTemplate + +/** + * Tool template mapper + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see BaseMapper + * @see ToolTemplate + */ +@Mapper +interface ToolTemplateMapper : BaseMapper { + fun selectOne(@Param("id") id: Long): ToolTemplate? + + fun selectList(): List +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolAddParam.kt new file mode 100644 index 0000000..0cbfcb8 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolAddParam.kt @@ -0,0 +1,44 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotBlank +import jakarta.validation.constraints.NotEmpty +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern + +data class ToolAddParam( + @field: NotBlank(message = "Name can not be blank") + val name: String?, + + @field: NotBlank(message = "ToolId can not be blank") + @field: Pattern( + regexp = "^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$", + message = "Ver can only match '^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$'" + ) + val toolId: String?, + + val description: String?, + + @field: NotNull(message = "BaseId can not be null") + val baseId: Long?, + + @field: NotNull(message = "AuthorId can not be null") + val authorId: Long?, + + @field: NotBlank(message = "Ver can not be blank") + @field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '..'") + val ver: String?, + + val privately: Boolean = false, + + @field: NotEmpty(message = "Keywords can not be empty") + val keywords: List, + + @field: NotEmpty(message = "Categories can not be empty") + val categories: List, + + @field: NotNull(message = "Source can not be null") + val source: String?, + + @field:NotNull(message = "Dist can not be null") + val dist: String? +) 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 new file mode 100644 index 0000000..77f4bfa --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt @@ -0,0 +1,15 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotBlank +import jakarta.validation.constraints.NotNull + +data class ToolBaseAddParam( + @field: NotBlank(message = "Name can not be blank") + val name: String?, + + @field: NotNull(message = "Source can not be null") + val source: String?, + + @field:NotNull(message = "Dist can not be null") + val dist: String? +) 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 new file mode 100644 index 0000000..6287b11 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt @@ -0,0 +1,14 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotNull + +data class ToolBaseUpdateParam( + @field: NotNull(message = "ID can not be null") + val id: Long?, + + val name: String?, + + val source: String?, + + val dist: String? +) 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 new file mode 100644 index 0000000..7e8bc39 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt @@ -0,0 +1,10 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotBlank + +data class ToolCategoryAddParam( + @field: NotBlank(message = "Name can not be blank") + val name: String?, + + 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 new file mode 100644 index 0000000..4fca7ec --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt @@ -0,0 +1,14 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotBlank +import jakarta.validation.constraints.NotNull + +data class ToolCategoryUpdateParam( + @field: NotNull(message = "ID can not be null") + val id: Long?, + + @field: NotBlank(message = "Name can not be blank") + val name: String?, + + 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 new file mode 100644 index 0000000..49839d0 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt @@ -0,0 +1,23 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotBlank +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern + +data class ToolTemplateAddParam( + @field: NotBlank(message = "Name can not be blank") + val name: String?, + + @field: NotBlank(message = "Ver can not be blank") + @field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '..'") + val ver: String?, + + @field: NotNull(message = "BaseId can not be null") + val baseId: Long? = null, + + @field: NotNull(message = "Source can not be null") + val source: String?, + + @field:NotNull(message = "Dist can not be null") + val dist: String? +) 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 new file mode 100644 index 0000000..d170e3e --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt @@ -0,0 +1,20 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern + +data class ToolTemplateUpdateParam( + @field: NotNull(message = "ID can not be null") + val id: Long?, + + val name: String?, + + @field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '..'") + val ver: String?, + + val baseId: Long?, + + val source: String?, + + val dist: String? +) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt new file mode 100644 index 0000000..94d1d0d --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt @@ -0,0 +1,34 @@ +package top.fatweb.oxygen.api.param.tool + +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern + +data class ToolUpdateParam( + @field: NotNull(message = "ID can not be null") + val id: Long?, + + val name: String?, + + @field: Pattern( + regexp = "^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$", + message = "Ver can only match '^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$'" + ) + val toolId: String?, + + val description: String?, + + val authorId: Long?, + + @field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '..'") + val ver: String?, + + val privately: Boolean?, + + val keywords: List, + + val categories: List, + + val source: String?, + + val dist: String? +) 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 new file mode 100644 index 0000000..0ccfff9 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolBaseService.kt @@ -0,0 +1,29 @@ +package top.fatweb.oxygen.api.service.tool + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.ToolCategory +import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam +import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam +import top.fatweb.oxygen.api.vo.tool.ToolBaseVo +import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo + +/** + * Tool base service interface + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IService + * @see ToolBase + */ +interface IToolBaseService : IService { + fun getOne(id: Long): ToolBaseVo? + + fun get(): List + + fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo + + fun update(toolBaseUpdateParam: ToolBaseUpdateParam): ToolBaseVo + + 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 aac755e..c661773 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 @@ -2,6 +2,9 @@ package top.fatweb.oxygen.api.service.tool import com.baomidou.mybatisplus.extension.service.IService import top.fatweb.oxygen.api.entity.tool.ToolCategory +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 service interface @@ -11,4 +14,14 @@ import top.fatweb.oxygen.api.entity.tool.ToolCategory * @see IService * @see ToolCategory */ -interface IToolCategoryService : IService \ No newline at end of file +interface IToolCategoryService : IService { + fun getOne(id: Long): ToolCategoryVo? + + fun get(): List + + fun add(toolCategoryAddParam: ToolCategoryAddParam): ToolCategoryVo + + fun update(toolCategoryUpdateParam: ToolCategoryUpdateParam): ToolCategoryVo + + fun delete(id: Long): Boolean +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolService.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolService.kt index c0df740..d32a1a5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolService.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolService.kt @@ -2,6 +2,9 @@ package top.fatweb.oxygen.api.service.tool import com.baomidou.mybatisplus.extension.service.IService import top.fatweb.oxygen.api.entity.tool.Tool +import top.fatweb.oxygen.api.param.tool.ToolAddParam +import top.fatweb.oxygen.api.param.tool.ToolUpdateParam +import top.fatweb.oxygen.api.vo.tool.ToolVo /** * Tool service interface @@ -11,4 +14,14 @@ import top.fatweb.oxygen.api.entity.tool.Tool * @see IService * @see Tool */ -interface IToolService : IService \ No newline at end of file +interface IToolService : IService { + fun getOne(id: Long): ToolVo? + + fun get(): List + + fun add(toolAddParam: ToolAddParam): ToolVo + + fun update(toolUpdateParam: ToolUpdateParam): ToolVo + + 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 new file mode 100644 index 0000000..3fcdf81 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IToolTemplateService.kt @@ -0,0 +1,27 @@ +package top.fatweb.oxygen.api.service.tool + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.oxygen.api.entity.tool.ToolTemplate +import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam +import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam +import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo + +/** + * Tool template service interface + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IService + * @see ToolTemplate + */ +interface IToolTemplateService : IService { + fun getOne(id: Long): ToolTemplateVo? + + fun get(): List + + fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo + + fun update(toolTemplateUpdateParam: ToolTemplateUpdateParam): ToolTemplateVo + + fun delete(id: Long): Boolean +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/RToolCategoryServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/RToolCategoryServiceImpl.kt index d7a6904..87844df 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/RToolCategoryServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/RToolCategoryServiceImpl.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.service.tool.impl import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service import top.fatweb.oxygen.api.entity.tool.RToolCategory import top.fatweb.oxygen.api.mapper.tool.RToolCategoryMapper import top.fatweb.oxygen.api.service.tool.IRToolCategoryService @@ -15,4 +16,5 @@ import top.fatweb.oxygen.api.service.tool.IRToolCategoryService * @see RToolCategory * @see IRToolCategoryService */ +@Service class RToolCategoryServiceImpl : ServiceImpl(), IRToolCategoryService \ 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 new file mode 100644 index 0000000..4b338da --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolBaseServiceImpl.kt @@ -0,0 +1,85 @@ +package top.fatweb.oxygen.api.service.tool.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import top.fatweb.oxygen.api.converter.tool.ToolBaseConverter +import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.ToolData +import top.fatweb.oxygen.api.exception.NoRecordFoundException +import top.fatweb.oxygen.api.mapper.tool.ToolBaseMapper +import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam +import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam +import top.fatweb.oxygen.api.service.tool.IToolBaseService +import top.fatweb.oxygen.api.service.tool.IToolDataService +import top.fatweb.oxygen.api.vo.tool.ToolBaseVo + +/** + * Tool base service implement + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ServiceImpl + * @see ToolBaseMapper + * @see ToolBase + * @see IToolBaseService + */ +@Service +class ToolBaseServiceImpl( + private val toolDataService: IToolDataService +) : ServiceImpl(), IToolBaseService { + override fun getOne(id: Long): ToolBaseVo? = baseMapper.selectOne(id)?.let(ToolBaseConverter::toolBaseToToolBaseVo) + + override fun get(): List = baseMapper.selectList().map(ToolBaseConverter::toolBaseToToolBaseVo) + + @Transactional + override fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo { + val newSource = ToolData().apply { data = toolBaseAddParam.source } + val newDist = ToolData().apply { data = toolBaseAddParam.dist } + + toolDataService.save(newSource) + toolDataService.save(newDist) + + val toolBase = ToolBase().apply { + name = toolBaseAddParam.name + sourceId = newSource.id + distId = newDist.id + source = newSource + dist = newDist + } + + this.save(toolBase) + + return ToolBaseConverter.toolBaseToToolBaseVo(toolBase) + } + + @Transactional + override fun update(toolBaseUpdateParam: ToolBaseUpdateParam): ToolBaseVo { + val toolBase = baseMapper.selectOne(toolBaseUpdateParam.id!!) ?: throw NoRecordFoundException() + + toolDataService.updateById(ToolData().apply { + id = toolBase.sourceId + data = toolBaseUpdateParam.source + }) + + toolDataService.updateById(ToolData().apply { + id = toolBase.distId + data = toolBaseUpdateParam.dist + }) + + this.updateById(ToolBase().apply { + id = toolBaseUpdateParam.id + name = toolBaseUpdateParam.name + }) + + return this.getOne(toolBase.id!!)!! + } + + @Transactional + override fun delete(id: Long): Boolean { + val toolBase = this.getById(id) + + return toolDataService.removeBatchByIds(listOf(toolBase.sourceId, toolBase.distId)) + && this.removeById(id) + } +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolCategoryServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolCategoryServiceImpl.kt index 4edbdb0..a9c408b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolCategoryServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolCategoryServiceImpl.kt @@ -1,9 +1,15 @@ package top.fatweb.oxygen.api.service.tool.impl import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import top.fatweb.oxygen.api.converter.tool.ToolCategoryConverter import top.fatweb.oxygen.api.entity.tool.ToolCategory import top.fatweb.oxygen.api.mapper.tool.ToolCategoryMapper +import top.fatweb.oxygen.api.param.tool.ToolCategoryAddParam +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 service implement @@ -15,4 +21,29 @@ import top.fatweb.oxygen.api.service.tool.IToolCategoryService * @see ToolCategory * @see IToolCategoryService */ -class ToolCategoryServiceImpl : ServiceImpl(), IToolCategoryService \ No newline at end of file +@Service +class ToolCategoryServiceImpl : ServiceImpl(), IToolCategoryService { + override fun getOne(id: Long): ToolCategoryVo? = + this.getById(id)?.let(ToolCategoryConverter::toolCategoryToToolCategoryVo) + + override fun get(): List = + this.list().map(ToolCategoryConverter::toolCategoryToToolCategoryVo) + + override fun add(toolCategoryAddParam: ToolCategoryAddParam): ToolCategoryVo { + val toolCategory = ToolCategoryConverter.toolCategoryAddParamToToolCategory(toolCategoryAddParam) + + this.save(toolCategory) + + return ToolCategoryConverter.toolCategoryToToolCategoryVo(toolCategory) + } + + override fun update(toolCategoryUpdateParam: ToolCategoryUpdateParam): ToolCategoryVo { + val toolCategory = ToolCategoryConverter.toolCategoryUpdateParamToToolCategory(toolCategoryUpdateParam) + + this.updateById(toolCategory) + + return ToolCategoryConverter.toolCategoryToToolCategoryVo(toolCategory) + } + + override fun delete(id: Long): Boolean = this.removeById(id) +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolDataServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolDataServiceImpl.kt index 545a48a..74cc3ca 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolDataServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolDataServiceImpl.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.service.tool.impl import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service import top.fatweb.oxygen.api.entity.tool.ToolData import top.fatweb.oxygen.api.mapper.tool.ToolDataMapper import top.fatweb.oxygen.api.service.tool.IToolDataService @@ -15,4 +16,5 @@ import top.fatweb.oxygen.api.service.tool.IToolDataService * @see ToolData * @see IToolDataService */ +@Service class ToolDataServiceImpl : ServiceImpl(), IToolDataService \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolServiceImpl.kt index 2fe45a2..f48ca96 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolServiceImpl.kt @@ -1,9 +1,22 @@ package top.fatweb.oxygen.api.service.tool.impl +import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import top.fatweb.oxygen.api.converter.tool.ToolConverter +import top.fatweb.oxygen.api.entity.tool.RToolCategory import top.fatweb.oxygen.api.entity.tool.Tool +import top.fatweb.oxygen.api.entity.tool.ToolData +import top.fatweb.oxygen.api.exception.NoRecordFoundException +import top.fatweb.oxygen.api.exception.ToolHasPublish +import top.fatweb.oxygen.api.exception.UserNotFoundException import top.fatweb.oxygen.api.mapper.tool.ToolMapper -import top.fatweb.oxygen.api.service.tool.IToolService +import top.fatweb.oxygen.api.param.tool.ToolAddParam +import top.fatweb.oxygen.api.param.tool.ToolUpdateParam +import top.fatweb.oxygen.api.service.permission.IUserService +import top.fatweb.oxygen.api.service.tool.* +import top.fatweb.oxygen.api.vo.tool.ToolVo /** * Tool service implement @@ -15,4 +28,95 @@ import top.fatweb.oxygen.api.service.tool.IToolService * @see Tool * @see IToolService */ -class ToolServiceImpl : ServiceImpl(), IToolService \ No newline at end of file +@Service +class ToolServiceImpl( + private val toolDataService: IToolDataService, + private val toolBaseService: IToolBaseService, + private val toolCategoryService: IToolCategoryService, + private val rToolCategoryService: IRToolCategoryService, + private val userService: IUserService +) : ServiceImpl(), IToolService { + override fun getOne(id: Long): ToolVo? = baseMapper.selectOne(id)?.let(ToolConverter::toolToToolVo) + + override fun get(): List = baseMapper.selectList().map(ToolConverter::toolToToolVo) + + @Transactional + override fun add(toolAddParam: ToolAddParam): ToolVo { + toolBaseService.getOne(toolAddParam.baseId!!) ?: throw NoRecordFoundException() + userService.getOne(toolAddParam.authorId!!) ?: throw UserNotFoundException() + + val newSource = ToolData().apply { data = toolAddParam.source } + val newDist = ToolData().apply { data = toolAddParam.dist } + + toolDataService.save(newSource) + toolDataService.save(newDist) + + val tool = Tool().apply { + name = toolAddParam.name + toolId = toolAddParam.toolId + description = toolAddParam.description + baseId = toolAddParam.baseId + authorId = toolAddParam.authorId + ver = toolAddParam.ver + privately = if (toolAddParam.privately) 1 else 0 + keywords = toolAddParam.keywords + sourceId = newSource.id + distId = newDist.id + } + + this.save(tool) + + toolAddParam.categories.forEach { + toolCategoryService.getById(it) ?: throw NoRecordFoundException() + rToolCategoryService.save(RToolCategory().apply { + toolId = tool.id + categoryId = it + }) + } + + return this.getOne(tool.id!!)!! + } + + @Transactional + override fun update(toolUpdateParam: ToolUpdateParam): ToolVo { + val tool = baseMapper.selectOne(toolUpdateParam.id!!) ?: throw NoRecordFoundException() + if (tool.publish == 1) { + throw ToolHasPublish() + } + userService.getOne(toolUpdateParam.authorId!!) ?: throw UserNotFoundException() + + toolDataService.updateById(ToolData().apply { + id = tool.sourceId + data = toolUpdateParam.source + }) + + toolDataService.updateById(ToolData().apply { + id = tool.distId + data = toolUpdateParam.dist + }) + + this.updateById(Tool().apply { + id = toolUpdateParam.id + name = toolUpdateParam.name + toolId = toolUpdateParam.toolId + description = toolUpdateParam.description + authorId = toolUpdateParam.authorId + ver = toolUpdateParam.ver + privately = toolUpdateParam.privately?.let { if (it) 1 else 0 } + keywords = toolUpdateParam.keywords + }) + + // TODO + + return this.getOne(tool.id!!)!! + } + + @Transactional + override fun delete(id: Long): Boolean { + val tool = this.getById(id) + + return toolDataService.removeBatchByIds(listOf(tool.sourceId, tool.distId)) + && rToolCategoryService.remove(KtQueryWrapper(RToolCategory()).eq(RToolCategory::toolId, tool.id)) + && this.removeById(tool.id) + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..f78b226 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/ToolTemplateServiceImpl.kt @@ -0,0 +1,96 @@ +package top.fatweb.oxygen.api.service.tool.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import top.fatweb.oxygen.api.converter.tool.ToolTemplateConverter +import top.fatweb.oxygen.api.entity.tool.ToolData +import top.fatweb.oxygen.api.entity.tool.ToolTemplate +import top.fatweb.oxygen.api.exception.NoRecordFoundException +import top.fatweb.oxygen.api.mapper.tool.ToolTemplateMapper +import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam +import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam +import top.fatweb.oxygen.api.service.tool.IToolBaseService +import top.fatweb.oxygen.api.service.tool.IToolDataService +import top.fatweb.oxygen.api.service.tool.IToolTemplateService +import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo + +/** + * Tool template service implement + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ServiceImpl + * @see ToolTemplateMapper + * @see ToolTemplate + * @see IToolTemplateService + */ +@Service +class ToolTemplateServiceImpl( + private val toolDataService: IToolDataService, + private val toolBaseService: IToolBaseService +) : ServiceImpl(), IToolTemplateService { + override fun getOne(id: Long): ToolTemplateVo? = + baseMapper.selectOne(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVo) + + override fun get(): List = + baseMapper.selectList().map(ToolTemplateConverter::toolTemplateToToolTemplateVo) + + @Transactional + override fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo { + toolBaseService.getOne(toolTemplateAddParam.baseId!!) ?: throw NoRecordFoundException() + + val newSource = ToolData().apply { data = toolTemplateAddParam.source } + val newDist = ToolData().apply { data = toolTemplateAddParam.dist } + + toolDataService.save(newSource) + toolDataService.save(newDist) + + val toolTemplate = ToolTemplate().apply { + name = toolTemplateAddParam.name + ver = toolTemplateAddParam.ver + baseId = toolTemplateAddParam.baseId + sourceId = newSource.id + distId = newDist.id + source = newSource + dist = newDist + } + + this.save(toolTemplate) + + return ToolTemplateConverter.toolTemplateToToolTemplateVo(toolTemplate) + } + + @Transactional + override fun update(toolTemplateUpdateParam: ToolTemplateUpdateParam): ToolTemplateVo { + val toolTemplate = baseMapper.selectOne(toolTemplateUpdateParam.id!!) ?: throw NoRecordFoundException() + toolTemplateUpdateParam.baseId?.let { toolBaseService.getOne(it) ?: throw NoRecordFoundException() } + + toolDataService.updateById(ToolData().apply { + id = toolTemplate.sourceId + data = toolTemplateUpdateParam.source + }) + + toolDataService.updateById(ToolData().apply { + id = toolTemplate.distId + data = toolTemplateUpdateParam.dist + }) + + this.updateById(ToolTemplate().apply { + id = toolTemplateUpdateParam.id + name = toolTemplateUpdateParam.name + ver = toolTemplateUpdateParam.ver + baseId = toolTemplateUpdateParam.baseId + }) + + return this.getOne(toolTemplate.id!!)!! + } + + @Transactional + override fun delete(id: Long): Boolean { + val toolTemplate = this.getById(id) + + return toolDataService.removeBatchByIds(listOf(toolTemplate.sourceId, toolTemplate.distId)) + && this.removeById(id) + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..cc92560 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt @@ -0,0 +1,20 @@ +package top.fatweb.oxygen.api.vo.tool + +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import java.time.LocalDateTime + +data class ToolBaseVo( + @JsonSerialize(using = ToStringSerializer::class) + val id: Long?, + + val name: String?, + + val source: ToolDataVo?, + + val dist: ToolDataVo?, + + val createTime: LocalDateTime?, + + 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 new file mode 100644 index 0000000..2c1d3a1 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolCategoryVo.kt @@ -0,0 +1,18 @@ +package top.fatweb.oxygen.api.vo.tool + +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import java.time.LocalDateTime + +data class ToolCategoryVo( + @JsonSerialize(using = ToStringSerializer::class) + val id: Long?, + + val name: String?, + + val enable: Boolean?, + + val createTime: LocalDateTime?, + + 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 new file mode 100644 index 0000000..dde38e5 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolDataVo.kt @@ -0,0 +1,16 @@ +package top.fatweb.oxygen.api.vo.tool + +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import java.time.LocalDateTime + +data class ToolDataVo( + @JsonSerialize(using = ToStringSerializer::class) + val id: Long?, + + val data: String?, + + val createTime: LocalDateTime?, + + 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 new file mode 100644 index 0000000..cce4be4 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt @@ -0,0 +1,25 @@ +package top.fatweb.oxygen.api.vo.tool + +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import java.time.LocalDateTime + +data class ToolTemplateVo( + @JsonSerialize(using = ToStringSerializer::class) + val id: Long?, + + val name: String?, + + val ver: String?, + + @JsonSerialize(using = ToStringSerializer::class) + val baseId: Long?, + + val source: ToolDataVo?, + + val dist: ToolDataVo?, + + val createTime: LocalDateTime?, + + val updateTime: LocalDateTime? +) \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt new file mode 100644 index 0000000..3b7fe20 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt @@ -0,0 +1,42 @@ +package top.fatweb.oxygen.api.vo.tool + +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer +import top.fatweb.oxygen.api.vo.permission.base.UserInfoVo +import java.time.LocalDateTime + +data class ToolVo ( + @JsonSerialize(using = ToStringSerializer::class) + val id: Long?, + + val name: String?, + + val toolId: String?, + + val description: String?, + + @JsonSerialize(using = ToStringSerializer::class) + val baseId: Long?, + + val author: UserInfoVo?, + + val ver: String?, + + val privately: Boolean?, + + val keywords: List?, + + val categories: List?, + + val source: ToolDataVo?, + + val dist: ToolDataVo?, + + val publish: Boolean?, + + val review: Int?, + + val createTime: LocalDateTime?, + + val updateTime: LocalDateTime? +) \ No newline at end of file diff --git a/src/main/resources/db/migration/master/R__Basic_data.sql b/src/main/resources/db/migration/master/R__Basic_data.sql index 0b5d2a8..e8bb177 100644 --- a/src/main/resources/db/migration/master/R__Basic_data.sql +++ b/src/main/resources/db/migration/master/R__Basic_data.sql @@ -74,12 +74,20 @@ insert into t_s_power (id, type_id) (1530303, 4), (1540101, 4), (1540102, 4), + (1540103, 4), + (1540104, 4), (1540201, 4), (1540202, 4), + (1540203, 4), + (1540204, 4), (1540301, 4), (1540302, 4), + (1540303, 4), + (1540304, 4), (1540401, 4), - (1540402, 4) as new_value + (1540402, 4), + (1540403, 4), + (1540404, 4) as new_value on duplicate key update type_id = new_value.type_id; insert into t_s_module (id, name) @@ -87,15 +95,15 @@ insert into t_s_module (id, name) on duplicate key update name = new_value.name; insert into t_s_menu (id, name, url, parent_id, module_id) - values (1990000, '系统管理', '/system', null, 1000000), - (1010000, '用户管理', '/system/user', 1990000, 1000000), - (1020000, '角色管理', '/system/role', 1990000, 1000000), - (1030000, '用户组管理', '/system/group', 1990000, 1000000), - (1040000, '权限管理', '/system/power', 1990000, 1000000), - (1510000, '系统概况', '/system/statistics', 1990000, 1000000), - (1520000, '日志管理', '/system/log', 1990000, 1000000), - (1530000, '系统设置', '/system/settings', 1990000, 1000000), - (1540000, '工具配置', '/system/tools', 1990000, 1000000) as new_value + values (1990000, '系统管理', '^/system$', null, 1000000), + (1010000, '用户管理', '^/system/user$', 1990000, 1000000), + (1020000, '角色管理', '^/system/role$', 1990000, 1000000), + (1030000, '用户组管理', '^/system/group$', 1990000, 1000000), + (1040000, '权限管理', '^/system/power$', 1990000, 1000000), + (1510000, '系统概况', '^/system/statistics$', 1990000, 1000000), + (1520000, '日志管理', '^/system/log$', 1990000, 1000000), + (1530000, '系统设置', '^/system/settings$', 1990000, 1000000), + (1540000, '工具配置', '^/system/tools(/.*)?$', 1990000, 1000000) as new_value on duplicate key update name =new_value.name, url =new_value.url, parent_id =new_value.parent_id; @@ -162,14 +170,22 @@ insert into t_s_operation(id, name, code, func_id) (1530301, '基础', 'system:settings:modify:base', 1530300), (1530302, '邮件', 'system:settings:modify:mail', 1530300), (1530303, '敏感词', 'system:settings:modify:sensitive', 1530300), - (1540101, '基板', 'system:tools:query:base', 1540100), - (1540102, '模板', 'system:tools:query:template', 1540100), - (1540201, '基板', 'system:tools:add:base', 1540200), - (1540202, '模板', 'system:tools:add:template', 1540200), - (1540301, '基板', 'system:tools:modify:base', 1540300), - (1540302, '模板', 'system:tools:modify:template', 1540300), - (1540401, '基板', 'system:tools:delete:base', 1540400), - (1540402, '模板', 'system:tools:delete:template', 1540400) as new_value + (1540101, '类别', 'system:tool:query:category', 1540100), + (1540102, '基板', 'system:tool:query:base', 1540100), + (1540103, '模板', 'system:tool:query:template', 1540100), + (1540104, '工具', 'system:tool:query:tool', 1540100), + (1540201, '类别', 'system:tool:add:category', 1540200), + (1540202, '基板', 'system:tool:add:base', 1540200), + (1540203, '模板', 'system:tool:add:template', 1540200), + (1540204, '工具', 'system:tool:add:tool', 1540200), + (1540301, '类别', 'system:tool:modify:category', 1540300), + (1540302, '基板', 'system:tool:modify:base', 1540300), + (1540303, '模板', 'system:tool:modify:template', 1540300), + (1540304, '工具', 'system:tool:modify:tool', 1540300), + (1540401, '类别', 'system:tool:delete:category', 1540400), + (1540402, '基板', 'system:tool:delete:base', 1540400), + (1540403, '模板', 'system:tool:delete:template', 1540400), + (1540404, '工具', 'system:tool:delete:tool', 1540400) as new_value on duplicate key update name=new_value.name, code=new_value.code, func_id=new_value.func_id; \ 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 4bed7ef..9e31827 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 @@ -6,18 +6,18 @@ create table if not exists t_b_tool_main name varchar(50) not null comment '工具名', tool_id varchar(50) not null comment '工具 ID', description varchar(500) null comment '简介', - base bigint not null comment '基于', - author bigint not null comment '作者', + base_id bigint not null comment '基板 ID', + author_id bigint not null comment '作者 ID', ver varchar(20) not null comment '版本', privately int not null default 0 comment '私有', - keyword varchar(500) not null comment '关键字', - source bigint null comment '源码', - dist bigint 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 '发布', review varchar(10) not null default 'NONE' comment '审核', create_time datetime not null default (utc_timestamp()) comment '创建时间', 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, deleted) + constraint t_b_tool_main_unique_tool_id unique (tool_id, author_id, deleted) ) comment '工具-主表'; \ No newline at end of file diff --git a/src/main/resources/db/migration/master/V1_0_0_240117__Add_table_'t_r_tool_main_category'.sql b/src/main/resources/db/migration/master/V1_0_0_240117__Add_table_'t_r_tool_main_category'.sql index ceb3afc..c711b56 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240117__Add_table_'t_r_tool_main_category'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240117__Add_table_'t_r_tool_main_category'.sql @@ -2,11 +2,9 @@ drop table if exists t_r_tool_main_category; create table if not exists t_r_tool_main_category ( - id bigint not null primary key, - tool_id bigint not null comment '工具', - category_id bigint not null comment '类别', - create_time datetime not null default (utc_timestamp()) comment '创建时间', - update_time datetime not null default (utc_timestamp()) comment '修改时间', - deleted bigint not null default 0, - version int not null default 0 + id bigint not null primary key, + tool_id bigint not null comment '工具', + category_id bigint not null comment '类别', + deleted bigint not null default 0, + version int not null default 0 ) comment '中间表-工具-主表-类别'; \ No newline at end of file diff --git a/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql b/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql index d9c8b71..d5317b0 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql @@ -5,9 +5,9 @@ create table if not exists t_b_tool_template id bigint not null primary key, name varchar(40) not null comment '模板名', ver varchar(20) not null comment '版本', - base varchar(20) not null comment '基于', - source bigint not null comment '源码', - dist bigint not null comment '产物', + base_id bigint not null comment '基板 ID', + source_id bigint not null comment '源码 ID', + dist_id bigint not null comment '产物 ID', create_time datetime not null default (utc_timestamp()) comment '创建时间', update_time datetime not null default (utc_timestamp()) comment '修改时间', deleted bigint not null default 0, diff --git a/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql b/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql index 84f0df4..d6e1c17 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql @@ -4,8 +4,8 @@ create table if not exists t_b_tool_base ( id bigint not null primary key, name varchar(20) not null comment '基板名', - source bigint not null comment '源码', - dist bigint not null comment '产物', + source_id bigint not null comment '源码 ID', + dist_id bigint not null comment '产物 ID', create_time datetime not null default (utc_timestamp()) comment '创建时间', update_time datetime not null default (utc_timestamp()) comment '修改时间', deleted bigint not null default 0, diff --git a/src/main/resources/mapper/tool/ToolBaseMapper.xml b/src/main/resources/mapper/tool/ToolBaseMapper.xml new file mode 100644 index 0000000..d940e45 --- /dev/null +++ b/src/main/resources/mapper/tool/ToolBaseMapper.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/tool/ToolDataMapper.xml b/src/main/resources/mapper/tool/ToolDataMapper.xml new file mode 100644 index 0000000..cb72ea3 --- /dev/null +++ b/src/main/resources/mapper/tool/ToolDataMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/main/resources/mapper/tool/ToolTemplateMapper.xml b/src/main/resources/mapper/tool/ToolTemplateMapper.xml new file mode 100644 index 0000000..cd73755 --- /dev/null +++ b/src/main/resources/mapper/tool/ToolTemplateMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +