Explorar o código

是否收藏接口

wangshan %!s(int64=4) %!d(string=hai) anos
pai
achega
50a8660912

+ 16 - 0
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -4,6 +4,7 @@ import (
 	"db"
 	"db"
 	"fmt"
 	"fmt"
 	"log"
 	"log"
+	"net/url"
 	qu "qfw/util"
 	qu "qfw/util"
 	"qfw/util/jy"
 	"qfw/util/jy"
 	"strconv"
 	"strconv"
@@ -13,6 +14,21 @@ import (
 	"util"
 	"util"
 )
 )
 
 
+//招标信息是否被收藏
+func IsCollByBids(bids, userid string) map[string]interface{} {
+	res := map[string]interface{}{}
+	for _, v := range strings.Split(bids, ",") {
+		//招标信息解密
+		log.Println("v:", v)
+		res[url.QueryEscape(v)] = false
+		bid := util.DecodeId(v)
+		if labArr := *db.Mysql.SelectBySql(fmt.Sprintf("select * from %s where bid = ? and userid = ?", db.DbConf.Bdcollection), bid, userid); len(labArr) == 1 {
+			res[url.QueryEscape(v)] = true
+		}
+	}
+	return res
+}
+
 //获取用户标签
 //获取用户标签
 type LabelByUser struct {
 type LabelByUser struct {
 	Lid   string `json:"lid"`
 	Lid   string `json:"lid"`

+ 1 - 0
src/jfw/modules/publicapply/src/bidcollection/service/action.go

@@ -9,4 +9,5 @@ type ServiceStruct struct {
 	bCAction       xweb.Mapper `xweb:"/bidcoll/action"`   //招标信息收藏
 	bCAction       xweb.Mapper `xweb:"/bidcoll/action"`   //招标信息收藏
 	labelAction    xweb.Mapper `xweb:"/bidcoll/label"`    //标签新增或删除
 	labelAction    xweb.Mapper `xweb:"/bidcoll/label"`    //标签新增或删除
 	getLabelAction xweb.Mapper `xweb:"/bidcoll/getLabel"` //获取标签
 	getLabelAction xweb.Mapper `xweb:"/bidcoll/getLabel"` //获取标签
+	isCollAction   xweb.Mapper `xweb:"/bidcoll/isColl"`   //招标信息是否被收藏
 }
 }

+ 18 - 0
src/jfw/modules/publicapply/src/bidcollection/service/service.go

@@ -4,9 +4,27 @@ import (
 	. "api"
 	. "api"
 	"bidcollection/entity"
 	"bidcollection/entity"
 	"encoding/json"
 	"encoding/json"
+	"log"
 	qu "qfw/util"
 	qu "qfw/util"
 )
 )
 
 
+//招标信息是否被收藏
+func (this *ServiceStruct) IsCollAction() {
+	userId, _ := this.GetSession("userId").(string)
+	defer qu.Catch()
+	r := func() Result {
+		if this.Method() != "POST" {
+			return Result{Data: nil, Error_msg: Error_msg_1005}
+		}
+		if this.GetString("bids") == "" {
+			return Result{Data: nil, Error_msg: Error_msg_1003}
+		}
+		log.Println(this.GetString("bids"), "++++++++")
+		return Result{Data: entity.IsCollByBids(this.GetString("bids"), userId)}
+	}()
+	this.ServeJson(r)
+}
+
 //获取标签
 //获取标签
 func (this *ServiceStruct) GetLabelAction() {
 func (this *ServiceStruct) GetLabelAction() {
 	userId, _ := this.GetSession("userId").(string)
 	userId, _ := this.GetSession("userId").(string)