You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
<?php
|
|
|
|
namespace app\enterprise\model;
|
|
|
|
use think\Model;
|
|
|
|
class Comment extends Model
|
|
{
|
|
|
|
public static function getPostsComment($relevance_id, $uid, $userIdArr = [])
|
|
{
|
|
$reply_user = $userIdArr;
|
|
$reply_user[] = 0;
|
|
$playWhere = " type = 1 and delete_time = 0 and relevance_id = {$relevance_id}";
|
|
$playWhere .= " and ( ";
|
|
$playWhere .= " reply_user_id in (".implode(",", $reply_user).")";
|
|
if (!empty($userIdArr)) {
|
|
$playWhere .= " or user_id in (".implode(",",$userIdArr).")";
|
|
}
|
|
$playWhere .= " )";
|
|
$comment = self::where($playWhere)->field('id,content,user_id,reply_user_id')->select();
|
|
foreach ($comment as &$commentValue) {
|
|
$commentValue = self::dataOption($commentValue,$uid);
|
|
}
|
|
return $comment;
|
|
}
|
|
|
|
public static function dataOption($commentValue,$uid)
|
|
{
|
|
$friend = Friend::getFriendName($uid, $commentValue['user_id']);
|
|
$commentValue['nickname'] = $friend['nickname'];
|
|
|
|
$commentValue['reply_user_name'] = '';
|
|
if ($commentValue['reply_user_id']) {
|
|
$friend = Friend::getFriendName($uid, $commentValue['reply_user_id']);
|
|
$commentValue['reply_user_name'] = $friend['nickname'];
|
|
}
|
|
|
|
unset($commentValue['reply_user_id']);
|
|
return $commentValue;
|
|
}
|
|
|
|
}
|