|
- <?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.simple.mapper.WxCUserBasicInfoMapper">
- <resultMap id="BaseResultMap" type="com.simple.domain.po.WxCUserBasicInfo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
- <result column="education" jdbcType="VARCHAR" property="education"/>
- <result column="sex" jdbcType="INTEGER" property="sex"/>
- <result column="email" jdbcType="VARCHAR" property="email"/>
- <result column="address" jdbcType="VARCHAR" property="address"/>
- <result column="poins" jdbcType="INTEGER" property="poins"/>
- <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="level" jdbcType="VARCHAR" property="level"/>
- <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
- `create_date`,`update_date`,`tenant_id`,`name`,level,nick_name
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId ">
- and c.`tenant_id` like concat('%', #{tenantId},'%')
- </if>
-
- <if test=" null != phone ">
- and `phone` like concat('%', #{phone},'%')
- </if>
-
- <if test=" null != birthdate ">
- and `birthdate` = #{birthdate}
- </if>
-
- <if test=" null != education ">
- and `education` like concat('%', #{education},'%')
- </if>
-
- <if test=" null != sex ">
- and `sex` = #{sex}
- </if>
-
- <if test=" null != email ">
- and `email` like concat('%', #{email},'%')
- </if>
-
- <if test=" null != address ">
- and `address` like concat('%', #{address},'%')
- </if>
-
- <if test=" null != poins ">
- and `poins` = #{poins}
- </if>
-
- <if test=" null != tagId ">
- and `tag_id` = #{tagId}
- </if>
-
- <if test=" null != cUserId ">
- and `c_user_id` = #{cUserId}
- </if>
-
- <if test=" null != createDate ">
- and c.`create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and c.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != name ">
- and c.`name` like concat('%', #{name},'%')
- </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.simple.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_c_user_basic_info
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <sql id="allUserColumns">
- c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`,
- cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.level,cb.nick_name
- </sql>
-
-
- <select id="list" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
- select
- <include refid="allUserColumns"/>
- from wx_c_user c
- left join wx_c_user_basic_info cb on cb.id = c.id and cb.tenant_id = c.tenant_id
- where 1=1
- <if test=" null != tenantId ">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != phone and phone !='' ">
- and c.`phone` = #{phone}
- </if>
- <if test=" null == phone or phone =='' ">
- and c.`phone` is not null
- </if>
- <if test=" null != startTime ">
- and cb.create_date >= #{startTime}
- </if>
-
- <if test=" null != endTime">
- and cb.update_date <= #{endTime}
- </if>
-
- <if test=" null != name and name != '' ">
- and cb.`name` like concat('%', #{name},'%')
- </if>
- </select>
- <update id="updateScore" parameterType="com.simple.domain.po.WxCUserBasicInfo">
- update wx_c_user_basic_info set poins=#{poins} where phone=#{phone} and tenant_id=#{tenantId}
- and c_user_id=#{cUserId}
-
- </update>
-
- <select id="findCountBySex" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(id) from wx_c_user_basic_info where sex =#{sex}
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date <= #{endTime}
- </if>
- </select>
-
-
- <select id="findCountByAge" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(id) from wx_c_user_basic_info where birthdate is not NULL
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date <= #{endTime}
- </if>
-
- <if test=" null != birthStartTime ">
- and birthdate >= #{birthStartTime}
- </if>
- <if test=" null != birthEndTime">
- and birthdate <= #{birthEndTime}
- </if>
- </select>
-
- <select id="findListMap" parameterType="com.simple.domain.dto.WxCUserBasicInfoDto" resultType="hashmap">
- select cu.id,cu.tenant_id tenantId,cu.open_id openId,cu.union_id unionId,
- cu.nick_name nickName,cu.gender,cu.avatar_url avatarUrl,cu.phone,
- cu.pure_phone purePhone,cu.city,cu.province,cu.`language`,cu.country_code countryCode,
- cu.register_ip registerIp,cu.verify_code_phone verifyCodePhone,cu.qrcode_source qrcodeSource,
- cu.scene,cu.scene_address sceneAddress,cu.score,cu.update_date updateDate,
- cu.create_date createDate,cu.app_id appId,cu.session_key sessionKey,cu.token,
- cu.expire_time expireTime,cu.latitude,cu.longitude,cubi.birthdate,cubi.education,
- cubi.sex,cubi.email,cubi.address,cubi.poins,cubi.`name`,cubi.`level`,cubi.id cubiid
- from wx_c_user cu left join wx_c_user_basic_info cubi
- on cu.phone=cubi.phone and cu.tenant_id=cubi.tenant_id
- where 1=1
- <if test=" null != tenantId ">
- and cu.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != phone and phone !='' ">
- and cu.`phone` = #{phone}
- </if>
- <if test=" null == phone or phone =='' ">
- and cu.`phone` is not null
- </if>
- <if test=" null != startTime ">
- and cubi.create_date >= #{startTime}
- </if>
-
- <if test=" null != endTime">
- and cubi.update_date <= #{endTime}
- </if>
- <if test=" null != name and name != '' ">
- and cb.`name` like concat('%', #{name},'%')
- </if>
- </select>
-
-
- </mapper>
|