打印机接口
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.print.PrinterAddDTO;
|
||||
import com.czg.account.dto.print.PrinterDelDTO;
|
||||
import com.czg.account.dto.print.PrinterEditDTO;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
import com.czg.account.service.PrintMachineService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 打印机管理
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/printer")
|
||||
public class PrintMachineController {
|
||||
@Resource
|
||||
private PrintMachineService printMachineService;
|
||||
|
||||
|
||||
/**
|
||||
* 打印机列表
|
||||
* @param name 名称
|
||||
* @param connectionType 类型 USB 网络 蓝牙
|
||||
* @return 打印机列表
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "printer:list", name = "打印机列表获取")
|
||||
@GetMapping
|
||||
public CzgResult<Page<PrintMachine>> list(String name, String connectionType) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper().eq(PrintMachine::getShopId, StpKit.USER.getShopId());
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
queryWrapper.like(PrintMachine::getName, name);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(connectionType)) {
|
||||
queryWrapper.eq(PrintMachine::getConnectionType, connectionType);
|
||||
}
|
||||
queryWrapper.orderBy(PrintMachine::getSort, true).orderBy(PrintMachine::getId, false);
|
||||
return CzgResult.success(printMachineService.page(PageUtil.buildPage(), queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机详情
|
||||
* @param id 打印机id
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "printer:detail", name = "打印机详情获取")
|
||||
@GetMapping("/detail")
|
||||
public CzgResult<PrintMachine> detail(@RequestParam Integer id) {
|
||||
return CzgResult.success(printMachineService.getOne(new QueryWrapper().eq(PrintMachine::getId, id).eq(PrintMachine::getShopId, StpKit.USER.getShopId())));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打印机新增
|
||||
* @return 打印机列表
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "printer:add", name = "打印机新增")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> list(@RequestBody @Validated PrinterAddDTO printerAddDTO) {
|
||||
return CzgResult.success(printMachineService.add(StpKit.USER.getShopId(), printerAddDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机修改
|
||||
* @return 打印机列表
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "printer:edit", name = "打印机编辑")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated PrinterEditDTO printerEditDTO) {
|
||||
return CzgResult.success(printMachineService.edit(StpKit.USER.getShopId(), printerEditDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机删除
|
||||
* @return 打印机列表
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "printer:del", name = "打印机删除")
|
||||
@DeleteMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated PrinterDelDTO printerDelDTO) {
|
||||
return CzgResult.success(printMachineService.remove(new QueryWrapper().eq(PrintMachine::getShopId, StpKit.USER.getShopId()).eq(PrintMachine::getId, printerDelDTO.getId())));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user