Commit dd54f122 by 蒋勇

d

parent 80966324
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class ChannelCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(ChannelCtl));
this.appS=system.getObject("service.common.appSve")
}
}
module.exports = ChannelCtl;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class PathtomethodCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(PathtomethodCtl));
this.appS=system.getObject("service.common.appSve")
}
}
module.exports = PathtomethodCtl;
......@@ -62,6 +62,9 @@ class DbFactory{
this.db.models.route.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.plugin.belongsTo(this.db.models.app,{constraints: false,});
//渠道和渠道路径方法映射
this.db.models.pathtomethod.belongsTo(this.db.models.channel,{constraints: false,});
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon(){
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("channel", {
code:{
type: DataTypes.STRING,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
routehost: {
type: DataTypes.STRING,
allowNull: false,
}//和user的from相同,在注册user时,去创建
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_channel',
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 appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("pathtomethod", {
path:{
type: DataTypes.STRING,
allowNull: false,
},
method: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
desc:{
type: DataTypes.STRING,
allowNull: false,
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_pathtomethod',
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 ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class ChannelService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(ChannelService));
}
async create(p,q,req){
let self =this
return this.db.transaction(async function (t) {
let u = await self.dao.create(p,t)
//创建路由--针对于特定来源渠道域名的路由,给中台服务添加路由
try{
let ps = ["/"]
let routeobj = await self.cjsonregister(ChannelService.newRouteUrl(settings.pmappname),
{ name: p.code, paths: ps, hosts: [p.routehost], strip_path: false })
}catch(e){
await self.cdel(ChannelService.routeUrl(p.code))
throw new Error("创建渠道报错")
}
return u
})
}
async update(p,q,req){
let self =this
return this.db.transaction(async function (t) {
let old=await self.dao.findOne({id:p.id})
let u = await self.dao.update(p,t)
//创建路由--针对于特定来源渠道域名的路由,给中台服务添加路由
try{
await self.cdel(ChannelService.routeUrl(old.code))
let ps = ["/"]
let routeobj = await self.cjsonregister(ChannelService.newRouteUrl(settings.pmappname),
{ name: p.code, paths: ps, hosts: [p.routehost], strip_path: false })
}catch(e){
throw new Error("创建渠道报错")
}
return u
})
}
async delete(p,q,req){
let self =this
return this.db.transaction(async function (t) {
let u = await self.dao.delete(p,t)
//创建路由--针对于特定来源渠道域名的路由,给中台服务添加路由
try{
await self.cdel(ChannelService.routeUrl(u.code))
}catch(e){
throw new Error("创建渠道报错")
}
return u
})
}
}
module.exports = ChannelService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class PathtomethodService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(PathtomethodService));
}
}
module.exports = PathtomethodService;
\ No newline at end of file
......@@ -159,6 +159,25 @@ class ServiceBase {
return null;
}
}
async cjsonupate(opurl,opts){
try{
let rtn=await system.postJsonTypeReq(opurl,opts,"PATCH")
console.log(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,",rtn);
if(rtn.statusCode==409){
//return new Error("已经存在相同的统一账号名称!");
return null;
}
if(rtn.statusCode==201){
return rtn.data;
}else{
throw new Error(rtn.data);
}
return null;
}catch(e){
console.log(e);
return null;
}
}
async cdel(opurl){
try{
let rtn=await system.delReq(opurl)
......
......@@ -26,6 +26,7 @@ var settings = {
return ENVINPUT.KONG_ADMIAN;
}
},
pmappname:"center-app",
pmappid:1,
pmcompanyid:1,
pmroleid:{"ta":1,"pr":2},
......
1.渠道管理
-建立渠道( 简码 名称 域名 )
--同时给中台服务建立一个新的路由
--建立路径与方法名的映射表,从属于渠道
--在中台建立新的 拦截器,读取渠道缓存,判断req.host,如果在渠道域名范围内,就
调用统一的渠道流入处理接口,解析出chanel-code,根据req.path,解析出方法名,method,调用生成者服务接口
添加数据{
channelcode:T,
method:'createChance',
bodydata:'xxx'
}
-建立消费者微服务
2.产品中心
3、交付商管理
---技能标签
---地区区域-----------组件----路径
4、日志服务调用
5、K8s环境搭建
--提供k8集群/镜像服务--git push tag--自动打包
--我们提供yaml上线文件/Dockerfile
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