insert into business_org_staff_rel(
rel_id,operate,store_id,b_id,org_id,staff_id,rel_cd
) values (
#{relId},#{operate},#{storeId},#{bId},#{orgId},#{staffId},#{relCd}
)
select t.rel_id,t.rel_id relId,t.operate,t.store_id,t.store_id storeId,t.b_id,t.b_id bId,t.org_id,t.org_id
orgId,t.staff_id,t.staff_id staffId,t.rel_cd,t.rel_cd relCd
from business_org_staff_rel t
where 1 =1
and t.rel_id= #{relId}
and t.operate= #{operate}
and t.store_id= #{storeId}
and t.b_id= #{bId}
and t.org_id= #{orgId}
and t.staff_id= #{staffId}
and t.rel_cd= #{relCd}
insert into u_org_staff_rel(
rel_id,status_cd,store_id,b_id,org_id,staff_id,rel_cd
) select t.rel_id,'0',t.store_id,t.b_id,t.org_id,t.staff_id,t.rel_cd from business_org_staff_rel t where 1=1
and t.rel_id= #{relId}
and t.operate= 'ADD'
and t.store_id= #{storeId}
and t.b_id= #{bId}
and t.org_id= #{orgId}
and t.staff_id= #{staffId}
and t.rel_cd= #{relCd}
select t.rel_id,t.rel_id relId,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.b_id,t.b_id
bId,t.org_id,t.org_id orgId,t.staff_id,t.staff_id staffId,t.rel_cd,t.rel_cd relCd,uo.parent_org_id parentOrgId,
uu.name staffName,uo.org_name departmentName,uo.org_id departmentId,td.`name` relCdName,puo.org_name parentOrgName,uo.org_name orgName
from u_org_staff_rel t
inner join u_org uo on t.org_id = uo.org_id and uo.status_cd = '0'
inner join u_org puo on uo.parent_org_id = puo.org_id and puo.status_cd = '0'
inner join u_user uu on t.staff_id = uu.user_id
left join t_dict td on t.rel_cd = td.status_cd and td.table_name = 'u_org_staff_rel' and td.table_columns = 'rel_cd'
where 1=1
and uu.status_cd = '0'
and uo.status_cd = '0'
and t.status_cd= '0'
and t.rel_id= #{relId}
and t.store_id= #{storeId}
and t.b_id= #{bId}
and t.org_id= #{orgId}
and t.staff_id= #{staffId}
and t.rel_cd= #{relCd}
limit #{page}, #{row}
update u_org_staff_rel t set t.status_cd = #{statusCd}
,t.b_id = #{newBId}
, t.store_id= #{storeId}
, t.org_id= #{orgId}
, t.staff_id= #{staffId}
, t.rel_cd= #{relCd}
where 1=1
and t.rel_id= #{relId}
and t.b_id= #{bId}
select count(1) count
from u_org_staff_rel t,u_org uo
where t.org_id = uo.org_id
and uo.status_cd = '0'
and t.rel_id= #{relId}
and t.status_cd= #{statusCd}
and t.store_id= #{storeId}
and t.b_id= #{bId}
and t.org_id= #{orgId}
and t.staff_id= #{staffId}
and t.rel_cd= #{relCd}
select
t.rel_id relId,t.org_id departmentId,t.staff_id staffId,t.store_id storeId,u.org_name departmentName,
u.parent_org_id companyId,o.org_name companyName,o.org_id companyId
from
u_org_staff_rel t
inner join u_org u on t.org_id = u.org_id
inner join u_org o on u.parent_org_id = o.org_id
WHERE 1 = 1
and t.staff_id in
#{item}
and t.staff_id =#{staffId}
select
t.rel_id relId,t.org_id departmentId,t.staff_id staffId,t.store_id storeId,u.org_name departmentName,
u.org_id orgId,u.parent_org_id parentOrgId,u.org_level orgLevel
from
u_org_staff_rel t
inner join u_org u on t.org_id = u.org_id
WHERE 1 = 1 AND t.status_cd=0
and t.staff_id in
#{item}
and t.staff_id =#{staffId}