🐛 修复作品集鉴权问题
This commit is contained in:
parent
534ad89633
commit
fe61bf1945
@ -76,7 +76,7 @@ public interface PortfolioService extends Service<Portfolio> {
|
||||
* @param idPortfolio
|
||||
* @return
|
||||
*/
|
||||
Map deletePortfolio(Integer idPortfolio);
|
||||
Map deletePortfolio(Integer idPortfolio) throws BaseApiException;
|
||||
|
||||
/**
|
||||
* 获取作品集列表数据
|
||||
|
@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.dto.*;
|
||||
import com.rymcu.forest.entity.Article;
|
||||
import com.rymcu.forest.entity.Portfolio;
|
||||
import com.rymcu.forest.entity.User;
|
||||
import com.rymcu.forest.mapper.PortfolioMapper;
|
||||
@ -152,11 +153,21 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map deletePortfolio(Integer idPortfolio) {
|
||||
public Map deletePortfolio(Integer idPortfolio) throws BaseApiException {
|
||||
Map map = new HashMap(1);
|
||||
if (idPortfolio == null || idPortfolio.equals(0)) {
|
||||
map.put("message", "作品集数据异常");
|
||||
}
|
||||
// 鉴权
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
Integer roleWeights = userService.findRoleWeightsByUser(user.getIdUser());
|
||||
if (roleWeights > 2) {
|
||||
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
||||
if (!user.getIdUser().equals(portfolio.getPortfolioAuthorId())) {
|
||||
map.put("message", "非法访问!");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Integer articleNumber = portfolioMapper.selectCountArticleNumber(idPortfolio);
|
||||
if (articleNumber > 0) {
|
||||
|
@ -68,7 +68,7 @@ public class PortfolioController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
public GlobalResult delete(Integer idPortfolio){
|
||||
public GlobalResult delete(Integer idPortfolio) throws BaseApiException {
|
||||
Map map = portfolioService.deletePortfolio(idPortfolio);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user