evaluation_rule.go 2.3 KB
package domain

import (
	"time"
)

const (
	EvaluationTypeRating int = 0 // 评估方式-评级
	EvaluationTypeScore  int = 1 // 评估方式-评分
)

type Rating struct {
	Levels []*RatingLevel `json:"levels" comment:"配置等级"`
}

type RatingLevel struct {
	Code           string  `json:"code" comment:"等级代号"`
	Name           string  `json:"name" comment:"等级名称"`
	Color          int     `json:"color" comment:"等级颜色"`
	QuantizedValue float64 `json:"quantizedValue" comment:"等级量化值"`
}

type Score struct {
	Min           float64       `json:"min" comment:"评分下限"`
	Max           float64       `json:"max" comment:"评分上限"`
	IntervalState int           `json:"intervalState" comment:"按分数子区间匹配等级(0关闭、1开启)"`
	DecimalPlaces int           `json:"decimalPlaces" comment:"保留小数点(0不保留、1保留一位、以此类推)"`
	Levels        []*ScoreLevel `json:"levels" comment:"配置等级区间"`
}

type ScoreLevel struct {
	Code  string  `json:"code" comment:"等级代号"`
	Name  string  `json:"name" comment:"等级名称"`
	Start float64 `json:"start" comment:"分数区间开始值"`
	End   float64 `json:"end" comment:"分数区间结束值"`
}

type EvaluationRule struct {
	Id        int64      `json:"id,string" comment:"ID"`
	Name      string     `json:"name" comment:"名称"`
	Remark    string     `json:"remark" comment:"备注"`
	CompanyId int64      `json:"companyId,string" comment:"公司ID"`
	CreatorId int64      `json:"creatorId,string" comment:"创建人ID"`
	Type      int        `json:"type" comment:"评估方式(0评级、1评分)"`
	Rating    Rating     `json:"rating" comment:"评级"`
	Score     Score      `json:"score" comment:"评分"`
	CreatedAt time.Time  `json:"createdAt" comment:"创建时间"`
	UpdatedAt time.Time  `json:"updatedAt" comment:"更新时间"`
	DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}

type EvaluationRuleRepository interface {
	Insert(rule *EvaluationRule) (*EvaluationRule, error)
	Remove(rule *EvaluationRule) (*EvaluationRule, error)
	FindOne(queryOptions map[string]interface{}) (*EvaluationRule, error)
	Find(queryOptions map[string]interface{}) (int64, []*EvaluationRule, error)
	Count(queryOptions map[string]interface{}) (int64, error)
}