游客模式
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
package com.peanut.modules.bookAbroad.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadLableService;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.master.service.BookAbroadToLableService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("visitorBookAbroad")
|
||||
@RequestMapping("visitor/bookAbroad")
|
||||
public class VisitorController {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookAbroadLableService lableService;
|
||||
@Autowired
|
||||
private BookAbroadToLableService toLableService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private BookListeningService bookListeningService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
|
||||
//推荐图书
|
||||
@RequestMapping("/getRecommendBooks")
|
||||
public R getRecommendBooks(){
|
||||
List<BookEntity> books = bookService.list(new LambdaQueryWrapper<BookEntity>()
|
||||
.eq(BookEntity::getState,1)
|
||||
.eq(BookEntity::getBookType,0)
|
||||
.last("limit 4"));
|
||||
return R.ok().put("books",books);
|
||||
}
|
||||
|
||||
//获取标签列表
|
||||
@RequestMapping("/getBookAbroadLableList")
|
||||
public R getBookAbroadLableList(@RequestBody Map<String,Object> params) {
|
||||
List<BookAbroadLable> list = lableService.list(new LambdaQueryWrapper<BookAbroadLable>()
|
||||
.eq(BookAbroadLable::getPid,0)
|
||||
.eq(BookAbroadLable::getType,params.get("type")));
|
||||
return R.ok().put("lableList",list);
|
||||
}
|
||||
|
||||
//获取子标签
|
||||
@RequestMapping("/getBookAbroadLableListByPid")
|
||||
public R getBookAbroadLableListByPid(@RequestBody Map<String,Object> params) {
|
||||
List<BookAbroadLable> list = lableService.list(new LambdaQueryWrapper<BookAbroadLable>()
|
||||
.eq(BookAbroadLable::getPid,params.get("pid")));
|
||||
return R.ok().put("lableList",list);
|
||||
}
|
||||
|
||||
//通过标签获取绑定图书
|
||||
@RequestMapping("/getAbroadBookListByLable")
|
||||
public R getAbroadBookListByLable(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<BookAbroadToLable> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,BookAbroadToLable::getBookId);
|
||||
wrapper.selectAs(BookAbroadToLable::getId,"toLableId");
|
||||
wrapper.selectAs(BookEntity::getId,"bookId");
|
||||
wrapper.selectAs(BookEntity::getAbroadPrice,"abroadPrice");
|
||||
wrapper.select(BookEntity::getImages);
|
||||
wrapper.select(BookEntity::getName);
|
||||
wrapper.eq(BookAbroadToLable::getLableId,params.get("lableId"));
|
||||
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
||||
List<Map<String,Object>> list = toLableService.listMaps(wrapper);
|
||||
for (Map<String, Object> map : list) {
|
||||
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
||||
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getBookId,map.get("bookId")));
|
||||
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
.eq(BookListeningEntity::getBookId,map.get("bookId")));
|
||||
map.put("readCount",readCount);
|
||||
map.put("buyCount",buyCount);
|
||||
map.put("listenCount",listenCount);
|
||||
}
|
||||
return R.ok().put("bookList",list);
|
||||
}
|
||||
|
||||
//图书详情
|
||||
@RequestMapping("/getBookInfo")
|
||||
public R getBookInfo(@RequestBody Map<String,Object> params) {
|
||||
BookEntity bookEntity = bookService.getById(params.get("bookId").toString());
|
||||
bookEntity.setAuthor(authorService.getById(bookEntity.getAuthorId()));
|
||||
bookEntity.setIsBuy(false);
|
||||
return R.ok().put("bookInfo",bookEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user