Commit ce5094f1 by 王昆

gsb

parent fc307087
{
// 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}/xggsve-merchant/main.js"
}
]
}
\ No newline at end of file
...@@ -4,14 +4,18 @@ var settings = require("../../../../config/settings"); ...@@ -4,14 +4,18 @@ var settings = require("../../../../config/settings");
class ActionAPI extends APIBase { class ActionAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.saasmainSve = system.getObject("service.main.saasmainSve");
// -------------------------------将要弃用------------------------------------------
this.merchantSve = system.getObject("service.merchant.merchantSve"); this.merchantSve = system.getObject("service.merchant.merchantSve");
this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve"); this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve"); this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve"); this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
this.merchanttitleSve = system.getObject("service.merchant.merchanttitleSve"); this.merchanttitleSve = system.getObject("service.merchant.merchanttitleSve");
this.merchantaddressSve = system.getObject("service.merchant.merchantaddressSve"); this.merchantaddressSve = system.getObject("service.merchant.merchantaddressSve");
} }
/** /**
* 接口跳转 * 接口跳转
...@@ -39,6 +43,20 @@ class ActionAPI extends APIBase { ...@@ -39,6 +43,20 @@ class ActionAPI extends APIBase {
async handleRequest(action_process, action_type, action_body) { async handleRequest(action_process, action_type, action_body) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "mainDics":
opResult = await this.saasmainSve.dics(action_body);
break;
case "mainPage":
opResult = await this.saasmainSve.pageByCondition(action_body);
break;
case "mainInfo":
opResult = await this.saasmainSve.info(action_body);
break;
case "mainSave":
opResult = await this.saasmainSve.save(action_body);
break;
// ------------------------------以下api为历史将要弃用的---------------------------------------
// 商户api // 商户api
case "infoList": case "infoList":
opResult = await this.merchantSve.apiInfoList(action_body); opResult = await this.merchantSve.apiInfoList(action_body);
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SaasMainDao extends Dao {
constructor() {
super(Dao.getModelName(SaasMainDao));
}
async listByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE id IN (:ids) `;
return await this.customQuery(sql, {
ids: ids
});
}
async mapByIds(ids, attrs) {
let result = {};
let list = await this.listByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async bySaasId(saasId, attrs) {
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE saas_id = :saasId `;
return await this.customQuery(sql, {
ids: ids
});
}
}
module.exports = SaasMainDao;
// 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);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("saasmain", {
name: DataTypes.STRING,
bank_account: DataTypes.STRING,
bank_name: DataTypes.STRING,
bank_no: DataTypes.STRING,
is_enabled: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
saas_id: DataTypes.INTEGER,
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'saas_main',
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 SaasMainService extends ServiceBase {
constructor() {
super("main", ServiceBase.getDaoName(SaasMainService));
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async dics(params) {
let saas_id = Number(this.trim(params.saas_id) || 0);
if (!saas_id) {
return system.getResultSuccess([]);
}
let list = await this.dao.bySaasId(Number(params.saas_id));
return system.getResultSuccess(list);
}
async info(params) {
if (!params.id) {
return getResult(null, "id不存在");
}
let main = await this.dao.getById(params.id);
if (!main) {
return getResult(null, "签约主体不存在");
}
this.handleDate(main, ["created_at"], null, -8);
return system.getResultSuccess(main);
}
async save(params) {
let id = Number(params.id || 0);
let saas_id = Number(params.saas_id || 0);
let name = this.trim(params.name);
let bank_account = this.trim(params.bank_account);
let bank_name = this.trim(params.bank_name);
let bank_no = this.trim(params.bank_no);
let main;
if (id) {
main = await this.dao.findById(id);
main.name = name;
main.bank_account = bank_account;
main.bank_name = bank_name;
main.bank_no = bank_no;
await main.save();
} else {
main = {
name: name,
bank_account: bank_account,
bank_name: bank_name,
bank_no: bank_no,
is_enabled: true,
saas_id: saas_id,
};
main = await this.dao.model.create(main);
}
return system.getResultSuccess(main);
}
async pageByCondition(params) {
var currentPage = Number(params.currentPage || 0);
var pageSize = Number(params.pageSize || 10);
var where = {
saas_id : params.saas_id,
};
if (params.name) {
where.name = {
[this.db.Op.like]: "%" + params.name + "%"
};
}
// this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd, true);
var orderby = [
["id", 'desc']
];
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
}
return system.getResultSuccess(page);
}
}
module.exports = SaasMainService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ 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