ctr_contract_invoice.go 35 KB

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