PC打印机列表

This commit is contained in:
2024-04-03 11:39:57 +08:00
parent a2bd783a21
commit 3f95f15775
2 changed files with 28 additions and 15 deletions

View File

@@ -34,7 +34,7 @@ public class TbPrintPCMachineController {
*/
@GetMapping
public Result queryByPage(TbPrintPCMachine tbPrintMachine) {
return this.tbPrintPCMachineService.queryByPage(tbPrintMachine);
return tbPrintPCMachineService.queryByPage(tbPrintMachine);
}
/**

View File

@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
/**
@@ -41,15 +42,15 @@ public class TbPrintPCMachineService {
public Result queryById(Integer id) {
TbPrintPCMachine tbPrintMachine = tbPrintMachineMapper.queryById(id);
if(tbPrintMachine==null){
if (tbPrintMachine == null) {
return Result.fail("数据不存在");
}
PrintMachineDto tbPrintMachineVO=new PrintMachineDto();
if (StringUtils.isNotBlank(tbPrintMachine.getConfig())){
PrintMachineDto tbPrintMachineVO = new PrintMachineDto();
if (StringUtils.isNotBlank(tbPrintMachine.getConfig())) {
tbPrintMachineVO.setConfig(JSON.parseObject(tbPrintMachine.getConfig(), PrintConfig.class));
}
BeanUtils.copyProperties(tbPrintMachine,tbPrintMachineVO);
return Result.success(CodeEnum.SUCCESS,tbPrintMachineVO);
BeanUtils.copyProperties(tbPrintMachine, tbPrintMachineVO);
return Result.success(CodeEnum.SUCCESS, tbPrintMachineVO);
}
/**
@@ -62,8 +63,20 @@ public class TbPrintPCMachineService {
PageHelper.startPage(tbPrintMachine.getPage(), tbPrintMachine.getPageSize());
tbPrintMachine.setContentType("local");
List<TbPrintPCMachine> tbPrintMachines = this.tbPrintMachineMapper.queryAll(tbPrintMachine);
PageInfo pageInfo=new PageInfo(tbPrintMachines);
return Result.success(CodeEnum.SUCCESS,pageInfo);
List<PrintMachineDto> printMachineList = new ArrayList<>();
for (TbPrintPCMachine printMachine : tbPrintMachines) {
PrintMachineDto tbPrintMachineVO = new PrintMachineDto();
if (StringUtils.isNotBlank(printMachine.getConfig())) {
tbPrintMachineVO.setConfig(JSON.parseObject(printMachine.getConfig(), PrintConfig.class));
}
BeanUtils.copyProperties(printMachine, tbPrintMachineVO);
printMachineList.add(tbPrintMachineVO);
}
PageInfo pageInfo = new PageInfo(tbPrintMachines);
pageInfo.setList(printMachineList);
return Result.success(CodeEnum.SUCCESS, pageInfo);
}
/**
@@ -76,13 +89,13 @@ public class TbPrintPCMachineService {
TbPrintPCMachine tbPrintMachine = new TbPrintPCMachine();
tbPrintMachine.setCreatedAt(Instant.now().toEpochMilli());
tbPrintMachine.setContentType("local");
if (resources.getConfig() != null){
if(CollectionUtils.isEmpty(resources.getConfig().getCategoryList())){
if (resources.getConfig() != null) {
if (CollectionUtils.isEmpty(resources.getConfig().getCategoryList())) {
resources.getConfig().setCategoryList(null);
}
tbPrintMachine.setConfig(JSONUtil.toJSONString(resources.getConfig(),true));
tbPrintMachine.setConfig(JSONUtil.toJSONString(resources.getConfig(), true));
}
BeanUtils.copyProperties(resources,tbPrintMachine);
BeanUtils.copyProperties(resources, tbPrintMachine);
tbPrintMachineMapper.insert(tbPrintMachine);
return Result.success(CodeEnum.SUCCESS);
}
@@ -96,10 +109,10 @@ public class TbPrintPCMachineService {
public Result update(PrintMachineDto resources) {
TbPrintPCMachine tbPrintMachine = new TbPrintPCMachine();
tbPrintMachine.setUpdatedAt(Instant.now().toEpochMilli());
if (resources.getConfig() != null){
tbPrintMachine.setConfig(JSONUtil.toJSONString(resources.getConfig(),true));
if (resources.getConfig() != null) {
tbPrintMachine.setConfig(JSONUtil.toJSONString(resources.getConfig(), true));
}
BeanUtils.copyProperties(resources,tbPrintMachine);
BeanUtils.copyProperties(resources, tbPrintMachine);
tbPrintMachineMapper.update(tbPrintMachine);
return Result.success(CodeEnum.SUCCESS);
}