add GetComments and update proto

This commit is contained in:
2023-08-14 14:27:29 +03:00
parent 85d1191dd9
commit 37e92e8473
16 changed files with 850 additions and 142 deletions

View File

@@ -89,6 +89,7 @@ func (m *ErrorRsp) validate(all bool) error {
if len(errors) > 0 {
return ErrorRspMultiError(errors)
}
return nil
}
@@ -194,6 +195,7 @@ func (m *Error) validate(all bool) error {
if len(errors) > 0 {
return ErrorMultiError(errors)
}
return nil
}
@@ -324,6 +326,7 @@ func (m *Package) validate(all bool) error {
if len(errors) > 0 {
return PackageMultiError(errors)
}
return nil
}
@@ -476,6 +479,7 @@ func (m *Module) validate(all bool) error {
if len(errors) > 0 {
return ModuleMultiError(errors)
}
return nil
}
@@ -617,6 +621,7 @@ func (m *Issue) validate(all bool) error {
if len(errors) > 0 {
return IssueMultiError(errors)
}
return nil
}
@@ -735,31 +740,14 @@ func (m *Comment) validate(all bool) error {
// no validation rules for Text
if m.GetCreated() <= 0 {
err := CommentValidationError{
field: "Created",
reason: "value must be greater than 0",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for Created
if m.GetUpdated() <= 0 {
err := CommentValidationError{
field: "Updated",
reason: "value must be greater than 0",
}
if !all {
return err
}
errors = append(errors, err)
}
// no validation rules for Updated
if len(errors) > 0 {
return CommentMultiError(errors)
}
return nil
}
@@ -858,6 +846,7 @@ func (m *ListPackageReq) validate(all bool) error {
if len(errors) > 0 {
return ListPackageReqMultiError(errors)
}
return nil
}
@@ -991,6 +980,7 @@ func (m *ListPackageRsp) validate(all bool) error {
if len(errors) > 0 {
return ListPackageRspMultiError(errors)
}
return nil
}
@@ -1123,6 +1113,7 @@ func (m *UpdatePackageReq) validate(all bool) error {
if len(errors) > 0 {
return UpdatePackageReqMultiError(errors)
}
return nil
}
@@ -1233,6 +1224,7 @@ func (m *UpdatePackageRsp) validate(all bool) error {
if len(errors) > 0 {
return UpdatePackageRspMultiError(errors)
}
return nil
}
@@ -1345,6 +1337,7 @@ func (m *CommentReq) validate(all bool) error {
if len(errors) > 0 {
return CommentReqMultiError(errors)
}
return nil
}
@@ -1456,6 +1449,7 @@ func (m *AddCommentReq) validate(all bool) error {
if len(errors) > 0 {
return AddCommentReqMultiError(errors)
}
return nil
}
@@ -1566,6 +1560,7 @@ func (m *AddCommentRsp) validate(all bool) error {
if len(errors) > 0 {
return AddCommentRspMultiError(errors)
}
return nil
}
@@ -1687,6 +1682,7 @@ func (m *AddPackageReq) validate(all bool) error {
if len(errors) > 0 {
return AddPackageReqMultiError(errors)
}
return nil
}
@@ -1797,6 +1793,7 @@ func (m *AddPackageRsp) validate(all bool) error {
if len(errors) > 0 {
return AddPackageRspMultiError(errors)
}
return nil
}
@@ -1896,6 +1893,7 @@ func (m *GetModuleReq) validate(all bool) error {
if len(errors) > 0 {
return GetModuleReqMultiError(errors)
}
return nil
}
@@ -2028,6 +2026,7 @@ func (m *GetModuleRsp) validate(all bool) error {
if len(errors) > 0 {
return GetModuleRspMultiError(errors)
}
return nil
}
@@ -2100,3 +2099,279 @@ var _ interface {
Cause() error
ErrorName() string
} = GetModuleRspValidationError{}
// Validate checks the field values on GetCommentsReq with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *GetCommentsReq) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on GetCommentsReq with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in GetCommentsReqMultiError,
// or nil if none found.
func (m *GetCommentsReq) ValidateAll() error {
return m.validate(true)
}
func (m *GetCommentsReq) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if len(m.GetId()) < 1 {
err := GetCommentsReqValidationError{
field: "Id",
reason: "value must contain at least 1 item(s)",
}
if !all {
return err
}
errors = append(errors, err)
}
_GetCommentsReq_Id_Unique := make(map[uint64]struct{}, len(m.GetId()))
for idx, item := range m.GetId() {
_, _ = idx, item
if _, exists := _GetCommentsReq_Id_Unique[item]; exists {
err := GetCommentsReqValidationError{
field: fmt.Sprintf("Id[%v]", idx),
reason: "repeated value must contain unique items",
}
if !all {
return err
}
errors = append(errors, err)
} else {
_GetCommentsReq_Id_Unique[item] = struct{}{}
}
if item <= 0 {
err := GetCommentsReqValidationError{
field: fmt.Sprintf("Id[%v]", idx),
reason: "value must be greater than 0",
}
if !all {
return err
}
errors = append(errors, err)
}
}
if len(errors) > 0 {
return GetCommentsReqMultiError(errors)
}
return nil
}
// GetCommentsReqMultiError is an error wrapping multiple validation errors
// returned by GetCommentsReq.ValidateAll() if the designated constraints
// aren't met.
type GetCommentsReqMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m GetCommentsReqMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m GetCommentsReqMultiError) AllErrors() []error { return m }
// GetCommentsReqValidationError is the validation error returned by
// GetCommentsReq.Validate if the designated constraints aren't met.
type GetCommentsReqValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e GetCommentsReqValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e GetCommentsReqValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e GetCommentsReqValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e GetCommentsReqValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e GetCommentsReqValidationError) ErrorName() string { return "GetCommentsReqValidationError" }
// Error satisfies the builtin error interface
func (e GetCommentsReqValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sGetCommentsReq.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = GetCommentsReqValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = GetCommentsReqValidationError{}
// Validate checks the field values on GetCommentsRsp with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *GetCommentsRsp) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on GetCommentsRsp with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in GetCommentsRspMultiError,
// or nil if none found.
func (m *GetCommentsRsp) ValidateAll() error {
return m.validate(true)
}
func (m *GetCommentsRsp) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
for idx, item := range m.GetComments() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, GetCommentsRspValidationError{
field: fmt.Sprintf("Comments[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, GetCommentsRspValidationError{
field: fmt.Sprintf("Comments[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return GetCommentsRspValidationError{
field: fmt.Sprintf("Comments[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return GetCommentsRspMultiError(errors)
}
return nil
}
// GetCommentsRspMultiError is an error wrapping multiple validation errors
// returned by GetCommentsRsp.ValidateAll() if the designated constraints
// aren't met.
type GetCommentsRspMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m GetCommentsRspMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m GetCommentsRspMultiError) AllErrors() []error { return m }
// GetCommentsRspValidationError is the validation error returned by
// GetCommentsRsp.Validate if the designated constraints aren't met.
type GetCommentsRspValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e GetCommentsRspValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e GetCommentsRspValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e GetCommentsRspValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e GetCommentsRspValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e GetCommentsRspValidationError) ErrorName() string { return "GetCommentsRspValidationError" }
// Error satisfies the builtin error interface
func (e GetCommentsRspValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sGetCommentsRsp.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = GetCommentsRspValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = GetCommentsRspValidationError{}