template_library.go 916 B

123456789101112131415161718192021222324252627282930
  1. package models
  2. import "github.com/beego/beego/v2/client/orm"
  3. type TemplateLibrary struct {
  4. TemplateLibraryId int `orm:"column(template_library_id);pk"`
  5. TemplateId string `json:"template_id"`
  6. Title string `json:"title"`
  7. PrimaryIndustry string `json:"primary_industry"`
  8. DeputyIndustry string `json:"deputy_industry"`
  9. Content string `json:"content"`
  10. Example string `json:"example"`
  11. }
  12. type TemplateLibraryResp struct {
  13. TemplateList []TemplateLibrary `json:"template_list"`
  14. }
  15. func AddTemplates(items []TemplateLibrary) (err error) {
  16. o := orm.NewOrmUsingDB("cygx")
  17. _, err = o.InsertMulti(len(items), &items)
  18. return
  19. }
  20. func GetTemplateLibraryByTemplateId(templateId string) (item *TemplateLibrary, err error) {
  21. o := orm.NewOrmUsingDB("cygx")
  22. sql := `SELECT * FROM template_library WHERE template_id=? `
  23. err = o.Raw(sql, templateId).QueryRow(&item)
  24. return
  25. }