base_region_auth.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "database/sql"
  8. "github.com/gogf/gf/database/gdb"
  9. "github.com/gogf/gf/frame/g"
  10. "github.com/gogf/gf/frame/gmvc"
  11. "time"
  12. "dashoo.cn/micro/app/model"
  13. )
  14. // BaseRegionAuthDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type BaseRegionAuthDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns baseRegionAuthColumns
  21. }
  22. // BaseRegionAuthColumns defines and stores column names for table base_region_auth.
  23. type baseRegionAuthColumns struct {
  24. Id string // 主键
  25. UserId string // 用户ID
  26. UserName string // 姓名
  27. UserPost string // 岗位
  28. UserPhone string // 电话
  29. SaleRegionId string // 销售区域ID
  30. SaleRegionName string // 销售区域名称
  31. ProvinceId string // 省ID
  32. ProvinceName string // 省名称
  33. CityId string // 市ID
  34. CityName string // 市名称
  35. Remark string // 备注
  36. CreatedBy string // 创建者
  37. CreatedName string // 创建人
  38. CreatedTime string // 创建时间
  39. UpdatedBy string // 更新者
  40. UpdatedName string // 更新人
  41. UpdatedTime string // 更新时间
  42. DeletedTime string // 删除时间
  43. }
  44. var (
  45. // BaseRegionAuth is globally public accessible object for table base_region_auth operations.
  46. BaseRegionAuth = BaseRegionAuthDao{
  47. M: g.DB("default").Model("base_region_auth").Safe(),
  48. DB: g.DB("default"),
  49. Table: "base_region_auth",
  50. Columns: baseRegionAuthColumns{
  51. Id: "id",
  52. UserId: "user_id",
  53. UserName: "user_name",
  54. UserPost: "user_post",
  55. UserPhone: "user_phone",
  56. SaleRegionId: "sale_region_id",
  57. SaleRegionName: "sale_region_name",
  58. ProvinceId: "province_id",
  59. ProvinceName: "province_name",
  60. CityId: "city_id",
  61. CityName: "city_name",
  62. Remark: "remark",
  63. CreatedBy: "created_by",
  64. CreatedName: "created_name",
  65. CreatedTime: "created_time",
  66. UpdatedBy: "updated_by",
  67. UpdatedName: "updated_name",
  68. UpdatedTime: "updated_time",
  69. DeletedTime: "deleted_time",
  70. },
  71. }
  72. )
  73. func NewBaseRegionAuthDao(tenant string) BaseRegionAuthDao {
  74. var dao BaseRegionAuthDao
  75. dao = BaseRegionAuthDao{
  76. M: g.DB(tenant).Model("base_region_auth").Safe(),
  77. DB: g.DB(tenant),
  78. Table: "base_region_auth",
  79. Columns: baseRegionAuthColumns{
  80. Id: "id",
  81. UserId: "user_id",
  82. UserName: "user_name",
  83. UserPost: "user_post",
  84. UserPhone: "user_phone",
  85. SaleRegionId: "sale_region_id",
  86. SaleRegionName: "sale_region_name",
  87. ProvinceId: "province_id",
  88. ProvinceName: "province_name",
  89. CityId: "city_id",
  90. CityName: "city_name",
  91. Remark: "remark",
  92. CreatedBy: "created_by",
  93. CreatedName: "created_name",
  94. CreatedTime: "created_time",
  95. UpdatedBy: "updated_by",
  96. UpdatedName: "updated_name",
  97. UpdatedTime: "updated_time",
  98. DeletedTime: "deleted_time",
  99. },
  100. }
  101. return dao
  102. }
  103. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  104. // of current DB object and with given context in it.
  105. // Note that this returned DB object can be used only once, so do not assign it to
  106. // a global or package variable for long using.
  107. func (d *BaseRegionAuthDao) Ctx(ctx context.Context) *BaseRegionAuthDao {
  108. return &BaseRegionAuthDao{M: d.M.Ctx(ctx)}
  109. }
  110. // As sets an alias name for current table.
  111. func (d *BaseRegionAuthDao) As(as string) *BaseRegionAuthDao {
  112. return &BaseRegionAuthDao{M: d.M.As(as)}
  113. }
  114. // TX sets the transaction for current operation.
  115. func (d *BaseRegionAuthDao) TX(tx *gdb.TX) *BaseRegionAuthDao {
  116. return &BaseRegionAuthDao{M: d.M.TX(tx)}
  117. }
  118. // Master marks the following operation on master node.
  119. func (d *BaseRegionAuthDao) Master() *BaseRegionAuthDao {
  120. return &BaseRegionAuthDao{M: d.M.Master()}
  121. }
  122. // Slave marks the following operation on slave node.
  123. // Note that it makes sense only if there's any slave node configured.
  124. func (d *BaseRegionAuthDao) Slave() *BaseRegionAuthDao {
  125. return &BaseRegionAuthDao{M: d.M.Slave()}
  126. }
  127. // Args sets custom arguments for model operation.
  128. func (d *BaseRegionAuthDao) Args(args ...interface{}) *BaseRegionAuthDao {
  129. return &BaseRegionAuthDao{M: d.M.Args(args...)}
  130. }
  131. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  132. // The parameter <table> can be joined table and its joined condition,
  133. // and also with its alias name, like:
  134. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  135. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  136. func (d *BaseRegionAuthDao) LeftJoin(table ...string) *BaseRegionAuthDao {
  137. return &BaseRegionAuthDao{M: d.M.LeftJoin(table...)}
  138. }
  139. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  140. // The parameter <table> can be joined table and its joined condition,
  141. // and also with its alias name, like:
  142. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  143. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  144. func (d *BaseRegionAuthDao) RightJoin(table ...string) *BaseRegionAuthDao {
  145. return &BaseRegionAuthDao{M: d.M.RightJoin(table...)}
  146. }
  147. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  148. // The parameter <table> can be joined table and its joined condition,
  149. // and also with its alias name, like:
  150. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  151. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  152. func (d *BaseRegionAuthDao) InnerJoin(table ...string) *BaseRegionAuthDao {
  153. return &BaseRegionAuthDao{M: d.M.InnerJoin(table...)}
  154. }
  155. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  156. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  157. func (d *BaseRegionAuthDao) Fields(fieldNamesOrMapStruct ...interface{}) *BaseRegionAuthDao {
  158. return &BaseRegionAuthDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  159. }
  160. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  161. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  162. func (d *BaseRegionAuthDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *BaseRegionAuthDao {
  163. return &BaseRegionAuthDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  164. }
  165. // Option sets the extra operation option for the model.
  166. func (d *BaseRegionAuthDao) Option(option int) *BaseRegionAuthDao {
  167. return &BaseRegionAuthDao{M: d.M.Option(option)}
  168. }
  169. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  170. // the data and where attributes for empty values.
  171. func (d *BaseRegionAuthDao) OmitEmpty() *BaseRegionAuthDao {
  172. return &BaseRegionAuthDao{M: d.M.OmitEmpty()}
  173. }
  174. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  175. func (d *BaseRegionAuthDao) Filter() *BaseRegionAuthDao {
  176. return &BaseRegionAuthDao{M: d.M.Filter()}
  177. }
  178. // Where sets the condition statement for the model. The parameter <where> can be type of
  179. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  180. // multiple conditions will be joined into where statement using "AND".
  181. // Eg:
  182. // Where("uid=10000")
  183. // Where("uid", 10000)
  184. // Where("money>? AND name like ?", 99999, "vip_%")
  185. // Where("uid", 1).Where("name", "john")
  186. // Where("status IN (?)", g.Slice{1,2,3})
  187. // Where("age IN(?,?)", 18, 50)
  188. // Where(User{ Id : 1, UserName : "john"})
  189. func (d *BaseRegionAuthDao) Where(where interface{}, args ...interface{}) *BaseRegionAuthDao {
  190. return &BaseRegionAuthDao{M: d.M.Where(where, args...)}
  191. }
  192. // WherePri does the same logic as M.Where except that if the parameter <where>
  193. // is a single condition like int/string/float/slice, it treats the condition as the primary
  194. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  195. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  196. // as string "123".
  197. func (d *BaseRegionAuthDao) WherePri(where interface{}, args ...interface{}) *BaseRegionAuthDao {
  198. return &BaseRegionAuthDao{M: d.M.WherePri(where, args...)}
  199. }
  200. // And adds "AND" condition to the where statement.
  201. func (d *BaseRegionAuthDao) And(where interface{}, args ...interface{}) *BaseRegionAuthDao {
  202. return &BaseRegionAuthDao{M: d.M.And(where, args...)}
  203. }
  204. // Or adds "OR" condition to the where statement.
  205. func (d *BaseRegionAuthDao) Or(where interface{}, args ...interface{}) *BaseRegionAuthDao {
  206. return &BaseRegionAuthDao{M: d.M.Or(where, args...)}
  207. }
  208. // Group sets the "GROUP BY" statement for the model.
  209. func (d *BaseRegionAuthDao) Group(groupBy string) *BaseRegionAuthDao {
  210. return &BaseRegionAuthDao{M: d.M.Group(groupBy)}
  211. }
  212. // Order sets the "ORDER BY" statement for the model.
  213. func (d *BaseRegionAuthDao) Order(orderBy ...string) *BaseRegionAuthDao {
  214. return &BaseRegionAuthDao{M: d.M.Order(orderBy...)}
  215. }
  216. // Limit sets the "LIMIT" statement for the model.
  217. // The parameter <limit> can be either one or two number, if passed two number is passed,
  218. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  219. // statement.
  220. func (d *BaseRegionAuthDao) Limit(limit ...int) *BaseRegionAuthDao {
  221. return &BaseRegionAuthDao{M: d.M.Limit(limit...)}
  222. }
  223. // Offset sets the "OFFSET" statement for the model.
  224. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  225. func (d *BaseRegionAuthDao) Offset(offset int) *BaseRegionAuthDao {
  226. return &BaseRegionAuthDao{M: d.M.Offset(offset)}
  227. }
  228. // Page sets the paging number for the model.
  229. // The parameter <page> is started from 1 for paging.
  230. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  231. func (d *BaseRegionAuthDao) Page(page, limit int) *BaseRegionAuthDao {
  232. return &BaseRegionAuthDao{M: d.M.Page(page, limit)}
  233. }
  234. // Batch sets the batch operation number for the model.
  235. func (d *BaseRegionAuthDao) Batch(batch int) *BaseRegionAuthDao {
  236. return &BaseRegionAuthDao{M: d.M.Batch(batch)}
  237. }
  238. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  239. // if there's another same sql request, it just reads and returns the result from cache, it
  240. // but not committed and executed into the database.
  241. //
  242. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  243. // If the parameter <duration> = 0, which means it never expires.
  244. // If the parameter <duration> > 0, which means it expires after <duration>.
  245. //
  246. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  247. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  248. //
  249. // Note that, the cache feature is disabled if the model is operating on a transaction.
  250. func (d *BaseRegionAuthDao) Cache(duration time.Duration, name ...string) *BaseRegionAuthDao {
  251. return &BaseRegionAuthDao{M: d.M.Cache(duration, name...)}
  252. }
  253. // Data sets the operation data for the model.
  254. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  255. // Eg:
  256. // Data("uid=10000")
  257. // Data("uid", 10000)
  258. // Data(g.Map{"uid": 10000, "name":"john"})
  259. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  260. func (d *BaseRegionAuthDao) Data(data ...interface{}) *BaseRegionAuthDao {
  261. return &BaseRegionAuthDao{M: d.M.Data(data...)}
  262. }
  263. // All does "SELECT FROM ..." statement for the model.
  264. // It retrieves the records from table and returns the result as []*model.BaseRegionAuth.
  265. // It returns nil if there's no record retrieved with the given conditions from table.
  266. //
  267. // The optional parameter <where> is the same as the parameter of M.Where function,
  268. // see M.Where.
  269. func (d *BaseRegionAuthDao) All(where ...interface{}) ([]*model.BaseRegionAuth, error) {
  270. all, err := d.M.All(where...)
  271. if err != nil {
  272. return nil, err
  273. }
  274. var entities []*model.BaseRegionAuth
  275. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  276. return nil, err
  277. }
  278. return entities, nil
  279. }
  280. // One retrieves one record from table and returns the result as *model.BaseRegionAuth.
  281. // It returns nil if there's no record retrieved with the given conditions from table.
  282. //
  283. // The optional parameter <where> is the same as the parameter of M.Where function,
  284. // see M.Where.
  285. func (d *BaseRegionAuthDao) One(where ...interface{}) (*model.BaseRegionAuth, error) {
  286. one, err := d.M.One(where...)
  287. if err != nil {
  288. return nil, err
  289. }
  290. var entity *model.BaseRegionAuth
  291. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  292. return nil, err
  293. }
  294. return entity, nil
  295. }
  296. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  297. // Also see M.WherePri and M.One.
  298. func (d *BaseRegionAuthDao) FindOne(where ...interface{}) (*model.BaseRegionAuth, error) {
  299. one, err := d.M.FindOne(where...)
  300. if err != nil {
  301. return nil, err
  302. }
  303. var entity *model.BaseRegionAuth
  304. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  305. return nil, err
  306. }
  307. return entity, nil
  308. }
  309. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  310. // Also see M.WherePri and M.All.
  311. func (d *BaseRegionAuthDao) FindAll(where ...interface{}) ([]*model.BaseRegionAuth, error) {
  312. all, err := d.M.FindAll(where...)
  313. if err != nil {
  314. return nil, err
  315. }
  316. var entities []*model.BaseRegionAuth
  317. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  318. return nil, err
  319. }
  320. return entities, nil
  321. }
  322. // Struct retrieves one record from table and converts it into given struct.
  323. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  324. // it can create the struct internally during converting.
  325. //
  326. // The optional parameter <where> is the same as the parameter of Model.Where function,
  327. // see Model.Where.
  328. //
  329. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  330. // from table and <pointer> is not nil.
  331. //
  332. // Eg:
  333. // user := new(User)
  334. // err := dao.User.Where("id", 1).Struct(user)
  335. //
  336. // user := (*User)(nil)
  337. // err := dao.User.Where("id", 1).Struct(&user)
  338. func (d *BaseRegionAuthDao) Struct(pointer interface{}, where ...interface{}) error {
  339. return d.M.Struct(pointer, where...)
  340. }
  341. // Structs retrieves records from table and converts them into given struct slice.
  342. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  343. // slice internally during converting.
  344. //
  345. // The optional parameter <where> is the same as the parameter of Model.Where function,
  346. // see Model.Where.
  347. //
  348. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  349. // from table and <pointer> is not empty.
  350. //
  351. // Eg:
  352. // users := ([]User)(nil)
  353. // err := dao.User.Structs(&users)
  354. //
  355. // users := ([]*User)(nil)
  356. // err := dao.User.Structs(&users)
  357. func (d *BaseRegionAuthDao) Structs(pointer interface{}, where ...interface{}) error {
  358. return d.M.Structs(pointer, where...)
  359. }
  360. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  361. // It calls function Struct if <pointer> is type of *struct/**struct.
  362. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  363. //
  364. // The optional parameter <where> is the same as the parameter of Model.Where function,
  365. // see Model.Where.
  366. //
  367. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  368. //
  369. // Eg:
  370. // user := new(User)
  371. // err := dao.User.Where("id", 1).Scan(user)
  372. //
  373. // user := (*User)(nil)
  374. // err := dao.User.Where("id", 1).Scan(&user)
  375. //
  376. // users := ([]User)(nil)
  377. // err := dao.User.Scan(&users)
  378. //
  379. // users := ([]*User)(nil)
  380. // err := dao.User.Scan(&users)
  381. func (d *BaseRegionAuthDao) Scan(pointer interface{}, where ...interface{}) error {
  382. return d.M.Scan(pointer, where...)
  383. }
  384. // Chunk iterates the table with given size and callback function.
  385. func (d *BaseRegionAuthDao) Chunk(limit int, callback func(entities []*model.BaseRegionAuth, err error) bool) {
  386. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  387. var entities []*model.BaseRegionAuth
  388. err = result.Structs(&entities)
  389. if err == sql.ErrNoRows {
  390. return false
  391. }
  392. return callback(entities, err)
  393. })
  394. }
  395. // LockUpdate sets the lock for update for current operation.
  396. func (d *BaseRegionAuthDao) LockUpdate() *BaseRegionAuthDao {
  397. return &BaseRegionAuthDao{M: d.M.LockUpdate()}
  398. }
  399. // LockShared sets the lock in share mode for current operation.
  400. func (d *BaseRegionAuthDao) LockShared() *BaseRegionAuthDao {
  401. return &BaseRegionAuthDao{M: d.M.LockShared()}
  402. }
  403. // Unscoped enables/disables the soft deleting feature.
  404. func (d *BaseRegionAuthDao) Unscoped() *BaseRegionAuthDao {
  405. return &BaseRegionAuthDao{M: d.M.Unscoped()}
  406. }