Add tool api

This commit is contained in:
2024-01-18 14:14:36 +08:00
parent 0512bab3ca
commit d559fc53dd
52 changed files with 1738 additions and 64 deletions

View File

@@ -0,0 +1,50 @@
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.entity.common.ResponseCode
import top.fatweb.oxygen.api.entity.common.ResponseResult
import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam
import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolBaseService
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
@BaseController(path = ["/system/tool/base"], name = "工具基板管理", description = "工具基板管理相关接口")
class BaseController(
private val toolBaseService: IToolBaseService
) {
@Operation(summary = "获取单个基板")
@GetMapping("/{id}")
fun getOne(@PathVariable id: Long): ResponseResult<ToolBaseVo> =
toolBaseService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) }
?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) }
@Operation(summary = "获取基板")
@GetMapping
fun get(): ResponseResult<List<ToolBaseVo>> =
ResponseResult.databaseSuccess(data = toolBaseService.get())
@Operation(summary = "新增基板")
@PostMapping
fun add(@RequestBody @Valid toolBaseAddParam: ToolBaseAddParam): ResponseResult<ToolBaseVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_INSERT_SUCCESS,
data = toolBaseService.add(toolBaseAddParam)
)
@Operation(summary = "更新基板")
@PutMapping
fun update(@RequestBody @Valid toolBaseUpdateParam: ToolBaseUpdateParam): ResponseResult<ToolBaseVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_UPDATE_SUCCESS,
data = toolBaseService.update(toolBaseUpdateParam)
)
@Operation(summary = "删除基板")
@DeleteMapping("/{id}")
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
if (toolBaseService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED)
}

View File

@@ -0,0 +1,57 @@
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.entity.common.ResponseCode
import top.fatweb.oxygen.api.entity.common.ResponseResult
import top.fatweb.oxygen.api.param.tool.ToolCategoryAddParam
import top.fatweb.oxygen.api.param.tool.ToolCategoryUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolCategoryService
import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
/**
* Tool category management controller
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@BaseController(path = ["/system/tool/category"], name = "工具类别管理", description = "工具列别管理相关接口")
class CategoryController(
private val toolCategoryService: IToolCategoryService
) {
@Operation(summary = "获取单个类别")
@GetMapping("/{id}")
fun getOne(@PathVariable id: Long): ResponseResult<ToolCategoryVo> =
toolCategoryService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) }
?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) }
@Operation(summary = "获取类别")
@GetMapping
fun get(): ResponseResult<List<ToolCategoryVo>> =
ResponseResult.databaseSuccess(data = toolCategoryService.get())
@Operation(summary = "新增类别")
@PostMapping
fun add(@RequestBody @Valid toolCategoryAddParam: ToolCategoryAddParam): ResponseResult<ToolCategoryVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_INSERT_SUCCESS,
data = toolCategoryService.add(toolCategoryAddParam)
)
@Operation(summary = "更新类别")
@PutMapping
fun update(@RequestBody @Valid toolCategoryUpdateParam: ToolCategoryUpdateParam): ResponseResult<ToolCategoryVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_UPDATE_SUCCESS,
data = toolCategoryService.update(toolCategoryUpdateParam)
)
@Operation(summary = "删除类别")
@DeleteMapping("/{id}")
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
if (toolCategoryService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED)
}

View File

@@ -0,0 +1,56 @@
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.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
/**
* Tool management controller
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@BaseController(path = ["/tool"], name = "工具管理", description = "工具管理相关接口")
class EditController(
private val toolService: IToolService
) {
@Operation(summary = "获取单个工具")
@GetMapping("/{id}")
fun getOne(@PathVariable id: Long): ResponseResult<ToolVo> =
toolService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) }
?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) }
@Operation(summary = "获取工具")
@GetMapping
fun get(): ResponseResult<List<ToolVo>> =
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 = "更新工具")
@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_FILED)
}

View File

@@ -0,0 +1,50 @@
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.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 = "工具管理相关接口")
class ManagementController(
private val toolService: IToolService
) {
@Operation(summary = "获取单个工具")
@GetMapping("/{id}")
fun getOne(@PathVariable id: Long): ResponseResult<ToolVo> =
toolService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) }
?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) }
@Operation(summary = "获取工具")
@GetMapping
fun get(): ResponseResult<List<ToolVo>> =
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 = "更新工具")
@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_FILED)
}

View File

@@ -0,0 +1,50 @@
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.entity.common.ResponseCode
import top.fatweb.oxygen.api.entity.common.ResponseResult
import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolTemplateService
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
@BaseController(path = ["/system/tool/template"], name = "工具模板管理", description = "工具模板管理相关接口")
class TemplateController(
private val toolTemplateService: IToolTemplateService
) {
@Operation(summary = "获取单个模板")
@GetMapping("/{id}")
fun getOne(@PathVariable id: Long): ResponseResult<ToolTemplateVo> =
toolTemplateService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) }
?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_NO_RECORD_FOUND) }
@Operation(summary = "获取模板")
@GetMapping
fun get(): ResponseResult<List<ToolTemplateVo>> =
ResponseResult.databaseSuccess(data = toolTemplateService.get())
@Operation(summary = "添加模板")
@PostMapping
fun add(@RequestBody @Valid toolTemplateAddParam: ToolTemplateAddParam): ResponseResult<ToolTemplateVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_INSERT_SUCCESS,
data = toolTemplateService.add(toolTemplateAddParam)
)
@Operation(summary = "更新模板")
@PutMapping
fun update(@RequestBody @Valid toolTemplateUpdateParam: ToolTemplateUpdateParam): ResponseResult<ToolTemplateVo> =
ResponseResult.databaseSuccess(
ResponseCode.DATABASE_UPDATE_SUCCESS,
data = toolTemplateService.update(toolTemplateUpdateParam)
)
@Operation(summary = "删除模板")
@DeleteMapping("/{id}")
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
if (toolTemplateService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FILED)
}