71 lines
2.0 KiB
Go
71 lines
2.0 KiB
Go
package loader
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
// Conf configures the mapping from the excel version
|
|
// to the eCalc structure
|
|
type Conf struct {
|
|
Title string `json:"title"`
|
|
Version string `json:"version"`
|
|
Values []Value `json:"values"`
|
|
Areas []Area `json:"areas"`
|
|
Rating Rating `json:"rating"`
|
|
}
|
|
|
|
// Value defines a single value inside the excel workbook
|
|
type Value struct {
|
|
Sheet int `json:"sheet"`
|
|
Cell string `json:"cell"`
|
|
Type string `json:"type"`
|
|
Struct string `json:"struct"`
|
|
Field string `json:"field"`
|
|
Default string `json:"default"`
|
|
}
|
|
|
|
// Area defines rows and cols, which are maped to
|
|
// a slice of a type. For example IndustrySector
|
|
type Area struct {
|
|
Sheet int `json:"sheet"`
|
|
StartRow int `json:"start_row"`
|
|
EndRow int `json:"end_row"`
|
|
Struct string `json:"struct"`
|
|
Cols []AreaCol `json:"cols"`
|
|
}
|
|
|
|
// AreaCol defines each col of an area. As Col-Definition
|
|
// the letter from the Excel should be used.
|
|
// For example "A" for the first col, "B" for the second ...
|
|
type AreaCol struct {
|
|
Col string `json:"col"`
|
|
Field string `json:"field"`
|
|
Type string `json:"type"`
|
|
Default string `json:"default"`
|
|
}
|
|
|
|
// Rating defines the area of the ratingarea
|
|
// The cols must be defined by the letter of the col
|
|
// for example "A" for the first col
|
|
type Rating struct {
|
|
Sheet int `json:"sheet"`
|
|
StartRow int `json:"start_row"`
|
|
EndRow int `json:"end_row"`
|
|
PointsCol string `json:"points_col"`
|
|
MaxPointsCol string `json:"max_points_col"`
|
|
IDCol string `json:"id_col"`
|
|
ShortNameCol string `json:"short_name_col"`
|
|
NameCol string `json:"name_col"`
|
|
EstimationsCol string `json:"estimations_col"`
|
|
WeightCol string `json:"weight_col"`
|
|
SelectedByUserCol string `json:"selected_by_user_col"`
|
|
}
|
|
|
|
// EncodeJSON writes the JSON of the conf into the Writer
|
|
func (c Conf) EncodeJSON(w io.Writer) error {
|
|
enc := json.NewEncoder(w)
|
|
enc.SetIndent("", " ")
|
|
return enc.Encode(c)
|
|
}
|