Commit f33d26a7 authored by ml's avatar ml

热门币种搜索

parent 9b18f9a7
...@@ -1068,9 +1068,9 @@ ...@@ -1068,9 +1068,9 @@
} }
}, },
"node_modules/@madex/ex-ts-dao": { "node_modules/@madex/ex-ts-dao": {
"version": "0.0.10", "version": "0.0.12",
"resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.10.tgz", "resolved": "https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.12.tgz",
"integrity": "sha512-+mmRCR86JvKs0bx0UfrA1Ld5NzOjvh7fkCCs4h7mbTzJJUirUlgFE3/wsM1e4xTyURpJ0hsROkNvahkn1yrClQ==", "integrity": "sha512-Ig1DpxD+GO+bAHQ+IE6ZoZxpVQhUHx66beoJE+S9awrWZxMywHI0PcreC33MDN1emt2ccm3VZjFBnzKG6PcPoA==",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@madex/ex-js-public": "git+ssh://git@bitbucket.org/biiigle/ex-js-public.git#master", "@madex/ex-js-public": "git+ssh://git@bitbucket.org/biiigle/ex-js-public.git#master",
......
import * as hotPairConfigService from "../service/hotPairConfig.service";
import { HotPairConfigVO, HotPairConfigPageVO } from "../service/hotPairConfig.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { getCurrentUserId, isAdminUserBySessionId } from "../../../utils/aclUserUtils";
/**
* 分页查询热门交易对配置列表
* @param req
* @param infoVO
*/
export const list = async (req: any, hotPairConfigPageVO: HotPairConfigPageVO) => {
let func_name = "hotPairConfigCtrl.list";
try {
hotPairConfigPageVO.page = Optional.opt(hotPairConfigPageVO, 'page', 1);
hotPairConfigPageVO.size = Optional.opt(hotPairConfigPageVO, 'size', 20);
let res = await hotPairConfigService.list(hotPairConfigPageVO.pair, Number(hotPairConfigPageVO.page), Number(hotPairConfigPageVO.size));
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加热门交易对
* @param req
* @param infoVO
*/
export const add = async (req: any, hotPairConfigVO: HotPairConfigVO) => {
let func_name = "hotPairConfigCtrl.add";
try {
ApiAssert.notNull(ErrorCode.PARAM_MISS, hotPairConfigVO.pair);
ApiAssert.notNull(ErrorCode.PARAM_MISS, hotPairConfigVO.weight);
let res = await hotPairConfigService.add(hotPairConfigVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改热门交易对
* @param req
* @param infoVO
*/
export const update = async (req: any, hotPairConfigVO: HotPairConfigVO) => {
let func_name = "hotPairConfigCtrl.update";
try {
ApiAssert.notNull(ErrorCode.PARAM_MISS, hotPairConfigVO.id);
ApiAssert.notNull(ErrorCode.PARAM_MISS, hotPairConfigVO.pair);
ApiAssert.notNull(ErrorCode.PARAM_MISS, hotPairConfigVO.weight);
let res = await hotPairConfigService.update(hotPairConfigVO);
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, hotPairConfigVO: HotPairConfigVO) => {
let func_name = "hotPairConfigCtrl.del";
try {
ApiAssert.notNull(ErrorCode.PARAM_MISS, hotPairConfigVO.id);
let res = await hotPairConfigService.del(Number(hotPairConfigVO.id));
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
\ No newline at end of file
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { ormDB, hotPairConfig } from "@madex/ex-ts-dao";
import { AclUserInfoConst } from "../../../constant/aclUserConstant";
import { CryptUtils } from "../../../utils/crypt-utils";
import { ErrorCode } from "../../../constant/errorCode";
import * as aclRoleAuthService from "../service/aclRoleAuth.service";
import * as aclUserService from "../service/aclUser.service";
import { getOneAclUserByAccount, getOneAclUserByUid } from "../../../utils/aclUserUtils";
import { RedisVal } from "../../../constant/redis-val";
import Config from "../../../../config";
import { AuthConfigConst } from "../../../constant/aclUserAuthConfigConstant";
import * as userOptLogService from "./userOptLog.service";
let { apiAssertUtils: ApiAssert, datetimeUtils: DatetimeUtils } = require('@madex/ex-js-public');
let { authCommon: AuthCommon, redisUtilsCommon: RedisClient, BigNumberUtils } = require('@madex/ex-js-common');
let _ = require('lodash');
let { logger } = require('@madex/ex-js-public');
export interface HotPairConfigVO {
id?: number;
pair?: string | any;
weight?: number;
createdAt?: Date | any;
updatedAt?: Date | any;
}
export interface HotPairConfigPageVO extends HotPairConfigVO {
page?: number,
size?: number
}
export async function list(pair: any, page: number, size: number) {
let where = Object.create(null);
if (pair) {
where.pair = { [ormDB.Op.like]: `${pair}%` };
}
let resList = await hotPairConfig.prototype.findAndCount({
where: where,
limit: size,
offset: (page - 1) * size,
order: [["weight", "desc"]],
raw: true
});
return resList;
}
export async function add(hotPairConfigVO: HotPairConfigVO) {
let dbInfo = await hotPairConfig.prototype.findOne({
where: {
pair: hotPairConfigVO.pair
},
raw: true
});
if (dbInfo) {
throw ErrorCode.DATA_EXIST;
}
hotPairConfigVO.createdAt = new Date();
hotPairConfigVO.updatedAt = new Date();
await hotPairConfig.prototype.create(hotPairConfigVO);
return 'success'
}
export async function update(hotPairConfigVO: HotPairConfigVO) {
let dbInfo = await hotPairConfig.prototype.findOne({
where: {
pair: hotPairConfigVO.pair,
id: { [ormDB.Op.ne]: hotPairConfigVO.id }
},
raw: true
});
if (dbInfo) {
throw ErrorCode.DATA_EXIST;
}
hotPairConfigVO.updatedAt = new Date();
await hotPairConfig.prototype.update({
pair: hotPairConfigVO.pair,
weight: hotPairConfigVO.weight
}, {
where: {
id: Number(hotPairConfigVO.id)
}
});
return 'success'
}
export async function del(id: number) {
let dbInfo = await hotPairConfig.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!dbInfo) {
throw ErrorCode.DATA_NOT_EXIST;
}
await hotPairConfig.prototype.destroy({
where: {
id: Number(id)
}
});
return 'success'
}
...@@ -14,6 +14,7 @@ import * as aclUserCtrl from "../../mvc/control/aclUser.control"; ...@@ -14,6 +14,7 @@ import * as aclUserCtrl from "../../mvc/control/aclUser.control";
import * as aclRoleAuthCtrl from "../../mvc/control/aclRoleAuth.control"; import * as aclRoleAuthCtrl from "../../mvc/control/aclRoleAuth.control";
import * as userOptCtrl from "../../mvc/control/userOpt.control"; import * as userOptCtrl from "../../mvc/control/userOpt.control";
import * as userAuthConfigCtrl from "../../mvc/control/userAuthConfig.control"; import * as userAuthConfigCtrl from "../../mvc/control/userAuthConfig.control";
import * as hotPairConfigCtrl from "../../mvc/control/hotPairConfig.control";
import * as ReqUtils from "../../../utils/req-utils"; import * as ReqUtils from "../../../utils/req-utils";
import * as spotPairCtrl from "../../mvc/control/spotPair.control"; import * as spotPairCtrl from "../../mvc/control/spotPair.control";
...@@ -72,6 +73,11 @@ const postFunc = { ...@@ -72,6 +73,11 @@ const postFunc = {
'user/auth/change/locked/status': userAuthConfigCtrl.changeLockedStatus, 'user/auth/change/locked/status': userAuthConfigCtrl.changeLockedStatus,
'user/auth/reset/totp': userAuthConfigCtrl.resetTotp, 'user/auth/reset/totp': userAuthConfigCtrl.resetTotp,
'hot/pair/config/list': hotPairConfigCtrl.list,
'hot/pair/config/add': hotPairConfigCtrl.add,
'hot/pair/config/update': hotPairConfigCtrl.update,
'hot/pair/config/del': hotPairConfigCtrl.del,
}; };
......
...@@ -44,6 +44,10 @@ let cmdWhiteList = { ...@@ -44,6 +44,10 @@ let cmdWhiteList = {
'user/auth/change/force/status': 1, 'user/auth/change/force/status': 1,
'user/auth/change/locked/status': 1, 'user/auth/change/locked/status': 1,
'user/auth/reset/totp': 1, 'user/auth/reset/totp': 1,
'hot/pair/config/list': 1,
'hot/pair/config/add': 1,
'hot/pair/config/update': 1,
'hot/pair/config/del': 1,
}; };
......
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