Refactor:1; Fix:2; Feat:1 #15

Merged
FatttSnake merged 4 commits from FatttSnake into dev 2024-03-18 17:31:26 +08:00
44 changed files with 425 additions and 93 deletions

View File

@@ -59,7 +59,7 @@ fun main(args: Array<String>) {
OxygenApiApplication::class.java.getResource("/application-config-template.yml")?.readText()?.let { OxygenApiApplication::class.java.getResource("/application-config-template.yml")?.readText()?.let {
File("data/application-config.example.yml").writeText( File("data/application-config.example.yml").writeText(
it.replace( it.replace(
"\$uuid\$", UUID.randomUUID().toString().replace("-", "") "\$uuid\$", UUID.randomUUID().toString()
) )
) )
} }

View File

@@ -8,9 +8,12 @@ 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.param.PageSortParam
import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam
import top.fatweb.oxygen.api.param.tool.ToolBaseGetParam
import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolBaseService import top.fatweb.oxygen.api.service.tool.IToolBaseService
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
/** /**
@@ -40,6 +43,24 @@ class BaseController(
fun getOne(@PathVariable id: Long): ResponseResult<ToolBaseVo> = fun getOne(@PathVariable id: Long): ResponseResult<ToolBaseVo> =
ResponseResult.databaseSuccess(data = toolBaseService.getOne(id)) ResponseResult.databaseSuccess(data = toolBaseService.getOne(id))
/**
* Get tool base paging information
*
* @param toolBaseGetParam Get tool base parameters
* @return Response object includes tool base paging information
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBaseGetParam
* @see ResponseResult
* @see PageVo
* @see ToolBaseVo
*/
@Operation(summary = "获取基板")
@GetMapping
@PreAuthorize("hasAnyAuthority('system:tool:query:base')")
fun get(toolBaseGetParam: ToolBaseGetParam?): ResponseResult<PageVo<ToolBaseVo>> =
ResponseResult.databaseSuccess(data = toolBaseService.get(toolBaseGetParam))
/** /**
* Get tool base list * Get tool base list
* *
@@ -49,11 +70,12 @@ class BaseController(
* @see ResponseResult * @see ResponseResult
* @see ToolBaseVo * @see ToolBaseVo
*/ */
@Operation(summary = "获取基板") @Operation(summary = "获取基板列表")
@GetMapping @GetMapping("/list")
@PreAuthorize("hasAnyAuthority('system:tool:query:base', 'system:tool:add:template', 'system:tool:modify:template')") @PreAuthorize("hasAnyAuthority('system:tool:add:template', 'system:tool:modify:template')")
fun get(): ResponseResult<List<ToolBaseVo>> = fun list(): ResponseResult<List<ToolBaseVo>> =
ResponseResult.databaseSuccess(data = toolBaseService.get()) ResponseResult.databaseSuccess(data = toolBaseService.getList())
/** /**
* Add tool base * Add tool base

View File

@@ -2,11 +2,13 @@ package top.fatweb.oxygen.api.controller.tool
import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Operation
import jakarta.validation.Valid import jakarta.validation.Valid
import jakarta.validation.constraints.NotNull
import org.springframework.web.bind.annotation.* import org.springframework.web.bind.annotation.*
import top.fatweb.oxygen.api.annotation.BaseController 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.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
import top.fatweb.oxygen.api.param.tool.ToolUpgradeParam import top.fatweb.oxygen.api.param.tool.ToolUpgradeParam
@@ -37,8 +39,8 @@ class EditController(
*/ */
@Operation(summary = "获取模板") @Operation(summary = "获取模板")
@GetMapping("/template") @GetMapping("/template")
fun getTemplate(): ResponseResult<List<ToolTemplateVo>> = fun getTemplate(platform: ToolBase.Platform): ResponseResult<List<ToolTemplateVo>> =
ResponseResult.databaseSuccess(data = editService.getTemplate()) ResponseResult.databaseSuccess(data = editService.getTemplate(platform))
/** /**
* Get tool template by ID * Get tool template by ID
@@ -137,11 +139,12 @@ class EditController(
fun detail( fun detail(
@PathVariable username: String, @PathVariable username: String,
@PathVariable toolId: String, @PathVariable toolId: String,
@PathVariable ver: String @PathVariable ver: String,
platform: ToolBase.Platform
): ResponseResult<ToolVo> = ): ResponseResult<ToolVo> =
ResponseResult.databaseSuccess( ResponseResult.databaseSuccess(
ResponseCode.DATABASE_SELECT_SUCCESS, ResponseCode.DATABASE_SELECT_SUCCESS,
data = editService.detail(username.trim(), toolId.trim(), ver.trim()) data = editService.detail(username.trim(), toolId.trim(), ver.trim(), platform)
) )
/** /**

View File

@@ -9,8 +9,10 @@ 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.param.tool.ToolTemplateAddParam import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateGetParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolTemplateService import top.fatweb.oxygen.api.service.tool.IToolTemplateService
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
/** /**
@@ -41,19 +43,22 @@ class TemplateController(
ResponseResult.databaseSuccess(data = toolTemplateService.getOne(id)) ResponseResult.databaseSuccess(data = toolTemplateService.getOne(id))
/** /**
* Get tool template list * Get tool template paging information
* *
* @return Response object includes tool template list * @param toolTemplateGetParam Get tool template parameters
* @return Response object includes tool template paging information
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolTemplateGetParam
* @see ResponseResult * @see ResponseResult
* @see PageVo
* @see ToolTemplateVo * @see ToolTemplateVo
*/ */
@Operation(summary = "获取模板") @Operation(summary = "获取模板")
@GetMapping @GetMapping
@PreAuthorize("hasAnyAuthority('system:tool:query:template')") @PreAuthorize("hasAnyAuthority('system:tool:query:template')")
fun get(): ResponseResult<List<ToolTemplateVo>> = fun get(toolTemplateGetParam: ToolTemplateGetParam?): ResponseResult<PageVo<ToolTemplateVo>> =
ResponseResult.databaseSuccess(data = toolTemplateService.get()) ResponseResult.databaseSuccess(data = toolTemplateService.get(toolTemplateGetParam))
/** /**
* Add tool template * Add tool template

View File

@@ -1,6 +1,8 @@
package top.fatweb.oxygen.api.converter.tool package top.fatweb.oxygen.api.converter.tool
import com.baomidou.mybatisplus.core.metadata.IPage
import top.fatweb.oxygen.api.entity.tool.ToolBase import top.fatweb.oxygen.api.entity.tool.ToolBase
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
import top.fatweb.oxygen.api.vo.tool.ToolDataVo import top.fatweb.oxygen.api.vo.tool.ToolDataVo
@@ -26,13 +28,14 @@ object ToolBaseConverter {
name = toolBase.name, name = toolBase.name,
source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo), source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo),
dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo), dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo),
platform = toolBase.platform,
compiled = toolBase.compiled == 1, compiled = toolBase.compiled == 1,
createTime = toolBase.createTime, createTime = toolBase.createTime,
updateTime = toolBase.updateTime updateTime = toolBase.updateTime
) )
/** /**
* Convert ToolBase object into ToolBaseVo object by get list * Convert ToolBase object into ToolBaseVo object by get page
* *
* @param toolBase ToolBase object * @param toolBase ToolBase object
* @return ToolBaseVo object * @return ToolBaseVo object
@@ -46,8 +49,29 @@ object ToolBaseConverter {
name = toolBase.name, name = toolBase.name,
source = ToolDataVo(id = toolBase.sourceId, data = null, createTime = null, updateTime = null), source = ToolDataVo(id = toolBase.sourceId, data = null, createTime = null, updateTime = null),
dist = ToolDataVo(id = toolBase.distId, data = null, createTime = null, updateTime = null), dist = ToolDataVo(id = toolBase.distId, data = null, createTime = null, updateTime = null),
platform = toolBase.platform,
compiled = toolBase.compiled == 1, compiled = toolBase.compiled == 1,
createTime = toolBase.createTime, createTime = toolBase.createTime,
updateTime = toolBase.updateTime updateTime = toolBase.updateTime
) )
/**
* Convert IPage<ToolBase> object into PageVo<ToolBaseVo> object
*
* @param toolBasePage IPage<ToolBase> object
* @return PageVo<ToolBaseVo> object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see IPage
* @see ToolBase
* @see PageVo
* @see ToolBaseVo
*/
fun toolBasePageToToolBasePageVo(toolBasePage: IPage<ToolBase>) = PageVo(
total = toolBasePage.total,
pages = toolBasePage.pages,
size = toolBasePage.size,
current = toolBasePage.current,
records = toolBasePage.records.map(::toolBaseToToolBaseVoByGetList)
)
} }

