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 8550ec52
authored
Jan 15, 2018
by
侯昆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
关联词页面整合
1 parent
fd08ce91
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
208 additions
and
26 deletions
serverside/cihai-admin/src/main/java/com/dookay/cihai/admin/controller/WordRelateController.java
serverside/cihai-admin/src/main/java/com/dookay/cihai/admin/controller/form/AddPicForm.java
serverside/cihai-admin/src/main/java/com/dookay/cihai/admin/controller/form/AddVideoForm.java
serverside/cihai-app/pom.xml
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/resources/application.properties
serverside/cihai-app/src/main/webapp/WEB-INF/jsp/word/character_baike.jsp
serverside/cihai-app/src/main/webapp/WEB-INF/jsp/word/relate.jsp
serverside/cihai-app/src/main/webapp/WEB-INF/jsp/word/statement_baike.jsp
serverside/cihai-app/src/main/webapp/static/css/vendor.css
serverside/cihai-app/src/main/webapp/static/百科详情-相关词-弹出框.html
serverside/cihai-core/src/test/java/com/dookay/cihai/core/excel/TestImportWord.java
serverside/cihai-admin/src/main/java/com/dookay/cihai/admin/controller/WordRelateController.java
View file @
8550ec5
...
...
@@ -15,13 +15,16 @@ package com.dookay.cihai.admin.controller;
****************************************/
import
com.alibaba.fastjson.JSON
;
import
com.dookay.cihai.admin.controller.form.AddPicForm
;
import
com.dookay.cihai.admin.controller.form.AddRelationForm
;
import
com.dookay.cihai.admin.controller.form.AddVideoForm
;
import
com.dookay.cihai.core.word.domain.WordDomain
;
import
com.dookay.cihai.core.word.domain.WordRelationDomain
;
import
com.dookay.cihai.core.word.query.WordQuery
;
import
com.dookay.cihai.core.word.service.IWordRelationService
;
import
com.dookay.cihai.core.word.service.IWordService
;
import
com.dookay.coral.common.core.exception.ServiceException
;
import
com.dookay.coral.common.core.utils.lang.EncodeUtils
;
import
com.dookay.coral.common.core.utils.lang.StringUtils
;
import
com.dookay.coral.common.web.config.ResourcesMappingProperties
;
import
com.dookay.coral.common.web.controller.BaseController
;
...
...
@@ -70,14 +73,14 @@ public class WordRelateController extends BaseController {
* @date 2018/1/9
*/
@RequestMapping
(
value
=
"/pic/add"
,
method
=
RequestMethod
.
POST
)
public
JsonResult
picAdd
(
String
word
,
MultipartFile
image
)
{
public
JsonResult
picAdd
(
@ModelAttribute
AddPicForm
form
)
{
WordQuery
q
=
new
WordQuery
();
q
.
setWord
(
word
);
q
.
setWord
(
form
.
getWord
()
);
WordDomain
wordDomain
=
wordService
.
getFirst
(
q
);
if
(
wordDomain
==
null
)
{
return
errorResult
(
"词条不存在"
);
}
List
<
ImageModel
>
modelList
=
doUpload
(
word
,
image
);
List
<
ImageModel
>
modelList
=
doUpload
(
form
.
getWord
(),
form
.
getImage
()
);
List
<
ImageModel
>
current
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
wordDomain
.
getBaikePhotos
()))
{
current
=
ImageModel
.
toList
(
wordDomain
.
getBaikePhotos
());
...
...
@@ -97,8 +100,7 @@ public class WordRelateController extends BaseController {
*/
private
List
<
ImageModel
>
doUpload
(
String
word
,
MultipartFile
image
)
{
List
<
ImageModel
>
modelList
=
new
ArrayList
<>();
String
wordPinyin
=
HanLP
.
convertToPinyinString
(
word
,
"_"
,
false
);
String
prefix
=
"word/"
+
wordPinyin
+
"/"
;
String
prefix
=
"word/"
+
word
+
"/"
;
String
fileUploadPath
=
resourcesMappingProperties
.
getUploadsMapping
()
+
prefix
;
try
{
URI
dirUri
=
new
URI
(
fileUploadPath
);
...
...
@@ -128,21 +130,19 @@ public class WordRelateController extends BaseController {
/**
* 添加视频
*
* @param word
* @param video
* @return
* @author houkun
* @date 2018/1/10
*/
@RequestMapping
(
value
=
"/video/add"
,
method
=
RequestMethod
.
POST
)
public
JsonResult
videoAdd
(
String
word
,
MultipartFile
video
)
{
public
JsonResult
videoAdd
(
@ModelAttribute
AddVideoForm
form
)
{
WordQuery
q
=
new
WordQuery
();
q
.
setWord
(
word
);
q
.
setWord
(
form
.
getWord
()
);
WordDomain
wordDomain
=
wordService
.
getFirst
(
q
);
if
(
wordDomain
==
null
)
{
return
errorResult
(
"词条不存在"
);
}
List
<
ImageModel
>
modelList
=
doUpload
(
word
,
video
);
List
<
ImageModel
>
modelList
=
doUpload
(
form
.
getWord
(),
form
.
getVideo
()
);
List
<
ImageModel
>
current
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
wordDomain
.
getBaikeVideo
()))
{
current
=
ImageModel
.
toList
(
wordDomain
.
getBaikeVideo
());
...
...
@@ -162,7 +162,8 @@ public class WordRelateController extends BaseController {
@RequestMapping
(
value
=
"/relation/add"
,
method
=
RequestMethod
.
POST
)
public
JsonResult
relationAdd
(
@ModelAttribute
AddRelationForm
addRelationForm
)
{
WordQuery
q
=
new
WordQuery
();
List
<
String
>
words
=
addRelationForm
.
getWords
().
stream
().
map
(
StringUtils:
:
trim
).
collect
(
Collectors
.
toList
());
List
<
String
>
words
=
addRelationForm
.
getWords
().
stream
()
.
map
(
StringUtils:
:
trim
).
collect
(
Collectors
.
toList
());
q
.
setWordIn
(
words
);
List
<
WordDomain
>
wordList
=
wordService
.
getList
(
q
);
if
(
wordList
.
size
()
<
addRelationForm
.
getWords
().
size
())
{
...
...
serverside/cihai-admin/src/main/java/com/dookay/cihai/admin/controller/form/AddPicForm.java
0 → 100644
View file @
8550ec5
package
com
.
dookay
.
cihai
.
admin
.
controller
.
form
;
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* @dookay.com Internet make it happen *
* *
****************************************/
import
lombok.Data
;
import
org.springframework.web.multipart.MultipartFile
;
/**
* @author houkun
* @date 2018/1/15
*/
@Data
public
class
AddPicForm
{
private
String
word
;
private
MultipartFile
image
;
}
serverside/cihai-admin/src/main/java/com/dookay/cihai/admin/controller/form/AddVideoForm.java
0 → 100644
View file @
8550ec5
package
com
.
dookay
.
cihai
.
admin
.
controller
.
form
;
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* @dookay.com Internet make it happen *
* *
****************************************/
import
lombok.Data
;
import
org.springframework.web.multipart.MultipartFile
;
/**
* @author houkun
* @date 2018/1/15
*/
@Data
public
class
AddVideoForm
{
private
String
word
;
private
MultipartFile
video
;
}
serverside/cihai-app/pom.xml
View file @
8550ec5
...
...
@@ -12,6 +12,10 @@
<name>
cihai-web-app
</name>
<artifactId>
cihai-app
</artifactId>
<properties>
<maven.test.skip>
true
</maven.test.skip>
<jetty.scope>
compile
</jetty.scope>
</properties>
<dependencies>
...
...
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/WordController.java
View file @
8550ec5
...
...
@@ -49,23 +49,18 @@ public class WordController extends BaseController {
@Autowired
private
IWordService
wordService
;
@Autowired
private
IWordRelationService
wordRelationService
;
/**
*
相关词列表
*
词信息
*
* @author houkun
* @date 2018/1/14
*/
@RequestMapping
(
value
=
"/relate/{id}"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
value
=
"相关词"
,
httpMethod
=
"GET"
,
response
=
RelateWordsVO
.
class
)
public
JsonResult
relate
(
@PathVariable
@ApiParam
(
value
=
"词的id"
,
required
=
true
)
Long
id
)
{
List
<
WordDomain
>
relateWords
=
wordRelationService
.
getRelateWord
(
id
);
List
<
WordDTO
>
dtos
=
relateWords
.
stream
().
map
(
WordDTO:
:
fromDomain
).
collect
(
Collectors
.
toList
());
RelateWordsVO
res
=
new
RelateWordsVO
();
res
.
setWords
(
dtos
);
return
successResult
(
"相关词"
,
res
);
@RequestMapping
(
value
=
"/info/{id}"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
value
=
"词信息"
,
httpMethod
=
"GET"
,
response
=
WordDTO
.
class
)
public
JsonResult
info
(
@PathVariable
@ApiParam
(
value
=
"词的id"
,
required
=
true
)
Long
id
)
{
WordDomain
wordDomain
=
wordService
.
get
(
id
);
return
successResult
(
"词信息"
,
WordDTO
.
fromDomain
(
wordDomain
));
}
/**
...
...
serverside/cihai-app/src/main/java/com/dookay/cihai/app/controller/WordHtmlController.java
View file @
8550ec5
...
...
@@ -14,11 +14,14 @@ package com.dookay.cihai.app.controller;
* *
****************************************/
import
com.dookay.cihai.app.controller.dto.WordDTO
;
import
com.dookay.cihai.app.controller.vo.CharacterBaikeVO
;
import
com.dookay.cihai.app.controller.vo.CharacterParaphVO
;
import
com.dookay.cihai.app.controller.vo.StatementBaikeVO
;
import
com.dookay.cihai.app.controller.vo.StatementParaphVO
;
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.IWordService
;
import
com.dookay.coral.common.web.controller.BaseController
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +31,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author houkun
* @date 2018/1/14
...
...
@@ -38,6 +45,8 @@ public class WordHtmlController extends BaseController {
@Autowired
private
IWordService
wordService
;
@Autowired
private
IWordRelationService
wordRelationService
;
/**
* 字释义
...
...
@@ -94,4 +103,22 @@ public class WordHtmlController extends BaseController {
mv
.
addObject
(
"vo"
,
StatementBaikeVO
.
fromDomain
(
statement
));
return
mv
;
}
/**
* 相关词
*
* @param id
* @return
*/
@RequestMapping
(
value
=
"/relate/{id}"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
relate
(
@PathVariable
(
"id"
)
Long
id
)
{
WordDomain
wordDomain
=
wordService
.
get
(
id
);
List
<
WordDomain
>
relateWords
=
wordRelationService
.
getRelateWord
(
id
);
List
<
WordDTO
>
vos
=
relateWords
.
stream
().
filter
(
r
->
!
r
.
getId
().
equals
(
id
)).
map
(
WordDTO:
:
fromDomain
).
collect
(
Collectors
.
toList
());
ModelAndView
mv
=
new
ModelAndView
(
"/word/relate"
);
mv
.
addObject
(
"word"
,
wordDomain
);
mv
.
addObject
(
"vos"
,
vos
);
return
mv
;
}
}
serverside/cihai-app/src/main/resources/application.properties
View file @
8550ec5
...
...
@@ -17,7 +17,7 @@ spring.datasource.druid.filter.config.enabled=true
# 关闭druid监控
spring.datasource.druid.filter.stat.enabled
=
false
# jsp页面配置
spring.mvc.view.prefix
=
/WEB-INF/jsp
/
spring.mvc.view.prefix
=
/WEB-INF/jsp
spring.mvc.view.suffix
=
.jsp
# mybatis插件配置
# 设置扫描 mapper xml路径
...
...
serverside/cihai-app/src/main/webapp/WEB-INF/jsp/word/character_baike.jsp
View file @
8550ec5
...
...
@@ -29,7 +29,7 @@
<c:if test="${vo.images.size() > 0}">
<div class="header-main-right">
<div class="album">
<a>
<a
href="/word/pics/${vo.wordId}"
>
<img src="${vo.images.get(0).file}">
<span>${vo.word}图册(${vo.images.size()})</span>
</a>
...
...
serverside/cihai-app/src/main/webapp/WEB-INF/jsp/word/relate.jsp
0 → 100644
View file @
8550ec5
<
%@ include file="/WEB-INF/jsp/include/taglib.jsp" %>
<
%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean
id=
"word"
scope=
"request"
type=
"com.dookay.cihai.core.word.domain.WordDomain"
/>
<jsp:useBean
id=
"vos"
scope=
"request"
type=
"java.util.List<com.dookay.cihai.app.controller.dto.WordDTO>"
/>
<!DOCTYPE html>
<html
lang=
"zh-CN"
>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1,shrink-to-fit=no"
>
<title>
辞海 - ${word.word}的相关词
</title>
<link
rel=
"stylesheet"
href=
"${ctx}/static/css/vendor.css"
>
</head>
<body
class=
"relation-word-body"
>
<div
class=
"container-fluid"
>
<div
class=
"relation-word"
>
<h4>
相关词
</h4>
<div
class=
"list-group"
>
<span
class=
"list-group-item list-group-item-header"
>
${word.word}
</span>
<c:forEach
items=
"${vos}"
var=
"item"
>
<a
class=
"list-group-item"
href=
"/word/info/${item.wordId}"
>
${item.word}
</a>
</c:forEach>
</div>
</div>
</div>
<script
src=
"${ctx}/static/js/plugins/jquery.min.js"
></script>
<script
src=
"${ctx}/static/js/vendor.js"
merge=
"true"
></script>
<script>
$
(
'.opt'
).
click
(
function
()
{
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'open'
))
{
$this
.
removeClass
(
'open'
).
text
(
'收起'
)
.
siblings
(
'.d-none'
).
removeClass
(
'd-block'
);
}
else
{
$this
.
addClass
(
'open'
).
text
(
'展开'
)
.
siblings
(
'.d-none'
).
addClass
(
'd-block'
);
}
});
</script>
</body>
</html>
\ No newline at end of file
serverside/cihai-app/src/main/webapp/WEB-INF/jsp/word/statement_baike.jsp
View file @
8550ec5
...
...
@@ -27,7 +27,7 @@
<c:if test="${vo.images.size() > 0}">
<div class="header-main-right">
<div class="album">
<a>
<a
href="/word/pics/${vo.wordId}"
>
<img src="${vo.images.get(0).file}">
<span>${vo.word}图册(${vo.images.size()})</span>
</a>
...
...
serverside/cihai-app/src/main/webapp/static/css/vendor.css
View file @
8550ec5
This diff could not be displayed because it is too large.
serverside/cihai-app/src/main/webapp/static/百科详情-相关词-弹出框.html
0 → 100644
View file @
8550ec5
<!DOCTYPE html>
<html
lang=
"zh-CN"
>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1,shrink-to-fit=no"
>
<title>
百科详情-相关词-弹出框
</title>
<link
rel=
"stylesheet"
href=
"css/vendor.css"
>
</head>
<body
class=
"relation-word-body"
>
<div
class=
"container-fluid"
>
<div
class=
"relation-word"
>
<h4>
相关词
</h4>
<div
class=
"list-group"
>
<span
class=
"list-group-item list-group-item-header"
>
开头
</span>
<a
class=
"list-group-item"
href=
"#"
>
象车
</a>
<a
class=
"list-group-item"
href=
"#"
>
象服
</a>
<a
class=
"list-group-item"
href=
"#"
>
象罔
</a>
<a
class=
"list-group-item d-none"
href=
"#"
>
隐藏的项1
</a>
<a
class=
"list-group-item d-none"
href=
"#"
>
隐藏的项2
</a>
<span
class=
"opt dropdown-toggle"
>
展开
</span>
</div>
<div
class=
"list-group"
>
<span
class=
"list-group-item list-group-item-header"
>
中间
</span>
<a
class=
"list-group-item"
href=
"#"
>
形象工程
</a>
<a
class=
"list-group-item"
href=
"#"
>
形象代言人
</a>
<a
class=
"list-group-item"
href=
"#"
>
形象大使
</a>
</div>
<div
class=
"list-group"
>
<span
class=
"list-group-item list-group-item-header"
>
结尾
</span>
<a
class=
"list-group-item"
href=
"#"
>
历象
</a>
<a
class=
"list-group-item"
href=
"#"
>
蛇吞象
</a>
<a
class=
"list-group-item"
href=
"#"
>
罔象
</a>
</div>
<h4>
相关成语
</h4>
<div
class=
"list-group"
>
<a
class=
"list-group-item"
href=
"#"
>
象齿焚身
</a>
<a
class=
"list-group-item"
href=
"#"
>
盲人摸象
</a>
<a
class=
"list-group-item"
href=
"#"
>
万象森罗
</a>
</div>
</div>
</div>
<script
src=
"js/plugins/jquery.min.js"
></script>
<script
src=
"js/vendor.js"
merge=
"true"
></script>
<script>
$
(
'.opt'
).
click
(
function
()
{
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'open'
))
{
$this
.
removeClass
(
'open'
).
text
(
'收起'
)
.
siblings
(
'.d-none'
).
removeClass
(
'd-block'
);
}
else
{
$this
.
addClass
(
'open'
).
text
(
'展开'
)
.
siblings
(
'.d-none'
).
addClass
(
'd-block'
);
}
});
</script>
</body>
</html>
\ No newline at end of file
serverside/cihai-core/src/test/java/com/dookay/cihai/core/excel/TestImportWord.java
View file @
8550ec5
...
...
@@ -51,7 +51,9 @@ public class TestImportWord extends CihaiCoreApplicationTests {
@Test
@Rollback
(
false
)
public
void
testImport
()
throws
Exception
{
File
excel
=
ResourceUtils
.
getFile
(
"classpath:辞海词语导入模版.xls"
);
// String file = "辞海词语导入模版.xls";
String
file
=
"鲁迅词条_V1.xls"
;
File
excel
=
ResourceUtils
.
getFile
(
"classpath:"
+
file
);
List
<
WordImportDTO
>
list
=
ExcelUtils
.
importExcel
(
excel
,
WordImportDTO
.
class
);
List
<
WordDomain
>
wordDomains
=
list
.
stream
().
map
(
WordImportDTO:
:
toDomain
).
collect
(
Collectors
.
toList
());
List
<
CustomDictionaryDomain
>
dictionaryDomains
=
list
.
stream
().
map
(
w
->
new
CustomDictionaryDomain
(
w
.
getWord
())).
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