Group.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\GroupLogic;
  4. use app\BaseController;
  5. use app\model\CommonModel;
  6. use think\exception\ValidateException;
  7. use think\facade\Config;
  8. use think\facade\Validate;
  9. //【企业和卡类型组合】
  10. class Group extends BaseController
  11. {
  12. //列表
  13. public function list()
  14. {
  15. $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => '', 'company_title' => '', 'card_title' => '', 'combination' => ''], 'post');
  16. return GroupLogic::list($param);
  17. }
  18. //添加
  19. public function add()
  20. {
  21. $param = $this->request->only(['company_id', 'card_id', 'remark' => ''], 'post');
  22. $val = Validate::rule(Config::get('validate_rules.GroupAdd'));
  23. if (!$val->check($param)) throw new ValidateException($val->getError());
  24. return GroupLogic::add($param);
  25. }
  26. //详情
  27. public function read()
  28. {
  29. $id = $this->request->post('id/d', 0);
  30. return GroupLogic::read($id);
  31. }
  32. //编辑
  33. public function edit()
  34. {
  35. $param = $this->request->only(['id', 'company_id', 'card_id', 'remark' => ''], 'post');
  36. $val = Validate::rule(array_merge(Config::get('validate_rules.GroupAdd'), ['id|分组id' => 'require|number|gt:0']));
  37. if (!$val->check($param)) throw new ValidateException($val->getError());
  38. return GroupLogic::edit($param);
  39. }
  40. //启禁用
  41. public function status()
  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 GroupLogic::status($param);
  47. }
  48. //删除
  49. public function delete()
  50. {
  51. $ids = $this->request->post('id/a', []);
  52. return GroupLogic::delete($ids);
  53. }
  54. }