xiangpei
2024-03-06 0c1a03ea09693ecddad0f733b39dc72647c1d021
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
81
82
83
84
85
86
87
88
89
90
package com.ycl.platform.domain.form;
 
import com.ycl.system.domain.group.Update;
import com.ycl.system.domain.group.Add;
import com.ycl.platform.base.AbsForm;
import com.ycl.platform.domain.entity.CheckTemplate;
 
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
 
import jakarta.validation.constraints.NotEmpty;
import org.springframework.beans.BeanUtils;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.lang.NonNull;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
 
/**
 * 考核模板表单
 *
 * @author xp
 * @since 2024-03-06
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "CheckTemplate表单", description = "考核模板表单")
public class CheckTemplateForm extends AbsForm {
 
    @NotNull(message = "模板名称不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("模板名称")
    private String templateName;
 
    @NotNull(message = "调整系数不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("调整系数")
    private BigDecimal adjustCoefficient;
 
    @NotNull(message = "调整系数计算方式不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("调整系数计算方式")
    private String adjustWay;
 
    @NotBlank(message = "状态不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("状态")
    private String status;
 
    @NotEmpty(message = "考核规则不能为空")
    @ApiModelProperty("考核规则")
    private List<RuleItem> ruleList;
 
    public static CheckTemplate getEntityByForm(@NonNull CheckTemplateForm form, CheckTemplate entity) {
        if(entity == null) {
          entity = new CheckTemplate();
        }
        BeanUtils.copyProperties(form, entity);
        return entity;
    }
 
    public class RuleItem {
 
        /**
         * 规则
         */
        private Integer ruleId;
 
        /**
         * 权重
         */
        private BigDecimal weight;
 
        public Integer getRuleId() {
            return ruleId;
        }
 
        public void setRuleId(Integer ruleId) {
            this.ruleId = ruleId;
        }
 
        public BigDecimal getWeight() {
            return weight;
        }
 
        public void setWeight(BigDecimal weight) {
            this.weight = weight;
        }
    }
 
}