<?php
|
|
namespace app\branch\model\activity;
|
|
use app\common\model\branch\ActivityFile as ActivityFileModel;
|
|
/**
|
* 活动文件模型
|
*/
|
class ActivityFile extends ActivityFileModel
|
{
|
/**
|
* 获取列表
|
*/
|
public function getList($params, $type, $activity_id)
|
{
|
$model = $this->alias('A')
|
->join('upload_file B', 'A.file_id=B.file_id', 'left')
|
->field('A.file_id,A.create_time,B.real_name')
|
->with(['file']);
|
if (!empty($params['keyword'])) {
|
$model = $model->where('B.real_name', 'like', '%'. $params['keyword'] .'%');
|
}
|
return $model->where('activity_id', '=', $activity_id)
|
->where('A.file_type', '=', $type)
|
->where('A.is_delete', '=', 0)
|
->order(['A.create_time' => 'desc'])
|
->paginate($params);
|
|
}
|
|
/**
|
* 新增记录
|
*/
|
public function add($data)
|
{
|
foreach ($data as &$item) {
|
$item['app_id'] = self::$app_id;
|
}
|
return $this->saveAll($data);
|
}
|
|
/**
|
* 删除
|
*/
|
public function setDelete($fileIds)
|
{
|
// return $this->save(['is_delete' => 1]);
|
return $this->where('file_id', 'in', $fileIds)->update(['is_delete' => 1]);
|
}
|
|
/**
|
* 获取活动文件总数量
|
*/
|
public static function getActivityFileTotal($where)
|
{
|
$model = new static;
|
return $model->where($where)->where('is_delete', '=', 0)->count();
|
}
|
}
|