From d083fa2946c515f9827e5d49bf70773816d3cd43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=BB=84=E7=8B=97=E6=A8=AA=E6=89=AB=E5=A3=AB?=
=?UTF-8?q?=E5=8A=9B=E6=9E=B6?= <949655436@qq.com>
Date: Sun, 15 Jan 2023 14:29:49 +0800
Subject: [PATCH] =?UTF-8?q?2023=E5=B9=B41=E6=9C=8815=E6=97=A514:26:48?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 35 ++-
.../java/com/platform/config/CorsConfig.java | 25 +-
.../java/com/platform/config/ShiroConfig.java | 1 +
.../com/platform/config/SwaggerConfig.java | 5 +-
.../modules/app/config/WebMvcConfig.java | 22 +-
.../controller/AppLiveSceneController.java | 3 +-
.../controller/LiveForeignController.java | 24 +-
.../service/impl/LiveForeignServiceImpl.java | 21 +-
.../controller/LiveChannelController.java | 38 ++-
.../controller/LiveCommentController.java | 28 +-
.../live/controller/LiveReportController.java | 28 +-
.../live/controller/LiveSceneController.java | 33 ++-
.../controller/MediaUploadController.java | 269 ++++++++++++------
.../modules/live/dao/LiveChannelDao.java | 11 +-
.../live/dao/LiveChannelTenantDao.java | 26 ++
.../live/entity/LiveChannelTenantEntity.java | 37 +++
.../live/service/LiveChannelService.java | 26 +-
.../service/LiveChannelTenantService.java | 24 ++
.../service/impl/LiveChannelServiceImpl.java | 52 ++++
.../impl/LiveChannelTenantServiceImpl.java | 32 +++
.../impl/LiveMultimediaServiceImpl.java | 18 +-
.../impl/TranscodingTaskServiceImpl.java | 4 +-
.../modules/oss/cloud/OSSFactory.java | 10 +-
.../oss/cloud/QcloudCloudStorageService.java | 192 ++++++-------
.../oss/controller/SysOssController.java | 5 +-
.../modules/plm/util/CosUtilProperties.java | 68 +++++
.../modules/plm/util/ImageFileProperties.java | 45 +++
.../sys/controller/SysTenantController.java | 8 +-
.../sys/controller/SysUserController.java | 10 +-
.../modules/sys/dao/SysTenantDao.java | 9 +
.../modules/sys/dto/SaveTenantDTO.java | 8 +
.../modules/sys/entity/SysTenantEntity.java | 39 ++-
.../modules/sys/service/SysTenantService.java | 4 +
.../service/impl/SysTenantServiceImpl.java | 81 +++++-
.../trtc/controller/TrtcController.java | 2 +-
.../video/controller/VideoController.java | 2 +-
src/main/resources/application-dev.yml | 8 +-
src/main/resources/application-live-prod.yml | 2 +-
.../resources/mapper/live/LiveChannelDao.xml | 42 ++-
.../mapper/live/LiveChannelTenantDao.xml | 26 ++
.../resources/mapper/live/LiveSceneDao.xml | 21 +-
.../resources/mapper/sys/SysTenantDao.xml | 13 +-
42 files changed, 1045 insertions(+), 312 deletions(-)
create mode 100644 src/main/java/com/platform/modules/live/dao/LiveChannelTenantDao.java
create mode 100644 src/main/java/com/platform/modules/live/entity/LiveChannelTenantEntity.java
create mode 100644 src/main/java/com/platform/modules/live/service/LiveChannelTenantService.java
create mode 100644 src/main/java/com/platform/modules/live/service/impl/LiveChannelTenantServiceImpl.java
create mode 100644 src/main/java/com/platform/modules/plm/util/CosUtilProperties.java
create mode 100644 src/main/java/com/platform/modules/plm/util/ImageFileProperties.java
create mode 100644 src/main/resources/mapper/live/LiveChannelTenantDao.xml
diff --git a/pom.xml b/pom.xml
index 2e5e52a..8dce506 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,8 @@
1.8
2.1.9
2.1.9
- 5.1.38
+
+ 8.0.26
1.1.3
2.3.0
2.6
@@ -33,7 +34,7 @@
0.0.9
[7.2.0, 7.2.99]
3.10.2
- 4.4
+ 5.6.8
2.9.2
2.9.9
7.7.0
@@ -100,6 +101,12 @@
druid-spring-boot-starter
${druid.version}
+
+
+
+
+
+
org.quartz-scheduler
quartz
@@ -274,10 +281,10 @@
20170516
- net.sf.json-lib
- json-lib
- 2.4
- jdk15
+ net.sf.json-lib
+ json-lib
+ 2.4
+ jdk15
com.google.code.gson
@@ -314,7 +321,7 @@
core
3.3.3
-
+
com.github.tencentyun
tls-sig-api
@@ -325,6 +332,18 @@
IKAnalyzer-lucene
8.0.0
+
+
+
+
+
+
+
+
+
+
+
+
@@ -353,7 +372,7 @@
true
-
+
org.codehaus.mojo
wagon-maven-plugin
diff --git a/src/main/java/com/platform/config/CorsConfig.java b/src/main/java/com/platform/config/CorsConfig.java
index 921fbbe..d327719 100644
--- a/src/main/java/com/platform/config/CorsConfig.java
+++ b/src/main/java/com/platform/config/CorsConfig.java
@@ -1,6 +1,10 @@
package com.platform.config;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@@ -14,5 +18,24 @@ public class CorsConfig extends WebMvcConfigurerAdapter {
.allowCredentials(true)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.maxAge(3600);
+
}
-}
\ No newline at end of file
+ @Bean
+ public CorsFilter corsFilter() {
+ final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
+ final CorsConfiguration corsConfiguration = new CorsConfiguration();
+ /*是否允许请求带有验证信息*/
+ corsConfiguration.setAllowCredentials(true);
+ /*允许访问的客户端域名*/
+ corsConfiguration.addAllowedOrigin("*");
+ /*允许服务端访问的客户端请求头*/
+ corsConfiguration.addAllowedHeader("*");
+ /*允许访问的方法名,GET POST等*/
+ corsConfiguration.addAllowedMethod("*");
+ urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
+ return new CorsFilter(urlBasedCorsConfigurationSource);
+ }
+
+
+
+}
diff --git a/src/main/java/com/platform/config/ShiroConfig.java b/src/main/java/com/platform/config/ShiroConfig.java
index 35e2a08..a6f25e1 100644
--- a/src/main/java/com/platform/config/ShiroConfig.java
+++ b/src/main/java/com/platform/config/ShiroConfig.java
@@ -63,6 +63,7 @@ public class ShiroConfig {
filterMap.put("/druid/**", "anon");
filterMap.put("/app/**", "anon");
filterMap.put("/test", "anon");
+ filterMap.put("/profile/**", "anon");
filterMap.put("/test/**", "anon");
filterMap.put("/sys/login", "anon");
filterMap.put("/video/**", "anon");
diff --git a/src/main/java/com/platform/config/SwaggerConfig.java b/src/main/java/com/platform/config/SwaggerConfig.java
index f642571..bcd1f54 100644
--- a/src/main/java/com/platform/config/SwaggerConfig.java
+++ b/src/main/java/com/platform/config/SwaggerConfig.java
@@ -1,7 +1,9 @@
package com.platform.config;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
+import com.platform.modules.plm.util.ImageFileProperties;
import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
@@ -28,6 +30,7 @@ import java.util.List;
@EnableSwaggerBootstrapUI
public class SwaggerConfig extends WebMvcConfigurerAdapter {
+
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
@@ -59,4 +62,4 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
.build();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/platform/modules/app/config/WebMvcConfig.java b/src/main/java/com/platform/modules/app/config/WebMvcConfig.java
index 076edc1..cd93d41 100644
--- a/src/main/java/com/platform/modules/app/config/WebMvcConfig.java
+++ b/src/main/java/com/platform/modules/app/config/WebMvcConfig.java
@@ -3,10 +3,12 @@ package com.platform.modules.app.config;
import java.util.List;
import com.platform.modules.foreign.oauth2.ForeignOAuth2Interceptor;
+import com.platform.modules.plm.util.ImageFileProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.platform.modules.app.interceptor.AuthorizationInterceptor;
@@ -18,6 +20,8 @@ import com.platform.modules.qk.interceptor.CloudClipsAuthorizationInterceptor;
*/
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
+ @Autowired
+ private ImageFileProperties imageFileProperties;
@Autowired
private AuthorizationInterceptor authorizationInterceptor;
@Autowired
@@ -29,15 +33,23 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
- registry.addInterceptor(qukanAuthorizationInterceptor).addPathPatterns("/api/cloud/clips/**");
+ registry.addInterceptor(authorizationInterceptor).addPathPatterns("/profile/**");
+// registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
+// registry.addInterceptor(qukanAuthorizationInterceptor).addPathPatterns("/api/cloud/clips/**");
// TODO 20190228 TROY 暂时只拦截列表,详情页数据需要公开,无法鉴权
- registry.addInterceptor(foreignOAuth2Interceptor).addPathPatterns("/foreign/live/scene/list")
- .addPathPatterns("/foreign/live/channel/list").addPathPatterns("/foreign/live/reporter/list").addPathPatterns("/foreign/live/task/allocation");
+// registry.addInterceptor(foreignOAuth2Interceptor).addPathPatterns("/foreign/live/scene/list")
+// .addPathPatterns("/foreign/live/channel/list").addPathPatterns("/foreign/live/reporter/list").addPathPatterns("/foreign/live/task/allocation");
}
@Override
public void addArgumentResolvers(List argumentResolvers) {
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
}
-}
\ No newline at end of file
+
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ /** 本地文件上传路径 */
+ registry.addResourceHandler("/profile/**")
+ .addResourceLocations("file:"+imageFileProperties.getImagePath()+"/");
+ }
+}
diff --git a/src/main/java/com/platform/modules/app/controller/AppLiveSceneController.java b/src/main/java/com/platform/modules/app/controller/AppLiveSceneController.java
index d0dd50b..a026379 100644
--- a/src/main/java/com/platform/modules/app/controller/AppLiveSceneController.java
+++ b/src/main/java/com/platform/modules/app/controller/AppLiveSceneController.java
@@ -86,7 +86,8 @@ public class AppLiveSceneController extends AppAbstractController {
@ApiImplicitParam(value = "标题图", name = "titleFile", dataType = "file"),
@ApiImplicitParam(value = "视频文件", name = "videoFile", dataType = "file")})
public R update(@ModelAttribute AppSceneEntityVo liveScene, Integer userId,
- @RequestParam(value = "titleFile", required = false) MultipartFile titleFile, @RequestParam(value = "videoFile", required = false) MultipartFile videoFile) {
+ @RequestParam(value = "titleFile", required = false) MultipartFile titleFile,
+ @RequestParam(value = "videoFile", required = false) MultipartFile videoFile) {
if (userId == null || null == liveScene || liveScene.getId() == null || liveScene.getLiveEnd() == null
|| liveScene.getLiveStart() == null || StringUtils.isBlank(liveScene.getLivePosition())
diff --git a/src/main/java/com/platform/modules/foreign/controller/LiveForeignController.java b/src/main/java/com/platform/modules/foreign/controller/LiveForeignController.java
index 6863662..1cddebd 100644
--- a/src/main/java/com/platform/modules/foreign/controller/LiveForeignController.java
+++ b/src/main/java/com/platform/modules/foreign/controller/LiveForeignController.java
@@ -9,9 +9,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import com.platform.modules.sys.controller.AbstractController;
import javax.servlet.http.HttpServletRequest;
+import com.platform.modules.sys.service.SysTenantService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -44,7 +46,7 @@ import net.sf.json.JSONObject;
*/
@RestController
@RequestMapping("/foreign/live")
-public class LiveForeignController {
+public class LiveForeignController {
@Autowired
private LiveForeignService liveForeignService;
@@ -92,6 +94,8 @@ public class LiveForeignController {
e.printStackTrace();
return R.error("信息不存在");
}
+
+
return R.ok().put("data", data);
}
@@ -102,9 +106,13 @@ public class LiveForeignController {
return R.error("缺少必要参数");
}
PageUtils pu = liveForeignService.getReportList(sceneId, page, size, reverse);
- return R.ok().put("data", pu);
- }
+ //根据机构评论默认头像
+ String tenantUrl= sysTenantService.selectTenant(sceneId);
+ return R.ok().put("data", pu).put("tenantUrl",tenantUrl);
+ }
+ @Autowired
+ private SysTenantService sysTenantService;
@GetMapping("/comment/list")
@ResponseBody
public R commentList(Integer sceneId, Integer page, Integer size) {
@@ -112,7 +120,9 @@ public class LiveForeignController {
return R.error("缺少必要参数");
}
List list = liveForeignService.getCommentList(sceneId, page, size);
- return R.ok().put("data", list);
+ //根据机构评论默认头像
+ String anonymousUrl= sysTenantService.selectAnonymousurl(sceneId);
+ return R.ok().put("data", list).put("anonymousUrl",anonymousUrl);
}
@GetMapping("/caster/streamsUrl")
@@ -220,7 +230,7 @@ public class LiveForeignController {
return R.ok().put("data", reporterInterviewProcesses);
}
-
+
@SysLog("任务分配")
@PostMapping("/task/allocation")
public R taskAllocation(Integer[] reporterIds,Integer userId, MultipartFile mediaFile, Integer durationTime) {
@@ -232,7 +242,7 @@ public class LiveForeignController {
return R.ok("success");
}
-
+
@GetMapping("/weixin/getJsApiTicket")
@ResponseBody
public R getWeixinJsApiTicket (String url) {
@@ -246,7 +256,7 @@ public class LiveForeignController {
return R.error("验证信息获取失败");
}
JSONObject object = liveForeignService.getWeixinJsApiTicket(url);
-
+
if(object==null || object.isEmpty()){
return R.error("验证信息获取失败");
}
diff --git a/src/main/java/com/platform/modules/foreign/service/impl/LiveForeignServiceImpl.java b/src/main/java/com/platform/modules/foreign/service/impl/LiveForeignServiceImpl.java
index b927658..b89853c 100644
--- a/src/main/java/com/platform/modules/foreign/service/impl/LiveForeignServiceImpl.java
+++ b/src/main/java/com/platform/modules/foreign/service/impl/LiveForeignServiceImpl.java
@@ -165,6 +165,7 @@ public class LiveForeignServiceImpl implements com.platform.modules.foreign.serv
String thumb = doc.get("thumb");
entity.put("thumb",
StringUtils.isNotBlank(thumb)
+ //图片压缩
? compressImage(MaterialUtils.getMaterialUrl(thumb, foreignProperties.getMediaurl()))
: "");
entity.put("title", doc.get("title"));
@@ -364,10 +365,10 @@ public class LiveForeignServiceImpl implements com.platform.modules.foreign.serv
}
return new PageUtils(pageStore);
}
-
+
/**
* 获取分页列表数据
- *
+ *
* @param sceneId
* 现场ID 必填
* @param page
@@ -457,7 +458,7 @@ public class LiveForeignServiceImpl implements com.platform.modules.foreign.serv
liveCommentService.insert(comment);
return;
}
-
+
@Override
public JSONArray channeltList(){
@@ -466,7 +467,7 @@ public class LiveForeignServiceImpl implements com.platform.modules.foreign.serv
/**
* 处理拼接图片资源路径
- *
+ *
* @param imgsStr
* @return
*/
@@ -590,31 +591,31 @@ public class LiveForeignServiceImpl implements com.platform.modules.foreign.serv
// 返回拼接压缩后地址
return sourceUrl + liveProperties.getCompressImage().getGeometricFormat();
}
-
+
/**
* 获取微信JS验证
*/
public JSONObject getWeixinJsApiTicket(String url){
JSONObject jsonObject = new JSONObject();
-
+
JsTicketApi jsTicketApi = new JsTicketApi(liveProperties.getWeixin().getAppId(), liveProperties.getWeixin().getAppSecret(), redisUtils);
-
+
String timeStamp = System.currentTimeMillis() / 1000 + "";
String nonceStr = StringKit.getRandomString(16);
-
+
String jsapi_ticket = jsTicketApi.getJsTicketFromRedis();
if(StringUtils.isBlank(jsapi_ticket)){
return null;
}
JsSignature signature = new JsSignature(nonceStr, jsapi_ticket, timeStamp, url);
-
+
String sign = JsSignKit.sign(signature);
jsonObject.put("appid", liveProperties.getWeixin().getAppId());
jsonObject.put("timeStamp", timeStamp);
jsonObject.put("nonceStr", nonceStr);
jsonObject.put("sign", sign);
jsonObject.put("url", url);
-
+
return jsonObject;
}
}
diff --git a/src/main/java/com/platform/modules/live/controller/LiveChannelController.java b/src/main/java/com/platform/modules/live/controller/LiveChannelController.java
index a67e54e..224fc4f 100644
--- a/src/main/java/com/platform/modules/live/controller/LiveChannelController.java
+++ b/src/main/java/com/platform/modules/live/controller/LiveChannelController.java
@@ -2,6 +2,7 @@ package com.platform.modules.live.controller;
import java.util.Map;
+import com.platform.modules.live.service.LiveChannelTenantService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -32,9 +33,9 @@ import springfox.documentation.annotations.ApiIgnore;
/**
* 现场栏目信息
- *
+ *
* @author weiyan
- * @email
+ * @email
* @date 2019-03-28 10:06:27
*/
@RestController
@@ -43,7 +44,7 @@ import springfox.documentation.annotations.ApiIgnore;
public class LiveChannelController extends AbstractController{
@Autowired
private LiveChannelService liveChannelService;
-
+
/**
* 列表
*/
@@ -57,11 +58,19 @@ public class LiveChannelController extends AbstractController{
@ApiResponses({@ApiResponse(code = HttpStatus.SC_OK, message = "success", response = LiveReportEntity.class, responseContainer = "List")})
public R list(@ApiIgnore @RequestParam(required = false) Map params){
params.put("isDelete", 0);
+ Long tenantId = getUser().getTenantId();
+ params.put("tenantId",tenantId);
PageUtils page = liveChannelService.page(params);
+ //济南报业查询所有
+ if (tenantId==1){
+ PageUtils pageall =liveChannelService.pageAll(params);
+ return R.ok().put("page", pageall);
+
+ }
return R.ok().put("page", page);
}
-
-
+
+
/**
* 信息
*/
@@ -74,6 +83,8 @@ public class LiveChannelController extends AbstractController{
/**
* 保存
*/
+ @Autowired
+ private LiveChannelTenantService liveChannelTenantService;
@SysLog("保存栏目信息")
@PostMapping("/save")
@RequiresPermissions("live:channel:save")
@@ -86,9 +97,14 @@ public class LiveChannelController extends AbstractController{
return R.error("栏目标识不能为空");
}
liveChannelService.save(liveChannel, getUserId());
+ //根据企业id保存对应的栏目
+ Long tenantId = getUser().getTenantId();
+ Integer channelId = liveChannel.getId();
+ liveChannelTenantService.saveByTenantId(tenantId,channelId);
+
return R.ok();
}
-
+
/**
* 修改
*/
@@ -109,19 +125,23 @@ public class LiveChannelController extends AbstractController{
liveChannelService.update(liveChannel, getUserId());
return R.ok();
}
-
+
/**
* 删除
*/
+
@SysLog("删除栏目信息")
@PostMapping("/delete")
@RequiresPermissions("live:channel:delete")
@ApiOperation("删除栏目信息")
public R delete(Integer[] ids){
liveChannelService.deleteBatch(ids, getUserId());
+ //删除关联表live_channel_tenant 对应数据
+ liveChannelTenantService.deleteChannelTenantBatch(ids,getUserId());
+
return R.ok();
}
-
+
/**
* 显示
*/
@@ -167,5 +187,5 @@ public class LiveChannelController extends AbstractController{
liveChannelService.priority(ids, prioritys, getUserId());
return R.ok();
}
-
+
}
diff --git a/src/main/java/com/platform/modules/live/controller/LiveCommentController.java b/src/main/java/com/platform/modules/live/controller/LiveCommentController.java
index ef4fa55..937e5db 100644
--- a/src/main/java/com/platform/modules/live/controller/LiveCommentController.java
+++ b/src/main/java/com/platform/modules/live/controller/LiveCommentController.java
@@ -2,6 +2,8 @@ package com.platform.modules.live.controller;
import java.util.Map;
+import com.platform.modules.sys.controller.SysTenantController;
+import com.platform.modules.sys.service.SysTenantService;
import org.apache.http.HttpStatus;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,9 +32,9 @@ import springfox.documentation.annotations.ApiIgnore;
/**
* 现场评论
- *
+ *
* @author weiyan
- * @email
+ * @email
* @date 2019-02-15 17:49:07
*/
@RestController
@@ -41,11 +43,12 @@ import springfox.documentation.annotations.ApiIgnore;
public class LiveCommentController extends AbstractController{
@Autowired
private LiveCommentService liveCommentService;
-
+
/**
* 列表
*/
-
+@Autowired
+private SysTenantService sysTenantService;
@GetMapping("/list")
@RequiresPermissions("live:comment:list")
@ApiOperation("评论列表")
@@ -59,10 +62,11 @@ public class LiveCommentController extends AbstractController{
public R list(@ApiIgnore @RequestParam(required = false) Map params){
params.put("isDelete", 0);
PageUtils page = liveCommentService.queryPageByParams(params);
+
return R.ok().put("page", page);
}
-
-
+
+
/**
* 信息
*/
@@ -76,7 +80,7 @@ public class LiveCommentController extends AbstractController{
}
return R.ok().put("info", liveCommentService.info(id));
}
-
+
/**
* 保存
*/
@@ -94,7 +98,7 @@ public class LiveCommentController extends AbstractController{
liveCommentService.save(liveComment, getUserId());
return R.ok();
}
-
+
/**
* 修改
*/
@@ -114,7 +118,7 @@ public class LiveCommentController extends AbstractController{
liveCommentService.update(liveComment,getUserId());
return R.ok();
}
-
+
/**
* 删除
*/
@@ -129,7 +133,7 @@ public class LiveCommentController extends AbstractController{
liveCommentService.deleteBatch(ids,getUserId());
return R.ok();
}
-
+
/**
* 发布
*/
@@ -144,7 +148,7 @@ public class LiveCommentController extends AbstractController{
liveCommentService.releaseBatch(ids,getUserId());
return R.ok();
}
-
+
/**
* 取消发布
*/
@@ -159,5 +163,5 @@ public class LiveCommentController extends AbstractController{
liveCommentService.cancelReleaseBatch(ids,getUserId());
return R.ok();
}
-
+
}
diff --git a/src/main/java/com/platform/modules/live/controller/LiveReportController.java b/src/main/java/com/platform/modules/live/controller/LiveReportController.java
index 2afcb24..94f42ad 100644
--- a/src/main/java/com/platform/modules/live/controller/LiveReportController.java
+++ b/src/main/java/com/platform/modules/live/controller/LiveReportController.java
@@ -8,6 +8,7 @@ import com.platform.modules.live.entity.LiveReportEntity;
import com.platform.modules.live.service.LiveReportService;
import com.platform.modules.live.utils.ReportTypeEnum;
import com.platform.modules.sys.controller.AbstractController;
+import com.platform.modules.sys.service.SysTenantService;
import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
@@ -22,9 +23,9 @@ import java.util.Map;
/**
* 直播报道
- *
+ *
* @author weiyan
- * @email
+ * @email
* @date 2019-01-19 12:13:39
*/
@RestController
@@ -33,10 +34,12 @@ import java.util.Map;
public class LiveReportController extends AbstractController{
@Autowired
private LiveReportService liveReportService;
-
+
/**
* 列表
*/
+ @Autowired
+ private SysTenantService sysTenantService;
@GetMapping("/list")
@RequiresPermissions("live:report:list")
@ApiOperation("报道列表")
@@ -50,10 +53,13 @@ public class LiveReportController extends AbstractController{
public R list(@ApiIgnore @RequestParam(required = false) Map params){
params.put("isDelete", 0);
PageUtils page = liveReportService.queryPageByParams(params, false);
+
+
+
return R.ok().put("page", page);
}
-
-
+
+
/**
* 信息
*/
@@ -64,7 +70,7 @@ public class LiveReportController extends AbstractController{
public R info(@RequestParam("id")Integer id){
return R.ok().put("info", liveReportService.info(id));
}
-
+
/**
* 保存
*/
@@ -90,7 +96,7 @@ public class LiveReportController extends AbstractController{
liveReportService.save(liveReport, getUserId());
return R.ok();
}
-
+
/**
* 修改
*/
@@ -121,7 +127,7 @@ public class LiveReportController extends AbstractController{
}
return R.ok();
}
-
+
/**
* 删除
*/
@@ -137,7 +143,7 @@ public class LiveReportController extends AbstractController{
liveReportService.deleteBatch(ids, getUserId());
return R.ok();
}
-
+
/**
* 发布
*/
@@ -153,7 +159,7 @@ public class LiveReportController extends AbstractController{
liveReportService.releaseBatch(ids,getUserId());
return R.ok();
}
-
+
/**
* 取消发布
*/
@@ -169,7 +175,7 @@ public class LiveReportController extends AbstractController{
liveReportService.cancelReleaseBatch(ids, getUserId());
return R.ok();
}
-
+
/**
* 置顶
*/
diff --git a/src/main/java/com/platform/modules/live/controller/LiveSceneController.java b/src/main/java/com/platform/modules/live/controller/LiveSceneController.java
index d9e4df2..4363820 100644
--- a/src/main/java/com/platform/modules/live/controller/LiveSceneController.java
+++ b/src/main/java/com/platform/modules/live/controller/LiveSceneController.java
@@ -44,9 +44,9 @@ import java.util.Map;
/**
* 现场表
- *
+ *
* @author TROY
- * @email
+ * @email
* @date 2019-01-19 14:50:50
*/
@RestController
@@ -82,8 +82,8 @@ public class LiveSceneController extends AbstractController {
return R.ok().put("page", page);
}
}
-
-
+
+
/**
* 信息
*/
@@ -125,7 +125,7 @@ public class LiveSceneController extends AbstractController {
return R.ok("现场保存成功");
}
-
+
/**
* 修改
*/
@@ -213,7 +213,7 @@ public class LiveSceneController extends AbstractController {
}
return R.ok();
}
-
+
@SysLog("现场开播")
@PostMapping("/startLive")
@RequiresPermissions("live:livescene:startLive")
@@ -482,7 +482,7 @@ public class LiveSceneController extends AbstractController {
}
return r;
}
-
+
/**
* 置顶
*/
@@ -525,13 +525,24 @@ public class LiveSceneController extends AbstractController {
liveSceneService.priority(ids, prioritys, getUserId());
return R.ok();
}
-
+
@GetMapping("/channels")
@ApiOperation(value = "获取所有栏目", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiresPermissions("live:livescene:channels")
public R channels(Integer sid){
// return R.ok().put("list", liveChannelService.getAllList());
- return R.ok().put("list", liveChannelService.getAllChannel());
+ //return R.ok().put("list", liveChannelService.getAllChannel());
+ //获取对应机构下的栏目
+
+ Long tenantId= getUser().getTenantId();
+
+ if (tenantId==1){
+ return R.ok().put("list", liveChannelService.getAllList());
+
+ }else {
+ return R.ok().put("list",liveChannelService.getAllChannelByTenant(tenantId));
+ }
+
}
@Autowired
@@ -572,7 +583,7 @@ public class LiveSceneController extends AbstractController {
}
return null;
}
-
+
@SysLog("现场还原")
@PostMapping("/cycle/recycle")
@RequiresPermissions("live:livescene:cycle:recycle")
@@ -584,7 +595,7 @@ public class LiveSceneController extends AbstractController {
liveSceneService.recycle(ids);
return R.ok();
}
-
+
@SysLog("现场彻底删除")
@PostMapping("/cycle/delete")
@RequiresPermissions("live:livescene:cycle:delete")
diff --git a/src/main/java/com/platform/modules/live/controller/MediaUploadController.java b/src/main/java/com/platform/modules/live/controller/MediaUploadController.java
index ed8dc9c..c6b47c9 100644
--- a/src/main/java/com/platform/modules/live/controller/MediaUploadController.java
+++ b/src/main/java/com/platform/modules/live/controller/MediaUploadController.java
@@ -1,5 +1,8 @@
package com.platform.modules.live.controller;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.StorageClass;
+import com.aliyuncs.auth.BasicSessionCredentials;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.FileUtils;
import com.platform.common.utils.R;
@@ -7,9 +10,19 @@ import com.platform.common.utils.RedisKeys;
import com.platform.common.utils.RedisUtils;
import com.platform.modules.live.service.LiveMultimediaSyncService;
import com.platform.modules.plm.entity.PlmChunkEntity;
+
+import com.platform.modules.plm.util.ImageFileProperties;
import com.platform.modules.plm.util.MateriaFileProperties;
import com.platform.modules.plm.util.MaterialUtils;
import com.platform.modules.video.service.RealPathResolver;
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.PutObjectResult;
+import com.qcloud.cos.region.Region;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -17,6 +30,7 @@ import org.apache.http.HttpStatus;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -24,100 +38,187 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Calendar;
+import java.util.UUID;
@RestController
@Api(value = "资源上传", tags = "资源上传")
@Slf4j
public class MediaUploadController {
-
- @Autowired
- private MateriaFileProperties materiaFileProperties;
- @Autowired
- private RealPathResolver realPathResolver;
- @Autowired
- private RedisUtils redisUtils;
-
- @SysLog("资源上传")
- @PostMapping("/common/upload_media")
- @ApiOperation("资源上传")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "materialFile", value = "上传文件", paramType = "update", dataType = "file")})
- @ApiResponses({@ApiResponse(code = HttpStatus.SC_OK, message = "success")})
- public R save(@RequestParam("materialFile") MultipartFile materialFile){
- try {
- String newCoverName = FileUtils.createFileName() + "." + FileUtils.getSuffix(materialFile.getOriginalFilename());
- String serverCoverPath = materiaFileProperties.getMediaPath() + "/" + MaterialUtils.getDateDir() +"/" + newCoverName;
- String newCoverPath = materiaFileProperties.getMateriaPath() + serverCoverPath;
- FileUtils.copy(materialFile.getInputStream(), realPathResolver.get(newCoverPath));
- return R.ok("资源上传成功").put("fileUrl", serverCoverPath);
- } catch (Exception e) {
-
- return R.error("资源上传失败");
- }
- }
- @PostMapping("/common/upload_media/chunk")
- @RequiresPermissions(value = {"live:multimedia:save", "live:multimedia:update"}, logical = Logical.OR)
- public R uploadChunk(PlmChunkEntity chunk) {
- if (null==chunk || null==chunk.getFile() || StringUtils.isBlank(chunk.getIdentifier())
- || null==chunk.getChunkNumber()) {
- return R.error("缺少必要参数");
- }
- String key = RedisKeys.getUploadMediaKey() + chunk.getIdentifier();
- String field = chunk.getIdentifier()+"#"+chunk.getChunkNumber();
- // 续传判断
- if (redisUtils.hexists(key, field)) {
- return R.ok("文件块上传成功");
- }
- MultipartFile file = chunk.getFile();
- String uploadFolder = materiaFileProperties.getMateriaPath() + materiaFileProperties.getMediaPath() + "/" +
- MaterialUtils.getDateDir() +"/";
- try {
- byte[] bytes = file.getBytes();
- Path path = Paths.get(MaterialUtils.generatePath(uploadFolder, chunk));
- //文件写入指定路径
- Files.write(path, bytes);
- // Redis状态存储
- redisUtils.hset(key, field, field);
- return R.ok("文件块上传成功");
- } catch (Exception e) {
- e.printStackTrace();
- return R.error("系统异常");
- }
- }
+ @Autowired
+ private MateriaFileProperties materiaFileProperties;
+ @Autowired
+ private ImageFileProperties imageFileProperties;
+ @Autowired
+ private RealPathResolver realPathResolver;
+ @Autowired
+ private RedisUtils redisUtils;
- @GetMapping("/common/upload_media/chunk")
- @RequiresPermissions(value = {"live:multimedia:save", "live:multimedia:update"}, logical = Logical.OR)
- public R checkChunk(PlmChunkEntity chunk, HttpServletResponse response) {
- String key = chunk.getIdentifier()+"#"+chunk.getChunkNumber();
- String desc = "文件已存在";
- if (!redisUtils.hexists(RedisKeys.getUploadMediaKey() + chunk.getIdentifier(), key)) {
- response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- desc = "文件不存在";
- }
- return R.ok(desc);
- }
- @PostMapping("/common/upload_media/merge")
- @RequiresPermissions(value = {"live:multimedia:save", "live:multimedia:update"}, logical = Logical.OR)
- public R mergeFile(String filename, String identifier) {
- String uploadFolder = materiaFileProperties.getMateriaPath() + materiaFileProperties.getMediaPath() + "/" +
- MaterialUtils.getDateDir();
- String file = uploadFolder + "/" + identifier + "/" + filename;
- String folder = uploadFolder + "/" + identifier;
- try {
- MaterialUtils.merge(file, folder, filename);
- redisUtils.delete(RedisKeys.getUploadMediaKey() + identifier);
- } catch (Exception e) {
- e.printStackTrace();
- // 合并异常后,分片数据可能全部丢失
- redisUtils.delete(RedisKeys.getUploadMediaKey() + identifier);
- return R.error("文件上传失败");
- }
- return R.ok("文件上传成功");
- }
+ @Value("${spring.tengxun.accessKey}")
+ private String accessKey;
+ @Value("${spring.tengxun.secretKey}")
+ private String secretKey;
+ @Value("${spring.tengxun.bucket}")
+ private String bucket;
+ @Value("${spring.tengxun.bucketName}")
+ private String bucketName;
+ @Value("${spring.tengxun.path}")
+ private String path;
+// @Value("${spring.tengxun.qianzui}")
+// private String qianzui;
+// @SysLog("资源上传")
+// @PostMapping("/common/upload_media")
+// @ApiOperation("资源上传")
+// @ApiImplicitParams({
+// @ApiImplicitParam(name = "materialFile", value = "上传文件", paramType = "update", dataType = "file")})
+// @ApiResponses({@ApiResponse(code = HttpStatus.SC_OK, message = "success")})
+// public R save(@RequestParam("materialFile") MultipartFile materialFile) {
+// try {
+// String newCoverName = FileUtils.createFileName() + "." + FileUtils.getSuffix(materialFile.getOriginalFilename());
+// String serverCoverPath = materiaFileProperties.getMediaPath() + "/" + MaterialUtils.getDateDir() + "/" + newCoverName;
+// String newCoverPath = materiaFileProperties.getMateriaPath() + serverCoverPath;
+// FileUtils.copy(materialFile.getInputStream(), realPathResolver.get(newCoverPath));
+// return R.ok("资源上传成功").put("fileUrl", serverCoverPath);
+// } catch (Exception e) {
+//
+// return R.error("资源上传失败");
+// }
+// }
+
+ // @SysLog("图片资源上传")
+// @PostMapping("/common/upload_image")
+// @ApiOperation("图片资源上传")
+// @ApiImplicitParams({
+// @ApiImplicitParam(name = "materialFile", value = "上传文件", paramType = "update", dataType = "file")})
+// @ApiResponses({@ApiResponse(code = HttpStatus.SC_OK, message = "success")})
+// public R saveImages(@RequestParam("materialFile") MultipartFile materialFile){
+// try {
+// String newCoverName = FileUtils.createFileName() + "." + FileUtils.getSuffix(materialFile.getOriginalFilename());
+// String serverCoverPath = imageFileProperties.getImagePath() + "/" + MaterialUtils.getDateDir() +"/" + newCoverName;
+// String filePath = "/profile/" + MaterialUtils.getDateDir() +"/" + newCoverName;
+// FileUtils.copy(materialFile.getInputStream(), realPathResolver.get(serverCoverPath));
+// return R.ok("资源上传成功").put("imageUrl", filePath);
+// } catch (Exception e) {
+//
+// return R.error("资源上传失败");
+// }
+// }
+//上传到腾讯云oss
+
+
+ @PostMapping("/common/upload_media/chunk")
+ @RequiresPermissions(value = {"live:multimedia:save", "live:multimedia:update"}, logical = Logical.OR)
+ public R uploadChunk(PlmChunkEntity chunk) {
+ if (null == chunk || null == chunk.getFile() || StringUtils.isBlank(chunk.getIdentifier())
+ || null == chunk.getChunkNumber()) {
+ return R.error("缺少必要参数");
+ }
+ String key = RedisKeys.getUploadMediaKey() + chunk.getIdentifier();
+ String field = chunk.getIdentifier() + "#" + chunk.getChunkNumber();
+ // 续传判断
+ if (redisUtils.hexists(key, field)) {
+ return R.ok("文件块上传成功");
+ }
+ MultipartFile file = chunk.getFile();
+ String uploadFolder = materiaFileProperties.getMateriaPath() + materiaFileProperties.getMediaPath() + "/" +
+ MaterialUtils.getDateDir() + "/";
+ try {
+ byte[] bytes = file.getBytes();
+ Path path = Paths.get(MaterialUtils.generatePath(uploadFolder, chunk));
+ //文件写入指定路径
+ Files.write(path, bytes);
+ // Redis状态存储
+ redisUtils.hset(key, field, field);
+ return R.ok("文件块上传成功");
+ } catch (Exception e) {
+ e.printStackTrace();
+ return R.error("系统异常");
+ }
+ }
+
+ @GetMapping("/common/upload_media/chunk")
+ @RequiresPermissions(value = {"live:multimedia:save", "live:multimedia:update"}, logical = Logical.OR)
+ public R checkChunk(PlmChunkEntity chunk, HttpServletResponse response) {
+ String key = chunk.getIdentifier() + "#" + chunk.getChunkNumber();
+ String desc = "文件已存在";
+ if (!redisUtils.hexists(RedisKeys.getUploadMediaKey() + chunk.getIdentifier(), key)) {
+ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ desc = "文件不存在";
+ }
+ return R.ok(desc);
+ }
+
+ @PostMapping("/common/upload_media/merge")
+ @RequiresPermissions(value = {"live:multimedia:save", "live:multimedia:update"}, logical = Logical.OR)
+ public R mergeFile(String filename, String identifier) {
+ String uploadFolder = materiaFileProperties.getMateriaPath() + materiaFileProperties.getMediaPath() + "/" +
+ MaterialUtils.getDateDir();
+ String file = uploadFolder + "/" + identifier + "/" + filename;
+ String folder = uploadFolder + "/" + identifier;
+ try {
+ MaterialUtils.merge(file, folder, filename);
+ redisUtils.delete(RedisKeys.getUploadMediaKey() + identifier);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // 合并异常后,分片数据可能全部丢失
+ redisUtils.delete(RedisKeys.getUploadMediaKey() + identifier);
+ return R.error("文件上传失败");
+ }
+ return R.ok("文件上传成功");
+ }
+
+ @SysLog("图片资源上传")
+ @PostMapping("/common/upload_media")
+ @ApiOperation("图片资源上传")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "materialFile", value = "上传文件", paramType = "update", dataType = "file")})
+ @ApiResponses({@ApiResponse(code = HttpStatus.SC_OK, message = "success")})
+ public R saveImages(@RequestParam("materialFile") MultipartFile file) {
+ if (file == null) {
+ return R.error("文件為空");
+ }
+ String oldFileName = file.getOriginalFilename();
+ String eName = oldFileName.substring(oldFileName.lastIndexOf("."));
+ String newFileName = UUID.randomUUID() + eName;
+ Calendar cal = Calendar.getInstance();
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DATE);
+ // 1 初始化用户身份信息(secretId, secretKey)
+ COSCredentials cred = new BasicCOSCredentials(accessKey, secretKey);
+ // 2 设置bucket的区域, COS地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
+ final Region region = new Region(bucket);
+ ClientConfig clientConfig = new ClientConfig(region);
+ // 3 生成cos客户端
+ COSClient cosclient = new COSClient(cred, clientConfig);
+ // bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式
+ String bucketName = this.bucketName;
+ // 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20 M 以下的文件使用该接口
+ // 大文件上传请参照 API 文档高级 API 上传
+ File localFile = null;
+ try {
+ localFile = File.createTempFile("temp", null);
+ file.transferTo(localFile);
+ // 指定要上传到 COS 上的路径
+ String key = "/" + "/" + year + "/" + month + "/" + day + "/" + newFileName;
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, localFile);
+ PutObjectResult putObjectResult = cosclient.putObject(putObjectRequest);
+// return new UploadMsg(1,"上传成功",this.path + putObjectRequest.getKey());
+ String url = this.path + putObjectRequest.getKey();
+ return R.ok().put("url", url);
+ } catch (IOException e) {
+ return R.error("上传失败");
+ } finally {
+ // 关闭客户端(关闭后台线程)
+ cosclient.shutdown();
+ }
+ }
}
diff --git a/src/main/java/com/platform/modules/live/dao/LiveChannelDao.java b/src/main/java/com/platform/modules/live/dao/LiveChannelDao.java
index 7eb8d79..6fad986 100644
--- a/src/main/java/com/platform/modules/live/dao/LiveChannelDao.java
+++ b/src/main/java/com/platform/modules/live/dao/LiveChannelDao.java
@@ -8,18 +8,23 @@ import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.platform.modules.live.entity.LiveChannelEntity;
+import org.apache.ibatis.annotations.Param;
/**
* 现场栏目信息
- *
+ *
* @author weiyan
- * @email
+ * @email
* @date 2019-03-28 10:06:27
*/
@Mapper
public interface LiveChannelDao extends BaseMapper {
-
+
List queryPageMap(Page