This commit is contained in:
lijiaqi 2024-04-26 16:06:56 +08:00
parent f5ef07a954
commit f361186ef4
1 changed files with 12 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.query.MPJQueryWrapper;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.common.cache.ConfigCache; import com.ydool.common.cache.ConfigCache;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
@ -152,12 +153,14 @@ public class UserServiceImpl extends BaseService<UserMapper, User> implements IU
@Override @Override
public AjaxResult userList(Page page, String value, String column, String orderBy, Boolean status, String role, public AjaxResult userList(Page page, String value, String column, String orderBy, Boolean status, String role,
String dept, String job) { String dept, String job) {
QueryWrapper<User> qw = new QueryWrapper<User>(); MPJQueryWrapper<User> qw = new MPJQueryWrapper<User>();
qw.selectAll(User.class).leftJoin("t_sys_dept dept on dept.id = t.dept");
if (StrUtil.isNotBlank(value)) { if (StrUtil.isNotBlank(value)) {
qw.like("AES_DECRYPT(from_base64 (phone),'" + CodecUtils.KEY + "')", value).lambda() qw.and(query ->
query.like("AES_DECRYPT(from_base64 (t.phone),'" + CodecUtils.KEY + "')", value).lambda()
.or().like(User::getLoginName, value) .or().like(User::getLoginName, value)
.or().like(User::getRemarks, value) .or().like(User::getRemarks, value)
.or().like(User::getUserName, value); .or().like(User::getUserName, value));
} }
qw.lambda().eq(ObjectUtil.isNotNull(status), User::getStatus, status) qw.lambda().eq(ObjectUtil.isNotNull(status), User::getStatus, status)
@ -166,12 +169,16 @@ public class UserServiceImpl extends BaseService<UserMapper, User> implements IU
.eq(StrUtil.isNotBlank(job), User::getJob, job); .eq(StrUtil.isNotBlank(job), User::getJob, job);
if ("desc".equals(orderBy) && StrUtil.isNotBlank(column)) { if ("desc".equals(orderBy) && StrUtil.isNotBlank(column)) {
qw.orderByDesc(StrUtil.toUnderlineCase(column)); qw.orderByDesc("t." + StrUtil.toUnderlineCase(column));
} }
if ("asc".equals(orderBy) && StrUtil.isNotBlank(column)) { if ("asc".equals(orderBy) && StrUtil.isNotBlank(column)) {
qw.orderByAsc(StrUtil.toUnderlineCase(column)); qw.orderByAsc("t." + StrUtil.toUnderlineCase(column));
} }
if (StrUtil.isBlank(column)) {
qw.orderByAsc("dept.sort_no");
}
Page<User> pageList = page(page, qw); Page<User> pageList = page(page, qw);