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.
164 lines
4.1 KiB
164 lines
4.1 KiB
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\api\model;
|
|
|
|
use think\Model;
|
|
|
|
|
|
/**
|
|
* @mixin think\Model
|
|
*/
|
|
class UploadLog extends Common
|
|
{
|
|
|
|
public $table = 'system_upload_log';
|
|
|
|
/**
|
|
* 上传日志数据模型
|
|
* @return array|\think\Collection
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function index()
|
|
{
|
|
$current = $this->request->param('current', '/');
|
|
|
|
$direct = $this->request->param('direct', 0);
|
|
|
|
$dic_arr = [
|
|
'host',
|
|
'y',
|
|
'date',
|
|
// 'd',
|
|
'url',
|
|
];
|
|
|
|
$current_arr = explode('/',$current);
|
|
|
|
if($current == '/' || $current == ''){
|
|
$current_arr = [
|
|
'/'
|
|
];
|
|
}
|
|
$current_arr[0] = '/';
|
|
//向下层取数据
|
|
$field_name = $dic_arr[count($current_arr)-1];
|
|
|
|
|
|
if($field_name == 'url'){
|
|
$field_str = $field_name.',name,type,size ,0 as isDirectory,update_time,id';
|
|
}else{
|
|
$field_str = $field_name.' as name ,1 as isDirectory';
|
|
}
|
|
|
|
$conition = [];
|
|
|
|
|
|
$current_arr_1 = $current_arr;
|
|
if(count($current_arr_1)>1){
|
|
unset($current_arr_1[count($current_arr_1)-1]);
|
|
$current_arr_1[0] = '';
|
|
}
|
|
$pre_current = implode('/',$current_arr_1);
|
|
|
|
$_op = $this->field($field_str);
|
|
//获取该id下的所有的域名
|
|
$siteModel = new Site();
|
|
$hosts_str = $siteModel->where('id',SITE_ID)->find();
|
|
$host_arr = [];
|
|
if($current == '' || $current == '/'){
|
|
if($hosts_str['host']){
|
|
$host_arr = explode(',',$hosts_str['host']);
|
|
}
|
|
if(count($host_arr)==0){
|
|
$host_arr[] = $_SERVER['host'];
|
|
}
|
|
$_op->whereIn('host',$host_arr);
|
|
}else{
|
|
$conition['host'] = $current_arr[1];
|
|
}
|
|
|
|
//年
|
|
if(isset($current_arr[2]) && $current_arr[2]!=''){
|
|
$conition['Y'] = $current_arr[2];
|
|
}
|
|
// //月
|
|
// if(isset($current_arr[3]) &&$current_arr[3]!='' ){
|
|
// $conition['m'] = $current_arr[3];
|
|
// }
|
|
// //日
|
|
// if(isset($current_arr[4]) && $current_arr[4]!=''){
|
|
// $conition['d'] = $current_arr[4];
|
|
// }
|
|
//日期
|
|
if(isset($current_arr[3]) && $current_arr[3]!=''){
|
|
$conition['date'] = $current_arr[3];
|
|
}
|
|
|
|
$_op->distinct(true);
|
|
$_op->where($conition);
|
|
|
|
$data = parent::parentLists(!empty($_op) ? $_op : '',1,0);
|
|
$count = $this->field($field_name)->where($conition)->group($field_name)->count();
|
|
|
|
$data['page_total'] = $count;
|
|
$returnData = [];
|
|
// $data['current'] = $current;
|
|
// $data['pre_current'] = $pre_current;
|
|
// $returnData['data'] = $data;
|
|
// $returnData['page_total'] = $data['page_total'];
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getLists(){
|
|
//执行通用查询
|
|
return parent::parentLists();
|
|
}
|
|
|
|
|
|
public function getStorgaeImagesLists(){
|
|
$type = $this->request->param('type', 0);
|
|
$_op = $this;
|
|
if($type){
|
|
$_op->where('type',$type);
|
|
}
|
|
|
|
|
|
//执行通用查询
|
|
return parent::parentLists();
|
|
}
|
|
|
|
/**
|
|
* 读取后
|
|
* @param Model $model
|
|
* @return bool|void
|
|
*/
|
|
public static function onAfterRead(Model $model)
|
|
{
|
|
if (in_array(request()->action(), ['edit', 'delete', 'status'])) {
|
|
return true;
|
|
}
|
|
$model->offsetSet('action_ip', long2ip((int)$model->getAttr('action_ip')));
|
|
}
|
|
|
|
/**
|
|
* 新增前
|
|
* @param Model $model
|
|
* @return mixed|void
|
|
*/
|
|
public static function onBeforeInsert(Model $model)
|
|
{
|
|
if (!in_array(request()->action(), ['add'])) {
|
|
return true;
|
|
}
|
|
//密码加密
|
|
$m = $model->getAttr('m');
|
|
$d = $model->getAttr('d');
|
|
$model->setAttr('date', $m.$d);
|
|
}
|
|
|
|
|
|
}
|
|
|