MassUserMapper.xml 5.01 KB
<?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.glsx.entmicro.mapper.MassUserMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.MassUser">
    <!--@Table scrm_mass_user-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="mass_id" jdbcType="INTEGER" property="massId" />
    <result column="user_id" jdbcType="VARCHAR" property="userId" />
    <result column="msg_id" jdbcType="VARCHAR" property="msgId" />
    <result column="is_send" jdbcType="TINYINT" property="isSend" />
    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    id, mass_id, user_id, msg_id, is_send, del_flag
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from scrm_mass_user
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByMassId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select t.id, t.mass_id, t.user_id, t.msg_id, t.is_send, t.del_flag from scrm_mass_user t
    left join entmicro_staff s on t.user_id = s.user_id left join entmicro_department d on d.id = s.department_id
    where t.mass_id = #{id,jdbcType=INTEGER} and t.del_flag = 0
  </select>
  <select id="selectByCondition" parameterType="cn.com.glsx.entmicro.model.request.MassUserRequest" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/> from scrm_mass_user
    where 1 = 1 and del_flag = 0
    <if test="obj.massId != null">
        and mass_id = #{obj.massId,jdbcType=INTEGER}
    </if>
    <if test="obj.userId != null and obj.userId != ''">
        and user_id = #{obj.userId,jdbcType=VARCHAR}
    </if>
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from scrm_mass_user
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="cn.com.glsx.entmicro.entity.MassUser" useGeneratedKeys="true">
    insert into scrm_mass_user (mass_id, user_id, is_send,
      del_flag)
    values (#{massId,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{isSend,jdbcType=TINYINT}, 
      #{delFlag,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="cn.com.glsx.entmicro.entity.MassUser" useGeneratedKeys="true">
    insert into scrm_mass_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="massId != null">
        mass_id,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="isSend != null">
        is_send,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="massId != null">
        #{massId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=VARCHAR},
      </if>
      <if test="isSend != null">
        #{isSend,jdbcType=TINYINT},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.com.glsx.entmicro.entity.MassUser">
    update scrm_mass_user
    <set>
      <if test="massId != null">
        mass_id = #{massId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=VARCHAR},
      </if>
      <if test="isSend != null">
        is_send = #{isSend,jdbcType=TINYINT},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.com.glsx.entmicro.entity.MassUser">
    update scrm_mass_user
    set mass_id = #{massId,jdbcType=INTEGER},
      user_id = #{userId,jdbcType=VARCHAR},
      is_send = #{isSend,jdbcType=TINYINT},
      del_flag = #{delFlag,jdbcType=TINYINT}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateDataByMassIdAndUserId" >
    update scrm_mass_user
    <set>
        <if test="isSend != null">
           is_send = #{isSend,jdbcType=TINYINT},
        </if>
        <if test="msgId != null and msgId != ''">
            msg_id = #{msgId,jdbcType=VARCHAR},
        </if>
    </set>
    where 1 = 1 and del_flag = 0 and mass_id = #{massId,jdbcType=INTEGER}
    <if test="userId != null and userId != ''">
        and user_id = #{userId,jdbcType=VARCHAR}
    </if>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    insert into scrm_mass_user (mass_id, user_id, is_send,del_flag)
    values
    <foreach collection="list" item="item" separator=",">
       (
           #{item.massId,jdbcType=INTEGER}, #{item.userId,jdbcType=VARCHAR},
           #{item.isSend,jdbcType=TINYINT}, #{item.delFlag,jdbcType=TINYINT}
        )
    </foreach>
  </insert>
</mapper>