| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | 'use strict';/** * * * @author Mai * @date * @version */const moment = require('moment');const messageType = require('../const/message_type');const path = require('path');module.exports = {    moment,    setMessage(message, type) {        let icon = '';        switch (type) {            case messageType.SUCCESS:                icon = 'check';                break;            case messageType.ERROR:                icon = 'exclamation-circle';                break;            case messageType.INFO:                icon = 'info-circle';                break;            case messageType.WARNING:                icon = 'warning';                break;            default:                break;        }        this.session.message = {            type,            icon,            message,        };    },    postError(error, msg) {        if (error.stack) {            this.session.postError = msg;        } else {            this.session.postError = error.toString();        }    },    ajaxErrorBody(error, msg) {        if (error.stack) {            this.body = {err: 4, msg: msg, data: null};        } else {            this.body = {err: 3, msg: error.toString(), data: null};        }    },    log(error) {        if (error.stack) {            this.logger.error(error);        } else {            this.getLogger('fail').info(JSON.stringify({                error: error,                project: this.session.sessionProject,                user: this.session.sessionUser,                body: this.session.body,            }));        }    },    get hisOssPath() {        return this.app.config.hisOssPath;    },    get hisOss() {        return this.app.hisOss;    },    get stashOssPath() {        return this.app.config.stashOssPath;    },    print(str) {        this.getLogger('out').info(str);    },    saveTempFile(filename, text) {        const filepath = path.join(this.app.config.logger.dir, this.app.config.version, filename);        this.helper.saveBufferFile(text, filepath);    }};
 |