Commit d7ff4690 authored by ml's avatar ml

金融部-其他管理-账号管理

parent ad32dd5b
import * as financeAccountService from "../service/fianceAccount.service";
import { FinanceAccountVO, FinanceAccountPageVO } from "../service/fianceAccount.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert, datetimeUtils } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { getCurrentUserId } from "../../../utils/aclUserUtils";
import { coinType, contractPairs, spotPairs } from "@madex/ex-ts-dao";
let isIp = require('is-ip');
/**
* 账户列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: FinanceAccountPageVO) => {
let func_name = "financeAccount.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await financeAccountService.list(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加新的账户
* @param req
* @param authConfigVO
*/
export const add = async (req: any, financeAccountVO: FinanceAccountVO) => {
let func_name = "financeAccount.control.add";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await paramValid(financeAccountVO);
let res = await financeAccountService.add(financeAccountVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改账户信息
* @param req
* @param authConfigVO
*/
export const update = async (req: any, financeAccountVO: FinanceAccountVO) => {
let func_name = "financeAccount.control.update";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!financeAccountVO.id) {
throw ErrorCode.PARAM_MISS
}
await paramValid(financeAccountVO);
let res = await financeAccountService.update(financeAccountVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 删除账户信息
* @param req
* @param authConfigVO
*/
export const del = async (req: any, financeAccountVO: FinanceAccountVO) => {
let func_name = "financeAccount.control.del";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!financeAccountVO.id) {
throw ErrorCode.PARAM_MISS
}
let res = await financeAccountService.del(financeAccountVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
async function paramValid(financeAccountVO: FinanceAccountVO) {
if (!financeAccountVO.account || !financeAccountVO.init_asset || !financeAccountVO.apikey ||
!financeAccountVO.secret || !financeAccountVO.secret_pwd ||
!financeAccountVO.platform) {
throw ErrorCode.PARAM_MISS;
}
}
import { financeMarketAccount, ormDB, } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service";
let _ = require('lodash');
let { logger } = require('@madex/ex-js-public');
export interface FinanceAccountVO {
id?: number;
account?: string | any;
remark?: string | any;
init_asset?: number;
apikey?: string | any;
secret?: string | any;
secret_pwd?: string | any;
platform?: number;
status?: number;
createdAt?: Date | any,
updatedAt?: Date | any,
}
export interface FinanceAccountPageVO extends FinanceAccountVO {
page?: number,
size?: number,
}
export async function list(pageVO: FinanceAccountPageVO) {
let where = {};
let resList = await financeMarketAccount.prototype.findAndCount({
where: where,
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [["id", "asc"]],
raw: true
});
return resList;
}
export async function add(financeAccountVO: FinanceAccountVO, currentUserId: any, ip: any) {
let dbOne = await financeMarketAccount.prototype.findOne({
where: {
account: financeAccountVO.account
},
raw: true
});
if (dbOne) {
throw ErrorCode.DATA_EXIST;
}
financeAccountVO.createdAt = new Date();
financeAccountVO.updatedAt = new Date();
if (!financeAccountVO.status) {
//默认可用
financeAccountVO.status = 1;
}
await financeMarketAccount.prototype.create(financeAccountVO);
//管理后台操作日志
addOptLog(currentUserId, 0, '新增账户', ip, JSON.stringify(financeAccountVO), '金融部-其他管理');
return 'success';
}
export async function update(financeAccountVO: FinanceAccountVO, currentUserId: any, ip: any) {
let exist = await financeMarketAccount.prototype.findOne({
where: {
id: financeAccountVO.id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
let dbOne = await financeMarketAccount.prototype.findOne({
where: {
account: financeAccountVO.account,
id: { [ormDB.Op.ne]: financeAccountVO.id }
},
raw: true
});
if (dbOne) {
throw ErrorCode.DATA_EXIST;
}
financeAccountVO.updatedAt = new Date();
await financeMarketAccount.prototype.update(financeAccountVO, {
where: {
id: Number(financeAccountVO.id)
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '修改账户信息', ip, JSON.stringify(financeAccountVO), '金融部-其他管理');
return 'success';
}
export async function del(id: number, currentUserId: any, ip: string | undefined) {
let exist = await financeMarketAccount.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
await financeMarketAccount.prototype.destroy({
where: {
id: id
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '删除账户信息', ip, `id:${id}`, '金融部-其他管理');
return 'success';
}
......@@ -52,6 +52,7 @@ import * as spotDataCtrl from "../../mvc/control/spotData.control";
import * as exBusinessAreaCtrl from "../../mvc/control/exBusinessArea.control";
import * as rewardTimePeriodCtrl from "../../mvc/control/rewardTimePeriod.control";
import * as collateralCtrl from "../../mvc/control/collateral.control";
import * as fianceAccountCtrl from "../../mvc/control/fianceAccount.control";
const getFunc = {
'user/info': userController.getUserInfo,
......@@ -304,6 +305,11 @@ const postFunc = {
//技术部-其他管理-返佣时间配置
'tech/other/reward/time/period/set': rewardTimePeriodCtrl.set,
'tech/other/reward/time/period/get': rewardTimePeriodCtrl.get,
//金融部-其他管理-账户管理
'fiance/other/account/list': fianceAccountCtrl.list,
'fiance/other/account/add': fianceAccountCtrl.add,
'fiance/other/account/update': fianceAccountCtrl.update,
'fiance/other/account/del': fianceAccountCtrl.del,
};
......
......@@ -2,6 +2,7 @@
import * as ReqUtils from "../utils/req-utils";
import Config from "../../config";
import * as collateralCtrl from "../functional/mvc/control/collateral.control";
const {
Res3Utils,
logger: Logger,
......@@ -238,10 +239,14 @@ let cmdWhiteList = {
//技术部-其他管理-返佣时间配置
'tech/other/reward/time/period/set': 1,
'tech/other/reward/time/period/get': 1,
//金融部-其他管理-账户管理
'fiance/other/account/list': 1,
'fiance/other/account/add': 1,
'fiance/other/account/update': 1,
'fiance/other/account/del': 1,
};
let filter = function (app: any) {
app.use(function (req, res, next) {
let path = ReqUtils.parsePath(req.originalUrl);
......
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