From 7a57493a194813ca4480d76639583169fea71835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Tue, 14 Oct 2025 16:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E5=8C=85=E6=94=B6=E8=97=8F=E6=88=BF?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/User.php | 9 +++++++++ application/api/model/User.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 175f331..43da592 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -234,6 +234,15 @@ class User extends BaseCom return V($reslut['code'], $reslut['msg'], $reslut['data']); } + //关注房间(红包专用) + public function follow_room() + { + $room_id = input('room_id', 0); + $type = input('type', 1);//1-收藏,0-取消收藏 + $reslut = model('user')->follow_room($this->uid, $room_id,$type); + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + //用户关系卡(亲密拍)、关系位(真爱拍) public function user_cp_list() { diff --git a/application/api/model/User.php b/application/api/model/User.php index a995a28..8169c1b 100644 --- a/application/api/model/User.php +++ b/application/api/model/User.php @@ -841,6 +841,35 @@ class User extends Model } + //关注房间(红包专用) + public function follow_room($user_id,$room_id,$type){ + if(empty($room_id)){ + return ['code' => 0, 'msg' => '房间ID不能为空', 'data' => null]; + } + if($type == 0){ + //取消关注 + $re = db::name('user_follow')->where(['user_id' => $user_id,'follow_id' => $room_id,'type' => 2])->delete(); + if(!$re){ + return ['code' => 0, 'msg' => '取消关注失败', 'data' => null]; + } + return ['code' => 1, 'msg' => '取消关注成功', 'data' => null]; + }else{ + //关注 + $data = [ + 'user_id' => $user_id, + 'follow_id' => $room_id, + 'type' => 2, + 'createtime' => time() + ]; + $re = db::name('user_follow')->insert($data); + if(!$re){ + return ['code' => 0, 'msg' => '关注失败', 'data' => null]; + } + return ['code' => 1, 'msg' => '关注成功', 'data' => null]; + } + } + + //更新用户ip public function update_user_ip($user_id,$ip){ //判断$ip是否是汉字