feat: (REQ-3057) 删除人员时代码优化
This commit is contained in:
parent
a82d2beff3
commit
4bc7c54e4b
@ -0,0 +1,57 @@
|
||||
package cn.axzo.im;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.config.MybatisPlusAutoConfiguration;
|
||||
import cn.axzo.im.config.RocketMQEventConfiguration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@Slf4j
|
||||
//@SpringBootApplication(scanBasePackages = "cn.axzo", exclude = MybatisPlusAutoConfiguration.class)
|
||||
//@EnableFeignClients(basePackages = {"cn.axzo"})
|
||||
//@MapperScan(value = {"cn.axzo.im.dao.mapper"})
|
||||
//@EnableDiscoveryClient
|
||||
//@Import(RocketMQEventConfiguration.class)
|
||||
public class ImCenterPreApplication {
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("rocket.consumer.listeners.disable", "true");
|
||||
System.setProperty("spring.profiles.active", "pre");
|
||||
System.setProperty("NACOS_HOST", "https://pre-nacos.axzo.cn");
|
||||
System.setProperty("NACOS_NAMESPACE_ID", "8b4cf725-7595-4c92-b2a6-9260a51ce078");
|
||||
System.setProperty("CUSTOM_ENV", "pre");
|
||||
System.setProperty("NACOS_PORT", "443");
|
||||
|
||||
System.setProperty("spring.redis.port", "6379");
|
||||
System.setProperty("spring.redis.host", "172.16.1.76");
|
||||
System.setProperty("spring.redis.password", "25HWbgHCsgoE2OktIn9w");
|
||||
System.setProperty("rocketmq.name-server", "172.16.2.82:9876");
|
||||
|
||||
SpringApplication application = new SpringApplication(ImCenterPreApplication.class);
|
||||
ApplicationContext applicationContext = application.run(args);
|
||||
Environment env = applicationContext.getEnvironment();
|
||||
log.info(
|
||||
"--------------------------------------------------------------------------------------------------------------------\n" +
|
||||
"Application 【{}】 is running on 【{}】 environment!\n" +
|
||||
"Api Local: \thttp://127.0.0.1:{}\n" +
|
||||
"Mysql: \t{}\t username:{}\n" +
|
||||
"Redis: \t{}:{}\t database:{}\n" +
|
||||
"RabbitMQ: \t{}\t username:{}",
|
||||
env.getProperty("spring.application.name"),
|
||||
env.getProperty("spring.profiles.active"),
|
||||
env.getProperty("server.port"),
|
||||
env.getProperty("spring.datasource.url"),
|
||||
env.getProperty("spring.datasource.username"),
|
||||
env.getProperty("spring.redis.host"),
|
||||
env.getProperty("spring.redis.port"),
|
||||
env.getProperty("spring.redis.database"),
|
||||
env.getProperty("spring.rabbitmq.addresses"),
|
||||
env.getProperty("spring.rabbitmq.username") +
|
||||
"\n----------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@ import org.springframework.core.env.Environment;
|
||||
//@EnableFeignClients(basePackages = {"cn.axzo"})
|
||||
//@MapperScan(value = {"cn.axzo.im.dao.mapper"})
|
||||
//@EnableDiscoveryClient
|
||||
//@Import(RocketMQEventConfiguration.class)
|
||||
@Import(RocketMQEventConfiguration.class)
|
||||
public class ImCenterTestApplication {
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("spring.profiles.active", "test");
|
||||
|
||||
@ -115,8 +115,7 @@ public class OrganizationalNodeUserChangeEventHandler implements EventHandler, I
|
||||
private OrgNodeUserPayLoadBean buildPayload(Event event) {
|
||||
|
||||
if (EventTypeEnum.NODE_USER_CREATE.getName().equalsIgnoreCase(event.getEventCode().getName())
|
||||
|| EventTypeEnum.NODE_USER_UPDATE.getName().equalsIgnoreCase(event.getEventCode().getName())
|
||||
|| EventTypeEnum.NODE_USER_DELETE.getName().equalsIgnoreCase(event.getEventCode().getName())) {
|
||||
|| EventTypeEnum.NODE_USER_UPDATE.getName().equalsIgnoreCase(event.getEventCode().getName())) {
|
||||
//解析数据
|
||||
OrganizationalNodeUserPayload payload = event.normalizedData(OrganizationalNodeUserPayload.class);
|
||||
OrgNodeUserPayLoad newNodeUser = this.buildPayload(payload.getId());
|
||||
@ -124,6 +123,14 @@ public class OrganizationalNodeUserChangeEventHandler implements EventHandler, I
|
||||
.build();
|
||||
}
|
||||
|
||||
if (EventTypeEnum.NODE_USER_DELETE.getName().equalsIgnoreCase(event.getEventCode().getName())) {
|
||||
//解析数据
|
||||
OrganizationalNodeUserPayload payload = event.normalizedData(OrganizationalNodeUserPayload.class);
|
||||
OrgNodeUserPayLoad newNodeUser = this.buildDeletePayload(payload);
|
||||
return OrgNodeUserPayLoadBean.builder().newNodeUser(newNodeUser)
|
||||
.build();
|
||||
}
|
||||
|
||||
if (EventTypeEnum.NODE_USER_UPSERTED.getName().equalsIgnoreCase(event.getEventCode().getName())) {
|
||||
//解析数据
|
||||
OrganizationalNodeUserUpsertedPayload payload = event.normalizedData(OrganizationalNodeUserUpsertedPayload.class);
|
||||
@ -154,6 +161,21 @@ public class OrganizationalNodeUserChangeEventHandler implements EventHandler, I
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建处理对象
|
||||
*/
|
||||
private OrgNodeUserPayLoad buildDeletePayload(OrganizationalNodeUserPayload payload) {
|
||||
|
||||
return OrgNodeUserPayLoad.builder()
|
||||
.workspaceId(payload.getWorkspaceId())
|
||||
.ouId(payload.getOrganizationalUnitId())
|
||||
.nodeId(payload.getOrganizationalNodeId())
|
||||
.jobId(payload.getOrganizationalJobId())
|
||||
.personId(payload.getPersonId())
|
||||
.tag(EventTypeEnum.NODE_USER_DELETE.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建处理对象
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user