diesel.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package routers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "kpt.xdmy/apiserver/model"
  5. "kpt.xdmy/apiserver/model/http"
  6. "kpt.xdmy/pkg/app"
  7. "kpt.xdmy/pkg/e"
  8. )
  9. func InsertDieselData(c *gin.Context) {
  10. appG := app.Gin{C: c}
  11. p := new(http.DieselReq)
  12. if !Bind(c, p) {
  13. return
  14. }
  15. err := svc.InsertDieselData(p)
  16. if err != nil {
  17. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  18. return
  19. }
  20. appG.Response(200, e.SUCCESS, true)
  21. }
  22. func InsertDieselImportExcel(c *gin.Context) {
  23. appG := app.Gin{C: c}
  24. data, err := svc.ImportExcel(c)
  25. if err != nil {
  26. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  27. return
  28. }
  29. appG.Response(200, e.SUCCESS, data)
  30. }
  31. func DieselOff(c *gin.Context) {
  32. p := new(http.DieselReq)
  33. if !Bind(c, p) {
  34. return
  35. }
  36. hrp := svc.DieselOff(p.Id)
  37. c.JSON(200, &hrp)
  38. }
  39. func EditPartpurchase(c *gin.Context) {
  40. appG := app.Gin{C: c}
  41. req := make([]*model.EditPartpurchaseReq, 0)
  42. if err := c.ShouldBind(&req); err != nil {
  43. appG.Response(500, e.ERROR, "数据格式不正确!"+err.Error())
  44. return
  45. }
  46. err := svc.EditPartpurchase(req)
  47. if err != nil {
  48. appG.Response(200, e.ERROR, err.Error())
  49. return
  50. }
  51. appG.Response(200, e.SUCCESS, true)
  52. }