
管理员
站长
- UID
- 1
- 积分
- 224315
- 余额
- 13 R
- Moe币
- 84800
- 在线时间
- 264 小时
- 注册时间
- 2025-12-28
- 最后登录
- 2026-9-19
|
} else if ("recommend".equals(dto.getSortBy())) {
wrapper.eq(Manga::getIsRecommend, 1).orderByDesc(Manga::getSortWeight);
} else {
wrapper.orderByDesc(Manga::getLastUpdateTime);
}
Page<Manga> page = mangaMapper.selectPage(
new Page<>(dto.getPageNum(), dto.getPageSize()), wrapper);
List<MangaListVO> records = page.getRecords().stream().map(manga -> {
MangaListVO vo = new MangaListVO();
vo.setId(manga.getId());
vo.setTitle(manga.getTitle());
vo.setAuthor(manga.getAuthor());
vo.setCover(manga.getCover());
vo.setCategoryId(manga.getCategoryId());
Category category = categoryMapper.selectById(manga.getCategoryId());
vo.setCategoryName(category != null ? category.getName() : "");
vo.setStatus(manga.getStatus());
vo.setPublishStatus(manga.getPublishStatus());
vo.setPriceType(manga.getPriceType());
vo.setPrice(manga.getPrice());
vo.setAgeRange(manga.getAgeRange());
vo.setClickCount(manga.getClickCount());
vo.setFavoriteCount(manga.getFavoriteCount());
vo.setCommentCount(manga.getCommentCount());
vo.setIsRecommend(manga.getIsRecommend());
vo.setSortWeight(manga.getSortWeight());
vo.setLastChapterTitle(manga.getLastChapterTitle());
vo.setLastUpdateTime(manga.getLastUpdateTime());
vo.setCreateTime(manga.getCreateTime());
return vo;
}).collect(Collectors.toList());
IPage<MangaListVO> result = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
result.setRecords(records);
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void incrementClick(Long id) {
mangaMapper.update(null, new com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper<Manga>()
.eq("id", id)
.setSql("click_count = click_count + 1"));
}
@Override
public List<MangaListVO> getRelated(Long mangaId, Integer limit, Long userId) {
if (limit == null) limit = 10;
Manga current = mangaMapper.selectById(mangaId);
if (current == null || current.getCategoryId() == null) {
return Collections.emptyList();
}
LambdaQueryWrapper<Manga> wrapper = new LambdaQueryWrapper<Manga>()
.eq(Manga::getPublishStatus, 1)
.eq(Manga::getCategoryId, current.getCategoryId())
.ne(Manga::getId, mangaId);
applyTeenFilter(wrapper, userId);
List<Manga> list = mangaMapper.selectList(
wrapper.orderByDesc(Manga::getClickCount)
.last("LIMIT " + limit));
return list.stream().map(m -> {
MangaListVO vo = new MangaListVO();
vo.setId(m.getId());
vo.setTitle(m.getTitle());
vo.setAuthor(m.getAuthor());
vo.setCover(m.getCover());
vo.setCategoryId(m.getCategoryId());
vo.setStatus(m.getStatus());
vo.setPriceType(m.getPriceType());
vo.setIsFree(m.getIsFree());
vo.setClickCount(m.getClickCount());
vo.setFavoriteCount(m.getFavoriteCount());
vo.setCommentCount(m.getCommentCount());
vo.setLastChapterTitle(m.getLastChapterTitle());
vo.setLastUpdateTime(m.getLastUpdateTime());
return vo;
}).collect(Collectors.toList());
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long submit(MangaSubmitDTO dto, Long userId) {
Manga manga = new Manga();
manga.setTitle(dto.getTitle());
manga.setAuthor(dto.getAuthor() != null ? dto.getAuthor() : "");
manga.setCategoryId(dto.getCategoryId());
manga.setCover(dto.getCover() != null ? dto.getCover() : "");
manga.setDescription(dto.getDescription());
manga.setStatus(dto.getStatus() != null ? dto.getStatus() : 0);
// 投稿必须显式选择适龄分级(DTO 已 @NotNull 校验),此处不再默认落 0,
// 防止创作者未选择时被静默归为「全年龄」而对未成年人可见
manga.setAgeRange(dto.getAgeRange());
manga.setUserId(userId);
// 投稿默认为下架状态,等待管理员审核上架
manga.setPublishStatus(0);
manga.setIsFree(1);
manga.setPriceType(0);
manga.setPrice(0);
manga.setIsRecommend(0);
manga.setSortWeight(0);
manga.setClickCount(0);
manga.setFavoriteCount(0);
manga.setCommentCount(0);
mangaMapper.insert(manga);
// 关联标签
if (dto.getTagIds() != null && !dto.getTagIds().isEmpty()) {
for (Long tagId : dto.getTagIds()) {
MangaTag mt = new MangaTag();
mt.setMangaId(manga.getId());
mt.setTagId(tagId);
mangaTagMapper.insert(mt);
}
}
return manga.getId();
}
@Override
public List<Map<String, Object>> getUserSubmissions(Long userId) {
List<Manga> list = mangaMapper.selectList(
new LambdaQueryWrapper<Manga>()
.eq(Manga::getUserId, userId)
.orderByDesc(Manga::getCreateTime));
return list.stream().map(manga -> {
Map<String, Object> map = new HashMap<>();
map.put("id", manga.getId());
map.put("title", manga.getTitle());
map.put("author", manga.getAuthor());
map.put("cover", manga.getCover());
map.put("categoryId", manga.getCategoryId());
Category category = categoryMapper.selectById(manga.getCategoryId());
map.put("categoryName", category != null ? category.getName() : "");
map.put("status", manga.getStatus());
map.put("publishStatus", manga.getPublishStatus());
map.put("ageRange", manga.getAgeRange());
map.put("clickCount", manga.getClickCount());
map.put("favoriteCount", manga.getFavoriteCount());
map.put("createTime", manga.getCreateTime());
return map;
}).collect(toList());
}
}
变了。低沉、甜腻、带着哀求。
我满意地笑了。
“怎么了?想要什么吗?”
康太仍跪着靠近我,颤抖的手抓住我的衬衫下摆。
“求你……摸我……”
“哦?这是怎么回事。刚才那副态度呢?狗对主人该怎么说?” |
|