13693261870
2025-07-08 5fe2a582e57d9ce35dbfb32c6e1c2227f35268f6
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
<?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.terra.system.mapper.sys.ResMapper">
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_res
        <where>
            1 = 1
            <if test="name != null">
                and (upper(cn_name) like #{name} or upper(en_name) like #{name})
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="category != null">
                and category = #{category}
            </if>
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="data != null">
                and data = #{data}
            </if>
        </where>
    </select>
 
    <select id="selectByPage" resultType="com.terra.system.entity.sys.ResEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName from lf.sys_res a
        <where>
            1 = 1
            <if test="name != null">
                and (upper(cn_name) like #{name} or upper(en_name) like #{name})
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="category != null">
                and category = #{category}
            </if>
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="data != null">
                and data = #{data}
            </if>
        </where>
        order by a.id desc
        limit #{limit} offset #{offset};
    </select>
 
    <select id="selectAll" resultType="com.terra.system.entity.sys.ResEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName
        from lf.sys_res a
        order by id desc;
    </select>
 
    <select id="selectById" resultType="com.terra.system.entity.sys.ResEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName
        from lf.sys_res a
        where id = #{id};
    </select>
 
    <select id="selectByPubid" resultType="com.terra.system.entity.sys.ResEntity">
        select * from lf.sys_res where pubid = #{pubid} limit 1;
    </select>
 
    <select id="selectCountForRole" resultType="java.lang.Integer">
        select count(a.*) from lf.sys_res a where not exists (select b.id from lf.sys_role_res b
        <where>
            b.resid = a.id
            <if test="roleid != null">
                and b.roleid = #{roleid}
            </if>
        </where>
        )
    </select>
 
    <select id="selectByPageForRole" resultType="com.terra.system.entity.sys.ResEntity">
        select a.* from lf.sys_res a where not exists (select b.id from lf.sys_role_res b
        <where>
            b.resid = a.id
            <if test="roleid != null">
                and b.roleid = #{roleid}
            </if>
        </where>
        )
        order by a.id desc
        limit #{limit} offset #{offset}
    </select>
 
    <insert id="insert" parameterType="com.terra.system.entity.sys.ResEntity">
        <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
            select currval('lf.sys_res_id_seq'::regclass) as id
        </selectKey>
 
        insert into lf.sys_res
        (cn_name,en_name,status,type,data,category,url,test,descr,depid,dirid,img,create_user,create_time,bak,tab,args,pubid)
        values
        (#{cnName},#{enName},#{status},#{type},#{data},#{category},#{url},#{test},#{descr},#{depid},#{dirid},#{img},#{createUser},now(),#{bak},#{tab},#{args},#{pubid})
    </insert>
 
    <insert id="inserts">
        insert into lf.sys_res
        (cn_name,en_name,status,type,data,category,url,test,descr,depid,dirid,img,create_user,create_time,bak,tab,args,pubid)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.cnName},#{item.enName},#{item.status},#{item.type},#{item.data},#{item.category},#{item.url},#{item.test},#{item.descr},#{item.depid},#{item.dirid},#{item.img},#{item.createUser},now(),#{item.bak},#{item.tab},#{item.args},#{item.pubid})
        </foreach>
    </insert>
 
    <delete id="delete">
        delete from lf.sys_layer where resid = #{id};
        delete from lf.sys_res where id = #{id};
    </delete>
 
    <delete id="deletes">
        delete from lf.sys_layer where resid in (${ids});
        delete from lf.sys_res where id in (${ids});
    </delete>
 
    <update id="update">
        update lf.sys_res
        set cn_name=#{cnName},en_name=#{enName},status=#{status},type=#{type},data=#{data},category=#{category},url=#{url},test=#{test},descr=#{descr},depid=#{depid},dirid=#{dirid},img=#{img},update_user=#{updateUser},update_time=now(),bak=#{bak},tab=#{tab},args=#{args},pubid=#{pubid}
        where id=#{id}
    </update>
 
    <update id="updates">
        <foreach collection="list" item="item" index="index" separator=";">
            update lf.sys_res
            set cn_name=#{item.cnName},en_name=#{item.enName},status=#{item.status},type=#{item.type},data=#{item.data},category=#{item.category},url=#{item.url},test=#{item.test},descr=#{item.descr},depid=#{item.depid},dirid=#{item.dirid},img=#{item.img},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak},tab=#{item.tab},args=#{item.args},pubid=#{item.pubid}
            where id = #{item.id}
        </foreach>
    </update>
</mapper>