1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- // Copyright 2019 githup.com. All rights reserved.
- // Use of this source code is governed by githup.com.
- package project
- import (
- "context"
- "github.com/jaryhe/gopkgs/database"
- "github.com/jaryhe/gopkgs/logger"
- "go.uber.org/zap"
- "smart-site-management/errors"
- dbmodel "smart-site-management/model"
- pb_v1 "smart-site-management/pb/v1"
- )
- func ProjectInfo(ctx context.Context, req *pb_v1.ProjectInfoRequest)(reply *pb_v1.ProjectInfoReply, err error) {
- p := &dbmodel.TProject{}
- where := map[string]interface{}{
- "id":req.ProjectId,
- }
- // 状态判断
- err = p.Find(database.DB(), where)
- if err != nil {
- logger.Error("ProjectInfo",
- zap.String("err", err.Error()))
- return nil, errors.DataBaseError
- }
- if p.Id == 0 {
- return nil, errors.NoRecordError
- }
- reply = &pb_v1.ProjectInfoReply{}
- reply.Location = p.Location
- reply.Name = p.Name
- reply.Phone = p.Phone
- reply.SafetyRecordNo = p.SafetyRecordNo
- reply.ProjectLeader = p.ProjectLeader
- reply.ProjectNo = p.ProjectNo
- reply.Lon = p.Lon
- reply.Lat = p.Lat
- reply.Price = p.Price
- reply.BuildingStorey = p.BuildingStorey
- reply.Construction = p.Construction
- reply.CoveredArea = p.CoveredArea
- reply.Desc = p.Desc
- reply.Design = p.Design
- reply.Development = p.Development
- reply.Exploration = p.Exploration
- reply.Oversee = p.Oversee
- reply.ProjectFunction = p.ProjectFunction
- reply.ProjectPlan = p.ProjectPlan
- reply.ProjectType = p.ProjectType
- reply.TotalLevel = int32(p.TotalLevel)
- reply.ProjectEffectPic = p.ProjectEffectPic
- reply.StartDay = p.StartDay.Format("2006-01-02")
- reply.EndDay = p.EndDay.Format("2006-01-02")
- if p.ProjectPlan == "" {
- reply.ProjectPlan = "[]"
- }
- if p.ProjectEffectPic == "" {
- reply.ProjectEffectPic = "[]"
- }
- return reply, nil
- }
|