admin
2022-04-16 04f09e52ffd4681bdfd85e51acd3da0d1280c3d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.yeshi.buwan.controller.admin.api;
 
import java.io.PrintWriter;
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoResource;
import com.yeshi.buwan.service.imp.VideoInfoService;
import com.yeshi.buwan.service.imp.VideoResourceService;
import com.yeshi.buwan.util.JsonUtil;
import com.yeshi.buwan.util.XingePushUtil;
 
@Controller
@RequestMapping("admin/new/api/push")
public class PushAdminCotroller {
    
    @Autowired
    private VideoInfoService viderInfoService;
    
    @Autowired
    private VideoResourceService videoResourceService;
    
    @RequestMapping(value = "pushVideo", method = RequestMethod.POST)
    public void pushVideo(String title,String content,String vid,PrintWriter out){
         VideoInfo vi = viderInfoService.getVideoInfo(vid);
         if(vi == null){
             String json = JsonUtil.loadFalseAdmin("不存在该视频");
             out.print(json);
             return;
         }
         List<VideoResource> resources = videoResourceService.getResourceByVideo(vi);
         vi.setResourceList(resources);
         int i = XingePushUtil.pushVideo(title, content, vi);
         String json;
         if(i==0){
              json = JsonUtil.loadTrueAdmin("推送失败");
         }else if(i==1){
             json = JsonUtil.loadTrueAdmin("IOS推送成功");
         }else if(i==2){
             json = JsonUtil.loadTrueAdmin("Andriod推送成功");
         }else{
             json = JsonUtil.loadTrueAdmin("推送成功");
         }
         out.print(json);
    }
    
}