Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
rszt
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
rszt
Commits
82aeca72
提交
82aeca72
authored
12月 14, 2020
作者:
renjiancai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
d3f19882
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
0 行增加
和
372 行删除
+0
-372
VideoLibraryController.java
...ce/bg/controller/videolibrary/VideoLibraryController.java
+0
-223
SolrManage.java
...e/src/main/java/com/zrqx/resource/bg/solr/SolrManage.java
+0
-149
没有找到文件。
com.zrqx.resource/src/main/java/com/zrqx/resource/bg/controller/videolibrary/VideoLibraryController.java
deleted
100644 → 0
浏览文件 @
d3f19882
package
com
.
zrqx
.
resource
.
bg
.
controller
.
videolibrary
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
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.enums.resource.LibraryStatusEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.resource.bg.recommend.UpdateRecommendResourceForm
;
import
com.zrqx.core.form.resource.bg.videolibrary.BatchUpdateVideoLibraryForm
;
import
com.zrqx.core.form.resource.bg.videolibrary.QueryVideoLibraryForm
;
import
com.zrqx.core.form.resource.bg.videolibrary.SaveUpdateVideoLibraryForm
;
import
com.zrqx.core.form.resource.bg.videolibrary.SaveVideoLibraryForm
;
import
com.zrqx.core.model.resource.videolibrary.VideoLibrary
;
import
com.zrqx.core.model.resource.videolibrary.VideoLibraryDiyType
;
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.videolibrary.VideoLibraryListVO
;
import
com.zrqx.core.vo.resource.videolibrary.VideoLibraryOneVO
;
import
com.zrqx.resource.bg.manage.RecommendResourceManage
;
import
com.zrqx.resource.bg.service.recommend.RecommendResourceService
;
import
com.zrqx.resource.bg.service.videolibrary.VideoLibraryDiyTypeService
;
import
com.zrqx.resource.bg.service.videolibrary.VideoLibraryService
;
import
com.zrqx.resource.bg.solr.SolrManage
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
tk.mybatis.mapper.entity.Example
;
/**
* 视频库Controller
*/
@RestController
@RequestMapping
(
"/bg/video-library"
)
@Api
(
description
=
"资源管理-视频库"
)
public
class
VideoLibraryController
{
@Autowired
private
SolrManage
solrManage
;
@Autowired
private
VideoLibraryService
service
;
@Autowired
private
VideoLibraryDiyTypeService
vdrService
;
@Autowired
private
RecommendResourceService
recommendResourceService
;
@Autowired
private
RecommendResourceManage
recommendResourceManage
;
@ApiOperation
(
value
=
"新增/修改 视频资源"
,
notes
=
"新增/修改 视频资源"
)
@PostMapping
(
value
=
"/save"
)
public
CallBack
<
Boolean
>
save
(
@RequestBody
SaveUpdateVideoLibraryForm
form
)
throws
IOException
{
if
(!
service
.
saveOrUpdate
(
form
))
{
throw
new
BaseException
(
"操作失败"
);
}
if
(
StringUtils
.
isNotBlank
(
form
.
getId
()))
{
VideoLibrary
entity
=
service
.
selectByPrimaryKey
(
form
.
getId
());
// 推荐位内容修改
UpdateRecommendResourceForm
res
=
new
UpdateRecommendResourceForm
();
res
.
setResId
(
form
.
getId
());
res
.
setResType
(
entity
.
getResourceType
());
res
.
setResImg
(
form
.
getImg
());
res
.
setSource
(
form
.
getAdSlogan
());
res
.
setResName
(
form
.
getName
());
recommendResourceService
.
updateResourceContent
(
res
);
}
// 增量索引
solrManage
.
asyncDeltaIndex
();
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"导入视频"
,
notes
=
"导入视频"
)
@PostMapping
(
value
=
"/import"
)
public
CallBack
<
Boolean
>
save
(
@RequestBody
SaveVideoLibraryForm
form
)
throws
IOException
{
if
(!
service
.
batchInsert
(
form
))
{
throw
new
BaseException
(
"操作失败"
);
}
// 增量索引
solrManage
.
asyncDeltaIndex
();
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"批量修改分类"
,
notes
=
"批量修改分类"
)
@PostMapping
(
value
=
"/batch/update/diytype"
)
public
CallBack
<
Boolean
>
updateDivType
(
@RequestBody
BatchUpdateVideoLibraryForm
form
)
{
List
<
VideoLibraryDiyType
>
list
=
new
ArrayList
<
VideoLibraryDiyType
>();
form
.
getIds
().
forEach
(
alId
->
{
// 刪除原有的分类
VideoLibraryDiyType
ob
=
new
VideoLibraryDiyType
();
ob
.
setVlId
(
alId
);
vdrService
.
delete
(
ob
);
// 添加
List
<
VideoLibraryDiyType
>
ls
=
form
.
getDiyType
();
ls
.
forEach
(
l
->
l
.
setVlId
(
alId
));
list
.
addAll
(
ls
);
});
if
(!
vdrService
.
insertList
(
list
))
{
throw
new
BaseException
(
"操作失败"
);
}
return
CallBack
.
success
();
}
/*@ApiOperation(value = "批量修改销售设置", notes = "批量修改销售设置")
@PostMapping(value = "/batch/update/price")
public CallBack<Boolean> updatePrice(@RequestBody BatchUpdateVideoLibraryForm form) throws IOException {
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
VideoLibrary entity = new VideoLibrary();
if (PriceOptionEnum.STATUS_0.getCode().equals(form.getPriceOption())) {
form.setRealPrice(new BigDecimal(0));
}
entity.setRealPrice(form.getRealPrice());
entity.setPrice(form.getPrice());
entity.setPriceOption(form.getPriceOption());
if (form.getSalesType() != null && form.getSalesType() == 1) {
form.getIds().forEach(f -> {
VideoLibrary videoLibrary = service.selectByPrimaryKey(f);
if (!videoLibrary.getSalesType().equals(form.getSalesType())) {
videoLibrary.setCourseId(null);
service.updateByPrimaryKey(videoLibrary);
}
});
}
if (form.getSalesType() != null && form.getSalesType() == 2) {
form.getIds().forEach(f -> {
VideoLibrary videoLibrary = service.selectByPrimaryKey(f);
if (!videoLibrary.getSalesType().equals(form.getSalesType())) {
// 删除推荐位资源
Example example1 = new Example(RecommendResource.class);
example1.createCriteria().andEqualTo("resId", f);
recommendResourceService.deleteByExample(example1);
}
});
}
entity.setSalesType(form.getSalesType());
entity.setUpdateTime(new Date());
if (!service.UpdateByExampleSelective(entity, example)) {
throw new BaseException("操作失败");
}
// 增量索引
solrManage.asyncDeltaIndex();
return CallBack.success();
}*/
@ApiOperation
(
value
=
"批量 上架/下架"
,
notes
=
"批量 上架/下架"
)
@PostMapping
(
value
=
"/batch/update/updown"
)
public
CallBack
<
Boolean
>
updateShowState
(
@RequestBody
BatchUpdateVideoLibraryForm
form
)
throws
IOException
{
VideoLibrary
f
=
new
VideoLibrary
();
f
.
setStatus
(
form
.
getStatus
());
f
.
setUpdateTime
(
new
Date
());
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andIn
(
"id"
,
form
.
getIds
());
service
.
UpdateByExampleSelective
(
f
,
example
);
//修改关联推荐位中的状态
recommendResourceManage
.
updateStatus
(
form
.
getIds
(),
5
,
form
.
getStatus
());
// 增量索引
solrManage
.
asyncDeltaIndex
();
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"删除"
,
notes
=
"删除"
)
@PostMapping
(
value
=
"/delete/{oid}"
)
public
CallBack
<
Boolean
>
delete
(
@PathVariable
String
oid
)
{
VideoLibrary
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
)
{
return
CallBack
.
success
(
service
.
batchDelete
(
ids
));
}
@ApiOperation
(
value
=
"查询"
,
notes
=
"根据ID查询"
)
@GetMapping
(
value
=
"/get/{oid}"
)
public
CallBack
<
VideoLibraryOneVO
>
getById
(
@PathVariable
String
oid
)
{
VideoLibrary
entity
=
service
.
selectByPrimaryKey
(
oid
);
VideoLibraryOneVO
vo
=
new
VideoLibraryOneVO
();
BeanUtils
.
copyProperties
(
entity
,
vo
);
Example
example
=
vdrService
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"vlId"
,
oid
);
List
<
VideoLibraryDiyType
>
list
=
vdrService
.
selectByExample
(
example
);
// 组装自定义分类
vo
.
setDiyType
(
list
);
return
CallBack
.
success
(
vo
);
}
@ApiOperation
(
value
=
"分页查询"
,
notes
=
"查询列表"
)
@GetMapping
(
value
=
"/page"
)
public
CallBack
<
PageInfo
<
VideoLibraryListVO
>>
page
(
QueryVideoLibraryForm
form
,
PageParam
pageParam
)
{
return
CallBack
.
success
(
service
.
page
(
form
,
pageParam
));
}
/*@ApiOperation(value = "分页查询直播回放管理", notes = "查询列表直播回放管理")
@GetMapping(value = "/live/page")
public CallBack<PageInfo<VideoLibraryListVO>> livePage(QueryVideoLibraryForm form, PageParam pageParam) {
return CallBack.success(service.livePage(form, pageParam));
}*/
/* @ApiOperation("导入元数据Excel")
@PostMapping(value = "/importExcel")
public CallBack<?> importVideo(@RequestParam("file") MultipartFile file) throws Exception {
ImportLabelVo vo = service.importLabelExcel(file);
return CallBack.success(vo);
}*/
}
com.zrqx.resource/src/main/java/com/zrqx/resource/bg/solr/SolrManage.java
deleted
100644 → 0
浏览文件 @
d3f19882
package
com
.
zrqx
.
resource
.
bg
.
solr
;
import
java.io.IOException
;
import
java.security.NoSuchAlgorithmException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
org.apache.commons.lang3.StringUtils
;
import
org.jboss.logging.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
com.zrqx.resource.commons.Redis
;
/**
* 全文检索更新索引
* @author ycw
* @date 2019年4月12日上午11:59:56
*/
@Component
public
class
SolrManage
extends
SolrAdapter
{
private
static
final
Logger
log
=
Logger
.
getLogger
(
SolrManage
.
class
);
@Value
(
"${solr-quartz}"
)
private
Boolean
offon
;
@Autowired
private
Redis
redis
;
/**
* 生成索引(全部),每天凌晨2点执行
*
* @author ycw
* @date: 2019年4月12日 上午11:57:20
*/
@Scheduled
(
cron
=
"0 0 2 * * ? "
)
public
void
commandIndex
(){
if
(
offon
){
SimpleDateFormat
f
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
log
.
info
(
"定时任务1:全文检索全部更新资源库索引开始...时间:"
+
f
.
format
(
new
Date
()));
String
result
=
this
.
createIndex
();
if
(
result
.
equals
(
"1"
)){
log
.
info
(
"定时任务1:全文检索更新成功...时间:"
+
f
.
format
(
new
Date
()));
}
else
{
log
.
info
(
"定时任务1:全文检索更新失败...时间:"
+
f
.
format
(
new
Date
()));
}
}
}
/**
* 增量更新
*
* @author ycw
* @date: 2019年4月12日 下午4:57:04
*/
/* @Scheduled(cron="0 0/30 * * * ? ") */
public
void
updateDeltaIndex
(){
if
(
offon
){
SimpleDateFormat
f
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
log
.
info
(
"定时任务2:全文检索全部更新资源库索引开始...时间:"
+
f
.
format
(
new
Date
()));
String
result
=
this
.
deltaImportIndex
();
if
(
result
.
equals
(
"1"
)){
log
.
info
(
"定时任务2:全文检索更新成功...时间:"
+
f
.
format
(
new
Date
()));
}
else
{
log
.
info
(
"定时任务2:全文检索更新失败...时间:"
+
f
.
format
(
new
Date
()));
}
}
}
/**
* 异步增量索引
*
* @author ycw
* @throws IOException
* @date: 2020年5月15日 上午10:13:51
*/
public
void
asyncDeltaIndex
()
throws
IOException
{
if
(
StringUtils
.
isBlank
(
redis
.
get
(
"solr_status"
))){
redis
.
set
(
"solr_status"
,
"1"
);
}
else
{
if
(!
redis
.
get
(
"solr_status"
).
equals
(
"1"
)){
return
;
}
}
SimpleDateFormat
f
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
ExecutorService
executor
=
Executors
.
newCachedThreadPool
();
executor
.
submit
(
new
Runnable
()
{
public
void
run
()
{
try
{
redis
.
set
(
"solr_status"
,
"0"
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
log
.
info
(
"全文检索资源库增量索引开始...时间:"
+
f
.
format
(
new
Date
()));
deltaImportIndex
();
log
.
info
(
"全文检索资源库增量索引成功...时间:"
+
f
.
format
(
new
Date
()));
try
{
redis
.
set
(
"solr_status"
,
"1"
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
});
}
/**
* 异步全量索引
*
* @author ycw
* @throws NoSuchAlgorithmException
* @throws IOException
* @date: 2020年5月15日 上午10:13:54
*/
public
void
asyncCreateIndex
()
throws
IOException
{
if
(
StringUtils
.
isBlank
(
redis
.
get
(
"solr_status"
))){
redis
.
set
(
"solr_status"
,
"1"
);
}
else
{
if
(!
redis
.
get
(
"solr_status"
).
equals
(
"1"
)){
return
;
}
}
SimpleDateFormat
f
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
ExecutorService
executor
=
Executors
.
newCachedThreadPool
();
executor
.
submit
(
new
Runnable
()
{
public
void
run
()
{
try
{
redis
.
set
(
"solr_status"
,
"0"
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
log
.
info
(
"全文检索资源库全量索引开始...时间:"
+
f
.
format
(
new
Date
()));
createIndex
();
log
.
info
(
"全文检索资源库全量索引成功...时间:"
+
f
.
format
(
new
Date
()));
try
{
redis
.
set
(
"solr_status"
,
"1"
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
});
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论