56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package handler
|
|
|
|
import (
|
|
"git.hpds.cc/Component/logging"
|
|
"github.com/gin-gonic/gin"
|
|
"hpds_annotation/config"
|
|
"hpds_annotation/internal/proto"
|
|
"hpds_annotation/internal/service"
|
|
e "hpds_annotation/pkg/err"
|
|
)
|
|
|
|
type HandlerService struct {
|
|
AppConfig *config.WebConfig
|
|
Logger *logging.Logger
|
|
}
|
|
|
|
func NewHandlerService(cfg *config.WebConfig, logger *logging.Logger) *HandlerService {
|
|
return &HandlerService{
|
|
AppConfig: cfg,
|
|
Logger: logger,
|
|
}
|
|
}
|
|
|
|
func (s HandlerService) GetList(c *gin.Context) (data interface{}, err error) {
|
|
repo := service.NewEdgeService(s.Logger)
|
|
var req proto.ListRequest
|
|
err = c.ShouldBindJSON(&req)
|
|
if err != nil {
|
|
return nil, e.NewValidErr(err)
|
|
}
|
|
data, err = repo.GetList(c, req)
|
|
return
|
|
}
|
|
|
|
func (s HandlerService) GetInfo(c *gin.Context) (data interface{}, err error) {
|
|
repo := service.NewEdgeService(s.Logger)
|
|
var req proto.ListRequest
|
|
err = c.ShouldBindJSON(&req)
|
|
if err != nil {
|
|
return nil, e.NewValidErr(err)
|
|
}
|
|
data, err = repo.GetInfo(c, req)
|
|
return
|
|
}
|
|
|
|
func (s HandlerService) LabelSubmit(c *gin.Context) (data interface{}, err error) {
|
|
repo := service.NewEdgeService(s.Logger)
|
|
var req proto.LabelRequest
|
|
err = c.ShouldBindJSON(&req)
|
|
if err != nil {
|
|
return nil, e.NewValidErr(err)
|
|
}
|
|
data, err = repo.LabelSubmit(c, req)
|
|
return
|
|
}
|