Add create tool api

This commit is contained in:
2024-01-26 14:54:40 +08:00
parent 6e73f8212b
commit a66c5caa60
33 changed files with 945 additions and 302 deletions

View File

@@ -2,54 +2,80 @@ package top.fatweb.oxygen.api.controller.tool
import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Operation
import jakarta.validation.Valid import jakarta.validation.Valid
import org.springframework.web.bind.annotation.* import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.annotation.BaseController
import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseCode
import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.entity.common.ResponseResult
import top.fatweb.oxygen.api.param.tool.ToolAddParam import top.fatweb.oxygen.api.param.tool.ToolCreateParam
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam import top.fatweb.oxygen.api.service.tool.IEditService
import top.fatweb.oxygen.api.service.tool.IToolService import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
import top.fatweb.oxygen.api.vo.tool.ToolVo import top.fatweb.oxygen.api.vo.tool.ToolVo
/** /**
* Tool management controller * Tool edit controller
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
*/ */
@BaseController(path = ["/tool"], name = "工具管理", description = "工具管理相关接口") @BaseController(path = ["/tool"], name = "工具编辑", description = "工具编辑相关接口")
class EditController( class EditController(
private val toolService: IToolService private val editService: IEditService
) { ) {
@Operation(summary = "获取单个工具") /**
@GetMapping("/{id}") * Get tool template list
fun getOne(@PathVariable id: Long): ResponseResult<ToolVo> = *
ResponseResult.databaseSuccess(data = toolService.getOne(id)) * @return Response object includes tool template list
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ResponseResult
* @see ToolTemplateVo
*/
@Operation(summary = "获取模板")
@GetMapping("/template")
fun getTemplate(): ResponseResult<List<ToolTemplateVo>> =
ResponseResult.databaseSuccess(data = editService.getTemplate())
@Operation(summary = "获取工具") /**
@GetMapping * Get tool template by ID
fun get(): ResponseResult<List<ToolVo>> = *
ResponseResult.databaseSuccess(data = toolService.get()) * @param id ID
* @return Response object includes tool template information
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ResponseResult
* @see ToolTemplateVo
*/
@Operation(summary = "获取单个模板")
@GetMapping("/template/{id}")
fun getTemplate(@PathVariable id: Long): ResponseResult<ToolTemplateVo> =
ResponseResult.databaseSuccess(data = editService.getTemplate(id))
@Operation(summary = "新增工具") /**
* Get tool category list
*
* @return Response object includes tool category list
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ResponseResult
* @see ToolCategoryVo
*/
@Operation(summary = "获取类别")
@GetMapping("/category")
fun getCategory(): ResponseResult<List<ToolCategoryVo>> =
ResponseResult.databaseSuccess(data = editService.getCategory())
/**
* Create tool
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Operation(summary = "创建工具")
@PostMapping @PostMapping
fun add(@RequestBody @Valid toolAddParam: ToolAddParam): ResponseResult<ToolVo> = fun create(@RequestBody @Valid toolCreateParam: ToolCreateParam): ResponseResult<ToolVo> =
ResponseResult.databaseSuccess( ResponseResult.databaseSuccess(ResponseCode.DATABASE_INSERT_SUCCESS, data = editService.create(toolCreateParam))
ResponseCode.DATABASE_INSERT_SUCCESS,
data = toolService.add(toolAddParam)
)
@Operation(summary = "更新工具")
@PutMapping
fun update(@RequestBody @Valid toolUpdateParam: ToolUpdateParam): ResponseResult<ToolVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_UPDATE_SUCCESS,
data = toolService.update(toolUpdateParam)
)
@Operation(summary = "删除工具")
@DeleteMapping("/{id}")
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
if (toolService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED)
} }

View File

@@ -1,21 +1,10 @@
package top.fatweb.oxygen.api.controller.tool 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.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 = "工具管理相关接口") @BaseController(path = ["/system/tool"], name = "工具管理", description = "工具管理相关接口")
class ManagementController( class ManagementController {
private val toolService: IToolService /* @Operation(summary = "获取单个工具")
) {
@Operation(summary = "获取单个工具")
@GetMapping("/{id}") @GetMapping("/{id}")
fun getOne(@PathVariable id: Long): ResponseResult<ToolVo> = fun getOne(@PathVariable id: Long): ResponseResult<ToolVo> =
ResponseResult.databaseSuccess(data = toolService.getOne(id)) ResponseResult.databaseSuccess(data = toolService.getOne(id))
@@ -25,14 +14,6 @@ class ManagementController(
fun get(): ResponseResult<List<ToolVo>> = fun get(): ResponseResult<List<ToolVo>> =
ResponseResult.databaseSuccess(data = toolService.get()) ResponseResult.databaseSuccess(data = toolService.get())
@Operation(summary = "新增工具")
@PostMapping
fun add(@RequestBody @Valid toolAddParam: ToolAddParam): ResponseResult<ToolVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_INSERT_SUCCESS,
data = toolService.add(toolAddParam)
)
@Operation(summary = "更新工具") @Operation(summary = "更新工具")
@PutMapping @PutMapping
fun update(@RequestBody @Valid toolUpdateParam: ToolUpdateParam): ResponseResult<ToolVo> = fun update(@RequestBody @Valid toolUpdateParam: ToolUpdateParam): ResponseResult<ToolVo> =
@@ -45,5 +26,5 @@ class ManagementController(
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
fun delete(@PathVariable id: Long): ResponseResult<Nothing> = fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
if (toolService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) if (toolService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED) else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED)*/
} }

View File

