コード例 #1
0
ファイル: CartController.php プロジェクト: AZ-WH/spirit
 public function getCartList(Request $request)
 {
     if (!$request->has('uid')) {
         return response()->json(Message::setResponseInfo('PARAMETER_ERROR'));
     }
     $page = $request->get('page', 1);
     $uid = $request->get('uid');
     $sid = 0;
     if ($request->has('sid')) {
         $sid = $request->get('sid');
     }
     $totalNum = $this->_model->getCartTolalNum($uid, $sid);
     $pagedata = $this->getPageData($page, $this->_length, $totalNum);
     $this->_response['page'] = $pagedata;
     if ($totalNum <= 0) {
         return response()->json(Message::setResponseInfo('DATA_EMPTY'));
     }
     $list = $this->_model->getCartList($uid, $sid, $pagedata->offset, $this->_length);
     if ($list) {
         $this->_response['cart'] = $list;
         return response()->json(Message::setResponseInfo('SUCCESS', $this->_response));
     } else {
         return response()->json(Message::setResponseInfo('FAILED'));
     }
 }
コード例 #2
0
ファイル: CategoryController.php プロジェクト: AZ-WH/spirit
 public function getList(Request $request)
 {
     $categoryList = $this->_model->getCategoryList();
     if (empty($categoryList)) {
         return response()->json(Message::setResponseInfo('DATA_EMPTY'));
     }
     $this->_response['category'] = $categoryList;
     return response()->json(Message::setResponseInfo('SUCCESS', $this->_response));
 }
コード例 #3
0
ファイル: UploadController.php プロジェクト: AZ-WH/spirit
 public function uploadImg(Request $request)
 {
     $filePath = '';
     if ($request->hasFile('cover')) {
         $destinationPath = './upload/';
         $filename = time() + mt_rand(1000, 9999);
         $exten = substr($request->file('cover')->getClientOriginalName(), strpos($request->file('cover')->getClientOriginalName(), '.') + 1);
         if ($request->file('cover')->isValid()) {
             if ($request->file('cover')->move($destinationPath, $filename . '.' . $exten)) {
                 $filePath = 'http://' . $_SERVER['SERVER_NAME'] . '/upload/' . $filename . '.' . $exten;
                 return response()->json(Message::setResponseInfo('SUCCESS', $filePath));
             }
         }
     }
     return response()->json(Message::setResponseInfo('FAILED'));
 }
コード例 #4
0
ファイル: GoodsController.php プロジェクト: AZ-WH/spirit
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getGoodsByDefultCategory(Request $request)
 {
     $page = 1;
     $category = new Category();
     $defaultCategory = $category->getDefaultCategory();
     if (!$defaultCategory) {
         return response()->json(Message::setResponseInfo('FAILED'));
     }
     $filter = array('category_id' => $defaultCategory->id);
     $goodsModel = new Goods();
     $totalNum = $goodsModel->getGoodsTotalNum($filter);
     $pagedata = $this->getPageData($page, $this->_length, $totalNum);
     $this->_data['page'] = $pagedata;
     if ($totalNum <= 0) {
         return response()->json(Message::setResponseInfo('SUCCESS', $this->_data));
     }
     $this->_data['goodsList'] = $goodsModel->getGoodsList($pagedata->offset, $this->_length, $filter);
     return response()->json(Message::setResponseInfo('SUCCESS', $this->_data));
 }
コード例 #5
0
ファイル: GoodsController.php プロジェクト: AZ-WH/spirit
 public function editGoods(Request $request)
 {
     if (!$request->has('gid')) {
         return response()->json(Message::setResponseInfo('PARAMETER_ERROR'));
     }
     $gid = $request->get('gid');
     $sqlData = array();
     if ($request->has('name')) {
         $sqlData['name'] = $request->get('name');
     }
     if ($request->has('o_price')) {
         $sqlData['o_price'] = $request->get('o_price');
     }
     if ($request->has('p_price')) {
         $sqlData['p_price'] = $request->get('p_price');
     }
     if ($request->has('c_id')) {
         $sqlData['c_id'] = $request->get('c_id');
     }
     if ($request->has('desc')) {
         $sqlData['desc'] = $request->get('desc');
     }
     if ($request->has('cover')) {
         $sqlData['cover'] = $request->get('cover');
     }
     if ($request->has('is_show')) {
         $request['is_show'] = $request->get('is_show');
     }
     if (empty($sqlData)) {
         return response()->json(Message::setResponseInfo('PARAMETER_ERROR'));
     }
     $sqlData['updated_at'] = date('Y-m-d H:i:s', time());
     if ($this->_model->editGoods($gid, $sqlData)) {
         return response()->json(Message::setResponseInfo('SUCCESS'));
     } else {
         return response()->json(Message::setResponseInfo('FAILED'));
     }
 }
コード例 #6
0
ファイル: ShopsController.php プロジェクト: AZ-WH/spirit
 public function addShopUser(Request $request)
 {
     $sid = 1;
     if (!$request->has('tel') || !$request->has('password') || !$request->has('name')) {
         return response()->json(Message::setResponseInfo('PARAMETER_ERROR'));
     }
     $tel = $request->get('tel');
     $salt = $this->getSalt();
     $password = sha1(md5($request->get('password')) . $salt);
     $sqlData = array('s_id' => 1, 'tel' => $tel, 'name' => $request->get('name'), 'password' => $password, 'salt' => $salt, 'created_at' => date('Y-m-d H:i:s', time()), 'updated_at' => date('Y-m-d H:i:s', time()));
     if ($this->_model->addShopUser($sqlData)) {
         return response()->json(Message::setResponseInfo('SUCCESS'));
     } else {
         return response()->json(Message::setResponseInfo('FAILED'));
     }
 }
コード例 #7
0
ファイル: ShopUserController.php プロジェクト: AZ-WH/spirit
 public function shopUser($sid)
 {
     $salt = $this->getSalt();
     $tel = $request->input('tel');
     $password = sha1(md5($request->input('password')) . $salt);
     $sqlData = array('tel' => $tel, 'password' => $password, 'salt' => $salt, 'created_at' => date('Y-m-d H:i:s', time()), 'updated_at' => date('Y-m-d H:i:s', time()));
     $userId = $this->_model->addAdminUser($sqlData);
     return response()->json(Message::setResponseInfo('SUCCESS', $userId));
 }
コード例 #8
0
ファイル: AuthController.php プロジェクト: AZ-WH/spirit
 public function delUser($uid)
 {
     if ($this->_model->delUser($uid)) {
         return response()->json(Message::setResponseInfo('SUCCESS'));
     } else {
         return response()->json(Message::setResponseInfo('FAILED'));
     }
 }
コード例 #9
0
ファイル: CategoryController.php プロジェクト: AZ-WH/spirit
 public function categoryInfo($cid)
 {
     $category = $this->_model->getCategoryInfo($cid);
     if (empty($category)) {
         return response()->json(Message::setResponseInfo('DATA_EMPTY'));
     }
     $this->_response['category'] = $category;
     return response()->json(Message::setResponseInfo('SUCCESS', $this->_response));
 }