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.
80 lines
1.8 KiB
80 lines
1.8 KiB
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\api\model;
|
|
|
|
use app\Request;
|
|
use think\facade\Db;
|
|
use think\Model;
|
|
|
|
/**
|
|
* @mixin think\Model
|
|
*/
|
|
class AdData extends Common
|
|
{
|
|
|
|
protected $table = 'bmz_ad_data';
|
|
protected $_data_table = 'ad_data';
|
|
/**
|
|
* 管理员列表数据模型
|
|
* @return array|\think\Collection
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function index()
|
|
{
|
|
|
|
$this->search_arr = ['name'];
|
|
|
|
$ad_id = $this->request->param('ad_id', 0);
|
|
$_op = $this->field('*');
|
|
|
|
if($ad_id){
|
|
$_op = $this->where('ad_id',$ad_id);
|
|
}
|
|
|
|
//执行通用查询
|
|
return parent::parentLists($_op);
|
|
}
|
|
|
|
|
|
/**
|
|
* 读取后
|
|
* @param Model $model
|
|
* @return bool|void
|
|
*/
|
|
public static function onAfterRead(Model $model)
|
|
{
|
|
if (in_array(request()->action(), ['edit', 'delete', 'status'])) {
|
|
return true;
|
|
}
|
|
|
|
if($model->getAttr('start_time') && $model->getAttr('end_time')){
|
|
$model->setAttr('datetime', [date('Y-m-d',$model->getAttr('start_time')),date('Y-m-d',$model->getAttr('end_time'))]);
|
|
}
|
|
|
|
|
|
//成时间戳转化时间字符串
|
|
$model->setAttr('end_time', date('Y-m-d H:i:s',$model->getAttr('end_time')));
|
|
$model->setAttr('start_time', date('Y-m-d H:i:s',$model->getAttr('start_time')));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 新增或修改前
|
|
* @param Model $model
|
|
* @return mixed|void
|
|
*/
|
|
// public static function onBeforeWrite(Model $model)
|
|
// {
|
|
// if (!in_array(request()->action(), ['add', 'edit','dataEdit','dataAdd'])) {
|
|
// return;
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
|
|
}
|
|
|