feat(content): 添加动态排序功能和token验证接口

- 在BaseQueryDto中新增sortBy和sortDesc字段用于排序控制
- 修改CmsContentMapper.xml实现动态SQL排序功能
- 添加validateToken接口用于验证用户登录状态
- 集成Sa-Token进行token有效性检查
- 提供清晰的排序参数描述和文档注释
This commit is contained in:
wangzhiwei 2026-01-29 17:13:26 +08:00
parent 063bfbde12
commit 85441c1a6c
3 changed files with 29 additions and 1 deletions

View File

@ -84,5 +84,22 @@ public class LoginController {
return CommonResult.success(sysUserService.phoneLogin(phoneLoginDto));
}
/**
* 验证token是否有效
*
* @return 验证结果
*/
@PostMapping("/validateToken")
@Operation(summary = "验证token是否有效", description = "验证token是否有效")
public CommonResult<Object> validateToken() {
try {
// 使用Sa-Token检查登录状态
cn.dev33.satoken.stp.StpUtil.checkLogin();
return CommonResult.success(true);
} catch (Exception e) {
return CommonResult.failed("无效的token请重新登录");
}
}
}

View File

@ -19,4 +19,10 @@ public class BaseQueryDto implements Serializable {
@Schema(description ="每页数量")
private Integer pageSize;
@Schema(description ="排序字段")
private String sortBy;
@Schema(description ="是否降序排序")
private Boolean sortDesc;
}

View File

@ -98,7 +98,12 @@
and delete_flag = #{deleteFlag}
</if>
</where>
order by sort asc, create_time desc
<if test="sortBy != null and sortBy != ''">
order by ${sortBy} ${sortDesc ? 'desc' : 'asc'}
</if>
<if test="sortBy == null or sortBy == ''">
order by sort asc, create_time desc
</if>
</select>
<!--查询列表-->