12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxReportMappingCategoryGroup struct {
- Id int `orm:"column(id);pk" description:"id"`
- ChartPermissionId int `description:"行业ID"`
- IdCygx int `description:"表cygx_report_mapping_cygx 主键ID"`
- ArticleId int `description:"报告Id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- PermissionType int `description:"1主观,2客观 ,0不限制"`
- }
- type CygxReportMappingCategoryGroupResp struct {
- Id int `orm:"column(id);pk" description:"id"`
- ChartPermissionId int `description:"行业ID"`
- IdCygx int `description:"表cygx_report_mapping_cygx 主键ID"`
- ArticleId int `description:"报告Id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- PermissionType int `description:"1主观,2客观 ,0不限制"`
- }
- // AddCygxReportMappingCategoryGroupMulti 批量添加
- func AddCygxReportMappingCategoryGroupMulti(items []*CygxReportMappingCategoryGroup, articleId int) (err error) {
- o, err := orm.NewOrm().Begin()
- if err != nil {
- return
- }
- defer func() {
- if err == nil {
- o.Commit()
- } else {
- o.Rollback()
- }
- }()
- //删除原有数据
- sql := ` DELETE FROM cygx_report_mapping_category_group WHERE article_id = ? AND is_by_hand = 0 `
- _, err = o.Raw(sql, articleId).Exec()
- if err != nil {
- return
- }
- //批量插入新的关联数据
- if len(items) > 0 {
- //批量添加流水信息
- _, err = o.InsertMulti(len(items), items)
- }
- return
- }
- // 列表
- func GetCygxReportMappingCategoryGroupList(condition string, pars []interface{}) (items []*CygxReportMappingCategoryGroupResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_report_mapping_category_group as art WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
|