Explorar el Código

用户分页修改

gao.qiang hace 2 años
padre
commit
cd996fd54b

+ 3 - 0
base-system/src/main/java/com/ozs/system/mapper/SysUserMapper.java

@@ -3,6 +3,7 @@ package com.ozs.system.mapper;
 import java.util.List;
 
 import com.ozs.common.core.domain.entity.SysUserUpdate;
+import com.ozs.common.core.domain.vo.SysUserVo;
 import icu.mhb.mybatisplus.plugln.base.mapper.JoinBaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -162,4 +163,6 @@ public interface SysUserMapper extends JoinBaseMapper<SysUser> {
     boolean dataPermission(@Param("id") Long id, @Param("dataPermission") int dataPermission);
 
     SysUser selectUserByUserId(@Param("userId") String userId);
+
+    List<SysUser> selectUserLists(SysUserVo sysUserVo);
 }

+ 4 - 0
base-system/src/main/java/com/ozs/system/service/ISysUserService.java

@@ -2,9 +2,11 @@ package com.ozs.system.service;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ozs.common.core.domain.entity.SysUser;
 import com.ozs.common.core.domain.entity.SysUserUpdate;
 import com.ozs.common.core.domain.entity.SysUsers;
+import com.ozs.common.core.domain.vo.SysUserVo;
 import icu.mhb.mybatisplus.plugln.base.service.JoinIService;
 
 /**
@@ -290,4 +292,6 @@ public interface ISysUserService extends JoinIService<SysUser> {
      * @return
      */
     boolean dataPermission(Long id,Integer dataPermission);
+
+    IPage<SysUser> queryPage(SysUserVo sysUserVo);
 }

+ 16 - 0
base-system/src/main/java/com/ozs/system/service/impl/SysUserServiceImpl.java

@@ -5,9 +5,12 @@ import java.util.List;
 import java.util.stream.Collectors;
 import javax.validation.Validator;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.pagehelper.PageHelper;
 import com.ozs.common.core.domain.entity.SysDept;
 import com.ozs.common.core.domain.entity.SysUserUpdate;
 import com.ozs.common.core.domain.entity.SysUsers;
+import com.ozs.common.core.domain.vo.SysUserVo;
 import com.ozs.common.utils.uuid.IdUtils;
 import com.ozs.system.mapper.SysDeptMapper;
 import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
@@ -657,4 +660,17 @@ public class SysUserServiceImpl extends JoinServiceImpl<SysUserMapper, SysUser>
     public boolean dataPermission(Long id, Integer dataPermission) {
         return userMapper.dataPermission(id, dataPermission);
     }
+
+    @Override
+    public IPage<SysUser> queryPage(SysUserVo sysUserVo) {
+        int pageNum = Integer.parseInt(sysUserVo.getPageNum().toString());
+        int pageSize = Integer.parseInt(sysUserVo.getPageSize().toString());
+        com.github.pagehelper.Page<SysUser> page = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> userMapper.selectUserLists(sysUserVo));
+        com.baomidou.mybatisplus.extension.plugins.pagination.Page<SysUser> pageR =
+                new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
+        pageR.setRecords(page.getResult());
+        pageR.setTotal(page.getTotal());
+        return pageR;
+    }
 }

+ 40 - 1
base-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -196,6 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="sex != null and sex != ''">sex = #{sex},</if>
  			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  			<if test="status != null and status != ''">status = #{status},</if>
+			<if test="password != null and password != ''">password = #{password},</if>
  			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  			<if test="loginDate != null">login_date = #{loginDate},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
@@ -271,5 +272,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		  AND del_flag = 1
 		  AND status = 1
 	</select>
-
+	<select id="selectUserLists" resultMap="SysUserResult" parameterType="com.ozs.common.core.domain.vo.SysUserVo">
+		select u.id,u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phone_num, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark
+        from sys_user u
+		<where>
+			<if test="userName != null and userName != ''">
+				and u.user_name like concat('%', #{userName}, '%') 
+			</if>
+			<if test="nickName != null and nickName != ''">
+				and u.nick_name like concat('%', #{nickName}, '%')
+			</if>
+			<if test="phoneNum != null and phoneNum != ''">
+				and u.phone_num like concat('%', #{phoneNum}, '%')
+			</if>
+			<if test="deptId != null and deptId != 0">
+				and u.dept_id=#{deptId}
+			</if>
+			<if test="status != null and status != 0">
+				and u.status=#{status}
+			</if>
+			<if test="!dsFlay">
+				and (
+				<if test="dsUserId != null and dsUserId != ''">
+					u.create_by=#{dsUserId}  or
+				</if>
+				<if test="dsDeptId != null and dsDeptId != 0">
+					u.dept_id=#{dsDeptId}  or
+				</if>
+				<if test="dsDeptIds != null">
+					u.dept_id in
+					<foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
+						#{item}
+					</foreach>
+				</if>
+				)
+			</if>
+			and u.del_flag = '1'
+		</where>
+	</select>
+     
 </mapper>