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.
88 lines
2.2 KiB
88 lines
2.2 KiB
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\api\model;
|
|
|
|
use app\Request;
|
|
use think\facade\Db;
|
|
use think\Model;
|
|
|
|
/**
|
|
* @mixin think\Model
|
|
*/
|
|
class Column extends Common
|
|
{
|
|
|
|
/**
|
|
* 管理员列表数据模型
|
|
* @return array|\think\Collection
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function index()
|
|
{
|
|
$username = $this->request->param('username', '');
|
|
$sex = $this->request->param('sex', '', 'intval');
|
|
$truename = $this->request->param('truename', '');
|
|
$_op = $this->where('site_id', SITE_ID); //没有默认where查询 这个一定要 否则获取不到下面的getOptions查询条件值
|
|
if ($username) {
|
|
$_op->whereLike('username', "%{$username}%");
|
|
}
|
|
$data = parent::parentLists($_op);
|
|
|
|
//获取栏目类型
|
|
$_column_type = config('dictionary.sqlfields.column_type');
|
|
$_model = Db::name('model')->column('*', 'id');
|
|
$data_tmp = $data['data'];
|
|
|
|
array_walk($data_tmp, function (&$v) use ($_model, $_column_type) {
|
|
$v['model_name'] = $_model[$v['model_id']]['name'];
|
|
$v['column_type_name'] = $_column_type[$v['type']];
|
|
});
|
|
$data['data'] = $data_tmp;
|
|
// $data = tree($data);
|
|
return $data;
|
|
}
|
|
|
|
|
|
/**
|
|
* 读取后
|
|
* @param Model $model
|
|
* @return bool|void
|
|
*/
|
|
public static function onAfterRead(Model $model)
|
|
{
|
|
$model->setAttr('open', true);
|
|
}
|
|
|
|
/**
|
|
* 新增前
|
|
* @param Model $model
|
|
* @return mixed|void
|
|
*/
|
|
public static function onBeforeInsert(Model $model)
|
|
{
|
|
//code
|
|
}
|
|
|
|
/**
|
|
* 新增或修改前
|
|
* @param Model $model
|
|
* @return mixed|void
|
|
*/
|
|
public static function onBeforeWrite(Model $model)
|
|
{
|
|
|
|
}
|
|
|
|
public static function onAfterDelete(Model $model)
|
|
{
|
|
//删除父级栏目下所有子栏目
|
|
self::destroy(function ($query) use ($model) {
|
|
$query->where('child_list', 'like', $model->getAttr('child_list') . '%');
|
|
});
|
|
parent::onAfterDelete($model);
|
|
}
|
|
|
|
}
|
|
|