package user import ( "context" "github.com/jaryhe/gopkgs/database" "github.com/jaryhe/gopkgs/logger" "github.com/jinzhu/gorm" "go.uber.org/zap" "smart-supplier-management/errors" dbmodel "smart-supplier-management/model" "smart-supplier-management/pb/v1" ) func ProviderApproveStatus(ctx context.Context, req *v1.ProviderApproveStatusRequest) (reply *v1.ProviderApproveStatusReply, err error) { if req.SocialCode == ""{ return nil, errors.ParamsError } p := dbmodel.TProvider{} where := map[string]interface{}{"social_code":req.SocialCode} err = p.FindSort(database.DB(), where, "created_at desc") if err != nil && err != gorm.ErrRecordNotFound { logger.Error("Login", zap.String("err", err.Error())) return nil, errors.DataBaseError } if p.Id == 0 { return nil, errors.NoRecordError } reply = &v1.ProviderApproveStatusReply{ Status:int32(p.Status), Feedback:p.Feedback, } if p.Status > 0 { reply.ApproveTime = p.ApproveTime.Format("2006-01-02 15:04:05") } return reply, nil }