123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.com.ty.lift.push.push.mapper.PushUserMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="cn.com.ty.lift.common.model.PushUserInfo">
- <id column="user_id" property="userId"/>
- <result column="username" property="userName"/>
- <result column="mobile" property="mobile"/>
- <result column="device_model" property="deviceModel"/>
- <result column="device_flag" property="deviceFlag"/>
- <result column="role_name" property="roleName"/>
- </resultMap>
- <select id="listByUserId" resultMap="BaseResultMap">
- SELECT
- ui.user_id,
- ui.NAME AS username,
- ua.mobile,
- ua.device_model,
- ua.device_flag,
- ro.NAME AS role_name
- FROM
- user_info ui
- LEFT JOIN user_account ua ON ui.user_id = ua.user_id
- LEFT JOIN user_role ur ON ui.user_id = ur.user_id
- LEFT JOIN role ro ON ro.id = ur.role_id
- <where>
- <if test="mtCompanyId != null and mtCompanyId > 0">
- AND ur.company_id = #{mtCompanyId}
- </if>
- <if test="userId != null and userId > 0">
- AND ui.user_id = #{userId}
- </if>
- </where>
- </select>
- <select id="listByUserIds" resultMap="BaseResultMap">
- SELECT
- ui.user_id,
- ui.NAME AS username,
- ua.mobile,
- ua.device_model,
- ua.device_flag,
- ro.NAME AS role_name
- FROM
- user_info ui
- LEFT JOIN user_account ua ON ui.user_id = ua.user_id
- LEFT JOIN user_role ur ON ui.user_id = ur.user_id
- LEFT JOIN role ro ON ro.id = ur.role_id
- <where>
- <if test="mtCompanyId != null and mtCompanyId > 0">
- AND ur.company_id = #{mtCompanyId}
- </if>
- <if test="userIds != null">
- AND ui.user_id IN
- <foreach collection="userIds" item="userId" open="(" separator="," close=")">
- #{userId, jdbcType=BIGINT}
- </foreach>
- </if>
- </where>
- </select>
- <select id="listByRoleCodes" resultMap="BaseResultMap">
- SELECT
- ui.user_id,
- ui.NAME AS username,
- ua.mobile,
- ua.device_model,
- ua.device_flag,
- ro.NAME AS role_name
- FROM
- user_info ui
- LEFT JOIN user_account ua ON ui.user_id = ua.user_id
- LEFT JOIN user_role ur ON ui.user_id = ur.user_id
- LEFT JOIN role ro ON ro.id = ur.role_id
- <where>
- <if test="mtCompanyId != null and mtCompanyId > 0">
- AND ur.company_id = #{mtCompanyId}
- </if>
- <if test="roleCodes != null">
- AND ro.code IN
- <foreach collection="roleCodes" item="roleCode" open="(" separator="," close=")">
- #{roleCode, jdbcType=VARCHAR}
- </foreach>
- </if>
- </where>
- </select>
- <select id="listByRoleCode" resultMap="BaseResultMap">
- SELECT
- ui.user_id,
- ui.NAME AS username,
- ua.mobile,
- ua.device_model,
- ua.device_flag,
- ro.NAME AS role_name
- FROM
- user_info ui
- LEFT JOIN user_account ua ON ui.user_id = ua.user_id
- LEFT JOIN user_role ur ON ui.user_id = ur.user_id
- LEFT JOIN role ro ON ro.id = ur.role_id
- <where>
- <if test="mtCompanyId != null and mtCompanyId > 0">
- AND ur.company_id = #{mtCompanyId}
- </if>
- <if test="roleCode != null and roleCode != ''">
- AND ro.code = #{roleCode, jdbcType=VARCHAR}
- </if>
- </where>
- </select>
- <select id="pageByMtCompany" resultMap="BaseResultMap" parameterType="java.lang.Long">
- SELECT
- ui.user_id,
- ui.NAME AS username,
- ua.mobile,
- ua.device_model,
- ua.device_flag,
- ro.NAME AS role_name
- FROM
- user_info ui
- LEFT JOIN user_account ua ON ui.user_id = ua.user_id
- LEFT JOIN user_role ur ON ui.user_id = ur.user_id
- LEFT JOIN role ro ON ro.id = ur.role_id
- LEFT JOIN mt_company_user mcu ON mcu.user_id = ui.user_id AND mcu.mt_company_id = ur.company_id
- <where>
- <if test="mtCompanyId != null and mtCompanyId > 0">
- mcu.mt_company_id = #{mtCompanyId}
- </if>
- </where>
- </select>
- </mapper>
|