| @@ -1,18 +1,25 @@ | ||||
| package com.stdiet.web.controller.custom; | ||||
|  | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.common.utils.DateUtils; | ||||
| import com.stdiet.common.utils.StringUtils; | ||||
| import com.stdiet.common.utils.sign.AesUtils; | ||||
| import com.stdiet.custom.domain.SysOrderPause; | ||||
| import com.stdiet.custom.domain.SysWxAdLog; | ||||
| import com.stdiet.custom.service.*; | ||||
| import com.stdiet.custom.utils.CookieUtils; | ||||
| import com.stdiet.custom.utils.HttpRequestUtils; | ||||
| import com.stdiet.system.service.ISysDictTypeService; | ||||
| import org.apache.commons.lang3.RandomStringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.servlet.http.Cookie; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.Date; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| @@ -38,6 +45,7 @@ public class SysWapController extends BaseController { | ||||
|     @Autowired | ||||
|     ISysSmsConfirmServie iSysSmsConfirmServie; | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 客户食谱详情 | ||||
|      * | ||||
| @@ -140,6 +148,29 @@ public class SysWapController extends BaseController { | ||||
|         return toAjax(iSysWxSaleAccountService.logWxAd(sysWxAdLog)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping(value = "/getCookie") | ||||
|     public AjaxResult getCookie(@RequestParam String phone, HttpServletResponse response) { | ||||
|         String tokenStr = phone + "_" + new Date().getTime() + "_" + RandomStringUtils.random(8); | ||||
|         Cookie cookie = new Cookie("token", AesUtils.encrypt(tokenStr)); | ||||
|         cookie.setMaxAge(24 * 60 * 60); | ||||
|         cookie.setSecure(true); | ||||
|         cookie.setHttpOnly(true); | ||||
|         cookie.setPath("/"); | ||||
|         response.addCookie(cookie); | ||||
|  | ||||
|         return AjaxResult.success(); | ||||
|     } | ||||
|  | ||||
|     @GetMapping(value = "/checkCookie") | ||||
|     public AjaxResult checkCookie(HttpServletRequest request) { | ||||
|         JSONObject resultObj = CookieUtils.checkCookieValida(request, "token"); | ||||
|         if (resultObj.getInteger("code") == 200) { | ||||
|             return AjaxResult.success(resultObj.getString("msg")); | ||||
|         } else { | ||||
|             return AjaxResult.error(resultObj.getInteger("code"), resultObj.getString("msg")); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @GetMapping(value = "/getCode") | ||||
|     public AjaxResult getCode(@RequestParam String phone) { | ||||
|  | ||||
| @@ -159,13 +190,23 @@ public class SysWapController extends BaseController { | ||||
|     } | ||||
|  | ||||
|     @GetMapping(value = "/checkCode") | ||||
|     public AjaxResult checkCode(@RequestParam String phone, @RequestParam String code) { | ||||
|     public AjaxResult checkCode(@RequestParam String phone, @RequestParam String code, HttpServletResponse response) { | ||||
|  | ||||
|         if (StringUtils.isEmpty(code)) { | ||||
|             return AjaxResult.error(50002, "验证码不能为空"); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         int checkCode = iSysSmsConfirmServie.checkSmsCode(phone, code); | ||||
|         if (checkCode == 0) { | ||||
|             return AjaxResult.success(); | ||||
|             String tokenStr = phone + "_" + new Date().getTime() + "_" + RandomStringUtils.randomAlphanumeric(8); | ||||
|             Cookie cookie = new Cookie("token", AesUtils.encrypt(tokenStr)); | ||||
|             cookie.setMaxAge(24 * 60 * 60); | ||||
|             cookie.setSecure(true); | ||||
|             cookie.setHttpOnly(true); | ||||
|             cookie.setPath("/"); | ||||
|             response.addCookie(cookie); | ||||
|             return new AjaxResult(20000, "登录成功"); | ||||
|         } else if (checkCode == 1) { | ||||
|             return AjaxResult.error(50003, "验证码失效"); | ||||
|         } else if (checkCode == 2) { | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| package com.stdiet.web.controller.custom; | ||||
|  | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.aliyun.vod20170321.models.GetPlayInfoResponseBody; | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| @@ -8,14 +9,18 @@ import com.stdiet.common.utils.AliyunVideoUtils; | ||||
| import com.stdiet.common.utils.StringUtils; | ||||
| import com.stdiet.common.utils.oss.AliyunOSSUtils; | ||||
| import com.stdiet.custom.domain.SysNutritionalVideo; | ||||
| import com.stdiet.custom.domain.SysOrder; | ||||
| import com.stdiet.custom.domain.SysVideoClassify; | ||||
| import com.stdiet.custom.dto.response.NutritionalVideoResponse; | ||||
| import com.stdiet.custom.dto.response.VideoClassifyResponse; | ||||
| import com.stdiet.custom.service.ISysNutritionalVideoService; | ||||
| import com.stdiet.custom.service.ISysOrderService; | ||||
| import com.stdiet.custom.service.ISysVideoClassifyService; | ||||
| import com.stdiet.custom.utils.CookieUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import java.util.List; | ||||
|  | ||||
|  | ||||
| @@ -29,18 +34,34 @@ public class VideoWebInterfaceController extends BaseController { | ||||
|     @Autowired | ||||
|     private ISysNutritionalVideoService sysNutritionalVideoService; | ||||
|  | ||||
|     @Autowired | ||||
|     private ISysOrderService iSysOrderService; | ||||
|  | ||||
|     /** | ||||
|      * 查询视频分类目录列表 | ||||
|      */ | ||||
|     @GetMapping("/getAllClassify") | ||||
|     public TableDataInfo getClassifyAndVideo(SysVideoClassify sysVideoClassify) | ||||
|     { | ||||
|     public TableDataInfo getClassifyAndVideo(SysVideoClassify sysVideoClassify, HttpServletRequest request) { | ||||
|  | ||||
|         JSONObject result = CookieUtils.checkCookieValida(request, "token"); | ||||
|         if (result.getInteger("code") != 200) { | ||||
|             TableDataInfo errInfo = new TableDataInfo(); | ||||
|             errInfo.setCode(result.getInteger("code")); | ||||
|             errInfo.setMsg(result.getString("msg")); | ||||
|             return errInfo; | ||||
|         } | ||||
|  | ||||
|         // 检查是否已消费 | ||||
|         SysOrder order = new SysOrder(); | ||||
|         order.setPhone(result.getString("phone")); | ||||
|         List<SysOrder> orders = iSysOrderService.selectSysOrderList(order); | ||||
|  | ||||
|         //不分页则不需要传pageNum、pageSize参数 | ||||
|         startPage(); | ||||
|         //父级分类ID 0表示主分类 | ||||
|         sysVideoClassify.setParentId(0L); | ||||
|         //客户类型 0 未付费客户  1已付费客户 | ||||
|         sysVideoClassify.setUserType(1); | ||||
|         sysVideoClassify.setParentId(sysVideoClassify.getParentId() == null ? 0L : sysVideoClassify.getParentId()); | ||||
|         //客户类型 0未付费客户-playLevel根据上传的标记  1已付费客户-playLevel全为0 | ||||
|         sysVideoClassify.setUserType(orders.size() > 0 ? 1 : 0); | ||||
|         List<VideoClassifyResponse> list = sysVideoClassifyService.getAllClassifyAndVideo(sysVideoClassify); | ||||
|         return getDataTable(list); | ||||
|     } | ||||
| @@ -48,17 +69,22 @@ public class VideoWebInterfaceController extends BaseController { | ||||
|  | ||||
|     /** | ||||
|      * 根据视频videoId获取视频详情以及播放地址 | ||||
|      * | ||||
|      * @param videoId 阿里云中对应videoId | ||||
|      * @return | ||||
|      */ | ||||
|     @GetMapping("/getVideoDetail/{videoId}") | ||||
|     public AjaxResult getVideoDetail(@PathVariable("videoId") String videoId) | ||||
|     { | ||||
|         if(StringUtils.isEmpty(videoId)){ | ||||
|     public AjaxResult getVideoDetail(@PathVariable("videoId") String videoId, HttpServletRequest request) { | ||||
|         JSONObject result = CookieUtils.checkCookieValida(request, "token"); | ||||
|         if (result.getInteger("code") != 200) { | ||||
|             return AjaxResult.error(result.getInteger("code"), result.getString("msg")); | ||||
|         } | ||||
|  | ||||
|         if (StringUtils.isEmpty(videoId)) { | ||||
|             return AjaxResult.error("视频加载失败"); | ||||
|         } | ||||
|         SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId); | ||||
|         if(sysNutritionalVideo == null){ | ||||
|         if (sysNutritionalVideo == null) { | ||||
|             return AjaxResult.error("视频加载失败"); | ||||
|         } | ||||
|         NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); | ||||
| @@ -69,7 +95,7 @@ public class VideoWebInterfaceController extends BaseController { | ||||
|                 //播放地址 | ||||
|                 nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); | ||||
|             } | ||||
|         }catch (Exception e){ | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
|             return AjaxResult.error("视频加载失败"); | ||||
|         } | ||||
| @@ -91,12 +117,13 @@ public class VideoWebInterfaceController extends BaseController { | ||||
|  | ||||
|     /** | ||||
|      * 更新视频播放次数 | ||||
|      * | ||||
|      * @param videoId 阿里云中对应videoId | ||||
|      * @return | ||||
|      */ | ||||
|     @GetMapping(value = "/updateVideoPlayNum") | ||||
|     public AjaxResult updateVideoPlayNum(@RequestParam(value = "videoId") String videoId) { | ||||
|         if(StringUtils.isEmpty(videoId)){ | ||||
|         if (StringUtils.isEmpty(videoId)) { | ||||
|             return AjaxResult.error("更新失败"); | ||||
|         } | ||||
|         return toAjax(sysNutritionalVideoService.updateVideoPlayNum(videoId)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user