qa.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package customer
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "zhiyuan/pkg/app"
  5. "zhiyuan/pkg/utils"
  6. "zhiyuan/services/aftersale"
  7. )
  8. func QaList(c *gin.Context) {
  9. page := app.HandlePageNum(c)
  10. where := map[string]interface{}{"deleted_at": 0}
  11. type Qa struct {
  12. ID int `json:"id"`
  13. Title string `json:"title"`
  14. Content string `json:"content"`
  15. DeletedAt int `json:"deleted_at"`
  16. CreatedAt string `json:"created_at"`
  17. UpdatedAt string `json:"updated_at"`
  18. }
  19. qaList := make([]*Qa, 0)
  20. if _, err := aftersale.GetQaList(where, nil, page, &qaList); err != nil {
  21. app.Error(c, err.Error())
  22. return
  23. }
  24. for k, v := range qaList {
  25. v.CreatedAt = utils.DateS(v.CreatedAt, "YYYY-MM-DD")
  26. v.UpdatedAt = utils.DateS(v.UpdatedAt, "YYYY-MM-DD")
  27. qaList[k] = v
  28. }
  29. app.Success(c, qaList)
  30. }
  31. func QaInfo(c *gin.Context) {
  32. id := utils.StrTo(c.Param("id")).MustInt()
  33. if id <= 0 {
  34. app.Error(c, "类型id有误")
  35. return
  36. }
  37. info, _ := aftersale.GetQaOne(map[string]interface{}{"id": id}, nil, nil)
  38. app.Success(c, info)
  39. }