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) TaskList(c *gin.Context) (data interface{}, err error) { repo := service.NewTaskService(s.Engine, s.Logger) us, _ := c.Get("operatorUser") userInfo := us.(*model.SystemUser) var req proto.TaskRequest err = c.ShouldBindJSON(&req) if err != nil { go s.SaveLog("TaskList", "Manage", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return nil, e.NewValidErr(err) } data, err = repo.TaskList(c, req) go s.SaveLog("任务列表", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return } func (s HandlerService) AddTask(c *gin.Context) (data interface{}, err error) { repo := service.NewTaskService(s.Engine, s.Logger) us, _ := c.Get("operatorUser") userInfo := us.(*model.SystemUser) var req proto.TaskItemRequest err = c.ShouldBindJSON(&req) if err != nil { go s.SaveLog("AddTask", "Manage", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return nil, e.NewValidErr(err) } data, err = repo.AddTask(c, req) go s.SaveLog("新增任务", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "") return }