CompanyMapper.xml
7.47 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
170
171
172
173
174
175
176
177
178
<?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.huaheng.pc.general.company.mapper.CompanyMapper">
<select id="selectCompanyByUserId" parameterType="Integer" resultType="com.huaheng.pc.general.company.domain.Company">
SELECT c.id, c.name, c.code
FROM sys_user_company suc
INNER JOIN company c ON suc.companyId = c.id AND suc.userId = #{userId}
INNER JOIN warehouse_company wc ON wc.companyId=c.id AND wc.warehouseId = #{warehouseId}
</select>
<select id="selectCompanyList" resultType="com.huaheng.pc.general.company.domain.Company">
SELECT c.id, c.code, c.parentId, c.type, c.name, c.address1, c.address2, c.city, c.province, c.country, c.postalCode,
c.attentionTo, c.phoneNum, c.mobile, c.faxNum, c.email, c.created, c.createdBy, c.lastUpdated, c.lastUpdatedBy, c.enable,
c.deleted, c.userDef1, c.userDef2, c.userDef3
FROM company c
inner join warehouse_company wc ON c.id = wc.companyId
<if test="id != null and id != ''">
AND c.id = #{id}
</if>
<if test="code != null and code != ''">
<bind name="codePattern" value="'%' + code + '%'" />
AND c.code like #{codePattern}
</if>
<if test="parentId != null and parentId != ''">
AND c.parentId = #{parentId}
</if>
<if test="type != null and type != ''">
<bind name="typePattern" value="'%' + type + '%'" />
AND c.type like #{typePattern}
</if>
<if test="name != null and name != ''">
<bind name="namePattern" value="'%' + name + '%'" />
AND c.name like #{namePattern}
</if>
<if test="address1 != null and address1 != ''">
<bind name="address1Pattern" value="'%' + address1 + '%'" />
AND c.address1 like #{address1Pattern}
</if>
<if test="address2 != null and address2 != ''">
<bind name="address2Pattern" value="'%' + address2 + '%'" />
AND c.address2 like #{address2Pattern}
</if>
<if test="city != null and city != ''">
<bind name="cityPattern" value="'%' + city + '%'" />
AND c.city like #{cityPattern}
</if>
<if test="province != null and province != ''">
<bind name="provincePattern" value="'%' + province + '%'" />
AND c.province like #{provincePattern}
</if>
<if test="country != null and country != ''">
<bind name="countryPattern" value="'%' + country + '%'" />
AND c.country like #{countryPattern}
</if>
<if test="postalCode != null and postalCode != ''">
<bind name="postalCodePattern" value="'%' + postalCode + '%'" />
AND c.postalCode like #{postalCodePattern}
</if>
<if test="attentionTo != null and attentionTo != ''">
<bind name="attentionToPattern" value="'%' + attentionTo + '%'" />
AND c.attentionTo like #{attentionToPattern}
</if>
<if test="phoneNum != null and phoneNum != ''">
<bind name="phoneNumPattern" value="'%' + phoneNum + '%'" />
AND c.phoneNum like #{phoneNumPattern}
</if>
<if test="mobile != null and mobile != ''">
<bind name="mobilePattern" value="'%' + mobile + '%'" />
AND c.mobile like #{mobilePattern}
</if>
<if test="faxNum != null and faxNum != ''">
<bind name="faxNumPattern" value="'%' + faxNum + '%'" />
AND c.faxNum like #{faxNumPattern}
</if>
<if test="email != null and email != ''">
<bind name="emailPattern" value="'%' + email + '%'" />
AND c.email like #{emailPattern}
</if>
<if test="created != null and created != ''">
AND c.created = #{created}
</if>
<if test="createdBy != null and createdBy != ''">
<bind name="createdByPattern" value="'%' + createdBy + '%'" />
AND c.createdBy like #{createdByPattern}
</if>
<if test="lastUpdated != null and lastUpdated != ''">
AND c.lastUpdated = #{lastUpdated}
</if>
<if test="lastUpdatedBy != null and lastUpdatedBy != ''">
<bind name="lastUpdatedByPattern" value="'%' + lastUpdatedBy + '%'" />
AND c.lastUpdatedBy like #{lastUpdatedByPattern}
</if>
<if test="enable != null and enable != ''">
AND c.enable = #{enable}
</if>
<if test="deleted != null and deleted != ''">
AND c.deleted = #{deleted}
</if>
<if test="userDef1 != null and userDef1 != ''">
<bind name="userDef1Pattern" value="'%' + userDef1 + '%'" />
AND c.userDef1 like #{userDef1Pattern}
</if>
<if test="userDef2 != null and userDef2 != ''">
<bind name="userDef2Pattern" value="'%' + userDef2 + '%'" />
AND c.userDef2 like #{userDef2Pattern}
</if>
<if test="userDef3 != null and userDef3 != ''">
<bind name="userDef3Pattern" value="'%' + userDef3 + '%'" />
AND c.userDef3 like #{userDef3Pattern}
</if>
<if test="warehouseId != null">
AND wc.warehouseId = #{warehouseId}
</if>
<if test="warehouseCode != null">
AND wc.warehouseCode = #{warehouseCode}
</if>
</select>
<select id="CompanyParent" resultType="java.util.Map">
SELECT id, code, name, enable
FROM company
<where>
<if test="enable != null and enable != ''">
AND enable = #{enable}
</if>
<if test="deleted != null and deleted != ''">
AND deleted = #{deleted}
</if>
<if test="type != null">
AND type = #{type}
</if>
</where>
</select>
<select id="getCurrentCompanyList" resultType="com.huaheng.pc.general.company.domain.Company">
SELECT c.id, c.code, c.parentId, c.name, c.enable
FROM company c
inner join warehouse_company wc ON c.id = wc.companyId
<if test="enable != null and enable != ''">
AND c.enable = #{enable}
</if>
<if test="deleted != null and deleted != ''">
AND c.deleted = #{deleted}
</if>
<if test="warehouseId != null">
AND wc.warehouseId = #{warehouseId}
</if>
<if test="warehouseCode != null">
AND wc.warehouseCode = #{warehouseCode}
</if>
</select>
<delete id="deleteCompanyByIds" parameterType="Integer">
update company set deleted=true where id in
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectCompanyWu" resultType="com.huaheng.pc.general.company.domain.CompanyWu">
select id, uCompanyCode, companyCode from company_wu
<where>
<if test="uCompanyCode != null and uCompanyCode != ''">
AND uCompanyCode = #{uCompanyCode}
</if>
<if test="companyCode != null and companyCode != ''">
AND companyCode = #{companyCode}
</if>
</where>
</select>
<select id="selcetIWCBycode" resultType="com.huaheng.pc.general.company.domain.WarehouseCompany">
select * from warehouse_company where warehouseCode = #{warehouseCode} AND companyCode=#{companyCode}
</select>
</mapper>