mirror of
https://github.com/201206030/novel-plus.git
synced 2025-06-24 04:46:37 +00:00
restful api改造
This commit is contained in:
@ -13,10 +13,7 @@ import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.service.FriendLinkService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -38,7 +35,7 @@ public class AuthorController extends BaseController{
|
||||
/**
|
||||
* 校验笔名是否存在
|
||||
* */
|
||||
@PostMapping("checkPenName")
|
||||
@GetMapping("checkPenName")
|
||||
public ResultBean checkPenName(String penName){
|
||||
|
||||
return ResultBean.ok(authorService.checkPenName(penName));
|
||||
@ -47,7 +44,7 @@ public class AuthorController extends BaseController{
|
||||
/**
|
||||
* 作家发布小说分页列表查询
|
||||
* */
|
||||
@PostMapping("listBookByPage")
|
||||
@GetMapping("listBookByPage")
|
||||
public ResultBean listBookByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize ,HttpServletRequest request){
|
||||
|
||||
return ResultBean.ok(new PageInfo<>(bookService.listBookPageByUserId(getUserDetails(request).getId(),page,pageSize)
|
||||
@ -90,8 +87,8 @@ public class AuthorController extends BaseController{
|
||||
/**
|
||||
* 删除章节
|
||||
*/
|
||||
@PostMapping("deleteIndex")
|
||||
public ResultBean deleteIndex(Long indexId, HttpServletRequest request) {
|
||||
@DeleteMapping("deleteIndex/{indexId}")
|
||||
public ResultBean deleteIndex(@PathVariable("indexId") Long indexId, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
@ -136,8 +133,8 @@ public class AuthorController extends BaseController{
|
||||
/**
|
||||
* 查询章节内容
|
||||
*/
|
||||
@PostMapping("queryIndexContent")
|
||||
public ResultBean queryIndexContent(Long indexId, HttpServletRequest request) {
|
||||
@GetMapping("queryIndexContent/{indexId}")
|
||||
public ResultBean queryIndexContent(@PathVariable("indexId") Long indexId, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
@ -167,7 +164,7 @@ public class AuthorController extends BaseController{
|
||||
/**
|
||||
* 作家日收入统计数据分页列表查询
|
||||
* */
|
||||
@PostMapping("listIncomeDailyByPage")
|
||||
@GetMapping("listIncomeDailyByPage")
|
||||
public ResultBean listIncomeDailyByPage(@RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int pageSize ,
|
||||
@RequestParam(value = "bookId", defaultValue = "0") Long bookId,
|
||||
@ -183,7 +180,7 @@ public class AuthorController extends BaseController{
|
||||
/**
|
||||
* 作家月收入统计数据分页列表查询
|
||||
* */
|
||||
@PostMapping("listIncomeMonthByPage")
|
||||
@GetMapping("listIncomeMonthByPage")
|
||||
public ResultBean listIncomeMonthByPage(@RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int pageSize ,
|
||||
@RequestParam(value = "bookId", defaultValue = "0") Long bookId,
|
||||
|
@ -12,10 +12,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
@ -41,7 +38,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询首页小说设置列表数据
|
||||
* */
|
||||
@PostMapping("listBookSetting")
|
||||
@GetMapping("listBookSetting")
|
||||
public ResultBean listBookSetting(){
|
||||
return ResultBean.ok(bookService.listBookSettingVO());
|
||||
}
|
||||
@ -49,7 +46,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询首页点击榜单数据
|
||||
* */
|
||||
@PostMapping("listClickRank")
|
||||
@GetMapping("listClickRank")
|
||||
public ResultBean listClickRank(){
|
||||
return ResultBean.ok(bookService.listClickRank());
|
||||
}
|
||||
@ -57,7 +54,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询首页新书榜单数据
|
||||
* */
|
||||
@PostMapping("listNewRank")
|
||||
@GetMapping("listNewRank")
|
||||
public ResultBean listNewRank(){
|
||||
return ResultBean.ok(bookService.listNewRank());
|
||||
}
|
||||
@ -65,7 +62,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询首页更新榜单数据
|
||||
* */
|
||||
@PostMapping("listUpdateRank")
|
||||
@GetMapping("listUpdateRank")
|
||||
public ResultBean listUpdateRank(){
|
||||
return ResultBean.ok(bookService.listUpdateRank());
|
||||
}
|
||||
@ -73,7 +70,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询小说分类列表
|
||||
* */
|
||||
@PostMapping("listBookCategory")
|
||||
@GetMapping("listBookCategory")
|
||||
public ResultBean listBookCategory(){
|
||||
return ResultBean.ok(bookService.listBookCategory());
|
||||
}
|
||||
@ -81,7 +78,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 分页搜索
|
||||
* */
|
||||
@PostMapping("searchByPage")
|
||||
@GetMapping("searchByPage")
|
||||
public ResultBean searchByPage(BookSP bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
||||
PageInfo<BookVO> pageInfo = bookService.searchByPage(bookSP,page,pageSize);
|
||||
return ResultBean.ok(pageInfo);
|
||||
@ -90,8 +87,8 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询小说详情信息
|
||||
* */
|
||||
@PostMapping("queryBookDetail")
|
||||
public ResultBean queryBookDetail(Long id){
|
||||
@GetMapping("queryBookDetail/{id}")
|
||||
public ResultBean queryBookDetail(@PathVariable("id") Long id){
|
||||
return ResultBean.ok(bookService.queryBookDetail(id));
|
||||
}
|
||||
|
||||
@ -99,7 +96,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询小说排行信息
|
||||
* */
|
||||
@PostMapping("listRank")
|
||||
@GetMapping("listRank")
|
||||
public ResultBean listRank(@RequestParam(value = "type",defaultValue = "0") Byte type,@RequestParam(value = "limit",defaultValue = "30") Integer limit){
|
||||
return ResultBean.ok(bookService.listRank(type,limit));
|
||||
}
|
||||
@ -120,7 +117,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 查询章节相关信息
|
||||
* */
|
||||
@PostMapping("queryBookIndexAbout")
|
||||
@GetMapping("queryBookIndexAbout")
|
||||
public ResultBean queryBookIndexAbout(Long bookId,Long lastBookIndexId) {
|
||||
Map<String,Object> data = new HashMap<>(2);
|
||||
data.put("bookIndexCount",bookService.queryIndexCount(bookId));
|
||||
@ -135,7 +132,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 根据分类id查询同类推荐书籍
|
||||
* */
|
||||
@PostMapping("listRecBookByCatId")
|
||||
@GetMapping("listRecBookByCatId")
|
||||
public ResultBean listRecBookByCatId(Integer catId) {
|
||||
return ResultBean.ok(bookService.listRecBookByCatId(catId));
|
||||
}
|
||||
@ -144,7 +141,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
*分页查询书籍评论列表
|
||||
* */
|
||||
@PostMapping("listCommentByPage")
|
||||
@GetMapping("listCommentByPage")
|
||||
public ResultBean listCommentByPage(@RequestParam("bookId") Long bookId,@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize) {
|
||||
return ResultBean.ok(new PageInfo<>(bookService.listCommentByPage(null,bookId,page,pageSize)));
|
||||
}
|
||||
@ -165,7 +162,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 根据小说ID查询小说前十条最新更新目录集合
|
||||
* */
|
||||
@PostMapping("queryNewIndexList")
|
||||
@GetMapping("queryNewIndexList")
|
||||
public ResultBean queryNewIndexList(Long bookId){
|
||||
return ResultBean.ok(bookService.queryIndexList(bookId,"index_num desc",1,10));
|
||||
}
|
||||
@ -173,7 +170,7 @@ public class BookController extends BaseController{
|
||||
/**
|
||||
* 目录页
|
||||
* */
|
||||
@PostMapping("/queryIndexList")
|
||||
@GetMapping("/queryIndexList")
|
||||
public ResultBean indexList(Long bookId,@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,@RequestParam(value = "orderBy") String orderBy) {
|
||||
return ResultBean.ok(new PageInfo<>(bookService.queryIndexList(bookId,orderBy,page,pageSize)));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.java2nb.novel.core.bean.ResultBean;
|
||||
import com.java2nb.novel.service.FriendLinkService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -22,7 +23,7 @@ public class FriendLinkController {
|
||||
/**
|
||||
* 查询首页友情链接
|
||||
* */
|
||||
@PostMapping("listIndexLink")
|
||||
@GetMapping("listIndexLink")
|
||||
public ResultBean listIndexLink(){
|
||||
return ResultBean.ok(friendLinkService.listIndexLink());
|
||||
}
|
||||
|
@ -5,10 +5,7 @@ import com.java2nb.novel.core.bean.ResultBean;
|
||||
import com.java2nb.novel.service.NewsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
@ -24,7 +21,7 @@ public class NewsController {
|
||||
/**
|
||||
* 查询首页新闻
|
||||
* */
|
||||
@PostMapping("listIndexNews")
|
||||
@GetMapping("listIndexNews")
|
||||
public ResultBean listIndexNews(){
|
||||
return ResultBean.ok(newsService.listIndexNews());
|
||||
}
|
||||
@ -32,7 +29,7 @@ public class NewsController {
|
||||
/**
|
||||
* 分页查询新闻列表
|
||||
* */
|
||||
@PostMapping("listByPage")
|
||||
@GetMapping("listByPage")
|
||||
public ResultBean listByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize){
|
||||
return ResultBean.ok(new PageInfo<>(newsService.listByPage(page,pageSize)));
|
||||
}
|
||||
|
@ -15,10 +15,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
@ -115,7 +112,7 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 查询小说是否已加入书架
|
||||
*/
|
||||
@PostMapping("queryIsInShelf")
|
||||
@GetMapping("queryIsInShelf")
|
||||
public ResultBean queryIsInShelf(Long bookId, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
@ -140,8 +137,8 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 移出书架
|
||||
* */
|
||||
@PostMapping("removeFromBookShelf")
|
||||
public ResultBean removeFromBookShelf(Long bookId, HttpServletRequest request) {
|
||||
@DeleteMapping("removeFromBookShelf/{bookId}")
|
||||
public ResultBean removeFromBookShelf(@PathVariable("bookId") Long bookId, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
@ -153,7 +150,7 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 分页查询书架
|
||||
* */
|
||||
@PostMapping("listBookShelfByPage")
|
||||
@GetMapping("listBookShelfByPage")
|
||||
public ResultBean listBookShelfByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
@ -165,7 +162,7 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 分页查询阅读记录
|
||||
* */
|
||||
@PostMapping("listReadHistoryByPage")
|
||||
@GetMapping("listReadHistoryByPage")
|
||||
public ResultBean listReadHistoryByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
@ -203,7 +200,7 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 分页查询我的反馈列表
|
||||
* */
|
||||
@PostMapping("listUserFeedBackByPage")
|
||||
@GetMapping("listUserFeedBackByPage")
|
||||
public ResultBean listUserFeedBackByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize, HttpServletRequest request){
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
@ -215,7 +212,7 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 查询个人信息
|
||||
* */
|
||||
@PostMapping("userInfo")
|
||||
@GetMapping("userInfo")
|
||||
public ResultBean userInfo(HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
@ -263,7 +260,7 @@ public class UserController extends BaseController {
|
||||
/**
|
||||
* 分页查询用户书评
|
||||
* */
|
||||
@PostMapping("listCommentByPage")
|
||||
@GetMapping("listCommentByPage")
|
||||
public ResultBean listCommentByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
|
Reference in New Issue
Block a user