github.com/weplanx/server@v0.2.6-0.20240318110640-f7e75155779a/api/tencent/controller.go (about) 1 package tencent 2 3 import ( 4 "context" 5 "github.com/cloudwego/hertz/pkg/app" 6 ) 7 8 type Controller struct { 9 TencentX *Service 10 } 11 12 func (x *Controller) CosPresigned(_ context.Context, c *app.RequestContext) { 13 r, err := x.TencentX.CosPresigned() 14 if err != nil { 15 c.Error(err) 16 return 17 } 18 19 c.JSON(200, r) 20 } 21 22 type CosImageInfoDto struct { 23 Url string `query:"url" vd:"required"` 24 } 25 26 func (x *Controller) CosImageInfo(ctx context.Context, c *app.RequestContext) { 27 var dto CosImageInfoDto 28 if err := c.BindAndValidate(&dto); err != nil { 29 c.Error(err) 30 return 31 } 32 33 r, err := x.TencentX.CosImageInfo(ctx, dto.Url) 34 if err != nil { 35 c.Error(err) 36 return 37 } 38 39 c.JSON(200, r) 40 }