last_attendance.go 993 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package staff
  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. "smart-site-management/model"
  11. "smart-site-management/pb/v1"
  12. )
  13. func LatestStaffData(ctx context.Context, req *v1.LatestStaffDataRequest) (reply *v1.LatestStaffDataReply, err error) {
  14. reply = &v1.LatestStaffDataReply{}
  15. if req.ProjectId == 0 {
  16. return nil,errors.ParamsError
  17. }
  18. p := model.TStaffAttendance{}
  19. result, err := p.Last(database.DB(), req.ProjectId)
  20. if err != nil {
  21. logger.Error("LatestStaffData",
  22. zap.String("err", err.Error()))
  23. return nil, errors.DataBaseError
  24. }
  25. reply.Group = result.Group
  26. reply.InOut = int32(result.InOut)
  27. reply.Name = result.Name
  28. reply.Photo = result.Photo
  29. reply.RecogTime = result.RecogTime
  30. reply.WorkNo = result.WorkNo
  31. reply.WorkType = result.WorkType
  32. return reply, nil
  33. }