Ver código fonte

Merge branch 'dev1.0.0' of https://app.yhyue.com/moapp/jyInfo into dev1.0.0

wangshan 3 anos atrás
pai
commit
54314fe7a7

+ 3 - 1
api/etc/info-api.yaml

@@ -21,4 +21,6 @@ Consumer:
     Hosts:
       - 127.0.0.1:2379
     Key: consumer.rpc
-AppId: 10000
+AppId: 10000
+MaxBytes: 2097152
+Timeout:  5000

+ 36 - 41
api/internal/logic/pubinfologic.go

@@ -2,8 +2,6 @@ package logic
 
 import (
 	"context"
-	"fmt"
-	"io/ioutil"
 	"jyInfo/rpc/consumer/consumer"
 	"net/http"
 
@@ -32,45 +30,42 @@ func NewPubInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Re
 }
 
 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
-		}
-	}
+	//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 consumer.Contact
-	//contact.Person = req.Contact.Person
-	//contact.Phone = req.Contact.Phone
-	//contact.Overt = req.Contact.Overt
-	contact.Person = req.ContactPerson
-	contact.Phone = req.ContactPhone
-	contact.Overt = req.ContactOvert
+	contact.Person = req.Contact.Person
+	contact.Phone = req.Contact.Phone
+	contact.Overt = req.Contact.Overt
 	pubinfo, err1 := l.svcCtx.Consumer.PublishInfo(l.ctx, &consumer.PublishInfoReq{
 		UserId:    req.UserId,
 		EntId:     req.EntId,
@@ -86,7 +81,7 @@ func (l *PubInfoLogic) PubInfo(req *types.PubInfoReq) (resp *types.CommonRes, er
 		Winner:    req.Winner,
 		Amount:    common.Float64All(req.Amount),
 		Detail:    req.Detail,
-		Attach:    common.MapToJson(attach),
+		Attach:    common.MapToJson(req.Attach),
 		Contact:   &contact,
 		AppId:     common.Int64All(req.AppId),
 		Phone:     req.Phone,

+ 3 - 37
api/internal/logic/pubsupplyinfologic.go

@@ -2,8 +2,6 @@ package logic
 
 import (
 	"context"
-	"fmt"
-	"io/ioutil"
 	"jyInfo/rpc/consumer/consumer"
 	"net/http"
 
@@ -32,42 +30,10 @@ func NewPubSupplyInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *h
 }
 
 func (l *PubSupplyInfoLogic) PubSupplyInfo(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 consumer.Contact
-	contact.Person = req.ContactPerson
-	contact.Phone = req.ContactPhone
-	contact.Overt = req.ContactOvert
+	contact.Person = req.Contact.Person
+	contact.Phone = req.Contact.Phone
+	contact.Overt = req.Contact.Overt
 	pubinfo, err1 := l.svcCtx.Consumer.PublishInfo(l.ctx, &consumer.PublishInfoReq{
 		UserId:    req.UserId,
 		EntId:     req.EntId,

+ 67 - 69
api/internal/types/types.go

@@ -2,28 +2,26 @@
 package types
 
 type PubInfoReq struct {
-	Title         string                 `form:"title"`
-	MsgType       string                 `form:"msgType,options=1|2|3"`
-	RelatedId     string                 `form:"relatedId,optional"`
-	Code          string                 `form:"code,optional"`
-	Province      string                 `form:"province,optional"`
-	City          string                 `form:"city,optional"`
-	Industry      []string               `form:"industry,optional"`
-	Buyer         string                 `form:"buyer,optional"`
-	Budget        string                 `form:"budget,optional"`
-	Winner        string                 `form:"winner,optional"`
-	Amount        string                 `form:"amount,optional"`
-	Detail        string                 `form:"detail"`
-	Attach        map[string]interface{} `form:"attach,optional"`
-	ContactPerson string                 `form:"contactPerson"`
-	ContactPhone  string                 `form:"contactPhone"`
-	ContactOvert  int64                  `form:"contactOvert"`
-	AppId         int64                  `form:"appId"`
-	EntId         string                 `form:"entId"`
-	UserId        string                 `form:"userId"`
-	ValidityTime  string                 `form:"validityTime,optional"`
-	Phone         string                 `form:"phone"`
-	EntName       string                 `form:"entName,optional"`
+	Title        string                 `json:"title"`
+	MsgType      string                 `json:"msgType,options=1|2|3"`
+	RelatedId    string                 `json:"relatedId,optional"`
+	Code         string                 `json:"code,optional"`
+	Province     string                 `json:"province,optional"`
+	City         string                 `json:"city,optional"`
+	Industry     []string               `json:"industry,optional"`
+	Buyer        string                 `json:"buyer,optional"`
+	Budget       string                 `json:"budget,optional"`
+	Winner       string                 `json:"winner,optional"`
+	Amount       string                 `json:"amount,optional"`
+	Detail       string                 `json:"detail"`
+	Attach       map[string]interface{} `json:"attach,optional"`
+	Contact      Contact                `json:"contact"`
+	AppId        int64                  `json:"appId"`
+	EntId        string                 `json:"entId"`
+	UserId       string                 `json:"userId"`
+	ValidityTime string                 `json:"validityTime,optional"`
+	Phone        string                 `json:"phone"`
+	EntName      string                 `json:"entName,optional"`
 }
 
 type Contact struct {
@@ -33,49 +31,49 @@ type Contact struct {
 }
 
 type MyPublishListReq struct {
-	UserId       string `form:"userId"`
-	AppId        int64  `form:"appId"`
-	Match        string `form:"match,optional"`
-	MsgType      string `form:"msgType,optional"`
-	ReviewStatus string `form:"reviewStatus,optional"`
-	PageSize     int    `form:"pageSize,optional,default=10"`
-	PageIndex    int    `form:"pageIndex,optional,default=1"`
+	UserId       string `json:"userId"`
+	AppId        int64  `json:"appId"`
+	Match        string `json:"match,optional"`
+	MsgType      string `json:"msgType,optional"`
+	ReviewStatus string `json:"reviewStatus,optional"`
+	PageSize     int    `json:"pageSize,optional,default=10"`
+	PageIndex    int    `json:"pageIndex,optional,default=1"`
 }
 
 type MyPublishCommonReq struct {
-	MsgId   string `form:"msgId"`
-	UserId  string `form:"userId"`
-	Type    string `form:"type"`
-	MsgType string `form:"msgType,optional"`
-	AppId   int64  `form:"appId"`
+	MsgId   string `json:"msgId"`
+	UserId  string `json:"userId"`
+	Type    string `json:"type"`
+	MsgType string `json:"msgType,optional"`
+	AppId   int64  `json:"appId"`
 }
 
 type ReviewCommonReq struct {
-	AppId int64  `form:"appId"`
-	MsgId string `form:"msgId"`
-	Type  int64  `form:"type"`
+	AppId int64  `json:"appId"`
+	MsgId string `json:"msgId"`
+	Type  int64  `json:"type"`
 }
 
 type InfoListReq struct {
-	AppId          int64  `form:"appId"`
-	MsgType        int    `form:"msgType,optional"`
-	PhoneType      int    `form:"phoneType,optional"`
-	Phone          string `form:"phone,optional"`
-	ReviewStatus   int    `form:"reviewStatus,optional"`
-	ApplyStartTime string `form:"applyStartTime,optional"`
-	ApplyEndTime   string `form:"applyEndTime,optional"`
-	PageSize       int64  `form:"pageSize"`
-	PageIndex      int64  `form:"pageIndex"`
-	IsDel          string `form:"isDel,optional"`
-	Published      string `form:"published,optional"`
+	AppId          int64  `json:"appId"`
+	MsgType        int    `json:"msgType,optional"`
+	PhoneType      int    `json:"phoneType,optional"`
+	Phone          string `json:"phone,optional"`
+	ReviewStatus   int    `json:"reviewStatus,optional"`
+	ApplyStartTime string `json:"applyStartTime,optional"`
+	ApplyEndTime   string `json:"applyEndTime,optional"`
+	PageSize       int64  `json:"pageSize"`
+	PageIndex      int64  `json:"pageIndex"`
+	IsDel          string `json:"isDel,optional"`
+	Published      string `json:"published,optional"`
 }
 
 type InfoExamineReq struct {
-	MsgId        string `form:"msgId"`
-	AppId        int64  `form:"appId"`
-	ReviewStatus int64  `form:"reviewStatus"`
-	ReviewDetail string `form:"reviewDetail,optional"`
-	MsgType      int64  `form:"msgType"`
+	MsgId        string `json:"msgId"`
+	AppId        int64  `json:"appId"`
+	ReviewStatus int64  `json:"reviewStatus"`
+	ReviewDetail string `json:"reviewDetail,optional"`
+	MsgType      int64  `json:"msgType"`
 }
 
 type AssProjecctReq struct {
@@ -86,31 +84,31 @@ type AssProjecctReq struct {
 }
 
 type PubSupplyInfoReq struct {
-	Keywords   string `form:"keywords"`
-	SearchType string `form:"searchType"`
-	Province   string `form:"province,optional"`
-	City       string `form:"city,optional"`
-	Time       string `form:"time,optional"`
-	Status     string `form:"status,optional"`
-	PageSize   int64  `form:"pageSize,optional"`
-	PageIndex  int64  `form:"pageIndex,optional"`
+	Keywords   string `json:"keywords"`
+	SearchType string `json:"searchType"`
+	Province   string `json:"province,optional"`
+	City       string `json:"city,optional"`
+	Time       string `json:"time,optional"`
+	Status     string `json:"status,optional"`
+	PageSize   int64  `json:"pageSize,optional"`
+	PageIndex  int64  `json:"pageIndex,optional"`
 }
 
 type SupplyInfoDetailReq struct {
-	MsgId   string `form:"msgId"`
-	MsgType int64  `form:"msgType"`
+	MsgId   string `json:"msgId"`
+	MsgType int64  `json:"msgType"`
 }
 
 type UploadReq struct {
-	FileName string `form:"fileName,optional"`
+	FileName string `json:"fileName,optional"`
 }
 
 type CommonReq struct {
-	UserId  string `form:"userId,optional"`
-	EntId   string `form:"entId,optional"`
-	AppId   int64  `form:"appId"`
-	Match   string `form:"match,optional"`
-	MsgType string `form:"msgType,optional"`
+	UserId  string `json:"userId,optional"`
+	EntId   string `json:"entId,optional"`
+	AppId   int64  `json:"appId"`
+	Match   string `json:"match,optional"`
+	MsgType string `json:"msgType,optional"`
 }
 
 type CommonRes struct {

+ 67 - 69
api/jyinfo.api

@@ -1,28 +1,26 @@
 type (
 	//信息发布
 	pubInfoReq {
-		Title         string                 `form:"title"`
-		MsgType       string                 `form:"msgType,options=1|2|3"`
-		RelatedId     string                 `form:"relatedId,optional"`
-		Code          string                 `form:"code,optional"`
-		Province      string                 `form:"province,optional"`
-		City          string                 `form:"city,optional"`
-		Industry      []string               `form:"industry,optional"`
-		Buyer         string                 `form:"buyer,optional"`
-		Budget        string                 `form:"budget,optional"`
-		Winner        string                 `form:"winner,optional"`
-		Amount        string                 `form:"amount,optional"`
-		Detail        string                 `form:"detail"`
-		Attach        map[string]interface{} `form:"attach,optional"`
-		ContactPerson string                 `form:"contactPerson"`
-		ContactPhone  string                 `form:"contactPhone"`
-		ContactOvert  int64                  `form:"contactOvert"`
-		AppId         int64                  `form:"appId"`
-		EntId         string                 `form:"entId"`
-		UserId        string                 `form:"userId"`
-		ValidityTime  string                 `form:"validityTime,optional"`
-		Phone         string                 `form:"phone"`
-		EntName       string                 `form:"entName,optional"`
+		Title        string                 `json:"title"`
+		MsgType      string                 `json:"msgType,options=1|2|3"`
+		RelatedId    string                 `json:"relatedId,optional"`
+		Code         string                 `json:"code,optional"`
+		Province     string                 `json:"province,optional"`
+		City         string                 `json:"city,optional"`
+		Industry     []string               `json:"industry,optional"`
+		Buyer        string                 `json:"buyer,optional"`
+		Budget       string                 `json:"budget,optional"`
+		Winner       string                 `json:"winner,optional"`
+		Amount       string                 `json:"amount,optional"`
+		Detail       string                 `json:"detail"`
+		Attach       map[string]interface{} `json:"attach,optional"`
+		Contact      Contact                `json:"contact"`
+		AppId        int64                  `json:"appId"`
+		EntId        string                 `json:"entId"`
+		UserId       string                 `json:"userId"`
+		ValidityTime string                 `json:"validityTime,optional"`
+		Phone        string                 `json:"phone"`
+		EntName      string                 `json:"entName,optional"`
 	}
 	Contact {
 		Person string `json:"person"`
@@ -30,45 +28,45 @@ type (
 		Overt  int64  `json:"overt"`
 	}
 	myPublishListReq {
-		UserId       string `form:"userId"`
-		AppId        int64  `form:"appId"`
-		Match        string `form:"match,optional"`
-		MsgType      string `form:"msgType,optional"`
-		ReviewStatus string `form:"reviewStatus,optional"`
-		PageSize     int    `form:"pageSize,optional,default=10"`
-		PageIndex    int    `form:"pageIndex,optional,default=1"`
+		UserId       string `json:"userId"`
+		AppId        int64  `json:"appId"`
+		Match        string `json:"match,optional"`
+		MsgType      string `json:"msgType,optional"`
+		ReviewStatus string `json:"reviewStatus,optional"`
+		PageSize     int    `json:"pageSize,optional,default=10"`
+		PageIndex    int    `json:"pageIndex,optional,default=1"`
 	}
 	myPublishCommonReq {
-		MsgId   string `form:"msgId"`
-		UserId  string `form:"userId"`
-		Type    string `form:"type"`
-		MsgType string `form:"msgType,optional"`
-		AppId   int64  `form:"appId"`
+		MsgId   string `json:"msgId"`
+		UserId  string `json:"userId"`
+		Type    string `json:"type"`
+		MsgType string `json:"msgType,optional"`
+		AppId   int64  `json:"appId"`
 	}
 	reviewCommonReq {
-		AppId int64  `form:"appId"`
-		MsgId string `form:"msgId"`
-		Type  int64  `form:"type"`
+		AppId int64  `json:"appId"`
+		MsgId string `json:"msgId"`
+		Type  int64  `json:"type"`
 	}
 	infoListReq {
-		AppId          int64  `form:"appId"`
-		MsgType        int    `form:"msgType,optional"`
-		PhoneType      int    `form:"phoneType,optional"`
-		Phone          string `form:"phone,optional"`
-		ReviewStatus   int    `form:"reviewStatus,optional"`
-		ApplyStartTime string `form:"applyStartTime,optional"`
-		ApplyEndTime   string `form:"applyEndTime,optional"`
-		PageSize       int64  `form:"pageSize"`
-		PageIndex      int64  `form:"pageIndex"`
-		IsDel          string `form:"isDel,optional"`
-		Published      string `form:"published,optional"`
+		AppId          int64  `json:"appId"`
+		MsgType        int    `json:"msgType,optional"`
+		PhoneType      int    `json:"phoneType,optional"`
+		Phone          string `json:"phone,optional"`
+		ReviewStatus   int    `json:"reviewStatus,optional"`
+		ApplyStartTime string `json:"applyStartTime,optional"`
+		ApplyEndTime   string `json:"applyEndTime,optional"`
+		PageSize       int64  `json:"pageSize"`
+		PageIndex      int64  `json:"pageIndex"`
+		IsDel          string `json:"isDel,optional"`
+		Published      string `json:"published,optional"`
 	}
 	infoExamineReq {
-		MsgId        string `form:"msgId"`
-		AppId        int64  `form:"appId"`
-		ReviewStatus int64  `form:"reviewStatus"`
-		ReviewDetail string `form:"reviewDetail,optional"`
-		MsgType      int64  `form:"msgType"`
+		MsgId        string `json:"msgId"`
+		AppId        int64  `json:"appId"`
+		ReviewStatus int64  `json:"reviewStatus"`
+		ReviewDetail string `json:"reviewDetail,optional"`
+		MsgType      int64  `json:"msgType"`
 	}
 	assProjecctReq {
 		UserId  string `json:"userId"`
@@ -77,28 +75,28 @@ type (
 		MsgType string `json:"msgType"`
 	}
 	pubSupplyInfoReq {
-		Keywords   string `form:"keywords"`
-		SearchType string `form:"searchType"`
-		Province   string `form:"province,optional"`
-		City       string `form:"city,optional"`
-		Time       string `form:"time,optional"`
-		Status     string `form:"status,optional"`
-		PageSize   int64  `form:"pageSize,optional"`
-		PageIndex  int64  `form:"pageIndex,optional"`
+		Keywords   string `json:"keywords"`
+		SearchType string `json:"searchType"`
+		Province   string `json:"province,optional"`
+		City       string `json:"city,optional"`
+		Time       string `json:"time,optional"`
+		Status     string `json:"status,optional"`
+		PageSize   int64  `json:"pageSize,optional"`
+		PageIndex  int64  `json:"pageIndex,optional"`
 	}
 	supplyInfoDetailReq {
-		MsgId   string `form:"msgId"`
-		MsgType int64  `form:"msgType"`
+		MsgId   string `json:"msgId"`
+		MsgType int64  `json:"msgType"`
 	}
 	uploadReq {
-		FileName string `form:"fileName,optional"`
+		FileName string `json:"fileName,optional"`
 	}
 	commonReq {
-		UserId  string `form:"userId,optional"`
-		EntId   string `form:"entId,optional"`
-		AppId   int64  `form:"appId"`
-		Match   string `form:"match,optional"`
-		MsgType string `form:"msgType,optional"`
+		UserId  string `json:"userId,optional"`
+		EntId   string `json:"entId,optional"`
+		AppId   int64  `json:"appId"`
+		Match   string `json:"match,optional"`
+		MsgType string `json:"msgType,optional"`
 	}
 	commonRes {
 		Err_code int         `json:"err_code"`