contract_template.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. WordConfig string `description:"生成word的json配置"`
  14. CreateTime time.Time `description:"创建时间"`
  15. }
  16. func GetContractTemplateMapByProductId(productId int) (items []*ContractTemplate, err error) {
  17. var condition string
  18. pars := make([]interface{}, 0)
  19. if productId > 0 {
  20. condition += `AND product_id = ? `
  21. pars = append(pars, productId)
  22. }
  23. o := orm.NewOrm()
  24. sql := ` SELECT * FROM contract_template WHERE 1=1 `
  25. sql += condition
  26. _, err = o.Raw(sql, pars).QueryRows(&items)
  27. return
  28. }
  29. //根据模板id获取模板信息
  30. func GetContractTemplateByTemplateId(templateId int) (item *ContractTemplate, err error) {
  31. o := orm.NewOrm()
  32. sql := ` SELECT * FROM contract_template WHERE contract_template_id=? `
  33. err = o.Raw(sql, templateId).QueryRow(&item)
  34. return
  35. }