Refactor:1; Feat:1 #27

Merged
FatttSnake merged 2 commits from FatttSnake into dev 2024-05-10 05:15:18 +08:00
17 changed files with 69 additions and 45 deletions

View File

@@ -7,7 +7,7 @@ import top.fatweb.oxygen.api.annotation.BaseController
import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.annotation.Trim
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.entity.tool.ToolBase import top.fatweb.oxygen.api.entity.tool.Platform
import top.fatweb.oxygen.api.param.PageSortParam import top.fatweb.oxygen.api.param.PageSortParam
import top.fatweb.oxygen.api.param.tool.ToolCreateParam import top.fatweb.oxygen.api.param.tool.ToolCreateParam
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam import top.fatweb.oxygen.api.param.tool.ToolUpdateParam
@@ -40,7 +40,7 @@ class EditController(
*/ */
@Operation(summary = "获取模板") @Operation(summary = "获取模板")
@GetMapping("/template") @GetMapping("/template")
fun getTemplate(platform: ToolBase.Platform): ResponseResult<List<ToolTemplateVo>> = fun getTemplate(platform: Platform): ResponseResult<List<ToolTemplateVo>> =
ResponseResult.databaseSuccess(data = editService.getTemplate(platform)) ResponseResult.databaseSuccess(data = editService.getTemplate(platform))
/** /**
@@ -144,7 +144,7 @@ class EditController(
@PathVariable username: String, @PathVariable username: String,
@PathVariable toolId: String, @PathVariable toolId: String,
@PathVariable ver: String, @PathVariable ver: String,
platform: ToolBase.Platform platform: Platform
): ResponseResult<ToolVo> = ): ResponseResult<ToolVo> =
ResponseResult.databaseSuccess( ResponseResult.databaseSuccess(
ResponseCode.DATABASE_SELECT_SUCCESS, ResponseCode.DATABASE_SELECT_SUCCESS,

View File

@@ -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")
}

View File

@@ -66,10 +66,10 @@ class Tool : Serializable {
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@TableField("platform") @TableField("platform")
var platform: ToolBase.Platform? = null var platform: Platform? = null
/** /**
* Description * Description

View File

@@ -1,7 +1,6 @@
package top.fatweb.oxygen.api.entity.tool package top.fatweb.oxygen.api.entity.tool
import com.baomidou.mybatisplus.annotation.* import com.baomidou.mybatisplus.annotation.*
import com.fasterxml.jackson.annotation.JsonValue
import java.io.Serializable import java.io.Serializable
import java.time.LocalDateTime import java.time.LocalDateTime
@@ -13,16 +12,6 @@ import java.time.LocalDateTime
*/ */
@TableName("t_b_tool_base") @TableName("t_b_tool_base")
class ToolBase : Serializable { 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 * ID
* *

View File

@@ -53,10 +53,10 @@ class ToolTemplate : Serializable {
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@TableField("platform") @TableField("platform")
var platform: ToolBase.Platform? = null var platform: Platform? = null
/** /**
* Entry point * Entry point

View File

@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.baomidou.mybatisplus.core.metadata.IPage import com.baomidou.mybatisplus.core.metadata.IPage
import org.apache.ibatis.annotations.Mapper import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param 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.Tool
import top.fatweb.oxygen.api.entity.tool.ToolBase
import top.fatweb.oxygen.api.entity.tool.ToolTemplate import top.fatweb.oxygen.api.entity.tool.ToolTemplate
/** /**
@@ -75,13 +75,14 @@ interface EditMapper : BaseMapper<Tool> {
* @return List of tool object * @return List of tool object
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see Platform
* @see Tool * @see Tool
*/ */
fun selectDetail( fun selectDetail(
@Param("username") username: String, @Param("username") username: String,
@Param("toolId") toolId: String, @Param("toolId") toolId: String,
@Param("ver") ver: String, @Param("ver") ver: String,
@Param("platform") platform: ToolBase.Platform, @Param("platform") platform: Platform,
@Param("operator") operator: String? @Param("operator") operator: String?
): Tool? ): Tool?
} }

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.baomidou.mybatisplus.core.metadata.IPage import com.baomidou.mybatisplus.core.metadata.IPage
import org.apache.ibatis.annotations.Mapper import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param 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.Tool
/** /**
@@ -26,7 +27,11 @@ interface StoreMapper : BaseMapper<Tool> {
* @since 1.0.0 * @since 1.0.0
* @see IPage * @see IPage
*/ */
fun selectAuthorToolIdPage(page: IPage<Long>, @Param("searchValue") searchValue: String?): IPage<String> fun selectAuthorToolIdPage(
page: IPage<Long>,
@Param("searchValue") searchValue: String?,
@Param("platform") platform: Platform
): IPage<String>
/** /**
* Select author and tool ID by username in page * Select author and tool ID by username in page

View File

@@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.NotNull
import top.fatweb.oxygen.api.annotation.Trim 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 * Add tool base parameters
@@ -30,9 +30,9 @@ data class ToolBaseAddParam(
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@Schema(description = "平台") @Schema(description = "平台")
@field:NotNull(message = "Platform can not be null") @field:NotNull(message = "Platform can not be null")
val platform: ToolBase.Platform? val platform: Platform?
) )

View File

@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.annotation.Trim
import top.fatweb.oxygen.api.entity.tool.Platform
import top.fatweb.oxygen.api.param.PageSortParam import top.fatweb.oxygen.api.param.PageSortParam
/** /**
@@ -21,5 +22,15 @@ data class ToolStoreGetParam(
*/ */
@Trim @Trim
@Schema(description = "查询内容", example = "ToolName") @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() ) : PageSortParam()

