系统管理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
|
||||
po.ID AS id,
|
||||
po.PARENT_ID AS pId ,
|
||||
po.COMPANY_ID as companyId,
|
||||
po.NAME as name,
|
||||
po."id" AS id,
|
||||
po."parent_id" AS pId ,
|
||||
po."company_id" as companyId,
|
||||
po."name" as name,
|
||||
po."foreign_id" as foreignId
|
||||
FROM
|
||||
"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
|
||||
po."is_active" = '1'
|
||||
<if test="companyId!=null and companyId!='' ">
|
||||
and pc.ID =#{companyId}
|
||||
and pc."id" =#{companyId}
|
||||
</if>
|
||||
<if test="childList!=null and childList!='' ">
|
||||
and po.ID in (${childList})
|
||||
and po."id" in (${childList})
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getAllRl" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
||||
SELECT
|
||||
po.ID AS id,
|
||||
po.PARENT_ID AS pId ,
|
||||
po.ID as companyId,
|
||||
po.NAME as name,
|
||||
po."id" AS id,
|
||||
po."parent_id" AS pId ,
|
||||
po."id" as companyId,
|
||||
po."name" as name,
|
||||
po."foreign_id" as foreignId
|
||||
FROM
|
||||
"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
|
||||
po."is_active" = '1'
|
||||
<if test="companyId!=null and companyId!='' ">
|
||||
and pc.ID =#{companyId}
|
||||
and pc."id" =#{companyId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCompanyTree" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
|
||||
SELECT
|
||||
ID AS id,
|
||||
PARENT_ID AS pId ,
|
||||
NAME as name,
|
||||
COMPANY_ID as companyId,
|
||||
"id" AS id,
|
||||
"parent_id" AS pId ,
|
||||
"name" as name,
|
||||
"company_id" as companyId,
|
||||
po."foreign_id" as foreignId
|
||||
FROM
|
||||
"ynrealname"."pm_organization"
|
||||
WHERE
|
||||
"is_active" = '1'
|
||||
<if test="companyId!=null and companyId!='' and companyId!='0' ">
|
||||
and COMPANY_ID = #{companyId}
|
||||
and "company_id" = #{companyId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<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})
|
||||
</insert>
|
||||
|
||||
|
|
@ -69,21 +69,21 @@
|
|||
update "ynrealname"."pm_organization"
|
||||
<set>
|
||||
<if test="name != null">
|
||||
NAME =#{name},
|
||||
"name" =#{name},
|
||||
</if>
|
||||
</set>
|
||||
where ID = #{id}
|
||||
where "id" = #{id}
|
||||
</update>
|
||||
|
||||
<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>
|
||||
|
||||
<select id="findCompanyInfo" resultType="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
|
||||
WHERE po.ID = #{id} AND po.IS_ACTIVE = 1
|
||||
WHERE po."id" = #{id} AND po."is_active" = 1
|
||||
</select>
|
||||
|
||||
<!-- <select id="getCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">-->
|
||||
|
|
@ -101,23 +101,23 @@
|
|||
<select id="getSubCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">
|
||||
WITH RECURSIVE org_tree(orgId, orgName, parentId, "level") AS (
|
||||
SELECT
|
||||
ID as orgId,
|
||||
NAME as orgName,
|
||||
PARENT_ID as parentId,
|
||||
"id" as orgId,
|
||||
"name" as orgName,
|
||||
"parent_id" as parentId,
|
||||
1 as "level"
|
||||
FROM "ynrealname"."pm_organization"
|
||||
WHERE ID = #{orgId} AND IS_ACTIVE = '1'
|
||||
WHERE "id" = #{orgId} AND "is_active" = '1'
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
po.ID as orgId,
|
||||
po.NAME as orgName,
|
||||
po.PARENT_ID as parentId,
|
||||
po."id" as orgId,
|
||||
po."name" as orgName,
|
||||
po."parent_id" as parentId,
|
||||
ot."level" + 1 as "level"
|
||||
FROM "ynrealname"."pm_organization" po
|
||||
INNER JOIN org_tree ot ON po.ID = ot.parentId
|
||||
WHERE po.IS_ACTIVE = '1' AND po.PARENT_ID > 0
|
||||
INNER JOIN org_tree ot ON po."id" = ot.parentId
|
||||
WHERE po."is_active" = '1' AND po."parent_id" > 0
|
||||
)
|
||||
SELECT
|
||||
orgId,
|
||||
|
|
|
|||
|
|
@ -172,7 +172,10 @@
|
|||
insert into "ynrealname"."sys_role_user"("roleId", "userId","is_active") values(#{roleId},#{userId},'1')
|
||||
</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"
|
||||
("username", "password", "loginname", "id_number","phone",
|
||||
<if test="orgId != null and orgId !=''">
|
||||
|
|
|
|||
Loading…
Reference in New Issue