approve_status.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package user
  4. import (
  5. "context"
  6. "github.com/jaryhe/gopkgs/database"
  7. "github.com/jaryhe/gopkgs/logger"
  8. "github.com/jinzhu/gorm"
  9. "go.uber.org/zap"
  10. "smart-enterprise-management/errors"
  11. dbmodel "smart-enterprise-management/model"
  12. pb_v1 "smart-enterprise-management/pb/v1"
  13. )
  14. func CompanyApproveStatus(ctx context.Context, req *pb_v1.CompanyApproveStatusRequest)(reply *pb_v1.CompanyApproveStatusReply, err error) {
  15. if req.SocialCode == ""{
  16. return nil, errors.ParamsError
  17. }
  18. p := dbmodel.TCompany{}
  19. where := map[string]interface{}{"social_code":req.SocialCode}
  20. err = p.FindSort(database.DB(), where, "created_at desc")
  21. if err != nil && err != gorm.ErrRecordNotFound {
  22. logger.Error("Login",
  23. zap.String("err", err.Error()))
  24. return nil, errors.DataBaseError
  25. }
  26. if p.Id == 0 {
  27. return nil, errors.UserNotExistError
  28. }
  29. reply = &pb_v1.CompanyApproveStatusReply{
  30. Status:int32(p.Status),
  31. Feedback:p.Feedback,
  32. }
  33. if p.Status > 0 {
  34. reply.ApproveTime = p.ApproveTime.Format("2006-01-02 15:04:05")
  35. }
  36. return reply, nil
  37. }