|
|
@@ -22,6 +22,7 @@ import jdk.jfr.Category;
|
|
22
|
22
|
import org.slf4j.Logger;
|
|
23
|
23
|
import org.slf4j.LoggerFactory;
|
|
24
|
24
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
25
|
+import org.springframework.beans.factory.annotation.Value;
|
|
25
|
26
|
import org.springframework.stereotype.Service;
|
|
26
|
27
|
import org.springframework.transaction.annotation.Transactional;
|
|
27
|
28
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -37,7 +38,8 @@ public class NovelServiceImpl implements NovelService {
|
|
37
|
38
|
private static final Logger logger = LoggerFactory.getLogger(NovelServiceImpl.class);
|
|
38
|
39
|
private final NovelRepository novelRepository; // JPA
|
|
39
|
40
|
|
|
40
|
|
-
|
|
|
41
|
+ @Value("${novel.amountDay}")
|
|
|
42
|
+ private Integer amountDay;
|
|
41
|
43
|
//private final NovelSearchRepository novelSearchRepository; // ES
|
|
42
|
44
|
|
|
43
|
45
|
@Autowired
|
|
|
@@ -252,7 +254,7 @@ public class NovelServiceImpl implements NovelService {
|
|
252
|
254
|
|
|
253
|
255
|
|
|
254
|
256
|
@Override
|
|
255
|
|
- public List<Category> getAllCategories() {
|
|
|
257
|
+ public List<NovelCategory> getAllCategories() {
|
|
256
|
258
|
|
|
257
|
259
|
return categoryMapper.selectCategoryList();
|
|
258
|
260
|
}
|
|
|
@@ -261,22 +263,18 @@ public class NovelServiceImpl implements NovelService {
|
|
261
|
263
|
public List<Novel> getHotNovels() {
|
|
262
|
264
|
// 获取最近一周热门小说
|
|
263
|
265
|
Map<String, Object> params = new HashMap<>();
|
|
264
|
|
- params.put("beginTime", DateUtils.addDays(new Date(), -7));
|
|
|
266
|
+ params.put("beginTime", DateUtils.addDays(new Date(), -amountDay));
|
|
265
|
267
|
return novelMapper.selectHotNovels(params);
|
|
266
|
268
|
}
|
|
267
|
269
|
|
|
268
|
270
|
@Override
|
|
269
|
|
- public List<Novel> getNovelsByCategory(Long categoryId) {
|
|
270
|
|
- // 使用若依分页工具
|
|
271
|
|
- startPage();
|
|
272
|
|
-
|
|
|
271
|
+ public NovelCategory getNovelsByCategory(Long categoryId) {
|
|
273
|
272
|
Novel novel = new Novel();
|
|
274
|
273
|
if (categoryId != null && categoryId > 0) {
|
|
275
|
274
|
novel.setCategoryId(categoryId);
|
|
276
|
275
|
}
|
|
277
|
|
-
|
|
278
|
|
- List<Novel> list = novelMapper.selectNovelList(novel,null);
|
|
279
|
|
- return (List<Novel>) getDataTable(list);
|
|
|
276
|
+ NovelCategory novelCategory = categoryMapper.selectById(categoryId.toString());
|
|
|
277
|
+ return novelCategory;
|
|
280
|
278
|
}
|
|
281
|
279
|
|
|
282
|
280
|
@Override
|