Add enable field to ToolBase and ToolTemplate
This commit is contained in:
@@ -25,6 +25,11 @@ class BaseController(
|
||||
fun get(): ResponseResult<List<ToolBaseVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolBaseService.get())
|
||||
|
||||
@Operation(summary = "获取基板列表")
|
||||
@GetMapping("/list")
|
||||
fun getList(): ResponseResult<List<ToolBaseVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolBaseService.getList())
|
||||
|
||||
@Operation(summary = "新增基板")
|
||||
@PostMapping
|
||||
fun add(@RequestBody @Valid toolBaseAddParam: ToolBaseAddParam): ResponseResult<ToolBaseVo> =
|
||||
|
||||
@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.converter.tool
|
||||
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolBase
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolDataVo
|
||||
|
||||
object ToolBaseConverter {
|
||||
fun toolBaseToToolBaseVo(toolBase: ToolBase) = ToolBaseVo(
|
||||
@@ -10,6 +11,17 @@ object ToolBaseConverter {
|
||||
source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
createTime = toolBase.createTime,
|
||||
updateTime = toolBase.updateTime
|
||||
updateTime = toolBase.updateTime,
|
||||
enable = toolBase.enable == 1
|
||||
)
|
||||
|
||||
fun toolBaseToToolBaseVoByGetList(toolBase: ToolBase) = ToolBaseVo(
|
||||
id = toolBase.id,
|
||||
name = toolBase.name,
|
||||
source = ToolDataVo(id = toolBase.sourceId, data = null, createTime = null, updateTime = null),
|
||||
dist = ToolDataVo(id = toolBase.distId, data = null, createTime = null, updateTime = null),
|
||||
createTime = toolBase.createTime,
|
||||
updateTime = toolBase.updateTime,
|
||||
enable = toolBase.enable == 1
|
||||
)
|
||||
}
|
||||
@@ -12,6 +12,7 @@ object ToolTemplateConverter {
|
||||
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
dist = toolTemplate.dist?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
createTime = toolTemplate.createTime,
|
||||
updateTime = toolTemplate.updateTime
|
||||
updateTime = toolTemplate.updateTime,
|
||||
enable = toolTemplate.enable == 1
|
||||
)
|
||||
}
|
||||
@@ -47,6 +47,15 @@ class ToolBase {
|
||||
@TableField("dist_id")
|
||||
var distId: Long? = null
|
||||
|
||||
/**
|
||||
* Enable
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@TableField("enable")
|
||||
var enable: Int? = null
|
||||
|
||||
/**
|
||||
* Create time
|
||||
*
|
||||
|
||||
@@ -65,6 +65,15 @@ class ToolTemplate {
|
||||
@TableField("dist_id")
|
||||
var distId: Long? = null
|
||||
|
||||
/**
|
||||
* Enable
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@TableField("enable")
|
||||
var enable: Int? = null
|
||||
|
||||
/**
|
||||
* Create time
|
||||
*
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
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?,
|
||||
val source: String = "",
|
||||
|
||||
@field:NotNull(message = "Dist can not be null")
|
||||
val dist: String?
|
||||
val dist: String = "",
|
||||
|
||||
val enable: Boolean = true
|
||||
)
|
||||
|
||||
@@ -10,5 +10,7 @@ data class ToolBaseUpdateParam(
|
||||
|
||||
val source: String?,
|
||||
|
||||
val dist: String?
|
||||
val dist: String?,
|
||||
|
||||
val enable: Boolean?
|
||||
)
|
||||
|
||||
@@ -19,5 +19,7 @@ data class ToolTemplateAddParam(
|
||||
val source: String?,
|
||||
|
||||
@field:NotNull(message = "Dist can not be null")
|
||||
val dist: String?
|
||||
val dist: String?,
|
||||
|
||||
val enable: Boolean = true
|
||||
)
|
||||
|
||||
@@ -16,5 +16,7 @@ data class ToolTemplateUpdateParam(
|
||||
|
||||
val source: String?,
|
||||
|
||||
val dist: String?
|
||||
val dist: String?,
|
||||
|
||||
val enable: Boolean?
|
||||
)
|
||||
|
||||
@@ -19,6 +19,8 @@ interface IToolBaseService : IService<ToolBase> {
|
||||
|
||||
fun get(): List<ToolBaseVo>
|
||||
|
||||
fun getList(): List<ToolBaseVo>
|
||||
|
||||
fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo
|
||||
|
||||
fun update(toolBaseUpdateParam: ToolBaseUpdateParam): ToolBaseVo
|
||||
|
||||
@@ -32,6 +32,7 @@ class ToolBaseServiceImpl(
|
||||
baseMapper.selectOne(id)?.let(ToolBaseConverter::toolBaseToToolBaseVo) ?: throw NoRecordFoundException()
|
||||
|
||||
override fun get(): List<ToolBaseVo> = baseMapper.selectList().map(ToolBaseConverter::toolBaseToToolBaseVo)
|
||||
override fun getList(): List<ToolBaseVo> = this.list().map(ToolBaseConverter::toolBaseToToolBaseVoByGetList)
|
||||
|
||||
@Transactional
|
||||
override fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo {
|
||||
@@ -47,6 +48,7 @@ class ToolBaseServiceImpl(
|
||||
distId = newDist.id
|
||||
source = newSource
|
||||
dist = newDist
|
||||
enable = if (toolBaseAddParam.enable) 1 else 0
|
||||
}
|
||||
|
||||
this.save(toolBase)
|
||||
@@ -71,6 +73,7 @@ class ToolBaseServiceImpl(
|
||||
this.updateById(ToolBase().apply {
|
||||
id = toolBaseUpdateParam.id
|
||||
name = toolBaseUpdateParam.name
|
||||
enable = toolBaseUpdateParam.enable?.let { if (it) 1 else 0 }
|
||||
})
|
||||
|
||||
return this.getOne(toolBase.id!!)
|
||||
|
||||
@@ -55,6 +55,7 @@ class ToolTemplateServiceImpl(
|
||||
distId = newDist.id
|
||||
source = newSource
|
||||
dist = newDist
|
||||
enable = if (toolTemplateAddParam.enable) 1 else 0
|
||||
}
|
||||
|
||||
this.save(toolTemplate)
|
||||
@@ -82,6 +83,7 @@ class ToolTemplateServiceImpl(
|
||||
name = toolTemplateUpdateParam.name
|
||||
ver = toolTemplateUpdateParam.ver
|
||||
baseId = toolTemplateUpdateParam.baseId
|
||||
enable = toolTemplateUpdateParam.enable?.let { if (it) 1 else 0 }
|
||||
})
|
||||
|
||||
return this.getOne(toolTemplate.id!!)
|
||||
|
||||
@@ -14,6 +14,8 @@ data class ToolBaseVo(
|
||||
|
||||
val dist: ToolDataVo?,
|
||||
|
||||
val enable: Boolean?,
|
||||
|
||||
val createTime: LocalDateTime?,
|
||||
|
||||
val updateTime: LocalDateTime?
|
||||
|
||||
@@ -19,6 +19,8 @@ data class ToolTemplateVo(
|
||||
|
||||
val dist: ToolDataVo?,
|
||||
|
||||
val enable: Boolean?,
|
||||
|
||||
val createTime: LocalDateTime?,
|
||||
|
||||
val updateTime: LocalDateTime?
|
||||
|
||||
@@ -8,6 +8,7 @@ create table if not exists t_b_tool_template
|
||||
base_id bigint not null comment '基板 ID',
|
||||
source_id bigint not null comment '源码 ID',
|
||||
dist_id bigint not null comment '产物 ID',
|
||||
enable int not null default 1 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,
|
||||
|
||||
@@ -6,6 +6,7 @@ create table if not exists t_b_tool_base
|
||||
name varchar(20) not null comment '基板名',
|
||||
source_id bigint not null comment '源码 ID',
|
||||
dist_id bigint not null comment '产物 ID',
|
||||
enable int not null default 1 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,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
t_b_tool_base.name as tool_base_name,
|
||||
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.enable as tool_base_enable,
|
||||
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.deleted as tool_base_deleted,
|
||||
@@ -33,6 +34,7 @@
|
||||
t_b_tool_base.name as tool_base_name,
|
||||
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.enable as tool_base_enable,
|
||||
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.deleted as tool_base_deleted,
|
||||
@@ -48,7 +50,8 @@
|
||||
tbtdd.deleted as tool_base_dist_delete,
|
||||
tbtdd.version as tool_base_dist_version
|
||||
from t_b_tool_base
|
||||
left join (select * from t_b_tool_data where deleted = 0) as tbtds on tbtds.id = t_b_tool_base.source_id
|
||||
left join (select * from t_b_tool_data where deleted = 0) as tbtds
|
||||
on tbtds.id = t_b_tool_base.source_id
|
||||
left join (select * from t_b_tool_data where deleted = 0) as tbtdd on tbtdd.id = t_b_tool_base.dist_id
|
||||
where t_b_tool_base.deleted = 0
|
||||
</select>
|
||||
@@ -58,6 +61,7 @@
|
||||
<result property="name" column="tool_base_name"/>
|
||||
<result property="sourceId" column="tool_base_source_id"/>
|
||||
<result property="distId" column="tool_base_dist_id"/>
|
||||
<result property="enable" column="tool_base_enable"/>
|
||||
<result property="createTime" column="tool_base_create_time"/>
|
||||
<result property="updateTime" column="tool_base_update_time"/>
|
||||
<result property="deleted" column="tool_base_deleted"/>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
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.dist_id as tool_template_dist_id,
|
||||
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,
|
||||
@@ -38,6 +39,7 @@
|
||||
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.dist_id as tool_template_dist_id,
|
||||
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,
|
||||
@@ -67,6 +69,7 @@
|
||||
<result property="baseId" column="tool_template_base_id"/>
|
||||
<result property="sourceId" column="tool_template_source_id"/>
|
||||
<result property="distId" column="tool_template_dist_id"/>
|
||||
<result property="enable" column="tool_template_enable"/>
|
||||
<result property="createTime" column="tool_template_create_time"/>
|
||||
<result property="updateTime" column="tool_template_update_time"/>
|
||||
<result property="deleted" column="tool_template_deleted"/>
|
||||
|
||||
Reference in New Issue
Block a user