Commit ae5885e6 by 肖康
parents c649a8f6 809dcce0
Showing with 10 additions and 2 deletions
......@@ -187,11 +187,18 @@ Class AjaxController extends Controller
$data['attribute'] = $attribute;
$count = TemplateListModel::where("template_name",trim($data['template_name']))
->where(function($q) use($request){
$q->where(["create_userid"=>$request->user->userId])->orWhere(["create_userid"=>1000]);
})->count("id");
if($count){
return $this->ajaxReturn(-1,"模板名称已经存在,请修改模板名称再提交!");
}
try{
DB::Connection("label")->transaction(function () use($data,$request) {
//创建模板
$templateList = TemplateListModel::create([
"template_name"=>$data['$template_name'],
"template_name"=>trim($data['template_name']),
"create_userid"=>$request->user->userId,
"create_username"=>$request->user->name,
"create_time"=>time(),
......@@ -210,8 +217,9 @@ Class AjaxController extends Controller
throw new \Exception("添加模板失败",-1);
}
});
return $this->ajaxReturn(0,"添加模板成功");
}catch(\Exception $e){
return $this->ajaxReturn(-1,"添加模板失败");
return $this->ajaxReturn(-1,$e->getMessage());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment