标签修改

This commit is contained in:
wuchunlei
2024-12-16 14:54:57 +08:00
parent e8599ff599
commit 978c7ab768
3 changed files with 47 additions and 3 deletions

View File

@@ -149,6 +149,7 @@ public class HomeController {
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>()

View File

@@ -32,6 +32,11 @@ public class BookAbroadLable implements Serializable {
*/
private String title;
/**
* 标题
*/
private String etitle;
/**
* 0否1是
*/

View File

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.master.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -27,6 +29,8 @@ public class BookAbroadController {
private com.peanut.modules.bookAbroad.service.BookAbroadLableService labelService;
@Autowired
private com.peanut.modules.bookAbroad.service.BookAbroadToLableService toLableService;
@Autowired
private BookService bookService;
//评论列表
@RequestMapping("/getBookAbroadCommentList")
@@ -47,7 +51,7 @@ public class BookAbroadController {
@RequestMapping("/insertBookAbroadLable")
public R insertBookAbroadLable(@RequestBody BookAbroadLable lable){
labelService.save(lable);
return R.ok();
return R.ok().put("bookAbroadLable",lable);
}
//标签详情
@@ -76,6 +80,9 @@ public class BookAbroadController {
@RequestMapping("/delBookAbroadLable")
public R delBookAbroadLable(@RequestBody Map<String,Object> params){
BookAbroadLable oldLable = labelService.getById(params.get("id").toString());
if (oldLable.getIsLast()!=1){
return R.error("不是最下级,禁止删除");
}
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
.eq(BookAbroadToLable::getLableId,params.get("id").toString()));
if (count > 0){
@@ -88,6 +95,10 @@ public class BookAbroadController {
//绑定图书和标签
@RequestMapping("/insertBookAbroadToLable")
public R insertBookAbroadToLable(@RequestBody BookAbroadToLable toLable){
BookAbroadLable oldLable = labelService.getById(toLable.getLableId());
if (oldLable.getIsLast()!=1){
return R.error("不是最下级,禁止绑定");
}
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
.eq(BookAbroadToLable::getBookId,toLable.getBookId())
.eq(BookAbroadToLable::getLableId,toLable.getLableId()));
@@ -106,6 +117,21 @@ public class BookAbroadController {
return R.ok();
}
//标签可绑定图书
@RequestMapping("/getBookListCanToLable")
public R getBookListCanToLable(@RequestBody Map<String,Object> params) {
List<Integer> collect = toLableService.list(new LambdaQueryWrapper<BookAbroadToLable>()
.eq(BookAbroadToLable::getLableId, params.get("lableId")))
.stream().map(BookAbroadToLable::getBookId).collect(Collectors.toList());
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
if (collect.size() != 0){
wrapper.notIn(BookEntity::getId,collect);
}
wrapper.like(StringUtils.isNotBlank(params.get("bookName").toString()),BookEntity::getTitle,params.get("bookName"));
Page<BookEntity> page = bookService.page(new Page<>(Long.valueOf(params.get("current").toString()),Long.valueOf(params.get("limit").toString())), wrapper);
return R.ok().put("page",page);
}
//通过标签获取绑定图书
@RequestMapping("/getAbroadBookListByLable")
public R getAbroadBookListByLable(@RequestBody Map<String,Object> params) {
@@ -113,13 +139,25 @@ public class BookAbroadController {
wrapper.leftJoin(BookEntity.class,BookEntity::getId,BookAbroadToLable::getBookId);
wrapper.selectAs(BookAbroadToLable::getId,"id");
wrapper.select(BookEntity::getName);
wrapper.select(BookAbroadToLable::getSort);
wrapper.select(BookAbroadToLable::getBookId);
wrapper.eq(BookAbroadToLable::getLableId,params.get("lableId"));
wrapper.orderByAsc(BookAbroadToLable::getSort);
return R.ok().put("bookList",toLableService.listMaps(wrapper));
}
//修改排序
@RequestMapping("/updateToLableSort")
public R updateToLableSort(@RequestBody Map<String,Object> params){
BookAbroadToLable toLable = toLableService.getById(params.get("toLableId").toString());
toLable.setSort(Integer.parseInt(params.get("sort").toString()));
toLableService.updateById(toLable);
return R.ok();
}
//标签树
@RequestMapping("/getLableTree")
public List<BookAbroadLable> getLableTree(@RequestBody Map<String,Object> params) {
public R getLableTree(@RequestBody Map<String,Object> params) {
List<BookAbroadLable> labels = labelService.list(new LambdaQueryWrapper<BookAbroadLable>()
.eq(BookAbroadLable::getType,params.get("type")));
List<BookAbroadLable> labelsTree = labels.stream().filter((bookAbroadLable) ->
@@ -130,7 +168,7 @@ public class BookAbroadController {
}).sorted((label1,label2)->{
return (label1.getSort() == null? 0 : label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return labelsTree;
return R.ok().put("labelsTree",labelsTree);
}
private List<BookAbroadLable> getLabelChildrens(BookAbroadLable root,List<BookAbroadLable> all){