Company.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\CompanyLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. //企业
  9. class Company extends BaseController
  10. {
  11. //获取企业列表
  12. public function List()
  13. {
  14. $param = $this->request->only([
  15. 'page' => 1,
  16. 'size' => 10,
  17. 'title' => '',
  18. 'contacts' => '',
  19. 'mobile' => '',
  20. 'status' => '',
  21. ], 'post');
  22. return CompanyLogic::List($param);
  23. }
  24. //添加企业
  25. public function Add()
  26. {
  27. $param = $this->request->only(['title', 'contacts', 'mobile', 'remark' => '',], 'post');
  28. $val = Validate::rule(Config::get('validate_rules.CompanyAdd'));
  29. if (!$val->check($param)) throw new ValidateException($val->getError());
  30. return CompanyLogic::Add($param);
  31. }
  32. //读取企业详情
  33. public function Read()
  34. {
  35. $id = $this->request->post('id/d', 0);
  36. return CompanyLogic::Read($id);
  37. }
  38. //编辑企业
  39. public function Edit()
  40. {
  41. $param = $this->request->only(['id', 'title', 'contacts', 'mobile', 'remark' => '',], 'post');
  42. $val = Validate::rule(array_merge(Config::get('validate_rules.CompanyAdd'), ['id' => 'require|number|gt:0']));
  43. if (!$val->check($param)) throw new ValidateException($val->getError());
  44. return CompanyLogic::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 CompanyLogic::Change($param);
  53. }
  54. //删除企业
  55. public function Delete()
  56. {
  57. $id = $this->request->post('id/d', 0);
  58. return CompanyLogic::Delete($id);
  59. }
  60. }