|
|
|
|
@@ -6,6 +6,7 @@ import com.gameplatform.server.model.dto.link.GameInterfaceResponse;
|
|
|
|
|
import com.gameplatform.server.model.entity.agent.LinkBatch;
|
|
|
|
|
import com.gameplatform.server.model.entity.agent.LinkTask;
|
|
|
|
|
import com.gameplatform.server.service.external.ScriptClient;
|
|
|
|
|
import com.gameplatform.server.service.link.LinkStatusService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
@@ -32,24 +33,34 @@ public class QrProxyController {
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(QrProxyController.class);
|
|
|
|
|
|
|
|
|
|
private final ScriptClient scriptClient;
|
|
|
|
|
private final LinkStatusService linkStatusService;
|
|
|
|
|
private final String appBaseUrl;
|
|
|
|
|
private final LinkTaskMapper linkTaskMapper;
|
|
|
|
|
private final LinkBatchMapper linkBatchMapper;
|
|
|
|
|
|
|
|
|
|
public QrProxyController(ScriptClient scriptClient,
|
|
|
|
|
LinkStatusService linkStatusService,
|
|
|
|
|
@Value("${app.base-url}") String appBaseUrl,
|
|
|
|
|
LinkTaskMapper linkTaskMapper,
|
|
|
|
|
LinkBatchMapper linkBatchMapper) {
|
|
|
|
|
this.scriptClient = scriptClient;
|
|
|
|
|
this.linkStatusService = linkStatusService;
|
|
|
|
|
this.appBaseUrl = appBaseUrl;
|
|
|
|
|
this.linkTaskMapper = linkTaskMapper;
|
|
|
|
|
this.linkBatchMapper = linkBatchMapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/{codeNo}/qr.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@GetMapping(value = "/image/{codeNo}/qr.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@Operation(summary = "二维码图片代理")
|
|
|
|
|
public Mono<ResponseEntity<byte[]>> qr(@PathVariable("codeNo") String codeNo) {
|
|
|
|
|
String path = "/" + codeNo + "/二维码.png";
|
|
|
|
|
// 通过codeNo查询machineId
|
|
|
|
|
String machineId = linkStatusService.getMechainIdByCode(codeNo);
|
|
|
|
|
if (machineId == null) {
|
|
|
|
|
log.warn("无法找到codeNo对应的machineId: {}", codeNo);
|
|
|
|
|
return Mono.just(ResponseEntity.notFound().build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String path = "/" + machineId + "/二维码.png";
|
|
|
|
|
return scriptClient.getQrPng(path)
|
|
|
|
|
.map(bytes -> ResponseEntity.ok()
|
|
|
|
|
.contentType(MediaType.IMAGE_PNG)
|
|
|
|
|
@@ -58,10 +69,17 @@ public class QrProxyController {
|
|
|
|
|
.body(bytes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/{codeNo}/homepage.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@GetMapping(value = "/image/{codeNo}/homepage.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@Operation(summary = "首次主页图片代理")
|
|
|
|
|
public Mono<ResponseEntity<byte[]>> homepage(@PathVariable("codeNo") String codeNo) {
|
|
|
|
|
String path = "/" + codeNo + "/首次主页.png";
|
|
|
|
|
// 通过codeNo查询machineId
|
|
|
|
|
String machineId = linkStatusService.getMechainIdByCode(codeNo);
|
|
|
|
|
if (machineId == null) {
|
|
|
|
|
log.warn("无法找到codeNo对应的machineId: {}", codeNo);
|
|
|
|
|
return Mono.just(ResponseEntity.notFound().build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String path = "/" + machineId + "/首次主页.png";
|
|
|
|
|
return scriptClient.getImagePng(path)
|
|
|
|
|
.map(bytes -> ResponseEntity.ok()
|
|
|
|
|
.contentType(MediaType.IMAGE_PNG)
|
|
|
|
|
@@ -70,10 +88,17 @@ public class QrProxyController {
|
|
|
|
|
.body(bytes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/{codeNo}/first-reward.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@GetMapping(value = "/image/{codeNo}/first-reward.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@Operation(summary = "首次赏金图片代理")
|
|
|
|
|
public Mono<ResponseEntity<byte[]>> firstReward(@PathVariable("codeNo") String codeNo) {
|
|
|
|
|
String path = "/" + codeNo + "/首次赏金.png";
|
|
|
|
|
// 通过codeNo查询machineId
|
|
|
|
|
String machineId = linkStatusService.getMechainIdByCode(codeNo);
|
|
|
|
|
if (machineId == null) {
|
|
|
|
|
log.warn("无法找到codeNo对应的machineId: {}", codeNo);
|
|
|
|
|
return Mono.just(ResponseEntity.notFound().build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String path = "/" + machineId + "/首次赏金.png";
|
|
|
|
|
return scriptClient.getImagePng(path)
|
|
|
|
|
.map(bytes -> ResponseEntity.ok()
|
|
|
|
|
.contentType(MediaType.IMAGE_PNG)
|
|
|
|
|
@@ -82,10 +107,17 @@ public class QrProxyController {
|
|
|
|
|
.body(bytes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/{codeNo}/mid-reward.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@GetMapping(value = "/image/{codeNo}/mid-reward.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@Operation(summary = "中途赏金图片代理")
|
|
|
|
|
public Mono<ResponseEntity<byte[]>> midReward(@PathVariable("codeNo") String codeNo) {
|
|
|
|
|
String path = "/" + codeNo + "/中途赏金.png";
|
|
|
|
|
// 通过codeNo查询machineId
|
|
|
|
|
String machineId = linkStatusService.getMechainIdByCode(codeNo);
|
|
|
|
|
if (machineId == null) {
|
|
|
|
|
log.warn("无法找到codeNo对应的machineId: {}", codeNo);
|
|
|
|
|
return Mono.just(ResponseEntity.notFound().build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String path = "/" + machineId + "/中途赏金.png";
|
|
|
|
|
return scriptClient.getImagePng(path)
|
|
|
|
|
.map(bytes -> ResponseEntity.ok()
|
|
|
|
|
.contentType(MediaType.IMAGE_PNG)
|
|
|
|
|
@@ -94,10 +126,17 @@ public class QrProxyController {
|
|
|
|
|
.body(bytes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/{codeNo}/end-reward.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@GetMapping(value = "/image/{codeNo}/end-reward.png", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
@Operation(summary = "结束赏金图片代理")
|
|
|
|
|
public Mono<ResponseEntity<byte[]>> endReward(@PathVariable("codeNo") String codeNo) {
|
|
|
|
|
String path = "/" + codeNo + "/结束赏金.png";
|
|
|
|
|
// 通过codeNo查询machineId
|
|
|
|
|
String machineId = linkStatusService.getMechainIdByCode(codeNo);
|
|
|
|
|
if (machineId == null) {
|
|
|
|
|
log.warn("无法找到codeNo对应的machineId: {}", codeNo);
|
|
|
|
|
return Mono.just(ResponseEntity.notFound().build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String path = "/" + machineId + "/结束赏金.png";
|
|
|
|
|
return scriptClient.getImagePng(path)
|
|
|
|
|
.map(bytes -> ResponseEntity.ok()
|
|
|
|
|
.contentType(MediaType.IMAGE_PNG)
|
|
|
|
|
@@ -112,13 +151,13 @@ public class QrProxyController {
|
|
|
|
|
Map<String, String> imageLinks = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 添加二维码链接
|
|
|
|
|
imageLinks.put("qrCode", appBaseUrl + "/api/link/" + codeNo + "/qr.png");
|
|
|
|
|
imageLinks.put("qrCode", appBaseUrl + "/api/link/image/" + codeNo + "/qr.png");
|
|
|
|
|
|
|
|
|
|
// 添加其他图片链接
|
|
|
|
|
imageLinks.put("homepage", appBaseUrl + "/api/link/" + codeNo + "/homepage.png");
|
|
|
|
|
imageLinks.put("firstReward", appBaseUrl + "/api/link/" + codeNo + "/first-reward.png");
|
|
|
|
|
imageLinks.put("midReward", appBaseUrl + "/api/link/" + codeNo + "/mid-reward.png");
|
|
|
|
|
imageLinks.put("endReward", appBaseUrl + "/api/link/" + codeNo + "/end-reward.png");
|
|
|
|
|
imageLinks.put("homepage", appBaseUrl + "/api/link/image/" + codeNo + "/homepage.png");
|
|
|
|
|
imageLinks.put("firstReward", appBaseUrl + "/api/link/image/" + codeNo + "/first-reward.png");
|
|
|
|
|
imageLinks.put("midReward", appBaseUrl + "/api/link/image/" + codeNo + "/mid-reward.png");
|
|
|
|
|
imageLinks.put("endReward", appBaseUrl + "/api/link/image/" + codeNo + "/end-reward.png");
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok()
|
|
|
|
|
.cacheControl(CacheControl.maxAge(5, TimeUnit.MINUTES).cachePublic())
|
|
|
|
|
@@ -148,20 +187,22 @@ public class QrProxyController {
|
|
|
|
|
// 构建响应对象
|
|
|
|
|
GameInterfaceResponse response = new GameInterfaceResponse();
|
|
|
|
|
response.setCodeNo(codeNo);
|
|
|
|
|
response.setMachineId(linkTask.getMachineId());
|
|
|
|
|
response.setQuantity(linkBatch.getQuantity());
|
|
|
|
|
response.setTimes(linkBatch.getTimes());
|
|
|
|
|
response.setTotalPoints(linkBatch.getQuantity() * linkBatch.getTimes());
|
|
|
|
|
response.setCompletedPoints(linkTask.getCompletedPoints());
|
|
|
|
|
|
|
|
|
|
// 设置游戏区域信息
|
|
|
|
|
response.setRegion(linkTask.getRegion());
|
|
|
|
|
response.setRegionDesc(getRegionDescription(linkTask.getRegion()));
|
|
|
|
|
|
|
|
|
|
// 设置图片链接
|
|
|
|
|
response.setQrCodeUrl(appBaseUrl + "/api/link/" + codeNo + "/qr.png");
|
|
|
|
|
response.setHomepageUrl(appBaseUrl + "/api/link/" + codeNo + "/homepage.png");
|
|
|
|
|
response.setFirstRewardUrl(appBaseUrl + "/api/link/" + codeNo + "/first-reward.png");
|
|
|
|
|
response.setMidRewardUrl(appBaseUrl + "/api/link/" + codeNo + "/mid-reward.png");
|
|
|
|
|
response.setEndRewardUrl(appBaseUrl + "/api/link/" + codeNo + "/end-reward.png");
|
|
|
|
|
response.setQrCodeUrl(appBaseUrl + "/api/link/image/" + codeNo + "/qr.png");
|
|
|
|
|
response.setHomepageUrl(appBaseUrl + "/api/link/image/" + codeNo + "/homepage.png");
|
|
|
|
|
response.setFirstRewardUrl(appBaseUrl + "/api/link/image/" + codeNo + "/first-reward.png");
|
|
|
|
|
response.setMidRewardUrl(appBaseUrl + "/api/link/image/" + codeNo + "/mid-reward.png");
|
|
|
|
|
response.setEndRewardUrl(appBaseUrl + "/api/link/image/" + codeNo + "/end-reward.png");
|
|
|
|
|
|
|
|
|
|
log.info("游戏界面数据构建完成: codeNo={}, totalPoints={}", codeNo, response.getTotalPoints());
|
|
|
|
|
|
|
|
|
|
|