|
|
@@ -17,6 +17,12 @@
|
|
|
<result column="second_plot_code" property="secondPlotCode"/>
|
|
|
</resultMap>
|
|
|
|
|
|
+ <!-- 扩展映射:继承基础映射并添加特有字段 -->
|
|
|
+ <resultMap id="SearchProjectMap" type="com.siwei.apply.domain.SerchProject" extends="projectMap">
|
|
|
+ <result property="attachmentInfoList" column="attachmentInfoList" typeHandler="com.siwei.apply.handler.JsonTypeHandler"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+
|
|
|
<insert id="add" parameterType="com.siwei.apply.domain.Project">
|
|
|
INSERT INTO t_project (id, name, code, company,
|
|
|
created_at, updated_at, project_type,first_plot_code,second_plot_code, creator_id)
|
|
|
@@ -150,7 +156,7 @@
|
|
|
WHERE flow.node_id = #{nodeId} LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
- <select id="getListSearch" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="projectMap">
|
|
|
+ <select id="getListSearchOld" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="projectMap">
|
|
|
SELECT *
|
|
|
FROM t_project
|
|
|
<where>
|
|
|
@@ -175,7 +181,8 @@
|
|
|
LIMIT #{pageSize} offset #{offset}
|
|
|
</select>
|
|
|
|
|
|
- <select id="getSearchCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
|
|
|
+
|
|
|
+ <select id="getSearchCountOld" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
|
|
|
SELECT COUNT(*)
|
|
|
FROM t_project
|
|
|
<where>
|
|
|
@@ -198,6 +205,112 @@
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getListSearch" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="SearchProjectMap">
|
|
|
+ SELECT
|
|
|
+ P."id" AS id,
|
|
|
+ P."name" AS name,
|
|
|
+ P."code" AS code,
|
|
|
+ P."company" AS company,
|
|
|
+ P."created_at" AS createAt,
|
|
|
+ P."updated_at" AS updateAt,
|
|
|
+ P."project_type" AS projectType,
|
|
|
+ P."on_chain_num" AS onChainNum,
|
|
|
+ P."creator_id" AS creatorId,
|
|
|
+ COALESCE(
|
|
|
+ jsonb_agg(jsonb_build_object('id', A.id,
|
|
|
+ 'fileName', A.file_name,
|
|
|
+ 'nodeId', A.node_id,
|
|
|
+ 'filePath', A.file_path)),
|
|
|
+ '[]' -- 确保返回空数组而不是 null
|
|
|
+ ) AS attachmentInfoList
|
|
|
+ FROM
|
|
|
+ public.t_project P
|
|
|
+ LEFT JOIN
|
|
|
+ public.t_project_attachment_info A ON P.id = A.project_id
|
|
|
+ <if test="keyWords != null and keyWords.size() > 0">
|
|
|
+ AND regexp_like(A.file_name,
|
|
|
+ REGEXP_REPLACE(
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , '[\r\n\s]+', '', 'g')
|
|
|
+ , 'i')
|
|
|
+ </if>
|
|
|
+ <where>
|
|
|
+ <if test="keyWords != null and keyWords.size() > 0">
|
|
|
+ regexp_like(P.name,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ OR
|
|
|
+ regexp_like(P.code,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ OR
|
|
|
+ regexp_like(P.company,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ OR
|
|
|
+ regexp_like(A.file_name,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ </if>
|
|
|
+ <if test="isOnchain != null and isOnchain">
|
|
|
+ AND on_chain_num > 0
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ P.id, P.name, P.code, P.company, P.created_at, P.updated_at, P.project_type, P.on_chain_num, P.creator_id
|
|
|
+ ORDER BY
|
|
|
+ updated_at DESC
|
|
|
+ LIMIT #{pageSize} OFFSET #{offset}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getSearchCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
|
|
|
+ SELECT COUNT(*)
|
|
|
+ FROM (
|
|
|
+ SELECT DISTINCT
|
|
|
+ P."id" AS id,
|
|
|
+ P."name" AS name,
|
|
|
+ P."code" AS code,
|
|
|
+ P."company" AS company,
|
|
|
+ P."created_at" AS createAt,
|
|
|
+ P."updated_at" AS updateAt,
|
|
|
+ P."project_type" AS projectType,
|
|
|
+ P."on_chain_num" AS onChainNum,
|
|
|
+ P."creator_id" AS creatorId
|
|
|
+ FROM "public"."t_project" P
|
|
|
+ LEFT JOIN public.t_project_attachment_info A ON P.id = A.project_id
|
|
|
+ <if test="keyWords != null and keyWords.size() > 0">
|
|
|
+ AND regexp_like(A.file_name,
|
|
|
+ REGEXP_REPLACE(
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , '[\r\n\s]+', '', 'g')
|
|
|
+ , 'i')
|
|
|
+ </if>
|
|
|
+ <where>
|
|
|
+ <if test="keyWords != null and keyWords.size() > 0">
|
|
|
+ regexp_like(P.name,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ OR
|
|
|
+ regexp_like(P.code,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ OR
|
|
|
+ regexp_like(P.company,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ OR
|
|
|
+ regexp_like(A.file_name,
|
|
|
+ <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
|
|
|
+ , 'i')
|
|
|
+ </if>
|
|
|
+ <if test="isOnchain != null and isOnchain">
|
|
|
+ AND on_chain_num > 0
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ) AS distinct_projects
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
<delete id="deleteNodeByTable">
|
|
|
DELETE FROM ${tableName}
|
|
|
WHERE id = #{nodeId}
|