店铺管理-店铺配置:打印机设置相关接口
This commit is contained in:
parent
c3597cd28e
commit
80edd84c4f
|
|
@ -0,0 +1,79 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.ShopPrinterDTO;
|
||||
import cn.ysk.cashier.service.shop.ShopPrinterService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 16:56
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "店铺配置-打印机设置")
|
||||
@RequestMapping("/api/shop-config/printer")
|
||||
public class ShopPrinterController {
|
||||
|
||||
private final ShopPrinterService shopPrinterService;
|
||||
|
||||
@GetMapping("page")
|
||||
@ApiOperation("分页")
|
||||
public ResponseEntity page(@RequestParam Map<String, Object> params) {
|
||||
Map<String, Object> page = shopPrinterService.page(params);
|
||||
return ResponseEntity.ok().body(page);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@ApiOperation("列表")
|
||||
public ResponseEntity list(@RequestParam Map<String, Object> params) {
|
||||
List<ShopPrinterDTO> list = shopPrinterService.list(params);
|
||||
return ResponseEntity.ok().body(list);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("详情")
|
||||
public ResponseEntity get(@PathVariable("id") Integer id) {
|
||||
ShopPrinterDTO data = shopPrinterService.get(id);
|
||||
return ResponseEntity.ok().body(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("保存")
|
||||
public ResponseEntity save(@RequestBody ShopPrinterDTO dto) {
|
||||
shopPrinterService.save(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改")
|
||||
public ResponseEntity update(@RequestBody ShopPrinterDTO dto) {
|
||||
shopPrinterService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@ApiOperation("删除")
|
||||
public ResponseEntity delete(@PathVariable("id") Integer id) {
|
||||
shopPrinterService.delete(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("update-status")
|
||||
@ApiOperation("停用或启用")
|
||||
public ResponseEntity updateStatus(@RequestBody ShopPrinterDTO dto) {
|
||||
shopPrinterService.updateStatus(dto.getId(), dto.getStatus());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 17:13
|
||||
*/
|
||||
@Data
|
||||
public class ShopPrinterDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String connectionType;
|
||||
|
||||
private String address;
|
||||
|
||||
private String port;
|
||||
|
||||
private String subType;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String shopId;
|
||||
|
||||
private String categoryIds;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private String createdAt;
|
||||
|
||||
private String updatedAt;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private String vendorId;
|
||||
|
||||
private String productId;
|
||||
private String config;
|
||||
|
||||
public String getCreatedAt() {
|
||||
if("".equals(createdAt) || createdAt == null){
|
||||
return "";
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(Long.valueOf(createdAt)));
|
||||
}
|
||||
|
||||
public String getUpdatedAt() {
|
||||
if("".equals(updatedAt) || updatedAt == null){
|
||||
return "";
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(Long.valueOf(updatedAt)));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
* @author tankaikai
|
||||
* @since 2024-09-25 11:47
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbPrintMachineMapper extends BaseMapper<TbPrintMachineEntity> {
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package cn.ysk.cashier.pojo.shop;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-25 11:49
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_print_machine")
|
||||
public class TbPrintMachineEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
private String connectionType;
|
||||
private String address;
|
||||
private String port;
|
||||
private String subType;
|
||||
private Integer status;
|
||||
private String shopId;
|
||||
private String categoryIds;
|
||||
private String contentType;
|
||||
private String config;
|
||||
private Long createdAt;
|
||||
private Long updatedAt;
|
||||
private String categoryList;
|
||||
private Integer sort;
|
||||
private String vendorId;
|
||||
private String productId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.map.MapProxy;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.shop.ShopPrinterDTO;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbPrintMachineMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineEntity;
|
||||
import cn.ysk.cashier.service.shop.ShopPrinterService;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置ServiceImpl
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-25 13:53
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ShopPrinterServiceImpl extends ServiceImpl<TbPrintMachineMapper, TbPrintMachineEntity> implements ShopPrinterService {
|
||||
|
||||
private QueryWrapper<TbPrintMachineEntity> getWrapper(Map<String, Object> params) {
|
||||
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
QueryWrapper<TbPrintMachineEntity> wrapper = new QueryWrapper<>();
|
||||
|
||||
String shopId = mapProxy.getStr("shopId");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(shopId), TbPrintMachineEntity::getShopId, shopId);
|
||||
String name = mapProxy.getStr("name");
|
||||
wrapper.lambda().likeRight(StrUtil.isNotEmpty(name), TbPrintMachineEntity::getName, name);
|
||||
String type = mapProxy.getStr("type");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(type), TbPrintMachineEntity::getType, type);
|
||||
String connectionType = mapProxy.getStr("connectionType");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(connectionType), TbPrintMachineEntity::getConnectionType, connectionType);
|
||||
String address = mapProxy.getStr("address");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(address), TbPrintMachineEntity::getAddress, address);
|
||||
String port = mapProxy.getStr("port");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(port), TbPrintMachineEntity::getPort, port);
|
||||
String subType = mapProxy.getStr("subType");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(subType), TbPrintMachineEntity::getSubType, subType);
|
||||
Integer status = mapProxy.getInt("status");
|
||||
wrapper.lambda().eq(ObjectUtil.isNotNull(status), TbPrintMachineEntity::getStatus, status);
|
||||
String categoryIds = mapProxy.getStr("categoryIds");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(categoryIds), TbPrintMachineEntity::getCategoryIds, categoryIds);
|
||||
String contentType = mapProxy.getStr("contentType");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(contentType), TbPrintMachineEntity::getContentType, contentType);
|
||||
String config = mapProxy.getStr("config");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(config), TbPrintMachineEntity::getConfig, config);
|
||||
String categoryList = mapProxy.getStr("categoryList");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(categoryList), TbPrintMachineEntity::getCategoryList, categoryList);
|
||||
String vendorId = mapProxy.getStr("vendorId");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(vendorId), TbPrintMachineEntity::getVendorId, vendorId);
|
||||
String productId = mapProxy.getStr("productId");
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(productId), TbPrintMachineEntity::getProductId, productId);
|
||||
|
||||
wrapper.lambda().orderByAsc(TbPrintMachineEntity::getSort);
|
||||
wrapper.lambda().orderByDesc(TbPrintMachineEntity::getId);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
Page<TbPrintMachineEntity> page = baseMapper.selectPage(new Page<>(pageNum, pageSize), getWrapper(params));
|
||||
List<ShopPrinterDTO> list = BeanUtil.copyToList(page.getRecords(), ShopPrinterDTO.class);
|
||||
return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopPrinterDTO> list(Map<String, Object> params) {
|
||||
List<TbPrintMachineEntity> list = baseMapper.selectList(getWrapper(params));
|
||||
return BeanUtil.copyToList(list, ShopPrinterDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopPrinterDTO get(Integer id) {
|
||||
TbPrintMachineEntity entity = baseMapper.selectById(id);
|
||||
return BeanUtil.toBean(entity, ShopPrinterDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ShopPrinterDTO dto) {
|
||||
CopyOptions options = new CopyOptions();
|
||||
options.setIgnoreProperties("createdAt", "updatedAt");
|
||||
TbPrintMachineEntity entity = BeanUtil.toBean(dto, TbPrintMachineEntity.class, options);
|
||||
entity.setCreatedAt(System.currentTimeMillis());
|
||||
entity.setUpdatedAt(System.currentTimeMillis());
|
||||
baseMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ShopPrinterDTO dto) {
|
||||
TbPrintMachineEntity entity = baseMapper.selectById(dto.getId());
|
||||
CopyOptions options = new CopyOptions();
|
||||
options.setIgnoreProperties("createdAt", "updatedAt");
|
||||
BeanUtil.copyProperties(dto, entity, options);
|
||||
entity.setUpdatedAt(System.currentTimeMillis());
|
||||
baseMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer id) {
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Integer id, Integer status) {
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<TbPrintMachineEntity>()
|
||||
.set(TbPrintMachineEntity::getStatus, status).eq(TbPrintMachineEntity::getId, id));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package cn.ysk.cashier.service.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.ShopPrinterDTO;
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置Service
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 17:15
|
||||
*/
|
||||
public interface ShopPrinterService extends IService<TbPrintMachineEntity> {
|
||||
|
||||
Map<String,Object> page(Map<String, Object> params);
|
||||
|
||||
List<ShopPrinterDTO> list(Map<String, Object> params);
|
||||
|
||||
ShopPrinterDTO get(Integer id);
|
||||
|
||||
void save(ShopPrinterDTO dto);
|
||||
|
||||
void update(ShopPrinterDTO dto);
|
||||
|
||||
void delete(Integer id);
|
||||
|
||||
void updateStatus(Integer id,Integer status);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?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="cn.ysk.cashier.mybatis.mapper.TbPrintMachineMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue