123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\CompanyLogic;
- use app\BaseController;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //企业
- class Company extends BaseController
- {
- //获取企业列表
- public function List()
- {
- $param = $this->request->only([
- 'page' => 1,
- 'size' => 10,
- 'title' => '',
- 'contacts' => '',
- 'mobile' => '',
- 'status' => '',
- ], 'post');
- return CompanyLogic::List($param);
- }
- //添加企业
- public function Add()
- {
- $param = $this->request->only(['title', 'contacts', 'mobile', 'remark' => '',], 'post');
- $val = Validate::rule(Config::get('validate_rules.CompanyAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return CompanyLogic::Add($param);
- }
- //读取企业详情
- public function Read()
- {
- $id = $this->request->post('id/d', 0);
- return CompanyLogic::Read($id);
- }
- //编辑企业
- public function Edit()
- {
- $param = $this->request->only(['id', 'title', 'contacts', 'mobile', 'remark' => '',], 'post');
- $val = Validate::rule(array_merge(Config::get('validate_rules.CompanyAdd'), ['id' => 'require|number|gt:0']));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return CompanyLogic::Edit($param);
- }
- //企业启禁用
- public function Change()
- {
- $param = $this->request->only(['id', 'status'], 'post');
- $val = Validate::rule(Config::get('validate_rules.status'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return CompanyLogic::Change($param);
- }
- //删除企业
- public function Delete()
- {
- $id = $this->request->post('id/d', 0);
- return CompanyLogic::Delete($id);
- }
- }
|