@@ -28,8 +28,7 @@ object ToolBaseConverter {
dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo), dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo),
compiled = toolBase.compiled == 1, compiled = toolBase.compiled == 1,
createTime = toolBase.createTime, createTime = toolBase.createTime,
updateTime = toolBase.updateTime, updateTime = toolBase.updateTime
enable = toolBase.enable == 1
) )
/** /**
@@ -49,7 +48,6 @@ object ToolBaseConverter {
dist = ToolDataVo(id = toolBase.distId, data = null, createTime = null, updateTime = null), dist = ToolDataVo(id = toolBase.distId, data = null, createTime = null, updateTime = null),
compiled = toolBase.compiled == 1, compiled = toolBase.compiled == 1,
createTime = toolBase.createTime, createTime = toolBase.createTime,
updateTime = toolBase.updateTime, updateTime = toolBase.updateTime
enable = toolBase.enable == 1
) )
} }

View File

@@ -1,6 +1,6 @@
package top.fatweb.oxygen.api.converter.tool package top.fatweb.oxygen.api.converter.tool
import top.fatweb.oxygen.api.converter.permission.UserInfoConverter import top.fatweb.oxygen.api.converter.permission.UserConverter
import top.fatweb.oxygen.api.entity.tool.Tool import top.fatweb.oxygen.api.entity.tool.Tool
import top.fatweb.oxygen.api.vo.tool.ToolVo import top.fatweb.oxygen.api.vo.tool.ToolVo
@@ -27,13 +27,14 @@ object ToolConverter {
toolId = tool.toolId, toolId = tool.toolId,
description = tool.description, description = tool.description,
baseId = tool.baseId, baseId = tool.baseId,
author = tool.author?.let(UserInfoConverter::userInfoToUserInfoVo), author = tool.author?.let(UserConverter::userToUserWithInfoVo),
ver = tool.ver, ver = tool.ver,
privately = tool.privately == 1, privately = tool.privately == 1,
keywords = tool.keywords, keywords = tool.keywords,
categories = tool.categories?.map(ToolCategoryConverter::toolCategoryToToolCategoryVo), categories = tool.categories?.map(ToolCategoryConverter::toolCategoryToToolCategoryVo),
source = tool.source?.let(ToolDataConverter::toolDataToToolDataVo), source = tool.source?.let(ToolDataConverter::toolDataToToolDataVo),
dist = tool.dist?.let(ToolDataConverter::toolDataToToolDataVo), dist = tool.dist?.let(ToolDataConverter::toolDataToToolDataVo),
entryPoint = tool.entryPoint,
publish = tool.publish == 1, publish = tool.publish == 1,
review = tool.review, review = tool.review,
createTime = tool.createTime, createTime = tool.createTime,

View File

@@ -1,6 +1,8 @@
package top.fatweb.oxygen.api.converter.tool package top.fatweb.oxygen.api.converter.tool
import top.fatweb.oxygen.api.entity.tool.ToolTemplate import top.fatweb.oxygen.api.entity.tool.ToolTemplate
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
import top.fatweb.oxygen.api.vo.tool.ToolDataVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
/** /**
@@ -25,8 +27,59 @@ object ToolTemplateConverter {
name = toolTemplate.name, name = toolTemplate.name,
base = toolTemplate.base?.let(ToolBaseConverter::toolBaseToToolBaseVo), base = toolTemplate.base?.let(ToolBaseConverter::toolBaseToToolBaseVo),
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo), source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
entryPoint = toolTemplate.entryPoint,
enable = toolTemplate.enable == 1,
createTime = toolTemplate.createTime, createTime = toolTemplate.createTime,
updateTime = toolTemplate.updateTime, updateTime = toolTemplate.updateTime
enable = toolTemplate.enable == 1 )
/**
* Convert ToolTemplate object into ToolTemplateVo object by list
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun toolTemplateToToolTemplateVoByList(toolTemplate: ToolTemplate) = ToolTemplateVo(
id = toolTemplate.id,
name = toolTemplate.name,
base = ToolBaseVo(
id = toolTemplate.baseId,
name = null,
source = null,
dist = null,
compiled = null,
createTime = null,
updateTime = null
),
source = ToolDataVo(id = toolTemplate.sourceId, data = null, createTime = null, updateTime = null),
entryPoint = toolTemplate.entryPoint,
enable = toolTemplate.enable == 1,
createTime = toolTemplate.createTime,
updateTime = toolTemplate.updateTime
)
/**
* Convert ToolTemplate object into ToolTemplateVo object with base dist
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun toolTemplateToToolTemplateVoWithBaseDist(toolTemplate: ToolTemplate) = ToolTemplateVo(
id = toolTemplate.id,
name = toolTemplate.name,
base = ToolBaseVo(
id = toolTemplate.baseId,
name = toolTemplate.base?.name,
source = null,
dist = ToolDataVo(id = null, data = toolTemplate.base?.distData, createTime = null, updateTime = null),
compiled = null,
createTime = null,
updateTime = null
),
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
entryPoint = toolTemplate.entryPoint,
enable = toolTemplate.enable == 1,
createTime = toolTemplate.createTime,
updateTime = toolTemplate.updateTime
) )
} }

View File

@@ -2,7 +2,8 @@ package top.fatweb.oxygen.api.entity.tool
import com.baomidou.mybatisplus.annotation.* import com.baomidou.mybatisplus.annotation.*
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler
import top.fatweb.oxygen.api.entity.permission.UserInfo import com.fasterxml.jackson.annotation.JsonValue
import top.fatweb.oxygen.api.entity.permission.User
import java.time.LocalDateTime import java.time.LocalDateTime
/** /**
@@ -13,6 +14,16 @@ import java.time.LocalDateTime
*/ */
@TableName("t_b_tool_main", autoResultMap = true) @TableName("t_b_tool_main", autoResultMap = true)
class Tool { class Tool {
/**
* Tool review type enum
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
enum class ReviewType(@field:EnumValue @field:JsonValue val code: String) {
NONE("NONE"), PASS("PASS"), REJECT("REJECT")
}
/** /**
* ID * ID
* *
@@ -112,6 +123,15 @@ class Tool {
@TableField("dist_id") @TableField("dist_id")
var distId: Long? = null var distId: Long? = null
/**
* Entry point
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@TableField("entry_point")
var entryPoint: String? = null
/** /**
* Publish * Publish
* *
@@ -128,7 +148,7 @@ class Tool {
* @since 1.0.0 * @since 1.0.0
*/ */
@TableField("review") @TableField("review")
var review: Int? = null var review: ReviewType? = null
/** /**
* Create time * Create time
@@ -177,7 +197,16 @@ class Tool {
* @since 1.0.0 * @since 1.0.0
*/ */
@TableField(exist = false) @TableField(exist = false)
var author: UserInfo? = null var author: User? = null
/**
* Base
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@TableField(exist = false)
var base: ToolBase? = null
/** /**
* Categories * Categories
@@ -207,6 +236,6 @@ class Tool {
var dist: ToolData? = null var dist: ToolData? = null
override fun toString(): String { override fun toString(): String {
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)" return "Tool(id=$id, name=$name, toolId=$toolId, description=$description, baseId=$baseId, authorId=$authorId, ver=$ver, privately=$privately, keywords=$keywords, sourceId=$sourceId, distId=$distId, entryPoint=$entryPoint, publish=$publish, review=$review, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, author=$author, categories=$categories, source=$source, dist=$dist)"
} }
} }

View File

@@ -56,15 +56,6 @@ class ToolBase {
@TableField("compiled") @TableField("compiled")
var compiled: Int? = null var compiled: Int? = null
/**
* Enable
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@TableField("enable")
var enable: Int? = null
/** /**
* Create time * Create time
* *
@@ -123,7 +114,16 @@ class ToolBase {
@TableField(exist = false) @TableField(exist = false)
var dist: ToolData? = null var dist: ToolData? = null
/**
* Dist data
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@TableField(exist = false)
var distData: String? = null
override fun toString(): String { override fun toString(): String {
return "ToolBase(id=$id, name=$name, sourceId=$sourceId, distId=$distId, compiled=$compiled, enable=$enable, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, dist=$dist)" return "ToolBase(id=$id, name=$name, sourceId=$sourceId, distId=$distId, compiled=$compiled, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, dist=$dist, distData=$distData)"
} }
} }

View File

@@ -47,6 +47,15 @@ class ToolTemplate {
@TableField("source_id") @TableField("source_id")
var sourceId: Long? = null var sourceId: Long? = null
/**
* Entry point
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@TableField("entry_point")
var entryPoint: String? = null
/** /**
* Enable * Enable
* *
@@ -115,6 +124,6 @@ class ToolTemplate {
var base: ToolBase? = null var base: ToolBase? = null
override fun toString(): String { override fun toString(): String {
return "ToolTemplate(id=$id, name=$name, baseId=$baseId, sourceId=$sourceId, enable=$enable, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, base=$base)" return "ToolTemplate(id=$id, name=$name, baseId=$baseId, sourceId=$sourceId, entryPoint=$entryPoint, enable=$enable, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, base=$base)"
} }
} }

View File

@@ -0,0 +1,22 @@
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
import top.fatweb.oxygen.api.entity.tool.ToolTemplate
/**
* Tool edit mapper
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see BaseMapper
* @see Tool
*/
@Mapper
interface EditMapper : BaseMapper<Tool> {
fun getTemplate(@Param("id") id: Long): ToolTemplate?
fun selectOne(@Param("id") id: Long, @Param("userId") userId: Long): Tool?
}

View File

@@ -2,7 +2,6 @@ package top.fatweb.oxygen.api.mapper.tool
import com.baomidou.mybatisplus.core.mapper.BaseMapper import com.baomidou.mybatisplus.core.mapper.BaseMapper
import org.apache.ibatis.annotations.Mapper import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import top.fatweb.oxygen.api.entity.tool.Tool import top.fatweb.oxygen.api.entity.tool.Tool
/** /**
@@ -14,8 +13,4 @@ import top.fatweb.oxygen.api.entity.tool.Tool
* @see Tool * @see Tool
*/ */
@Mapper @Mapper
interface ToolMapper : BaseMapper<Tool> { interface ToolMapper : BaseMapper<Tool>
fun selectOne(@Param("id") id: Long): Tool?
fun selectList(): List<Tool>
}

View File

@@ -1,44 +0,0 @@
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 '<number>.<number>.<number>'")
val ver: String?,
val privately: Boolean = false,
@field: NotEmpty(message = "Keywords can not be empty")
val keywords: List<String>,
@field: NotEmpty(message = "Categories can not be empty")
val categories: List<Long>,
@field: NotNull(message = "Source can not be null")
val source: String?,
@field:NotNull(message = "Dist can not be null")
val dist: String?
)

View File

@@ -18,14 +18,5 @@ data class ToolBaseAddParam(
*/ */
@Schema(description = "名称", required = true) @Schema(description = "名称", required = true)
@field: NotBlank(message = "Name can not be blank") @field: NotBlank(message = "Name can not be blank")
val name: String?, val name: String?
/**
* Enable
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean = true
) )

View File

@@ -45,14 +45,5 @@ data class ToolBaseUpdateParam(
* @since 1.0.0 * @since 1.0.0
*/ */
@Schema(description = "产物") @Schema(description = "产物")
val dist: String?, val dist: String?
/**
* Enable
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "启用", allowableValues = ["true", "false"])
val enable: Boolean?
) )

View File

@@ -0,0 +1,99 @@
package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotEmpty
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Pattern
/**
* Create tool parameters
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "创建工具请求参数")
data class ToolCreateParam(
/**
* 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?,
/**
* Tool ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "工具唯一 ID", required = true, example = "tool_a")
@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?,
/**
* Description
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "简介")
val description: String?,
/**
* Version
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "版本", required = true, example = "1.0.3")
@field: NotBlank(message = "Ver can not be blank")
@field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '<number>.<number>.<number>'")
val ver: String?,
/**
* Template ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "模板 ID", required = true)
@field: NotNull(message = "TemplateId can not be null")
val templateId: Long?,
/**
* Privately
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "私有", allowableValues = ["true", "false"], defaultValue = "false")
val privately: Boolean = false,
/**
* Keywords
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "关键词", required = true)
@field: NotEmpty(message = "Keywords can not be empty")
val keywords: List<String>,
/**
* Categories
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "类别", required = true)
@field: NotEmpty(message = "Categories can not be empty")
val categories: List<Long>
)

View File

@@ -31,6 +31,16 @@ data class ToolTemplateAddParam(
@field: NotNull(message = "BaseId can not be null") @field: NotNull(message = "BaseId can not be null")
val baseId: Long? = null, val baseId: Long? = null,
/**
* Entry point
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "入口文件", required = true)
@field:NotBlank(message = "EntryPoint can not be null")
val entryPoint: String? = null,
/** /**
* Enable * Enable
* *

View File

@@ -47,6 +47,15 @@ data class ToolTemplateUpdateParam(
@Schema(description = "源码") @Schema(description = "源码")
val source: String?, val source: String?,
/**
* Entry point
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "入口文件")
val entryPoint: String?,
/** /**
* Enable * Enable
* *

View File

@@ -1,34 +1,118 @@
package top.fatweb.oxygen.api.param.tool package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Pattern import jakarta.validation.constraints.Pattern
/**
* Update tool parameters
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
data class ToolUpdateParam( data class ToolUpdateParam(
/**
* ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "ID", required = true)
@field: NotNull(message = "ID can not be null") @field: NotNull(message = "ID can not be null")
val id: Long?, val id: Long?,
/**
* Name
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "名称")
val name: String?, val name: String?,
/**
* Tool ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "工具唯一 ID", example = "tool_a")
@field: Pattern( @field: Pattern(
regexp = "^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$", regexp = "^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$",
message = "Ver can only match '^[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 toolId: String?,
/**
* Description
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "简介")
val description: String?, val description: String?,
/**
* Author ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "作者 ID")
val authorId: Long?, val authorId: Long?,
/**
* Version
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "版本", example = "1.0.3")
@field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '<number>.<number>.<number>'") @field: Pattern(regexp = "^\\d+\\.\\d+\\.\\d+\$", message = "Ver can only match '<number>.<number>.<number>'")
val ver: String?, val ver: String?,
/**
* Privately
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "私有", allowableValues = ["true", "false"])
val privately: Boolean?, val privately: Boolean?,
/**
* Keywords
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "关键词")
val keywords: List<String>, val keywords: List<String>,
/**
* Categories
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "类别")
val categories: List<Long>, val categories: List<Long>,
/**
* Source
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "源码")
val source: String?, val source: String?,
/**
* Dist
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "产物")
val dist: String? val dist: String?
) )

View File

@@ -0,0 +1,74 @@
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.ToolCreateParam
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam
import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
import top.fatweb.oxygen.api.vo.tool.ToolVo
/**
* Tool edit service interface
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see IService
* @see Tool
*/
interface IEditService : IService<Tool> {
/**
* Get tool template as list
*
* @return List of ToolTemplateVo object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolTemplateVo
*/
fun getTemplate(): List<ToolTemplateVo>
/**
* Get tool template by ID
*
* @param id ID
* @return ToolTemplateVo object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolTemplateVo
*/
fun getTemplate(id: Long): ToolTemplateVo
/**
* Get tool category as list
*
* @return List of ToolCategoryVo object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolCategoryVo
*/
fun getCategory(): List<ToolCategoryVo>
/**
* Get tool by ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun getOne(id: Long): ToolVo
/**
* Create tool
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun create(toolCreateParam: ToolCreateParam): ToolVo
/**
* Update tool
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun update(toolUpdateParam: ToolUpdateParam): ToolVo
}

View File

@@ -2,9 +2,6 @@ package top.fatweb.oxygen.api.service.tool
import com.baomidou.mybatisplus.extension.service.IService import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.oxygen.api.entity.tool.Tool 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 * Tool service interface
@@ -14,14 +11,4 @@ import top.fatweb.oxygen.api.vo.tool.ToolVo
* @see IService * @see IService
* @see Tool * @see Tool
*/ */
interface IToolService : IService<Tool> { interface IToolService : IService<Tool>
fun getOne(id: Long): ToolVo
fun get(): List<ToolVo>
fun add(toolAddParam: ToolAddParam): ToolVo
fun update(toolUpdateParam: ToolUpdateParam): ToolVo
fun delete(id: Long): Boolean
}

View File

@@ -0,0 +1,92 @@
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.ToolCategoryConverter
import top.fatweb.oxygen.api.converter.tool.ToolConverter
import top.fatweb.oxygen.api.converter.tool.ToolTemplateConverter
import top.fatweb.oxygen.api.entity.tool.*
import top.fatweb.oxygen.api.exception.NoRecordFoundException
import top.fatweb.oxygen.api.exception.UserNotFoundException
import top.fatweb.oxygen.api.mapper.tool.EditMapper
import top.fatweb.oxygen.api.param.tool.ToolCreateParam
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam
import top.fatweb.oxygen.api.service.tool.*
import top.fatweb.oxygen.api.util.WebUtil
import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
import top.fatweb.oxygen.api.vo.tool.ToolVo
/**
* Tool edit service implement
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ServiceImpl
* @see EditMapper
* @see Tool
* @see IEditService
*/
@Service
class EditServiceImpl(
private val toolTemplateService: IToolTemplateService,
private val toolCategoryService: IToolCategoryService,
private val toolDataService: IToolDataService,
private val rToolCategoryService: IRToolCategoryService
) : ServiceImpl<EditMapper, Tool>(), IEditService {
override fun getTemplate(): List<ToolTemplateVo> =
toolTemplateService.list(KtQueryWrapper(ToolTemplate()).eq(ToolTemplate::enable, 1))
.map(ToolTemplateConverter::toolTemplateToToolTemplateVoByList)
override fun getTemplate(id: Long): ToolTemplateVo =
baseMapper.getTemplate(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVoWithBaseDist)
?: throw NoRecordFoundException()
override fun getCategory(): List<ToolCategoryVo> =
toolCategoryService.list(KtQueryWrapper(ToolCategory()).eq(ToolCategory::enable, 1))
.map(ToolCategoryConverter::toolCategoryToToolCategoryVo)
override fun getOne(id: Long): ToolVo =
baseMapper.selectOne(id, WebUtil.getLoginUserId() ?: throw UserNotFoundException())
?.let(ToolConverter::toolToToolVo) ?: throw NoRecordFoundException()
@Transactional
override fun create(toolCreateParam: ToolCreateParam): ToolVo {
val template = this.getTemplate(toolCreateParam.templateId!!)
val newSource = ToolData().apply { data = template.source!!.data }
val newDist = ToolData().apply { data = "" }
toolDataService.saveBatch(listOf(newSource, newDist))
val tool = Tool().apply {
name = toolCreateParam.name!!.trim()
toolId = toolCreateParam.toolId
description = toolCreateParam.description
baseId = template.base!!.id
authorId = WebUtil.getLoginUserId() ?: throw UserNotFoundException()
ver = toolCreateParam.ver!!.split(".").map(String::toLong).joinToString(".")
privately = if (toolCreateParam.privately) 1 else 0
keywords = toolCreateParam.keywords
sourceId = newSource.id
distId = newDist.id
}
this.save(tool)
toolCreateParam.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 {
TODO("Not yet implemented")
}
}

View File

@@ -38,8 +38,7 @@ class ToolBaseServiceImpl(
val newSource = ToolData().apply { data = "" } val newSource = ToolData().apply { data = "" }
val newDist = ToolData().apply { data = "" } val newDist = ToolData().apply { data = "" }
toolDataService.save(newSource) toolDataService.saveBatch(listOf(newSource, newDist))
toolDataService.save(newDist)
val toolBase = ToolBase().apply { val toolBase = ToolBase().apply {
name = toolBaseAddParam.name name = toolBaseAddParam.name
@@ -47,7 +46,6 @@ class ToolBaseServiceImpl(
distId = newDist.id distId = newDist.id
source = newSource source = newSource
dist = newDist dist = newDist
enable = if (toolBaseAddParam.enable) 1 else 0
} }
this.save(toolBase) this.save(toolBase)
@@ -81,7 +79,6 @@ class ToolBaseServiceImpl(
id = toolBaseUpdateParam.id id = toolBaseUpdateParam.id
name = toolBaseUpdateParam.name name = toolBaseUpdateParam.name
compiled = hasCompiled compiled = hasCompiled
enable = toolBaseUpdateParam.enable?.let { if (it) 1 else 0 }
}) })
return this.getOne(toolBase.id!!) return this.getOne(toolBase.id!!)

View File

@@ -1,21 +1,10 @@
package top.fatweb.oxygen.api.service.tool.impl package top.fatweb.oxygen.api.service.tool.impl
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service 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.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.mapper.tool.ToolMapper import top.fatweb.oxygen.api.mapper.tool.ToolMapper
import top.fatweb.oxygen.api.param.tool.ToolAddParam import top.fatweb.oxygen.api.service.tool.IToolService
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 * Tool service implement
@@ -28,55 +17,13 @@ import top.fatweb.oxygen.api.vo.tool.ToolVo
* @see IToolService * @see IToolService
*/ */
@Service @Service
class ToolServiceImpl( class ToolServiceImpl : ServiceImpl<ToolMapper, Tool>(), IToolService {
private val toolDataService: IToolDataService, /*
private val toolBaseService: IToolBaseService,
private val toolCategoryService: IToolCategoryService,
private val rToolCategoryService: IRToolCategoryService,
private val userService: IUserService
) : ServiceImpl<ToolMapper, Tool>(), IToolService {
override fun getOne(id: Long): ToolVo = override fun getOne(id: Long): ToolVo =
baseMapper.selectOne(id)?.let(ToolConverter::toolToToolVo) ?: throw NoRecordFoundException() baseMapper.selectOne(id)?.let(ToolConverter::toolToToolVo) ?: throw NoRecordFoundException()
override fun get(): List<ToolVo> = baseMapper.selectList().map(ToolConverter::toolToToolVo) override fun get(): List<ToolVo> = baseMapper.selectList().map(ToolConverter::toolToToolVo)
@Transactional
override fun add(toolAddParam: ToolAddParam): ToolVo {
toolBaseService.getOne(toolAddParam.baseId!!)
userService.getOne(toolAddParam.authorId!!)
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 @Transactional
override fun update(toolUpdateParam: ToolUpdateParam): ToolVo { override fun update(toolUpdateParam: ToolUpdateParam): ToolVo {
val tool = baseMapper.selectOne(toolUpdateParam.id!!) ?: throw NoRecordFoundException() val tool = baseMapper.selectOne(toolUpdateParam.id!!) ?: throw NoRecordFoundException()
@@ -119,4 +66,5 @@ class ToolServiceImpl(
&& rToolCategoryService.remove(KtQueryWrapper(RToolCategory()).eq(RToolCategory::toolId, tool.id)) && rToolCategoryService.remove(KtQueryWrapper(RToolCategory()).eq(RToolCategory::toolId, tool.id))
&& this.removeById(tool.id) && this.removeById(tool.id)
} }
*/
} }

View File

@@ -50,6 +50,7 @@ class ToolTemplateServiceImpl(
baseId = toolTemplateAddParam.baseId baseId = toolTemplateAddParam.baseId
sourceId = newSource.id sourceId = newSource.id
source = newSource source = newSource
entryPoint = toolTemplateAddParam.entryPoint
enable = if (toolTemplateAddParam.enable) 1 else 0 enable = if (toolTemplateAddParam.enable) 1 else 0
} }
@@ -72,6 +73,7 @@ class ToolTemplateServiceImpl(
id = toolTemplateUpdateParam.id id = toolTemplateUpdateParam.id
name = toolTemplateUpdateParam.name name = toolTemplateUpdateParam.name
baseId = toolTemplateUpdateParam.baseId baseId = toolTemplateUpdateParam.baseId
entryPoint = toolTemplateUpdateParam.entryPoint
enable = toolTemplateUpdateParam.enable?.let { if (it) 1 else 0 } enable = toolTemplateUpdateParam.enable?.let { if (it) 1 else 0 }
}) })

