findme-backend-merchant-java/src/main/java/com/xjhs/findmemerchant/entity/BusinessPeriod.java
2026-01-09 12:20:44 +08:00

81 lines
1.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.xjhs.findmemerchant.entity;
import com.xjhs.findmemerchant.common.jpa.AbstractBaseEntity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Comment;
/**
* 门店营业时间段
* 对应表business_periods
*/
@Getter
@Setter
@Entity
@Table(
name = "business_periods",
indexes = {
@Index(name = "idx_business_periods_store_id", columnList = "store_id")
}
)
public class BusinessPeriod extends AbstractBaseEntity {
/**
* 门店
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_id", insertable = false, updatable = false)
@Comment("门店Id")
private Store store;
/**
* 周几0=周日 ... 6=周六
*/
@Column(name = "day_of_week")
@Comment("周几0周日 1周一 ... 6周六")
private Integer dayOfWeek;
/**
* 开始时间HH:MM
*/
@Column(name = "start_time", length = 5)
@Comment("开始时间HH:MM")
private String startTime;
/**
* 结束时间HH:MM
*/
@Column(name = "end_time", length = 5)
@Comment("结束时间HH:MM")
private String endTime;
/**
* 是否启用
*/
@Column(name = "is_enabled")
@Comment("是否启用")
private Boolean isEnabled = Boolean.TRUE;
// ========== 业务方法 ==========
/**
* 中文周几,比如:周一
*/
public String getDayName() {
if (dayOfWeek == null) {
return "未知";
}
return switch (dayOfWeek) {
case 0 -> "周日";
case 1 -> "周一";
case 2 -> "周二";
case 3 -> "周三";
case 4 -> "周四";
case 5 -> "周五";
case 6 -> "周六";
default -> "未知";
};
}
}