agent-skill-backend/src/main/resources/mapper/WithdrawalRecordMapper.xml

139 lines
6.2 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.kexue.skills.mapper.WithdrawalRecordMapper">
<resultMap id="BaseResultMap" type="com.kexue.skills.entity.WithdrawalRecord">
<id column="record_id" property="recordId" jdbcType="BIGINT"/>
<result column="user_id" property="userId" jdbcType="BIGINT"/>
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
<result column="withdrawal_amount" property="withdrawalAmount" jdbcType="DECIMAL"/>
<result column="fee_amount" property="feeAmount" jdbcType="DECIMAL"/>
<result column="actual_amount" property="actualAmount" jdbcType="DECIMAL"/>
<result column="status" property="status" jdbcType="TINYINT"/>
<result column="withdrawal_no" property="withdrawalNo" jdbcType="VARCHAR"/>
<result column="bank_name" property="bankName" jdbcType="VARCHAR"/>
<result column="bank_account" property="bankAccount" jdbcType="VARCHAR"/>
<result column="bank_cardholder" property="bankCardholder" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="delete_flag" property="deleteFlag" jdbcType="TINYINT"/>
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
record_id, user_id, user_name, withdrawal_amount, fee_amount, actual_amount, status, withdrawal_no, bank_name, bank_account, bank_cardholder, remark, create_time, update_time, delete_flag, create_by, update_by
</sql>
<select id="queryById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM withdrawal_record
WHERE record_id = #{recordId} AND delete_flag = 0
</select>
<select id="queryByUserId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM withdrawal_record
WHERE user_id = #{userId} AND delete_flag = 0
ORDER BY create_time DESC
</select>
<select id="queryByWithdrawalNo" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM withdrawal_record
WHERE withdrawal_no = #{withdrawalNo} AND delete_flag = 0
</select>
<select id="getPageList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM withdrawal_record
WHERE delete_flag = 0
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
AND user_name LIKE CONCAT('%', #{userName}, '%')
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="withdrawalNo != null and withdrawalNo != ''">
AND withdrawal_no LIKE CONCAT('%', #{withdrawalNo}, '%')
</if>
ORDER BY create_time DESC
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM withdrawal_record
WHERE delete_flag = 0
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
AND user_name LIKE CONCAT('%', #{userName}, '%')
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="withdrawalNo != null and withdrawalNo != ''">
AND withdrawal_no LIKE CONCAT('%', #{withdrawalNo}, '%')
</if>
ORDER BY create_time DESC
</select>
<insert id="insert" parameterType="com.kexue.skills.entity.WithdrawalRecord">
INSERT INTO withdrawal_record (
user_id, user_name, withdrawal_amount, fee_amount, actual_amount, status, withdrawal_no, bank_name, bank_account, bank_cardholder, remark, create_time, update_time, delete_flag, create_by, update_by
) VALUES (
#{userId}, #{userName}, #{withdrawalAmount}, #{feeAmount}, #{actualAmount}, #{status}, #{withdrawalNo}, #{bankName}, #{bankAccount}, #{bankCardholder}, #{remark}, #{createTime}, #{updateTime}, #{deleteFlag}, #{createBy}, #{updateBy}
)
</insert>
<update id="update" parameterType="com.kexue.skills.entity.WithdrawalRecord">
UPDATE withdrawal_record
<set>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="withdrawalAmount != null">withdrawal_amount = #{withdrawalAmount},</if>
<if test="feeAmount != null">fee_amount = #{feeAmount},</if>
<if test="actualAmount != null">actual_amount = #{actualAmount},</if>
<if test="status != null">status = #{status},</if>
<if test="withdrawalNo != null">withdrawal_no = #{withdrawalNo},</if>
<if test="bankName != null">bank_name = #{bankName},</if>
<if test="bankAccount != null">bank_account = #{bankAccount},</if>
<if test="bankCardholder != null">bank_cardholder = #{bankCardholder},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = #{updateTime}
</set>
WHERE record_id = #{recordId}
</update>
<update id="updateStatus" parameterType="java.util.Map">
UPDATE withdrawal_record
SET status = #{status}, update_time = CURRENT_TIMESTAMP
WHERE record_id = #{recordId}
</update>
<update id="logicDeleteById" parameterType="java.util.Map">
UPDATE withdrawal_record
SET delete_flag = 1, update_time = CURRENT_TIMESTAMP
WHERE record_id = #{recordId}
</update>
<delete id="deleteById" parameterType="java.lang.Long">
DELETE FROM withdrawal_record
WHERE record_id = #{recordId}
</delete>
</mapper>