package data_manage import ( "eta_gn/eta_api/global" "eta_gn/eta_api/utils" ) // GetChartInfoByPublicClassifyId // @Description: 根据公共分类id获取指标列表 // @author: Roc // @datetime 2024-12-03 14:09:32 // @param classifyId int // @param chartInfoType int // @param source int // @return items []*ChartClassifyItems // @return err error func GetChartInfoByPublicClassifyId(classifyId, source int) (items []*ChartClassifyItems, err error) { o := global.DmSQL["data"] sql := ` SELECT chart_info_id,chart_classify_id,chart_public_classify_id,chart_name AS chart_classify_name,chart_name_en AS chart_classify_name_en,unique_code,source,sys_user_id,sys_user_real_name,start_date,chart_type, public_sort as sort,is_join_permission FROM chart_info WHERE chart_public_classify_id = ? AND source = ?` sql += ` order by public_sort asc,chart_info_id asc ` err = o.Raw(sql, classifyId, source).Scan(&items).Error return } // UpdatePublicChartSuccess // @Description: 更新指标的公开成功状态 // @author: Roc // @datetime 2024-12-06 13:37:01 // @param chartInfoId int // @param classifyId int // @return err error func UpdatePublicChartSuccess(chartInfoId, classifyId int) (err error) { sql := `UPDATE chart_info set public_status = ?,chart_public_classify_id = ? ,modify_time=now(),public_time = now() WHERE chart_info_id = ?` err = global.DmSQL["data"].Exec(sql, utils.DataPublicSuccess, classifyId, chartInfoId).Error return } // UpdatePublicChart // @Description: 更新指标的公开状态 // @author: Roc // @datetime 2024-12-06 11:10:53 // @param chartInfoIdList []int // @param status int // @return err error func UpdatePublicChart(chartInfoIdList []int, status int) (err error) { if len(chartInfoIdList) <= 0 { return } sql := `UPDATE chart_info set public_status = ?,modify_time=now() ` if status == utils.DataPublicSuccess { sql += `,public_time = now() ` } sql += ` WHERE chart_info_id in (?) ` err = global.DmSQL["data"].Exec(sql, status, chartInfoIdList).Error return } // UpdatePublicClassifyIdByChartInfoIdList // @Description: 根据指标id列表更新所属公共分类id // @author: Roc // @datetime 2024-12-10 13:18:52 // @param chartInfoId int // @param chartClassifyId int // @return err error func UpdatePublicClassifyIdByChartInfoIdList(chartInfoIdList []int, chartClassifyId int) (err error) { if len(chartInfoIdList) <= 0 { return } sql := ` UPDATE chart_info SET chart_public_classify_id = ? WHERE chart_info_id in (?) AND public_status = 3 ` err = global.DmSQL["data"].Exec(sql, chartClassifyId, chartInfoIdList).Error return }