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
8593e6dc
Commit
8593e6dc
authored
Nov 29, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
国际化新接口
parent
aacb2918
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
339 additions
and
260 deletions
+339
-260
i18n.control.ts
src/functional/mvc/control/i18n.control.ts
+10
-27
i18nlog.control.ts
src/functional/mvc/control/i18nlog.control.ts
+1
-2
i18n.service.ts
src/functional/mvc/service/i18n.service.ts
+238
-153
i18nlog.service.ts
src/functional/mvc/service/i18nlog.service.ts
+80
-68
index.ts
src/functional/router/v1/index.ts
+6
-6
access-limit.ts
src/setting/access-limit.ts
+4
-4
No files found.
src/functional/mvc/control/i18n.control.ts
View file @
8593e6dc
...
...
@@ -27,7 +27,7 @@ export const list = async (req: any, infoPageVO: I18nInfoPageVO) => {
}
};
/**
* 添加国际化信息
* 添加国际化信息
-发布版本
* @param req
* @param infoVO
*/
...
...
@@ -35,7 +35,6 @@ export const add = async (req: any, infoVO: I18nInfoVO) => {
let
func_name
=
"i18nCtrl.add"
;
let
cmd
=
req
.
path
;
try
{
await
preCheck
(
infoVO
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
res
=
await
i18nService
.
add
(
infoVO
,
currentUserId
,
ip
);
...
...
@@ -46,19 +45,19 @@ export const add = async (req: any, infoVO: I18nInfoVO) => {
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
*
修改国际化信息
*
添加国际化信息-发布版本-预览
* @param req
* @param infoVO
*/
export
const
update
=
async
(
req
:
any
,
infoVO
:
I18nInfoVO
)
=>
{
let
func_name
=
"i18nCtrl.
update
"
;
export
const
preview
=
async
(
req
:
any
,
infoVO
:
I18nInfoVO
)
=>
{
let
func_name
=
"i18nCtrl.
preview
"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
infoVO
.
id
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
res
=
await
i18nService
.
update
(
infoVO
,
currentUserId
,
ip
);
let
res
=
await
i18nService
.
preview
(
infoVO
,
currentUserId
,
ip
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
...
...
@@ -67,18 +66,15 @@ export const update = async (req: any, infoVO: I18nInfoVO) => {
}
};
/**
*
删除国际化信息
*
国际化信息版本列表
* @param req
* @param infoVO
*/
export
const
del
=
async
(
req
:
any
,
infoVO
:
I18nInfoVO
)
=>
{
let
func_name
=
"i18nCtrl.
del
"
;
export
const
versionList
=
async
(
req
:
any
,
infoVO
:
I18nInfoVO
)
=>
{
let
func_name
=
"i18nCtrl.
versionList
"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
infoVO
.
id
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
res
=
await
i18nService
.
del
(
infoVO
,
currentUserId
,
ip
);
let
res
=
await
i18nService
.
versionList
();
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
...
...
@@ -88,16 +84,3 @@ export const del = async (req: any, infoVO: I18nInfoVO) => {
};
/**
* 校验
* @param infoVO
*/
async
function
preCheck
(
infoVO
:
I18nInfoVO
)
{
if
(
!
[
1
,
2
,
3
,
4
,
5
].
includes
(
infoVO
.
platform
))
{
throw
ErrorCode
.
PARAM_MISS
;
}
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
infoVO
.
module
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
infoVO
.
code
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
infoVO
.
lang
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
infoVO
.
content
);
}
\ No newline at end of file
src/functional/mvc/control/i18nlog.control.ts
View file @
8593e6dc
...
...
@@ -36,8 +36,7 @@ export const revert = async (req: any, i18nInfoLogVO: I18nInfoLogVO) => {
try
{
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
i18nInfoLogVO
.
id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
i18nInfoLogVO
.
info_id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
i18nInfoLogVO
.
version
);
let
res
=
await
i18nLogService
.
revert
(
i18nInfoLogVO
,
currentUserId
,
ip
);
return
Res3Utils
.
result
(
res
);
}
...
...
src/functional/mvc/service/i18n.service.ts
View file @
8593e6dc
This diff is collapsed.
Click to expand it.
src/functional/mvc/service/i18nlog.service.ts
View file @
8593e6dc
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
i18nInfo
,
i18nInfo
Log
,
ormDB
}
from
"@madex/ex-ts-dao"
;
import
{
i18nInfo
,
i18nInfo
History
,
ormDB
}
from
"@madex/ex-ts-dao"
;
import
*
as
i18nService
from
"./i18n.service"
;
import
{
I18nInfoPageVO
,
I18nInfoVO
}
from
"./i18n.service"
;
import
{
getLastVersionList
,
I18nInfoPageVO
,
I18nInfoVO
}
from
"./i18n.service"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
import
{
ROBOT_KEYS
,
sendRobotMessage
}
from
"../../../utils/robotUtils"
;
let
{
logger
}
=
require
(
'@madex/ex-js-public'
);
export
interface
I18nInfoLogVO
extends
I18nInfoPageVO
{
info_id
?:
number
;
version
:
string
;
}
export
async
function
list
(
i18nInfoLogVO
:
I18nInfoLogVO
)
{
if
(
i18nInfoLogVO
.
code
)
{
i18nInfoLogVO
.
code
=
{
[
ormDB
.
Op
.
like
]:
`
${
i18nInfoLogVO
.
code
}
%`
}
;
let
condition
=
{};
if
(
i18nInfoLogVO
.
platform
)
{
condition
[
'platform'
]
=
Number
(
i18nInfoLogVO
.
platform
)
;
}
if
(
i18nInfoLogVO
.
sub_code
)
{
i18nInfoLogVO
.
sub_code
=
{
[
ormDB
.
Op
.
like
]:
`
${
i18nInfoLogVO
.
sub_code
}
%`
};
if
(
i18nInfoLogVO
.
module
)
{
condition
[
'module'
]
=
Number
(
i18nInfoLogVO
.
module
);
}
if
(
i18nInfoLogVO
.
desc
)
{
i18nInfoLogVO
.
desc
=
{
[
ormDB
.
Op
.
like
]:
`
${
i18nInfoLogVO
.
desc
}
%`
}
;
if
(
i18nInfoLogVO
.
code
)
{
condition
[
'code'
]
=
i18nInfoLogVO
.
code
;
}
if
(
i18nInfoLogVO
.
updatedAt
)
{
i18nInfoLogVO
.
updatedAt
=
{
[
ormDB
.
Op
.
gte
]:
new
Date
(
i18nInfoLogVO
.
updatedAt
).
getTime
()
};
if
(
i18nInfoLogVO
.
zh_cn
)
{
condition
[
'zh_cn'
]
=
{
[
ormDB
.
Op
.
like
]:
`
${
i18nInfoLogVO
.
zh_cn
}
%`
};
}
let
page
=
Number
(
i18nInfoLogVO
.
page
);
let
size
=
Number
(
i18nInfoLogVO
.
size
);
let
where
=
Object
.
assign
(
i18nInfoLogVO
);
delete
i18nInfoLogVO
.
page
;
delete
i18nInfoLogVO
.
size
;
let
resList
=
await
i18nInfoLog
.
prototype
.
findAndCount
({
where
:
where
,
let
resList
=
await
i18nInfoHistory
.
prototype
.
findAndCount
({
where
:
condition
,
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"
updatedAt"
,
"de
sc"
]],
order
:
[[
"
id"
,
"a
sc"
]],
raw
:
true
});
return
resList
;
}
export
const
add
=
async
(
infoLogVO
:
any
,
tx
:
any
)
=>
{
if
(
!
infoLogVO
.
createdAt
)
{
infoLogVO
.
createdAt
=
new
Date
();
}
if
(
!
infoLogVO
.
updatedAt
)
{
infoLogVO
.
updatedAt
=
new
Date
();
}
await
i18nInfoLog
.
prototype
.
create
(
infoLogVO
,
{
transaction
:
tx
,
});
};
export
async
function
revert
(
i18nInfoLogVO
:
I18nInfoLogVO
,
currentUserId
:
any
,
ip
:
any
)
{
let
dbOneI18nInfoLog
=
await
i18nInfoLog
.
prototype
.
findOne
({
raw
:
true
,
let
dbHistoryList
=
await
i18nInfoHistory
.
prototype
.
findAll
({
where
:
{
id
:
i18nInfoLogVO
.
id
}
});
if
(
!
dbOneI18nInfoLog
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
let
infoId
=
dbOneI18nInfoLog
.
info_id
;
let
dbOneI18nInfo
=
await
i18nInfo
.
prototype
.
findOne
({
version
:
i18nInfoLogVO
.
version
},
order
:
[[
'info_id'
,
'asc'
]],
raw
:
true
,
where
:
{
id
:
infoId
}
});
let
itemInfo
=
{
platform
:
dbOneI18nInfoLog
.
platform
,
module
:
dbOneI18nInfoLog
.
module
,
code
:
dbOneI18nInfoLog
.
code
,
sub_code
:
dbOneI18nInfoLog
.
sub_code
,
lang
:
dbOneI18nInfoLog
.
lang
,
desc
:
dbOneI18nInfoLog
.
desc
,
content
:
dbOneI18nInfoLog
.
content
,
createdAt
:
dbOneI18nInfoLog
.
createdAt
,
updatedAt
:
dbOneI18nInfoLog
.
updatedAt
,
let
insertInfoList
:
any
=
[];
let
insertHistoryList
:
any
=
[];
for
(
let
item
of
dbHistoryList
)
{
delete
item
.
info_id
;
delete
item
.
id
;
insertInfoList
.
push
(
item
);
}
if
(
!
dbOneI18nInfo
)
{
await
i18nService
.
add
(
itemInfo
,
currentUserId
,
ip
);
let
currentVersionList
=
await
getLastVersionList
();
let
current_version
=
""
;
for
(
let
item
of
currentVersionList
)
{
current_version
=
item
.
version
;
let
info_id
=
item
.
id
;
item
.
info_id
=
info_id
;
item
.
created_at
=
item
.
updated_at
;
delete
item
.
id
;
insertHistoryList
.
push
(
item
)
}
else
{
delete
itemInfo
.
createdAt
;
await
i18nInfo
.
prototype
.
update
(
itemInfo
,
{
where
:
{
id
:
infoId
}
});
let
tx
;
try
{
tx
=
await
ormDB
.
transaction
();
if
(
insertInfoList
.
length
)
{
//删除历史版本
await
i18nInfoHistory
.
prototype
.
destroy
({
where
:
{
version
:
i18nInfoLogVO
.
version
},
transaction
:
tx
});
//删除当前版本
await
i18nInfo
.
prototype
.
destroy
({
where
:
{},
transaction
:
tx
});
//当前版本存入历史
await
i18nInfoHistory
.
prototype
.
bulkCreate
(
insertHistoryList
,
{
transaction
:
tx
});
//恢复到传入的历史版本
await
i18nInfo
.
prototype
.
bulkCreate
(
insertInfoList
);
}
await
tx
.
commit
();
}
await
i18nInfoLog
.
prototype
.
destroy
(
{
where
:
{
id
:
Number
(
i18nInfoLogVO
.
id
)
catch
(
e
)
{
if
(
tx
)
{
await
tx
.
rollback
();
}
});
return
'ok'
;
logger
.
error
(
'i18nInfo.add.error:'
+
e
);
throw
e
;
}
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'国际化信息版本回退'
,
ip
,
`当前版本:
${
current_version
}
,回退到:
${
i18nInfoLogVO
.
version
}
`
,
'国际化管理'
);
sendRobotMessage
(
ROBOT_KEYS
.
COMMON_KEY
,
`国际化信息版本回退:当前版本:
${
current_version
}
,回退到:
${
i18nInfoLogVO
.
version
}
`
);
return
'success'
;
}
\ No newline at end of file
src/functional/router/v1/index.ts
View file @
8593e6dc
...
...
@@ -55,12 +55,12 @@ const getFunc = {
const
postFunc
=
{
//技术部-其他管理-国际化管理
'i18n/info/list'
:
i18nCtrl
.
list
,
'i18n/info/add'
:
i18nCtrl
.
add
,
'i18n/info/
update'
:
i18nCtrl
.
update
,
'i18n/info/
del'
:
i18nCtrl
.
del
,
'i18n/info/
log/list'
:
i18nLogCtrl
.
list
,
'i18n/info/
log/revert'
:
i18nLogCtrl
.
revert
,
'i18n/info/list'
:
i18nCtrl
.
list
,
//当前版本信息列表
'i18n/info/add'
:
i18nCtrl
.
add
,
//发布版本
'i18n/info/
preview'
:
i18nCtrl
.
preview
,
//发布版本-预览
'i18n/info/
version/list'
:
i18nCtrl
.
versionList
,
//版本列表
'i18n/info/
history/list'
:
i18nLogCtrl
.
list
,
//历史版本信息列表
'i18n/info/
history/revert'
:
i18nLogCtrl
.
revert
,
//版本回退
//金融部-交易管理-交易对配置
'spotPair/save'
:
spotPairCtrl
.
save
,
//新增
'spotPair/update'
:
spotPairCtrl
.
update
,
//修改
...
...
src/setting/access-limit.ts
View file @
8593e6dc
...
...
@@ -12,10 +12,10 @@ 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
,
'i18n/info/
preview
'
:
1
,
'i18n/info/
version/list
'
:
1
,
'i18n/info/
history
/list'
:
1
,
'i18n/info/
history
/revert'
:
1
,
//金融部-交易管理-交易对配置
'spotPair/save'
:
1
,
'spotPair/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