叫号配置接口

This commit is contained in:
SongZhang 2024-09-19 10:16:50 +08:00
parent 66dc7c8581
commit 079bf18d4c
11 changed files with 210 additions and 0 deletions

View File

@ -113,5 +113,21 @@ public class TbCallTableController {
return ResponseEntity.ok(tbCallService.getCallRecord(shopId, callTableId, page, size));
}
@AnonymousAccess
@GetMapping("config")
public ResponseEntity<?> getConfig(
@RequestParam Integer shopId
) {
return ResponseEntity.ok(tbCallService.getConfig(shopId));
}
@AnonymousAccess
@PutMapping("config")
public ResponseEntity<?> updateConfig(
@RequestBody UpdateConfigDTO configDTO
) {
return ResponseEntity.ok(tbCallService.updateConfig(configDTO));
}
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.dto.calltable;
import lombok.Data;
import org.bouncycastle.asn1.cmc.PendInfo;
import javax.validation.constraints.NotNull;
@Data
public class UpdateConfigDTO {
@NotNull
private Integer shopId;
private Integer isOnline;
private String bgCover;
private Integer isPostpone;
private Integer postponeNum;
}

View File

@ -0,0 +1,60 @@
package cn.ysk.cashier.mybatis.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "tb_call_config")
public class TbCallConfig {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Integer id;
@Size(max = 255)
@Column(name = "page_address")
private String pageAddress;
@Column(name = "is_online")
private Byte isOnline;
@Size(max = 255)
@Column(name = "bg_cover")
private String bgCover;
@Size(max = 255)
@Column(name = "success_msg")
private String successMsg;
@Size(max = 255)
@Column(name = "near_msg")
private String nearMsg;
@Size(max = 255)
@Column(name = "calling_msg")
private String callingMsg;
@NotNull
@Column(name = "shop_id", nullable = false)
private Integer shopId;
@Column(name = "create_time")
private Instant createTime;
@Column(name = "update_time")
private Instant updateTime;
@Column(name = "is_postpone")
private Byte isPostpone;
@Column(name = "postpone_num")
private Integer postponeNum;
}

View File

@ -0,0 +1,18 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.TbCallConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Administrator
* @description 针对表tb_call_config的数据库操作Mapper
* @createDate 2024-09-19 09:49:19
* @Entity cn.ysk.cashier.mybatis.entity.TbCallConfig
*/
public interface TbCallConfigMapper extends BaseMapper<TbCallConfig> {
}

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.mybatis.entity.TbCallConfig;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author Administrator
* @description 针对表tb_call_config的数据库操作Service
* @createDate 2024-09-19 09:49:19
*/
public interface TbCallConfigService extends IService<TbCallConfig> {
}

View File

