Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
石磊
/
cihai
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8a9d7222
authored
Jan 15, 2018
by
侯昆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
关联词页面整合
1 parent
8550ec52
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
13 deletions
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/HomeController.java
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/WordController.java
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/WordHtmlController.java
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/dto/WordDTO.java
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/vo/CharacterBaikeVO.java
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/vo/StatementBaikeVO.java
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/HomeController.java
View file @
8a9d722
...
@@ -27,11 +27,14 @@ import com.dookay.cihai.core.word.dto.RecommendStatementDTO;
...
@@ -27,11 +27,14 @@ import com.dookay.cihai.core.word.dto.RecommendStatementDTO;
import
com.dookay.cihai.core.word.query.CustomDictionaryQuery
;
import
com.dookay.cihai.core.word.query.CustomDictionaryQuery
;
import
com.dookay.cihai.core.word.query.WordQuery
;
import
com.dookay.cihai.core.word.query.WordQuery
;
import
com.dookay.cihai.core.word.service.ICustomDictionaryService
;
import
com.dookay.cihai.core.word.service.ICustomDictionaryService
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
import
com.dookay.cihai.core.word.service.IWordService
;
import
com.dookay.cihai.core.word.service.IWordService
;
import
com.dookay.coral.common.core.utils.lang.StringUtils
;
import
com.dookay.coral.common.core.utils.lang.StringUtils
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
com.dookay.coral.common.web.response.JsonResult
;
import
com.dookay.coral.common.web.response.JsonResult
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.MimeTypeUtils
;
import
org.springframework.util.MimeTypeUtils
;
...
@@ -57,6 +60,8 @@ public class HomeController extends BaseController {
...
@@ -57,6 +60,8 @@ public class HomeController extends BaseController {
@Autowired
@Autowired
private
IWordService
wordService
;
private
IWordService
wordService
;
@Autowired
@Autowired
private
IWordRelationService
wordRelationService
;
@Autowired
private
ICustomDictionaryService
customDictionaryService
;
private
ICustomDictionaryService
customDictionaryService
;
@Autowired
@Autowired
private
AipWordUtilBean
aipWordUtilBean
;
private
AipWordUtilBean
aipWordUtilBean
;
...
@@ -98,9 +103,9 @@ public class HomeController extends BaseController {
...
@@ -98,9 +103,9 @@ public class HomeController extends BaseController {
wordQuery
.
setKeyword
(
null
);
wordQuery
.
setKeyword
(
null
);
wordDomain
=
wordService
.
getFirst
(
wordQuery
);
wordDomain
=
wordService
.
getFirst
(
wordQuery
);
if
(
wordDomain
==
null
)
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
if
(
wordDomain
==
null
)
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
return
successResult
(
"搜索结果"
,
WordDTO
.
fromDomain
(
wordDomain
));
return
successResult
(
"搜索结果"
,
WordDTO
.
fromDomain
(
wordDomain
,
wordRelationService
));
}
}
return
successResult
(
"success"
,
WordDTO
.
fromDomain
(
wordDomain
));
return
successResult
(
"success"
,
WordDTO
.
fromDomain
(
wordDomain
,
wordRelationService
));
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
return
errorResult
(
String
.
format
(
"暂无\"%s\"检索结果"
,
keyword
));
}
}
...
@@ -135,7 +140,7 @@ public class HomeController extends BaseController {
...
@@ -135,7 +140,7 @@ public class HomeController extends BaseController {
wordDomain
=
wordService
.
getFirst
(
wordQuery
);
wordDomain
=
wordService
.
getFirst
(
wordQuery
);
if
(
wordDomain
==
null
)
return
errorResult
(
"暂无检索结果"
);
if
(
wordDomain
==
null
)
return
errorResult
(
"暂无检索结果"
);
}
}
return
successResult
(
"搜索结果"
,
WordDTO
.
fromDomain
(
wordDomain
));
return
successResult
(
"搜索结果"
,
WordDTO
.
fromDomain
(
wordDomain
,
wordRelationService
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
errorResult
(
"暂无检索结果"
);
return
errorResult
(
"暂无检索结果"
);
}
}
...
...
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/WordController.java
View file @
8a9d722
...
@@ -15,7 +15,6 @@ package com.dookay.cihai.app.controller;
...
@@ -15,7 +15,6 @@ package com.dookay.cihai.app.controller;
****************************************/
****************************************/
import
com.dookay.cihai.app.controller.dto.WordDTO
;
import
com.dookay.cihai.app.controller.dto.WordDTO
;
import
com.dookay.cihai.app.controller.vo.RelateWordsVO
;
import
com.dookay.cihai.app.controller.vo.WordPicsVO
;
import
com.dookay.cihai.app.controller.vo.WordPicsVO
;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
...
@@ -34,7 +33,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -34,7 +33,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* 词语控制器
* 词语控制器
...
@@ -49,6 +47,8 @@ public class WordController extends BaseController {
...
@@ -49,6 +47,8 @@ public class WordController extends BaseController {
@Autowired
@Autowired
private
IWordService
wordService
;
private
IWordService
wordService
;
@Autowired
private
IWordRelationService
wordRelationService
;
/**
/**
* 词信息
* 词信息
...
@@ -60,7 +60,7 @@ public class WordController extends BaseController {
...
@@ -60,7 +60,7 @@ public class WordController extends BaseController {
@ApiOperation
(
value
=
"词信息"
,
httpMethod
=
"GET"
,
response
=
WordDTO
.
class
)
@ApiOperation
(
value
=
"词信息"
,
httpMethod
=
"GET"
,
response
=
WordDTO
.
class
)
public
JsonResult
info
(
@PathVariable
@ApiParam
(
value
=
"词的id"
,
required
=
true
)
Long
id
)
{
public
JsonResult
info
(
@PathVariable
@ApiParam
(
value
=
"词的id"
,
required
=
true
)
Long
id
)
{
WordDomain
wordDomain
=
wordService
.
get
(
id
);
WordDomain
wordDomain
=
wordService
.
get
(
id
);
return
successResult
(
"词信息"
,
WordDTO
.
fromDomain
(
wordDomain
));
return
successResult
(
"词信息"
,
WordDTO
.
fromDomain
(
wordDomain
,
wordRelationService
));
}
}
/**
/**
...
...
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/WordHtmlController.java
View file @
8a9d722
...
@@ -20,7 +20,6 @@ import com.dookay.cihai.app.controller.vo.CharacterParaphVO;
...
@@ -20,7 +20,6 @@ import com.dookay.cihai.app.controller.vo.CharacterParaphVO;
import
com.dookay.cihai.app.controller.vo.StatementBaikeVO
;
import
com.dookay.cihai.app.controller.vo.StatementBaikeVO
;
import
com.dookay.cihai.app.controller.vo.StatementParaphVO
;
import
com.dookay.cihai.app.controller.vo.StatementParaphVO
;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.enums.WordType
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
import
com.dookay.cihai.core.word.service.IWordService
;
import
com.dookay.cihai.core.word.service.IWordService
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
com.dookay.coral.common.web.controller.BaseController
;
...
@@ -32,7 +31,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -32,7 +31,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -115,7 +113,7 @@ public class WordHtmlController extends BaseController {
...
@@ -115,7 +113,7 @@ public class WordHtmlController extends BaseController {
public
ModelAndView
relate
(
@PathVariable
(
"id"
)
Long
id
)
{
public
ModelAndView
relate
(
@PathVariable
(
"id"
)
Long
id
)
{
WordDomain
wordDomain
=
wordService
.
get
(
id
);
WordDomain
wordDomain
=
wordService
.
get
(
id
);
List
<
WordDomain
>
relateWords
=
wordRelationService
.
getRelateWord
(
id
);
List
<
WordDomain
>
relateWords
=
wordRelationService
.
getRelateWord
(
id
);
List
<
WordDTO
>
vos
=
relateWords
.
stream
().
filter
(
r
->
!
r
.
getId
().
equals
(
id
)).
map
(
WordDTO:
:
fromDomain
).
collect
(
Collectors
.
toList
());
List
<
WordDTO
>
vos
=
relateWords
.
stream
().
filter
(
r
->
!
r
.
getId
().
equals
(
id
)).
map
(
word
->
WordDTO
.
fromDomain
(
word
,
wordRelationService
)
).
collect
(
Collectors
.
toList
());
ModelAndView
mv
=
new
ModelAndView
(
"/word/relate"
);
ModelAndView
mv
=
new
ModelAndView
(
"/word/relate"
);
mv
.
addObject
(
"word"
,
wordDomain
);
mv
.
addObject
(
"word"
,
wordDomain
);
mv
.
addObject
(
"vos"
,
vos
);
mv
.
addObject
(
"vos"
,
vos
);
...
...
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/dto/WordDTO.java
View file @
8a9d722
...
@@ -16,10 +16,14 @@ package com.dookay.cihai.app.controller.dto;
...
@@ -16,10 +16,14 @@ package com.dookay.cihai.app.controller.dto;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.enums.WordType
;
import
com.dookay.cihai.core.word.enums.WordType
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
import
com.dookay.coral.common.core.utils.lang.CollectionUtils
;
import
com.dookay.coral.common.core.utils.lang.StringUtils
;
import
com.dookay.coral.common.core.utils.lang.StringUtils
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
/**
/**
* 词语 DTO
* 词语 DTO
*
*
...
@@ -39,8 +43,10 @@ public class WordDTO {
...
@@ -39,8 +43,10 @@ public class WordDTO {
private
Boolean
hasParaph
;
private
Boolean
hasParaph
;
@ApiModelProperty
(
"是否有百科页"
)
@ApiModelProperty
(
"是否有百科页"
)
private
Boolean
hasBaike
;
private
Boolean
hasBaike
;
@ApiModelProperty
(
"是否有相关词"
)
private
Boolean
hasRelated
;
public
static
WordDTO
fromDomain
(
WordDomain
word
)
{
public
static
WordDTO
fromDomain
(
WordDomain
word
,
IWordRelationService
wordRelationService
)
{
WordDTO
wordDTO
=
new
WordDTO
();
WordDTO
wordDTO
=
new
WordDTO
();
wordDTO
.
setWordId
(
word
.
getId
());
wordDTO
.
setWordId
(
word
.
getId
());
wordDTO
.
setWord
(
word
.
getWord
());
wordDTO
.
setWord
(
word
.
getWord
());
...
@@ -51,6 +57,8 @@ public class WordDTO {
...
@@ -51,6 +57,8 @@ public class WordDTO {
wordDTO
.
setType
(
type
);
wordDTO
.
setType
(
type
);
wordDTO
.
setHasParaph
(!
StringUtils
.
isAllBlank
(
word
.
getBody
(),
word
.
getWordBrief
()));
wordDTO
.
setHasParaph
(!
StringUtils
.
isAllBlank
(
word
.
getBody
(),
word
.
getWordBrief
()));
wordDTO
.
setHasBaike
(!
StringUtils
.
isAllBlank
(
word
.
getBaikeBrief
(),
word
.
getBaikeParaphrase
()));
wordDTO
.
setHasBaike
(!
StringUtils
.
isAllBlank
(
word
.
getBaikeBrief
(),
word
.
getBaikeParaphrase
()));
List
<
WordDomain
>
relateWord
=
wordRelationService
.
getRelateWord
(
word
.
getId
());
wordDTO
.
setHasRelated
(
CollectionUtils
.
isNotEmpty
(
relateWord
));
return
wordDTO
;
return
wordDTO
;
}
}
}
}
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/vo/CharacterBaikeVO.java
View file @
8a9d722
...
@@ -62,7 +62,7 @@ public class CharacterBaikeVO {
...
@@ -62,7 +62,7 @@ public class CharacterBaikeVO {
.
map
(
StringUtils:
:
trim
)
.
map
(
StringUtils:
:
trim
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
dto
.
setSpell
(
spell
);
dto
.
setSpell
(
spell
);
List
<
String
>
body
=
Arrays
.
stream
(
StringUtils
.
split
(
word
.
getBaikeParaphrase
(),
'\
r
'
))
List
<
String
>
body
=
Arrays
.
stream
(
StringUtils
.
split
(
word
.
getBaikeParaphrase
(),
'\
n
'
))
.
filter
(
StringUtils:
:
isNoneBlank
)
.
filter
(
StringUtils:
:
isNoneBlank
)
.
map
(
StringUtils:
:
trim
)
.
map
(
StringUtils:
:
trim
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
...
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/vo/StatementBaikeVO.java
View file @
8a9d722
...
@@ -57,7 +57,7 @@ public class StatementBaikeVO {
...
@@ -57,7 +57,7 @@ public class StatementBaikeVO {
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
dto
.
setBrief
(
brief
);
dto
.
setBrief
(
brief
);
dto
.
setSpell
(
word
.
getWordSpell
());
dto
.
setSpell
(
word
.
getWordSpell
());
List
<
String
>
body
=
Arrays
.
stream
(
StringUtils
.
split
(
word
.
getBaikeParaphrase
(),
'\
r
'
))
List
<
String
>
body
=
Arrays
.
stream
(
StringUtils
.
split
(
word
.
getBaikeParaphrase
(),
'\
n
'
))
.
filter
(
StringUtils:
:
isNoneBlank
)
.
filter
(
StringUtils:
:
isNoneBlank
)
.
map
(
StringUtils:
:
trim
)
.
map
(
StringUtils:
:
trim
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment