mirror of https://github.com/certd/certd
perf: 子域名托管重复域名不允许添加
parent
58fadc8928
commit
ffc0c7bb7b
|
@ -415,7 +415,7 @@ export default {
|
|||
is_present_no: "否",
|
||||
basicInfo: "基础信息",
|
||||
titlea: "名称",
|
||||
disabled: "是否禁用",
|
||||
disabled: "禁用",
|
||||
ordera: "排序",
|
||||
supportBuy: "支持购买",
|
||||
intro: "介绍",
|
||||
|
|
|
@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue