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.
93 lines
3.4 KiB
93 lines
3.4 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\wap\model\material;
|
|
|
|
use think\Db;
|
|
use traits\ModelTrait;
|
|
use basic\ModelBasic;
|
|
use app\wap\model\material\DataDownloadCategpry;
|
|
|
|
/**资料 model
|
|
* Class DataDownload
|
|
* @package app\wap\model\material
|
|
*/
|
|
class DataDownload extends ModelBasic
|
|
{
|
|
use ModelTrait;
|
|
|
|
public static function PreWhere($alias = '', $model = null)
|
|
{
|
|
if (is_null($model)) $model = new self();
|
|
if ($alias) {
|
|
$model = $model->alias($alias);
|
|
$alias .= '.';
|
|
}
|
|
return $model->where([$alias . 'is_show' => 1, $alias . 'status' => 1, $alias . 'is_del' => 0]);
|
|
}
|
|
|
|
/**列表
|
|
* @param int $page
|
|
* @param int $limit
|
|
* @param $tid
|
|
* @return array
|
|
*/
|
|
public static function getDataDownloadExercisesList($page, $limit, $pid, $cate_id, $search)
|
|
{
|
|
$model = self::PreWhere();
|
|
if ($cate_id) {
|
|
$model = $model->where(['cate_id' => $cate_id]);
|
|
} else if ($pid && !$cate_id) {
|
|
$cate_ids = DataDownloadCategpry::where('pid', $pid)->column('id');
|
|
$model = $model->where('cate_id', 'in', $cate_ids);
|
|
}
|
|
if ($search) $model = $model->where('title', 'LIKE', "%$search%");
|
|
$list = $model->order('sort desc,id desc')->page($page, $limit)->select();
|
|
$list = count($list) ? $list->toArray() : [];
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* 获取单个资料的详细信息
|
|
* @param $uid 用户id
|
|
* @param $id 资料id
|
|
* */
|
|
public static function getOneDataDownload($uid, $id)
|
|
{
|
|
$data = self::PreWhere()->find($id);
|
|
if (!$data) return self::setErrorInfo('您要查看的资料不存在!');
|
|
if ($data->is_show == 0) return self::setErrorInfo('您要查看的资料已下架!');
|
|
$title = $data->title;
|
|
$data->collect = self::getDb('special_relation')->where(['link_id' => $id, 'type' => 1, 'uid' => $uid, 'category' => 1])->count() ? true : false;
|
|
$data->abstract = htmlspecialchars_decode($data->abstract);
|
|
$data = json_encode($data->toArray());
|
|
return compact('data', 'title');
|
|
}
|
|
|
|
/**讲师名下资料
|
|
* @param $mer_id
|
|
* @param $page
|
|
* @param $limit
|
|
*/
|
|
public static function getLecturerDataDownloadList($mer_id, $page, $limit,$institution = 0)
|
|
{
|
|
if ($mer_id) {
|
|
$model = self::PreWhere();
|
|
$model = $model->where('mer_id' ,'in', $mer_id)->where('institution_id',$institution)->order('sort desc,id desc');
|
|
$list = $model->page($page, $limit)->select();
|
|
$list = count($list) ? $list->toArray() : [];
|
|
} else {
|
|
$list = [];
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
}
|
|
|