const BaseController = require("./base"); class ConfigController extends BaseController { constructor(props) { super(props); } async getConfig() { try { let config = await this.service.config.getConfig(); return this.success(config) } catch (error) { return this.error(error) } } async setConfig() { try { this.ctx.validate({ ip: 'string', port: 'string', aet: 'string', region: 'string', accessKeyId: 'string', accessKeySecret: 'string', bucket: 'string', basePath: 'string', eiscPath: 'string', pacsPath: 'string', ossPacsPath: 'string', }) let { host,port,aet } = this.ctx.request.body let para = this.ctx.request.body let findOne = await this.ctx.model.Config.findOne({}) let result if (findOne) { result = await this.ctx.model.Config.updateOne({}, { $set: { ...para } }) } else { let pacs = new this.ctx.model.Config(para) result = await pacs.save() } // let pacs = this.ctx.model.Config(para) // let result = await pacs.save() return this.success(result) } catch (error) { return this.error(error) } } } module.exports = ConfigController;