View File

@@ -58,15 +58,6 @@ data class ToolBaseVo(
@Schema(description = "已编译") @Schema(description = "已编译")
val compiled: Boolean?, val compiled: Boolean?,
/**
* Enable
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "启用")
val enable: Boolean?,
/** /**
* Create time * Create time
* *

View File

@@ -49,6 +49,15 @@ data class ToolTemplateVo(
@Schema(description = "源码") @Schema(description = "源码")
val source: ToolDataVo?, val source: ToolDataVo?,
/**
* Entry point
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "入口文件")
val entryPoint: String?,
/** /**
* Enable * Enable
* *

View File

@@ -2,41 +2,176 @@ package top.fatweb.oxygen.api.vo.tool
import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
import top.fatweb.oxygen.api.vo.permission.base.UserInfoVo import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.oxygen.api.entity.tool.Tool
import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo
import java.time.LocalDateTime import java.time.LocalDateTime
data class ToolVo ( /**
* Tool value object
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
data class ToolVo(
/**
* ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@JsonSerialize(using = ToStringSerializer::class) @JsonSerialize(using = ToStringSerializer::class)
val id: Long?, val id: Long?,
/**
* Name
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "名称")
val name: String?, val name: String?,
/**
* Tool ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "工具 ID")
val toolId: String?, val toolId: String?,
/**
* Description
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "简介")
val description: String?, val description: String?,
/**
* Base ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@JsonSerialize(using = ToStringSerializer::class) @JsonSerialize(using = ToStringSerializer::class)
@Schema(description = "基板 ID")
val baseId: Long?, val baseId: Long?,
val author: UserInfoVo?, /**
* Author
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see UserWithInfoVo
*/
@Schema(description = "作者")
val author: UserWithInfoVo?,
/**
* Version
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "版本")
val ver: String?, val ver: String?,
/**
* Privately
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "私有")
val privately: Boolean?, val privately: Boolean?,
/**
* Keywords
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "关键字")
val keywords: List<String>?, val keywords: List<String>?,
/**
* Categories
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolCategoryVo
*/
@Schema(description = "类别")
val categories: List<ToolCategoryVo>?, val categories: List<ToolCategoryVo>?,
/**
* Source
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolDataVo
*/
@Schema(description = "源码")
val source: ToolDataVo?, val source: ToolDataVo?,
/**
* Dist
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolDataVo
*/
@Schema(description = "产物")
val dist: ToolDataVo?, val dist: ToolDataVo?,
/**
* Entry point
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "入口文件")
val entryPoint: String?,
/**
* Publish
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "发布")
val publish: Boolean?, val publish: Boolean?,
val review: Int?, /**
* Review
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see Tool.ReviewType
*/
@Schema(description = "审核")
val review: Tool.ReviewType?,
/**
* 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?, 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? val updateTime: LocalDateTime?
) )

View File

@@ -13,6 +13,7 @@ create table if not exists t_b_tool_main
keywords varchar(500) not null comment '关键字', keywords varchar(500) not null comment '关键字',
source_id bigint not null comment '源码 ID', source_id bigint not null comment '源码 ID',
dist_id bigint not null comment '产物 ID', dist_id bigint not null comment '产物 ID',
entry_point varchar(64) not null default 'main.tsx' comment '入口文件',
publish int not null default 0 comment '发布', publish int not null default 0 comment '发布',
review varchar(10) not null default 'NONE' comment '审核', review varchar(10) not null default 'NONE' comment '审核',
create_time datetime not null default (utc_timestamp()) comment '创建时间', create_time datetime not null default (utc_timestamp()) comment '创建时间',

View File

@@ -6,6 +6,7 @@ create table if not exists t_b_tool_template
name varchar(40) not null comment '模板名', name varchar(40) not null comment '模板名',
base_id bigint not null comment '基板 ID', base_id bigint not null comment '基板 ID',
source_id bigint not null comment '源码 ID', source_id bigint not null comment '源码 ID',
entry_point varchar(64) not null default 'main.tsx' comment '入口文件',
enable int not null default 1 comment '启用', enable int not null default 1 comment '启用',
create_time datetime not null default (utc_timestamp()) comment '创建时间', create_time datetime not null default (utc_timestamp()) comment '创建时间',
update_time datetime not null default (utc_timestamp()) comment '修改时间', update_time datetime not null default (utc_timestamp()) comment '修改时间',

View File

@@ -7,7 +7,6 @@ create table if not exists t_b_tool_base
source_id bigint not null comment '源码 ID', source_id bigint not null comment '源码 ID',
dist_id bigint not null comment '产物 ID', dist_id bigint not null comment '产物 ID',
compiled int not null default 0 comment '已编译', compiled int not null default 0 comment '已编译',
enable int not null default 1 comment '启用',
create_time datetime not null default (utc_timestamp()) comment '创建时间', create_time datetime not null default (utc_timestamp()) comment '创建时间',
update_time datetime not null default (utc_timestamp()) comment '修改时间', update_time datetime not null default (utc_timestamp()) comment '修改时间',
deleted bigint not null default 0, deleted bigint not null default 0,

View File

@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.oxygen.api.mapper.tool.EditMapper">
<select id="getTemplate" resultMap="toolTemplateWithBaseDataMap">
select t_b_tool_template.id as tool_template_id,
t_b_tool_template.name as tool_template_name,
t_b_tool_template.base_id as tool_template_base_id,
t_b_tool_template.source_id as tool_template_source_id,
t_b_tool_template.entry_point as tool_template_entry_point,
t_b_tool_template.enable as tool_template_enable,
t_b_tool_template.create_time as tool_template_create_time,
t_b_tool_template.update_time as tool_template_update_time,
t_b_tool_template.deleted as tool_template_deleted,
t_b_tool_template.version as tool_template_version,
tbtds.data as tool_template_source_data,
tbtds.create_time as tool_template_source_create_time,
tbtds.update_time as tool_template_source_update_time,
tbtds.deleted as tool_template_source_delete,
tbtds.version as tool_template_source_version,
tbtb.name as tool_template_base_name,
tbtbd.data as tool_template_base_dist_data
from t_b_tool_template
left join (select * from t_b_tool_data where deleted = 0) as tbtds
on tbtds.id = t_b_tool_template.source_id
left join (select * from t_b_tool_base where deleted = 0) as tbtb
on tbtb.id = t_b_tool_template.base_id
left join (select * from t_b_tool_data where deleted = 0) as tbtbd
on tbtbd.id = tbtb.dist_id
where t_b_tool_template.deleted = 0
and t_b_tool_template.id = #{id}
</select>
<select id="selectOne" resultMap="toolMap">
select t_b_tool_main.id as tool_id,
t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id,
t_b_tool_main.ver as tool_ver,
t_b_tool_main.privately as tool_privately,
t_b_tool_main.keywords as tool_keywords,
t_b_tool_main.source_id as tool_source_id,
t_b_tool_main.dist_id as tool_dist_id,
t_b_tool_main.entry_point as tool_entry_point,
t_b_tool_main.publish as tool_publish,
t_b_tool_main.review as tool_review,
t_b_tool_main.create_time as tool_create_time,
t_b_tool_main.update_time as tool_update_time,
t_b_tool_main.deleted as tool_deleted,
t_b_tool_main.version as tool_version,
tsu.id as user_id,
tsu.username as user_username,
tsui.id as user_info_id,
tsui.nickname as user_info_nickname,
tsui.avatar as user_info_avatar,
tsui.email as user_info_email,
tbtb.name as tool_base_name,
tbtb.dist_id as tool_base_dist_id,
tbtbd.data as tool_base_dist_data,
tbts.data as tool_source_data,
tbts.create_time as tool_source_create_time,
tbts.update_time as tool_source_update_time,
tbts.deleted as tool_source_deleted,
tbts.version as tool_source_version,
tbtd.data as tool_dist_data,
tbtd.create_time as tool_dist_create_time,
tbtd.update_time as tool_dist_update_time,
tbtd.deleted as tool_dist_deleted,
tbtd.version as tool_dist_version,
tbtc.id as tool_category_id,
tbtc.name as tool_category_name,
tbtc.enable as tool_category_enable,
tbtc.create_time as tool_category_create_time,
tbtc.update_time as tool_category_update_time,
tbtc.deleted as tool_category_deleted,
tbtc.version as tool_category_version
from t_b_tool_main
left join (select * from t_s_user where deleted = 0) as tsu on tsu.id = t_b_tool_main.author_id
left join (select * from t_s_user_info where deleted = 0) as tsui
on tsui.user_id = t_b_tool_main.author_id
left join (select * from t_b_tool_base where deleted = 0) as tbtb on tbtb.id = t_b_tool_main.base_id
left join (select * from t_b_tool_data where deleted = 0) as tbtbd on tbtbd.id = tbtb.dist_id
left join (select * from t_b_tool_data where deleted = 0) as tbts on tbts.id = t_b_tool_main.source_id
left join (select * from t_b_tool_data where deleted = 0) as tbtd on tbtd.id = t_b_tool_main.dist_id
left join (select * from t_r_tool_main_category where deleted = 0) as trtmc
on t_b_tool_main.id = trtmc.tool_id
left join (select * from t_b_tool_category where deleted = 0 and enable = 1) as tbtc
on tbtc.id = trtmc.category_id
where t_b_tool_main.deleted = 0
and t_b_tool_main.author_id = #{userId}
and t_b_tool_main.id = #{id}
</select>
<resultMap id="toolTemplateWithBaseDataMap" type="toolTemplate" extends="top.fatweb.oxygen.api.mapper.tool.ToolTemplateMapper.toolTemplateWithDataMap">
<association property="base">
<id property="id" column="tool_template_base_id"/>
<result property="name" column="tool_template_base_name"/>
<result property="distData" column="tool_template_base_dist_data"/>
</association>
</resultMap>
<resultMap id="toolMap" type="tool">
<id property="id" column="tool_id"/>
<result property="name" column="tool_name"/>
<result property="toolId" column="tool_tool_id"/>
<result property="description" column="tool_description"/>
<result property="baseId" column="tool_base_id"/>
<result property="authorId" column="tool_author_id"/>
<result property="ver" column="tool_ver"/>
<result property="privately" column="tool_privately"/>
<result property="sourceId" column="tool_source_id"/>
<result property="distId" column="tool_dist_id"/>
<result property="entryPoint" column="tool_entry_point"/>
<result property="publish" column="tool_publish"/>
<result property="review" column="tool_review"/>
<result property="updateTime" column="tool_update_time"/>
<result property="createTime" column="tool_create_time"/>
<result property="deleted" column="tool_deleted"/>
<result property="version" column="tool_version"/>
<association property="author" resultMap="top.fatweb.oxygen.api.mapper.permission.UserMapper.userWithInfoMap"/>
<association property="base" resultMap="top.fatweb.oxygen.api.mapper.tool.ToolBaseMapper.toolBaseWithDataMap"/>
<association property="source">
<id property="id" column="tool_source_id"/>
<result property="data" column="tool_source_data"/>
<result property="createTime" column="tool_source_create_time"/>
<result property="updateTime" column="tool_source_update_time"/>
<result property="deleted" column="tool_source_deleted"/>
<result property="version" column="tool_source_version"/>
</association>
<association property="dist">
<id property="id" column="tool_dist_id"/>
<result property="data" column="tool_dist_data"/>
<result property="createTime" column="tool_dist_create_time"/>
<result property="updateTime" column="tool_dist_update_time"/>
<result property="deleted" column="tool_dist_deleted"/>
<result property="version" column="tool_dist_version"/>
</association>
<collection property="keywords" ofType="string" column="tool_keywords"/>
<collection property="categories" resultMap="top.fatweb.oxygen.api.mapper.tool.ToolCategoryMapper.toolCategoryMap"/>
</resultMap>
</mapper>

View File

@@ -7,7 +7,6 @@
t_b_tool_base.source_id as tool_base_source_id, t_b_tool_base.source_id as tool_base_source_id,
t_b_tool_base.dist_id as tool_base_dist_id, t_b_tool_base.dist_id as tool_base_dist_id,
t_b_tool_base.compiled as tool_base_compiled, t_b_tool_base.compiled as tool_base_compiled,
t_b_tool_base.enable as tool_base_enable,
t_b_tool_base.create_time as tool_base_create_time, t_b_tool_base.create_time as tool_base_create_time,
t_b_tool_base.update_time as tool_base_update_time, t_b_tool_base.update_time as tool_base_update_time,
t_b_tool_base.deleted as tool_base_deleted, t_b_tool_base.deleted as tool_base_deleted,
@@ -36,7 +35,6 @@
<result property="sourceId" column="tool_base_source_id"/> <result property="sourceId" column="tool_base_source_id"/>
<result property="distId" column="tool_base_dist_id"/> <result property="distId" column="tool_base_dist_id"/>
<result property="compiled" column="tool_base_compiled"/> <result property="compiled" column="tool_base_compiled"/>
<result property="enable" column="tool_base_enable"/>
<result property="createTime" column="tool_base_create_time"/> <result property="createTime" column="tool_base_create_time"/>
<result property="updateTime" column="tool_base_update_time"/> <result property="updateTime" column="tool_base_update_time"/>
<result property="deleted" column="tool_base_deleted"/> <result property="deleted" column="tool_base_deleted"/>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.oxygen.api.mapper.tool.ToolCategoryMapper">
<resultMap id="toolCategoryMap" type="toolCategory">
<id property="id" column="tool_category_id"/>
<result property="name" column="tool_category_name"/>
<result property="enable" column="tool_category_enable"/>
<result property="createTime" column="tool_category_create_time"/>
<result property="updateTime" column="tool_category_update_time"/>
<result property="deleted" column="tool_category_deleted"/>
<result property="version" column="tool_category_version"/>
</resultMap>
</mapper>

View File

@@ -6,6 +6,7 @@
t_b_tool_template.name as tool_template_name, t_b_tool_template.name as tool_template_name,
t_b_tool_template.base_id as tool_template_base_id, t_b_tool_template.base_id as tool_template_base_id,
t_b_tool_template.source_id as tool_template_source_id, t_b_tool_template.source_id as tool_template_source_id,
t_b_tool_template.entry_point as tool_template_entry_point,
t_b_tool_template.enable as tool_template_enable, t_b_tool_template.enable as tool_template_enable,
t_b_tool_template.create_time as tool_template_create_time, t_b_tool_template.create_time as tool_template_create_time,
t_b_tool_template.update_time as tool_template_update_time, t_b_tool_template.update_time as tool_template_update_time,
@@ -16,8 +17,7 @@
tbtds.update_time as tool_template_source_update_time, tbtds.update_time as tool_template_source_update_time,
tbtds.deleted as tool_template_source_delete, tbtds.deleted as tool_template_source_delete,
tbtds.version as tool_template_source_version, tbtds.version as tool_template_source_version,
tbtb.name as tool_template_base_name, tbtb.name as tool_template_base_name
tbtb.enable as tool_template_base_enable
from t_b_tool_template from t_b_tool_template
left join (select * from t_b_tool_data where deleted = 0) as tbtds left join (select * from t_b_tool_data where deleted = 0) as tbtds
on tbtds.id = t_b_tool_template.source_id on tbtds.id = t_b_tool_template.source_id
@@ -32,13 +32,13 @@
t_b_tool_template.name as tool_template_name, t_b_tool_template.name as tool_template_name,
t_b_tool_template.base_id as tool_template_base_id, t_b_tool_template.base_id as tool_template_base_id,
t_b_tool_template.source_id as tool_template_source_id, t_b_tool_template.source_id as tool_template_source_id,
t_b_tool_template.entry_point as tool_template_entry_point,
t_b_tool_template.enable as tool_template_enable, t_b_tool_template.enable as tool_template_enable,
t_b_tool_template.create_time as tool_template_create_time, t_b_tool_template.create_time as tool_template_create_time,
t_b_tool_template.update_time as tool_template_update_time, t_b_tool_template.update_time as tool_template_update_time,
t_b_tool_template.deleted as tool_template_deleted, t_b_tool_template.deleted as tool_template_deleted,
t_b_tool_template.version as tool_template_version, t_b_tool_template.version as tool_template_version,
tbtb.name as tool_template_base_name, tbtb.name as tool_template_base_name
tbtb.enable as tool_template_base_enable
from t_b_tool_template from t_b_tool_template
left join (select * from t_b_tool_base where deleted = 0) as tbtb left join (select * from t_b_tool_base where deleted = 0) as tbtb
on tbtb.id = t_b_tool_template.base_id on tbtb.id = t_b_tool_template.base_id
@@ -50,6 +50,7 @@
<result property="name" column="tool_template_name"/> <result property="name" column="tool_template_name"/>
<result property="baseId" column="tool_template_base_id"/> <result property="baseId" column="tool_template_base_id"/>
<result property="sourceId" column="tool_template_source_id"/> <result property="sourceId" column="tool_template_source_id"/>
<result property="entryPoint" column="tool_template_entry_point"/>
<result property="enable" column="tool_template_enable"/> <result property="enable" column="tool_template_enable"/>
<result property="createTime" column="tool_template_create_time"/> <result property="createTime" column="tool_template_create_time"/>
<result property="updateTime" column="tool_template_update_time"/> <result property="updateTime" column="tool_template_update_time"/>
@@ -58,7 +59,6 @@
<association property="base"> <association property="base">
<id property="id" column="tool_template_base_id"/> <id property="id" column="tool_template_base_id"/>
<result property="name" column="tool_template_base_name"/> <result property="name" column="tool_template_base_name"/>
<result property="enable" column="tool_template_base_enable"/>
</association> </association>
</resultMap> </resultMap>