通知媒介增加任务队列查看功能

This commit is contained in:
GoEdgeLab
2021-08-24 14:22:44 +08:00
parent 55fe8f5707
commit 17b9eee78d
23 changed files with 489 additions and 165 deletions

View File

@@ -4,14 +4,15 @@ import (
"context"
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
// 消息接收人服务
// MessageRecipientService 消息接收人服务
type MessageRecipientService struct {
BaseService
}
// 创建接收人
// CreateMessageRecipient 创建接收人
func (this *MessageRecipientService) CreateMessageRecipient(ctx context.Context, req *pb.CreateMessageRecipientRequest) (*pb.CreateMessageRecipientResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -27,7 +28,7 @@ func (this *MessageRecipientService) CreateMessageRecipient(ctx context.Context,
return &pb.CreateMessageRecipientResponse{MessageRecipientId: recipientId}, nil
}
// 修改接收人
// UpdateMessageRecipient 修改接收人
func (this *MessageRecipientService) UpdateMessageRecipient(ctx context.Context, req *pb.UpdateMessageRecipientRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -43,7 +44,7 @@ func (this *MessageRecipientService) UpdateMessageRecipient(ctx context.Context,
return this.Success()
}
// 删除接收人
// DeleteMessageRecipient 删除接收人
func (this *MessageRecipientService) DeleteMessageRecipient(ctx context.Context, req *pb.DeleteMessageRecipientRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -58,7 +59,7 @@ func (this *MessageRecipientService) DeleteMessageRecipient(ctx context.Context,
return this.Success()
}
// 计算接收人数量
// CountAllEnabledMessageRecipients 计算接收人数量
func (this *MessageRecipientService) CountAllEnabledMessageRecipients(ctx context.Context, req *pb.CountAllEnabledMessageRecipientsRequest) (*pb.RPCCountResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -74,7 +75,7 @@ func (this *MessageRecipientService) CountAllEnabledMessageRecipients(ctx contex
return this.SuccessCount(count)
}
// 列出单页接收人
// ListEnabledMessageRecipients 列出单页接收人
func (this *MessageRecipientService) ListEnabledMessageRecipients(ctx context.Context, req *pb.ListEnabledMessageRecipientsRequest) (*pb.ListEnabledMessageRecipientsResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -82,6 +83,7 @@ func (this *MessageRecipientService) ListEnabledMessageRecipients(ctx context.Co
}
var tx = this.NullTx()
var cacheMap = maps.Map{}
recipients, err := models.SharedMessageRecipientDAO.ListAllEnabledRecipients(tx, req.AdminId, req.MessageRecipientGroupId, req.MediaType, req.Keyword, req.Offset, req.Size)
if err != nil {
return nil, err
@@ -104,7 +106,7 @@ func (this *MessageRecipientService) ListEnabledMessageRecipients(ctx context.Co
}
// 媒介实例
instance, err := models.SharedMessageMediaInstanceDAO.FindEnabledMessageMediaInstance(tx, int64(recipient.InstanceId))
instance, err := models.SharedMessageMediaInstanceDAO.FindEnabledMessageMediaInstance(tx, int64(recipient.InstanceId), cacheMap)
if err != nil {
return nil, err
}
@@ -151,7 +153,7 @@ func (this *MessageRecipientService) ListEnabledMessageRecipients(ctx context.Co
return &pb.ListEnabledMessageRecipientsResponse{MessageRecipients: pbRecipients}, nil
}
// 查找单个接收人信息
// FindEnabledMessageRecipient 查找单个接收人信息
func (this *MessageRecipientService) FindEnabledMessageRecipient(ctx context.Context, req *pb.FindEnabledMessageRecipientRequest) (*pb.FindEnabledMessageRecipientResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -159,7 +161,8 @@ func (this *MessageRecipientService) FindEnabledMessageRecipient(ctx context.Con
}
var tx = this.NullTx()
recipient, err := models.SharedMessageRecipientDAO.FindEnabledMessageRecipient(tx, req.MessageRecipientId)
var cacheMap = maps.Map{}
recipient, err := models.SharedMessageRecipientDAO.FindEnabledMessageRecipient(tx, req.MessageRecipientId, cacheMap)
if err != nil {
return nil, err
}
@@ -183,7 +186,7 @@ func (this *MessageRecipientService) FindEnabledMessageRecipient(ctx context.Con
}
// 媒介实例
instance, err := models.SharedMessageMediaInstanceDAO.FindEnabledMessageMediaInstance(tx, int64(recipient.InstanceId))
instance, err := models.SharedMessageMediaInstanceDAO.FindEnabledMessageMediaInstance(tx, int64(recipient.InstanceId), cacheMap)
if err != nil {
return nil, err
}