|
@@ -66,10 +66,11 @@ func (m *Follow) CheckCStatus() error {
|
|
|
pname := m.GetString("pcname")
|
|
|
pcode := m.GetString("pccode")
|
|
|
userId, _ := m.GetSession("userId").(string)
|
|
|
+ openId, _ := m.GetSession("s_m_openid").(string)
|
|
|
flag := false
|
|
|
followid := ""
|
|
|
if userId != "" {
|
|
|
- flag, followid = MFollow(userId, pname, pcode, "")
|
|
|
+ flag, followid = MFollow(userId, pname, pcode, "", openId)
|
|
|
// follows, _ := mongodb.FindOneByField("follow_project", `{"s_id":"`+s_id+`","s_openid":"`+s_openid.(string)+`"}`, `{"_id":1}`)
|
|
|
// if follows != nil && *follows != nil && len(*follows) > 0 {
|
|
|
// flag = "t"
|
|
@@ -106,9 +107,9 @@ func (m *Follow) Fwsave() {
|
|
|
var status = "n"
|
|
|
var followId string
|
|
|
s_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- if mongodb.Count("follow_project", `{"s_userid":"`+userId+`"}`) >= followLimit {
|
|
|
+ if mongodb.Count("follow_project", `{"s_openid":"`+openid+`"}`) >= followLimit {
|
|
|
status = "m"
|
|
|
- } else if mongodb.Count("follow_project", `{"s_userid":"`+m.GetSession("userId").(string)+`","s_id":"`+s_id+`"}`) > 0 {
|
|
|
+ } else if mongodb.Count("follow_project", `{"s_openid":"`+openid+`","s_id":"`+s_id+`"}`) > 0 {
|
|
|
status = "e"
|
|
|
} else {
|
|
|
data := make(map[string]interface{})
|
|
@@ -318,8 +319,9 @@ func (m *Follow) Photo(tp string) error {
|
|
|
m.T["projectname"] = projectname
|
|
|
m.T["projectcode"] = projectcode
|
|
|
userId, _ := m.GetSession("userId").(string)
|
|
|
+ openid := m.GetSession("s_m_openid").(string)
|
|
|
if userId != "" {
|
|
|
- flag, followid := MFollow(userId, projectname, projectcode, "")
|
|
|
+ flag, followid := MFollow(userId, projectname, projectcode, "", openid)
|
|
|
if flag && len(followid) > 0 {
|
|
|
m.Redirect("/follow/set/list/" + followid)
|
|
|
return nil
|
|
@@ -398,14 +400,15 @@ func (m *Follow) Photo(tp string) error {
|
|
|
func (m *Follow) AjaxReq() {
|
|
|
defer util.Catch()
|
|
|
userId := m.GetSession("userId").(string)
|
|
|
+ openid := m.GetSession("s_m_openid").(string)
|
|
|
var status = "n"
|
|
|
reqType := m.GetString("reqType")
|
|
|
var followId string
|
|
|
if reqType == "follow" { //快照页面关注
|
|
|
s_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- if mongodb.Count("follow_project", `{"s_userid":"`+userId+`"}`) >= followLimit {
|
|
|
+ if mongodb.Count("follow_project", `{"s_openid":"`+openid+`"}`) >= followLimit {
|
|
|
status = "m"
|
|
|
- } else if mongodb.Count("follow_project", `{"s_userid":"`+m.GetSession("userId").(string)+`","s_id":"`+s_id+`"}`) > 0 {
|
|
|
+ } else if mongodb.Count("follow_project", `{"s_openid":"`+openid+`","s_id":"`+s_id+`"}`) > 0 {
|
|
|
status = "e"
|
|
|
} else {
|
|
|
publishtime, _ := m.GetInt("publishtime")
|
|
@@ -418,7 +421,6 @@ func (m *Follow) AjaxReq() {
|
|
|
toptype := m.GetString("toptype")
|
|
|
s_type := m.GetString("type")
|
|
|
if projectname != "" || projectcode != "" {
|
|
|
- openid := m.GetSession("s_m_openid").(string)
|
|
|
data := map[string]interface{}{
|
|
|
"s_userid": userId,
|
|
|
"s_openid": openid,
|
|
@@ -479,7 +481,7 @@ func (m *Follow) AjaxReq() {
|
|
|
}
|
|
|
}
|
|
|
} else if reqType == "cancel" { //取消关注
|
|
|
- if data, ok := mongodb.FindOne("follow_project", `{"s_userid":"`+userId+`","_id":"`+util.DecodeArticleId2ByCheck(m.GetString("id"))[0]+`"}`); ok && data != nil {
|
|
|
+ if data, ok := mongodb.FindOne("follow_project", `{"s_openid":"`+openid+`","_id":"`+util.DecodeArticleId2ByCheck(m.GetString("id"))[0]+`"}`); ok && data != nil {
|
|
|
(*data)["s_followid"] = util.BsonIdToSId((*data)["_id"])
|
|
|
delete(*data, "_id")
|
|
|
(*data)["i_status"] = 1
|
|
@@ -491,7 +493,7 @@ func (m *Follow) AjaxReq() {
|
|
|
}
|
|
|
} else if reqType == "followset" {
|
|
|
id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- if mongodb.Count("follow_project", map[string]interface{}{"_id": bson.ObjectIdHex(id), "s_userid": m.GetSession("userId").(string)}) == 1 {
|
|
|
+ if mongodb.Count("follow_project", map[string]interface{}{"_id": bson.ObjectIdHex(id), "s_openid": openid}) == 1 {
|
|
|
data := make(map[string]interface{})
|
|
|
data["l_updatetime"] = time.Now().Unix()
|
|
|
if remind, _ := m.GetInteger("remind"); remind == 1 {
|
|
@@ -519,7 +521,8 @@ func (m *Follow) AjaxReq() {
|
|
|
//我关注的项目
|
|
|
func (m *Follow) List() error {
|
|
|
defer util.Catch()
|
|
|
- datas, ok := mongodb.Find("follow_project", `{"s_userid":"`+m.GetSession("userId").(string)+`"}`, `{"l_lastpushtime":-1,"l_createtime":-1}`, `{"s_projectname":1,"s_projectcode":1,"i_remind":1,"l_lastpushtime":1,"l_createtime":1}`, false, -1, -1)
|
|
|
+ myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
+ datas, ok := mongodb.Find("follow_project", `{"s_openid":"`+myopenid+`"}`, `{"l_lastpushtime":-1,"l_createtime":-1}`, `{"s_projectname":1,"s_projectcode":1,"i_remind":1,"l_lastpushtime":1,"l_createtime":1}`, false, -1, -1)
|
|
|
m.T["flag"] = false
|
|
|
if ok && datas != nil && len(*datas) > 0 {
|
|
|
for k, v := range *datas {
|
|
@@ -534,7 +537,6 @@ func (m *Follow) List() error {
|
|
|
m.T["flag"] = true
|
|
|
}
|
|
|
}
|
|
|
- myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
m.T["openid"] = se.EncodeString(myopenid)
|
|
|
mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
@@ -559,10 +561,10 @@ func (m *Follow) Addsave() error {
|
|
|
var status = "n"
|
|
|
var id string
|
|
|
userId := m.GetSession("userId").(string)
|
|
|
- if mongodb.Count("follow_project", `{"s_userid":"`+userId+`"}`) >= followLimit {
|
|
|
+ openid := m.GetSession("s_m_openid").(string)
|
|
|
+ if mongodb.Count("follow_project", `{"s_openid":"`+openid+`"}`) >= followLimit {
|
|
|
status = "m"
|
|
|
} else {
|
|
|
- openid := m.GetSession("s_m_openid").(string)
|
|
|
if projectname := m.GetString("projectname"); projectname != "" {
|
|
|
data := map[string]interface{}{
|
|
|
"s_userid": userId,
|
|
@@ -647,7 +649,7 @@ func (m *Follow) Set(tp, id string) error {
|
|
|
fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
|
|
|
data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
"_id": bson.ObjectIdHex(id),
|
|
|
- "s_userid": m.GetSession("userId").(string),
|
|
|
+ "s_openid": m.GetSession("s_m_openid").(string),
|
|
|
}, fields)
|
|
|
m.T["isDel"] = false
|
|
|
if ok && (data == nil || len(*data) == 0) {
|