Add store get tool api

This commit is contained in:
2024-02-17 14:24:42 +08:00
parent b32f062594
commit c5dcb432ef
10 changed files with 239 additions and 5 deletions

View File

@@ -0,0 +1,31 @@
package top.fatweb.oxygen.api.controller.tool
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.GetMapping
import top.fatweb.oxygen.api.annotation.BaseController
import top.fatweb.oxygen.api.entity.common.ResponseResult
import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam
import top.fatweb.oxygen.api.service.tool.IStoreService
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolVo
/**
* Tool store controller
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@BaseController(path = ["/tool/store"], name = "工具商店", description = "工具商店相关接口")
class StoreController(
private val storeService: IStoreService
) {
/**
* Get store tool in page
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@GetMapping
fun get(@Valid toolStoreGetParam: ToolStoreGetParam): ResponseResult<PageVo<ToolVo>> =
ResponseResult.databaseSuccess(data = storeService.getPage(toolStoreGetParam))
}

View File

@@ -7,7 +7,7 @@ import org.apache.ibatis.annotations.Param
import top.fatweb.oxygen.api.entity.tool.Tool
/**
* Tool mapper
* Tool management mapper
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
@@ -35,7 +35,7 @@ interface ManagementMapper : BaseMapper<Tool> {
* @param searchType Type of search
* @param searchValue Value to search for
* @param searchRegex Use regex
* @return Tool object in page
* @return Tool ID in page
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see IPage
@@ -55,6 +55,7 @@ interface ManagementMapper : BaseMapper<Tool> {
* @return List of tool object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see Tool
*/
fun selectListByIds(@Param("ids") ids: List<Long>): List<Tool>
}

View File

@@ -0,0 +1,41 @@
package top.fatweb.oxygen.api.mapper.tool
import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.baomidou.mybatisplus.core.metadata.IPage
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import top.fatweb.oxygen.api.entity.tool.Tool
/**
* Tool store mapper
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see BaseMapper
* @see Tool
*/
@Mapper
interface StoreMapper : BaseMapper<Tool> {
/**
* Select tool ID in page
*
* @param page Pagination
* @param searchValue Value to search for
* @return Tool ID in page
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see IPage
*/
fun selectPage(page: IPage<Long>, @Param("searchValue") searchValue: String?): IPage<Long>
/**
* Select tool in list by tool IDs
*
* @param ids List of tool IDs
* @return List of tool object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see Tool
*/
fun selectListByIds(@Param("ids") ids: List<Long>): List<Tool>
}

View File

@@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.oxygen.api.param.PageSortParam
/**
* Get tool in management parameters
* Get tool parameters in tool management
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0

View File

@@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank
/**
* Pass tool in management parameters
* Pass tool parameters in tool management
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0

View File

@@ -0,0 +1,16 @@
package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.oxygen.api.param.PageSortParam
/**
* Get tool parameters in tool store
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see PageSortParam
*/
data class ToolStoreGetParam(
@Schema(description = "查询内容", example = "ToolName")
val searchValue: String?
) : PageSortParam()

View File

@@ -28,7 +28,7 @@ interface IManagementService : IService<Tool> {
fun getOne(id: Long): ToolVo
/**
* Get tool as page
* Get tool in page
*
* @param toolManagementGetParam Get tool parameters in tool management
* @return PageVo<ToolVo> object

View File

@@ -0,0 +1,25 @@
package top.fatweb.oxygen.api.service.tool
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.oxygen.api.entity.tool.Tool
import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolVo
/**
* Tool store service interface
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see IService
* @see Tool
*/
interface IStoreService : IService<Tool> {
/**
* Get tool in page
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun getPage(toolStoreGetParam: ToolStoreGetParam?): PageVo<ToolVo>
}

View File

@@ -0,0 +1,37 @@
package top.fatweb.oxygen.api.service.tool.impl
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service
import top.fatweb.oxygen.api.converter.tool.ToolConverter
import top.fatweb.oxygen.api.entity.tool.Tool
import top.fatweb.oxygen.api.mapper.tool.StoreMapper
import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam
import top.fatweb.oxygen.api.service.tool.IStoreService
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolVo
/**
* Tool store service implement
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ServiceImpl
* @see StoreMapper
* @see Tool
* @see IStoreService
*/
@Service
class StoreServiceImpl : ServiceImpl<StoreMapper, Tool>(), IStoreService {
override fun getPage(toolStoreGetParam: ToolStoreGetParam?): PageVo<ToolVo> {
val toolIdsPage = Page<Long>(toolStoreGetParam?.currentPage ?: 1, 20)
val toolIdsIPage = baseMapper.selectPage(toolIdsPage, toolStoreGetParam?.searchValue)
val toolPage = Page<Tool>(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total)
if (toolIdsIPage.total > 0) {
toolPage.setRecords(baseMapper.selectListByIds(toolIdsIPage.records))
}
return ToolConverter.toolPageToToolPageVo(toolPage)
}
}