user_post_entity.go 2.3 KB

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