Merge branch 'gyj' into test

This commit is contained in:
2024-09-19 15:33:53 +08:00
3 changed files with 51 additions and 4 deletions

View File

@@ -0,0 +1,40 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbVersion;
import com.chaozhanggui.system.cashierservice.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author yijiegong
*/
@RestController
@RequestMapping("/version")
public class VersionController {
@Autowired
LoginService loginService;
@GetMapping("pcDownload")
public ResponseEntity<Void> pcDownload(HttpServletRequest request, HttpServletResponse response) {
TbVersion pcVersion = loginService.getCurrentPcVersion();
if (pcVersion == null) {
throw new RuntimeException("未找到PC版本信息");
}
// 重定向到下载地址
HttpHeaders headers = new HttpHeaders();
headers.setLocation(java.net.URI.create(pcVersion.getUrl()));
return new ResponseEntity<>(headers, HttpStatus.FOUND);
}
}