diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt index 86f8d4c..dec2efb 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt @@ -7,7 +7,7 @@ import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult -import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.Platform import top.fatweb.oxygen.api.param.PageSortParam import top.fatweb.oxygen.api.param.tool.ToolCreateParam import top.fatweb.oxygen.api.param.tool.ToolUpdateParam @@ -40,7 +40,7 @@ class EditController( */ @Operation(summary = "获取模板") @GetMapping("/template") - fun getTemplate(platform: ToolBase.Platform): ResponseResult> = + fun getTemplate(platform: Platform): ResponseResult> = ResponseResult.databaseSuccess(data = editService.getTemplate(platform)) /** @@ -144,7 +144,7 @@ class EditController( @PathVariable username: String, @PathVariable toolId: String, @PathVariable ver: String, - platform: ToolBase.Platform + platform: Platform ): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_SELECT_SUCCESS, diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Platform.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Platform.kt new file mode 100644 index 0000000..f959266 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Platform.kt @@ -0,0 +1,14 @@ +package top.fatweb.oxygen.api.entity.tool + +import com.baomidou.mybatisplus.annotation.EnumValue +import com.fasterxml.jackson.annotation.JsonValue + +/** + * Platform enum + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ +enum class Platform(@field:EnumValue @field:JsonValue val code: String) { + WEB("WEB"), DESKTOP("DESKTOP"), ANDROID("ANDROID") +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt index 947f2d0..bef4466 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/Tool.kt @@ -66,10 +66,10 @@ class Tool : Serializable { * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @TableField("platform") - var platform: ToolBase.Platform? = null + var platform: Platform? = null /** * Description diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt index 94765cf..a88745b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolBase.kt @@ -1,7 +1,6 @@ package top.fatweb.oxygen.api.entity.tool import com.baomidou.mybatisplus.annotation.* -import com.fasterxml.jackson.annotation.JsonValue import java.io.Serializable import java.time.LocalDateTime @@ -13,16 +12,6 @@ import java.time.LocalDateTime */ @TableName("t_b_tool_base") class ToolBase : Serializable { - /** - * Platform enum - * - * @author FatttSnake, fatttsnake@gmail.com - * @since 1.0.0 - */ - enum class Platform(@field:EnumValue @field:JsonValue val code: String) { - WEB("WEB"), DESKTOP("DESKTOP"), ANDROID("ANDROID") - } - /** * ID * diff --git a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt index d82358b..b2b5007 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/entity/tool/ToolTemplate.kt @@ -53,10 +53,10 @@ class ToolTemplate : Serializable { * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @TableField("platform") - var platform: ToolBase.Platform? = null + var platform: Platform? = null /** * Entry point diff --git a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt index 7cc0da1..5f6bbcc 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt @@ -4,8 +4,8 @@ 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.Platform import top.fatweb.oxygen.api.entity.tool.Tool -import top.fatweb.oxygen.api.entity.tool.ToolBase import top.fatweb.oxygen.api.entity.tool.ToolTemplate /** @@ -75,13 +75,14 @@ interface EditMapper : BaseMapper { * @return List of tool object * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 + * @see Platform * @see Tool */ fun selectDetail( @Param("username") username: String, @Param("toolId") toolId: String, @Param("ver") ver: String, - @Param("platform") platform: ToolBase.Platform, + @Param("platform") platform: Platform, @Param("operator") operator: String? ): Tool? } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/StoreMapper.kt b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/StoreMapper.kt index 7efdf91..c51d574 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/StoreMapper.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/StoreMapper.kt @@ -4,6 +4,7 @@ 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.Platform import top.fatweb.oxygen.api.entity.tool.Tool /** @@ -26,7 +27,11 @@ interface StoreMapper : BaseMapper { * @since 1.0.0 * @see IPage */ - fun selectAuthorToolIdPage(page: IPage, @Param("searchValue") searchValue: String?): IPage + fun selectAuthorToolIdPage( + page: IPage, + @Param("searchValue") searchValue: String?, + @Param("platform") platform: Platform + ): IPage /** * Select author and tool ID by username in page diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt index 9a3bef3..a221097 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull import top.fatweb.oxygen.api.annotation.Trim -import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.Platform /** * Add tool base parameters @@ -30,9 +30,9 @@ data class ToolBaseAddParam( * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @Schema(description = "平台") @field:NotNull(message = "Platform can not be null") - val platform: ToolBase.Platform? + val platform: Platform? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt index f127bcb..413a893 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import top.fatweb.oxygen.api.annotation.Trim +import top.fatweb.oxygen.api.entity.tool.Platform import top.fatweb.oxygen.api.param.PageSortParam /** @@ -21,5 +22,15 @@ data class ToolStoreGetParam( */ @Trim @Schema(description = "查询内容", example = "ToolName") - var searchValue: String? + var searchValue: String?, + + /** + * Platform to search for + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Platform + */ + @Schema(description = "指定平台", example = "DESKTOP") + val platform: Platform ) : PageSortParam() diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt index 1863b31..d4d5b61 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt @@ -5,7 +5,7 @@ import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.Pattern import top.fatweb.oxygen.api.annotation.Trim -import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.Platform /** * Upgrade tool parameters @@ -36,11 +36,11 @@ data class ToolUpgradeParam( * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @Schema(description = "平台") @field:NotNull(message = "Platform can not be null") - val platform: ToolBase.Platform?, + val platform: Platform?, /** diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IEditService.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IEditService.kt index e9b64bc..32c7f60 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IEditService.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/IEditService.kt @@ -1,8 +1,8 @@ package top.fatweb.oxygen.api.service.tool import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.oxygen.api.entity.tool.Platform import top.fatweb.oxygen.api.entity.tool.Tool -import top.fatweb.oxygen.api.entity.tool.ToolBase import top.fatweb.oxygen.api.param.PageSortParam import top.fatweb.oxygen.api.param.tool.ToolCreateParam import top.fatweb.oxygen.api.param.tool.ToolUpdateParam @@ -27,10 +27,10 @@ interface IEditService : IService { * @return List of ToolTemplateVo object * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform * @see ToolTemplateVo */ - fun getTemplate(platform: ToolBase.Platform): List + fun getTemplate(platform: Platform): List /** * Get tool template by ID @@ -122,10 +122,10 @@ interface IEditService : IService { * @return ToolVo object * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform * @see ToolVo */ - fun detail(username: String, toolId: String, ver: String, platform: ToolBase.Platform): ToolVo + fun detail(username: String, toolId: String, ver: String, platform: Platform): ToolVo /** * Submit tool review diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt index 74e2208..e1b161b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt @@ -41,7 +41,7 @@ class EditServiceImpl( private val toolDataService: IToolDataService, private val rToolCategoryService: IRToolCategoryService ) : ServiceImpl(), IEditService { - override fun getTemplate(platform: ToolBase.Platform): List = + override fun getTemplate(platform: Platform): List = toolTemplateService.list( KtQueryWrapper(ToolTemplate()) .eq(ToolTemplate::platform, platform) @@ -227,7 +227,7 @@ class EditServiceImpl( return ToolConverter.toolPageToToolPageVo(toolPage) } - override fun detail(username: String, toolId: String, ver: String, platform: ToolBase.Platform): ToolVo { + override fun detail(username: String, toolId: String, ver: String, platform: Platform): ToolVo { if (username == "!" && WebUtil.getLoginUserId() == null) { throw NoRecordFoundException() } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/StoreServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/StoreServiceImpl.kt index 18fb21a..18db2eb 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/StoreServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/StoreServiceImpl.kt @@ -39,7 +39,8 @@ class StoreServiceImpl( val toolIdsPage = Page(toolStoreGetParam.currentPage, 20) toolIdsPage.setOptimizeCountSql(false) - val toolIdsIPage = baseMapper.selectAuthorToolIdPage(toolIdsPage, toolStoreGetParam.searchValue) + val toolIdsIPage = + baseMapper.selectAuthorToolIdPage(toolIdsPage, toolStoreGetParam.searchValue, toolStoreGetParam.platform) val toolPage = Page(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total) if (toolIdsIPage.total > 0) { toolPage.setRecords(baseMapper.selectListByAuthorToolIds(toolIdsIPage.records, WebUtil.getLoginUserId())) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt index 25278c1..eee7000 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolBaseVo.kt @@ -3,7 +3,7 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import io.swagger.v3.oas.annotations.media.Schema -import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.Platform import java.time.LocalDateTime /** @@ -55,10 +55,10 @@ data class ToolBaseVo( * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @Schema(description = "平台") - val platform: ToolBase.Platform?, + val platform: Platform?, /** * Compiled diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt index cad88bb..e5d8e4a 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolTemplateVo.kt @@ -3,7 +3,7 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import io.swagger.v3.oas.annotations.media.Schema -import top.fatweb.oxygen.api.entity.tool.ToolBase +import top.fatweb.oxygen.api.entity.tool.Platform import java.time.LocalDateTime /** @@ -55,10 +55,10 @@ data class ToolTemplateVo( * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @Schema(description = "平台") - val platform: ToolBase.Platform?, + val platform: Platform?, /** * Entry point diff --git a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt index 3be8f47..4515dc2 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/vo/tool/ToolVo.kt @@ -3,8 +3,8 @@ package top.fatweb.oxygen.api.vo.tool import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.entity.tool.Platform import top.fatweb.oxygen.api.entity.tool.Tool -import top.fatweb.oxygen.api.entity.tool.ToolBase import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo import java.time.LocalDateTime @@ -56,10 +56,10 @@ data class ToolVo( * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 - * @see ToolBase.Platform + * @see Platform */ @Schema(description = "平台") - val platform: ToolBase.Platform?, + val platform: Platform?, /** * Description diff --git a/src/main/resources/mapper/tool/StoreMapper.xml b/src/main/resources/mapper/tool/StoreMapper.xml index ca63d96..c526555 100644 --- a/src/main/resources/mapper/tool/StoreMapper.xml +++ b/src/main/resources/mapper/tool/StoreMapper.xml @@ -20,6 +20,9 @@ or tk.keyword like concat('%', #{searchValue}, '%') ) + + and temp1.platform = #{platform} +