mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore: domain manager
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { Constants, CrudController } from '@certd/lib-server';
|
||||
import {DomainService} from "../../../modules/cert/service/domain-service.js";
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/cert/domain')
|
||||
export class DomainController extends CrudController<DomainService> {
|
||||
@Inject()
|
||||
service: DomainService;
|
||||
|
||||
getService(): DomainService {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
@Post('/page', { summary: Constants.per.authOnly })
|
||||
async page(@Body(ALL) body: any) {
|
||||
body.query = body.query ?? {};
|
||||
body.query.userId = this.getUserId();
|
||||
const domain = body.query.domain;
|
||||
delete body.query.domain;
|
||||
|
||||
const bq = qb => {
|
||||
if (domain) {
|
||||
qb.andWhere('domain like :domain', { domain: `%${domain}%` });
|
||||
}
|
||||
};
|
||||
|
||||
const pageRet = await this.getService().page({
|
||||
query: body.query,
|
||||
page: body.page,
|
||||
sort: body.sort,
|
||||
buildQuery: bq,
|
||||
});
|
||||
return this.ok(pageRet);
|
||||
}
|
||||
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Body(ALL) body: any) {
|
||||
body.query = body.query ?? {};
|
||||
body.query.userId = this.getUserId();
|
||||
const list = await this.getService().list(body);
|
||||
return this.ok(list);
|
||||
}
|
||||
|
||||
@Post('/add', { summary: Constants.per.authOnly })
|
||||
async add(@Body(ALL) bean: any) {
|
||||
bean.userId = this.getUserId();
|
||||
return super.add(bean);
|
||||
}
|
||||
|
||||
@Post('/update', { summary: Constants.per.authOnly })
|
||||
async update(@Body(ALL) bean: any) {
|
||||
await this.service.checkUserId(bean.id, this.getUserId());
|
||||
delete bean.userId;
|
||||
return super.update(bean);
|
||||
}
|
||||
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
async info(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@Post('/deleteByIds', { summary: Constants.per.authOnly })
|
||||
async deleteByIds(@Body(ALL) body: any) {
|
||||
await this.service.delete(body.ids, {
|
||||
userId: this.getUserId(),
|
||||
});
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,26 +13,26 @@ export class DomainEntity {
|
||||
@Column({ comment: '主域名', length: 100 })
|
||||
domain: string;
|
||||
|
||||
@Column({ comment: '校验类型', name: 'challenge_type', length: 100 })
|
||||
@Column({ comment: '校验类型', name: 'challenge_type', length: 50 })
|
||||
challengeType : string;
|
||||
|
||||
@Column({ comment: 'DNS提供商', name: 'dns_provider_type', length: 100 })
|
||||
@Column({ comment: 'DNS提供商', name: 'dns_provider_type', length: 50 })
|
||||
dnsProviderType: string;
|
||||
|
||||
@Column({ comment: 'DNS提供商授权', name: 'dns_provider_access', length: 200 })
|
||||
@Column({ comment: 'DNS提供商授权', name: 'dns_provider_access' })
|
||||
dnsProviderAccess: number;
|
||||
|
||||
@Column({ comment: '是否禁用', name: 'disabled' })
|
||||
disabled: boolean;
|
||||
|
||||
|
||||
@Column({ comment: 'http上传类型', name: 'http_uploader_type', length: 200 })
|
||||
@Column({ comment: 'http上传类型', name: 'http_uploader_type', length: 50 })
|
||||
httpUploaderType: string;
|
||||
|
||||
@Column({ comment: 'http上传授权', name: 'http_uploader_access', length: 200 })
|
||||
@Column({ comment: 'http上传授权', name: 'http_uploader_access' })
|
||||
httpUploaderAccess: number;
|
||||
|
||||
@Column({ comment: 'http上传根目录', name: 'http_upload_root_dir', length: 200 })
|
||||
@Column({ comment: 'http上传根目录', name: 'http_upload_root_dir', length: 512 })
|
||||
httpUploadRootDir: string;
|
||||
|
||||
@Column({
|
||||
|
||||
Reference in New Issue
Block a user