test card url
This commit is contained in:
@ -142,6 +142,26 @@ func (cu *CardUpdate) ClearCp() *CardUpdate {
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (cu *CardUpdate) SetURL(s string) *CardUpdate {
|
||||
cu.mutation.SetURL(s)
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (cu *CardUpdate) SetNillableURL(s *string) *CardUpdate {
|
||||
if s != nil {
|
||||
cu.SetURL(*s)
|
||||
}
|
||||
return cu
|
||||
}
|
||||
|
||||
// ClearURL clears the value of the "url" field.
|
||||
func (cu *CardUpdate) ClearURL() *CardUpdate {
|
||||
cu.mutation.ClearURL()
|
||||
return cu
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
|
||||
cu.mutation.SetOwnerID(id)
|
||||
@ -247,6 +267,9 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if cu.mutation.CpCleared() {
|
||||
_spec.ClearField(card.FieldCp, field.TypeInt)
|
||||
}
|
||||
if value, ok := cu.mutation.URL(); ok {
|
||||
_spec.SetField(card.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if cu.mutation.URLCleared() {
|
||||
_spec.ClearField(card.FieldURL, field.TypeString)
|
||||
}
|
||||
@ -416,6 +439,26 @@ func (cuo *CardUpdateOne) ClearCp() *CardUpdateOne {
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (cuo *CardUpdateOne) SetURL(s string) *CardUpdateOne {
|
||||
cuo.mutation.SetURL(s)
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (cuo *CardUpdateOne) SetNillableURL(s *string) *CardUpdateOne {
|
||||
if s != nil {
|
||||
cuo.SetURL(*s)
|
||||
}
|
||||
return cuo
|
||||
}
|
||||
|
||||
// ClearURL clears the value of the "url" field.
|
||||
func (cuo *CardUpdateOne) ClearURL() *CardUpdateOne {
|
||||
cuo.mutation.ClearURL()
|
||||
return cuo
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
||||
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
|
||||
cuo.mutation.SetOwnerID(id)
|
||||
@ -551,6 +594,9 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error)
|
||||
if cuo.mutation.CpCleared() {
|
||||
_spec.ClearField(card.FieldCp, field.TypeInt)
|
||||
}
|
||||
if value, ok := cuo.mutation.URL(); ok {
|
||||
_spec.SetField(card.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if cuo.mutation.URLCleared() {
|
||||
_spec.ClearField(card.FieldURL, field.TypeString)
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ var (
|
||||
{Name: "ten_post", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_get", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ten_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230801"},
|
||||
{Name: "next", Type: field.TypeString, Nullable: true, Default: "20230811"},
|
||||
{Name: "group_users", Type: field.TypeInt, Nullable: true},
|
||||
}
|
||||
// UsersTable holds the schema information for the "users" table.
|
||||
|
@ -4496,6 +4496,12 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) {
|
||||
s.Cp.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.URL.Set {
|
||||
e.FieldStart("url")
|
||||
s.URL.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Owner.Set {
|
||||
e.FieldStart("owner")
|
||||
@ -4504,13 +4510,14 @@ func (s *UpdateCardReq) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfUpdateCardReq = [6]string{
|
||||
var jsonFieldsNameOfUpdateCardReq = [7]string{
|
||||
0: "card",
|
||||
1: "skill",
|
||||
2: "status",
|
||||
3: "token",
|
||||
4: "cp",
|
||||
5: "owner",
|
||||
5: "url",
|
||||
6: "owner",
|
||||
}
|
||||
|
||||
// Decode decodes UpdateCardReq from json.
|
||||
@ -4571,6 +4578,16 @@ func (s *UpdateCardReq) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"cp\"")
|
||||
}
|
||||
case "url":
|
||||
if err := func() error {
|
||||
s.URL.Reset()
|
||||
if err := s.URL.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"url\"")
|
||||
}
|
||||
case "owner":
|
||||
if err := func() error {
|
||||
s.Owner.Reset()
|
||||
|
@ -2092,6 +2092,7 @@ type UpdateCardReq struct {
|
||||
Status OptString `json:"status"`
|
||||
Token OptString `json:"token"`
|
||||
Cp OptInt `json:"cp"`
|
||||
URL OptString `json:"url"`
|
||||
Owner OptInt `json:"owner"`
|
||||
}
|
||||
|
||||
@ -2120,6 +2121,11 @@ func (s *UpdateCardReq) GetCp() OptInt {
|
||||
return s.Cp
|
||||
}
|
||||
|
||||
// GetURL returns the value of URL.
|
||||
func (s *UpdateCardReq) GetURL() OptString {
|
||||
return s.URL
|
||||
}
|
||||
|
||||
// GetOwner returns the value of Owner.
|
||||
func (s *UpdateCardReq) GetOwner() OptInt {
|
||||
return s.Owner
|
||||
@ -2150,6 +2156,11 @@ func (s *UpdateCardReq) SetCp(val OptInt) {
|
||||
s.Cp = val
|
||||
}
|
||||
|
||||
// SetURL sets the value of URL.
|
||||
func (s *UpdateCardReq) SetURL(val OptString) {
|
||||
s.URL = val
|
||||
}
|
||||
|
||||
// SetOwner sets the value of Owner.
|
||||
func (s *UpdateCardReq) SetOwner(val OptInt) {
|
||||
s.Owner = val
|
||||
|
@ -131,6 +131,9 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
if v, ok := req.Skill.Get(); ok {
|
||||
b.SetSkill(v)
|
||||
}
|
||||
if v, ok := req.URL.Get(); ok {
|
||||
b.SetURL(v)
|
||||
}
|
||||
if v, ok := req.Status.Get(); ok {
|
||||
b.SetStatus(v)
|
||||
}
|
||||
@ -182,8 +185,8 @@ func (h *OgentHandler) UpdateCard(ctx context.Context, req *UpdateCardReq, param
|
||||
|
||||
// DeleteCard handles DELETE /cards/{id} requests.
|
||||
func (h *OgentHandler) DeleteCard(ctx context.Context, params DeleteCardParams) (DeleteCardRes, error) {
|
||||
err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
//err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
//err := h.client.Card.DeleteOneID(0).Exec(ctx)
|
||||
err := h.client.Card.DeleteOneID(params.ID).Exec(ctx)
|
||||
if err != nil {
|
||||
switch {
|
||||
case ent.IsNotFound(err):
|
||||
|
@ -258,6 +258,9 @@
|
||||
"cp": {
|
||||
"type": "integer"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"owner": {
|
||||
"type": "integer"
|
||||
}
|
||||
|
@ -131,7 +131,6 @@ func (Card) Fields() []ent.Field {
|
||||
Optional(),
|
||||
|
||||
field.String("url").
|
||||
Immutable().
|
||||
Default(url).
|
||||
Optional(),
|
||||
|
||||
|
Reference in New Issue
Block a user