123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- package logic
- import (
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerinfo"
- "context"
- "net/http"
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jyInfo/api/internal/svc"
- "app.yhyue.com/moapp/jyInfo/api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type PubInfoLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- r *http.Request
- }
- func NewPubInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *PubInfoLogic {
- return &PubInfoLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- r: r,
- }
- }
- func (l *PubInfoLogic) PubInfo(req *types.PubInfoReq) (resp *types.CommonRes, err error) {
- //err2 := l.r.ParseMultipartForm(50 * 1024 * 1024 * 1024)
- //if err2 != nil {
- // fmt.Println(err2)
- //}
- //fhs := l.r.MultipartForm.File["file"]
- //var uploads []*consumer.InfoFileUploadResp
- //var upload *consumer.InfoFileUploadResp
- //attach := map[string]interface{}{}
- //var err0 error
- //if len(fhs) > 0 {
- // for _, fheader := range fhs {
- // file, err1 := fheader.Open()
- // if err1 != nil {
- // fmt.Println(err1)
- // continue
- // }
- // defer file.Close()
- // bt, _ := ioutil.ReadAll(file)
- // upload, err0 = l.svcCtx.Consumer.InfoFileUpload(l.ctx, &consumer.InfoFileUploadReq{
- // FileName: fheader.Filename,
- // File: bt,
- // FileSize: fheader.Size,
- // })
- // if err0 != nil {
- // continue
- // }
- // uploads = append(uploads, upload)
- // }
- // for n, v := range uploads {
- // attach[common.InterfaceToStr(n+1)] = v.Data
- // }
- //}
- var contact consumerinfo.Contact
- contact.Person = req.Contact.Person
- contact.Phone = req.Contact.Phone
- contact.Overt = req.Contact.Overt
- pubinfo, err1 := l.svcCtx.Consumer.PublishInfo(l.ctx, &consumerinfo.PublishInfoReq{
- UserId: req.UserId,
- EntId: req.EntId,
- Title: req.Title,
- MsgType: req.MsgType,
- RelatedId: req.RelatedId,
- Code: req.Code,
- Province: req.Province,
- City: req.City,
- Industry: req.Industry,
- Buyer: req.Buyer,
- Budget: req.Budget,
- Winner: req.Winner,
- Amount: req.Amount,
- Detail: req.Detail,
- Attach: common.MapToJson(req.Attach),
- Contact: &contact,
- AppId: req.AppId,
- Phone: req.Phone,
- EntName: req.EntName,
- JyPublishingMedia: req.JyPublishingMedia,
- RecommendedService: req.RecommendedService,
- DeliveryAddress: req.DeliveryAddress,
- })
- if err1 != nil {
- return &types.CommonRes{
- Err_code: -1,
- Err_msg: "错误",
- Data: nil,
- }, nil
- }
- return &types.CommonRes{
- Err_code: common.IntAll(pubinfo.ErrCode),
- Err_msg: pubinfo.ErrMsg,
- Data: pubinfo.PublishId,
- }, nil
- }
|