1
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
|
||||
"observer-server/biz/model/dto"
|
||||
"observer-server/biz/service"
|
||||
)
|
||||
|
||||
// cAnnotate 标注众包接口(登录态,手机号取自 token)
|
||||
type cAnnotate struct{}
|
||||
|
||||
var Annotate = &cAnnotate{}
|
||||
|
||||
// Tasks 可领任务列表 + 我的统计
|
||||
func (c *cAnnotate) Tasks(ctx context.Context, req *dto.AnnotateTaskListReq) (*dto.AnnotateTaskListRes, error) {
|
||||
return service.Annotate.AppTaskList(ctx, req)
|
||||
}
|
||||
|
||||
// Claim 领取标注图片
|
||||
func (c *cAnnotate) Claim(ctx context.Context, req *dto.AnnotateClaimReq) (*dto.AnnotateClaimRes, error) {
|
||||
return service.Annotate.AppClaim(ctx, req)
|
||||
}
|
||||
|
||||
// Submit 提交标注
|
||||
func (c *cAnnotate) Submit(ctx context.Context, req *dto.AnnotateSubmitReq) (*dto.AnnotateSubmitRes, error) {
|
||||
return service.Annotate.AppSubmit(ctx, req)
|
||||
}
|
||||
|
||||
// Me 我的标注统计
|
||||
func (c *cAnnotate) Me(ctx context.Context, req *dto.AnnotateMeReq) (*dto.AnnotateMeRes, error) {
|
||||
return service.Annotate.AppMe(ctx, req)
|
||||
}
|
||||
|
||||
// Image 标注图片访问(直写响应体:service 校验归属返回路径,controller 输出二进制;
|
||||
// 登录态鉴权,与管理端 image 端点隔离)
|
||||
func (c *cAnnotate) Image(ctx context.Context, req *dto.AnnotateImageReq) (*dto.AnnotateImageRes, error) {
|
||||
path, err := service.Dataset.ImageFile(ctx, req.DatasetId, req.Filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
r.Response.ServeFile(path)
|
||||
return &dto.AnnotateImageRes{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user