You've already forked FrameTour-BE
feat(printer): 添加打印机管理相关接口
- 新增 detail 接口用于根据 accessKey 获取打印机详情 - 新增 scenic 接口用于获取打印机关联的景区基础信息 - 新增 open 接口用于打开打印机(设置状态为1) - 新增 close 接口用于关闭打印机(设置状态为0) - 实现了 getByAccessKey、getScenicBasicByAccessKey、openPrinter 和 closePrinter 服务方法 - 添加了 PrinterEntity 的导入和相关异常处理逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.ycwl.basic.controller.printer;
|
package com.ycwl.basic.controller.printer;
|
||||||
|
|
||||||
import com.ycwl.basic.annotation.IgnoreToken;
|
import com.ycwl.basic.annotation.IgnoreToken;
|
||||||
|
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
|
||||||
import com.ycwl.basic.model.printer.req.PrinterSyncReq;
|
import com.ycwl.basic.model.printer.req.PrinterSyncReq;
|
||||||
import com.ycwl.basic.model.printer.req.WorkerAuthReqVo;
|
import com.ycwl.basic.model.printer.req.WorkerAuthReqVo;
|
||||||
import com.ycwl.basic.model.printer.resp.PrintTaskResp;
|
import com.ycwl.basic.model.printer.resp.PrintTaskResp;
|
||||||
@@ -40,4 +41,26 @@ public class PrinterTaskController {
|
|||||||
printerService.taskFail(taskId, req);
|
printerService.taskFail(taskId, req);
|
||||||
return ApiResponse.success("OK");
|
return ApiResponse.success("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/detail")
|
||||||
|
public ApiResponse<PrinterEntity> detail(@RequestBody WorkerAuthReqVo req) {
|
||||||
|
return ApiResponse.success(printerService.getByAccessKey(req.getAccessKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/scenic")
|
||||||
|
public ApiResponse scenic(@RequestBody WorkerAuthReqVo req) {
|
||||||
|
return ApiResponse.success(printerService.getScenicBasicByAccessKey(req.getAccessKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/open")
|
||||||
|
public ApiResponse open(@RequestBody WorkerAuthReqVo req) {
|
||||||
|
printerService.openPrinter(req.getAccessKey());
|
||||||
|
return ApiResponse.success("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/close")
|
||||||
|
public ApiResponse close(@RequestBody WorkerAuthReqVo req) {
|
||||||
|
printerService.closePrinter(req.getAccessKey());
|
||||||
|
return ApiResponse.success("OK");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -143,4 +143,30 @@ public interface PrinterService {
|
|||||||
* @return 订单信息
|
* @return 订单信息
|
||||||
*/
|
*/
|
||||||
Map<String, Object> createVirtualOrder(Long sourceId, Long scenicId, Integer printerId, Boolean needEnhance, String printImgUrl);
|
Map<String, Object> createVirtualOrder(Long sourceId, Long scenicId, Integer printerId, Boolean needEnhance, String printImgUrl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据accessKey获取打印机详情
|
||||||
|
* @param accessKey 打印机accessKey
|
||||||
|
* @return 打印机实体
|
||||||
|
*/
|
||||||
|
PrinterEntity getByAccessKey(String accessKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据accessKey获取打印机对应的景区基础信息
|
||||||
|
* @param accessKey 打印机accessKey
|
||||||
|
* @return 景区基础信息
|
||||||
|
*/
|
||||||
|
Object getScenicBasicByAccessKey(String accessKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开打印机(设置status=1)
|
||||||
|
* @param accessKey 打印机accessKey
|
||||||
|
*/
|
||||||
|
void openPrinter(String accessKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭打印机(设置status=0)
|
||||||
|
* @param accessKey 打印机accessKey
|
||||||
|
*/
|
||||||
|
void closePrinter(String accessKey);
|
||||||
}
|
}
|
||||||
@@ -1808,5 +1808,40 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrinterEntity getByAccessKey(String accessKey) {
|
||||||
|
if (accessKey == null) {
|
||||||
|
throw new BaseException("accessKey不能为空");
|
||||||
|
}
|
||||||
|
PrinterEntity printer = printerMapper.findByAccessKey(accessKey);
|
||||||
|
if (printer == null) {
|
||||||
|
throw new BaseException("打印机不存在");
|
||||||
|
}
|
||||||
|
return printer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getScenicBasicByAccessKey(String accessKey) {
|
||||||
|
PrinterEntity printer = getByAccessKey(accessKey);
|
||||||
|
if (printer.getScenicId() == null) {
|
||||||
|
throw new BaseException("打印机未关联景区");
|
||||||
|
}
|
||||||
|
return scenicRepository.getScenicBasic(printer.getScenicId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openPrinter(String accessKey) {
|
||||||
|
PrinterEntity printer = getByAccessKey(accessKey);
|
||||||
|
printer.setStatus(1);
|
||||||
|
printerMapper.update(printer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closePrinter(String accessKey) {
|
||||||
|
PrinterEntity printer = getByAccessKey(accessKey);
|
||||||
|
printer.setStatus(0);
|
||||||
|
printerMapper.update(printer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user