perf: 子域名托管重复域名不允许添加

v2^2
xiaojunnuo 2025-07-18 16:36:56 +08:00
parent 58fadc8928
commit ffc0c7bb7b
2 changed files with 22 additions and 1 deletions

View File

@ -415,7 +415,7 @@ export default {
is_present_no: "否",
basicInfo: "基础信息",
titlea: "名称",
disabled: "是否禁用",
disabled: "禁用",
ordera: "排序",
supportBuy: "支持购买",
intro: "介绍",

View File

@ -36,4 +36,25 @@ export class SubDomainService extends BaseService<SubDomainEntity> {
return list.map(item=>item.domain);
}
async add(bean: SubDomainEntity) {
const {domain, userId} = bean;
if (!domain) {
throw new Error('域名不能为空');
}
if (!userId) {
throw new Error('用户ID不能为空');
}
const exist = await this.repository.findOne({
where: {
domain,
userId,
},
});
if (exist) {
throw new Error('域名已存在');
}
return await super.add(bean)
}
}