1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\main\constants\BookConstants;
- use app\main\constants\ErrorCodeConstants;
- use app\main\service\BookService;
- use think\Cookie;
- class Bookshelf extends Api
- {
- public function _initialize()
- {
- parent::_initialize();
- }
- public function insert()
- {
- $bookId = $this->request->post('book_id');
- $chapterId = $this->request->post('chapter_id', 0);
- $idx = $this->request->post('idx', 0);
- if (!Cookie::has('user_id')) {
- $this->error('用户没有登录');
- }
- $result = BookService::instance()->setBookShelf($bookId);
- if ($result->code == ErrorCodeConstants::SUCCESS) {
- $this->success();
- } else {
- $this->error($result->msg);
- }
- }
- public function delbooks(){
- if ($this->request->isAjax()) {
- $bookIds = $this->request->post('bookIds');
- $bookArr = \GuzzleHttp\json_decode($bookIds, true);
- $data = BookService::instance()->delBookShelf($bookArr);
- return json(['err' => 0]);
- }
- }
- }
|