ID_,ORG_ID_,USER_ID_,IS_MASTER_,IS_CURRENT_,IS_CHARGE_,POS_ID_,START_DATE_,END_DATE_,IS_REL_ACTIVE_,UPDATE_TIME_,IS_DELE_,VERSION_
UPDATE UC_ORG_USER SET,UPDATE_TIME_ = #{updateTime,jdbcType=TIMESTAMP}
POS_ID_=#{relId,jdbcType=VARCHAR}
WHERE
ID_=#{id}
update UC_ORG_USER set IS_MASTER_=1,UPDATE_TIME_ = #{updateTime,jdbcType=TIMESTAMP} where ID_=#{id}
update UC_ORG_USER set IS_MASTER_=0,UPDATE_TIME_ = #{updateTime,jdbcType=TIMESTAMP} where USER_ID_=#{userId}
DELETE FROM UC_ORG_USER WHERE IS_DELE_='1'
UPDATE UC_ORG_USER SET IS_DELE_='1',UPDATE_TIME_ = #{updateTime,jdbcType=TIMESTAMP}
WHERE
USER_ID_=#{userId} and ORG_ID_ =#{orgId}
UPDATE UC_ORG_USER SET IS_DELE_='1',UPDATE_TIME_ = #{updateTime,jdbcType=TIMESTAMP}
WHERE
USER_ID_=#{userId}
DELETE FROM UC_ORG_USER WHERE USER_ID_=#{userId}
UPDATE UC_ORG_USER SET IS_DELE_='1',UPDATE_TIME_ = #{updateTime,jdbcType=TIMESTAMP} where ORG_ID_ = #{orgId}
#{startDate} or END_DATE_<#{endDate})
]]>
update uc_org_user SET IS_DELE_='1' WHERE ORG_ID_=#{orgId} AND USER_ID_=#{userId} AND POS_ID_ IS NULL
update uc_org_user SET ORG_ID_=#{orgId} where POS_ID_ = #{postId}
INSERT INTO UC_ORG_USER
(ID_,ORG_ID_,USER_ID_,IS_MASTER_,IS_CHARGE_,POS_ID_,START_DATE_,END_DATE_,IS_REL_ACTIVE_,UPDATE_TIME_,IS_DELE_,VERSION_,create_by_,create_time_,create_org_id_)
VALUES
(#{item.id,jdbcType=VARCHAR}, #{item.orgId,jdbcType=VARCHAR}, #{item.userId,jdbcType=VARCHAR}, #{item.isMaster,jdbcType=NUMERIC},
#{item.isCharge,jdbcType=NUMERIC},#{item.relId,jdbcType=VARCHAR},#{item.startDate,jdbcType=TIMESTAMP},#{item.endDate,jdbcType=TIMESTAMP},
#{item.isRelActive,jdbcType=NUMERIC},#{item.updateTime,jdbcType=TIMESTAMP},#{item.isDelete,jdbcType=VARCHAR},#{item.version,jdbcType=NUMERIC},
#{item.createBy,jdbcType=VARCHAR},#{item.createTime,jdbcType=TIMESTAMP},#{item.createOrgId,jdbcType=VARCHAR})
INSERT INTO UC_ORG_USER
(ID_,ORG_ID_,USER_ID_,IS_MASTER_,IS_CHARGE_,POS_ID_,START_DATE_,END_DATE_,IS_REL_ACTIVE_,UPDATE_TIME_,IS_DELE_,VERSION_,create_by_,create_time_,create_org_id_)
(
select #{item.id,jdbcType=VARCHAR}, #{item.orgId,jdbcType=VARCHAR}, #{item.userId,jdbcType=VARCHAR}, #{item.isMaster,jdbcType=NUMERIC},
#{item.isCharge,jdbcType=NUMERIC},#{item.relId,jdbcType=VARCHAR},#{item.startDate,jdbcType=TIMESTAMP},#{item.endDate,jdbcType=TIMESTAMP},
#{item.isRelActive,jdbcType=NUMERIC},#{item.updateTime,jdbcType=TIMESTAMP},#{item.isDelete,jdbcType=VARCHAR},#{item.version,jdbcType=NUMERIC},
#{item.createBy,jdbcType=VARCHAR},#{item.createTime,jdbcType=TIMESTAMP},#{item.createOrgId,jdbcType=VARCHAR} FROM DUAL
)
DELETE FROM uc_org_user WHERE ID_ IN(
select id from(
SELECT aa.id_ as id FROM uc_org_user aa LEFT JOIN (SELECT * FROM (SELECT USER_ID_,ORG_ID_,COUNT(USER_ID_) AS ct FROM uc_org_user GROUP BY USER_ID_,ORG_ID_) AS nt WHERE nt.ct>1) bb
ON aa.USER_ID_ = bb.USER_ID_ AND aa.ORG_ID_ = bb.ORG_ID_ WHERE bb.USER_ID_ is not null AND aa.POS_ID_ is null) as c
)
DELETE FROM uc_org_user WHERE ID_ IN(
select id from(
SELECT aa.id_ as id FROM uc_org_user aa LEFT JOIN (SELECT * FROM (SELECT USER_ID_,ORG_ID_,COUNT(USER_ID_) AS ct FROM uc_org_user GROUP BY USER_ID_,ORG_ID_) nt WHERE nt.ct>1) bb
ON aa.USER_ID_ = bb.USER_ID_ AND aa.ORG_ID_ = bb.ORG_ID_ WHERE bb.USER_ID_ is not null AND aa.POS_ID_ is null) c
)