1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package cygx
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type SummaryFastsearchKeywords struct {
- Id int `description:"活动类型id"`
- KeyWord string `description:"关键词"`
- }
- type CygxSummaryFastsearchKeywords struct {
- Id int `description:"活动类型id"`
- KeyWord string `description:"关键词"`
- CreateTime time.Time `description:"创建时间"`
- }
- type SummaryFastsearchKeywordsResp struct {
- KeyWord string `description:"关键词,多个用 , 隔开"`
- }
- type SummaryFastsearchKeyType struct {
- KeyType string `description:"关键词类型 ‘活动:Activity’,’纪要:Summary'"`
- }
- type SummaryFastsearchKeywordsListResp struct {
- List []*SummaryFastsearchKeywords
- }
- // 列表
- func GetSummaryFastsearchKeywordsList() (items []*SummaryFastsearchKeywords, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_summary_fastsearch_keywords ORDER BY sort DESC`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // 添加快捷搜索词
- func AddSummaryFastsearchKeywords(items []*CygxSummaryFastsearchKeywords) (newId int64, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- fmt.Println(err)
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- //删除原有的词库信息
- sql := ` DELETE FROM cygx_summary_fastsearch_keywords`
- _, err = to.Raw(sql).Exec()
- if err != nil {
- return
- }
- for _, v := range items {
- newId, err = to.Insert(v)
- if err != nil {
- return
- }
- }
- return
- }
|