CompanyNewsItemMapper.xml
2.86 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
<?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="weaver.portal.mapper.companyNews.CompanyNewsItemMapper">
<!--void updateById(CompanyNewsItem companyNewsItem);-->
<update id="updateById">
update portal_companynewsitem
<set>
<if test="setting != null and setting != ''">
setting = #{setting},
</if>
<if test="orderIndex != null and orderIndex!=0">
order_index = #{orderIndex}
</if>
</set>
where id =#{id}
</update>
<!--void deleteByIds(List<Integer> ids);-->
<delete id="deleteByIds">
delete from portal_companynewsitem where id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
<!--void save(CompanyNewsItem companyNewsItem);-->
<insert id="save" databaseId="mysql">
insert into portal_companynewsitem(setting,companynews_id,order_index) select #{setting},#{companynewsId},coalesce(max(id),0)+1 from portal_companynewsitem
</insert>
<insert id="save" databaseId="sqlserver">
insert into portal_companynewsitem(setting,companynews_id,order_index) values(#{setting},#{companynewsId},(select coalesce(max(id),0)+1 from portal_companynewsitem))
</insert>
<insert id="save">
<selectKey order="BEFORE" keyProperty="id" resultType="_int">
select customer_companynew_id_seq.nextval from dual
</selectKey>
insert into portal_companynewsitem(id,setting,companynews_id,order_index) values(#{id},#{setting},#{companynewsId},(select coalesce(max(id),0)+1 from portal_companynewsitem))
</insert>
<!-- List<CompanyNewsItem> findByCompanyNewId(String companynewsId);-->
<select id="findByCompanyNewId" resultMap="resultMap1">
select * from portal_companynewsitem where companynews_id = #{companynewsId} order by order_index asc
</select>
<resultMap id="resultMap1" type="weaver.portal.entity.companyNews.CompanyNewsItem">
<id column="id" property="id"></id>
<result column="setting" property="setting"></result>
<result column="companynews_id" property="companynewsId"></result>
<result column="order_index" property="orderIndex"></result>
</resultMap>
<!--CompanyNewsItem findById(CompanyNewsItem companyNewsItem);-->
<select id="findById" resultMap="resultMap2">
select id,setting,companynews_id from portal_companynewsitem where id = #{id}
</select>
<resultMap id="resultMap2" type="weaver.portal.entity.companyNews.CompanyNewsItem">
<id column="id" property="id"></id>
<result column="setting" property="setting"></result>
<result column="companynews_id" property="companynewsId"></result>
</resultMap>
</mapper>