Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
scsm
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
scsm
Commits
c11d5ce9
提交
c11d5ce9
authored
12月 09, 2020
作者:
renjiancai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
9f88a79e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
654 行增加
和
7 行删除
+654
-7
EbookController.java
...om/zrqx/resource/bg/controller/ebook/EbookController.java
+62
-7
AnnexLibraryController.java
...fg/controller/pc/annexlibrary/AnnexLibraryController.java
+0
-0
FgArticleLibraryController.java
...troller/pc/articlelibrary/FgArticleLibraryController.java
+211
-0
FgEbookController.java
...qx/resource/fg/controller/pc/ebook/FgEbookController.java
+185
-0
FgIndexController.java
...qx/resource/fg/controller/pc/index/FgIndexController.java
+179
-0
FgEbookMapper.java
...java/com/zrqx/resource/fg/mapper/ebook/FgEbookMapper.java
+6
-0
FgEbookService.java
...va/com/zrqx/resource/fg/service/ebook/FgEbookService.java
+3
-0
FgEbookServiceImpl.java
...om/zrqx/resource/fg/service/ebook/FgEbookServiceImpl.java
+8
-0
没有找到文件。
com.zrqx.resource/src/main/java/com/zrqx/resource/bg/controller/ebook/EbookController.java
浏览文件 @
c11d5ce9
...
...
@@ -13,13 +13,16 @@ import org.springframework.web.bind.annotation.PathVariable;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.enums.resource.EbookOptionEnum
;
import
com.zrqx.core.enums.resource.EbookStatusEnum
;
import
com.zrqx.core.exception.BusinessValidateException
;
import
com.zrqx.core.exception.ParameterValidateException
;
import
com.zrqx.core.form.resource.bg.diytype.SaveDiyTypeForm
;
import
com.zrqx.core.form.resource.bg.ebook.QueryEbookInfoForm
;
import
com.zrqx.core.form.resource.bg.ebook.SaveUpdateEbookForm
;
import
com.zrqx.core.form.resource.bg.ebook.UpdateEbookForm
;
...
...
@@ -29,18 +32,18 @@ import com.zrqx.core.model.resource.ebook.EbookImage;
import
com.zrqx.core.model.resource.membercollection.MemberCollection
;
import
com.zrqx.core.model.resource.resourcerelation.ResourceRelation
;
import
com.zrqx.core.util.bean.BeanUtils
;
import
com.zrqx.core.util.excelutil.ExcelUtil
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.ebook.EbookListVO
;
import
com.zrqx.core.vo.resource.ebook.EbookVO
;
import
com.zrqx.core.vo.resource.ebook.ImportExcelBookVO
;
import
com.zrqx.resource.bg.service.ResourceRelationService
;
import
com.zrqx.resource.bg.service.ebook.EBookImageService
;
import
com.zrqx.resource.bg.service.ebook.EbookDiyTypeService
;
import
com.zrqx.resource.bg.service.ebook.EbookService
;
import
com.zrqx.resource.bg.service.membercollection.MemberCollectionService
;
import
com.zrqx.resource.bg.service.pdffilelibrary.PdfLibraryService
;
import
com.zrqx.resource.commons.Redis
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -65,10 +68,6 @@ public class EbookController {
@Autowired
private
EBookImageService
eBookImageService
;
@Autowired
private
Redis
redis
;
@Autowired
private
PdfLibraryService
pdfLibraryService
;
@Autowired
private
ResourceRelationService
resourceRelationService
;
@Autowired
private
MemberCollectionService
memberCollectionService
;
...
...
@@ -210,7 +209,63 @@ public class EbookController {
Map
<
String
,
String
>
map
=
EbookOptionEnum
.
getAllEnumMap
();
return
CallBack
.
success
(
map
);
}
@ApiOperation
(
value
=
"导入图书Excel"
)
@PostMapping
(
value
=
ResourceRequestPath
.
IMPORT
,
produces
=
"application/json;charset=UTF-8"
)
public
CallBack
<
String
>
importBook
(
@RequestParam
(
"file"
)
MultipartFile
file
,
SaveDiyTypeForm
form
)
throws
Exception
{
List
<
ImportExcelBookVO
>
list
=
ExcelUtil
.
importExcel
(
file
.
getInputStream
(),
ImportExcelBookVO
.
class
,
file
.
getOriginalFilename
());
list
.
forEach
(
ec
->
{
Example
example
=
ebookservice
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"isbn"
,
ec
.
getIsbn
());
Ebook
ebookList
=
ebookservice
.
selectOneByExample
(
example
);
if
(
ebookList
!=
null
&&
!
ebookList
.
equals
(
""
))
{
Ebook
ebook
=
new
Ebook
();
BeanUtils
.
copyProperties
(
ec
,
ebook
);
if
(
ec
.
getPublishTime
()
!=
null
&&
!
ec
.
getPublishTime
().
equals
(
""
))
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM"
);
try
{
ebook
.
setPublishTime
(
sdf
.
parse
(
ec
.
getPublishTime
()));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
ebook
.
setUploadTime
(
new
Date
());
ebook
.
setBookStatus
(
1
);
ebookservice
.
insert
(
ebook
);
// 添加分类
EbookDiyType
classify
=
new
EbookDiyType
();
classify
.
setCode
(
form
.
getCode
());
classify
.
setDiyTypeId
(
form
.
getDiytypeId
());
classify
.
setEbookId
(
ebook
.
getId
());
dtservice
.
insert
(
classify
);
}
else
{
BeanUtils
.
copyProperties
(
ec
,
ebookList
);
if
(
ec
.
getPublishTime
()
!=
null
&&
!
ec
.
getPublishTime
().
equals
(
""
))
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM"
);
try
{
ebookList
.
setPublishTime
(
sdf
.
parse
(
ec
.
getPublishTime
()));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
ebookList
.
setUploadTime
(
new
Date
());
ebookList
.
setBookStatus
(
1
);
ebookservice
.
updateByPrimaryKeySelective
(
ebookList
);
//删除分类
EbookDiyType
type
=
new
EbookDiyType
();
type
.
setEbookId
(
ebookList
.
getId
());
dtservice
.
delete
(
type
);
// 添加分类
EbookDiyType
classify
=
new
EbookDiyType
();
classify
.
setCode
(
form
.
getCode
());
classify
.
setDiyTypeId
(
form
.
getDiytypeId
());
classify
.
setEbookId
(
ebookList
.
getId
());
dtservice
.
insert
(
classify
);
}
});
return
CallBack
.
success
();
}
/**
* 批量修改
*
...
...
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/controller/pc/annexlibrary/AnnexLibraryController.java
0 → 100644
浏览文件 @
c11d5ce9
差异被折叠。
点击展开。
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/controller/pc/articlelibrary/FgArticleLibraryController.java
0 → 100644
浏览文件 @
c11d5ce9
package
com
.
zrqx
.
resource
.
fg
.
controller
.
pc
.
articlelibrary
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
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.RestController
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.enums.resource.LibraryStatusEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.resource.bg.articlelibrary.BatchUpdateArticleLibraryForm
;
import
com.zrqx.core.form.resource.bg.articlelibrary.QueryArticleLibraryForm
;
import
com.zrqx.core.form.resource.bg.articlelibrary.SaveUpdateArticleLibraryForm
;
import
com.zrqx.core.form.resource.bg.recommend.UpdateRecommendResourceForm
;
import
com.zrqx.core.model.resource.articlelibrary.ArticleLibrary
;
import
com.zrqx.core.model.resource.articlelibrary.ArticleLibraryDiyType
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO
;
import
com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryOneVO
;
import
com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryDiyTypeService
;
import
com.zrqx.resource.bg.service.articlelibrary.ArticleLibraryService
;
import
com.zrqx.resource.bg.service.recommend.RecommendResourceService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
tk.mybatis.mapper.entity.Example
;
/**
* 文章库Controller
*/
@RestController
@RequestMapping
(
ResourceRequestPath
.
FG_PC
+
ResourceRequestPath
.
ARTICLE_LIBRARY
)
@Api
(
description
=
"资源管理-文章库"
)
public
class
FgArticleLibraryController
{
@Autowired
private
ArticleLibraryService
service
;
@Autowired
private
ArticleLibraryDiyTypeService
adrService
;
/** 推荐位内容*/
@Autowired
private
RecommendResourceService
recommendResourceService
;
@ApiOperation
(
value
=
"新增"
,
notes
=
"新增一个"
)
@PostMapping
(
value
=
"/save"
)
public
CallBack
<
Boolean
>
save
(
@RequestBody
SaveUpdateArticleLibraryForm
form
)
{
if
(!
service
.
saveOrUpdate
(
form
))
{
throw
new
BaseException
(
"操作失败"
);
}
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"更新"
,
notes
=
"根据ID更新"
)
@PostMapping
(
value
=
"/update"
)
public
CallBack
<
Boolean
>
update
(
@RequestBody
SaveUpdateArticleLibraryForm
form
)
{
if
(!
service
.
saveOrUpdate
(
form
))
{
throw
new
BaseException
(
"操作失败"
);
}
ArticleLibrary
entity
=
service
.
selectByPrimaryKey
(
form
.
getId
());
//推荐位内容修改
UpdateRecommendResourceForm
res
=
new
UpdateRecommendResourceForm
();
res
.
setResId
(
form
.
getId
());
res
.
setResType
(
entity
.
getResourceType
());
res
.
setResImg
(
form
.
getImg
());
res
.
setResName
(
form
.
getName
());
recommendResourceService
.
updateResourceContent
(
res
);
return
CallBack
.
success
();
}
/*@ApiOperation(value = "更新文章封面", notes = "根据ID更新")
@PostMapping(value = "/img/update")
public CallBack<Boolean> updateImg(@RequestBody UpdateArticleImgForm form) {
ArticleLibrary entity = new ArticleLibrary();
BeanUtils.copyProperties(form, entity);
entity.setUpdateTime(new Date());
if (!service.updateByPrimaryKeySelective(entity)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}*/
/*@ApiOperation(value = "批量审核", notes = "批量审核")
@PostMapping(value = "/batch/update/status")
public CallBack<Boolean> updateArray(@RequestBody List<String> ids) {
Example example = service.createExample();
example.createCriteria().andIn("id", ids);
ArticleLibrary entity = new ArticleLibrary();
entity.setStatus(LibraryStatusEnum.STATUS_1.getCode());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity,example)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改阅读权限", notes = "批量修改阅读权限")
@PostMapping(value = "/batch/update/read")
public CallBack<Boolean> updateReadTextPower(@RequestBody BatchUpdateArticleLibraryForm form) {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
ArticleLibrary entity = new ArticleLibrary();
entity.setReadTextPower(form.getReadTextPower());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity,example)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量修改价格", notes = "批量修改价格")
@PostMapping(value = "/batch/update/price")
public CallBack<Boolean> updatePrice(@RequestBody BatchUpdateArticleLibraryForm form) {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
ArticleLibrary entity = new ArticleLibrary();
entity.setRealPrice(form.getRealPrice());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity,example)) {
throw new BaseException("操作失败");
}
return CallBack.success();
}*/
@ApiOperation
(
value
=
"批量修改分类"
,
notes
=
"批量修改分类"
)
@PostMapping
(
value
=
"/batch/update/diytype"
)
public
CallBack
<
Boolean
>
updateDivType
(
@RequestBody
BatchUpdateArticleLibraryForm
form
)
{
List
<
ArticleLibraryDiyType
>
list
=
new
ArrayList
<
ArticleLibraryDiyType
>();
form
.
getIds
().
forEach
(
alId
->
{
//刪除原有的分类
ArticleLibraryDiyType
ob
=
new
ArticleLibraryDiyType
();
ob
.
setAlId
(
alId
);
adrService
.
delete
(
ob
);
//添加
List
<
ArticleLibraryDiyType
>
ls
=
form
.
getDiyType
();
ls
.
forEach
(
l
->
l
.
setAlId
(
alId
));
list
.
addAll
(
ls
);
});
if
(!
adrService
.
insertUuidList
(
list
))
{
throw
new
BaseException
(
"操作失败"
);
}
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"批量 上架/下架"
,
notes
=
"批量 上架/下架"
)
@PostMapping
(
value
=
"/batch/update/updown"
)
public
CallBack
<
Boolean
>
updateShowState
(
@RequestBody
BatchUpdateArticleLibraryForm
form
)
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andIn
(
"id"
,
form
.
getIds
());
List
<
ArticleLibrary
>
list
=
service
.
selectByExample
(
example
);
for
(
ArticleLibrary
entity
:
list
)
{
entity
.
setStatus
(
form
.
getStatus
());
entity
.
setUpdateTime
(
new
Date
());
if
(!
service
.
updateByPrimaryKey
(
entity
))
{
throw
new
BaseException
(
"操作失败"
);
}
}
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"删除"
,
notes
=
"删除"
)
@PostMapping
(
value
=
"/delete/{oid}"
)
public
CallBack
<
Boolean
>
delete
(
@PathVariable
String
oid
)
{
ArticleLibrary
entity
=
service
.
selectByPrimaryKey
(
oid
);
if
(
entity
.
getStatus
()
==
LibraryStatusEnum
.
STATUS_1
.
getCode
())
{
throw
new
BaseException
(
"不能删除已上架的资源"
);
}
if
(!
service
.
batchDelete
(
Arrays
.
asList
(
oid
)))
{
throw
new
BaseException
(
"操作失败"
);
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"批量删除"
,
notes
=
"批量删除"
)
@PostMapping
(
value
=
"/batch/delete"
)
public
CallBack
<
Boolean
>
deleteByIds
(
@RequestBody
List
<
String
>
ids
)
{
if
(
ids
.
size
()
==
0
)
{
throw
new
BaseException
(
"没有选中任何数据,请重新选择"
);
}
return
CallBack
.
success
(
service
.
batchDelete
(
ids
));
}
@ApiOperation
(
value
=
"查询"
,
notes
=
"根据ID查询"
)
@GetMapping
(
value
=
"/get/oid"
)
public
CallBack
<
ArticleLibraryOneVO
>
getById
(
@PathVariable
String
oid
)
{
ArticleLibrary
entity
=
service
.
selectByPrimaryKey
(
oid
);
ArticleLibraryOneVO
vo
=
new
ArticleLibraryOneVO
();
BeanUtils
.
copyProperties
(
entity
,
vo
);
//组装自定义分类
Example
example
=
adrService
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"alId"
,
oid
);
List
<
ArticleLibraryDiyType
>
list
=
adrService
.
selectByExample
(
example
);
vo
.
setDiyType
(
list
);
return
CallBack
.
success
(
vo
);
}
@ApiOperation
(
value
=
"分页查询"
,
notes
=
"分页查询"
)
@GetMapping
(
value
=
"/page"
)
public
CallBack
<
PageInfo
<
ArticleLibraryListVO
>>
page
(
QueryArticleLibraryForm
form
,
PageParam
pageParam
){
return
CallBack
.
success
(
service
.
page
(
form
,
pageParam
));
}
}
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/controller/pc/ebook/FgEbookController.java
0 → 100644
浏览文件 @
c11d5ce9
package
com
.
zrqx
.
resource
.
fg
.
controller
.
pc
.
ebook
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.solr.client.solrj.SolrClient
;
import
org.apache.solr.client.solrj.SolrQuery
;
import
org.apache.solr.client.solrj.response.QueryResponse
;
import
org.apache.solr.common.SolrDocument
;
import
org.apache.solr.common.SolrDocumentList
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.enums.resource.EbookPromptMessageEnum
;
import
com.zrqx.core.form.resource.fg.ebook.FgQueryEbookInfoForm
;
import
com.zrqx.core.model.resource.ebook.Ebook
;
import
com.zrqx.core.model.resource.ebook.EbookImage
;
import
com.zrqx.core.util.bean.BeanUtils
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.fg.diytype.FgDiyTypeVo
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookListVO
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookVO
;
import
com.zrqx.core.vo.resource.fg.resource.FgAboutListVo
;
import
com.zrqx.resource.fg.service.ebook.FgEBookImageService
;
import
com.zrqx.resource.fg.service.ebook.FgEbookDiyTypeService
;
import
com.zrqx.resource.fg.service.ebook.FgEbookService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
tk.mybatis.mapper.entity.Example
;
/**
* 电子书管理-controller
* @author Conan
* @date 2018年7月13日上午10:02:31
*/
@RestController
@RequestMapping
(
ResourceRequestPath
.
FG_PC
+
ResourceRequestPath
.
EBOOK
)
@Api
(
description
=
"前台-电子书管理"
)
public
class
FgEbookController
{
final
static
int
NEIGHBORHOOD_NUM
=
2
;
final
static
int
RECOMMENDER_NUM
=
3
;
@Autowired
private
FgEBookImageService
bookservice
;
@Autowired
private
FgEbookService
ebookservice
;
@Autowired
private
FgEbookDiyTypeService
ebookDiyTypeService
;
@Autowired
private
SolrClient
client
;
@ApiOperation
(
"查询电子书列表"
)
@GetMapping
(
ResourceRequestPath
.
PAGE
)
public
CallBack
<
PageInfo
<
FgEbookListVO
>>
getBookList
(
FgQueryEbookInfoForm
form
,
PageParam
pageParam
)
{
if
(
null
!=
pageParam
&&
StringUtils
.
isBlank
(
pageParam
.
getOrderBy
()))
{
pageParam
.
setOrderBy
(
"uploadTime desc,id desc"
);
}
List
<
FgEbookListVO
>
list
=
ebookservice
.
page
(
form
,
pageParam
);
return
CallBack
.
success
(
new
PageInfo
<
FgEbookListVO
>(
list
));
}
@ApiOperation
(
"根据id查找电子书"
)
@GetMapping
(
ResourceRequestPath
.
GET_OID
)
public
CallBack
<
FgEbookVO
>
echo
(
@PathVariable
String
oid
)
{
FgEbookVO
vo
=
ebookservice
.
ebookOneInfoById
(
oid
);
return
CallBack
.
success
(
vo
);
}
@ApiOperation
(
value
=
"权限提示列表"
,
notes
=
"权限提示列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
MESSAGE
)
public
CallBack
<
Map
<
String
,
String
>>
getMessage
()
{
Map
<
String
,
String
>
map
=
EbookPromptMessageEnum
.
getAllEnumMap
();
return
CallBack
.
success
(
map
);
}
@ApiOperation
(
value
=
"查询电子书全部信息(跨服务调用)"
,
notes
=
"根据ID查询"
)
@GetMapping
(
value
=
ResourceRequestPath
.
OID
)
public
CallBack
<
FgEbookVO
>
getOneById
(
@PathVariable
String
oid
)
{
FgEbookVO
vo
=
new
FgEbookVO
();
EbookImage
book
=
bookservice
.
selectByPrimaryKey
(
oid
);
BeanUtils
.
copyProperties
(
book
,
vo
);
Ebook
ebook
=
ebookservice
.
selectByPrimaryKey
(
oid
);
BeanUtils
.
copyProperties
(
ebook
,
vo
);
return
CallBack
.
success
(
vo
);
}
@ApiOperation
(
value
=
"通过id集合查询(跨服务调用)"
,
notes
=
"通过id集合查询电子书信息"
)
@GetMapping
(
value
=
ResourceRequestPath
.
IDLIST
)
public
CallBack
<
List
<
FgEbookVO
>>
getListByIds
(
@RequestParam
(
value
=
"ids"
)
List
<
String
>
ids
)
{
Example
example
=
bookservice
.
createExample
();
example
.
createCriteria
().
andIn
(
"id"
,
ids
);
List
<
EbookImage
>
books
=
bookservice
.
selectByExample
(
example
);
List
<
FgEbookVO
>
vos
=
BeanUtils
.
copyList
(
books
,
FgEbookVO
.
class
);
vos
.
forEach
(
vo
->{
Ebook
ebook
=
ebookservice
.
selectByPrimaryKey
(
vo
.
getId
());
BeanUtils
.
copyProperties
(
ebook
,
vo
);
});
return
CallBack
.
success
(
vos
);
}
@ApiOperation
(
value
=
"获取图书对应类型的全部自定义分类"
,
notes
=
"查询"
)
@GetMapping
(
value
=
ResourceRequestPath
.
ALL
+
ResourceRequestPath
.
DIYTYPE
)
public
CallBack
<
List
<
FgDiyTypeVo
>>
queryAllDiyType
(
@RequestParam
List
<
String
>
ids
){
return
CallBack
.
success
(
ebookDiyTypeService
.
queryAllDiyType
(
ids
));
}
@ApiOperation
(
value
=
"图书相关资源"
,
notes
=
"查询图书相关资源"
)
@GetMapping
(
value
=
ResourceRequestPath
.
RELATION_RESOURCE
+
ResourceRequestPath
.
OID
)
public
CallBack
<
List
<
FgAboutListVo
>>
queryByRelation
(
@PathVariable
String
oid
){
Ebook
ebook
=
ebookservice
.
selectByPrimaryKey
(
oid
);
// 相关资源
String
guanjianzi
=
ebook
.
getName
();
List
<
FgAboutListVo
>
xglist
=
new
ArrayList
<
FgAboutListVo
>();
if
(
guanjianzi
==
null
||
guanjianzi
.
equals
(
""
)){
//title查询结果list
//封装数据...
return
CallBack
.
success
(
xglist
);
}
guanjianzi
=
regEx
(
guanjianzi
);
try
{
SolrQuery
query
=
new
SolrQuery
();
query
.
setStart
(
0
).
setRows
(
12
).
setQuery
(
"name:"
+
guanjianzi
);
query
.
set
(
"fq"
,
" resourceType:3 || resourceType:4 || resourceType:1"
);
QueryResponse
resp
=
client
.
query
(
query
);
SolrDocumentList
sdl
=
resp
.
getResults
();
System
.
out
.
println
(
"相关资源:"
+
sdl
.
getNumFound
()+
"条结果"
);
for
(
SolrDocument
sd:
sdl
)
{
String
id
=
sd
.
getFieldValue
(
"id"
).
toString
();
String
title
=
sd
.
getFieldValue
(
"name"
).
toString
().
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
if
(
id
.
equals
(
oid
)){
continue
;
}
Integer
resourceType
=(
Integer
)
sd
.
getFieldValue
(
"resourceType"
);
String
title2
=
title
.
substring
(
0
,
title
.
length
()<=
100
?
title
.
length
():
100
);
FgAboutListVo
fgAboutListVo
=
new
FgAboutListVo
();
fgAboutListVo
.
setResourceId
(
id
);
fgAboutListVo
.
setName
(
title
);
fgAboutListVo
.
setResourceType
(
resourceType
);
//fgAboutListVo.setResourceType(resourceType);
xglist
.
add
(
fgAboutListVo
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"相关资源查询 异常..."
);
e
.
printStackTrace
();
}
return
CallBack
.
success
(
xglist
);
}
/**
* 正则,过滤特殊字符
*
* @param input
* @return
* @author ycw
* @date: 2019年3月1日 下午3:19:46
*/
private
String
regEx
(
String
input
)
{
// 去掉特殊字符
if
(!
input
.
trim
().
equals
(
""
))
{
String
regEx
=
"[`~!@#$%^&*()+=|{}':;',\\[\\] .<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"
;
Pattern
p
=
Pattern
.
compile
(
regEx
);
Matcher
m
=
p
.
matcher
(
input
);
input
=
m
.
replaceAll
(
""
).
trim
();
}
return
input
;
}
}
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/controller/pc/index/FgIndexController.java
0 → 100644
浏览文件 @
c11d5ce9
package
com
.
zrqx
.
resource
.
fg
.
controller
.
pc
.
index
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.solr.client.solrj.SolrClient
;
import
org.apache.solr.client.solrj.SolrQuery
;
import
org.apache.solr.client.solrj.response.QueryResponse
;
import
org.apache.solr.common.SolrDocument
;
import
org.apache.solr.common.SolrDocumentList
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.enums.resource.EbookPromptMessageEnum
;
import
com.zrqx.core.form.resource.fg.ebook.FgQueryEbookInfoForm
;
import
com.zrqx.core.model.resource.ebook.Ebook
;
import
com.zrqx.core.model.resource.ebook.EbookImage
;
import
com.zrqx.core.util.bean.BeanUtils
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.fg.diytype.FgDiyTypeVo
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookListVO
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookVO
;
import
com.zrqx.core.vo.resource.fg.pc.index.FgIndexEbookListVO
;
import
com.zrqx.core.vo.resource.fg.resource.FgAboutListVo
;
import
com.zrqx.resource.fg.service.ebook.FgEBookImageService
;
import
com.zrqx.resource.fg.service.ebook.FgEbookDiyTypeService
;
import
com.zrqx.resource.fg.service.ebook.FgEbookService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
tk.mybatis.mapper.entity.Example
;
/**
* 电子书管理-controller
* @author Conan
* @date 2018年7月13日上午10:02:31
*/
@RestController
@RequestMapping
(
ResourceRequestPath
.
FG
+
ResourceRequestPath
.
INDEX
)
@Api
(
description
=
"前台-首页"
)
public
class
FgIndexController
{
@Autowired
private
FgEBookImageService
bookservice
;
@Autowired
private
FgEbookService
ebookservice
;
@Autowired
private
FgEbookDiyTypeService
ebookDiyTypeService
;
@Autowired
private
SolrClient
client
;
@ApiOperation
(
"查询电子书列表"
)
@GetMapping
(
ResourceRequestPath
.
PAGE
)
public
CallBack
<
List
<
FgIndexEbookListVO
>>
getBookList
()
{
List
<
FgIndexEbookListVO
>
list
=
ebookservice
.
list
();
return
CallBack
.
success
(
list
);
}
@ApiOperation
(
"根据id查找电子书"
)
@GetMapping
(
ResourceRequestPath
.
GET_OID
)
public
CallBack
<
FgEbookVO
>
echo
(
@PathVariable
String
oid
)
{
FgEbookVO
vo
=
ebookservice
.
ebookOneInfoById
(
oid
);
return
CallBack
.
success
(
vo
);
}
@ApiOperation
(
value
=
"权限提示列表"
,
notes
=
"权限提示列表"
)
@GetMapping
(
value
=
ResourceRequestPath
.
MESSAGE
)
public
CallBack
<
Map
<
String
,
String
>>
getMessage
()
{
Map
<
String
,
String
>
map
=
EbookPromptMessageEnum
.
getAllEnumMap
();
return
CallBack
.
success
(
map
);
}
@ApiOperation
(
value
=
"查询电子书全部信息(跨服务调用)"
,
notes
=
"根据ID查询"
)
@GetMapping
(
value
=
ResourceRequestPath
.
OID
)
public
CallBack
<
FgEbookVO
>
getOneById
(
@PathVariable
String
oid
)
{
FgEbookVO
vo
=
new
FgEbookVO
();
EbookImage
book
=
bookservice
.
selectByPrimaryKey
(
oid
);
BeanUtils
.
copyProperties
(
book
,
vo
);
Ebook
ebook
=
ebookservice
.
selectByPrimaryKey
(
oid
);
BeanUtils
.
copyProperties
(
ebook
,
vo
);
return
CallBack
.
success
(
vo
);
}
@ApiOperation
(
value
=
"通过id集合查询(跨服务调用)"
,
notes
=
"通过id集合查询电子书信息"
)
@GetMapping
(
value
=
ResourceRequestPath
.
IDLIST
)
public
CallBack
<
List
<
FgEbookVO
>>
getListByIds
(
@RequestParam
(
value
=
"ids"
)
List
<
String
>
ids
)
{
Example
example
=
bookservice
.
createExample
();
example
.
createCriteria
().
andIn
(
"id"
,
ids
);
List
<
EbookImage
>
books
=
bookservice
.
selectByExample
(
example
);
List
<
FgEbookVO
>
vos
=
BeanUtils
.
copyList
(
books
,
FgEbookVO
.
class
);
vos
.
forEach
(
vo
->{
Ebook
ebook
=
ebookservice
.
selectByPrimaryKey
(
vo
.
getId
());
BeanUtils
.
copyProperties
(
ebook
,
vo
);
});
return
CallBack
.
success
(
vos
);
}
@ApiOperation
(
value
=
"获取图书对应类型的全部自定义分类"
,
notes
=
"查询"
)
@GetMapping
(
value
=
ResourceRequestPath
.
ALL
+
ResourceRequestPath
.
DIYTYPE
)
public
CallBack
<
List
<
FgDiyTypeVo
>>
queryAllDiyType
(
@RequestParam
List
<
String
>
ids
){
return
CallBack
.
success
(
ebookDiyTypeService
.
queryAllDiyType
(
ids
));
}
@ApiOperation
(
value
=
"图书相关资源"
,
notes
=
"查询图书相关资源"
)
@GetMapping
(
value
=
ResourceRequestPath
.
RELATION_RESOURCE
+
ResourceRequestPath
.
OID
)
public
CallBack
<
List
<
FgAboutListVo
>>
queryByRelation
(
@PathVariable
String
oid
){
Ebook
ebook
=
ebookservice
.
selectByPrimaryKey
(
oid
);
// 相关资源
String
guanjianzi
=
ebook
.
getName
();
List
<
FgAboutListVo
>
xglist
=
new
ArrayList
<
FgAboutListVo
>();
if
(
guanjianzi
==
null
||
guanjianzi
.
equals
(
""
)){
//title查询结果list
//封装数据...
return
CallBack
.
success
(
xglist
);
}
guanjianzi
=
regEx
(
guanjianzi
);
try
{
SolrQuery
query
=
new
SolrQuery
();
query
.
setStart
(
0
).
setRows
(
12
).
setQuery
(
"name:"
+
guanjianzi
);
query
.
set
(
"fq"
,
" resourceType:3 || resourceType:4 || resourceType:1"
);
QueryResponse
resp
=
client
.
query
(
query
);
SolrDocumentList
sdl
=
resp
.
getResults
();
System
.
out
.
println
(
"相关资源:"
+
sdl
.
getNumFound
()+
"条结果"
);
for
(
SolrDocument
sd:
sdl
)
{
String
id
=
sd
.
getFieldValue
(
"id"
).
toString
();
String
title
=
sd
.
getFieldValue
(
"name"
).
toString
().
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
if
(
id
.
equals
(
oid
)){
continue
;
}
Integer
resourceType
=(
Integer
)
sd
.
getFieldValue
(
"resourceType"
);
String
title2
=
title
.
substring
(
0
,
title
.
length
()<=
100
?
title
.
length
():
100
);
FgAboutListVo
fgAboutListVo
=
new
FgAboutListVo
();
fgAboutListVo
.
setResourceId
(
id
);
fgAboutListVo
.
setName
(
title
);
fgAboutListVo
.
setResourceType
(
resourceType
);
//fgAboutListVo.setResourceType(resourceType);
xglist
.
add
(
fgAboutListVo
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"相关资源查询 异常..."
);
e
.
printStackTrace
();
}
return
CallBack
.
success
(
xglist
);
}
/**
* 正则,过滤特殊字符
*
* @param input
* @return
* @author ycw
* @date: 2019年3月1日 下午3:19:46
*/
private
String
regEx
(
String
input
)
{
// 去掉特殊字符
if
(!
input
.
trim
().
equals
(
""
))
{
String
regEx
=
"[`~!@#$%^&*()+=|{}':;',\\[\\] .<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"
;
Pattern
p
=
Pattern
.
compile
(
regEx
);
Matcher
m
=
p
.
matcher
(
input
);
input
=
m
.
replaceAll
(
""
).
trim
();
}
return
input
;
}
}
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/mapper/ebook/FgEbookMapper.java
浏览文件 @
c11d5ce9
...
...
@@ -12,6 +12,7 @@ import com.zrqx.core.form.resource.fg.ebook.FgQueryRecommedEbookForm;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.resource.ebook.Ebook
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookListVO
;
import
com.zrqx.core.vo.resource.fg.pc.index.FgIndexEbookListVO
;
/**
* 电子书-mapper
...
...
@@ -200,4 +201,9 @@ public interface FgEbookMapper extends BaseMapper<Ebook>{
+
"</if>"
+
"</script>"
)
List
<
String
>
searchList
(
@Param
(
"name"
)
String
name
);
@Select
(
"<script>"
+
"select be.id,be.name,be.bookCover,be.price FROM res_ebook be "
+
"where be.bookStatus = 1 order by be.uploadTime desc"
+
"</script>"
)
List
<
FgIndexEbookListVO
>
list
();
}
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/service/ebook/FgEbookService.java
浏览文件 @
c11d5ce9
...
...
@@ -11,6 +11,7 @@ import com.zrqx.core.service.BaseService;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookListVO
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookVO
;
import
com.zrqx.core.vo.resource.fg.pc.index.FgIndexEbookListVO
;
/**
* 电子书-service
...
...
@@ -80,5 +81,7 @@ public interface FgEbookService extends BaseService<Ebook, String>{
* @date: 2019年5月31日 上午10:33:58
*/
FgEbookVO
getInfoBysolrDocument
(
SolrDocument
solrDocument
);
List
<
FgIndexEbookListVO
>
list
();
}
com.zrqx.resource/src/main/java/com/zrqx/resource/fg/service/ebook/FgEbookServiceImpl.java
浏览文件 @
c11d5ce9
...
...
@@ -36,6 +36,7 @@ import com.zrqx.core.util.page.PageParam;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookListVO
;
import
com.zrqx.core.vo.resource.fg.ebook.FgEbookVO
;
import
com.zrqx.core.vo.resource.fg.pc.index.FgIndexEbookListVO
;
import
com.zrqx.resource.bg.service.ebook.EBookImageService
;
import
com.zrqx.resource.commons.Redis
;
import
com.zrqx.resource.fg.client.order.FgOrderClient
;
...
...
@@ -295,4 +296,11 @@ public class FgEbookServiceImpl extends BaseServiceImpl<Ebook, String> implement
}
}*/
}
@Override
public
List
<
FgIndexEbookListVO
>
list
()
{
// TODO Auto-generated method stub
return
ebookMapper
.
list
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论