...
|
...
|
@@ -3,12 +3,14 @@ package com.yohobuy.platform.grass.service.impl; |
|
|
|
|
|
import com.yohobuy.platform.common.util.BeanTool;
|
|
|
import com.yohobuy.platform.common.util.DateUtil;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassArticleLabelDao;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassLabelDAO;
|
|
|
import com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassLabel;
|
|
|
import com.yohobuy.platform.dal.grass.model.LabelGroup;
|
|
|
import com.yohobuy.platform.grass.service.IlabelGroupService;
|
|
|
import com.yohobuy.platform.grass.service.IlabelService;
|
|
|
import com.yohobuy.platform.model.common.ApiResponse;
|
|
|
import com.yohobuy.platform.model.common.PageResponseVO;
|
|
|
import com.yohobuy.platform.model.grass.request.GrassLabelReq;
|
|
|
import com.yohobuy.platform.model.grass.request.LabelGroupReq;
|
...
|
...
|
@@ -36,6 +38,9 @@ public class LabelServiceImpl implements IlabelService { |
|
|
@Autowired
|
|
|
private IGrassLabelGroupDAO labelGroupDAO;
|
|
|
|
|
|
@Autowired
|
|
|
private IGrassArticleLabelDao grassArticleLabelDao;
|
|
|
|
|
|
@Override
|
|
|
public PageResponseVO<GrassLabelBo> getGrassLabelList(GrassLabelReq req) {
|
|
|
logger.info("enter getGrassLabelList req={} ", req);
|
...
|
...
|
@@ -58,7 +63,8 @@ public class LabelServiceImpl implements IlabelService { |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void addUpLabel(GrassLabelReq req) {
|
|
|
public ApiResponse addUpLabel(GrassLabelReq req) {
|
|
|
try{
|
|
|
logger.info("enter addUpLabel req={}", req);
|
|
|
Integer id = req.getId();
|
|
|
GrassLabel record = new GrassLabel();
|
...
|
...
|
@@ -82,13 +88,28 @@ public class LabelServiceImpl implements IlabelService { |
|
|
labelGroupDAO.updateLabelNum(req.getGroupId(), true);
|
|
|
logger.info("addUpLabel insert success! req={}",req);
|
|
|
}
|
|
|
|
|
|
return new ApiResponse.ApiResponseBuilder().build();
|
|
|
}catch (Exception e){
|
|
|
logger.warn("addUpLabel req={} error, e{}",req, e);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(201).build();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void deleteLabel(GrassLabelReq req) {
|
|
|
public ApiResponse deleteLabel(GrassLabelReq req) {
|
|
|
logger.info("enter deleteLabel req={} ",req);
|
|
|
grassLabelDAO.deleteByPrimaryKey(req.getId());
|
|
|
Integer labelId = req.getId();
|
|
|
//文章 关联了 标签 则不允许删除
|
|
|
int count = grassArticleLabelDao.countByLabelId(labelId);
|
|
|
if(count > 0 ){
|
|
|
logger.info("deleteLabel req={} error! bind with articles ",req);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(201).message("标签与文章绑定,不能删除").build();
|
|
|
}
|
|
|
grassLabelDAO.deleteByPrimaryKey(labelId);
|
|
|
labelGroupDAO.updateLabelNum(req.getGroupId(),false);
|
|
|
return new ApiResponse.ApiResponseBuilder().message("success").build();
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
|