Card.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Add()
  20. {
  21. $param = $this->request->only(['title'], 'post');
  22. $val = Validate::rule(Config::get('validate_rules.cardAdd'));
  23. if (!$val->check($param)) throw new ValidateException($val->getError());
  24. return CardLogic::Add($param);
  25. }
  26. //获取卡类型详情
  27. public function Read()
  28. {
  29. $id = $this->request->post('id/d',0);
  30. return CardLogic::Read($id);
  31. }
  32. //编辑卡类型
  33. public function Edit()
  34. {
  35. $param = $this->request->only(['id','title'], 'post');
  36. $val = Validate::rule(Config::get('validate_rules.cardEdit'));
  37. if (!$val->check($param)) throw new ValidateException($val->getError());
  38. return CardLogic::Edit($param);
  39. }
  40. //卡类型启禁用
  41. public function Change()
  42. {
  43. $param = $this->request->only(['id','status'], 'post');
  44. $val = Validate::rule(Config::get('validate_rules.status'));
  45. if (!$val->check($param)) throw new ValidateException($val->getError());
  46. return CardLogic::Change($param);
  47. }
  48. //删除卡类型
  49. public function Delete()
  50. {
  51. $id = $this->request->post('id/d',0);
  52. return CardLogic::Delete($id);
  53. }
  54. }