View File

@@ -28,6 +28,7 @@ object ToolConverter {
name = tool.name, name = tool.name,
toolId = tool.toolId, toolId = tool.toolId,
icon = tool.icon, icon = tool.icon,
platform = tool.platform,
description = tool.description, description = tool.description,
base = tool.base?.let(ToolBaseConverter::toolBaseToToolBaseVo), base = tool.base?.let(ToolBaseConverter::toolBaseToToolBaseVo),
author = tool.author?.let(UserConverter::userToUserWithInfoVo), author = tool.author?.let(UserConverter::userToUserWithInfoVo),

View File

@@ -1,6 +1,8 @@
package top.fatweb.oxygen.api.converter.tool package top.fatweb.oxygen.api.converter.tool
import com.baomidou.mybatisplus.core.metadata.IPage
import top.fatweb.oxygen.api.entity.tool.ToolTemplate import top.fatweb.oxygen.api.entity.tool.ToolTemplate
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
import top.fatweb.oxygen.api.vo.tool.ToolDataVo import top.fatweb.oxygen.api.vo.tool.ToolDataVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
@@ -27,12 +29,27 @@ object ToolTemplateConverter {
name = toolTemplate.name, name = toolTemplate.name,
base = toolTemplate.base?.let(ToolBaseConverter::toolBaseToToolBaseVo), base = toolTemplate.base?.let(ToolBaseConverter::toolBaseToToolBaseVo),
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo), source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
platform = toolTemplate.platform,
entryPoint = toolTemplate.entryPoint, entryPoint = toolTemplate.entryPoint,
enable = toolTemplate.enable == 1, enable = toolTemplate.enable == 1,
createTime = toolTemplate.createTime, createTime = toolTemplate.createTime,
updateTime = toolTemplate.updateTime updateTime = toolTemplate.updateTime
) )
/**
* Convert IPage<ToolTemplate> object into PageVo<ToolTemplateVo> object
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
fun toolTemplatePageToToolTemplatePageVo(toolTemplatePage: IPage<ToolTemplate>) = PageVo(
total = toolTemplatePage.total,
pages = toolTemplatePage.pages,
size = toolTemplatePage.size,
current = toolTemplatePage.current,
records = toolTemplatePage.records.map(::toolTemplateToToolTemplateVo)
)
/** /**
* Convert ToolTemplate object into ToolTemplateVo object by list * Convert ToolTemplate object into ToolTemplateVo object by list
* *
@@ -47,11 +64,13 @@ object ToolTemplateConverter {
name = null, name = null,
source = null, source = null,
dist = null, dist = null,
platform = toolTemplate.base?.platform,
compiled = null, compiled = null,
createTime = null, createTime = null,
updateTime = null updateTime = null
), ),
source = ToolDataVo(id = toolTemplate.sourceId, data = null, createTime = null, updateTime = null), source = ToolDataVo(id = toolTemplate.sourceId, data = null, createTime = null, updateTime = null),
platform = toolTemplate.platform,
entryPoint = toolTemplate.entryPoint, entryPoint = toolTemplate.entryPoint,
enable = toolTemplate.enable == 1, enable = toolTemplate.enable == 1,
createTime = toolTemplate.createTime, createTime = toolTemplate.createTime,
@@ -72,11 +91,13 @@ object ToolTemplateConverter {
name = toolTemplate.base?.name, name = toolTemplate.base?.name,
source = null, source = null,
dist = ToolDataVo(id = null, data = toolTemplate.base?.distData, createTime = null, updateTime = null), dist = ToolDataVo(id = null, data = toolTemplate.base?.distData, createTime = null, updateTime = null),
platform = toolTemplate.base?.platform,
compiled = null, compiled = null,
createTime = null, createTime = null,
updateTime = null updateTime = null
), ),
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo), source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
platform = toolTemplate.platform,
entryPoint = toolTemplate.entryPoint, entryPoint = toolTemplate.entryPoint,
enable = toolTemplate.enable == 1, enable = toolTemplate.enable == 1,
createTime = toolTemplate.createTime, createTime = toolTemplate.createTime,

View File

@@ -60,6 +60,16 @@ class Tool {
@TableField("icon") @TableField("icon")
var icon: String? = null var icon: String? = null
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@TableField("platform")
var platform: ToolBase.Platform? = null
/** /**
* Description * Description
* *
@@ -237,6 +247,6 @@ class Tool {
var dist: ToolData? = null var dist: ToolData? = null
override fun toString(): String { override fun toString(): String {
return "Tool(id=$id, name=$name, toolId=$toolId, icon=$icon, description=$description, baseId=$baseId, authorId=$authorId, ver=$ver, keywords=$keywords, sourceId=$sourceId, distId=$distId, entryPoint=$entryPoint, publish=$publish, review=$review, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, author=$author, base=$base, categories=$categories, source=$source, dist=$dist)" return "Tool(id=$id, name=$name, toolId=$toolId, icon=$icon, platform=$platform, description=$description, baseId=$baseId, authorId=$authorId, ver=$ver, keywords=$keywords, sourceId=$sourceId, distId=$distId, entryPoint=$entryPoint, publish=$publish, review=$review, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, author=$author, base=$base, categories=$categories, source=$source, dist=$dist)"
} }
} }

View File

@@ -1,6 +1,7 @@
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.time.LocalDateTime import java.time.LocalDateTime
/** /**
@@ -11,6 +12,16 @@ import java.time.LocalDateTime
*/ */
@TableName("t_b_tool_base") @TableName("t_b_tool_base")
class ToolBase { class ToolBase {
/**
* 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
* *
@@ -47,6 +58,16 @@ class ToolBase {
@TableField("dist_id") @TableField("dist_id")
var distId: Long? = null var distId: Long? = null
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see Platform
*/
@TableField("platform")
var platform: Platform? = null
/** /**
* Has compiled * Has compiled
* *
@@ -124,6 +145,6 @@ class ToolBase {
var distData: String? = null var distData: String? = null
override fun toString(): String { override fun toString(): String {
return "ToolBase(id=$id, name=$name, sourceId=$sourceId, distId=$distId, compiled=$compiled, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, dist=$dist, distData=$distData)" return "ToolBase(id=$id, name=$name, sourceId=$sourceId, distId=$distId, platform=$platform, compiled=$compiled, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, dist=$dist, distData=$distData)"
} }
} }

View File

@@ -47,6 +47,16 @@ class ToolTemplate {
@TableField("source_id") @TableField("source_id")
var sourceId: Long? = null var sourceId: Long? = null
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@TableField("platform")
var platform: ToolBase.Platform? = null
/** /**
* Entry point * Entry point
* *
@@ -124,6 +134,6 @@ class ToolTemplate {
var base: ToolBase? = null var base: ToolBase? = null
override fun toString(): String { override fun toString(): String {
return "ToolTemplate(id=$id, name=$name, baseId=$baseId, sourceId=$sourceId, entryPoint=$entryPoint, enable=$enable, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, base=$base)" return "ToolTemplate(id=$id, name=$name, baseId=$baseId, sourceId=$sourceId, platform=$platform, entryPoint=$entryPoint, enable=$enable, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, source=$source, base=$base)"
} }
} }

View File

@@ -38,7 +38,7 @@ class JwtAuthenticationTokenFilter(private val redisUtil: RedisUtil) : OncePerRe
val token = WebUtil.getToken(tokenWithPrefix) val token = WebUtil.getToken(tokenWithPrefix)
JwtUtil.parseJwt(token) JwtUtil.parseJwt(token)
val redisKeyPattern = "${SecurityProperties.jwtIssuer}_login_*:" + token val redisKeyPattern = "${SecurityProperties.jwtIssuer}_login_*:${token}"
val redisKeys = redisUtil.keys(redisKeyPattern) val redisKeys = redisUtil.keys(redisKeyPattern)
if (redisKeys.isEmpty()) { if (redisKeys.isEmpty()) {
throw TokenHasExpiredException() throw TokenHasExpiredException()

View File

@@ -93,10 +93,10 @@ class ExceptionHandler {
is DisabledException -> { is DisabledException -> {
logger.debug(e.localizedMessage, e) logger.debug(e.localizedMessage, e)
ResponseResult.fail(ResponseCode.PERMISSION_USER_CREDENTIALS_EXPIRED, "User has been disabled", null) ResponseResult.fail(ResponseCode.PERMISSION_USER_DISABLE, "User has been disabled", null)
} }
is TokenExpiredException -> { is TokenExpiredException, is TokenHasExpiredException -> {
logger.debug(e.localizedMessage, e) logger.debug(e.localizedMessage, e)
ResponseResult.fail(ResponseCode.PERMISSION_TOKEN_HAS_EXPIRED, e.localizedMessage, null) ResponseResult.fail(ResponseCode.PERMISSION_TOKEN_HAS_EXPIRED, e.localizedMessage, null)
} }
@@ -120,11 +120,6 @@ class ExceptionHandler {
ResponseResult.fail(ResponseCode.PERMISSION_TOKEN_ILLEGAL, "Token illegal", null) ResponseResult.fail(ResponseCode.PERMISSION_TOKEN_ILLEGAL, "Token illegal", null)
} }
is TokenHasExpiredException -> {
logger.debug(e.localizedMessage, e)
ResponseResult.fail(ResponseCode.PERMISSION_TOKEN_HAS_EXPIRED, e.localizedMessage, null)
}
is AccessDeniedException -> { is AccessDeniedException -> {
logger.debug(e.localizedMessage, e) logger.debug(e.localizedMessage, e)
ResponseResult.fail(ResponseCode.PERMISSION_ACCESS_DENIED, "Access Denied", null) ResponseResult.fail(ResponseCode.PERMISSION_ACCESS_DENIED, "Access Denied", null)

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper
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.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
/** /**
@@ -66,6 +67,7 @@ interface EditMapper : BaseMapper<Tool> {
@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("operator") operator: String? @Param("operator") operator: String?
): List<Tool>? ): List<Tool>?
} }

View File

@@ -43,6 +43,7 @@ interface ManagementMapper : BaseMapper<Tool> {
fun selectPage( fun selectPage(
page: IPage<Long>, page: IPage<Long>,
@Param("review") review: List<String>?, @Param("review") review: List<String>?,
@Param("platform") platform: List<String>?,
@Param("searchType") searchType: String, @Param("searchType") searchType: String,
@Param("searchValue") searchValue: String?, @Param("searchValue") searchValue: String?,
@Param("searchRegex") searchRegex: Boolean @Param("searchRegex") searchRegex: Boolean

View File

@@ -1,6 +1,7 @@
package top.fatweb.oxygen.api.mapper.tool package top.fatweb.oxygen.api.mapper.tool
import com.baomidou.mybatisplus.core.mapper.BaseMapper 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.Mapper
import org.apache.ibatis.annotations.Param import org.apache.ibatis.annotations.Param
import top.fatweb.oxygen.api.entity.tool.ToolTemplate import top.fatweb.oxygen.api.entity.tool.ToolTemplate
@@ -34,5 +35,8 @@ interface ToolTemplateMapper : BaseMapper<ToolTemplate> {
* @since 1.0.0 * @since 1.0.0
* @see ToolTemplate * @see ToolTemplate
*/ */
fun selectList(): List<ToolTemplate> fun selectListWithBaseName(
page: IPage<ToolTemplate>,
@Param("platform") platform: List<String>?
): IPage<ToolTemplate>
} }

