Security.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\shop\controller\supplier;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\supplier\ServiceSecurity as ServiceSecurityModel;
  5. /**
  6. * 服务管理控制器
  7. */
  8. class Security extends Controller
  9. {
  10. /**
  11. * 获取列表
  12. */
  13. public function index()
  14. {
  15. // 列表
  16. $model = new ServiceSecurityModel;
  17. $category = $model->getAll();
  18. return $this->renderSuccess('', compact('category'));
  19. }
  20. /**
  21. * 添加
  22. */
  23. public function add()
  24. {
  25. $model = new ServiceSecurityModel;
  26. // 新增记录
  27. if ($model->add($this->postData())) {
  28. return $this->renderSuccess('添加成功');
  29. }
  30. return $this->renderError($model->getError() ?: '添加失败');
  31. }
  32. /**
  33. * 编辑
  34. */
  35. public function edit($service_security_id)
  36. {
  37. // 分类详情
  38. $model = ServiceSecurityModel::detail($service_security_id);
  39. // 更新记录
  40. if ($model->edit($this->postData())) {
  41. return $this->renderSuccess('更新成功');
  42. }
  43. return $this->renderError($model->getError() ?: '更新失败');
  44. }
  45. /**
  46. * 删除
  47. */
  48. public function delete($service_security_id)
  49. {
  50. $model = ServiceSecurityModel::detail($service_security_id);
  51. if (!$model->remove()) {
  52. return $this->renderError('该服务使用中,删除失败');
  53. }
  54. return $this->renderSuccess('删除成功');
  55. }
  56. }