123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace app\admin\controller\home;
- use app\admin\controller\BaseController;
- use app\admin\server\home\HomeGoodsServer;
- class HomeGoods extends BaseController
- {
- /**
- * Notes:获取项目列表
- * @return \support\Response
- * User: YCP
- * Date: 2022/10/31
- */
- public function getGoodsList()
- {
- [$page, $limit] = $this->getPage();
- $keywords = $this->request->get('keywords');
- $category_id = $this->request->get('category_id');//分类id
- $result = HomeGoodsServer::getGoodsList($page,$limit,$keywords,$category_id);
- return json_success($result, '成功');
- }
- /**
- * Notes:修改项目
- * @return \support\Response
- * User: YCP
- * Date: 2022/10/31
- */
- public function updateGoods()
- {
- $params = $this->request->post();
- $admin_id = $this->request->admin_id;
- $this->validateCheck('home\HomeGoodsValidate',
- [
- 'goods_id' => $params['goods_id']?? '',
- 'goods_category_id' => $params['goods_category_id']?? '',
- 'goods_name' => $params['goods_name']?? '',
- 'goods_img' => $params['goods_img']?? '',
- 'goods_mobile' => $params['goods_mobile']?? '',
- ],
- 'update');
- $result = HomeGoodsServer::updateGoods($params, $admin_id);
- return json_success($result, '修改成功');
- }
- /**
- * Notes:删除项目
- * @return \support\Response
- * User: YCP
- * Date: 2022/10/31
- */
- public function delGoods()
- {
- $goods_id = $this->request->get('goods_id');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('home\HomeGoodsValidate', ['goods_id' => $goods_id], 'info');
- $result = HomeGoodsServer::delGoods($goods_id,$admin_id);
- if ($result){
- return json_success($result, '删除成功');
- }else{
- throw new \Exception('删除失败!');
- }
- }
- /**
- * Notes:添加项目
- * @return \support\Response
- * User: YCP
- * Date: 2022/10/31
- */
- public function addGoods()
- {
-
- $params = $this->request->post();
- $admin_id = $this->request->admin_id;
- $this->validateCheck('home\HomeGoodsValidate',
- [
- 'goods_category_id' => $params['goods_category_id']?? '',
- 'goods_name' => $params['goods_name']?? '',
- 'goods_img' => $params['goods_img']?? '',
- 'goods_mobile' => $params['goods_mobile']?? '',
- ],
- 'create');
- $result = HomeGoodsServer::insertGoods($params, $admin_id);
- return json_success($result, '添加成功');
- }
- /**
- * Notes:查询项目详情
- * @return \support\Response
- * User: YCP
- * Date: 2022/10/31
- */
- public function goodsInfo()
- {
- $goods_id = $this->request->get('goods_id');
- $this->validateCheck('home\HomeGoodsValidate', ['goods_id' => $goods_id], 'info');
- $result = HomeGoodsServer::goodsInfo($goods_id);
- return json_success($result, '成功');
- }
- }
|