| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\api\controller;
- use app\api\service\CustomerService;
- use app\api\validate\AddCustomerValidate;
- use app\api\validate\LoginValidate;
- use app\common\model\CustomerModel;
- use app\Request;
- use think\App;
- class Customer extends \app\BaseController
- {
- private $service;
- public function __construct(App $app)
- {
- $this->service = new CustomerService();
- parent::__construct($app);
- }
- public function add(Request $request) {
- $params = (new AddCustomerValidate())->message([
- 'name_zh.require' => lang("The customer name_zh does not comply with the rule"),
- 'name_en.require' => lang("The customer name_en does not comply with the rule"),
- 'mobile.require' => lang("The mobile does not comply with the rule"),
- 'address.require' => lang("The address does not comply with the rule"),
- 'email.email' => lang("The email does not comply with the rule"),
- 'sex.require' => lang("The sex does not comply with the rule"),
- 'linkman.require' => lang("The linkman does not comply with the rule"),
- 'zue_coin.require' => lang("The zue_coin does not comply with the rule"),
- 'sun_calendar.require' => lang("The sun_calendar does not comply with the rule"),
- 'lunar_calendar.require' => lang("The lunar_calendar does not comply with the rule"),
- ])->requestBodyCheck($request);
- $res = $this->service->add($params);
- predicate($res->bool, $res->message);
- return $this->ok($res->data);
- }
- /**
- * @return \think\response\Json
- * @throws \app\exception\BaseException
- */
- public function getCustomer() {
- $params = $this->request->param();
- if(!isset($params['name']) && !isset($params['mobile']) && !isset($params['customer_id']))
- predicate(false, '搜索条件必须存在一个');
- $res = $this->service->getCustomer(
- isset($params['customer_id']) ? format_string($params['customer_id']) : null,
- isset($params['name']) ? format_string($params['name']) : null,
- isset($params['mobile']) ? format_string($params['mobile']) : null
- );
- predicate($res->bool, $res->message);
- return $this->ok($res->data);
- }
- }
|