|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <?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="com.iformall.mapper.MallUserInfoMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.MallUserInfo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="username" jdbcType="VARCHAR" property="username"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="password" jdbcType="VARCHAR" property="password"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
- <result column="invest_rule" jdbcType="INTEGER" property="investRule"/>
- <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
- <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
- <result column="email" jdbcType="VARCHAR" property="email"/>
- </resultMap>
-
- <sql id="allSafeColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,`web_open_id`,email
- </sql>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,
- `bopen_id`,`web_open_id`,email
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != username and ''!=username">
- and `username` like concat('%', #{username},'%')
- </if>
-
- <if test=" null != nickName ">
- and `nick_name` like concat('%', #{nickName},'%')
- </if>
-
- <if test=" null != name ">
- and `name` like concat('%', #{name},'%')
- </if>
-
- <if test=" null != password ">
- and `password` like concat('%', #{password},'%')
- </if>
-
- <if test=" null != createTime ">
- and `create_time` = #{createTime}
- </if>
-
- <if test=" null != lastLoginTime ">
- and `last_login_time` = #{lastLoginTime}
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
- </if>
-
- <if test=" null != isAdmin ">
- and `is_admin` = #{isAdmin}
- </if>
-
- <if test=" null != investRule ">
- and `invest_rule` = #{investRule}
- </if>
- <if test=" null != phone and ''!=phone">
- and `phone` = #{phone}
- </if>
- <if test=" null != bopenId ">
- and `bopen_id` = #{bopenId}
- </if>
- <if test=" null != webOpenId ">
- and `web_open_id` = #{webOpenId}
- </if>
- <if test=" null != email ">
- and `email` = #{email}
- </if>
- <if test="null != withWechatForQuery ">
- <if test="0 == withWechatForQuery ">
- and `web_open_id` is not null
- </if>
- <if test="1 == withWechatForQuery ">
- and `web_open_id` is null
- </if>
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.MallUserInfo" resultMap="BaseResultMap">
- select
- <include refid="allSafeColumns"/>
- from mall_user_info
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="selectByUserName" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from mall_user_info
- where 1=1
- <if test=" null != username ">
- and username=#{username}
- </if>
- </select>
-
- <select id="getById" resultMap="BaseResultMap">
- select
- <include refid="allSafeColumns"/>
- from mall_user_info
- where 1=1
- <if test=" null != id ">
- and id=#{id}
- </if>
- </select>
-
- <select id="selectByUserNameWebOpen" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from mall_user_info
- where 1=1
- <if test=" null != username ">
- and username=#{username}
- </if>
- <if test=" null != webOpenId ">
- and `web_open_id`=#{webOpenId}
- </if>
- </select>
-
- <select id="selectByBOpenId" resultMap="BaseResultMap">
- select
- <include refid="allSafeColumns"/>
- from mall_user_info
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != bopenId ">
- and `bopen_id`=#{bopenId}
- </if>
- </select>
-
- <select id="selectByWebOpenId" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from mall_user_info
- where 1=1
- <if test=" null != webOpenId ">
- and `web_open_id`=#{webOpenId}
- </if>
- </select>
-
- <update id="removeWebOpenId">
- update mall_user_info
- set `web_open_id` = null
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != username ">
- and username=#{username}
- </if>
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- </update>
-
- <update id="removeAllOpenId">
- update mall_user_info
- set `web_open_id` = null, `bopen_id` = null
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != username ">
- and username=#{username}
- </if>
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- </update>
-
- <select id="selectByPhone" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from mall_user_info
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != phone ">
- and `phone`=#{phone}
- </if>
- </select>
-
- <select id="hasButtonPermission" resultType="java.lang.Integer">
- SELECT 1
- FROM mall_user_role ur, mall_user_role_permission rp, mall_permission p
- WHERE rp.role_id = ur.role_id
- AND rp.permission_id = p.id
- AND p.resource_type = 1
- AND ur.uid = #{userId}
- AND p.permission = #{permission}
- </select>
-
- <select id="cntByUserName" resultType="java.lang.Integer">
- select count(*) from mall_user_info where status = 1
- <if test=" null != username ">
- and username=#{username}
- </if>
- <if test=" null != phone ">
- and `phone` = #{phone}
- </if>
- <if test=" null != id ">
- and `id` != #{id}
- </if>
- </select>
-
- <!-- 查询用户的所有权限 -->
- <select id="queryAllMenu" resultType="com.iformall.domain.po.MallPermission">
- select p.*
- from mall_permission p
- LEFT JOIN mall_role_permission rp on rp.permission_id = p.id
- LEFT JOIN mall_user_role ur on ur.role_id = rp.role_id
- where ur.uid = #{userId}
- </select>
-
- <!-- 查询用户的所有权限 -->
- <select id="queryAllPerms" resultType="string">
- select p.permission from mall_user_role ur
- LEFT JOIN mall_role_permission rp on ur.role_id = rp.role_id
- LEFT JOIN mall_permission p on rp.permission_id = p.id
- where ur.uid = #{userId}
- </select>
-
- <!-- 查询用户的所有菜单ID -->
- <select id="queryAllMenuId" resultType="long">
- select distinct rp.permission_id from mall_user_role ur
- LEFT JOIN mall_role_permission rp on ur.role_id = rp.role_id
- where ur.uid = #{userId}
- </select>
-
-
- <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.MallUserInfoVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="username" jdbcType="VARCHAR" property="username"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="password" jdbcType="VARCHAR" property="password"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
- <result column="invest_rule" jdbcType="INTEGER" property="investRule"/>
- <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
- <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
- <result column="email" property="email"/>
-
- <result column="mall_name" jdbcType="VARCHAR" property="mallName"/>
- <result column="mall_group" jdbcType="VARCHAR" property="mallGroup"/>
- <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
- <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH"/>
- </resultMap>
-
- <sql id="allSafeVColumns">
- u.`id`,u.`tenant_id`,u.`parent_tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`,
- m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email
- </sql>
-
- <sql id="allVColumns">
- u.`id`,u.`tenant_id`,u.`parent_tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`,
- u.`bopen_id`,u.`web_open_id`,
- m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email
- </sql>
-
-
- <select id="selectUsersByPhone" resultMap="VBaseResultMap">
- select
- <include refid="allSafeVColumns"/>
- from mall_user_info u
- left join wx_mall m on m.`tenant_id` = u.`tenant_id`
- where 1=1
- <if test=" null != phone ">
- and u.`phone` = #{phone}
- </if>
- </select>
-
- <select id="selectUsersByWebOpenId" resultMap="VBaseResultMap">
- select
- <include refid="allSafeVColumns"/>
- from mall_user_info u
- left join wx_mall m on m.`tenant_id` = u.`tenant_id`
- where 1=1
- <if test=" null != webOpenId ">
- and u.`web_open_id` = #{webOpenId}
- </if>
- </select>
-
- </mapper>
|