| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package controllers
- import (
- "fwh-toolbox-server/services"
- "strconv"
- "github.com/gofiber/fiber/v2"
- "go.uber.org/zap"
- )
- // 查询模版列表
- // /despatchConfig/touTemplatePro/list
- func QueryTouTemplateProList(c *fiber.Ctx) error {
- pageSize, _ := strconv.Atoi(c.Query("pageSize", "20"))
- pageNum, _ := strconv.Atoi(c.Query("pageNum", "1"))
- tempTypeStr := c.Query("tempType", "")
- statusStr := c.Query("status", "")
- search := c.Query("search", "")
- if pageSize <= 0 || pageNum <= 0 {
- return Fail(c, "Invalid request para")
- }
- var tempType *int = nil
- var status *int = nil
- if tempTypeStr != "" {
- tempTypeNumber, err := strconv.Atoi(tempTypeStr)
- if err == nil {
- tempType = &tempTypeNumber
- }
- }
- if statusStr != "" {
- statusNumber, err := strconv.Atoi(statusStr)
- if err == nil {
- status = &statusNumber
- }
- }
- zap.L().Info("QueryTouTemplateProList", zap.String("statusStr", statusStr), zap.String("tempTypeStr", tempTypeStr))
- zap.L().Info("QueryTouTemplateProList", zap.Any("status", status), zap.Any("tempType", tempType))
- listPage, err := services.GetTouTemplateProList(uint(pageNum), uint(pageSize), tempType, status, search)
- if err != nil {
- zap.L().Warn("FWH query failed.", zap.String("err", err.Error()))
- return Error(c, "FWH query failed.")
- }
- return Success(c, listPage)
- }
- // 查询模版信息
- // /despatchConfig/touTemplatePro/info
- func QueryTouTemplateProDetailInfo(c *fiber.Ctx) error {
- id, _ := strconv.Atoi(c.Query("id", "0"))
- if id <= 0 {
- return Fail(c, "Invalid request para")
- }
- detailInfo, err := services.GetTouTemplateProDetailInfo(uint(id))
- if err != nil {
- zap.L().Warn("FWH query failed.", zap.String("err", err.Error()))
- return Error(c, "FWH query failed.")
- }
- return Success(c, detailInfo)
- }
|