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.
69 lines
2.2 KiB
69 lines
2.2 KiB
<?php
|
|
|
|
|
|
namespace app\admin\logic\content;
|
|
|
|
|
|
use app\common\basics\Logic;
|
|
use app\common\model\content\Help;
|
|
use app\common\model\content\Resource;
|
|
use app\common\model\user\UserResource;
|
|
use app\common\server\AreaServer;
|
|
use app\common\server\UrlServer;
|
|
use Exception;
|
|
|
|
class ResourceDownloadLogic extends Logic
|
|
{
|
|
/**
|
|
* 获取分类
|
|
* @param $get
|
|
* @return array
|
|
*/
|
|
public static function lists($get)
|
|
{
|
|
try {
|
|
$where = [
|
|
['a.type', '=', 0]
|
|
];
|
|
|
|
if (!empty($get['title']) and $get['title'])
|
|
$where[] = ['c.title', 'like', '%'.$get['title'].'%'];
|
|
|
|
if (!empty($get['cid']) and is_numeric($get['cid']))
|
|
$where[] = ['c.cid', '=', $get['cid']];
|
|
|
|
|
|
$model = new UserResource();
|
|
$lists = $model->field('c.*,a.create_time as download_time,b.nickname,b.avatar,b.mobile,d.name as cname')
|
|
->alias('a')
|
|
->join('user b','a.user_id=b.id','LEFT')
|
|
->join('resource c','a.resource_id=c.id','LEFT')
|
|
->join('resource_category d','c.cid=d.id','LEFT')
|
|
->where($where)
|
|
->order('a.create_time', 'desc')
|
|
->paginate([
|
|
'page' => $get['page'],
|
|
'list_rows' => $get['limit'],
|
|
'var_page' => 'page'
|
|
])
|
|
->toArray();
|
|
|
|
foreach ($lists['data'] as &$item) {
|
|
$item['category'] = $item['cname'] ?? '未知';
|
|
$item['is_show'] = $item['is_show'] ? '显示' : '隐藏';
|
|
$item['path'] = $item['path']?UrlServer::getFileUrl($item['path']):'';
|
|
$item['path_name']= $item['path']?substr($item['path'],strrpos($item['path'],"/")+1):'';
|
|
$item['address'] = $item['province_id']?AreaServer::getAddress([
|
|
$item['province_id'],
|
|
$item['city_id'],
|
|
$item['district_id']]):'';
|
|
|
|
}
|
|
|
|
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
|
|
} catch (Exception $e) {
|
|
return ['error'=>$e->getMessage()];
|
|
}
|
|
}
|
|
|
|
}
|