12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\library\Ip;
- use app\common\service\WaterBookService;
- use app\main\service\AdminService;
- use app\main\service\UserService;
- use think\Cookie;
- class Category extends Api
- {
- public function _initialize()
- {
- parent::_initialize();
- }
- /**
- * 男女频道下的分类信息数据
- * @param int $sex 频道
- * @return json
- */
- public function channelcategoriesapi()
- {
- $sex = input('sex');
- $data = model('BookCategory')::channelCategories($sex);
- return json($data);
- }
- /**
- * 查询类目下的书籍列表数据
- * @param int $book_category_id 书籍分类id
- * @param int $type 书籍分类id
- * @return json
- */
- public function booklistapi()
- {
- $book_category_id = input('book_category_id', 8);
- $type = input('type', 'all');
- $page = input('page', 1);
- $user_id = Cookie::get('user_id');
- //清水
- if ($user_id) {
- $userInfo = UserService::instance()->getUserModel()->getUserInfo($user_id);
- $channel_id = $userInfo['channel_id'] ?? 0;
- if (empty($channel_id)) {
- $is_water = false;
- } else {
- $channel_id = AdminService::instance()->getAdminExtendModel()->getChannelId($channel_id);
- $is_water = WaterBookService::instance()->showBook($channel_id, $user_id, Ip::ip());
- }
- } else {
- $is_water = false;
- }
- $books = model('BookCategory')::booklist($book_category_id, $type, $page, $is_water);
- return json($books);
- }
- }
|