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

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

parent 0456929a
......@@ -119,4 +119,12 @@ public interface AgentApplicationInfoService {
* @param agentId Agent应用id
*/
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
}
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;
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.data_analyze.constants.DataAnalyzeTimeDimensionEnum;
import cn.com.poc.data_analyze.constants.DataAnalyzeTimeRangeEnum;
......@@ -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.BizDataAnalyzePointRecordService;
import cn.com.poc.expose.aggregate.AgentDataAnalyzeService;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
......@@ -270,5 +273,4 @@ public class AgentDataAnalyzeServiceImpl implements AgentDataAnalyzeService {
countEntity.setChannelDataCount(channelDataCountList);
result.add(countEntity);
}
}
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.expose.aggregate.AgentDataAnalyzeService;
import cn.com.poc.expose.dto.agent_data_analyze.*;
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 javax.annotation.Resource;
......@@ -20,8 +24,12 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Resource
private AgentDataAnalyzeService agentDataAnalyzeService;
@Resource
private AgentApplicationInfoService agentApplicationInfoService;
@Override
public List<AgentDataAnalyzeGeneralDto> getGeneralUsageData(String agentId, List<String> channel) {
checkPermission(agentId);
List<AgentDataAnalyzeGeneralDto> result = new ArrayList<>();
List<AgentDataAnalyzeGeneralEntity> generalUsageDataEntity = agentDataAnalyzeService.getGeneralUsageData(agentId, channel);
for (AgentDataAnalyzeGeneralEntity entity : generalUsageDataEntity) {
......@@ -36,6 +44,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override
public List<ChannelUsersCountDto> getChannelUsersCount(String agentId, List<String> channel) {
checkPermission(agentId);
List<ChannelUsersCountDto> result = new ArrayList<>();
List<ChannelUsersCountEntity> channelUsersCountEntities = agentDataAnalyzeService.getChannelUserCount(agentId, channel);
for (ChannelUsersCountEntity entity : channelUsersCountEntities) {
......@@ -49,6 +58,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override
public List<ChannelUsageCountDto> getSendMessageCount(String agentId, List<String> channel) {
checkPermission(agentId);
List<ChannelUsageCountDto> result = new ArrayList<>();
List<ChannelUsageCountEntity> sendMessageCountEntities = agentDataAnalyzeService.getSendMessageCount(agentId, channel);
for (ChannelUsageCountEntity entity : sendMessageCountEntities) {
......@@ -62,6 +72,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override
public List<ChannelPointCountDto> getPointUsageCount(String agentId, List<String> channel) {
checkPermission(agentId);
List<ChannelPointCountDto> result = new ArrayList<>();
List<ChannelPointCountEntity> pointCountEntities = agentDataAnalyzeService.getPointUsageCount(agentId, channel);
for (ChannelPointCountEntity pointCountEntity : pointCountEntities) {
......@@ -75,6 +86,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
@Override
public List<AgentDataAnalyzeTrendDto> getAgentDataTrend(GetAgentDataTrendRequestDto dto) {
checkPermission(dto.getAgentId());
List<AgentDataAnalyzeTrendDto> result = new ArrayList<>();
List<AgentDataAnalyzeTrendEntity> agentDataAnalyzeTrendEntities = agentDataAnalyzeService.getAgentDataTrend(dto.getAgentId(), dto.getChannel(), dto.getTimeRange());
for (AgentDataAnalyzeTrendEntity entity : agentDataAnalyzeTrendEntities) {
......@@ -87,4 +99,15 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
}
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");
}
}
}
......@@ -78,4 +78,5 @@ arg.cannot.null=Arg can not be null
nickName.max.len=Overnickname
remark.max.len=Remark content too long
file.content.empty=The file content cannot be empty
payment.package.configuration.not.exist=The equity packet configuration does not exist
\ No newline at end of file
payment.package.configuration.not.exist=The equity packet configuration does not exist
no.permission=No permission
\ No newline at end of file
......@@ -78,4 +78,5 @@ arg.cannot.null=\u8BF7\u6C42\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A
nickName.max.len=\u6635\u79F0\u8FC7\u957F
remark.max.len=\u5185\u5BB9\u8FC7\u957F
file.content.empty=\u6587\u6863\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A
payment.package.configuration.not.exist=\u6743\u76CA\u5305\u914D\u7F6E\u4E0D\u5B58\u5728
\ No newline at end of file
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
......@@ -78,4 +78,5 @@ arg.cannot.null=\u8ACB\u6C42\u53C3\u6578\u4E0D\u80FD\u7232\u7A7A
nickName.max.len=\u6635\u7A31\u904E\u9577
remark.max.len=\u5185\u5BB9\u904E\u9577
file.content.empty=\u6587\u4EF6\u5185\u5BB9\u4E0D\u80FD\u7232\u7A7A
payment.package.configuration.not.exist=\u6B0A\u76CA\u5305\u914D\u7F6E\u4E0D\u5B58\u5728
\ No newline at end of file
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