Optimize ToolBase api
This commit is contained in:
@@ -10,6 +10,7 @@ object ToolBaseConverter {
|
|||||||
name = toolBase.name,
|
name = toolBase.name,
|
||||||
source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||||
dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo),
|
dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||||
|
compiled = toolBase.compiled == 1,
|
||||||
createTime = toolBase.createTime,
|
createTime = toolBase.createTime,
|
||||||
updateTime = toolBase.updateTime,
|
updateTime = toolBase.updateTime,
|
||||||
enable = toolBase.enable == 1
|
enable = toolBase.enable == 1
|
||||||
@@ -20,6 +21,7 @@ object ToolBaseConverter {
|
|||||||
name = toolBase.name,
|
name = toolBase.name,
|
||||||
source = ToolDataVo(id = toolBase.sourceId, data = null, createTime = null, updateTime = null),
|
source = ToolDataVo(id = toolBase.sourceId, data = null, createTime = null, updateTime = null),
|
||||||
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,
|
||||||
createTime = toolBase.createTime,
|
createTime = toolBase.createTime,
|
||||||
updateTime = toolBase.updateTime,
|
updateTime = toolBase.updateTime,
|
||||||
enable = toolBase.enable == 1
|
enable = toolBase.enable == 1
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ class ToolBase {
|
|||||||
@TableField("dist_id")
|
@TableField("dist_id")
|
||||||
var distId: Long? = null
|
var distId: Long? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has compiled
|
||||||
|
*
|
||||||
|
* @author FatttSnake, fatttsnake@gmail.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@TableField("compiled")
|
||||||
|
var compiled: Int? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable
|
* Enable
|
||||||
*
|
*
|
||||||
@@ -115,6 +124,6 @@ class ToolBase {
|
|||||||
var dist: ToolData? = null
|
var dist: ToolData? = null
|
||||||
|
|
||||||
override fun toString(): String {
|
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)"
|
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)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,19 +59,28 @@ class ToolBaseServiceImpl(
|
|||||||
override fun update(toolBaseUpdateParam: ToolBaseUpdateParam): ToolBaseVo {
|
override fun update(toolBaseUpdateParam: ToolBaseUpdateParam): ToolBaseVo {
|
||||||
val toolBase = baseMapper.selectOne(toolBaseUpdateParam.id!!) ?: throw NoRecordFoundException()
|
val toolBase = baseMapper.selectOne(toolBaseUpdateParam.id!!) ?: throw NoRecordFoundException()
|
||||||
|
|
||||||
toolDataService.updateById(ToolData().apply {
|
var hasCompiled: Int? = null
|
||||||
id = toolBase.sourceId
|
|
||||||
data = toolBaseUpdateParam.source
|
|
||||||
})
|
|
||||||
|
|
||||||
toolDataService.updateById(ToolData().apply {
|
if (!toolBaseUpdateParam.source.isNullOrBlank()) {
|
||||||
id = toolBase.distId
|
toolDataService.updateById(ToolData().apply {
|
||||||
data = toolBaseUpdateParam.dist
|
id = toolBase.sourceId
|
||||||
})
|
data = toolBaseUpdateParam.source
|
||||||
|
})
|
||||||
|
hasCompiled = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!toolBaseUpdateParam.dist.isNullOrBlank()) {
|
||||||
|
toolDataService.updateById(ToolData().apply {
|
||||||
|
id = toolBase.distId
|
||||||
|
data = toolBaseUpdateParam.dist
|
||||||
|
})
|
||||||
|
hasCompiled = 1
|
||||||
|
}
|
||||||
|
|
||||||
this.updateById(ToolBase().apply {
|
this.updateById(ToolBase().apply {
|
||||||
id = toolBaseUpdateParam.id
|
id = toolBaseUpdateParam.id
|
||||||
name = toolBaseUpdateParam.name
|
name = toolBaseUpdateParam.name
|
||||||
|
compiled = hasCompiled
|
||||||
enable = toolBaseUpdateParam.enable?.let { if (it) 1 else 0 }
|
enable = toolBaseUpdateParam.enable?.let { if (it) 1 else 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ data class ToolBaseVo(
|
|||||||
|
|
||||||
val dist: ToolDataVo?,
|
val dist: ToolDataVo?,
|
||||||
|
|
||||||
|
val compiled: Boolean?,
|
||||||
|
|
||||||
val enable: Boolean?,
|
val enable: Boolean?,
|
||||||
|
|
||||||
val createTime: LocalDateTime?,
|
val createTime: LocalDateTime?,
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ drop table if exists t_b_tool_data;
|
|||||||
|
|
||||||
create table if not exists t_b_tool_data
|
create table if not exists t_b_tool_data
|
||||||
(
|
(
|
||||||
id bigint not null primary key,
|
id bigint not null primary key,
|
||||||
data text not null comment '数据',
|
data mediumtext not null 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,
|
||||||
version int not null default 0
|
version int not null default 0
|
||||||
) comment '工具-数据表';
|
) comment '工具-数据表';
|
||||||
@@ -6,6 +6,7 @@ create table if not exists t_b_tool_base
|
|||||||
name varchar(20) not null comment '基板名',
|
name varchar(20) 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',
|
||||||
|
compiled int not null default 0 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 '修改时间',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
t_b_tool_base.name as tool_base_name,
|
t_b_tool_base.name as tool_base_name,
|
||||||
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.enable as tool_base_enable,
|
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,
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
<result property="name" column="tool_base_name"/>
|
<result property="name" column="tool_base_name"/>
|
||||||
<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="enable" column="tool_base_enable"/>
|
<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"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user