|
|
@@ -11,4 +11,42 @@ use think\Model;
|
|
|
class ContractComment extends Model
|
|
|
{
|
|
|
//
|
|
|
+ /**
|
|
|
+ * 评论列表
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
+ public function getCommentList($post)
|
|
|
+ {
|
|
|
+ $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
|
|
|
+ $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"];
|
|
|
+ $where=[];
|
|
|
+// if(isset($post["status"]) && in_array((string)$post["status"], ["0","1"])){
|
|
|
+// $where[]=["status","=",(int)$post["status"]];
|
|
|
+// }
|
|
|
+ if(!empty($post["uid"])&&$post["uid"]>0){
|
|
|
+ $where[]=["uid","=",$post["uid"]];
|
|
|
+ }
|
|
|
+ if(!empty($post["to_uid"])&&$post["to_uid"]>0){
|
|
|
+ $where[]=["to_uid","=",$post["to_uid"]];
|
|
|
+ }
|
|
|
+ $totalCount = $this->where($where)->count();
|
|
|
+ $data=null;
|
|
|
+ if($totalCount>0){
|
|
|
+ $data = $this
|
|
|
+// ->field($field)
|
|
|
+ ->where($where)
|
|
|
+ ->order("create_time", "desc")
|
|
|
+ ->page($post["page"], $post["pageSize"])
|
|
|
+ ->select();
|
|
|
+ if(!empty($data)){
|
|
|
+ $data = $data->toArray();
|
|
|
+ foreach ($data as $k => $v){
|
|
|
+ $data[$k]["uid_nickname"] = (new User())->where("id", $v["uid"])->value("nickname");
|
|
|
+ $data[$k]["avatar"] = (new User())->where("id", $v["uid"])->value("avatar");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data = empty($data)?[]:$data;
|
|
|
+ return ["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount];
|
|
|
+ }
|
|
|
}
|