Refactor:1; Fix:2; Feat:1 #15
@@ -59,7 +59,7 @@ fun main(args: Array<String>) {
|
||||
OxygenApiApplication::class.java.getResource("/application-config-template.yml")?.readText()?.let {
|
||||
File("data/application-config.example.yml").writeText(
|
||||
it.replace(
|
||||
"\$uuid\$", UUID.randomUUID().toString().replace("-", "")
|
||||
"\$uuid\$", UUID.randomUUID().toString()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,9 +8,12 @@ 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.param.PageSortParam
|
||||
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.service.tool.IToolBaseService
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
|
||||
|
||||
/**
|
||||
@@ -40,6 +43,24 @@ class BaseController(
|
||||
fun getOne(@PathVariable id: Long): ResponseResult<ToolBaseVo> =
|
||||
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
|
||||
*
|
||||
@@ -49,11 +70,12 @@ class BaseController(
|
||||
* @see ResponseResult
|
||||
* @see ToolBaseVo
|
||||
*/
|
||||
@Operation(summary = "获取基板")
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:base', 'system:tool:add:template', 'system:tool:modify:template')")
|
||||
fun get(): ResponseResult<List<ToolBaseVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolBaseService.get())
|
||||
@Operation(summary = "获取基板列表")
|
||||
@GetMapping("/list")
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:add:template', 'system:tool:modify:template')")
|
||||
fun list(): ResponseResult<List<ToolBaseVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolBaseService.getList())
|
||||
|
||||
|
||||
/**
|
||||
* Add tool base
|
||||
|
||||
@@ -2,11 +2,13 @@ package top.fatweb.oxygen.api.controller.tool
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import jakarta.validation.Valid
|
||||
import jakarta.validation.constraints.NotNull
|
||||
import org.springframework.web.bind.annotation.*
|
||||
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.param.tool.ToolCreateParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolUpgradeParam
|
||||
@@ -37,8 +39,8 @@ class EditController(
|
||||
*/
|
||||
@Operation(summary = "获取模板")
|
||||
@GetMapping("/template")
|
||||
fun getTemplate(): ResponseResult<List<ToolTemplateVo>> =
|
||||
ResponseResult.databaseSuccess(data = editService.getTemplate())
|
||||
fun getTemplate(platform: ToolBase.Platform): ResponseResult<List<ToolTemplateVo>> =
|
||||
ResponseResult.databaseSuccess(data = editService.getTemplate(platform))
|
||||
|
||||
/**
|
||||
* Get tool template by ID
|
||||
@@ -137,11 +139,12 @@ class EditController(
|
||||
fun detail(
|
||||
@PathVariable username: String,
|
||||
@PathVariable toolId: String,
|
||||
@PathVariable ver: String
|
||||
@PathVariable ver: String,
|
||||
platform: ToolBase.Platform
|
||||
): ResponseResult<ToolVo> =
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_SELECT_SUCCESS,
|
||||
data = editService.detail(username.trim(), toolId.trim(), ver.trim())
|
||||
data = editService.detail(username.trim(), toolId.trim(), ver.trim(), platform)
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.ResponseResult
|
||||
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.service.tool.IToolTemplateService
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
|
||||
/**
|
||||
@@ -41,19 +43,22 @@ class TemplateController(
|
||||
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
|
||||
* @since 1.0.0
|
||||
* @see ToolTemplateGetParam
|
||||
* @see ResponseResult
|
||||
* @see PageVo
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
@Operation(summary = "获取模板")
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('system:tool:query:template')")
|
||||
fun get(): ResponseResult<List<ToolTemplateVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolTemplateService.get())
|
||||
fun get(toolTemplateGetParam: ToolTemplateGetParam?): ResponseResult<PageVo<ToolTemplateVo>> =
|
||||
ResponseResult.databaseSuccess(data = toolTemplateService.get(toolTemplateGetParam))
|
||||
|
||||
/**
|
||||
* Add tool template
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolDataVo
|
||||
|
||||
@@ -26,13 +28,14 @@ object ToolBaseConverter {
|
||||
name = toolBase.name,
|
||||
source = toolBase.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
dist = toolBase.dist?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
platform = toolBase.platform,
|
||||
compiled = toolBase.compiled == 1,
|
||||
createTime = toolBase.createTime,
|
||||
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
|
||||
* @return ToolBaseVo object
|
||||
@@ -46,8 +49,29 @@ object ToolBaseConverter {
|
||||
name = toolBase.name,
|
||||
source = ToolDataVo(id = toolBase.sourceId, data = null, createTime = null, updateTime = null),
|
||||
dist = ToolDataVo(id = toolBase.distId, data = null, createTime = null, updateTime = null),
|
||||
platform = toolBase.platform,
|
||||
compiled = toolBase.compiled == 1,
|
||||
createTime = toolBase.createTime,
|
||||
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)
|
||||
)
|
||||
}
|
||||
@@ -28,6 +28,7 @@ object ToolConverter {
|
||||
name = tool.name,
|
||||
toolId = tool.toolId,
|
||||
icon = tool.icon,
|
||||
platform = tool.platform,
|
||||
description = tool.description,
|
||||
base = tool.base?.let(ToolBaseConverter::toolBaseToToolBaseVo),
|
||||
author = tool.author?.let(UserConverter::userToUserWithInfoVo),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolDataVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
@@ -27,12 +29,27 @@ object ToolTemplateConverter {
|
||||
name = toolTemplate.name,
|
||||
base = toolTemplate.base?.let(ToolBaseConverter::toolBaseToToolBaseVo),
|
||||
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
platform = toolTemplate.platform,
|
||||
entryPoint = toolTemplate.entryPoint,
|
||||
enable = toolTemplate.enable == 1,
|
||||
createTime = toolTemplate.createTime,
|
||||
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
|
||||
*
|
||||
@@ -47,11 +64,13 @@ object ToolTemplateConverter {
|
||||
name = null,
|
||||
source = null,
|
||||
dist = null,
|
||||
platform = toolTemplate.base?.platform,
|
||||
compiled = null,
|
||||
createTime = null,
|
||||
updateTime = null
|
||||
),
|
||||
source = ToolDataVo(id = toolTemplate.sourceId, data = null, createTime = null, updateTime = null),
|
||||
platform = toolTemplate.platform,
|
||||
entryPoint = toolTemplate.entryPoint,
|
||||
enable = toolTemplate.enable == 1,
|
||||
createTime = toolTemplate.createTime,
|
||||
@@ -72,11 +91,13 @@ object ToolTemplateConverter {
|
||||
name = toolTemplate.base?.name,
|
||||
source = null,
|
||||
dist = ToolDataVo(id = null, data = toolTemplate.base?.distData, createTime = null, updateTime = null),
|
||||
platform = toolTemplate.base?.platform,
|
||||
compiled = null,
|
||||
createTime = null,
|
||||
updateTime = null
|
||||
),
|
||||
source = toolTemplate.source?.let(ToolDataConverter::toolDataToToolDataVo),
|
||||
platform = toolTemplate.platform,
|
||||
entryPoint = toolTemplate.entryPoint,
|
||||
enable = toolTemplate.enable == 1,
|
||||
createTime = toolTemplate.createTime,
|
||||
|
||||
@@ -60,6 +60,16 @@ class Tool {
|
||||
@TableField("icon")
|
||||
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
|
||||
*
|
||||
@@ -237,6 +247,6 @@ class Tool {
|
||||
var dist: ToolData? = null
|
||||
|
||||
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)"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package top.fatweb.oxygen.api.entity.tool
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*
|
||||
import com.fasterxml.jackson.annotation.JsonValue
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
@@ -11,6 +12,16 @@ import java.time.LocalDateTime
|
||||
*/
|
||||
@TableName("t_b_tool_base")
|
||||
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
|
||||
*
|
||||
@@ -47,6 +58,16 @@ class ToolBase {
|
||||
@TableField("dist_id")
|
||||
var distId: Long? = null
|
||||
|
||||
/**
|
||||
* Platform
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see Platform
|
||||
*/
|
||||
@TableField("platform")
|
||||
var platform: Platform? = null
|
||||
|
||||
/**
|
||||
* Has compiled
|
||||
*
|
||||
@@ -124,6 +145,6 @@ class ToolBase {
|
||||
var distData: String? = null
|
||||
|
||||
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)"
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,16 @@ class ToolTemplate {
|
||||
@TableField("source_id")
|
||||
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
|
||||
*
|
||||
@@ -124,6 +134,6 @@ class ToolTemplate {
|
||||
var base: ToolBase? = null
|
||||
|
||||
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)"
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class JwtAuthenticationTokenFilter(private val redisUtil: RedisUtil) : OncePerRe
|
||||
val token = WebUtil.getToken(tokenWithPrefix)
|
||||
JwtUtil.parseJwt(token)
|
||||
|
||||
val redisKeyPattern = "${SecurityProperties.jwtIssuer}_login_*:" + token
|
||||
val redisKeyPattern = "${SecurityProperties.jwtIssuer}_login_*:${token}"
|
||||
val redisKeys = redisUtil.keys(redisKeyPattern)
|
||||
if (redisKeys.isEmpty()) {
|
||||
throw TokenHasExpiredException()
|
||||
|
||||
@@ -93,10 +93,10 @@ class ExceptionHandler {
|
||||
|
||||
is DisabledException -> {
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
is TokenHasExpiredException -> {
|
||||
logger.debug(e.localizedMessage, e)
|
||||
ResponseResult.fail(ResponseCode.PERMISSION_TOKEN_HAS_EXPIRED, e.localizedMessage, null)
|
||||
}
|
||||
|
||||
is AccessDeniedException -> {
|
||||
logger.debug(e.localizedMessage, e)
|
||||
ResponseResult.fail(ResponseCode.PERMISSION_ACCESS_DENIED, "Access Denied", null)
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper
|
||||
import org.apache.ibatis.annotations.Mapper
|
||||
import org.apache.ibatis.annotations.Param
|
||||
import top.fatweb.oxygen.api.entity.tool.Tool
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolBase
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolTemplate
|
||||
|
||||
/**
|
||||
@@ -66,6 +67,7 @@ interface EditMapper : BaseMapper<Tool> {
|
||||
@Param("username") username: String,
|
||||
@Param("toolId") toolId: String,
|
||||
@Param("ver") ver: String,
|
||||
@Param("platform") platform: ToolBase.Platform,
|
||||
@Param("operator") operator: String?
|
||||
): List<Tool>?
|
||||
}
|
||||
@@ -43,6 +43,7 @@ interface ManagementMapper : BaseMapper<Tool> {
|
||||
fun selectPage(
|
||||
page: IPage<Long>,
|
||||
@Param("review") review: List<String>?,
|
||||
@Param("platform") platform: List<String>?,
|
||||
@Param("searchType") searchType: String,
|
||||
@Param("searchValue") searchValue: String?,
|
||||
@Param("searchRegex") searchRegex: Boolean
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package top.fatweb.oxygen.api.mapper.tool
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import org.apache.ibatis.annotations.Mapper
|
||||
import org.apache.ibatis.annotations.Param
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolTemplate
|
||||
@@ -34,5 +35,8 @@ interface ToolTemplateMapper : BaseMapper<ToolTemplate> {
|
||||
* @since 1.0.0
|
||||
* @see ToolTemplate
|
||||
*/
|
||||
fun selectList(): List<ToolTemplate>
|
||||
fun selectListWithBaseName(
|
||||
page: IPage<ToolTemplate>,
|
||||
@Param("platform") platform: List<String>?
|
||||
): IPage<ToolTemplate>
|
||||
}
|
||||
@@ -110,8 +110,8 @@ data class UserAddParam(
|
||||
*/
|
||||
@Trim
|
||||
@Schema(description = "邮箱", required = true, example = "user@email.com")
|
||||
@NotBlank(message = "Email can not be blank")
|
||||
@Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address")
|
||||
@field:NotBlank(message = "Email can not be blank")
|
||||
@field:Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address")
|
||||
var email: String?,
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,8 +112,8 @@ data class UserUpdateParam(
|
||||
*/
|
||||
@Trim
|
||||
@Schema(description = "邮箱", required = true, example = "user@email.com")
|
||||
@NotBlank(message = "Email can not be blank")
|
||||
@Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address")
|
||||
@field:NotBlank(message = "Email can not be blank")
|
||||
@field:Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address")
|
||||
var email: String?,
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,9 @@ package top.fatweb.oxygen.api.param.tool
|
||||
|
||||
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
|
||||
|
||||
/**
|
||||
* Add tool base parameters
|
||||
@@ -21,5 +23,16 @@ data class ToolBaseAddParam(
|
||||
@Trim
|
||||
@Schema(description = "名称", required = true)
|
||||
@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?
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
@@ -62,5 +62,18 @@ data class ToolManagementGetParam(
|
||||
allowableValues = ["NONE", "PROCESSING", "REJECT", "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()
|
||||
|
||||
@@ -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()
|
||||
@@ -32,15 +32,6 @@ data class ToolTemplateUpdateParam(
|
||||
@Schema(description = "名称")
|
||||
var name: String?,
|
||||
|
||||
/**
|
||||
* Base ID
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Schema(description = "Base ID")
|
||||
val baseId: Long?,
|
||||
|
||||
/**
|
||||
* Source
|
||||
*
|
||||
|
||||
@@ -2,8 +2,10 @@ package top.fatweb.oxygen.api.param.tool
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
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
|
||||
|
||||
/**
|
||||
* Upgrade tool parameters
|
||||
@@ -29,6 +31,18 @@ data class ToolUpgradeParam(
|
||||
)
|
||||
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
|
||||
*
|
||||
|
||||
@@ -264,19 +264,19 @@ class AuthenticationServiceImpl(
|
||||
override fun logout(token: String): Boolean {
|
||||
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 {
|
||||
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)
|
||||
val jwt = JwtUtil.createJwt(WebUtil.getLoginUserId().toString())
|
||||
|
||||
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(
|
||||
redisKey, loginUser, SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit
|
||||
)
|
||||
@@ -390,7 +390,7 @@ class AuthenticationServiceImpl(
|
||||
|
||||
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)
|
||||
|
||||
return LoginVo(jwt, loginUser.user.id, loginUser.user.currentLoginTime, loginUser.user.currentLoginIp)
|
||||
|
||||
@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.service.tool
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService
|
||||
import top.fatweb.oxygen.api.entity.tool.Tool
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolBase
|
||||
import top.fatweb.oxygen.api.param.tool.ToolCreateParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolUpdateParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolUpgradeParam
|
||||
@@ -19,14 +20,15 @@ import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
*/
|
||||
interface IEditService : IService<Tool> {
|
||||
/**
|
||||
* Get tool template as list
|
||||
* Get tool template as list by platform
|
||||
*
|
||||
* @return List of ToolTemplateVo object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBase.Platform
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
fun getTemplate(): List<ToolTemplateVo>
|
||||
fun getTemplate(platform: ToolBase.Platform): List<ToolTemplateVo>
|
||||
|
||||
/**
|
||||
* Get tool template by ID
|
||||
@@ -111,12 +113,14 @@ interface IEditService : IService<Tool> {
|
||||
* @param username Username
|
||||
* @param toolId Tool ID
|
||||
* @param ver Version
|
||||
* @param platform Platform
|
||||
* @return ToolVo object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBase.Platform
|
||||
* @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
|
||||
|
||||
@@ -3,7 +3,9 @@ package top.fatweb.oxygen.api.service.tool
|
||||
import com.baomidou.mybatisplus.extension.service.IService
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolBase
|
||||
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.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolBaseVo
|
||||
|
||||
/**
|
||||
@@ -27,14 +29,27 @@ interface IToolBaseService : IService<ToolBase> {
|
||||
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
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBaseVo
|
||||
*/
|
||||
fun get(): List<ToolBaseVo>
|
||||
fun getList(): List<ToolBaseVo>
|
||||
|
||||
/**
|
||||
* Add tool base
|
||||
|
||||
@@ -3,7 +3,9 @@ package top.fatweb.oxygen.api.service.tool
|
||||
import com.baomidou.mybatisplus.extension.service.IService
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolTemplate
|
||||
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.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
|
||||
/**
|
||||
@@ -27,14 +29,16 @@ interface IToolTemplateService : IService<ToolTemplate> {
|
||||
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
|
||||
* @since 1.0.0
|
||||
* @see ToolTemplateGetParam
|
||||
* @see PageVo
|
||||
* @see ToolTemplateVo
|
||||
*/
|
||||
fun get(): List<ToolTemplateVo>
|
||||
fun get(toolTemplateGetParam: ToolTemplateGetParam?): PageVo<ToolTemplateVo>
|
||||
|
||||
/**
|
||||
* Add tool template
|
||||
|
||||
@@ -38,9 +38,12 @@ class EditServiceImpl(
|
||||
private val toolDataService: IToolDataService,
|
||||
private val rToolCategoryService: IRToolCategoryService
|
||||
) : ServiceImpl<EditMapper, Tool>(), IEditService {
|
||||
override fun getTemplate(): List<ToolTemplateVo> =
|
||||
toolTemplateService.list(KtQueryWrapper(ToolTemplate()).eq(ToolTemplate::enable, 1))
|
||||
.map(ToolTemplateConverter::toolTemplateToToolTemplateVoByList)
|
||||
override fun getTemplate(platform: ToolBase.Platform): List<ToolTemplateVo> =
|
||||
toolTemplateService.list(
|
||||
KtQueryWrapper(ToolTemplate())
|
||||
.eq(ToolTemplate::platform, platform)
|
||||
.eq(ToolTemplate::enable, 1)
|
||||
).map(ToolTemplateConverter::toolTemplateToToolTemplateVoByList)
|
||||
|
||||
override fun getTemplate(id: Long): ToolTemplateVo =
|
||||
baseMapper.selectTemplate(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVoWithBaseDist)
|
||||
@@ -56,11 +59,15 @@ class EditServiceImpl(
|
||||
|
||||
@Transactional
|
||||
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!!)
|
||||
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 newDist = ToolData().apply { data = "" }
|
||||
toolDataService.saveBatch(listOf(newSource, newDist))
|
||||
@@ -69,6 +76,7 @@ class EditServiceImpl(
|
||||
name = toolCreateParam.name!!.trim()
|
||||
toolId = toolCreateParam.toolId
|
||||
icon = toolCreateParam.icon
|
||||
platform = template.platform
|
||||
description = toolCreateParam.description
|
||||
baseId = template.base!!.id
|
||||
authorId = WebUtil.getLoginUserId()!!
|
||||
@@ -94,7 +102,7 @@ class EditServiceImpl(
|
||||
|
||||
@Transactional
|
||||
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) {
|
||||
throw ToolUnderReviewException()
|
||||
}
|
||||
@@ -206,11 +214,11 @@ class EditServiceImpl(
|
||||
baseMapper.selectPersonal(WebUtil.getLoginUserId()!!)
|
||||
.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) {
|
||||
throw NoRecordFoundException()
|
||||
}
|
||||
val toolList = baseMapper.selectDetail(username, toolId, ver, WebUtil.getLoginUsername())
|
||||
val toolList = baseMapper.selectDetail(username, toolId, ver, platform, WebUtil.getLoginUsername())
|
||||
if (toolList.isNullOrEmpty()) {
|
||||
throw NoRecordFoundException()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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.KtUpdateWrapper
|
||||
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.IRToolCategoryService
|
||||
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.ToolVo
|
||||
import java.time.LocalDateTime
|
||||
@@ -53,6 +51,7 @@ class ManagementServiceImpl(
|
||||
baseMapper.selectPage(
|
||||
toolIdsPage,
|
||||
toolManagementGetParam?.review?.split(","),
|
||||
toolManagementGetParam?.platform?.split(","),
|
||||
toolManagementGetParam?.searchType ?: "ALL",
|
||||
toolManagementGetParam?.searchValue,
|
||||
toolManagementGetParam?.searchRegex ?: false
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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 org.springframework.stereotype.Service
|
||||
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.mapper.tool.ToolBaseMapper
|
||||
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.service.tool.IToolBaseService
|
||||
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
|
||||
|
||||
/**
|
||||
@@ -31,7 +36,24 @@ class ToolBaseServiceImpl(
|
||||
override fun getOne(id: Long): ToolBaseVo =
|
||||
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
|
||||
override fun add(toolBaseAddParam: ToolBaseAddParam): ToolBaseVo {
|
||||
@@ -46,6 +68,7 @@ class ToolBaseServiceImpl(
|
||||
distId = newDist.id
|
||||
source = newSource
|
||||
dist = newDist
|
||||
platform = toolBaseAddParam.platform
|
||||
}
|
||||
|
||||
this.save(toolBase)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package top.fatweb.oxygen.api.service.tool.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.springframework.stereotype.Service
|
||||
import 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.mapper.tool.ToolTemplateMapper
|
||||
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.service.tool.IToolBaseService
|
||||
import top.fatweb.oxygen.api.service.tool.IToolDataService
|
||||
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
|
||||
|
||||
/**
|
||||
@@ -34,12 +38,20 @@ class ToolTemplateServiceImpl(
|
||||
baseMapper.selectOne(id)?.let(ToolTemplateConverter::toolTemplateToToolTemplateVo)
|
||||
?: throw NoRecordFoundException()
|
||||
|
||||
override fun get(): List<ToolTemplateVo> =
|
||||
baseMapper.selectList().map(ToolTemplateConverter::toolTemplateToToolTemplateVo)
|
||||
override fun get(toolTemplateGetParam: ToolTemplateGetParam?): PageVo<ToolTemplateVo> {
|
||||
val templatePage =
|
||||
Page<ToolTemplate>(toolTemplateGetParam?.currentPage ?: 1, toolTemplateGetParam?.pageSize ?: 20)
|
||||
|
||||
PageUtil.setPageSort(toolTemplateGetParam, templatePage)
|
||||
|
||||
return ToolTemplateConverter.toolTemplatePageToToolTemplatePageVo(
|
||||
baseMapper.selectListWithBaseName(templatePage, toolTemplateGetParam?.platform?.split(","))
|
||||
)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
override fun add(toolTemplateAddParam: ToolTemplateAddParam): ToolTemplateVo {
|
||||
toolBaseService.getOne(toolTemplateAddParam.baseId!!)
|
||||
val toolBase = toolBaseService.getOne(toolTemplateAddParam.baseId!!)
|
||||
|
||||
val newSource = ToolData().apply { data = "" }
|
||||
|
||||
@@ -50,6 +62,7 @@ class ToolTemplateServiceImpl(
|
||||
baseId = toolTemplateAddParam.baseId
|
||||
sourceId = newSource.id
|
||||
source = newSource
|
||||
platform = toolBase.platform
|
||||
entryPoint = toolTemplateAddParam.entryPoint
|
||||
enable = if (toolTemplateAddParam.enable) 1 else 0
|
||||
}
|
||||
@@ -62,7 +75,6 @@ class ToolTemplateServiceImpl(
|
||||
@Transactional
|
||||
override fun update(toolTemplateUpdateParam: ToolTemplateUpdateParam): ToolTemplateVo {
|
||||
val toolTemplate = baseMapper.selectOne(toolTemplateUpdateParam.id!!) ?: throw NoRecordFoundException()
|
||||
toolTemplateUpdateParam.baseId?.let(toolBaseService::getOne)
|
||||
|
||||
toolDataService.updateById(ToolData().apply {
|
||||
id = toolTemplate.sourceId
|
||||
@@ -72,7 +84,6 @@ class ToolTemplateServiceImpl(
|
||||
this.updateById(ToolTemplate().apply {
|
||||
id = toolTemplateUpdateParam.id
|
||||
name = toolTemplateUpdateParam.name
|
||||
baseId = toolTemplateUpdateParam.baseId
|
||||
entryPoint = toolTemplateUpdateParam.entryPoint
|
||||
enable = toolTemplateUpdateParam.enable?.let { if (it) 1 else 0 }
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ object JwtUtil {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
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")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +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 java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
@@ -49,6 +50,16 @@ data class ToolBaseVo(
|
||||
@Schema(description = "产物")
|
||||
val dist: ToolDataVo?,
|
||||
|
||||
/**
|
||||
* Platform
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBase.Platform
|
||||
*/
|
||||
@Schema(description = "平台")
|
||||
val platform: ToolBase.Platform?,
|
||||
|
||||
/**
|
||||
* Compiled
|
||||
*
|
||||
|
||||
@@ -3,6 +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 java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
@@ -49,6 +50,16 @@ data class ToolTemplateVo(
|
||||
@Schema(description = "源码")
|
||||
val source: ToolDataVo?,
|
||||
|
||||
/**
|
||||
* Platform
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBase.Platform
|
||||
*/
|
||||
@Schema(description = "平台")
|
||||
val platform: ToolBase.Platform?,
|
||||
|
||||
/**
|
||||
* Entry point
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.Tool
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolBase
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@@ -50,6 +51,16 @@ data class ToolVo(
|
||||
@Schema(description = "图标")
|
||||
val icon: String?,
|
||||
|
||||
/**
|
||||
* Platform
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolBase.Platform
|
||||
*/
|
||||
@Schema(description = "平台")
|
||||
val platform: ToolBase.Platform?,
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@ app:
|
||||
# token-prefix: "Bearer " # Token prefix
|
||||
# jwt-ttl: 2 # The life of token
|
||||
# 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
|
||||
# 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]
|
||||
@@ -62,5 +62,8 @@ logging:
|
||||
# max-file-size: 10MB # Maximum log file size
|
||||
# max-history: 7 # Maximum number of archive log files to keep
|
||||
|
||||
mybatis-plus:
|
||||
type-aliases-package: top.fatweb.oxygen.api.entity
|
||||
|
||||
knife4j:
|
||||
production: true # Production environment mode will block doc
|
||||
@@ -6,6 +6,7 @@ create table if not exists t_b_tool_main
|
||||
name varchar(50) not null comment '工具名',
|
||||
tool_id varchar(50) not null comment '工具 ID',
|
||||
icon text not null comment '图标',
|
||||
platform varchar(20) not null comment '平台',
|
||||
description varchar(500) null comment '简介',
|
||||
base_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 '修改时间',
|
||||
deleted bigint 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_publish unique (tool_id, author_id, publish, 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_platform_author_publish unique (tool_id, platform, author_id, publish, deleted)
|
||||
) comment '工具-主表';
|
||||
@@ -6,11 +6,12 @@ create table if not exists t_b_tool_template
|
||||
name varchar(40) not null comment '模板名',
|
||||
base_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 '入口文件',
|
||||
enable int not null default 1 comment '启用',
|
||||
create_time datetime not null default (utc_timestamp()) comment '创建时间',
|
||||
update_time datetime not null default (utc_timestamp()) comment '修改时间',
|
||||
deleted bigint 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 '工具-模板表'
|
||||
@@ -6,10 +6,11 @@ create table if not exists t_b_tool_base
|
||||
name varchar(20) not null comment '基板名',
|
||||
source_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 '已编译',
|
||||
create_time datetime not null default (utc_timestamp()) comment '创建时间',
|
||||
update_time datetime not null default (utc_timestamp()) comment '修改时间',
|
||||
deleted bigint 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)
|
||||
)
|
||||
@@ -6,6 +6,7 @@
|
||||
t_b_tool_template.name as tool_template_name,
|
||||
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.platform as tool_template_platform,
|
||||
t_b_tool_template.entry_point as tool_template_entry_point,
|
||||
t_b_tool_template.enable as tool_template_enable,
|
||||
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.tool_id as tool_tool_id,
|
||||
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.base_id as tool_base_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.tool_id as tool_tool_id,
|
||||
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.base_id as tool_base_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.tool_id as tool_tool_id,
|
||||
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.base_id as tool_base_id,
|
||||
t_b_tool_main.author_id as tool_author_id,
|
||||
@@ -187,6 +191,7 @@
|
||||
<where>
|
||||
and t_b_tool_main.deleted = 0
|
||||
and t_b_tool_main.tool_id = #{toolId}
|
||||
and t_b_tool_main.platform = #{platform}
|
||||
<choose>
|
||||
<when test="operator == null">
|
||||
and tsu.username = #{username}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
t_b_tool_main.name as tool_name,
|
||||
t_b_tool_main.tool_id as tool_tool_id,
|
||||
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.base_id as tool_base_id,
|
||||
t_b_tool_main.author_id as tool_author_id,
|
||||
@@ -74,6 +75,11 @@
|
||||
close=")" nullable="true">
|
||||
#{item}
|
||||
</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">
|
||||
<choose>
|
||||
<when test="searchType == 'NAME'">
|
||||
@@ -155,6 +161,7 @@
|
||||
t_b_tool_main.name as tool_name,
|
||||
t_b_tool_main.tool_id as tool_tool_id,
|
||||
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.base_id as tool_base_id,
|
||||
t_b_tool_main.author_id as tool_author_id,
|
||||
@@ -216,6 +223,7 @@
|
||||
<result property="name" column="tool_name"/>
|
||||
<result property="toolId" column="tool_tool_id"/>
|
||||
<result property="icon" column="tool_icon"/>
|
||||
<result property="platform" column="tool_platform"/>
|
||||
<result property="description" column="tool_description"/>
|
||||
<result property="baseId" column="tool_base_id"/>
|
||||
<result property="authorId" column="tool_author_id"/>
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
t_b_tool_main.name as tool_name,
|
||||
t_b_tool_main.tool_id as tool_tool_id,
|
||||
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.base_id as tool_base_id,
|
||||
t_b_tool_main.author_id as tool_author_id,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
t_b_tool_base.name as tool_base_name,
|
||||
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.platform as tool_base_platform,
|
||||
t_b_tool_base.compiled as tool_base_compiled,
|
||||
t_b_tool_base.create_time as tool_base_create_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="sourceId" column="tool_base_source_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="createTime" column="tool_base_create_time"/>
|
||||
<result property="updateTime" column="tool_base_update_time"/>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
t_b_tool_template.name as tool_template_name,
|
||||
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.platform as tool_template_platform,
|
||||
t_b_tool_template.entry_point as tool_template_entry_point,
|
||||
t_b_tool_template.enable as tool_template_enable,
|
||||
t_b_tool_template.create_time as tool_template_create_time,
|
||||
@@ -27,22 +28,29 @@
|
||||
and t_b_tool_template.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultMap="toolTemplateMap">
|
||||
select t_b_tool_template.id as tool_template_id,
|
||||
t_b_tool_template.name as tool_template_name,
|
||||
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.entry_point as tool_template_entry_point,
|
||||
t_b_tool_template.enable as tool_template_enable,
|
||||
t_b_tool_template.create_time as tool_template_create_time,
|
||||
t_b_tool_template.update_time as tool_template_update_time,
|
||||
t_b_tool_template.deleted as tool_template_deleted,
|
||||
t_b_tool_template.version as tool_template_version,
|
||||
tbtb.name as tool_template_base_name
|
||||
<select id="selectListWithBaseName" resultMap="toolTemplateMap">
|
||||
select t_b_tool_template.id as tool_template_id,
|
||||
t_b_tool_template.name as tool_template_name,
|
||||
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.platform as tool_template_platform,
|
||||
t_b_tool_template.entry_point as tool_template_entry_point,
|
||||
t_b_tool_template.enable as tool_template_enable,
|
||||
t_b_tool_template.create_time as tool_template_create_time,
|
||||
t_b_tool_template.update_time as tool_template_update_time,
|
||||
t_b_tool_template.deleted as tool_template_deleted,
|
||||
t_b_tool_template.version as tool_template_version,
|
||||
tbtb.name as tool_template_base_name
|
||||
from t_b_tool_template
|
||||
left join (select * from t_b_tool_base where deleted = 0) as tbtb
|
||||
on tbtb.id = t_b_tool_template.base_id
|
||||
where t_b_tool_template.deleted = 0
|
||||
left join (select * from t_b_tool_base where deleted = 0) as tbtb
|
||||
on tbtb.id = t_b_tool_template.base_id
|
||||
<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>
|
||||
|
||||
<resultMap id="toolTemplateMap" type="toolTemplate">
|
||||
@@ -50,6 +58,7 @@
|
||||
<result property="name" column="tool_template_name"/>
|
||||
<result property="baseId" column="tool_template_base_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="enable" column="tool_template_enable"/>
|
||||
<result property="createTime" column="tool_template_create_time"/>
|
||||
|
||||
Reference in New Issue
Block a user