优化结构
This commit is contained in:
@@ -73,6 +73,7 @@ func main() {
|
|||||||
|
|
||||||
//统一初始化
|
//统一初始化
|
||||||
models.ConfigAllInit()
|
models.ConfigAllInit()
|
||||||
|
routers.ReturnInit()
|
||||||
routers.ApiUserInit() //用户表先初始化这是必须的因为后面需要用到用户组
|
routers.ApiUserInit() //用户表先初始化这是必须的因为后面需要用到用户组
|
||||||
routers.ApiFilesInit()
|
routers.ApiFilesInit()
|
||||||
routers.ApiScheduleInit()
|
routers.ApiScheduleInit()
|
||||||
@@ -80,6 +81,8 @@ func main() {
|
|||||||
routers.ApiWorkOrderInit()
|
routers.ApiWorkOrderInit()
|
||||||
routers.ApiWarehouseInit()
|
routers.ApiWarehouseInit()
|
||||||
|
|
||||||
|
routers.BindsInit() //最后初始化绑定数据表
|
||||||
|
|
||||||
//创建必要目录
|
//创建必要目录
|
||||||
for _, path := range models.ConfigsFile.Pahts {
|
for _, path := range models.ConfigsFile.Pahts {
|
||||||
fmt.Println(path)
|
fmt.Println(path)
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
package routers
|
package routers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrorCode map[string]interface{}
|
|
||||||
|
|
||||||
// 版本信息,由 main.go 在启动前赋值(值来自 -ldflags 注入)
|
// 版本信息,由 main.go 在启动前赋值(值来自 -ldflags 注入)
|
||||||
var (
|
var (
|
||||||
GitVersion = "dev"
|
GitVersion = "dev"
|
||||||
@@ -17,21 +11,6 @@ var (
|
|||||||
BuildTime = "unknown"
|
BuildTime = "unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
//读取默认配置
|
|
||||||
fmt.Println("尝试读取错误码文件")
|
|
||||||
data, err := os.ReadFile("./defConfig/errorCodes.json")
|
|
||||||
if err != nil {
|
|
||||||
|
|
||||||
fmt.Println("读取错误码文件失败", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := json.Unmarshal(data, &ErrorCode); err != nil {
|
|
||||||
fmt.Println("解析错误码文件失败", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 把数据分离成cookie和json
|
// 把数据分离成cookie和json
|
||||||
func SeparateData(ctx *gin.Context) (map[string]interface{}, string) {
|
func SeparateData(ctx *gin.Context) (map[string]interface{}, string) {
|
||||||
var jsonData map[string]interface{}
|
var jsonData map[string]interface{}
|
||||||
@@ -67,9 +46,9 @@ func ApiRoot(r *gin.RouterGroup) {
|
|||||||
r.GET("/", func(ctx *gin.Context) {
|
r.GET("/", func(ctx *gin.Context) {
|
||||||
ReturnJson(ctx, "apiOK", gin.H{
|
ReturnJson(ctx, "apiOK", gin.H{
|
||||||
"isOpsApiRoot": true,
|
"isOpsApiRoot": true,
|
||||||
"version": GitVersion,
|
"version": GitVersion,
|
||||||
"gitCommit": GitCommit,
|
"gitCommit": GitCommit,
|
||||||
"buildTime": BuildTime,
|
"buildTime": BuildTime,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -92,12 +92,7 @@ type TabPurchaseCosts struct {
|
|||||||
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TabPurchaseFileBind struct {
|
|
||||||
ID uint `gorm:"primarykey"`
|
|
||||||
OrderID uint `gorm:"not null"`
|
|
||||||
FileID uint `gorm:"not null"`
|
|
||||||
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TabPurchaseCommit 记录订单状态变更及评论
|
// TabPurchaseCommit 记录订单状态变更及评论
|
||||||
type TabPurchaseCommit struct {
|
type TabPurchaseCommit struct {
|
||||||
@@ -130,7 +125,7 @@ func ApiPurchaseInit() {
|
|||||||
|
|
||||||
models.DB.AutoMigrate(&TabPurchaseOrder{})
|
models.DB.AutoMigrate(&TabPurchaseOrder{})
|
||||||
models.DB.AutoMigrate(&TabPurchaseCosts{})
|
models.DB.AutoMigrate(&TabPurchaseCosts{})
|
||||||
models.DB.AutoMigrate(&TabPurchaseFileBind{})
|
|
||||||
models.DB.AutoMigrate(&TabPurchaseLog{})
|
models.DB.AutoMigrate(&TabPurchaseLog{})
|
||||||
models.DB.AutoMigrate(&TabPurchaseCommit{})
|
models.DB.AutoMigrate(&TabPurchaseCommit{})
|
||||||
|
|
||||||
|
|||||||
@@ -41,28 +41,12 @@ type TabWarehouseItem struct {
|
|||||||
ContainerID *uint `gorm:"index;comment:所属容器id,nil=未入库" json:"ContainerID"`
|
ContainerID *uint `gorm:"index;comment:所属容器id,nil=未入库" json:"ContainerID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TabWarehouseContainerFileBind struct {
|
|
||||||
ID uint `gorm:"primaryKey"`
|
|
||||||
ContainerID uint `gorm:"not null;index;comment:关联容器id"`
|
|
||||||
FileID uint `gorm:"not null;comment:关联文件id"`
|
|
||||||
CreatorID uint `gorm:"not null;comment:上传人id"`
|
|
||||||
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TabWarehouseItemFileBind struct {
|
|
||||||
ID uint `gorm:"primaryKey"`
|
|
||||||
ItemID uint `gorm:"not null;index;comment:关联物品id"`
|
|
||||||
FileID uint `gorm:"not null;comment:关联文件id"`
|
|
||||||
CreatorID uint `gorm:"not null;comment:上传人id"`
|
|
||||||
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TabWarehouseItemCommit struct {
|
type TabWarehouseItemCommit struct {
|
||||||
ID uint `gorm:"primaryKey" json:"ID"`
|
ID uint `gorm:"primaryKey" json:"ID"`
|
||||||
ItemID uint `gorm:"not null;index;comment:关联物品id" json:"ItemID"`
|
ItemID uint `gorm:"not null;index;comment:关联物品id" json:"ItemID"`
|
||||||
UserID uint `gorm:"not null;comment:操作人id" json:"UserID"`
|
UserID uint `gorm:"not null;comment:操作人id" json:"UserID"`
|
||||||
OldContainer *uint `gorm:"index;comment:原容器id" json:"OldContainer"`
|
OldContainer *uint `gorm:"index;comment:原容器id" json:"OldContainer"`
|
||||||
NewContainer *uint `gorm:"index;comment:新容器id" json:"NewContainer"`
|
NewContainer *uint `gorm:"index;comment:新容器id" json:"NewContainer"`
|
||||||
Remark string `gorm:"type:text;comment:备注" json:"Remark"`
|
Remark string `gorm:"type:text;comment:备注" json:"Remark"`
|
||||||
IP string `gorm:"size:50;comment:操作IP" json:"IP"`
|
IP string `gorm:"size:50;comment:操作IP" json:"IP"`
|
||||||
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime" json:"CreatedAt"`
|
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime" json:"CreatedAt"`
|
||||||
@@ -81,18 +65,9 @@ type TabWarehouseLog struct {
|
|||||||
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TabWarehouseItemWorkOrderBind struct {
|
|
||||||
ID uint `gorm:"primaryKey"`
|
|
||||||
ItemID uint `gorm:"not null;index;comment:关联物品id"`
|
|
||||||
WorkOrderID uint `gorm:"not null;index;comment:关联工单id"`
|
|
||||||
Remark string `gorm:"size:500;comment:备注"`
|
|
||||||
CreatorID uint `gorm:"not null;comment:绑定人id"`
|
|
||||||
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
warehouseUserGroup TabUserGroups
|
warehouseUserGroup TabUserGroups
|
||||||
warehouseAdmins []uint
|
warehouseAdmins []uint
|
||||||
)
|
)
|
||||||
|
|
||||||
// updateWarehouseAdminsCash 刷新仓库管理员缓存
|
// updateWarehouseAdminsCash 刷新仓库管理员缓存
|
||||||
@@ -163,11 +138,8 @@ func ApiWarehouseInit() {
|
|||||||
models.DB.AutoMigrate(
|
models.DB.AutoMigrate(
|
||||||
&TabWarehouseContainer{},
|
&TabWarehouseContainer{},
|
||||||
&TabWarehouseItem{},
|
&TabWarehouseItem{},
|
||||||
&TabWarehouseContainerFileBind{},
|
|
||||||
&TabWarehouseItemFileBind{},
|
|
||||||
&TabWarehouseItemCommit{},
|
&TabWarehouseItemCommit{},
|
||||||
&TabWarehouseLog{},
|
&TabWarehouseLog{},
|
||||||
&TabWarehouseItemWorkOrderBind{},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
warehouseUserGroup.Name = "warehouse_admin"
|
warehouseUserGroup.Name = "warehouse_admin"
|
||||||
@@ -257,8 +229,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||||
models.DB.Create(&TabWarehouseContainerFileBind{
|
models.DB.Create(&TabWarehouseContainerFileBind{
|
||||||
ContainerID: c.ID,
|
ContainerID: c.ID,
|
||||||
FileID: findFile.ID,
|
FileID: findFile.ID,
|
||||||
CreatorID: user.ID,
|
CreatorID: user.ID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -470,8 +442,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnJson(ctx, "apiOK", gin.H{
|
ReturnJson(ctx, "apiOK", gin.H{
|
||||||
"all_count": count,
|
"all_count": count,
|
||||||
"containers": containers,
|
"containers": containers,
|
||||||
"canModifyContainers": canModifyContainers,
|
"canModifyContainers": canModifyContainers,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -541,10 +513,10 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnJson(ctx, "apiOK", gin.H{
|
ReturnJson(ctx, "apiOK", gin.H{
|
||||||
"container": c,
|
"container": c,
|
||||||
"photos": files,
|
"photos": files,
|
||||||
"parent_chain": parentChain,
|
"parent_chain": parentChain,
|
||||||
"depth": depth,
|
"depth": depth,
|
||||||
"canModifyContainer": canModifyWarehouse(user.ID, c.CreatorID),
|
"canModifyContainer": canModifyWarehouse(user.ID, c.CreatorID),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -558,11 +530,11 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FromAdd struct {
|
type FromAdd struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
SerialNumber string `json:"serial_number"`
|
SerialNumber string `json:"serial_number"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
Quantity int `json:"quantity"`
|
Quantity int `json:"quantity"`
|
||||||
ContainerID *uint `json:"container_id"`
|
ContainerID *uint `json:"container_id"`
|
||||||
Photos []string `json:"photos"`
|
Photos []string `json:"photos"`
|
||||||
}
|
}
|
||||||
var from FromAdd
|
var from FromAdd
|
||||||
@@ -705,11 +677,11 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FromUpdate struct {
|
type FromUpdate struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
SerialNumber string `json:"serial_number"`
|
SerialNumber string `json:"serial_number"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
Quantity int `json:"quantity"`
|
Quantity int `json:"quantity"`
|
||||||
Photos []string `json:"photos"`
|
Photos []string `json:"photos"`
|
||||||
}
|
}
|
||||||
var from FromUpdate
|
var from FromUpdate
|
||||||
@@ -906,8 +878,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnJson(ctx, "apiOK", gin.H{
|
ReturnJson(ctx, "apiOK", gin.H{
|
||||||
"all_count": count,
|
"all_count": count,
|
||||||
"items": itemsWithBreadcrumb,
|
"items": itemsWithBreadcrumb,
|
||||||
"canModifyItems": canModifyItems,
|
"canModifyItems": canModifyItems,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1011,9 +983,9 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FromMove struct {
|
type FromMove struct {
|
||||||
ItemID uint `json:"item_id"`
|
ItemID uint `json:"item_id"`
|
||||||
NewContainer *uint `json:"new_container"`
|
NewContainer *uint `json:"new_container"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
var from FromMove
|
var from FromMove
|
||||||
if err := decodeJSON(data, &from); err != nil || from.ItemID == 0 {
|
if err := decodeJSON(data, &from); err != nil || from.ItemID == 0 {
|
||||||
@@ -1095,7 +1067,7 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
ReturnJson(ctx, "apiOK", gin.H{
|
ReturnJson(ctx, "apiOK", gin.H{
|
||||||
"container_total": count.ContainerTotal,
|
"container_total": count.ContainerTotal,
|
||||||
"item_total": count.ItemTotal,
|
"item_total": count.ItemTotal,
|
||||||
"unstored_items": count.UnstoredItems,
|
"unstored_items": count.UnstoredItems,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,12 +50,7 @@ type TabWorkOrder struct {
|
|||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TabWorkOrderFileBind struct {
|
|
||||||
ID uint `gorm:"primarykey"`
|
|
||||||
WorkOrderID uint `gorm:"not null;index;comment:关联工单ID"`
|
|
||||||
FileID uint `gorm:"not null;comment:关联文件ID"`
|
|
||||||
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TabWorkOrderCommit struct {
|
type TabWorkOrderCommit struct {
|
||||||
ID uint `gorm:"primarykey"`
|
ID uint `gorm:"primarykey"`
|
||||||
@@ -81,22 +76,7 @@ type TabWorkOrderLog struct {
|
|||||||
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TabWorkOrderCommitFileBind struct {
|
|
||||||
ID uint `gorm:"primarykey"`
|
|
||||||
CommitID uint `gorm:"not null;index;comment:关联进度ID"`
|
|
||||||
FileID uint `gorm:"not null;comment:关联文件ID"`
|
|
||||||
WorkOrderID uint `gorm:"not null;index;comment:关联工单ID"`
|
|
||||||
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TabWorkOrderPurchaseOrderBind 工单与采购订单的关联表
|
|
||||||
type TabWorkOrderPurchaseOrderBind struct {
|
|
||||||
ID uint `gorm:"primarykey"`
|
|
||||||
WorkOrderID uint `gorm:"not null;index;comment:关联工单ID"`
|
|
||||||
CommitID uint `gorm:"not null;index;comment:关联进度ID"`
|
|
||||||
PurchaseOrderID uint `gorm:"not null;comment:关联采购订单ID"`
|
|
||||||
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PurchaseOrderInfo 采购订单简要信息
|
// PurchaseOrderInfo 采购订单简要信息
|
||||||
type PurchaseOrderInfo struct {
|
type PurchaseOrderInfo struct {
|
||||||
@@ -109,11 +89,10 @@ type PurchaseOrderInfo struct {
|
|||||||
|
|
||||||
func ApiWorkOrderInit() {
|
func ApiWorkOrderInit() {
|
||||||
models.DB.AutoMigrate(&TabWorkOrder{})
|
models.DB.AutoMigrate(&TabWorkOrder{})
|
||||||
models.DB.AutoMigrate(&TabWorkOrderFileBind{})
|
|
||||||
models.DB.AutoMigrate(&TabWorkOrderCommit{})
|
models.DB.AutoMigrate(&TabWorkOrderCommit{})
|
||||||
models.DB.AutoMigrate(&TabWorkOrderLog{})
|
models.DB.AutoMigrate(&TabWorkOrderLog{})
|
||||||
models.DB.AutoMigrate(&TabWorkOrderCommitFileBind{})
|
|
||||||
models.DB.AutoMigrate(&TabWorkOrderPurchaseOrderBind{})
|
|
||||||
|
|
||||||
workOrderUserGroup.Name = "work_order_admin"
|
workOrderUserGroup.Name = "work_order_admin"
|
||||||
if models.DB.Where(&workOrderUserGroup).First(&workOrderUserGroup).Error == nil {
|
if models.DB.Where(&workOrderUserGroup).First(&workOrderUserGroup).Error == nil {
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package routers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ops/models"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
//跨模块绑定区
|
||||||
|
//绑定数据统一处理区
|
||||||
|
|
||||||
|
type TabPurchaseFileBind struct {
|
||||||
|
ID uint `gorm:"primarykey"`
|
||||||
|
OrderID uint `gorm:"not null"`
|
||||||
|
FileID uint `gorm:"not null"`
|
||||||
|
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TabWarehouseItemFileBind struct {
|
||||||
|
ID uint `gorm:"primaryKey"`
|
||||||
|
ItemID uint `gorm:"not null;index;comment:关联物品id"`
|
||||||
|
FileID uint `gorm:"not null;comment:关联文件id"`
|
||||||
|
CreatorID uint `gorm:"not null;comment:上传人id"`
|
||||||
|
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TabWarehouseItemWorkOrderBind struct {
|
||||||
|
ID uint `gorm:"primaryKey"`
|
||||||
|
ItemID uint `gorm:"not null;index;comment:关联物品id"`
|
||||||
|
WorkOrderID uint `gorm:"not null;index;comment:关联工单id"`
|
||||||
|
Remark string `gorm:"size:500;comment:备注"`
|
||||||
|
CreatorID uint `gorm:"not null;comment:绑定人id"`
|
||||||
|
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TabWorkOrderFileBind struct {
|
||||||
|
ID uint `gorm:"primarykey"`
|
||||||
|
WorkOrderID uint `gorm:"not null;index;comment:关联工单ID"`
|
||||||
|
FileID uint `gorm:"not null;comment:关联文件ID"`
|
||||||
|
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TabWorkOrderCommitFileBind struct {
|
||||||
|
ID uint `gorm:"primarykey"`
|
||||||
|
CommitID uint `gorm:"not null;index;comment:关联进度ID"`
|
||||||
|
FileID uint `gorm:"not null;comment:关联文件ID"`
|
||||||
|
WorkOrderID uint `gorm:"not null;index;comment:关联工单ID"`
|
||||||
|
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TabWorkOrderPurchaseOrderBind 工单与采购订单的关联表
|
||||||
|
type TabWorkOrderPurchaseOrderBind struct {
|
||||||
|
ID uint `gorm:"primarykey"`
|
||||||
|
WorkOrderID uint `gorm:"not null;index;comment:关联工单ID"`
|
||||||
|
CommitID uint `gorm:"not null;index;comment:关联进度ID"`
|
||||||
|
PurchaseOrderID uint `gorm:"not null;comment:关联采购订单ID"`
|
||||||
|
CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TabWarehouseContainerFileBind struct {
|
||||||
|
ID uint `gorm:"primaryKey"`
|
||||||
|
ContainerID uint `gorm:"not null;index;comment:关联容器id"`
|
||||||
|
FileID uint `gorm:"not null;comment:关联文件id"`
|
||||||
|
CreatorID uint `gorm:"not null;comment:上传人id"`
|
||||||
|
CreatedAt time.Time `gorm:"type:datetime;autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func BindsInit() {
|
||||||
|
models.DB.AutoMigrate(
|
||||||
|
&TabPurchaseFileBind{},
|
||||||
|
&TabWarehouseItemFileBind{},
|
||||||
|
&TabWarehouseItemWorkOrderBind{},
|
||||||
|
&TabWarehouseContainerFileBind{},
|
||||||
|
&TabWorkOrderFileBind{},
|
||||||
|
&TabWorkOrderCommitFileBind{},
|
||||||
|
&TabWorkOrderPurchaseOrderBind{},
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,10 +3,27 @@ package routers
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrorCode map[string]interface{}
|
||||||
|
|
||||||
|
func ReturnInit() {
|
||||||
|
//读取默认配置
|
||||||
|
fmt.Println("尝试读取错误码文件")
|
||||||
|
data, err := os.ReadFile("./defConfig/errorCodes.json")
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
fmt.Println("读取错误码文件失败", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := json.Unmarshal(data, &ErrorCode); err != nil {
|
||||||
|
fmt.Println("解析错误码文件失败", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func DebugPrintJson(data map[string]interface{}) {
|
func DebugPrintJson(data map[string]interface{}) {
|
||||||
p, _ := json.MarshalIndent(data, "", " ")
|
p, _ := json.MarshalIndent(data, "", " ")
|
||||||
fmt.Println("\n", string(p))
|
fmt.Println("\n", string(p))
|
||||||
|
|||||||
Reference in New Issue
Block a user