contract_template.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package contract_template
  2. import (
  3. "rdluck_tools/orm"
  4. "time"
  5. )
  6. type ContractTemplate struct {
  7. ContractTemplateId int `orm:"column(contract_template_id);pk"`
  8. ProductId int `description:"产品id"`
  9. Title string `description:"标题"`
  10. Url string `description:"模板地址"`
  11. Html string `description:"html模板"`
  12. PdfHtml string `description:"生成pdf的html模板"`
  13. CreateTime time.Time `description:"创建时间"`
  14. }
  15. func GetContractTemplateMapByProductId(productId int) (items []*ContractTemplate, err error) {
  16. var condition string
  17. pars := make([]interface{}, 0)
  18. if productId > 0 {
  19. condition += `AND product_id = ? `
  20. pars = append(pars, productId)
  21. }
  22. o := orm.NewOrm()
  23. sql := ` SELECT * FROM contract_template WHERE 1=1 `
  24. sql += condition
  25. _, err = o.Raw(sql, pars).QueryRows(&items)
  26. return
  27. }
  28. //根据模板id获取模板信息
  29. func GetContractTemplateByTemplateId(templateId int) (item *ContractTemplate, err error) {
  30. o := orm.NewOrm()
  31. sql := ` SELECT * FROM contract_template WHERE contract_template_id=? `
  32. err = o.Raw(sql, templateId).QueryRow(&item)
  33. return
  34. }