|
|
|
@ -5,19 +5,13 @@ import java.util.Map;
|
|
|
|
|
import com.luoo.music.client.UserClient;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import com.luoo.music.pojo.Article;
|
|
|
|
|
import com.luoo.music.service.ArticleService;
|
|
|
|
|
|
|
|
|
|
import entity.PageResult;
|
|
|
|
|
import entity.Result;
|
|
|
|
|
import entity.StatusCode;
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import api.Result;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 控制器层
|
|
|
|
|
* @author Administrator
|
|
|
|
@ -34,33 +28,32 @@ public class ArticleController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserClient userClient;
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/admin",method = RequestMethod.GET)
|
|
|
|
|
public Result findAdmin(){
|
|
|
|
|
Result result =userClient.findAll();
|
|
|
|
|
return result;
|
|
|
|
|
@GetMapping("/admin")
|
|
|
|
|
public Result findAdmin(){
|
|
|
|
|
return userClient.findAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/examine/{articleId}",method = RequestMethod.PUT)
|
|
|
|
|
public Result examine (@PathVariable String articleId){
|
|
|
|
|
@PutMapping("/examine/{articleId}")
|
|
|
|
|
public Result<Void> examine (@PathVariable String articleId){
|
|
|
|
|
|
|
|
|
|
articleService.updateState(articleId);
|
|
|
|
|
return new Result(true,StatusCode.OK,"审核成功");
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/thumbup/{articleId}",method = RequestMethod.PUT)
|
|
|
|
|
public Result thumbup (@PathVariable String articleId){
|
|
|
|
|
@PutMapping("/thumbup/{articleId}")
|
|
|
|
|
public Result<Void> thumbup (@PathVariable String articleId){
|
|
|
|
|
|
|
|
|
|
articleService.addThumbup(articleId);
|
|
|
|
|
return new Result(true,StatusCode.OK,"点赞成功");
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询全部数据
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(method= RequestMethod.GET)
|
|
|
|
|
public Result findAll(){
|
|
|
|
|
return new Result(true,StatusCode.OK,"查询成功",articleService.findAll());
|
|
|
|
|
@GetMapping
|
|
|
|
|
public Result<List<Article>> findAll(){
|
|
|
|
|
return Result.success(articleService.findAll());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -68,14 +61,14 @@ public class ArticleController {
|
|
|
|
|
* @param id ID
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/{id}",method= RequestMethod.GET)
|
|
|
|
|
public Result findById(@PathVariable String id){
|
|
|
|
|
return new Result(true,StatusCode.OK,"查询成功",articleService.findById(id));
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
public Result<Article> findById(@PathVariable String id){
|
|
|
|
|
return Result.success(articleService.findById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/findByVolid/{volid}",method = RequestMethod.GET)
|
|
|
|
|
public Result findByVolid(@PathVariable String volid){
|
|
|
|
|
return new Result(true,StatusCode.OK,"查询成功",articleService.findByVolid(volid));
|
|
|
|
|
@GetMapping("/findByVolid/{volid}")
|
|
|
|
|
public Result<Article> findByVolid(@PathVariable String volid){
|
|
|
|
|
return Result.success(articleService.findByVolid(volid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -86,10 +79,10 @@ public class ArticleController {
|
|
|
|
|
* @param size 页大小
|
|
|
|
|
* @return 分页结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
|
|
|
|
|
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
|
|
|
|
|
@PostMapping("/search/{page}/{size}")
|
|
|
|
|
public Result<PageResult<Article>> findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
|
|
|
|
|
Page<Article> pageList = articleService.findSearch(searchMap, page, size);
|
|
|
|
|
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Article>(pageList.getTotalElements(), pageList.getContent()) );
|
|
|
|
|
return Result.success(new PageResult<Article>(pageList.getTotalElements(), pageList.getContent()) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -97,40 +90,40 @@ public class ArticleController {
|
|
|
|
|
* @param searchMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/search",method = RequestMethod.POST)
|
|
|
|
|
public Result findSearch( @RequestBody Map searchMap){
|
|
|
|
|
return new Result(true,StatusCode.OK,"查询成功",articleService.findSearch(searchMap));
|
|
|
|
|
@PostMapping("/search")
|
|
|
|
|
public Result<List<Article>> findSearch( @RequestBody Map searchMap){
|
|
|
|
|
return Result.success(articleService.findSearch(searchMap));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 增加
|
|
|
|
|
* @param article
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(method=RequestMethod.POST)
|
|
|
|
|
public Result add(@RequestBody Article article ){
|
|
|
|
|
@PostMapping
|
|
|
|
|
public Result<Void> add(@RequestBody Article article ){
|
|
|
|
|
articleService.add(article);
|
|
|
|
|
return new Result(true,StatusCode.OK,"增加成功");
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改
|
|
|
|
|
* @param article
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
|
|
|
|
|
public Result update(@RequestBody Article article, @PathVariable String id ){
|
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
|
public Result<Void> update(@RequestBody Article article, @PathVariable String id ){
|
|
|
|
|
article.setId(id);
|
|
|
|
|
articleService.update(article);
|
|
|
|
|
return new Result(true,StatusCode.OK,"修改成功");
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/{id}",method= RequestMethod.DELETE)
|
|
|
|
|
public Result delete(@PathVariable String id ){
|
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
|
public Result<Void> delete(@PathVariable String id ){
|
|
|
|
|
articleService.deleteById(id);
|
|
|
|
|
return new Result(true,StatusCode.OK,"删除成功");
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|