package com.rongyichuang.rating.entity; import com.rongyichuang.common.entity.BaseEntity; import jakarta.persistence.*; import org.hibernate.annotations.Where; import java.util.List; /** * 评分模板实体类 */ @Entity @Table(name = "t_rating_scheme") @Where(clause = "state = 1") public class RatingScheme extends BaseEntity { /** * 模板名称 */ @Column(name = "name", nullable = false, length = 128) private String name; /** * 模板描述 */ @Column(name = "description", length = 512) private String description; /** * 评分条目列表 */ @OneToMany(mappedBy = "scheme", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OrderBy("orderNo ASC") private List items; // 构造函数 public RatingScheme() {} public RatingScheme(String name, String description) { this.name = name; this.description = description; } // Getter和Setter方法 public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public List getItems() { return items; } public void setItems(List items) { this.items = items; } /** * 计算模板总分 */ public Integer getTotalScore() { if (items == null || items.isEmpty()) { return 0; } return items.stream() .mapToInt(RatingItem::getMaxScore) .sum(); } }