Commit 46ecc98c by 王昆

gsb

parent d560de0c
var fs = require("fs"); var fs = require("fs");
var objsettings = require("../config/objsettings"); var objsettings = require("../config/objsettings");
var settings = require("../config/settings"); var settings = require("../config/settings");
class System { class System {
static declare(ns) { static declare(ns) {
var ar = ns.split('.'); var ar = ns.split('.');
...@@ -15,6 +16,7 @@ class System { ...@@ -15,6 +16,7 @@ class System {
} }
} }
} }
static register(key, ClassObj) { static register(key, ClassObj) {
if (System.objTable[key] != null) { if (System.objTable[key] != null) {
throw new Error("相同key的对象已经存在"); throw new Error("相同key的对象已经存在");
...@@ -25,6 +27,7 @@ class System { ...@@ -25,6 +27,7 @@ class System {
return System.objTable[key]; return System.objTable[key];
} }
static getResult(data, opmsg = "操作成功", req) { static getResult(data, opmsg = "操作成功", req) {
return { return {
status: !data ? -1 : 0, status: !data ? -1 : 0,
...@@ -33,6 +36,7 @@ class System { ...@@ -33,6 +36,7 @@ class System {
bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : "empty" bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : "empty"
}; };
} }
/** /**
* 请求返回成功 * 请求返回成功
* @param {*} data 操作成功返回的数据 * @param {*} data 操作成功返回的数据
...@@ -45,6 +49,7 @@ class System { ...@@ -45,6 +49,7 @@ class System {
data: data || null, data: data || null,
}; };
} }
/** /**
* 请求返回失败 * 请求返回失败
* @param {*} status 操作失败状态,默认为-1 * @param {*} status 操作失败状态,默认为-1
...@@ -58,6 +63,7 @@ class System { ...@@ -58,6 +63,7 @@ class System {
data: data, data: data,
}; };
} }
static getObject(objpath) { static getObject(objpath) {
var pathArray = objpath.split("."); var pathArray = objpath.split(".");
var packageName = pathArray[0]; var packageName = pathArray[0];
...@@ -81,6 +87,7 @@ class System { ...@@ -81,6 +87,7 @@ class System {
return System.register(objabspath, ClassObj); return System.register(objabspath, ClassObj);
} }
} }
static getUiConfig(appid) { static getUiConfig(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js"; var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js";
if (settings.env == "dev") { if (settings.env == "dev") {
...@@ -89,6 +96,7 @@ class System { ...@@ -89,6 +96,7 @@ class System {
var configValue = require(configPath); var configValue = require(configPath);
return configValue; return configValue;
} }
static getUiConfig2(appid) { static getUiConfig2(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/index.js"; var configPath = settings.basepath + "/app/base/db/metadata/index.js";
// if(settings.env=="dev"){ // if(settings.env=="dev"){
...@@ -99,6 +107,7 @@ class System { ...@@ -99,6 +107,7 @@ class System {
var configValue = require(configPath); var configValue = require(configPath);
return configValue[appid]; return configValue[appid];
} }
static get_client_ip(req) { static get_client_ip(req) {
var ip = req.headers['x-forwarded-for'] || var ip = req.headers['x-forwarded-for'] ||
req.ip || req.ip ||
...@@ -144,6 +153,7 @@ class System { ...@@ -144,6 +153,7 @@ class System {
} }
} }
} }
static getUid(len, radix) { static getUid(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var uuid = [], var uuid = [],
...@@ -210,6 +220,7 @@ class System { ...@@ -210,6 +220,7 @@ class System {
} }
} }
} }
Date.prototype.Format = function (fmt) { //author: meizz Date.prototype.Format = function (fmt) { //author: meizz
var o = { var o = {
"M+": this.getMonth() + 1, //月份 "M+": this.getMonth() + 1, //月份
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment