提交 bc079d87 编写于 作者: 雨爱无痕

Merge branch 'master' of https://github.com/easysoft/zendata

Version = 2.3
Version = 3.1.0
Language = zh
VERSION=2.3
VERSION=3.1.0
PROJECT=zd
ifeq ($(OS),Windows_NT)
......
{
"name": "zd",
"productName": "zd",
"version": "1.0.0",
"version": "3.1.0",
"description": "zd",
"main": ".webpack/main",
"scripts": {
......
......@@ -2,6 +2,7 @@ package commandConfig
import (
consts "github.com/easysoft/zendata/internal/pkg/const"
"github.com/easysoft/zendata/internal/pkg/model"
"github.com/easysoft/zendata/pkg/utils/vari"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
......@@ -14,5 +15,9 @@ func NewGormDB() (gormDb *gorm.DB, err error) {
gormDb = gormDb.Debug()
}
err = gormDb.AutoMigrate(
model.Models...,
)
return
}
......@@ -94,7 +94,7 @@ var (
SqliteDriver = "sqlite3"
SqliteFile = "file:" + TmpDir + "cache/.data.db"
SqliteTrackTable = "excel_update"
SqliteTrackTable = "zd_excel"
ExcelBorder = `{"border": [{"type":"left","color":"999999","style":1}, {"type":"top","color":"999999","style":1},
{"type":"bottom","color":"999999","style":1}, {"type":"right","color":"999999","style":1}]}`
......
......@@ -7,8 +7,9 @@ import (
var (
CommonPrefix = "zd_"
Models = []interface{}{
&ZdExcel{},
&ZdDef{}, &ZdField{}, &ZdSection{}, &ZdRefer{},
&ZdRanges{}, &ZdRangesItem{}, &ZdText{}, &ZdConfig{}, &ZdInstances{}, &ZdInstancesItem{}, &ZdExcel{},
&ZdRanges{}, &ZdRangesItem{}, &ZdText{}, &ZdConfig{}, &ZdInstances{}, &ZdInstancesItem{},
&ZdMock{}, &ZdMockSampleSrc{},
}
)
......@@ -293,11 +294,12 @@ type ZdExcel struct {
Title string `gorm:"column:title" json:"title"`
Sheet string `gorm:"column:sheet" json:"sheet"`
Yaml string `gorm:"yaml" json:"yaml"`
Path string `gorm:"column:path" json:"path" yaml:"-"`
Folder string `gorm:"folder" json:"folder" yaml:"-"`
FileName string `gorm:"column:fileName" json:"fileName" yaml:"-"`
ReferName string `gorm:"column:referName" json:"referName" yaml:"-"`
ChangeTime string `gorm:"column:changeTime" json:"changeTime"`
Yaml string `gorm:"yaml" json:"yaml"`
Path string `gorm:"column:path" json:"path" yaml:"-"`
Folder string `gorm:"folder" json:"folder" yaml:"-"`
FileName string `gorm:"column:fileName" json:"fileName" yaml:"-"`
ReferName string `gorm:"column:referName" json:"referName" yaml:"-"`
}
func (*ZdExcel) TableName() string {
......
......@@ -405,8 +405,8 @@ func (s *ExcelService) isExcelChanged(path string) (changed bool, sqlBeforeCompl
fileChangeTime = s.getDirModTime(path).Unix()
}
sqlStr := fmt.Sprintf("SELECT id, name, changeTime FROM %s "+
"WHERE name = '%s' "+
sqlStr := fmt.Sprintf("SELECT id, path, changeTime FROM %s "+
"WHERE path = '%s' "+
"ORDER BY changeTime DESC "+
"LIMIT 1;",
consts.SqliteTrackTable, path)
......@@ -435,10 +435,10 @@ func (s *ExcelService) isExcelChanged(path string) (changed bool, sqlBeforeCompl
if changed {
if !found {
sqlBeforeCompleted = fmt.Sprintf("INSERT INTO %s(name, changeTime) VALUES('%s', %d)",
sqlBeforeCompleted = fmt.Sprintf("INSERT INTO %s(path, changeTime) VALUES('%s', %d)",
consts.SqliteTrackTable, path, fileChangeTime)
} else {
sqlBeforeCompleted = fmt.Sprintf("UPDATE %s SET changeTime = %d WHERE name = '%s'",
sqlBeforeCompleted = fmt.Sprintf("UPDATE %s SET changeTime = %d WHERE path = '%s'",
consts.SqliteTrackTable, fileChangeTime, path)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册