feed_formula.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package group
  2. import (
  3. "net/http"
  4. "tmr-watch/models"
  5. "tmr-watch/pkg/app"
  6. "tmr-watch/pkg/e"
  7. "tmr-watch/service/group"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // DistributeFeedFormula 饲料配方下发
  11. func DistributeFeedFormula(c *gin.Context) {
  12. appG := app.Gin{C: c}
  13. var req models.PastureBodyRequest
  14. if err := c.BindJSON(&req); err != nil {
  15. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  16. return
  17. }
  18. if len(req.Body) <= 0 {
  19. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  20. }
  21. if err := group.DistributeFeedFormulaService(&req); err != nil {
  22. appG.Response(http.StatusBadRequest, e.ERROR_ADD_FAIL, nil)
  23. return
  24. }
  25. appG.Response(http.StatusOK, e.SUCCESS, map[string]bool{
  26. "success": true,
  27. })
  28. }
  29. // AnalysisAccuracy 准确性分析
  30. func AnalysisAccuracy(c *gin.Context) {
  31. appG := app.Gin{C: c}
  32. var req models.AnalysisAccuracyRequest
  33. if err := c.BindJSON(&req); err != nil {
  34. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  35. return
  36. }
  37. if res, err := group.AnalysisAccuracyService(&req); err != nil {
  38. appG.Response(http.StatusBadRequest, e.ERROR_GET_S_FAIL, map[string]interface{}{
  39. "error": err,
  40. })
  41. } else {
  42. appG.Response(http.StatusOK, e.SUCCESS, res)
  43. }
  44. }
  45. // ProcessAnalysis 过程分析
  46. func ProcessAnalysis(c *gin.Context) {
  47. appG := app.Gin{C: c}
  48. var req models.AnalysisAccuracyRequest
  49. if err := c.BindJSON(&req); err != nil {
  50. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  51. return
  52. }
  53. if res, err := group.ProcessAnalysisService(&req); err != nil {
  54. appG.Response(http.StatusBadRequest, e.ERROR_GET_S_FAIL, map[string]interface{}{
  55. "error": err,
  56. })
  57. } else {
  58. appG.Response(http.StatusOK, e.SUCCESS, res)
  59. }
  60. }