contract_template.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package contract
  2. import (
  3. "github.com/beego/beego/v2/client/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. ContentConfig string `description:"合同中一些特定区域的文字展示配置;json格式"`
  15. CreateTime time.Time `description:"创建时间"`
  16. }
  17. func GetContractTemplateMapByProductId(productId int) (items []*ContractTemplate, err error) {
  18. var condition string
  19. pars := make([]interface{}, 0)
  20. if productId > 0 {
  21. condition += `AND product_id = ? `
  22. pars = append(pars, productId)
  23. }
  24. o := orm.NewOrm()
  25. sql := ` SELECT * FROM contract_template WHERE 1=1 `
  26. sql += condition
  27. _, err = o.Raw(sql, pars).QueryRows(&items)
  28. return
  29. }
  30. //根据模板id获取模板信息
  31. func GetContractTemplateByTemplateId(templateId int) (item *ContractTemplate, err error) {
  32. o := orm.NewOrm()
  33. sql := ` SELECT * FROM contract_template WHERE contract_template_id=? `
  34. err = o.Raw(sql, templateId).QueryRow(&item)
  35. return
  36. }