PC端添加本地打印机
This commit is contained in:
@@ -0,0 +1,85 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbPrintPCMachine;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.PrintMachineDto;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbPrintPCMachineService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PC端添加打印机
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2024-04-01 10:52:52
|
||||||
|
*/
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("tbPrintMachine")
|
||||||
|
public class TbPrintPCMachineController {
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private TbPrintPCMachineService tbPrintPCMachineService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 筛选条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
@GetMapping
|
||||||
|
public Result queryByPage(TbPrintPCMachine tbPrintMachine) {
|
||||||
|
return this.tbPrintPCMachineService.queryByPage(tbPrintMachine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 单条数据
|
||||||
|
*/
|
||||||
|
@GetMapping("{id}")
|
||||||
|
public Result queryById(@PathVariable("id") Integer id) {
|
||||||
|
return tbPrintPCMachineService.queryById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 实体
|
||||||
|
* @return 新增结果
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody PrintMachineDto tbPrintMachine) {
|
||||||
|
return tbPrintPCMachineService.insert(tbPrintMachine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑数据
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 实体
|
||||||
|
* @return 编辑结果
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody PrintMachineDto tbPrintMachine) {
|
||||||
|
return tbPrintPCMachineService.update(tbPrintMachine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 删除是否成功
|
||||||
|
*/
|
||||||
|
@DeleteMapping
|
||||||
|
public Result deleteById(Integer id) {
|
||||||
|
return tbPrintPCMachineService.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.dao;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbPrintPCMachine;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Mapper
|
||||||
|
public interface TbPrintPCMachineMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
TbPrintPCMachine queryById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 查询条件
|
||||||
|
* @return 对象列表
|
||||||
|
*/
|
||||||
|
List<TbPrintPCMachine> queryAll(TbPrintPCMachine tbPrintMachine);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 实例对象
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int insert(TbPrintPCMachine tbPrintMachine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增数据(MyBatis原生foreach方法)
|
||||||
|
*
|
||||||
|
* @param entities List<TbPrintMachine> 实例对象列表
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int insertBatch(@Param("entities") List<TbPrintPCMachine> entities);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 实例对象
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int update(TbPrintPCMachine tbPrintMachine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int deleteById(Integer id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机设备(TbPrintMachine)实体类
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2024-04-01 10:52:53
|
||||||
|
*/
|
||||||
|
public class TbPrintPCMachine implements Serializable {
|
||||||
|
private static final long serialVersionUID = -45444134635096942L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* printer
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* 现在打印机支持USB 和 网络、蓝牙
|
||||||
|
*/
|
||||||
|
private String connectionType;
|
||||||
|
/**
|
||||||
|
* ip地址
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
/**
|
||||||
|
* 端口
|
||||||
|
*/
|
||||||
|
private String port;
|
||||||
|
/**
|
||||||
|
* 打印类型(分类)label标签cash小票kitchen出品
|
||||||
|
*/
|
||||||
|
private String subType;
|
||||||
|
/**
|
||||||
|
* 状态 online
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 店铺Id
|
||||||
|
*/
|
||||||
|
private String shopId;
|
||||||
|
/**
|
||||||
|
* 分类Id
|
||||||
|
*/
|
||||||
|
private String categoryIds;
|
||||||
|
/**
|
||||||
|
* 现在打印机支持USB 和 网络两种
|
||||||
|
*/
|
||||||
|
private String contentType;
|
||||||
|
/**
|
||||||
|
* 主配置
|
||||||
|
*/
|
||||||
|
private String config;
|
||||||
|
|
||||||
|
private Long createdAt;
|
||||||
|
|
||||||
|
private Long updatedAt;
|
||||||
|
/**
|
||||||
|
* 分类
|
||||||
|
*/
|
||||||
|
private String categoryList;
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
/**
|
||||||
|
* Android打印机需要标识设备ID
|
||||||
|
*/
|
||||||
|
private String vendorId;
|
||||||
|
/**
|
||||||
|
* Android打印机需要标识设备ID
|
||||||
|
*/
|
||||||
|
private String productId;
|
||||||
|
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getPageSize() {
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(Integer pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(Integer page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConnectionType() {
|
||||||
|
return connectionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectionType(String connectionType) {
|
||||||
|
this.connectionType = connectionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(String port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubType() {
|
||||||
|
return subType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubType(String subType) {
|
||||||
|
this.subType = subType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShopId() {
|
||||||
|
return shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopId(String shopId) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryIds() {
|
||||||
|
return categoryIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryIds(String categoryIds) {
|
||||||
|
this.categoryIds = categoryIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContentType() {
|
||||||
|
return contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentType(String contentType) {
|
||||||
|
this.contentType = contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfig(String config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Long createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Long updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryList() {
|
||||||
|
return categoryList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryList(String categoryList) {
|
||||||
|
this.categoryList = categoryList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(Integer sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVendorId() {
|
||||||
|
return vendorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVendorId(String vendorId) {
|
||||||
|
this.vendorId = vendorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(String productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopCategory;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 12847
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PrintConfig {
|
||||||
|
@NotNull(message = "设备尺寸不能为空")
|
||||||
|
private String width;
|
||||||
|
@NotNull(message = "打印份数不能为空")
|
||||||
|
private String printerNum;
|
||||||
|
|
||||||
|
private List<TbShopCategory> categoryList;
|
||||||
|
|
||||||
|
private String model;
|
||||||
|
@NotNull(message = "尾部留空需设置")
|
||||||
|
private String feet;
|
||||||
|
@NotNull(message = "自动切刀0开启1关闭")
|
||||||
|
private String autoCut;
|
||||||
|
private String deviceName;//选择设备
|
||||||
|
//打印子订单 0开启1关闭
|
||||||
|
private String printSub;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PrintMachineDto {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 设备名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** printer */
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** 现在打印机支持USB 和 网络、蓝牙 */
|
||||||
|
private String connectionType;
|
||||||
|
|
||||||
|
/** ip地址 */
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/** 端口 */
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
/** 打印类型(分类) */
|
||||||
|
private String subType;
|
||||||
|
|
||||||
|
/** 状态 online */
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/** 店铺Id */
|
||||||
|
@NotNull(message = "店铺ID不能为空")
|
||||||
|
private String shopId;
|
||||||
|
|
||||||
|
/** 现在打印机支持USB 和 网络两种 */
|
||||||
|
private String contentType;
|
||||||
|
|
||||||
|
/** 主配置 */
|
||||||
|
private PrintConfig config;
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.chaozhanggui.system.cashierservice.dao.TbPrintPCMachineMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbPrintPCMachine;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.PrintConfig;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.PrintMachineDto;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机设备(TbPrintMachine)表服务接口
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2024-04-01 10:52:53
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class TbPrintPCMachineService {
|
||||||
|
@Autowired
|
||||||
|
private TbPrintPCMachineMapper tbPrintMachineMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Result queryById(Integer id) {
|
||||||
|
TbPrintPCMachine tbPrintMachine = tbPrintMachineMapper.queryById(id);
|
||||||
|
if(tbPrintMachine==null){
|
||||||
|
return Result.fail("数据不存在");
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param tbPrintMachine 筛选条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
public Result queryByPage(TbPrintPCMachine tbPrintMachine) {
|
||||||
|
PageHelper.startPage(tbPrintMachine.getPage(), tbPrintMachine.getPageSize());
|
||||||
|
List<TbPrintPCMachine> tbPrintMachines = this.tbPrintMachineMapper.queryAll(tbPrintMachine);
|
||||||
|
PageInfo pageInfo=new PageInfo(tbPrintMachines);
|
||||||
|
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param resources 实例对象
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
public Result insert(PrintMachineDto resources) {
|
||||||
|
TbPrintPCMachine tbPrintMachine = new TbPrintPCMachine();
|
||||||
|
tbPrintMachine.setCreatedAt(Instant.now().toEpochMilli());
|
||||||
|
if (resources.getConfig() != null){
|
||||||
|
tbPrintMachine.setConfig(JSONUtil.toJSONString(resources.getConfig(),true));
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(resources,tbPrintMachine);
|
||||||
|
tbPrintMachineMapper.insert(tbPrintMachine);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*
|
||||||
|
* @param resources 实例对象
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(resources,tbPrintMachine);
|
||||||
|
tbPrintMachineMapper.update(tbPrintMachine);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public Result deleteById(Integer id) {
|
||||||
|
tbPrintMachineMapper.deleteById(id);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -69,6 +69,17 @@ public class JSONUtil {
|
|||||||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", false, true, false);
|
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将对象转为JSON字符串。
|
||||||
|
* 日期转为特别的格式,不忽略null值的字段,不格式化JSON字符串
|
||||||
|
*
|
||||||
|
* @param obj 被转换的对象
|
||||||
|
* @return JSON字符串,发送异常时抛出
|
||||||
|
*/
|
||||||
|
public static String toJSONString(Object obj,boolean ignoreNull) {
|
||||||
|
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", ignoreNull, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将对象转为JSON字符串。不抛出异常,专用于日志打印
|
* 将对象转为JSON字符串。不抛出异常,专用于日志打印
|
||||||
*
|
*
|
||||||
|
|||||||
193
src/main/resources/mapper/TbPrintPCMachineMapper.xml
Normal file
193
src/main/resources/mapper/TbPrintPCMachineMapper.xml
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbPrintPCMachineMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbPrintPCMachine" id="TbPrintMachineMap">
|
||||||
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="type" column="type" jdbcType="VARCHAR"/>
|
||||||
|
<result property="connectionType" column="connection_type" jdbcType="VARCHAR"/>
|
||||||
|
<result property="address" column="address" jdbcType="VARCHAR"/>
|
||||||
|
<result property="port" column="port" jdbcType="VARCHAR"/>
|
||||||
|
<result property="subType" column="sub_type" jdbcType="VARCHAR"/>
|
||||||
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||||
|
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
|
||||||
|
<result property="categoryIds" column="category_ids" jdbcType="VARCHAR"/>
|
||||||
|
<result property="contentType" column="content_type" jdbcType="VARCHAR"/>
|
||||||
|
<result property="config" column="config" jdbcType="VARCHAR"/>
|
||||||
|
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
|
||||||
|
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
|
||||||
|
<result property="categoryList" column="category_list" jdbcType="VARCHAR"/>
|
||||||
|
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||||
|
<result property="vendorId" column="vendor_id" jdbcType="VARCHAR"/>
|
||||||
|
<result property="productId" column="product_id" jdbcType="VARCHAR"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id
|
||||||
|
, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, content_type, config, created_at, updated_at, category_list, sort, vendor_id, product_id </sql>
|
||||||
|
|
||||||
|
<!--查询单个-->
|
||||||
|
<select id="queryById" resultMap="TbPrintMachineMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
|
||||||
|
from tb_print_machine
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--查询指定行数据-->
|
||||||
|
<select id="queryAll" resultMap="TbPrintMachineMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
|
||||||
|
from tb_print_machine
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
and name = #{name}
|
||||||
|
</if>
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
and type = #{type}
|
||||||
|
</if>
|
||||||
|
<if test="connectionType != null and connectionType != ''">
|
||||||
|
and connection_type = #{connectionType}
|
||||||
|
</if>
|
||||||
|
<if test="address != null and address != ''">
|
||||||
|
and address = #{address}
|
||||||
|
</if>
|
||||||
|
<if test="port != null and port != ''">
|
||||||
|
and port = #{port}
|
||||||
|
</if>
|
||||||
|
<if test="subType != null and subType != ''">
|
||||||
|
and sub_type = #{subType}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
|
<if test="categoryIds != null and categoryIds != ''">
|
||||||
|
and category_ids = #{categoryIds}
|
||||||
|
</if>
|
||||||
|
<if test="contentType != null and contentType != ''">
|
||||||
|
and content_type = #{contentType}
|
||||||
|
</if>
|
||||||
|
<if test="config != null and config != ''">
|
||||||
|
and config = #{config}
|
||||||
|
</if>
|
||||||
|
<if test="createdAt != null">
|
||||||
|
and created_at = #{createdAt}
|
||||||
|
</if>
|
||||||
|
<if test="updatedAt != null">
|
||||||
|
and updated_at = #{updatedAt}
|
||||||
|
</if>
|
||||||
|
<if test="categoryList != null and categoryList != ''">
|
||||||
|
and category_list = #{categoryList}
|
||||||
|
</if>
|
||||||
|
<if test="sort != null">
|
||||||
|
and sort = #{sort}
|
||||||
|
</if>
|
||||||
|
<if test="vendorId != null and vendorId != ''">
|
||||||
|
and vendor_id = #{vendorId}
|
||||||
|
</if>
|
||||||
|
<if test="productId != null and productId != ''">
|
||||||
|
and product_id = #{productId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by created_at desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!--新增所有列-->
|
||||||
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into tb_print_machine(name, type, connection_type, address, port, sub_type, status, shop_id,
|
||||||
|
category_ids, content_type, config, created_at, updated_at, category_list, sort,
|
||||||
|
vendor_id, product_id)
|
||||||
|
values (#{name}, #{type}, #{connectionType}, #{address}, #{port}, #{subType}, #{status}, #{shopId},
|
||||||
|
#{categoryIds}, #{contentType}, #{config}, #{createdAt}, #{updatedAt}, #{categoryList}, #{sort},
|
||||||
|
#{vendorId}, #{productId})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into tb_print_machine(name, type, connection_type, address, port, sub_type, status, shop_id,
|
||||||
|
category_ids, content_type, config, created_at, updated_at, category_list, sort, vendor_id, product_id)
|
||||||
|
values
|
||||||
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
|
(#{entity.name}, #{entity.type}, #{entity.connectionType}, #{entity.address}, #{entity.port},
|
||||||
|
#{entity.subType}, #{entity.status}, #{entity.shopId}, #{entity.categoryIds}, #{entity.contentType},
|
||||||
|
#{entity.config}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.categoryList}, #{entity.sort},
|
||||||
|
#{entity.vendorId}, #{entity.productId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!--通过主键修改数据-->
|
||||||
|
<update id="update">
|
||||||
|
update tb_print_machine
|
||||||
|
<set>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
type = #{type},
|
||||||
|
</if>
|
||||||
|
<if test="connectionType != null and connectionType != ''">
|
||||||
|
connection_type = #{connectionType},
|
||||||
|
</if>
|
||||||
|
<if test="address != null and address != ''">
|
||||||
|
address = #{address},
|
||||||
|
</if>
|
||||||
|
<if test="port != null and port != ''">
|
||||||
|
port = #{port},
|
||||||
|
</if>
|
||||||
|
<if test="subType != null and subType != ''">
|
||||||
|
sub_type = #{subType},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status = #{status},
|
||||||
|
</if>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
shop_id = #{shopId},
|
||||||
|
</if>
|
||||||
|
<if test="categoryIds != null and categoryIds != ''">
|
||||||
|
category_ids = #{categoryIds},
|
||||||
|
</if>
|
||||||
|
<if test="contentType != null and contentType != ''">
|
||||||
|
content_type = #{contentType},
|
||||||
|
</if>
|
||||||
|
<if test="config != null and config != ''">
|
||||||
|
config = #{config},
|
||||||
|
</if>
|
||||||
|
<if test="createdAt != null">
|
||||||
|
created_at = #{createdAt},
|
||||||
|
</if>
|
||||||
|
<if test="updatedAt != null">
|
||||||
|
updated_at = #{updatedAt},
|
||||||
|
</if>
|
||||||
|
<if test="categoryList != null and categoryList != ''">
|
||||||
|
category_list = #{categoryList},
|
||||||
|
</if>
|
||||||
|
<if test="sort != null">
|
||||||
|
sort = #{sort},
|
||||||
|
</if>
|
||||||
|
<if test="vendorId != null and vendorId != ''">
|
||||||
|
vendor_id = #{vendorId},
|
||||||
|
</if>
|
||||||
|
<if test="productId != null and productId != ''">
|
||||||
|
product_id = #{productId},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!--通过主键删除-->
|
||||||
|
<delete id="deleteById">
|
||||||
|
delete
|
||||||
|
from tb_print_machine
|
||||||
|
where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user