| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- package com.ydtech.modules.admin.dao;
- import com.baomidou.mybatisplus.core.mapper.BaseMapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ydtech.core.page.PageResult;
- import com.ydtech.modules.admin.model.SysUser;
- import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
- import com.ydtech.modules.admin.model.vo.SysUserVO;
- import com.ydtech.modules.base.model.dto.PageDto;
- import org.apache.ibatis.annotations.Param;
- import org.apache.ibatis.annotations.Select;
- import org.springframework.stereotype.Repository;
- import java.util.List;
- /**
- * @author Administrator
- * @description 针对表【sys_user(用户管理)】的数据库操作Mapper
- * @createDate 2022-08-17 11:41:01
- * @Entity generator.domain.SysUser
- */
- @Repository
- public interface SysUserMapper extends BaseMapper<SysUser> {
- String userSql = "select t1.id as userId,t1.name as name,t1.sex as sex,t1.mobile as mobile,t1.`status` as `status`,t2.id as deptId,t2.`name` as deptName,sd2.id as pDeptId,sd2.`name` as pDeptName,t4.id as roleId,t4.`name` as roleName " +
- " from sys_user t1 " +
- " left join sys_dept t2 on t1.dept_id=t2.id " +
- " left join sys_dept sd2 on sd2.id=t2.parent_id " +
- " left join sys_user_role t3 on t1.id=t3.user_id" +
- " left join sys_role t4 on t3.role_id=t4.id" +
- " where t1.id=#{userId}";
- ;
- String internalUserSql = "select t.id,t.name,t.dept_id deptid,t2.name deptname,t3.id comid,t3.name comname,t.status " +
- "from sys_user t left join sys_dept t2 on t.dept_id=t2.id " +
- "left join sys_dept t3 on t2.parent_id=t3.id " +
- "left join esm_user_internal a on t.id=a.id " +
- "where t.id=#{userId}";
- String internalUserByDeptIdSql = "select t1.id,t1.name,t1.dept_id deptid,sd.name deptname,sd2.id comid,sd2.name comname,t2.status " +
- "from sys_user t1 left join esm_user_internal t2 on t1.id=t2.id " +
- "LEFT JOIN sys_dept sd ON t1.dept_id=sd.id " +
- "LEFT JOIN sys_dept sd2 ON sd2.id=sd.parent_id " +
- "where 1=1 and t2.isteamleader = '1' and t1.dept_id=#{deptId}";
- String selectUserParamSql = "select su.id as userId,su.name,info.sex,su.mobile,su.status" +
- ",sd.id as deptId,sd.name as deptName" +
- ",psd.id as pDeptId,psd.name as pDeptName" +
- ",t4.id as roleId" +
- ",t4.name as roleName"
- ;
- String selectUserFromSql = " from sys_user su " +
- " left join sys_dept sd on su.dept_id=sd.id " +
- " left join sys_dept psd on sd.parent_id=psd.id " +
- " left join sys_user_info info on info.id=su.id " +
- " left join sys_user_role t3 on su.id=t3.user_id " +
- " left join sys_role t4 on t3.role_id=t4.id " +
- " where 1=1 " +
- " AND sd.id <> '' "
- + ""
- ;
- String selectUserFromWhereSql = " " +
- // "<if test='page.columnFilters.usertype !=null and page.columnFilters.usertype.value!=\"\" and page.columnFilters.usertype.value!=null '>" +
- // " and su.usertype = #{page.columnFilters.usertype.value}" +
- // "</if> " +
- // "<if test='page.columnFilters.approvalStatus !=null and page.columnFilters.approvalStatus.value!=\"\" and page.columnFilters.approvalStatus.value!=null '>" +
- // " and su.approval_status = #{page.columnFilters.approvalStatus.value}" +
- // "</if> " +
- "<if test='page.dto !=null '> " +
- "<if test='page.dto.status !=null and page.dto.status!=\"\" '> " +
- " and su.status = #{page.dto.status}" +
- "</if> " +
- "<if test='page.dto.name !=null and page.dto.name!=\"\" '> " +
- " and su.name like concat('%',#{page.dto.name},'%')" +
- "</if> " +
- "<if test='page.dto.userId !=null and page.dto.userId!=\"\" '>" +
- " and su.id = #{page.dto.userId}" +
- "</if> " +
- "<if test='page.dto.mobile !=null and page.dto.mobile!=\"\" '>" +
- " and su.mobile = #{page.dto.mobile}" +
- "</if> " +
- "<if test='page.dto.deptId !=null and page.dto.deptId!=\"\" '>" +
- " and su.dept_id like concat('%',#{page.dto.deptId},'%')" +
- "</if> " +
- "<if test='page.dto.roleId !=null and page.dto.roleId!=\"\" '>" +
- " and t3.role_id = #{page.dto.roleId}" +
- "</if> " +
- "</if> " +
- "";
- // String selectUserFromWhereSql = " " +
- // " and su.usertype = #{page.columnFilters.usertype.value}" +
- // " and su.status = #{page.columnFilters.status.value}" +
- // " and su.name like concat('%',#{page.columnFilters.name.value},'%')" +
- // " and su.id = #{page.columnFilters.userId.value}" +
- // " and su.mobile = #{page.columnFilters.mobile.value}" +
- // "";
- @Select(internalUserSql)
- SysUserVO gainInternalUser(@Param("userId") String userId);
- @Select(internalUserByDeptIdSql)
- SysUserVO gainInternalUserByDeptId(@Param("deptId") String deptId);
- @Select("SELECT u.id,u.name,r.id roleId,r.name roleName FROM sys_user u " +
- "LEFT JOIN sys_user_role sur ON sur.user_id = u.id " +
- "LEFT JOIN sys_role r ON r.id = sur.role_id WHERE r.id IN ('20','21') and u.status=1 and u.dept_id=#{deptId}")
- List<SysUserVO> findByReferrerId(@Param("deptId") String deptId);
- // @Select("select * from (" + selectUserParamSql + selectUserFromSql + selectUserFromWhereSql + " limit #{page.pageNum},#{page.pageSize} ) aaa")
- @Select({"<script>",
- "select * from (",
- selectUserParamSql,
- selectUserFromSql,
- selectUserFromWhereSql,
- " limit #{page.pageNum},#{page.pageSize} ) aaa",
- "</script>"})
- List<SysUserBaseVO> gainUserBaseInfo(@Param("page") PageDto pageDto);
- /**
- * 获取用户列表
- * @param page 分页信息
- * @param sysUser 查询条件
- * @param containsSubDept 是否包含下级机构
- * @return
- */
- public IPage<SysUser> selectUserPage(Page page, @Param("sysUser")SysUser sysUser,@Param("containsSubDept")String containsSubDept);
- // @Select("select count(1) " + selectUserFromSql + selectUserFromWhereSql)
- @Select({"<script>", "select count(1) ", selectUserFromSql, selectUserFromWhereSql, "</script>"})
- int gainUserBaseInfoCount(@Param("page") PageDto pageDto);
- @Select(userSql)
- SysUserBaseVO selectUserById(@Param("userId") String userId);
- String selectSql = "SELECT u.* FROM sys_user u " +
- "LEFT JOIN sys_user_role sur ON sur.user_id = u.id " +
- " WHERE sur.role_id IN ('20') and u.status=1 " +
- "<if test='userId!=\"\" '>" +
- " and u.id=#{userId} " +
- "</if> " ;
- @Select({"<script>",selectSql,"</script>"})
- List<SysUser> findAllAgentRoleUser(@Param("userId") String userId);
- }
|