|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import jodd.util.StringUtil; |
|
|
import jodd.util.StringUtil; |
|
|
import org.jeecg.common.exception.JeecgBootException; |
|
|
import org.jeecg.common.exception.JeecgBootException; |
|
|
import org.jeecg.common.system.util.AppletUserUtil; |
|
|
import org.jeecg.common.system.util.AppletUserUtil; |
|
|
|
|
|
import org.jeecg.common.system.vo.AppletUser; |
|
|
import org.jeecg.modules.applet.query.AppletBookQuery; |
|
|
import org.jeecg.modules.applet.query.AppletBookQuery; |
|
|
import org.jeecg.modules.applet.service.AppletApiBooksService; |
|
|
import org.jeecg.modules.applet.service.AppletApiBooksService; |
|
|
import org.jeecg.modules.demo.appletBookStand.entity.AppletBookStand; |
|
|
import org.jeecg.modules.demo.appletBookStand.entity.AppletBookStand; |
|
|
@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -51,13 +53,16 @@ public class AppletApiBooksServiceImpl implements AppletApiBooksService { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public IPage<AppletBooks> getBooks(Page<AppletBooks> page, String title, String category, String label) { |
|
|
public IPage<AppletBooks> getBooks(Page<AppletBooks> page, String title, String category, String label) { |
|
|
return appletBooksService |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<AppletBooks> list = appletBooksService |
|
|
.lambdaQuery() |
|
|
.lambdaQuery() |
|
|
.like(StringUtil.isNotEmpty(title), AppletBooks::getBooksName, title) |
|
|
.like(StringUtil.isNotEmpty(title), AppletBooks::getBooksName, title) |
|
|
.eq(StringUtil.isNotEmpty(category), AppletBooks::getBooksClassification, category) |
|
|
.eq(StringUtil.isNotEmpty(category), AppletBooks::getBooksClassification, category) |
|
|
.like(StringUtil.isNotEmpty(label), AppletBooks::getBooksLabel, label) |
|
|
.like(StringUtil.isNotEmpty(label), AppletBooks::getBooksLabel, label) |
|
|
.eq(AppletBooks::getStatus, "Y") |
|
|
.eq(AppletBooks::getStatus, "Y") |
|
|
.page(page); |
|
|
.page(page); |
|
|
|
|
|
|
|
|
|
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -104,6 +109,9 @@ public class AppletApiBooksServiceImpl implements AppletApiBooksService { |
|
|
appletBookStand.setUserId(userId); |
|
|
appletBookStand.setUserId(userId); |
|
|
appletBookStand.setBookId(id); |
|
|
appletBookStand.setBookId(id); |
|
|
appletBookStandService.save(appletBookStand); |
|
|
appletBookStandService.save(appletBookStand); |
|
|
|
|
|
}else { |
|
|
|
|
|
one.setUpdateTime(new Date()); |
|
|
|
|
|
appletBookStandService.updateById(one); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -127,23 +135,16 @@ public class AppletApiBooksServiceImpl implements AppletApiBooksService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取课程列表 |
|
|
* 获取课程列表 |
|
|
* |
|
|
|
|
|
* @param id |
|
|
* @param id |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public IPage<AppletCourse> getCourses(Page<AppletCourse> coursePage, String id) { |
|
|
public IPage<AppletCourse> getCourses(Page<AppletCourse> coursePage, String id) { |
|
|
// 先验证书籍是否存在 |
|
|
|
|
|
AppletBooks book = appletBooksService.getById(id); |
|
|
|
|
|
if (book == null) { |
|
|
|
|
|
throw new JeecgBootException("书籍不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
// 根据书籍ID查询关联的课程列表 |
|
|
// 根据书籍ID查询关联的课程列表 |
|
|
IPage<AppletCourse> pageResult = appletCourseService |
|
|
IPage<AppletCourse> pageResult = appletCourseService |
|
|
.lambdaQuery() |
|
|
.lambdaQuery() |
|
|
.eq(AppletCourse::getBookId, id) |
|
|
.eq(AppletCourse::getBookId, id) |
|
|
.page(coursePage); |
|
|
.page(coursePage); |
|
|
|
|
|
|
|
|
return pageResult; |
|
|
return pageResult; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -157,4 +158,20 @@ public class AppletApiBooksServiceImpl implements AppletApiBooksService { |
|
|
return appletCategorizeService.list(); |
|
|
return appletCategorizeService.list(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public AppletBooks detail(String id) { |
|
|
|
|
|
|
|
|
|
|
|
AppletBooks book = appletBooksService.getById(id); |
|
|
|
|
|
|
|
|
|
|
|
AppletUser user = AppletUserUtil.getAppletUserFromRequest(); |
|
|
|
|
|
|
|
|
|
|
|
if (user != null){ |
|
|
|
|
|
book.setIsStand(appletBookStandService.lambdaQuery() |
|
|
|
|
|
.eq(AppletBookStand::getBookId, book.getId()) |
|
|
|
|
|
.eq(AppletBookStand::getUserId, user.getId()) |
|
|
|
|
|
.one() != null); |
|
|
|
|
|
} |
|
|
|
|
|
return book; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |