From 564bf7ab6a639c2c4557d35b8fd9b51dca60a738 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期二, 22 八月 2023 13:32:34 +0800
Subject: [PATCH] #规则完善

---
 src/main/resources/mapper/OrderMapper.xml |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/OrderMapper.xml b/src/main/resources/mapper/OrderMapper.xml
index db34d6c..92140e8 100644
--- a/src/main/resources/mapper/OrderMapper.xml
+++ b/src/main/resources/mapper/OrderMapper.xml
@@ -30,4 +30,75 @@
 
     </resultMap>
 
+    <select id="selectByUuid" resultMap="BaseResultMap">
+        select * from man_order
+        where 1=1
+        and uuid = #{uuid}
+        <if test="hostId != null">
+            and host_id = #{hostId}
+        </if>
+    </select>
+
+    <select id="selectOrderByNewestUuid" resultMap="BaseResultMap">
+        select top 1 * from man_order
+        where 1=1
+        <if test="hostId != null">
+            and host_id = #{hostId}
+        </if>
+        order by uuid + 0 desc
+    </select>
+
+    <select id="listByPage" resultMap="BaseResultMap">
+        SELECT
+        mo.*
+        FROM man_order mo
+        LEFT JOIN sys_dept sd ON mo.dept_id = sd.id
+        WHERE 1=1
+        <choose>
+            <when test="deptId != null and deptId != ''">
+                AND (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
+                or
+                (
+                    user_id = #{userId}
+                    or
+                    mo.id in
+                    (
+                        select
+                        order_id
+                        from man_order_foll
+                        where 1=1
+                        and user_id = #{userId}
+                    )
+                )
+            </when>
+            <otherwise>
+                and
+                (
+                    user_id = #{userId}
+                    or
+                    mo.id in
+                    (
+                        select
+                        order_id
+                        from man_order_foll
+                        where 1=1
+                        and user_id = #{userId}
+                    )
+                )
+            </otherwise>
+        </choose>
+        <if test="hostId != null">
+            and mo.host_id = #{hostId}
+        </if>
+        <if test="condition != null and condition != ''">
+            and (
+            mo.uuid like concat('%',#{condition},'%')
+            or mo.name like concat('%',#{condition},'%')
+            or mo.remarks like concat('%',#{condition},'%')
+            or mo.addr like concat('%',#{condition},'%')
+            )
+        </if>
+        ORDER BY mo.create_time DESC
+    </select>
+
 </mapper>

--
Gitblit v1.9.1