feat:合图新增debug模块

This commit is contained in:
momo 2023-10-18 11:48:32 +08:00
parent 6a982689ef
commit e14fd8b286
2 changed files with 27 additions and 10 deletions

View File

@ -136,6 +136,7 @@ type (
Metadata *string Metadata *string
DiffTimeLogoCombine int64 DiffTimeLogoCombine int64
DiffTimeUploadFile int64 DiffTimeUploadFile int64
DebugData *auth.DebugData `json:"debug_data"`
} }
) )
type TemplateTagColor struct { type TemplateTagColor struct {
@ -144,6 +145,7 @@ type TemplateTagColor struct {
} }
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
var resp = &LogoCombineRes{}
logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(in.LogoUrl) logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(in.LogoUrl)
if logoResourceId == "" { if logoResourceId == "" {
return nil, errors.New("invalid logo url") return nil, errors.New("invalid logo url")
@ -167,10 +169,12 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
if err == nil && resourceInfo.ResourceId != "" { if err == nil && resourceInfo.ResourceId != "" {
if in.Debug == nil || (in.Debug != nil && in.Debug.IsCache == 1) {
return &LogoCombineRes{ return &LogoCombineRes{
ResourceId: resourceId, ResourceId: resourceId,
ResourceUrl: resourceInfo.ResourceUrl, ResourceUrl: resourceInfo.ResourceUrl,
}, nil }, nil
}
} else { } else {
if err != nil { if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
@ -308,12 +312,19 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
return nil, err return nil, err
} }
return &LogoCombineRes{ resp.ResourceId = uploadRes.ResourceId
ResourceId: uploadRes.ResourceId, resp.ResourceUrl = &uploadRes.ResourceUrl
ResourceUrl: &uploadRes.ResourceUrl, resp.DiffTimeLogoCombine = diffTimeLogoCombine
resp.DiffTimeUploadFile = diffTimeUploadFile
if in.Debug != nil {
resp.DebugData = &auth.DebugData{
DiffTimeLogoCombine: diffTimeLogoCombine, DiffTimeLogoCombine: diffTimeLogoCombine,
DiffTimeUploadFile: diffTimeUploadFile, DiffTimeUploadFile: diffTimeUploadFile,
}, nil }
}
return resp, nil
} }
/* logo合图 */ /* logo合图 */

View File

@ -24,6 +24,12 @@ const (
IDTYPE_Guest IDTYPE = 2 IDTYPE_Guest IDTYPE = 2
) )
// DebugData
type DebugData struct {
DiffTimeLogoCombine int64 `json:"diff_time_logo_combine"` // 合图算法时间
DiffTimeUploadFile int64 `json:"diff_time_upload_file"` // 合图上传时间
}
// Debug 相关的结构 // Debug 相关的结构
type Debug struct { type Debug struct {
Exp *int64 `json:"exp"` Exp *int64 `json:"exp"`