123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import { IncomingMessage, ServerResponse } from "http";
- import request from "request";
- import Session from "../system/module/mvc/lib/session";
- /**
- * Global variable
- **/
- declare global{
- //系统对象
- let SYSTEM:any;
- //全局FS对象
- let FILE:any;
- //全局Request
- let REQUEST:request;
- //全局Moment
- let Moment:Moment;
- //Logger
- declare namespace LOGGER {
- function log(msg:string):void;
- function info(msg:string):void;
- function debug(msg:string):void;
- function warn(msg:string):void;
- function error(msg:string):void;
- }
- //数据库配置项接口
- declare interface DBOption{
- host:string,
- port:number,
- user?:string,
- password?:string,
- database?:string,
- prefix?:string
- }
- declare function DBCallback(err:Error,data:any):void;
- declare function H(helperName:string):any;
- declare function M(moduleName:string):any;
- // declare namespace DBManager {
- // function create(DatabaseType:string,option:DBOption,GlobalName?:string,callback?:(err:Error|null,conn?:any)=>void);
- // /**
- // * @param dbname 数据库名称,目前支持: redis | mysql | mongodb | memcache
- // */
- // function getOption(dbname:string):DBOption;
- // }
- // let ROOTPATH:string;
- // let SYSTEM:object;
- declare interface RequestData{
- req:IncomingMessage|undefined,
- res:ServerResponse|undefined,
- path:string|null,
- refer:any,
- method:string,
- COOKIE:any,
- GET:any,
- POST:any,
- UPLOAD:any,
- SESSION:any
- }
- declare class CONTROLLER{
- REFERER:string;
- REQPATH:string;
- REQMETHOD:string;
- REQTIME:number;
- COOKIE:any;
- GET:any;
- POST:any;
- UPLOAD:any;
- SESSION:Session;
- DATA:AnyKeyString;
- end(data:any,status?:number,mime?:string):void;
- endRedirect(location:string,permanently?:boolean);
- endJSON(somthing:any);
- endAPI(errorCode:number,somthing:any);
- endView(viewname:string,data?:any,option?:any);
- setCookie(key:string,value:any,expire?:number|'forever',path?:string);
- renewCookie(key:string,expire:number|'forever',path?:string);
- }
- declare class MysqlUtil{
- /**
- * K-V数据转为Sql语句结构
- **/
- public static objToKVString(obj:any,joinStr?:string,keyPrefix?:string);
- /**
- * 自动处理数据模型与数据,返回处理后符合模型的数据对象,包含数据安全性处理
- * @param module 数据模型
- * @param data 待处理数据
- * @param filter 自动过滤非模型字段数据(可选,默认不过滤)
- * @prarm reverse 反向处理,由写入处理变为取出处理,并自动根据模型字段类型进行可视化处理(可选,默认写入状态)
- **/
- public static analyzeFields(module:any,data:any,filter?:boolean,reverse?:boolean)
- public static escape(value:any);
- public static createPageLimit(page?:number,perPage?:number,orderField?:string);
- public static createOrderBy(order_filed?:string,order_desc?:boolean);
- }
- declare interface MysqlResult{err:any|null,data:any|Array|null|undefined}
- declare interface AnyKeyString{[key:string]:any}
- }
- export = {}
|