Add kdoc and permission
This commit is contained in:
@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.controller.tool
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import top.fatweb.oxygen.api.annotation.BaseController
|
||||
import top.fatweb.oxygen.api.entity.common.ResponseCode
|
||||
@@ -11,38 +12,100 @@ import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam
|
||||
import top.fatweb.oxygen.api.service.tool.IToolBaseService
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
|
||||
|
||||
/**
|
||||
* Tool base management controller
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IToolBaseService
|
||||
*/
|
||||
@BaseController(path = ["/system/tool/base"], name = "工具基板管理", description = "工具基板管理相关接口")
|
||||
class BaseController(
|
||||
private val toolBaseService: IToolBaseService
|
||||
) {
|
||||
/**
|
||||
* Get tool base by ID
|
||||
*
|
||||
* @param id Tool base ID
|
||||
* @return Response object includes tool base information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see ToolBaseVo
|
||||
*/
|
||||
@Operation(summary = "获取单个基板")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:base')")
|
||||
fun getOne(@PathVariable id: Long): ResponseResult<ToolBaseVo> =
|
||||
ResponseResult.databaseSuccess(data = toolBaseService.getOne(id))
|
||||
|
||||
/**
|
||||
* Get tool base list
|
||||
*
|
||||
* @return Response object includes tool base list
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see ToolBaseVo
|
||||
*/
|
||||
@Operation(summary = "获取基板")
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:base', 'system:tool:add:template', 'system:tool:modify:template')")
|
||||
fun get(): ResponseResult<List<ToolBaseVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolBaseService.get())
|
||||
|
||||
/**
|
||||
* Add tool base
|
||||
*
|
||||
* @param toolBaseAddParam Add tool base parameters
|
||||
* @return Response object includes tool base information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBaseAddParam
|
||||
* @see ResponseResult
|
||||
* @see ToolBaseVo
|
||||
*/
|
||||
@Operation(summary = "新增基板")
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:add:base')")
|
||||
fun add(@RequestBody @Valid toolBaseAddParam: ToolBaseAddParam): ResponseResult<ToolBaseVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_INSERT_SUCCESS,
|
||||
data = toolBaseService.add(toolBaseAddParam)
|
||||
)
|
||||
|
||||
/**
|
||||
* Update tool base
|
||||
*
|
||||
* @param toolBaseUpdateParam Update tool base parameters
|
||||
* @return Response object includes tool base information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBaseUpdateParam
|
||||
* @see ResponseResult
|
||||
* @see ToolBaseVo
|
||||
*/
|
||||
@Operation(summary = "更新基板")
|
||||
@PutMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:modify:base')")
|
||||
fun update(@RequestBody @Valid toolBaseUpdateParam: ToolBaseUpdateParam): ResponseResult<ToolBaseVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_UPDATE_SUCCESS,
|
||||
data = toolBaseService.update(toolBaseUpdateParam)
|
||||
)
|
||||
|
||||
/**
|
||||
* Delete tool base by ID
|
||||
*
|
||||
* @param id Tool base ID
|
||||
* @return Response object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
*/
|
||||
@Operation(summary = "删除基板")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:delete:base')")
|
||||
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
|
||||
if (toolBaseService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
|
||||
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED)
|
||||
|
||||
@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.controller.tool
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import top.fatweb.oxygen.api.annotation.BaseController
|
||||
import top.fatweb.oxygen.api.entity.common.ResponseCode
|
||||
@@ -11,7 +12,6 @@ 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
|
||||
*
|
||||
@@ -22,34 +22,89 @@ import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
|
||||
class CategoryController(
|
||||
private val toolCategoryService: IToolCategoryService
|
||||
) {
|
||||
/**
|
||||
* Get tool category by ID
|
||||
*
|
||||
* @param id Tool category ID
|
||||
* @return Response object includes tool template information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see ToolCategoryVo
|
||||
*/
|
||||
@Operation(summary = "获取单个类别")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:category')")
|
||||
fun getOne(@PathVariable id: Long): ResponseResult<ToolCategoryVo> =
|
||||
ResponseResult.databaseSuccess(data = toolCategoryService.getOne(id))
|
||||
|
||||
/**
|
||||
* Get tool category list
|
||||
*
|
||||
* @return Response object includes tool template list
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see ToolCategoryVo
|
||||
*/
|
||||
@Operation(summary = "获取类别")
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:category')")
|
||||
fun get(): ResponseResult<List<ToolCategoryVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolCategoryService.get())
|
||||
|
||||
/**
|
||||
* Add tool category
|
||||
*
|
||||
* @param toolCategoryAddParam Add tool category parameters
|
||||
* @return Response object includes tool category information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolCategoryAddParam
|
||||
* @see ResponseResult
|
||||
* @see ToolCategoryVo
|
||||
*/
|
||||
@Operation(summary = "新增类别")
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:add:category')")
|
||||
fun add(@RequestBody @Valid toolCategoryAddParam: ToolCategoryAddParam): ResponseResult<ToolCategoryVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_INSERT_SUCCESS,
|
||||
data = toolCategoryService.add(toolCategoryAddParam)
|
||||
)
|
||||
|
||||
/**
|
||||
* Update tool category
|
||||
*
|
||||
* @param toolCategoryUpdateParam Update tool category parameters
|
||||
* @return Response object includes tool category information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolCategoryUpdateParam
|
||||
* @see ResponseResult
|
||||
* @see ToolCategoryVo
|
||||
*/
|
||||
@Operation(summary = "更新类别")
|
||||
@PutMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:modify:category')")
|
||||
fun update(@RequestBody @Valid toolCategoryUpdateParam: ToolCategoryUpdateParam): ResponseResult<ToolCategoryVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_UPDATE_SUCCESS,
|
||||
data = toolCategoryService.update(toolCategoryUpdateParam)
|
||||
)
|
||||
|
||||
/**
|
||||
* Delete tool category
|
||||
*
|
||||
* @param id Tool category ID
|
||||
* @return Response object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
*/
|
||||
@Operation(summary = "删除类别")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:delete:category')")
|
||||
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
|
||||
if (toolCategoryService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
|
||||
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED)
|
||||
|
||||
@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.controller.tool
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import top.fatweb.oxygen.api.annotation.BaseController
|
||||
import top.fatweb.oxygen.api.entity.common.ResponseCode
|
||||
@@ -11,38 +12,100 @@ import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam
|
||||
import top.fatweb.oxygen.api.service.tool.IToolTemplateService
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
|
||||
/**
|
||||
* Tool template management controller
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IToolTemplateService
|
||||
*/
|
||||
@BaseController(path = ["/system/tool/template"], name = "工具模板管理", description = "工具模板管理相关接口")
|
||||
class TemplateController(
|
||||
private val toolTemplateService: IToolTemplateService
|
||||
) {
|
||||
/**
|
||||
* Get tool template by ID
|
||||
*
|
||||
* @param id Tool template ID
|
||||
* @return Response object includes tool template information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
@Operation(summary = "获取单个模板")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:template')")
|
||||
fun getOne(@PathVariable id: Long): ResponseResult<ToolTemplateVo> =
|
||||
ResponseResult.databaseSuccess(data = toolTemplateService.getOne(id))
|
||||
|
||||
/**
|
||||
* Get tool template list
|
||||
*
|
||||
* @return Response object includes tool template list
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
@Operation(summary = "获取模板")
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:template')")
|
||||
fun get(): ResponseResult<List<ToolTemplateVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolTemplateService.get())
|
||||
|
||||
/**
|
||||
* Add tool template
|
||||
*
|
||||
* @param toolTemplateAddParam Add tool template parameters
|
||||
* @return Response object includes tool template information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolTemplateAddParam
|
||||
* @see ResponseResult
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
@Operation(summary = "添加模板")
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:add:template')")
|
||||
fun add(@RequestBody @Valid toolTemplateAddParam: ToolTemplateAddParam): ResponseResult<ToolTemplateVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_INSERT_SUCCESS,
|
||||
data = toolTemplateService.add(toolTemplateAddParam)
|
||||
)
|
||||
|
||||
/**
|
||||
* Update tool template
|
||||
*
|
||||
* @param toolTemplateUpdateParam Update tool template parameters
|
||||
* @return Response object includes tool template information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolTemplateUpdateParam
|
||||
* @see ResponseResult
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
@Operation(summary = "更新模板")
|
||||
@PutMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:modify:template')")
|
||||
fun update(@RequestBody @Valid toolTemplateUpdateParam: ToolTemplateUpdateParam): ResponseResult<ToolTemplateVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_UPDATE_SUCCESS,
|
||||
data = toolTemplateService.update(toolTemplateUpdateParam)
|
||||
)
|
||||
|
||||
/**
|
||||
* Delete tool template
|
||||
*
|
||||
* @param id Tool template ID
|
||||
* @return Response object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
*/
|
||||
@Operation(summary = "删除模板")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:delete:template')")
|
||||
fun delete(@PathVariable id: Long): ResponseResult<Nothing> =
|
||||
if (toolTemplateService.delete(id)) ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
|
||||
else ResponseResult.databaseFail(ResponseCode.DATABASE_DELETE_FAILED)
|
||||
|
||||
Reference in New Issue
Block a user