price_driven.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package price_driven
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "hongze/hongze_yb/controller/response"
  5. "hongze/hongze_yb/models/request"
  6. "hongze/hongze_yb/services/price_driven"
  7. "hongze/hongze_yb/services/user"
  8. )
  9. // PriceDrivenDetail 价格驱动详情
  10. // @Tags 价格驱动模块
  11. // @Description 获取价格驱动详情
  12. // @Param variety_tag_id query int true "标签ID"
  13. // @Success 200 {object} response.PriceDrivenItem
  14. // @failure 400 {string} string "获取失败"
  15. // @Router /price_driven/detail [get]
  16. func PriceDrivenDetail(c *gin.Context) {
  17. var req request.PriceDrivenDetailReq
  18. if err := c.Bind(&req); err != nil {
  19. response.Fail("参数有误", c)
  20. return
  21. }
  22. if req.VarietyTagId <= 0 {
  23. response.Fail("参数有误", c)
  24. return
  25. }
  26. item, errMsg, err := price_driven.GetPriceDrivenDetail(req.VarietyTagId)
  27. if err != nil {
  28. response.FailMsg(errMsg, "GetPriceDrivenDetail ErrMsg:"+err.Error(), c)
  29. return
  30. }
  31. response.OkData("获取成功", item, c)
  32. }
  33. // PriceDrivenVisitLog 价格驱动访问记录
  34. // @Tags 价格驱动模块
  35. // @Description 价格驱动访问记录
  36. // @Param price_driven_id query int true "价格驱动ID"
  37. // @Param source_agent query int true "来源"
  38. // @Success 200 {string} string "操作成功"
  39. // @failure 400 {string} string "操作失败"
  40. // @Router /price_driven/visit_log [post]
  41. func PriceDrivenVisitLog(c *gin.Context) {
  42. var req request.PriceDrivenVisitReq
  43. if err := c.Bind(&req); err != nil {
  44. response.Fail("参数有误", c)
  45. return
  46. }
  47. if req.PriceDrivenId <= 0 {
  48. response.Fail("参数有误", c)
  49. return
  50. }
  51. userInfo := user.GetInfoByClaims(c)
  52. errMsg, err := price_driven.SavePriceDrivenVisitLog(req.PriceDrivenId, req.SourceAgent, userInfo)
  53. if err != nil {
  54. response.FailMsg(errMsg, "PriceDrivenVisitLog ErrMsg:"+err.Error(), c)
  55. return
  56. }
  57. response.Ok("操作成功", c)
  58. }