ApiFinanceMapper.xml
7.97 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?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.lhcredit.project.business.apiFinance.mapper.ApiFinanceMapper">
<resultMap type="ApiFinance" id="ApiFinanceResult">
<result property="id" column="id" />
<result property="baseName" column="base_name" />
<result property="creditCode" column="credit_code" />
<result property="applicationTime" column="application_time" />
<result property="type" column="type" />
<result property="completionTime" column="completion_time" />
<result property="authCode" column="auth_code" />
<result property="uId" column="u_id" />
<result property="progress" column="progress" />
<result property="orgId" column="org_id" />
<result property="reconciliation" column="reconciliation" />
</resultMap>
<sql id="selectApiFinanceVo">
select id, base_name, credit_code, application_time, type, completion_time, auth_code, u_id , progress , org_id ,reconciliation from api_finance
</sql>
<select id="getFinanceCountByUser" parameterType="String" resultType="Long">
SELECT
COUNT( id ) AS "financeCount"
FROM
api_finance
WHERE
u_id = #{uId}
</select>
<select id="selectApiFinanceList" parameterType="com.lhcredit.project.business.apiFinance.domain.ApiFinance" resultMap="ApiFinanceResult">
<include refid="selectApiFinanceVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="baseName != null and baseName != ''">
and base_name LIKE CONCAT('%', #{baseName}, '%')
</if>
<if test="creditCode != null and creditCode != ''">
and credit_code LIKE CONCAT('%', #{creditCode}, '%')
</if>
<if test="applicationTime != null "> and application_time = #{applicationTime}</if>
<if test="type != null and type != '' "> and type = #{type}</if>
<if test="completionTime != null "> and completion_time = #{completionTime}</if>
<if test="authCode != null and authCode != '' "> and auth_code = #{authCode}</if>
<if test="uId != null and uId != '' "> and u_id = #{uId}</if>
<if test="progress != null "> and progress = #{progress}</if> <!-- 修正字段名 -->
<if test="orgId != null "> and org_id = #{orgId}</if>
<if test="reconciliation != null "> and reconciliation = #{reconciliation}</if>
<!-- 时间范围查询优化 -->
<if test="startTime != null">
<if test="endTime != null">
and application_time between #{startTime} and #{endTime}
</if>
</if>
</where>
<!-- 合并排序条件 -->
<if test="(completionTimeOrder != null and completionTimeOrder != '')
or (applicationTimeOrder != null and applicationTimeOrder != '')">
order by
<choose>
<when test="completionTimeOrder != null and completionTimeOrder != ''">
completion_time ${completionTimeOrder}
<if test="applicationTimeOrder != null and applicationTimeOrder != ''">
, application_time ${applicationTimeOrder}
</if>
</when>
<otherwise>
application_time ${applicationTimeOrder}
</otherwise>
</choose>
</if>
<!-- 默认排序放在动态排序之后 -->
<if test="(completionTimeOrder == null or completionTimeOrder == '')
and (applicationTimeOrder == null or applicationTimeOrder == '')">
order by application_time desc
</if>
</select>
<select id="selectApiFinanceById" parameterType="Integer" resultMap="ApiFinanceResult">
<include refid="selectApiFinanceVo"/>
where id = #{id}
</select>
<select id="getAllByContractId" parameterType="com.lhcredit.project.business.apiFinance.domain.ApiFinance" resultMap="ApiFinanceResult">
select a.* from api_finance a join front_dept f on a.org_id = f.id
<where>
<if test="contractId != null and contractId != '' ">
and f.contract_num = #{contractId}
</if>
<if test="orgId != null and orgId != '' ">
and a.org_id = #{orgId}
</if>
<if test="uId != null and uId != '' ">
and a.u_id = #{uId}
</if>
<if test="type != null and type != '' ">
and a.type = #{type}
</if>
<if test="startTime != null">
<if test="endTime != null">
and application_time between #{startTime} and #{endTime}
</if>
</if>
</where>
</select>
<insert id="insertApiFinance" parameterType="ApiFinance" useGeneratedKeys="true" keyProperty="id">
insert into api_finance
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="baseName != null and baseName != '' ">base_name,</if>
<if test="creditCode != null and creditCode != '' ">credit_code,</if>
<if test="applicationTime != null ">application_time,</if>
<if test="type != null and type != '' ">type,</if>
<if test="completionTime != null ">completion_time,</if>
<if test="authCode != null and authCode != '' ">auth_code,</if>
<if test="uId != null and uId != '' ">u_id,</if>
<if test="progress != null ">progress,</if>
<if test="orgId != null ">org_id,</if>
<if test="reconciliation != null and reconciliation != '' ">reconciliation,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="baseName != null and baseName != '' ">#{baseName},</if>
<if test="creditCode != null and creditCode != '' ">#{creditCode},</if>
<if test="applicationTime != null ">#{applicationTime},</if>
<if test="type != null and type != '' ">#{type},</if>
<if test="completionTime != null ">#{completionTime},</if>
<if test="authCode != null and authCode != '' ">#{authCode},</if>
<if test="uId != null and uId != '' ">#{uId},</if>
<if test="progress != null ">#{progress},</if>
<if test="orgId != null ">#{orgId},</if>
<if test="reconciliation != null and reconciliation != '' ">#{reconciliation},</if>
</trim>
</insert>
<update id="updateApiFinance" parameterType="ApiFinance">
update api_finance
<trim prefix="SET" suffixOverrides=",">
<if test="baseName != null and baseName != '' ">base_name = #{baseName},</if>
<if test="creditCode != null and creditCode != '' ">credit_code = #{creditCode},</if>
<if test="applicationTime != null ">application_time = #{applicationTime},</if>
<if test="type != null and type != '' ">type = #{type},</if>
<if test="completionTime != null ">completion_time = #{completionTime},</if>
<if test="authCode != null and authCode != '' ">auth_code = #{authCode},</if>
<if test="uId != null and uId != '' ">u_id = #{uId},</if>
<if test="progress != null ">progress = #{progress},</if>
<if test="orgId != null ">org_id = #{orgId},</if>
<if test="reconciliation != null and reconciliation != '' ">reconciliation = #{reconciliation},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteApiFinanceById" parameterType="Integer">
delete from api_finance where id = #{id}
</delete>
<delete id="deleteApiFinanceByIds" parameterType="String">
delete from api_finance where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>