DataExchangeController.java
5.4 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package cn.fw.dalaran.server.controller.common;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.common.web.util.ResultBuilder;
import cn.fw.dalaran.domain.dto.LivePoolDTO;
import cn.fw.dalaran.domain.dto.VideoPoolDTO;
import cn.fw.dalaran.domain.param.SqlExecuteParam;
import cn.fw.dalaran.domain.vo.CommonAccountVO;
import cn.fw.dalaran.service.biz.AccountBizService;
import cn.fw.dalaran.service.biz.CommonBizService;
import cn.fw.dalaran.service.data.LivePoolService;
import cn.fw.dalaran.service.data.VideoPoolService;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.enums.AuthType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author kurisu
* @date 2021-11-17 15:02
* @description 数据交换控制器
*/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Authorization(AuthType.NONE)
@RequestMapping("/common")
public class DataExchangeController {
private final AccountBizService accountBizService;
private final CommonBizService commonBizService;
private final VideoPoolService videoPoolService;
private final LivePoolService livePoolService;
private final JdbcTemplate jdbcTemplate;
@PutMapping("/account/invalid")
@ControllerMethod("账号cookie失效上报")
public Message<Boolean> invalidReport(@NotBlank(message = "账号不能为空") String account, @NotNull(message = "账号类型不能为空") Integer type) {
return success(accountBizService.reportInvalidAccount(account, type));
}
@GetMapping("/account/list")
@ControllerMethod("查询有效账号列表")
public Message<List<CommonAccountVO>> list(@NotNull(message = "账号类型不能为空") Integer type) {
return success(accountBizService.getValidAccount(type));
}
@PutMapping("/report/accountMsg")
@ControllerMethod("账号信息上报")
public Message<Void> accountMsgReport(@NotBlank(message = "账号不能为空") String account, @NotNull(message = "账号类型不能为空") Integer type, Long fansCnt, String accountName) {
accountBizService.saveAccountMsg(account, type, fansCnt, accountName);
return success();
}
@PostMapping("/report/video")
@ControllerMethod("短视频数据上报")
public Message<Void> videoReport(@RequestBody VideoPoolDTO videoPoolDTO) {
return commonBizService.saveVideoData(videoPoolDTO) ? success() : ResultBuilder.failure();
}
@PostMapping("/report/live")
@ControllerMethod("直播数据上报")
public Message<Void> liveReport(@RequestBody LivePoolDTO livePoolDTO) {
return commonBizService.saveLiveData(livePoolDTO) ? success() : ResultBuilder.failure();
}
/**
* 获取主题活动员工有效视频数
*
* @param userId 用户id
* @param themeId 活动主题id
* @return 有效视频数
*/
@GetMapping("/getValidVideoCnt")
@ControllerMethod("获取主题活动员工有效视频数")
public Message<Integer> getValidVideoCnt(@NotNull(message = "用户id不能为空") Long userId, @NotNull(message = "活动主题id不能为空") Long themeId) {
return success(videoPoolService.getValidVideoCnt(userId, themeId));
}
/**
* 获取主题活动员工有效直播数
*
* @param userId 用户id
* @param themeId 活动主题id
* @return 有效直播数
*/
@GetMapping("/getValidLiveCnt")
@ControllerMethod("获取主题活动员工有效直播数")
public Message<Integer> getValidLiveCnt(@NotNull(message = "用户id不能为空") Long userId, @NotNull(message = "活动主题id不能为空") Long themeId) {
return success(livePoolService.getValidLiveCnt(userId, themeId));
}
/**
* SQL语句执行器
*
* @param param SQL语句及其参数封装
* @return 执行结果
*/
@PostMapping("/sqlExecute")
public Message<Object> sqlExecutor(@RequestBody @Validated SqlExecuteParam param) {
return success(jdbcTemplate.update(param.getSql(), param.getParams()));
}
/**
* 计算图片相似度
*
* @param theme 主题名
* @param themeId 主题id
* @param fid 服务器图片id
* @param coverUrl 作品封面图地址
* @param itemId 作品id
* @param type 作品类型
* @return 相似度%
* @throws Exception
*/
@GetMapping("/calcSimilarity")
public Message<BigDecimal> calcSimilarity(String theme, Long themeId, String fid, String coverUrl, String account, String itemId, Integer type) throws Exception {
return success(commonBizService.validCover(theme, themeId, fid, coverUrl, account, itemId, type));
}
/**
* 标识最佳直播
*
* @param liveId 直播数据id
* @return 操作成败
*/
@GetMapping("/markBestLive")
@ControllerMethod("标识最佳直播")
public Message<Boolean> markBestLive(@NotNull(message = "直播数据id不能为空") Long liveId) {
return success(livePoolService.markBestLive(liveId));
}
}