50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
|
package mongo
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"finclip-app-manager/domain/entity"
|
||
|
"finclip-app-manager/domain/repository"
|
||
|
mgo "gitlab.finogeeks.club/finclip-backend-v2/finclip-mgo"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
var _ repository.IRedDotRepo = new(RedDotByMongoRepo)
|
||
|
|
||
|
type RedDotByMongoRepo struct {
|
||
|
}
|
||
|
|
||
|
type RedDotReadRecordMongo struct {
|
||
|
Type string `json:"type" bson:"type"` //红点类型
|
||
|
TraceId string `json:"traceId" bson:"trace_id"` //红点唯一标识
|
||
|
AccountId string `json:"accountId" bson:"account_id"` //已经阅读的账户Id
|
||
|
CreateTime int64 `json:"createTime" bson:"create_time""` //创建时间
|
||
|
UpdateTime int64 `json:"updateTime" bson:"update_time"` //更新时间
|
||
|
}
|
||
|
|
||
|
func (r RedDotByMongoRepo) ReadTrialQr(ctx context.Context, readDotType string, id string, userId string) error {
|
||
|
info := entity.RedDotReadRecord{
|
||
|
Type: readDotType,
|
||
|
TraceId: id,
|
||
|
AccountId: userId,
|
||
|
CreateTime: time.Now().UnixNano() / 1e6,
|
||
|
}
|
||
|
return redDotTable.Insert(ctx, convertRedDotReadRecordToRedDotReadRecordMongo(&info))
|
||
|
}
|
||
|
|
||
|
func (r RedDotByMongoRepo) NotFound(err error) bool {
|
||
|
return err == mgo.ErrNotFound
|
||
|
}
|
||
|
|
||
|
func convertRedDotReadRecordToRedDotReadRecordMongo(redDotReadRecord *entity.RedDotReadRecord) RedDotReadRecordMongo {
|
||
|
result := RedDotReadRecordMongo{}
|
||
|
|
||
|
result.Type = redDotReadRecord.Type
|
||
|
result.TraceId = redDotReadRecord.TraceId
|
||
|
result.AccountId = redDotReadRecord.AccountId
|
||
|
result.CreateTime = redDotReadRecord.CreateTime
|
||
|
result.UpdateTime = redDotReadRecord.UpdateTime
|
||
|
|
||
|
return result
|
||
|
}
|
||
|
|