v1.0.13
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Skipped

This commit is contained in:
Timi
2026-08-13 17:52:03 +08:00
parent 348f7396a1
commit 36e2a37af2
14 changed files with 310 additions and 6 deletions
@@ -14,6 +14,21 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class Tag extends UUIDEntity {
///
///
/// @author 夜雨
/// @since 2026-08-12 16:49
public enum OwnerType {
GAO_STORE
}
/// 归属类型
protected OwnerType ownerType;
/// 归属 ID
protected String ownerId;
/// 名称多语言 ID
protected String nameLangId;
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.Tag;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@@ -13,4 +14,6 @@ import java.util.List;
public interface TagMapper extends BaseMapper<Tag, String> {
List<Tag> selectByIdList(Collection<String> idList);
Tag selectByOwnerAndZhCN(@Param("ownerType") Tag.OwnerType ownerType, @Param("ownerId") String ownerId, @Param("zhCN") String zhCN);
}
@@ -40,6 +40,9 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> impl
public void create(Tag tag) {
TimiException.required(tag, "not found tag");
TimiException.required(tag.getZhCN(), "not found tag.zhCN");
TimiException.required(tag.getOwnerType(), "not found ownerType");
TimiException.required(tag.getOwnerId(), "not found ownerId");
checkZhCNUniqueInOwner(tag, null);
tag.setNameLangId(multilingualService.create(tag.getZhCN()));
super.create(tag);
}
@@ -48,12 +51,15 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> impl
public void update(Tag tag) {
TimiException.required(tag, "not found tag");
TimiException.required(tag.getId(), "not found tag.id");
Tag dbTag = get(tag.getId());
TimiException.required(dbTag, "not found tag");
tag.setOwnerType(dbTag.getOwnerType());
tag.setOwnerId(dbTag.getOwnerId());
if (tag.getZhCN() != null) {
if (tag.getNameLangId() == null) {
Tag dbTag = get(tag.getId());
TimiException.required(dbTag, "not found tag");
tag.setNameLangId(dbTag.getNameLangId());
}
checkZhCNUniqueInOwner(tag, tag.getId());
tag.setNameLangId(multilingualService.createIfDifferent(tag.getNameLangId(), tag.getZhCN()));
}
super.update(tag);
@@ -97,4 +103,9 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> impl
example.setBizId(bizId);
return applyMapper.selectAllByExample(example);
}
private void checkZhCNUniqueInOwner(Tag tag, String allowedId) {
Tag existed = mapper.selectByOwnerAndZhCN(tag.getOwnerType(), tag.getOwnerId(), tag.getZhCN());
TimiException.requiredTrue(existed == null || existed.getId().equals(allowedId), "该标签名称已存在");
}
}