approve_status.go 1020 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package user
  2. import (
  3. "context"
  4. "github.com/jaryhe/gopkgs/database"
  5. "github.com/jaryhe/gopkgs/logger"
  6. "github.com/jinzhu/gorm"
  7. "go.uber.org/zap"
  8. "smart-supplier-management/errors"
  9. dbmodel "smart-supplier-management/model"
  10. "smart-supplier-management/pb/v1"
  11. )
  12. func ProviderApproveStatus(ctx context.Context, req *v1.ProviderApproveStatusRequest) (reply *v1.ProviderApproveStatusReply, err error) {
  13. if req.SocialCode == ""{
  14. return nil, errors.ParamsError
  15. }
  16. p := dbmodel.TProvider{}
  17. where := map[string]interface{}{"social_code":req.SocialCode}
  18. err = p.FindSort(database.DB(), where, "created_at desc")
  19. if err != nil && err != gorm.ErrRecordNotFound {
  20. logger.Error("Login",
  21. zap.String("err", err.Error()))
  22. return nil, errors.DataBaseError
  23. }
  24. if p.Id == 0 {
  25. return nil, errors.NoRecordError
  26. }
  27. reply = &v1.ProviderApproveStatusReply{
  28. Status:int32(p.Status),
  29. Feedback:p.Feedback,
  30. }
  31. if p.Status > 0 {
  32. reply.ApproveTime = p.ApproveTime.Format("2006-01-02 15:04:05")
  33. }
  34. return reply, nil
  35. }