系统管理SQL 修改
This commit is contained in:
parent
11712ec7e3
commit
5d38e04a88
|
|
@ -7,61 +7,61 @@
|
||||||
|
|
||||||
<select id="getAll" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
<select id="getAll" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
||||||
SELECT
|
SELECT
|
||||||
po.ID AS id,
|
po."id" AS id,
|
||||||
po.PARENT_ID AS pId ,
|
po."parent_id" AS pId ,
|
||||||
po.COMPANY_ID as companyId,
|
po."company_id" as companyId,
|
||||||
po.NAME as name,
|
po."name" as name,
|
||||||
po."foreign_id" as foreignId
|
po."foreign_id" as foreignId
|
||||||
FROM
|
FROM
|
||||||
"ynrealname"."pm_organization" po
|
"ynrealname"."pm_organization" po
|
||||||
LEFT JOIN "ynrealname"."pm_company" pc on po.COMPANY_ID = pc.ID
|
LEFT JOIN "ynrealname"."pm_company" pc on po."company_id" = pc."id"
|
||||||
WHERE
|
WHERE
|
||||||
po."is_active" = '1'
|
po."is_active" = '1'
|
||||||
<if test="companyId!=null and companyId!='' ">
|
<if test="companyId!=null and companyId!='' ">
|
||||||
and pc.ID =#{companyId}
|
and pc."id" =#{companyId}
|
||||||
</if>
|
</if>
|
||||||
<if test="childList!=null and childList!='' ">
|
<if test="childList!=null and childList!='' ">
|
||||||
and po.ID in (${childList})
|
and po."id" in (${childList})
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAllRl" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
<select id="getAllRl" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
||||||
SELECT
|
SELECT
|
||||||
po.ID AS id,
|
po."id" AS id,
|
||||||
po.PARENT_ID AS pId ,
|
po."parent_id" AS pId ,
|
||||||
po.ID as companyId,
|
po."id" as companyId,
|
||||||
po.NAME as name,
|
po."name" as name,
|
||||||
po."foreign_id" as foreignId
|
po."foreign_id" as foreignId
|
||||||
FROM
|
FROM
|
||||||
"ynrealname"."pm_organization" po
|
"ynrealname"."pm_organization" po
|
||||||
LEFT JOIN "ynrealname"."pm_company" pc on po.COMPANY_ID = pc.ID
|
LEFT JOIN "ynrealname"."pm_company" pc on po."company_id" = pc."id"
|
||||||
WHERE
|
WHERE
|
||||||
po."is_active" = '1'
|
po."is_active" = '1'
|
||||||
<if test="companyId!=null and companyId!='' ">
|
<if test="companyId!=null and companyId!='' ">
|
||||||
and pc.ID =#{companyId}
|
and pc."id" =#{companyId}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getCompanyTree" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
<select id="getCompanyTree" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
||||||
SELECT
|
SELECT
|
||||||
ID AS id,
|
"id" AS id,
|
||||||
PARENT_ID AS pId ,
|
"parent_id" AS pId ,
|
||||||
NAME as name,
|
"name" as name,
|
||||||
COMPANY_ID as companyId,
|
"company_id" as companyId,
|
||||||
po."foreign_id" as foreignId
|
po."foreign_id" as foreignId
|
||||||
FROM
|
FROM
|
||||||
"ynrealname"."pm_organization"
|
"ynrealname"."pm_organization"
|
||||||
WHERE
|
WHERE
|
||||||
"is_active" = '1'
|
"is_active" = '1'
|
||||||
<if test="companyId!=null and companyId!='' and companyId!='0' ">
|
<if test="companyId!=null and companyId!='' and companyId!='0' ">
|
||||||
and COMPANY_ID = #{companyId}
|
and "company_id" = #{companyId}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="addOrg" parameterType="com.bonus.bmw.basic.entity.OrgBean">
|
<insert id="addOrg" parameterType="com.bonus.bmw.basic.entity.OrgBean">
|
||||||
insert into "ynrealname"."pm_organization"( NAME,PARENT_ID,IS_ACTIVE,TYPE,"update_time",COMPANY_ID)
|
insert into "ynrealname"."pm_organization"( "name","parent_id","is_active","type","update_time","company_id")
|
||||||
values ( #{name},#{parentId},'1',#{type},now(),#{companyId})
|
values ( #{name},#{parentId},'1',#{type},now(),#{companyId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
@ -69,21 +69,21 @@
|
||||||
update "ynrealname"."pm_organization"
|
update "ynrealname"."pm_organization"
|
||||||
<set>
|
<set>
|
||||||
<if test="name != null">
|
<if test="name != null">
|
||||||
NAME =#{name},
|
"name" =#{name},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where ID = #{id}
|
where "id" = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="deleteOrg" parameterType="com.bonus.bmw.basic.entity.OrgBean">
|
<update id="deleteOrg" parameterType="com.bonus.bmw.basic.entity.OrgBean">
|
||||||
update "ynrealname"."pm_organization" set IS_ACTIVE = 0 WHERE ID = #{id}
|
update "ynrealname"."pm_organization" set "is_active" = 0 WHERE "id" = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="findCompanyInfo" resultType="com.bonus.bmw.basic.entity.OrgBean"
|
<select id="findCompanyInfo" resultType="com.bonus.bmw.basic.entity.OrgBean"
|
||||||
parameterType="com.bonus.bmw.basic.entity.OrgBean">
|
parameterType="com.bonus.bmw.basic.entity.OrgBean">
|
||||||
SELECT po.ID as companyId,po.NAME as companyName,po.PARENT_ID as parentId
|
SELECT po."id" as companyId,po."name" as companyName,po."parent_id" as parentId
|
||||||
FROM "ynrealname"."pm_organization" po
|
FROM "ynrealname"."pm_organization" po
|
||||||
WHERE po.ID = #{id} AND po.IS_ACTIVE = 1
|
WHERE po."id" = #{id} AND po."is_active" = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- <select id="getCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">-->
|
<!-- <select id="getCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">-->
|
||||||
|
|
@ -101,23 +101,23 @@
|
||||||
<select id="getSubCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">
|
<select id="getSubCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">
|
||||||
WITH RECURSIVE org_tree(orgId, orgName, parentId, "level") AS (
|
WITH RECURSIVE org_tree(orgId, orgName, parentId, "level") AS (
|
||||||
SELECT
|
SELECT
|
||||||
ID as orgId,
|
"id" as orgId,
|
||||||
NAME as orgName,
|
"name" as orgName,
|
||||||
PARENT_ID as parentId,
|
"parent_id" as parentId,
|
||||||
1 as "level"
|
1 as "level"
|
||||||
FROM "ynrealname"."pm_organization"
|
FROM "ynrealname"."pm_organization"
|
||||||
WHERE ID = #{orgId} AND IS_ACTIVE = '1'
|
WHERE "id" = #{orgId} AND "is_active" = '1'
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
po.ID as orgId,
|
po."id" as orgId,
|
||||||
po.NAME as orgName,
|
po."name" as orgName,
|
||||||
po.PARENT_ID as parentId,
|
po."parent_id" as parentId,
|
||||||
ot."level" + 1 as "level"
|
ot."level" + 1 as "level"
|
||||||
FROM "ynrealname"."pm_organization" po
|
FROM "ynrealname"."pm_organization" po
|
||||||
INNER JOIN org_tree ot ON po.ID = ot.parentId
|
INNER JOIN org_tree ot ON po."id" = ot.parentId
|
||||||
WHERE po.IS_ACTIVE = '1' AND po.PARENT_ID > 0
|
WHERE po."is_active" = '1' AND po."parent_id" > 0
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
orgId,
|
orgId,
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,10 @@
|
||||||
insert into "ynrealname"."sys_role_user"("roleId", "userId","is_active") values(#{roleId},#{userId},'1')
|
insert into "ynrealname"."sys_role_user"("roleId", "userId","is_active") values(#{roleId},#{userId},'1')
|
||||||
</insert>
|
</insert>
|
||||||
<!-- 添加用户 -->
|
<!-- 添加用户 -->
|
||||||
<insert id="saveUser" useGeneratedKeys="true" keyProperty = "userId" keyColumn="id">
|
<insert id="saveUser">
|
||||||
|
<selectKey resultType="java.lang.Long" keyProperty="userId" order="BEFORE">
|
||||||
|
SELECT @@IDENTITY
|
||||||
|
</selectKey>
|
||||||
insert into "ynrealname"."sys_user"
|
insert into "ynrealname"."sys_user"
|
||||||
("username", "password", "loginname", "id_number","phone",
|
("username", "password", "loginname", "id_number","phone",
|
||||||
<if test="orgId != null and orgId !=''">
|
<if test="orgId != null and orgId !=''">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue