CompanyMapper.xml
6.67 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?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="cn.runsa.portal.base.dao.CompanyMapper">
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Company">
<id column="coId" property="id" jdbcType="INTEGER" />
<result column="coCode" property="code" jdbcType="VARCHAR" />
<result column="coName" property="name" jdbcType="VARCHAR" />
<result column="coDesc" property="desc" jdbcType="VARCHAR" />
<result column="ptValid" property="valid" jdbcType="SMALLINT" />
<result column="plId" property="plId" jdbcType="INTEGER" />
<result column="coCorpman" property="corpman" jdbcType="VARCHAR" />
<result column="ptChief" property="chief" jdbcType="VARCHAR" />
<result column="ptPhone" property="phone" jdbcType="VARCHAR" />
<result column="ptTelphone" property="telphone" jdbcType="VARCHAR" />
<result column="ptEmail" property="email" jdbcType="VARCHAR" />
<result column="ptPost" property="post" jdbcType="VARCHAR" />
<result column="ptUrl" property="url" jdbcType="VARCHAR" />
<result column="diId" property="diId" jdbcType="INTEGER" />
<result column="ptAddr" property="addr" jdbcType="VARCHAR" />
<result column="coTaxId" property="taxId" jdbcType="VARCHAR" />
<result column="coLicense" property="license" jdbcType="VARCHAR" />
<result column="coOrgCode" property="orgCode" jdbcType="VARCHAR" />
<result column="ptRemark1" property="remark1" jdbcType="VARCHAR" />
<result column="ptRemark2" property="remark2" jdbcType="VARCHAR" />
<result column="ptRemark3" property="remark3" jdbcType="VARCHAR" />
<result column="ptUpTime" property="upTime" jdbcType="TIMESTAMP" />
<result column="ptUpdater" property="updater" jdbcType="INTEGER" />
<collection property="corpBizList" javaType="ArrayList"
ofType="cn.runsa.portal.base.entity.CorpBizEntity">
<id column="coId" property="coId" jdbcType="INTEGER" />
<result column="beId" property="beId" jdbcType="INTEGER" />
</collection>
<collection property="bizList" javaType="ArrayList"
ofType="cn.runsa.portal.base.entity.BizEntity">
<id column="beId" property="id" jdbcType="INTEGER" />
<result column="beName" property="name" jdbcType="VARCHAR" />
</collection>
</resultMap>
<insert id="insertCompany" parameterType="cn.runsa.portal.base.entity.Company">
<selectKey resultType="java.lang.Integer" keyProperty="id"
order="AFTER">
SELECT LAST_INSERT_ID()
</selectKey>
insert into mtcorp(coCode,coName,coDesc,ptValid
,coCorpman,ptChief,ptPhone,ptTelphone,ptEmail
,ptPost,ptUrl,diId,ptAddr,coTaxId,coLicense,coOrgCode,ptRemark1
,ptRemark2,ptRemark3,ptUpTime,ptUpdater,plId)
values(#{code},#{name},#{desc},#{valid},#{corpman},#{chief},#{phone},
#{telphone},#{email},#{post},#{url},#{diId},#{addr},
#{taxId},#{license},#{orgCode},#{remark1},#{remark2},#{remark3},now(),#{updater},#{plId})
</insert>
<select id="existsCoName" resultType="Boolean"
parameterType="cn.runsa.portal.base.entity.Company">
SELECT
COUNT(*)
FROM
mtCorp t1
LEFT JOIN mtCorpBizEntity t2 ON t2.coId = t1.coId
LEFT JOIN mtBizEntity t3 ON t3.beId = t2.beId
WHERE t1.coName = #{name}
AND t2.beId IN
<foreach item="item" collection="corpBizList" separator=","
open="(" close=")" index="">
#{item.beId, jdbcType=NUMERIC}
</foreach>
<if test="id!=null and id!=''">
AND t1.coId != #{id}
</if>
</select>
<!-- 税务登记号可为空 -->
<select id="existsTaxId" resultType="Boolean"
parameterType="cn.runsa.portal.base.entity.Company">
SELECT COUNT(*) FROM mtcorp WHERE 1=1
<if test="taxId!=null and taxId!=''">
AND coTaxId = #{taxId}
</if>
<if test="taxId==null or taxId==''">
AND 1=0
</if>
<if test="id!=null and id!=''">
AND coId != #{id}
</if>
</select>
<insert id="insertCorpBiz" parameterType="cn.runsa.portal.base.entity.Company">
insert into mtCorpBizEntity (coId,beId) values
<foreach collection="corpBizList" item="item" separator=",">
(#{id},#{item.beId})
</foreach>
</insert>
<select id="selectById" parameterType="java.lang.Integer"
resultMap="BaseResultMap">
SELECT
t1.coId,
t1.coCode,
t1.coName,
t1.coDesc,
t1.ptValid,
t1.plId,
t1.coCorpman,
t1.ptChief,
t1.ptPhone,
t1.ptTelphone,
t1.ptEmail,
t1.ptPost,
t1.ptUrl,
t1.diId,
t1.ptAddr,
t1.coTaxId,
t1.coLicense,
t1.coOrgCode,
t1.ptRemark1,
t1.ptRemark2,
t1.ptRemark3,
t1.ptUpTime,
t1.ptUpdater,
t3.beId,
t3.beName
FROM mtCorp t1
LEFT JOIN mtCorpBizEntity t2 ON t2.coId = t1.coId
LEFT JOIN mtBizEntity t3 ON t3.beId = t2.beId
WHERE t1.coId = #{id}
</select>
<update id="updateCompany" parameterType="cn.runsa.portal.base.entity.Company">
update mtcorp set
coCode=#{code},coName=#{name},ptValid=#{valid},ptUpTime=now(),ptUpdater=#{updater}
<if test="desc!=null and desc!=''">
,coDesc = #{desc,jdbcType=VARCHAR}
</if>
<if test="corpman!=null and corpman!=''">
,coCorpman = #{corpman,jdbcType=VARCHAR}
</if>
<if test="chief!=null and chief!=''">
,ptChief = #{chief,jdbcType=VARCHAR}
</if>
<if test="phone!=null and phone!=''">
,ptPhone = #{phone,jdbcType=VARCHAR}
</if>
<if test="telphone!=null and telphone!=''">
,ptTelphone = #{telphone,jdbcType=VARCHAR}
</if>
<if test="email!=null and email!=''">
,ptEmail = #{email,jdbcType=VARCHAR}
</if>
<if test="post!=null and post!=''">
,ptPost = #{post,jdbcType=VARCHAR}
</if>
<if test="url!=null and url!=''">
,ptUrl = #{url,jdbcType=VARCHAR}
</if>
<if test="diId!=null and diId!=''">
,diId = #{diId,jdbcType=INTEGER}
</if>
<if test="addr!=null and addr!=''">
,ptAddr = #{addr,jdbcType=VARCHAR}
</if>
<if test="taxId!=null and taxId!=''">
,coTaxId = #{taxId,jdbcType=VARCHAR}
</if>
<if test="license!=null and license!=''">
,coLicense = #{license,jdbcType=VARCHAR}
</if>
<if test="orgCode!=null and orgCode!=''">
,coOrgCode = #{orgCode,jdbcType=VARCHAR}
</if>
<if test="remark1!=null and remark1!=''">
,ptRemark1 = #{remark1,jdbcType=VARCHAR}
</if>
<if test="remark2!=null and remark2!=''">
,ptRemark2 = #{remark2,jdbcType=VARCHAR}
</if>
<if test="remark3!=null and remark3!=''">
,ptRemark3 = #{remark3,jdbcType=VARCHAR}
</if>
where coId = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteCorpBiz" parameterType="java.lang.Integer">
delete from mtCorpBizEntity where coId = #{coId,jdbcType=INTEGER}
</delete>
<delete id="deleteCompany" parameterType="java.lang.Integer">
delete from mtcorp where coId = #{coId,jdbcType=INTEGER}
</delete>
<select id="existsEmployee" resultType="Boolean" parameterType="java.lang.Integer">
SELECT COUNT(*) FROM mtemployee WHERE coId = #{coId,jdbcType=INTEGER}
</select>
</mapper>