gen_table_entity.go 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. You may not really want to edit it.
  3. // ==========================================================================
  4. package gen_table
  5. import (
  6. "database/sql"
  7. "github.com/gogf/gf/database/gdb"
  8. "github.com/gogf/gf/os/gtime"
  9. )
  10. // Entity is the golang structure for table gen_table.
  11. type Entity struct {
  12. TableId int64 `orm:"table_id,primary" json:"table_id"` // 编号
  13. TableName string `orm:"table_name" json:"table_name"` // 表名称
  14. TableComment string `orm:"table_comment" json:"table_comment"` // 表描述
  15. ClassName string `orm:"class_name" json:"class_name"` // 实体类名称
  16. TplCategory string `orm:"tpl_category" json:"tpl_category"` // 使用的模板(crud单表操作 tree树表操作)
  17. PackageName string `orm:"package_name" json:"package_name"` // 生成包路径
  18. ModuleName string `orm:"module_name" json:"module_name"` // 生成模块名
  19. BusinessName string `orm:"business_name" json:"business_name"` // 生成业务名
  20. FunctionName string `orm:"function_name" json:"function_name"` // 生成功能名
  21. FunctionAuthor string `orm:"function_author" json:"function_author"` // 生成功能作者
  22. Options string `orm:"options" json:"options"` // 其它生成选项
  23. CreateBy string `orm:"create_by" json:"create_by"` // 创建者
  24. CreateTime *gtime.Time `orm:"create_time" json:"create_time"` // 创建时间
  25. UpdateBy string `orm:"update_by" json:"update_by"` // 更新者
  26. UpdateTime *gtime.Time `orm:"update_time" json:"update_time"` // 更新时间
  27. Remark string `orm:"remark" json:"remark"` // 备注
  28. }
  29. //修改页面请求参数
  30. type EditReq struct {
  31. TableId int64 `p:"tableId" v:"required#主键ID不能为空"`
  32. TableName string `p:"tableName" v:"required#表名称不能为空"`
  33. TableComment string `p:"tableComment" v:"required#表描述不能为空"`
  34. ClassName string `p:"className" v:"required#实体类名称不能为空"`
  35. FunctionAuthor string `p:"functionAuthor" v:"required#作者不能为空"`
  36. TplCategory string `p:"tplCategory"`
  37. PackageName string `p:"packageName" v:"required#生成包路径不能为空"`
  38. ModuleName string `p:"moduleName" v:"required#生成模块名不能为空"`
  39. BusinessName string `p:"businessName" v:"required#生成业务名不能为空"`
  40. FunctionName string `p:"functionName" v:"required#生成功能名不能为空"`
  41. Remark string `p:"remark"`
  42. Params string `p:"params"`
  43. Columns string `p:"columns"`
  44. TreeCode string `p:"tree_code"`
  45. TreeParentCode string `p:"tree_parent_code"`
  46. TreeName string `p:"tree_name"`
  47. UserName string
  48. }
  49. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  50. // the data and where attributes for empty values.
  51. func (r *Entity) OmitEmpty() *arModel {
  52. return Model.Data(r).OmitEmpty()
  53. }
  54. // Inserts does "INSERT...INTO..." statement for inserting current object into table.
  55. func (r *Entity) Insert() (result sql.Result, err error) {
  56. return Model.Data(r).Insert()
  57. }
  58. // InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
  59. func (r *Entity) InsertIgnore() (result sql.Result, err error) {
  60. return Model.Data(r).InsertIgnore()
  61. }
  62. // Replace does "REPLACE...INTO..." statement for inserting current object into table.
  63. // If there's already another same record in the table (it checks using primary key or unique index),
  64. // it deletes it and insert this one.
  65. func (r *Entity) Replace() (result sql.Result, err error) {
  66. return Model.Data(r).Replace()
  67. }
  68. // Save does "INSERT...INTO..." statement for inserting/updating current object into table.
  69. // It updates the record if there's already another same record in the table
  70. // (it checks using primary key or unique index).
  71. func (r *Entity) Save() (result sql.Result, err error) {
  72. return Model.Data(r).Save()
  73. }
  74. // Update does "UPDATE...WHERE..." statement for updating current object from table.
  75. // It updates the record if there's already another same record in the table
  76. // (it checks using primary key or unique index).
  77. func (r *Entity) Update() (result sql.Result, err error) {
  78. return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
  79. }
  80. // Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
  81. func (r *Entity) Delete() (result sql.Result, err error) {
  82. return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
  83. }