IndustryController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020-08-28
  6. * Time: 8:53
  7. */
  8. namespace app\back\controller;
  9. use app\back\model\IndustryModel;
  10. use cmf\controller\AdminBaseController;
  11. class IndustryController extends AdminBaseController
  12. {
  13. public function index()
  14. {
  15. $where = [];
  16. $list = IndustryModel::where($where)->order('list_order','asc')->select();
  17. $this->assign('list',$list);
  18. return $this->fetch();
  19. }
  20. public function add()
  21. {
  22. return $this->fetch();
  23. }
  24. public function addPost()
  25. {
  26. $data = $this->request->param();
  27. $industryModel = new IndustryModel();
  28. $industryModel->allowField(true)->isUpdate(false)->save($data);
  29. $this->success('添加成功');
  30. }
  31. public function edit()
  32. {
  33. $id = $this->request->param('id');
  34. $info = IndustryModel::get($id);
  35. $this->assign('info',$info);
  36. return $this->fetch();
  37. }
  38. public function editPost()
  39. {
  40. $data = $this->request->param();
  41. $industryModel = new IndustryModel();
  42. $industryModel->allowField(true)->isUpdate(true)->save($data);
  43. $this->success('编辑成功');
  44. }
  45. public function delete()
  46. {
  47. $id = $this->request->param('id');
  48. IndustryModel::destroy($id);
  49. $this->success('删除成功');
  50. }
  51. public function show()
  52. {
  53. $ids = $this->request->param('ids/a');
  54. $is_show = $this->request->param('is_show');
  55. IndustryModel::where('id','in',$ids)->update(['is_show'=>$is_show]);
  56. $this->success('操作成功');
  57. }
  58. public function listOrder()
  59. {
  60. $industryModel = new IndustryModel();
  61. parent::listOrders($industryModel);
  62. $this->success("排序更新成功!");
  63. }
  64. }