CompanyCreditMapper.xml
5.5 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
<?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.trash.business.mapper.CompanyCreditMapper">
<resultMap type="com.trash.business.domain.CompanyCredit" id="CompanyCreditResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="time" column="time" />
<result property="place" column="place" />
<result property="reason" column="reason" />
<result property="status" column="status" />
<result property="lostCredit" column="lost_credit" />
<result property="objectId" column="object_id" />
<result property="createBy" column="create_by" />
</resultMap>
<sql id="selectCompanyCreditVo">
select id, name, time, place, reason, status, lost_credit, object_id, create_by from company_credit
</sql>
<select id="selectCompanyCreditList" parameterType="CompanyCredit" resultMap="CompanyCreditResult">
<include refid="selectCompanyCreditVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="time != null "> and DATE_FORMAT(time,("%y%m%d")) = DATE_FORMAT(#{time},("%y%m%d"))</if>
<if test="place != null and place != ''"> and place = #{place}</if>
<if test="reason != null and reason != ''"> and reason = #{reason}</if>
<if test="status != null "> and status = #{status}</if>
<if test="lostCredit != null "> and lost_credit = #{lostCredit}</if>
<if test="objectId != null and objectId != ''"> and object_id = #{objectId}</if>
</where>
</select>
<select id="selectCompanyCreditById" parameterType="Long" resultMap="CompanyCreditResult">
<include refid="selectCompanyCreditVo"/>
where id = #{id}
</select>
<insert id="insertCompanyCredit" parameterType="CompanyCredit" useGeneratedKeys="true" keyProperty="id">
insert into company_credit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="time != null">time,</if>
<if test="place != null">place,</if>
<if test="reason != null">reason,</if>
<if test="status != null">status,</if>
<if test="lostCredit != null">lost_credit,</if>
<if test="objectId != null">object_id,</if>
<if test="createBy != null">create_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="time != null">#{time},</if>
<if test="place != null">#{place},</if>
<if test="reason != null">#{reason},</if>
<if test="status != null">#{status},</if>
<if test="lostCredit != null">#{lostCredit},</if>
<if test="objectId != null">#{objectId},</if>
<if test="createBy != null">#{createBy},</if>
</trim>
</insert>
<update id="updateCompanyCredit" parameterType="CompanyCredit">
update company_credit
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="time != null">time = #{time},</if>
<if test="place != null">place = #{place},</if>
<if test="reason != null">reason = #{reason},</if>
<if test="status != null">status = #{status},</if>
<if test="lostCredit != null">lost_credit = #{lostCredit},</if>
<if test="objectId != null">object_id = #{objectId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCompanyCreditById" parameterType="Long">
delete from company_credit where id = #{id}
</delete>
<delete id="deleteCompanyCreditByIds" parameterType="String">
delete from company_credit where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getNames" parameterType="CompanyCredit" resultType="String">
select DISTINCT name from company_credit
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="status != null "> and status = #{status}</if>
<if test="lostCredit != null "> and lost_credit = #{lostCredit}</if>
</where>
</select>
<select id="getPlaces" parameterType="CompanyCredit" resultType="String">
select DISTINCT place from company_credit
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="status != null "> and status = #{status}</if>
<if test="lostCredit != null "> and lost_credit = #{lostCredit}</if>
</where>
</select>
<select id="selectCompanyCreditHistory" parameterType="CompanyCredit" resultMap="CompanyCreditResult">
select c.* from (select a.* from company_credit a where not exists (select b.* from company_credit b where a.name = b.name and a.id < id )) c
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="place != null and place != ''"> and place = #{place}</if>
</where>
</select>
</mapper>