mirror of
https://github.com/201206030/novel.git
synced 2025-07-16 17:26:38 +00:00
后台小说发布功能上线
This commit is contained in:
@ -1,128 +0,0 @@
|
||||
package com.java2nb.books.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
|
||||
import com.java2nb.books.domain.BookContentDO;
|
||||
import com.java2nb.books.service.BookContentService;
|
||||
import com.java2nb.common.utils.PageBean;
|
||||
import com.java2nb.common.utils.Query;
|
||||
import com.java2nb.common.utils.R;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-13 09:28:11
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/books/bookContent")
|
||||
public class BookContentController {
|
||||
@Autowired
|
||||
private BookContentService bookContentService;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("books:bookContent:bookContent")
|
||||
String BookContent() {
|
||||
return "books/bookContent/bookContent";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取列表", notes = "获取列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("books:bookContent:bookContent")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
//查询列表数据
|
||||
Query query = new Query(params);
|
||||
List<BookContentDO> bookContentList = bookContentService.list(query);
|
||||
int total = bookContentService.count(query);
|
||||
PageBean pageBean = new PageBean(bookContentList, total);
|
||||
return R.ok().put("data", pageBean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增页面", notes = "新增页面")
|
||||
@GetMapping("/add")
|
||||
String add() {
|
||||
return "books/bookContent/add";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改页面", notes = "修改页面")
|
||||
@GetMapping("/edit/{id}")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
BookContentDO bookContent = bookContentService.get(id);
|
||||
model.addAttribute("bookContent", bookContent);
|
||||
return "books/bookContent/edit";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看页面", notes = "查看页面")
|
||||
@GetMapping("/detail/{id}")
|
||||
String detail(@PathVariable("id") Long id, Model model) {
|
||||
BookContentDO bookContent = bookContentService.get(id);
|
||||
model.addAttribute("bookContent", bookContent);
|
||||
return "books/bookContent/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation(value = "新增", notes = "新增")
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
public R save( BookContentDO bookContent) {
|
||||
if (bookContentService.save(bookContent) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation(value = "修改", notes = "修改")
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
public R update( BookContentDO bookContent) {
|
||||
bookContentService.update(bookContent);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public R remove( Long id) {
|
||||
if (bookContentService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "批量删除", notes = "批量删除")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||
bookContentService.batchRemove(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -150,7 +150,9 @@ public class BookController {
|
||||
}
|
||||
|
||||
@GetMapping("/index")
|
||||
String BookIndex() {
|
||||
String BookIndex(Long bookId, Model model) {
|
||||
|
||||
model.addAttribute("bookId",bookId);
|
||||
return "books/bookIndex/bookIndex";
|
||||
}
|
||||
|
||||
@ -167,26 +169,26 @@ public class BookController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 删除章节
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@ApiOperation(value = "删除章节", notes = "删除章节")
|
||||
@PostMapping("/index/remove")
|
||||
@ResponseBody
|
||||
public R indexRemove( Long id) {
|
||||
if (bookService.indexRemove(id) > 0) {
|
||||
public R indexRemove( Long id,Long bookId) {
|
||||
if (bookService.indexRemove(id,bookId) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 删除章节
|
||||
*/
|
||||
@ApiOperation(value = "批量删除", notes = "批量删除")
|
||||
@ApiOperation(value = "批量删除章节", notes = "批量删除章节")
|
||||
@PostMapping("/index/batchRemove")
|
||||
@ResponseBody
|
||||
public R indexRemove(@RequestParam("ids[]") Long[] ids) {
|
||||
bookService.batchIndexRemove(ids);
|
||||
public R indexRemove(@RequestParam("ids[]") Long[] ids,@RequestParam("bookIds[]") Long[] bookIds) {
|
||||
bookService.batchIndexRemove(ids,bookIds);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
@ -1,128 +0,0 @@
|
||||
package com.java2nb.books.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
|
||||
import com.java2nb.books.domain.BookIndexDO;
|
||||
import com.java2nb.books.service.BookIndexService;
|
||||
import com.java2nb.common.utils.PageBean;
|
||||
import com.java2nb.common.utils.Query;
|
||||
import com.java2nb.common.utils.R;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-13 09:28:15
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/books/bookIndex")
|
||||
public class BookIndexController {
|
||||
@Autowired
|
||||
private BookIndexService bookIndexService;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("books:bookIndex:bookIndex")
|
||||
String BookIndex() {
|
||||
return "books/bookIndex/bookIndex";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取列表", notes = "获取列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("books:bookIndex:bookIndex")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
//查询列表数据
|
||||
Query query = new Query(params);
|
||||
List<BookIndexDO> bookIndexList = bookIndexService.list(query);
|
||||
int total = bookIndexService.count(query);
|
||||
PageBean pageBean = new PageBean(bookIndexList, total);
|
||||
return R.ok().put("data", pageBean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增页面", notes = "新增页面")
|
||||
@GetMapping("/add")
|
||||
String add() {
|
||||
return "books/bookIndex/add";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改页面", notes = "修改页面")
|
||||
@GetMapping("/edit/{id}")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
BookIndexDO bookIndex = bookIndexService.get(id);
|
||||
model.addAttribute("bookIndex", bookIndex);
|
||||
return "books/bookIndex/edit";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看页面", notes = "查看页面")
|
||||
@GetMapping("/detail/{id}")
|
||||
String detail(@PathVariable("id") Long id, Model model) {
|
||||
BookIndexDO bookIndex = bookIndexService.get(id);
|
||||
model.addAttribute("bookIndex", bookIndex);
|
||||
return "books/bookIndex/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation(value = "新增", notes = "新增")
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
public R save( BookIndexDO bookIndex) {
|
||||
if (bookIndexService.save(bookIndex) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation(value = "修改", notes = "修改")
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
public R update( BookIndexDO bookIndex) {
|
||||
bookIndexService.update(bookIndex);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "删除", notes = "删除")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public R remove( Long id) {
|
||||
if (bookIndexService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "批量删除", notes = "批量删除")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||
bookIndexService.batchRemove(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,4 +32,6 @@ public interface BookContentDao {
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
void insertBatch(List<BookContentDO> newContentList);
|
||||
|
||||
void removeByBookIds(@Param("bookIds") String bookIds);
|
||||
}
|
||||
|
@ -40,4 +40,6 @@ public interface BookIndexDao {
|
||||
List<BookIndexVO> listVO(Query query);
|
||||
|
||||
int countVO(Query query);
|
||||
|
||||
void removeByBookIds(@Param("bookIds") String bookIds);
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package com.java2nb.books.service;
|
||||
|
||||
import com.java2nb.books.domain.BookContentDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-13 09:28:11
|
||||
*/
|
||||
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);
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.java2nb.books.service;
|
||||
|
||||
import com.java2nb.books.domain.BookIndexDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-13 09:28:15
|
||||
*/
|
||||
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);
|
||||
}
|
@ -42,7 +42,7 @@ public interface BookService {
|
||||
|
||||
int indexVOCount(Query query);
|
||||
|
||||
int indexRemove(Long id);
|
||||
int indexRemove(Long id, Long bookId);
|
||||
|
||||
int batchIndexRemove(Long[] ids);
|
||||
int batchIndexRemove(Long[] ids, Long[] bookIds);
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
package com.java2nb.books.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.books.dao.BookContentDao;
|
||||
import com.java2nb.books.domain.BookContentDO;
|
||||
import com.java2nb.books.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);
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.java2nb.books.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.books.dao.BookIndexDao;
|
||||
import com.java2nb.books.domain.BookIndexDO;
|
||||
import com.java2nb.books.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);
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -68,15 +67,26 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
return bookDao.update(book);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return bookDao.remove(id);
|
||||
int rows = bookDao.remove(id);
|
||||
bookIndexDao.removeByBookIds(id+"");
|
||||
bookContentDao.removeByBookIds(id+"");
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return bookDao.batchRemove(ids);
|
||||
|
||||
int rows = bookDao.batchRemove(ids);
|
||||
String bookIds = StringUtils.join(ids,",");
|
||||
bookIndexDao.removeByBookIds(bookIds);
|
||||
bookContentDao.removeByBookIds(bookIds);
|
||||
return rows;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,12 +118,16 @@ public class BookServiceImpl implements BookService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexRemove(Long id) {
|
||||
@Transactional
|
||||
public int indexRemove(Long id, Long bookId) {
|
||||
bookContentDao.removeByBookIds(id+"");
|
||||
return bookIndexDao.remove(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int batchIndexRemove(Long[] ids) {
|
||||
public int batchIndexRemove(Long[] ids, Long[] bookIds) {
|
||||
bookContentDao.removeByBookIds(StringUtils.join(ids,","));
|
||||
return bookIndexDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user