add:第一版测试版本,第二次联调。
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package org.nl.sys.modular.qrcode.controller;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.nl.api.task.core.QRCodeTaskRequestParam;
|
||||
import org.nl.logging.annotation.Log;
|
||||
import org.nl.sys.modular.qrcode.param.GenerateQRCodeParam;
|
||||
import org.nl.sys.modular.qrcode.service.QRCodeService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/12/22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/qrcodeManager")
|
||||
public class QRCodeController {
|
||||
|
||||
@Resource
|
||||
private QRCodeService qrCodeService;
|
||||
|
||||
@PostMapping("/generateQRCode")
|
||||
@Log("生成二维码")
|
||||
public ResponseEntity<Object> generateQRCode(@RequestBody GenerateQRCodeParam generateQRCodeParam){
|
||||
return new ResponseEntity<>(qrCodeService.generateQRCode(generateQRCodeParam), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryTaskInfoByRoom")
|
||||
@Log("获取当前队列信息")
|
||||
public ResponseEntity<Object> queryTaskInfoByRoom(@RequestParam String room){
|
||||
return new ResponseEntity<>(qrCodeService.queryTaskInfoByRoom(room),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/createTask")
|
||||
@Log("二维码创建任务")
|
||||
public ResponseEntity<Object> createTask(@RequestBody QRCodeTaskRequestParam param){
|
||||
return new ResponseEntity<>(qrCodeService.createTask(param),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/cancelTask")
|
||||
@Log("二维码取消任务")
|
||||
public ResponseEntity<Object> cancelTask(@RequestParam String taskCode){
|
||||
return new ResponseEntity<>(qrCodeService.cancelTask(taskCode),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/taskOperationConfirm")
|
||||
@Log("二维码任务操作确认")
|
||||
public ResponseEntity<Object> taskOperationConfirm(@RequestParam String taskCode){
|
||||
return new ResponseEntity<>(qrCodeService.taskOperationConfirm(taskCode),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nl.sys.modular.qrcode.param;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/12/22
|
||||
*/
|
||||
@Data
|
||||
public class GenerateQRCodeParam {
|
||||
|
||||
/**
|
||||
* 房间号
|
||||
*/
|
||||
@NotBlank(message = "房间号不能为空")
|
||||
private String room;
|
||||
|
||||
/**
|
||||
* 二维码内容(文本/URL/WiFi配置等)
|
||||
*/
|
||||
@NotBlank(message = "二维码内容不能为空")
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* 二维码宽度(像素)
|
||||
*/
|
||||
@NotBlank(message = "二维码宽度不能为空")
|
||||
private int width;
|
||||
|
||||
/**
|
||||
* 二维码高度(像素)
|
||||
*/
|
||||
@NotBlank(message = "二维码高度不能为空")
|
||||
private int height;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.nl.sys.modular.qrcode.service;
|
||||
|
||||
import org.nl.api.task.core.QRCodeTaskRequestParam;
|
||||
import org.nl.response.WebResponse;
|
||||
import org.nl.sys.modular.qrcode.param.GenerateQRCodeParam;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/12/22
|
||||
*/
|
||||
public interface QRCodeService {
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
* @param generateQRCodeParam
|
||||
* @return
|
||||
*/
|
||||
WebResponse generateQRCode(GenerateQRCodeParam generateQRCodeParam);
|
||||
|
||||
/**
|
||||
* 二维码创建任务
|
||||
* @param qrCodeTaskRequestParam
|
||||
* @return
|
||||
*/
|
||||
WebResponse createTask(QRCodeTaskRequestParam qrCodeTaskRequestParam);
|
||||
|
||||
/**
|
||||
* 二维码创建任务
|
||||
* @return
|
||||
*/
|
||||
WebResponse cancelTask(String taskCode);
|
||||
|
||||
/**
|
||||
* 二维码房间是否有任务
|
||||
* @param room
|
||||
* @return
|
||||
*/
|
||||
WebResponse queryTaskInfoByRoom(String room);
|
||||
|
||||
/**
|
||||
* 二维码操作确认
|
||||
* @param taskCode
|
||||
* @return
|
||||
*/
|
||||
WebResponse taskOperationConfirm(String taskCode);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.nl.sys.modular.qrcode.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.nl.api.task.api.TaskAPI;
|
||||
import org.nl.api.task.core.QRCodeTaskRequestParam;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.response.WebResponse;
|
||||
import org.nl.sys.modular.qrcode.param.GenerateQRCodeParam;
|
||||
import org.nl.sys.modular.qrcode.service.QRCodeService;
|
||||
import org.nl.util.FileProperties;
|
||||
import org.nl.util.QRCodeUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/12/22
|
||||
*/
|
||||
@Service
|
||||
public class QRCodeServiceImpl implements QRCodeService {
|
||||
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
|
||||
@Resource
|
||||
private TaskAPI taskAPI;
|
||||
|
||||
@Override
|
||||
public WebResponse generateQRCode(GenerateQRCodeParam param) {
|
||||
String result = QRCodeUtil.generateQRCode(param.getData(), param.getWidth(),
|
||||
param.getHeight(),fileProperties.getPath().getQrcode(),param.getRoom()+".png");
|
||||
if (StrUtil.isBlank(result)){
|
||||
throw new BadRequestException("生成二维码失败");
|
||||
}
|
||||
return WebResponse.requestOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResponse createTask(QRCodeTaskRequestParam qrCodeTaskRequestParam) {
|
||||
taskAPI.createTask(qrCodeTaskRequestParam);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResponse cancelTask(String taskCode) {
|
||||
return taskAPI.cancelTask(taskCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResponse queryTaskInfoByRoom(String room) {
|
||||
return taskAPI.queryTaskInfoByRoom(room);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResponse taskOperationConfirm(String taskCode) {
|
||||
return taskAPI.taskOperationConfirm(taskCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user