Commit 93503735 by 王昆

gsb

parents 20fabd08 d9c7f676
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/bigdata/main.js"
}
]
}
\ No newline at end of file
{
"git.ignoreLimitWarning": true
}
\ No newline at end of file
#!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com"
ADD xgg-web /apps/xgg-web/
WORKDIR /apps/xgg-web/
RUN cnpm install -S
CMD ["node","/apps/xgg-web/main.js"]
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,
DB_NAME: process.env.PAAS_DB_NAME,
REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT,
REDIS_PWD: process.env.REDIS_PWD,
REDIS_DB: process.env.PAAS_REDIS_DB,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
env: ENVINPUT.APP_ENV,
platformid: 1,
platformcompanyid: 1,
commonroleid: 1,
passroleid: 2,
tanentroleid: 1,
protocalPrefix: "http://",
appKey: "wx76a324c5d201d1a4",
secret: "f99d413b767f09b5dff0b3610366cc46",
salt: "%iatpD1gcxz7iF#B",
defaultpwd: "987456",
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 4001,
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;
},
},
homePage: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return localsettings.reqHomePageDevUrl;
} else {
return "http://open.gongsibao.com/";
}
},
authUrl: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return localsettings.reqAuthUrl;
} else {
return "http://open.gongsibao.com/auth";
}
},
docUrl: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
return localsettings.docUrl;
} else {
return "http://open.gongsibao.com/web/common/metaCtl/getApiDoc";
}
},
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;
\ No newline at end of file
node_modules/
\ No newline at end of file
const system=require("../system");
class ApiBase{
constructor(){
this.cacheManager=system.getObject("db.cacheManager");
}
async checkKey(appKey){
// let key = await this.cacheManager["InitAppKeyCache"].getAppKeyVal(appKey);
// if(key==null){
// return system.getResult2(null,null,"ok","请检查您的授权KEY");
// }
return {status:1};
}
}
module.exports=ApiBase;
var System=require("../../system");
var settings=require("../../../config/settings");
const querystring = require('querystring');
const ApiBase =require("../api.base");
class ChinaAffairSearchApi extends ApiBase{
constructor(){
super();
this.affairUrl = settings.reqEsAddrIc()+"bigdata_patent_affair_op/_search";
};
buildDate(date){
var date = new Date(date);
var time = Date.parse(date);
time=time / 1000;
return time;
};
async SearchbyFilingno(obj){//根据申请号查询并根据法律状态日期排序
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
}
var filingno = obj.filingno==null?"":obj.filingno;
if(filingno==""){
return {status:-1,msg:"传入申请号信息为空",data:null,buckets:null};
}
var params= {
"query": {
"bool": {
"must": [
]
}
},
"sort": [
{
"aff_date": "asc"
}
]
};
var param = {
"term": {
"filing_no": filingno
}
}
params.query.bool.must.push(param);
var rc=System.getObject("util.execClient");
var rtn=null;
var requrl = this.affairUrl;
try{
rtn=await rc.execPost(params,requrl);
var j=JSON.parse(rtn.stdout);
return System.getResult2(j.hits,null);
}catch(e){
return rtn=System.getResult2(null,null);
}
};
}
module.exports = ChinaAffairSearchApi;
\ No newline at end of file
var System = require("../../system");
var settings = require("../../../config/settings");
const ApiBase = require("../api.base");
//const cyjAppKey="ccb00829347e4048833af213e502c8c5";
class GsbIcSearchApi extends ApiBase {
constructor() {
super();
this.iccompanynameSearchUrl = settings.apiconfig.iccompanynameSearchUrl(settings.env);
};
buildDate(date) {
var date = new Date(date);
var time = Date.parse(date);
time = time / 1000;
return time;
};
async getConvertSemiangleStr(str) {
var result = "";
str = str.replace(/\s+/g, "");
var len = str.length;
for (var i = 0; i < len; i++) {
var cCode = str.charCodeAt(i);
//全角与半角相差(除空格外):65248(十进制)
cCode = (cCode >= 0xFF01 && cCode <= 0xFF5E) ? (cCode - 65248) : cCode;
//处理空格
cCode = (cCode == 0x03000) ? 0x0020 : cCode;
result += String.fromCharCode(cCode);
}
return result;
};
async companynamesearch(obj) {
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var companyName = obj.companyName == null ? "" : obj.companyName;
companyName = await this.getConvertSemiangleStr(companyName);
var pageSize = obj.pageSize == null ? 15 : obj.pageSize;
if (obj.currentPage == null) {
var from = 0;
} else {
var from = Number((obj.currentPage - 1) * obj.pageSize);
}
var reqUrl = this.iccompanynameSearchUrl;
var params = {
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "company_name",
"query": '\"' + companyName + '\"'
}
}
]
}
},
"from": from,
"size": pageSize,
"_source": [
"company_id",
"company_province",
"company_domain",
"company_name",
"legal_person",
"reg_status",
"reg_unit",
"reg_capital",
"estibish_time",
"reg_location",
"credit_code"
],
"sort": [
{
"reg_capital": "desc"
}
]
};
var rc = System.getObject("util.execClient");
var rtn = null;
try {
rtn = await rc.execPost(params, reqUrl);
var j = JSON.parse(rtn.stdout);
var sources = [];
var data = {
"result": 1,
"totalSize": j.hits.total,
"pageSize": pageSize,
"currentPage": obj.currentPage - 1, "list": sources
};
j.hits.hits.forEach(function (c) {
if (c._source.estibish_time != null) {
var time = new Date(c._source.estibish_time * 1000);
c._source.estibish_time = time.toLocaleDateString();
}
var source = {
entId: c._source.company_id,
province: c._source.company_province,
domainEntName: c._source.company_domain,
entName: c._source.company_name,
entLegalperson: c._source.legal_person,
entStatus: c._source.reg_status,
capitalUnit: c._source.reg_unit,
capitalStandard: c._source.reg_capital,
foundedTime: c._source.estibish_time,
regLocation: c._source.reg_location,
creditCode: c._source.credit_code,
};
sources.push(source);
});
j.hits.hits = data;
var a = { status: 0, msg: "操作成功", data: data };
return a;
} catch (e) {
return { status: -1, msg: "操作失败", data: null };
}
};
}
module.exports = GsbIcSearchApi;
// var capi=new GsbTmSearchApi();
// capi.xzSearch({}).then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system=require("../system");
class CtlBase{
constructor(sname){
this.serviceName=sname;
this.service=system.getObject("service."+sname);
this.cacheManager=system.getObject("db.cacheManager");
}
notify(req,msg){
if(req.session){
req.session.bizmsg=msg;
}
}
async findOne(queryobj,qobj){
var rd=await this.service.findOne(qobj);
return system.getResult2(rd,null);
}
async findAndCountAll(queryobj,obj,req){
obj.codepath=req.codepath;
if(req.session.user){
obj.uid=req.session.user.id;
obj.appid=req.session.user.app_id;
obj.onlyCode=req.session.user.unionId;
obj.account_id=req.session.user.account_id;
obj.ukstr=req.session.user.app_id+"¥"+req.session.user.id+"¥"+req.session.user.nickName+"¥"+req.session.user.headUrl;
}
var apps=await this.service.findAndCountAll(obj);
return system.getResult2(apps,null);
}
async refQuery(queryobj,qobj){
var rd=await this.service.refQuery(qobj);
return system.getResult2(rd,null);
}
async bulkDelete(queryobj,ids){
var rd=await this.service.bulkDelete(ids);
return system.getResult2(rd,null);
}
async delete(queryobj,qobj){
var rd=await this.service.delete(qobj);
return system.getResult2(rd,null);
}
async create(queryobj,qobj,req){
if(req && req.session && req.session.app){
qobj.app_id=req.session.app.id;
qobj.onlyCode=req.session.user.unionId;
if(req.codepath){
qobj.codepath=req.codepath;
}
}
var rd=await this.service.create(qobj);
return system.getResult2(rd,null);
}
async update(queryobj,qobj,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.getResult2(rd,null);
}
static getServiceName(ClassObj){
return ClassObj["name"].substring(0,ClassObj["name"].lastIndexOf("Ctl")).toLowerCase()+"Sve";
}
async initNewInstance(queryobj,req){
return system.getResult2({},null);
}
async findById(oid){
var rd=await this.service.findById(oid);
return system.getResult2(rd,null);
}
// async doExecute(methodname,params){
// var result= await this[methodname](params);
// return system.getResult2(result,null);
// }
}
module.exports=CtlBase;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class ArticleCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(ArticleCtl));
//this.appS=system.getObject("service.appSve");
}
async findById(q,oid){
return super.findById(Number(oid.id));
}
}
module.exports=ArticleCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
class AuthCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(AuthCtl));
}
async saveAuths(query,qobj,req){
var auths=qobj.aus;
var xrtn=await this.service.saveAuths(auths);
return system.getResult2(xrtn,null);
}
async findAuthsByRole(query,qobj,req){
var rolecodestrs=qobj.rolecode;
var xrtn=await this.service.findAuthsByRole(rolecodestrs);
return system.getResult2(xrtn,null);
}
}
module.exports=AuthCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmmerchantCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmmerchantCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmmerchantCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmmerchantcompanyCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmmerchantcompanyCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmmerchantcompanyCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmorderCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmorderCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmorderCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmrequirementsCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmrequirementsCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmrequirementsCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmrequirementsapplyCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmrequirementsapplyCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmrequirementsapplyCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmuserCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmuserCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmuserCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class BmuserbizCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(BmuserbizCtl));
//this.appS=system.getObject("service.appSve");
}
}
module.exports=BmuserbizCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class CacheCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(CacheCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(queryobj,qobj){
return system.getResult2({},null);
}
async delCache(queryobj,qobj){
await this.service.delCache(qobj);
return system.getResult2({},null);
}
async findOnlines(queryobj,qobj,req){
//var ms=await this.cacheManager["VisitCountCache"].findOnlines(req.session.app.appid);
var ms=await this.cacheManager["VisitCountCache"].findOnlines();
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
console.log(ms);
return system.getResult2(ms,null);
}
async clearAllCache(queryobj,qobj){
console.log("clearAllCache===========================");
await this.service.clearAllCache(qobj);
return system.getResult2({},null);
}
}
module.exports=CacheCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class LoopplayCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(LoopplayCtl));
//this.appS=system.getObject("service.appSve");
}
async findById(q,oid){
return super.findById(Number(oid.id));
}
async findByChannelcode(qobj,obj,req){
if(obj.channelcode==null||obj.channelcode==""||obj.channelcode=="undefined"){
return {code:-1,msg:"参数channelcode错误"};
}
var result=await this.service.findByChannelcode(obj);
return {code:1,msg:"success",data:result};
}
async findAll(queryobj,obj,req){
var lst= await this.service.findAll();
return system.getResult2(lst,null);
}
async findAndCountAll(queryobj,obj,req){
obj.codepath=req.codepath;
if(req.session.user){
obj.uid=req.session.user.id;
obj.appid=req.session.user.app_id;
obj.onlyCode=req.session.user.unionId;
obj.account_id=req.session.user.account_id;
obj.ukstr=req.session.user.app_id+"¥"+req.session.user.id+"¥"+req.session.user.nickName+"¥"+req.session.user.headUrl;
}
var apps=await this.service.findAndCountAll(obj);
return system.getResult2(apps,null);
}
// async findAll(q,oid){
// var rd=await this.service.findAll();
// return system.getResult2(rd,null);
// return super.findById(Number(oid.id));
// }
}
module.exports=LoopplayCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
class MetaCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(MetaCtl));
this.userS=system.getObject("service.userSve");
this.authS=system.getObject("service.authSve");
// this.productS=system.getObject("service.productSve");
// this.productC=system.getObject("web.productCtl");
}
//权限 角色+资源节点code+权限字符串,codepath--
async getUiConfig(queryObj,req){
var bizCode=queryObj.biz;
var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
console.log(cfg);
var tmpRoleAuthStr="";
if(req && req.session && req.session.user){
var tmpRoles=[];
if(req.session.user.Roles){
req.session.user.Roles.forEach(r=>{
tmpRoles.push(r.code);
});
//按照角色获取权限列表
var auths=await this.authS.findAuthsByRole(tmpRoles);
var codeauthattrs=auths.map(r=>{
if(r.authstrs && r.authstrs!=""){
return r.authstrs;
}else{
return "";
}
});
tmpRoleAuthStr=codeauthattrs.join(",");
}
}
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
var toolbar=[];
const bizConfigData= cfg.config["bizs"][bizCode];
console.log(bizCode);
Object.keys(bizConfigData.config.auth).map(k=>{
//只要有权限就添加
if( req.session.user && req.session.user.isAdmin){
toolbar=toolbar.concat(bizConfigData.config.auth[k]);
}else{
if(tmpRoleAuthStr.indexOf(k)>=0){
toolbar=toolbar.concat(bizConfigData.config.auth[k]);
}
}
})
bizConfigData.config.toolbar=toolbar;
return system.getResult2(bizConfigData.config,null);
}
// async getCacheQuery(bizCode){
// var bizCode=queryObj.biz;
// var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
// console.log(cfg);
// //获取当前登录人的角色,进而获取权限,进而合并工具栏目
// var toolbar=[];
// const bizConfigData= cfg.config["bizs"][bizCode];
// Object.keys(bizConfigData.config.auth).map(k=>{
// //只要有权限就添加
// toolbar=toolbar.concat(bizConfigData.config.auth[k]);
// })
// bizConfigData.config.toolbar=toolbar;
// return system.getResult2(bizConfigData.config,null);
// }
async getDicConfig(queryObj){
var dicKey=queryObj["dicKey"];
var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
return system.getResult2(cfg.config["pdict"][dicKey],null);
}
//每个角色有一个code/codepath的集合
//只要当前code出现在codepath中,就返回
//针对叶子节点授权,那么父节点出现在codepath中,所以可以实现父节点返回
async getRsConfig(q,req){
var rs2=[];
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
var tmpRoleCodepathStr=[];
if(req && req.session && req.session.user){
//按照用户查询角色
// try{
// var user= await this.userS.getAuths(req.session.user.id);
// var roles=await user.getRoles({raw:true});
// console.log(roles);
// }catch(e){
// console.log(e);
// }
var tmpRoles=[];
if(req.session.user.Roles){
req.session.user.Roles.forEach(r=>{
tmpRoles.push(r.code);
});
//按照角色获取权限列表
var auths=await this.authS.findAuthsByRole(tmpRoles,req.session.user.company_id);
var codepathattrs=auths.map(r=>{
if(r.authstrs && r.authstrs!=""){
if(r.codepath) {
var cparr = r.codepath.split("/");
for(var c of cparr) {
tmpRoleCodepathStr.push(c);
}
}
return r.codepath;
}else{
return "";
}
});
}
}
console.log(".....................获取当前登录人的角色,进而获取权限,进而合并工具栏目.getRsConfig");
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
for(var i =0;i<cfg.config["rstree"].children.length;i++){
var r=cfg.config["rstree"].children[i];
console.log(r.code);
var funcrange=function(n){
if(req && req.session && req.session.user){
if( req.session.user.isAdmin || req.session.user.isSuper){
if(n.codePath.indexOf("pmg")<0 && req.session.user.isAdmin ){
n.hidden=false;
}
if(n.codePath.indexOf("pmg")>=0 && req.session.user.isAdmin){
n.hidden=true;
}
if(n.codePath.indexOf("pmg")>=0 && req.session.user.isSuper ){
console.log("isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper");
n.hidden=false;
}
if(n.codePath.indexOf("pmg")<0 && req.session.user.isSuper && !req.session.user.isAdmin){
console.log("isSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuperisSuper");
n.hidden=true;
}
}else{
if(tmpRoleCodepathStr.indexOf(n.code)<0){
if(n.isctl && n.isctl=="no"){
n.hidden=false;
console.log(n.code,"no ctl","show menu");
}else {
n.hidden=true;
console.log(n.code,"no authed","hide menu");
}
}else{
n.hidden=false;
console.log(n.code,"authed......","show menu");
}
}
}
if(n.children){
n.children.forEach((dd)=>{
return funcrange(dd);
});
}else{
if(n.isctl && n.isctl=="no"){
n.hidden=false;
}
return;
}
};
funcrange(r);
}
return system.getResult2(cfg.config["rstree"],null);
}
async getRouteConfig(){
var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
var tmp={};
tmp.bizs=cfg.config["bizs"];
// var products=await this.productS.list(settings.wxconfig.appId);
// tmp.ps=await this.productC.addVisitCountData(products);
return system.getResult2(tmp,null);
}
async getRouteConfigWithoutProduct(){
var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
//获取当前登录人的角色,进而获取权限,进而合并工具栏目
var tmp={};
tmp.bizs=cfg.config["bizs"];
console.log(tmp);
return system.getResult2(tmp,null);
}
async findSubSystems(q,req){
var rtnSubs=[];
var cfg=await this.service.getUiConfig(settings.wxconfig.appId);
var tmpRoleCodepathStr=[];
if(req && req.session && req.session.user){
var tmpRoles=[];
if(req.session.user.Roles || req.session.user.isAdmin){
if(req.session.user.Roles){
req.session.user.Roles.forEach(r=>{
tmpRoles.push(r.code);
});
}
//按照角色获取权限列表
var auths=await this.authS.findAuthsByRole(tmpRoles);
var codepathattrs=auths.map(r=>{
if(r.authstrs && r.authstrs!=""){
if(r.codepath) {
var cparr = r.codepath.split("/");
for(var c of cparr) {
tmpRoleCodepathStr.push(c);
}
}
return r.codepath;
}else{
return "";
}
});
for(var i =0;i<cfg.config["rstree"].children.length;i++){
var r=cfg.config["rstree"].children[i];
if(r.isSubmenu){
if(tmpRoleCodepathStr.indexOf(r.code)>=0){
rtnSubs.push({subcode:r.code,subtitle:r.label});
}else{
if(req.session.user.isAdmin){
if(r.code.indexOf("pmg")<0){
rtnSubs.push({subcode:r.code,subtitle:r.label});
}
}
if(req.session.user.isSuper){
if(r.code.indexOf("pmg")>=0){
rtnSubs.push({subcode:r.code,subtitle:r.label});
}
}
}
}
}
}
}
return system.getResult2(rtnSubs,null);
}
}
module.exports=MetaCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class NewschannelCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(NewschannelCtl));
//this.appS=system.getObject("service.appSve");
}
async findAgreenment(queryobj,qobj,req){
var rd=await this.service.findAgreenment();
return system.getResult2(rd,null);
}
async initNewInstance(queryobj,qobj){
var u=uuidv4();
var aid=u.replace(/\-/g,"");
var rd={name:"",appid:aid}
return system.getResult2(rd,null);
}
async findPrev5(queryobj,qobj){
var rd=await this.service.findPrev5();
return system.getResult2(rd,null);
}
}
module.exports=NewschannelCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class OplogCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(OplogCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(qobj){
var u=uuidv4();
var aid=u.replace(/\-/g,"");
var rd={name:"",appid:aid}
return system.getResult2(rd,null);
}
async debug(obj){
obj.logLevel="debug";
return this.create(null,obj);
}
async info(obj){
obj.logLevel="info";
return this.create(null,obj);
}
async warn(obj){
obj.logLevel="warn";
return this.create(null,obj);
}
async error(obj){
obj.logLevel="error";
return this.create(null,obj);
}
async fatal(obj){
obj.logLevel="fatal";
return this.create(null,obj);
}
}
module.exports=OplogCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class PConfigCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(PConfigCtl));
this.cacheManager=system.getObject("db.cacheManager");
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(queryobj,qobj){
var u=uuidv4();
var aid=u.replace(/\-/g,"");
var rd={name:"",appid:aid}
return system.getResult2(rd,null);
}
async getConfigValue(obj,req){
var configType=obj.configType;
var pconfig=await this.cacheManager["PConfigCache"].cachePConfig();
var result= pconfig.find(item => {
return item.configType === configType;
});
return result;
}
}
module.exports=PConfigCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class RoleCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(RoleCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(queryobj,req){
return system.getResult2({},null);
}
}
module.exports=RoleCtl;
var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class TaskCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(TaskCtl));
}
async restartTasks(queryobj,qobj){
var result=await this.service.restartTasks(qobj);
return system.getResult2(result,null);
}
async restartTasks2(queryobj,qobj){
var result=await this.service.restartTasks2(qobj);
return system.getResult2(result,null);
}
async initNewInstance(queryobj,qobj){
var u=uuidv4();
var aid=u.replace(/\-/g,"");
var rd={name:"",appid:aid}
return system.getResult2(rd,null);
}
async makerpt(queryobj,qobj){
var result=await this.service.makerpt(qobj);
return system.getResult2(result,null);
}
}
module.exports=TaskCtl;
// var System = require("../../system")
// const crypto = require('crypto');
// var xlsx = require('node-xlsx');
// var fs = require("fs");
// var accesskey = 'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla';
// var accessKeyId = 'LTAIyAUK8AD04P5S';
// var settings = require("../../../config/settings");
// class ToolCtl {
// constructor() {
// this.gsbIcSearchApi = System.getObject("api.gsbicsearch");
// this.appKeyStr = "wx76a324c5d201d1a4";
// }
// async getCompanyInfoByLikeName(oo, o, req) {
// var appkey = this.appKeyStr;
// var data = {
// appKey: appkey,
// pagesize: 5,
// page: 0,
// companyName: o.likestr,
// };
// var company = await this.gsbIcSearchApi.companynamesearch(data);
// if (company.status == 0) {
// return { data: company.data.list };
// } else {
// return {};
// }
// }
// async getEntregistryByCompanyName(o, req) {
// var appkey = this.appKeyStr;
// var data = {
// appKey: appkey,
// pagesize: 1,
// page: 0,
// companyName: o.companyName,
// };
// var company = await this.gsbIcSearchApi.companynameonesearch(data);
// if (company.status == 0 && company.data.totalSize > 0) {
// return company.data.list[0];
// } else {
// return {};
// }
// }
// }
// module.exports = ToolCtl;
\ No newline at end of file
var System = require("../../system")
const crypto = require('crypto');
var fs = require("fs");
var accesskey = 'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla';
var accessKeyId = 'LTAIyAUK8AD04P5S';
var url = "https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class UploadCtl {
constructor() {
this.cmdPdf2HtmlPattern = "docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 '{fileName}'";
this.restS = System.getObject("util.execClient");
this.cmdInsertToFilePattern = "sed -i 's/id=\"page-container\"/id=\"page-container\" contenteditable=\"true\"/'";
//sed -i 's/1111/&BBB/' /tmp/input.txt
//sed 's/{position}/{content}/g' {path}
}
async getOssConfig() {
var policyText = {
"expiration": "2119-12-31T16:00:00.000Z",
"conditions": [
["content-length-range", 0, 1048576000],
["starts-with", "$key", "zc"]
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha1', accesskey).update(policyBase64).digest().toString('base64'); //base64
var data = {
OSSAccessKeyId: accessKeyId,
policy: policyBase64,
Signature: signature,
Bucket: 'gsb-zc',
success_action_status: 201,
url: url
};
return data;
};
async upfile(srckey, dest) {
var oss = System.getObject("util.ossClient");
var result = await oss.upfile(srckey, "/tmp/" + dest);
return result;
};
async downfile(srckey) {
var oss = System.getObject("util.ossClient");
var downfile = await oss.downfile(srckey).then(function () {
downfile = "/tmp/" + srckey;
return downfile;
});
return downfile;
};
async pdf2html(obj) {
var srckey = obj.key;
var downfile = await this.downfile(srckey);
var cmd = this.cmdPdf2HtmlPattern.replace(/\{fileName\}/g, srckey);
var rtn = await this.restS.exec(cmd);
var path = "/tmp/" + srckey.split(".pdf")[0] + ".html";
var a = await this.insertToFile(path);
fs.unlink("/tmp/" + srckey);
var result = await this.upfile(srckey.split(".pdf")[0] + ".html", srckey.split(".pdf")[0] + ".html");
return result.url;
};
async insertToFile(path) {
var cmd = this.cmdInsertToFilePattern + " " + path;
return await this.restS.exec(cmd);
};
}
module.exports = UploadCtl;
\ No newline at end of file
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.oplogCtl");
class UserCtl extends CtlBase{
constructor(){
super(CtlBase.getServiceName(UserCtl));
//this.loginS=system.getObject("service.userSve");
this.restS=system.getObject("util.restClient");
this.smsS=system.getObject("util.smsClient");
}
// async update(ueryobj,qobj,req){
// if(qobj.ecompany_id && qobj.ecompany_id!=""){
// //为了实现下个页面的跳转获取参数
// if(req.session){
// req.session.ecompany_id=qobj.ecompany_id;
// }
// }
// var results=await super.update(ueryobj,qobj,req);
// return results;
// }
async loginUser(qobj,pobj,req) {
return super.findById(req.session.user.id);
}
//获取验证码,发送给指定手机
async fetchVcode(qobj,pobj,req){
var mobile= pobj.mobile;
//生成一个验证码,发送
var vcode=await this.service.getUidStr(6,10);
await this.smsS.sendMsg(mobile,vcode);
return system.getResult2({vcodestr:vcode});
}
async checkLogin(qobj,req){
if(req.session.user){
var tmp={
id:req.session.user.id,
nickName:req.session.user.nickName,
mobile : req.session.user.mobile,
isAdmin:req.session.user.isAdmin,
}
return system.getResult2(tmp,req);
}else{
var x={
status:-99,
msg:"no login"
};
req.session.user=null;
req.session.destroy();
return system.getResult2(x,req);
}
}
async exit(qobj,req){
req.session.user=null;
req.session.destroy();
return system.getResult2("exit");
}
async register(qobj,pobj,req){
console.log(pobj.u);
var u=await this.service.register(pobj.u);
//req.session.user=u;
return system.getResult2(u);
}
async login(qobj,pobj,req){
//state为p_app表中appkey
var existedUser=await this.service.getUserByUserNamePwd(pobj.u);
if(existedUser!=null){
req.session.user=existedUser;
}
return system.getResult2(existedUser);
}
async getUserInfo(accessToken, openId) {
let reqUrl = 'https://api.weixin.qq.com/sns/userinfo';
let params = {
access_token: accessToken,
openid: openId,
lang: 'zh_CN'
};
var data=querystring.stringify(params);
var rtn=await this.restS.execGet(data,reqUrl);
return JSON.parse(rtn.stdout);
}
async getToken(code,req,state) {
if(settings.env=="prod"){
let reqUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';
console.log(state);
var appobj=await this.cacheManager["AppCache"].cacheApp(state);
console.log(appobj);
let params = {
appid: appobj.appid,
secret: appobj.secret,
code: code,
grant_type: 'authorization_code'
};
var data=querystring.stringify(params);
var rtn=await this.restS.execGet(data,reqUrl);
return JSON.parse(rtn.stdout);
}else{
var rtn={
"access_token":"ACCESS_TOKEN",
"expires_in":7200,
"refresh_token":"REFRESH_TOKEN",
"openid":"xxyy",
"scope":"SCOPE",
"unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
}
return rtn;
}
}
async getUidStr(len, radix) {
    var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
    var uuid = [], i;
    radix = radix || chars.length;
    if (len) {
      for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
    } else {
      var r;
      uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
      uuid[14] = '4';
      for (i = 0; i < 36; i++) {
        if (!uuid[i]) {
          r = 0 | Math.random()*16;
          uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
        }
      }
    }
    return uuid.join('');
}
}
module.exports=UserCtl;
const system=require("../system")
class CacheBase{
constructor(){
this.redisClient=system.getObject("util.redisClient");
this.desc="请在子类中定义本缓存的说明!"
}
}
module.exports=CacheBase;
const CacheBase=require("../cache.base");
const system=require("../../system");
//缓存首次登录的赠送的宝币数量
class AppCache extends CacheBase{
constructor(){
super();
this.prefix="g_appkey_";
this.appDao=system.getObject("db.appDao");
}
async cacheApp(appkey){
const key=this.prefix+appkey;
var configValue=await this.redisClient.get(key);
if(!configValue || configValue=="undefined"){
console.log("uiconfig no cache....");
const configValue=await this.appDao.findOne(appkey);
var s=JSON.stringify(configValue);
await this.redisClient.set(key,s);
return configValue;
}else {
console.log("uiconfig already cache....");
}
return JSON.parse(configValue);
}
}
module.exports=AppCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
class BMUserCache extends CacheBase {
constructor() {
super();
this.bmuserDao = system.getObject("db.bmuserDao");
this.globalKeyPrefix = "applet_bmuser";
}
async del(openid) {
var key = this.globalKeyPrefix + "_" + openid;
await this.redisClient.delete(key);
}
async set(openid, value) {
var key = this.globalKeyPrefix + "_" + openid;
this.redisClient.set(key, value);
return key;
}
async get(openid) {
var key = this.globalKeyPrefix + "_" + openid;
const value = await this.redisClient.get(key);
if (value) {
return value;
} else {
var user = await this.bmuserDao.findOne({openId: openid});
if(user) {
user = JSON.stringify(user);
await this.redisClient.set(key, user);
return user;
} else {
return null;
}
}
}
}
module.exports = BMUserCache;
\ No newline at end of file
const CacheBase=require("../cache.base");
const system=require("../../system");
//缓存首次登录的赠送的宝币数量
class MagCache extends CacheBase{
constructor(){
super();
this.prefix="magCache";
}
async keys(p){
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcache");
return this.redisClient.keys(p);
}
async get(k){
return this.redisClient.get(k);
}
async del(k){
return this.redisClient.delete(k);
}
async clearAll(){
console.log("xxxxxxxxxxxxxxxxxxxclearAll............");
return this.redisClient.flushall();
}
}
module.exports=MagCache;
const CacheBase=require("../cache.base");
const system=require("../../system");
const settings=require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class UIConfigCache extends CacheBase{
constructor(){
super();
this.prefix="g_uiconfig_";
}
async cacheUiConfig(appid){
// const key=this.prefix+appid;
// var configValue=null;
// console.log(configValue);
// if(!configValue || configValue=="undefined"){
// console.log("uiconfig no cache....");
// configValue =system.getUiConfig2(appid);
// if(settings.env!="dev"){
// await this.redisClient.set(key,JSON.stringify(configValue));
// }
// return configV
// }else {
// console.log("uiconfig already cache....");
// }
// return JSON.parse(configValue);
var configValue =system.getUiConfig2(appid);
return configValue;
}
}
module.exports=UIConfigCache;
const system=require("../system");
class Dao{
constructor(modelName){
this.modelName=modelName;
var db=system.getObject("db.connection").getCon();
this.db=db;
console.log("........set dao model..........");
this.model=db.models[this.modelName];
}
preCreate(u){
return u;
}
async create(u,t){
var u2=this.preCreate(u);
if(t){
return this.model.create(u2,{transaction: t}).then(u=>{
return u;
});
}else{
return this.model.create(u2,{transaction: t}).then(u=>{
return u;
});
}
}
static getModelName(ClassObj){
return ClassObj["name"].substring(0,ClassObj["name"].lastIndexOf("Dao")).toLowerCase()
}
async refQuery(qobj){
var w={};
if(qobj.likestr){
w[qobj.fields[0]]={[this.db.Op.like]:"%"+qobj.likestr+"%"};
return this.model.findAll({where:w,attributes:qobj.fields});
}else{
return this.model.findAll({attributes:qobj.fields});
}
}
async bulkDelete(ids){
var en= await this.model.destroy({where:{id:{[this.db.Op.in]:ids}}});
return en;
}
async delete(qobj){
var en= await this.model.findOne({where:qobj});
if(en!=null){
return en.destroy();
}
return null;
}
extraModelFilter(){
//return {"key":"include","value":{model:this.db.models.app}};
return null;
}
extraWhere(obj,where){
return where;
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["created_at","DESC"]];
}
buildQuery(qobj){
var linkAttrs=[];
const pageNo=qobj.pageInfo.pageNo;
const pageSize=qobj.pageInfo.pageSize;
const search=qobj.search;
var qc={};
//设置分页查询条件
qc.limit=pageSize;
qc.offset=(pageNo-1)*pageSize;
//默认的查询排序
qc.order=this.orderBy();
//构造where条件
qc.where={};
if(search){
Object.keys(search).forEach(k=>{
console.log(search[k],":search[k]search[k]search[k]");
if(search[k] && search[k]!='undefined' && search[k]!=""){
if((k.indexOf("Date")>=0 || k.indexOf("_at")>=0 )){
if(search[k]!="" && search[k]){
var stdate=new Date(search[k][0]);
var enddate=new Date(search[k][1]);
qc.where[k]={[this.db.Op.between]:[stdate,enddate]};
}
}
else if (k.indexOf("id")>=0) {
qc.where[k]=search[k];
}
else if (k.indexOf("channelCode")>=0) {
qc.where[k]=search[k];
}
else if (k.indexOf("Type")>=0) {
qc.where[k]=search[k];
}
else if (k.indexOf("Status")>=0) {
qc.where[k]=search[k];
}
else if (k.indexOf("status")>=0) {
qc.where[k]=search[k];
}
else{
if(k.indexOf("~")>=0){
linkAttrs.push(k);
}else{
qc.where[k]={[this.db.Op.like]:"%"+search[k]+"%"};
}
}
}
});
}
this.extraWhere(qobj,qc.where,qc,linkAttrs);
var extraFilter=this.extraModelFilter();
if(extraFilter){
qc[extraFilter.key]=extraFilter.value;
}
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
console.log(qc);
return qc;
}
buildaggs(qobj) {
var aggsinfos = [];
if (qobj.aggsinfo) {
qobj.aggsinfo.sum.forEach(aggitem => {
var t1 = [this.db.fn('SUM', this.db.col(aggitem.field)), aggitem.field + "_" + "sum"];
aggsinfos.push(t1);
});
qobj.aggsinfo.avg.forEach(aggitem => {
var t2 = [this.db.fn('AVG', this.db.col(aggitem.field)), aggitem.field + "_" + "avg"];
aggsinfos.push(t2);
});
}
return aggsinfos;
}
async findAggs(qobj, qcwhere) {
var aggArray = this.buildaggs(qobj);
if (aggArray.length != 0) {
qcwhere["attributes"] = {};
qcwhere["attributes"] = aggArray;
qcwhere["raw"] = true;
var aggResult = await this.model.findOne(qcwhere);
return aggResult;
} else {
return {};
}
}
async findAndCountAll(qobj,t){
var qc = this.buildQuery(qobj);
var apps = await this.model.findAndCountAll(qc);
var aggresult = await this.findAggs(qobj, qc);
var rtn = {};
rtn.results = apps;
rtn.aggresult = aggresult;
return rtn;
}
preUpdate(obj){
return obj;
}
async update(obj,tm){
var obj2=this.preUpdate(obj);
if(tm!=null && tm!='undefined'){
return this.model.update(obj2,{where:{id:obj2.id},transaction:tm});
}else {
return this.model.update(obj2,{where:{id:obj2.id}});
}
}
async updateByWhere(setObj,whereObj,t){
if(t&&t!='undefined'){
if(whereObj&&whereObj!='undefined'){
whereObj.transaction=t;
}else {
whereObj={transaction: t};
}
}
return this.model.update(setObj,whereObj);
}
async customExecAddOrPutSql(sql,paras=null){
return this.db.query(sql,paras);
}
async customQuery(sql,paras,t){
var tmpParas=null;//||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
if(t&&t!='undefined'){
if(paras==null||paras=='undefined'){
tmpParas={type: this.db.QueryTypes.SELECT };
tmpParas.transaction=t;
}else {
tmpParas={replacements: paras, type: this.db.QueryTypes.SELECT };
tmpParas.transaction=t;
}
}else {
tmpParas=paras==null||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
}
return this.db.query(sql,tmpParas);
}
async findCount(whereObj=null){
return this.model.count(whereObj, {logging : false}).then(c=>{
return c;
});
}
async findSum(fieldName,whereObj=null){
return this.model.sum(fieldName,whereObj);
}
async getPageList(pageIndex,pageSize,whereObj=null,orderObj=null,attributesObj=null,includeObj=null){
var tmpWhere={};
tmpWhere.limit=pageSize;
tmpWhere.offset= (pageIndex - 1) * pageSize;
if(whereObj!=null){
tmpWhere.where=whereObj;
}
if(orderObj!=null&&orderObj.length>0){
tmpWhere.order=orderObj;
}
if(attributesObj!=null&&attributesObj.length>0){
tmpWhere.attributes=attributesObj;
}
if(includeObj!=null&&includeObj.length>0){
tmpWhere.include=includeObj;
tmpWhere.distinct=true;
}
tmpWhere.raw=true;
return await this.model.findAndCountAll(tmpWhere);
}
async findOne(obj){
return this.model.findOne({"where":obj});
}
async findById(oid){
return this.model.findById(oid);
}
}
module.exports=Dao;
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 AppDao extends Dao{
constructor(){
super(Dao.getModelName(AppDao));
}
async findOne(paramappid,t){
if(t){
var app= await this.model.findOne({where:{appid:paramappid}},{transaction:t});
return app;
}else{
var app= await this.model.findOne({where:{appid:paramappid}});
return app;
}
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
}
module.exports=AppDao;
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 AuthDao extends Dao{
constructor(){
super(Dao.getModelName(AuthDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
}
module.exports=AuthDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BMmerchantDao extends Dao{
constructor(){
super(Dao.getModelName(BMmerchantDao));
}
}
module.exports=BMmerchantDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BMmerchantcompanyDao extends Dao{
constructor(){
super(Dao.getModelName(BMmerchantcompanyDao));
}
async findByMerchantId(merchantId) {
var sql = [];
sql.push("SELECT");
sql.push("`id`, `merchantId`, `name`, `regname`, `created_at`, `updated_at`");
sql.push("FROM");
sql.push("`bm_merchant_company` ");
sql.push("WHERE merchantId = :merchantId");
var list = await this.customQuery(sql.join(" "), {
merchantId: merchantId,
});
return list;
}
}
module.exports=BMmerchantcompanyDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BMorderDao extends Dao{
constructor(){
super(Dao.getModelName(BMorderDao));
}
}
module.exports=BMorderDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BmrequirementsDao extends Dao{
constructor(){
super(Dao.getModelName(BmrequirementsDao));
}
async getById(id) {
return await this.model.findOne({where:{id:id}, raw: true});
}
async findMapByIds(ids) {
var result = [];
if(!ids || ids.length == 0) {
return result;
}
var sql = "SELECT * FROM bm_requirements where id IN (:ids) ";
var list = await this.customQuery(sql, {ids:ids});
if(!list || list.length == 0) {
return result;
}
for(var item of list) {
result["id_" + item.id] = item;
}
return result;
}
}
module.exports=BmrequirementsDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BmrequirementsapplyDao extends Dao{
constructor(){
super(Dao.getModelName(BmrequirementsapplyDao));
}
}
module.exports=BmrequirementsapplyDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BmuserDao extends Dao{
constructor(){
super(Dao.getModelName(BmuserDao));
}
}
module.exports=BmuserDao;
const system=require("../../system");
const Dao=require("../dao.base");
class BmuserbizDao extends Dao{
constructor(){
super(Dao.getModelName(BmuserbizDao));
}
async findMapByOrderIds(orderIds, attrs) {
var result = [];
if(!orderIds || orderIds.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM bm_user_biz where orderId IN (:orderIds) ";
var list = await this.customQuery(sql, {orderIds:orderIds});
if(!list || list.length == 0) {
return result;
}
for(var item of list) {
result["id_" + item.orderId] = item;
}
return result;
}
}
module.exports=BmuserbizDao;
const fs=require("fs");
const settings=require("../../../config/settings");
class CacheManager{
constructor(){
//await this.buildCacheMap();
this.buildCacheMap();
}
buildCacheMap(){
var self=this;
self.doc={};
var cachePath=settings.basepath+"/app/base/db/cache/";
const files=fs.readdirSync(cachePath);
if(files){
files.forEach(function(r){
var classObj=require(cachePath+"/"+r);
self[classObj.name]=new classObj();
var refTmp=self[classObj.name];
if(refTmp.prefix){
self.doc[refTmp.prefix]=refTmp.desc;
}
else{
console.log("请在"+classObj.name+"缓存中定义prefix");
}
});
}
}
}
module.exports=CacheManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
const Sequelize = require('sequelize');
const settings=require("../../../config/settings")
const fs=require("fs")
const path=require("path");
class DbFactory{
constructor(){
const dbConfig=settings.database();
this.db=new Sequelize(dbConfig.dbname,
dbConfig.user,
dbConfig.password,
dbConfig.config);
this.db.Sequelize=Sequelize;
this.db.Op=Sequelize.Op;
this.initModels();
this.initRelations();
}
async initModels(){
var self=this;
var modelpath=path.normalize(path.join(__dirname, '..'))+"/models/";
var models=fs.readdirSync(modelpath);
models.forEach(function(m){
self.db.import(modelpath+m);
});
console.log("init models....");
}
async initRelations(){
/**
一个账户对应多个登陆用户
一个账户对应一个commany
一个APP对应多个登陆用户
一个APP有多个角色
登陆用户和角色多对多
**/
/*建立用户和角色之间的关系*/
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.article.belongsTo(this.db.models.newschannel,{constraints: false,});
this.db.models.newschannel.hasMany(this.db.models.article,{constraints: false,});
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon(){
var that=this;
// await this.db.authenticate().then(()=>{
// console.log('Connection has been established successfully.');
// }).catch(err => {
// console.error('Unable to connect to the database:', err);
// throw err;
// });
//同步模型
if(settings.env=="dev"){
}
return this.db;
}
}
module.exports=DbFactory;
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 MetaDao{
constructor(){
//super(Dao.getModelName(AppDao));
}
}
module.exports=MetaDao;
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;
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 OplogDao extends Dao{
constructor(){
super(Dao.getModelName(OplogDao));
}
}
module.exports=OplogDao;
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;
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});
}
}
module.exports=PConfigDao;
const system=require("../../system");
const Dao=require("../dao.base");
class RoleDao extends Dao{
constructor(){
super(Dao.getModelName(RoleDao));
}
async findOne(paramappid,t){
var app= await this.model.findOne({where:{appid:paramappid}},{transaction:t});
return app;
}
async preUpdate(u){
return u;
}
async update(obj){
var obj2=await this.preUpdate(obj);
await this.model.update(obj2,{where:{id:obj2.id}});
var role=await this.model.findOne({where:{id:obj2.id}});
return role;
}
async preCreate(u){
return u;
}
async create(u,t){
var self=this;
var u2= await this.preCreate(u);
if(t){
var role= await this.model.create(u2,{transaction: t});
return role;
}else{
var role= await this.model.create(u2);
return role;
}
}
}
module.exports=RoleDao;
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 UserDao extends Dao{
constructor(){
super(Dao.getModelName(UserDao));
this.appDao=system.getObject("db.appDao");
}
async getAuths(userid){
var self=this;
return this.model.findOne({
where:{id:userid},
include:[{model:self.db.models.account,attributes:["id","isSuper","referrerOnlyCode"]},
{model:self.db.models.role,as:"Roles",attributes:["id","code"],},
],
});
}
async getUserByOpenId(popenid,appkey,t){
var app=await this.appDao.findOne(appkey);
var tUser=await this.model.findOne({
where:{openId:popenid},
include:[{model:this.db.models.app,raw:true},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{model:this.db.models.account,attributes:["id","isSuper","referrerOnlyCode"],raw:true},
{model:this.db.models.role,as:"Roles",attributes:["id","code"],include:[
{model:this.db.models.product,as:"Products",attributes:["id","code"],raw:true}
]},
]},{transaction:t});
if(tUser!=null){
tUser=tUser.get({plain:true});
tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
}
// console.log("tUser.partnerinfo...................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>999sy");
// console.log(tUser);
return tUser;
}
async setAccount(user,account,t){
var user=await user.setAccount(account,{transaction: t});
return user;
}
async setApp(user,app,t){
//按照APPId,获取app对象
var user=await user.setApp(app,{transaction: t});
return user;
}
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"]}]};
}
extraWhere(obj,w,qc,linkAttrs){
if(obj.codepath && obj.codepath!=""){
// if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询
// console.log(obj);
// w["app_id"]=obj.appid;
// }
}
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;
}
async preUpdate(u){
if(u.roles && 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 user=await this.model.findOne({where:{id:obj2.id}});
user.setRoles(obj2.roles);
return user;
}
async findAndCountAll(qobj,t){
var users=await super.findAndCountAll(qobj,t);
return users;
}
async preCreate(u){
// var roles=await this.db.models.role.findAll({where:{id:{[this.db.Op.like]:u.roles}}});
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// console.log(roles);
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// u.roles=roles
return u;
}
async create(u,t){
var self=this;
var u2=await this.preCreate(u);
if(t){
return this.model.create(u2,{transaction: t}).then(user=>{
return user;
});
}else{
return this.model.create(u2).then(user=>{
return user;
});
}
}
}
module.exports=UserDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
const system=require("../system");
const settings=require("../../config/settings.js");
const reclient=system.getObject("util.redisClient");
//获取平台配置兑换率
//初次登录的赠送数量
//创建一笔交易
//同时增加账户数量,增加系统平台账户
var dbf=system.getObject("db.connection");
var db=dbf.getCon();
db.sync({force:true}).then(async ()=>{
console.log("sync complete...");
//创建role
const Role=db.models.role;
Role.bulkCreate([
{ name:"访客",code:"guest"},
]);
});
module.exports={
"bizName":"article",
"list":{
columnMetaData:[
{"width":"200","label":"编码","prop":"code","isShowTip":true,"isTmpl":false},
{"width":"200","label":"次续","prop":"orderNo","isShowTip":true,"isTmpl":false},
{"width":"200","label":"用途","prop":"usageType","isShowTip":true,"isTmpl":false},
{"width":"200","label":"媒体类型","prop":"mediaType","isShowTip":true,"isTmpl":false},
{"width":"100","label":"频道","prop":"newschannel.title","isShowTip":true,"isTmpl":false},
{"width":"100","label":"标题","prop":"title","isShowTip":true,"isTmpl":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":"true"},
]
},
"form":[
{
"title":"次续",
ctls:[
{"type":"number","prop":"orderNo","placeHolder":"请输入(整数数字)","style":""},
]
},
{
"title":"编码",
"validProp":"code",
"rule": [
{ "required": true, "message": '请输入编码', "trigger": 'blur' },
],
ctls:[
{"type":"input","label":"编码","prop":"code","placeHolder":"请输入编码","style":""},
]
},
{
"title":"频道",
ctls:[
{"type":"select","refModel":"newschannel","isMulti":false,"label":"频道","prop":"newschannel_id","labelField":"title","valueField":"id","style":""},
]
},
{
"title":"用途",
"validProp":"usageType",
"rule": [
{ "required": true, "message": '用途', "trigger": 'blur' },
],
"ctls":[
{"type":"select","dicKey":"usageType","prop":"usageType","labelField":"label","valueField":"value","style":""},
]
},
{
"title":"媒体类型",
"validProp":"mediaType",
"rule": [
{ "required": true, "message": '媒体类型', "trigger": 'blur' },
],
"ctls":[
{"type":"select","dicKey":"mediaType","prop":"mediaType","labelField":"label","valueField":"value","style":""},
]
},
{
"title":"标题",
"ctls":[
{"type":"input","label":"标题","prop":"title","disabled":false,"placeHolder":"请输入标题","style":""},
]
},
{
"title":"标题缩略图",
"ctls":[
{"type":"upload","label":"标题缩略图","prop":"listimg","placeHolder":"请输入标题","style":""},
]
},
{
"title":"视频",
"ctls":[
{"type":"upload","label":"视频","prop":"videourl","placeHolder":"请输入标题","style":""},
]
},
{
"title":"概要",
"ctls":[
{"type":"textarea","label":"概要","prop":"desc","placeHolder":"请输入概要","style":""},
]
},
{
"title":"文章内容",
"ctls":[
{"type":"html","label":"标题","prop":"content","height":"500px","disabled":false,"placeHolder":"请输入标题","style":""},
]
},
],
"search":[
{
"title":"频道",
ctls:[
{"type":"select","refModel":"newschannel","isMulti":false,"label":"频道","prop":"newschannel_id","labelField":"title","valueField":"id","style":""},
]
},
{
"title":"标题",
ctls:[
{"type":"input","label":"标题","prop":"title","placeHolder":"请输入标题","style":""},
]
},
],
"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":"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},
],
}
}
module.exports={
"bizName":"article",
"list":{
columnMetaData:[
{"width":"","label":"","prop":"code","isShowTip":true,"pos":"left","isTmpl":true,"isOther":true},
]
},
"form":[
],
"search":[
{
"title":"频道",
ctls:[
{"type":"select","refModel":"newschannel","isMulti":false,"label":"频道","prop":"newschannel_id","labelField":"title","valueField":"id","style":""},
]
},
{
"title":"标题",
ctls:[
{"type":"input","label":"标题","prop":"title","placeHolder":"请输入标题","style":""},
]
},
],
"auth":{
"add":[
],
"edit":[
],
"delete":[
],
"common":[
],
}
}
module.exports={
"bizName":"accounts",
"list":{
columnMetaData:[
{"width":"100","label":"头像","name":"null","isShowTip":false,"isTmpl":true,"isBtns":false},
{"width":"100","label":"昵称","prop":"nickName","isShowTip":true,"isTmpl":false},
{"width":"200","label":"唯一标识","prop":"unionId","isShowTip":true,"isTmpl":false},
{"width":"100","label":"宝币余额","prop":"baoBalance","isShowTip":true,"isTmpl":false},
{"width":"150","label":"钱包余额","prop":"renBalance","isShowTip":true,"isTmpl":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":true}
]
},
"form":[
],
"search":[
{
"title":"昵称",
"ctls":[
{"type":"input","label":"昵称","prop":"nickName","placeHolder":"","style":""},
]
},
],
"auth":{
"add":[
],
"edit":[
],
"delete":[
// {"icon":"el-icon-remove","title":"删除","type":"default","key":"delete","isInRow":true},
],
"common":[
],
}
}
module.exports={
"bizName":"article",
"list":{
columnMetaData:[
{"width":"100","label":"编码","prop":"code","isShowTip":true,"isTmpl":false},
{"width":"100","label":"续号","prop":"orderNo","isShowTip":true,"isTmpl":false},
{"width":"100","label":"标题","prop":"title","isShowTip":true,"isTmpl":false},
{"width":"100","label":"左图","prop":"leftimg","isShowTip":false,"isTmpl":true,"isBtns":false},
{"width":"100","label":"右图","prop":"rightimg","isShowTip":false,"isTmpl":true,"isBtns":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":"true"},
]
},
"form":[
{
"title":"续号",
ctls:[
{"type":"number","prop":"orderNo","placeHolder":"请输入续号","style":""},
]
},
{
"title":"编码",
"validProp":"code",
"rule": [
{ "required": true, "message": '请输入编码', "trigger": 'blur' },
],
ctls:[
{"type":"input","label":"编码","prop":"code","placeHolder":"请输入编码","style":""},
]
},
{
"title":"标题",
"ctls":[
{"type":"input","label":"标题","prop":"title","disabled":false,"placeHolder":"请输入标题","style":""},
]
},
{
"title":"左图",
"ctls":[
{"type":"upload","label":"左图","prop":"leftimg","placeHolder":"请输入标题","style":""},
]
},
{
"title":"右图",
"ctls":[
{"type":"upload","label":"右图","prop":"rightimg","placeHolder":"请输入标题","style":""},
]
},
],
"search":[
{
"title":"标题",
ctls:[
{"type":"input","label":"标题","prop":"title","placeHolder":"请输入标题","style":""},
]
},
],
"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":"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},
],
}
}
module.exports={
"bizName":"newschannel",
"list":{
columnMetaData:[
{"width":"200","label":"次续","prop":"orderNo","isShowTip":true,"isTmpl":false},
{"width":"200","label":"编码","prop":"code","isShowTip":true,"isTmpl":false},
{"width":"100","label":"标题","prop":"title","isShowTip":true,"isTmpl":false},
{"width":"200","label":"用途","prop":"usageType","isShowTip":true,"isTmpl":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":"true"},
]
},
"form":[
{
"title":"次续",
ctls:[
{"type":"number","prop":"orderNo","placeHolder":"请输入(整数数字)","style":""},
]
},
{
"title":"编码",
"validProp":"code",
"rule": [
{ "required": true, "message": '请输入编码', "trigger": 'blur' },
],
ctls:[
{"type":"input","label":"编码","prop":"code","placeHolder":"请输入编码","style":""},
]
},
{
"title":"用途",
"validProp":"usageType",
"rule": [
{ "required": true, "message": '用途', "trigger": 'blur' },
],
"ctls":[
{"type":"select","dicKey":"usageType","prop":"usageType","labelField":"label","valueField":"value","style":""},
]
},
{
"title":"标题",
"ctls":[
{"type":"input","label":"标题","prop":"title","disabled":false,"placeHolder":"请输入标题","style":""},
]
},
{
"title":"缩略图",
"ctls":[
{"type":"upload","label":"缩略图","prop":"bgimg","placeHolder":"请输入标题","style":""},
]
},
{
"title":"",
"ctls":[
{"type":"switch","prop":"isPubed","acText":"发布","inactText":"不发布","placeHolder":" ","style":""},
]
},
],
"search":[
{
"title":"标题",
ctls:[
{"type":"input","label":"标题","prop":"title","placeHolder":"请输入标题","style":""},
]
},
],
"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":"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},
],
}
}
module.exports={
"list":{
columnMetaData:[
{"width":"100","label":"编码","prop":"code","isShowTip":true,"isTmpl":false},
{"width":"200","label":"名称","prop":"name","isShowTip":true,"isTmpl":false},
{"width":"200","label":"描述","prop":"description","isShowTip":true,"isTmpl":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":true},
]
},
"form":[
{
"title":"编码",
ctls:[
{"type":"input","label":"编码","prop":"code","placeHolder":"请输入一个编码","style":""},
]
},
{
"title":"名称",
ctls:[
{"type":"input","label":"名称","prop":"name","placeHolder":"请输入一个名称","style":""},
]
},
{
"title":"描述",
ctls:[
{"type":"input","label":"描述","prop":"description","placeHolder":"描述","style":""},
]
},
],
"search":[
{
"title":"名称",
ctls:[
{"type":"input","label":"昵称","prop":"name","placeHolder":"请输入角色名称","style":""},
]
},
],
"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":"edit","isInRow":true},
{"icon":"el-icon-edit","title":"授权","type":"default","key":"auth","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},
],
}
}
module.exports={
"list":{
columnMetaData:[
{"width":"100","label":"昵称","prop":"nickName","isShowTip":true,"isTmpl":false},
{"width":"100","label":"角色","prop":"Roles","isShowTip":true,"isTmpl":false},
{"width":"80","label":"状态","prop":"isEnabled","isShowTip":true,"isTmpl":false},
{"width":"null","label":"操作","name":"null","isShowTip":false,"isTmpl":true,"isBtns":true},
]
},
"form":[
{
"title":"昵称",
ctls:[
{"type":"input","label":"昵称","prop":"nickName","placeHolder":"昵称","style":""},
]
},
{
"title":"",
ctls:[
{"type":"switch","prop":"isAdmin","acText":"是管理员","inactText":"否","placeHolder":"请输入单次使用消耗的宝币数","style":""},
]
},
{
"title":"角色",
ctls:[
{"type":"select","refModel":"role","isMulti":true,"label":"角色","prop":"roles","labelField":"name","valueField":"id","style":""},
]
},
],
"search":[
{
"title":"昵称",
ctls:[
{"type":"input","label":"昵称","prop":"nickName","placeHolder":"请输入昵称","style":""},
]
},
],
"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":"edit","isInRow":true},
],
"delete":[
{"icon":"el-icon-remove","title":"删除","type":"default","key":"delete","isInRow":true},
{"icon":"el-icon-edit","title":"停用","type":"default","key":"stopUser","isInRow":true,"boolProp":"isEnabled","falseText":"启用"},
],
"common":[
{"icon":"el-icon-cancel","title":"取消","type":"default","key":"cancel","isOnForm":true},
],
}
}
const fs=require("fs");
const path=require("path");
const appsPath=path.normalize(__dirname+"/apps");
const bizsPath=path.normalize(__dirname+"/bizs");
var appJsons={
}
function getBizFilePath(appJson,bizCode){
const filePath=bizsPath+"/"+appJson.appid+"/"+bizCode+".js";
return filePath;
}
//异常日志处理todo
function initAppBizs(appJson){
for(var bizCode in appJson.config.bizs)
{
const bizfilePath=getBizFilePath(appJson,bizCode);
delete require.cache[bizfilePath];
const bizConfig=require(bizfilePath);
appJson.config.bizs[bizCode].config=bizConfig;
}
return appJson;
}
//初始化资源树
function initRsTree(appjson,appidfolder,objJson,parentCodePath){
if(!parentCodePath){//说明当前是根结点
objJson.codePath=objJson.code;
}else{
objJson.codePath=parentCodePath+"/"+objJson.code;
}
if(objJson["bizCode"]){//表示叶子节点
objJson.auths=[];
if(appjson.config.bizs[objJson["bizCode"]]){
objJson.bizConfig=appjson.config.bizs[objJson["bizCode"]].config;
objJson.path=appjson.config.bizs[objJson["bizCode"]].path;
appjson.config.bizs[objJson["bizCode"]].codepath=objJson.codePath;
}
}else{
if(objJson.children){
objJson.children.forEach(obj=>{
initRsTree(appjson,appidfolder,obj,objJson.codePath);
});
}
}
}
fs.readdirSync(appsPath,{withFileTypes:true}).forEach(f=>{
const ff=path.join(appsPath,f);
delete require.cache[ff];
var appJson=require(ff);
appJson= initAppBizs(appJson);
initRsTree(appJson,appJson.appid,appJson.config.rstree,null);
appJsons[appJson.appid]=appJson;
});
module.exports=appJsons;
module.exports= {
"code": "pmg",
"isleft":true,
"label": "平台管理",
"icon":"el-icon-menu",
"isSubmenu": true,
"children": [
{
"code": "cms", "isGroup": true,"icon":"el-icon-news", "label": "内容管理", "children": [
{
"code": "newschannel",
"label": "频道发布",
"isMenu": true,
"bizCode": "newschannel",
"bizConfig": null,
"path": ""
},
{
"code": "article",
"label": "内容发布",
"isMenu": true,
"bizCode": "article",
"bizConfig": null,
"path": ""
},
{
"code": "loopplay",
"label": "轮播图",
"isMenu": true,
"bizCode": "loopplay",
"bizConfig": null,
"path": ""
},
{
"code": "articledetail",
"label": "文章内容",
"isMenu": false,
"bizCode": "articledetail",
"bizConfig": null,
"path": ""
},
{
"code": "channelquery",
"label": "更多文章",
"isMenu": false,
"bizCode": "channelquery",
"bizConfig": null,
"path": ""
},
]
},
{
"code": "smg", "isGroup": true,"icon":"el-icon-news", "label": "系统管理", "children": [
{
"code": "users",
"label": "用户管理",
"isMenu": true,
"bizCode": "users",
"bizConfig": null,
"path": ""
},
{
"code": "roles",
"label": "角色管理",
"isMenu": true,
"bizCode": "roles",
"bizConfig": null,
"path": ""
},
]
},
],
};
\ No newline at end of file
module.exports= {
"code": "toolCenter",
"label": "工具集",
"src": "/imgs/logo.png",
"isSubmenu": false,
"isMenu": false,
"children": [
{
"code": "tools", "isGroup": true, "label": "查询工具", "children": [
{
"code": "patentdetail",
"label": "专眼查专利详情",
"bizCode": "patentdetail",
"bizConfig": null,
"path": ""
},
// {
// "code": "patentreport",
// "label": "专利报告",
// "bizCode": "patentreport",
// "bizConfig": null,
// "path": ""
// },
{
"code": "patentadvancedsearch",
"label": "专眼查高级检索",
"bizCode": "patentadvancedsearch",
"bizConfig": null,
"path": ""
},
{
"code": "patentanalysis",
"label": "专利分析",
"bizCode": "patentanalysis",
"bizConfig": null,
"path": ""
},
// {
// "code": "patentquery",
// "label": "专利检索",
// "bizCode": "patentquery",
// "bizConfig": null,
// "path": ""
// },
]
},
],
};
\ No newline at end of file
const system=require("../../system");
const settings=require("../../../config/settings");
const uiconfig=system.getUiConfig2(settings.wxconfig.appId);
module.exports = (db, DataTypes) => {
return db.define("article", {
code: {
type: DataTypes.STRING,
allowNull: false,
},
title: {
type: DataTypes.STRING,
allowNull: false,
},//需要在后台补充
listimg: {
type: DataTypes.STRING,
allowNull: true,
},//需要在后台补充
videourl: {
type: DataTypes.STRING,
allowNull: true,
},//需要在后台补充
desc: {
type: DataTypes.STRING,
allowNull: true,
},//需要在后台补充
content: {
type: DataTypes.TEXT('long'),
allowNull: false,
},
mediaType:{
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.mediaType),
defaultValue: "qt",
},
usageType:{//用途类型
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.usageType),
defaultValue: "qt",
},
orderNo:{
type:DataTypes.INTEGER,
allowNull: false,
defaultValue:0
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'cms_article',
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("auth", {
rolecode: DataTypes.STRING,
bizcode: DataTypes.STRING,
codepath: DataTypes.STRING,
authstrs: DataTypes.STRING
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_auths',
validate: {
}
});
}
module.exports = (db, DataTypes) => {
return db.define("bmmerchant", {
name: DataTypes.STRING(100),
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_merchant',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("bmmerchantcompany", {
merchantId: DataTypes.INTEGER,
name: DataTypes.STRING(100),
regname: DataTypes.STRING(100),
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_merchant_company',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("bmorder", {
merchantId: DataTypes.INTEGER,
companyId: DataTypes.INTEGER,
userId: DataTypes.INTEGER,
orderNo: DataTypes.STRING(100),
status: DataTypes.INTEGER,
name: DataTypes.STRING(100),
ownerId: DataTypes.INTEGER,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_order',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("bmrequirements", {
name: DataTypes.STRING(50),
type: DataTypes.STRING(100),
teamName: DataTypes.STRING(20),
budget: DataTypes.INTEGER,
desc: DataTypes.STRING(300),
status: DataTypes.INTEGER,
publish_time: DataTypes.DATE,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_requirements',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("bmrequirementsapply", {
req_id: DataTypes.INTEGER,
user_id: DataTypes.INTEGER,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_requirements_apply',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("bmuser", {
openId: DataTypes.STRING(100),
mobile: DataTypes.STRING(30),
passwd: DataTypes.STRING(64),
nickname: DataTypes.STRING(64),
realname: DataTypes.STRING(64),
headurl: DataTypes.STRING(64),
balance: DataTypes.INTEGER,
income: DataTypes.INTEGER,
agreement: {
type:DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_user',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("bmuserbiz", {
merchantId: DataTypes.INTEGER,
companyId: DataTypes.INTEGER,
orderId: DataTypes.INTEGER,
orderNo: DataTypes.STRING(32),
user_id: DataTypes.INTEGER,
taxNo: DataTypes.STRING(64),
idcard_front: DataTypes.STRING(300),
idcard_back: DataTypes.STRING(300),
idcard: DataTypes.STRING(20),
bank_front: DataTypes.STRING(300),
bank_back: DataTypes.STRING(300),
bank: DataTypes.STRING(100),
bankno: DataTypes.STRING(30),
bankaddr: DataTypes.STRING(200),
person_img: DataTypes.STRING(300),
legal_name: DataTypes.STRING(20),
legal_mobile: DataTypes.STRING(20),
companyNames: DataTypes.STRING(100),
businessScope: DataTypes.STRING(300),
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bm_user_biz',
validate: {}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("loopplay", {
code: {
type: DataTypes.STRING,
allowNull: false,
},
title: {
type: DataTypes.STRING,
allowNull: false,
},
leftimg: {
type: DataTypes.STRING,
},//需要在后台补充
rightimg: {
type: DataTypes.STRING,
},//需要在后台补充
orderNo:{
type:DataTypes.INTEGER,
allowNull: false,
defaultValue:0
}
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'cms_loopplay',
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.wxconfig.appId);
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,
},
businessLicense_id : DataTypes.INTEGER,
},{
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 settings=require("../../../config/settings");
const uiconfig=system.getUiConfig2(settings.wxconfig.appId);
module.exports = (db, DataTypes) => {
return db.define("newschannel", {
code:{
type:DataTypes.STRING,
allowNull: false,
},
title:{
type:DataTypes.STRING,
allowNull: false,
},//需要在后台补充
bgimg:{
type:DataTypes.STRING,
allowNull: true,
},//需要在后台补充
isPubed:{
type:DataTypes.BOOLEAN,
allowNull: true,
defaultValue: true,
},
usageType:{//用途类型
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.usageType),
defaultValue: "qt",
},
orderNo:{
type:DataTypes.INTEGER,
allowNull: false,
defaultValue:0
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'cms_newschannel',
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.wxconfig.appId);
module.exports = (db, DataTypes) => {
return db.define("oplog", {
appid: {
type:DataTypes.STRING,
allowNull: true,
},
appname:{
type:DataTypes.STRING,
allowNull: false,
},
userid: { type: DataTypes.INTEGER,allowNull: true},
username:{
type:DataTypes.STRING,
allowNull: true,
},
sex:{
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,
},
flag:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
opTitle:DataTypes.STRING(500),
app_code:DataTypes.INTEGER(50),
},{
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) => {
const enums={
price:"宝币兑换率",
initGift:"初次赠送",
platformProfitRatio:"平台的分成比率",
referrerProfitRatio:"推荐人分成比率",
apiCallPrice:"API调用价格",
apiInitGift:"API初次赠送次数",
platformUseProfit:"平台使用费",
wtsName:"委托书联系人名称",
wtsMobile:"委托书电话",
wtsZipcode:"委托书邮编",
withdrawalData:"提现申请限制日期范围20-31,-1不限制",
withdrawalLimit:"提现限制额度,-1不限制,0则不发放提现申请,大于0则为限制的额度",
withdrawalIssueLimit:"提现申请发放限制,-1不限制,0则不发放提现申请,大于0则为限制的额度",
logOpWrite:"操作日志步骤是否写入,0否,1是",
invoiceTaxRate:"发票税率",
bussinessAllotChannelConfig:"商机分配渠道配置,格式:wssyh5,yzc等",
}
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,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_config',
validate: {
},
});
PConfig.enums=enums;
return PConfig;
}
module.exports = (db, DataTypes) => {
return db.define("role", {
name: DataTypes.STRING,
code: DataTypes.STRING,
description: DataTypes.STRING
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_role',
validate: {
}
});
}
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}]
// }
]
});
}
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.
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.
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.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
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