@ -0,0 +1,22 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.ysk.cashier.mybatis.entity.TbCallConfig;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ysk.cashier.mybatis.service.TbCallConfigService;
import cn.ysk.cashier.mybatis.mapper.TbCallConfigMapper;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description 针对表tb_call_config的数据库操作Service实现
* @createDate 2024-09-19 09:49:19
*/
@Service
public class TbCallConfigServiceImpl extends ServiceImpl<TbCallConfigMapper, TbCallConfig>
implements TbCallConfigService{
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ysk.cashier.mybatis.entity.TbCallQueue;
import cn.ysk.cashier.mybatis.service.TbCallQueueService;
import cn.ysk.cashier.mybatis.mapper.TbCallQueueMapper;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
* @createDate 2024-09-12 15:34:30
*/
@Service
@Primary
public class TbCallQueueServiceImpl extends ServiceImpl<TbCallQueueMapper, TbCallQueue>
implements TbCallQueueService{

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ysk.cashier.mybatis.entity.TbCallTable;
import cn.ysk.cashier.mybatis.service.TbCallTableService;
import cn.ysk.cashier.mybatis.mapper.TbCallTableMapper;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
@ -11,6 +12,7 @@ import org.springframework.stereotype.Service;
* @description 针对表tb_call_table的数据库操作Service实现
* @createDate 2024-09-12 15:07:15
*/
@Primary
@Service
public class TbCallTableServiceImpl extends ServiceImpl<TbCallTableMapper, TbCallTable>
implements TbCallTableService{

View File

@ -22,4 +22,8 @@ public interface TbCallService {
Object getQueue(Integer shopId, Integer callTableId, Integer state, Integer page, Integer size);
Object getCallRecord(Integer shopId, Integer callTableId, Integer page, Integer size);
Object getConfig(Integer shopId);
Object updateConfig(UpdateConfigDTO configDTO);
}

View File

@ -8,10 +8,12 @@ import cn.hutool.extra.qrcode.QrConfig;
import cn.ysk.cashier.cons.RedisConstant;
import cn.ysk.cashier.dto.calltable.*;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbCallConfig;
import cn.ysk.cashier.mybatis.entity.TbCallQueue;
import cn.ysk.cashier.mybatis.entity.TbCallTable;
import cn.ysk.cashier.mybatis.mapper.TbCallQueueMapper;
import cn.ysk.cashier.mybatis.mapper.TbShopUserMapper;
import cn.ysk.cashier.mybatis.service.TbCallConfigService;
import cn.ysk.cashier.mybatis.service.TbCallQueueService;
import cn.ysk.cashier.mybatis.service.TbCallTableService;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
@ -43,6 +45,7 @@ public class TbCallServiceImpl implements TbCallService {
private final StringRedisTemplate redisTemplate;
private final TbCallQueueMapper tbCallQueueMapper;
private final WxMiniUtils wxMiniUtils;
private final TbCallConfigService tbCallConfigService;
@Override
public Object add(CallTableDTO addCallTableDTO) {
@ -418,4 +421,30 @@ public class TbCallServiceImpl implements TbCallService {
public Object getCallRecord(Integer shopId, Integer callTableId, Integer page, Integer size) {
return tbCallQueueMapper.selectCallRecord(shopId, callTableId, new Page<>(page, size));
}
@Override
public Object getConfig(Integer shopId) {
TbCallConfig config = tbCallConfigService.lambdaQuery().eq(TbCallConfig::getShopId, shopId).one();
if (config == null) {
config = new TbCallConfig();
config.setShopId(shopId);
config.setCreateTime(DateUtil.date().toInstant());
tbCallConfigService.save(config);
config = tbCallConfigService.lambdaQuery().eq(TbCallConfig::getShopId, shopId).one();
}
return config;
}
@Override
public Object updateConfig(UpdateConfigDTO configDTO) {
TbCallConfig config = tbCallConfigService.lambdaQuery().eq(TbCallConfig::getShopId, configDTO.getShopId()).one();
if (config == null) {
throw new BadRequestException("未查询到配置信息");
}
TbCallConfig tbCallConfig = BeanUtil.copyProperties(configDTO, TbCallConfig.class);
tbCallConfig.setId(config.getId());
tbCallConfig.setUpdateTime(DateUtil.date().toInstant());
return tbCallConfigService.updateById(tbCallConfig);
}
}

View File

@ -0,0 +1,28 @@
<?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.TbCallConfigMapper">
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbCallConfig">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="page_address" column="page_address" jdbcType="VARCHAR"/>
<result property="is_online" column="is_online" jdbcType="TINYINT"/>
<result property="bg_cover" column="bg_cover" jdbcType="VARCHAR"/>
<result property="success_msg" column="success_msg" jdbcType="VARCHAR"/>
<result property="near_msg" column="near_msg" jdbcType="VARCHAR"/>
<result property="pass_msg" column="pass_msg" jdbcType="VARCHAR"/>
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
<result property="is_postpone" column="is_postpone" jdbcType="TINYINT"/>
<result property="postpone_num" column="postpone_num" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,page_address,is_online,
bg_cover,success_msg,near_msg,
pass_msg,shop_id,create_time,
update_time,is_postpone,postpone_num
</sql>
</mapper>