Commit 2c33b8a6 by 王栋源

wdy

parent 260d0592
#!/bin/bash #!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang/node105:v2 FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com" MAINTAINER jy "jiangyong@gongsibao.com"
ADD igirl-channel-web /apps/igirl-channel-web/ ADD center-admin /apps/center-admin/
WORKDIR /apps/igirl-channel-web/ WORKDIR /apps/center-admin/
RUN cnpm install -S RUN cnpm install -S
CMD ["node","/apps/igirl-channel-web/main.js"] CMD ["node","/apps/center-admin/main.js"]
......
node_modules/ node_modules/
\ No newline at end of file
{ {
// 使用 IntelliSense 了解相关属性。 // Use IntelliSense to learn about possible attributes.
// 悬停以查看现有属性的描述。 // Hover to view descriptions of existing attributes.
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
......
const system = require("../system"); const system = require("../system");
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const uuidv4 = require('uuid/v4');
const DocBase = require("./doc.base"); const DocBase = require("./doc.base");
class APIBase extends DocBase { class APIBase extends DocBase {
constructor() { constructor() {
...@@ -8,54 +9,69 @@ class APIBase extends DocBase { ...@@ -8,54 +9,69 @@ class APIBase extends DocBase {
this.logCtl = system.getObject("web.common.oplogCtl"); this.logCtl = system.getObject("web.common.oplogCtl");
this.apitradeSvr = system.getObject("service.common.apitradeSve"); this.apitradeSvr = system.getObject("service.common.apitradeSve");
} }
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
async isExistInNoAuthMainfest(gname, methodname) { async isExistInNoAuthMainfest(gname, methodname) {
var fullname = gname + "." + methodname; var fullname = gname + "." + methodname;
var lst = [ var lst = [
"test.test",
"transfer.acceptOrder",
"transfer.queryOrderState",
"transfer.closeOrder",
"transfer.test",
"transfer.queryOrder",
"transfer.selnotarytype",
"transfer.writecommunicationlog",
"transfer.uppaymentstatus",
"transfer.m5"
]; ];
var x = lst.indexOf(fullname); var x = lst.indexOf(fullname);
return x >= 0; return x >= 0;
} }
async checkAcck(gname, methodname, pobj, query, req) { async checkAcck(gname, methodname, pobj, query, req) {
var apptocheck=null; var apptocheck = null;
var isExistInNoAuth = await this.isExistInNoAuthMainfest(gname, methodname); var isExistInNoAuth = await this.isExistInNoAuthMainfest(gname, methodname);
if (!isExistInNoAuth) {//在验证请单里面,那么就检查访问token if (!isExistInNoAuth) {//在验证请单里面,那么就检查访问token
var ak = req.headers["accesskey"]; var ak = req.headers["accesskey"];
apptocheck = await this.cacheManager["ApiAccessKeyCheckCache"].cache(ak, { status: true }, 3000); apptocheck = await this.cacheManager["ApiAccessKeyCheckCache"].cache(ak, { status: true }, 3000);
} }
return {apptocheck:apptocheck,ispass:isExistInNoAuth || apptocheck}; return { apptocheck: apptocheck, ispass: isExistInNoAuth || apptocheck };
} }
async doexec(gname, methodname, pobj, query, req) { async doexec(gname, methodname, pobj, query, req) {
try { try {
var requestid = req.headers["request-id"] || this.getUUID();
//检查访问token //检查访问token
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req); var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (!isPassResult.ispass) { if (!isPassResult.ispass) {
// return system.getResultFail(system.tokenFail, "访问token失效,请重新获取"); return system.getResultFail(system.tokenFail, "访问token失效,请重新获取");
// } }
pobj.requestid = requestid
var rtn = await this[methodname](pobj, query); var rtn = await this[methodname](pobj, query);
// if(isPassResult.apptocheck){ if (isPassResult.apptocheck) {
// var app=isPassResult.apptocheck.app; var app = isPassResult.apptocheck.app;
// if(methodname && methodname.indexOf("recvNotificationForCacheCount")<0){ if (methodname && methodname.indexOf("recvNotificationForCacheCount") < 0) {
// this.apitradeSvr.create({ this.apitradeSvr.create({
// srcappkey: app.appkey, srcappkey: app.appkey,
// tradeType: "consume", tradeType: "consume",
// op: req.classname + "/" + methodname, op: req.classname + "/" + methodname + "; requestid:" + requestid,
// params: JSON.stringify(pobj), params: JSON.stringify(pobj),
// clientIp: req.clientIp, clientIp: req.clientIp,
// agent: req.uagent, agent: req.uagent,
// destappkey:settings.appKey, destappkey: settings.appKey,
// }); });
// } }
// } }
return rtn; return rtn;
} catch (e) { } catch (e) {
console.log(e.stack,"api调用出现异常,请联系管理员..........") console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.error({ this.logCtl.error({
optitle: "api调用出现异常,请联系管理员", optitle: "api调用出现异常,请联系管理员",
op: pobj.classname + "/" + methodname, op: pobj.classname + "/" + methodname + "; requestid:" + requestid,
content: e.stack, content: e.stack,
clientIp: pobj.clientIp clientIp: pobj.clientIp
}); });
......
var APIBase = require("../../api.base");
var system = require("../../../system");
const Client = require('aliyun-api-gateway').Client;
const client = new Client('203756933', '1hxwkxz2tyn80i3ucrdbchru59zpxibz');
const md5 = require("MD5");
class TradeTransferAPI extends APIBase {
constructor() {
super();
this.tradetransferSve = system.getObject("service.transfer.tradetransferSve");
this.notarizationflowSve = system.getObject("service.transfer.notarizationflowSve");
}
async acceptOrder(pobj, query) {
pobj.channelParams.fq_ordernum = pobj.orderNo;
return await this.tradetransferSve.createtransfer(pobj.channelParams);
}
async closeOrder(pobj, query) {
return await this.tradetransferSve.orderclose(pobj);
}
async queryOrderState(pobj, query) {
return await this.tradetransferSve.ordersel(pobj);
}
async queryOrder(pobj, query) {
return await this.tradetransferSve.querytradeproducelist(pobj);
}
async selnotarytype(pobj, query) {
return await this.notarizationflowSve.selnotarytype(pobj);
}
async writecommunicationlog(pobj, query) {
return await this.tradetransferSve.writecommunicationlog(pobj);
}
async uppaymentstatus() {
return await this.tradetransferSve.uppaymentstatus();
}
async m5(p) {
var keys = p.keys(jsonObj).sort();
if (keys.length == 0) {
reqResult.code = -230;
reqResult.msg = "请求参数信息为空";
return reqResult;
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && jsonObj[tKey]) {
signArr.push(tKey + "=" + jsonObj[tKey]);
}
}
if (signArr.length == 0) {
reqResult.code = -250;
reqResult.msg = "请求组装签名参数信息为空";
return reqResult;
}
signArr.push("key=" + pay_key);
var signStr = signArr.join("&");
// console.log(signStr, ",signStr.......................");
var tmpSign = md5(signStr).toUpperCase();
var signStr = "appid=00000051&body=sdfg&cusid=990581007426001&notify_url=dfgdsfgdf&randomstr=dfghrtjjn&reqsn=1564125456123&returl=sdsd154541&trxamt=100&version=12"
var tmpSign = md5(signStr).toUpperCase();
return tmpSign
}
async test(pobj, query) {
var url = 'https://jaxiya.gongsibao.com/orders/refuse';
var result = await client.post(url, {
data: {
"BizId": "trademark_prepayment_pre-cn-o401er9gv01",
"UserName": "阿里云",
"Mobile": "18600480430",
"RegisterNumber": "25559504",
"Classification": "20",
"Price": "10"
},
headers: {
accept: 'application/json'
}
});
return result;
console.log(JSON.stringify(result));
}
exam() {
return "xxx";
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "x",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: null,
}
],
rtnTypeDesc: "xxxx",
rtnType: "xxx"
}
];
}
}
module.exports = TradeTransferAPI;
\ No newline at end of file
...@@ -2,7 +2,9 @@ const system = require("../system"); ...@@ -2,7 +2,9 @@ const system = require("../system");
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
class CtlBase { class CtlBase {
constructor() { constructor(gname, sname) {
this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
} }
...@@ -11,16 +13,91 @@ class CtlBase { ...@@ -11,16 +13,91 @@ class CtlBase {
var u = uuid.replace(/\-/g, ""); var u = uuid.replace(/\-/g, "");
return u; return u;
} }
async encryptPasswd(passwd) {
if (!passwd) {
throw new Error("请输入密码");
}
var rtn=await this.service.getEncryptStr(passwd);
return rtn;
}
notify(req, msg) { notify(req, msg) {
if (req.session) { if (req.session) {
req.session.bizmsg = msg; req.session.bizmsg = msg;
} }
} }
async findOne(queryobj, qobj) {
var rd = await this.service.findOne(qobj);
return system.getResult(rd);
}
async findAndCountAll(obj, queryobj, req) {
obj.codepath = req.codepath;
if (req.session.user) {
obj.uid = req.session.user.id;
}
//
// if(obj.search){
// obj.search.opath=obj.ppath;
// }
// if(obj.search){
// obj.search.company_id=obj.company_id;
// }
var apps = await this.service.findAndCountAll(obj);
return system.getResult(apps);
}
async refQuery(queryobj, qobj, req) {
// qobj.refwhere = { app_id: req.appid };
var rd = await this.service.refQuery(qobj);
return system.getResult(rd);
}
async bulkDelete(queryobj, ids) {
var rd = await this.service.bulkDelete(ids);
return system.getResult(rd);
}
async delete(queryobj, qobj) {
var rd = await this.service.delete(qobj);
return system.getResult(rd);
}
async create(qobj, queryobj, req) {
if (req && req.session && req.session.app) {
// qobj.app_id = req.appid;
if (req.codepath) {
qobj.codepath = req.codepath;
}
}
var rd = await this.service.create(qobj);
return system.getResult(rd);
}
async update(qobj, queryobj, req) {
if (req && req.session && req.session.user) {
qobj.onlyCode = req.session.user.unionId;
}
if (req.codepath) {
qobj.codepath = req.codepath;
}
var rd = await this.service.update(qobj);
return system.getResult(rd);
}
static getServiceName(ClassObj) { static getServiceName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve"; return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
} }
async initNewInstance(queryobj, req) {
return system.getResult({});
}
async findById(oid) {
var rd = await this.service.findById(oid);
return system.getResult(rd);
}
//按照单据号查询出单据
async findByCode(qobj,queryobj, req) {
var rd = await this.service.findOne({ id: qobj.code});
if (!rd) {
var rd = await this.service.findOne({ code: qobj.code});
}
return system.getResult(rd);
}
async timestampConvertDate(time) { async timestampConvertDate(time) {
if (time == null) { if (time == null) {
...@@ -46,12 +123,15 @@ class CtlBase { ...@@ -46,12 +123,15 @@ class CtlBase {
var d = new Date(time); var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(); return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
} }
async setContextParams(pobj, qobj, req) { async setContextParams(pobj, qobj, req) {
pobj.userid = req.session.user ? req.session.user.id : null; pobj.userid = req.session.user ? req.session.user.id : null;
//to do
if( req.session.user){
pobj.company_id=req.session.user.owner.id;
pobj.opath=req.session.user.opath;
pobj.ppath=req.session.user.ppath;
}
req.codepath=req.headers["codepath"];
} }
async doexec(methodname, pobj, query, req) { async doexec(methodname, pobj, query, req) {
......
...@@ -34,6 +34,9 @@ class UserCtl extends CtlBase { ...@@ -34,6 +34,9 @@ class UserCtl extends CtlBase {
//开始远程登录,返回code //开始远程登录,返回code
var jumpobj = await this.service.navSysSetting(req.session.user); var jumpobj = await this.service.navSysSetting(req.session.user);
if (jumpobj) { if (jumpobj) {
if(settings.companyKey){//说明是自主登录
jumpobj.jumpUrl=jumpobj.jumpUrl+"&companyKey="+settings.companyKey;
}
return system.getResultSuccess(jumpobj); return system.getResultSuccess(jumpobj);
} }
return system.getResultFail(); return system.getResultFail();
...@@ -67,7 +70,9 @@ class UserCtl extends CtlBase { ...@@ -67,7 +70,9 @@ class UserCtl extends CtlBase {
created_at: req.session.user.created_at, created_at: req.session.user.created_at,
email: req.session.user.email, email: req.session.user.email,
headUrl: req.session.user.headUrl, headUrl: req.session.user.headUrl,
roles: x ? x.join(",") : "" roles: x ? x.join(",") : "",
owner:req.session.user.owner,
isSelfLogin:settings.companyKey?true:false
} }
return system.getResult(tmp, "用户登录", req); return system.getResult(tmp, "用户登录", req);
} else { } else {
......
...@@ -6,15 +6,18 @@ class MetaCtl extends CtlBase { ...@@ -6,15 +6,18 @@ class MetaCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(MetaCtl)); super("common", CtlBase.getServiceName(MetaCtl));
this.userS = system.getObject("service.auth.userSve"); this.userS = system.getObject("service.auth.userSve");
this.service = system.getObject("service.common.metaSve");
} }
//根据查询参数来确定当前会话对应的应用 //根据查询参数来确定当前会话对应的应用
async getAppInfo(req) { async getAppInfo(req) {
var acckapp = await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, 3600); var acckapp = await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, 3600);
if(settings.companyKey){//说明单独登录
acckapp.app.oauthlogin=acckapp.app.oauthlogin.replace("#","&companyKey="+settings.companyKey+"#");
acckapp.app.oauthreg=acckapp.app.oauthreg.replace("#","&companyKey="+settings.companyKey+"#");
}
if (acckapp) { if (acckapp) {
var rs = await this.getRsConfig2(null, req); var rs = await this.getRsConfig2(null, req);
var bcom = await this.getBaseComp(); var bcom = await this.getBaseComp();
var rtn = { "appinfo": escape(JSON.stringify(acckapp.app)), "basecomp": bcom, "rsconfig": escape(JSON.stringify(rs)), "app": acckapp.app }; var rtn = { "paasurl":settings.paasUrl(),"appinfo": escape(JSON.stringify(acckapp.app)), "basecomp": bcom, "rsconfig": escape(JSON.stringify(rs)), "app": acckapp.app };
req.session.app = acckapp.app; req.session.app = acckapp.app;
return rtn; return rtn;
} else { } else {
...@@ -42,9 +45,9 @@ class MetaCtl extends CtlBase { ...@@ -42,9 +45,9 @@ class MetaCtl extends CtlBase {
} }
//权限 角色+资源节点code+权限字符串,codepath-- //权限 角色+资源节点code+权限字符串,codepath--
async getUiConfig(queryObj, req) { async getUiConfig(pobj,queryObj, req) {
var bizCode = queryObj.biz; var bizCode = queryObj.biz;
var cfg = await this.service.getUiConfig(settings.wxconfig.appId); var cfg = await this.service.getUiConfig(settings.appKey);
console.log(cfg); console.log(cfg);
var tmpRoleAuthStr = ""; var tmpRoleAuthStr = "";
if (req && req.session && req.session.user) { if (req && req.session && req.session.user) {
...@@ -54,7 +57,7 @@ class MetaCtl extends CtlBase { ...@@ -54,7 +57,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id); var auths = await this.service.findAuthsByRole(tmpRoles, req.session.user.app_id,req.session.user.owner.id);
var codeauthattrs = auths.map(r => { var codeauthattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
return r.authstrs; return r.authstrs;
...@@ -85,9 +88,9 @@ class MetaCtl extends CtlBase { ...@@ -85,9 +88,9 @@ class MetaCtl extends CtlBase {
return system.getResultSuccess(bizConfigData.config); return system.getResultSuccess(bizConfigData.config);
} }
async getDicConfig(queryObj, req) { async getDicConfig(pobj,queryObj, req) {
var dicKey = queryObj["dicKey"]; var dicKey = queryObj["dicKey"];
var cfg = await this.service.getUiConfig(settings.wxconfig.appId); var cfg = await this.service.getUiConfig(settings.appKey);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目 //获取当前登录人的角色,进而获取权限,进而合并工具栏目
if (dicKey == "data_priv") { if (dicKey == "data_priv") {
if (req.session && req.session.user && !req.session.user.isSuper) { if (req.session && req.session.user && !req.session.user.isSuper) {
...@@ -108,7 +111,7 @@ class MetaCtl extends CtlBase { ...@@ -108,7 +111,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.service.findAuthsByRole(tmpRoles, req.session.user.app_id); var auths = await this.service.findAuthsByRole(tmpRoles, req.session.user.app_id,req.session.user.owner.id);
var codepathattrs = auths.map(r => { var codepathattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
if (r.codepath) { if (r.codepath) {
...@@ -165,7 +168,7 @@ class MetaCtl extends CtlBase { ...@@ -165,7 +168,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.service.findAuthsByRole(tmpRoles, req.session.user.app_id); var auths = await this.service.findAuthsByRole(tmpRoles, req.session.user.app_id,req.session.user.owner.id);
var codepathattrs = auths.map(r => { var codepathattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
if (r.codepath) { if (r.codepath) {
......
...@@ -6,7 +6,7 @@ var moment = require("moment"); ...@@ -6,7 +6,7 @@ var moment = require("moment");
class OplogCtl extends CtlBase { class OplogCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(OplogCtl)); super("common", CtlBase.getServiceName(OplogCtl));
this.oplogSve=system.getObject("service.common.oplogSve"); //this.appS=system.getObject("service.appSve");
} }
async initNewInstance(qobj) { async initNewInstance(qobj) {
...@@ -17,23 +17,23 @@ class OplogCtl extends CtlBase { ...@@ -17,23 +17,23 @@ class OplogCtl extends CtlBase {
} }
async debug(obj) { async debug(obj) {
obj.logLevel = "debug"; obj.logLevel = "debug";
return this.oplogSve.create(obj); return this.create(obj);
} }
async info(obj) { async info(obj) {
obj.logLevel = "info"; obj.logLevel = "info";
return this.oplogSve.create(obj); return this.create(obj);
} }
async warn(obj) { async warn(obj) {
obj.logLevel = "warn"; obj.logLevel = "warn";
return this.oplogSve.create(obj); return this.create(obj);
} }
async error(obj) { async error(obj) {
obj.logLevel = "error"; obj.logLevel = "error";
return this.oplogSve.create(obj); return this.create(obj);
} }
async fatal(obj) { async fatal(obj) {
obj.logLevel = "fatal"; obj.logLevel = "fatal";
return this.oplogSve.create(obj); return this.create(obj);
} }
/* /*
......
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var moment = require("moment");
class NotarizationflowCtl extends CtlBase {
constructor() {
super("transfer", CtlBase.getServiceName(NotarizationflowCtl));
//this.appS=system.getObject("service.appSve");
}
//首次加载
async firstload(p, q) {
var notarinfo = await this.service.firstload(p);
return notarinfo;
}
//提交阿里
async submitali(p, q, req) {
var notarinfo = p;
if (notarinfo) {
var rtn = await this.service.update(notarinfo);
if (rtn) {
var alirtn = await this.service.setfiletoali(notarinfo);
if (alirtn) {
return { data: alirtn, status: 0, msg: "提交成功" }
}else{
return { data: null, status: -202, msg: "提交失败" }
}
}else{
return { data: null, status: -201, msg: "保存失败" }
}
}else{
return { data: null, status: -200, msg: "参数异常" }
}
}
}
module.exports = NotarizationflowCtl;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
class TmjsonfileCtl extends CtlBase {
constructor() {
super("transfer", CtlBase.getServiceName(TmjsonfileCtl));
this.execS = system.getObject("util.execClient");
this.uploadfileossurl=settings.uploadfileossurl();
}
async createjsonfile(p, o, q) {
var rtn = await this.service.createjsonfile();
var self=this;
console.log(rtn);
if (rtn.status > -1) {
var newdate = new Date();
var m = newdate.getMonth() + 1;
var d = newdate.getDate();
var strdate = ""
if (newdate.getHours() > 12) {
strdate = newdate.getFullYear() + "" + m + d + "_2.json";
} else {
strdate = newdate.getFullYear() + "" + m + d + "_1.json";
}
var self = this;;
var gobj = {
action: "GenerateUploadFilePolicy",
reqbody: { FileType: "PARTNER_SYNC_FILE" }
}
var rst = await self.service.aliclient(gobj);
console.log(rst)
var url=this.uploadfileossurl+"/uploadfile/"+strdate+"/"+rst.EncodedPolicy+"/"+rst.Signature;
var upl=await self.execS.execGet(null,url);
console.log(upl);
if(upl.stdout){
var obj = { zc_url: "https://partner-sync-file.oss-cn-beijing.aliyuncs.com/1956270874932536/"+ strdate};
var rtn = await this.service.create(obj);
if (rtn) {
return { status: 0, msg: "成功" };
}else{
return { status: -201, msg: "创建失败" };
}
}else {
return { status: -202, msg: "上传失败" };
}
} else {
return { status: -200, msg: "json文件生成失败" };
}
}
}
module.exports = TmjsonfileCtl;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
var cacheBaseComp = null;
class TradetransferCtl extends CtlBase {
constructor() {
super("transfer", CtlBase.getServiceName(TradetransferCtl));
this.postfile = system.getObject("util.restClient");
}
async submit(p, q, req) {
if (req && req.session && req.session.user) {
p.onlyCode = req.session.user.unionId;
}
if (req.codepath) {
p.codepath = req.codepath;
}
var result = null;
try {
if (p.transfer_status == "CONFIRM_ORDER") {
p.aliorder_status = "1",
result = await this.service.confirmorder(p);
console.log(result)
}
if (p.transfer_status == "CLOSE_ORDER_ONLY") {
p.aliorder_status = "11",
result = await this.service.refuseorder(p)
}
if (p.transfer_status == "PROVIDE_MATERIAL") {
p.aliorder_status = "3",
result = await this.service.supplymaterail(p)
}
if (p.transfer_status == "BUYER_EXPRESS") {
p.aliorder_status = "5",
result = await this.service.posttransfermatereial(p)
}
if (p.transfer_status == "BUYER_PROVIDE_MATERIAL") {
p.aliorder_status = "6",
result = await this.service.receivedtransfermaterail(p)
}
if (p.transfer_status == "SUBMIT_TO_SBJ") {
p.aliorder_status = "7",
result = await this.service.submittedtransfermaterail(p)
}
if (p.transfer_status == "SBJ_ACCEPT") {
p.aliorder_status = "8",
result = await this.service.acceptedtransfermaterail(p)
}
if (p.transfer_status == "SBJ_SUCCESS") {
p.aliorder_status = "8",
result = await this.service.approvedtransfer(p)
}
if (p.transfer_status == "SBJ_FAIL") {
p.aliorder_status = "8",
result = await this.service.refusetransfer(p)
}
if (p.transfer_status == "TRANSFER_SUCCESS") {
p.aliorder_status = "12",
result = await this.service.tradesuccess(p)
}
if (p.transfer_status == "TRANSFER_FAIL") {
p.aliorder_status = "10",
result = await this.service.tradefail(p)
}
if (p.transfer_status == "RefuseOrder") {
p.aliorder_status = "10",
result = await this.service.tradefail(p)
}
if (result && result.Success) {
var rd = await this.service.update(p);
return system.getResult(rd);
} else {
return system.getResult(null, "阿里请求失败");
}
} catch (error) {
return system.getResult(null, "请求异常");
}
}
async findone(p, q, req) {
var traninfo = await this.service.findOne({ ali_bizid: p.ali_bizid });
return { data: traninfo.dataValues, status: 0, msg: "操作成功" }
}
//获取签名
async generateuploadfilepolicy(p, q, req) {
var self = this;;
var gobj = {
action: "GenerateUploadFilePolicy",
reqbody: { FileType: "LEGAL_NOTICE" }
}
if (p.mtype && p.mtype == 'json') {
gobj.reqbody.FileType = 'PARTNER_SYNC_FILE';
}
try {
var rst = await self.service.aliclient(gobj);
console.log(rst)
var source = {
OSSAccessKeyId: rst.AccessId,
policy: rst.EncodedPolicy,
Signature: rst.Signature,
Bucket: 'trade-mark-user-upload',
url: "https://trade-mark-user-upload.oss-cn-beijing.aliyuncs.com",
filedir: rst.FileDir
}
if (p.mtype && p.mtype == 'json') {
source.url = "https://partner-sync-file.oss-cn-beijing.aliyuncs.com";
source.Bucket = "partner-sync-file";
}
console.log(source)
return source;
} catch (e) {
console.log(e)
}
}
}
module.exports = TradetransferCtl;
const system = require("../../../system"); const system = require("../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../config/settings");
function exp(db, DataTypes) { function exp(db, DataTypes) {
var base = { var base = {
code: { code: {
...@@ -7,6 +7,8 @@ function exp(db, DataTypes) { ...@@ -7,6 +7,8 @@ function exp(db, DataTypes) {
unique: true unique: true
}, },
name: DataTypes.STRING(1000), name: DataTypes.STRING(1000),
company_id:DataTypes.INTEGER,
opath:DataTypes.STRING(256),
}; };
return base; return base;
} }
......
...@@ -136,8 +136,6 @@ class Dao { ...@@ -136,8 +136,6 @@ class Dao {
if (extraFilter) { if (extraFilter) {
qc[extraFilter.key] = extraFilter.value; qc[extraFilter.key] = extraFilter.value;
} }
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
console.log(qc);
return qc; return qc;
} }
buildaggs(qobj) { buildaggs(qobj) {
...@@ -259,4 +257,4 @@ class Dao { ...@@ -259,4 +257,4 @@ class Dao {
return this.model.findById(oid); return this.model.findById(oid);
} }
} }
module.exports = Dao; module.exports = Dao;
\ No newline at end of file
...@@ -6,13 +6,21 @@ var glob = require("glob"); ...@@ -6,13 +6,21 @@ var glob = require("glob");
class DbFactory{ class DbFactory{
constructor(){ constructor(){
const dbConfig=settings.database(); const dbConfig=settings.database();
// const dbConfighb=settings.databasehb();
this.db=new Sequelize(dbConfig.dbname, this.db=new Sequelize(dbConfig.dbname,
dbConfig.user, dbConfig.user,
dbConfig.password, dbConfig.password,
dbConfig.config); dbConfig.config);
this.dbigirlweb=new Sequelize("igirl",
dbConfig.user,
dbConfig.password,
dbConfig.config);
this.db.Sequelize=Sequelize; this.db.Sequelize=Sequelize;
this.db.Op=Sequelize.Op; this.db.Op=Sequelize.Op;
this.dbigirlweb.Sequelize=Sequelize;
this.dbigirlweb.Op=Sequelize.Op;
this.initModels(); this.initModels();
this.initRelations(); this.initRelations();
} }
...@@ -30,26 +38,6 @@ class DbFactory{ ...@@ -30,26 +38,6 @@ class DbFactory{
console.log("init models...."); console.log("init models....");
} }
async initRelations(){ async initRelations(){
/**
一个账户对应多个登陆用户
一个账户对应一个commany
一个APP对应多个登陆用户
一个APP有多个角色
登陆用户和角色多对多
**/
/*建立账户和用户之间的关系*/
//account--不属于任何一个app,是统一用户
//用户登录时首先按照用户名和密码检查account是否存在,如果不存在则提示账号或密码不对,如果
//存在则按照按照accountid和应用key,查看user,后台实现对应user登录
/*建立api调用日志和api之间的关系*/
// this.db.models.apitrade.belongsTo(this.db.models.app,{constraints: false,});
} }
//async getCon(){,用于使用替换table模型内字段数据使用 //async getCon(){,用于使用替换table模型内字段数据使用
getCon(){ getCon(){
...@@ -77,11 +65,11 @@ class DbFactory{ ...@@ -77,11 +65,11 @@ class DbFactory{
} }
return this.db; return this.db;
} }
getConhb(){ getConigirl(){
var that=this; var that=this;
if(settings.env=="dev"){ if(settings.env=="dev"){
} }
return this.dbhb; return this.dbigirlweb;
} }
} }
module.exports=DbFactory; module.exports=DbFactory;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppDao extends Dao {
constructor() {
super(Dao.getModelName(AppDao));
}
async getItemByAppKey(appKey) {
return this.model.findOne({
where: {
uappKey: appKey
},
attributes: ["id",
"name", // 应用名称
"appDataOpType", // 应用数据操作类型:00独立,10全委托,20部分委托
"appPayType", // 支付类型:00第三方应用自己支付,10平台代收款
"contactName", // 联系人姓名
"contactMobile", // 联系人手机
"contactEmail", // 联系人邮箱
"uappKey", // 平台应用key
"appSecret", // 密钥信息,用于进行签名请求接口
"status", // 状态 0禁用 1启用
"uAppId",
"channelAppId", // 渠道appID
"channelAppKey", // 渠道appKey
"pushOrderUrl", //获取渠道推送订单的url
"appSourceCode", //app来源code
"notes"],
raw: true
});
}
}
module.exports = AppDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppProductDao extends Dao {
constructor() {
super(Dao.getModelName(AppProductDao));
}
async findOneByServiceItemCode(itemCode, appId) {
return this.model.findOne({
where: {
serviceItemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
async findOneByCode(itemCode, appId) {
return this.model.findOne({
where: {
itemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
async findOneByChannelItemCode(channelItemCode, appId) {
return this.model.findOne({
where: {
channelItemCode: channelItemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"deliveryUrl",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
}
module.exports = AppProductDao;
module.exports = {
"appid": "d47f72a7228243a3bad03541d2a2c22c",
"label": "加西亚交付平台",
"config": {
"rstree": {
"code": "projroot",
"label": "projroot",
"children": [
{
"code": "diliverCenter",
"label": "交付中心",
"src": "/imgs/logo.png",
"isSubmenu": true,
"isleft": true,
"children": [
{
"code": "singleMonitor", "isGroup": true, "label": "个人监控", "children": [
{
"code": "mytradetransferdiliver",
"label": "商标转让",
"isMenu": true,
"bizCode": "mytradetransferdiliver",
"bizConfig": null,
"path": "",
"isleft": true,
},
{
"code": "mynotarizationflow",
"label": "公证申请",
"bizCode": "mynotarizationflow",
"bizConfig": null,
"path": "",
"isleft": true,
},
{
"code": "tansfersupplymaterail",
"label": "交易补充资料",
"bizCode": "tansfersupplymaterail",
"bizConfig": null,
"path": "",
"isleft": true,
}
]
},
{
"code": "projMonitor", "isGroup": true, "label": "全局监控", "children": [
{
"code": "alltradetransferdilivers",
"label": "商标转让",
"isMenu": true,
"bizCode": "alltradetransferdilivers",
"bizConfig": null,
"path": "",
"isleft": true,
},
{
"code": "mynotarizationflow",
"label": "公证申请",
"bizCode": "mynotarizationflow",
"bizConfig": null,
"path": ""
},
{
"code": "tansfersupplymaterail",
"label": "公证申请",
"bizCode": "tansfersupplymaterail",
"bizConfig": null,
"path": ""
},
{
"code": "tmjsonfileversion",
"label": "商标文件",
"isMenu": true,
"bizCode": "tmjsonfileversion",
"bizConfig": null,
"path": ""
},
]
},
],
},
],
},
"bizs": {
"home": { "title": "前台首页", "config": null, "path": "/", "comname": "home" },
"admin": { "title": "后台首页", "config": null, "path": "/index", "comname": "admin" },
"mytradetransferdiliver": { "title": "商标转让", "config": null, "path": "/mytradetransferdiliver", "comname": "tradetransferdiliver" },
"tmjsonfileversion": { "title": "商标文件", "config": null, "path": "/tmjsonfileversion", "comname": "tmjsonfileversion" },
"mynotarizationflow": {
"title": "公证申请",
"config": null,
"isDynamicRoute": false,
"path": "/mynotarizationflow",
"comname": "mynotarizationflow"
},
"tansfersupplymaterail": {
"title": "公证申请",
"config": null,
"isDynamicRoute": false,
"path": "/tansfersupplymaterail",
"comname": "tansfersupplymaterail"
},
},
"pauths": [
"add", "edit", "delete", "export", "show"
],
"pdict": {
//应用数据操作类型
"app_data_op_type": { "00": "独立", "10": "全委托", "20": "部分委托" },
//支付类型
"app_pay_type": { "00": "第三方支付", "10": "平台代收款" },
"app_type": { "api": "数据API", "web": "站点", "app": "移动APP", "xcx": "小程序", "access": "接入" },
"data_priv": { "auth.role": "角色", "auth.user": "用户", "common.app": "应用" },
"noticeType": { "sms": "短信", "email": "邮件", "wechat": "微信" },
"authType": { "add": "新增", "edit": "编辑", "delete": "删除", "export": "导出", "show": "查看" },
"mediaType": { "vd": "视频", "ad": "音频", "qt": "其它" },
"usageType": { "kt": "课堂", "taxkt": "财税课堂", "qt": "其它" },
"opstatus": { "0": "失败", "1": "成功" },
"sex": { "male": "男", "female": "女" },
"configType": { "price": "宝币兑换率", "initGift": "初次赠送", "apiInitGift": "API初次赠送", "apiCallPrice": "api调用价格" },
"logLevel": { "debug": 0, "info": 1, "warn": 2, "error": 3, "fatal": 4 },
"msgType": { "sys": "系统", "single": "单点", "multi": "群发", "mryzSingle": "每日易照单点", "mryzLicense": "群发", },
"tradeType": {
"fill": "充值宝币", "consume": "消费宝币", "gift": "赠送宝币", "giftMoney": "红包", "refund": "退款", "payment": "付款",
},
"question_status": { "waithandle": "待解决", "inmiddle": "解决中", "waitcheck": "待验证", "success": "成功解决", "invalid": "无效问题" },
"urgent_status": { "urgent": "紧急", "general": "一般" }
}
}
}
\ No newline at end of file
module.exports={ module.exports={
"list":{ "list":{
columnMetaData:[ columnMetaData:[
{"width":"200","label":"公司名称","prop":"companyName","isShowTip":true,"isTmpl":false}, {"width":"100","label":"应用id ","prop":"app_id","isShowTip":true,"isTmpl":false},
{"width":"200","label":"业务员","prop":"accountName","isShowTip":true,"isTmpl":false}, {"width":"80","label":"产品编码","prop":"itemCode","isShowTip":true,"isTmpl":false},
{"width":"200","label":"日期","prop":"created_at","isShowTip":true,"isTmpl":false}, {"width":"80","label":"产品名称","prop":"itemName","isShowTip":true,"isTmpl":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":"true"} {"width":"100","label":"产品大类Id","prop":"productOneType_id","isShowTip":true,"isTmpl":false},
] // {"width":"100","label":"尼斯大类","prop":"ncl_one","isShowTip":true,"isTmpl":false},
}, // {"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":true},
"form":[ ]
],
"search":[
{
"title":"公司名称",
ctls:[
{"type":"input","label":"公司名称","prop":"companyName","placeHolder":"请输入公司名称","style":""},
]
}, },
"form":[
],
"auth":{
"add":[
{"icon":"el-icon-plus","title":"新增","type":"default","key":"new","isOnGrid":true},
{"icon":"el-icon-save","title":"保存","type":"default","key":"save","isOnForm":true},
],
"edit":[
{"icon":"el-icon-edit","title":"查看","type":"default","key":"myedit","isInRow":true},
{"icon":"el-icon-plus","title":"预览","type":"default","key":"rpreview","isInRow":true},
],
"delete":[
{"icon":"el-icon-remove","title":"删除","type":"default","key":"delete","isInRow":true},
], ],
"common":[ "search":[
{"icon":"el-icon-cancel","title":"取消","type":"default","key":"cancel","isOnForm":true}, {
"title":"基本查询",
ctls:[
{"type":"input","label":"名称","prop":"itemName","placeHolder":"请输入姓名","style":""},
// {"type":"input","label":"注册号","prop":"tm_number","placeHolder":"请输入注册号","style":""},
]
},
], ],
"auth":{
"add":[
{"icon":"el-icon-save","title":"保存","type":"default","key":"save","isOnForm":true},
{"icon":"el-icon-save","title":"提交","type":"default","key":"submit","isOnForm":true},
],
"edit":[
{"icon":"el-icon-edit","title":"修改","type":"default","key":"edit","isInRow":true},
],
"delete":[
// {"icon":"el-icon-remove","title":"删除","type":"default","key":"delete","isInRow":true},
],
"common":[
{"icon":"el-icon-cancel","title":"取消","type":"default","key":"cancel","isOnForm":true},
],
}
} }
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ const bizsPath=path.normalize(__dirname+"/bizs"); ...@@ -5,6 +5,7 @@ const bizsPath=path.normalize(__dirname+"/bizs");
var appJsons={ var appJsons={
} }
function getBizFilePath(appJson,bizCode){ function getBizFilePath(appJson,bizCode){
const filePath=bizsPath+"/"+"bizjs"+"/"+bizCode+".js"; const filePath=bizsPath+"/"+"bizjs"+"/"+bizCode+".js";
return filePath; return filePath;
...@@ -53,6 +54,6 @@ fs.readdirSync(appsPath).forEach(f=>{ ...@@ -53,6 +54,6 @@ fs.readdirSync(appsPath).forEach(f=>{
var appJson=require(ff); var appJson=require(ff);
appJson= initAppBizs(appJson); appJson= initAppBizs(appJson);
initRsTree(appJson,appJson.appid,appJson.config.rstree,null); initRsTree(appJson,appJson.appid,appJson.config.rstree,null);
appJsons[appJson.appid]=appJson; appJsons["config"]=appJson;
}); });
module.exports=appJsons; module.exports=appJsons;
...@@ -34,13 +34,13 @@ module.exports = (db, DataTypes) => { ...@@ -34,13 +34,13 @@ module.exports = (db, DataTypes) => {
type:DataTypes.BOOLEAN, type:DataTypes.BOOLEAN,
defaultValue: false defaultValue: false
}, },
openId:DataTypes.STRING,
app_id:DataTypes.INTEGER, app_id:DataTypes.INTEGER,
account_id:DataTypes.INTEGER, account_id:DataTypes.INTEGER,
isEnabled:{ isEnabled:{
type:DataTypes.BOOLEAN, type:DataTypes.BOOLEAN,
defaultValue: true defaultValue: true
}, },
company_id:DataTypes.INTEGER,
},{ },{
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("app", {
name: DataTypes.STRING(100), // 应用名称
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
}, // 应用数据操作类型:00独立,10全委托,20部分委托
appPayType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type),
}, // 支付类型:00第三方支付,10平台代收款
contactName : DataTypes.STRING(30), // 联系人姓名
contactMobile: DataTypes.STRING(30), // 联系人手机
contactEmail : DataTypes.STRING(30), // 联系人邮箱
uappKey : DataTypes.STRING(64), // 平台应用key
uAppId : DataTypes.INTEGER, //
appSecret : DataTypes.STRING(64), // 密钥信息,用于进行签名请求接口
status : DataTypes.INTEGER, // 状态 0禁用 1启用
channelAppId : DataTypes.STRING(64), // 渠道appID
channelAppKey: DataTypes.STRING(64), // 渠道appKey
pushOrderUrl : DataTypes.STRING(500), // 获取渠道推送订单的url
appSourceCode : DataTypes.STRING(50), // app来源code
notes : DataTypes.STRING, // 备注
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appproduct", {
app_id :DataTypes.STRING(50),// 应用id
itemCode :DataTypes.STRING(100),// 产品编码
itemName :DataTypes.STRING(100),// 产品名称
picUrl :DataTypes.STRING(500),// 产品图片地址
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
channelItemName :DataTypes.STRING(100),// 渠道产品名称
serviceItemCode :DataTypes.STRING(100),// 服务商产品编码
status :DataTypes.BOOLEAN,// 状态 0禁用 1启用
verifyPrice :DataTypes.BOOLEAN,// 是否验证价格 0不验证 1验证
proPrice :DataTypes.DOUBLE,// 产品价格
serviceCharge :DataTypes.DOUBLE,// 服务费
publicExpense :DataTypes.DOUBLE,// 官费
rateConfig :DataTypes.DECIMAL(12, 2),// 税率
discountsRateConfig :DataTypes.DECIMAL(12, 2),// 优惠税率
channelProfitRate :DataTypes.DECIMAL(12, 2),// 渠道利润分成比率(只分订单中毛利润总额的分成)
sort :DataTypes.INTEGER,// 排序
productType_id :DataTypes.INTEGER,// 产品类型Id
productOneType_id :DataTypes.INTEGER,// 产品大类Id
deliveryUrl:DataTypes.STRING(500),// 交付地址
productLogo:DataTypes.STRING(500),// 产品logo
productDesc:DataTypes.STRING(1024),// 产品描述
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_product',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
...@@ -11,12 +11,17 @@ class UserService extends ServiceBase{ ...@@ -11,12 +11,17 @@ class UserService extends ServiceBase{
var openuser=await this.apiCallWithAk(settings.paasUrl()+"api/auth/accessAuth/authByCode",{opencode:code}); var openuser=await this.apiCallWithAk(settings.paasUrl()+"api/auth/accessAuth/authByCode",{opencode:code});
if(openuser){ if(openuser){
//先查看是否已经存在当前用户 //先查看是否已经存在当前用户
existedUser=await this.dao.findOne({userName:openuser.userName,app_id:openuser.app_id}); existedUser=await this.db.models.user.findOne({where:{userName:openuser.userName,app_id:openuser.app_id,company_id:openuser.owner.id}});
if(!existedUser){ if(!existedUser){
openuser.company_id=openuser.owner.id;
existedUser=await this.register(openuser); existedUser=await this.register(openuser);
} }
rawUser=existedUser.get({raw:true}); rawUser=existedUser.get({raw:true});
rawUser.Roles=openuser.Roles; rawUser.Roles=openuser.Roles;
rawUser.owner=openuser.owner;
rawUser.opath=openuser.opath;
rawUser.ppath=openuser.ppath;
rawUser.password=openuser.password;
} }
return rawUser; return rawUser;
} }
...@@ -29,14 +34,21 @@ class UserService extends ServiceBase{ ...@@ -29,14 +34,21 @@ class UserService extends ServiceBase{
}); });
} }
//在平台进行登录,返回目标认证地址 //在平台进行登录,返回目标认证地址
//由于是从某个具体应用导航回平台,那么需要带着这个应用所属的公司信息
//todo
async navSysSetting(user){ async navSysSetting(user){
var sysLoginUrl=settings.paasUrl()+"web/auth/userCtl/login?appKey="+settings.appKey+"\&toKey="+settings.paasKey; var sysLoginUrl=settings.paasUrl()+"web/auth/userCtl/login?appKey="+settings.appKey+"\&toKey="+settings.paasKey;
var x={userName:user.userName,password:user.password,mobile:user.mobile}; if(settings.companyKey){//说明是自主登录,不需要平台内go登录
sysLoginUrl=settings.paasUrl()+"web/auth/userCtl/login?appKey="+settings.appKey+"\&toKey="+settings.paasKey+"\&companyKey="+settings.companyKey;
}
var x={userName:user.userName,password:user.password,mobile:user.mobile,owner_id:user.owner.id};
var restResult=await this.restS.execPost({u:x},sysLoginUrl); var restResult=await this.restS.execPost({u:x},sysLoginUrl);
if(restResult){ if(restResult){
var rtnres=JSON.parse(restResult.stdout); var rtnres=JSON.parse(restResult.stdout);
if(rtnres.status==0){ if(rtnres.status==0){
return rtnres.data; return rtnres.data;
}else{
} }
} }
return null; return null;
......
const system=require("../../../system"); const system=require("../../../system");
const settings=require("../../../../config/settings"); const settings=require("../../../../config/settings");
const ServiceBase=require("../../sve.base") const ServiceBase=require("../../sve.base")
var WXPay = require('wx-pay');
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
class ApiTradeService extends ServiceBase{ class ApiTradeService extends ServiceBase{
constructor(){ constructor(){
......
...@@ -19,10 +19,11 @@ class MetaService extends ServiceBase{ ...@@ -19,10 +19,11 @@ class MetaService extends ServiceBase{
var basecomp=await this.apiCallWithAk(settings.paasUrl()+"api/meta/baseComp/getBaseComp",{}); var basecomp=await this.apiCallWithAk(settings.paasUrl()+"api/meta/baseComp/getBaseComp",{});
return basecomp.basecom; return basecomp.basecom;
} }
async findAuthsByRole(rolesarray, appid){ async findAuthsByRole(rolesarray, appid,comid){
var result =await this.apiCallWithAk(settings.paasUrl()+"api/auth/roleAuth/findAuthsByRole",{ var result =await this.apiCallWithAk(settings.paasUrl()+"api/auth/roleAuth/findAuthsByRole",{
roles:rolesarray, roles:rolesarray,
appid:appid appid:appid,
companyid:comid,
}); });
return result; return result;
} }
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapService));
}
async getItemByAppKey(appKey) {
return this.dao.getItemByAppKey(appKey);
}
}
module.exports = AapService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AppProductService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AppProductService));
}
//根据渠道产品码获取产品详情
async findByChannelItemCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var channelItemCode = obj.channelItemCode;
if(!channelItemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var product = await this.dao.model.findOne({
where:{channelItemCode:channelItemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig"],
raw:true
});
if(!product){
return system.getResultFail(-104, "未知产品");
}
return system.getResultSuccess(product);
}
//获取产品列表(根据父类产品编码获取)
async findByProductTypeCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productType_id:pProduct.id,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig",
"productLogo","productDesc"
],
raw:true
});
return system.getResultSuccess(pList);
}
//获取产品列表(根据产品一类编码获取)
async findByProductOneTypeCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productOneType_id:pProduct.id,productType_id:{ [this.db.Op.ne]: 0 },app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig",
"productLogo","productDesc"
],
raw:true
});
return system.getResultSuccess(pList);
}
}
module.exports = AppProductService;
const system = require("../system"); const system = require("../system");
var moment = require('moment') var moment = require('moment')
var settings=require("../../config/settings"); var settings = require("../../config/settings");
class ServiceBase { class ServiceBase {
constructor(gname,daoName) { constructor(gname, daoName) {
//this.dbf=system.getObject("db.connection"); //this.dbf=system.getObject("db.connection");
this.db = system.getObject("db.common.connection").getCon(); this.db = system.getObject("db.common.connection").getCon();
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.daoName = daoName; this.daoName = daoName;
this.dao = system.getObject("db." +gname+"."+ daoName); this.dao = system.getObject("db." + gname + "." + daoName);
this.restS=system.getObject("util.restClient"); this.restS = system.getObject("util.restClient");
this.execS = system.getObject("util.execClient");
this.channelApiUrl = settings.channelApiUrl();
this.appInfo = {
aliyuntmtransfer: { appkey: "201912031344", secret: "7cbb846246874167b5c7e01cd0016c88" }
};
} }
async apiCallWithAk(url,params){ async apiCallWithAk(url, params) {
var acckapp=await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey); var acckapp = await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey);
var acck=acckapp.accessKey; var acck = acckapp.accessKey;
//按照访问token //按照访问token
var restResult=await this.restS.execPostWithAK(params,url,acck); var restResult = await this.restS.execPostWithAK(params, url, acck);
if(restResult){ if (restResult) {
if(restResult.status==0){ if (restResult.status == 0) {
var resultRtn=restResult.data; var resultRtn = restResult.data;
return resultRtn; return resultRtn;
}else{ } else {
await this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey); await this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
return null; return null;
} }
} }
return null; return null;
} }
async apiCallWithAkNoWait(url,params){ async apiCallWithAkNoWait(url, params) {
var acckapp=await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey); var acckapp = await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey);
var acck=acckapp.accessKey; var acck = acckapp.accessKey;
//按照访问token //按照访问token
this.restS.execPostWithAK(params,url,acck).then((restResult)=>{ this.restS.execPostWithAK(params, url, acck).then((restResult) => {
if(restResult){ if (restResult) {
if(restResult.status==0){ if (restResult.status == 0) {
var resultRtn=restResult.data; var resultRtn = restResult.data;
return resultRtn; return resultRtn;
}else{ } else {
this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey); this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
return null;
}
}
return null; return null;
}
}
return null;
}); });
} }
static getDaoName(ClassObj) { static getDaoName(ClassObj) {
...@@ -132,5 +138,49 @@ class ServiceBase { ...@@ -132,5 +138,49 @@ class ServiceBase {
} }
return uuid.join(''); return uuid.join('');
} }
async aliclient(obj) {
var sobj = {
"actionProcess": "aliyuntmtransfer",
"actionType": "aliclient",
"sign": "2FviZ9PGws8Pt1fBhq0t90mjUvI",
"actionBody": obj
}
var tokenInfo = await this.getToken();
var reqUrl = this.channelApiUrl + "/action/tradetransfer/aliclienttransfer";
var rtn = await this.execS.execPostTK(sobj, reqUrl, tokenInfo.data.token);
//var rtn = await this.execS.execPostTK(sobj, reqUrl,"token");
return rtn;
}
async getToken() {
var self = this;
var reqTokenUrl = this.channelApiUrl + "/auth/accessAuth/getToken";
var reqParam = self.appInfo["aliyuntmtransfer"];
if (!reqParam.appkey || !reqParam.secret) {
return system.getResult(null, "reqType类型有误,请求失败");
}
var rtn = await this.execS.execPost(reqParam, reqTokenUrl);
if (!rtn.stdout) {
return system.getResult(null, "获取token失败");
}
var tokenResult = JSON.parse(rtn.stdout);
if (tokenResult.status == 0) {
tokenResult.data.secret = reqParam.secret;
}
return tokenResult;
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
isStrEmpty(str) {
return this.trim(str) ? true : false;
}
} }
module.exports = ServiceBase; module.exports = ServiceBase;
...@@ -97,7 +97,8 @@ class System { ...@@ -97,7 +97,8 @@ class System {
// } // }
delete require.cache[configPath]; delete require.cache[configPath];
var configValue = require(configPath); var configValue = require(configPath);
return configValue[appid];
return configValue["config"];
} }
static get_client_ip(req) { static get_client_ip(req) {
var ip = req.headers['x-forwarded-for'] || var ip = req.headers['x-forwarded-for'] ||
......
...@@ -246,3 +246,13 @@ x(2,3,4,5); ...@@ -246,3 +246,13 @@ x(2,3,4,5);
// } // }
// }, // },
// ] // ]
40d64e586551405c9bcafab87266bb04
f99d413b767f09b5dff0b3610366bb46
40d64e586551405c9bcafab87266bc04
f99d413b767f09b5dff0b3610366cc46
115.28.188.38:8888
class TestBase{
constructor(){
this.apiDoc={
group:"逻辑分组",
desc:"请对当前类进行描述",
exam:"概要示例",
methods:[]
};
this.initClassDoc();
}
initClassDoc(){
throw new Error(`
请定义当前类的API文档,重写initClassDoc方法.
在initClassDoc方法中调用如下方法:
1.descClass(groupName,classDesc,exam)增加当前类的描述和使用示例
2.descMethod(methodName,paramName,paramType,defaultValue,paramDesc)增加方法的说明
`);
}
descClass(groupName,classDesc,exam){
this.group=groupName;
this.apiDoc.desc=classDesc;
this.apiDoc.exam=exam;
}
descMethod(methodDesc,methodName,paramDesc,paramName,paramType,defaultValue,rtnTypeDesc,rtnType){
var mobj=this.apiDoc.methods.filter((m)=>{
if(m.name==methodName){
return true;
}else{
return false;
}
})[0];
var param={
pname:paramName,
ptype:paramType,
pdesc:paramDesc,
pdefaultValue:defaultValue,
};
if(mobj!=null){
mobj.params.push(param);
}else{
this.apiDoc.methods.push(
{
methodDesc:methodDesc?methodDesc:"",
name:methodName,
params:[param],
rtnTypeDesc:rtnTypeDesc,
rtnType:rtnType
}
);
}
}
}
class Test extends TestBase{
constructor(){
super();
}
initClassDoc(){
this.descClass("class desc",`
xxxxxx
xxxxx
xxxxxxxx
`);
this.descMethod("hello",{
pname:"pname1",
ptype:"int",
pdesc:"xccccc"
});
this.descMethod("hello",{
pname:"pname2",
ptype:"str",
pdesc:"xccccyyyc"
});
}
}
class Test2 extends TestBase{
constructor(){
super();
}
initClassDoc(){
this.descClass("class desc222222",`
xxxxxx
xxxxx
xxxxxxxx
`);
this.descMethod("test2hello",{
pname:"pname1",
ptype:"int",
pdesc:"xccccc"
});
this.descMethod("world",{
pname:"pname2",
ptype:"str",
pdesc:"xccccyyyc"
});
}
}
class Test3 extends TestBase{
constructor(){
super();
}
}
module.exports={cls:Test,doc:new Test().apiDoc};
var t1=new Test();
var t2=new Test2();
console.log(t1.apiDoc);
console.log(t2.apiDoc);
技术总监 职位描述
岗位职责:
负责公司基础平台的设计开发
负责公司开发团队的建设
负责制定项目技术方案,负责系统的架构设计、优化,参与核心架构部分代码编写;
负责软件开发任务的需求分析、技术方案设计、开发计划制定,指导项目团队成员的日常开发工作、解决开发中的技术问题;
职位要求
财务软件开发经验者优先
8年以上Javaphp互联网开发经验,5年以上应用架构经验。
熟悉分布式存储、搜索、异步框架、集群与负载均衡,消息中间件等技术;
有大型分布式、高并发、高负载、高可用系统架构、设计、开发和调优经验;
熟悉各种常用设计模式,能将设计模式应用到日常工作。
熟悉至少一种较为常见的主流数据库及SQL语言,有一定的sql调优经验;熟悉Linux操作系统以及常用版本管理软件操作(如:svn,git)
熟悉至少一种nosql数据库
计算机相关专业本科以上学历。
具有良好的沟通表达能力和团队协作能力。
var RPCClient = require('@alicloud/pop-core').RPCClient;
class AliApiClient {
constructor() {
this.client = new RPCClient({
accessKeyId: 'LTAI4FvNyYTUtvfUsuoMzy7D',
accessKeySecret: '1B4YqlWxNUtMpifbtmExQwY7m3Caj4',
endpoint: 'https://trademark.aliyuncs.com',
apiVersion: '2018-07-24'
});
}
async reqbyget(obj,cbk) {
var self = this;
var action = obj.action;
var reqbody = obj.reqbody;
return self.client.request(action, reqbody, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
}
async reqbypost(obj,cbk) {
var self = this;
var action = obj.action;
var reqbody = obj.reqbody;
return self.client.request(action, reqbody, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET
headers: {}, // set the http request headers
});
}
}
module.exports = AliApiClient;
\ No newline at end of file
var excel = require('exceljs');
const system=require("../system");
const uuidv4 = require('uuid/v4');
const fs=require("fs");
class ExcelClient {
constructor() {
this.columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
this.ossClient=system.getObject("util.ossClient");
this.filedownloadDao = system.getObject("db.filedownloadDao");
}
async download(params) {
var self = this;
var title = params.title || "";
var code = params.code || uuidv4();
var fileName = params.fileName || code + ".xlsx";
var filePath = params.filePath || "/tmp/" + fileName;
var rows = params.rows || [];
var user = params.user || {};
var wb = new excel.Workbook();
wb.properties.date1904 = true;
var sheet = wb.addWorksheet("sheet1");
var headers = rows[0];
console.log(headers, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 headers");
if(title) {
sheet.addRow([title]);
sheet.getCell("A1").font = {
    name: '微软雅黑',
    family: 4,
    size: 12,
    bold: true
};
sheet.getCell('A1').alignment = { vertical: 'middle', horizontal: 'center' };
var colkey = 0;
if(headers.length > 0) {
colkey = headers.length - 1;
}
var endColumn = this.columns[colkey] || "A";
sheet.mergeCells("A1:" + endColumn + "1");
}
for(var r of rows) {
sheet.addRow(r);
}
wb.xlsx.writeFile(filePath).then(async function(d) {
var rtn = await self.ossClient.upfile(fileName, filePath);
fs.unlink(filePath,function(err){});
var obj = {
user_id : user.id || 0,
userName : user.userName || "",
code : code,
fileName : fileName,
filePath : rtn.url || "",
isDownload : false,
}
var obj = await self.filedownloadDao.create(obj);
});
}
}
module.exports = ExcelClient;
var childproc = require('child_process');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const uuidv4 = require('uuid/v4');
class ExecClient {
constructor() {
this.cmdPostPattern = "curl -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdGetPattern = "curl -G -X GET {url}";
this.cmdPostTK = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}";
}
async exec(cmd) {
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//异常需要try/catch自己捕获或外部catch捕获
const { stdout, stderr } = await exec(cmd);
return { stdout, stderr };
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
async execPostTK(subData, url, token) {
let cmd = this.FetchPostTK(subData, url, token);
var result = await this.exec(cmd, {
maxBuffer: 1024 * 1024 * 15
});
var rtn = result.stdout;
if (rtn) {
return JSON.parse(rtn);
} else {
return null;
}
}
FetchPostTK(subData, url, token) {
var data = JSON.stringify(subData);
var requestId = this.getUUID();
var cmd = this.cmdPostTK.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{tk\}/g, token).replace(/\{requestId\}/g, requestId);
return cmd;
}
async exec2(cmd) {
return exec(cmd, { encoding: "base64" });
}
FetchPostCmd(subData, url) {
var data = JSON.stringify(subData);
var cmd = this.cmdPostPattern.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
console.log(cmd);
return cmd;
}
async execPost(subData, url) {
let cmd = this.FetchPostCmd(subData, url);
var result = await this.exec(cmd);
return result;
}
async execPost2(subData, url) {
let cmd = this.FetchPostCmd(subData, url);
var result = await this.exec2(cmd);
return result;
}
FetchGetCmd(subData, url) {
var cmd = this.cmdGetPattern.replace(
/\{data\}/g, subData).replace(/\{url\}/g, url);
console.log(cmd);
return cmd;
}
async execGet(subData, url) {
let cmd = this.FetchGetCmd(subData, url);
console.log(cmd);
var result = await this.exec(cmd);
return result;
}
async execGet2(subData, url) {
let cmd = this.FetchGetCmd(subData, url);
console.log(cmd);
var result = await this.exec2(cmd);
return result;
}
async execGetTimeOut(subData, url, timeOut = 5000) {
//timeOut,单位是毫秒
let cmd = this.FetchGetCmd(subData, url);
var options = {
timeout: timeOut,
};
const { stdout, stderr } = await exec(cmd, options);
return { stdout, stderr };
}
}
module.exports = ExecClient;
// var x=new RestClient();
// x.execGet("","http://www.163.com").then(function(r){
// console.log(r.stdout);
// console.log(r.stderr);
// });
var nodemailer = require('nodemailer');
class MailClient{
constructor(){
this.mailer=nodemailer.createTransport({
service: 'aliyun',
secureConnection: true,
port: 465,
auth: {
user: 'czhd_ip@gongsibao.com',
pass: 'HANtang2018'
}
});
}
//嵌入图片
// var mailOptions = {
// from: 'bsspirit ',
// to: 'xxxxx@163.com',
// subject: 'Embedded Image',
// html: '<b>Hello world ✔</b><br/>Embedded image: <img src="cid:00000001"/>',
// attachments: [{
// filename: '01.png',
// path: './img/r-book1.png',
// cid: '00000001'
// }]
// }
//发送邮件
// var mailOptions = {
// from: 'bsspirit ',
// to: 'xxxxx@163.com',
// subject: 'Hello ✔',
// text: 'Hello world ✔',
// html: '<b>Hello world ✔</b>' // html body
// attachments: [
// {
// filename: 'text0.txt',
// content: 'hello world!'
// },
// {
// filename: 'text1.txt',
// path: './attach/text1.txt'
// }
// ]
// };
async sendMsg(to,title,text,html,cc,bcc,atts){
var options={
from: "czhd_ip@gongsibao.com", // sender address
to: to, // list of receivers
cc: cc||'',
bcc: bcc||'',
subject: title, // Subject line
text: text || '', // plaintext body
html: html || '',// html body
attachments: atts||[
]
};
var self=this;
var p=new Promise(function(resv,rej){
self.mailer.sendMail(options, function(error, info){
if(error){
return rej(error);
}else{
return resv(info.response);
}
});
});
return p;
}
}
module.exports=MailClient;
// var d=new MailClient();
// d.sendMsg("zhangjiao@gongsibao.com","test","see","hello txt",null,null,[
// {
// filename: 'text1.jpg',
// path: 'https://gsb-zc.oss-cn-beijing.aliyuncs.com/zc_3369154019592833720182216128337mmexport1540195729827.jpg'
// }
// ]).then(r=>{
// console.log(r);
// }).catch(e=>{
// console.log(e);
// });
var co = require('co');
var OSS = require('ali-oss');
class OSSClient{
constructor(){
this.client=new OSS({
endpoint: 'https://oss-cn-beijing.aliyuncs.com',
accessKeyId: 'LTAIyAUK8AD04P5S',
accessKeySecret: 'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla'
});
this.client.useBucket('gsb-zc');
}
async downfile(key){
var me=this;
var result=await co(function* () {
var result = yield me.client.get(key, '/tmp/'+key);
return result;
});
return result;
}
async upfile(key,filepath){
var me=this;
var result=await co(function* () {
var result = yield me.client.put(key, filepath);
return result;
})
return result;
}
async putBuffer (key,buf) {
try {
var result = await this.client.put(key, buf);
console.log(result);
return result
} catch (e) {
console.log(e);
return null
}
}
}
module.exports=OSSClient;
// var oss=new OSSClient();
// var key="netsharp_QSzjD4HdKdTmRR6b5486pEA3AbsW8Pr8.jpg"
// oss.upfile(key,"/usr/devws/OMC/igirl-api/r3.jpg").then(function(result){
// console.log(result);
// });
// oss.downfile(key).then(function(result){
// console.log(result);
// });
var childproc = require('child_process');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const querystring = require('querystring');
var settings=require("../../config/settings");
class RestClient{
constructor(){
this.cmdGetPattern = "curl {-G} -k -d '{data}' {url}";
this.cmdPostPattern="curl -k -H 'Content-type: application/json' -d '{data}' '{url}'";
this.cmdPostPatternWithAK="curl -k -H 'Content-type: application/json' -H 'AccessKey:{ak}' -d '{data}' {url}";
this.cmdDownLoadFilePattern="curl -G -o {fileName} {url}";
this.cmdPostPattern2="curl -k -H 'Content-type: application/x-www-form-urlencoded' -d '{data}' {url}";
// form-data形式post data参数类型 md5=2&data=1
this.cmdPostPattern5="curl -k --data '{data}' {url}";
}
FetchGetCmd(subData, url) {
var cmd = this.cmdGetPattern.replace(/\{\-G\}/g, "-G").replace(
/\{data\}/g, subData).replace(/\{url\}/g, url);
return cmd;
}
FetchPostCmd(subData, url) {
var data=JSON.stringify(subData);
var cmd= this.cmdPostPattern.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
return cmd;
}
FetchPostCmdWithAK(subData, url,acck) {
var data=JSON.stringify(subData);
var cmd= this.cmdPostPatternWithAK.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{ak\}/g,acck);
return cmd;
}
FetchPostCmd2(subData, url) {
var data=subData;
var cmd= this.cmdPostPattern2.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
return cmd;
}
FetchPostCmd3(subData, url) {
var data=subData;
var cmd= this.cmdPostPattern3.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
return cmd;
}
FetchGetCmd3(url) {
var cmd = this.cmdGetPattern3.replace(/\{\-G\}/g, "-G").replace(/\{url\}/g, url);
return cmd;
}
FetchPostCmd4(subData, url) {
var data=subData;
var cmd= this.cmdPostPattern4.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
return cmd;
}
FetchPostCmd5(subData, url) {
var data=subData;
var cmd= this.cmdPostPattern5.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
return cmd;
}
FetchDownLoadCmd(outfname,url) {
// console.log(this.cmdPattern);
var cmd = this.cmdDownLoadFilePattern.replace(/\{fileName\}/g, outfname).replace(
/\{url\}/g, url);
return cmd;
}
async exec(cmd,options) {
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//异常需要try/catch自己捕获或外部catch捕获
if(options){
const { stdout, stderr } = await exec(cmd,options);
return { stdout, stderr };
}else{
const { stdout, stderr } = await exec(cmd);
return { stdout, stderr };
}
}
async execDownload(url,outfname){
let cmd=this.FetchDownLoadCmd(outfname,url);
var result=await this.exec(cmd);
return result;
}
async execGet(subData, url){
let cmd=this.FetchGetCmd(subData,url);
var result=await this.exec(cmd);
return result;
}
async execGet2(subData, url){
var data=querystring.stringify(subData);
let cmd=this.FetchGetCmd(data,url);
var result=await this.exec(cmd);
return result;
}
async execPost(subData, url){
let cmd=this.FetchPostCmd(subData,url);
var result=await this.exec(cmd,{
maxBuffer: 10000 * 1024
});
return result;
}
async execPostWithAK(subData, url,ak){
let cmd=this.FetchPostCmdWithAK(subData,url,ak);
var result=await this.exec(cmd,{
maxBuffer:1024*1024*15
});
var rtn=result.stdout;
if(rtn){
return JSON.parse(rtn);
}else{
return null;
}
}
async execPost2(subData, url){
let cmd=this.FetchPostCmd2(subData,url);
console.log(cmd);
var result=await this.exec(cmd);
return result;
}
async execPost3(subData, url){
let cmd=this.FetchPostCmd3(subData,url);
console.log(cmd);
var result=await this.exec(cmd);
return result;
}
async execGet3(url){
let cmd=this.FetchGetCmd3(url);
console.log("execGet3-----01");
console.log(cmd);
var result=await this.exec(cmd);
return result;
}
async execPostESignBao(subData, url){
let cmd=this.FetchPostCmd4(subData,url);
console.log(cmd);
var result=await this.exec(cmd);
return result;
}
async execPostForm(subData, url){
let cmd=this.FetchPostCmd5(subData,url);
console.log(cmd);
var result=await this.exec(cmd);
return result;
}
async execCustomPostESignBao(cmd){
console.log(cmd);
var result=await this.exec(cmd);
return result;
}
test(){
console.log("hello");
}
}
module.exports=RestClient;
// var x=new RestClient();
// x.execGet("","http://www.163.com").then(function(r){
// console.log(r.stdout);
// console.log(r.stderr);
// });
// var util = require('util');
// var ssdb = require('ssdb-node');
// const settings = require("../../config/settings");
// const bluebird = require("bluebird");
// bluebird.promisifyAll(ssdb);
// class SsdbClient {
// constructor() {
// this.pool = new ssdb({
// port: 8888,
// host: '192.168.18.26',
// auth: 'lowlogslowlogslowlogslowlogYsy123',
// authCallback:""
// });
// }
// async set(obj) {
// var key = obj.key;
// var value = obj.value;
// return new Promise((resolve, reject) => {
// this.pool.set(key, value, function (err, data) {
// if (err) {
// reject(err)
// } else {
// resolve(data)
// }
// });
// })
// }
// async get(obj) {
// var key = obj.key;
// return new Promise((resolve, reject) => {
// this.pool.get(key, function (err, data) {
// if (err) {
// reject(err)
// } else {
// resolve(data)
// }
// });
// })
// }
// }
// module.exports = SsdbClient;
\ No newline at end of file
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var methodOverride = require('method-override');
var cookierParser = require('cookie-parser');
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
var bodyParser = require('body-parser');
var multer = require('multer');
var errorHandler = require('errorhandler');
var settings = require('./settings');
var System = require('../base/system');
var routes = require('./routes');
const logCtl=System.getObject("web.common.oplogCtl");
const clientRedis= System.getObject("util.redisClient").client;
//const tm=System.getObject("db.taskManager");
module.exports = function (app) {
app.set('port', settings.port);
app.set('views', settings.basepath + '/app/front/entry');
app.set('view engine', 'ejs');
app.use(methodOverride());
app.use(cookierParser());
app.use(bodyParser.json({limit:'50mb'}));
app.use(bodyParser.urlencoded({limit:'50mb',extended:true}));
routes(app);//初始化路由
app.use(express.static(path.join(settings.basepath, '/app/front/entry/public')));
app.all('*',function (req, res, next) {
req.objs=System;
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// res.header('Access-Control-Allow-Credentials', 'true');
if (req.method == 'OPTIONS') {
res.send(200); /让options请求快速返回/
}
else {
next();
}
 });
if(settings.env=="dev"){
app.use(session(
{
name:'pmsid',
cookie: {maxAge: 3600000},
rolling:true,
resave: false,
saveUninitialized: false,
secret: 'uwotm8',
store: new RedisStore({
client:clientRedis,
}),
}));
}else{
app.use(session(
{
name:'jxysessionid',
cookie: {maxAge: 3600000},
rolling:true,
resave: false,
saveUninitialized: false,
secret: 'uwotm8',
store: new RedisStore({
client:clientRedis,
}),
}));
}
// development only
if ('development' == app.get('env')) {
app.use(errorHandler());
}else{
app.use(function(err,req,res){
console.log("prod error handler................................>>>>>>>>>>>>>>>>>");
console.log(err);
logCtl.error({
optitle:"environment 调用异常error:",
op:classPath+"/"+methodName,
content:e.toString(),
clientIp:System.get_client_ip(req),
agent:req.headers["user-agent"],
});
//logerApp.error("prod error handler",err);
res.send("link admin");
});
}
};
var settings={
redis:{
host: "43.247.184.32",
port: 8967,
password: "Gongsibao2018",
db:10,
},
database:{
dbname : "igirl_channel",
user: "write",
password: "write",
config: {
host: '43.247.184.35',
port: 8899,
dialect: 'mysql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 90000000,
idle: 1000000
},
debug:false,
dialectOptions:{
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
}
},
reqEsDevUrl:"http://192.168.4.249:9200/",
};
module.exports = settings;
var path= require('path');
var basepath=path.normalize(path.join(__dirname, '../..'));
var settings = {
web:path.join(basepath,"app/base/controller/impl"),
api:path.join(basepath,"app/base/api/impl"),
util:path.join(basepath,"app/base/utils"),
service:path.join(basepath,"app/base/service/impl"),
db:path.join(basepath,"app/base/db/impl"),
tool:path.join(basepath,"app/base/tool"),
service2:path.join(basepath,"app/base/service"),
applet:path.join(basepath,"app/base/wxapplet/impl"),
};
module.exports = settings;
var url=require("url");
var qr=require("qr-image")
module.exports = function (app) {
app.get('/api/qc', function(req,res){
var params = url.parse(req.url,true);
var detailLink = params.query.detailLink;
try {
var img = qr.image(detailLink,{size :10});
console.log(detailLink)
res.writeHead(200, {'Content-Type': 'image/png'});
img.pipe(res);
} catch (e) {
res.writeHead(414, {'Content-Type': 'text/html'});
res.end('<h1>414 Request-URI Too Large</h1>');
}
});
};
var url = require("url");
var System = require("../../base/system");
module.exports = function (app) {
app.get('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
classPath=gname+"."+classPath;
var tClientIp = System.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent= req.headers["user-agent"];
req.classname=classPath;
var params = [];
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
app.post('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
var params = [];
classPath=gname+"."+classPath;
var tClientIp = System.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent= req.headers["user-agent"];
req.classname=classPath;
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
};
var fs=require("fs");
var settings=require("../settings");
var glob = require("glob");
var system = require('../../base/system');
var bizcompCache={};
async function asycReadFile(path){
var p=new Promise(function(reslv,reject){
fs.readFile(path,function(err,r){
if(err){
reject(err);
}else{
reslv(r);
}
});
});
return p;
}
async function buildComponent(compname){
if(bizcompCache[compname] && settings.env=="prod"){
return bizcompCache[compname];
}else{
var htmlpath=settings.basepath+"/app/front/vues/pages/"+compname+"/"+compname+".html";
var jspath=settings.basepath+"/app/front/vues/pages/"+compname+"/"+compname+".js";
var html= await asycReadFile(htmlpath);
var tmpl=html.toString("utf-8");
var js= await asycReadFile(jspath);
var jsstr=js.toString("utf-8");
jsstr=jsstr.replace("${tmpl}",tmpl);
bizcompCache[compname]=jsstr;
return jsstr;
}
}
module.exports = function (app) {
app.get('/vue/comp/base',function(req,res){
var vuePath=settings.basepath+"/app/front/vues/base";
var baseComps=[];
var rs=glob.sync(vuePath+"/**/*.vue");
if(rs){
rs.forEach(function(r){
var comp="";
if(settings.env=="dev"){
delete require.cache[r];
comp=require(r).replace(/\n/g,"");
}else{
comp=require(r).replace(/\n/g,"");
}
baseComps.push(comp);
});
res.end(JSON.stringify(baseComps));
}
});
app.get('/vue/comp/:cname',function(req,res){
var componentName=req.params.cname;
var theme=req.headers["theme"];
var hostname=req.hostname;
buildComponent(componentName,theme,hostname).then(function(r){
res.end(escape(r.replace(/\n/g,"")));
// res.end(r);
});
});
};
var url = require("url");
var System = require("../../base/system");
var metaCtl=System.getObject("web.common.metaCtl");
var userCtl=System.getObject("web.auth.userCtl");
module.exports = function (app) {
app.get("/auth",async function(req,res){
await userCtl.authByCode(req);
res.redirect("/");
});
app.get("/",async function(req,res){
console.log(req.hostname);
var appinfo=await metaCtl.getAppInfo(req);
if(!appinfo){
res.render("index",{appinfo:null,app:null});
}else{
res.render("index",appinfo);
}
});
app.all("/web/*", function (req, res, next) {
if (
req.url.indexOf("checkLogin") > 0 ||
req.url.indexOf("metaCtl") > 0 ||
req.url.indexOf("getOssConfig") > 0) {
return next();
}
if (!req.session.user) {
var x = {
status: -99,
msg: "no login"
};
res.end(JSON.stringify(x));
} else {
//console.log(req.headers);
next();
}
});
app.get("/admin",async function(req,res){
var appinfo=await metaCtl.getAppInfo(req);
res.render("admin",appinfo);
});
app.get('/web/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
classPath=gname+"."+classPath;
var params = [];
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("web." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
app.post('/web/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname=req.params["gname"];
var params = [];
classPath=gname+"."+classPath;
var tClientIp = System.get_client_ip(req);
req.body.clientIp = tClientIp;
req.body.agent= req.headers["user-agent"];
req.body.classname=classPath;
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("web." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
};
var path = require('path');
var ENVINPUT={
DB_HOST:process.env.DB_HOST,
DB_PORT:process.env.DB_PORT,
DB_USER:process.env.DB_USER,
DB_PWD:process.env.DB_PWD,
REDIS_HOST:process.env.REDIS_HOST,
REDIS_PORT:process.env.REDIS_PORT,
REDIS_PWD:process.env.REDIS_PWD,
REDIS_DB:process.env.JIAXIYA_REDIS_DB,
DB_NAME:process.env.JIAXIYA_DB_NAME,
APP_ENV:process.env.APP_ENV?process.env.APP_ENV:"dev"
};
var settings = {
env:ENVINPUT.APP_ENV,
appKey:"d47f72a7228243a3bad03541d2a2c22c",
paasKey:"wx76a324c5d201d1a4",
secret:"047c51d2f0974802a17dde560d2871cb",
//为了直接从应用客户端登录,需要查询出当前用户所在公司
//如果有这个配置,就表示支持从应用自己的客户端登录或注册
companyKey:"af4dfb53282d4743866259e0b15b134e",
salt: "%iatpD1gcxz7iF#B",
basepath : path.normalize(path.join(__dirname, '../..')),
port : process.env.NODE_PORT || 3003,
paasUrl:function(){
if(this.env=="dev"){
return "http://p.apps.com:4001/";
}else {
return "https://open.gongsibao.com/";
}
},
channelApiUrl: function () {
if (this.env == "dev") {
return "http://192.168.18.61:4003";
} else {
return "http://zc-channel-service";
}
},
uploadfileossurl:function () {
if (this.env == "dev") {
return "http://192.168.18.15:8080";
} else {
return "http://localhost:8080";
}
},
reqEsAddr:function(){
if(this.env=="dev"){
var localsettings=require("./localsettings");
return "http://43.247.184.94:7200/";//localsettings.reqEsDevUrl;
}else {
return "http://43.247.184.94:7200/";
}
},
apiconfig:{
opLogUrl:function(){
return settings.reqEsAddr()+"bigdata_zc_op_log/_doc?pretty";
},
opLogEsIsAdd:function(){
return 1;
},
},
redis:function(){
if(this.env=="dev"){
var localsettings=require("./localsettings");
return localsettings.redis;
}else {
return {
host:ENVINPUT.REDIS_HOST,
port:ENVINPUT.REDIS_PORT,
password:ENVINPUT.REDIS_PWD,
db:ENVINPUT.REDIS_DB,
};
}
},
database:function(){
if(this.env=="dev"){
var localsettings=require("./localsettings");
return localsettings.database;
}else{
return {
dbname : ENVINPUT.DB_NAME,
user : ENVINPUT.DB_USER,
password : ENVINPUT.DB_PWD,
config : {
host: ENVINPUT.DB_HOST,
dialect: 'mysql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 90000000,
idle: 1000000
},
debug:false,
dialectOptions:{
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
},
};
}
}
};
settings.ENVINPUT=ENVINPUT;
module.exports = settings;
var Server=require('socket.io');
var System = require('../base/system');
var redisClient=System.getObject("util.redisClient");
const logCtl=System.getObject("web.oplogCtl");
const notifyCtl=System.getObject("web.socketNotifyCtl");
const msgHistoryService=System.getObject("service.msghistorySve");
class MsgHandler{
constructor(server,client){
this.server=server;
this.client=client;
this.init();
}
notifyClient(ukchannel,msg){
var msgH={msgType:"system",sender:"s¥s¥s¥s",target:msg.to,content:msg.content};
msgHistoryService.create(msgH).then((m)=>{
redisClient.publish(ukchannel,JSON.stringify(msg));
}).catch(e=>{
console.log(e);
logCtl.info({
optitle:"socket.server.js->notifyClient接口调用异常error:",
op:"chatmsg",
content:e.stack,
clientIp:null,
agent:"",
});
});
}
init(){
var self=this;
//转发通信消息
this.client.on("chatmsg",msg=>{
const from=msg.from;
const to=msg.to;
const msgContent=msg.content;
var arrs=to.split("¥");
var tochannel=arrs[0]+"¥"+arrs[1];
//发布消息
//持久化消息
var msgH={msgType:"single",sender:msg.from,target:msg.to,content:msg.content};
msgHistoryService.create(msgH).then((m)=>{
redisClient.publish(tochannel,JSON.stringify(msg));
}).catch(e=>{
console.log(e);
logCtl.info({
optitle:"socket.server.js->发布消息->持久化消息接口调用异常error:",
op:"chatmsg",
content:e,
clientIp:null,
agent:"",
});
});
//self.server.users[to].emit("chatmsg",msg);
});
this.client.on("mryzmsg", async msg=>{
try {
const from=msg.from;
const to=msg.to;
const msgContent=msg.content;
var fromArrs = from.split("¥");
var toArrs=to.split("¥");
var fromId = Number(fromArrs[1]);
var toId = Number(toArrs[1]);
var fromChannel = fromArrs[0]+"¥"+fromArrs[1];
var toChannel = toArrs[0]+"¥"+toArrs[1];
// 消息对象
var msgH = {
msgType:msg.msgType || "mryzSingle",
sender:from,
senderId:fromId,
target:msg.to,
targetId:toId,
content:msgContent,
isRead:false,
businessLicense_id:msg.businessLicense_id || 0,
};
msgH = await msgHistoryService.saveMsg(msgH);
redisClient.publish(fromChannel, JSON.stringify(msgH));
if(fromChannel != toChannel) {
redisClient.publish(toChannel, JSON.stringify(msgH));
}
} catch (e) {
console.error(e);
logCtl.info({
optitle:"socket.server.js->发布每日易照消息->持久化每日易照消息接口调用异常error:",
op:"mryzmsg",
content:e,
clientIp:null,
agent:"",
});
}
//self.server.users[to].emit("chatmsg",msg);
});
//响应消息处理
this.client.on("replymsg",(msg,fn)=>{
var p=null;
var invokeObj= System.getObject("web."+msg.cls);
console.log(invokeObj);
if(invokeObj[msg.method]){
p=invokeObj[msg.method].apply(invokeObj,[msg.data]);
}
p.then(r=>{
fn(r);
}).then(()=>{
logCtl.info({
optitle:"socket.server.js->响应消息处理->接口调用info:",
op:msg.cls+"/"+msg.method,
content:JSON.stringify(msg.data),
clientIp:null,
agent:"",
});
}).catch(err=>{
logCtl.error({
optitle:"socket.server.js->响应消息处理->接口调用异常error:",
op:msg.cls+"/"+msg.method,
content:JSON.stringify(msg.data),
clientIp:null,
agent:"",
});
})
});
}
}
class SocketServer{
constructor(httpServer){
this.server=Server(httpServer,{
serveClient: false,
});
this.users={};
this.init();
this.onlines=0;
}
init(){
var self=this;
//挂载到web应用的控制器
notifyCtl.setSocketServer(self);
//订阅广播频道
redisClient.subscribe("brc",self);
//中间件可以在链接事件发出前调用一次
this.server.use((socket,next)=>{
next();
});
this.server.on('connection', function(client){
console.log("connection.....socket");
//链接登录事件
client.on('login', function(data){
console.log("login...........................................................success");
console.log(data);
console.log(client.remoteAddress);
var uk=data.appid+"¥"+data.id;
client.uk=uk;
client.uid=data.id;
client.username=data.nickName;
client.appname=data.appname;
client.appkey=data.appkey;
client.sex=data.sex;
client.imgUrl=data.imgUrl;
self.users[uk]=new MsgHandler(self,client);
//订阅uk私人频道
var ss = redisClient.subscribe(uk,self);
//加入redisClient列表
redisClient.sadd("onlineset"+"¥"+data.appkey,[uk+"¥"+data.nickName+"¥"+data.imgUrl]).then(n=>{
//当前在线
self.onlines=n;
redisClient.publish("brc",JSON.stringify({"type":"online","content":n}));
});
});
//链接断开事件
client.on('disconnect', async function(r){
console.log("connection.........................................dismiss.............");
if(client.uk) {
await redisClient.srem("onlineset"+"¥"+client.appkey,client.uk+"¥"+client.username+"¥"+client.imgUrl);
await redisClient.publish("brc",JSON.stringify({"type":"online","content":(self.onlines--)}));
delete self.users[client.uk];
redisClient.unsubscribe(client.uk);
//redisClient.unsubscribe("brc");
console.log(client.uk+"¥"+client.username+"¥"+client.imgUrl);
}
});
});
}
}
module.exports=SocketServer;
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="keywords" content="PAAS 开放平台">
<meta name="baidu-site-verification" content="lATAxZAm8y" />
<meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8, user-scalable=1">
<title id="idtitle"><%=app.name%></title>
<link rel="stylesheet" href="/css/ele/index_2.5.4.css">
<link rel="stylesheet" href="<%=paasurl%>/css/pagecom.css">
<link rel="stylesheet" href="/css/pagecom.css">
<link rel="stylesheet" href="/css/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/fontawesome/css/toolicon-style.css">
<link rel="stylesheet" href="/css/fontface-timely.css">
<script src="/js/vue/vue.min_2.6.10.js"></script>
<script src="/js/vue/vue-router.min.js"></script>
<script src="/js/vue/vuex.min.js"></script>
<script src="/js/ele/index_2.5.4.js"></script>
<script src="/js/vue/axios.min.js"></script>
<script>
//缓存当前域名对应的公司信息,公司、页脚、银行账号---全局变量
var appinfo = JSON.parse(unescape('<%=appinfo%>'));
console.log(appinfo);
//缓存当前的基础组件列表
var basecomp=JSON.parse(unescape('<%=basecomp%>'));
//缓存当前的菜单配置
var global_rsconfig=JSON.parse(unescape('<%=rsconfig%>'));
console.log(JSON.stringify(global_rsconfig));
</script>
<style>
body{
margin: 0px;
padding: 0px;
font-size: 14px;
box-sizing: border-box;
height: 100%;
}
.app-main{
width:100%;
height:100%;
background:url("<%=app.bkimageUrl?app.bkimageUrl:'/imgs/pt3.jpg'%>") no-repeat;background-size: cover;
box-sizing: border-box;
}
.app-header{
display: flex;
justify-content:space-between;
color: white;
padding: 15px;
box-sizing: border-box;
cursor: pointer;
}
.app-stage{
display: flex;
width: 100%;
padding: 5px;
box-sizing: border-box;
}
.app-stage .leftnav{
background-color:green;
max-width: 250px;
min-width: 250px;
flex-grow:1;
box-sizing: border-box;
}
.app-stage .leftnav .el-card__body {
height: 85%;
}
.app-stage .rightcontent{
flex-grow:2;
margin-left: 5px;
margin-right: 15px;
box-sizing: border-box;
}
.app-stage .rightcontent >.el-card{
border-radius: 0px;
height: 100%;
box-shadow:unset;
box-sizing: border-box;
}
.app-stage .is-always-shadow{
box-shadow: unset;
}
.app-stage .leftnav > .el-card{
border-radius: 0px;
height: 100%;
box-sizing: border-box;
}
#appName{
font-size: 30px;
font-family:MicrosoftYaHei;
}
.el-button--text{
color: white
}
.activeColor{
color:deepskyblue;
}
</style>
</head>
<body>
<div id="app" v-loading="loading" class="app-main" style="visibility:hidden">
<div id="app-header" class="app-header">
<div id="appName" @click="clkapp"><%=app.name%>后台管理</div>
<div id="login">
<span v-if="currentUser">欢迎您,{{currentUser.nickName}}
<el-button @click="exitclick" type="text" icon="el-icon-setting">退出</el-button>
</span>
</div>
</div>
<div id="app-stage" class="app-stage">
<div class="leftnav">
<el-card id="leftnav">
<gsb-leftmenu bkcolor="white" ref="leftmenu" key="leftmenu" formatprop="formatItem" @menuselect="onMenuSelect"></gsb-leftmenu>
</el-card>
</div>
<div class="rightcontent">
<transition name="slide-fade">
<router-view>
</router-view>
</transition>
</div>
</div>
</div>
<script src="/js/vue/jquery.min.js"></script>
<script src="/js/common.js"></script>
<script src="/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="keywords" content="PAAS 开放平台">
<meta name="baidu-site-verification" content="lATAxZAm8y" />
<meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8, user-scalable=1">
<title id="idtitle"><%=app?app.name:'应用未启用'%></title>
<link rel="stylesheet" href="/css/ele/index_2.5.4.css">
<link rel="stylesheet" href="/css/pagecom.css">
<link rel="stylesheet" href="/css/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/fontawesome/css/toolicon-style.css">
<link rel="stylesheet" href="/css/fontface-timely.css">
<script src="/js/vue/vue.min_2.6.10.js"></script>
<script src="/js/vue/vue-router.min.js"></script>
<script src="/js/vue/vuex.min.js"></script>
<script src="/js/ele/index_2.5.4.js"></script>
<script src="/js/vue/axios.min.js"></script>
<script>
var appinfo = JSON.parse(unescape('<%=appinfo?appinfo:null%>'));
//缓存当前的基础组件列表
var basecomp=JSON.parse(unescape('<%=basecomp%>'));
</script>
<style>
body{
margin: 0px;
padding: 0px;
font-size: 14px;
}
.app-main{
width:100%;
height:100%;
background:url("<%=app.bkimageUrl?app.bkimageUrl:'/imgs/pt3.jpg'%>") no-repeat;background-size: cover;
}
.app-header{
display: flex;
justify-content:space-between;
color: white;
padding: 15px;
cursor: pointer;
}
#appName{
font-size: 30px;
font-family:MicrosoftYaHei;
}
.el-button--text{
color: white
}
.activeColor{
color:deepskyblue;
}
.hoverclass:hover{
color:deepskyblue;
}
</style>
</head>
<body>
<div id="app" v-loading="loading" class="app-main" style="visibility:hidden">
<div id="app-header" class="app-header">
<div id="appName">
<span><%=app?app.name:'应用未启用'%></span>
<span v-if="currentUser" style="font-size:14px"><span class="fa fa-home" ></span>{{currentUser.owner.name}}</span>
</div>
<div id="login">
<span v-if="currentUser">欢迎您,{{currentUser.nickName}}
<el-button v-if="currentUser.isSelfLogin" @click="exitclick" type="text" icon="el-icon-setting">退出</el-button>
</span>
<gsb-button-group v-if="!currentUser" @select="onselect" ikey="login" :btns="logins"></gsb-button-group>
</div>
</div>
<transition name="slide-fade">
<router-view>
</router-view>
</transition>
<div v-if="currentUser" style="position:fixed;bottom:100px;right:50px;opacity: 0.6;">
<el-card style="height:350px;width:200px;font-size:20px;border-radius: 0px">
<div class="hoverclass" style="cursor:pointer;padding:30px" @click="bizadmin" v-if="currentUser"><i class="el-icon-setting"></i>业务管理</div>
<div class="hoverclass" style="cursor:pointer;padding:30px" @click="settingclick" v-if="currentUser && currentUser.isAdmin"><i class="el-icon-setting"></i>系统管理</div>
</el-card>
</div>
</div>
<script src="/js/vue/jquery.min.js"></script>
<script src="/js/common.js"></script>
<script src="/js/index.js"></script>
</body>
</html>
\ No newline at end of file
.autumn-main-nav-item,.autumn-search .el-input-group__append,.autumn-search-text{font-family:MicrosoftYaHei;font-weight:400}.autumn-img1,.autumn-img2,.autumn-img3,.autumn-search{text-align:center}.serviceSmall li,.serviceSmallName{list-style:none;box-sizing:border-box}.autumn-main-content,.autumn-main-top-item,.autumn-two-main-left,.autumn-two-right,.content-item-shade,.serviceSmall li,.serviceSmallName,.spring_daohang{box-sizing:border-box}.autumn{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.autumn-search{width:1200px;height:173px;margin:0 auto;line-height:173px;z-index:99}.autumn-search-text{display:inline-block;margin-right:42px;font-size:30px;color:rgba(252,86,52,1)}.autumn-search-input{width:788px;height:54px;background:rgba(255,255,255,1);border:2px solid rgba(253,98,40,1)}.autumn-search .el-input__inner{width:631px;line-height:54px;height:54px;border:none;border-radius:0}.autumn-search .el-input-group__append{width:157px;background:#FC5634;font-size:16px;color:rgba(255,255,255,1);border:none;border-radius:0}.autumn-main-top{width:100%;height:264px;padding:20px 0}.autumn-main-top-item{float:left;width:25%;height:100%;padding:10px;cursor:pointer}.autumn-main-top-item:hover{opacity:.8}.autumn-main-top-item>img{width:100%;height:100%}.autumn-main-nav{margin:25px 10px;width:100%;height:42px;border-left:1px solid rgba(229,59,24,1)}.autumn-main-nav-item{float:left;width:125px;height:40px;line-height:40px;border:1px solid rgba(229,59,24,1);border-left:none;font-size:14px;color:rgba(252,86,52,1);text-align:center;cursor:pointer}.autumn-main-content{margin:22px 0;width:100%;max-height:670px;padding:0 10px}.autumn-main-content-item{display:inline-block;width:231px;height:164px;background-color:#f4a460;position:relative;cursor:pointer}.autumn-main-content-item>img,.content-item-shade{height:100%;width:100%}.content-item-shade{position:absolute;top:0;font-size:18px;background-color:rgba(0,0,0,.6);color:#fff;padding:20px 40px;opacity:0;transition:opacity .5s;-moz-transition:opacity .5s;-webkit-transition:opacity .5s;-o-transition:opacity .5s}.content-item-shade>div{width:100%;line-height:40px;height:40px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.autumn-main-content-item:hover .content-item-shade{opacity:1}.autumn-img1{width:100%;height:693px;background:url(/imgs/autumn/bj1.png);background-size:100% 100%}.autumn-img2{width:100%;height:662px;background:url(/imgs/autumn/bj2.png);background-size:100% 100%}.autumn-img3{width:100%;height:616px;background:url(/imgs/autumn/bj3.png);background-size:100% 100%}.autumn-bj>img{margin-top:99px}.autumn-two{position:absolute;top:83px;width:100%;height:400px;z-index:999}.autumn-two-main{width:1200px;height:100%;margin:0 auto}.autumn-two-main-left{float:left;width:200px;height:100%;background:rgba(0,0,0,.5);border-radius:3px;-webkit-border-radius:3px}.autumn-two-left-item,.autumn-two-left-item-cla{width:100%;height:50px;line-height:50px;font-size:14px;cursor:pointer}.autumn-two-left-item{text-align:left;color:rgba(255,255,255,.7)}.autumn-two-left-item:last-child{text-align:center;background:#fc5634;color:#fff}.autumn-two-left-item-cla{text-align:left;background-color:#FFF;color:#FD6228}.autumn-two-left-item-span{display:block;width:60%;height:100%;margin:0 auto}.autumn-two-right{width:1000px;height:100%;overflow-y:auto;float:right;background-color:#fff;text-align:left;cursor:default}.colorPieceModel,.serviceSmallName{border-radius:8px;text-align:center;float:left}.autumn-tow-right-it,.autumn-tow-right-title{cursor:pointer;font-size:14px;font-family:PingFangSC-Regular;overflow:hidden}.autumn-tow-right-title{width:100%;padding-left:11px;line-height:36px;color:rgba(56,64,75,1);font-weight:700}.autumn-tow-right-lists{float:left;width:100%;height:100%}.autumn-tow-right-it{float:left;line-height:30px;font-weight:400;color:#666;position:relative;padding:0 11px}.autumn-tow-right-it:after{content:'';position:absolute;width:1px;height:10px;background-color:#a4a4a4;top:10px;right:0}.autumn-tow-right-it:last-child{position:static}.autumn-tow-right-it:hover{color:#FD6228}.colorPieceModel{width:220px;height:460px;color:#fff;font-size:32px;font-family:JZhongYi;overflow:hidden}.moreservice-spring-left-button,.moreservice-spring-right-button{top:45%;font-size:36px;color:rgba(210,214,218,1);z-index:9999;cursor:pointer;position:absolute}.moreservice-spring-right-button{right:0}.moreservice-spring-left-button{left:0}#ip-button:hover{color:#6592F7}#ic-button:hover{color:#A78CEE}#pa-button:hover{color:#EB9E55}.serviceSmall{float:left;width:77%;padding-left:0;margin-bottom:0}.serviceSmall li{width:32%;height:121px;padding:15px;float:left;background-color:#fff;border-radius:8px;margin-left:8px;margin-bottom:8px;transition:box-shadow .2s,margin-top .2s;-webkit-transition:box-shadow .2s,margin-top .2s}#ip li:hover{cursor:pointer;box-shadow:2px 2px 8px #6592F7;margin-top:-2px}#ic li:hover{cursor:pointer;box-shadow:2px 2px 8px #A78CEE;margin-top:-2px}#pa li:hover{cursor:pointer;box-shadow:2px 2px 8px #EB9E55;margin-top:-2px}#LX201906101755oFppND li:hover{cursor:pointer;box-shadow:2px 2px 8px #4081f7;margin-top:-2px}#LX201906111013bmwgjj li:hover{cursor:pointer;box-shadow:2px 2px 8px #ec927f;margin-top:-2px}.serviceSmall h5{color:#38404b;font-size:16px;margin:0 auto}.serviceSmall p{height:35px;color:#828282;font-size:12px;line-height:18px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.serviceSmall li span{color:#FF394D;font-size:16px}.serviceSmallName{padding:12px;margin-left:44px;margin-top:15px;width:130px;height:121px;color:#fff;font-size:14px}.serviceSmallImg{height:auto;margin:0 auto 5px;display:block}.spring_daohang{position:absolute;bottom:10px;left:0;width:950px;height:10px;float:left;padding-right:50px}.spring_daohang_list,.spring_daohang_list_xz{width:10px;height:10px;border-radius:50%;float:right;margin-left:15px;cursor:pointer}.spring_daohang_list{opacity:.5}.spring_daohang_list_xz{opacity:1}
\ No newline at end of file
/* * {
margin: 0;
padding: 0;
} */
.cut {
width: 400px;
height: 400px;
margin: 30px auto;
}
.c-item {
max-width: 600px;
margin: 10px auto;
margin-top: 20px;
}
.content {
margin: auto;
max-width: 1200px;
margin-bottom: 100px;
}
.test-button {
display: flex;
flex-wrap: wrap;
align-content: center;
justify-content: center;
}
.btn {
display: inline-block;
line-height: 1;
white-space: nowrap;
cursor: pointer;
background: #fff;
border: 1px solid #c0ccda;
color: #1f2d3d;
text-align: center;
box-sizing: border-box;
outline: none;
margin:20px 10px 0px 0px;
padding: 9px 15px;
font-size: 14px;
border-radius: 4px;
color: #fff;
background-color: #50bfff;
border-color: #50bfff;
transition: all .2s ease;
text-decoration: none;
user-select: none;
}
.des {
line-height: 30px;
}
code.language-html {
padding: 10px 20px;
margin: 10px 0px;
display: block;
background-color: #333;
color: #fff;
overflow-x: auto;
font-family: Consolas, Monaco, Droid, Sans, Mono, Source, Code, Pro, Menlo, Lucida, Sans, Type, Writer, Ubuntu, Mono;
border-radius: 5px;
white-space: pre;
}
.show-info {
margin-bottom: 50px;
}
.show-info h2 {
line-height: 50px;
}
/*.title, .title:hover, .title-focus, .title:visited {
color: black;
}*/
.cropper_title {
display: block;
text-decoration: none;
text-align: center;
line-height: 1.5;
margin: 20px 0px;
background-image: -webkit-linear-gradient(left,#3498db,#f47920 10%,#d71345 20%,#f7acbc 30%,#ffd400 40%,#3498db 50%,#f47920 60%,#d71345 70%,#f7acbc 80%,#ffd400 90%,#3498db);
color: transparent;
-webkit-background-clip: text;
background-size: 200% 100%;
animation: slide 5s infinite linear;
font-size: 40px;
}
.test {
height: 500px;
}
.model {
position: fixed;
z-index: 10;
width: 100vw;
height: 100vh;
overflow: auto;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
}
.model-show {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
}
.model img {
display: block;
margin: auto;
max-width: 80%;
user-select: none;
background-position: 0px 0px, 10px 10px;
background-size: 20px 20px;
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%),linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
}
.c-item {
display: block;
user-select: none;
}
@keyframes slide {
0% {
background-position: 0 0;
}
100% {
background-position: -100% 0;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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