work_order.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package model
  2. import (
  3. "kpt-pasture/http/util"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. type WorkOrder struct {
  7. Id int64 `json:"id"`
  8. Name string `json:"name"`
  9. CategoryId pasturePb.WorkOrderCategory_Kind `json:"categoryId"`
  10. CategoryName string `json:"categoryName"`
  11. Priority pasturePb.Priority_Kind `json:"priority"`
  12. ExecTime string `json:"execTime"`
  13. SubscribeUnit pasturePb.WorkOrderSubscribeUnit_Kind `json:"subscribeUnit"`
  14. ExecPersons string `json:"execPersons"`
  15. ExecDepartmental string `json:"execDepartmental"`
  16. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  17. Photos string `json:"photos"`
  18. Remarks string `json:"remarks"`
  19. OperationId int64 `json:"operationId"`
  20. OperationName string `json:"operationName"`
  21. CreatedAt int64 `json:"createdAt"`
  22. UpdatedAt int64 `json:"updatedAt"`
  23. }
  24. func (w *WorkOrder) TableName() string {
  25. return "work_order"
  26. }
  27. func NewWorkOrder(req *pasturePb.WorkOrderList, systemUser *SystemUser, workOrderCategoryMap map[pasturePb.WorkOrderCategory_Kind]string) *WorkOrder {
  28. return &WorkOrder{
  29. Name: req.Name,
  30. CategoryId: req.CategoryId,
  31. CategoryName: workOrderCategoryMap[req.CategoryId],
  32. Priority: req.Priority,
  33. ExecTime: req.ExecTime,
  34. SubscribeUnit: req.SubscribeUnit,
  35. ExecPersons: util.Int32SliceToString(req.ExecPersons, ","),
  36. ExecDepartmental: util.Int32SliceToString(req.ExecDepartmental, ","),
  37. IsShow: req.IsShow,
  38. Photos: "",
  39. Remarks: req.Remarks,
  40. OperationId: systemUser.Id,
  41. OperationName: systemUser.Name,
  42. }
  43. }