1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxIndustrialActivityGroupManagement struct {
- Id int `orm:"column(id);pk" description:"主键ID"`
- ActivityId int `description:"活动ID"`
- IndustrialManagementId int `description:"cygx_industrial_management表的主键ID"`
- Source int `description:"来源,1 活动,2专项调研"`
- CreateTime time.Time `description:"创建时间"`
- }
- // 获取标的列表
- func GetCygxIndustrialSubjectList(subjectName string) (items []*CygxIndustrialSubject, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- s.*
- FROM
- cygx_industrial_subject as s
- INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = s.industrial_management_id
- WHERE
- subject_name = ? `
- _, err = o.Raw(sql, subjectName).QueryRows(&items)
- return
- }
- // AddCygxActiuvityGroupMulti 批量添加
- func AddCygxActiuvityGroupMulti(items []*CygxIndustrialActivityGroupManagement, itemsSubject []*CygxIndustrialActivityGroupSubject) (err error) {
- o, err := orm.NewOrm().Begin()
- if err != nil {
- return
- }
- defer func() {
- if err == nil {
- o.Commit()
- } else {
- o.Rollback()
- }
- }()
- if len(items) > 0 {
- //批量添加关联的产业
- _, err = o.InsertMulti(len(items), items)
- }
- if len(itemsSubject) > 0 {
- //批量添加关联的标的
- _, err = o.InsertMulti(len(itemsSubject), itemsSubject)
- }
- return
- }
- // GetActivityIndustryRelationList 获取活动与产业关联列表
- func GetActivityIndustryRelationList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
- sql := `SELECT
- a.activity_id,
- b.industrial_management_id
- FROM
- cygx_activity AS a
- JOIN cygx_industrial_activity_group_management AS b ON a.activity_id = b.activity_id
- WHERE
- 1 = 1 AND b.source = 1 `
- if condition != `` {
- sql += condition
- }
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
- // 获取数量
- func GetCygxIndustrialActivityGroupManagementCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_industrial_activity_group_management as art WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // CygxIndustrialActivityGroupManagement 获取活动与产业关联列表
- func GetCygxIndustrialActivityGroupManagementList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
- sql := `SELECT
- *
- FROM
- cygx_industrial_activity_group_management
- WHERE
- 1 = 1 `
- if condition != `` {
- sql += condition
- }
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
|