info.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 githup.com. All rights reserved.
  2. // Use of this source code is governed by githup.com.
  3. package project
  4. import (
  5. "context"
  6. "github.com/jaryhe/gopkgs/database"
  7. "github.com/jaryhe/gopkgs/logger"
  8. "go.uber.org/zap"
  9. "smart-site-management/errors"
  10. dbmodel "smart-site-management/model"
  11. pb_v1 "smart-site-management/pb/v1"
  12. )
  13. func ProjectInfo(ctx context.Context, req *pb_v1.ProjectInfoRequest)(reply *pb_v1.ProjectInfoReply, err error) {
  14. p := &dbmodel.TProject{}
  15. where := map[string]interface{}{
  16. "id":req.ProjectId,
  17. }
  18. // 状态判断
  19. err = p.Find(database.DB(), where)
  20. if err != nil {
  21. logger.Error("ProjectInfo",
  22. zap.String("err", err.Error()))
  23. return nil, errors.DataBaseError
  24. }
  25. if p.Id == 0 {
  26. return nil, errors.NoRecordError
  27. }
  28. reply = &pb_v1.ProjectInfoReply{}
  29. reply.Location = p.Location
  30. reply.Name = p.Name
  31. reply.Phone = p.Phone
  32. reply.SafetyRecordNo = p.SafetyRecordNo
  33. reply.ProjectLeader = p.ProjectLeader
  34. reply.ProjectNo = p.ProjectNo
  35. reply.Lon = p.Lon
  36. reply.Lat = p.Lat
  37. reply.Price = p.Price
  38. reply.BuildingStorey = p.BuildingStorey
  39. reply.Construction = p.Construction
  40. reply.CoveredArea = p.CoveredArea
  41. reply.Desc = p.Desc
  42. reply.Design = p.Design
  43. reply.Development = p.Development
  44. reply.Exploration = p.Exploration
  45. reply.Oversee = p.Oversee
  46. reply.ProjectFunction = p.ProjectFunction
  47. reply.ProjectPlan = p.ProjectPlan
  48. reply.ProjectType = p.ProjectType
  49. reply.TotalLevel = int32(p.TotalLevel)
  50. reply.ProjectEffectPic = p.ProjectEffectPic
  51. reply.StartDay = p.StartDay.Format("2006-01-02")
  52. reply.EndDay = p.EndDay.Format("2006-01-02")
  53. if p.ProjectPlan == "" {
  54. reply.ProjectPlan = "[]"
  55. }
  56. if p.ProjectEffectPic == "" {
  57. reply.ProjectEffectPic = "[]"
  58. }
  59. return reply, nil
  60. }