123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\controller\goods;
-
-
- use app\admin\logic\goods\UnitLogic;
- use app\admin\validate\goods\UnitValidate;
- use app\common\basics\AdminBase;
- use app\common\model\goods\GoodsUnit as GoodsUnitModel;
- use app\common\server\JsonServer;
-
-
- class Unit extends AdminBase
- {
-
-
- public function lists()
- {
- if ($this->request->isAjax()) {
- $get = $this->request->get();
- return JsonServer::success('获取成功', UnitLogic::lists($get));
- }
- return view();
- }
-
-
-
-
- public function add()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- (new UnitValidate())->goCheck('add');
- if (UnitLogic::addUnit($post)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(UnitLogic::getError() ?: '操作失败');
- }
- return view();
- }
-
-
-
- public function edit()
- {
- $id = $this->request->get('unit_id');
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- (new UnitValidate())->goCheck('edit');
- if (UnitLogic::editUnit($post)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(UnitLogic::getError() ?: '操作失败');
- }
- return view('', ['detail' => GoodsUnitModel::find($id)]);
- }
-
-
-
- public function del()
- {
- if ($this->request->isAjax()) {
- $id = $this->request->post('id');
- (new UnitValidate())->goCheck('del');
- if (UnitLogic::del($id)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(UnitLogic::getError() ?: '操作失败');
- }
- }
- }
|