liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
<?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">
<!-- 
    namespace:必须与对应的接口全类名一致
    id:必须与对应接口的某个对应的方法名一致
    
 -->
<mapper namespace="com.basic.x01.securityCheck.mapper.SecurityMonthItemMapper">
    <resultMap id="TbSecurityMonthItem" type="TbSecurityMonthItem">
        <id property="itemId" column="item_id" />
        <result property="orgId" column="org_id" />
        <result property="itemYear" column="item_year" />
        <result property="itemMonth" column="item_month" />
        <result property="itemContent" column="item_content" />
        <result property="createTime" column="create_time" />
    </resultMap>
    
    <select id="getMonthItemByTime" resultMap="TbSecurityMonthItem">
        select * from tb_security_month_item
        where org_id=#{orgId} and item_year=#{year} and item_month=#{month}
    </select>
    <update id="updateTbSecurityMonthItem" parameterType="TbSecurityMonthItem">
        update tb_security_month_item
        set item_content=#{itemContent}
        where item_id=#{itemId} and org_id=#{orgId}
    </update>
    <insert id="insertTbSecurityMonthItemList" parameterType="java.util.List">
        insert into tb_security_month_item(item_id, org_id, item_year, item_month,
            item_content, create_time, create_user_id) values
        <foreach collection="list" item="item" index="index" separator="," >
            (replace(uuid(),'-',''), #{item.orgId}, #{item.itemYear}, #{item.itemMonth},
            #{item.itemContent}, 
            date_format(now(),'%Y-%m-%d %H:%i:%S'),
            #{item.createUserId}
            )
        </foreach>
    </insert>
    <select id="getItemYearList" resultType="java.lang.String">
        select distinct item_year from tb_security_month_item
        where org_id=#{orgId}
        order by item_year desc
    </select>
    <select id="getMonthItemById" resultMap="TbSecurityMonthItem">
        select * from tb_security_month_item
        where org_id=#{orgId} and item_id=#{itemId}
    </select>
    <select id="getMonthItem" resultMap="TbSecurityMonthItem">
        select * from tb_security_month_item
        where org_id=#{orgId} and item_year=#{itemYear}
        order by item_month
    </select>
</mapper>