1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Modules\Book\Services;
- use App\Modules\Book\BookConfig;
- use App\Modules\Book\Book;
- use Redis;
- use DB;
- class BookConfigService
- {
- /**
- * 根据id获取图书
- * @param $bid
- * @return mixed
- */
- public static function getBookById($bid)
- {
- $res = BookConfig::getBookById($bid);
- return $res;
- }
- /**
- * 根据bid数组获取多本图书
- * @param $where
- * @param null $order
- * @return mixed
- */
- public static function getBooksByIds(array $where, $order = [],$is_on_shelf = '')
- {
- if(empty($where)){
- return (object)array();
- }
- if ($order)
- $res = BookConfig::getBooksByIds($where, $order,$is_on_shelf);
- else
- $res = BookConfig::getBooksByIds($where,$order,$is_on_shelf);
- return $res;
- }
-
-
- //阅读记录用到的图书信息 bid cover last_chapter
- public static function getBookSimpleInfoFroReadRecord(array $bid){
- return BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
- ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
- ->select('book_configs.bid', 'book_configs.cover', 'book_configs.book_name', 'books.chapter_count','books.last_chapter','book_categories.channel_name')
- ->whereIn('book_configs.bid', $bid)
- ->get();
- }
- public static function getBookSimpleInfoByBidAndFields($bid,$field){
- return BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
- ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
- ->select($field)
- ->where('book_configs.bid', $bid)
- ->first();
- }
- /**
- *
- * 根据条件获取图书
- * @param array $where ['key'=>'根据关键词查询','category_id'=>'根据分类id查询','is_on_shelf'=>上下架查询,'channel_name'=>'频道查询(男频女频)']
- * @param array $order 排序 默认是bid排序
- * @param int $page_size
- * @return mixed
- */
- public static function getBooks(array $where, array $order = [], $page_size = 15)
- {
- return BookConfig::getBooks($where, $order, $page_size);
- }
- }
|