Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
member-api
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
曲欣亮
member-api
Commits
7d47b305
Commit
7d47b305
authored
Aug 28, 2018
by
曲欣亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目基本完成,达到使用要求
parent
a8d6fa2e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
75 deletions
+146
-75
LanguageController.java
src/main/java/com/egolm/lang/LanguageController.java
+114
-68
ExceptionHandler.java
src/main/java/com/egolm/lang/config/ExceptionHandler.java
+3
-5
ContentArgs.java
src/main/java/com/egolm/lang/model/ContentArgs.java
+29
-0
common.js
src/main/resources/static/assets/common.js
+0
-2
No files found.
src/main/java/com/egolm/lang/LanguageController.java
View file @
7d47b305
...
@@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
...
@@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
@@ -20,6 +21,7 @@ import com.egolm.common.GsonUtil;
...
@@ -20,6 +21,7 @@ import com.egolm.common.GsonUtil;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.lang.config.XException
;
import
com.egolm.lang.config.XException
;
import
com.egolm.lang.model.ContentArgs
;
import
com.egolm.lang.service.LanguageService
;
import
com.egolm.lang.service.LanguageService
;
import
com.egolm.lang.service.TranslateService
;
import
com.egolm.lang.service.TranslateService
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
@@ -45,8 +47,8 @@ public class LanguageController {
...
@@ -45,8 +47,8 @@ public class LanguageController {
@PostMapping
(
"menus"
)
@PostMapping
(
"menus"
)
@ApiOperation
(
"查询翻译树"
)
@ApiOperation
(
"查询翻译树"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
menus
(
String
sParentLink
)
{
public
Object
menus
(
String
sParentLink
)
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
...
@@ -94,8 +96,8 @@ public class LanguageController {
...
@@ -94,8 +96,8 @@ public class LanguageController {
@PostMapping
(
"append"
)
@PostMapping
(
"append"
)
@ApiOperation
(
"增加一个翻译节点"
)
@ApiOperation
(
"增加一个翻译节点"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
append
(
String
sLink
)
{
public
Object
append
(
String
sLink
)
{
service
.
append
(
sLink
);
service
.
append
(
sLink
);
...
@@ -106,8 +108,8 @@ public class LanguageController {
...
@@ -106,8 +108,8 @@ public class LanguageController {
@PostMapping
(
"delete"
)
@PostMapping
(
"delete"
)
@ApiOperation
(
"删除一个翻译节点"
)
@ApiOperation
(
"删除一个翻译节点"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
delete
(
String
sLink
)
{
public
Object
delete
(
String
sLink
)
{
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
...
@@ -119,8 +121,8 @@ public class LanguageController {
...
@@ -119,8 +121,8 @@ public class LanguageController {
@PostMapping
(
"move"
)
@PostMapping
(
"move"
)
@ApiOperation
(
"移动一个翻译节点"
)
@ApiOperation
(
"移动一个翻译节点"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
move
(
String
sLink
,
String
sParentLink
)
{
public
Object
move
(
String
sLink
,
String
sParentLink
)
{
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
...
@@ -133,8 +135,8 @@ public class LanguageController {
...
@@ -133,8 +135,8 @@ public class LanguageController {
@PostMapping
(
"rename"
)
@PostMapping
(
"rename"
)
@ApiOperation
(
"重命名一个翻译节点"
)
@ApiOperation
(
"重命名一个翻译节点"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
rename
(
String
sLink
,
String
sNodeNO
)
{
public
Object
rename
(
String
sLink
,
String
sNodeNO
)
{
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
...
@@ -146,14 +148,17 @@ public class LanguageController {
...
@@ -146,14 +148,17 @@ public class LanguageController {
@PostMapping
(
"update"
)
@PostMapping
(
"update"
)
@ApiOperation
(
"修改翻译节点文档"
)
@ApiOperation
(
"修改翻译节点文档"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
update
(
String
sLink
,
String
sContentText
)
{
public
Object
update
(
String
sLink
,
String
sContentText
)
{
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
List
<?>
list
=
GsonUtil
.
toList
(
sContentText
);
Map
<
String
,
Object
>
contentMap
=
GsonUtil
.
toMap
(
sContentText
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
Map
<
String
,
Object
>
tmp
=
new
HashMap
<
String
,
Object
>();
String
sCaption
=
(
String
)
contentMap
.
get
(
"sCaption"
);
List
<?>
list
=
(
List
<?>)
contentMap
.
get
(
"sDocuments"
);
List
<
Map
<
String
,
String
>>
ary
=
new
ArrayList
<
Map
<
String
,
String
>>();
List
<
Map
<
String
,
String
>>
ary
=
new
ArrayList
<
Map
<
String
,
String
>>();
if
(
list
!=
null
)
{
for
(
Object
obj
:
list
)
{
for
(
Object
obj
:
list
)
{
Map
<?,
?>
docMap
=
(
Map
<?,
?>)
obj
;
Map
<?,
?>
docMap
=
(
Map
<?,
?>)
obj
;
String
sText
=
(
String
)
docMap
.
get
(
"sText"
);
String
sText
=
(
String
)
docMap
.
get
(
"sText"
);
...
@@ -168,24 +173,26 @@ public class LanguageController {
...
@@ -168,24 +173,26 @@ public class LanguageController {
ary
.
add
(
map
);
ary
.
add
(
map
);
}
}
}
}
}
tmp
.
put
(
"sDocuments"
,
ary
);
if
(
StringUtil
.
isNotBlank
(
sCaption
))
{
tmp
.
put
(
"sCaption"
,
sCaption
);
}
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
try
{
service
.
update
(
sNodeID
,
mapper
.
writerWithDefaultPrettyPrinter
().
writeValueAsString
(
ary
));
service
.
update
(
sNodeID
,
mapper
.
writerWithDefaultPrettyPrinter
().
writeValueAsString
(
tmp
));
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
throw
new
XException
(
"JSON格式错误"
,
e
);
throw
new
XException
(
"JSON格式错误"
,
e
);
}
}
return
Rjx
.
jsonOk
();
return
Rjx
.
jsonOk
();
}
else
{
return
Rjx
.
jsonErr
();
}
}
}
@ResponseBody
@ResponseBody
@PostMapping
(
"queryDetail"
)
@PostMapping
(
"queryDetail"
)
@ApiOperation
(
"查询翻译文档详情"
)
@ApiOperation
(
"查询翻译文档详情"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
})
})
public
Object
queryByLink
(
String
sLink
)
{
public
Object
queryByLink
(
String
sLink
)
{
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
...
@@ -196,23 +203,38 @@ public class LanguageController {
...
@@ -196,23 +203,38 @@ public class LanguageController {
@PostMapping
(
"getDocumentsByLink"
)
@PostMapping
(
"getDocumentsByLink"
)
@ApiOperation
(
"查询翻译文档"
)
@ApiOperation
(
"查询翻译文档"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sLink"
,
dataType
=
"string"
,
required
=
true
,
value
=
"要查询文档树的目录"
)
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sLink"
,
dataType
=
"string"
,
required
=
true
,
value
=
"要查询文档树的目录"
)
})
})
public
Object
getDocumentsByLink
(
String
sLink
)
{
public
Object
getDocumentsByLink
(
String
sLink
)
{
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
);
Map
<
String
,
Object
>
map
=
service
.
getNodeMapByID
(
sNodeID
);
Map
<
String
,
Object
>
map
=
service
.
getNodeMapByID
(
sNodeID
);
String
sContentText
=
(
String
)
map
.
get
(
"sContentText"
);
String
sContentText
=
(
String
)
map
.
get
(
"sContentText"
);
return
Rjx
.
jsonOk
().
setData
(
GsonUtil
.
toList
(
sContentText
));
Map
<
String
,
Object
>
contentMap
=
GsonUtil
.
toMap
(
sContentText
);
List
<?>
ary
=
(
List
<?>)
contentMap
.
get
(
"sDocuments"
);
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
if
(
ary
!=
null
&&
ary
.
size
()
>
0
)
{
for
(
Object
obj
:
ary
)
{
Map
<?,
?>
objMap
=
(
Map
<?,
?>)
obj
;
String
sText
=
(
String
)
objMap
.
get
(
"sText"
);
String
sTarget
=
(
String
)
objMap
.
get
(
"sTarget"
);
result
.
put
(
sText
,
sTarget
);
}
}
String
sCaption
=
(
String
)
contentMap
.
get
(
"sCaption"
);
if
(
StringUtil
.
isNotBlank
(
sCaption
))
{
result
.
put
(
"Caption"
,
sCaption
);
}
return
Rjx
.
jsonOk
().
setData
(
result
);
}
}
@ResponseBody
@ResponseBody
@PostMapping
(
"getTreeByLink"
)
@PostMapping
(
"getTreeByLink"
)
@ApiOperation
(
"查询翻译文档树"
)
@ApiOperation
(
"查询翻译文档树"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"
query
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"
header
"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sTopLink"
,
dataType
=
"string"
,
required
=
true
,
value
=
"要查询文档树的根[最上层]目录"
)
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sTopLink"
,
dataType
=
"string"
,
required
=
true
,
value
=
"要查询文档树的根[最上层]目录"
)
})
})
public
Object
getTreeByLink
(
String
sTopLink
)
{
public
Object
getTreeByLink
(
String
sTopLink
)
{
...
@@ -234,7 +256,8 @@ public class LanguageController {
...
@@ -234,7 +256,8 @@ public class LanguageController {
String
sNodeNO
=
(
String
)
nodeMap
.
get
(
"sNodeNO"
);
String
sNodeNO
=
(
String
)
nodeMap
.
get
(
"sNodeNO"
);
if
((
sParentID_
==
null
&&
sParentID
==
null
)
||
(
sParentID_
!=
null
&&
sParentID
!=
null
&&
sParentID
.
equals
(
sParentID_
)))
{
if
((
sParentID_
==
null
&&
sParentID
==
null
)
||
(
sParentID_
!=
null
&&
sParentID
!=
null
&&
sParentID
.
equals
(
sParentID_
)))
{
String
sContentText
=
(
String
)
nodeMap
.
get
(
"sContentText"
);
String
sContentText
=
(
String
)
nodeMap
.
get
(
"sContentText"
);
List
<?>
ary
=
GsonUtil
.
toList
(
sContentText
);
Map
<
String
,
Object
>
contentMap
=
GsonUtil
.
toMap
(
sContentText
);
List
<?>
ary
=
(
List
<?>)
contentMap
.
get
(
"sDocuments"
);
Map
<
String
,
Object
>
cmap
=
this
.
toDoc
(
list
,
sNodeID
);
Map
<
String
,
Object
>
cmap
=
this
.
toDoc
(
list
,
sNodeID
);
if
(
ary
!=
null
&&
ary
.
size
()
>
0
)
{
if
(
ary
!=
null
&&
ary
.
size
()
>
0
)
{
for
(
Object
obj
:
ary
)
{
for
(
Object
obj
:
ary
)
{
...
@@ -244,6 +267,10 @@ public class LanguageController {
...
@@ -244,6 +267,10 @@ public class LanguageController {
cmap
.
put
(
sText
,
sTarget
);
cmap
.
put
(
sText
,
sTarget
);
}
}
}
}
String
sCaption
=
(
String
)
contentMap
.
get
(
"sCaption"
);
if
(
StringUtil
.
isNotBlank
(
sCaption
))
{
cmap
.
put
(
"Caption"
,
sCaption
);
}
node
.
put
(
sNodeNO
,
cmap
);
node
.
put
(
sNodeNO
,
cmap
);
}
}
}
}
...
@@ -254,58 +281,77 @@ public class LanguageController {
...
@@ -254,58 +281,77 @@ public class LanguageController {
@PostMapping
(
"translate"
)
@PostMapping
(
"translate"
)
@ApiOperation
(
"翻译文档"
)
@ApiOperation
(
"翻译文档"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sDocument"
,
dataType
=
"string"
,
required
=
true
,
value
=
"翻译文档对象[JSON]结构"
)
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sLink"
,
dataType
=
"string"
,
required
=
true
,
value
=
"sLink"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"sDocuments"
,
dataType
=
"string"
,
required
=
true
,
value
=
"翻译文档数组"
,
allowMultiple
=
true
)
})
})
public
Object
translate
(
String
sLink
,
String
sDocument
)
{
public
Object
translate
(
String
sLink
,
String
[]
sDocuments
,
String
sCaption
)
{
List
<
Map
<
String
,
String
>>
tmp
=
new
ArrayList
<
Map
<
String
,
String
>>();
for
(
String
doc
:
sDocuments
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"sText"
,
doc
);
tmp
.
add
(
map
);
}
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
,
true
);
String
sNodeID
=
service
.
getNodeIDByLink
(
sLink
,
true
);
Map
<
String
,
Object
>
nodeMap
=
service
.
getNodeMapByID
(
sNodeID
);
Map
<
String
,
Object
>
nodeMap
=
service
.
getNodeMapByID
(
sNodeID
);
String
sContentText
=
(
String
)
nodeMap
.
get
(
"sContentText"
);
String
sContentText
=
(
String
)
nodeMap
.
get
(
"sContentText"
);
List
<?>
list
=
GsonUtil
.
toList
(
sContentText
);
Map
<
String
,
Object
>
textMap
=
GsonUtil
.
toMap
(
sContentText
);
String
dst
=
null
;
String
caption
=
(
String
)
textMap
.
get
(
"sCaption"
);
List
<?>
list
=
(
List
<?>)
textMap
.
get
(
"sDocuments"
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
Object
obj
:
list
)
{
for
(
Object
obj
:
list
)
{
Map
<?,
?>
map
=
(
Map
<?,
?>)
obj
;
Map
<?,
?>
objMap
=
(
Map
<?,
?>)
obj
;
String
sText
=
(
String
)
map
.
get
(
"sText"
);
String
sText
=
(
String
)
objMap
.
get
(
"sText"
);
String
sTarget
=
(
String
)
map
.
get
(
"sTarget"
);
String
sTarget
=
(
String
)
objMap
.
get
(
"sTarget"
);
if
(
sDocument
.
equals
(
sText
)
&&
StringUtil
.
isNotBlank
(
sTarget
))
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
dst
=
sTarget
;
map
.
put
(
"sText"
,
sText
);
map
.
put
(
"sTarget"
,
sTarget
);
tmp
.
add
(
map
);
}
}
}
}
boolean
isUpdate
=
false
;
for
(
Map
<
String
,
String
>
map
:
tmp
)
{
String
sText
=
map
.
get
(
"sText"
);
String
sTarget
=
map
.
get
(
"sTarget"
);
if
(
StringUtil
.
isBlank
(
sTarget
))
{
isUpdate
=
true
;
map
.
put
(
"sTarget"
,
translate
.
st
(
sText
,
"auto"
,
"en"
));
}
}
if
(
StringUtil
.
isBlank
(
dst
))
{
dst
=
translate
.
st
(
sDocument
,
"auto"
,
"en"
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"sText"
,
sDocument
);
map
.
put
(
"sTarget"
,
dst
);
List
<
Object
>
tmp
=
new
ArrayList
<
Object
>();
if
(
list
!=
null
)
{
tmp
.
addAll
(
list
);
}
}
tmp
.
add
(
map
);
if
(
StringUtil
.
isBlank
(
caption
)
&&
StringUtil
.
isNotBlank
(
sCaption
))
{
isUpdate
=
true
;
caption
=
sCaption
;
}
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"sCaption"
,
caption
);
map
.
put
(
"sDocuments"
,
tmp
);
if
(
isUpdate
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
try
{
service
.
update
(
sNodeID
,
mapper
.
writerWithDefaultPrettyPrinter
().
writeValueAsString
(
tm
p
));
service
.
update
(
sNodeID
,
mapper
.
writerWithDefaultPrettyPrinter
().
writeValueAsString
(
ma
p
));
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
throw
new
XException
(
"JSON格式错误"
,
e
);
throw
new
XException
(
"JSON格式错误"
,
e
);
}
}
}
}
return
Rjx
.
jsonOk
().
setData
(
dst
);
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
result
.
put
(
"caption"
,
caption
);
for
(
Map
<
String
,
String
>
m
:
tmp
)
{
result
.
put
(
m
.
get
(
"sText"
),
m
.
get
(
"sTarget"
));
}
return
Rjx
.
jsonOk
().
setData
(
result
);
}
}
// @ResponseBody
@ResponseBody
// @PostMapping("translate")
@PostMapping
(
"translateByJson"
)
// @ApiOperation("翻译文档")
@ApiOperation
(
"翻译文档"
)
// @ApiImplicitParams({
@ApiImplicitParams
({
// @ApiImplicitParam(paramType = "query", name = "appid", dataType = "string", required = false, value = "appid"),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"appid"
,
dataType
=
"string"
,
required
=
false
,
value
=
"appid"
),
// @ApiImplicitParam(paramType = "query", name = "sig", dataType = "string", required = false, value = "sig"),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"sig"
,
dataType
=
"string"
,
required
=
false
,
value
=
"sig"
)
// })
})
// public Object translate(String sLink, String json) {
public
Object
translate
(
@RequestBody
ContentArgs
content
)
{
// String sNodeID = service.getNodeIDByLink(sLink, true);
return
this
.
translate
(
content
.
getsLink
(),
content
.
getsDocuments
(),
content
.
getsCaption
());
//
}
// return Rjx.jsonOk();
// }
public
LanguageService
getService
()
{
public
LanguageService
getService
()
{
return
service
;
return
service
;
...
...
src/main/java/com/egolm/lang/config/ExceptionHandler.java
View file @
7d47b305
...
@@ -3,8 +3,7 @@ package com.egolm.lang.config;
...
@@ -3,8 +3,7 @@ package com.egolm.lang.config;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.logging.Log
;
import
org.apache.log4j.Logger
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
...
@@ -15,10 +14,11 @@ import com.egolm.common.bean.Rjx;
...
@@ -15,10 +14,11 @@ import com.egolm.common.bean.Rjx;
@Component
@Component
public
class
ExceptionHandler
implements
HandlerExceptionResolver
{
public
class
ExceptionHandler
implements
HandlerExceptionResolver
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ExceptionHandler
.
class
);
private
Logger
logger
=
Logger
.
getLogger
(
ExceptionHandler
.
class
);
@Override
@Override
public
ModelAndView
resolveException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
{
public
ModelAndView
resolveException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
{
logger
.
error
(
""
,
ex
);
ModelAndView
mav
=
new
ModelAndView
(
new
MappingJackson2JsonView
());
ModelAndView
mav
=
new
ModelAndView
(
new
MappingJackson2JsonView
());
try
{
try
{
response
.
setContentType
(
"application/json"
);
response
.
setContentType
(
"application/json"
);
...
@@ -29,8 +29,6 @@ public class ExceptionHandler implements HandlerExceptionResolver {
...
@@ -29,8 +29,6 @@ public class ExceptionHandler implements HandlerExceptionResolver {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
mav
.
addAllObjects
(
Rjx
.
jsonErr
().
setMessage
(
"异常处理失败"
));
mav
.
addAllObjects
(
Rjx
.
jsonErr
().
setMessage
(
"异常处理失败"
));
}
finally
{
logger
.
error
(
""
,
ex
);
}
}
return
mav
;
return
mav
;
}
}
...
...
src/main/java/com/egolm/lang/model/ContentArgs.java
0 → 100644
View file @
7d47b305
package
com
.
egolm
.
lang
.
model
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
@ApiModel
public
class
ContentArgs
{
@ApiModelProperty
(
"翻译节点目录"
)
private
String
sLink
;
@ApiModelProperty
(
"sCaption"
)
private
String
sCaption
;
@ApiModelProperty
(
"要翻译的文档"
)
private
String
[]
sDocuments
;
public
String
getsLink
()
{
return
sLink
;
}
public
String
getsCaption
()
{
return
sCaption
;
}
public
String
[]
getsDocuments
()
{
return
sDocuments
;
}
}
\ No newline at end of file
src/main/resources/static/assets/common.js
View file @
7d47b305
...
@@ -48,8 +48,6 @@ $(document).ajaxSuccess(function(event, xhr, options) {
...
@@ -48,8 +48,6 @@ $(document).ajaxSuccess(function(event, xhr, options) {
var
message
=
xhr
.
responseJSON
.
message
;
var
message
=
xhr
.
responseJSON
.
message
;
if
(
code
==
300
)
{
if
(
code
==
300
)
{
window
.
location
.
href
=
"/lang/login.html"
;
window
.
location
.
href
=
"/lang/login.html"
;
}
else
if
(
code
==
500
&&
message
)
{
alert
(
message
);
}
}
}
}
});
});
\ No newline at end of file
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