Add auto publish to tool management api
This commit is contained in:
@@ -1,16 +1,13 @@
|
|||||||
package top.fatweb.oxygen.api.controller.tool
|
package top.fatweb.oxygen.api.controller.tool
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation
|
import io.swagger.v3.oas.annotations.Operation
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping
|
import jakarta.validation.Valid
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.*
|
||||||
import org.springframework.web.bind.annotation.PatchMapping
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping
|
|
||||||
import top.fatweb.oxygen.api.annotation.BaseController
|
import top.fatweb.oxygen.api.annotation.BaseController
|
||||||
import top.fatweb.oxygen.api.entity.common.ResponseCode
|
import top.fatweb.oxygen.api.entity.common.ResponseCode
|
||||||
import top.fatweb.oxygen.api.entity.common.ResponseResult
|
import top.fatweb.oxygen.api.entity.common.ResponseResult
|
||||||
import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam
|
import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam
|
||||||
|
import top.fatweb.oxygen.api.param.tool.ToolManagementPassParam
|
||||||
import top.fatweb.oxygen.api.service.tool.IManagementService
|
import top.fatweb.oxygen.api.service.tool.IManagementService
|
||||||
import top.fatweb.oxygen.api.vo.PageVo
|
import top.fatweb.oxygen.api.vo.PageVo
|
||||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||||
@@ -40,7 +37,7 @@ class ManagementController(
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
fun get(toolManagementGetParam: ToolManagementGetParam): ResponseResult<PageVo<ToolVo>> =
|
fun get(toolManagementGetParam: ToolManagementGetParam): ResponseResult<PageVo<ToolVo>> =
|
||||||
ResponseResult.databaseSuccess(data = managementService.getPage(toolManagementGetParam))
|
ResponseResult.databaseSuccess(data = managementService.getPage(toolManagementGetParam))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass tool review
|
* Pass tool review
|
||||||
*
|
*
|
||||||
@@ -49,8 +46,14 @@ class ManagementController(
|
|||||||
*/
|
*/
|
||||||
@Operation(summary = "通过审核")
|
@Operation(summary = "通过审核")
|
||||||
@PostMapping("/{id}")
|
@PostMapping("/{id}")
|
||||||
fun pass(@PathVariable id: Long): ResponseResult<ToolVo> =
|
fun pass(
|
||||||
ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS, data = managementService.pass(id))
|
@PathVariable id: Long,
|
||||||
|
@RequestBody @Valid toolManagementPassParam: ToolManagementPassParam
|
||||||
|
): ResponseResult<ToolVo> =
|
||||||
|
ResponseResult.databaseSuccess(
|
||||||
|
ResponseCode.DATABASE_UPDATE_SUCCESS,
|
||||||
|
data = managementService.pass(id, toolManagementPassParam)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reject tool review
|
* Reject tool review
|
||||||
@@ -71,7 +74,7 @@ class ManagementController(
|
|||||||
*/
|
*/
|
||||||
@Operation(summary = "下架")
|
@Operation(summary = "下架")
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
fun offShelve(@PathVariable id: Long):ResponseResult<ToolVo> =
|
fun offShelve(@PathVariable id: Long): ResponseResult<ToolVo> =
|
||||||
ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS, data = managementService.offShelve(id))
|
ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS, data = managementService.offShelve(id))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package top.fatweb.oxygen.api.param.tool
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
|
import jakarta.validation.constraints.NotBlank
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass tool in management parameters
|
||||||
|
*
|
||||||
|
* @author FatttSnake, fatttsnake@gmail.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
data class ToolManagementPassParam(
|
||||||
|
/**
|
||||||
|
* Dist
|
||||||
|
*
|
||||||
|
* @author FatttSnake, fatttsnake@gmail.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Schema(description = "产物")
|
||||||
|
@field:NotBlank(message = "Dist can not be blank")
|
||||||
|
val dist: String?
|
||||||
|
)
|
||||||
@@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.service.tool
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService
|
import com.baomidou.mybatisplus.extension.service.IService
|
||||||
import top.fatweb.oxygen.api.entity.tool.Tool
|
import top.fatweb.oxygen.api.entity.tool.Tool
|
||||||
import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam
|
import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam
|
||||||
|
import top.fatweb.oxygen.api.param.tool.ToolManagementPassParam
|
||||||
import top.fatweb.oxygen.api.vo.PageVo
|
import top.fatweb.oxygen.api.vo.PageVo
|
||||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ interface IManagementService : IService<Tool> {
|
|||||||
|
|
||||||
fun getPage(toolManagementGetParam: ToolManagementGetParam?): PageVo<ToolVo>
|
fun getPage(toolManagementGetParam: ToolManagementGetParam?): PageVo<ToolVo>
|
||||||
|
|
||||||
fun pass(id: Long): ToolVo
|
fun pass(id: Long, toolManagementPassParam: ToolManagementPassParam): ToolVo
|
||||||
|
|
||||||
fun reject(id: Long): ToolVo
|
fun reject(id: Long): ToolVo
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ import org.springframework.transaction.annotation.Transactional
|
|||||||
import top.fatweb.oxygen.api.converter.tool.ToolConverter
|
import top.fatweb.oxygen.api.converter.tool.ToolConverter
|
||||||
import top.fatweb.oxygen.api.entity.tool.RToolCategory
|
import top.fatweb.oxygen.api.entity.tool.RToolCategory
|
||||||
import top.fatweb.oxygen.api.entity.tool.Tool
|
import top.fatweb.oxygen.api.entity.tool.Tool
|
||||||
|
import top.fatweb.oxygen.api.entity.tool.ToolData
|
||||||
import top.fatweb.oxygen.api.exception.NoRecordFoundException
|
import top.fatweb.oxygen.api.exception.NoRecordFoundException
|
||||||
import top.fatweb.oxygen.api.exception.ToolHasNotBeenPublishedException
|
import top.fatweb.oxygen.api.exception.ToolHasNotBeenPublishedException
|
||||||
import top.fatweb.oxygen.api.exception.ToolNotUnderReviewException
|
import top.fatweb.oxygen.api.exception.ToolNotUnderReviewException
|
||||||
import top.fatweb.oxygen.api.mapper.tool.ManagementMapper
|
import top.fatweb.oxygen.api.mapper.tool.ManagementMapper
|
||||||
import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam
|
import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam
|
||||||
import top.fatweb.oxygen.api.service.tool.IEditService
|
import top.fatweb.oxygen.api.param.tool.ToolManagementPassParam
|
||||||
import top.fatweb.oxygen.api.service.tool.IManagementService
|
import top.fatweb.oxygen.api.service.tool.IManagementService
|
||||||
import top.fatweb.oxygen.api.service.tool.IRToolCategoryService
|
import top.fatweb.oxygen.api.service.tool.IRToolCategoryService
|
||||||
import top.fatweb.oxygen.api.service.tool.IToolDataService
|
import top.fatweb.oxygen.api.service.tool.IToolDataService
|
||||||
import top.fatweb.oxygen.api.util.PageUtil
|
import top.fatweb.oxygen.api.util.PageUtil
|
||||||
import top.fatweb.oxygen.api.util.WebUtil
|
|
||||||
import top.fatweb.oxygen.api.vo.PageVo
|
import top.fatweb.oxygen.api.vo.PageVo
|
||||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@@ -44,6 +44,7 @@ class ManagementServiceImpl(
|
|||||||
override fun getOne(id: Long): ToolVo =
|
override fun getOne(id: Long): ToolVo =
|
||||||
baseMapper.selectOne(id)
|
baseMapper.selectOne(id)
|
||||||
?.let(ToolConverter::toolToToolVo) ?: throw NoRecordFoundException()
|
?.let(ToolConverter::toolToToolVo) ?: throw NoRecordFoundException()
|
||||||
|
|
||||||
override fun getPage(toolManagementGetParam: ToolManagementGetParam?): PageVo<ToolVo> {
|
override fun getPage(toolManagementGetParam: ToolManagementGetParam?): PageVo<ToolVo> {
|
||||||
val toolIdsPage = Page<Long>(toolManagementGetParam?.currentPage ?: 1, toolManagementGetParam?.pageSize ?: 20)
|
val toolIdsPage = Page<Long>(toolManagementGetParam?.currentPage ?: 1, toolManagementGetParam?.pageSize ?: 20)
|
||||||
|
|
||||||
@@ -65,12 +66,16 @@ class ManagementServiceImpl(
|
|||||||
return ToolConverter.toolPageToToolPageVo(toolPage)
|
return ToolConverter.toolPageToToolPageVo(toolPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pass(id: Long): ToolVo {
|
override fun pass(id: Long, toolManagementPassParam: ToolManagementPassParam): ToolVo {
|
||||||
val tool = this.getById(id) ?: throw NoRecordFoundException()
|
val tool = this.getById(id) ?: throw NoRecordFoundException()
|
||||||
if (tool.review !== Tool.ReviewType.PROCESSING) {
|
if (tool.review !== Tool.ReviewType.PROCESSING) {
|
||||||
throw ToolNotUnderReviewException()
|
throw ToolNotUnderReviewException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolDataService.update(
|
||||||
|
KtUpdateWrapper(ToolData()).eq(ToolData::id, tool.distId).set(ToolData::data, toolManagementPassParam.dist)
|
||||||
|
)
|
||||||
|
|
||||||
this.update(
|
this.update(
|
||||||
KtUpdateWrapper(Tool())
|
KtUpdateWrapper(Tool())
|
||||||
.eq(Tool::id, id)
|
.eq(Tool::id, id)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ToolCategoryServiceImpl : ServiceImpl<ToolCategoryMapper, ToolCategory>(),
|
|||||||
override fun update(toolCategoryUpdateParam: ToolCategoryUpdateParam): ToolCategoryVo {
|
override fun update(toolCategoryUpdateParam: ToolCategoryUpdateParam): ToolCategoryVo {
|
||||||
val toolCategory = ToolCategoryConverter.toolCategoryUpdateParamToToolCategory(toolCategoryUpdateParam)
|
val toolCategory = ToolCategoryConverter.toolCategoryUpdateParamToToolCategory(toolCategoryUpdateParam)
|
||||||
|
|
||||||
if (this.updateById(toolCategory)) {
|
if (!this.updateById(toolCategory)) {
|
||||||
throw DatabaseUpdateException()
|
throw DatabaseUpdateException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user