feat(common): 添加通用工具类和配置优化
- 新增 JsonConfig,统一配置Long转字符串和LocalDateTime多格式支持 - 新增 MybatisPlusConfig,集成分页插件支持PostgreSQL数据库 - 新增 PhoneUtils,提供手机号格式化、验证及脱敏工具方法 - 优化 UserRoleController,使用MyBatis-Plus分页插件实现分页查询和模糊搜索 - FeishuAuthServiceImpl中调用PhoneUtils去除手机号+86前缀,确保手机号一致性处理
This commit is contained in:
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -42,15 +43,21 @@ public class UserRoleController {
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(required = false) String keyword) {
|
||||
|
||||
|
||||
Page<SysUser> page = new Page<>(pageNum, pageSize);
|
||||
List<SysUser> users = userMapper.selectPageList(null, null, keyword);
|
||||
|
||||
// 手动设置分页结果
|
||||
page.setRecords(users);
|
||||
page.setTotal(users.size());
|
||||
|
||||
return ResultUtils.success("查询成功", page);
|
||||
// 使用MyBatis-Plus分页插件,将page作为第一个参数传入
|
||||
Page<SysUser> resultPage = userMapper.selectPage(page, new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getDeleted, 0)
|
||||
.and(StringUtils.hasText(keyword), qw -> qw
|
||||
.like(SysUser::getUsername, keyword)
|
||||
.or()
|
||||
.like(SysUser::getRealName, keyword)
|
||||
.or()
|
||||
.like(SysUser::getPhone, keyword)
|
||||
)
|
||||
.orderByDesc(SysUser::getCreateTime));
|
||||
|
||||
return ResultUtils.success("查询成功", resultPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user