<?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.webmanage.mapper.ApprovalRecordMapper">
|
|
<resultMap id="BaseResultMap" type="com.webmanage.entity.ApprovalRecord">
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
<result column="order_id" property="orderId" jdbcType="VARCHAR"/>
|
<result column="approver_id" property="approverId" jdbcType="BIGINT"/>
|
<result column="approver_name" property="approverName" jdbcType="VARCHAR"/>
|
<result column="approver_role" property="approverRole" jdbcType="VARCHAR"/>
|
<result column="approval_step" property="approvalStep" jdbcType="VARCHAR"/>
|
<result column="approval_result" property="approvalResult" jdbcType="VARCHAR"/>
|
<result column="approval_opinion" property="approvalOpinion" jdbcType="VARCHAR"/>
|
<result column="approval_time" property="approvalTime" jdbcType="TIMESTAMP"/>
|
<result column="need_authorization" property="needAuthorization" jdbcType="BOOLEAN"/>
|
<result column="authorizer_id" property="authorizerId" jdbcType="BIGINT"/>
|
<result column="authorizer_name" property="authorizerName" jdbcType="VARCHAR"/>
|
<result column="authorization_time" property="authorizationTime" jdbcType="TIMESTAMP"/>
|
<result column="authorization_opinion" property="authorizationOpinion" jdbcType="VARCHAR"/>
|
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
|
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP"/>
|
<result column="deleted" property="deleted" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
id, order_id, approver_id, approver_name, approver_role, approval_step, approval_result,
|
approval_opinion, approval_time, need_authorization, authorizer_id, authorizer_name,
|
authorization_time, authorization_opinion, created_at, updated_at, deleted
|
</sql>
|
|
<select id="selectApprovalRecordPage" resultMap="BaseResultMap">
|
SELECT ar.<include refid="Base_Column_List"/>
|
FROM approval_record ar
|
LEFT JOIN order_info oi ON ar.order_id = oi.order_id
|
WHERE ar.deleted = 0
|
<if test="orderId != null and orderId != ''">
|
AND ar.order_id = #{orderId}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND oi.product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="providerName != null and providerName != ''">
|
AND oi.provider_name LIKE CONCAT('%', #{providerName}, '%')
|
</if>
|
<if test="approverId != null">
|
AND ar.approver_id = #{approverId}
|
</if>
|
<if test="approvalResult != null and approvalResult != ''">
|
AND ar.approval_result = #{approvalResult}
|
</if>
|
<if test="approvalStep != null and approvalStep != ''">
|
AND ar.approval_step = #{approvalStep}
|
</if>
|
<if test="needAuthorization != null">
|
AND ar.need_authorization = #{needAuthorization}
|
</if>
|
<if test="applyTimeStart != null and applyTimeStart != ''">
|
AND oi.apply_time >= #{applyTimeStart}
|
</if>
|
<if test="applyTimeEnd != null and applyTimeEnd != ''">
|
AND oi.apply_time <= #{applyTimeEnd}
|
</if>
|
<if test="approvalTimeStart != null and approvalTimeStart != ''">
|
AND ar.approval_time >= #{approvalTimeStart}
|
</if>
|
<if test="approvalTimeEnd != null and approvalTimeEnd != ''">
|
AND ar.approval_time <= #{approvalTimeEnd}
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy == 'approval_time'">ar.approval_time</when>
|
<when test="orderBy == 'created_at'">ar.created_at</when>
|
<otherwise>ar.created_at</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection == 'asc'">ASC</when>
|
<otherwise>DESC</otherwise>
|
</choose>
|
</select>
|
|
<select id="selectByOrderId" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List"/>
|
FROM approval_record
|
WHERE deleted = 0 AND order_id = #{orderId}
|
ORDER BY created_at ASC
|
</select>
|
|
<select id="selectPendingApprovalPage" resultMap="BaseResultMap">
|
SELECT ar.<include refid="Base_Column_List"/>
|
FROM approval_record ar
|
LEFT JOIN order_info oi ON ar.order_id = oi.order_id
|
WHERE ar.deleted = 0 AND ar.approval_result IS NULL
|
<if test="orderId != null and orderId != ''">
|
AND ar.order_id = #{orderId}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND oi.product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="providerName != null and providerName != ''">
|
AND oi.provider_name LIKE CONCAT('%', #{providerName}, '%')
|
</if>
|
<if test="approvalStep != null and approvalStep != ''">
|
AND ar.approval_step = #{approvalStep}
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy == 'approval_time'">ar.approval_time</when>
|
<when test="orderBy == 'created_at'">ar.created_at</when>
|
<otherwise>ar.created_at</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection == 'asc'">ASC</when>
|
<otherwise>DESC</otherwise>
|
</choose>
|
</select>
|
|
</mapper>
|