修改文件表的名字
This commit is contained in:
@@ -180,7 +180,7 @@ func ApiPurchase(r *gin.RouterGroup) {
|
||||
for _, b := range binds {
|
||||
fileIDs = append(fileIDs, b.FileID)
|
||||
}
|
||||
var files []TabFileInfo_
|
||||
var files []TabFileInfo
|
||||
if len(fileIDs) > 0 {
|
||||
models.DB.Where("id IN ?", fileIDs).Find(&files)
|
||||
}
|
||||
@@ -585,7 +585,7 @@ func ApiPurchase(r *gin.RouterGroup) {
|
||||
|
||||
//绑定文件
|
||||
for i := 0; i < len(jsondata.Photos); i++ {
|
||||
findFile := TabFileInfo_{
|
||||
findFile := TabFileInfo{
|
||||
Sha256: jsondata.Photos[i],
|
||||
Type: "image",
|
||||
}
|
||||
@@ -731,7 +731,7 @@ func ApiPurchase(r *gin.RouterGroup) {
|
||||
// 重建图片绑定:先删旧,再插新
|
||||
models.DB.Where("order_id = ?", from.ID).Delete(&TabPurchaseFileBind{})
|
||||
for _, hash := range from.Photos {
|
||||
findFile := TabFileInfo_{Sha256: hash, Type: "image"}
|
||||
findFile := TabFileInfo{Sha256: hash, Type: "image"}
|
||||
if models.DB.Where(&findFile).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabPurchaseFileBind{
|
||||
OrderID: from.ID,
|
||||
|
||||
@@ -253,8 +253,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
|
||||
// 绑定图片
|
||||
for _, hash := range from.Photos {
|
||||
var findFile TabFileInfo_
|
||||
if models.DB.Where(&TabFileInfo_{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
var findFile TabFileInfo
|
||||
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWarehouseContainerFileBind{
|
||||
ContainerID: c.ID,
|
||||
FileID: findFile.ID,
|
||||
@@ -335,8 +335,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
// 重建图片绑定
|
||||
models.DB.Where("container_id = ?", from.ID).Delete(&TabWarehouseContainerFileBind{})
|
||||
for _, hash := range from.Photos {
|
||||
var findFile TabFileInfo_
|
||||
if models.DB.Where(&TabFileInfo_{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
var findFile TabFileInfo
|
||||
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWarehouseContainerFileBind{
|
||||
ContainerID: from.ID,
|
||||
FileID: findFile.ID,
|
||||
@@ -535,7 +535,7 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
for _, b := range binds {
|
||||
fileIDs = append(fileIDs, b.FileID)
|
||||
}
|
||||
var files []TabFileInfo_
|
||||
var files []TabFileInfo
|
||||
if len(fileIDs) > 0 {
|
||||
models.DB.Where("id IN ?", fileIDs).Find(&files)
|
||||
}
|
||||
@@ -639,8 +639,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
|
||||
// 绑定图片
|
||||
for _, hash := range from.Photos {
|
||||
var findFile TabFileInfo_
|
||||
if models.DB.Where(&TabFileInfo_{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
var findFile TabFileInfo
|
||||
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWarehouseItemFileBind{
|
||||
ItemID: item.ID,
|
||||
FileID: findFile.ID,
|
||||
@@ -668,8 +668,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
|
||||
// 新增/更新时绑定图片
|
||||
for _, hash := range from.Photos {
|
||||
var findFile TabFileInfo_
|
||||
if models.DB.Where(&TabFileInfo_{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
var findFile TabFileInfo
|
||||
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
// 检查是否已绑定,避免重复
|
||||
var count int64
|
||||
models.DB.Model(&TabWarehouseItemFileBind{}).Where("item_id = ? AND file_id = ?", itemID, findFile.ID).Count(&count)
|
||||
@@ -748,8 +748,8 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
// 重建图片绑定
|
||||
models.DB.Where("item_id = ?", from.ID).Delete(&TabWarehouseItemFileBind{})
|
||||
for _, hash := range from.Photos {
|
||||
var findFile TabFileInfo_
|
||||
if models.DB.Where(&TabFileInfo_{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
var findFile TabFileInfo
|
||||
if models.DB.Where(&TabFileInfo{Sha256: hash, Type: "image"}).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWarehouseItemFileBind{
|
||||
ItemID: from.ID,
|
||||
FileID: findFile.ID,
|
||||
@@ -942,7 +942,7 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
||||
for _, b := range binds {
|
||||
fileIDs = append(fileIDs, b.FileID)
|
||||
}
|
||||
var files []TabFileInfo_
|
||||
var files []TabFileInfo
|
||||
if len(fileIDs) > 0 {
|
||||
models.DB.Where("id IN ?", fileIDs).Find(&files)
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ func ApiWorkOrder(r *gin.RouterGroup) {
|
||||
|
||||
// 绑定图片
|
||||
for _, hash := range from.Photos {
|
||||
findFile := TabFileInfo_{Sha256: hash, Type: "image"}
|
||||
findFile := TabFileInfo{Sha256: hash, Type: "image"}
|
||||
if models.DB.Where(&findFile).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWorkOrderFileBind{
|
||||
WorkOrderID: order.ID,
|
||||
@@ -257,7 +257,7 @@ func ApiWorkOrder(r *gin.RouterGroup) {
|
||||
// 重建图片绑定
|
||||
models.DB.Where("work_order_id = ?", from.ID).Delete(&TabWorkOrderFileBind{})
|
||||
for _, hash := range from.Photos {
|
||||
findFile := TabFileInfo_{Sha256: hash, Type: "image"}
|
||||
findFile := TabFileInfo{Sha256: hash, Type: "image"}
|
||||
if models.DB.Where(&findFile).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWorkOrderFileBind{
|
||||
WorkOrderID: from.ID,
|
||||
@@ -357,7 +357,7 @@ func ApiWorkOrder(r *gin.RouterGroup) {
|
||||
for _, b := range binds {
|
||||
fileIDs = append(fileIDs, b.FileID)
|
||||
}
|
||||
var files []TabFileInfo_
|
||||
var files []TabFileInfo
|
||||
if len(fileIDs) > 0 {
|
||||
models.DB.Where("id IN ?", fileIDs).Find(&files)
|
||||
}
|
||||
@@ -369,12 +369,12 @@ func ApiWorkOrder(r *gin.RouterGroup) {
|
||||
// 为每条 commit 附加图片和采购订单
|
||||
type CommitWithPhotos struct {
|
||||
TabWorkOrderCommit
|
||||
Photos []TabFileInfo_ `json:"photos"`
|
||||
Photos []TabFileInfo `json:"photos"`
|
||||
PurchaseOrders []PurchaseOrderInfo `json:"purchaseOrders"`
|
||||
}
|
||||
var commitsWithPhotos []CommitWithPhotos
|
||||
for _, c := range commits {
|
||||
item := CommitWithPhotos{TabWorkOrderCommit: c, Photos: []TabFileInfo_{}, PurchaseOrders: []PurchaseOrderInfo{}}
|
||||
item := CommitWithPhotos{TabWorkOrderCommit: c, Photos: []TabFileInfo{}, PurchaseOrders: []PurchaseOrderInfo{}}
|
||||
|
||||
// 附加图片
|
||||
var fileBinds []TabWorkOrderCommitFileBind
|
||||
@@ -547,7 +547,7 @@ func ApiWorkOrder(r *gin.RouterGroup) {
|
||||
|
||||
// 绑定进度图片
|
||||
for _, hash := range from.Photos {
|
||||
findFile := TabFileInfo_{Sha256: hash, Type: "image"}
|
||||
findFile := TabFileInfo{Sha256: hash, Type: "image"}
|
||||
if models.DB.Where(&findFile).First(&findFile).Error == nil {
|
||||
models.DB.Create(&TabWorkOrderCommitFileBind{
|
||||
CommitID: commit.ID,
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type TabFileInfo_ struct {
|
||||
type TabFileInfo struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement"`
|
||||
Name string `gorm:"not null;size:256;index"` // 前端报告的文件名
|
||||
Size int64 `gorm:"not null"`
|
||||
@@ -31,7 +31,7 @@ func file_save() {
|
||||
|
||||
func ApiFilesInit() {
|
||||
|
||||
models.DB.AutoMigrate(&TabFileInfo_{})
|
||||
models.DB.AutoMigrate(&TabFileInfo{})
|
||||
}
|
||||
|
||||
func ApiFiles(r *gin.RouterGroup) {
|
||||
@@ -55,7 +55,7 @@ func ApiFiles(r *gin.RouterGroup) {
|
||||
download = false
|
||||
}
|
||||
if isPartOK {
|
||||
file_info := TabFileInfo_{
|
||||
file_info := TabFileInfo{
|
||||
Sha256: hash,
|
||||
}
|
||||
if models.DB.Where(&file_info).First(&file_info).Error == nil {
|
||||
@@ -127,7 +127,7 @@ func ApiFiles(r *gin.RouterGroup) {
|
||||
}
|
||||
//记录到数据库
|
||||
//先检查数据库有没有数据
|
||||
fund_file_info := TabFileInfo_{
|
||||
fund_file_info := TabFileInfo{
|
||||
Name: filename,
|
||||
Size: file.Size,
|
||||
Sha256: hash_str,
|
||||
@@ -135,7 +135,7 @@ func ApiFiles(r *gin.RouterGroup) {
|
||||
Type: "image",
|
||||
UserID: user.ID,
|
||||
}
|
||||
fund_file_info2 := TabFileInfo_{}
|
||||
fund_file_info2 := TabFileInfo{}
|
||||
|
||||
models.DB.Where(&fund_file_info).Find(&fund_file_info2)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func ReturnJson(ctx *gin.Context, errMsg string, data map[string]interface{}) {
|
||||
|
||||
}
|
||||
|
||||
func ReturnFile(ctx *gin.Context, file_info *TabFileInfo_, preview bool) {
|
||||
func ReturnFile(ctx *gin.Context, file_info *TabFileInfo, preview bool) {
|
||||
if preview {
|
||||
ctx.File(file_info.Path)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user