Subversion Repositories SmartDukaan

Rev

Rev 3137 | Rev 3390 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?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="in.shop2020.crm.persistence.TicketMapper">
  <resultMap type="ticket" id="ticketResult">
    <id property="id" column="id"/>
  </resultMap>

  <insert id="insertTicket" parameterType="ticket" useGeneratedKeys="true" keyProperty="id">
    INSERT INTO ticket
      (customerId, openDate, closeDate, creatorId, description, assigneeId, status,
       priority, category, productName, airwayBillNo, orderId, customerEmailId)
    VALUES
      (#{customerId}, NOW(),  #{closeDate},  #{creatorId}, #{description}, #{assigneeId}, #{status},
       #{priority}, #{category}, #{productName}, #{airwayBillNo}, #{orderId}, #{customerEmailId})
  </insert>
  
  <update id="updateTicket" parameterType="ticket">
    UPDATE ticket
    SET
    <if test="assigneeId != null">
      assigneeId = #{assigneeId},
    </if>
    <if test="status != null">
      status = #{status},
    </if>
    <if test="priority != null">
      priority = #{priority},
    </if>
    <if test="category != null">
      category = #{category},
    </if>
    <if test="description != null">
      description = #{description},
    </if>
    closeDate = #{closeDate}
    WHERE id = #{id}
  </update>

  <select id="getTickets" parameterType="long" resultType="ticket">
    SELECT * FROM ticket
    WHERE customerId = #{customerId}
    ORDER BY openDate DESC
  </select>
  
  <select id="getTicket" parameterType="long" resultType="ticket">
    SELECT * FROM ticket
    WHERE id = #{ticketId}
  </select>
  
  <select id="getAssignedTickets" parameterType="long" resultType="ticket">
    SELECT * FROM ticket
    WHERE assigneeId = #{agentId}
    ORDER BY openDate DESC
  </select>

  <select id="getUnassignedTickets" resultType="ticket">
    SELECT * FROM ticket
    WHERE assigneeId IS NULL
    ORDER BY openDate DESC
  </select>
</mapper>