despatchConfigControllers.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package controllers
  2. import (
  3. "fwh-toolbox-server/services"
  4. "strconv"
  5. "github.com/gofiber/fiber/v2"
  6. "go.uber.org/zap"
  7. )
  8. // 查询模版列表
  9. // /despatchConfig/touTemplatePro/list
  10. func QueryTouTemplateProList(c *fiber.Ctx) error {
  11. pageSize, _ := strconv.Atoi(c.Query("pageSize", "20"))
  12. pageNum, _ := strconv.Atoi(c.Query("pageNum", "1"))
  13. tempTypeStr := c.Query("tempType", "")
  14. statusStr := c.Query("status", "")
  15. search := c.Query("search", "")
  16. if pageSize <= 0 || pageNum <= 0 {
  17. return Fail(c, "Invalid request para")
  18. }
  19. var tempType *int = nil
  20. var status *int = nil
  21. if tempTypeStr != "" {
  22. tempTypeNumber, err := strconv.Atoi(tempTypeStr)
  23. if err == nil {
  24. tempType = &tempTypeNumber
  25. }
  26. }
  27. if statusStr != "" {
  28. statusNumber, err := strconv.Atoi(statusStr)
  29. if err == nil {
  30. status = &statusNumber
  31. }
  32. }
  33. zap.L().Info("QueryTouTemplateProList", zap.String("statusStr", statusStr), zap.String("tempTypeStr", tempTypeStr))
  34. zap.L().Info("QueryTouTemplateProList", zap.Any("status", status), zap.Any("tempType", tempType))
  35. listPage, err := services.GetTouTemplateProList(uint(pageNum), uint(pageSize), tempType, status, search)
  36. if err != nil {
  37. zap.L().Warn("FWH query failed.", zap.String("err", err.Error()))
  38. return Error(c, "FWH query failed.")
  39. }
  40. return Success(c, listPage)
  41. }
  42. // 查询模版信息
  43. // /despatchConfig/touTemplatePro/info
  44. func QueryTouTemplateProDetailInfo(c *fiber.Ctx) error {
  45. id, _ := strconv.Atoi(c.Query("id", "0"))
  46. if id <= 0 {
  47. return Fail(c, "Invalid request para")
  48. }
  49. detailInfo, err := services.GetTouTemplateProDetailInfo(uint(id))
  50. if err != nil {
  51. zap.L().Warn("FWH query failed.", zap.String("err", err.Error()))
  52. return Error(c, "FWH query failed.")
  53. }
  54. return Success(c, detailInfo)
  55. }