Commit 56716e4c authored by ml's avatar ml

增加接口、逻辑调整

parent b3374626
...@@ -57,4 +57,7 @@ export const ErrorCode = { ...@@ -57,4 +57,7 @@ export const ErrorCode = {
PWD_ILLEGAL:'30053',//密码过短或过长 PWD_ILLEGAL:'30053',//密码过短或过长
FIXED_AND_DEFAULT:'30054',//固定和默认不能同时为是 FIXED_AND_DEFAULT:'30054',//固定和默认不能同时为是
NOT_HIDDEN_TWO:'30055',//每种语言非隐藏并且固定的至少要有2个 NOT_HIDDEN_TWO:'30055',//每种语言非隐藏并且固定的至少要有2个
COIN_TYPE_NOT_EXIST:'30056',//指定币种不存在
PAIR_NOT_EXIST:'30057',//指定币对不存在
LIMIT_ERROR:'30058',//limit参数必须在10-2000之间
} }
import * as apikeyStrictService from "../service/apikeyStrict.service";
import { ApikeyStrictVO, ApikeyStrictPageVO } from "../service/apikeyStrict.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert, datetimeUtils } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
import { getCurrentUserId } from "../../../utils/aclUserUtils";
let isIp = require('is-ip');
/**
* API限速列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: ApikeyStrictPageVO) => {
let func_name = "apikeyStrict.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await apikeyStrictService.list(pageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 添加新的API限速
* @param req
* @param authConfigVO
*/
export const add = async (req: any, apikeyStrictVO: ApikeyStrictVO) => {
let func_name = "apikeyStrict.control.add";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await paramValid(apikeyStrictVO);
let res = await apikeyStrictService.add(apikeyStrictVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改API限速
* @param req
* @param authConfigVO
*/
export const update = async (req: any, apikeyStrictVO: ApikeyStrictVO) => {
let func_name = "apikeyStrict.control.update";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!apikeyStrictVO.id) {
throw ErrorCode.PARAM_MISS
}
await paramValid(apikeyStrictVO);
let res = await apikeyStrictService.update(apikeyStrictVO, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 删除Api限速
* @param req
* @param authConfigVO
*/
export const del = async (req: any, apikeyStrictVO: ApikeyStrictVO) => {
let func_name = "apikeyStrict.control.del";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!apikeyStrictVO.id) {
throw ErrorCode.PARAM_MISS
}
let res = await apikeyStrictService.del(apikeyStrictVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
async function paramValid(apikeyStrictVO: ApikeyStrictVO) {
let userId = apikeyStrictVO.user_id;
let limit = apikeyStrictVO.limit;
if (!userId || !limit) {
throw ErrorCode.PARAM_MISS
}
if (limit < 10 || limit > 2000) {
throw ErrorCode.LIMIT_ERROR;
}
}
import * as systemTriggerService from "../service/systemTrigger.service";
import { SystemTriggerVO, SystemTriggerPageVO } from "../service/systemTrigger.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, spotPairs } from "@madex/ex-ts-dao";
let isIp = require('is-ip');
/**
* 触发配置列表
* @param req
* @param infoVO
*/
export const list = async (req: any, pageVO: SystemTriggerPageVO) => {
let func_name = "systemTrigger.control.list";
try {
pageVO.page = Optional.opt(pageVO, 'page', 1);
pageVO.size = Optional.opt(pageVO, 'size', 20);
let res = await systemTriggerService.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, systemTriggerVO: SystemTriggerVO) => {
let func_name = "systemTrigger.control.add";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await paramValid(systemTriggerVO);
let res = await systemTriggerService.add(systemTriggerVO, 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, systemTriggerVO: SystemTriggerVO) => {
let func_name = "systemTrigger.control.update";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!systemTriggerVO.id) {
throw ErrorCode.PARAM_MISS
}
await paramValid(systemTriggerVO);
let res = await systemTriggerService.update(systemTriggerVO, 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, systemTriggerVO: SystemTriggerVO) => {
let func_name = "systemTrigger.control.del";
try {
let ip = isIp(req.ip) ? req.ip : '*.*.*.*';
let currentUserId = await getCurrentUserId(req.cookies.session_id);
if (!systemTriggerVO.id) {
throw ErrorCode.PARAM_MISS
}
let res = await systemTriggerService.del(systemTriggerVO.id, currentUserId, ip);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
async function paramValid(systemTriggerVO: SystemTriggerVO) {
let symbolOrPair = systemTriggerVO.trigger_symbol;
let triggerType = systemTriggerVO.trigger_type;
if (!symbolOrPair || !triggerType || !systemTriggerVO.trigger_time) {
throw ErrorCode.PARAM_MISS
}
if (triggerType == 1) {
let dbInfo = await coinType.prototype.findOne({
where: {
symbol: symbolOrPair
},
raw: true
});
if (!dbInfo) {
throw ErrorCode.COIN_TYPE_NOT_EXIST
}
}
else {
//TODO:之前查的 ex_pair 现在查询的是 spot_pairs 是否需要补充别的查询合约交易对的逻辑???
let dbInfo = await spotPairs.prototype.findOne({
where: {
symbol: symbolOrPair
},
raw: true
});
if (!dbInfo) {
throw ErrorCode.PAIR_NOT_EXIST
}
}
}
import { userApikeyStrict, } 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 ApikeyStrictVO {
id?: number;
user_id?: number;
limit?: number;
comment?: string;
createdAt?: Date | any,
updatedAt?: Date | any,
}
export interface ApikeyStrictPageVO extends ApikeyStrictVO {
page?: number,
size?: number,
}
export async function list(pageVO: ApikeyStrictPageVO) {
let where = {};
if (pageVO.user_id) {
where['user_id'] = pageVO.user_id
}
let resList = await userApikeyStrict.prototype.findAndCount({
where: where,
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [["id", "desc"]],
raw: true
});
return resList;
}
export async function add(apikeyStrictVO: ApikeyStrictVO, currentUserId: any, ip: string | undefined) {
apikeyStrictVO.createdAt = new Date();
apikeyStrictVO.updatedAt = new Date();
let dbInfo = await userApikeyStrict.prototype.findOne({
where: {
user_id: apikeyStrictVO.user_id
},
raw: true
});
if (dbInfo) {
throw ErrorCode.DATA_EXIST
}
await userApikeyStrict.prototype.create(apikeyStrictVO);
//管理后台操作日志
addOptLog(currentUserId, 0, '新增API限速', ip, JSON.stringify(apikeyStrictVO), 'API限速管理');
return 'success';
}
export async function update(apikeyStrictVO: ApikeyStrictVO, currentUserId: any, ip: string | undefined) {
let exist = await userApikeyStrict.prototype.findOne({
where: {
id: apikeyStrictVO.id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
apikeyStrictVO.updatedAt = new Date();
//不修改user_id
apikeyStrictVO.user_id = exist.user_id;
await userApikeyStrict.prototype.update(apikeyStrictVO, {
where: {
id: Number(apikeyStrictVO.id)
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '修改API限速', ip, JSON.stringify(apikeyStrictVO), 'API限速管理');
return 'success';
}
export async function del(id: number, currentUserId: any, ip: string | undefined) {
let exist = await userApikeyStrict.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
await userApikeyStrict.prototype.destroy({
where: {
id: id
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '删除API限速', ip, `id:${id}`, 'API限速管理');
return 'success';
}
...@@ -57,8 +57,8 @@ export async function list(noticePageVO: NoticePageVO) { ...@@ -57,8 +57,8 @@ export async function list(noticePageVO: NoticePageVO) {
let date = datetimeUtils.trim(noticePageVO.push_time, 's'); let date = datetimeUtils.trim(noticePageVO.push_time, 's');
where.push_time = { [ormDB.Op.gte]: date }; where.push_time = { [ormDB.Op.gte]: date };
} }
if (!noticePageVO.del_sign) { if (noticePageVO.del_sign || noticePageVO.del_sign === 0) {
where.del_sign = 0; where.del_sign = noticePageVO.del_sign;
} }
if (noticePageVO.status) { if (noticePageVO.status) {
where.status = noticePageVO.status; where.status = noticePageVO.status;
...@@ -86,7 +86,7 @@ export async function add(noticeVO: NoticeVO, currentUserId: any, ip: any) { ...@@ -86,7 +86,7 @@ export async function add(noticeVO: NoticeVO, currentUserId: any, ip: any) {
noticeVO.publish_flag = 0; noticeVO.publish_flag = 0;
} }
if (!noticeVO.push_type) { if (!noticeVO.push_type) {
noticeVO.push_type = 1; noticeVO.push_type = 0;
} }
noticeVO.del_sign = 0; noticeVO.del_sign = 0;
noticeVO.status = 0; noticeVO.status = 0;
...@@ -142,13 +142,13 @@ export async function update(noticeVO: NoticeVO, currentUserId: any, ip: any) { ...@@ -142,13 +142,13 @@ export async function update(noticeVO: NoticeVO, currentUserId: any, ip: any) {
if (noticeVO.content) { if (noticeVO.content) {
updateInfo['content'] = noticeVO.content; updateInfo['content'] = noticeVO.content;
} }
if (noticeVO.publish_flag) { if (noticeVO.publish_flag || noticeVO.publish_flag === 0) {
updateInfo['publish_flag'] = noticeVO.publish_flag; updateInfo['publish_flag'] = noticeVO.publish_flag;
} }
if (noticeVO.notice_type) { if (noticeVO.notice_type) {
updateInfo['notice_type'] = noticeVO.notice_type; updateInfo['notice_type'] = noticeVO.notice_type;
} }
if (noticeVO.push_type) { if (noticeVO.push_type || noticeVO.push_type === 0) {
updateInfo['push_type'] = noticeVO.push_type; updateInfo['push_type'] = noticeVO.push_type;
} }
if (noticeVO.push_time) { if (noticeVO.push_time) {
......
import { systemTrigger, } 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 SystemTriggerVO {
id?: number;
trigger_symbol?: string | any;
trigger_type?: number;
trigger_action?: number;
status?: number;
trigger_time?: Date | any,
createdAt?: Date | any,
updatedAt?: Date | any,
}
export interface SystemTriggerPageVO extends SystemTriggerVO {
page?: number,
size?: number,
}
export async function list(pageVO: SystemTriggerPageVO) {
let where = {};
if (pageVO.trigger_action) {
where['trigger_action'] = pageVO.trigger_action
}
if (pageVO.trigger_symbol) {
where['trigger_symbol'] = pageVO.trigger_symbol
}
if (pageVO.status || pageVO.status === 0) {
where['status'] = pageVO.status
}
let resList = await systemTrigger.prototype.findAndCount({
where: where,
limit: pageVO.size,
offset: (Number(pageVO.page) - 1) * Number(pageVO.size),
order: [["trigger_time", "desc"]],
raw: true
});
return resList;
}
export async function add(systemTriggerVO: SystemTriggerVO, currentUserId: any, ip: string | undefined) {
systemTriggerVO.createdAt = new Date();
systemTriggerVO.updatedAt = new Date();
if (!systemTriggerVO.status) {
systemTriggerVO.status = 0;
}
await systemTrigger.prototype.create(systemTriggerVO);
//管理后台操作日志
addOptLog(currentUserId, 0, '新增触发配置', ip, JSON.stringify(systemTriggerVO), '触发配置管理');
return 'success';
}
export async function update(systemTriggerVO: SystemTriggerVO, currentUserId: any, ip: string | undefined) {
let exist = await systemTrigger.prototype.findOne({
where: {
id: systemTriggerVO.id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
systemTriggerVO.updatedAt = new Date();
await systemTrigger.prototype.update(systemTriggerVO, {
where: {
id: Number(systemTriggerVO.id)
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '修改触发配置', ip, JSON.stringify(systemTriggerVO), '触发配置管理');
return 'success';
}
export async function del(id: number, currentUserId: any, ip: string | undefined) {
let exist = await systemTrigger.prototype.findOne({
where: {
id: id
},
raw: true
});
if (!exist) {
throw ErrorCode.DATA_NOT_EXIST
}
await systemTrigger.prototype.destroy({
where: {
id: id
}
})
//管理后台操作日志
addOptLog(currentUserId, 0, '删除触发配置', ip, `id:${id}`, '触发配置管理');
return 'success';
}
...@@ -34,6 +34,9 @@ import * as appApplyVersionCtrl from "../../mvc/control/appApplyVersion.control" ...@@ -34,6 +34,9 @@ import * as appApplyVersionCtrl from "../../mvc/control/appApplyVersion.control"
import * as appDynamicDomainCtrl from "../../mvc/control/appDynamicDomain.control"; import * as appDynamicDomainCtrl from "../../mvc/control/appDynamicDomain.control";
import * as appSpecialModelCtrl from "../../mvc/control/appSpecialModel.control"; import * as appSpecialModelCtrl from "../../mvc/control/appSpecialModel.control";
import * as appFeatureCtrl from "../../mvc/control/appFeature.control"; import * as appFeatureCtrl from "../../mvc/control/appFeature.control";
import * as systemTriggerCtrl from "../../mvc/control/systemTrigger.control";
import * as apikeyStrictCtrl from "../../mvc/control/apikeyStrict.control";
import { systemTrigger } from "@madex/ex-ts-dao";
const getFunc = { const getFunc = {
'user/info': userController.getUserInfo, 'user/info': userController.getUserInfo,
...@@ -155,24 +158,34 @@ const postFunc = { ...@@ -155,24 +158,34 @@ const postFunc = {
'mUser/fee/setting/submit': commonUserFeeSettingCtrl.submit,//提交普通用户手续费 'mUser/fee/setting/submit': commonUserFeeSettingCtrl.submit,//提交普通用户手续费
'mUser/fee/vip/level/list': commonUserFeeSettingCtrl.vipLevelList,//用户等级费率列表 'mUser/fee/vip/level/list': commonUserFeeSettingCtrl.vipLevelList,//用户等级费率列表
//技术部-App版本管理 //技术部-App管理-App版本管理
'tech/app/version/list': appVersionCtrl.list, 'tech/app/version/list': appVersionCtrl.list,
'tech/app/version/add': appVersionCtrl.add, 'tech/app/version/add': appVersionCtrl.add,
'tech/app/version/update': appVersionCtrl.update, 'tech/app/version/update': appVersionCtrl.update,
//技术部-App首页入口管理 //技术部-App管理-App首页入口管理
'tech/app/feature/list': appFeatureCtrl.list, 'tech/app/feature/list': appFeatureCtrl.list,
'tech/app/feature/add': appFeatureCtrl.add, 'tech/app/feature/add': appFeatureCtrl.add,
'tech/app/feature/update': appFeatureCtrl.update, 'tech/app/feature/update': appFeatureCtrl.update,
'tech/app/feature/del': appFeatureCtrl.del, 'tech/app/feature/del': appFeatureCtrl.del,
//技术部-App审核管理 //技术部-App管理-App审核管理
'tech/app/apply/version/list': appApplyVersionCtrl.list, 'tech/app/apply/version/list': appApplyVersionCtrl.list,
'tech/app/apply/version/modify': appApplyVersionCtrl.modify, 'tech/app/apply/version/modify': appApplyVersionCtrl.modify,
//技术部-App动态域名 //技术部-App管理-App动态域名
'tech/app/dynamic/domain/get': appDynamicDomainCtrl.get, 'tech/app/dynamic/domain/get': appDynamicDomainCtrl.get,
'tech/app/dynamic/domain/update': appDynamicDomainCtrl.update, 'tech/app/dynamic/domain/update': appDynamicDomainCtrl.update,
//技术部-App特定机型配置 //技术部-App管理-App特定机型配置
'tech/app/special/model/get': appSpecialModelCtrl.get, 'tech/app/special/model/get': appSpecialModelCtrl.get,
'tech/app/special/model/update': appSpecialModelCtrl.update, 'tech/app/special/model/update': appSpecialModelCtrl.update,
//技术部-其他管理-触发配置管理
'tech/other/system/trigger/list': systemTriggerCtrl.list,
'tech/other/system/trigger/add': systemTriggerCtrl.add,
'tech/other/system/trigger/update': systemTriggerCtrl.update,
'tech/other/system/trigger/del': systemTriggerCtrl.del,
//技术部-其他管理-API限速管理
'tech/other/apikey/strict/list': apikeyStrictCtrl.list,
'tech/other/apikey/strict/add': apikeyStrictCtrl.add,
'tech/other/apikey/strict/update': apikeyStrictCtrl.update,
'tech/other/apikey/strict/del': apikeyStrictCtrl.del,
}; };
// TODO 这里先和 nodejs 的注册路由方式保持一样,后面在调整。 // TODO 这里先和 nodejs 的注册路由方式保持一样,后面在调整。
......
...@@ -114,25 +114,34 @@ let cmdWhiteList = { ...@@ -114,25 +114,34 @@ let cmdWhiteList = {
'mUser/fee/setting/delete': 1, 'mUser/fee/setting/delete': 1,
'mUser/fee/setting/submit': 1, 'mUser/fee/setting/submit': 1,
'mUser/fee/vip/level/list': 1, 'mUser/fee/vip/level/list': 1,
//技术部-App版本管理 //技术部-App管理-App版本管理
'tech/app/version/list': 1, 'tech/app/version/list': 1,
'tech/app/version/add': 1, 'tech/app/version/add': 1,
'tech/app/version/update': 1, 'tech/app/version/update': 1,
//技术部-App首页入口管理 //技术部-App管理-App首页入口管理
'tech/app/feature/list': 1, 'tech/app/feature/list': 1,
'tech/app/feature/add': 1, 'tech/app/feature/add': 1,
'tech/app/feature/update': 1, 'tech/app/feature/update': 1,
'tech/app/feature/del': 1, 'tech/app/feature/del': 1,
//技术部-App审核管理 //技术部-App管理-App审核管理
'tech/app/apply/version/list': 1, 'tech/app/apply/version/list': 1,
'tech/app/apply/version/modify': 1, 'tech/app/apply/version/modify': 1,
//技术部-App动态域名 //技术部-App管理-App动态域名
'tech/app/dynamic/domain/get': 1, 'tech/app/dynamic/domain/get': 1,
'tech/app/dynamic/domain/update': 1, 'tech/app/dynamic/domain/update': 1,
//技术部-App特定机型配置 //技术部-App管理-App特定机型配置
'tech/app/special/model/get': 1, 'tech/app/special/model/get': 1,
'tech/app/special/model/update': 1, 'tech/app/special/model/update': 1,
//技术部-其他管理-触发配置管理
'tech/other/system/trigger/list': 1,
'tech/other/system/trigger/add': 1,
'tech/other/system/trigger/update': 1,
'tech/other/system/trigger/del': 1,
//技术部-其他管理-API限速管理
'tech/other/apikey/strict/list': 1,
'tech/other/apikey/strict/add': 1,
'tech/other/apikey/strict/update': 1,
'tech/other/apikey/strict/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