添加kafka配置管理

This commit is contained in:
wanggeng 2022-03-21 14:34:05 +08:00
parent 56ca764efb
commit c2a8dbba0e
15 changed files with 89 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.department.IDepartmentDeleteAfterHandler; import ink.wgink.interfaces.department.IDepartmentDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -26,9 +27,14 @@ public class DepartmentDeleteAfterHandlerImpl implements IDepartmentDeleteAfterH
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(List<String> departmentIds) throws SystemException { public void handle(List<String> departmentIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (departmentIds == null || departmentIds.isEmpty()) { if (departmentIds == null || departmentIds.isEmpty()) {
return; return;
} }

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.department.IDepartmentSaveAfterHandler; import ink.wgink.interfaces.department.IDepartmentSaveAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -25,9 +26,14 @@ public class DepartmentSaveAfterHandlerImpl implements IDepartmentSaveAfterHandl
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String departmentId, String departmentParentId, String departmentName, String departmentCode, Integer departmentType, String departmentAreaCode, String departmentAreaName) throws SystemException { public void handle(String departmentId, String departmentParentId, String departmentName, String departmentCode, Integer departmentType, String departmentAreaCode, String departmentAreaName) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(departmentId)) { if (StringUtils.isBlank(departmentId)) {
return; return;
} }

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.department.IDepartmentUpdateAfterHandler; import ink.wgink.interfaces.department.IDepartmentUpdateAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -25,6 +26,8 @@ public class DepartmentUpdateAfterHandlerImpl implements IDepartmentUpdateAfterH
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String departmentId, public void handle(String departmentId,
@ -33,6 +36,9 @@ public class DepartmentUpdateAfterHandlerImpl implements IDepartmentUpdateAfterH
Integer departmentType, Integer departmentType,
String departmentAreaCode, String departmentAreaCode,
String departmentAreaName) throws SystemException { String departmentAreaName) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(departmentId)) { if (StringUtils.isBlank(departmentId)) {
return; return;
} }

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridDeleteAfterHandler; import ink.wgink.interfaces.map.IGridDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -29,9 +30,14 @@ public class GridDeleteAfterHandlerImpl implements IGridDeleteAfterHandler {
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handler(List<String> gridIds) throws SystemException { public void handler(List<String> gridIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (gridIds.isEmpty()) { if (gridIds.isEmpty()) {
return; return;
} }

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridPointDeleteAfterHandler; import ink.wgink.interfaces.map.IGridPointDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -25,9 +26,14 @@ import java.util.Map;
public class GridPointDeleteAfterHandlerImpl implements IGridPointDeleteAfterHandler { public class GridPointDeleteAfterHandlerImpl implements IGridPointDeleteAfterHandler {
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(List<String> gridIds) throws SystemException { public void handle(List<String> gridIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (gridIds == null || gridIds.isEmpty()) { if (gridIds == null || gridIds.isEmpty()) {
return; return;
} }

View File

@ -7,6 +7,7 @@ import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridPointSaveAfterHandler; import ink.wgink.interfaces.map.IGridPointSaveAfterHandler;
import ink.wgink.module.map.pojo.dtos.grid.GridPointDTO; import ink.wgink.module.map.pojo.dtos.grid.GridPointDTO;
import ink.wgink.module.map.service.grid.IGridPointService; import ink.wgink.module.map.service.grid.IGridPointService;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.UUIDUtil; import ink.wgink.util.UUIDUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -31,9 +32,14 @@ public class GridPointSaveAfterHandlerImpl implements IGridPointSaveAfterHandler
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired @Autowired
private IGridPointService gridPointService; private IGridPointService gridPointService;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String gridId) throws SystemException { public void handle(String gridId) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(gridId)) { if (StringUtils.isBlank(gridId)) {
return; return;
} }

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridRelationDeleteAfterHandler; import ink.wgink.interfaces.map.IGridRelationDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -26,9 +27,14 @@ public class GridRelationDeleteAfterHandlerImpl implements IGridRelationDeleteAf
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(List<String> relationIds) throws SystemException { public void handle(List<String> relationIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (relationIds.isEmpty()) { if (relationIds.isEmpty()) {
return; return;
} }

View File

@ -8,6 +8,7 @@ import ink.wgink.interfaces.map.IGridRelationSaveAfterHandler;
import ink.wgink.module.map.pojo.dtos.grid.GridDTO; import ink.wgink.module.map.pojo.dtos.grid.GridDTO;
import ink.wgink.module.map.service.grid.IGridService; import ink.wgink.module.map.service.grid.IGridService;
import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.service.user.service.IUserService; import ink.wgink.service.user.service.IUserService;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,9 +36,14 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH
private IUserService userService; private IUserService userService;
@Autowired @Autowired
private IGridService gridService; private IGridService gridService;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(List<String> relationIds) throws SystemException { public void handle(List<String> relationIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (relationIds.isEmpty()) { if (relationIds.isEmpty()) {
return; return;
} }
@ -53,6 +59,9 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH
@Override @Override
public void handle(UserDTO userDTO) throws SystemException { public void handle(UserDTO userDTO) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
List<GridDTO> gridDTOs = gridService.listByRelationId(userDTO.getUserId()); List<GridDTO> gridDTOs = gridService.listByRelationId(userDTO.getUserId());
if (gridDTOs.isEmpty()) { if (gridDTOs.isEmpty()) {
return; return;

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridSaveAfterHandler; import ink.wgink.interfaces.map.IGridSaveAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -25,9 +26,14 @@ public class GridSaveAfterHandlerImpl implements IGridSaveAfterHandler {
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String gridId, String gridCode, String gridName, String fillColor, String areaCode, String areaName) throws SystemException { public void handle(String gridId, String gridCode, String gridName, String fillColor, String areaCode, String areaName) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(gridId)) { if (StringUtils.isBlank(gridId)) {
return; return;
} }

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridUpdateAfterHandler; import ink.wgink.interfaces.map.IGridUpdateAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -28,9 +29,14 @@ public class GridUpdateAfterHandlerImpl implements IGridUpdateAfterHandler {
@Autowired @Autowired
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String gridId, String gridName, String fillColor) throws SystemException { public void handle(String gridId, String gridName, String fillColor) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(gridId)) { if (StringUtils.isBlank(gridId)) {
return; return;
} }

View File

@ -6,6 +6,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.role.IRoleUserDeleteAfterHandler; import ink.wgink.interfaces.role.IRoleUserDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil; import ink.wgink.util.string.WStringUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,9 +30,14 @@ public class RoleUserDeleteAfterHandlerImpl implements IRoleUserDeleteAfterHandl
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired @Autowired
private ParamsConfigProperties paramsConfigProperties; private ParamsConfigProperties paramsConfigProperties;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String roleId, List<String> userIds) throws SystemException { public void handle(String roleId, List<String> userIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(roleId)) { if (StringUtils.isBlank(roleId)) {
return; return;
} }

View File

@ -8,6 +8,7 @@ import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler; import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.service.role.service.IRoleUserService; import ink.wgink.service.role.service.IRoleUserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -36,9 +37,14 @@ public class RoleUserSaveAfterHandlerImpl implements IRoleUserSaveAfterHandler {
private IUserExpandService userExpandService; private IUserExpandService userExpandService;
@Autowired @Autowired
private ParamsConfigProperties paramsConfigProperties; private ParamsConfigProperties paramsConfigProperties;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String roleId, List<String> userIds) throws SystemException { public void handle(String roleId, List<String> userIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(roleId)) { if (StringUtils.isBlank(roleId)) {
return; return;
} }

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException; import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.user.IUserUpdateAfterHandler; import ink.wgink.interfaces.user.IUserUpdateAfterHandler;
import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.service.user.service.IUserService; import ink.wgink.service.user.service.IUserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,9 +30,14 @@ public class UserUpdateAfterHandlerImpl implements IUserUpdateAfterHandler {
private KafkaTemplate kafkaTemplate; private KafkaTemplate kafkaTemplate;
@Autowired @Autowired
private IUserService userService; private IUserService userService;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override @Override
public void handle(String userId) throws SystemException { public void handle(String userId) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (StringUtils.isBlank(userId)) { if (StringUtils.isBlank(userId)) {
return; return;
} }

View File

@ -68,6 +68,7 @@ spring:
max-idle: 8 max-idle: 8
min-idle: 0 min-idle: 0
kafka: kafka:
active: false
bootstrap-servers: 192.168.0.103:9092 bootstrap-servers: 192.168.0.103:9092
producer: producer:
# 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败 # 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败

View File

@ -115,6 +115,13 @@ file:
access-key: smartcity access-key: smartcity
secret-key: smartcity secret-key: smartcity
# appToken
app-token:
has-department: false
has-role: true
has-position: false
has-group: false
# 即时通讯 # 即时通讯
websocket: websocket:
url: ${server.ip} url: ${server.ip}