mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-05 08:46:38 +00:00
feat: 后台小说删除
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
import com.java2nb.novel.domain.BookContentDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 小说内容表
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-14 19:52:06
|
||||
*/
|
||||
public interface BookContentService {
|
||||
|
||||
BookContentDO get(Long id);
|
||||
|
||||
List<BookContentDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(BookContentDO bookContent);
|
||||
|
||||
int update(BookContentDO bookContent);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
import com.java2nb.novel.domain.BookIndexDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 小说目录表
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-14 19:51:54
|
||||
*/
|
||||
public interface BookIndexService {
|
||||
|
||||
BookIndexDO get(Long id);
|
||||
|
||||
List<BookIndexDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(BookIndexDO bookIndex);
|
||||
|
||||
int update(BookIndexDO bookIndex);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.novel.dao.BookContentDao;
|
||||
import com.java2nb.novel.domain.BookContentDO;
|
||||
import com.java2nb.novel.service.BookContentService;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
public class BookContentServiceImpl implements BookContentService {
|
||||
@Autowired
|
||||
private BookContentDao bookContentDao;
|
||||
|
||||
@Override
|
||||
public BookContentDO get(Long id){
|
||||
return bookContentDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookContentDO> list(Map<String, Object> map){
|
||||
return bookContentDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map){
|
||||
return bookContentDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookContentDO bookContent){
|
||||
return bookContentDao.save(bookContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookContentDO bookContent){
|
||||
return bookContentDao.update(bookContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return bookContentDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return bookContentDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.novel.dao.BookIndexDao;
|
||||
import com.java2nb.novel.domain.BookIndexDO;
|
||||
import com.java2nb.novel.service.BookIndexService;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
public class BookIndexServiceImpl implements BookIndexService {
|
||||
@Autowired
|
||||
private BookIndexDao bookIndexDao;
|
||||
|
||||
@Override
|
||||
public BookIndexDO get(Long id){
|
||||
return bookIndexDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookIndexDO> list(Map<String, Object> map){
|
||||
return bookIndexDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map){
|
||||
return bookIndexDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookIndexDO bookIndex){
|
||||
return bookIndexDao.save(bookIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookIndexDO bookIndex){
|
||||
return bookIndexDao.update(bookIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return bookIndexDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return bookIndexDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +1,79 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.java2nb.novel.dao.BookContentDao;
|
||||
import com.java2nb.novel.dao.BookDao;
|
||||
import com.java2nb.novel.dao.BookIndexDao;
|
||||
import com.java2nb.novel.domain.BookDO;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.java2nb.novel.dao.BookDao;
|
||||
import com.java2nb.novel.domain.BookDO;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
public class BookServiceImpl implements BookService {
|
||||
@Autowired
|
||||
private BookDao bookDao;
|
||||
|
||||
@Override
|
||||
public BookDO get(Long id){
|
||||
return bookDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookDO> list(Map<String, Object> map){
|
||||
return bookDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map){
|
||||
return bookDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookDO book){
|
||||
return bookDao.save(book);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookDO book){
|
||||
return bookDao.update(book);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return bookDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return bookDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Object, Object> tableSta(Date minDate) {
|
||||
List<Map<Object, Object>> maps = bookDao.tableSta(minDate);
|
||||
@Autowired
|
||||
private BookDao bookDao;
|
||||
@Autowired
|
||||
private BookIndexDao bookIndexDao;
|
||||
@Autowired
|
||||
private BookContentDao bookContentDao;
|
||||
|
||||
return maps.stream().collect(Collectors.toMap(x -> x.get("staDate"), x -> x.get("bookCount")));
|
||||
@Override
|
||||
public BookDO get(Long id) {
|
||||
return bookDao.get(id);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<BookDO> list(Map<String, Object> map) {
|
||||
return bookDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return bookDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookDO book) {
|
||||
return bookDao.save(book);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookDO book) {
|
||||
return bookDao.update(book);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
List<Long> indexIds = bookIndexDao.getIdsByBookId(id);
|
||||
if (!CollectionUtils.isEmpty(indexIds)) {
|
||||
Long[] indexIdArray = indexIds.toArray(new Long[0]);
|
||||
bookIndexDao.batchRemove(indexIdArray);
|
||||
bookContentDao.removeByIndexIds(indexIdArray);
|
||||
}
|
||||
return bookDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids) {
|
||||
return bookDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Object, Object> tableSta(Date minDate) {
|
||||
List<Map<Object, Object>> maps = bookDao.tableSta(minDate);
|
||||
|
||||
return maps.stream().collect(Collectors.toMap(x -> x.get("staDate"), x -> x.get("bookCount")));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user