package models import "github.com/beego/beego/v2/client/orm" type TemplateLibrary struct { TemplateLibraryId int `orm:"column(template_library_id);pk"` TemplateId string `json:"template_id"` Title string `json:"title"` PrimaryIndustry string `json:"primary_industry"` DeputyIndustry string `json:"deputy_industry"` Content string `json:"content"` Example string `json:"example"` } type TemplateLibraryResp struct { TemplateList []TemplateLibrary `json:"template_list"` } func AddTemplates(items []TemplateLibrary) (err error) { o := orm.NewOrmUsingDB("cygx") _, err = o.InsertMulti(len(items), &items) return } func GetTemplateLibraryByTemplateId(templateId string) (item *TemplateLibrary, err error) { o := orm.NewOrmUsingDB("cygx") sql := `SELECT * FROM template_library WHERE template_id=? ` err = o.Raw(sql, templateId).QueryRow(&item) return }