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
@@ -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), "该标签名称已存在");
}
}