...
|
...
|
@@ -10,20 +10,20 @@ import org.springframework.stereotype.Service; |
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@Service
|
|
|
public class PublicLabelService {
|
|
|
public class PublicLabelService {
|
|
|
|
|
|
@Resource
|
|
|
private PublicLabelRepository repository;
|
|
|
@Resource
|
|
|
private PublicLabelRepository repository;
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(PublicLabelService.class);
|
|
|
|
|
|
public void deletePublicLabel(PublicLabel publicLabel) throws Exception{
|
|
|
public void deletePublicLabel(PublicLabel publicLabel) throws Exception {
|
|
|
Integer relateId = publicLabel.getRelateId();
|
|
|
Integer srcChannel = publicLabel.getSrcChannel();
|
|
|
PublicLabel publicLabelFromDB = getByRelateIdAndSrcChannel(relateId, srcChannel);
|
|
|
if (publicLabelFromDB != null) {
|
|
|
repository.deleteById(publicLabelFromDB.getId());
|
|
|
}else{
|
|
|
} else {
|
|
|
logger.error("deletePublicLabel数据不存在relateId={}", publicLabel.getRelateId());
|
|
|
throw new Exception("deletePublicLabel失败");
|
|
|
}
|
...
|
...
|
@@ -34,18 +34,22 @@ public class PublicLabelService { |
|
|
Integer srcChannel = publicLabel.getSrcChannel();
|
|
|
PublicLabel publicLabelFromDB = getByRelateIdAndSrcChannel(relateId, srcChannel);
|
|
|
if (publicLabelFromDB != null) { //更新 需要保证原来的字段值不被null覆盖掉
|
|
|
publicLabelFromDB = BeanCopyUtils.copyNonNullProperties(publicLabel , publicLabelFromDB ,
|
|
|
publicLabelFromDB = BeanCopyUtils.copyNonNullProperties(publicLabel, publicLabelFromDB,
|
|
|
PublicLabel.class);
|
|
|
repository.save(publicLabelFromDB);
|
|
|
}else{ //新增
|
|
|
} else { //新增
|
|
|
repository.save(publicLabel);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private PublicLabel getByRelateIdAndSrcChannel(Integer relateId , Integer srcChannel){
|
|
|
if(relateId == null || srcChannel == null){
|
|
|
private PublicLabel getByRelateIdAndSrcChannel(Integer relateId, Integer srcChannel) {
|
|
|
if (relateId == null || srcChannel == null) {
|
|
|
return null;
|
|
|
}
|
|
|
return repository.findByRelateIdAndSrcChannel(relateId, srcChannel);
|
|
|
}
|
|
|
|
|
|
public Integer findIdByArticleId(Integer trueId, Integer grassSrcChannel) {
|
|
|
return repository.findIdByArticleId(trueId, grassSrcChannel);
|
|
|
}
|
|
|
} |
...
|
...
|
|