Add developer profile api
This commit is contained in:
@@ -80,7 +80,7 @@ class SecurityConfig(
|
||||
"/forget",
|
||||
"/retrieve"
|
||||
).anonymous()
|
||||
.requestMatchers("/tool/detail/**", "/tool/store").permitAll()
|
||||
.requestMatchers("/tool/detail/**", "/tool/store", "/tool/store/*", "/system/user/info/*").permitAll()
|
||||
// Authentication required
|
||||
.anyRequest().authenticated()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import top.fatweb.oxygen.api.entity.common.ResponseResult
|
||||
import top.fatweb.oxygen.api.param.permission.user.*
|
||||
import top.fatweb.oxygen.api.service.permission.IUserService
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithPasswordRoleInfoVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithPowerInfoVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithRoleInfoVo
|
||||
@@ -35,15 +36,34 @@ class UserController(
|
||||
* @see UserWithPowerInfoVo
|
||||
*/
|
||||
@Operation(summary = "获取当前用户信息")
|
||||
@GetMapping("info")
|
||||
@GetMapping("/info")
|
||||
fun getInfo(): ResponseResult<UserWithPowerInfoVo> =
|
||||
ResponseResult.databaseSuccess(data = userService.getInfo())
|
||||
|
||||
/**
|
||||
* Update current user information
|
||||
* Get basic user information
|
||||
*
|
||||
* @param username Username
|
||||
* @return Response object includes user basic information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ResponseResult
|
||||
* @see UserWithPowerInfoVo
|
||||
*/
|
||||
@Operation(summary = "获取指定用户基本信息")
|
||||
@GetMapping("/info/{username}")
|
||||
fun getBasicInfo(@PathVariable username: String): ResponseResult<UserWithInfoVo> =
|
||||
ResponseResult.databaseSuccess(data = userService.getBasicInfo(username))
|
||||
|
||||
/**
|
||||
* Update current user information
|
||||
*
|
||||
* @param userInfoUpdateParam Update user information parameters
|
||||
* @return Response object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see UserInfoUpdateParam
|
||||
* @see ResponseResult
|
||||
*/
|
||||
@Operation(summary = "更新当前用户信息")
|
||||
@PatchMapping("info")
|
||||
@@ -54,8 +74,12 @@ class UserController(
|
||||
/**
|
||||
* Change password
|
||||
*
|
||||
* @param userChangePasswordParam User change password parameters
|
||||
* @return Response object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see UserChangePasswordParam
|
||||
* @see ResponseResult
|
||||
*/
|
||||
@Operation(summary = "更改密码")
|
||||
@PostMapping("info")
|
||||
|
||||
@@ -2,8 +2,10 @@ package top.fatweb.oxygen.api.controller.tool
|
||||
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import top.fatweb.oxygen.api.annotation.BaseController
|
||||
import top.fatweb.oxygen.api.entity.common.ResponseResult
|
||||
import top.fatweb.oxygen.api.param.PageSortParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam
|
||||
import top.fatweb.oxygen.api.service.tool.IStoreService
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
@@ -14,18 +16,42 @@ import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IStoreService
|
||||
*/
|
||||
@BaseController(path = ["/tool/store"], name = "工具商店", description = "工具商店相关接口")
|
||||
class StoreController(
|
||||
private val storeService: IStoreService
|
||||
) {
|
||||
/**
|
||||
* Get store tool in page
|
||||
* Get store tool paging information
|
||||
*
|
||||
* @param toolStoreGetParam Get tool parameters in tool store
|
||||
* @return Response object includes store tool paging information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see ToolStoreGetParam
|
||||
* @see ResponseResult
|
||||
* @see PageVo
|
||||
* @see ToolVo
|
||||
*/
|
||||
@GetMapping
|
||||
fun get(@Valid toolStoreGetParam: ToolStoreGetParam): ResponseResult<PageVo<ToolVo>> =
|
||||
ResponseResult.databaseSuccess(data = storeService.getPage(toolStoreGetParam))
|
||||
|
||||
/**
|
||||
* Get store tool paging information by username
|
||||
*
|
||||
* @param username Username
|
||||
* @param pageSortParam Page sort parameters
|
||||
* @return Response object includes store tool paging information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see PageSortParam
|
||||
* @see ResponseResult
|
||||
* @see PageVo
|
||||
* @see ToolVo
|
||||
*/
|
||||
@GetMapping("/{username}")
|
||||
fun get(@PathVariable username: String, @Valid pageSortParam: PageSortParam): ResponseResult<PageVo<ToolVo>> =
|
||||
ResponseResult.databaseSuccess(data = storeService.getPage(pageSortParam, username))
|
||||
}
|
||||
@@ -27,6 +27,17 @@ interface UserMapper : BaseMapper<User> {
|
||||
*/
|
||||
fun selectOneWithPowerInfoByAccount(@Param("account") account: String): User?
|
||||
|
||||
/**
|
||||
* Select one user with basic information by username
|
||||
*
|
||||
* @param username Username
|
||||
* @return User object with basic information
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see User
|
||||
*/
|
||||
fun selectOneWithBasicInfoByUsername(@Param("username") username: String): User?
|
||||
|
||||
/**
|
||||
* Select user ID in page
|
||||
*
|
||||
|
||||
@@ -28,6 +28,18 @@ interface StoreMapper : BaseMapper<Tool> {
|
||||
*/
|
||||
fun selectPage(page: IPage<Long>, @Param("searchValue") searchValue: String?): IPage<Long>
|
||||
|
||||
/**
|
||||
* Select tool ID by username in page
|
||||
*
|
||||
* @param page Pagination
|
||||
* @param username Username
|
||||
* @return Tool ID in page
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see IPage
|
||||
*/
|
||||
fun selectPageByUsername(page: IPage<Long>, @Param("username") username: String): IPage<Long>
|
||||
|
||||
/**
|
||||
* Select tool in list by tool IDs
|
||||
*
|
||||
|
||||
@@ -39,6 +39,17 @@ interface IUserService : IService<User> {
|
||||
*/
|
||||
fun getInfo(): UserWithPowerInfoVo
|
||||
|
||||
/**
|
||||
* Get user information by username
|
||||
*
|
||||
* @param username Username
|
||||
* @return UserWithInfoVo object
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see UserWithInfoVo
|
||||
*/
|
||||
fun getBasicInfo(username: String): UserWithInfoVo
|
||||
|
||||
/**
|
||||
* Update user information
|
||||
*
|
||||
|
||||
@@ -28,6 +28,7 @@ import top.fatweb.oxygen.api.util.RedisUtil
|
||||
import top.fatweb.oxygen.api.util.StrUtil
|
||||
import top.fatweb.oxygen.api.util.WebUtil
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithInfoVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithPasswordRoleInfoVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithPowerInfoVo
|
||||
import top.fatweb.oxygen.api.vo.permission.UserWithRoleInfoVo
|
||||
@@ -85,6 +86,11 @@ class UserServiceImpl(
|
||||
WebUtil.getLoginUsername()?.let(::getUserWithPowerByAccount)?.let(UserConverter::userToUserWithPowerInfoVo)
|
||||
?: throw UserNotFoundException()
|
||||
|
||||
override fun getBasicInfo(username: String): UserWithInfoVo =
|
||||
baseMapper.selectOneWithBasicInfoByUsername(username)?.let(UserConverter::userToUserWithInfoVo)
|
||||
?: throw NoRecordFoundException()
|
||||
|
||||
|
||||
override fun updateInfo(userInfoUpdateParam: UserInfoUpdateParam): Boolean {
|
||||
val userId = WebUtil.getLoginUserId() ?: throw AccessDeniedException("Access denied")
|
||||
return userInfoService.update(
|
||||
|
||||
@@ -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.param.PageSortParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
import top.fatweb.oxygen.api.vo.tool.ToolVo
|
||||
@@ -22,4 +23,12 @@ interface IStoreService : IService<Tool> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
fun getPage(toolStoreGetParam: ToolStoreGetParam?): PageVo<ToolVo>
|
||||
|
||||
/**
|
||||
* Get tool by username in page
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
fun getPage(pageSortParam: PageSortParam, username: String): PageVo<ToolVo>
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.springframework.stereotype.Service
|
||||
import top.fatweb.oxygen.api.converter.tool.ToolConverter
|
||||
import top.fatweb.oxygen.api.entity.tool.Tool
|
||||
import top.fatweb.oxygen.api.mapper.tool.StoreMapper
|
||||
import top.fatweb.oxygen.api.param.PageSortParam
|
||||
import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam
|
||||
import top.fatweb.oxygen.api.service.tool.IStoreService
|
||||
import top.fatweb.oxygen.api.vo.PageVo
|
||||
@@ -35,4 +36,17 @@ class StoreServiceImpl : ServiceImpl<StoreMapper, Tool>(), IStoreService {
|
||||
|
||||
return ToolConverter.toolPageToToolPageVo(toolPage)
|
||||
}
|
||||
|
||||
override fun getPage(pageSortParam: PageSortParam, username: String): PageVo<ToolVo> {
|
||||
val toolIdsPage = Page<Long>(pageSortParam.currentPage, 20)
|
||||
toolIdsPage.setOptimizeCountSql(false)
|
||||
|
||||
val toolIdsIPage = baseMapper.selectPageByUsername(toolIdsPage, username)
|
||||
val toolPage = Page<Tool>(toolIdsIPage.current, toolIdsIPage.size, toolIdsIPage.total)
|
||||
if (toolIdsIPage.total > 0) {
|
||||
toolPage.setRecords(baseMapper.selectListByIds(toolIdsIPage.records))
|
||||
}
|
||||
|
||||
return ToolConverter.toolPageToToolPageVo(toolPage)
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,18 @@
|
||||
and (tsui.email = #{account} or t_s_user.username = #{account});
|
||||
</select>
|
||||
|
||||
<select id="selectOneWithBasicInfoByUsername" resultMap="userWithInfoMap">
|
||||
select t_s_user.id as user_id,
|
||||
t_s_user.username as user_username,
|
||||
tsui.id as user_info_id,
|
||||
tsui.nickname as user_info_nickname,
|
||||
tsui.avatar as user_info_avatar
|
||||
from t_s_user
|
||||
left join (select * from t_s_user_info where deleted = 0) as tsui on t_s_user.id = tsui.user_id
|
||||
where t_s_user.deleted = 0
|
||||
and t_s_user.username = #{username};
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultType="long">
|
||||
select t_s_user.id
|
||||
from t_s_user
|
||||
|
||||
@@ -38,6 +38,23 @@
|
||||
) as tb
|
||||
</select>
|
||||
|
||||
<select id="selectPageByUsername" resultType="long">
|
||||
select distinct tb.id
|
||||
from (select tbtm.id
|
||||
from (select temp.id, temp.author_id, temp.review, temp.publish
|
||||
from (select *,
|
||||
row_number() over (partition by t_b_tool_main.tool_id, t_b_tool_main.author_id order by t_b_tool_main.id desc)
|
||||
as rn
|
||||
from t_b_tool_main
|
||||
where deleted = 0) temp
|
||||
where temp.rn = 1) as tbtm
|
||||
left join (select * from t_s_user where deleted = 0) as tsu on tsu.id = tbtm.author_id
|
||||
where tbtm.publish != 0
|
||||
and tbtm.review = 'PASS'
|
||||
and tsu.username = #{username}
|
||||
order by tbtm.publish desc) as tb
|
||||
</select>
|
||||
|
||||
<select id="selectListByIds" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolWithAuthor">
|
||||
select t_b_tool_main.id as tool_id,
|
||||
t_b_tool_main.name as tool_name,
|
||||
|
||||
Reference in New Issue
Block a user