店铺管理-店铺配置:打印机设置相关接口

This commit is contained in:
谭凯凯
2024-09-25 11:17:51 +08:00
committed by Tankaikai
parent 45a6bcbe9d
commit caaa3196b3
6 changed files with 327 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import com.chaozhanggui.system.cashierservice.service.ShopPrinterService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 店铺打印机配置
* @author tankaikai
* @since 2024-09-24 16:56
*/
@Slf4j
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("shop-config/printer")
public class ShopPrinterController {
@Resource
private ShopPrinterService shopPrinterService;
@GetMapping("page")
public Result page(@RequestParam Map<String, Object> params) {
PageInfo<ShopPrinterDTO> page = shopPrinterService.page(params);
return Result.success(CodeEnum.SUCCESS,page);
}
@GetMapping("list")
public Result list(@RequestParam Map<String, Object> params) {
List<ShopPrinterDTO> list = shopPrinterService.list(params);
return Result.success(CodeEnum.SUCCESS,list);
}
@GetMapping("{id}")
public Result get(@PathVariable("id") Integer id) {
ShopPrinterDTO dto = shopPrinterService.get(id);
return Result.success(CodeEnum.SUCCESS,dto);
}
@PostMapping
public Result save(@RequestBody ShopPrinterDTO dto) {
shopPrinterService.save(dto);
return Result.success(CodeEnum.SUCCESS);
}
@PutMapping
public Result update(@RequestBody ShopPrinterDTO dto) {
shopPrinterService.update(dto);
return Result.success(CodeEnum.SUCCESS);
}
@DeleteMapping("{id}")
public Result delete(@PathVariable("id") Integer id){
shopPrinterService.delete(id);
return Result.success(CodeEnum.SUCCESS);
}
@PostMapping("update-status")
public Result updateStatus(@RequestBody ShopPrinterDTO dto){
shopPrinterService.updateStatus(dto.getId(),dto.getStatus());
return Result.success(CodeEnum.SUCCESS);
}
}

View File

@@ -0,0 +1,19 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author tankaikai
* @since 2024-09-24 17:25
*/
@Mapper
public interface ShopPrinterServiceMapper {
List<ShopPrinterDTO> getList(Map<String, Object> params);
int updateStatus(@Param("id") Integer id, @Param("status") Integer status);
}

View File

@@ -0,0 +1,64 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
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() {
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)));
}
}

View File

@@ -0,0 +1,30 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Map;
/**
* 打印机配置
* @author tankaikai
* @since 2024-09-24 17:15
*/
public interface ShopPrinterService {
PageInfo<ShopPrinterDTO> 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);
}

View File

@@ -0,0 +1,79 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapProxy;
import com.chaozhanggui.system.cashierservice.dao.ShopPrinterServiceMapper;
import com.chaozhanggui.system.cashierservice.dao.TbPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import com.chaozhanggui.system.cashierservice.service.ShopPrinterService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 店铺打印配置
*
* @author tankaikai
* @since 2024-09-24 17:23
*/
@Service
public class ShopPrinterServiceImpl implements ShopPrinterService {
@Resource
private ShopPrinterServiceMapper shopPrinterServiceMapper;
@Resource
private TbPrintMachineMapper tbPrintMachineMapper;
@Override
public PageInfo<ShopPrinterDTO> page(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
Integer pageNum = mapProxy.getInt("pageNum");
Integer pageSize = mapProxy.getInt("pageSize");
PageInfo<ShopPrinterDTO> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> shopPrinterServiceMapper.getList(params));
return pageInfo;
}
@Override
public List<ShopPrinterDTO> list(Map<String, Object> params) {
return shopPrinterServiceMapper.getList(params);
}
@Override
public ShopPrinterDTO get(Integer id) {
TbPrintMachineWithBLOBs entity = tbPrintMachineMapper.selectByPrimaryKey(id);
return BeanUtil.toBean(entity, ShopPrinterDTO.class);
}
@Override
public void save(ShopPrinterDTO dto) {
TbPrintMachineWithBLOBs entity = new TbPrintMachineWithBLOBs();
BeanUtil.copyProperties(dto, entity, "createdAt", "updatedAt");
entity.setCreatedAt(System.currentTimeMillis());
entity.setUpdatedAt(System.currentTimeMillis());
tbPrintMachineMapper.insert(entity);
}
@Override
public void update(ShopPrinterDTO dto) {
TbPrintMachineWithBLOBs entity = tbPrintMachineMapper.selectByPrimaryKey(dto.getId());
BeanUtil.copyProperties(dto, entity, "createdAt", "updatedAt");
entity.setUpdatedAt(System.currentTimeMillis());
tbPrintMachineMapper.updateByPrimaryKeyWithBLOBs(entity);
}
@Override
public void delete(Integer id) {
tbPrintMachineMapper.deleteByPrimaryKey(id);
}
@Override
public void updateStatus(Integer id, Integer status) {
shopPrinterServiceMapper.updateStatus(id, status);
}
}

View File

@@ -0,0 +1,65 @@
<?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.ShopPrinterServiceMapper">
<sql id="Base_Column_List">
id, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, content_type, created_at, updated_at, sort, vendor_id, product_id
</sql>
<sql id="Blob_Column_List">
config, category_list
</sql>
<select id="getList" resultType="com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO">
select
<include refid="Base_Column_List" />,
<include refid="Blob_Column_List" />
from tb_print_machine
where shop_id = #{shopId}
<if test="name != null and name != ''">
and name like concat(#{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 != ''">
and status = #{status}
</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="categoryList != null and categoryList != ''">
and category_list = #{categoryList}
</if>
<if test="vendorId != null and vendorId != ''">
and vendor_id = #{vendorId}
</if>
<if test="productId != null and productId != ''">
and product_id = #{productId}
</if>
order by sort asc,id desc
</select>
<update id="updateStatus">
update tb_print_machine set status = #{status} where id = #{id}
</update>
</mapper>