Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
c136b23b
Commit
c136b23b
authored
Aug 22, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息通知
parent
ab6e8c30
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
249 additions
and
2 deletions
+249
-2
errorCode.ts
src/constant/errorCode.ts
+1
-0
notice.control.ts
src/functional/mvc/control/notice.control.ts
+65
-0
notice.service.ts
src/functional/mvc/service/notice.service.ts
+170
-0
index.ts
src/functional/router/v1/index.ts
+5
-0
access-limit.ts
src/setting/access-limit.ts
+8
-2
No files found.
src/constant/errorCode.ts
View file @
c136b23b
...
@@ -24,5 +24,6 @@ export const ErrorCode = {
...
@@ -24,5 +24,6 @@ export const ErrorCode = {
TOTP_KEY_OVERSTAYED
:
'30022'
,
//密钥已失效,请重新获取
TOTP_KEY_OVERSTAYED
:
'30022'
,
//密钥已失效,请重新获取
USER_TYPE_ILLEGAL
:
'30023'
,
//用户类型不合法
USER_TYPE_ILLEGAL
:
'30023'
,
//用户类型不合法
NEED_INPUT_GOOGLE_CODE
:
'30024'
,
//请输入Google验证码
NEED_INPUT_GOOGLE_CODE
:
'30024'
,
//请输入Google验证码
PUSH_NOT_UPDATE
:
'30025'
,
//已经推送不允许修改
}
}
src/functional/mvc/control/notice.control.ts
0 → 100644
View file @
c136b23b
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
);
}
};
src/functional/mvc/service/notice.service.ts
0 → 100644
View file @
c136b23b
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'
}
src/functional/router/v1/index.ts
View file @
c136b23b
...
@@ -19,6 +19,7 @@ import * as ReqUtils from "../../../utils/req-utils";
...
@@ -19,6 +19,7 @@ import * as ReqUtils from "../../../utils/req-utils";
import
*
as
spotPairCtrl
from
"../../mvc/control/spotPair.control"
;
import
*
as
spotPairCtrl
from
"../../mvc/control/spotPair.control"
;
import
*
as
coinTypeCtrl
from
"../../mvc/control/coinType.control"
;
import
*
as
coinTypeCtrl
from
"../../mvc/control/coinType.control"
;
import
*
as
noticeCtrl
from
"../../mvc/control/notice.control"
;
const
getFunc
=
{
const
getFunc
=
{
'user/info'
:
userController
.
getUserInfo
,
'user/info'
:
userController
.
getUserInfo
,
};
};
...
@@ -78,6 +79,10 @@ const postFunc = {
...
@@ -78,6 +79,10 @@ const postFunc = {
'hot/pair/config/update'
:
hotPairConfigCtrl
.
update
,
'hot/pair/config/update'
:
hotPairConfigCtrl
.
update
,
'hot/pair/config/del'
:
hotPairConfigCtrl
.
del
,
'hot/pair/config/del'
:
hotPairConfigCtrl
.
del
,
'notice/list'
:
noticeCtrl
.
list
,
'notice/add'
:
noticeCtrl
.
add
,
'notice/update'
:
noticeCtrl
.
update
,
};
};
...
...
src/setting/access-limit.ts
View file @
c136b23b
...
@@ -8,13 +8,16 @@ const {
...
@@ -8,13 +8,16 @@ const {
let
cmdWhiteList
=
{
let
cmdWhiteList
=
{
'i18n/info/list'
:
1
,
'i18n/info/list'
:
1
,
'i18n/info/add'
:
1
,
'i18n/info/add'
:
1
,
'i18n/info/update'
:
1
,
'i18n/info/update'
:
1
,
'i18n/info/del'
:
1
,
'i18n/info/del'
:
1
,
'i18n/info/log/list'
:
1
,
'i18n/info/log/list'
:
1
,
'i18n/info/log/revert'
:
1
,
'i18n/info/log/revert'
:
1
,
'spotpair/add'
:
1
,
'spotpair/list'
:
1
,
'coinType/add'
:
1
,
'coinType/list'
:
1
,
'acl/user/add'
:
1
,
'acl/user/add'
:
1
,
'acl/user/list'
:
1
,
'acl/user/list'
:
1
,
'acl/user/update'
:
1
,
'acl/user/update'
:
1
,
...
@@ -48,6 +51,9 @@ let cmdWhiteList = {
...
@@ -48,6 +51,9 @@ let cmdWhiteList = {
'hot/pair/config/add'
:
1
,
'hot/pair/config/add'
:
1
,
'hot/pair/config/update'
:
1
,
'hot/pair/config/update'
:
1
,
'hot/pair/config/del'
:
1
,
'hot/pair/config/del'
:
1
,
'notice/list'
:
1
,
'notice/add'
:
1
,
'notice/update'
:
1
,
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment