casbin_rule_entity.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // Replace does "REPLACE...INTO..." statement for inserting current object into table.
  29. // If there's already another same record in the table (it checks using primary key or unique index),
  30. // it deletes it and insert this one.
  31. func (r *Entity) Replace() (result sql.Result, err error) {
  32. return Model.Data(r).Replace()
  33. }
  34. // Save does "INSERT...INTO..." statement for inserting/updating current object into table.
  35. // It updates the record if there's already another same record in the table
  36. // (it checks using primary key or unique index).
  37. func (r *Entity) Save() (result sql.Result, err error) {
  38. return Model.Data(r).Save()
  39. }
  40. // Update does "UPDATE...WHERE..." statement for updating current object from table.
  41. // It updates the record if there's already another same record in the table
  42. // (it checks using primary key or unique index).
  43. func (r *Entity) Update() (result sql.Result, err error) {
  44. return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
  45. }
  46. // Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
  47. func (r *Entity) Delete() (result sql.Result, err error) {
  48. return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
  49. }