xkrs_ms/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml
2020-12-18 16:00:10 +08:00

121 lines
5.7 KiB
XML

<?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.stdiet.custom.mapper.SysWxUserInfoMapper">
<resultMap type="SysWxUserInfo" id="SysWxUserInfoResult">
<result property="openid" column="openid"/>
<result property="nickName" column="nick_name"/>
<result property="appid" column="appid"/>
<result property="phone" column="phone"/>
<result property="avatarUrl" column="avatar_url"/>
<result property="sex" column="sex"/>
<result property="city" column="city"/>
<result property="province" column="province"/>
<result property="country" column="country"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectSysWxUserInfoVo">
select openid, nick_name, appid, phone, avatar_url, sex, city, province, country, create_by, create_time, update_by, update_time, remark from sys_wx_user_info
</sql>
<select id="selectSysWxUserInfoList" parameterType="SysWxUserInfo" resultMap="SysWxUserInfoResult">
<include refid="selectSysWxUserInfoVo"/>
<where>
<if test="nickName != null and nickName != ''">and nick_name like concat('%', #{nickName}, '%')</if>
<if test="appid != null and appid != ''">and appid = #{appid}</if>
<if test="phone != null and phone != ''">and phone = #{phone}</if>
<if test="sex != null and sex != ''">and sex = #{sex}</if>
</where>
</select>
<select id="selectSysWxUserInfoListNot" parameterType="SysWxUserInfo" resultMap="SysWxUserInfoResult">
select distinct user.openid, user.nick_name, user.appid, user.phone, user.avatar_url, user.sex, user.update_time from sys_wx_user_info user
right join sys_order
on user.phone = sys_order.phone
<where>
<if test="appid != null and appid != ''">and appid = #{appid}</if>
<if test="openid != null and openid != ''">and openid != #{openid}</if>
</where>
order by update_time desc
</select>
<select id="selectSysWxUserInfoById" parameterType="String" resultMap="SysWxUserInfoResult">
<include refid="selectSysWxUserInfoVo"/>
where openid = #{openid}
</select>
<insert id="insertSysWxUserInfo" parameterType="SysWxUserInfo">
insert into sys_wx_user_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="openid != null">openid,</if>
<if test="nickName != null">nick_name,</if>
<if test="appid != null">appid,</if>
<if test="phone != null">phone,</if>
<if test="avatarUrl != null">avatar_url,</if>
<if test="sex != null">sex,</if>
<if test="city != null">city,</if>
<if test="province != null">province,</if>
<if test="country != null">country,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openid != null">#{openid},</if>
<if test="nickName != null">#{nickName},</if>
<if test="appid != null">#{appid},</if>
<if test="phone != null">#{phone},</if>
<if test="avatarUrl != null">#{avatarUrl},</if>
<if test="sex != null">#{sex},</if>
<if test="city != null">#{city},</if>
<if test="province != null">#{province},</if>
<if test="country != null">#{country},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSysWxUserInfo" parameterType="SysWxUserInfo">
update sys_wx_user_info
<trim prefix="SET" suffixOverrides=",">
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="appid != null">appid = #{appid},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="avatarUrl != null">avatar_url = #{avatarUrl},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="city != null">city = #{city},</if>
<if test="province != null">province = #{province},</if>
<if test="country != null">country = #{country},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where openid = #{openid}
</update>
<delete id="deleteSysWxUserInfoById" parameterType="String">
delete from sys_wx_user_info where openid = #{openid}
</delete>
<delete id="deleteSysWxUserInfoByIds" parameterType="String">
delete from sys_wx_user_info where openid in
<foreach item="openid" collection="array" open="(" separator="," close=")">
#{openid}
</foreach>
</delete>
</mapper>