diff --git a/hl-wechat/pom.xml b/hl-wechat/pom.xml index 62bab8f..9a51a00 100644 --- a/hl-wechat/pom.xml +++ b/hl-wechat/pom.xml @@ -8,6 +8,7 @@ 3.8.1 4.0.0 + jar hl-wechat @@ -16,4 +17,18 @@ 8 + + + + com.ruoyi + ruoyi-common + + + + com.dtflys.forest + forest-spring-boot-starter + 1.5.16 + + + \ No newline at end of file diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/config/VideoConfig.java b/hl-wechat/src/main/java/com/ruoyi/hl/config/VideoConfig.java index dc4f51e..3735f33 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/config/VideoConfig.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/config/VideoConfig.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.config; +package com.ruoyi.hl.config; import lombok.Data; import org.springframework.beans.factory.annotation.Value; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/config/WxConfig.java b/hl-wechat/src/main/java/com/ruoyi/hl/config/WxConfig.java index 27229b6..d9142c6 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/config/WxConfig.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/config/WxConfig.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.config; +package com.ruoyi.hl.config; import lombok.Getter; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/controller/WxController.java b/hl-wechat/src/main/java/com/ruoyi/hl/controller/WxController.java index 9a31f18..bbe4d43 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/controller/WxController.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/controller/WxController.java @@ -1,12 +1,9 @@ -package com.ruoyi.system.controller; - -import cn.hutool.core.util.StrUtil; +package com.ruoyi.hl.controller; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.system.config.WxConfig; -import com.ruoyi.system.forest.clients.MiniWeChatClients; -import com.ruoyi.system.forest.ptoto.WxPublicCode2UserInfoRes; -import com.ruoyi.system.service.WxService; +import com.ruoyi.hl.config.WxConfig; +import com.ruoyi.hl.forest.clients.MiniWeChatClients; +import com.ruoyi.hl.service.WxService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -27,8 +24,8 @@ public class WxController { @RequestMapping("/getAuth/{id}") - public AjaxResult open(@PathVariable String id){ - return AjaxResult.success(String.format(wxConfig.getAuthUrl(),wxConfig.getPublicAppid(),wxConfig.getRedirectUrl(),id )); + public AjaxResult open(@PathVariable String id) { + return AjaxResult.success(String.format(wxConfig.getAuthUrl(), wxConfig.getPublicAppid(), wxConfig.getRedirectUrl(), id)); } /*@RequestMapping("/code2videourl/{code}/{id}") diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java index 3defbea..828c80d 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java @@ -1,13 +1,13 @@ -package com.ruoyi.system.forest.clients; +package com.ruoyi.hl.forest.clients; import com.dtflys.forest.annotation.*; -import com.ruoyi.system.forest.interceptor.UnlimitedInterceptor; -import com.ruoyi.system.forest.interceptor.WriteLogInterceptor; -import com.ruoyi.system.forest.ptoto.WxMiniCode2SessionRes; -import com.ruoyi.system.forest.ptoto.WxMiniTokenRes; -import com.ruoyi.system.forest.ptoto.WxPublicCode2UserInfoRes; -import com.ruoyi.system.forest.ptoto.WxUserInfoRes; +import com.ruoyi.hl.forest.ptoto.WxMiniCode2SessionRes; +import com.ruoyi.hl.forest.ptoto.WxMiniTokenRes; +import com.ruoyi.hl.forest.ptoto.WxPublicCode2UserInfoRes; +import com.ruoyi.hl.forest.ptoto.WxUserInfoRes; +import com.ruoyi.hl.forest.interceptor.UnlimitedInterceptor; +import com.ruoyi.hl.forest.interceptor.WriteLogInterceptor; import java.util.Map; @@ -49,20 +49,6 @@ public interface MiniWeChatClients { ) WxMiniCode2SessionRes code2session(@Var("appid") String appid, @Var("secret") String secret, @Var("code") String code); - /** - * 获取公众号用户信息 - * @param appid - * @param secret - * @param code - * @return - */ - @GetRequest( - url = "/sns/oauth2/access_token?appid=${appid}&secret=${secret}&code=${code}&grant_type=authorization_code", - interceptor = WriteLogInterceptor.class,dataType = "json" - ) - WxPublicCode2UserInfoRes code2userinfo(@Var("appid") String appid, @Var("secret") String secret, @Var("code") String code); - - /** * 获取分享码 * @param token diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java index f3bdaff..ba4aa74 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.interceptor; +package com.ruoyi.hl.forest.interceptor; import com.dtflys.forest.exceptions.ForestRuntimeException; @@ -8,7 +8,7 @@ import com.dtflys.forest.interceptor.Interceptor; import com.ruoyi.common.utils.BytesUtil; -import com.ruoyi.system.config.WxConfig; +import com.ruoyi.hl.config.WxConfig; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java index 4919b4e..3669c84 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.interceptor; +package com.ruoyi.hl.forest.interceptor; import com.alibaba.fastjson.JSONObject; import com.dtflys.forest.exceptions.ForestRuntimeException; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java index 58b3acf..47e1032 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java index 58ec41e..0f3830a 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java index 31504a9..12f2930 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java index 09354fb..1399b87 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java index c2c86dd..de00bcf 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java index 3153424..4c6b296 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java index 361d683..881f44e 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java index 159658c..69279c3 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java index caff0b5..fee99f8 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/service/WxService.java b/hl-wechat/src/main/java/com/ruoyi/hl/service/WxService.java index ed77657..7a817d3 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/service/WxService.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/service/WxService.java @@ -1,4 +1,4 @@ -package com.ruoyi.system.service; +package com.ruoyi.hl.service; import cn.hutool.core.util.StrUtil; diff --git a/hl-wechat/src/main/java/com/ruoyi/hl/service/WxTokenService.java b/hl-wechat/src/main/java/com/ruoyi/hl/service/WxTokenService.java index e8815c5..1b680b4 100644 --- a/hl-wechat/src/main/java/com/ruoyi/hl/service/WxTokenService.java +++ b/hl-wechat/src/main/java/com/ruoyi/hl/service/WxTokenService.java @@ -1,17 +1,15 @@ -package com.ruoyi.system.service; +package com.ruoyi.hl.service; import cn.hutool.core.util.StrUtil; import com.ruoyi.common.core.redis.RedisCache; -import com.ruoyi.system.config.WxConfig; -import com.ruoyi.system.forest.clients.MiniWeChatClients; -import com.ruoyi.system.forest.ptoto.WxMiniTokenRes; +import com.ruoyi.hl.forest.ptoto.WxMiniTokenRes; +import com.ruoyi.hl.config.WxConfig; +import com.ruoyi.hl.forest.clients.MiniWeChatClients; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; diff --git a/hl-wechat/src/main/resources/application.yml b/hl-wechat/src/main/resources/application.yml index 141698b..9b3c414 100644 --- a/hl-wechat/src/main/resources/application.yml +++ b/hl-wechat/src/main/resources/application.yml @@ -1,5 +1,4 @@ #微信配置 - wx: public: redirect_uri: http://asdf.com @@ -23,101 +22,3 @@ forest: - -# 开发环境配置 -server: - # 服务器的HTTP端口,默认为8081 - port: 8081 - servlet: - # 应用的访问路径 - context-path: / - tomcat: - # tomcat的URI编码 - uri-encoding: UTF-8 - # 连接数满后的排队数,默认为100 - accept-count: 1000 - threads: - # tomcat最大线程数,默认为200 - max: 800 - # Tomcat启动初始化的线程数,默认值10 - min-spare: 100 - -# 日志配置 -logging: - level: - com.ruoyi: debug - org.springframework: warn - -# Spring配置 -spring: - # 资源信息 - messages: - # 国际化资源文件路径 - basename: i18n/messages - profiles: - active: druid - # 文件上传 - servlet: - multipart: - # 单个文件大小 - max-file-size: 10MB - # 设置总上传的文件大小 - max-request-size: 20MB - # 服务模块 - devtools: - restart: - # 热部署开关 - enabled: true - # redis 配置 - redis: - # 地址 - host: 192.168.1.182 - # 端口,默认为6379 - port: 6379 - # 数据库索引 - database: 0 - # 密码 - password: - # 连接超时时间 - timeout: 10s - lettuce: - pool: - # 连接池中的最小空闲连接 - min-idle: 0 - # 连接池中的最大空闲连接 - max-idle: 8 - # 连接池的最大数据库连接数 - max-active: 8 - # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms - -# MyBatis配置 -mybatis: - # 搜索指定包别名 - typeAliasesPackage: com.ruoyi.**.domain - # 配置mapper的扫描,找到所有的mapper.xml映射文件 - mapperLocations: classpath*:mapper/**/*Mapper.xml - # 加载全局的配置文件 - configLocation: classpath:mybatis/mybatis-config.xml - -# PageHelper分页插件 -pagehelper: - helperDialect: mysql - supportMethodsArguments: true - params: count=countSql - -# Swagger配置 -swagger: - # 是否开启swagger - enabled: true - # 请求前缀 - pathMapping: /wechat - -# 防止XSS攻击 -xss: - # 过滤开关 - enabled: true - # 排除链接(多个用逗号分隔) - excludes: /system/notice - # 匹配链接 - urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/pom.xml b/pom.xml index b4931db..8fc012c 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,17 @@ + + cn.hutool + hutool-core + 5.6.0 + + + + com.dtflys.forest + forest-spring-boot-starter + 1.5.16 + org.springframework.boot @@ -199,6 +210,7 @@ ${ruoyi.version} + @@ -214,7 +226,12 @@ - + + org.projectlombok + lombok + 1.18.4 + provided + diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 14769e5..2050707 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -61,6 +61,12 @@ ruoyi-generator + + com.dtflys.forest + forest-spring-boot-starter + 1.5.16 + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index e3c56ee..de7731c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -3,17 +3,19 @@ package com.ruoyi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; /** * 启动程序 - * + * * @author ruoyi */ -@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) -public class RuoYiApplication -{ - public static void main(String[] args) - { + +@EnableScheduling +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class RuoYiApplication { + public static void main(String[] args) { // System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(RuoYiApplication.class, args); System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/config/VideoConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/config/VideoConfig.java index e5d0567..c585dd1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/config/VideoConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/config/VideoConfig.java @@ -1,9 +1,11 @@ -package hl.config; +package com.ruoyi.hl.config; import lombok.Data; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; @Data +@Component public class VideoConfig { @Value("video.baseUrl") private String baseUrl; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/config/WxConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/config/WxConfig.java index f193cab..9c50770 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/config/WxConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/config/WxConfig.java @@ -1,4 +1,4 @@ -package hl.config; +package com.ruoyi.hl.config; import lombok.Getter; @@ -26,7 +26,7 @@ public class WxConfig { private String redirectUrl; @Getter - private String authUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect"; + private String authUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=%s#wechat_redirect"; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/controller/WxController.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/controller/WxController.java index a1c973c..b8bff10 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/controller/WxController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/controller/WxController.java @@ -1,14 +1,31 @@ -package hl.controller; +package com.ruoyi.hl.controller; +import cn.hutool.core.util.StrUtil; import com.ruoyi.common.core.domain.AjaxResult; -import hl.config.WxConfig; -import hl.forest.clients.MiniWeChatClients; -import hl.service.WxService; +import com.ruoyi.framework.web.service.AliOSSService; +import com.ruoyi.hl.config.WxConfig; +import com.ruoyi.hl.forest.clients.MiniWeChatClients; +import com.ruoyi.hl.forest.ptoto.WxPublicCode2UserInfoRes; +import com.ruoyi.hl.forest.ptoto.WxUserInfoRes; +import com.ruoyi.hl.service.WxService; +import com.ruoyi.hl.service.WxTokenService; +import com.ruoyi.system.domain.BFile; +import com.ruoyi.system.domain.BVideoAllow; +import com.ruoyi.system.domain.BVideos; +import com.ruoyi.system.service.IBFileService; +import com.ruoyi.system.service.IBVideoAllowService; +import com.ruoyi.system.service.IBVideosService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Slf4j @RestController @RequestMapping("/wx") public class WxController { @@ -22,20 +39,71 @@ public class WxController { @Autowired private WxConfig wxConfig; + @Autowired + private IBVideoAllowService bVideoAllowService; + + @Autowired + private IBVideosService videosService; + + @Autowired + private IBFileService fileService; + @Autowired + private WxTokenService wxTokenService; + + @Autowired + private AliOSSService ossService; + @RequestMapping("/getAuth/{id}") public AjaxResult open(@PathVariable String id) { - return AjaxResult.success(String.format(wxConfig.getAuthUrl(), wxConfig.getPublicAppid(), wxConfig.getRedirectUrl(), id)); + String auth=String.format(wxConfig.getAuthUrl(), wxConfig.getPublicAppid(), wxConfig.getRedirectUrl(), id); + log.debug("authUrl:{}",auth); + return AjaxResult.success("ok",auth); } - /*@RequestMapping("/code2videourl/{code}/{id}") + @RequestMapping("/code2videourl/{code}/{id}") public AjaxResult code2videourl(@PathVariable String id,@PathVariable String code){ - String openid="a"; + String openid="45"; WxPublicCode2UserInfoRes wxPublicCode2UserInfoRes=weChatClients.code2userinfo(wxConfig.getPublicAppid(),wxConfig.getPublicSecret(),code); - if (wxPublicCode2UserInfoRes.getErrcode()!=0){ + if (wxPublicCode2UserInfoRes==null){ + log.info("wxPublicCode2UserInfoRes is null"); + } + if (StrUtil.isBlankIfStr(wxPublicCode2UserInfoRes.getOpenid())){ return AjaxResult.error("获取openid错误"); } openid=wxPublicCode2UserInfoRes.getOpenid(); - return wxService.getOwnVideo(id,openid); - }*/ + log.info("openId:{}, accessToken:{}",openid,wxPublicCode2UserInfoRes.getAccessToken()); + WxUserInfoRes wxUserInfoRes=weChatClients.userInfo(wxPublicCode2UserInfoRes.getAccessToken(),openid); + + String nickname=wxUserInfoRes.getNickname(); + return wxService.getOwnVideo(id,openid,nickname); + //return AjaxResult.success("ok",id+"----"+openid); + } + @RequestMapping("/list/{openIds}") + public AjaxResult list(@PathVariable String openIds){ + String[] ids=openIds.split("----"); + String allowId=ids[0]; + String openId=ids[1]; + + + BVideoAllow bVideoAllow=new BVideoAllow(); + bVideoAllow.setAllowId(allowId); + bVideoAllow.setWxOpenid(openId); + List allowList= bVideoAllowService.selectBVideoAllowList(bVideoAllow); + if (allowList!=null&&allowList.size()>0){ + BVideoAllow allow=allowList.get(0); + + BVideos bVideos=new BVideos(); + bVideos.setParentId(allow.getVideoId()); + List videosList=videosService.selectBVideosList(bVideos); + videosList.forEach(v->{ + BFile file=fileService.selectBFileById(v.getFileId()); + v.setPath(ossService.getDomain() + "/" + file.getUuid()); + }); + return AjaxResult.success(videosList); + }else { + return AjaxResult.success(new ArrayList<>()); + } + + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java index d06eb0a..ca81d88 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/clients/MiniWeChatClients.java @@ -1,13 +1,13 @@ -package hl.forest.clients; +package com.ruoyi.hl.forest.clients; import com.dtflys.forest.annotation.*; -import hl.forest.interceptor.UnlimitedInterceptor; -import hl.forest.interceptor.WriteLogInterceptor; -import hl.forest.ptoto.WxMiniCode2SessionRes; -import hl.forest.ptoto.WxMiniTokenRes; -import hl.forest.ptoto.WxPublicCode2UserInfoRes; -import hl.forest.ptoto.WxUserInfoRes; +import com.ruoyi.hl.forest.interceptor.UnlimitedInterceptor; +import com.ruoyi.hl.forest.interceptor.WriteLogInterceptor; +import com.ruoyi.hl.forest.ptoto.WxMiniCode2SessionRes; +import com.ruoyi.hl.forest.ptoto.WxMiniTokenRes; +import com.ruoyi.hl.forest.ptoto.WxPublicCode2UserInfoRes; +import com.ruoyi.hl.forest.ptoto.WxUserInfoRes; import java.util.Map; @@ -30,7 +30,7 @@ public interface MiniWeChatClients { * * @return */ - @GetRequest(url = "/cgi-bin/user/info?access_token=${token}&openid=${openid}&lang=zh_CN", + @GetRequest(url = "/sns/userinfo?access_token=${token}&openid=${openid}&lang=zh_CN", dataType ="json",interceptor = WriteLogInterceptor.class ) WxUserInfoRes userInfo(@Var("token") String token, @Var("openid") String openid); @@ -50,7 +50,7 @@ public interface MiniWeChatClients { WxMiniCode2SessionRes code2session(@Var("appid") String appid, @Var("secret") String secret, @Var("code") String code); /** - * 获取公众号用户信息 + * 获取信息 * @param appid * @param secret * @param code diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java index 02d2d87..b84ce03 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/UnlimitedInterceptor.java @@ -1,4 +1,4 @@ -package hl.forest.interceptor; +package com.ruoyi.hl.forest.interceptor; import com.dtflys.forest.exceptions.ForestRuntimeException; @@ -7,7 +7,7 @@ import com.dtflys.forest.http.ForestResponse; import com.dtflys.forest.interceptor.Interceptor; import com.ruoyi.common.utils.BytesUtil; -import hl.config.WxConfig; +import com.ruoyi.hl.config.WxConfig; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java index bdfbe54..3669c84 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/interceptor/WriteLogInterceptor.java @@ -1,4 +1,4 @@ -package hl.forest.interceptor; +package com.ruoyi.hl.forest.interceptor; import com.alibaba.fastjson.JSONObject; import com.dtflys.forest.exceptions.ForestRuntimeException; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java index 35144a6..6304f16 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxAuthAccessTokenRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java index d36ae6e..11c6504 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxGetUnlimitedRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java index 4041541..0296048 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniCode2SessionRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java index 5397367..76994e2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxMiniTokenRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java index 99fd2e7..de00bcf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublicCode2UserInfoRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java index 7677246..4c6b296 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxPublickTokenRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java index d7e0a8c..881f44e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java index 1c9edd3..58a7943 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxSendTemplateRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java index e9be302..fee99f8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/forest/ptoto/WxUserInfoRes.java @@ -1,4 +1,4 @@ -package hl.forest.ptoto; +package com.ruoyi.hl.forest.ptoto; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxService.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxService.java index 07225c6..a1209d2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxService.java @@ -1,12 +1,22 @@ -package hl.service; - +package com.ruoyi.hl.service; + +import cn.hutool.core.util.StrUtil; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.hl.config.VideoConfig; +import com.ruoyi.system.domain.BVideoAllow; +import com.ruoyi.system.domain.BVideos; +import com.ruoyi.system.service.IBVideoAllowService; +import com.ruoyi.system.service.IBVideosService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class WxService { - /*@Autowired - private IBVideoAllowService ibVideoAllowService; + @Autowired + private IBVideoAllowService ibVideoAllowService; @Autowired private IBVideosService videosService; @@ -15,7 +25,7 @@ public class WxService { private VideoConfig videoConfig; - public synchronized AjaxResult getOwnVideo(String id, String openid){ + public synchronized AjaxResult getOwnVideo(String id, String openid,String nickname){ BVideoAllow bVideoAllow =new BVideoAllow(); bVideoAllow.setAllowId(id); @@ -28,6 +38,7 @@ public class WxService { String loadOpenid=allow.getWxOpenid(); if (StrUtil.isBlankIfStr(loadOpenid)){ allow.setWxOpenid(openid); + allow.setWxNickname(nickname); ibVideoAllowService.updateBVideoAllow(allow); }else if (!loadOpenid.equals(openid)){ @@ -38,6 +49,6 @@ public class WxService { return AjaxResult.error(404,"未找到视频"); } - return AjaxResult.success(id+"----"+openid); - }*/ + return AjaxResult.success("ok",id+"----"+openid); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxTokenService.java b/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxTokenService.java index 530724e..c4ee5c3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxTokenService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hl/service/WxTokenService.java @@ -1,15 +1,16 @@ -package hl.service; +package com.ruoyi.hl.service; import cn.hutool.core.util.StrUtil; import com.ruoyi.common.core.redis.RedisCache; -import hl.config.WxConfig; -import hl.forest.clients.MiniWeChatClients; -import hl.forest.ptoto.WxMiniTokenRes; +import com.ruoyi.hl.config.WxConfig; +import com.ruoyi.hl.forest.clients.MiniWeChatClients; +import com.ruoyi.hl.forest.ptoto.WxMiniTokenRes; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import java.util.concurrent.TimeUnit; @@ -26,7 +27,7 @@ public class WxTokenService implements CommandLineRunner { private MiniWeChatClients miniWeChatClients; - //@Autowired + @Autowired private RedisCache redisCache; @Autowired @@ -34,7 +35,7 @@ public class WxTokenService implements CommandLineRunner { @Override public void run(String... args) throws Exception { - //refreshToken();//刷新token + refreshToken();//刷新token } @@ -51,11 +52,11 @@ public class WxTokenService implements CommandLineRunner { /** * 每分钟检测redis里的token是否到期 */ - //@Scheduled(cron = "0 * * * * ?") + @Scheduled(cron = "0 * * * * ?") public void refreshToken() { String pToken = redisCache.getCacheObject(pTokenK); if (pToken == null || pToken.equals("token")) { - refreshPublicToken(); + //refreshPublicToken(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java index 955c784..bfedb53 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java @@ -6,7 +6,10 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Resource; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; + +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.web.controller.mapper.VideoDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.FastByteArrayOutputStream; import org.springframework.web.bind.annotation.GetMapping; @@ -38,6 +41,11 @@ public class CaptchaController @Autowired private ISysConfigService configService; + + + @Autowired + private VideoDao videoDao; + /** * 生成验证码 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ilisteners/PutProcessData.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ilisteners/PutProcessData.java index 83bd45b..2181abd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ilisteners/PutProcessData.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ilisteners/PutProcessData.java @@ -1,4 +1,4 @@ -package com.ruoyi.web.controller.listener; +package com.ruoyi.web.controller.ilisteners; import lombok.Data; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/FileDao.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/FileDao.java index f532c0a..510bda7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/FileDao.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/FileDao.java @@ -1,2 +1,26 @@ -package com.ruoyi.web.controller.mapper;public class FileDao { +package com.ruoyi.web.controller.mapper; + +import com.ruoyi.system.domain.BFile; +import org.apache.ibatis.annotations.*; +import org.apache.ibatis.type.JdbcType; + +import java.util.List; + +@Mapper +public interface FileDao { + + @Select("") + @Results({ + @Result(column="video_name", property="videoName", jdbcType= JdbcType.VARCHAR), + + }) + public List findByNoIds(@Param("list") List ids); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/VideoDao.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/VideoDao.java index eac121d..797059b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/VideoDao.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/mapper/VideoDao.java @@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Select; import java.util.List; @Mapper -public interface Dao { - @Select("select file_id from b_video where parent_id= #{id}") +public interface VideoDao { + @Select("select file_id from b_videos where parent_id= #{id}") List findByParentId(long id); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BFileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BFileController.java index 6f396a8..6041991 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BFileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BFileController.java @@ -1,17 +1,31 @@ -package com.ruoyi.system.controller; +package com.ruoyi.web.controller.upload; +import java.io.File; +import java.io.IOException; +import java.util.Date; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.oss.OSS; +import com.github.pagehelper.PageHelper; +import com.ruoyi.framework.web.ilisteners.PutProcessData; +import com.ruoyi.framework.web.service.AliOSSService; +import com.ruoyi.system.domain.BVideos; +import com.ruoyi.system.service.IBVideosService; +import com.ruoyi.web.controller.mapper.FileDao; +import com.ruoyi.web.controller.mapper.VideoDao; +import com.ruoyi.web.serveice.UploadService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -20,64 +34,227 @@ import com.ruoyi.system.domain.BFile; import com.ruoyi.system.service.IBFileService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; /** * 【请填写功能名称】Controller - * + * * @author ruoyi * @date 2022-03-09 */ @RestController -@RequestMapping("/system/file") -public class BFileController extends BaseController -{ +@RequestMapping("/videos/file") +public class BFileController extends BaseController { + @Autowired private IBFileService bFileService; + @Autowired + private IBVideosService videosService; + + @Autowired + private AliOSSService ossService; + + @Autowired + private VideoDao videoDao; + + @Autowired + private FileDao fileDao; + + @Autowired + private UploadService uploadService; + + /** * 查询【请填写功能名称】列表 */ @PreAuthorize("@ss.hasPermi('system:file:list')") @GetMapping("/list") - public TableDataInfo list(BFile bFile) - { + public TableDataInfo list(BFile bFile) { startPage(); + PageHelper.orderBy("id desc"); List list = bFileService.selectBFileList(bFile); return getDataTable(list); } - /** - * 导出【请填写功能名称】列表 - */ - @PreAuthorize("@ss.hasPermi('system:file:export')") - @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, BFile bFile) - { - List list = bFileService.selectBFileList(bFile); - ExcelUtil util = new ExcelUtil(BFile.class); - util.exportExcel(response, list, "【请填写功能名称】数据"); - } /** * 获取【请填写功能名称】详细信息 */ @PreAuthorize("@ss.hasPermi('system:file:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(bFileService.selectBFileById(id)); } +/* + + */ +/** + * 新增【请填写功能名称】 + *//* + + @PreAuthorize("@ss.hasPermi('system:file:add')") + @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) + @PostMapping("/addFile") + public AjaxResult addFile(@RequestParam("file") MultipartFile multipartFile, @RequestParam("remark") String remark, @RequestParam("videoName") String videoName) { + BFile bFile = new BFile(); + OSS client = ossService.newOss(); + + Date now = new Date(); + String filename = now.getTime() + "." + FileUtil.getSuffix(multipartFile.getOriginalFilename()); + String suffix = "/" + filename; + String path = ossService.getPath(ossService.getPrefix(), suffix); + try { + + + //System.out.println(ossService.getDomain() + "/" + path); + bFile.setGmtCreate(now); + bFile.setVideoName(videoName); + bFile.setPercent("0%"); + bFile.setMemo(remark); + bFile.setUuid(path); + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error(e.getMessage()); + } + + if (bFileService.insertBFile(bFile) > 0) { + File f = null; + try { + f = File.createTempFile("tmp", null); + multipartFile.transferTo(f); + PutProcessData processData = new PutProcessData(); + processData.setId(filename); + File finalF = f; + executorService2.execute(new Runnable() { + @Override + public void run() { + ossService.uploadSuffix(client, processData, filename, finalF, suffix); + } + }); + executorService.execute(new Runnable() { + @Override + public void run() { + BFile bFile = new BFile(); + + bFile.setUuid(path); + List bFileList = bFileService.selectBFileList(bFile); + BFile findFile = bFileList != null && bFileList.size() > 0 ? bFileList.get(0) : null; + if (findFile == null) { + logger.info("findFile is null"); + return; + } + + try { + logger.info("upload start"); + + //ossService.uploadSuffix(client, multipartFile.getBytes(), suffix); + + + while (true) { + logger.info("v1 upload path:{}, success:{}, fail:{}", path, processData.isSuccess(), processData.isFail()); + if (processData.isSuccess() || processData.isFail()) { + if (processData.isSuccess()) { + findFile.setPercent("100%"); + findFile.setDone(1L); + } else if (processData.isFail()) { + findFile.setPercent("-1%"); + findFile.setDone(2L); + } + + bFileService.updateBFile(findFile); + break; + } else { + findFile.setPercent(processData.getProcess() + "%"); + bFileService.updateBFile(findFile); + } + Thread.sleep(1000); + } + } catch (Exception e) { + e.printStackTrace(); + } + + logger.info("upload success, url:{}", path); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (f != null) { + f.delete(); + } + } + return toAjax(1); + } else { + return toAjax(0); + } + + } +*/ + + + /** * 新增【请填写功能名称】 */ @PreAuthorize("@ss.hasPermi('system:file:add')") @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody BFile bFile) - { - return toAjax(bFileService.insertBFile(bFile)); + @PostMapping("/addFile") + public AjaxResult addFile(@RequestParam("file") MultipartFile multipartFile, @RequestParam("remark") String remark, @RequestParam("videoName") String videoName) { + BFile bFile = new BFile(); + + + Date now = new Date(); + String filename = now.getTime() + "." + FileUtil.getSuffix(multipartFile.getOriginalFilename()); + String suffix = "/" + filename; + String path = ossService.getPath(ossService.getPrefix(), suffix); + try { + + + //System.out.println(ossService.getDomain() + "/" + path); + bFile.setGmtCreate(now); + bFile.setVideoName(videoName); + bFile.setPercent("0%"); + bFile.setMemo(remark); + bFile.setUuid(path); + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error(e.getMessage()); + } + + if (bFileService.insertBFile(bFile) > 0) { + File f = new File("/root/jars/tmp/"+filename); + BFile findFile=null; + try { + if (!f.createNewFile()){ + logger.info("create file fail"); + return AjaxResult.error("创建文件失败"); + } + multipartFile.transferTo(f); + BFile param = new BFile(); + + param.setUuid(path); + List bFileList = bFileService.selectBFileList(param); + findFile = bFileList != null && bFileList.size() > 0 ? bFileList.get(0) : null; + if (findFile == null) { + logger.info("findFile is null"); + return AjaxResult.error("保存文件失败"); + } + + uploadService.uploadFile(findFile,filename,f,suffix); + } catch (IOException e) { + e.printStackTrace(); + } + + + + + return toAjax(1); + } else { + return toAjax(0); + } + } /** @@ -86,8 +263,7 @@ public class BFileController extends BaseController @PreAuthorize("@ss.hasPermi('system:file:edit')") @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody BFile bFile) - { + public AjaxResult edit(@RequestBody BFile bFile) { return toAjax(bFileService.updateBFile(bFile)); } @@ -96,9 +272,55 @@ public class BFileController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:file:remove')") @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { - return toAjax(bFileService.deleteBFileByIds(ids)); + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + int updRow = 0; + OSS client = ossService.newOss(); + for (Long id : ids) { + BFile bFile = bFileService.selectBFileById(id); + + + if (bFile != null) { + try { + ossService.remove(client, ossService.getBucketName(), bFile.getUuid()); + updRow += bFileService.deleteBFileById(id); + BVideos bVideos = new BVideos(); + bVideos.setFileId(bFile.getId()); + List a = videosService.selectBVideosList(bVideos); + if (a != null && a.size() > 0) { + a.forEach(v -> { + videosService.deleteBVideosById(v.getId()); + }); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + return toAjax(updRow); } + + @PreAuthorize("@ss.hasPermi('system:file:query')") + @Log(title = "【请填写功能名称】") + @GetMapping("/getNoAuthFiles") + public AjaxResult getNoAuthFiles(@RequestParam("videoId") Long id, @RequestParam("memo") String memo) { + List ids = videoDao.findByParentId(id); + if (ids.size() == 0) { + ids.add(-1L); + } + + List files = fileDao.findByNoIds(ids); + if (StrUtil.isNotBlank(memo)){ + files=files.stream().filter(v->{ + return v.getMemo().contains(memo); + }).collect(Collectors.toList()); + } + + + return AjaxResult.success(files); + } + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideoAllowController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideoAllowController.java index 9b6139b..061cb50 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideoAllowController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideoAllowController.java @@ -1,7 +1,13 @@ -package com.ruoyi.system.controller; +package com.ruoyi.web.controller.upload; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.lang.UUID; +import cn.hutool.core.util.RandomUtil; +import com.ruoyi.common.core.redis.RedisCache; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -23,49 +29,62 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 允许列Controller - * + * * @author ruoyi * @date 2022-03-10 */ @RestController @RequestMapping("/system/allow") -public class BVideoAllowController extends BaseController -{ +public class BVideoAllowController extends BaseController { + + public static String short_link_key = "short_link_"; + public static String short_link_code_key = "short_link_code_"; + + public static final String ranString=RandomUtil.BASE_CHAR.toUpperCase()+RandomUtil.BASE_CHAR_NUMBER; + + @Autowired private IBVideoAllowService bVideoAllowService; + @Value("${hl.share_domain}") + private String share_domain; + + @Value("${hl.share_short_domain}") + private String share_short_domain; + + @Autowired + private RedisCache redisCache; + /** * 查询允许列列表 */ @PreAuthorize("@ss.hasPermi('system:allow:list')") @GetMapping("/list") - public TableDataInfo list(BVideoAllow bVideoAllow) - { + public TableDataInfo list(BVideoAllow bVideoAllow) { startPage(); List list = bVideoAllowService.selectBVideoAllowList(bVideoAllow); + list.forEach(v -> { + String short_link = redisCache.getCacheObject(short_link_key + v.getId()); + + if (short_link == null) { + String code = RandomUtil.randomString(ranString,7); + redisCache.setCacheObject(short_link_key + v.getId(), share_short_domain + code); + redisCache.setCacheObject(short_link_code_key + code, share_domain + "?isFirst=true&allowId=" + v.getAllowId()); + } + + + v.setLink(short_link); + }); return getDataTable(list); } - /** - * 导出允许列列表 - */ - @PreAuthorize("@ss.hasPermi('system:allow:export')") - @Log(title = "允许列", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, BVideoAllow bVideoAllow) - { - List list = bVideoAllowService.selectBVideoAllowList(bVideoAllow); - ExcelUtil util = new ExcelUtil(BVideoAllow.class); - util.exportExcel(response, list, "允许列数据"); - } /** * 获取允许列详细信息 */ @PreAuthorize("@ss.hasPermi('system:allow:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(bVideoAllowService.selectBVideoAllowById(id)); } @@ -75,8 +94,10 @@ public class BVideoAllowController extends BaseController @PreAuthorize("@ss.hasPermi('system:allow:add')") @Log(title = "允许列", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody BVideoAllow bVideoAllow) - { + public AjaxResult add(@RequestBody BVideoAllow bVideoAllow) { + Date now = new Date(); + bVideoAllow.setGmtCreate(now); + bVideoAllow.setAllowId(UUID.randomUUID().toString()); return toAjax(bVideoAllowService.insertBVideoAllow(bVideoAllow)); } @@ -86,8 +107,7 @@ public class BVideoAllowController extends BaseController @PreAuthorize("@ss.hasPermi('system:allow:edit')") @Log(title = "允许列", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody BVideoAllow bVideoAllow) - { + public AjaxResult edit(@RequestBody BVideoAllow bVideoAllow) { return toAjax(bVideoAllowService.updateBVideoAllow(bVideoAllow)); } @@ -96,9 +116,8 @@ public class BVideoAllowController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:allow:remove')") @Log(title = "允许列", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(bVideoAllowService.deleteBVideoAllowByIds(ids)); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideosController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideosController.java index 228550c..4d1de64 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideosController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/BVideosController.java @@ -1,17 +1,19 @@ -package com.ruoyi.system.controller; +package com.ruoyi.web.controller.upload; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; +import javax.xml.crypto.Data; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.system.domain.BFile; +import com.ruoyi.system.service.IBFileService; +import com.sun.imageio.plugins.common.BitFile; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -23,27 +25,77 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 视频信息Controller - * + * * @author ruoyi * @date 2022-03-09 */ @RestController @RequestMapping("/system/videos") -public class BVideosController extends BaseController -{ +public class BVideosController extends BaseController { + @Autowired private IBVideosService bVideosService; + + @Autowired + private IBFileService ibFileService; + + + @PreAuthorize("@ss.hasPermi('system:videos:manageFiles')") + @Log(title = "【请填写功能名称】") + @PostMapping("/insertVideos") + public AjaxResult insert(@RequestBody JSONObject jsonObject) { + Date now = new Date(); + JSONArray fileIds = jsonObject.getJSONArray("ids"); + for (int i = 0; i < fileIds.size(); i++) { + + Long fileId = ((Integer) fileIds.get(i)).longValue(); + BFile bFile = ibFileService.selectBFileById(fileId); + + BVideos bVideos = new BVideos(); + bVideos.setGmtCreate(now); + bVideos.setGmtModified(now); + bVideos.setFileId(fileId); + bVideos.setName(bFile.getVideoName()); + bVideos.setParentId(jsonObject.getLong("videoId")); + bVideos.setFileId(fileId); + bVideos.setType(2L); + bVideosService.insertBVideos(bVideos); + } + + + return AjaxResult.success(); + } + /** * 查询视频信息列表 */ @PreAuthorize("@ss.hasPermi('system:videos:list')") @GetMapping("/list") - public TableDataInfo list(BVideos bVideos) - { + public TableDataInfo list(BVideos bVideos) { startPage(); + List list = bVideosService.selectBVideosList(bVideos); - return getDataTable(list); + JSONArray res = new JSONArray(); + for (int i = 0; i < list.size(); i++) { + BVideos videos = list.get(i); + BVideos queryParam = new BVideos(); + queryParam.setParentId(videos.getId()); + List videoChildren = bVideosService.selectBVideosList(queryParam); + List filenames = new ArrayList<>(); + videoChildren.forEach(v -> { + BFile file = ibFileService.selectBFileById(v.getFileId()); + if (file != null&&filenames.size()<10) + filenames.add(file.getVideoName()); + }); + JSONObject jsonObject = (JSONObject) JSONObject.toJSON(videos); + jsonObject.put("filenames", String.join(",", filenames)); + res.add(jsonObject); + + } + TableDataInfo rspData=getDataTable(list); + rspData.setRows(res); + return rspData; } /** @@ -52,8 +104,7 @@ public class BVideosController extends BaseController @PreAuthorize("@ss.hasPermi('system:videos:export')") @Log(title = "视频信息", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, BVideos bVideos) - { + public void export(HttpServletResponse response, BVideos bVideos) { List list = bVideosService.selectBVideosList(bVideos); ExcelUtil util = new ExcelUtil(BVideos.class); util.exportExcel(response, list, "视频信息数据"); @@ -64,8 +115,7 @@ public class BVideosController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:videos:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(bVideosService.selectBVideosById(id)); } @@ -75,8 +125,7 @@ public class BVideosController extends BaseController @PreAuthorize("@ss.hasPermi('system:videos:add')") @Log(title = "视频信息", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody BVideos bVideos) - { + public AjaxResult add(@RequestBody BVideos bVideos) { return toAjax(bVideosService.insertBVideos(bVideos)); } @@ -86,8 +135,7 @@ public class BVideosController extends BaseController @PreAuthorize("@ss.hasPermi('system:videos:edit')") @Log(title = "视频信息", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody BVideos bVideos) - { + public AjaxResult edit(@RequestBody BVideos bVideos) { return toAjax(bVideosService.updateBVideos(bVideos)); } @@ -96,9 +144,8 @@ public class BVideosController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:videos:remove')") @Log(title = "视频信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(bVideosService.deleteBVideosByIds(ids)); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/ShortLinkController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/ShortLinkController.java index 6303176..83e9b16 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/ShortLinkController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/ShortLinkController.java @@ -1,26 +1,20 @@ package com.ruoyi.web.controller.upload; -import cn.hutool.core.util.RandomUtil; -import com.ruoyi.common.core.page.TableDataInfo; +import cn.hutool.core.util.StrUtil; import com.ruoyi.common.core.redis.RedisCache; -import com.ruoyi.system.domain.BVideoAllow; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; 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.RestController; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.RedirectView; -import static com.ruoyi.framework.datasource.DynamicDataSourceContextHolder.log; - @Slf4j @Controller @RequestMapping("/s") -public class ShortController { +public class ShortLinkController { @Autowired private RedisCache redisCache; @@ -33,9 +27,7 @@ public class ShortController { @GetMapping("/{code}") public ModelAndView list(@PathVariable("code") String code) { - String completeUrl=redisCache.getCacheObject(BVideoAllowController.short_link_code_key+code); - log.info("jump to completeUrl:{}",completeUrl); ModelAndView downloadView = new ModelAndView(new RedirectView(completeUrl)); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/VideosController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/VideosController.java index 3c738cd..a5664a5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/VideosController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/upload/VideosController.java @@ -1,2 +1,31 @@ -package com.ruoyi.web.controller.upload;public class UploadFileController { +package com.ruoyi.web.controller.upload; + +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.system.domain.SysConfig; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static com.ruoyi.common.utils.PageUtils.startPage; + +@RestController +@RequestMapping("/videos") +public class VideosController { + + + + /** + * 获取参数配置列表 + */ + /*@PreAuthorize("@ss.hasPermi('videos:list')") + @GetMapping("/list") + public TableDataInfo list(SysConfig config) + { + startPage(); + List list = configService.selectConfigList(config); + return getDataTable(list); + }*/ } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 0b94245..d094383 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -2,6 +2,7 @@ package com.ruoyi.web.core.config; import java.util.ArrayList; import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; @@ -24,21 +25,27 @@ import springfox.documentation.spring.web.plugins.Docket; /** * Swagger2的接口配置 - * + * * @author ruoyi */ @Configuration -public class SwaggerConfig -{ - /** 系统基础配置 */ +public class SwaggerConfig { + + /** + * 系统基础配置 + */ @Autowired private RuoYiConfig ruoyiConfig; - /** 是否开启swagger */ + /** + * 是否开启swagger + */ @Value("${swagger.enabled}") private boolean enabled; - /** 设置请求的统一前缀 */ + /** + * 设置请求的统一前缀 + */ @Value("${swagger.pathMapping}") private String pathMapping; @@ -46,8 +53,7 @@ public class SwaggerConfig * 创建API */ @Bean - public Docket createRestApi() - { + public Docket createRestApi() { return new Docket(DocumentationType.OAS_30) // 是否启用Swagger .enable(enabled) @@ -71,8 +77,7 @@ public class SwaggerConfig /** * 安全模式,这里指定token通过Authorization头请求头传递 */ - private List securitySchemes() - { + private List securitySchemes() { List apiKeyList = new ArrayList(); apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); return apiKeyList; @@ -81,8 +86,7 @@ public class SwaggerConfig /** * 安全上下文 */ - private List securityContexts() - { + private List securityContexts() { List securityContexts = new ArrayList<>(); securityContexts.add( SecurityContext.builder() @@ -95,8 +99,7 @@ public class SwaggerConfig /** * 默认的安全上引用 */ - private List defaultAuth() - { + private List defaultAuth() { AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; authorizationScopes[0] = authorizationScope; @@ -108,8 +111,7 @@ public class SwaggerConfig /** * 添加摘要信息 */ - private ApiInfo apiInfo() - { + private ApiInfo apiInfo() { // 用ApiInfoBuilder进行定制 return new ApiInfoBuilder() // 设置标题 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/serveice/UploadService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/serveice/UploadService.java index bdd2085..50c1b12 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/serveice/UploadService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/serveice/UploadService.java @@ -1,2 +1,86 @@ -package com.ruoyi.web.serveice;public class UploadService { +package com.ruoyi.web.serveice; + +import com.aliyun.oss.OSS; +import com.ruoyi.framework.web.ilisteners.PutProcessData; +import com.ruoyi.framework.web.service.AliOSSService; +import com.ruoyi.system.domain.BFile; +import com.ruoyi.system.service.IBFileService; +import com.ruoyi.system.service.IBVideosService; +import com.ruoyi.web.controller.mapper.FileDao; +import com.ruoyi.web.controller.mapper.VideoDao; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@Slf4j +@Component +public class UploadService { + + + private ExecutorService executorService = Executors.newSingleThreadExecutor(); + + @Autowired + private IBFileService bFileService; + + @Autowired + private IBVideosService videosService; + + @Autowired + private AliOSSService ossService; + + @Autowired + private VideoDao videoDao; + + @Autowired + private FileDao fileDao; + + public void uploadFile(BFile bfile, String filename, File f, String suffix){ + OSS client = ossService.newOss(); + + executorService.submit(new Runnable() { + @Override + public void run() { + log.info("upload start v1"); + try { + //ossService.uploadSuffix(client, multipartFile.getBytes(), suffix); + PutProcessData processData = new PutProcessData(); + processData.setId(filename); + bfile.setDone(3L); + bFileService.updateBFile(bfile); + + ossService.uploadSuffix(client, processData, filename, f, suffix,bFileService,bfile); + /*while (true) { + logger.info("upload path:{}, success:{}, fail:{}", path, processData.isSuccess(), processData.isFail()); + if (processData.isSuccess() || processData.isFail()) { + if (processData.isSuccess()) { + bfile.setPercent("100%"); + bfile.setDone(1L); + } else if (processData.isFail()) { + bfile.setPercent("-1%"); + bfile.setDone(2L); + } + + bFileService.updateBFile(bfile); + break; + } else { + bfile.setPercent(processData.getProcess() + "%"); + bFileService.updateBFile(bfile); + } + Thread.sleep(1000); + }*/ + } catch (Exception e) { + + e.printStackTrace(); + } finally { + f.delete(); + } + + + } + }); + } } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 1f098e4..4864dfe 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -8,7 +8,7 @@ spring: master: url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: password + password: nolan5146 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index ccef250..6496ec3 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -14,15 +14,67 @@ ruoyi: addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 captchaType: math +ali: + oss: + prefix: videos + domain: https://xd-video-0.oss-cn-shanghai.aliyuncs.com + bucketName: jelkfjoiweur + endpoint: oss-cn-shanghai.aliyuncs.com + accessKey: LTAI5tQLkBCyQGRmKmXyibjK + secret: RJ4kUelf1QySoDVW4JCzcasRHDocsA +# oss: +# prefix: oss +# domain: https://xd-video-0.oss-cn-shanghai.aliyuncs.com +# bucketName: xd-video-0 +# endpoint: oss-cn-shanghai.aliyuncs.com +# accessKey: LTAI4G1Rfc8i5sRdBKREgcVV +# secret: V5MRq7o1V1imCgWfKRyGy7cTPpbuku + +hl: + #跳转地址 + share_domain: http://fajslkdjf.com + share_short_domain: http://fajslkdjf.com + + + +#微信配置 +wx: + public: + #微信授权地址 + redirect_uri: https://admin.sibaotech.com/test + appid: wxcb8766dc193524dd + secret: ae75181cb64cc5d4156a3d3b805d6fcc + +video: + baseUrl: +forest: + variables: + wechat_clients_url: https://api.weixin.qq.com + wechat_mch_clients_url: https://api.mch.weixin.qq.com + ## 日志总开关,打开/关闭Forest请求/响应日志 + log-enabled: true + ## 打开/关闭Forest请求日志 + log-request: false + ## 打开/关闭Forest响应状态日志 + log-response-status: true + ## 打开/关闭Forest响应内容日志 + log-response-content: true + + + + # 开发环境配置 + server: # 服务器的HTTP端口,默认为8080 port: 8080 + servlet: # 应用的访问路径 context-path: / tomcat: + # tomcat的URI编码 uri-encoding: UTF-8 # 连接数满后的排队数,默认为100 @@ -51,7 +103,7 @@ spring: servlet: multipart: # 单个文件大小 - max-file-size: 10MB + max-file-size: 1024MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 @@ -99,6 +151,8 @@ mybatis: mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml + configuration: + map-underscore-to-camel-case: true # PageHelper分页插件 pagehelper: diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index e18104c..eb9a806 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -16,6 +16,12 @@ + + + com.aliyun.oss + aliyun-sdk-oss + 3.10.2 + @@ -124,7 +130,11 @@ javax.servlet javax.servlet-api - + + cn.hutool + hutool-core + 5.6.0 + \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java index 3246b77..78b01f8 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java @@ -20,8 +20,8 @@ import org.springframework.stereotype.Component; **/ @SuppressWarnings(value = { "unchecked", "rawtypes" }) @Component -public class RedisCache -{ +public class RedisCache { + @Autowired public RedisTemplate redisTemplate; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/BytesUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/BytesUtil.java index 72ab80c..cbab5d0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/BytesUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/BytesUtil.java @@ -1,4 +1,4 @@ -package com.github.wxiaoqi.security.common.util; +package com.ruoyi.common.utils; import java.util.Arrays; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 58dd02a..a3a5a3a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -97,17 +97,18 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/register", "/captchaImage").anonymous() + .antMatchers("/login", "/register", "/captchaImage", "/s/*").anonymous() .antMatchers( HttpMethod.GET, "/", "/*.html", - "/**/*.html", + "/**/*.html","/wx/**", "/**/*.css", "/**/*.js", "/profile/**" ).permitAll() .antMatchers("/swagger-ui.html").anonymous() + .antMatchers("/wx/**").anonymous() .antMatchers("/swagger-resources/**").anonymous() .antMatchers("/webjars/**").anonymous() .antMatchers("/*/api-docs").anonymous() diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutObjectProgressListener.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutObjectProgressListener.java index 4422ea0..e403e27 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutObjectProgressListener.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutObjectProgressListener.java @@ -1,8 +1,10 @@ -package com.ruoyi.web.controller.ilisteners; +package com.ruoyi.framework.web.ilisteners; import com.aliyun.oss.event.ProgressEvent; import com.aliyun.oss.event.ProgressEventType; import com.aliyun.oss.event.ProgressListener; +import com.ruoyi.system.domain.BFile; +import com.ruoyi.system.service.IBFileService; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -12,17 +14,36 @@ public class PutObjectProgressListener implements ProgressListener { private long totalBytes = -1; private boolean succeed = false; private int percent = 0; - int sum = 0; private boolean fail = false; + private int lastPercent=0; + private IBFileService bFileService ; + private BFile bile; + + public void onSuccess(String percent){ + bile.setPercent(percent+"%"); + bFileService.updateBFile(bile); + } + public void onFail(){ + bile.setPercent("-1%"); + bile.setDone(2L); + bFileService.updateBFile(bile); + } + public void onCompleted(){ + bile.setPercent("100%"); + bile.setDone(1L); + bFileService.updateBFile(bile); + } + // 构造方法中加入session public PutObjectProgressListener() { } - public PutObjectProgressListener(PutProcessData mSession, int sum) { + public PutObjectProgressListener(PutProcessData mSession,IBFileService bFileService, BFile bile) { this.session = mSession; - this.sum = sum; - this.session.setProcess("0 %"); + this.bFileService=bFileService; + this.bile=bile; + log.info("========================{}============================", session.getId()); @@ -46,25 +67,34 @@ public class PutObjectProgressListener implements ProgressListener { if (this.totalBytes != -1) { percent = (int) (this.bytesWritten * 100.0 / this.totalBytes); // 将进度percent放入session中 - this.session.setProcess(percent + " %"); //session.setAttribute("upload_percent", percent); + if (lastPercent!=percent){ + lastPercent=percent; + onSuccess(percent+""); + log.info("v1 upload process id:{}, percent:{}", session.getId(), percent); + } } else { } break; case TRANSFER_COMPLETED_EVENT: this.succeed = true; - + this.session.setSuccess(true); + onCompleted(); break; case TRANSFER_FAILED_EVENT: fail = true; + this.session.setFail(true); + onFail(); break; default: break; } //控制台打印进度 - log.info("upload process id:{}, percent:{}", session.getId(), percent); + this.session.setProcess(percent + " %"); + + //System.out.println("percent:" + percent); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutProcessData.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutProcessData.java index 2181abd..4e889fd 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutProcessData.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/ilisteners/PutProcessData.java @@ -1,10 +1,12 @@ -package com.ruoyi.web.controller.ilisteners; +package com.ruoyi.framework.web.ilisteners; import lombok.Data; @Data public class PutProcessData { - private Long id; + private String id; private String process; + private boolean success=false; + private boolean fail=false; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/AliOSSService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/AliOSSService.java index 88287b9..415b562 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/AliOSSService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/AliOSSService.java @@ -1,2 +1,119 @@ -package com.ruoyi.system.service;public class AliOSSService { +package com.ruoyi.framework.web.service; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.PutObjectRequest; +import com.aliyun.oss.model.PutObjectResult; +import com.ruoyi.common.exception.base.BaseException; +import com.ruoyi.framework.web.ilisteners.PutObjectProgressListener; +import com.ruoyi.framework.web.ilisteners.PutProcessData; +import com.ruoyi.system.domain.BFile; +import com.ruoyi.system.service.IBFileService; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.util.UUID; + +@Data +@Slf4j +@Service +public class AliOSSService { + + @Value("${ali.oss.endpoint}") + private String endpoint = "yourEndpoint"; + + + // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 + @Value("${ali.oss.accessKey}") + private String accessKeyId = "yourAccessKeyId"; + + @Value("${ali.oss.secret}") + private String accessKeySecret = "yourAccessKeySecret"; + + + //阿里云BucketName + @Value("${ali.oss.bucketName}") + private String bucketName; + + //阿里云绑定的域名 + @Value("${ali.oss.domain}") + private String domain; + + //阿里云路径前缀 + @Value("${ali.oss.prefix}") + private String prefix; + + + public OSS newOss() { + log.info("new oss accessKeyId:{}", accessKeyId); + return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + } + + public void remove(OSS client, String objectName, String path) { + if (client.doesObjectExist(objectName, path)){ + client.deleteObject(bucketName, path); + } + + } + + + public String upload(OSS client, InputStream inputStream, String path) { + try { + client.putObject(bucketName, path, inputStream); + + } catch (Exception e) { + throw new BaseException("上传文件失败,请检查配置信息"); + } + + return domain + "/" + path; + } + + + public String upload(OSS client, PutProcessData processData , String fileName, File f, String path, IBFileService bFileService, BFile bile) { + try { + /*PutObjectResult putObjectResult=client.putObject(bucketName, path, inputStream);*/ + client + .putObject(new PutObjectRequest(bucketName, + path, f) + . withProgressListener( + new PutObjectProgressListener(processData,bFileService,bile) + )); + + } catch (Exception e) { + throw new BaseException("上传文件失败,请检查配置信息"); + } + + return domain + "/" + path; + } + public String uploadSuffix(OSS client, PutProcessData processData , String fileName, File f, String suffix,IBFileService bFileService, BFile bile) { + + return upload(client, processData, fileName, f, getPath(getPrefix(), suffix),bFileService,bile); + } + + public String uploadSuffix(OSS client, byte[] data, String suffix) { + return upload(client, new ByteArrayInputStream(data), getPath(getPrefix(), suffix)); + } + + + public String uploadSuffix(OSS client, InputStream inputStream, String suffix) { + return upload(client, inputStream, getPath(getPrefix(), suffix)); + } + + public String getPath(String prefix, String suffix) { + //生成uuid + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + //文件路径 + String path = DateUtil.today().replaceAll("-", ""); + if (StrUtil.isNotBlank(prefix)) { + path = prefix + "/" + path; + } + + return path + suffix; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BFile.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BFile.java index f96a2ac..cf91913 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BFile.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BFile.java @@ -11,7 +11,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 【请填写功能名称】对象 b_file * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-14 */ public class BFile extends BaseEntity { @@ -20,9 +20,9 @@ public class BFile extends BaseEntity /** $column.columnComment */ private Long id; - /** 文件id */ - @Excel(name = "文件id") - private String uuid; + /** 视频名称 */ + @Excel(name = "视频名称") + private String videoName; /** 备注 */ @Excel(name = "备注") @@ -32,6 +32,18 @@ public class BFile extends BaseEntity @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private Date gmtCreate; + /** 文件id */ + @Excel(name = "文件id") + private String uuid; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String percent; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private Long done; + public void setId(Long id) { this.id = id; @@ -41,14 +53,14 @@ public class BFile extends BaseEntity { return id; } - public void setUuid(String uuid) + public void setVideoName(String videoName) { - this.uuid = uuid; + this.videoName = videoName; } - public String getUuid() + public String getVideoName() { - return uuid; + return videoName; } public void setMemo(String memo) { @@ -68,14 +80,44 @@ public class BFile extends BaseEntity { return gmtCreate; } + public void setUuid(String uuid) + { + this.uuid = uuid; + } + + public String getUuid() + { + return uuid; + } + public void setPercent(String percent) + { + this.percent = percent; + } + + public String getPercent() + { + return percent; + } + public void setDone(Long done) + { + this.done = done; + } + + public Long getDone() + { + return done; + } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) - .append("uuid", getUuid()) + .append("videoName", getVideoName()) .append("memo", getMemo()) .append("gmtCreate", getGmtCreate()) + .append("uuid", getUuid()) + .append("percent", getPercent()) + .append("done", getDone()) .toString(); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BVideoAllow.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BVideoAllow.java index 7c80ec5..73994b5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BVideoAllow.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BVideoAllow.java @@ -11,7 +11,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 允许列对象 b_video_allow * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-10 */ public class BVideoAllow extends BaseEntity { @@ -32,13 +32,21 @@ public class BVideoAllow extends BaseEntity @Excel(name = "微信公众号昵称") private String wxNickname; + /** 备注 */ + @Excel(name = "备注") + private String memo; + + /** 分享链接 */ + @Excel(name = "分享链接") + private String link; + /** $column.columnComment */ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") - private Date gmtCreate; + private Long videoId; /** $column.columnComment */ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") - private Long videoId; + private Date gmtCreate; public void setId(Long id) { @@ -76,14 +84,23 @@ public class BVideoAllow extends BaseEntity { return wxNickname; } - public void setGmtCreate(Date gmtCreate) + public void setMemo(String memo) { - this.gmtCreate = gmtCreate; + this.memo = memo; } - public Date getGmtCreate() + public String getMemo() { - return gmtCreate; + return memo; + } + public void setLink(String link) + { + this.link = link; + } + + public String getLink() + { + return link; } public void setVideoId(Long videoId) { @@ -94,6 +111,15 @@ public class BVideoAllow extends BaseEntity { return videoId; } + public void setGmtCreate(Date gmtCreate) + { + this.gmtCreate = gmtCreate; + } + + public Date getGmtCreate() + { + return gmtCreate; + } @Override public String toString() { @@ -102,8 +128,10 @@ public class BVideoAllow extends BaseEntity .append("allowId", getAllowId()) .append("wxOpenid", getWxOpenid()) .append("wxNickname", getWxNickname()) - .append("gmtCreate", getGmtCreate()) + .append("memo", getMemo()) + .append("link", getLink()) .append("videoId", getVideoId()) + .append("gmtCreate", getGmtCreate()) .toString(); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BFileMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BFileMapper.java index 97ad8ac..ffdd59d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BFileMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BFileMapper.java @@ -7,7 +7,7 @@ import com.ruoyi.system.domain.BFile; * 【请填写功能名称】Mapper接口 * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-14 */ public interface BFileMapper { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BVideoAllowMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BVideoAllowMapper.java index e2283fc..88410be 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BVideoAllowMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BVideoAllowMapper.java @@ -7,7 +7,7 @@ import com.ruoyi.system.domain.BVideoAllow; * 允许列Mapper接口 * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-10 */ public interface BVideoAllowMapper { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBFileService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBFileService.java index b139860..4d68599 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBFileService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBFileService.java @@ -7,7 +7,7 @@ import com.ruoyi.system.domain.BFile; * 【请填写功能名称】Service接口 * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-14 */ public interface IBFileService { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBVideoAllowService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBVideoAllowService.java index 978df50..c809e3f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBVideoAllowService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBVideoAllowService.java @@ -7,7 +7,7 @@ import com.ruoyi.system.domain.BVideoAllow; * 允许列Service接口 * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-10 */ public interface IBVideoAllowService { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BFileServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BFileServiceImpl.java index 83fbfad..b28cc11 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BFileServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BFileServiceImpl.java @@ -11,7 +11,7 @@ import com.ruoyi.system.service.IBFileService; * 【请填写功能名称】Service业务层处理 * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-14 */ @Service public class BFileServiceImpl implements IBFileService diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BVideoAllowServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BVideoAllowServiceImpl.java index 13a0678..4e72c20 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BVideoAllowServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BVideoAllowServiceImpl.java @@ -11,7 +11,7 @@ import com.ruoyi.system.service.IBVideoAllowService; * 允许列Service业务层处理 * * @author ruoyi - * @date 2022-03-09 + * @date 2022-03-10 */ @Service public class BVideoAllowServiceImpl implements IBVideoAllowService diff --git a/ruoyi-system/src/main/resources/mapper/system/BFileMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BFileMapper.xml index 32e5be8..b899e2b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BFileMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BFileMapper.xml @@ -6,21 +6,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + + - select id, uuid, memo, gmt_create from b_file + select id, video_name, memo, gmt_create, uuid, percent, done from b_file @@ -32,23 +38,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into b_file - uuid, + video_name, memo, gmt_create, + uuid, + percent, + done, - #{uuid}, + #{videoName}, #{memo}, #{gmtCreate}, + #{uuid}, + #{percent}, + #{done}, update b_file - uuid = #{uuid}, + video_name = #{videoName}, memo = #{memo}, gmt_create = #{gmtCreate}, + uuid = #{uuid}, + percent = #{percent}, + done = #{done}, where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/BVideoAllowMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BVideoAllowMapper.xml index 08eab66..dc84494 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BVideoAllowMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BVideoAllowMapper.xml @@ -9,12 +9,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + - select id, allow_id, wx_openid, wx_nickname, gmt_create, video_id from b_video_allow + select id, allow_id, wx_openid, wx_nickname, memo, link, video_id, gmt_create from b_video_allow @@ -39,15 +43,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" allow_id, wx_openid, wx_nickname, - gmt_create, + memo, + link, video_id, + gmt_create, #{allowId}, #{wxOpenid}, #{wxNickname}, - #{gmtCreate}, + #{memo}, + #{link}, #{videoId}, + #{gmtCreate}, @@ -57,8 +65,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" allow_id = #{allowId}, wx_openid = #{wxOpenid}, wx_nickname = #{wxNickname}, - gmt_create = #{gmtCreate}, + memo = #{memo}, + link = #{link}, video_id = #{videoId}, + gmt_create = #{gmtCreate}, where id = #{id} diff --git a/ruoyi-ui/.env.production b/ruoyi-ui/.env.production index cb064ec..02d82d2 100644 --- a/ruoyi-ui/.env.production +++ b/ruoyi-ui/.env.production @@ -1,8 +1,8 @@ -# 页面标题 -VUE_APP_TITLE = 若依管理系统 - -# 生产环境配置 -ENV = 'production' - -# 若依管理系统/生产环境 -VUE_APP_BASE_API = '/prod-api' +# 页面标题 +VUE_APP_TITLE = 若依管理系统 + +# 生产环境配置 +ENV = 'production' + +# 若依管理系统/生产环境 +VUE_APP_BASE_API = 'http://106.15.102.28:8080' diff --git a/ruoyi-ui/.env.staging b/ruoyi-ui/.env.staging index a47af9a..63da983 100644 --- a/ruoyi-ui/.env.staging +++ b/ruoyi-ui/.env.staging @@ -1,10 +1,10 @@ -# 页面标题 -VUE_APP_TITLE = 若依管理系统 - -NODE_ENV = production - -# 测试环境配置 -ENV = 'staging' - -# 若依管理系统/测试环境 -VUE_APP_BASE_API = '/stage-api' +# 页面标题 +VUE_APP_TITLE = 若依管理系统 + +NODE_ENV = production + +# 测试环境配置 +ENV = 'staging' + +# 若依管理系统/测试环境 +VUE_APP_BASE_API = 'http://106.15.102.28:8080' diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index fc15b2e..ea6f772 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,90 +1,90 @@ -{ - "name": "ruoyi", - "version": "3.8.1", - "description": "若依管理系统", - "author": "若依", - "license": "MIT", - "scripts": { - "dev": "vue-cli-service serve", - "build:prod": "vue-cli-service build", - "build:stage": "vue-cli-service build --mode staging", - "preview": "node build/index.js --preview", - "lint": "eslint --ext .js,.vue src" - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, - "lint-staged": { - "src/**/*.{js,vue}": [ - "eslint --fix", - "git add" - ] - }, - "keywords": [ - "vue", - "admin", - "dashboard", - "element-ui", - "boilerplate", - "admin-template", - "management-system" - ], - "repository": { - "type": "git", - "url": "https://gitee.com/y_project/RuoYi-Vue.git" - }, - "dependencies": { - "@riophae/vue-treeselect": "0.4.0", - "axios": "0.24.0", - "clipboard": "2.0.8", - "core-js": "3.19.1", - "echarts": "4.9.0", - "element-ui": "2.15.6", - "file-saver": "2.0.5", - "fuse.js": "6.4.3", - "highlight.js": "9.18.5", - "js-beautify": "1.13.0", - "js-cookie": "3.0.1", - "jsencrypt": "3.2.1", - "nprogress": "0.2.0", - "quill": "1.3.7", - "screenfull": "5.0.2", - "sortablejs": "1.10.2", - "vue": "2.6.12", - "vue-count-to": "1.0.13", - "vue-cropper": "0.5.5", - "vue-meta": "2.4.0", - "vue-router": "3.4.9", - "vuedraggable": "2.24.3", - "vuex": "3.6.0" - }, - "devDependencies": { - "@vue/cli-plugin-babel": "4.4.6", - "@vue/cli-plugin-eslint": "4.4.6", - "@vue/cli-service": "4.4.6", - "babel-eslint": "10.1.0", - "babel-plugin-dynamic-import-node": "2.3.3", - "chalk": "4.1.0", - "compression-webpack-plugin": "5.0.2", - "connect": "3.6.6", - "eslint": "7.15.0", - "eslint-plugin-vue": "7.2.0", - "lint-staged": "10.5.3", - "runjs": "4.4.2", - "sass": "1.32.13", - "sass-loader": "10.1.1", - "script-ext-html-webpack-plugin": "2.1.5", - "svg-sprite-loader": "5.1.1", - "vue-template-compiler": "2.6.12" - }, - "engines": { - "node": ">=8.9", - "npm": ">= 3.0.0" - }, - "browserslist": [ - "> 1%", - "last 2 versions" - ] -} +{ + "name": "ruoyi", + "version": "3.8.1", + "description": "若依管理系统", + "author": "若依", + "license": "MIT", + "scripts": { + "dev": "vue-cli-service serve", + "build:prod": "vue-cli-service build", + "build:stage": "vue-cli-service build --mode staging", + "preview": "node build/index.js --preview", + "lint": "eslint --ext .js,.vue src" + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "src/**/*.{js,vue}": [ + "eslint --fix", + "git add" + ] + }, + "keywords": [ + "vue", + "admin", + "dashboard", + "element-ui", + "boilerplate", + "admin-template", + "management-system" + ], + "repository": { + "type": "git", + "url": "https://gitee.com/y_project/RuoYi-Vue.git" + }, + "dependencies": { + "@riophae/vue-treeselect": "0.4.0", + "axios": "0.24.0", + "clipboard": "2.0.8", + "core-js": "3.19.1", + "echarts": "4.9.0", + "element-ui": "2.15.6", + "file-saver": "2.0.5", + "fuse.js": "6.4.3", + "highlight.js": "9.18.5", + "js-beautify": "1.13.0", + "js-cookie": "3.0.1", + "jsencrypt": "3.2.1", + "nprogress": "0.2.0", + "quill": "1.3.7", + "screenfull": "5.0.2", + "sortablejs": "1.10.2", + "vue": "2.6.12", + "vue-count-to": "1.0.13", + "vue-cropper": "0.5.5", + "vue-meta": "2.4.0", + "vue-router": "3.4.9", + "vuedraggable": "2.24.3", + "vuex": "3.6.0" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "4.4.6", + "@vue/cli-plugin-eslint": "4.4.6", + "@vue/cli-service": "4.4.6", + "babel-eslint": "10.1.0", + "babel-plugin-dynamic-import-node": "2.3.3", + "chalk": "4.1.0", + "compression-webpack-plugin": "5.0.2", + "connect": "3.6.6", + "eslint": "7.15.0", + "eslint-plugin-vue": "7.2.0", + "lint-staged": "10.5.3", + "runjs": "4.4.2", + "sass": "1.32.13", + "sass-loader": "10.1.1", + "script-ext-html-webpack-plugin": "2.1.5", + "svg-sprite-loader": "5.1.1", + "vue-template-compiler": "2.6.12" + }, + "engines": { + "node": ">=8.9", + "npm": ">= 3.0.0" + }, + "browserslist": [ + "> 1%", + "last 2 versions" + ] +} diff --git a/ruoyi-ui/public/index.html b/ruoyi-ui/public/index.html index 56fd45b..2dbbe98 100644 --- a/ruoyi-ui/public/index.html +++ b/ruoyi-ui/public/index.html @@ -1,208 +1,209 @@ - - - - - - - - - <%= webpackConfig.name %> - - - - -
-
-
-
-
-
正在加载系统资源,请耐心等待
-
-
- - + + + + + + + + + <%= webpackConfig.name %> + + + + +
+
+
+
+
+
正在加载系统资源,请耐心等待
+
+
+ + + diff --git a/ruoyi-ui/src/api/system/file.js b/ruoyi-ui/src/api/system/file.js index 9595c84..17cac08 100644 --- a/ruoyi-ui/src/api/system/file.js +++ b/ruoyi-ui/src/api/system/file.js @@ -3,7 +3,15 @@ import request from '@/utils/request' // 查询【请填写功能名称】列表 export function listFile(query) { return request({ - url: '/system/file/list', + url: '/videos/file/list', + method: 'get', + params: query + }) +} +// 未被选中的列表 +export function getNoAuthFiles(query) { + return request({ + url: '/videos/file/getNoAuthFiles', method: 'get', params: query }) @@ -12,7 +20,7 @@ export function listFile(query) { // 查询【请填写功能名称】详细 export function getFile(id) { return request({ - url: '/system/file/' + id, + url: '/videos/file/' + id, method: 'get' }) } @@ -20,7 +28,7 @@ export function getFile(id) { // 新增【请填写功能名称】 export function addFile(data) { return request({ - url: '/system/file', + url: '/videos/file', method: 'post', data: data }) @@ -29,7 +37,7 @@ export function addFile(data) { // 修改【请填写功能名称】 export function updateFile(data) { return request({ - url: '/system/file', + url: '/videos/file', method: 'put', data: data }) @@ -38,7 +46,7 @@ export function updateFile(data) { // 删除【请填写功能名称】 export function delFile(id) { return request({ - url: '/system/file/' + id, + url: '/videos/file/' + id, method: 'delete' }) } diff --git a/ruoyi-ui/src/api/system/videos.js b/ruoyi-ui/src/api/system/videos.js index 2bbfbf0..40d7eed 100644 --- a/ruoyi-ui/src/api/system/videos.js +++ b/ruoyi-ui/src/api/system/videos.js @@ -25,6 +25,14 @@ export function addVideos(data) { data: data }) } +// 给分享链接 +export function addShareFile(data) { + return request({ + url: '/system/videos/insertVideos', + method: 'post', + data: data + }) +} // 修改视频信息 export function updateVideos(data) { diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index 0ef9d70..4680a45 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -120,6 +120,34 @@ export const dynamicRoutes = [ } ] }, + { + path: '/system/manage', + component: Layout, + hidden: true, + permissions: ['system:videos:manage'], + children: [ + { + path: 'user/:videoId(\\d+)', + component: () => import('@/views/system/manage/files'), + name: 'AuthUser', + meta: { } + } + ] + }, + { + path: '/system/allow', + component: Layout, + hidden: true, + permissions: ['system:videos:manage'], + children: [ + { + path: 'user/:videoId(\\d+)', + component: () => import('@/views/system/allow/index'), + name: 'AuthUser', + meta: { } + } + ] + }, { path: '/system/dict-data', component: Layout, diff --git a/ruoyi-ui/src/views/system/allow/index.vue b/ruoyi-ui/src/views/system/allow/index.vue index 8de5e75..d3bba91 100644 --- a/ruoyi-ui/src/views/system/allow/index.vue +++ b/ruoyi-ui/src/views/system/allow/index.vue @@ -1,42 +1,11 @@ \ No newline at end of file + + + diff --git a/ruoyi-ui/src/views/system/videos/index.vue b/ruoyi-ui/src/views/system/videos/index.vue index 7696fc1..88e75c9 100644 --- a/ruoyi-ui/src/views/system/videos/index.vue +++ b/ruoyi-ui/src/views/system/videos/index.vue @@ -1,54 +1,15 @@