diff --git a/api/shiyan/maptostruct/shiyan.go b/api/shiyan/maptostruct/shiyan.go index c8a029f..fa428fc 100644 --- a/api/shiyan/maptostruct/shiyan.go +++ b/api/shiyan/maptostruct/shiyan.go @@ -914,3 +914,13 @@ func generateSchedule(startDate time.Time, numDays int) []Shift { } return shifts } + +/* +* +@ 作者: 秦东 +@ 时间: 2026-01-13 10:14:42 +@ 功能: 校正数据表字段 +*/ +func (a *ApiMethod) JiaoZhengTableWord(c *gin.Context) { + +} diff --git a/api/version1/dataCenter/runDataBase.go b/api/version1/dataCenter/runDataBase.go index e5652da..5bc72b0 100644 --- a/api/version1/dataCenter/runDataBase.go +++ b/api/version1/dataCenter/runDataBase.go @@ -54,18 +54,48 @@ func (a *ApiMethod) GainDataTable(c *gin.Context) { return } tableInfo, err := requestData.ObtainDataBaseAllTableMysql() - fmt.Printf("tableInfo:%v\n", tableInfo) - for _, v := range tableInfo { - // if v.TableKey != "taskrecord" { - sql := fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建人行政组织';", v.TableKey, "createrOrg") - overall.CONSTANT_DB_CustomerForm.Exec(sql) - // } - } + // fmt.Printf("tableInfo:%v\n", tableInfo) + // for _, v := range tableInfo { + // // if v.TableKey != "taskrecord" { + // sql := fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建人行政组织';", v.TableKey, "createrOrg") + // overall.CONSTANT_DB_CustomerForm.Exec(sql) + // // } + // } + // for _, v := range tableInfo { + // // if v.TableKey != "taskrecord" { + // sql := fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建人岗位';", v.TableKey, "createrPositon") + // overall.CONSTANT_DB_CustomerForm.Exec(sql) + // // } + // } + for _, v := range tableInfo { - // if v.TableKey != "taskrecord" { - sql := fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建人岗位';", v.TableKey, "createrPositon") - overall.CONSTANT_DB_CustomerForm.Exec(sql) - // } + var haveWordKey []string + for _, tv := range v.Fields { + if !publicmethod.IsInTrue[string](tv.Field, haveWordKey) { + haveWordKey = append(haveWordKey, tv.Field) + } + } + if len(haveWordKey) > 0 { + WriteTableKey(v.TableKey, haveWordKey) + } + } + publicmethod.Result(0, tableInfo, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2026-01-13 10:32:27 +@ 功能: 写入表格欠缺的字段 +*/ +func WriteTableKey(tableName string, wordKey []string) { + oldTable := []string{"id", "masters_key", "creater", "createrOrg", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen", "createrPositon"} + for _, ov := range oldTable { + if !publicmethod.IsInTrue[string](ov, wordKey) { + sql := fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建人岗位';", tableName, ov) + overall.CONSTANT_DB_CustomerForm.Exec(sql) + } + } +} diff --git a/models/customerForm/taskrecord.go b/models/customerForm/taskrecord.go index 811a717..0c6557e 100644 --- a/models/customerForm/taskrecord.go +++ b/models/customerForm/taskrecord.go @@ -31,7 +31,7 @@ type TaskRecord struct { RunFlowId int64 `json:"runFlowId" gorm:"column:runFlowId;type:bigint(20) unsigned;default:0;not null;comment:正在执行得流程"` MsgId int64 `json:"msgId" gorm:"column:msgId;type:bigint(20) unsigned;default:0;not null;comment:发送消息得任务ID"` CreaterOrg int64 `json:"createrOrg" gorm:"column:createrOrg;type:bigint(20) unsigned;default:0;not null;comment:发起人行政组织"` - CreaterPositon int64 `json:"createrPositon" gorm:"column:createrPositon;type:bigint(20) unsigned;default:0;not null;comment:发起人岗位"` + CreaterPositon int64 `json:" " gorm:"column:createrPositon;type:bigint(20) unsigned;default:0;not null;comment:发起人岗位"` } func (TaskRecord *TaskRecord) TableName() string {