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?
|
||||
|
||||
Reference in New Issue
Block a user