添加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 ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.department.IDepartmentDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
@ -26,9 +27,14 @@ public class DepartmentDeleteAfterHandlerImpl implements IDepartmentDeleteAfterH
@Autowired
private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override
public void handle(List<String> departmentIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (departmentIds == null || departmentIds.isEmpty()) {
return;
}

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.department.IDepartmentSaveAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
@ -25,9 +26,14 @@ public class DepartmentSaveAfterHandlerImpl implements IDepartmentSaveAfterHandl
@Autowired
private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override
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)) {
return;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridRelationDeleteAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
@ -26,9 +27,14 @@ public class GridRelationDeleteAfterHandlerImpl implements IGridRelationDeleteAf
@Autowired
private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override
public void handle(List<String> relationIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (relationIds.isEmpty()) {
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.service.grid.IGridService;
import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import ink.wgink.service.user.service.IUserService;
import ink.wgink.util.string.WStringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,9 +36,14 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH
private IUserService userService;
@Autowired
private IGridService gridService;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override
public void handle(List<String> relationIds) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
if (relationIds.isEmpty()) {
return;
}
@ -53,6 +59,9 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH
@Override
public void handle(UserDTO userDTO) throws SystemException {
if (!kafkaCustomProperties.getActive()) {
return;
}
List<GridDTO> gridDTOs = gridService.listByRelationId(userDTO.getUserId());
if (gridDTOs.isEmpty()) {
return;

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.exceptions.base.SystemException;
import ink.wgink.interfaces.map.IGridSaveAfterHandler;
import ink.wgink.properties.kafka.KafkaCustomProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
@ -25,9 +26,14 @@ public class GridSaveAfterHandlerImpl implements IGridSaveAfterHandler {
@Autowired
private KafkaTemplate kafkaTemplate;
@Autowired
private KafkaCustomProperties kafkaCustomProperties;
@Override
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)) {
return;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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