作者 xwp
1 个管道 的构建 通过 耗费 11 秒

后台修改

... ... @@ -36,6 +36,52 @@ class User extends Backend
}
/**
* 添加
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validate($validate);
}
$params['status'] = 'normal';
$params['is_default'] = false;
$user = $this->model->where(['mobile'=>$params['mobile'],'is_default'=>true])->find();
if(empty($user)){
$params['is_default'] = true;
}else{
if(empty($user['username']) || empty($user['nickname'])){
$params['is_default'] = true;
}
}
$result = $this->model->allowField(true)->insert($params,false,true);
if ($result !== false) {
$this->success();
} else {
$this->error($this->model->getError());
}
} catch (\think\exception\PDOException $e) {
$this->error($e->getMessage());
} catch (\think\Exception $e) {
$this->error($e->getMessage());
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
return $this->view->fetch();
}
/**
* 查看
*/
public function index()
... ...