初始化状态

This commit is contained in:
2025-05-09 11:15:09 +08:00
parent fc255e5969
commit 1132c2adc6
3 changed files with 38 additions and 10 deletions

View File

@@ -78,6 +78,8 @@ public class ShopTable implements Serializable {
* 关台closed
*/
private String status;
@Column(ignore = true)
private String statusMsg;
@Column(onInsertValue = "now()")
private LocalDateTime createTime;

View File

@@ -1,35 +1,49 @@
package com.czg.enums;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
/**
* 台桌状态枚举
*
* @author Administrator
*/
@Getter
public enum ShopTableStatusEnum {
// 未绑定
UNBOUND("unbound","未绑定"),
UNBOUND("unbound", "未绑定"),
// 空闲
IDLE("idle","空闲"),
IDLE("idle", "空闲"),
// 点餐中
ORDERING("ordering","点餐中"),
ORDERING("ordering", "点餐中"),
// 未结账
UNSETTLED("unsettled","未结账"),
UNSETTLED("unsettled", "未结账"),
// 支付中
PAYING("paying","支付中"),
PAYING("paying", "支付中"),
// 已结账 (待清台)
SETTLED("settled","已结账 (待清台)"),
SETTLED("settled", "已结账 (待清台)"),
// 关台
CLOSED("closed","关台"),
CLOSED("closed", "关台"),
// 预定
SUBSCRIBE("subscribe","预定"),
SUBSCRIBE("subscribe", "预定"),
;
private final String value;
private final String msg;
ShopTableStatusEnum(String value,String msg) {
// 静态代码块,在类加载时执行,用于初始化映射关系
private static final Map<String, String> VALUE_MSG_MAP = new HashMap<>();
static {
for (ShopTableStatusEnum status : ShopTableStatusEnum.values()) {
VALUE_MSG_MAP.put(status.getValue(), status.getMsg());
}
}
ShopTableStatusEnum(String value, String msg) {
this.value = value;
this.msg = msg;
}
@@ -37,4 +51,12 @@ public enum ShopTableStatusEnum {
public boolean equalsVal(String val) {
return val.equals(value);
}
public static String getMsgByValue(String value) {
if (StrUtil.isBlank(value)) {
return "";
}
return VALUE_MSG_MAP.get(value);
}
}

View File

@@ -305,6 +305,10 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
@Override
public Page<ShopTableVO> pageInfo(Long shopId, Integer areaId, String tableCode, String status, String name, Boolean isBind) {
PageHelper.startPage(PageUtil.buildPageHelp());
return PageUtil.convert(new PageInfo<>(mapper.pageInfo(shopId, areaId, tableCode, status, name, isBind)));
List<ShopTableVO> shopTableVOS = mapper.pageInfo(shopId, areaId, tableCode, status, name, isBind);
for (ShopTableVO shopTableVO : shopTableVOS) {
shopTableVO.setStatusMsg(ShopTableStatusEnum.getMsgByValue(shopTableVO.getStatus()));
}
return PageUtil.convert(new PageInfo<>(shopTableVOS));
}
}