View File

@@ -110,8 +110,8 @@ data class UserAddParam(
*/ */
@Trim @Trim
@Schema(description = "邮箱", required = true, example = "user@email.com") @Schema(description = "邮箱", required = true, example = "user@email.com")
@NotBlank(message = "Email can not be blank") @field:NotBlank(message = "Email can not be blank")
@Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address") @field:Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address")
var email: String?, var email: String?,
/** /**

View File

@@ -112,8 +112,8 @@ data class UserUpdateParam(
*/ */
@Trim @Trim
@Schema(description = "邮箱", required = true, example = "user@email.com") @Schema(description = "邮箱", required = true, example = "user@email.com")
@NotBlank(message = "Email can not be blank") @field:NotBlank(message = "Email can not be blank")
@Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address") @field:Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address")
var email: String?, var email: String?,
/** /**

View File

@@ -2,7 +2,9 @@ package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotBlank
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
/** /**
* Add tool base parameters * Add tool base parameters
@@ -21,5 +23,16 @@ data class ToolBaseAddParam(
@Trim @Trim
@Schema(description = "名称", required = true) @Schema(description = "名称", required = true)
@field: NotBlank(message = "Name can not be blank") @field: NotBlank(message = "Name can not be blank")
var name: String? var name: String?,
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@Schema(description = "平台")
@field:NotNull(message = "Platform can not be null")
val platform: ToolBase.Platform?
) )

View File

@@ -0,0 +1,27 @@
package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.oxygen.api.param.PageSortParam
/**
* Get tool base parameters
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see PageSortParam
*/
@Schema(description = "获取工具基板请求参数")
data class ToolBaseGetParam(
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(
description = "平台过滤(多个使用逗号分隔)",
allowableValues = ["WEB", "DESKTOP", "ANDROID"],
example = "WEB"
)
val platform: String?
) : PageSortParam()

