| @@ -17,12 +17,19 @@ public class TtVideoLibrary extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoId") | |||
| private String videoId; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoUrl") | |||
| private String videoUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="封面图",name="preview") | |||
| private String preview; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="时长",name="duration") | |||
| private Integer duration; | |||
| private String duration; | |||
| @io.swagger.annotations.ApiModelProperty(value="有效时间",name="exceedTime") | |||
| private Date exceedTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| @@ -11,4 +11,5 @@ public interface TtVideoLibraryMapper extends CommonMapper<TtVideoLibrary, Long> | |||
| int deleteById(Long id); | |||
| TtVideoLibrary getByVideoId(String videoId); | |||
| } | |||
| @@ -7,7 +7,7 @@ import org.springframework.scheduling.annotation.Async; | |||
| public interface WxCallBackService { | |||
| /** | |||
| * 积分同步 | |||
| * | |||
| * @param record | |||
| */ | |||
| @Async | |||
| @@ -0,0 +1,23 @@ | |||
| package com.iformall.service.tt; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| public interface TtVideoLibraryService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<TtVideoLibrary> listAsPage(TtVideoLibrary record, Integer pageIndex, Integer pageSize); | |||
| @Async | |||
| void saveOrUpdate(TtVideoLibrary video); | |||
| } | |||
| @@ -6,6 +6,8 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.enums.EnumTtCouponStatus; | |||
| import com.iformall.enums.EnumTtCouponType; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| @@ -62,7 +64,7 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| } | |||
| } | |||
| record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_DRAFT.getCode()); | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| @@ -74,7 +76,17 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| record.setUpdateDate(new Date()); | |||
| ttCouponMapper.updateById(record); | |||
| } | |||
| return new ResultData(record.getId()); | |||
| if(record.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode()) | |||
| && record.getColumnCoupons() != null && record.getColumnCoupons().size() > 0){ | |||
| for (TtCoupon ttc:record.getColumnCoupons()) { | |||
| ttc.updateTenantInfo(record); | |||
| ttc.setType(EnumTtCouponType.COUPON_MORE.getCode()); | |||
| ttc.setColumnId(record.getId()); | |||
| this.saveOrUpdate(ttc); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| @@ -0,0 +1,67 @@ | |||
| package com.iformall.service.tt.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import com.iformall.douyin.pay.DouYinPayHelper; | |||
| import com.iformall.douyin.pay.orderQuery.OrderQueryResult; | |||
| import com.iformall.douyin.pay.preOrder.CreatePreOrderResult; | |||
| import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.TtOrderMapper; | |||
| import com.iformall.mapper.TtVideoLibraryMapper; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import com.iformall.service.tt.TtVideoLibraryService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class TtVideoLibraryServiceImpl implements TtVideoLibraryService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private TtVideoLibraryMapper ttVideoLibraryMapper; | |||
| @Override | |||
| public PageInfo<TtVideoLibrary> listAsPage(TtVideoLibrary record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> ttVideoLibraryMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(TtVideoLibrary video) { | |||
| TtVideoLibrary videoLib = ttVideoLibraryMapper.getByVideoId(video.getVideoId()); | |||
| if(videoLib != null && videoLib.getIsDel().equals(EnumYesOrNo.YES.getCode())){ | |||
| videoLib.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| videoLib.setUpdateDate(new Date()); | |||
| ttVideoLibraryMapper.updateById(videoLib); | |||
| } | |||
| if(videoLib == null){ | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| video.setId(idWorker.nextId()); | |||
| video.setCreateDate(new Date()); | |||
| video.setUpdateDate(new Date()); | |||
| ttVideoLibraryMapper.insert(video); | |||
| } | |||
| } | |||
| } | |||
| @@ -39,85 +39,90 @@ | |||
| <result column="business_id" jdbcType="BIGINT" property="businessId"/> | |||
| <result column="business_name" jdbcType="VARCHAR" property="businessName"/> | |||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | |||
| <result column="merchant_pic" jdbcType="VARCHAR" property="merchantPic"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `tenant_id`, `parent_tenant_id`, `type`, `cover_img`, `cover_picture`, `detail_picture`, | |||
| `title`, `sub_title`, `video_id`, `video_time`, `html`, `is_landscape`, `is_payment`, | |||
| `sale_price`, `orig_price`, `is_preview`, `preview_duration`, `detail`, `false_sell_count`, | |||
| `dy_title`, `inventory`, `remark`, `status`, `create_date`, `update_date`, | |||
| `see_count`, `sell_count`, `assess_count`, `collect_count`, `is_del`, | |||
| `column_id`, `popularity`, `merchant_id`, `business_id`, `business_name` | |||
| c.`id`, c.`tenant_id`, c.`parent_tenant_id`, c.`type`, c.`cover_img`, c.`cover_picture`, c.`detail_picture`, | |||
| c.`title`, c.`sub_title`, c.`video_id`, c.`video_time`, c.`html`, c.`is_landscape`, c.`is_payment`, | |||
| c.`sale_price`, c.`orig_price`, c.`is_preview`, c.`preview_duration`, c.`detail`, c.`false_sell_count`, | |||
| c.`dy_title`, c.`inventory`, c.`remark`, c.`status`, c.`create_date`, c.`update_date`, | |||
| c.`see_count`, c.`sell_count`, c.`assess_count`, c.`collect_count`, c.`is_del`, | |||
| c.`column_id`, c.`popularity`, c.`merchant_id`, c.`business_id`, c.`business_name`, | |||
| m.name merchant_name, m.img_url merchant_pic | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where `is_del` = 0 | |||
| where c.`is_del` = 0 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| and c.`id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| and c.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| and c.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| and c.`type` = #{type} | |||
| </if> | |||
| <if test=" null != title and ''!=title"> | |||
| and `title` like concat('%', #{title},'%') | |||
| and c.`title` like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != isLandscape "> | |||
| and `is_landscape` = #{isLandscape} | |||
| and c.`is_landscape` = #{isLandscape} | |||
| </if> | |||
| <if test=" null != isPayment "> | |||
| and `is_payment` = #{isPayment} | |||
| and c.`is_payment` = #{isPayment} | |||
| </if> | |||
| <if test=" null != isPreview "> | |||
| and `is_preview` = #{isPreview} | |||
| and c.`is_preview` = #{isPreview} | |||
| </if> | |||
| <if test=" null != status"> | |||
| and `status` = #{status} | |||
| and c.`status` = #{status} | |||
| </if> | |||
| <if test="startdate != null"> | |||
| and `create_date` >= #{startdate} | |||
| and c.`create_date` >= #{startdate} | |||
| </if> | |||
| <if test="enddate != null"> | |||
| and `create_date` <= #{enddate} | |||
| and c.`create_date` <= #{enddate} | |||
| </if> | |||
| <if test=" null != businessId "> | |||
| and `business_id` = #{businessId} | |||
| and c.`business_id` = #{businessId} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and `merchant_id` = #{merchantId} | |||
| and c.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| and c.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| order by c.`update_date` desc | |||
| <!--<if test=" null != sortColumns">order by ${sortColumns}</if>--> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.tt.TtCoupon" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_coupon | |||
| from tt_coupon c | |||
| left join wx_merchant m on m.id = c.merchant_id | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| @@ -5,15 +5,18 @@ | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="video_id" jdbcType="VARCHAR" property="videoId"/> | |||
| <result column="video_url" jdbcType="VARCHAR" property="videoUrl"/> | |||
| <result column="preview" jdbcType="VARCHAR" property="preview"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="duration" jdbcType="INTEGER" property="duration"/> | |||
| <result column="duration" jdbcType="VARCHAR" property="duration"/> | |||
| <result column="exceed_time" jdbcType="TIMESTAMP" property="exceedTime"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `tenant_id`, `parent_tenant_id`, `preview`, `name`, `duration`, `create_date`, `update_date` | |||
| `id`, `tenant_id`, `parent_tenant_id`, `video_id`, `video_url`, `preview`, `name`, `duration`, `exceed_time`,`create_date`, `update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -30,6 +33,11 @@ | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != videoId and '' != videoId"> | |||
| and `video_id` = #{videoId} | |||
| </if> | |||
| <if test=" null != name and ''!=name"> | |||
| and `title` like concat('%', #{name},'%') | |||
| </if> | |||
| @@ -61,4 +69,13 @@ | |||
| update tt_video_library set is_del = 1,update_date=now() where id = #{id} | |||
| </delete> | |||
| <select id="getByVideoId" parameterType="String" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_video_library | |||
| where `video_id` = #{videoId} | |||
| </select> | |||
| </mapper> | |||
| @@ -1,24 +1,34 @@ | |||
| package com.iformall.controller.tt; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.service.WxFlowService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import com.iformall.service.tt.TtVideoLibraryService; | |||
| import com.iformall.utils.RedisLock; | |||
| import com.iformall.video.VideoFactory; | |||
| import com.iformall.video.entity.VideUploadResult; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("ttCoupon") | |||
| @Api(description = "") | |||
| @@ -29,9 +39,21 @@ public class TtCouponController extends BaseController { | |||
| @Autowired | |||
| private TtCouponService ttCouponService; | |||
| @Autowired | |||
| private TtVideoLibraryService ttVideoLibraryService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private WxFlowService wxFlowService; | |||
| @Autowired | |||
| VideoFactory videoFactory; | |||
| @Autowired | |||
| String videoType; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @@ -52,9 +74,47 @@ public class TtCouponController extends BaseController { | |||
| @SystemControllerLog(description = "-新增") | |||
| public ResultData add(@RequestBody TtCoupon record) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::add"); | |||
| if(record == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| record.updateTenantInfo(tenantEntity); | |||
| if(record.getMerchantId() == null){ | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| List<WxMerchant> list = wxMerchantService.findList(merchantQ); | |||
| if(list != null && list.size() > 0){ | |||
| record.setMerchantId(list.get(0).getId()); | |||
| } | |||
| } | |||
| if(record.getMerchantId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到作者"); | |||
| } | |||
| if(record.getBusinessId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未选择分类"); | |||
| } | |||
| if(StringUtils.isBlank(record.getVideoId())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未上传视频"); | |||
| }else{ | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(record.getVideoId()); | |||
| if(result.isSuccess()){ | |||
| record.setVideoTime(result.getDuration()); | |||
| TtVideoLibrary video = new TtVideoLibrary(); | |||
| video.updateTenantInfo(tenantEntity); | |||
| video.setVideoId(record.getVideoId()); | |||
| video.setVideoUrl(result.getVideoUrl()); | |||
| video.setPreview(result.getCoverURL()); | |||
| video.setDuration(result.getDuration()); | |||
| ttVideoLibraryService.saveOrUpdate(video); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||
| } | |||
| } | |||
| record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||
| ResultData resultData = ttCouponService.saveOrUpdate(record); | |||
| if (resultData.code != 200) { | |||
| return resultData; | |||
| @@ -67,6 +127,7 @@ public class TtCouponController extends BaseController { | |||
| //修改coupon applyStatus状态为审核中 | |||
| record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_EXAMINE.getCode()); | |||
| } | |||
| return resultData; | |||
| } | |||
| @@ -78,32 +139,66 @@ public class TtCouponController extends BaseController { | |||
| if (record.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| record.updateTenantInfo(tenantEntity); | |||
| if(EnumDelFlag.YES.getCode().equals(record.getIsDel())){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到课程,或课程已删除"); | |||
| } | |||
| TtCoupon coupon = ttCouponService.getById(record.getId()); | |||
| if (null == coupon || EnumDelFlag.YES.getCode().equals(record.getIsDel())) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到课程,或课程已删除"); | |||
| } | |||
| if(record.getMerchantId() == null){ | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| List<WxMerchant> list = wxMerchantService.findList(merchantQ); | |||
| if(list != null && list.size() > 0){ | |||
| record.setMerchantId(list.get(0).getId()); | |||
| } | |||
| } | |||
| if(record.getMerchantId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到作者"); | |||
| } | |||
| if(record.getBusinessId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未选择分类"); | |||
| } | |||
| if(!record.getMerchantId().equals(coupon.getMerchantId())){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"作者课程不匹配"); | |||
| } | |||
| if(StringUtils.isBlank(record.getVideoId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未上传视频"); | |||
| } | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(record.getVideoId()); | |||
| if(result.isSuccess()){ | |||
| record.setVideoTime(result.getDuration()); | |||
| TtVideoLibrary video = new TtVideoLibrary(); | |||
| video.updateTenantInfo(tenantEntity); | |||
| video.setVideoId(record.getVideoId()); | |||
| video.setVideoUrl(result.getVideoUrl()); | |||
| video.setPreview(result.getCoverURL()); | |||
| video.setDuration(result.getDuration()); | |||
| ttVideoLibraryService.saveOrUpdate(video); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||
| } | |||
| TtCoupon coupon = ttCouponService.getById(record.getId()); | |||
| if (null == coupon) { | |||
| return new ResultData(ResultData.ERROR, "未查询到数据。"+record.getId()); | |||
| } | |||
| //启动审批流 | |||
| // if (record.getFlowParams() != null && record.getFlowParams().size() > 0) { | |||
| // logger.info("------coupon.update().businessType:"+record.getFlowParams().get("businessType")); | |||
| // record.getFlowParams().put("businessId",record.getId()); | |||
| // wxFlowService.start(record.getFlowParams(), getUserId(), getUser().getName(), getTenantInfo()); | |||
| // //作废审批 | |||
| // if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(record.getStatus())) { | |||
| // record.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| // return new ResultData(record); | |||
| // } else { | |||
| // //投放审批 | |||
| // record.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| // } | |||
| // } | |||
| // record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||
| ResultData resultData = ttCouponService.saveOrUpdate(record); | |||
| if (resultData.code != 200) { | |||
| return resultData; | |||
| } | |||
| //启动投放审批 | |||
| if(record.getFlowParams() !=null && record.getFlowParams().size()>0) { | |||
| record.getFlowParams().put("businessId",record.getId()); | |||
| wxFlowService.start(record.getFlowParams(), getUserId(), getUser().getName(), tenantEntity); | |||
| //修改coupon applyStatus状态为审核中 | |||
| record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_EXAMINE.getCode()); | |||
| } | |||
| return ttCouponService.saveOrUpdate(record); | |||
| return resultData; | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @@ -94,4 +94,25 @@ public class VideoController extends BaseController { | |||
| } | |||
| } | |||
| /** | |||
| * 获取视频信息 | |||
| * | |||
| * @param | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @GetMapping(value = "/getVideoDetail") | |||
| @ApiOperation("上传视频进度") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData getVideoDetail(String videoId) { | |||
| try { | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(videoId); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -19,4 +19,6 @@ public interface VideoExcutor { | |||
| public VideUploadResult uploadNetVideo(String title,String url,String ext); | |||
| public String getVedioUploadProgress(String videoId); | |||
| VideUploadResult getVideoDetail(String videoId); | |||
| } | |||
| @@ -132,4 +132,33 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||
| public String getVedioUploadProgress(String videoId) { | |||
| return AliyunVedioUpload.getUploadProgress(redisTemplate, videoId); | |||
| } | |||
| @Override | |||
| public VideUploadResult getVideoDetail(String videoId) { | |||
| VideUploadResult result = new VideUploadResult(); | |||
| result.setVideoId(videoId); | |||
| try { | |||
| GetPlayInfoResponse response = AliyunVedioServer.getPlayInfoResponse(config, videoId); | |||
| if(response != null){ | |||
| List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList(); | |||
| //播放地址 | |||
| for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) { | |||
| result.setVideoUrl(playInfo.getPlayURL()); | |||
| break; | |||
| } | |||
| GetPlayInfoResponse.VideoBase videoBase = response.getVideoBase(); | |||
| result.setDuration(videoBase.getDuration()); | |||
| result.setCoverURL(videoBase.getCoverURL()); | |||
| result.setTitle(videoBase.getTitle()); | |||
| result.setSuccess(true); | |||
| }else{ | |||
| result.setSuccess(false); | |||
| result.setMsg("未获取到视频"); | |||
| } | |||
| } catch (ClientException e) { | |||
| result.setSuccess(false); | |||
| result.setMsg("获取视频请求异常"); | |||
| } | |||
| return result; | |||
| } | |||
| } | |||