const APIBase = require("../../api.base");
const system = require("../../../system");
const settings = require("../../../../config/settings");
/**
 * 用户端调用订单相关接口
 */
class Template extends APIBase {
    constructor() {
        super();
        this.templateinfoSve = system.getObject("service.template.templateinfoSve");
        this.templatelinkSve = system.getObject("service.template.templatelinkSve");
    }
    /**
      * 接口跳转-POST请求
      * action_process  执行的流程
      * action_type     执行的类型
      * action_body     执行的参数
      */
    async springBoard(pobj, qobj, req) {
        if (!pobj.actionType) {
            return system.getResult(null, "actionType参数不能为空");
        }
        var result = await this.opActionProcess(pobj, pobj.actionType, req);
        return result;
    }
    async opActionProcess(pobj, action_type, req) {
        var opResult = null;
        var self = this;
        pobj.clientIp = req.clientIp;
        pobj.xctx = req.xctx;
        switch (action_type) {
            case "test"://测试
                opResult = system.getResultSuccess("测试接口");
                break;
            // case "createTemplate"://创建模板
            //     opResult = await this.templateinfoSve.createTemplate(pobj);
            //     break;
            case "editTemplateContent"://修改模板内容
                opResult = await this.templateinfoSve.editTemplateContent(pobj);
                break;
            // case "updateSwitchStatus"://修改模板启用状态
            //     opResult = await this.templateinfoSve.updateSwitchStatus(pobj);
            //     break;
            case "findAndCountAll"://模板列表查询
                pobj.actionBody.company_id = pobj.company_id;
                opResult = await this.templateinfoSve.findAndCountAll(pobj.actionBody);
                break;
            case "findOneByCode"://模板查询
                opResult = await this.templateinfoSve.findOneByCode(pobj);
                break;
            // case "editTemplateTdk"://编辑模板TDK
            //     opResult = await this.templateinfoSve.editTemplateTdk(pobj);
            //     break;
            case "getTemplateAndLinkInfo"://根据链接参数获取模板链接信息
                opResult = await this.templatelinkSve.getTemplateAndLinkInfo(pobj);
                break;
            default:
                opResult = system.getResult(null, "action_type参数错误");
                break;
        }
        return opResult;
    }

}
module.exports = Template;
