diff --git a/drip/api.gen.go b/drip/api.gen.go index 8536f0f..e4262ca 100644 --- a/drip/api.gen.go +++ b/drip/api.gen.go @@ -35,6 +35,13 @@ const ( NodeStatusPending NodeStatus = "NodeStatusPending" ) +// Defines values for PublisherStatus. +const ( + PublisherStatusActive PublisherStatus = "PublisherStatusActive" + PublisherStatusBanned PublisherStatus = "PublisherStatusBanned" + PublisherStatusDeleted PublisherStatus = "PublisherStatusDeleted" +) + // ActionJobResult defines model for ActionJobResult. type ActionJobResult struct { // ActionRunId Identifier of the run this result belongs to @@ -192,6 +199,7 @@ type Publisher struct { Members *[]PublisherMember `json:"members,omitempty"` Name *string `json:"name,omitempty"` SourceCodeRepo *string `json:"source_code_repo,omitempty"` + Status *PublisherStatus `json:"status,omitempty"` Support *string `json:"support,omitempty"` Website *string `json:"website,omitempty"` } @@ -206,6 +214,9 @@ type PublisherMember struct { User *PublisherUser `json:"user,omitempty"` } +// PublisherStatus defines model for PublisherStatus. +type PublisherStatus string + // PublisherUser defines model for PublisherUser. type PublisherUser struct { // Email The email address for this user. @@ -3407,56 +3418,56 @@ var swaggerSpec = []string{ "QkLlrAWcI0MEWmmuUSQTdJeHdw8Pjpk+KuK3tdFB2Dy+d3phSIyL4hlIQ/OQHFGOcKZEsXmW1ly/4Ax0", "sYgdK2UHy9ziE2pWvxgQWxAJOpccmZljx3btwkMGceXb8N5oCgOo9AfuBUR38M+KVS8JGpIT/ZMi9Aua", "KUEookriEg7JxUzkaYILl4oFyJi24C0VU9HpZZSD/aQINg72Mgf0XToNkmtSeHTVHHwb1MvbOoXCUVq1", - "UAXCm06QyGUMo1gkUAb+zUZ5lgmpg88WMFZMt8Qd7ehzpDYweIc1d4wMLoMUaYsDjE8KuUaQBJeh0R+2", - "7L0sl9i4mx2XKsQMmFOWtqR98BGhSSJRP1heMGVmcLtYp0cf7VGEUY7rOggxwM8zNKaPcc4IA6BAjsUL", - "i4pwyOU37m47XEem4z7mw0AlHuUhJ82scIzeWT+G7AQQmDpM5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BdVn07liGxliWFS2PIWc1Z0oxPvX4YOvlzZI+zhROgWRcQtomDP52", - "WA8J/Fb+7aKBxHyi2TRy9tPNDiEKeORe33cUiVctFelm/pbkkOXZYg6wIudRust91bldZh9e7d5QW+D4", - "vUCyv22Xp9ireILeppFapbxWN9lWPe48gDH7zewWYfbdvfmtQzs3LP7TePNP0ripIbAy1scQdHkUjaLc", - "cN5bvRVyN6zGHcqs1qe+H13WZriLyK1lddqKmLpzOb2Ljx6ZVam2DLeXHuoseNqFpNCwtx3Z6dxMnCst", - "5l27lt1KvFbt1x0lPrj4DB5uQzRYumlK99qCzKc6vt2KbOslEkHT0B507Bi0v6eJ2VJN7Z8sUnnSJrsV", - "Hq3TJhsY1r0MpElLd5UKHYM+L5u942XU1PIl0G4Y3bvseMSU/5Iw/1CfjXYqvM1zj/tPu+cbpPM8xtUP", - "S/G/1L2HNEK4oK6lANW+vWkN0y5b7bpYcHf0bZ88Bba95aGvxQlvI3vC26g8G6778F6nLGsDt3V2FZTi", - "+w1wm7y7JT8Um3IIn3NpzsI2j4tDLvPMHXEJq0XZbid7/SE+TdMKi7KfAs07EX8/FVz08zycZnNR/a0q", - "3fop19U60fUx/05p2nBH91VEGkgjfCzO0eeVXD5zaYXnD7+DGILjx2aF50ZOcDGTYh7Pb1GEWYbbK5GR", - "dbAFT+1pxtVJt5Qn3jm0xB5/vfJZaWPsZl1QFc//2LB9mBRB8HTj75A26Ci/LuVxBxIIw6cMwlrNtbNJ", - "hLBqw9n5um3l+7VNjfxdcguPekf2KRvww2UDTHy05nuN5rHzavcLC0KH6W9YZxA8kv3HOpHCzXl37Ub9", - "u5XggjppC8mZgQ05pZxOYY7zXftlSwB1u1hyFxKeh04ltdyVYM7XhEW6LCskwlcl3C4HZFd4h2ovnnI/", - "t/nYJoSYbjnvYVX3vpl/+30NsGXFEI59Hb33n7CxDPzBCz8sE/5klR+3FB2br39BpWYTGuvu408uTePD", - "ou197evY86NHrRehjPP4C+jRmusC3Lf1tjFZzED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"vfmtQzs3LP7TePNP0ripIbAy1scQdHkUjaLccN5bvRVyN6zGHcqs1qe+H13WZriLyK1lddqKmLpzOb2L", + "jx6ZVam2DLeXHuoseNqFpNCwtx3Z6dxMnCst5l27lt1KvFbt1x0lPrj4DB5uQzRYumlK99qCzKc6vt2K", + "bOslEkHT0B507Bi0v6eJ2VJN7Z8sUnnSJrsVHq3TJhsY1r0MpElLd5UKHYM+L5u942XU1PIl0G4Y3bvs", + "eMSU/5Iw/yihjXYqvM1zj/tPu+cbpPM8xtUPS/G/1L2HNEK4oK6lANW+vWkN0y5b7bpYcHdSb588Bba9", + "5Rm1xYF0I3sg3ag8yq77rGGnLGsDt3V2FZTi+w1wm7y7JT8Um3IIH8tpju42j4szOfPMncgJq0XZbid7", + "/SE+TdMKi7KfAs07EX8/FVz08zycZnNR/a0q3fop19U60fUx/05p2nBH91VEGkgjfCyO/eeVXD5zaYXn", + "D7+DGILjx2aF50ZOcDGTYh7Pb1GEWYbbK5GRdbAFT+3hy9XBvJQn3rG5xJ5BufJZaWPsZl1QFc//2LB9", + "mBRB8DDm75A26Ci/LuVxBxIIw6cMwlrNtbNJhLBqw9n5um3l+7VNjfxdcguPekf2KRvww2UDTHy05nuN", + "5in5avcLC0Jn/29YZxA8Qf7HOpHCzXl37Ub9u5XggjppC8mZgQ05pZxOYY7zXftlSwB1u1hyFxKeh04l", + "tVztYM7XhEW6LCskwjc73C4HZFd4h2ovnnI/t/nYJoSYbjnvYVX3vpl/+30NsGXFEI59Hb33n7CxDPzB", + "Cz8sE/5klR+3FB2br39BpWYTGuvu408uTePDou197evY86NHrfe2jPP4C+jRmusC3Lf1tjFZzEDai3uE", + "vXHInWUu7R0S4VtKzZnKo1RM1Wgaq5b7LfybCt2pywRfGRKYDslUHeztWRpeIFl7+KjHdcG3usTXnddd", + "tLnN7b3+lauuO/fVmP1+H599in7//fffX5yevnjz5sOvvx6cnh5cXPzrU0Se/bz/8m8vXu6/eLn/YX//", + "wPzvX8+DdOQJbb9F9ihPqH8KWOP1bV4L/FmMRxtfzxu8h1f1vHm34LjMg1cLWgCbq2wrXAZvWcIFpEQB", + "miubR5b2rjdaHoetyPHRhcHvM/UcIeyLRwuEbZNB24Ofg3cJBS9Wfr/+UuW267nb2d/Ctm1fObzm3uC2", + "M/+D7rC/r2w4WcKyZJDBl3cHdV2j1CW/oU0GNZ27SnuNd57w3W7X+i6pr86LftfGDBeee0MkxMCuwW5N", + "F+aufnplx8GosjpZ6g6nvhsKysEVeeYL33MykWJur1xwZuWY6V/zMbEH6NsT4XPVdazHMWhzS9ED7kC4", + "e7oazH73j02/XWoeJvt28/26Y9At12LHNE2Lr6GHHvP8aKHn+ShvhbwPtj4dk/LYj0mpJXRz1ZHLNRjF", + "7m1EaC4YM7dFoY2kGRsaX3Io5DS6ubr5bwAAAP//cBhpWLeCAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/ent/migrate/migrations/20240614001941_migration.sql b/ent/migrate/migrations/20240614001941_migration.sql new file mode 100644 index 0000000..d420430 --- /dev/null +++ b/ent/migrate/migrations/20240614001941_migration.sql @@ -0,0 +1,2 @@ +-- Modify "publishers" table +ALTER TABLE "publishers" ADD COLUMN "status" character varying NOT NULL DEFAULT 'active'; diff --git a/ent/migrate/migrations/atlas.sum b/ent/migrate/migrations/atlas.sum index a3480f8..8a33061 100644 --- a/ent/migrate/migrations/atlas.sum +++ b/ent/migrate/migrations/atlas.sum @@ -1,7 +1,8 @@ -h1:2QXQ3z5rSkR97vRuWeBJ1mE+6Wxd3t8Gu+pvpiBI9hA= +h1:OgiKl98ZRvLrobZ10hFMunx6rgR3vdfqVcnun8f3gRA= 20240526144817_migration.sql h1:sP6keX+oMyLL2qpIFx0Ns0WYfWM5hJ4zkFPmLWT68fM= 20240528220411_migration.sql h1:SR44sOEaWbDgYCKJZIKcGCI7Ta+LqL71z225Nhs2+HM= 20240528221846_migration.sql h1:EkUonGI9Bu689qWX4pG3PRC+On4f6u7UvwDbaR8mCNk= 20240528222851_migration.sql h1:VaQhEaDGe8M2kuNtKVjuMWMLJ9RhJVraVgSM4rm/XcQ= 20240601211932_migration.sql h1:zTofjRbLfoZZF8k6dvAMUDJGRENHAG3m1qqtLgTXUCQ= 20240613231838_migration.sql h1:fbgEWDDA7hcQP5gdX6WDpPWG+340dT40CgkwIG7KGxw= +20240614001941_migration.sql h1:Lqzo8WsAsbS0yDD0Vwl9uWET5GpHljAUBIzvD3n/Sp0= diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 0b6baac..c8dfa9b 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -217,6 +217,7 @@ var ( {Name: "support_email", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, {Name: "source_code_repo", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, {Name: "logo_url", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, + {Name: "status", Type: field.TypeEnum, Enums: []string{"active", "banned", "deleted", "pending"}, Default: "active"}, } // PublishersTable holds the schema information for the "publishers" table. PublishersTable = &schema.Table{ diff --git a/ent/mutation.go b/ent/mutation.go index 66d2616..80494c2 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -5583,6 +5583,7 @@ type PublisherMutation struct { support_email *string source_code_repo *string logo_url *string + status *schema.PublisherStatus clearedFields map[string]struct{} publisher_permissions map[int]struct{} removedpublisher_permissions map[int]struct{} @@ -6055,6 +6056,42 @@ func (m *PublisherMutation) ResetLogoURL() { delete(m.clearedFields, publisher.FieldLogoURL) } +// SetStatus sets the "status" field. +func (m *PublisherMutation) SetStatus(ss schema.PublisherStatus) { + m.status = &ss +} + +// Status returns the value of the "status" field in the mutation. +func (m *PublisherMutation) Status() (r schema.PublisherStatus, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Publisher entity. +// If the Publisher object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PublisherMutation) OldStatus(ctx context.Context) (v schema.PublisherStatus, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// ResetStatus resets all changes to the "status" field. +func (m *PublisherMutation) ResetStatus() { + m.status = nil +} + // AddPublisherPermissionIDs adds the "publisher_permissions" edge to the PublisherPermission entity by ids. func (m *PublisherMutation) AddPublisherPermissionIDs(ids ...int) { if m.publisher_permissions == nil { @@ -6251,7 +6288,7 @@ func (m *PublisherMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PublisherMutation) Fields() []string { - fields := make([]string, 0, 8) + fields := make([]string, 0, 9) if m.create_time != nil { fields = append(fields, publisher.FieldCreateTime) } @@ -6276,6 +6313,9 @@ func (m *PublisherMutation) Fields() []string { if m.logo_url != nil { fields = append(fields, publisher.FieldLogoURL) } + if m.status != nil { + fields = append(fields, publisher.FieldStatus) + } return fields } @@ -6300,6 +6340,8 @@ func (m *PublisherMutation) Field(name string) (ent.Value, bool) { return m.SourceCodeRepo() case publisher.FieldLogoURL: return m.LogoURL() + case publisher.FieldStatus: + return m.Status() } return nil, false } @@ -6325,6 +6367,8 @@ func (m *PublisherMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldSourceCodeRepo(ctx) case publisher.FieldLogoURL: return m.OldLogoURL(ctx) + case publisher.FieldStatus: + return m.OldStatus(ctx) } return nil, fmt.Errorf("unknown Publisher field %s", name) } @@ -6390,6 +6434,13 @@ func (m *PublisherMutation) SetField(name string, value ent.Value) error { } m.SetLogoURL(v) return nil + case publisher.FieldStatus: + v, ok := value.(schema.PublisherStatus) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil } return fmt.Errorf("unknown Publisher field %s", name) } @@ -6496,6 +6547,9 @@ func (m *PublisherMutation) ResetField(name string) error { case publisher.FieldLogoURL: m.ResetLogoURL() return nil + case publisher.FieldStatus: + m.ResetStatus() + return nil } return fmt.Errorf("unknown Publisher field %s", name) } diff --git a/ent/publisher.go b/ent/publisher.go index 9c35eb8..0b6f14a 100644 --- a/ent/publisher.go +++ b/ent/publisher.go @@ -5,6 +5,7 @@ package ent import ( "fmt" "registry-backend/ent/publisher" + "registry-backend/ent/schema" "strings" "time" @@ -34,6 +35,8 @@ type Publisher struct { SourceCodeRepo string `json:"source_code_repo,omitempty"` // LogoURL holds the value of the "logo_url" field. LogoURL string `json:"logo_url,omitempty"` + // Status holds the value of the "status" field. + Status schema.PublisherStatus `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the PublisherQuery when eager-loading is set. Edges PublisherEdges `json:"edges"` @@ -85,7 +88,7 @@ func (*Publisher) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case publisher.FieldID, publisher.FieldName, publisher.FieldDescription, publisher.FieldWebsite, publisher.FieldSupportEmail, publisher.FieldSourceCodeRepo, publisher.FieldLogoURL: + case publisher.FieldID, publisher.FieldName, publisher.FieldDescription, publisher.FieldWebsite, publisher.FieldSupportEmail, publisher.FieldSourceCodeRepo, publisher.FieldLogoURL, publisher.FieldStatus: values[i] = new(sql.NullString) case publisher.FieldCreateTime, publisher.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -158,6 +161,12 @@ func (pu *Publisher) assignValues(columns []string, values []any) error { } else if value.Valid { pu.LogoURL = value.String } + case publisher.FieldStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + pu.Status = schema.PublisherStatus(value.String) + } default: pu.selectValues.Set(columns[i], values[i]) } @@ -232,6 +241,9 @@ func (pu *Publisher) String() string { builder.WriteString(", ") builder.WriteString("logo_url=") builder.WriteString(pu.LogoURL) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", pu.Status)) builder.WriteByte(')') return builder.String() } diff --git a/ent/publisher/publisher.go b/ent/publisher/publisher.go index a905a76..7011f7b 100644 --- a/ent/publisher/publisher.go +++ b/ent/publisher/publisher.go @@ -3,6 +3,8 @@ package publisher import ( + "fmt" + "registry-backend/ent/schema" "time" "entgo.io/ent/dialect/sql" @@ -30,6 +32,8 @@ const ( FieldSourceCodeRepo = "source_code_repo" // FieldLogoURL holds the string denoting the logo_url field in the database. FieldLogoURL = "logo_url" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" // EdgePublisherPermissions holds the string denoting the publisher_permissions edge name in mutations. EdgePublisherPermissions = "publisher_permissions" // EdgeNodes holds the string denoting the nodes edge name in mutations. @@ -72,6 +76,7 @@ var Columns = []string{ FieldSupportEmail, FieldSourceCodeRepo, FieldLogoURL, + FieldStatus, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -93,6 +98,18 @@ var ( UpdateDefaultUpdateTime func() time.Time ) +const DefaultStatus schema.PublisherStatus = "active" + +// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. +func StatusValidator(s schema.PublisherStatus) error { + switch s { + case "active", "banned", "deleted", "pending": + return nil + default: + return fmt.Errorf("publisher: invalid enum value for status field: %q", s) + } +} + // OrderOption defines the ordering options for the Publisher queries. type OrderOption func(*sql.Selector) @@ -141,6 +158,11 @@ func ByLogoURL(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLogoURL, opts...).ToFunc() } +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + // ByPublisherPermissionsCount orders the results by publisher_permissions count. func ByPublisherPermissionsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/ent/publisher/where.go b/ent/publisher/where.go index bb77b21..3e417e8 100644 --- a/ent/publisher/where.go +++ b/ent/publisher/where.go @@ -4,6 +4,7 @@ package publisher import ( "registry-backend/ent/predicate" + "registry-backend/ent/schema" "time" "entgo.io/ent/dialect/sql" @@ -625,6 +626,36 @@ func LogoURLContainsFold(v string) predicate.Publisher { return predicate.Publisher(sql.FieldContainsFold(FieldLogoURL, v)) } +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v schema.PublisherStatus) predicate.Publisher { + vc := v + return predicate.Publisher(sql.FieldEQ(FieldStatus, vc)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v schema.PublisherStatus) predicate.Publisher { + vc := v + return predicate.Publisher(sql.FieldNEQ(FieldStatus, vc)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...schema.PublisherStatus) predicate.Publisher { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Publisher(sql.FieldIn(FieldStatus, v...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...schema.PublisherStatus) predicate.Publisher { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Publisher(sql.FieldNotIn(FieldStatus, v...)) +} + // HasPublisherPermissions applies the HasEdge predicate on the "publisher_permissions" edge. func HasPublisherPermissions() predicate.Publisher { return predicate.Publisher(func(s *sql.Selector) { diff --git a/ent/publisher_create.go b/ent/publisher_create.go index 77be4ed..d652b9c 100644 --- a/ent/publisher_create.go +++ b/ent/publisher_create.go @@ -10,6 +10,7 @@ import ( "registry-backend/ent/personalaccesstoken" "registry-backend/ent/publisher" "registry-backend/ent/publisherpermission" + "registry-backend/ent/schema" "time" "entgo.io/ent/dialect" @@ -131,6 +132,20 @@ func (pc *PublisherCreate) SetNillableLogoURL(s *string) *PublisherCreate { return pc } +// SetStatus sets the "status" field. +func (pc *PublisherCreate) SetStatus(ss schema.PublisherStatus) *PublisherCreate { + pc.mutation.SetStatus(ss) + return pc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (pc *PublisherCreate) SetNillableStatus(ss *schema.PublisherStatus) *PublisherCreate { + if ss != nil { + pc.SetStatus(*ss) + } + return pc +} + // SetID sets the "id" field. func (pc *PublisherCreate) SetID(s string) *PublisherCreate { pc.mutation.SetID(s) @@ -225,6 +240,10 @@ func (pc *PublisherCreate) defaults() { v := publisher.DefaultUpdateTime() pc.mutation.SetUpdateTime(v) } + if _, ok := pc.mutation.Status(); !ok { + v := publisher.DefaultStatus + pc.mutation.SetStatus(v) + } } // check runs all checks and user-defined validators on the builder. @@ -238,6 +257,14 @@ func (pc *PublisherCreate) check() error { if _, ok := pc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Publisher.name"`)} } + if _, ok := pc.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Publisher.status"`)} + } + if v, ok := pc.mutation.Status(); ok { + if err := publisher.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Publisher.status": %w`, err)} + } + } return nil } @@ -306,6 +333,10 @@ func (pc *PublisherCreate) createSpec() (*Publisher, *sqlgraph.CreateSpec) { _spec.SetField(publisher.FieldLogoURL, field.TypeString, value) _node.LogoURL = value } + if value, ok := pc.mutation.Status(); ok { + _spec.SetField(publisher.FieldStatus, field.TypeEnum, value) + _node.Status = value + } if nodes := pc.mutation.PublisherPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -520,6 +551,18 @@ func (u *PublisherUpsert) ClearLogoURL() *PublisherUpsert { return u } +// SetStatus sets the "status" field. +func (u *PublisherUpsert) SetStatus(v schema.PublisherStatus) *PublisherUpsert { + u.Set(publisher.FieldStatus, v) + return u +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *PublisherUpsert) UpdateStatus() *PublisherUpsert { + u.SetExcluded(publisher.FieldStatus) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -704,6 +747,20 @@ func (u *PublisherUpsertOne) ClearLogoURL() *PublisherUpsertOne { }) } +// SetStatus sets the "status" field. +func (u *PublisherUpsertOne) SetStatus(v schema.PublisherStatus) *PublisherUpsertOne { + return u.Update(func(s *PublisherUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *PublisherUpsertOne) UpdateStatus() *PublisherUpsertOne { + return u.Update(func(s *PublisherUpsert) { + s.UpdateStatus() + }) +} + // Exec executes the query. func (u *PublisherUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1055,6 +1112,20 @@ func (u *PublisherUpsertBulk) ClearLogoURL() *PublisherUpsertBulk { }) } +// SetStatus sets the "status" field. +func (u *PublisherUpsertBulk) SetStatus(v schema.PublisherStatus) *PublisherUpsertBulk { + return u.Update(func(s *PublisherUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *PublisherUpsertBulk) UpdateStatus() *PublisherUpsertBulk { + return u.Update(func(s *PublisherUpsert) { + s.UpdateStatus() + }) +} + // Exec executes the query. func (u *PublisherUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/ent/publisher_update.go b/ent/publisher_update.go index 652a361..1d61136 100644 --- a/ent/publisher_update.go +++ b/ent/publisher_update.go @@ -11,6 +11,7 @@ import ( "registry-backend/ent/predicate" "registry-backend/ent/publisher" "registry-backend/ent/publisherpermission" + "registry-backend/ent/schema" "time" "entgo.io/ent/dialect/sql" @@ -152,6 +153,20 @@ func (pu *PublisherUpdate) ClearLogoURL() *PublisherUpdate { return pu } +// SetStatus sets the "status" field. +func (pu *PublisherUpdate) SetStatus(ss schema.PublisherStatus) *PublisherUpdate { + pu.mutation.SetStatus(ss) + return pu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (pu *PublisherUpdate) SetNillableStatus(ss *schema.PublisherStatus) *PublisherUpdate { + if ss != nil { + pu.SetStatus(*ss) + } + return pu +} + // AddPublisherPermissionIDs adds the "publisher_permissions" edge to the PublisherPermission entity by IDs. func (pu *PublisherUpdate) AddPublisherPermissionIDs(ids ...int) *PublisherUpdate { pu.mutation.AddPublisherPermissionIDs(ids...) @@ -301,7 +316,20 @@ func (pu *PublisherUpdate) defaults() { } } +// check runs all checks and user-defined validators on the builder. +func (pu *PublisherUpdate) check() error { + if v, ok := pu.mutation.Status(); ok { + if err := publisher.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Publisher.status": %w`, err)} + } + } + return nil +} + func (pu *PublisherUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := pu.check(); err != nil { + return n, err + } _spec := sqlgraph.NewUpdateSpec(publisher.Table, publisher.Columns, sqlgraph.NewFieldSpec(publisher.FieldID, field.TypeString)) if ps := pu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { @@ -346,6 +374,9 @@ func (pu *PublisherUpdate) sqlSave(ctx context.Context) (n int, err error) { if pu.mutation.LogoURLCleared() { _spec.ClearField(publisher.FieldLogoURL, field.TypeString) } + if value, ok := pu.mutation.Status(); ok { + _spec.SetField(publisher.FieldStatus, field.TypeEnum, value) + } if pu.mutation.PublisherPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -621,6 +652,20 @@ func (puo *PublisherUpdateOne) ClearLogoURL() *PublisherUpdateOne { return puo } +// SetStatus sets the "status" field. +func (puo *PublisherUpdateOne) SetStatus(ss schema.PublisherStatus) *PublisherUpdateOne { + puo.mutation.SetStatus(ss) + return puo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (puo *PublisherUpdateOne) SetNillableStatus(ss *schema.PublisherStatus) *PublisherUpdateOne { + if ss != nil { + puo.SetStatus(*ss) + } + return puo +} + // AddPublisherPermissionIDs adds the "publisher_permissions" edge to the PublisherPermission entity by IDs. func (puo *PublisherUpdateOne) AddPublisherPermissionIDs(ids ...int) *PublisherUpdateOne { puo.mutation.AddPublisherPermissionIDs(ids...) @@ -783,7 +828,20 @@ func (puo *PublisherUpdateOne) defaults() { } } +// check runs all checks and user-defined validators on the builder. +func (puo *PublisherUpdateOne) check() error { + if v, ok := puo.mutation.Status(); ok { + if err := publisher.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Publisher.status": %w`, err)} + } + } + return nil +} + func (puo *PublisherUpdateOne) sqlSave(ctx context.Context) (_node *Publisher, err error) { + if err := puo.check(); err != nil { + return _node, err + } _spec := sqlgraph.NewUpdateSpec(publisher.Table, publisher.Columns, sqlgraph.NewFieldSpec(publisher.FieldID, field.TypeString)) id, ok := puo.mutation.ID() if !ok { @@ -845,6 +903,9 @@ func (puo *PublisherUpdateOne) sqlSave(ctx context.Context) (_node *Publisher, e if puo.mutation.LogoURLCleared() { _spec.ClearField(publisher.FieldLogoURL, field.TypeString) } + if value, ok := puo.mutation.Status(); ok { + _spec.SetField(publisher.FieldStatus, field.TypeEnum, value) + } if puo.mutation.PublisherPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/schema/publisher.go b/ent/schema/publisher.go index 95c4e98..92c854c 100644 --- a/ent/schema/publisher.go +++ b/ent/schema/publisher.go @@ -36,6 +36,9 @@ func (Publisher) Fields() []ent.Field { field.String("logo_url").Optional().SchemaType(map[string]string{ dialect.Postgres: "text", }).Optional(), + field.Enum("status"). + GoType(PublisherStatus("")). + Default(string(PublisherStatusActive)), } } @@ -52,3 +55,21 @@ func (Publisher) Edges() []ent.Edge { edge.To("personal_access_tokens", PersonalAccessToken.Type), } } + +type PublisherStatus string + +const ( + PublisherStatusActive PublisherStatus = "active" + PublisherStatusPending PublisherStatus = "pending" + PublisherStatusDeleted PublisherStatus = "deleted" + PublisherStatusBanned PublisherStatus = "banned" +) + +func (PublisherStatus) Values() (types []string) { + return []string{ + string(PublisherStatusActive), + string(PublisherStatusBanned), + string(PublisherStatusDeleted), + string(PublisherStatusPending), + } +} diff --git a/integration-tests/registry_integration_test.go b/integration-tests/registry_integration_test.go index b4e1265..27fb1f9 100644 --- a/integration-tests/registry_integration_test.go +++ b/integration-tests/registry_integration_test.go @@ -53,6 +53,7 @@ func TestRegistry(t *testing.T) { support := "test-support" logo := "test-logo" name := "test-name" + status := drip.PublisherStatusActive t.Run("Create Publisher", func(t *testing.T) { createPublisherResponse, err := impl.CreatePublisher(ctx, drip.CreatePublisherRequestObject{ @@ -74,6 +75,9 @@ func TestRegistry(t *testing.T) { assert.Equal(t, website, *createPublisherResponse.(drip.CreatePublisher201JSONResponse).Website) assert.Equal(t, support, *createPublisherResponse.(drip.CreatePublisher201JSONResponse).Support) assert.Equal(t, logo, *createPublisherResponse.(drip.CreatePublisher201JSONResponse).Logo) + assert.Equal(t, name, *createPublisherResponse.(drip.CreatePublisher201JSONResponse).Name) + assert.Equal(t, drip.PublisherStatusActive, *createPublisherResponse.(drip.CreatePublisher201JSONResponse).Status) + }) t.Run("Validate Publisher", func(t *testing.T) { @@ -129,7 +133,7 @@ func TestRegistry(t *testing.T) { Support: &support, Logo: &logo, Name: &name, - + Status: &status, // generated thus ignored in comparison Members: res200[0].Members, CreatedAt: res200[0].CreatedAt, diff --git a/mapper/publisher.go b/mapper/publisher.go index 6a02a00..0308f67 100644 --- a/mapper/publisher.go +++ b/mapper/publisher.go @@ -5,6 +5,7 @@ import ( "regexp" "registry-backend/drip" "registry-backend/ent" + "registry-backend/ent/schema" ) func ApiCreatePublisherToDb(publisher *drip.Publisher, client *ent.Client) (*ent.PublisherCreate, error) { @@ -112,9 +113,27 @@ func DbPublisherToApiPublisher(publisher *ent.Publisher, public bool) *drip.Publ Website: &publisher.Website, CreatedAt: &publisher.CreateTime, Members: &members, + Status: DbPublisherStatusToApiPublisherStatus(publisher.Status), } } func ToStringPointer(s string) *string { return &s } + +func DbPublisherStatusToApiPublisherStatus(status schema.PublisherStatus) *drip.PublisherStatus { + var publisherStatus drip.PublisherStatus + + switch status { + case schema.PublisherStatusActive: + publisherStatus = drip.PublisherStatusActive + case schema.PublisherStatusBanned: + publisherStatus = drip.PublisherStatusBanned + case schema.PublisherStatusDeleted: + publisherStatus = drip.PublisherStatusDeleted + default: + publisherStatus = "" + } + + return &publisherStatus +} diff --git a/openapi.yml b/openapi.yml index ca0e086..ddd0d7f 100644 --- a/openapi.yml +++ b/openapi.yml @@ -1488,6 +1488,9 @@ components: items: $ref: "#/components/schemas/PublisherMember" description: A list of members in the publisher. + status: + $ref: "#/components/schemas/PublisherStatus" + description: The status of the publisher. PublisherMember: type: object properties: @@ -1596,6 +1599,12 @@ components: - NodeStatusDeleted - NodeStatusBanned - NodeStatusPending + PublisherStatus: + type: string + enum: + - PublisherStatusActive + - PublisherStatusDeleted + - PublisherStatusBanned securitySchemes: BearerAuth: type: http