ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 控制器 ## 代码 ``` <?php namespace app\agent\controller; use think\Controller; class RbacController extends Controller { /** * 添加角色提交 */ public function roleAddPost() { if ($this->request->isPost()) { $data = $this->request->param(); $result = $this->validate($data, 'role'); if ($result !== true) { // 验证失败 输出错误信息 $this->error($result); } else { $result = Db::name('role')->insert($data); if ($result) { $this->success("添加角色成功", url("rbac/index")); } else { $this->error("添加角色失败"); } } } } } ```