1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package index
- import (
- "context"
- "hongze/mysteel_watch/global"
- "hongze/mysteel_watch/models/base"
- )
- // 钢联化工指标数据
- type BaseFromMysteelChemicalIndex struct {
- BaseFromMysteelChemicalIndexId int64 `gorm:"primaryKey;column:base_from_mysteel_chemical_index_id" json:"base_from_mysteel_chemical_index_id"` //序号
- IndexCode string `gorm:"column:index_code" json:"index_code"`
- IndexName string `gorm:"column:index_name" json:"index_name"`
- Unit string `gorm:"column:unit" json:"unit"`
- Source string `gorm:"column:source" json:"source"`
- Frequency string `gorm:"column:frequency" json:"frequency"`
- StartDate string `gorm:"column:start_date" json:"start_date"`
- EndDate string `gorm:"column:end_date" json:"end_date"`
- Describe string `gorm:"column:describe" json:"describe"`
- UpdateWeek string `gorm:"column:update_week" json:"update_week"`
- SysUserId int `gorm:"column:sys_user_id" json:"sys_user_id"`
- SysUserRealName string `gorm:"column:sys_user_real_name" json:"sys_user_real_name"`
- base.TimeBase
- }
- // TableName get sql table name.获取数据库表名
- func (r *BaseFromMysteelChemicalIndex) TableName() string {
- return "base_from_mysteel_chemical_index"
- }
- // 新增
- func (r *BaseFromMysteelChemicalIndex) Add(runMod string) (err error) {
- if runMod == "release" {
- err = global.MYSQL["hzdata"].Create(r).Error
- return
- } else {
- err = global.DEFAULT_MYSQL.Create(r).Error
- return
- }
- }
- // 修改
- func (r *BaseFromMysteelChemicalIndex) Update(runMod string, updateCols []string) (err error) {
- if runMod == "release" {
- err = global.MYSQL["hzdata"].Model(r).Select(updateCols).Updates(r).Error
- return
- } else {
- err = global.DEFAULT_MYSQL.Model(r).Select(updateCols).Updates(r).Error
- return
- }
- }
- type IndexAddReq struct {
- IndexCode string `json:"IndexCode" binding:"required"` //指标编码
- UpdateWeek string `json:"UpdateWeek"` //更新周期
- RunMode string `description:"运行环境:debug:测试(默认),release:生产" json:"UpdateWeek"` //更新周期
- }
- func (d *BaseFromMysteelChemicalIndex) GetIndexItem(runMod, indexCode string) (item *BaseFromMysteelChemicalIndex, err error) {
- if runMod == "release" {
- err = global.MYSQL["hzdata"].WithContext(context.TODO()).Model(d).
- Where("index_code = ?", indexCode).First(&item).Error
- return
- } else {
- err = global.DEFAULT_MYSQL.WithContext(context.TODO()).Model(d).
- Where("index_code = ?", indexCode).First(&item).Error
- return
- }
- }
- type IndexDeleteReq struct {
- IndexCode string `json:"IndexCode" binding:"required"` //指标编码
- }
|