pubinfologic.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerinfo"
  4. "context"
  5. "net/http"
  6. "app.yhyue.com/moapp/jybase/common"
  7. "app.yhyue.com/moapp/jyInfo/api/internal/svc"
  8. "app.yhyue.com/moapp/jyInfo/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type PubInfoLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. r *http.Request
  16. }
  17. func NewPubInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *PubInfoLogic {
  18. return &PubInfoLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. r: r,
  23. }
  24. }
  25. func (l *PubInfoLogic) PubInfo(req *types.PubInfoReq) (resp *types.CommonRes, err error) {
  26. //err2 := l.r.ParseMultipartForm(50 * 1024 * 1024 * 1024)
  27. //if err2 != nil {
  28. // fmt.Println(err2)
  29. //}
  30. //fhs := l.r.MultipartForm.File["file"]
  31. //var uploads []*consumer.InfoFileUploadResp
  32. //var upload *consumer.InfoFileUploadResp
  33. //attach := map[string]interface{}{}
  34. //var err0 error
  35. //if len(fhs) > 0 {
  36. // for _, fheader := range fhs {
  37. // file, err1 := fheader.Open()
  38. // if err1 != nil {
  39. // fmt.Println(err1)
  40. // continue
  41. // }
  42. // defer file.Close()
  43. // bt, _ := ioutil.ReadAll(file)
  44. // upload, err0 = l.svcCtx.Consumer.InfoFileUpload(l.ctx, &consumer.InfoFileUploadReq{
  45. // FileName: fheader.Filename,
  46. // File: bt,
  47. // FileSize: fheader.Size,
  48. // })
  49. // if err0 != nil {
  50. // continue
  51. // }
  52. // uploads = append(uploads, upload)
  53. // }
  54. // for n, v := range uploads {
  55. // attach[common.InterfaceToStr(n+1)] = v.Data
  56. // }
  57. //}
  58. var contact consumerinfo.Contact
  59. contact.Person = req.Contact.Person
  60. contact.Phone = req.Contact.Phone
  61. contact.Overt = req.Contact.Overt
  62. pubinfo, err1 := l.svcCtx.Consumer.PublishInfo(l.ctx, &consumerinfo.PublishInfoReq{
  63. UserId: req.UserId,
  64. EntId: req.EntId,
  65. Title: req.Title,
  66. MsgType: req.MsgType,
  67. RelatedId: req.RelatedId,
  68. Code: req.Code,
  69. Province: req.Province,
  70. City: req.City,
  71. Industry: req.Industry,
  72. Buyer: req.Buyer,
  73. Budget: req.Budget,
  74. Winner: req.Winner,
  75. Amount: req.Amount,
  76. Detail: req.Detail,
  77. Attach: common.MapToJson(req.Attach),
  78. Contact: &contact,
  79. AppId: req.AppId,
  80. Phone: req.Phone,
  81. EntName: req.EntName,
  82. JyPublishingMedia: req.JyPublishingMedia,
  83. RecommendedService: req.RecommendedService,
  84. DeliveryAddress: req.DeliveryAddress,
  85. })
  86. if err1 != nil {
  87. return &types.CommonRes{
  88. Err_code: -1,
  89. Err_msg: "错误",
  90. Data: nil,
  91. }, nil
  92. }
  93. return &types.CommonRes{
  94. Err_code: common.IntAll(pubinfo.ErrCode),
  95. Err_msg: pubinfo.ErrMsg,
  96. Data: pubinfo.PublishId,
  97. }, nil
  98. }