Commit 9cb6ccca by 蒋勇

d

parent 567e162e
...@@ -7,6 +7,10 @@ class CtlBase { ...@@ -7,6 +7,10 @@ class CtlBase {
this.service = system.getObject("service." + gname + "." + sname); this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
} }
static getServiceName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
}
async setContextParams(pobj, qobj, req) { async setContextParams(pobj, qobj, req) {
} }
......
const system = require("../../system"); const system = require("../../system");
const settings = require("../../../config/settings"); const settings = require("../../../config/settings");
const uiconfig = system.getUiConfig2(settings.wxconfig.appId); const appconfig = system.getSysConfig();
function exp(db, DataTypes) { function exp(db, DataTypes) {
var base = { var base = {
//继承的表引用用户信息user_id //继承的表引用用户信息user_id
...@@ -16,10 +16,10 @@ function exp(db, DataTypes) { ...@@ -16,10 +16,10 @@ function exp(db, DataTypes) {
}, },
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过" auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.audit_status), values: Object.keys(appconfig.pdict.audit_status),
set: function (val) { set: function (val) {
this.setDataValue("auditStatus", val); this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", uiconfig.config.pdict.audit_status[val]); this.setDataValue("auditStatusName", appconfig.pdict.audit_status[val]);
}, },
defaultValue:"dsh", defaultValue:"dsh",
}, },
...@@ -29,7 +29,7 @@ function exp(db, DataTypes) { ...@@ -29,7 +29,7 @@ function exp(db, DataTypes) {
values: Object.keys(uiconfig.config.pdict.source_type), values: Object.keys(uiconfig.config.pdict.source_type),
set: function (val) { set: function (val) {
this.setDataValue("sourceType", val); this.setDataValue("sourceType", val);
this.setDataValue("sourceTypeName", uiconfig.config.pdict.source_type[val]); this.setDataValue("sourceTypeName", appconfig.pdict.source_type[val]);
} }
}, },
sourceOrderNo: DataTypes.STRING(100),//来源单号 sourceOrderNo: DataTypes.STRING(100),//来源单号
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class AccountDao extends Dao{
constructor(){
super(Dao.getModelName(AccountDao));
}
async findOrCreate(ac,t){
var account= await this.model.findOne({where:{unionId:ac.unionId}},{transaction:t});
if(account){
return account;
}else{
account=await this.model.create(ac,{transaction:t});
return account;
}
}
async findOneByOnlyCode(onlycode){
return this.model.findOne({"where":{"onlyCode":onlycode}});
}
}
module.exports=AccountDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class AccountLogDao extends Dao{
constructor(){
super(Dao.getModelName(AccountLogDao));
}
}
module.exports=AccountLogDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class PAccountDao extends Dao{
constructor(){
super(Dao.getModelName(PAccountDao));
}
async findPAccount(t){
return this.model.findOne({},{transaction:t});
}
}
module.exports=PAccountDao;
...@@ -3,7 +3,6 @@ const Dao=require("../../dao.base"); ...@@ -3,7 +3,6 @@ const Dao=require("../../dao.base");
class UserDao extends Dao{ class UserDao extends Dao{
constructor(){ constructor(){
super(Dao.getModelName(UserDao)); super(Dao.getModelName(UserDao));
this.appDao=system.getObject("db.common.appDao");
} }
async getAuths(userid){ async getAuths(userid){
var self=this; var self=this;
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class UsereaccountDao extends Dao{
constructor(){
super(Dao.getModelName(UsereaccountDao));
}
}
module.exports=UsereaccountDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ApiTradeDao extends Dao{
constructor(){
super(Dao.getModelName(ApiTradeDao));
}
// extraWhere(obj,w){
// if(obj.codepath && obj.codepath!=""){
// if(obj.codepath.indexOf("mytraderecord")>0){//说明是普通用户的交易查询
// w["user_id"]=obj.uid;
// }
// }
// return w;
// }
async create(tradeobj,t){
var trade=await super.create(tradeobj,t)
return trade;
}
}
module.exports=ApiTradeDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ArticleDao extends Dao{
constructor(){
super(Dao.getModelName(ArticleDao));
}
extraModelFilter(){
return {"key":"include","value":[{model:this.db.models.newschannel,attributes:["id","title"]},]};
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["orderNo","ASC"]];
}
}
module.exports=ArticleDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ChannelDao extends Dao{
constructor(){
super(Dao.getModelName(ChannelDao));
}
extraModelFilter(){
//return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return {"key":"include","value":[{model:this.db.models.role,as:"Roles",attributes:["id","name"]}]};
}
async preUpdate(u){
if(u.roles.length>0){
var roles=await this.db.models.role.findAll({where:{id:{[this.db.Op.in]:u.roles}}});
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
console.log(roles);
u.roles=roles
}
return u;
}
async update(obj){
var obj2=await this.preUpdate(obj);
console.log("update....................");
console.log(obj2);
await this.model.update(obj2,{where:{id:obj2.id}});
var channel=await this.model.findOne({where:{id:obj2.id}});
channel.setRoles(obj2.roles);
return channel;
}
}
module.exports=ChannelDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class LoopplayDao extends Dao{
constructor(){
super(Dao.getModelName(LoopplayDao));
}
// channelCode: ""
// extraModelFilter(){
// return {"key":"include","value":[{model:this.db.models.newschannel,attributes:["id","title"]},]};
// }
extraWhere(obj, w){
let channelCode = obj.channelCode || '';
if(channelCode == "index") {
w["channelCode"] = '';
} else if(channelCode) {
w["channelCode"] = channelCode;
}
// if(pageType == 1) {
// w["status"] = {[this.db.Op.in]: ['1']};
// } else if (pageType == 2) {
// w["status"] = {[this.db.Op.in]: ['2']};
// } else if (pageType == 3) {
// w["status"] = {[this.db.Op.in]: ['4','8','16']};
// }
return w;
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["orderNo","ASC"]];
}
}
module.exports=LoopplayDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class NewschannelDao extends Dao{
constructor(){
super(Dao.getModelName(NewschannelDao));
}
async findAgreenment(queryobj,qobj,req){
var result =await this.model.findAll({
where:{id:1},
include:{
model:this.db.models.article,
limit:1,
offset:0
},
});
console.log("---------------------------------------------------------------zhangjiao");
console.log(result);
return result;
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["orderNo","ASC"]];
}
async findPrev5(queryobj,qobj){
console.log(qobj);
return this.model.findAll({
where:{isPubed:1},
include:{
model:this.db.models.article,
limit:5,
offset:0
},
limit:6,
offset:0,
});
}
}
module.exports=NewschannelDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class SloganpictureDao extends Dao{
constructor(){
super(Dao.getModelName(SloganpictureDao));
}
// extraModelFilter(){
// return {"key":"include","value":[{model:this.db.models.newschannel,attributes:["id","title"]},]};
// }
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["orderNo","ASC"]];
}
}
module.exports=SloganpictureDao;
const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var glob = require("glob");
class APIDocManager{
constructor(){
this.doc={};
this.buildAPIDocMap();
}
async buildAPIDocMap(){
var self=this;
//订阅任务频道
var apiPath=settings.basepath+"/app/base/api/impl";
var rs = glob.sync(apiPath + "/**/*.js");
if(rs){
for(let r of rs){
// var ps=r.split("/");
// var nl=ps.length;
// var pkname=ps[nl-2];
// var fname=ps[nl-1].split(".")[0];
// var obj=system.getObject("api."+pkname+"."+fname);
var ClassObj=require(r);
var obj=new ClassObj();
var gk=obj.apiDoc.group+"|"+obj.apiDoc.groupDesc
if(!this.doc[gk]){
this.doc[gk]=[];
this.doc[gk].push(obj.apiDoc);
}else{
this.doc[gk].push(obj.apiDoc);
}
}
}
}
}
module.exports=APIDocManager;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ApiTradeDao extends Dao{
constructor(){
super(Dao.getModelName(ApiTradeDao));
}
// extraWhere(obj,w){
// if(obj.codepath && obj.codepath!=""){
// if(obj.codepath.indexOf("mytraderecord")>0){//说明是普通用户的交易查询
// w["user_id"]=obj.uid;
// }
// }
// return w;
// }
async create(tradeobj,t){
var trade=await super.create(tradeobj,t)
return trade;
}
}
module.exports=ApiTradeDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppDao extends Dao {
constructor() {
super(Dao.getModelName(AppDao));
}
async findOneById(id, t) {
var sqlWhere = {
where: { id: id },
attributes: ["id", "appkey", "secret", "domainName"], raw: true
};
if (t) {
sqlWhere.transaction = t;
}
var app = await this.model.findOne(sqlWhere);
return app;
}
async findOne(appKey, secret, t) {
var tmpAttributes = [`id`,
`appkey`,
`name`,
`domainName`,
`homePage`,
`docUrl`,
`authUrl`,
`logoUrl`,
`bkimageUrl`,
`showimgUrl`,
`detailimgUrl`,
`description`,
`isEnabled`,
`isPublish`,
`isCommon`,
`appType`,
`uiconfigUrl`,
`opCacheUrl`,
`notifyCacheCountUrl`];
if (t) {
var app = await this.model.findOne({ where: { appkey: appKey, secret: secret }, attributes: tmpAttributes, raw: true }, { transaction: t });
return app;
} else {
var app = await this.model.findOne({ where: { appkey: appKey, secret: secret }, attributes: tmpAttributes, raw: true });
return app;
}
}
async findOne2(appKey, t) {
var tmpAttributes = [`id`,
`appkey`,
`name`,
`domainName`,
`homePage`,
`docUrl`,
`authUrl`,
`logoUrl`,
`bkimageUrl`,
`showimgUrl`,
`detailimgUrl`,
`description`,
`isEnabled`,
`isPublish`,
`isCommon`,
`isSaas`,
`appType`,
`uiconfigUrl`,
`opCacheUrl`,
`notifyCacheCountUrl`];
if (t) {
var app = await this.model.findOne({ where: { appkey: appKey }, attributes: tmpAttributes, raw: true }, { transaction: t });
return app;
} else {
var app = await this.model.findOne({ where: { appkey: appKey }, attributes: tmpAttributes, raw: true });
return app;
}
}
async findAndCountAll(qobj, t) {
if(qobj.codepath.indexOf("comapps")>=0){
var rtn={};
var comp=await this.db.models.company.findOne({where:{companykey:qobj.search.companykey}});
var apps=await comp.getApps();
rtn.results={rows:apps,count:apps.length};
rtn.aggresult={};
return rtn;
}else{
return super.findAndCountAll(qobj, t);
}
}
extraWhere(obj, w, qc, linkAttrs) {
if (obj.codepath && obj.codepath != "") {
if (obj.codepath.indexOf("pmgmyapps") > 0) {//说明是应用管理员的查询
w["creator_id"] = obj.userid;
}
}
if (linkAttrs.length > 0) {
var search = obj.search;
var lnkKey = linkAttrs[0];
var strq = "$" + lnkKey.replace("~", ".") + "$";
w[strq] = { [this.db.Op.like]: "%" + search[lnkKey] + "%" };
}
return w;
}
}
module.exports = AppDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CompanyDao extends Dao {
constructor() {
super(Dao.getModelName(CompanyDao));
}
extraWhere(obj, w, qc, linkAttrs) {
return w;
}
// extraModelFilter(pobj){
// return {"key":"include",
// "value":[{
// model:this.db.models.user,
// as:"Users",
// through:{
// where:{id:pobj.uid}
// }
// },
// ]};
// }
}
module.exports = CompanyDao;
...@@ -18,8 +18,6 @@ class DbFactory{ ...@@ -18,8 +18,6 @@ class DbFactory{
async initModels(){ async initModels(){
var self=this; var self=this;
var modelpath=path.normalize(path.join(__dirname, '../..'))+"/models/"; var modelpath=path.normalize(path.join(__dirname, '../..'))+"/models/";
console.log("modelpath=====================================================");
console.log(modelpath);
var models=glob.sync(modelpath+"/**/*.js"); var models=glob.sync(modelpath+"/**/*.js");
console.log(models.length); console.log(models.length);
models.forEach(function(m){ models.forEach(function(m){
...@@ -29,58 +27,14 @@ class DbFactory{ ...@@ -29,58 +27,14 @@ class DbFactory{
console.log("init models...."); console.log("init models....");
} }
async initRelations(){ async initRelations(){
/**
一个账户对应多个登陆用户
一个账户对应一个commany
一个APP对应多个登陆用户
一个APP有多个角色
登陆用户和角色多对多
**/
/*建立账户和用户之间的关系*/
//account--不属于任何一个app,是统一用户
//用户登录时首先按照用户名和密码检查account是否存在,如果不存在则提示账号或密码不对,如果
//存在则按照按照accountid和应用key,查看user,后台实现对应user登录
//管理员添加用户,需要同时增加开放平台用户及其所属租户创建的公司
this.db.models.user.belongsTo(this.db.models.account,{constraints: false,});
this.db.models.account.hasMany(this.db.models.user,{constraints: false,});
this.db.models.user.belongsTo(this.db.models.company,{as:"owner",constraints: false,});//人员直属公司
this.db.models.user.belongsTo(this.db.models.user,{as:"tanentor",constraints: false,});//指定用户所属租户
this.db.models.app.belongsTo(this.db.models.user,{as:"creator",constraints: false,});//指定用户所属租户
this.db.models.user.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.role.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.role.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.dataauth.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.dataauth.belongsTo(this.db.models.user,{constraints: false,}); this.db.models.dataauth.belongsTo(this.db.models.user,{constraints: false,});
/*建立用户和角色之间的关系*/ /*建立用户和角色之间的关系*/
this.db.models.user.belongsToMany(this.db.models.role, {as:"Roles",through: 'p_userrole',constraints: false,}); this.db.models.user.belongsToMany(this.db.models.role, {as:"Roles",through: 'p_userrole',constraints: false,});
this.db.models.role.belongsToMany(this.db.models.user, {as:"Users",through: 'p_userrole',constraints: false,}); this.db.models.role.belongsToMany(this.db.models.user, {as:"Users",through: 'p_userrole',constraints: false,});
this.db.models.pconfig.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.pconfig.belongsTo(this.db.models.company,{constraints: false,});
/*建立应用和租户公司之间的关系*/
this.db.models.company.belongsToMany(this.db.models.app, {through: this.db.models.companyapp,constraints: false,});
this.db.models.app.belongsToMany(this.db.models.company, {through: this.db.models.companyapp,constraints: false,});
/*建立用户和租户之间的关系*/
this.db.models.user.belongsToMany(this.db.models.company, {through: this.db.models.usercompany,constraints: false,});
this.db.models.company.belongsToMany(this.db.models.user, {through: this.db.models.usercompany,constraints: false,});
/*组织机构*/ /*组织机构*/
this.db.models.org.belongsTo(this.db.models.org,{constraints: false,}); this.db.models.org.belongsTo(this.db.models.org,{constraints: false,});
this.db.models.org.hasMany(this.db.models.org,{constraints: false,}); this.db.models.org.hasMany(this.db.models.org,{constraints: false,});
this.db.models.org.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.org.belongsTo(this.db.models.app,{constraints: false,});
//组织机构和角色是多对多关系 //组织机构和角色是多对多关系
this.db.models.org.belongsToMany(this.db.models.role,{through: this.db.models.orgrole,constraints: false,}); this.db.models.org.belongsToMany(this.db.models.role,{through: this.db.models.orgrole,constraints: false,});
...@@ -88,7 +42,6 @@ class DbFactory{ ...@@ -88,7 +42,6 @@ class DbFactory{
//组织机构和用户是多对多关系 //组织机构和用户是多对多关系
this.db.models.user.belongsTo(this.db.models.org,{constraints: false,}); this.db.models.user.belongsTo(this.db.models.org,{constraints: false,});
} }
//async getCon(){,用于使用替换table模型内字段数据使用 //async getCon(){,用于使用替换table模型内字段数据使用
getCon(){ getCon(){
...@@ -116,12 +69,6 @@ class DbFactory{ ...@@ -116,12 +69,6 @@ class DbFactory{
} }
return this.db; return this.db;
} }
getConhb(){
var that=this;
if(settings.env=="dev"){
}
return this.dbhb;
}
} }
module.exports=DbFactory; module.exports=DbFactory;
// const dbf=new DbFactory(); // const dbf=new DbFactory();
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class MetaDao{
constructor(){
//super(Dao.getModelName(AppDao));
}
}
module.exports=MetaDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class OplogDao extends Dao{
constructor(){
super(Dao.getModelName(OplogDao));
}
}
module.exports=OplogDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class PConfigDao extends Dao{
constructor(){
super(Dao.getModelName(PConfigDao));
}
async findByConfigType(type,t){
return this.model.findOne({where:{configType:type}},{transaction:t});
}
extraWhere(obj,w,qc,linkAttrs){
// if(obj.codepath && obj.codepath!=""){
// // if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询
// // console.log(obj);
// // w["app_id"]=obj.appid;
// // }
// }
w["app_id"]=obj.appid;
w["company_id"]=obj.tocompanyid;
return w;
}
}
module.exports=PConfigDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class TaskDao extends Dao{
constructor(){
super(Dao.getModelName(TaskDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
async delete(task,qobj,t){
return task.destroy({where:qobj,transaction:t});
}
}
module.exports=TaskDao;
const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var cron = require('node-cron');
class TaskManager{
constructor(){
this.taskDic={};
this.redisClient=system.getObject("util.redisClient");
this.buildTaskMap();
}
async buildTaskMap(){
var self=this;
//订阅任务频道
await this.redisClient.subscribeTask("task",this);
var taskPath=settings.basepath+"/app/base/db/task/";
const files=fs.readdirSync(taskPath);
if(files){
files.forEach(function(r){
var classObj=require(taskPath+"/"+r);
self[classObj.name]=new classObj();
});
}
}
async addTask(taskClassName,exp){
(async (tn,ep)=>{
if(!this.taskDic[tn]){
this.taskDic[tn]=cron.schedule(ep,()=>{
this[tn].doTask();
});
}
})(taskClassName,exp);
}
async deleteTask(taskClassName){
if(this.taskDic[taskClassName]){
this.taskDic[taskClassName].destroy();
delete this.taskDic[taskClassName];
}
}
async clearlist(){
var x=await this.redisClient.clearlist("tasklist");
return x;
}
async publish(channel,msg){
var x=await this.redisClient.publish(channel,msg);
return x;
}
async newTask(taskstr){
return this.redisClient.rpush("tasklist",taskstr);
}
}
module.exports=TaskManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
const system=require("../../../system");
const Dao=require("../../dao.base");
class UploadDao extends Dao{
constructor(){
super(Dao.getModelName(UploadDao));
}
}
module.exports=UploadDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MsgHistoryDao extends Dao{
constructor(){
super(Dao.getModelName(MsgHistoryDao));
}
extraWhere(obj,w){
if(obj.ukstr && obj.ukstr!=""){
// w={[this.db.Op.or]:[
// {[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
// {[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
// ]
// };
w[this.db.Op.or]=[
{[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
{[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
];
}
return w;
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]];
}
}
module.exports=MsgHistoryDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MsgNoticeDao extends Dao{
constructor(){
super(Dao.getModelName(MsgNoticeDao));
}
async saveNotice(msg, t) {
var noticeFrom = await super.findOne({fromId : msg.senderId, toId : msg.targetId});
if(noticeFrom) {
var set = {lastMsgId:msg.id};
if(msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
await super.updateByWhere(set, {where:{id:noticeFrom.id}}, t);
} else {
noticeFrom = {
fromuser: msg.sender,
fromId:msg.senderId,
touser: msg.target,
toId:msg.targetId,
isAccepted:true,
lastMsgId:msg.id,
businessLicense_id : msg.businessLicense_id || 0
};
await super.create(noticeFrom, t);
}
var noticeTo = await super.findOne({fromId : msg.targetId, toId : msg.senderId});
if(noticeTo) {
var set = {lastMsgId:msg.id};
if(msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
await super.updateByWhere(set, {where:{id:noticeTo.id}}, t);
} else {
noticeTo = {
fromuser: msg.target,
fromId:msg.targetId,
touser: msg.sender,
toId:msg.senderId,
isAccepted:true,
lastMsgId:msg.id,
businessLicense_id : msg.businessLicense_id || 0
};
await super.create(noticeTo, t);
}
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]];
}
}
module.exports=MsgNoticeDao;
...@@ -9,66 +9,10 @@ const md5 = require("MD5"); ...@@ -9,66 +9,10 @@ const md5 = require("MD5");
var dbf=system.getObject("db.common.connection"); var dbf=system.getObject("db.common.connection");
var db=dbf.getCon(); var db=dbf.getCon();
db.sync({force:true}).then(async ()=>{ db.sync({force:true}).then(async ()=>{
console.log("sync complete...");
//创建平台配置
const PConfig=db.models.pconfig;
var pconfigObjs=await PConfig.bulkCreate([
{configType:"price",configValue:"100",app_id:settings.platformid,company_id:settings.platformcompanyid,appkey:settings.appKey},
{configType:"initGift",configValue:"10000",app_id:settings.platformid,company_id:settings.platformcompanyid,appkey:settings.appKey},
{configType:"apiInitGift",configValue:"500",app_id:settings.platformid,company_id:settings.platformcompanyid,appkey:settings.appKey},
{configType:"apiCallPrice",configValue:"10",app_id:settings.platformid,company_id:settings.platformcompanyid,appkey:settings.appKey},
{configType:"logOpWrite",configValue:"-1",app_id:settings.platformid,company_id:settings.platformcompanyid,appkey:settings.appKey},//操作日志步骤是否写入,0否,1是
]);
//创建平台账户
const PAccount=db.models.paccount;
const pa=await PAccount.create({});
//创建APP const User=db.models.user;
const App=db.models.app; User.create({userName:"sm",password:md5("123"+ "_" + settings.salt),isSuper:true,isAdmin:true,isEnabled:true,nickName:"superman"}).then(function(u){
const Account=db.models.account; console.log("sync complete...");
const Company=db.models.company;
const Auth=db.models.auth;
//创建role
const Role=db.models.role;
var hp=settings.homePage();
var authUrl=settings.authUrl();
//建立平台应用和上帝超级管理员
App.create({appkey:"wx76a324c5d201d1a4",
name:"蜂擎开放平台",
homePage:hp,
docUrl:settings.docUrl(),
authUrl:authUrl,isEnabled:true,isSaas:true,secret:"f99d413b767f09b5dff0b3610366cc46",logoUrl:"",
isCommon:true,
isPublic:false,
appType:"web",
}).then(app=>{
const User=db.models.user;
User.create({owner_id:settings.platformid,userName:"sm",password:md5("123"+ "_" + settings.salt),isSuper:true,isAdmin:true,isEnabled:true,nickName:"superman"}).then(function(u){
app.setCreator(u);
u.setApp(app);
Account.create({nickName:"superman",userName:"sm",password:md5("123")}).then(function(ac){
u.setAccount(ac);
});
//设置当前平台初始的租户,并默认设置当前租户所其用的APP
Company.create({name:"蜂擎云服科技有限公司"}).then(async function(cmp){
await u.addCompany(cmp,{through:{isCurrent:false}});
await cmp.addApp(app);
Role.bulkCreate([
{ name:"租户",code:"common",isSystem:1,app_id:app.id,company_id:cmp.id},
{ name:"路过",code:"pass",isSystem:1,app_id:app.id,company_id:cmp.id},
]);
});
//设置当前初始租户所开启的应用
//初始化平台的租户权限
Auth.create({
rolecode:"common",
bizcode:"companyinfo",
codepath:"paasroot/tanentCenter/appMag/companyinfo",
authstrs:"add,edit,delete",
app_id:1,
company_id:1
});
});
}); });
//创建role //创建role
......
module.exports = {
"config": {
"pdict": {
"app_type": { "api": "API服务","web": "PCWEB","app":"移动APP","xcx":"小程序","access":"接入"},
"data_priv": { "auth.role": "角色", "auth.user": "用户" },
"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": "付款",
},
"node_type":{"org":"组织","arc":"文档"}
}
}
}
const fs=require("fs");
const path=require("path");
const appPath=path.normalize(__dirname+"/app");
const bizsPath=path.normalize(__dirname+"/bizs");
var appJsons={
config:require(appPath+"/"+"platform.js").config
}
module.exports=appJsons;
const system=require("../../../system"); const system=require("../../../system");
const settings=require("../../../../config/settings"); const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey); const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("org", { return db.define("org", {
code: { code: {
...@@ -22,7 +22,7 @@ module.exports = (db, DataTypes) => { ...@@ -22,7 +22,7 @@ module.exports = (db, DataTypes) => {
nodeType: {//默认为组织 nodeType: {//默认为组织
type:DataTypes.ENUM, type:DataTypes.ENUM,
allowNull: false, allowNull: false,
values: Object.keys(uiconfig.config.pdict.node_type), values: Object.keys(appconfig.pdict.node_type),
defaultValue:'org' defaultValue:'org'
}, },
isPosition:{//是否是岗位 isPosition:{//是否是岗位
......
const system=require("../../../system"); const system=require("../../../system");
const settings=require("../../../../config/settings"); const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey); const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("user", { return db.define("user", {
userName: { userName: {
...@@ -18,7 +18,7 @@ module.exports = (db, DataTypes) => { ...@@ -18,7 +18,7 @@ module.exports = (db, DataTypes) => {
sex: { sex: {
type:DataTypes.ENUM, type:DataTypes.ENUM,
allowNull: true, allowNull: true,
values: Object.keys(uiconfig.config.pdict.sex), values: Object.keys(appconfig.pdict.sex),
}, },
mobile:DataTypes.STRING, mobile:DataTypes.STRING,
mail: { mail: {
...@@ -34,9 +34,7 @@ module.exports = (db, DataTypes) => { ...@@ -34,9 +34,7 @@ module.exports = (db, DataTypes) => {
type:DataTypes.BOOLEAN, type:DataTypes.BOOLEAN,
defaultValue: false defaultValue: false
}, },
wxopenid:DataTypes.STRING, center_id:DataTypes.INTEGER,
app_id:DataTypes.INTEGER,
account_id:DataTypes.INTEGER,
isEnabled:{ isEnabled:{
type:DataTypes.BOOLEAN, type:DataTypes.BOOLEAN,
defaultValue: true defaultValue: true
......
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("account", {
nickName: {
type:DataTypes.STRING(128),
allowNull: true,
},
userName:DataTypes.STRING,
password: {
type:DataTypes.STRING,
validate: {
// length(value){
// if(value.length<6){
// throw new Error("lenght。。。")
// }
// }
}
},
sex: {
type:DataTypes.ENUM,
allowNull: true,
values: Object.keys(uiconfig.config.pdict.sex),
},
headUrl: DataTypes.STRING,
mobile: DataTypes.STRING,
baoBalance:{
type:DataTypes.DECIMAL(12,2),
defaultValue:0.00,
},
renBalance:{
type:DataTypes.DECIMAL(12,2),
defaultValue:0.00,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_account',
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("apitrade", {
tradeType: {
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.tradeType),
},
op:{//访问路径
type:DataTypes.STRING,
allowNull: true,
},
srcappkey:{//
type:DataTypes.STRING,
allowNull: true,
},
destappkey:{//
type:DataTypes.STRING,
allowNull: true,
},
params:{
type:DataTypes.STRING(1024),
allowNull: true,
},
clientIp:DataTypes.STRING,
agent:{
type:DataTypes.STRING,
allowNull: true,
},
isAllowed:{
type:DataTypes.BOOLEAN,
defaultValue: true
},
amount: {//每条多少钱
type:DataTypes.INTEGER ,
allowNull: false,
defaultValue: 0
},
desc:DataTypes.STRING,//比如前500条免费
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt:false,
//freezeTableName: true,
// define the table's name
tableName: 'api_trade',
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("app", {
appkey: DataTypes.STRING,//需要在后台补充
secret: DataTypes.STRING,//需要在后台补充
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
domainName: DataTypes.STRING,//域名
homePage: DataTypes.STRING,//首页
authUrl: DataTypes.STRING,//认证地址
docUrl: DataTypes.STRING,//接口文档地址
uiconfigUrl: DataTypes.STRING,//基础信息配置信息地址
logoUrl: DataTypes.STRING,//应用Logo
bkimageUrl: DataTypes.STRING,//应用背景图
showimgUrl: DataTypes.STRING,//应用显示图标
detailimgUrl: DataTypes.STRING,//应用详情介绍地址
opCacheUrl: DataTypes.STRING,//操作缓存地址
notifyCacheCountUrl: DataTypes.STRING,//接收API使用计数的通知URL
description: DataTypes.STRING,//应用描述
isSaas: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true
},//是否启用
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否启用
isPublish: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否对外
isCommon: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否公共服务
appType: {
type: DataTypes.ENUM,
allowNull: true,
values: Object.keys(uiconfig.config.pdict.app_type),
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_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}]
// }
]
});
}
module.exports = (db, DataTypes) => {
return db.define("company", {
name: {
type:DataTypes.STRING,
allowNull: false,
},
creditCode: {
type:DataTypes.STRING,
allowNull: true,
},
licenseUrl: DataTypes.STRING,
description: DataTypes.STRING,
companykey:{
type:DataTypes.STRING,
allowNull: true,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_company',
validate: {
},
});
}
module.exports = (db, DataTypes) => {
return db.define("companyapp", {
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_companyapp',
validate: {
},
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("oplog", {
appkey: {
type:DataTypes.STRING,
allowNull: true,
},
appname:{
type:DataTypes.STRING,
allowNull: false,
},
userid: { type: DataTypes.INTEGER,allowNull: true},
username:{
type:DataTypes.STRING,
allowNull: true,
},
logLevel: {
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.logLevel),
defaultValue: "info",
},
op:{
type:DataTypes.STRING,
allowNull: true,
},
content:{
type:DataTypes.STRING(4000),
allowNull: true,
},
clientIp:DataTypes.STRING,
agent:{
type:DataTypes.STRING,
allowNull: true,
},
opTitle:DataTypes.STRING(500),
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt:false,
//freezeTableName: true,
// define the table's name
tableName: 'op_log',
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}]
// }
]
});
}
module.exports = (db, DataTypes) => {
return db.define("paccount", {
baoBalance:{
type:DataTypes.DECIMAL(12,2),
defaultValue:0.00,
},
renBalance:{
type:DataTypes.DECIMAL(12,2),
defaultValue:0.00,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'pp_account',
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}]
// }
]
});
}
module.exports = (db, DataTypes) => {
const enums={
price:"宝币兑换率",
initGift:"初次赠送",
apiCallPrice:"API调用价格",
apiInitGift:"API初次赠送次数",
logOpWrite:"操作日志步骤是否写入,0否,1是",
}
var PConfig=db.define("pconfig", {
name: {
type:DataTypes.STRING,
allowNull: false,
// get(){
// const ctype = this.getDataValue("configType");
// return enums[ctype];
// }
},
configType: {
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(enums),
set:function(val){
this.setDataValue("name",enums[val]);
this.setDataValue("configType",val);
}
},
configValue: {
type:DataTypes.STRING,
allowNull: false,
},
appkey: {
type:DataTypes.STRING,
allowNull: false,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_config',
validate: {
},
});
PConfig.enums=enums;
return PConfig;
}
module.exports = (db, DataTypes) => {
return db.define("task", {
app_id:DataTypes.STRING,//需要在后台补充
taskClassName: {
type:DataTypes.STRING(100),
allowNull: false,
unique: true
},//和user的from相同,在注册user时,去创建
taskexp: {
type:DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
desc:DataTypes.STRING,//需要在后台补充
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_task',
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}]
// }
]
});
}
module.exports = (db, DataTypes) => {
return db.define("usercompany", {
isCurrent: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否对外
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_usercompany',
validate: {
},
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("msghistory", {
msgType:{
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.msgType),
},
sender:DataTypes.STRING,
senderId:DataTypes.INTEGER,
target:DataTypes.STRING,
targetId:DataTypes.INTEGER,
content: {
type: DataTypes.TEXT('long'),
allowNull: false,
},//需要在后台补充
isRead:{//分享时是否渠道店铺名称,0否,1是
type:DataTypes.BOOLEAN,
defaultValue: false,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'msghistory',
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}]
// }
]
});
}
module.exports = (db, DataTypes) => {
return db.define("msgnotice", {
fromuser: DataTypes.STRING,//需要在后台补充
fromId:DataTypes.INTEGER,
touser: DataTypes.STRING,//需要在后台补充
toId:DataTypes.INTEGER,
businessLicense_id:DataTypes.INTEGER,
//"onlineset"+"¥"+data.appkey:[uk+"¥"+data.nickName+"¥"+data.imgUrl] uk=appid¥uid
isAccepted:DataTypes.BOOLEAN,
lastMsgId:DataTypes.INTEGER,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'msgnotice',
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 system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const appconfig = system.getSysConfig();
class AppService extends ServiceBase { class AppService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(AppService)); super("common", ServiceBase.getDaoName(AppService));
......
var fs = require("fs"); var fs = require("fs");
var objsettings = require("../config/objsettings"); var objsettings = require("../config/objsettings");
var settings = require("../config/settings"); var settings = require("../config/settings");
const request = require('request');
class System { class System {
static declare(ns) { static declare(ns) {
var ar = ns.split('.'); var ar = ns.split('.');
...@@ -15,6 +16,98 @@ class System { ...@@ -15,6 +16,98 @@ class System {
} }
} }
} }
static async delReq(url,qdata){
let rtn={}
let promise=new Promise(function(resv,rej){
request.del({
url: url,
qs: qdata
}, function(error, response, body) {
rtn.statusCode=response.statusCode
if (!error) {
if(body){
let data=JSON.parse(body)
rtn.data=data
}else{
rtn.data=null
}
resv(rtn);
}else{
rej(error)
}
});
})
return promise;
}
static async getReq(url,qdata){
let promise=new Promise(function(resv,rej){
request.get({
url: url,
qs: qdata
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
resv(body);
}else{
rej(error)
}
});
})
return promise;
}
static async postJsonTypeReq(url,data){
let promise=new Promise(function(resv,rej){
request({
url: url,
method: "POST",
json: true,
headers: {
"content-type": "application/json",
},
body: JSON.stringify(data)
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
resv(body);
}else{
rej(error)
}
});
})
return promise;
}
static async post3wFormTypeReq(url,data){
let rtn={}
let promise=new Promise(function(resv,rej){
request.post({
url: url,
form: data
}, function(error, response, body) {
rtn.statusCode=response.statusCode
if (!error) {
let data=JSON.parse(body)
rtn.data=data
resv(rtn);
}else{
rej(error)
}
});
})
return promise;
}
static async postMpFormTypeReq(url,formdata){
let promise=new Promise(function(resv,rej){
request.post({
url: url,
formData: formdata
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
resv(body);
}else{
rej(error)
}
});
})
return promise;
}
static register(key, ClassObj,groupName,filename) { static register(key, ClassObj,groupName,filename) {
if (System.objTable[key] != null) { if (System.objTable[key] != null) {
throw new Error("相同key的对象已经存在"); throw new Error("相同key的对象已经存在");
...@@ -108,15 +201,8 @@ class System { ...@@ -108,15 +201,8 @@ class System {
return System.register(objabspath, ClassObj,groupName,filename); return System.register(objabspath, ClassObj,groupName,filename);
} }
} }
static getUiConfig(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js"; static getSysConfig() {
if (settings.env == "dev") {
delete require.cache[configPath];
}
var configValue = require(configPath);
return configValue;
}
static getUiConfig2(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/index.js"; var configPath = settings.basepath + "/app/base/db/metadata/index.js";
// if(settings.env=="dev"){ // if(settings.env=="dev"){
// console.log("delete "+configPath+"cache config"); // console.log("delete "+configPath+"cache config");
...@@ -124,7 +210,7 @@ class System { ...@@ -124,7 +210,7 @@ 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'] ||
...@@ -140,6 +226,7 @@ class System { ...@@ -140,6 +226,7 @@ class System {
} }
}; };
} }
Date.prototype.Format = function (fmt) { //author: meizz Date.prototype.Format = function (fmt) { //author: meizz
var o = { var o = {
...@@ -189,3 +276,12 @@ System.verifyOpencodeFail = 2040; ...@@ -189,3 +276,12 @@ System.verifyOpencodeFail = 2040;
//重复操作 //重复操作
System.redoFail = 2050; System.redoFail = 2050;
module.exports = System; module.exports = System;
// (async ()=>{
// try{
// let d=await System.getReq("http://127.0.0.1:8001x/services")
// console.log(d)
// }catch(e){
// console.log(e);
// }
// })()
\ No newline at end of file
...@@ -6,11 +6,11 @@ var settings = { ...@@ -6,11 +6,11 @@ var settings = {
db: 9, db: 9,
}, },
database: { database: {
dbname: "paas", dbname: "center-manage",
user: "write", user: "root",
password: "write", password: "123456",
config: { config: {
host: '192.168.18.237', host: '192.168.4.119',
port: 3306, port: 3306,
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
......
var path= require('path'); var path= require('path');
var basepath=path.normalize(path.join(__dirname, '../..')); var basepath=path.normalize(path.join(__dirname, '../..'));
var settings = { var settings = {
webbase:path.join(basepath,"app/base/controller/ctl.base.js") webbase:path.join(basepath,"app/base/controller/ctl.base.js"),
web:path.join(basepath,"app/base/controller/impl"), web:path.join(basepath,"app/base/controller/impl"),
apibase:path.join(basepath,"app/base/api/api.base.js"), apibase:path.join(basepath,"app/base/api/api.base.js"),
api:path.join(basepath,"app/base/api/impl"), api:path.join(basepath,"app/base/api/impl"),
......
...@@ -17,6 +17,7 @@ var settings = { ...@@ -17,6 +17,7 @@ var settings = {
defaultpwd:"987456", defaultpwd:"987456",
basepath : path.normalize(path.join(__dirname, '../..')), basepath : path.normalize(path.join(__dirname, '../..')),
port : process.env.NODE_PORT || 4001, port : process.env.NODE_PORT || 4001,
kongurl:"http://127.0.0.1:8001/",
redis:function(){ redis:function(){
if(this.env=="dev"){ if(this.env=="dev"){
var localsettings=require("./localsettings"); var localsettings=require("./localsettings");
......
...@@ -31,3 +31,4 @@ var server = http.createServer(app); ...@@ -31,3 +31,4 @@ var server = http.createServer(app);
server.listen(setttings.port, function(){ server.listen(setttings.port, function(){
console.log('Express server listening on port ' + app.get('port')); console.log('Express server listening on port ' + app.get('port'));
}); });
{ {
"name": "bigdata", "name": "center-manage",
"version": "1.0.0", "version": "1.0.0",
"description": "h5framework", "description": "h5framework",
"main": "main.js", "main": "main.js",
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@alicloud/pop-core": "^1.7.7", "@alicloud/pop-core": "^1.7.7",
"MD5": "^1.3.0",
"after": "^0.8.2", "after": "^0.8.2",
"ali-oss": "^4.12.2", "ali-oss": "^4.12.2",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
"crypto-js": "^3.1.9-1", "crypto-js": "^3.1.9-1",
"easyimage": "^3.1.0", "easyimage": "^3.1.0",
"ejs": "^2.5.8", "ejs": "^2.5.8",
"element-ui": "^2.4.0",
"engine.io-parser": "^2.1.2", "engine.io-parser": "^2.1.2",
"errorhandler": "^1.5.0", "errorhandler": "^1.5.0",
"exceljs": "^1.6.3", "exceljs": "^1.6.3",
...@@ -34,16 +34,13 @@ ...@@ -34,16 +34,13 @@
"gm": "^1.23.1", "gm": "^1.23.1",
"log4js": "^2.10.0", "log4js": "^2.10.0",
"method-override": "^2.3.10", "method-override": "^2.3.10",
"mongoose": "^5.3.6",
"morgan": "^1.9.0", "morgan": "^1.9.0",
"multer": "^1.3.0", "multer": "^1.3.0",
"mysql2": "^1.5.3", "mysql2": "^1.5.3",
"node-cron": "^2.0.1", "node-cron": "^2.0.1",
"node-uuid": "^1.4.8", "node-uuid": "^1.4.8",
"node-wxpay": "^1.1.3",
"pdfcrowd": "^4.2.0", "pdfcrowd": "^4.2.0",
"pinyin": "^2.8.3", "pinyin": "^2.8.3",
"puppeteer": "^1.8.0",
"qr-image": "^3.2.0", "qr-image": "^3.2.0",
"sequelize": "^4.37.8", "sequelize": "^4.37.8",
"sequelize-cli": "^4.1.1", "sequelize-cli": "^4.1.1",
...@@ -51,14 +48,10 @@ ...@@ -51,14 +48,10 @@
"sha1": "^1.1.1", "sha1": "^1.1.1",
"socket.io": "^2.1.1", "socket.io": "^2.1.1",
"uuid": "^3.2.1", "uuid": "^3.2.1",
"weixin-pay": "^1.1.7",
"wx-pay": "^1.0.2",
"xml2js": "^0.4.19" "xml2js": "^0.4.19"
}, },
"devDependencies": { "devDependencies": {
"del": "^5.1.0", "del": "^5.1.0",
"element-theme": "^2.0.1",
"element-theme-chalk": "^2.4.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-if": "^3.0.0", "gulp-if": "^3.0.0",
"gulp-imagemin": "^6.2.0", "gulp-imagemin": "^6.2.0",
......
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