View File

@@ -62,5 +62,18 @@ data class ToolManagementGetParam(
allowableValues = ["NONE", "PROCESSING", "REJECT", "PASS"], allowableValues = ["NONE", "PROCESSING", "REJECT", "PASS"],
example = "NONE,PASS" example = "NONE,PASS"
) )
val review: String? val review: String?,
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(
description = "平台过滤(多个使用逗号分隔)",
allowableValues = ["WEB", "DESKTOP", "ANDROID"],
example = "WEB"
)
val platform: String?
) : PageSortParam() ) : PageSortParam()

View File

@@ -0,0 +1,27 @@
package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.oxygen.api.param.PageSortParam
/**
* Get tool template parameters
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see PageSortParam
*/
@Schema(description = "获取工具模板请求参数")
data class ToolTemplateGetParam(
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(
description = "平台过滤(多个使用逗号分隔)",
allowableValues = ["WEB", "DESKTOP", "ANDROID"],
example = "WEB"
)
val platform: String?
) : PageSortParam()

View File

@@ -32,15 +32,6 @@ data class ToolTemplateUpdateParam(
@Schema(description = "名称") @Schema(description = "名称")
var name: String?, var name: String?,
/**
* Base ID
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "Base ID")
val baseId: Long?,
/** /**
* Source * Source
* *

View File

@@ -2,8 +2,10 @@ package top.fatweb.oxygen.api.param.tool
import io.swagger.v3.oas.annotations.media.Schema 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.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
/** /**
* Upgrade tool parameters * Upgrade tool parameters
@@ -29,6 +31,18 @@ data class ToolUpgradeParam(
) )
var toolId: String?, var toolId: String?,
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@Schema(description = "平台")
@field:NotNull(message = "Platform can not be null")
val platform: ToolBase.Platform?,
/** /**
* Version * Version
* *

View File

@@ -264,19 +264,19 @@ class AuthenticationServiceImpl(
override fun logout(token: String): Boolean { override fun logout(token: String): Boolean {
val loginUser = WebUtil.getLoginUser() ?: throw TokenHasExpiredException() val loginUser = WebUtil.getLoginUser() ?: throw TokenHasExpiredException()
return redisUtil.delObject("${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:" + token) return redisUtil.delObject("${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:${token}")
} }
override fun renewToken(token: String): TokenVo { override fun renewToken(token: String): TokenVo {
val loginUser = WebUtil.getLoginUser() ?: throw TokenHasExpiredException() val loginUser = WebUtil.getLoginUser() ?: throw TokenHasExpiredException()
val oldRedisKey = "${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:" + token val oldRedisKey = "${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:${token}"
redisUtil.delObject(oldRedisKey) redisUtil.delObject(oldRedisKey)
val jwt = JwtUtil.createJwt(WebUtil.getLoginUserId().toString()) val jwt = JwtUtil.createJwt(WebUtil.getLoginUserId().toString())
jwt ?: throw RuntimeException("Login failed") jwt ?: throw RuntimeException("Login failed")
val redisKey = "${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:" + jwt val redisKey = "${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:${jwt}"
redisUtil.setObject( redisUtil.setObject(
redisKey, loginUser, SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit redisKey, loginUser, SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit
) )
@@ -390,7 +390,7 @@ class AuthenticationServiceImpl(
jwt ?: throw RuntimeException("Login failed") jwt ?: throw RuntimeException("Login failed")
val redisKey = "${SecurityProperties.jwtIssuer}_login_${userId}:" + jwt val redisKey = "${SecurityProperties.jwtIssuer}_login_${userId}:${jwt}"
redisUtil.setObject(redisKey, loginUser, SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit) redisUtil.setObject(redisKey, loginUser, SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit)
return LoginVo(jwt, loginUser.user.id, loginUser.user.currentLoginTime, loginUser.user.currentLoginIp) return LoginVo(jwt, loginUser.user.id, loginUser.user.currentLoginTime, loginUser.user.currentLoginIp)

View File

@@ -2,6 +2,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.entity.tool.ToolBase
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
import top.fatweb.oxygen.api.param.tool.ToolUpgradeParam import top.fatweb.oxygen.api.param.tool.ToolUpgradeParam
@@ -19,14 +20,15 @@ import top.fatweb.oxygen.api.vo.tool.ToolVo
*/ */
interface IEditService : IService<Tool> { interface IEditService : IService<Tool> {
/** /**
* Get tool template as list * Get tool template as list by platform
* *
* @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 ToolTemplateVo * @see ToolTemplateVo
*/ */
fun getTemplate(): List<ToolTemplateVo> fun getTemplate(platform: ToolBase.Platform): List<ToolTemplateVo>
/** /**
* Get tool template by ID * Get tool template by ID
@@ -111,12 +113,14 @@ interface IEditService : IService<Tool> {
* @param username Username * @param username Username
* @param toolId Tool ID * @param toolId Tool ID
* @param ver Version * @param ver Version
* @param platform Platform
* @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 ToolVo * @see ToolVo
*/ */
fun detail(username: String, toolId: String, ver: String): ToolVo fun detail(username: String, toolId: String, ver: String, platform: ToolBase.Platform): ToolVo
/** /**
* Submit tool review * Submit tool review

View File

@@ -3,7 +3,9 @@ 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.ToolBase import top.fatweb.oxygen.api.entity.tool.ToolBase
import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam
import top.fatweb.oxygen.api.param.tool.ToolBaseGetParam
import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
/** /**
@@ -27,14 +29,27 @@ interface IToolBaseService : IService<ToolBase> {
fun getOne(id: Long): ToolBaseVo fun getOne(id: Long): ToolBaseVo
/** /**
* Get tool base in list * Get tool base in page
*
* @param toolBaseGetParam Get tool base parameters
* @return PageVo<ToolBaseVo> object
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBaseGetParam
* @see PageVo
* @see ToolBaseVo
*/
fun get(toolBaseGetParam: ToolBaseGetParam?): PageVo<ToolBaseVo>
/**
* Get all tool base in list
* *
* @return List of ToolBaseVo object * @return List of ToolBaseVo object
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolBaseVo * @see ToolBaseVo
*/ */
fun get(): List<ToolBaseVo> fun getList(): List<ToolBaseVo>
/** /**
* Add tool base * Add tool base

View File

@@ -3,7 +3,9 @@ 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.ToolTemplate import top.fatweb.oxygen.api.entity.tool.ToolTemplate
import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateGetParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
/** /**
@@ -27,14 +29,16 @@ interface IToolTemplateService : IService<ToolTemplate> {
fun getOne(id: Long): ToolTemplateVo fun getOne(id: Long): ToolTemplateVo
/** /**
* Get tool template in list * Get tool template in page
* *
* @return List of ToolTemplateVo object * @return Page of ToolTemplateVo object
* @author FatttSnake, fatttsnake@gmail.com * @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0 * @since 1.0.0
* @see ToolTemplateGetParam
* @see PageVo
* @see ToolTemplateVo * @see ToolTemplateVo
*/ */
fun get(): List<ToolTemplateVo> fun get(toolTemplateGetParam: ToolTemplateGetParam?): PageVo<ToolTemplateVo>
/** /**
* Add tool template * Add tool template

View File

@@ -38,9 +38,12 @@ 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(): List<ToolTemplateVo> = override fun getTemplate(platform: ToolBase.Platform): List<ToolTemplateVo> =
toolTemplateService.list(KtQueryWrapper(ToolTemplate()).eq(ToolTemplate::enable, 1)) toolTemplateService.list(
.map(ToolTemplateConverter::toolTemplateToToolTemplateVoByList) KtQueryWrapper(ToolTemplate())
.eq(ToolTemplate::platform, platform)
.eq(ToolTemplate::enable, 1)
).map(ToolTemplateConverter::toolTemplateToToolTemplateVoByList)
override fun getTemplate(id: Long): ToolTemplateVo = override fun getTemplate(id: Long): ToolTemplateVo =
baseMapper.selectTemplate(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVoWithBaseDist) baseMapper.selectTemplate(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVoWithBaseDist)
@@ -56,11 +59,15 @@ class EditServiceImpl(
@Transactional @Transactional
override fun create(toolCreateParam: ToolCreateParam): ToolVo { override fun create(toolCreateParam: ToolCreateParam): ToolVo {
baseMapper.selectOne(
KtQueryWrapper(Tool()).eq(Tool::toolId, toolCreateParam.toolId!!)
.eq(Tool::authorId, WebUtil.getLoginUserId()!!)
)?.let { throw DuplicateKeyException("Duplicate Key") }
val template = this.getTemplate(toolCreateParam.templateId!!) val template = this.getTemplate(toolCreateParam.templateId!!)
baseMapper.selectOne(
KtQueryWrapper(Tool())
.eq(Tool::toolId, toolCreateParam.toolId!!)
.eq(Tool::authorId, WebUtil.getLoginUserId()!!)
.eq(Tool::platform, template.platform)
)?.let {
throw DuplicateKeyException("Duplicate Key")
}
val newSource = ToolData().apply { data = template.source!!.data } val newSource = ToolData().apply { data = template.source!!.data }
val newDist = ToolData().apply { data = "" } val newDist = ToolData().apply { data = "" }
toolDataService.saveBatch(listOf(newSource, newDist)) toolDataService.saveBatch(listOf(newSource, newDist))
@@ -69,6 +76,7 @@ class EditServiceImpl(
name = toolCreateParam.name!!.trim() name = toolCreateParam.name!!.trim()
toolId = toolCreateParam.toolId toolId = toolCreateParam.toolId
icon = toolCreateParam.icon icon = toolCreateParam.icon
platform = template.platform
description = toolCreateParam.description description = toolCreateParam.description
baseId = template.base!!.id baseId = template.base!!.id
authorId = WebUtil.getLoginUserId()!! authorId = WebUtil.getLoginUserId()!!
@@ -94,7 +102,7 @@ class EditServiceImpl(
@Transactional @Transactional
override fun upgrade(toolUpgradeParam: ToolUpgradeParam): ToolVo { override fun upgrade(toolUpgradeParam: ToolUpgradeParam): ToolVo {
val originalTool = this.detail("!", toolUpgradeParam.toolId!!, "latest") val originalTool = this.detail("!", toolUpgradeParam.toolId!!, "latest", toolUpgradeParam.platform!!)
if (originalTool.review == Tool.ReviewType.PROCESSING) { if (originalTool.review == Tool.ReviewType.PROCESSING) {
throw ToolUnderReviewException() throw ToolUnderReviewException()
} }
@@ -206,11 +214,11 @@ class EditServiceImpl(
baseMapper.selectPersonal(WebUtil.getLoginUserId()!!) baseMapper.selectPersonal(WebUtil.getLoginUserId()!!)
.map(ToolConverter::toolToToolVo) .map(ToolConverter::toolToToolVo)
override fun detail(username: String, toolId: String, ver: String): ToolVo { override fun detail(username: String, toolId: String, ver: String, platform: ToolBase.Platform): ToolVo {
if (username == "!" && WebUtil.getLoginUserId() == null) { if (username == "!" && WebUtil.getLoginUserId() == null) {
throw NoRecordFoundException() throw NoRecordFoundException()
} }
val toolList = baseMapper.selectDetail(username, toolId, ver, WebUtil.getLoginUsername()) val toolList = baseMapper.selectDetail(username, toolId, ver, platform, WebUtil.getLoginUsername())
if (toolList.isNullOrEmpty()) { if (toolList.isNullOrEmpty()) {
throw NoRecordFoundException() throw NoRecordFoundException()
} }

View File

@@ -1,6 +1,5 @@
package top.fatweb.oxygen.api.service.tool.impl package top.fatweb.oxygen.api.service.tool.impl
import com.baomidou.mybatisplus.core.metadata.OrderItem
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper import com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper
import com.baomidou.mybatisplus.extension.plugins.pagination.Page import com.baomidou.mybatisplus.extension.plugins.pagination.Page
@@ -20,7 +19,6 @@ 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.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
@@ -53,6 +51,7 @@ class ManagementServiceImpl(
baseMapper.selectPage( baseMapper.selectPage(
toolIdsPage, toolIdsPage,
toolManagementGetParam?.review?.split(","), toolManagementGetParam?.review?.split(","),
toolManagementGetParam?.platform?.split(","),
toolManagementGetParam?.searchType ?: "ALL", toolManagementGetParam?.searchType ?: "ALL",
toolManagementGetParam?.searchValue, toolManagementGetParam?.searchValue,
toolManagementGetParam?.searchRegex ?: false toolManagementGetParam?.searchRegex ?: false

View File

@@ -1,5 +1,7 @@
package top.fatweb.oxygen.api.service.tool.impl package top.fatweb.oxygen.api.service.tool.impl
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional import org.springframework.transaction.annotation.Transactional
@@ -9,9 +11,12 @@ 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.mapper.tool.ToolBaseMapper import top.fatweb.oxygen.api.mapper.tool.ToolBaseMapper
import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam
import top.fatweb.oxygen.api.param.tool.ToolBaseGetParam
import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolBaseService import top.fatweb.oxygen.api.service.tool.IToolBaseService
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.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
/** /**
@@ -31,7 +36,24 @@ class ToolBaseServiceImpl(
override fun getOne(id: Long): ToolBaseVo = override fun getOne(id: Long): ToolBaseVo =
baseMapper.selectOne(id)?.let(ToolBaseConverter::toolBaseToToolBaseVo) ?: throw NoRecordFoundException() baseMapper.selectOne(id)?.let(ToolBaseConverter::toolBaseToToolBaseVo) ?: throw NoRecordFoundException()
override fun get(): List<ToolBaseVo> = this.list().map(ToolBaseConverter::toolBaseToToolBaseVoByGetList) override fun get(toolBaseGetParam: ToolBaseGetParam?): PageVo<ToolBaseVo> {
val basePage = Page<ToolBase>(toolBaseGetParam?.currentPage ?: 1, toolBaseGetParam?.pageSize ?: 20)
PageUtil.setPageSort(toolBaseGetParam, basePage)
return ToolBaseConverter.toolBasePageToToolBasePageVo(
this.page(
basePage,
KtQueryWrapper(ToolBase()).`in`(
!toolBaseGetParam?.platform.isNullOrBlank(),
ToolBase::platform,
toolBaseGetParam?.platform?.split(",")
)
)
)
}
override fun getList(): List<ToolBaseVo> = this.list().map(ToolBaseConverter::toolBaseToToolBaseVoByGetList)
@Transactional @Transactional
override fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo { override fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo {
@@ -46,6 +68,7 @@ class ToolBaseServiceImpl(
distId = newDist.id distId = newDist.id
source = newSource source = newSource
dist = newDist dist = newDist
platform = toolBaseAddParam.platform
} }
this.save(toolBase) this.save(toolBase)

View File

@@ -1,5 +1,6 @@
package top.fatweb.oxygen.api.service.tool.impl 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional import org.springframework.transaction.annotation.Transactional
@@ -9,10 +10,13 @@ import top.fatweb.oxygen.api.entity.tool.ToolTemplate
import top.fatweb.oxygen.api.exception.NoRecordFoundException import top.fatweb.oxygen.api.exception.NoRecordFoundException
import top.fatweb.oxygen.api.mapper.tool.ToolTemplateMapper import top.fatweb.oxygen.api.mapper.tool.ToolTemplateMapper
import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateGetParam
import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam import top.fatweb.oxygen.api.param.tool.ToolTemplateUpdateParam
import top.fatweb.oxygen.api.service.tool.IToolBaseService import top.fatweb.oxygen.api.service.tool.IToolBaseService
import top.fatweb.oxygen.api.service.tool.IToolDataService import top.fatweb.oxygen.api.service.tool.IToolDataService
import top.fatweb.oxygen.api.service.tool.IToolTemplateService import top.fatweb.oxygen.api.service.tool.IToolTemplateService
import top.fatweb.oxygen.api.util.PageUtil
import top.fatweb.oxygen.api.vo.PageVo
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
/** /**
@@ -34,12 +38,20 @@ class ToolTemplateServiceImpl(
baseMapper.selectOne(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVo) baseMapper.selectOne(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVo)
?: throw NoRecordFoundException() ?: throw NoRecordFoundException()
override fun get(): List<ToolTemplateVo> = override fun get(toolTemplateGetParam: ToolTemplateGetParam?): PageVo<ToolTemplateVo> {
baseMapper.selectList().map(ToolTemplateConverter::toolTemplateToToolTemplateVo) val templatePage =
Page<ToolTemplate>(toolTemplateGetParam?.currentPage ?: 1, toolTemplateGetParam?.pageSize ?: 20)
PageUtil.setPageSort(toolTemplateGetParam, templatePage)
return ToolTemplateConverter.toolTemplatePageToToolTemplatePageVo(
baseMapper.selectListWithBaseName(templatePage, toolTemplateGetParam?.platform?.split(","))
)
}
@Transactional @Transactional
override fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo { override fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo {
toolBaseService.getOne(toolTemplateAddParam.baseId!!) val toolBase = toolBaseService.getOne(toolTemplateAddParam.baseId!!)
val newSource = ToolData().apply { data = "" } val newSource = ToolData().apply { data = "" }
@@ -50,6 +62,7 @@ class ToolTemplateServiceImpl(
baseId = toolTemplateAddParam.baseId baseId = toolTemplateAddParam.baseId
sourceId = newSource.id sourceId = newSource.id
source = newSource source = newSource
platform = toolBase.platform
entryPoint = toolTemplateAddParam.entryPoint entryPoint = toolTemplateAddParam.entryPoint
enable = if (toolTemplateAddParam.enable) 1 else 0 enable = if (toolTemplateAddParam.enable) 1 else 0
} }
@@ -62,7 +75,6 @@ class ToolTemplateServiceImpl(
@Transactional @Transactional
override fun update(toolTemplateUpdateParam: ToolTemplateUpdateParam): ToolTemplateVo { override fun update(toolTemplateUpdateParam: ToolTemplateUpdateParam): ToolTemplateVo {
val toolTemplate = baseMapper.selectOne(toolTemplateUpdateParam.id!!) ?: throw NoRecordFoundException() val toolTemplate = baseMapper.selectOne(toolTemplateUpdateParam.id!!) ?: throw NoRecordFoundException()
toolTemplateUpdateParam.baseId?.let(toolBaseService::getOne)
toolDataService.updateById(ToolData().apply { toolDataService.updateById(ToolData().apply {
id = toolTemplate.sourceId id = toolTemplate.sourceId
@@ -72,7 +84,6 @@ class ToolTemplateServiceImpl(
this.updateById(ToolTemplate().apply { this.updateById(ToolTemplate().apply {
id = toolTemplateUpdateParam.id id = toolTemplateUpdateParam.id
name = toolTemplateUpdateParam.name name = toolTemplateUpdateParam.name
baseId = toolTemplateUpdateParam.baseId
entryPoint = toolTemplateUpdateParam.entryPoint entryPoint = toolTemplateUpdateParam.entryPoint
enable = toolTemplateUpdateParam.enable?.let { if (it) 1 else 0 } enable = toolTemplateUpdateParam.enable?.let { if (it) 1 else 0 }
}) })

View File

@@ -25,7 +25,7 @@ object JwtUtil {
* @since 1.0.0 * @since 1.0.0
*/ */
private fun generalKey(): SecretKeySpec { private fun generalKey(): SecretKeySpec {
val encodeKey = Base64.getDecoder().decode(SecurityProperties.jwtKey) val encodeKey = Base64.getEncoder().encode(SecurityProperties.jwtKey.toByteArray())
return SecretKeySpec(encodeKey, 0, encodeKey.size, "AES") return SecretKeySpec(encodeKey, 0, encodeKey.size, "AES")
} }

View File

@@ -3,6 +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 java.time.LocalDateTime import java.time.LocalDateTime
/** /**
@@ -49,6 +50,16 @@ data class ToolBaseVo(
@Schema(description = "产物") @Schema(description = "产物")
val dist: ToolDataVo?, val dist: ToolDataVo?,
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@Schema(description = "平台")
val platform: ToolBase.Platform?,
/** /**
* Compiled * Compiled
* *

View File

@@ -3,6 +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 java.time.LocalDateTime import java.time.LocalDateTime
/** /**
@@ -49,6 +50,16 @@ data class ToolTemplateVo(
@Schema(description = "源码") @Schema(description = "源码")
val source: ToolDataVo?, val source: ToolDataVo?,
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@Schema(description = "平台")
val platform: ToolBase.Platform?,
/** /**
* Entry point * Entry point
* *

View File

@@ -4,6 +4,7 @@ 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.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
@@ -50,6 +51,16 @@ data class ToolVo(
@Schema(description = "图标") @Schema(description = "图标")
val icon: String?, val icon: String?,
/**
* Platform
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
* @see ToolBase.Platform
*/
@Schema(description = "平台")
val platform: ToolBase.Platform?,
/** /**
* Description * Description
* *

View File

@@ -11,7 +11,7 @@ app:
# token-prefix: "Bearer " # Token prefix # token-prefix: "Bearer " # Token prefix
# jwt-ttl: 2 # The life of token # jwt-ttl: 2 # The life of token
# jwt-ttl-unit: hours # Unit of life of token [nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days] # jwt-ttl-unit: hours # Unit of life of token [nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days]
jwt-key: $uuid$ # Key to generate token (Only numbers and letters allow) jwt-key: $uuid$ # Key to generate token
# jwt-issuer: Oxygen # Token issuer # jwt-issuer: Oxygen # Token issuer
# redis-ttl: 20 # The life of token in redis # redis-ttl: 20 # The life of token in redis
# redis-ttl-unit: minutes # Unit of life of token in redis [nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days] # redis-ttl-unit: minutes # Unit of life of token in redis [nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days]
@@ -62,5 +62,8 @@ logging:
# max-file-size: 10MB # Maximum log file size # max-file-size: 10MB # Maximum log file size
# max-history: 7 # Maximum number of archive log files to keep # max-history: 7 # Maximum number of archive log files to keep
mybatis-plus:
type-aliases-package: top.fatweb.oxygen.api.entity
knife4j: knife4j:
production: true # Production environment mode will block doc production: true # Production environment mode will block doc

View File

@@ -6,6 +6,7 @@ create table if not exists t_b_tool_main
name varchar(50) not null comment '工具名', name varchar(50) not null comment '工具名',
tool_id varchar(50) not null comment '工具 ID', tool_id varchar(50) not null comment '工具 ID',
icon text not null comment '图标', icon text not null comment '图标',
platform varchar(20) not null comment '平台',
description varchar(500) null comment '简介', description varchar(500) null comment '简介',
base_id bigint not null comment '基板 ID', base_id bigint not null comment '基板 ID',
author_id bigint not null comment '作者 ID', author_id bigint not null comment '作者 ID',
@@ -20,6 +21,6 @@ create table if not exists t_b_tool_main
update_time datetime not null default (utc_timestamp()) comment '修改时间', update_time datetime not null default (utc_timestamp()) comment '修改时间',
deleted bigint not null default 0, deleted bigint not null default 0,
version int not null default 0, version int not null default 0,
constraint t_b_tool_main_unique_tool_id_ver unique (tool_id, author_id, ver, deleted), constraint t_b_tool_main_unique_tool_id_platform_author_ver unique (tool_id, platform, author_id, ver, deleted),
constraint t_b_tool_main_unique_tool_id_publish unique (tool_id, author_id, publish, deleted) constraint t_b_tool_main_unique_tool_id_platform_author_publish unique (tool_id, platform, author_id, publish, deleted)
) comment '工具-主表'; ) comment '工具-主表';

View File

@@ -6,11 +6,12 @@ create table if not exists t_b_tool_template
name varchar(40) not null comment '模板名', name varchar(40) not null comment '模板名',
base_id bigint not null comment '基板 ID', base_id bigint not null comment '基板 ID',
source_id bigint not null comment '源码 ID', source_id bigint not null comment '源码 ID',
platform varchar(20) not null comment '平台',
entry_point varchar(64) not null default 'main.tsx' comment '入口文件', entry_point varchar(64) not null default 'main.tsx' comment '入口文件',
enable int not null default 1 comment '启用', enable int not null default 1 comment '启用',
create_time datetime not null default (utc_timestamp()) comment '创建时间', create_time datetime not null default (utc_timestamp()) comment '创建时间',
update_time datetime not null default (utc_timestamp()) comment '修改时间', update_time datetime not null default (utc_timestamp()) comment '修改时间',
deleted bigint not null default 0, deleted bigint not null default 0,
version int not null default 0, version int not null default 0,
constraint t_b_tool_template_unique_name unique (name, deleted) constraint t_b_tool_template_unique_name_platform unique (name, platform, deleted)
) comment '工具-模板表' ) comment '工具-模板表'

View File

@@ -6,10 +6,11 @@ create table if not exists t_b_tool_base
name varchar(20) not null comment '基板名', name varchar(20) not null comment '基板名',
source_id bigint not null comment '源码 ID', source_id bigint not null comment '源码 ID',
dist_id bigint not null comment '产物 ID', dist_id bigint not null comment '产物 ID',
platform varchar(20) not null comment '平台',
compiled int not null default 0 comment '已编译', compiled int not null default 0 comment '已编译',
create_time datetime not null default (utc_timestamp()) comment '创建时间', create_time datetime not null default (utc_timestamp()) comment '创建时间',
update_time datetime not null default (utc_timestamp()) comment '修改时间', update_time datetime not null default (utc_timestamp()) comment '修改时间',
deleted bigint not null default 0, deleted bigint not null default 0,
version int not null default 0, version int not null default 0,
constraint t_b_tool_base_unique_name unique (name, deleted) constraint t_b_tool_base_unique_name_platform unique (name, platform, deleted)
) )

View File

@@ -6,6 +6,7 @@
t_b_tool_template.name as tool_template_name, t_b_tool_template.name as tool_template_name,
t_b_tool_template.base_id as tool_template_base_id, t_b_tool_template.base_id as tool_template_base_id,
t_b_tool_template.source_id as tool_template_source_id, t_b_tool_template.source_id as tool_template_source_id,
t_b_tool_template.platform as tool_template_platform,
t_b_tool_template.entry_point as tool_template_entry_point, t_b_tool_template.entry_point as tool_template_entry_point,
t_b_tool_template.enable as tool_template_enable, t_b_tool_template.enable as tool_template_enable,
t_b_tool_template.create_time as tool_template_create_time, t_b_tool_template.create_time as tool_template_create_time,
@@ -35,6 +36,7 @@
t_b_tool_main.name as tool_name, t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id, t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon, t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description, t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id, t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id, t_b_tool_main.author_id as tool_author_id,
@@ -97,6 +99,7 @@
t_b_tool_main.name as tool_name, t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id, t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon, t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description, t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id, t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id, t_b_tool_main.author_id as tool_author_id,
@@ -133,6 +136,7 @@
t_b_tool_main.name as tool_name, t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id, t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon, t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description, t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id, t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id, t_b_tool_main.author_id as tool_author_id,
@@ -187,6 +191,7 @@
<where> <where>
and t_b_tool_main.deleted = 0 and t_b_tool_main.deleted = 0
and t_b_tool_main.tool_id = #{toolId} and t_b_tool_main.tool_id = #{toolId}
and t_b_tool_main.platform = #{platform}
<choose> <choose>
<when test="operator == null"> <when test="operator == null">
and tsu.username = #{username} and tsu.username = #{username}

View File

@@ -6,6 +6,7 @@
t_b_tool_main.name as tool_name, t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id, t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon, t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description, t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id, t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id, t_b_tool_main.author_id as tool_author_id,
@@ -74,6 +75,11 @@
close=")" nullable="true"> close=")" nullable="true">
#{item} #{item}
</foreach> </foreach>
<foreach collection="platform" item="item" index="index" open="and t_b_tool_main.platform in ("
separator=","
close=")" nullable="true">
#{item}
</foreach>
<if test="searchValue != null"> <if test="searchValue != null">
<choose> <choose>
<when test="searchType == 'NAME'"> <when test="searchType == 'NAME'">
@@ -155,6 +161,7 @@
t_b_tool_main.name as tool_name, t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id, t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon, t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description, t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id, t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id, t_b_tool_main.author_id as tool_author_id,
@@ -216,6 +223,7 @@
<result property="name" column="tool_name"/> <result property="name" column="tool_name"/>
<result property="toolId" column="tool_tool_id"/> <result property="toolId" column="tool_tool_id"/>
<result property="icon" column="tool_icon"/> <result property="icon" column="tool_icon"/>
<result property="platform" column="tool_platform"/>
<result property="description" column="tool_description"/> <result property="description" column="tool_description"/>
<result property="baseId" column="tool_base_id"/> <result property="baseId" column="tool_base_id"/>
<result property="authorId" column="tool_author_id"/> <result property="authorId" column="tool_author_id"/>

View File

@@ -60,6 +60,7 @@
t_b_tool_main.name as tool_name, t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id, t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon, t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description, t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id, t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id, t_b_tool_main.author_id as tool_author_id,

View File

@@ -6,6 +6,7 @@
t_b_tool_base.name as tool_base_name, t_b_tool_base.name as tool_base_name,
t_b_tool_base.source_id as tool_base_source_id, t_b_tool_base.source_id as tool_base_source_id,
t_b_tool_base.dist_id as tool_base_dist_id, t_b_tool_base.dist_id as tool_base_dist_id,
t_b_tool_base.platform as tool_base_platform,
t_b_tool_base.compiled as tool_base_compiled, t_b_tool_base.compiled as tool_base_compiled,
t_b_tool_base.create_time as tool_base_create_time, t_b_tool_base.create_time as tool_base_create_time,
t_b_tool_base.update_time as tool_base_update_time, t_b_tool_base.update_time as tool_base_update_time,
@@ -34,6 +35,7 @@
<result property="name" column="tool_base_name"/> <result property="name" column="tool_base_name"/>
<result property="sourceId" column="tool_base_source_id"/> <result property="sourceId" column="tool_base_source_id"/>
<result property="distId" column="tool_base_dist_id"/> <result property="distId" column="tool_base_dist_id"/>
<result property="platform" column="tool_base_platform"/>
<result property="compiled" column="tool_base_compiled"/> <result property="compiled" column="tool_base_compiled"/>
<result property="createTime" column="tool_base_create_time"/> <result property="createTime" column="tool_base_create_time"/>
<result property="updateTime" column="tool_base_update_time"/> <result property="updateTime" column="tool_base_update_time"/>

View File

@@ -6,6 +6,7 @@
t_b_tool_template.name as tool_template_name, t_b_tool_template.name as tool_template_name,
t_b_tool_template.base_id as tool_template_base_id, t_b_tool_template.base_id as tool_template_base_id,
t_b_tool_template.source_id as tool_template_source_id, t_b_tool_template.source_id as tool_template_source_id,
t_b_tool_template.platform as tool_template_platform,
t_b_tool_template.entry_point as tool_template_entry_point, t_b_tool_template.entry_point as tool_template_entry_point,
t_b_tool_template.enable as tool_template_enable, t_b_tool_template.enable as tool_template_enable,
t_b_tool_template.create_time as tool_template_create_time, t_b_tool_template.create_time as tool_template_create_time,
@@ -27,11 +28,12 @@
and t_b_tool_template.id = #{id} and t_b_tool_template.id = #{id}
</select> </select>
<select id="selectList" resultMap="toolTemplateMap"> <select id="selectListWithBaseName" resultMap="toolTemplateMap">
select t_b_tool_template.id as tool_template_id, select t_b_tool_template.id as tool_template_id,
t_b_tool_template.name as tool_template_name, t_b_tool_template.name as tool_template_name,
t_b_tool_template.base_id as tool_template_base_id, t_b_tool_template.base_id as tool_template_base_id,
t_b_tool_template.source_id as tool_template_source_id, t_b_tool_template.source_id as tool_template_source_id,
t_b_tool_template.platform as tool_template_platform,
t_b_tool_template.entry_point as tool_template_entry_point, t_b_tool_template.entry_point as tool_template_entry_point,
t_b_tool_template.enable as tool_template_enable, t_b_tool_template.enable as tool_template_enable,
t_b_tool_template.create_time as tool_template_create_time, t_b_tool_template.create_time as tool_template_create_time,
@@ -42,7 +44,13 @@
from t_b_tool_template from t_b_tool_template
left join (select * from t_b_tool_base where deleted = 0) as tbtb left join (select * from t_b_tool_base where deleted = 0) as tbtb
on tbtb.id = t_b_tool_template.base_id on tbtb.id = t_b_tool_template.base_id
where t_b_tool_template.deleted = 0 <where>
and t_b_tool_template.deleted = 0
<foreach collection="platform" item="item" index="index" open="and t_b_tool_template.platform in ("
separator="," close=")" nullable="true">
#{item}
</foreach>
</where>
</select> </select>
<resultMap id="toolTemplateMap" type="toolTemplate"> <resultMap id="toolTemplateMap" type="toolTemplate">
@@ -50,6 +58,7 @@
<result property="name" column="tool_template_name"/> <result property="name" column="tool_template_name"/>
<result property="baseId" column="tool_template_base_id"/> <result property="baseId" column="tool_template_base_id"/>
<result property="sourceId" column="tool_template_source_id"/> <result property="sourceId" column="tool_template_source_id"/>
<result property="platform" column="tool_template_platform"/>
<result property="entryPoint" column="tool_template_entry_point"/> <result property="entryPoint" column="tool_template_entry_point"/>
<result property="enable" column="tool_template_enable"/> <result property="enable" column="tool_template_enable"/>
<result property="createTime" column="tool_template_create_time"/> <result property="createTime" column="tool_template_create_time"/>