zj
2024-06-03 81a29edf665881828e4ca1f0e444bfcbc6ab6f24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?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.nq.dao.UserLeverApplyMapper">
 
    <resultMap type="com.nq.pojo.UserLeverApply" id="UserLeverApplyResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="leverageRatio"    column="leverage_ratio"    />
        <result property="applyStatus"    column="apply_status"    />
        <result property="applyTime"    column="apply_time"    />
    </resultMap>
 
    <resultMap type="com.nq.vo.user.UserApplyLeverRes" id="UserLeverApplyVoResult">
        <result property="userLeverApply.id"    column="id"    />
        <result property="userLeverApply.userId"    column="user_id"    />
        <result property="userLeverApply.leverageRatio"    column="leverage_ratio"    />
        <result property="userLeverApply.applyStatus"    column="apply_status"    />
        <result property="userLeverApply.applyTime"    column="apply_time"    />
        <result property="user.agentName"    column="agent_name"    />
        <result property="user.phone"    column="phone"    />
        <result property="user.realName"    column="real_name"    />
        <result property="user.leverageRatio"    column="user_leverage"    />
    </resultMap>
 
    <sql id="selectUserLeverApplyVo">
        select id, user_id, leverage_ratio, apply_status, apply_time from user_lever_apply
    </sql>
 
    <select id="selectUserLeverApplyList" parameterType="com.nq.pojo.UserLeverApply" resultMap="UserLeverApplyResult">
        <include refid="selectUserLeverApplyVo"/>
        <where>
                1=1
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="leverageRatio != null "> and leverage_ratio = #{leverageRatio}</if>
            <if test="applyStatus != null "> and apply_status = #{applyStatus}</if>
            <if test="applyTime != null "> and apply_time = #{applyTime}</if>
        </where>
    </select>
 
    <select id="selectUserLeverApplyVoList" parameterType="com.nq.pojo.UserLeverApply" resultMap="UserLeverApplyVoResult">
            select ula.*,u.agent_name,u.phone,u.real_name,u.leverage_ratio as 'user_leverage'
            from user_lever_apply ula
            left join user u on ula.user_id = u.id
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="leverageRatio != null "> and leverage_ratio = #{leverageRatio}</if>
            <if test="applyStatus != null "> and apply_status = #{applyStatus}</if>
            <if test="applyTime != null "> and apply_time = #{applyTime}</if>
        </where>
        ORDER BY id DESC
    </select>
 
 
    <select id="selectUserLeverApplyById" parameterType="Long" resultMap="UserLeverApplyResult">
        <include refid="selectUserLeverApplyVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertUserLeverApply" parameterType="com.nq.pojo.UserLeverApply">
        insert into user_lever_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="leverageRatio != null">leverage_ratio,</if>
            <if test="applyStatus != null">apply_status,</if>
            <if test="applyTime != null">apply_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="leverageRatio != null">#{leverageRatio},</if>
            <if test="applyStatus != null">#{applyStatus},</if>
            <if test="applyTime != null">#{applyTime},</if>
         </trim>
    </insert>
 
    <update id="updateUserLeverApply" parameterType="com.nq.pojo.UserLeverApply">
        update user_lever_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="leverageRatio != null">leverage_ratio = #{leverageRatio},</if>
            <if test="applyStatus != null">apply_status = #{applyStatus},</if>
            <if test="applyTime != null">apply_time = #{applyTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteUserLeverApplyById" parameterType="Long">
        delete from user_lever_apply where id = #{id}
    </delete>
 
    <delete id="deleteUserLeverApplyByIds" parameterType="String">
        delete from user_lever_apply where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>