123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 划卡喜欢记录模型
- */
- class MatchLike extends Model
- {
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- /**
- * 获取喜欢列表
- */
- public function getVoiceUserList($user_id,$pageStart=1,$pageNum=10) {
- $where = [];
- $where["a.fans_id"] = $user_id;
- $list = $this->alias("a")
- ->field("a.id,a.user_id,a.fans_id,u.nickname,u.avatar,v.voice,v.voice_time,t.name as type_name")
- ->join("hx_user u","u.id = a.user_id","left")
- ->join("hx_match_voice v","v.user_id = a.user_id","left")
- ->join("hx_match_type t","t.id = v.type_id","left")
- ->where($where)
- ->limit($pageStart,$pageNum)
- ->select();
- if(!$list) return [];
- foreach($list as $k => &$v) {
- $v["voice"] || $v["voice"] = "";
- $v["voice_time"] || $v["voice_time"] = 0;
- $v["type_name"] || $v["type_name"] = "";
- }
- return $list;
- }
- /**
- * 获取喜欢列表
- */
- public function getVoiceFansList($user_id,$pageStart=1,$pageNum=10) {
- $where = [];
- $where["a.user_id"] = $user_id;
- $list = $this->alias("a")
- ->field("a.id,a.fans_id as user_id,u.nickname,u.avatar,v.voice,v.voice_time,t.name as type_name")
- ->join("hx_user u","u.id = a.fans_id","left")
- ->join("hx_match_voice v","v.user_id = a.fans_id","left")
- ->join("hx_match_type t","t.id = v.type_id","left")
- ->where($where)
- ->limit($pageStart,$pageNum)
- ->select();
- if(!$list) return [];
- foreach($list as $k => &$v) {
- $v["voice"] || $v["voice"] = "";
- $v["voice_time"] || $v["voice_time"] = 0;
- $v["type_name"] || $v["type_name"] = "";
- }
- return $list;
- }
- }
|