|
|
@@ -17,10 +17,12 @@ import com.usoftchina.bi.server.model.po.DataConnectorList;
|
|
|
import com.usoftchina.bi.core.base.RepCode;
|
|
|
import com.usoftchina.bi.core.base.RepEntity;
|
|
|
import com.usoftchina.bi.core.base.TestPage;
|
|
|
+import com.usoftchina.bi.server.model.po.MessageLog;
|
|
|
import com.usoftchina.bi.server.model.vo.configVo.*;
|
|
|
import com.usoftchina.bi.server.model.vo.dataVo.ColumnValuesInfo;
|
|
|
import com.usoftchina.bi.server.model.vo.dataVo.DataSourceCopyInfo;
|
|
|
import com.usoftchina.bi.server.service.chart.GetChartsDataUtilService;
|
|
|
+import com.usoftchina.bi.server.service.common.MessageLogService;
|
|
|
import com.usoftchina.bi.server.service.strategy.StrategysService;
|
|
|
import com.usoftchina.bi.server.service.chart.ChartsUtilService;
|
|
|
import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
|
|
|
@@ -34,6 +36,7 @@ import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
@@ -61,6 +64,8 @@ public class DataConnectorService {
|
|
|
GetChartsDataUtilService getChartsDataUtilService;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
+ @Autowired
|
|
|
+ private MessageLogService messageLogService;
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DataConnectorService.class);
|
|
|
|
|
|
@@ -214,22 +219,38 @@ public class DataConnectorService {
|
|
|
/*
|
|
|
更新数据源分组
|
|
|
*/
|
|
|
- public RepEntity updateConfigGroup(GroupUpdateId groupUpdateId) {
|
|
|
+ public RepEntity updateConfigGroup(String token, GroupUpdateId groupUpdateId) {
|
|
|
+ Map<String, String> resMap = GetTokenDataUtil.getTokenData(token);
|
|
|
+ String username = resMap.get("name");
|
|
|
int id = groupUpdateId.getId();
|
|
|
int groupId = groupUpdateId.getGroupId();
|
|
|
+ GroupInfo groupInfo = dataConnectorMapper.getConnectorGroupById(groupId);
|
|
|
+ String groupName = null;
|
|
|
+ if (!ObjectUtils.isEmpty(groupInfo)) {
|
|
|
+ groupName = groupInfo.getGroupName();
|
|
|
+ }
|
|
|
dataConnectorMapper.updateConfigGroup(id, groupId);
|
|
|
+ String dataName = dataConnectorMapper.getOneData(id).getDataName();
|
|
|
+ // 记录LOG
|
|
|
+ MessageLog messageLog = new MessageLog(username, "更新数据源分组为( "+ groupName + ")", "更新成功", null, "数据源", dataName);
|
|
|
+ messageLogService.customizeLog(messageLog);
|
|
|
return new RepEntity(RepCode.success);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
删除数据源
|
|
|
*/
|
|
|
- public RepEntity delDataConnector(Long id) {
|
|
|
+ public RepEntity delDataConnector(String token, Long id) {
|
|
|
+ Map<String, String> resMap = GetTokenDataUtil.getTokenData(token);
|
|
|
+ String username = resMap.get("name");
|
|
|
+ String dataName = dataConnectorMapper.getOneData(id.intValue()).getDataName();
|
|
|
int count = dataConnectorMapper.countChartsById(id);
|
|
|
if (count > 0) {
|
|
|
throw new MyException(RepCode.CHARTS_USED_DATACONNECTOR);
|
|
|
}
|
|
|
dataConnectorMapper.deleteData(id);
|
|
|
+ // 记录LOG
|
|
|
+ messageLogService.delete("数据源", dataName, username, null);
|
|
|
return new RepEntity(RepCode.success);
|
|
|
}
|
|
|
|
|
|
@@ -280,7 +301,6 @@ public class DataConnectorService {
|
|
|
/*
|
|
|
更新数据源分组
|
|
|
*/
|
|
|
- @CacheEvict(value = "singleDataConnector", key = "#body.id")
|
|
|
public RepEntity updataDataConnectorGroup(GroupInfo groupInfo) {
|
|
|
dataConnectorMapper.updataConnectorGroup(groupInfo);
|
|
|
return new RepEntity(RepCode.success);
|
|
|
@@ -289,7 +309,6 @@ public class DataConnectorService {
|
|
|
/*
|
|
|
批量更新数据源分组
|
|
|
*/
|
|
|
- @CacheEvict(value = "singleDataConnector")
|
|
|
public RepEntity updataConnectorGroups(List<GroupInfo> groupInfoList) {
|
|
|
Iterator isList = groupInfoList.iterator();
|
|
|
GroupInfo groupInfo = new GroupInfo();
|
|
|
@@ -304,7 +323,6 @@ public class DataConnectorService {
|
|
|
/*
|
|
|
删除数据源分组
|
|
|
*/
|
|
|
- @CacheEvict(value = "singleDataConnector")
|
|
|
public RepEntity delDataConnectorGroup(Long id) {
|
|
|
List<String> groupName = dataConnectorMapper.getFatherId(id.intValue());
|
|
|
if (groupName.size() != 0) {
|