casbin_rule_entity.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. You may not really want to edit it.
  3. // ==========================================================================
  4. package casbin_rule
  5. import (
  6. "database/sql"
  7. "github.com/gogf/gf/database/gdb"
  8. )
  9. // Entity is the golang structure for table casbin_rule.
  10. type Entity struct {
  11. Ptype string `orm:"ptype" json:"ptype"` //
  12. V0 string `orm:"v0" json:"v_0"` //
  13. V1 string `orm:"v1" json:"v_1"` //
  14. V2 string `orm:"v2" json:"v_2"` //
  15. V3 string `orm:"v3" json:"v_3"` //
  16. V4 string `orm:"v4" json:"v_4"` //
  17. V5 string `orm:"v5" json:"v_5"` //
  18. }
  19. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  20. // the data and where attributes for empty values.
  21. func (r *Entity) OmitEmpty() *arModel {
  22. return Model.Data(r).OmitEmpty()
  23. }
  24. // Inserts does "INSERT...INTO..." statement for inserting current object into table.
  25. func (r *Entity) Insert() (result sql.Result, err error) {
  26. return Model.Data(r).Insert()
  27. }
  28. // InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
  29. func (r *Entity) InsertIgnore() (result sql.Result, err error) {
  30. return Model.Data(r).InsertIgnore()
  31. }
  32. // Replace does "REPLACE...INTO..." statement for inserting current object into table.
  33. // If there's already another same record in the table (it checks using primary key or unique index),
  34. // it deletes it and insert this one.
  35. func (r *Entity) Replace() (result sql.Result, err error) {
  36. return Model.Data(r).Replace()
  37. }
  38. // Save does "INSERT...INTO..." statement for inserting/updating current object into table.
  39. // It updates the record if there's already another same record in the table
  40. // (it checks using primary key or unique index).
  41. func (r *Entity) Save() (result sql.Result, err error) {
  42. return Model.Data(r).Save()
  43. }
  44. // Update does "UPDATE...WHERE..." statement for updating current object from table.
  45. // It updates the record if there's already another same record in the table
  46. // (it checks using primary key or unique index).
  47. func (r *Entity) Update() (result sql.Result, err error) {
  48. return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
  49. }
  50. // Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
  51. func (r *Entity) Delete() (result sql.Result, err error) {
  52. return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
  53. }