Commit 7871c64b authored by 1486327116's avatar 1486327116

Merge remote-tracking branch 'origin/master'

parents b567f188 c136b23b
This diff is collapsed.
......@@ -24,5 +24,6 @@ export const ErrorCode = {
TOTP_KEY_OVERSTAYED: '30022',//密钥已失效,请重新获取
USER_TYPE_ILLEGAL: '30023',//用户类型不合法
NEED_INPUT_GOOGLE_CODE: '30024',//请输入Google验证码
PUSH_NOT_UPDATE: '30025',//已经推送不允许修改
}
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";
/**
* 分页查询热门交易对配置列表
* @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
import * as noticeService from "../service/notice.service";
import { NoticeVO, NoticePageVO } from "../service/notice.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
import { ErrorCode } from "../../../constant/errorCode";
/**
* 消息列表
* @param req
* @param infoVO
*/
export const list = async (req: any, noticePageVO: NoticePageVO) => {
let func_name = "noticeCtrl.list";
try {
noticePageVO.page = Optional.opt(noticePageVO, 'page', 1);
noticePageVO.size = Optional.opt(noticePageVO, 'size', 20);
let res = await noticeService.list(noticePageVO);
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, noticeVO: NoticeVO) => {
let func_name = "noticeCtrl.add";
try {
ApiAssert.notNull(ErrorCode.PARAM_MISS, noticeVO.content);
ApiAssert.notNull(ErrorCode.PARAM_MISS, noticeVO.notice_type);
ApiAssert.notNull(ErrorCode.PARAM_MISS, noticeVO.push_time);
let res = await noticeService.add(noticeVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/**
* 修改消息 删除 就传 del_sign = 1
* 推送给指定的多个用户的消息 目前只能一个一个修改 不支持批量修改
* 需要支持的话 可能数据库要调整 增加一个 group_id 字段
* @param req
* @param infoVO
*/
export const update = async (req: any, noticeVO: NoticeVO) => {
let func_name = "noticeCtrl.update";
try {
ApiAssert.notNull(ErrorCode.PARAM_MISS, noticeVO.id);
let res = await noticeService.update(noticeVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
import { ormDB, hotPairConfig } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
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'
}
import { ormDB, noticeModel, noticeRead } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
let _ = require('lodash');
let { logger, datetimeUtils } = require('@madex/ex-js-public');
export interface NoticeVO {
id?: number;
content?: string | any;
publish_flag?: number;
user_id?: string | any;
notice_type?: number;
push_type?: number;
push_time?: Date | any;
del_sign?: number;
status?: number;
createdAt?: Date | any;
updatedAt?: Date | any;
}
export interface NoticePageVO extends NoticeVO {
page?: number,
size?: number
}
export async function list(noticePageVO: NoticePageVO) {
let where = Object.create(null);
if (noticePageVO.publish_flag) {
where.publish_flag = noticePageVO.publish_flag;
}
if (Number(noticePageVO.user_id) >= 0) {
where.user_id = noticePageVO.user_id;
}
if (noticePageVO.notice_type) {
where.notice_type = noticePageVO.notice_type;
}
if (noticePageVO.push_type) {
where.push_type = noticePageVO.push_type;
}
if (noticePageVO.push_time) {
let date = datetimeUtils.trim(noticePageVO.push_time, 's');
where.push_time = { [ormDB.Op.gte]: date };
}
if (!noticePageVO.del_sign) {
where.del_sign = 0;
}
if (noticePageVO.status) {
where.status = noticePageVO.status;
}
if (noticePageVO.createdAt) {
let date = datetimeUtils.trim(noticePageVO.createdAt, 's');
where.createdAt = { [ormDB.Op.gte]: date }
}
let resList = await noticeModel.prototype.findAndCount({
where: where,
limit: noticePageVO.size,
offset: (Number(noticePageVO.page) - 1) * Number(noticePageVO.size),
order: [["id", "desc"]],
raw: true
});
return resList;
}
export async function add(noticeVO: NoticeVO) {
let insertList: any = [];
if (!noticeVO.publish_flag) {
noticeVO.publish_flag = 0;
}
if (!noticeVO.push_type) {
noticeVO.push_type = 1;
}
noticeVO.del_sign = 0;
noticeVO.status = 0;
noticeVO.createdAt = new Date();
noticeVO.updatedAt = new Date();
if (!noticeVO.user_id) {
noticeVO.user_id = 0;
insertList.push(noticeVO);
}
else {//多个uid 的消息
let uids = noticeVO.user_id.split(',');
for (let oneUid of uids) {
let item = {
content: noticeVO.content,
publish_flag: noticeVO.publish_flag,
user_id: oneUid,
notice_type: noticeVO.notice_type,
push_type: noticeVO.push_type,
push_time: noticeVO.push_time,
del_sign: noticeVO.del_sign,
status: noticeVO.status,
createdAt: noticeVO.createdAt,
updatedAt: noticeVO.updatedAt,
}
insertList.push(item);
}
}
await noticeModel.prototype.bulkCreate(insertList);
return 'success'
}
export async function update(noticeVO: NoticeVO) {
let dbInfo = await noticeModel.prototype.findOne({
where: {
id: noticeVO.id
},
raw: true
});
if (!dbInfo) {
throw ErrorCode.DATA_NOT_EXIST;
}
if (dbInfo.status == 1) {
throw ErrorCode.PUSH_NOT_UPDATE;
}
let updateInfo = {};
if (noticeVO.content) {
updateInfo['content'] = noticeVO.content;
}
if (noticeVO.publish_flag) {
updateInfo['publish_flag'] = noticeVO.publish_flag;
}
if (noticeVO.notice_type) {
updateInfo['notice_type'] = noticeVO.notice_type;
}
if (noticeVO.push_type) {
updateInfo['push_type'] = noticeVO.push_type;
}
if (noticeVO.push_time) {
updateInfo['push_time'] = noticeVO.push_time;
}
if (noticeVO.del_sign) {
updateInfo['del_sign'] = noticeVO.del_sign;
}
updateInfo['updatedAt'] = new Date();
await noticeModel.prototype.update(updateInfo, {
where: {
id: Number(noticeVO.id)
}
});
return 'success'
}
......@@ -14,10 +14,12 @@ import * as aclUserCtrl from "../../mvc/control/aclUser.control";
import * as aclRoleAuthCtrl from "../../mvc/control/aclRoleAuth.control";
import * as userOptCtrl from "../../mvc/control/userOpt.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 spotPairCtrl from "../../mvc/control/spotPair.control";
import * as coinTypeCtrl from "../../mvc/control/coinType.control";
import * as noticeCtrl from "../../mvc/control/notice.control";
const getFunc = {
'user/info': userController.getUserInfo,
};
......@@ -75,6 +77,15 @@ const postFunc = {
'user/auth/change/locked/status': userAuthConfigCtrl.changeLockedStatus,
'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,
'notice/list': noticeCtrl.list,
'notice/add': noticeCtrl.add,
'notice/update': noticeCtrl.update,
};
......
......@@ -8,13 +8,16 @@ const {
let cmdWhiteList = {
'i18n/info/list': 1,
let cmdWhiteList = {'i18n/info/list': 1,
'i18n/info/add': 1,
'i18n/info/update': 1,
'i18n/info/del': 1,
'i18n/info/log/list': 1,
'i18n/info/log/revert': 1,
'spotpair/add': 1,
'spotpair/list': 1,
'coinType/add': 1,
'coinType/list': 1,
'acl/user/add': 1,
'acl/user/list': 1,
'acl/user/update': 1,
......@@ -44,6 +47,13 @@ let cmdWhiteList = {
'user/auth/change/force/status': 1,
'user/auth/change/locked/status': 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,
'notice/list': 1,
'notice/add': 1,
'notice/update': 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