Explorar el Código

fix:联系人信息回显修改

duxin hace 3 años
padre
commit
568d4331ad
Se han modificado 3 ficheros con 19 adiciones y 18 borrados
  1. 3 3
      api/internal/types/types.go
  2. 3 3
      api/jyinfo.api
  3. 13 12
      rpc/consumer/internal/logic/inforelatedlogic.go

+ 3 - 3
api/internal/types/types.go

@@ -85,10 +85,10 @@ type InfoExamineReq struct {
 type AssProjecctReq struct {
 	UserId  string `header:"userId"`
 	AppId   string `header:"appId"`
-	Match   string `json:"match"`
-	MsgType int64  `json:"msgType"`
+	Match   string `json:"match,optional"`
+	MsgType int64  `json:"msgType,optional"`
 	EntId   int64  `header:"entId"`
-	Type    int64  `json:"type"`
+	Type    int64  `json:"type,optional"`
 }
 
 type PubSupplyInfoReq struct {

+ 3 - 3
api/jyinfo.api

@@ -77,10 +77,10 @@ type (
 	assProjecctReq {
 		UserId  string `header:"userId"`
 		AppId   string `header:"appId"`
-		Match   string `json:"match"`
-		MsgType int64  `json:"msgType"`
+		Match   string `json:"match,optional"`
+		MsgType int64  `json:"msgType,optional"`
 		EntId   int64  `header:"entId"`
-		Type    int64  `json:"type"`
+		Type    int64  `json:"type,optional"`
 	}
 	pubSupplyInfoReq {
 		Keywords   string `json:"keywords"`

+ 13 - 12
rpc/consumer/internal/logic/inforelatedlogic.go

@@ -35,17 +35,18 @@ func (l *InfoRelatedLogic) InfoRelated(in *consumerinfo.UserIdReq) (*consumerinf
 		resp      consumerinfo.InfoRelatedResp
 	)
 	log.Println("关联公告接口调用", in)
-	queryName = ` and type=` + mc.InterfaceToStr(in.MsgType)
+
 	if in.AppId != "" {
-		queryName = queryName + ` and app_id = ` + util.StrFormat(in.AppId)
+		queryName += ` and app_id = ` + util.StrFormat(in.AppId)
 	}
 	if in.EntId != 0 {
-		queryName = queryName + ` and ent_id = ` + mc.InterfaceToStr(in.EntId)
+		queryName += ` and ent_id = ` + mc.InterfaceToStr(in.EntId)
 	}
 	switch in.MsgId {
 	case 0:
+		queryName += ` and type=` + mc.InterfaceToStr(in.MsgType)
 		if in.Match != "" {
-			queryName = queryName + ` and title LIKE '%` + in.Match + `%' `
+			queryName += ` and title LIKE '%` + in.Match + `%' `
 		}
 		allData := model.Mysql.SelectBySql(`SELECT * from information WHERE user_id="` + in.UserId + `" and published=2 and is_del=1` + queryName + ` order by create_time desc limit 50`)
 		if allData == nil || len(*allData) == 0 {
@@ -62,13 +63,11 @@ func (l *InfoRelatedLogic) InfoRelated(in *consumerinfo.UserIdReq) (*consumerinf
 			resp.Data = append(resp.Data, &data)
 		}
 	case 1:
-		var allData *[]map[string]interface{}
-		switch in.MsgType {
-		case 3:
-			allData = model.Mysql.SelectBySql(`SELECT * from supply_info WHERE user_id="` + in.UserId + `"` + queryName + ` order by create_time desc limit 1`)
-		default:
-			allData = model.Mysql.SelectBySql(`SELECT * from information WHERE user_id="` + in.UserId + `"` + queryName + ` order by create_time desc limit 1`)
-		}
+		allData := model.Mysql.SelectBySql(`SELECT a.id,a.title,a.create_time,a.contact_person,a.contact_phone,a.contact_overt  from (SELECT id,title,create_time,contact_person,contact_phone,contact_overt from information WHERE user_id= "` + in.UserId + `"
+			union all
+			SELECT id,title,create_time,contact_person,contact_phone,contact_overt  from supply_info WHERE is_del = 1 and user_id= "` + in.UserId + `" ) a  order by a.create_time desc limit 1`)
+		oneData := model.Mysql.SelectBySql(`SELECT * from information WHERE user_id="` + in.UserId + `" order by create_time desc limit 1`)
+
 		if allData == nil || len(*allData) == 0 {
 			return &resp, nil
 		}
@@ -79,7 +78,9 @@ func (l *InfoRelatedLogic) InfoRelated(in *consumerinfo.UserIdReq) (*consumerinf
 			data.Person = mc.InterfaceToStr(v["contact_person"])
 			data.Phone = mc.InterfaceToStr(v["contact_phone"])
 			data.Overt = mc.Int64All(v["contact_overt"])
-			data.RecommendedService = mc.Int64All(v["recommended_service"])
+			if oneData != nil && len(*oneData) > 0 {
+				data.RecommendedService = mc.Int64All((*oneData)[0]["recommended_service"])
+			}
 			resp.Data = append(resp.Data, &data)
 		}
 	}