123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\mobile\controller;
- //地址
- use app\BaseController;
- use app\mobile\logic\AddrLogic;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- class Addr extends BaseController
- {
- //列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10], 'post');
- return AddrLogic::list($param);
- }
- //添加
- public function add()
- {
- $param = $this->request->only(['addr_code', 'addr', 'contactor', 'mobile'], 'post');
- $val = Validate::rule(Config::get('validate_rules.AddrAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AddrLogic::add($param);
- }
- //详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return AddrLogic::read($id);
- }
- //修改
- public function edit()
- {
- $param = $this->request->only(['id', 'addr_code', 'addr', 'contactor', 'mobile'], 'post');
- $val = Validate::rule(array_merge(Config::get('validate_rules.AddrAdd'), ['id' => 'require|number|gt:0']));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return AddrLogic::edit($param);
- }
- //删除
- public function delete()
- {
- $id = $this->request->post('id/d', 0);
- return AddrLogic::delete($id);
- }
- }
|