刘光辉
4 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
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
<?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="jnpf.dmsMapper.DmsDocumentMapper">
    <resultMap id="Document" type="jnpf.dmsEntity.permission.entity.DmsDocumentEntity">
        <result column="id" property="id" typeHandler="jnpf.dmsDatabase.DmsUuidTypeHandler"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="folder_id" property="folderId" typeHandler="jnpf.dmsDatabase.DmsUuidTypeHandler"/>
        <result column="main_document_id" property="mainDocumentId" typeHandler="jnpf.dmsDatabase.DmsUuidTypeHandler"/>
        <result column="document_no" property="documentNo"/>
        <result column="name" property="name"/>
        <result column="document_type" property="documentType"/>
        <result column="responsible_dept_id" property="responsibleDeptId"/>
        <result column="created_by" property="createdBy"/>
        <result column="created_at" property="createdAt"/>
    </resultMap>
    <resultMap id="Count" type="java.lang.Integer"><result column="record_count"/></resultMap>
    <sql id="Columns">id, tenant_id, folder_id, main_document_id, document_no, name, document_type, responsible_dept_id, created_by, created_at</sql>
    <select id="selectByTenantAndId" resultMap="Document">
        SELECT <include refid="Columns"/> FROM public.dms_documents WHERE tenant_id=#{tenantId} AND id=#{id}
    </select>
    <select id="selectByTenantAndIdForUpdate" resultMap="Document">
        SELECT <include refid="Columns"/> FROM public.dms_documents WHERE tenant_id=#{tenantId} AND id=#{id} FOR UPDATE
    </select>
    <select id="selectByTenantAndIds" resultMap="Document">
        SELECT <include refid="Columns"/> FROM public.dms_documents WHERE tenant_id=#{tenantId} AND id IN
        <foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
    </select>
    <update id="bindMainDocument">
        UPDATE public.dms_documents SET main_document_id=#{mainDocumentId}
        WHERE tenant_id=#{tenantId} AND id=#{id} AND main_document_id IS NULL
    </update>
    <select id="countRecords" resultMap="Count">
        SELECT COUNT(*) AS record_count FROM public.dms_documents WHERE tenant_id=#{tenantId} AND main_document_id=#{mainDocumentId}
    </select>
</mapper>