Commit 1c3fd664 authored by alex yao's avatar alex yao

feat:Agent應用數據看板權限限制

parent 0456929a
...@@ -119,4 +119,12 @@ public interface AgentApplicationInfoService { ...@@ -119,4 +119,12 @@ public interface AgentApplicationInfoService {
* @param agentId Agent应用id * @param agentId Agent应用id
*/ */
void collectOrCancelAgentInPerson(String agentId) throws Exception; void collectOrCancelAgentInPerson(String agentId) throws Exception;
/**
* 判断用户是否拥有该应用权限
*
* @param agentId 应用id
* @param memberId 用户id
*/
boolean hasPublishAgentPermission(String agentId, Long memberId);
} }
...@@ -484,6 +484,14 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -484,6 +484,14 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
} }
public boolean hasPublishAgentPermission(String agentId, Long memberId) {
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.getByAgentId(agentId);
if (publishEntity != null && publishEntity.getMemberId().equals(memberId.intValue())) {
return true;
}
return false;
}
/** /**
* 构建应用信息提示词 * 构建应用信息提示词
* *
......
package cn.com.poc.expose.aggregate.impl; package cn.com.poc.expose.aggregate.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.DateUtils; import cn.com.poc.common.utils.DateUtils;
import cn.com.poc.data_analyze.constants.DataAnalyzeTimeDimensionEnum; import cn.com.poc.data_analyze.constants.DataAnalyzeTimeDimensionEnum;
import cn.com.poc.data_analyze.constants.DataAnalyzeTimeRangeEnum; import cn.com.poc.data_analyze.constants.DataAnalyzeTimeRangeEnum;
...@@ -12,6 +14,7 @@ import cn.com.poc.data_analyze.query.*; ...@@ -12,6 +14,7 @@ import cn.com.poc.data_analyze.query.*;
import cn.com.poc.data_analyze.service.BizDataAnalyzeDialogueRecordService; import cn.com.poc.data_analyze.service.BizDataAnalyzeDialogueRecordService;
import cn.com.poc.data_analyze.service.BizDataAnalyzePointRecordService; import cn.com.poc.data_analyze.service.BizDataAnalyzePointRecordService;
import cn.com.poc.expose.aggregate.AgentDataAnalyzeService; import cn.com.poc.expose.aggregate.AgentDataAnalyzeService;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -270,5 +273,4 @@ public class AgentDataAnalyzeServiceImpl implements AgentDataAnalyzeService { ...@@ -270,5 +273,4 @@ public class AgentDataAnalyzeServiceImpl implements AgentDataAnalyzeService {
countEntity.setChannelDataCount(channelDataCountList); countEntity.setChannelDataCount(channelDataCountList);
result.add(countEntity); result.add(countEntity);
} }
} }
package cn.com.poc.expose.rest.impl; package cn.com.poc.expose.rest.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.data_analyze.entity.*; import cn.com.poc.data_analyze.entity.*;
import cn.com.poc.expose.aggregate.AgentDataAnalyzeService; import cn.com.poc.expose.aggregate.AgentDataAnalyzeService;
import cn.com.poc.expose.dto.agent_data_analyze.*; import cn.com.poc.expose.dto.agent_data_analyze.*;
import cn.com.poc.expose.rest.AgentDataAnalyzeRest; import cn.com.poc.expose.rest.AgentDataAnalyzeRest;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -20,8 +24,12 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest { ...@@ -20,8 +24,12 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Resource @Resource
private AgentDataAnalyzeService agentDataAnalyzeService; private AgentDataAnalyzeService agentDataAnalyzeService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
@Override @Override
public List<AgentDataAnalyzeGeneralDto> getGeneralUsageData(String agentId, List<String> channel) { public List<AgentDataAnalyzeGeneralDto> getGeneralUsageData(String agentId, List<String> channel) {
checkPermission(agentId);
List<AgentDataAnalyzeGeneralDto> result = new ArrayList<>(); List<AgentDataAnalyzeGeneralDto> result = new ArrayList<>();
List<AgentDataAnalyzeGeneralEntity> generalUsageDataEntity = agentDataAnalyzeService.getGeneralUsageData(agentId, channel); List<AgentDataAnalyzeGeneralEntity> generalUsageDataEntity = agentDataAnalyzeService.getGeneralUsageData(agentId, channel);
for (AgentDataAnalyzeGeneralEntity entity : generalUsageDataEntity) { for (AgentDataAnalyzeGeneralEntity entity : generalUsageDataEntity) {
...@@ -36,6 +44,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest { ...@@ -36,6 +44,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override @Override
public List<ChannelUsersCountDto> getChannelUsersCount(String agentId, List<String> channel) { public List<ChannelUsersCountDto> getChannelUsersCount(String agentId, List<String> channel) {
checkPermission(agentId);
List<ChannelUsersCountDto> result = new ArrayList<>(); List<ChannelUsersCountDto> result = new ArrayList<>();
List<ChannelUsersCountEntity> channelUsersCountEntities = agentDataAnalyzeService.getChannelUserCount(agentId, channel); List<ChannelUsersCountEntity> channelUsersCountEntities = agentDataAnalyzeService.getChannelUserCount(agentId, channel);
for (ChannelUsersCountEntity entity : channelUsersCountEntities) { for (ChannelUsersCountEntity entity : channelUsersCountEntities) {
...@@ -49,6 +58,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest { ...@@ -49,6 +58,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override @Override
public List<ChannelUsageCountDto> getSendMessageCount(String agentId, List<String> channel) { public List<ChannelUsageCountDto> getSendMessageCount(String agentId, List<String> channel) {
checkPermission(agentId);
List<ChannelUsageCountDto> result = new ArrayList<>(); List<ChannelUsageCountDto> result = new ArrayList<>();
List<ChannelUsageCountEntity> sendMessageCountEntities = agentDataAnalyzeService.getSendMessageCount(agentId, channel); List<ChannelUsageCountEntity> sendMessageCountEntities = agentDataAnalyzeService.getSendMessageCount(agentId, channel);
for (ChannelUsageCountEntity entity : sendMessageCountEntities) { for (ChannelUsageCountEntity entity : sendMessageCountEntities) {
...@@ -62,6 +72,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest { ...@@ -62,6 +72,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override @Override
public List<ChannelPointCountDto> getPointUsageCount(String agentId, List<String> channel) { public List<ChannelPointCountDto> getPointUsageCount(String agentId, List<String> channel) {
checkPermission(agentId);
List<ChannelPointCountDto> result = new ArrayList<>(); List<ChannelPointCountDto> result = new ArrayList<>();
List<ChannelPointCountEntity> pointCountEntities = agentDataAnalyzeService.getPointUsageCount(agentId, channel); List<ChannelPointCountEntity> pointCountEntities = agentDataAnalyzeService.getPointUsageCount(agentId, channel);
for (ChannelPointCountEntity pointCountEntity : pointCountEntities) { for (ChannelPointCountEntity pointCountEntity : pointCountEntities) {
...@@ -75,6 +86,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest { ...@@ -75,6 +86,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override @Override
public List<AgentDataAnalyzeTrendDto> getAgentDataTrend(GetAgentDataTrendRequestDto dto) { public List<AgentDataAnalyzeTrendDto> getAgentDataTrend(GetAgentDataTrendRequestDto dto) {
checkPermission(dto.getAgentId());
List<AgentDataAnalyzeTrendDto> result = new ArrayList<>(); List<AgentDataAnalyzeTrendDto> result = new ArrayList<>();
List<AgentDataAnalyzeTrendEntity> agentDataAnalyzeTrendEntities = agentDataAnalyzeService.getAgentDataTrend(dto.getAgentId(), dto.getChannel(), dto.getTimeRange()); List<AgentDataAnalyzeTrendEntity> agentDataAnalyzeTrendEntities = agentDataAnalyzeService.getAgentDataTrend(dto.getAgentId(), dto.getChannel(), dto.getTimeRange());
for (AgentDataAnalyzeTrendEntity entity : agentDataAnalyzeTrendEntities) { for (AgentDataAnalyzeTrendEntity entity : agentDataAnalyzeTrendEntities) {
...@@ -87,4 +99,15 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest { ...@@ -87,4 +99,15 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
} }
return result; return result;
} }
private void checkPermission(String agentId) {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new I18nMessageException("exception/user.does.not.exist");
}
if (!agentApplicationInfoService.hasPublishAgentPermission(agentId, userBaseEntity.getUserId())) {
throw new I18nMessageException("exception/no.permission");
}
}
} }
...@@ -79,3 +79,4 @@ nickName.max.len=Overnickname ...@@ -79,3 +79,4 @@ nickName.max.len=Overnickname
remark.max.len=Remark content too long remark.max.len=Remark content too long
file.content.empty=The file content cannot be empty file.content.empty=The file content cannot be empty
payment.package.configuration.not.exist=The equity packet configuration does not exist payment.package.configuration.not.exist=The equity packet configuration does not exist
no.permission=No permission
\ No newline at end of file
...@@ -79,3 +79,4 @@ nickName.max.len=\u6635\u79F0\u8FC7\u957F ...@@ -79,3 +79,4 @@ nickName.max.len=\u6635\u79F0\u8FC7\u957F
remark.max.len=\u5185\u5BB9\u8FC7\u957F remark.max.len=\u5185\u5BB9\u8FC7\u957F
file.content.empty=\u6587\u6863\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A file.content.empty=\u6587\u6863\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A
payment.package.configuration.not.exist=\u6743\u76CA\u5305\u914D\u7F6E\u4E0D\u5B58\u5728 payment.package.configuration.not.exist=\u6743\u76CA\u5305\u914D\u7F6E\u4E0D\u5B58\u5728
no.permission=\u6682\u65E0\u6743\u9650
\ No newline at end of file
...@@ -79,3 +79,4 @@ nickName.max.len=\u6635\u7A31\u904E\u9577 ...@@ -79,3 +79,4 @@ nickName.max.len=\u6635\u7A31\u904E\u9577
remark.max.len=\u5185\u5BB9\u904E\u9577 remark.max.len=\u5185\u5BB9\u904E\u9577
file.content.empty=\u6587\u4EF6\u5185\u5BB9\u4E0D\u80FD\u7232\u7A7A file.content.empty=\u6587\u4EF6\u5185\u5BB9\u4E0D\u80FD\u7232\u7A7A
payment.package.configuration.not.exist=\u6B0A\u76CA\u5305\u914D\u7F6E\u4E0D\u5B58\u5728 payment.package.configuration.not.exist=\u6B0A\u76CA\u5305\u914D\u7F6E\u4E0D\u5B58\u5728
no.permission=\u66AB\u7121\u6B0A\u9650
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment