package data_manage

import (
	"eta_gn/eta_api/global"
	"time"
)

// EdbPythonCode python指标运算代码
type EdbPythonCode struct {
	EdbPythonCodeId int    `orm:"column(edb_python_code_id);pk" gorm:"primaryKey" `
	EdbInfoId       int    `description:"指标id"`
	EdbCode         string `description:"指标编码"`
	PythonCode      string `description:"python代码"`
	ModifyTime      time.Time
	CreateTime      time.Time
}

// Update 更新EdbPythonCode信息
func (edbPythonCode *EdbPythonCode) Update(cols []string) (err error) {
	err = global.DmSQL["data"].Select(cols).Updates(edbPythonCode).Error

	return
}

// GetEdbPythonCodeById 根据指标id获取python代码
func GetEdbPythonCodeById(edbInfoId int) (item *EdbPythonCode, err error) {
	sql := ` SELECT * FROM edb_python_code WHERE edb_info_id=? `
	err = global.DmSQL["data"].Raw(sql, edbInfoId).First(&item).Error

	return
}