12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package models
- import (
- "fmt"
- operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
- "sort"
- "time"
- )
- type TmrGear struct {
- Id int64 `json:"id"`
- TmrId int64 `json:"tmr_id"`
- Gear string `json:"name"`
- Rev int64 `json:"rev"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt int64 `json:"updated_at"`
- }
- func (t *TmrGear) TableName() string {
- return "tmr_gear"
- }
- func NewTmrGearList(tmrId int64, req *operationPb.UpdateOrCreateTmrGearRequest) []*TmrGear {
- sort.Slice(req.Params, func(i, j int) bool {
- return req.Params[i].Rev < req.Params[j].Rev
- })
- res := make([]*TmrGear, len(req.Params))
- for i, v := range req.Params {
- res[i] = &TmrGear{
- TmrId: tmrId,
- Gear: fmt.Sprintf("%d", i+1),
- Rev: int64(v.Rev),
- CreatedAt: time.Now().Unix(),
- UpdatedAt: time.Now().Unix(),
- }
- }
- return res
- }
- type TmrGearDetail struct {
- BCode string `json:"bcode"`
- CCount int32 `json:"ccount"`
- FName string `json:"fname"`
- GearRate float64 `json:"gear_rate"`
- Length int32 `json:"length"`
- Sort int32 `json:"sort"`
- Speed float64 `json:"speed"`
- UseInBar string `json:"useinbar"`
- Weight float64 `json:"weight"`
- Pid int64 `json:"pid"`
- FBarid int64 `json:"fbarid"`
- }
|