ctr_contract_invoice.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  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. "github.com/gogf/gf/util/gconv"
  12. "strings"
  13. "time"
  14. model "dashoo.cn/micro/app/model/contract"
  15. )
  16. // CtrContractInvoiceDao is the manager for logic model data accessing and custom defined data operations functions management.
  17. type CtrContractInvoiceDao struct {
  18. gmvc.M // M is the core and embedded struct that inherits all chaining operations from gdb.Model.
  19. C ctrContractInvoiceColumns // C is the short type for Columns, which contains all the column names of Table for convenient usage.
  20. DB gdb.DB // DB is the raw underlying database management object.
  21. Table string // Table is the underlying table name of the DAO.
  22. TableAs string // TableAs is the underlying table alias name of the DAO.
  23. }
  24. // CtrContractInvoiceColumns defines and stores column names for table ctr_contract_invoice.
  25. type ctrContractInvoiceColumns struct {
  26. Id string // 主键
  27. CustId string // 关联客户
  28. CustName string // 客户名称
  29. ContractId string // 关联合同
  30. ContractCode string // 合同编号
  31. ContractAmount string // 合同金额
  32. InvoiceAmount string // 开票金额
  33. InvoiceDate string // 开票日期
  34. InvoiceType string // 开票类型
  35. ApproStatus string // 审核状态 10 待提交审核 20 待审核 30 审核已同意 40 审核已拒绝 50 审核已撤销
  36. InvoiceCode string // 发票号码
  37. ActualInvoiceDate string // 实际开票日期
  38. CourierCode string // 快递单号
  39. Remark string // 备注
  40. CreatedBy string // 创建者
  41. CreatedName string // 创建人
  42. CreatedTime string // 创建时间
  43. UpdatedBy string // 更新者
  44. UpdatedName string // 更新人
  45. UpdatedTime string // 更新时间
  46. DeletedTime string // 删除时间
  47. }
  48. var (
  49. // CtrContractInvoice is globally public accessible object for table ctr_contract_invoice operations.
  50. CtrContractInvoice = CtrContractInvoiceDao{
  51. M: g.DB("default").Model("ctr_contract_invoice").Safe(),
  52. DB: g.DB("default"),
  53. Table: "ctr_contract_invoice",
  54. C: ctrContractInvoiceColumns{
  55. Id: "id",
  56. CustId: "cust_id",
  57. CustName: "cust_name",
  58. ContractId: "contract_id",
  59. ContractCode: "contract_code",
  60. ContractAmount: "contract_amount",
  61. InvoiceAmount: "invoice_amount",
  62. InvoiceDate: "invoice_date",
  63. InvoiceType: "invoice_type",
  64. ApproStatus: "appro_status",
  65. InvoiceCode: "invoice_code",
  66. ActualInvoiceDate: "actual_invoice_date",
  67. CourierCode: "courier_code",
  68. Remark: "remark",
  69. CreatedBy: "created_by",
  70. CreatedName: "created_name",
  71. CreatedTime: "created_time",
  72. UpdatedBy: "updated_by",
  73. UpdatedName: "updated_name",
  74. UpdatedTime: "updated_time",
  75. DeletedTime: "deleted_time",
  76. },
  77. }
  78. )
  79. func NewCtrContractInvoiceDao(tenant string) CtrContractInvoiceDao {
  80. var dao CtrContractInvoiceDao
  81. dao = CtrContractInvoiceDao{
  82. M: g.DB(tenant).Model("ctr_contract_invoice").Safe(),
  83. DB: g.DB(tenant),
  84. Table: "ctr_contract_invoice",
  85. C: ctrContractInvoiceColumns{
  86. Id: "id",
  87. CustId: "cust_id",
  88. CustName: "cust_name",
  89. ContractId: "contract_id",
  90. ContractCode: "contract_code",
  91. ContractAmount: "contract_amount",
  92. InvoiceAmount: "invoice_amount",
  93. InvoiceDate: "invoice_date",
  94. InvoiceType: "invoice_type",
  95. ApproStatus: "appro_status",
  96. InvoiceCode: "invoice_code",
  97. ActualInvoiceDate: "actual_invoice_date",
  98. CourierCode: "courier_code",
  99. Remark: "remark",
  100. CreatedBy: "created_by",
  101. CreatedName: "created_name",
  102. CreatedTime: "created_time",
  103. UpdatedBy: "updated_by",
  104. UpdatedName: "updated_name",
  105. UpdatedTime: "updated_time",
  106. DeletedTime: "deleted_time",
  107. },
  108. }
  109. return dao
  110. }
  111. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  112. // of current DB object and with given context in it.
  113. // Note that this returned DB object can be used only once, so do not assign it to
  114. // a global or package variable for long using.
  115. func (d *CtrContractInvoiceDao) Ctx(ctx context.Context) *CtrContractInvoiceDao {
  116. return &CtrContractInvoiceDao{M: d.M.Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  117. }
  118. // GetCtx returns the context for current Model.
  119. // It returns "context.Background() i"s there's no context previously set.
  120. func (d *CtrContractInvoiceDao) GetCtx() context.Context {
  121. return d.M.GetCtx()
  122. }
  123. // As sets an alias name for current table.
  124. func (d *CtrContractInvoiceDao) As(as string) *CtrContractInvoiceDao {
  125. return &CtrContractInvoiceDao{M: d.M.As(as), Table: d.Table, TableAs: as}
  126. }
  127. // TX sets the transaction for current operation.
  128. func (d *CtrContractInvoiceDao) TX(tx *gdb.TX) *CtrContractInvoiceDao {
  129. return &CtrContractInvoiceDao{M: d.M.TX(tx), Table: d.Table, TableAs: d.TableAs}
  130. }
  131. // Master marks the following operation on master node.
  132. func (d *CtrContractInvoiceDao) Master() *CtrContractInvoiceDao {
  133. return &CtrContractInvoiceDao{M: d.M.Master(), Table: d.Table, TableAs: d.TableAs}
  134. }
  135. // Slave marks the following operation on slave node.
  136. // Note that it makes sense only if there's any slave node configured.
  137. func (d *CtrContractInvoiceDao) Slave() *CtrContractInvoiceDao {
  138. return &CtrContractInvoiceDao{M: d.M.Slave(), Table: d.Table, TableAs: d.TableAs}
  139. }
  140. // Args sets custom arguments for model operation.
  141. func (d *CtrContractInvoiceDao) Args(args ...interface{}) *CtrContractInvoiceDao {
  142. return &CtrContractInvoiceDao{M: d.M.Args(args...), Table: d.Table, TableAs: d.TableAs}
  143. }
  144. // Handler calls each of "handlers" on current Model and returns a new Model.
  145. // ModelHandler is a function that handles given Model and returns a new Model that is custom modified.
  146. func (d *CtrContractInvoiceDao) Handler(handlers ...gdb.ModelHandler) *CtrContractInvoiceDao {
  147. return &CtrContractInvoiceDao{M: d.M.Handler(handlers...), Table: d.Table, TableAs: d.TableAs}
  148. }
  149. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  150. // The parameter <table> can be joined table and its joined condition,
  151. // and also with its alias name, like:
  152. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  153. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  154. func (d *CtrContractInvoiceDao) LeftJoin(table ...string) *CtrContractInvoiceDao {
  155. return &CtrContractInvoiceDao{M: d.M.LeftJoin(table...), Table: d.Table, TableAs: d.TableAs}
  156. }
  157. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  158. // The parameter <table> can be joined table and its joined condition,
  159. // and also with its alias name, like:
  160. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  161. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  162. func (d *CtrContractInvoiceDao) RightJoin(table ...string) *CtrContractInvoiceDao {
  163. return &CtrContractInvoiceDao{M: d.M.RightJoin(table...), Table: d.Table, TableAs: d.TableAs}
  164. }
  165. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  166. // The parameter <table> can be joined table and its joined condition,
  167. // and also with its alias name, like:
  168. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  169. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  170. func (d *CtrContractInvoiceDao) InnerJoin(table ...string) *CtrContractInvoiceDao {
  171. return &CtrContractInvoiceDao{M: d.M.InnerJoin(table...), Table: d.Table, TableAs: d.TableAs}
  172. }
  173. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  174. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  175. func (d *CtrContractInvoiceDao) Fields(fieldNamesOrMapStruct ...interface{}) *CtrContractInvoiceDao {
  176. return &CtrContractInvoiceDao{M: d.M.Fields(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  177. }
  178. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  179. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  180. func (d *CtrContractInvoiceDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *CtrContractInvoiceDao {
  181. return &CtrContractInvoiceDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  182. }
  183. // FieldCount formats and appends commonly used field "COUNT(column)" to the select fields of model.
  184. func (d *CtrContractInvoiceDao) FieldCount(column string, as ...string) *CtrContractInvoiceDao {
  185. return &CtrContractInvoiceDao{M: d.M.FieldCount(column, as...), Table: d.Table, TableAs: d.TableAs}
  186. }
  187. // FieldSum formats and appends commonly used field "SUM(column)" to the select fields of model.
  188. func (d *CtrContractInvoiceDao) FieldSum(column string, as ...string) *CtrContractInvoiceDao {
  189. return &CtrContractInvoiceDao{M: d.M.FieldSum(column, as...), Table: d.Table, TableAs: d.TableAs}
  190. }
  191. // FieldMin formats and appends commonly used field "MIN(column)" to the select fields of model.
  192. func (d *CtrContractInvoiceDao) FieldMin(column string, as ...string) *CtrContractInvoiceDao {
  193. return &CtrContractInvoiceDao{M: d.M.FieldMin(column, as...), Table: d.Table, TableAs: d.TableAs}
  194. }
  195. // FieldMax formats and appends commonly used field "MAX(column)" to the select fields of model.
  196. func (d *CtrContractInvoiceDao) FieldMax(column string, as ...string) *CtrContractInvoiceDao {
  197. return &CtrContractInvoiceDao{M: d.M.FieldMax(column, as...), Table: d.Table, TableAs: d.TableAs}
  198. }
  199. // FieldAvg formats and appends commonly used field "AVG(column)" to the select fields of model.
  200. func (d *CtrContractInvoiceDao) FieldAvg(column string, as ...string) *CtrContractInvoiceDao {
  201. return &CtrContractInvoiceDao{M: d.M.FieldAvg(column, as...), Table: d.Table, TableAs: d.TableAs}
  202. }
  203. // Option adds extra operation option for the model.
  204. // Deprecated, use separate operations instead.
  205. func (d *CtrContractInvoiceDao) Option(option int) *CtrContractInvoiceDao {
  206. return &CtrContractInvoiceDao{M: d.M.Option(option), Table: d.Table, TableAs: d.TableAs}
  207. }
  208. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  209. // the data and where attributes for empty values.
  210. func (d *CtrContractInvoiceDao) OmitEmpty() *CtrContractInvoiceDao {
  211. return &CtrContractInvoiceDao{M: d.M.OmitEmpty(), Table: d.Table, TableAs: d.TableAs}
  212. }
  213. // OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
  214. // the Where/Having parameters for "empty" values.
  215. func (d *CtrContractInvoiceDao) OmitEmptyWhere() *CtrContractInvoiceDao {
  216. return &CtrContractInvoiceDao{M: d.M.OmitEmptyWhere(), Table: d.Table, TableAs: d.TableAs}
  217. }
  218. // OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
  219. // the Data parameters for "empty" values.
  220. func (d *CtrContractInvoiceDao) OmitEmptyData() *CtrContractInvoiceDao {
  221. return &CtrContractInvoiceDao{M: d.M.OmitEmptyData(), Table: d.Table, TableAs: d.TableAs}
  222. }
  223. // OmitNil sets optionOmitNil option for the model, which automatically filers
  224. // the data and where parameters for "nil" values.
  225. func (d *CtrContractInvoiceDao) OmitNil() *CtrContractInvoiceDao {
  226. return &CtrContractInvoiceDao{M: d.M.OmitNil(), Table: d.Table, TableAs: d.TableAs}
  227. }
  228. // OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
  229. // the Where/Having parameters for "nil" values.
  230. func (d *CtrContractInvoiceDao) OmitNilWhere() *CtrContractInvoiceDao {
  231. return &CtrContractInvoiceDao{M: d.M.OmitNilWhere(), Table: d.Table, TableAs: d.TableAs}
  232. }
  233. // OmitNilData sets optionOmitNilData option for the model, which automatically filers
  234. // the Data parameters for "nil" values.
  235. func (d *CtrContractInvoiceDao) OmitNilData() *CtrContractInvoiceDao {
  236. return &CtrContractInvoiceDao{M: d.M.OmitNilData(), Table: d.Table, TableAs: d.TableAs}
  237. }
  238. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  239. // Note that this function supports only single table operations.
  240. // Deprecated, filter feature is automatically enabled from GoFrame v1.16.0, it is so no longer used.
  241. func (d *CtrContractInvoiceDao) Filter() *CtrContractInvoiceDao {
  242. return &CtrContractInvoiceDao{M: d.M.Filter(), Table: d.Table, TableAs: d.TableAs}
  243. }
  244. // Where sets the condition statement for the model. The parameter <where> can be type of
  245. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  246. // multiple conditions will be joined into where statement using "AND".
  247. // Eg:
  248. // Where("uid=10000")
  249. // Where("uid", 10000)
  250. // Where("money>? AND name like ?", 99999, "vip_%")
  251. // Where("uid", 1).Where("name", "john")
  252. // Where("status IN (?)", g.Slice{1,2,3})
  253. // Where("age IN(?,?)", 18, 50)
  254. // Where(User{ Id : 1, UserName : "john"})
  255. func (d *CtrContractInvoiceDao) Where(where interface{}, args ...interface{}) *CtrContractInvoiceDao {
  256. return &CtrContractInvoiceDao{M: d.M.Where(where, args...), Table: d.Table, TableAs: d.TableAs}
  257. }
  258. // WherePri does the same logic as M.Where except that if the parameter <where>
  259. // is a single condition like int/string/float/slice, it treats the condition as the primary
  260. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  261. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  262. // as string "123".
  263. func (d *CtrContractInvoiceDao) WherePri(where interface{}, args ...interface{}) *CtrContractInvoiceDao {
  264. return &CtrContractInvoiceDao{M: d.M.WherePri(where, args...), Table: d.Table, TableAs: d.TableAs}
  265. }
  266. // Having sets the having statement for the model.
  267. // The parameters of this function usage are as the same as function Where.
  268. // See Where.
  269. func (d *CtrContractInvoiceDao) Having(having interface{}, args ...interface{}) *CtrContractInvoiceDao {
  270. return &CtrContractInvoiceDao{M: d.M.Having(having, args...), Table: d.Table, TableAs: d.TableAs}
  271. }
  272. // Wheref builds condition string using fmt.Sprintf and arguments.
  273. // Note that if the number of "args" is more than the place holder in "format",
  274. // the extra "args" will be used as the where condition arguments of the Model.
  275. func (d *CtrContractInvoiceDao) Wheref(format string, args ...interface{}) *CtrContractInvoiceDao {
  276. return &CtrContractInvoiceDao{M: d.M.Wheref(format, args...), Table: d.Table, TableAs: d.TableAs}
  277. }
  278. // WhereLT builds "column < value" statement.
  279. func (d *CtrContractInvoiceDao) WhereLT(column string, value interface{}) *CtrContractInvoiceDao {
  280. return &CtrContractInvoiceDao{M: d.M.WhereLT(column, value), Table: d.Table, TableAs: d.TableAs}
  281. }
  282. // WhereLTE builds "column <= value" statement.
  283. func (d *CtrContractInvoiceDao) WhereLTE(column string, value interface{}) *CtrContractInvoiceDao {
  284. return &CtrContractInvoiceDao{M: d.M.WhereLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  285. }
  286. // WhereGT builds "column > value" statement.
  287. func (d *CtrContractInvoiceDao) WhereGT(column string, value interface{}) *CtrContractInvoiceDao {
  288. return &CtrContractInvoiceDao{M: d.M.WhereGT(column, value), Table: d.Table, TableAs: d.TableAs}
  289. }
  290. // WhereGTE builds "column >= value" statement.
  291. func (d *CtrContractInvoiceDao) WhereGTE(column string, value interface{}) *CtrContractInvoiceDao {
  292. return &CtrContractInvoiceDao{M: d.M.WhereGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  293. }
  294. // WhereBetween builds "column BETWEEN min AND max" statement.
  295. func (d *CtrContractInvoiceDao) WhereBetween(column string, min, max interface{}) *CtrContractInvoiceDao {
  296. return &CtrContractInvoiceDao{M: d.M.WhereBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  297. }
  298. // WhereLike builds "column LIKE like" statement.
  299. func (d *CtrContractInvoiceDao) WhereLike(column string, like interface{}) *CtrContractInvoiceDao {
  300. return &CtrContractInvoiceDao{M: d.M.WhereLike(column, like), Table: d.Table, TableAs: d.TableAs}
  301. }
  302. // WhereIn builds "column IN (in)" statement.
  303. func (d *CtrContractInvoiceDao) WhereIn(column string, in interface{}) *CtrContractInvoiceDao {
  304. return &CtrContractInvoiceDao{M: d.M.WhereIn(column, in), Table: d.Table, TableAs: d.TableAs}
  305. }
  306. // WhereNull builds "columns[0] IS NULL AND columns[1] IS NULL ..." statement.
  307. func (d *CtrContractInvoiceDao) WhereNull(columns ...string) *CtrContractInvoiceDao {
  308. return &CtrContractInvoiceDao{M: d.M.WhereNull(columns...), Table: d.Table, TableAs: d.TableAs}
  309. }
  310. // WhereNotBetween builds "column NOT BETWEEN min AND max" statement.
  311. func (d *CtrContractInvoiceDao) WhereNotBetween(column string, min, max interface{}) *CtrContractInvoiceDao {
  312. return &CtrContractInvoiceDao{M: d.M.WhereNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  313. }
  314. // WhereNotLike builds "column NOT LIKE like" statement.
  315. func (d *CtrContractInvoiceDao) WhereNotLike(column string, like interface{}) *CtrContractInvoiceDao {
  316. return &CtrContractInvoiceDao{M: d.M.WhereNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  317. }
  318. // WhereNot builds "column != value" statement.
  319. func (d *CtrContractInvoiceDao) WhereNot(column string, value interface{}) *CtrContractInvoiceDao {
  320. return &CtrContractInvoiceDao{M: d.M.WhereNot(column, value), Table: d.Table, TableAs: d.TableAs}
  321. }
  322. // WhereNotIn builds "column NOT IN (in)" statement.
  323. func (d *CtrContractInvoiceDao) WhereNotIn(column string, in interface{}) *CtrContractInvoiceDao {
  324. return &CtrContractInvoiceDao{M: d.M.WhereNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  325. }
  326. // WhereNotNull builds "columns[0] IS NOT NULL AND columns[1] IS NOT NULL ..." statement.
  327. func (d *CtrContractInvoiceDao) WhereNotNull(columns ...string) *CtrContractInvoiceDao {
  328. return &CtrContractInvoiceDao{M: d.M.WhereNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  329. }
  330. // WhereOr adds "OR" condition to the where statement.
  331. func (d *CtrContractInvoiceDao) WhereOr(where interface{}, args ...interface{}) *CtrContractInvoiceDao {
  332. return &CtrContractInvoiceDao{M: d.M.WhereOr(where, args...), Table: d.Table, TableAs: d.TableAs}
  333. }
  334. // WhereOrf builds "OR" condition string using fmt.Sprintf and arguments.
  335. func (d *CtrContractInvoiceDao) WhereOrf(format string, args ...interface{}) *CtrContractInvoiceDao {
  336. return &CtrContractInvoiceDao{M: d.M.WhereOrf(format, args...), Table: d.Table, TableAs: d.TableAs}
  337. }
  338. // WhereOrLT builds "column < value" statement in "OR" conditions..
  339. func (d *CtrContractInvoiceDao) WhereOrLT(column string, value interface{}) *CtrContractInvoiceDao {
  340. return &CtrContractInvoiceDao{M: d.M.WhereOrLT(column, value), Table: d.Table, TableAs: d.TableAs}
  341. }
  342. // WhereOrLTE builds "column <= value" statement in "OR" conditions..
  343. func (d *CtrContractInvoiceDao) WhereOrLTE(column string, value interface{}) *CtrContractInvoiceDao {
  344. return &CtrContractInvoiceDao{M: d.M.WhereOrLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  345. }
  346. // WhereOrGT builds "column > value" statement in "OR" conditions..
  347. func (d *CtrContractInvoiceDao) WhereOrGT(column string, value interface{}) *CtrContractInvoiceDao {
  348. return &CtrContractInvoiceDao{M: d.M.WhereOrGT(column, value), Table: d.Table, TableAs: d.TableAs}
  349. }
  350. // WhereOrGTE builds "column >= value" statement in "OR" conditions..
  351. func (d *CtrContractInvoiceDao) WhereOrGTE(column string, value interface{}) *CtrContractInvoiceDao {
  352. return &CtrContractInvoiceDao{M: d.M.WhereOrGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  353. }
  354. // WhereOrBetween builds "column BETWEEN min AND max" statement in "OR" conditions.
  355. func (d *CtrContractInvoiceDao) WhereOrBetween(column string, min, max interface{}) *CtrContractInvoiceDao {
  356. return &CtrContractInvoiceDao{M: d.M.WhereOrBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  357. }
  358. // WhereOrLike builds "column LIKE like" statement in "OR" conditions.
  359. func (d *CtrContractInvoiceDao) WhereOrLike(column string, like interface{}) *CtrContractInvoiceDao {
  360. return &CtrContractInvoiceDao{M: d.M.WhereOrLike(column, like), Table: d.Table, TableAs: d.TableAs}
  361. }
  362. // WhereOrIn builds "column IN (in)" statement in "OR" conditions.
  363. func (d *CtrContractInvoiceDao) WhereOrIn(column string, in interface{}) *CtrContractInvoiceDao {
  364. return &CtrContractInvoiceDao{M: d.M.WhereOrIn(column, in), Table: d.Table, TableAs: d.TableAs}
  365. }
  366. // WhereOrNull builds "columns[0] IS NULL OR columns[1] IS NULL ..." statement in "OR" conditions.
  367. func (d *CtrContractInvoiceDao) WhereOrNull(columns ...string) *CtrContractInvoiceDao {
  368. return &CtrContractInvoiceDao{M: d.M.WhereOrNull(columns...), Table: d.Table, TableAs: d.TableAs}
  369. }
  370. // WhereOrNotBetween builds "column NOT BETWEEN min AND max" statement in "OR" conditions.
  371. func (d *CtrContractInvoiceDao) WhereOrNotBetween(column string, min, max interface{}) *CtrContractInvoiceDao {
  372. return &CtrContractInvoiceDao{M: d.M.WhereOrNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  373. }
  374. // WhereOrNotLike builds "column NOT LIKE like" statement in "OR" conditions.
  375. func (d *CtrContractInvoiceDao) WhereOrNotLike(column string, like interface{}) *CtrContractInvoiceDao {
  376. return &CtrContractInvoiceDao{M: d.M.WhereOrNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  377. }
  378. // WhereOrNotIn builds "column NOT IN (in)" statement.
  379. func (d *CtrContractInvoiceDao) WhereOrNotIn(column string, in interface{}) *CtrContractInvoiceDao {
  380. return &CtrContractInvoiceDao{M: d.M.WhereOrNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  381. }
  382. // WhereOrNotNull builds "columns[0] IS NOT NULL OR columns[1] IS NOT NULL ..." statement in "OR" conditions.
  383. func (d *CtrContractInvoiceDao) WhereOrNotNull(columns ...string) *CtrContractInvoiceDao {
  384. return &CtrContractInvoiceDao{M: d.M.WhereOrNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  385. }
  386. // Group sets the "GROUP BY" statement for the model.
  387. func (d *CtrContractInvoiceDao) Group(groupBy ...string) *CtrContractInvoiceDao {
  388. return &CtrContractInvoiceDao{M: d.M.Group(groupBy...), Table: d.Table, TableAs: d.TableAs}
  389. }
  390. // And adds "AND" condition to the where statement.
  391. // Deprecated, use Where instead.
  392. func (d *CtrContractInvoiceDao) And(where interface{}, args ...interface{}) *CtrContractInvoiceDao {
  393. return &CtrContractInvoiceDao{M: d.M.And(where, args...), Table: d.Table, TableAs: d.TableAs}
  394. }
  395. // Or adds "OR" condition to the where statement.
  396. // Deprecated, use WhereOr instead.
  397. func (d *CtrContractInvoiceDao) Or(where interface{}, args ...interface{}) *CtrContractInvoiceDao {
  398. return &CtrContractInvoiceDao{M: d.M.Or(where, args...), Table: d.Table, TableAs: d.TableAs}
  399. }
  400. // GroupBy sets the "GROUP BY" statement for the model.
  401. func (d *CtrContractInvoiceDao) GroupBy(groupBy string) *CtrContractInvoiceDao {
  402. return &CtrContractInvoiceDao{M: d.M.Group(groupBy), Table: d.Table, TableAs: d.TableAs}
  403. }
  404. // Order sets the "ORDER BY" statement for the model.
  405. func (d *CtrContractInvoiceDao) Order(orderBy ...string) *CtrContractInvoiceDao {
  406. return &CtrContractInvoiceDao{M: d.M.Order(orderBy...), Table: d.Table, TableAs: d.TableAs}
  407. }
  408. // OrderAsc sets the "ORDER BY xxx ASC" statement for the model.
  409. func (d *CtrContractInvoiceDao) OrderAsc(column string) *CtrContractInvoiceDao {
  410. return &CtrContractInvoiceDao{M: d.M.OrderAsc(column), Table: d.Table, TableAs: d.TableAs}
  411. }
  412. // OrderDesc sets the "ORDER BY xxx DESC" statement for the model.
  413. func (d *CtrContractInvoiceDao) OrderDesc(column string) *CtrContractInvoiceDao {
  414. return &CtrContractInvoiceDao{M: d.M.OrderDesc(column), Table: d.Table, TableAs: d.TableAs}
  415. }
  416. // OrderRandom sets the "ORDER BY RANDOM()" statement for the model.
  417. func (d *CtrContractInvoiceDao) OrderRandom() *CtrContractInvoiceDao {
  418. return &CtrContractInvoiceDao{M: d.M.OrderRandom(), Table: d.Table, TableAs: d.TableAs}
  419. }
  420. // OrderBy is alias of Model.Order.
  421. // See Model.Order.
  422. // Deprecated, use Order instead.
  423. func (d *CtrContractInvoiceDao) OrderBy(orderBy string) *CtrContractInvoiceDao {
  424. return &CtrContractInvoiceDao{M: d.M.Order(orderBy), Table: d.Table, TableAs: d.TableAs}
  425. }
  426. // Limit sets the "LIMIT" statement for the model.
  427. // The parameter <limit> can be either one or two number, if passed two number is passed,
  428. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  429. // statement.
  430. func (d *CtrContractInvoiceDao) Limit(limit ...int) *CtrContractInvoiceDao {
  431. return &CtrContractInvoiceDao{M: d.M.Limit(limit...), Table: d.Table, TableAs: d.TableAs}
  432. }
  433. // Offset sets the "OFFSET" statement for the model.
  434. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  435. func (d *CtrContractInvoiceDao) Offset(offset int) *CtrContractInvoiceDao {
  436. return &CtrContractInvoiceDao{M: d.M.Offset(offset), Table: d.Table, TableAs: d.TableAs}
  437. }
  438. // Distinct forces the query to only return distinct results.
  439. func (d *CtrContractInvoiceDao) Distinct() *CtrContractInvoiceDao {
  440. return &CtrContractInvoiceDao{M: d.M.Distinct(), Table: d.Table, TableAs: d.TableAs}
  441. }
  442. // Page sets the paging number for the model.
  443. // The parameter <page> is started from 1 for paging.
  444. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  445. func (d *CtrContractInvoiceDao) Page(page, limit int) *CtrContractInvoiceDao {
  446. return &CtrContractInvoiceDao{M: d.M.Page(page, limit), Table: d.Table, TableAs: d.TableAs}
  447. }
  448. // Batch sets the batch operation number for the model.
  449. func (d *CtrContractInvoiceDao) Batch(batch int) *CtrContractInvoiceDao {
  450. return &CtrContractInvoiceDao{M: d.M.Batch(batch), Table: d.Table, TableAs: d.TableAs}
  451. }
  452. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  453. // if there's another same sql request, it just reads and returns the result from cache, it
  454. // but not committed and executed into the database.
  455. //
  456. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  457. // If the parameter <duration> = 0, which means it never expires.
  458. // If the parameter <duration> > 0, which means it expires after <duration>.
  459. //
  460. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  461. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  462. //
  463. // Note that, the cache feature is disabled if the model is operating on a transaction.
  464. func (d *CtrContractInvoiceDao) Cache(duration time.Duration, name ...string) *CtrContractInvoiceDao {
  465. return &CtrContractInvoiceDao{M: d.M.Cache(duration, name...), Table: d.Table, TableAs: d.TableAs}
  466. }
  467. // Data sets the operation data for the model.
  468. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  469. // Eg:
  470. // Data("uid=10000")
  471. // Data("uid", 10000)
  472. // Data(g.Map{"uid": 10000, "name":"john"})
  473. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  474. func (d *CtrContractInvoiceDao) Data(data ...interface{}) *CtrContractInvoiceDao {
  475. return &CtrContractInvoiceDao{M: d.M.Data(data...), Table: d.Table, TableAs: d.TableAs}
  476. }
  477. // All does "SELECT FROM ..." statement for the model.
  478. // It retrieves the records from table and returns the result as []*model.CtrContractInvoice.
  479. // It returns nil if there's no record retrieved with the given conditions from table.
  480. //
  481. // The optional parameter <where> is the same as the parameter of M.Where function,
  482. // see M.Where.
  483. func (d *CtrContractInvoiceDao) All(where ...interface{}) ([]*model.CtrContractInvoice, error) {
  484. all, err := d.M.All(where...)
  485. if err != nil {
  486. return nil, err
  487. }
  488. var entities []*model.CtrContractInvoice
  489. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  490. return nil, err
  491. }
  492. return entities, nil
  493. }
  494. // One retrieves one record from table and returns the result as *model.CtrContractInvoice.
  495. // It returns nil if there's no record retrieved with the given conditions from table.
  496. //
  497. // The optional parameter <where> is the same as the parameter of M.Where function,
  498. // see M.Where.
  499. func (d *CtrContractInvoiceDao) One(where ...interface{}) (*model.CtrContractInvoice, error) {
  500. one, err := d.M.One(where...)
  501. if err != nil {
  502. return nil, err
  503. }
  504. var entity *model.CtrContractInvoice
  505. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  506. return nil, err
  507. }
  508. return entity, nil
  509. }
  510. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  511. // Also see M.WherePri and M.One.
  512. func (d *CtrContractInvoiceDao) FindOne(where ...interface{}) (*model.CtrContractInvoice, error) {
  513. one, err := d.M.FindOne(where...)
  514. if err != nil {
  515. return nil, err
  516. }
  517. var entity *model.CtrContractInvoice
  518. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  519. return nil, err
  520. }
  521. return entity, nil
  522. }
  523. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  524. // Also see M.WherePri and M.All.
  525. func (d *CtrContractInvoiceDao) FindAll(where ...interface{}) ([]*model.CtrContractInvoice, error) {
  526. all, err := d.M.FindAll(where...)
  527. if err != nil {
  528. return nil, err
  529. }
  530. var entities []*model.CtrContractInvoice
  531. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  532. return nil, err
  533. }
  534. return entities, nil
  535. }
  536. // Struct retrieves one record from table and converts it into given struct.
  537. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  538. // it can create the struct internally during converting.
  539. //
  540. // The optional parameter <where> is the same as the parameter of Model.Where function,
  541. // see Model.Where.
  542. //
  543. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  544. // from table and <pointer> is not nil.
  545. //
  546. // Eg:
  547. // user := new(User)
  548. // err := dao.User.Where("id", 1).Struct(user)
  549. //
  550. // user := (*User)(nil)
  551. // err := dao.User.Where("id", 1).Struct(&user)
  552. func (d *CtrContractInvoiceDao) Struct(pointer interface{}, where ...interface{}) error {
  553. return d.M.Struct(pointer, where...)
  554. }
  555. // Structs retrieves records from table and converts them into given struct slice.
  556. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  557. // slice internally during converting.
  558. //
  559. // The optional parameter <where> is the same as the parameter of Model.Where function,
  560. // see Model.Where.
  561. //
  562. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  563. // from table and <pointer> is not empty.
  564. //
  565. // Eg:
  566. // users := ([]User)(nil)
  567. // err := dao.User.Structs(&users)
  568. //
  569. // users := ([]*User)(nil)
  570. // err := dao.User.Structs(&users)
  571. func (d *CtrContractInvoiceDao) Structs(pointer interface{}, where ...interface{}) error {
  572. return d.M.Structs(pointer, where...)
  573. }
  574. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  575. // It calls function Struct if <pointer> is type of *struct/**struct.
  576. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  577. //
  578. // The optional parameter <where> is the same as the parameter of Model.Where function,
  579. // see Model.Where.
  580. //
  581. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  582. //
  583. // Eg:
  584. // user := new(User)
  585. // err := dao.User.Where("id", 1).Scan(user)
  586. //
  587. // user := (*User)(nil)
  588. // err := dao.User.Where("id", 1).Scan(&user)
  589. //
  590. // users := ([]User)(nil)
  591. // err := dao.User.Scan(&users)
  592. //
  593. // users := ([]*User)(nil)
  594. // err := dao.User.Scan(&users)
  595. func (d *CtrContractInvoiceDao) Scan(pointer interface{}, where ...interface{}) error {
  596. return d.M.Scan(pointer, where...)
  597. }
  598. // Chunk iterates the table with given size and callback function.
  599. func (d *CtrContractInvoiceDao) Chunk(limit int, callback func(entities []*model.CtrContractInvoice, err error) bool) {
  600. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  601. var entities []*model.CtrContractInvoice
  602. err = result.Structs(&entities)
  603. if err == sql.ErrNoRows {
  604. return false
  605. }
  606. return callback(entities, err)
  607. })
  608. }
  609. // LockUpdate sets the lock for update for current operation.
  610. func (d *CtrContractInvoiceDao) LockUpdate() *CtrContractInvoiceDao {
  611. return &CtrContractInvoiceDao{M: d.M.LockUpdate(), Table: d.Table, TableAs: d.TableAs}
  612. }
  613. // LockShared sets the lock in share mode for current operation.
  614. func (d *CtrContractInvoiceDao) LockShared() *CtrContractInvoiceDao {
  615. return &CtrContractInvoiceDao{M: d.M.LockShared(), Table: d.Table, TableAs: d.TableAs}
  616. }
  617. // Unscoped enables/disables the soft deleting feature.
  618. func (d *CtrContractInvoiceDao) Unscoped() *CtrContractInvoiceDao {
  619. return &CtrContractInvoiceDao{M: d.M.Unscoped(), Table: d.Table, TableAs: d.TableAs}
  620. }
  621. // DataScope enables the DataScope feature.
  622. func (d *CtrContractInvoiceDao) DataScope(ctx context.Context, userCol ...string) *CtrContractInvoiceDao {
  623. cs := ctx.Value("contextService")
  624. dataScope := gconv.Map(cs)["dataScope"].(g.Map)
  625. if dataScope != nil {
  626. tableAs := d.TableAs
  627. if d.TableAs != "" {
  628. tableAs += "."
  629. }
  630. userIds, ok := dataScope["userIds"]
  631. delete(dataScope, "userIds")
  632. var orColumns []string
  633. var orValues []interface{}
  634. if ok && userIds != "-1" {
  635. column := "created_by"
  636. if len(userCol) == 1 {
  637. column = userCol[0]
  638. }
  639. if ok, _ := d.M.HasField(column); ok {
  640. orColumns = append(orColumns, tableAs+column+" IN (?) ")
  641. orValues = append(orValues, userIds)
  642. }
  643. if d.Table == "sys_user" {
  644. column = "id"
  645. orColumns = append(orColumns, tableAs+column+" IN (?) ")
  646. orValues = append(orValues, userIds)
  647. }
  648. }
  649. bigColumns := "is_big"
  650. if ok, _ := d.M.HasField("is_big"); ok {
  651. if val, ok := dataScope[bigColumns]; ok && val != "" {
  652. orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
  653. orValues = append(orValues, val)
  654. }
  655. delete(dataScope, bigColumns)
  656. }
  657. var andColumns []string
  658. var andValues []interface{}
  659. for k, v := range dataScope {
  660. if ok, _ := d.M.HasField(k); ok {
  661. andColumns = append(andColumns, tableAs+k+" IN (?) ")
  662. andValues = append(andValues, v)
  663. }
  664. }
  665. if len(andColumns) > 0 {
  666. andWhereSql := strings.Join(andColumns, " AND ")
  667. orColumns = append(orColumns, "("+andWhereSql+")")
  668. orValues = append(orValues, andValues...)
  669. }
  670. whereSql := strings.Join(orColumns, " OR ")
  671. return &CtrContractInvoiceDao{M: d.M.Where(whereSql, orValues...).Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  672. }
  673. return d
  674. }