Card.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\CardLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. class Card extends BaseController
  9. {
  10. //获取卡类型列表
  11. public function list()
  12. {
  13. $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => '', 'title' => '',], 'post');
  14. $val = Validate::rule(Config::get('validate_rules.common'));
  15. if (!$val->check($param)) throw new ValidateException($val->getError());
  16. return CardLogic::list($param);
  17. }
  18. //获取全部卡类型
  19. public function all()
  20. {
  21. $keyword = $this->request->post('keyword', '');
  22. return CardLogic::all($keyword);
  23. }
  24. //添加卡类型
  25. public function add()
  26. {
  27. $param = $this->request->only(['title'], 'post');
  28. $val = Validate::rule(Config::get('validate_rules.cardAdd'));
  29. if (!$val->check($param)) throw new ValidateException($val->getError());
  30. return CardLogic::add($param);
  31. }
  32. //获取卡类型详情
  33. public function read()
  34. {
  35. $id = $this->request->post('id/d', 0);
  36. return CardLogic::read($id);
  37. }
  38. //编辑卡类型
  39. public function edit()
  40. {
  41. $param = $this->request->only(['id', 'title'], 'post');
  42. $val = Validate::rule(Config::get('validate_rules.cardEdit'));
  43. if (!$val->check($param)) throw new ValidateException($val->getError());
  44. return CardLogic::edit($param);
  45. }
  46. //卡类型启禁用
  47. public function change()
  48. {
  49. $param = $this->request->only(['id', 'status'], 'post');
  50. $val = Validate::rule(Config::get('validate_rules.status'));
  51. if (!$val->check($param)) throw new ValidateException($val->getError());
  52. return CardLogic::change($param);
  53. }
  54. //删除卡类型
  55. public function delete()
  56. {
  57. $id = $this->request->post('id/d', 0);
  58. return CardLogic::delete($id);
  59. }
  60. }