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