✨ 作品集功能完善
This commit is contained in:
parent
9c38e94b04
commit
d747b6f9bc
@ -65,4 +65,12 @@ public interface PortfolioMapper extends Mapper<Portfolio> {
|
||||
* @return
|
||||
*/
|
||||
Integer updateArticleSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle, @Param("sortNo") Integer sortNo);
|
||||
|
||||
/**
|
||||
* 取消绑定文章
|
||||
* @param idPortfolio
|
||||
* @param idArticle
|
||||
* @return
|
||||
*/
|
||||
Integer unbindArticle(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle);
|
||||
}
|
||||
|
@ -62,4 +62,19 @@ public interface PortfolioService extends Service<Portfolio> {
|
||||
* @return
|
||||
*/
|
||||
Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle);
|
||||
|
||||
/**
|
||||
* 取消绑定文章
|
||||
* @param idPortfolio
|
||||
* @param idArticle
|
||||
* @return
|
||||
*/
|
||||
Map unbindArticle(Integer idPortfolio, Integer idArticle);
|
||||
|
||||
/**
|
||||
* 删除作品集
|
||||
* @param idPortfolio
|
||||
* @return
|
||||
*/
|
||||
Map deletePortfolio(Integer idPortfolio);
|
||||
}
|
||||
|
@ -50,6 +50,9 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
@Override
|
||||
public PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type) {
|
||||
PortfolioDTO portfolio = portfolioMapper.selectPortfolioDTOById(idPortfolio,type);
|
||||
if (portfolio == null) {
|
||||
return new PortfolioDTO();
|
||||
}
|
||||
Author author = userService.selectAuthor(portfolio.getPortfolioAuthorId());
|
||||
genPortfolioAuthor(portfolio,author);
|
||||
Integer articleNumber = portfolioMapper.selectCountArticleNumber(portfolio.getIdPortfolio());
|
||||
@ -96,7 +99,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
public Map bindArticle(PortfolioArticleDTO portfolioArticle) {
|
||||
Map map = new HashMap(1);
|
||||
Integer count = portfolioMapper.selectCountPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio());
|
||||
if (count == 0) {
|
||||
if (count.equals(0)) {
|
||||
Integer maxSortNo = portfolioMapper.selectMaxSortNo(portfolioArticle.getIdPortfolio());
|
||||
portfolioMapper.insertPortfolioArticle(portfolioArticle.getIdArticle(),portfolioArticle.getIdPortfolio(),maxSortNo);
|
||||
map.put("message", "绑定成功!");
|
||||
@ -109,10 +112,10 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
@Override
|
||||
public Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle) {
|
||||
Map map = new HashMap(1);
|
||||
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio() == 0) {
|
||||
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio().equals(0)) {
|
||||
map.put("message", "作品集数据异常!");
|
||||
}
|
||||
if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle() == 0) {
|
||||
if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle().equals(0)) {
|
||||
map.put("message", "文章数据异常!");
|
||||
}
|
||||
if (portfolioArticle.getSortNo() == null) {
|
||||
@ -127,6 +130,44 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map unbindArticle(Integer idPortfolio, Integer idArticle) {
|
||||
Map map = new HashMap(1);
|
||||
if (idPortfolio == null || idPortfolio.equals(0)) {
|
||||
map.put("message", "作品集数据异常");
|
||||
}
|
||||
if (idArticle == null || idArticle.equals(0)) {
|
||||
map.put("message", "文章数据异常");
|
||||
}
|
||||
Integer result = portfolioMapper.unbindArticle(idPortfolio,idArticle);
|
||||
if (result > 0) {
|
||||
map.put("message", "操作成功!");
|
||||
} else {
|
||||
map.put("message", "操作失败!");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map deletePortfolio(Integer idPortfolio) {
|
||||
Map map = new HashMap(1);
|
||||
if (idPortfolio == null || idPortfolio.equals(0)) {
|
||||
map.put("message", "作品集数据异常");
|
||||
}
|
||||
|
||||
Integer articleNumber = portfolioMapper.selectCountArticleNumber(idPortfolio);
|
||||
if (articleNumber > 0) {
|
||||
map.put("message", "该作品集已绑定文章不允许删除!");
|
||||
} else {
|
||||
Integer result = portfolioMapper.deleteByPrimaryKey(idPortfolio);
|
||||
if (result.equals(0)) {
|
||||
map.put("message", "操作失败!");
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private PortfolioDTO genPortfolioAuthor(PortfolioDTO portfolioDTO, Author author) {
|
||||
portfolioDTO.setPortfolioAuthorAvatarUrl(author.getUserAvatarURL());
|
||||
portfolioDTO.setPortfolioAuthorName(author.getUserNickname());
|
||||
|
@ -61,4 +61,16 @@ public class PortfolioController {
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@DeleteMapping("/unbind-article")
|
||||
public GlobalResult unbindArticle(Integer idArticle,Integer idPortfolio) {
|
||||
Map map = portfolioService.unbindArticle(idPortfolio,idArticle);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
public GlobalResult delete(Integer idPortfolio){
|
||||
Map map = portfolioService.deletePortfolio(idPortfolio);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,9 @@
|
||||
<update id="updateArticleSortNo">
|
||||
update vertical_portfolio_article set sort_no = #{sortNo} where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle}
|
||||
</update>
|
||||
<delete id="unbindArticle">
|
||||
delete from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle}
|
||||
</delete>
|
||||
<select id="selectUserPortfoliosByIdUser" resultMap="DTOResultMap">
|
||||
select id, portfolio_head_img_url, portfolio_title, portfolio_author_id, portfolio_description, updated_time from vertical_portfolio where portfolio_author_id = #{idUser}
|
||||
</select>
|
||||
|
Loading…
Reference in New Issue
Block a user