Files
certd/packages/ui/certd-server/src/controller/basic/settings-controller.ts
T

60 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-10-12 14:59:12 +08:00
import { Config, Controller, Get, Inject, Provide } from '@midwayjs/core';
2024-10-10 18:38:22 +08:00
import { BaseController, Constants, SysInstallInfo, SysPublicSettings, SysSettingsService, SysSiteEnv, SysSiteInfo } from '@certd/lib-server';
2024-10-05 01:46:25 +08:00
import { AppKey, getPlusInfo } from '@certd/pipeline';
/**
*/
@Provide()
@Controller('/api/basic/settings')
export class BasicSettingsController extends BaseController {
@Inject()
sysSettingsService: SysSettingsService;
2024-09-24 02:42:08 +08:00
@Config('account.server.baseUrl')
accountServerBaseUrl: any;
2024-10-10 18:38:22 +08:00
@Config('agent')
agentConfig: SysSiteEnv['agent'];
public async getSysPublic() {
2024-10-12 14:59:12 +08:00
return await this.sysSettingsService.getSetting(SysPublicSettings);
}
2024-08-25 01:55:34 +08:00
public async getInstallInfo() {
2024-09-24 02:42:08 +08:00
const settings: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
settings.accountServerBaseUrl = this.accountServerBaseUrl;
settings.appKey = AppKey;
2024-10-12 14:59:12 +08:00
return settings;
2024-08-25 01:55:34 +08:00
}
2024-09-23 11:27:53 +08:00
public async getSiteInfo() {
2024-10-12 14:59:12 +08:00
return await this.sysSettingsService.getSetting(SysSiteInfo);
2024-09-23 11:27:53 +08:00
}
2024-10-05 01:46:25 +08:00
2024-10-10 18:38:22 +08:00
public async getSiteEnv() {
const env: SysSiteEnv = {
agent: this.agentConfig,
};
2024-10-12 14:59:12 +08:00
return env;
2024-10-10 18:38:22 +08:00
}
2024-10-12 14:59:12 +08:00
async plusInfo() {
return getPlusInfo();
}
@Get('/all', { summary: Constants.per.guest })
async getAllSettings() {
const sysPublic = await this.getSysPublic();
const installInfo = await this.getInstallInfo();
const siteInfo = await this.getSiteInfo();
const siteEnv = await this.getSiteEnv();
const plusInfo = await this.plusInfo();
2024-10-05 01:46:25 +08:00
return this.ok({
2024-10-12 14:59:12 +08:00
sysPublic,
installInfo,
siteInfo,
siteEnv,
plusInfo,
2024-10-05 01:46:25 +08:00
});
}
}