初始化状态

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,9 +1,14 @@
package com.czg.enums;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
/**
* 台桌状态枚举
*
* @author Administrator
*/
@@ -29,6 +34,15 @@ public enum ShopTableStatusEnum {
private final String value;
private final 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));
}
}