视频功能
This commit is contained in:
		| @@ -0,0 +1,103 @@ | ||||
| package com.stdiet.web.controller.custom; | ||||
|  | ||||
| import java.util.List; | ||||
| 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 com.stdiet.common.annotation.Log; | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.common.enums.BusinessType; | ||||
| import com.stdiet.custom.domain.SysNutritionalVideo; | ||||
| import com.stdiet.custom.service.ISysNutritionalVideoService; | ||||
| import com.stdiet.common.utils.poi.ExcelUtil; | ||||
| import com.stdiet.common.core.page.TableDataInfo; | ||||
|  | ||||
| /** | ||||
|  * 营养视频Controller | ||||
|  * | ||||
|  * @author xzj | ||||
|  * @date 2021-04-29 | ||||
|  */ | ||||
| @RestController | ||||
| @RequestMapping("/custom/nutritionalVideo") | ||||
| public class SysNutritionalVideoController extends BaseController | ||||
| { | ||||
|     @Autowired | ||||
|     private ISysNutritionalVideoService sysNutritionalVideoService; | ||||
|  | ||||
|     /** | ||||
|      * 查询营养视频列表 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:list')") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo list(SysNutritionalVideo sysNutritionalVideo) | ||||
|     { | ||||
|         startPage(); | ||||
|         List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo); | ||||
|         return getDataTable(list); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 导出营养视频列表 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:export')") | ||||
|     @Log(title = "营养视频", businessType = BusinessType.EXPORT) | ||||
|     @GetMapping("/export") | ||||
|     public AjaxResult export(SysNutritionalVideo sysNutritionalVideo) | ||||
|     { | ||||
|         List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo); | ||||
|         ExcelUtil<SysNutritionalVideo> util = new ExcelUtil<SysNutritionalVideo>(SysNutritionalVideo.class); | ||||
|         return util.exportExcel(list, "nutritionalVideo"); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取营养视频详细信息 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:query')") | ||||
|     @GetMapping(value = "/{id}") | ||||
|     public AjaxResult getInfo(@PathVariable("id") Long id) | ||||
|     { | ||||
|         return AjaxResult.success(sysNutritionalVideoService.selectSysNutritionalVideoById(id)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增营养视频 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:add')") | ||||
|     @Log(title = "营养视频", businessType = BusinessType.INSERT) | ||||
|     @PostMapping | ||||
|     public AjaxResult add(@RequestBody SysNutritionalVideo sysNutritionalVideo) | ||||
|     { | ||||
|         return toAjax(sysNutritionalVideoService.insertSysNutritionalVideo(sysNutritionalVideo)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改营养视频 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:edit')") | ||||
|     @Log(title = "营养视频", businessType = BusinessType.UPDATE) | ||||
|     @PutMapping | ||||
|     public AjaxResult edit(@RequestBody SysNutritionalVideo sysNutritionalVideo) | ||||
|     { | ||||
|         return toAjax(sysNutritionalVideoService.updateSysNutritionalVideo(sysNutritionalVideo)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 删除营养视频 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:remove')") | ||||
|     @Log(title = "营养视频", businessType = BusinessType.DELETE) | ||||
|     @DeleteMapping("/{ids}") | ||||
|     public AjaxResult remove(@PathVariable Long[] ids) | ||||
|     { | ||||
|         return toAjax(sysNutritionalVideoService.deleteSysNutritionalVideoByIds(ids)); | ||||
|     } | ||||
| } | ||||
| @@ -64,6 +64,9 @@ public class WechatAppletController extends BaseController { | ||||
|     @Autowired | ||||
|     private ISysCustomerService sysCustomerService; | ||||
|  | ||||
|     @Autowired | ||||
|     private ISysNutritionalVideoService sysNutritionalVideoService; | ||||
|  | ||||
|     /** | ||||
|      * 查询微信小程序中展示的客户案例 | ||||
|      */ | ||||
| @@ -363,12 +366,13 @@ public class WechatAppletController extends BaseController { | ||||
|      * 更新用户通知消息已读状态 | ||||
|      */ | ||||
|     @GetMapping(value = "/getVideoList") | ||||
|     public AjaxResult getVideoList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,  @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) { | ||||
|     public TableDataInfo getVideoList(SysNutritionalVideo sysNutritionalVideo) { | ||||
|         AjaxResult result = AjaxResult.success(); | ||||
|         int total = 0; | ||||
|         List<NutritionalVideoResponse> nutritionalVideoList = new ArrayList<>(); | ||||
|         startPage(); | ||||
|         //int total = 0; | ||||
|         //List<NutritionalVideoResponse> nutritionalVideoList = new ArrayList<>(); | ||||
|         try{ | ||||
|             GetVideoListResponseBody videoListResponseBody = AliyunVideoUtils.getVideoListByPage(null, "Normal", pageNum, pageSize); | ||||
|             /**GetVideoListResponseBody videoListResponseBody = AliyunVideoUtils.getVideoListByPage(null, "Normal", 1, 10); | ||||
|             if(videoListResponseBody != null){ | ||||
|                 total = videoListResponseBody.total; | ||||
|                 for (GetVideoListResponseBody.GetVideoListResponseBodyVideoListVideo video : videoListResponseBody.videoList.video) { | ||||
| @@ -379,14 +383,20 @@ public class WechatAppletController extends BaseController { | ||||
|                     nutritionalVideoResponse.setDescription(video.getDescription()); | ||||
|                     nutritionalVideoResponse.setTags(video.getTags()); | ||||
|                     nutritionalVideoList.add(nutritionalVideoResponse); | ||||
|                     System.out.println(video.getVideoId()); | ||||
|                     System.out.println(video.getCoverURL()); | ||||
|                     System.out.println(video.getTitle()); | ||||
|                     System.out.println(video.getDescription()); | ||||
|                 } | ||||
|             } | ||||
|             System.out.println();**/ | ||||
|             sysNutritionalVideo.setShowFlag(1); | ||||
|             List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo); | ||||
|             return getDataTable(list); | ||||
|         }catch (Exception e){ | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|         result.put("total", total); | ||||
|         result.put("nutritionalVideoList", nutritionalVideoList); | ||||
|         return result; | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @@ -398,17 +408,18 @@ public class WechatAppletController extends BaseController { | ||||
|         AjaxResult result = AjaxResult.success(); | ||||
|         NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); | ||||
|         try{ | ||||
|             GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId); | ||||
|             GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId); | ||||
|             List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo; | ||||
|             if(playList != null && playList.size() > 0){ | ||||
|                 nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); | ||||
|             } | ||||
|             if(videoInfoResponseBody != null){ | ||||
|                 nutritionalVideoResponse.setDescription(videoInfoResponseBody.video.description); | ||||
|                 nutritionalVideoResponse.setTags(videoInfoResponseBody.video.tags); | ||||
|                 nutritionalVideoResponse.setTitle(videoInfoResponseBody.video.title); | ||||
|                 nutritionalVideoResponse.setCreateTime(videoInfoResponseBody.video.creationTime); | ||||
|             SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId); | ||||
|             if(sysNutritionalVideo != null){ | ||||
|                 GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId); | ||||
|                 //GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId); | ||||
|                 List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo; | ||||
|                 if(playList != null && playList.size() > 0){ | ||||
|                     nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); | ||||
|                 } | ||||
|                 nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription()); | ||||
|                 nutritionalVideoResponse.setTags(sysNutritionalVideo.getTags()); | ||||
|                 nutritionalVideoResponse.setTitle(sysNutritionalVideo.getTitle()); | ||||
|                 nutritionalVideoResponse.setCreateTime(DateUtils.dateTime(sysNutritionalVideo.getCreateTime())); | ||||
|             } | ||||
|         }catch (Exception e){ | ||||
|             e.printStackTrace(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user