Commit 91ac22e9 by zhaoxiqing

gsb

parent df365e65
...@@ -7,6 +7,7 @@ class ActionAPI extends APIBase { ...@@ -7,6 +7,7 @@ class ActionAPI extends APIBase {
this.originSve = system.getObject("service.channel.originSve"); this.originSve = system.getObject("service.channel.originSve");
this.channelSve = system.getObject("service.channel.channelSve"); this.channelSve = system.getObject("service.channel.channelSve");
this.channelmerchantSve = system.getObject("service.channel.channelmerchantSve"); this.channelmerchantSve = system.getObject("service.channel.channelmerchantSve");
this.platformchannelService = system.getObject("service.channel.platformchannelSve" );
} }
/** /**
* 接口跳转 * 接口跳转
...@@ -23,11 +24,11 @@ class ActionAPI extends APIBase { ...@@ -23,11 +24,11 @@ class ActionAPI extends APIBase {
return system.getResult(null, "action_type参数不能为空"); return system.getResult(null, "action_type参数不能为空");
} }
try { try {
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body); result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
return result; return result;
} }
...@@ -73,6 +74,15 @@ class ActionAPI extends APIBase { ...@@ -73,6 +74,15 @@ class ActionAPI extends APIBase {
case "merchantPage": case "merchantPage":
opResult = await this.channelmerchantSve.page(action_body); opResult = await this.channelmerchantSve.page(action_body);
break; break;
//渠道绑定
case "bindPlatform":
opResult = await this.platformchannelService.bindPlatform(action_body);
break;
//绑定渠道推送
case "pushbindingchannel" :
opResult = await this.platformchannelService.pushbindingchannel(action_body);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
...@@ -122,4 +132,4 @@ class ActionAPI extends APIBase { ...@@ -122,4 +132,4 @@ class ActionAPI extends APIBase {
]; ];
} }
} }
module.exports = ActionAPI; module.exports = ActionAPI;
\ No newline at end of file
...@@ -5,6 +5,16 @@ class ChannelDao extends Dao { ...@@ -5,6 +5,16 @@ class ChannelDao extends Dao {
super(Dao.getModelName(ChannelDao)); super(Dao.getModelName(ChannelDao));
} }
async findById(id) {
var sql = [];
sql.push("SELECT");
sql.push("`id`");
sql.push("FROM");
sql.push(this.model.tableName);
sql.push("WHERE `id` = :id ");
return await this.customQuery(sql.join(" "), { id:id }) || [];
}
async suggest(name) { async suggest(name) {
var sql = []; var sql = [];
sql.push("SELECT"); sql.push("SELECT");
...@@ -73,4 +83,4 @@ module.exports = ChannelDao; ...@@ -73,4 +83,4 @@ module.exports = ChannelDao;
// console.log(i); // console.log(i);
// } // }
// //
// })(); // })();
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class PlatformchannelDao extends Dao {
constructor() {
super(Dao.getModelName(PlatformchannelDao));
}
}
module.exports = PlatformchannelDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("platformchannel", {
platform_id: DataTypes.INTEGER,
channel_id: DataTypes.INTEGER,
platform_channel_id : DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ch_platform_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 ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class PlatformchannelService extends ServiceBase {
constructor() {
super("channel", ServiceBase.getDaoName(PlatformchannelService));
this.channelDao = system.getObject("db.channel.channelDao");
}
async bindPlatform(params){
var data = await this.channelDao.findById(params.channel_id);
if(data.length == 0){
return system.getErrResult("渠道ID不存在");
}
var platformchannel = {
platform_id : this.trim(params.platform_id),
channel_id : this.trim(params.channel_id),
platform_channel_id : this.trim(params.platform_channel_id)
};
var platformchannelData = await this.dao.findOne(platformchannel);
if(platformchannelData != null){
return system.getResultSuccess(platformchannelData.id);
}
let suData = await this.dao.create(platformchannel);
if(this.trim(suData.id)){
return system.getResultSuccess(suData.id)
}
return system.getErrResult("绑定失败")
}
//绑定渠道推送
async pushbindingchannel(params){
console.log(params)
}
trim(o) {
if(!o) {
return "";
}
return o.toString().trim();
}
}
module.exports = PlatformchannelService;
...@@ -45,6 +45,24 @@ class System { ...@@ -45,6 +45,24 @@ class System {
data: data || null, data: data || null,
}; };
} }
static getErrResult(errmsg) {
return {
status: -1,
msg: errmsg,
data: null
};
}
static getSuccResult(data) {
return {
status: 0,
msg: "",
data: data
};
}
/** /**
* 请求返回失败 * 请求返回失败
* @param {*} status 操作失败状态,默认为-1 * @param {*} status 操作失败状态,默认为-1
...@@ -234,4 +252,4 @@ System.appidFail = 1200; ...@@ -234,4 +252,4 @@ System.appidFail = 1200;
System.signFail = 1300; System.signFail = 1300;
//获取访问token失败 //获取访问token失败
System.getAppInfoFail = 1130; System.getAppInfoFail = 1130;
module.exports = System; module.exports = System;
\ No newline at end of file
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