Fix:3; Refactor:2; Feat3; Docs:1 #23
@@ -8,8 +8,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.entity.tool.ToolBase
|
||||
import top.fatweb.oxygen.api.param.PageSortParam
|
||||
import top.fatweb.oxygen.api.param.tool.*
|
||||
import top.fatweb.oxygen.api.service.tool.IEditService
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
@@ -111,13 +113,16 @@ class EditController(
|
||||
* @return Response object includes tool list
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see PageSortParam
|
||||
* @see ResponseResult
|
||||
* @see PageVo
|
||||
* @see ToolVo
|
||||
*/
|
||||
@Trim
|
||||
@Operation(summary = "获取个人工具")
|
||||
@GetMapping
|
||||
fun get(): ResponseResult<List<ToolVo>> =
|
||||
ResponseResult.databaseSuccess(ResponseCode.DATABASE_SELECT_SUCCESS, data = editService.get())
|
||||
fun get(@Valid pageSortParam: PageSortParam): ResponseResult<PageVo<ToolVo>> =
|
||||
ResponseResult.databaseSuccess(ResponseCode.DATABASE_SELECT_SUCCESS, data = editService.getPage(pageSortParam))
|
||||
|
||||
/**
|
||||
* Get tool detail
|
||||
|
||||
@@ -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.Tool
|
||||
@@ -41,15 +42,28 @@ interface EditMapper : BaseMapper<Tool> {
|
||||
fun selectOne(@Param("id") id: Long, @Param("userId") userId: Long): Tool?
|
||||
|
||||
/**
|
||||
* Select tool in list by User ID
|
||||
* Select tool ID by user ID in page
|
||||
*
|
||||
* @param page Pagination
|
||||
* @param userId User ID
|
||||
* @return List of tool object
|
||||
* @return Tool ID in page
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IPage
|
||||
*/
|
||||
fun selectPersonalToolIdPage(page: IPage<String>, @Param("userId") userId: Long): IPage<String>
|
||||
|
||||
/**
|
||||
* Select tool in list by tool IDs and user ID
|
||||
*
|
||||
* @param toolIds List of tool Ids
|
||||
* @param userId User ID
|
||||
* @return List of Tool object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see Tool
|
||||
*/
|
||||
fun selectPersonal(@Param("userId") userId: Long): List<Tool>
|
||||
fun selectListByToolIds(@Param("toolIds") toolIds: List<String>, @Param("userId") userId: Long): List<Tool>
|
||||
|
||||
/**
|
||||
* Select tool detail
|
||||
|
||||
@@ -29,11 +29,11 @@ interface StoreMapper : BaseMapper<Tool> {
|
||||
fun selectAuthorToolIdPage(page: IPage<Long>, @Param("searchValue") searchValue: String?): IPage<String>
|
||||
|
||||
/**
|
||||
* Select tool ID by username in page
|
||||
* Select author and tool ID by username in page
|
||||
*
|
||||
* @param page Pagination
|
||||
* @param username Username
|
||||
* @return Tool ID in page
|
||||
* @return Author:Tool_ID in page
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IPage
|
||||
@@ -44,7 +44,7 @@ interface StoreMapper : BaseMapper<Tool> {
|
||||
* Select tool in list by tool IDs
|
||||
*
|
||||
* @param ids List of tool IDs
|
||||
* @return List of tool object
|
||||
* @return List of Tool object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see Tool
|
||||
|
||||
@@ -4,5 +4,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper
|
||||
import org.apache.ibatis.annotations.Mapper
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolFavorite
|
||||
|
||||
/**
|
||||
* Tool favorite mapper
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see BaseMapper
|
||||
* @see ToolFavorite
|
||||
*/
|
||||
@Mapper
|
||||
interface ToolFavoriteMapper : BaseMapper<ToolFavorite>
|
||||
@@ -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.Tool
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolBase
|
||||
import top.fatweb.oxygen.api.param.PageSortParam
|
||||
import top.fatweb.oxygen.api.param.tool.*
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
@@ -98,12 +100,15 @@ interface IEditService : IService<Tool> {
|
||||
/**
|
||||
* Get personal tools
|
||||
*
|
||||
* @return List of ToolVo object
|
||||
* @param pageSortParam Page sort parameters
|
||||
* @return PageVo<ToolVo> object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see PageSortParam
|
||||
* @see PageVo
|
||||
* @see ToolVo
|
||||
*/
|
||||
fun get(): List<ToolVo>
|
||||
fun getPage(pageSortParam: PageSortParam): PageVo<ToolVo>
|
||||
|
||||
/**
|
||||
* Get tool detail
|
||||
|
||||
@@ -19,16 +19,27 @@ interface IStoreService : IService<Tool> {
|
||||
/**
|
||||
* Get tool in page
|
||||
*
|
||||
* @param toolStoreGetParam Get tool parameters in tool store
|
||||
* @return PageVo<ToolVo> object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolStoreGetParam
|
||||
* @see PageVo
|
||||
* @see ToolVo
|
||||
*/
|
||||
fun getPage(toolStoreGetParam: ToolStoreGetParam?): PageVo<ToolVo>
|
||||
fun getPage(toolStoreGetParam: ToolStoreGetParam): PageVo<ToolVo>
|
||||
|
||||
/**
|
||||
* Get tool by username in page
|
||||
*
|
||||
* @param pageSortParam Page sort parameters
|
||||
* @param username Username
|
||||
* @return PageVo<ToolVo< object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see PageSortParam
|
||||
* @see PageVo
|
||||
* @see ToolVo
|
||||
*/
|
||||
fun getPage(pageSortParam: PageSortParam, username: String): PageVo<ToolVo>
|
||||
}
|
||||
@@ -3,4 +3,12 @@ package top.fatweb.oxygen.api.service.tool
|
||||
import com.baomidou.mybatisplus.extension.service.IService
|
||||
import top.fatweb.oxygen.api.entity.tool.ToolFavorite
|
||||
|
||||
/**
|
||||
* Tool favorite service interface
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IService
|
||||
* @see ToolFavorite
|
||||
*/
|
||||
interface IToolFavoriteService : IService<ToolFavorite>
|
||||
@@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.service.tool.impl
|
||||
|
||||
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
||||
import com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.springframework.dao.DuplicateKeyException
|
||||
import org.springframework.stereotype.Service
|
||||
@@ -12,9 +13,11 @@ import top.fatweb.oxygen.api.converter.tool.ToolTemplateConverter
|
||||
import top.fatweb.oxygen.api.entity.tool.*
|
||||
import top.fatweb.oxygen.api.exception.*
|
||||
import top.fatweb.oxygen.api.mapper.tool.EditMapper
|
||||
import top.fatweb.oxygen.api.param.PageSortParam
|
||||
import top.fatweb.oxygen.api.param.tool.*
|
||||
import top.fatweb.oxygen.api.service.tool.*
|
||||
import top.fatweb.oxygen.api.util.WebUtil
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolCategoryVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolTemplateVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
@@ -210,9 +213,18 @@ class EditServiceImpl(
|
||||
return this.getOne(tool.id!!)
|
||||
}
|
||||
|
||||
override fun get(): List<ToolVo> =
|
||||
baseMapper.selectPersonal(WebUtil.getLoginUserId()!!)
|
||||
.map(ToolConverter::toolToToolVo)
|
||||
override fun getPage(pageSortParam: PageSortParam): PageVo<ToolVo> {
|
||||
val toolIdsPage = Page<String>(pageSortParam.currentPage, 20)
|
||||
toolIdsPage.setOptimizeCountSql(false)
|
||||
|
||||
val toolIdsIPage = baseMapper.selectPersonalToolIdPage(toolIdsPage, WebUtil.getLoginUserId()!!)
|
||||
val toolPage = Page<Tool>(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total)
|
||||
if (toolIdsIPage.total > 0) {
|
||||
toolPage.setRecords(baseMapper.selectListByToolIds(toolIdsIPage.records, WebUtil.getLoginUserId()!!))
|
||||
}
|
||||
|
||||
return ToolConverter.toolPageToToolPageVo(toolPage)
|
||||
}
|
||||
|
||||
override fun detail(username: String, toolId: String, ver: String, platform: ToolBase.Platform): ToolVo {
|
||||
if (username == "!" && WebUtil.getLoginUserId() == null) {
|
||||
@@ -272,7 +284,12 @@ class EditServiceImpl(
|
||||
throw RecordAlreadyExists()
|
||||
}
|
||||
|
||||
this.detail(toolFavoriteAddParam.username!!, toolFavoriteAddParam.toolId!!, "latest", toolFavoriteAddParam.platform!!)
|
||||
this.detail(
|
||||
toolFavoriteAddParam.username!!,
|
||||
toolFavoriteAddParam.toolId!!,
|
||||
"latest",
|
||||
toolFavoriteAddParam.platform!!
|
||||
)
|
||||
|
||||
toolFavoriteService.save(
|
||||
ToolFavorite().apply {
|
||||
|
||||
@@ -25,11 +25,11 @@ import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
*/
|
||||
@Service
|
||||
class StoreServiceImpl : ServiceImpl<StoreMapper, Tool>(), IStoreService {
|
||||
override fun getPage(toolStoreGetParam: ToolStoreGetParam?): PageVo<ToolVo> {
|
||||
val toolIdsPage = Page<Long>(toolStoreGetParam?.currentPage ?: 1, 20)
|
||||
override fun getPage(toolStoreGetParam: ToolStoreGetParam): PageVo<ToolVo> {
|
||||
val toolIdsPage = Page<Long>(toolStoreGetParam.currentPage, 20)
|
||||
toolIdsPage.setOptimizeCountSql(false)
|
||||
|
||||
val toolIdsIPage = baseMapper.selectAuthorToolIdPage(toolIdsPage, toolStoreGetParam?.searchValue)
|
||||
val toolIdsIPage = baseMapper.selectAuthorToolIdPage(toolIdsPage, toolStoreGetParam.searchValue)
|
||||
val toolPage = Page<Tool>(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total)
|
||||
if (toolIdsIPage.total > 0) {
|
||||
toolPage.setRecords(baseMapper.selectListByAuthorToolIds(toolIdsIPage.records, WebUtil.getLoginUserId()))
|
||||
|
||||
@@ -6,5 +6,15 @@ import top.fatweb.oxygen.api.entity.tool.ToolFavorite
|
||||
import top.fatweb.oxygen.api.mapper.tool.ToolFavoriteMapper
|
||||
import top.fatweb.oxygen.api.service.tool.IToolFavoriteService
|
||||
|
||||
/**
|
||||
* Tool favorite service implement
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ServiceImpl
|
||||
* @see ToolFavoriteMapper
|
||||
* @see ToolFavorite
|
||||
* @see IToolFavoriteService
|
||||
*/
|
||||
@Service
|
||||
class ToolFavoriteServiceImpl : ServiceImpl<ToolFavoriteMapper, ToolFavorite>(), IToolFavoriteService
|
||||
@@ -94,7 +94,15 @@
|
||||
and t_b_tool_main.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectPersonal" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolMap">
|
||||
<select id="selectPersonalToolIdPage" resultType="string">
|
||||
select distinct t_b_tool_main.tool_id
|
||||
from t_b_tool_main
|
||||
where t_b_tool_main.deleted = 0
|
||||
and t_b_tool_main.author_id = #{userId}
|
||||
order by t_b_tool_main.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectListByToolIds" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolMap">
|
||||
select t_b_tool_main.id as tool_id,
|
||||
t_b_tool_main.name as tool_name,
|
||||
t_b_tool_main.tool_id as tool_tool_id,
|
||||
@@ -126,9 +134,18 @@
|
||||
on t_b_tool_main.id = trtmc.tool_id
|
||||
left join (select * from t_b_tool_category where deleted = 0 and enable = 1) as tbtc
|
||||
on tbtc.id = trtmc.category_id
|
||||
where t_b_tool_main.deleted = 0
|
||||
and t_b_tool_main.author_id = #{userId}
|
||||
order by t_b_tool_main.id desc
|
||||
<where>
|
||||
and t_b_tool_main.deleted = 0
|
||||
and t_b_tool_main.author_id = #{userId}
|
||||
<foreach collection="toolIds" item="item" index="index" open="and t_b_tool_main.tool_id in (" separator="," close=")"
|
||||
nullable="true">
|
||||
#{item}
|
||||
</foreach>
|
||||
</where>
|
||||
<foreach collection="toolIds" item="item" index="index" open="order by field(t_b_tool_main.tool_id," separator=","
|
||||
close="), t_b_tool_main.id desc" nullable="true">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectDetail" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolWithDataMap">
|
||||
|
||||
Reference in New Issue
Block a user