lrj
2 天以前 c61d4fe27c97d2ecc907756aa571a4ef14a7b9b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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<RatingItem> 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<RatingItem> getItems() {
        return items;
    }
 
    public void setItems(List<RatingItem> items) {
        this.items = items;
    }
 
    /**
     * 计算模板总分
     */
    public Integer getTotalScore() {
        if (items == null || items.isEmpty()) {
            return 0;
        }
        return items.stream()
                .mapToInt(RatingItem::getMaxScore)
                .sum();
    }
}