shikeying
2022-10-28 e75364c0d66fff66432bce505c136d51034ba408
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
53
54
55
56
57
58
59
60
61
package com.iplatform.recvideo.api;
 
import com.iplatform.model.po.Rc_video_user;
import com.iplatform.recvideo.ResponseValue;
import com.iplatform.recvideo.service.VideoShowServiceImpl;
import com.walker.infrastructure.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
@RestController
@RequestMapping("/api/video")
public class ShowResultApi {
 
    private VideoShowServiceImpl videoShowService;
 
    @Autowired
    public ShowResultApi(VideoShowServiceImpl videoShowService){
        this.videoShowService = videoShowService;
    }
 
    @RequestMapping("/rec_list")
    @ResponseBody
    public ResponseValue showUserRecommendList(String userId){
        if(StringUtils.isEmpty(userId)){
            return ResponseValue.error("参数错误");
        }
        long userIdValue = Long.parseLong(userId);
        List<Rc_video_user> data = this.videoShowService.queryRecommendList(userIdValue, 128);
        ResponseValue<List<Rc_video_user>> responseValue = ResponseValue.success(data);
        return responseValue;
    }
 
    @RequestMapping("/rec_list_test")
    @ResponseBody
    public ResponseValue testUserRecommendList(String userId){
        if(StringUtils.isEmpty(userId)){
            return ResponseValue.error("参数错误");
        }
        long userIdValue = Long.parseLong(userId);
//        List<Rc_video_user> data = this.videoShowService.queryRecommendList(userIdValue, 128);
        List<Rc_video_user> data = new ArrayList<>();
        data.add(this.testAcquireVideoUser(userIdValue, "test"));
        ResponseValue<List<Rc_video_user>> responseValue = ResponseValue.success(data);
        return responseValue;
    }
 
    private Rc_video_user testAcquireVideoUser(long userId, String videoId){
        Rc_video_user user = new Rc_video_user();
        user.setUser_id(userId);
        user.setVideo_id(videoId);
        user.setCreate_time(20221011164126L);
        user.setScore(0.8);
        user.setId(System.nanoTime());
        return user;
    }
}