Commit b567f188 authored by 1486327116's avatar 1486327116

init

parent 9b18f9a7
import * as service from "../service/coinType.service"; import * as service from "../service/coinType.service";
import { AddParam, ListParam } from "../service/coinType.service"; import { AddParam, ListParam } from "../service/coinType.service";
let { logger, ResponseUtils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public'); let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
export const list = async (req: any, param: ListParam) => { export const list = async (req: any, param: ListParam) => {
...@@ -11,16 +11,16 @@ export const list = async (req: any, param: ListParam) => { ...@@ -11,16 +11,16 @@ export const list = async (req: any, param: ListParam) => {
param.page = Optional.opt(param, 'page', 1); param.page = Optional.opt(param, 'page', 1);
param.size = Optional.opt(param, 'size', 50); param.size = Optional.opt(param, 'size', 50);
let res = await service.list(param); let res = await service.list(param);
return ResponseUtils.success(cmd, res); return Res3Utils.result(res);
} }
catch (e) { catch (e) {
logger.error(`${func_name} error:${e}`); logger.error(`${func_name} error:${e}`);
return ResponseUtils.error(func_name, cmd, e); return Res3Utils.getErrorResult(e);
} }
}; };
export const add = async (req: any, param: AddParam) => { export const save = async (req: any, param: AddParam) => {
let func_name = "coinTypeCtl.add"; let func_name = "coinTypeCtl.save";
let cmd = req.path; let cmd = req.path;
try { try {
ApiAssert.notNull('3000', param.symbol); ApiAssert.notNull('3000', param.symbol);
...@@ -33,11 +33,26 @@ export const add = async (req: any, param: AddParam) => { ...@@ -33,11 +33,26 @@ export const add = async (req: any, param: AddParam) => {
ApiAssert.isInt('3000', param.deposit_confirm_count); ApiAssert.isInt('3000', param.deposit_confirm_count);
ApiAssert.isInt('3000', param.safe_confirm_count); ApiAssert.isInt('3000', param.safe_confirm_count);
let res = await service.add(param); let res = await service.save(param);
return ResponseUtils.success(cmd, res); return Res3Utils.result(res);
} }
catch (e) { catch (e) {
logger.error(`${func_name} error:${e}`); logger.error(`${func_name} error:${e}`);
return ResponseUtils.error(func_name, cmd, e); return Res3Utils.getErrorResult(e);
}
};
export const pushToCoreSystem = async (req: any, id: any) => {
let func_name = "coinTypeCtl.pushToCoreSystem";
let cmd = req.path;
try {
ApiAssert.notNull('3000', id);
let res = await service.pushToCoreSystem(id);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
} }
}; };
import * as service from "../service/spotPair.service"; import * as service from "../service/spotPair.service";
import { AddParam, ListParam } from "../service/spotPair.service"; import { AddParam, ListParam } from "../service/spotPair.service";
let { logger, ResponseUtils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public'); let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
export const list = async (req: any, param: ListParam) => { export const list = async (req: any, param: ListParam) => {
...@@ -11,16 +11,16 @@ export const list = async (req: any, param: ListParam) => { ...@@ -11,16 +11,16 @@ export const list = async (req: any, param: ListParam) => {
param.page = Optional.opt(param, 'page', 1); param.page = Optional.opt(param, 'page', 1);
param.size = Optional.opt(param, 'size', 50); param.size = Optional.opt(param, 'size', 50);
let res = await service.list(param); let res = await service.list(param);
return ResponseUtils.success(cmd, res); return Res3Utils.result(res);
} }
catch (e) { catch (e) {
logger.error(`${func_name} error:${e}`); logger.error(`${func_name} error:${e}`);
return ResponseUtils.error(func_name, cmd, e); return Res3Utils.getErrorResult(e);
} }
}; };
export const add = async (req: any, param: AddParam) => { export const save = async (req: any, param: AddParam) => {
let func_name = "spotPairCtl.add"; let func_name = "spotPairCtl.save";
let cmd = req.path; let cmd = req.path;
try { try {
ApiAssert.notNull('3000', param.base); ApiAssert.notNull('3000', param.base);
...@@ -31,11 +31,26 @@ export const add = async (req: any, param: AddParam) => { ...@@ -31,11 +31,26 @@ export const add = async (req: any, param: AddParam) => {
ApiAssert.notNull('3000', param.quantity_scale); ApiAssert.notNull('3000', param.quantity_scale);
ApiAssert.notNull('3000', param.maker_fee); ApiAssert.notNull('3000', param.maker_fee);
ApiAssert.notNull('3000', param.taker_fee); ApiAssert.notNull('3000', param.taker_fee);
let res = await service.add(param); let res = await service.save(param);
return ResponseUtils.success(cmd, res); return Res3Utils.result(res);
} }
catch (e) { catch (e) {
logger.error(`${func_name} error:${e}`); logger.error(`${func_name} error:${e}`);
return ResponseUtils.error(func_name, cmd, e); return Res3Utils.getErrorResult(e);
}
};
export const pushToCoreSystem = async (req: any, id: any) => {
let func_name = "spotPairCtl.pushToCoreSystem";
let cmd = req.path;
try {
ApiAssert.notNull('3000', id);
let res = await service.pushToCoreSystem(id);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
} }
}; };
...@@ -11,6 +11,8 @@ export interface ListParam { ...@@ -11,6 +11,8 @@ export interface ListParam {
} }
export interface AddParam { export interface AddParam {
id:any,
symbol: string; symbol: string;
is_active: number; is_active: number;
...@@ -101,8 +103,24 @@ export async function list(param: ListParam) { ...@@ -101,8 +103,24 @@ export async function list(param: ListParam) {
return resList; return resList;
} }
export const add = async (param: AddParam) => { export const save = async (param: AddParam) => {
let id = param.id;
if (id) {
delete param.id
await coinType.prototype.update(param,{
where:{id:id}
})
}else {
await coinType.prototype.create(param); await coinType.prototype.create(param);
}
return 'ok';
};
export const pushToCoreSystem = async (id: any) => {
await coinType.prototype.update({ main_status:1 },{
where:{id:id,main_status:0}
})
return 'ok'; return 'ok';
}; };
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上 // @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { spotPairs, ormDB } from "@madex/ex-ts-dao"; import { spotPairs, ormDB, coinType } from "@madex/ex-ts-dao";
import { NUMBER } from "sequelize"; import { NUMBER } from "sequelize";
...@@ -10,6 +10,7 @@ export interface ListParam { ...@@ -10,6 +10,7 @@ export interface ListParam {
} }
export interface AddParam { export interface AddParam {
id: any;
base:string; base:string;
quote:string; quote:string;
symbol:string; symbol:string;
...@@ -36,8 +37,23 @@ export async function list(param: ListParam) { ...@@ -36,8 +37,23 @@ export async function list(param: ListParam) {
return resList; return resList;
} }
export const add = async (param: AddParam) => { export const save = async (param: AddParam) => {
let id = param.id;
if (id) {
delete param.id
await spotPairs.prototype.update(param,{
where:{id:id}
})
}else {
await spotPairs.prototype.create(param); await spotPairs.prototype.create(param);
}
return 'ok';
};
export const pushToCoreSystem = async (id: any) => {
await spotPairs.prototype.update({ status:1 },{
where:{id:id,status:0}
})
return 'ok'; return 'ok';
}; };
...@@ -31,10 +31,13 @@ const postFunc = { ...@@ -31,10 +31,13 @@ const postFunc = {
'i18n/info/log/list': i18nLogCtrl.list, 'i18n/info/log/list': i18nLogCtrl.list,
'i18n/info/log/revert': i18nLogCtrl.revert, 'i18n/info/log/revert': i18nLogCtrl.revert,
'spotpair/add': spotPairCtrl.add, 'spotPair/add': spotPairCtrl.save,
'spotpair/list': spotPairCtrl.list, 'spotPair/list': spotPairCtrl.list,
'coinType/add': coinTypeCtrl.add, 'spotPair/spotPairCtl': spotPairCtrl.pushToCoreSystem,
'coinType/add': coinTypeCtrl.save,
'coinType/list': coinTypeCtrl.list, 'coinType/list': coinTypeCtrl.list,
'coinType/spotPairCtl': coinTypeCtrl.pushToCoreSystem,
'acl/user/add': aclUserCtrl.add, 'acl/user/add': aclUserCtrl.add,
'acl/user/list': aclUserCtrl.list, 'acl/user/list': aclUserCtrl.list,
......
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