CustomerServiceMessageMapper.xml 6.38 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.dj.weapp.mapper.CustomerServiceMessageMapper" >
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.weapp.model.CustomerServiceMessage" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="account_id" property="accountId" jdbcType="INTEGER" />
    <result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
    <result column="send_type" property="sendType" jdbcType="CHAR" />
    <result column="send_status" property="sendStatus" jdbcType="CHAR" />
    <result column="message_status" property="messageStatus" jdbcType="CHAR" />
    <result column="message_type" property="messageType" jdbcType="VARCHAR" />
    <result column="message_cover" property="messageCover" jdbcType="VARCHAR" />
    <result column="message_content" property="messageContent" jdbcType="VARCHAR" />
    <result column="avatar_url" property="avatarUrl" jdbcType="VARCHAR" />
    <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
    <result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
    <result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
    <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
    <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
  </resultMap>
  <resultMap id="DTOResultMap" type="cn.com.glsx.dj.weapp.dto.CustomerServiceMessageDTO" extends="BaseResultMap">
    <result column="avatar_url" property="avatarUrl" jdbcType="VARCHAR" />
    <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="message_content_new" property="messageContentNew" jdbcType="VARCHAR" />
    <result column="message_type_new" property="messageTypeNew" jdbcType="VARCHAR" />
    <result column="unread_count" property="unreadCount" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
    -->
    id, account_id, merchant_id, send_type, send_status, message_status, message_type, message_cover, message_content,avatar_url,
    created_by, created_date, updated_by, updated_date, deleted_flag
  </sql>

  <select id="countByMerchantId" parameterType="java.lang.Integer" resultType="java.lang.Integer" >
    select count(*) from dj_weapp_customer_service_message
    WHERE message_status='N' AND deleted_flag='N' and send_type='C'
    AND merchant_id = #{merchantId,jdbcType=INTEGER}
  </select>

  <select id="getByAccountId" resultMap="DTOResultMap">
    select
    a.id, a.account_id, a.merchant_id, a.send_type, a.message_status, a.message_type, a.message_cover, a.message_content, a.avatar_url, a.created_date, a.created_by,
    b.avatar_url,b.nick_name,b.phone,b.message_type_new,b.message_content_new,b.unread_count
    from dj_weapp_customer_service_message a
    LEFT JOIN dj_weapp_customer_service_message_catalog b on a.merchant_id=b.merchant_id
    where a.account_id=b.account_id and a.account_id = #{accountId} and a.merchant_id = #{merchantId} and a.deleted_flag = 'N' and b.deleted_flag='N' order by a.created_date
  </select>

  <select id="getUnreadByAccountId" resultMap="DTOResultMap">
    select
    a.id, a.account_id, a.merchant_id, a.send_type, a.message_status, a.message_type, a.message_cover, a.message_content, a.avatar_url, a.created_date, a.created_by,
    b.avatar_url,b.nick_name,b.phone,b.message_type_new,b.message_content_new,b.unread_count
    from dj_weapp_customer_service_message a
    LEFT JOIN dj_weapp_customer_service_message_catalog b on a.merchant_id=b.merchant_id
    where a.account_id=b.account_id and a.account_id = #{record.accountId}
    and a.send_type=#{record.sendType} and a.merchant_id = #{record.merchantId}
    and a.deleted_flag = 'N' and a.message_status='N' and b.deleted_flag='N' order by a.created_date
  </select>

  <select id="getByMerchantId" parameterType="java.lang.Integer"
          resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from dj_weapp_customer_service_message
    where merchant_id = #{merchantId} and deleted_flag = 'N'
  </select>

  <select id="getMerchantByUnread"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from dj_weapp_customer_service_message a
    where message_status= #{status} and send_type=#{type} and deleted_flag = 'N'
  </select>

  <update id="updateByAccountId" parameterType="cn.com.glsx.dj.weapp.model.CustomerServiceMessage" >
    update dj_weapp_customer_service_message
    <set >
      <if test="record.merchantId != null" >
        merchant_id = #{record.merchantId,jdbcType=INTEGER},
      </if>
      <if test="record.sendType != null" >
        send_type = #{record.sendType,jdbcType=CHAR},
      </if>
      <if test="record.sendStatus != null" >
        send_status = #{record.sendStatus,jdbcType=CHAR},
      </if>
      <if test="record.messageStatus != null" >
        message_status = #{record.messageStatus,jdbcType=CHAR},
      </if>
      <if test="record.messageType != null" >
        message_type = #{record.messageType,jdbcType=VARCHAR},
      </if>
      <if test="record.messageCover != null" >
        message_cover = #{record.messageCover,jdbcType=VARCHAR},
      </if>
      <if test="record.messageContent != null" >
        message_content = #{record.messageContent,jdbcType=VARCHAR},
      </if>
      <if test="record.avatarUrl != null" >
        avatar_url = #{record.avatarUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.createdBy != null" >
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
      <if test="record.createdDate != null" >
        created_date = #{record.createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updatedBy != null" >
        updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedDate != null" >
        updated_date = #{record.updatedDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedFlag != null" >
        deleted_flag = #{record.deletedFlag,jdbcType=CHAR},
      </if>
    </set>
    where account_id = #{record.accountId,jdbcType=INTEGER} and send_type=#{record.sendType,jdbcType=CHAR}
    and merchant_id = #{record.merchantId,jdbcType=INTEGER} and deleted_flag='N'
  </update>

</mapper>