diff --git a/service/drafting.go b/service/drafting.go index f811272..ab1b933 100644 --- a/service/drafting.go +++ b/service/drafting.go @@ -16,7 +16,7 @@ func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto { if query.Name != "" { dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) } - records, total, err := dq.Debug().Omit(d.Proto).FindByPage(query.Offset(), query.Size) + records, total, err := dq.Debug().Omit(d.Proto).Order(d.UpdateAt.Desc()).FindByPage(query.Offset(), query.Size) if err != nil { panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) } @@ -29,7 +29,7 @@ func ListDraftingQuery(query *dto.ListDraftingReqDto) []*model.Drafting { if query.Type != 0 { dq = dq.Where(d.Type.Eq(query.Type)) } - records, err := dq.Debug().Omit(d.Proto).Find() + records, err := dq.Debug().Omit(d.Proto).Order(d.UpdateAt.Desc()).Find() if err != nil { panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) } diff --git a/third_party/electrical_machinery/electrical_machinery.go b/third_party/electrical_machinery/electrical_machinery.go index e72684f..e43eb3b 100644 --- a/third_party/electrical_machinery/electrical_machinery.go +++ b/third_party/electrical_machinery/electrical_machinery.go @@ -54,6 +54,9 @@ func (s *electricalMachineryImpl) Stop() { } func (s *electricalMachineryImpl) SendElectricMachineryMessage(info *message.ElectricMachinery) { + if s.electricalMachineryUdpClient == nil { + return + } s.electricalMachineryUdpClient.Send(info.Encode()) }