<?php
namespace app\myadmin\model;
use think\Model;
use think\facade\Session;
class Files extends Model
{
protected $autoWriteTimestamp = true;
protected $createTime = "create_time";
protected $updateTime = "update_time";
public function index($Data)
{
$where=[];
if(Session::get("cateId")!=1){
$where["adminId"]=Session::get("adminId");
}
$cur_page = intval($Data["page"])-1; $count=$this->where($where)->count();
$info=$this->where($where)->limit(($cur_page*$Data["limit"]),$Data["limit"])->order("id asc")
->alias("a")
->leftJoin("admin b","b.id = a.adminId")
->field("a.*,b.nickname")
->select();
if($info){
return ["code"=>0,"msg"=>"获取成功","data"=>$info,"count"=>$count];
}else{
return ["code"=>1,"msg"=>"暂无内容"];
}
}
public function del($Int)
{
$Int_more=explode(",",$Int);
foreach($Int_more as $k=>$v){
$topic = $this->where("id",$v)->value("topic");
if(file_exists($topic)) {
@unlink($topic);
}
}
$info=$this->destroy($Int);
if ($info) {
return ["code"=>0,"msg"=>"成功"];
} else {
return ["code"=>1,"msg"=>"失败"];
}
}
}