|
|
@@ -2975,11 +2975,11 @@ func (r *WrDeliveryAvalidHoldLB) GetDataEx() (interface{}, error) {
|
|
|
|
|
|
// WrUserFriend 我的朋友
|
|
|
type WrUserFriend struct {
|
|
|
- USERID int64 `json:"userid" xorm:"'USERID'" form:"userid"` // 用户id(查我的朋友时填自己的userid, 找新朋友时填写新朋友userid)
|
|
|
+ USERID int64 `json:"userid" xorm:"'USERID'" form:"userid"` // 用户id
|
|
|
FRIENDUSERID int64 `json:"frienduserid" xorm:"'FRIENDUSERID'"` // 朋友id
|
|
|
FRIENDNAME string `json:"friendname" xorm:"'FRIENDNAME'"` // 朋友名称(已脱敏)
|
|
|
-
|
|
|
- QueryType int32 `json:"querytype"` // 查询类型 1-查我的朋友 2-查找新朋友
|
|
|
+ ISFRIEND int32 `json:"isfriend" xorm:"'ISFRIEND'"` // 是否好友 0-不是 1-是
|
|
|
+ NEWUSERID int64 `json:"-" form:"newuserid"` // 新朋友id
|
|
|
}
|
|
|
|
|
|
func (r *WrUserFriend) calc() {
|
|
|
@@ -2988,19 +2988,21 @@ func (r *WrUserFriend) calc() {
|
|
|
|
|
|
func (r *WrUserFriend) buildSql() string {
|
|
|
var sqlId utils.SQLVal
|
|
|
- if r.QueryType == 1 {
|
|
|
- sqlId = "select t.userid, t.frienduserid, u.accountname friendname" +
|
|
|
+ if r.NEWUSERID > 0 {
|
|
|
+ sqlId =
|
|
|
+ "select t.userid frienduserid, t.accountname friendname, nvl(f.userid-f.userid+1,0) isfriend" +
|
|
|
+ " from useraccount t" +
|
|
|
+ " left join userfriend f on t.userid=f.frienduserid and f.userid=%v" +
|
|
|
+ " where 1 = 1" +
|
|
|
+ " and t.userid = %v"
|
|
|
+ sqlId.FormatParam(r.USERID, r.NEWUSERID)
|
|
|
+ } else {
|
|
|
+ sqlId = "select t.userid, t.frienduserid, u.accountname friendname, 1 as isfriend" +
|
|
|
" from UserFriend t" +
|
|
|
" left join useraccount u" +
|
|
|
" on t.frienduserid = u.userid" +
|
|
|
" where 1 = 1"
|
|
|
sqlId.And("t.userid", r.USERID)
|
|
|
- } else {
|
|
|
- sqlId =
|
|
|
- "select t.userid frienduserid, t.accountname friendname" +
|
|
|
- " from useraccount t" +
|
|
|
- " where 1 = 1"
|
|
|
- sqlId.And("t.userid", r.USERID)
|
|
|
}
|
|
|
|
|
|
return sqlId.String()
|
|
|
@@ -3012,7 +3014,6 @@ func (r *WrUserFriend) GetDataEx() (interface{}, error) {
|
|
|
err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
for i := range sData {
|
|
|
sData[i].calc()
|
|
|
- sData[i].QueryType = r.QueryType
|
|
|
}
|
|
|
return sData, err
|
|
|
}
|