|
@@ -13,6 +13,7 @@ import cn.rankin.productservice.repository.MerchantProductRepository;
|
|
|
import cn.rankin.productservice.repository.TagGroupRepository;
|
|
|
import cn.rankin.productservice.repository.TagRepository;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -127,15 +128,25 @@ public class TagService {
|
|
|
|
|
|
@Transactional
|
|
|
public APIResult<Tag> create(TagDTO tagDTO) {
|
|
|
+ Tag tag = convert(tagDTO);
|
|
|
+
|
|
|
+ String merchantId = null;
|
|
|
+
|
|
|
String groupId = tagDTO.getGroupId();
|
|
|
- TagGroup tagGroup = tagGroupRepository.find(groupId);
|
|
|
- if (tagGroup == null) {
|
|
|
- return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
|
|
|
- }
|
|
|
+ if(StringUtils.isNotBlank(groupId)){
|
|
|
+ //兼容旧版本 tagGroup
|
|
|
+ TagGroup tagGroup = tagGroupRepository.find(groupId);
|
|
|
+ if (tagGroup == null) {
|
|
|
+ return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
- String merchantId = tagGroup.getMerchantId();
|
|
|
+ merchantId = tagGroup.getMerchantId();
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //新版本
|
|
|
+ merchantId = tagDTO.getMerchantId();
|
|
|
+ }
|
|
|
|
|
|
- Tag tag = convert(tagDTO);
|
|
|
tag.setMerchantId(merchantId);
|
|
|
Tag result = tagRepository.save(tag);
|
|
|
|