2024-05-17 18:27:26 +08:00
|
|
|
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
2021-05-03 11:32:43 +08:00
|
|
|
|
|
|
|
|
package services
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2024-07-27 14:15:25 +08:00
|
|
|
|
2021-05-03 11:32:43 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// LatestItemService 最近使用的条目服务
|
|
|
|
|
type LatestItemService struct {
|
|
|
|
|
BaseService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IncreaseLatestItem 记录最近使用的条目
|
|
|
|
|
func (this *LatestItemService) IncreaseLatestItem(ctx context.Context, req *pb.IncreaseLatestItemRequest) (*pb.RPCSuccess, error) {
|
2022-07-22 14:35:17 +08:00
|
|
|
_, err := this.ValidateAdmin(ctx)
|
2021-05-03 11:32:43 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
var tx = this.NullTx()
|
|
|
|
|
err = models.SharedLatestItemDAO.IncreaseItemCount(tx, req.ItemType, req.ItemId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return this.Success()
|
|
|
|
|
}
|