SQL 修改

This commit is contained in:
cwchen 2025-08-22 10:53:13 +08:00
parent 183106222f
commit 5fd14cf810
2 changed files with 19 additions and 19 deletions

View File

@ -21,15 +21,15 @@
and t."phone" like concat('%', #{params.phonenumber}, '%')
</if>
<if test="params.orgId != null and params.orgId != '' and params.roleLevel &lt; 3">
AND po."id" in (${params.orgAll})
AND po.ID in (${params.orgAll})
</if>
<if test="params.orgId != null and params.orgId != '' and params.roleLevel >= 3">
AND po."id" = #{params.orgId}
AND po.ID = #{params.orgId}
</if>
<if test="params.keyWord != null and params.keyWord != ''">
and (
t."id_number" = #{params.keyWord} or
bp.NAME like concat('%', #{params.keyWord}, '%') or
bp."name" like concat('%', #{params.keyWord}, '%') or
sr."name" = #{params.keyWord}
)
</if>
@ -42,18 +42,18 @@
t."username" AS userName,
t."id_number" AS idNumber,
t."phone" AS phonenumber,
CASE
WHEN sr."type" LIKE '%3%' THEN po2."name"
ELSE po.NAME
CASE
WHEN sr."type" LIKE '%3%' THEN po2.NAME
ELSE po.NAME
END AS orgName,
sr.NAME AS roleName,
CASE
WHEN sr."type" LIKE '%3%' THEN bp.NAME
WHEN sr."type" LIKE '%4%' THEN bs."sub_NAME"
ELSE bp2."name"
sr."name" AS roleName,
CASE
WHEN sr."type" LIKE '%3%' THEN bp."name"
WHEN sr."type" LIKE '%4%' THEN bs."sub_name"
ELSE bp2."name"
END AS proName,
t."createTime",
t.STATUS,
t."status",
t."is_push"
FROM
"ynrealname"."sys_user" t
@ -78,15 +78,15 @@
and t."phone" like concat('%', #{params.phonenumber}, '%')
</if>
<if test="params.orgId != null and params.orgId != '' and params.roleLevel &lt; 3">
AND po."id" in (${params.orgAll})
AND po.ID in (${params.orgAll})
</if>
<if test="params.orgId != null and params.orgId != '' and params.roleLevel >= 3">
AND po."id" = #{params.orgId}
AND po.ID = #{params.orgId}
</if>
<if test="params.keyWord != null and params.keyWord != ''">
and (
t."id_number" = #{params.keyWord} or
bp.NAME like concat('%', #{params.keyWord}, '%') or
bp."name" like concat('%', #{params.keyWord}, '%') or
sr."name" = #{params.keyWord}
)
</if>

View File

@ -43,19 +43,19 @@
<select id="getCompanyAndSubCompany" resultType="com.bonus.system.api.domain.SelectBean">
SELECT
"id",
ID,
NAME,
CASE WHEN "company_id" = "foreign_id" THEN 1 ELSE 2 END as type
FROM
"ynrealname"."pm_organization"
WHERE
"is_active" = '1'
IS_ACTIVE = '1'
AND "foreign_id" IS NOT NULL
<if test="orgId != null and orgId != '' and roleLevel &lt; 3 and roleLevel &gt; 1">
AND INSTR(getParentList(#{orgId}), "id") > 0
AND INSTR(ID, getParentList(#{orgId})) > 0
</if>
<if test="orgId != null and orgId != '' and roleLevel &gt;= 3">
AND INSTR(getParentList(#{orgId}), "id") > 0
AND INSTR(ID, getParentList(#{orgId})) > 0
OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY
</if>
</select>