123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //go:generate reform
- package models
- import (
- "encoding/json"
- )
- //reform:fixok_userid2empguid
- type FixOkRow struct {
- Id int `reform:"UserId,pk"`
- EmpGUID int `reform:"EmpGUID"`
- }
- func (fixOkRow *FixOkRow) AfterFind() error {
- return nil
- }
- func (pass *FixOkRow) ParseFixokJson(fixokJsonPass map[string]interface{}) *FixOkRow {
- passId, err := fixokJsonPass["id"].(json.Number).Int64()
- if err != nil {
- panic(err)
- }
- pass.Id = int(passId)
- fixokJsonPassPersonIdN, fixokJsonPassPersonIdOk := fixokJsonPass["person_id"].(json.Number)
- if !fixokJsonPassPersonIdOk {
- return pass
- }
- personId, err := fixokJsonPassPersonIdN.Int64()
- if err != nil {
- panic(err)
- }
- pass.EmpGUID = int(personId)
- //pass.Firstname = fixokJsonPass["Firstname"].(string)
- //pass.Lastname = fixokJsonPass["Lastname"].(string)
- /*patronymic, patronymicOk := fixokJsonPass["Patronymic"].(string)
- if patronymicOk {
- pass.Patronymic = &patronymic
- }
- photoIdN, photoIdOk := fixokJsonPass["photo_id"].(json.Number)
- if !photoIdOk {
- // print warning
- pass.PhotoId = 0
- } else {
- photoId, err := photoIdN.Int64()
- if err != nil {
- panic(err)
- }
- pass.PhotoId = int(photoId)
- }
- pass.IsActual, _ = fixokJsonPass["is_actual"].(bool)*/
- return pass
- }
- type FixOkRows []FixOkRow
- func (passes FixOkRows) ToMap() map[int]*FixOkRow {
- passMap := map[int]*FixOkRow{}
- for idx, pass := range passes {
- passMap[pass.Id] = &passes[idx]
- }
- return passMap
- }
|