View File

@@ -5,7 +5,7 @@ import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Pattern import jakarta.validation.constraints.Pattern
import top.fatweb.oxygen.api.annotation.Trim 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 * Upgrade tool parameters
@@ -36,11 +36,11 @@ data class ToolUpgradeParam(
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@Schema(description = "平台") @Schema(description = "平台")
@field:NotNull(message = "Platform can not be null") @field:NotNull(message = "Platform can not be null")
val platform: ToolBase.Platform?, val platform: Platform?,
/** /**

View File

@@ -1,8 +1,8 @@
package top.fatweb.oxygen.api.service.tool 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.Platform
import top.fatweb.oxygen.api.entity.tool.Tool 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.PageSortParam
import top.fatweb.oxygen.api.param.tool.ToolCreateParam import top.fatweb.oxygen.api.param.tool.ToolCreateParam
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam import top.fatweb.oxygen.api.param.tool.ToolUpdateParam
@@ -27,10 +27,10 @@ interface IEditService : IService<Tool> {
* @return List of ToolTemplateVo object * @return List of ToolTemplateVo object
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
* @see ToolTemplateVo * @see ToolTemplateVo
*/ */
fun getTemplate(platform: ToolBase.Platform): List<ToolTemplateVo> fun getTemplate(platform: Platform): List<ToolTemplateVo>
/** /**
* Get tool template by ID * Get tool template by ID
@@ -122,10 +122,10 @@ interface IEditService : IService<Tool> {
* @return ToolVo object * @return ToolVo object
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
* @see ToolVo * @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 * Submit tool review

View File

@@ -41,7 +41,7 @@ class EditServiceImpl(
private val toolDataService: IToolDataService, private val toolDataService: IToolDataService,
private val rToolCategoryService: IRToolCategoryService private val rToolCategoryService: IRToolCategoryService
) : ServiceImpl<EditMapper, Tool>(), IEditService { ) : ServiceImpl<EditMapper, Tool>(), IEditService {
override fun getTemplate(platform: ToolBase.Platform): List<ToolTemplateVo> = override fun getTemplate(platform: Platform): List<ToolTemplateVo> =
toolTemplateService.list( toolTemplateService.list(
KtQueryWrapper(ToolTemplate()) KtQueryWrapper(ToolTemplate())
.eq(ToolTemplate::platform, platform) .eq(ToolTemplate::platform, platform)
@@ -227,7 +227,7 @@ class EditServiceImpl(
return ToolConverter.toolPageToToolPageVo(toolPage) 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) { if (username == "!" && WebUtil.getLoginUserId() == null) {
throw NoRecordFoundException() throw NoRecordFoundException()
} }

View File

@@ -39,7 +39,8 @@ class StoreServiceImpl(
val toolIdsPage = Page<Long>(toolStoreGetParam.currentPage, 20) val toolIdsPage = Page<Long>(toolStoreGetParam.currentPage, 20)
toolIdsPage.setOptimizeCountSql(false) toolIdsPage.setOptimizeCountSql(false)
val toolIdsIPage = baseMapper.selectAuthorToolIdPage(toolIdsPage, toolStoreGetParam.searchValue) val toolIdsIPage =
baseMapper.selectAuthorToolIdPage(toolIdsPage, toolStoreGetParam.searchValue, toolStoreGetParam.platform)
val toolPage = Page<Tool>(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total) val toolPage = Page<Tool>(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total)
if (toolIdsIPage.total > 0) { if (toolIdsIPage.total > 0) {
toolPage.setRecords(baseMapper.selectListByAuthorToolIds(toolIdsIPage.records, WebUtil.getLoginUserId())) toolPage.setRecords(baseMapper.selectListByAuthorToolIds(toolIdsIPage.records, WebUtil.getLoginUserId()))

View File

@@ -3,7 +3,7 @@ package top.fatweb.oxygen.api.vo.tool
import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
import io.swagger.v3.oas.annotations.media.Schema 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 import java.time.LocalDateTime
/** /**
@@ -55,10 +55,10 @@ data class ToolBaseVo(
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@Schema(description = "平台") @Schema(description = "平台")
val platform: ToolBase.Platform?, val platform: Platform?,
/** /**
* Compiled * Compiled

View File

@@ -3,7 +3,7 @@ package top.fatweb.oxygen.api.vo.tool
import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
import io.swagger.v3.oas.annotations.media.Schema 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 import java.time.LocalDateTime
/** /**
@@ -55,10 +55,10 @@ data class ToolTemplateVo(
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@Schema(description = "平台") @Schema(description = "平台")
val platform: ToolBase.Platform?, val platform: Platform?,
/** /**
* Entry point * Entry point

View File

@@ -3,8 +3,8 @@ package top.fatweb.oxygen.api.vo.tool
import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
import io.swagger.v3.oas.annotations.media.Schema 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.Tool
import top.fatweb.oxygen.api.entity.tool.ToolBase
import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo
import java.time.LocalDateTime import java.time.LocalDateTime
@@ -56,10 +56,10 @@ data class ToolVo(
* *
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBase.Platform * @see Platform
*/ */
@Schema(description = "平台") @Schema(description = "平台")
val platform: ToolBase.Platform?, val platform: Platform?,
/** /**
* Description * Description

View File

@@ -20,6 +20,9 @@
or tk.keyword like concat('%', #{searchValue}, '%') or tk.keyword like concat('%', #{searchValue}, '%')
) )
</if> </if>
<if test="platform != null">
and temp1.platform = #{platform}
</if>
</where> </where>
<choose> <choose>
<when test="searchValue != null"> <when test="searchValue != null">