This commit is contained in:
parent
ef63b8f6db
commit
2897173672
|
|
@ -8,6 +8,7 @@ import live.tomey.api.express.service.NewsService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,7 +18,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/news")
|
@RequestMapping("/news")
|
||||||
public class NewsServiceController {
|
public class NewsController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private NewsService newsService;
|
private NewsService newsService;
|
||||||
|
|
||||||
|
|
@ -36,7 +37,24 @@ public class NewsServiceController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PassToken
|
||||||
|
@PostMapping("/post")
|
||||||
|
private Result<List<News>> postList(HttpServletRequest request){
|
||||||
|
try {
|
||||||
|
News news = new News();
|
||||||
|
news.setContent(request.getParameter("content"));
|
||||||
|
news.setImgUrl(request.getParameter("imgUrl"));
|
||||||
|
news.setTitle(request.getParameter("title"));
|
||||||
|
ServerResult<List<News>> serverResult = newsService.getNewsList(news);
|
||||||
|
if (serverResult.isStart()) {
|
||||||
|
return new Result<>(true, serverResult.getData());
|
||||||
|
} else {
|
||||||
|
return new Result<>(false, -1, serverResult.getMsg());
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
return new Result<>(false,-1,e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@PassToken
|
@PassToken
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
private Result<List<News>> List(News news) {
|
private Result<List<News>> List(News news) {
|
||||||
Loading…
Reference in New Issue