build: trident-sync prepare

This commit is contained in:
xiaojunnuo
2023-01-29 13:44:19 +08:00
parent dcd1023a39
commit 07a45b4530
589 changed files with 36886 additions and 2 deletions

View File

@@ -0,0 +1,80 @@
import {
ALL,
Body,
Controller,
Inject,
Post,
Provide,
Query,
} from '@midwayjs/decorator';
import { CrudController } from '../../../basic/crud-controller';
import { AccessService } from '../service/access-service';
/**
* 授权
*/
@Provide()
@Controller('/api/pi/access')
export class AccessController extends CrudController {
@Inject()
service: AccessService;
getService() {
return this.service;
}
@Post('/page')
async page(@Body(ALL) body) {
body.query = body.query ?? {};
body.query.userId = this.ctx.user.id;
return super.page(body);
}
@Post('/list')
async list(@Body(ALL) body) {
body.userId = this.ctx.user.id;
return super.list(body);
}
@Post('/add')
async add(@Body(ALL) bean) {
bean.userId = this.ctx.user.id;
return super.add(bean);
}
@Post('/update')
async update(@Body(ALL) bean) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
return super.update(bean);
}
@Post('/info')
async info(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
return super.info(id);
}
@Post('/delete')
async delete(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
return super.delete(id);
}
@Post('/define')
async define(@Query('type') type) {
const provider = this.service.getDefineByType(type);
return this.ok(provider);
}
@Post('/accessTypeDict')
async getAccessTypeDict() {
const list = this.service.getDefineList();
const dict = [];
for (const item of list) {
dict.push({
value: item.name,
label: item.title,
});
}
return this.ok(dict);
}
}

View File

@@ -0,0 +1,40 @@
import {
ALL,
Controller,
Inject,
Post,
Provide,
Query,
} from '@midwayjs/decorator';
import { DnsProviderService } from '../service/dns-provider-service';
import { BaseController } from '../../../basic/base-controller';
/**
* 插件
*/
@Provide()
@Controller('/api/pi/dnsProvider')
export class DnsProviderController extends BaseController {
@Inject()
service: DnsProviderService;
@Post('/list')
async list(@Query(ALL) query) {
query.userId = this.ctx.user.id;
const list = this.service.getList();
return this.ok(list);
}
@Post('/dnsProviderTypeDict')
async getDnsProviderTypeDict() {
const list = this.service.getList();
const dict = [];
for (const item of list) {
dict.push({
value: item.name,
label: item.title,
});
}
return this.ok(dict);
}
}

View File

@@ -0,0 +1,106 @@
import {
ALL,
Body,
Controller,
Inject,
Post,
Provide,
Query,
} from '@midwayjs/decorator';
import { CrudController } from '../../../basic/crud-controller';
import { PipelineEntity } from '../entity/pipeline';
import { HistoryService } from '../service/history-service';
import { HistoryLogService } from '../service/history-log-service';
import { HistoryEntity } from '../entity/history';
import { HistoryLogEntity } from '../entity/history-log';
/**
* 证书
*/
@Provide()
@Controller('/api/pi/history')
export class HistoryController extends CrudController {
@Inject()
service: HistoryService;
@Inject()
logService: HistoryLogService;
getService() {
return this.service;
}
@Post('/page')
async page(@Body(ALL) body) {
body.query.userId = this.ctx.user.id;
return super.page(body);
}
@Post('/list')
async list(@Body(ALL) body) {
body.userId = this.ctx.user.id;
if (body.pipelineId == null) {
return this.ok([]);
}
const buildQuery = qb => {
qb.limit(10);
};
const listRet = await this.getService().list(
body,
{ prop: 'id', asc: false },
buildQuery
);
return this.ok(listRet);
}
@Post('/add')
async add(@Body(ALL) bean: PipelineEntity) {
bean.userId = this.ctx.user.id;
return super.add(bean);
}
@Post('/update')
async update(@Body(ALL) bean) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
return super.update(bean);
}
@Post('/save')
async save(@Body(ALL) bean: HistoryEntity) {
bean.userId = this.ctx.user.id;
if (bean.id > 0) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
}
await this.service.save(bean);
return this.ok(bean.id);
}
@Post('/saveLog')
async saveLog(@Body(ALL) bean: HistoryLogEntity) {
bean.userId = this.ctx.user.id;
if (bean.id > 0) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
}
await this.logService.save(bean);
return this.ok(bean.id);
}
@Post('/delete')
async delete(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
return super.delete(id);
}
@Post('/detail')
async detail(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
const detail = await this.service.detail(id);
return this.ok(detail);
}
@Post('/logs')
async logs(@Query('id') id) {
await this.logService.checkUserId(id, this.ctx.user.id);
const logInfo = await this.logService.info(id);
return this.ok(logInfo);
}
}

View File

@@ -0,0 +1,77 @@
import {
ALL,
Body,
Controller,
Inject,
Post,
Provide,
Query,
} from '@midwayjs/decorator';
import { CrudController } from '../../../basic/crud-controller';
import { PipelineService } from '../service/pipeline-service';
import { PipelineEntity } from '../entity/pipeline';
/**
* 证书
*/
@Provide()
@Controller('/api/pi/pipeline')
export class PipelineController extends CrudController {
@Inject()
service: PipelineService;
getService() {
return this.service;
}
@Post('/page')
async page(@Body(ALL) body) {
body.query.userId = this.ctx.user.id;
const buildQuery = qb => {
qb.where({});
};
return super.page({ ...body, buildQuery });
}
@Post('/add')
async add(@Body(ALL) bean: PipelineEntity) {
bean.userId = this.ctx.user.id;
return super.add(bean);
}
@Post('/update')
async update(@Body(ALL) bean) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
return super.update(bean);
}
@Post('/save')
async save(@Body(ALL) bean: PipelineEntity) {
bean.userId = this.ctx.user.id;
if (bean.id > 0) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
}
await this.service.save(bean);
return this.ok(bean.id);
}
@Post('/delete')
async delete(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
return super.delete(id);
}
@Post('/detail')
async detail(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
const detail = await this.service.detail(id);
return this.ok(detail);
}
@Post('/trigger')
async trigger(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
await this.service.trigger(id);
return this.ok({});
}
}

View File

@@ -0,0 +1,27 @@
import {
ALL,
Controller,
Inject,
Post,
Provide,
Query,
} from '@midwayjs/decorator';
import { BaseController } from '../../../basic/base-controller';
import { PluginService } from '../service/plugin-service';
/**
* 插件
*/
@Provide()
@Controller('/api/pi/plugin')
export class PluginController extends BaseController {
@Inject()
service: PluginService;
@Post('/list')
async list(@Query(ALL) query) {
query.userId = this.ctx.user.id;
const list = this.service.getList();
return this.ok(list);
}
}