系统用户列表返回数据修改
This commit is contained in:
parent
809e670847
commit
ed87c2f676
|
|
@ -3,14 +3,10 @@ package com.czg.controller.admin;
|
||||||
import com.czg.account.dto.user.SysUserAddDTO;
|
import com.czg.account.dto.user.SysUserAddDTO;
|
||||||
import com.czg.account.dto.user.SysUserEditDTO;
|
import com.czg.account.dto.user.SysUserEditDTO;
|
||||||
import com.czg.account.dto.user.SysUserEditPwdDTO;
|
import com.czg.account.dto.user.SysUserEditPwdDTO;
|
||||||
import com.czg.account.entity.SysUser;
|
|
||||||
import com.czg.account.entity.SysUsersRoles;
|
|
||||||
import com.czg.account.service.SysUserService;
|
import com.czg.account.service.SysUserService;
|
||||||
import com.czg.account.vo.SysUserDetailVO;
|
import com.czg.account.vo.SysUserDetailVO;
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
|
||||||
import com.czg.annotation.SaAdminCheckRole;
|
import com.czg.annotation.SaAdminCheckRole;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
@ -40,7 +36,7 @@ public class SysController {
|
||||||
// @SaAdminCheckPermission("sysUser:list")
|
// @SaAdminCheckPermission("sysUser:list")
|
||||||
@SaAdminCheckRole("admin")
|
@SaAdminCheckRole("admin")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public CzgResult<Page<SysUser>> list(String key, String startTime, String endTime, Integer status) {
|
public CzgResult<Page<SysUserDetailVO>> list(String key, String startTime, String endTime, Integer status) {
|
||||||
return CzgResult.success(sysUserService.getPage(key, startTime, endTime, status));
|
return CzgResult.success(sysUserService.getPage(key, startTime, endTime, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
|
|
||||||
Boolean removeUserAndRole(Long id);
|
Boolean removeUserAndRole(Long id);
|
||||||
|
|
||||||
Page<SysUser> getPage(String key, String startTime, String endTime, Integer status);
|
Page<SysUserDetailVO> getPage(String key, String startTime, String endTime, Integer status);
|
||||||
|
|
||||||
Boolean edit(SysUserEditDTO sysUserEditDTO);
|
Boolean edit(SysUserEditDTO sysUserEditDTO);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package com.czg.service.account.mapper;
|
package com.czg.service.account.mapper;
|
||||||
|
|
||||||
import com.czg.account.entity.SysUser;
|
import com.czg.account.entity.SysUser;
|
||||||
|
import com.czg.account.vo.SysUserDetailVO;
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户 映射层。
|
* 系统用户 映射层。
|
||||||
|
|
@ -11,4 +15,5 @@ import com.mybatisflex.core.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
|
|
||||||
|
List<SysUserDetailVO> page(@Param("key") String key, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("status") Integer status);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import com.czg.service.account.mapper.SysRoleMapper;
|
||||||
import com.czg.service.account.mapper.SysUserMapper;
|
import com.czg.service.account.mapper.SysUserMapper;
|
||||||
import com.czg.service.account.mapper.SysUsersRolesMapper;
|
import com.czg.service.account.mapper.SysUsersRolesMapper;
|
||||||
import com.czg.utils.PageUtil;
|
import com.czg.utils.PageUtil;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
|
@ -99,24 +101,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SysUser> getPage(String key, String startTime, String endTime, Integer status) {
|
public Page<SysUserDetailVO> getPage(String key, String startTime, String endTime, Integer status) {
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||||
if (StrUtil.isNotBlank(key)) {
|
return PageUtil.convert(new PageInfo<>(mapper.page(key, startTime, endTime, status)));
|
||||||
queryWrapper.and(column(SysUser::getAccount).like(key).or(column(SysUser::getNickName).like(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(startTime)) {
|
|
||||||
queryWrapper.ge(SysUser::getCreateTime, DateUtil.parse(startTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(endTime)) {
|
|
||||||
queryWrapper.le(SysUser::getCreateTime, DateUtil.parse(endTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != null) {
|
|
||||||
queryWrapper.eq(SysUser::getStatus, status);
|
|
||||||
}
|
|
||||||
return page(PageUtil.buildPage(), queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -180,8 +167,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void download(String key, String startTime, String endTime, Integer status, HttpServletResponse response) throws IOException {
|
public void download(String key, String startTime, String endTime, Integer status, HttpServletResponse response) throws IOException {
|
||||||
Page<SysUser> sysUserPage = getPage(key, startTime, endTime, status);
|
Page<SysUserDetailVO> sysUserPage = getPage(key, startTime, endTime, status);
|
||||||
List<SysUser> records = sysUserPage.getRecords();
|
List<SysUserDetailVO> records = sysUserPage.getRecords();
|
||||||
|
|
||||||
// 1. 创建 ExcelWriter
|
// 1. 创建 ExcelWriter
|
||||||
// true 表示使用 XLSX 格式
|
// true 表示使用 XLSX 格式
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,25 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.czg.service.account.mapper.SysUserMapper">
|
<mapper namespace="com.czg.service.account.mapper.SysUserMapper">
|
||||||
|
|
||||||
|
<select id="page" resultType="com.czg.account.vo.SysUserDetailVO">
|
||||||
|
select a.*, b.role_id from sys_user as a
|
||||||
|
left join sys_users_roles as b on a.id=b.user_id
|
||||||
|
<where>
|
||||||
|
<if test="key != null and key != ''">
|
||||||
|
and (a.nick_name like concat('%', #{key}, '%') or a.account like concat('%', #{key}, '%'))
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
and a.create_time >= #{startTime}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
and a.create_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="status != null">
|
||||||
|
and a.status=#{status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by a.create_time desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue