From 3dc935a98a2eaadb78827aadffa518a1d3ec00ca Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Fri, 26 Jan 2024 17:31:26 +0800 Subject: [PATCH] Add icon and publish time to tool --- .../api/converter/tool/ToolConverter.kt | 2 + .../top/fatweb/oxygen/api/entity/tool/Tool.kt | 22 ++++- .../oxygen/api/param/tool/ToolCreateParam.kt | 10 ++ .../api/service/tool/impl/EditServiceImpl.kt | 1 + .../top/fatweb/oxygen/api/vo/tool/ToolVo.kt | 19 ++++ ..._0_0_240115__Add_table_'t_b_tool_main'.sql | 38 ++++---- src/main/resources/mapper/tool/EditMapper.xml | 92 ++++++++++--------- 7 files changed, 121 insertions(+), 63 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt index 83f2069..bed4354 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt @@ -25,6 +25,7 @@ object ToolConverter { id = tool.id, name = tool.name, toolId = tool.toolId, + icon = tool.icon, description = tool.description, baseId = tool.baseId, author = tool.author?.let(UserConverter::userToUserWithInfoVo), @@ -37,6 +38,7 @@ object ToolConverter { entryPoint = tool.entryPoint, publish = tool.publish == 1, review = tool.review, + publishTime = tool.publishTime, createTime = tool.createTime, updateTime = tool.updateTime ) 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 9c04a29..7c61490 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 @@ -51,6 +51,15 @@ class Tool { @TableField("tool_id") var toolId: String? = null + /** + * Icon + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @TableField("icon") + var icon: String? = null + /** * Description * @@ -146,10 +155,21 @@ class Tool { * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 + * @see ReviewType */ @TableField("review") var review: ReviewType? = null + /** + * Publish time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @TableField("publish_time") + var publishTime: LocalDateTime? = null + /** * Create time * @@ -236,6 +256,6 @@ class Tool { var dist: ToolData? = null 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, entryPoint=$entryPoint, 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, icon=$icon, description=$description, baseId=$baseId, authorId=$authorId, ver=$ver, privately=$privately, keywords=$keywords, sourceId=$sourceId, distId=$distId, entryPoint=$entryPoint, publish=$publish, review=$review, publishTime=$publishTime, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, author=$author, base=$base, categories=$categories, source=$source, dist=$dist)" } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt index 01d1159..1955b93 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt @@ -38,6 +38,16 @@ data class ToolCreateParam( ) val toolId: String?, + /** + * Icon + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "图标", required = true) + @field: NotBlank(message = "Icon can not be blank") + val icon: String?, + /** * Description * diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt index 6bfc39a..434abf8 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt @@ -62,6 +62,7 @@ class EditServiceImpl( val tool = Tool().apply { name = toolCreateParam.name!!.trim() toolId = toolCreateParam.toolId + icon = toolCreateParam.icon description = toolCreateParam.description baseId = template.base!!.id authorId = WebUtil.getLoginUserId() ?: throw UserNotFoundException() 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 index fe30113..8569307 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt @@ -41,6 +41,15 @@ data class ToolVo( @Schema(description = "工具 ID") val toolId: String?, + /** + * Icon + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Schema(description = "图标") + val icon: String?, + /** * Description * @@ -155,6 +164,16 @@ data class ToolVo( @Schema(description = "审核") val review: Tool.ReviewType?, + /** + * Publish time + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LocalDateTime + */ + @Schema(description = "发布时间", example = "1900-01-01T00:00:00.000Z") + val publishTime: LocalDateTime?, + /** * Create time * 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 9b24ce1..39ba7c4 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 @@ -2,23 +2,25 @@ drop table if exists t_b_tool_main; create table if not exists t_b_tool_main ( - id bigint not null primary key, - name varchar(50) not null comment '工具名', - tool_id varchar(50) not null comment '工具 ID', - description varchar(500) 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 '私有', - keywords varchar(500) not null comment '关键字', - source_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 '发布', - 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, + id bigint not null primary key, + name varchar(50) not null comment '工具名', + tool_id varchar(50) not null comment '工具 ID', + icon text not null comment '图标', + description varchar(500) 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 '私有', + keywords varchar(500) not null comment '关键字', + source_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 '发布', + review varchar(10) not null default 'NONE' comment '审核', + publish_time datetime 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, constraint t_b_tool_main_unique_tool_id unique (tool_id, author_id, ver, deleted) ) comment '工具-主表'; \ No newline at end of file diff --git a/src/main/resources/mapper/tool/EditMapper.xml b/src/main/resources/mapper/tool/EditMapper.xml index f3dd370..f3f1c9f 100644 --- a/src/main/resources/mapper/tool/EditMapper.xml +++ b/src/main/resources/mapper/tool/EditMapper.xml @@ -31,50 +31,52 @@