Theme.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\ThemeLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. //手机主题
  9. class Theme extends BaseController
  10. {
  11. //列表
  12. public function list()
  13. {
  14. $param = $this->request->only(['page' => 1, 'size' => 10, 'company_title' => '', 'card_title' => '', 'status' => ''], 'post');
  15. return ThemeLogic::list($param);
  16. }
  17. //添加
  18. public function add()
  19. {
  20. $param = $this->request->only([
  21. 'group_id',
  22. 'code',
  23. 'modular',
  24. ], 'post');
  25. $val = Validate::rule(Config::get('validate_rules.ThemeAdd'));
  26. if (!$val->check($param)) throw new ValidateException($val->getError());
  27. return ThemeLogic::add($param);
  28. }
  29. //详情
  30. public function read()
  31. {
  32. $id = $this->request->post('id/d', 0);
  33. return ThemeLogic::read($id);
  34. }
  35. //修改
  36. public function edit()
  37. {
  38. $param = $this->request->only([
  39. 'id',
  40. 'group_id',
  41. 'code',
  42. 'modular',
  43. ], 'post');
  44. $val = Validate::rule(array_merge(Config::get('validate_rules.ThemeAdd'), ['id|主题id' => 'require|number|gt:0']));
  45. if (!$val->check($param)) throw new ValidateException($val->getError());
  46. return ThemeLogic::edit($param);
  47. }
  48. //启禁用
  49. public function status()
  50. {
  51. $param = $this->request->only(['id', 'status'], 'post');
  52. $val = Validate::rule(Config::get('validate_rules.status'));
  53. if (!$val->check($param)) throw new ValidateException($val->getError());
  54. return ThemeLogic::status($param);
  55. }
  56. }