package handler import ( "fmt" "github.com/gin-gonic/gin" "hpds-iot-web/internal/proto" "hpds-iot-web/internal/service" "hpds-iot-web/model" e "hpds-iot-web/pkg/err" ) func (s HandlerService) GetOwnerProjectList(c *gin.Context) (data interface{}, err error) { repo := service.NewDatasetService(s.AppConfig, s.Engine, s.Logger) us, _ := c.Get("operatorUser") userInfo := us.(*model.SystemUser) var req proto.OwnerProjectRequest err = c.ShouldBindJSON(&req) if err != nil { go s.SaveLog("GetOwnerProjectList", "Dataset", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return nil, e.NewValidErr(err) } data, err = repo.GetOwnerProjectList(c, req) go s.SaveLog("获取业主及项目列表", "Dataset", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return } func (s HandlerService) DatasetList(c *gin.Context) (data interface{}, err error) { repo := service.NewDatasetService(s.AppConfig, s.Engine, s.Logger) us, _ := c.Get("operatorUser") userInfo := us.(*model.SystemUser) var req proto.DatasetRequest err = c.ShouldBindJSON(&req) if err != nil { go s.SaveLog("DatasetList", "Dataset", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return nil, e.NewValidErr(err) } if req.Size < 1 { req.Size = 20 } if req.Size > 1000 { req.Size = 1000 } if req.Page < 1 { req.Page = 1 } data, err = repo.DatasetList(c, req) go s.SaveLog("获取数据集列表", "Dataset", "", "", ToString(data), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return } func (s HandlerService) ImportDataset(c *gin.Context) (data interface{}, err error) { repo := service.NewDatasetService(s.AppConfig, s.Engine, s.Logger) us, _ := c.Get("operatorUser") userInfo := us.(*model.SystemUser) var req proto.ImportDatasetRequest err = c.ShouldBindJSON(&req) if err != nil { go s.SaveLog("ImportDataset", "Dataset", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return nil, e.NewValidErr(err) } req.Creator = userInfo.UserId data, err = repo.ImportDataset(c, req) go s.SaveLog("导入数据集", "Dataset", "", "", ToString(data), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return }