From 2ba261ddf0269cf131721605eadf45fd033dc002 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期五, 10 十一月 2023 10:43:16 +0800
Subject: [PATCH] bug修改

---
 utils/image/image.go |    8 ++
 models/material.go   |    2 
 docs/swagger.yaml    |   35 +++++++++++
 docs/docs.go         |   50 ++++++++++++++++
 docs/swagger.json    |   50 ++++++++++++++++
 5 files changed, 143 insertions(+), 2 deletions(-)

diff --git a/docs/docs.go b/docs/docs.go
index 1a45405..05469e2 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2224,6 +2224,24 @@
                 "CostingMethodAverageCost"
             ]
         },
+        "constvar.FileType": {
+            "type": "string",
+            "enum": [
+                "file",
+                "picture",
+                "thumbnail"
+            ],
+            "x-enum-comments": {
+                "FileType_File": "鏂囦欢",
+                "FileType_Picture": "鍥剧墖",
+                "FileType_Thumbnail": "缂╃暐鍥�"
+            },
+            "x-enum-varnames": [
+                "FileType_File",
+                "FileType_Picture",
+                "FileType_Thumbnail"
+            ]
+        },
         "constvar.ForceRemovalStrategy": {
             "type": "integer",
             "enum": [
@@ -2436,6 +2454,26 @@
                 "ReservationNever"
             ]
         },
+        "models.Attachment": {
+            "type": "object",
+            "properties": {
+                "FileUrl": {
+                    "type": "string"
+                },
+                "ext": {
+                    "type": "string"
+                },
+                "fileName": {
+                    "type": "string"
+                },
+                "fileType": {
+                    "$ref": "#/definitions/constvar.FileType"
+                },
+                "id": {
+                    "type": "integer"
+                }
+            }
+        },
         "models.Company": {
             "type": "object",
             "properties": {
@@ -2579,6 +2617,18 @@
                     "description": "鏁伴噺",
                     "type": "number"
                 },
+                "attachmentIDs": {
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "attachmentList": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Attachment"
+                    }
+                },
                 "barcode": {
                     "description": "鏉$爜",
                     "type": "string"
diff --git a/docs/swagger.json b/docs/swagger.json
index 12bd7d8..ad5b07c 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2212,6 +2212,24 @@
                 "CostingMethodAverageCost"
             ]
         },
+        "constvar.FileType": {
+            "type": "string",
+            "enum": [
+                "file",
+                "picture",
+                "thumbnail"
+            ],
+            "x-enum-comments": {
+                "FileType_File": "鏂囦欢",
+                "FileType_Picture": "鍥剧墖",
+                "FileType_Thumbnail": "缂╃暐鍥�"
+            },
+            "x-enum-varnames": [
+                "FileType_File",
+                "FileType_Picture",
+                "FileType_Thumbnail"
+            ]
+        },
         "constvar.ForceRemovalStrategy": {
             "type": "integer",
             "enum": [
@@ -2424,6 +2442,26 @@
                 "ReservationNever"
             ]
         },
+        "models.Attachment": {
+            "type": "object",
+            "properties": {
+                "FileUrl": {
+                    "type": "string"
+                },
+                "ext": {
+                    "type": "string"
+                },
+                "fileName": {
+                    "type": "string"
+                },
+                "fileType": {
+                    "$ref": "#/definitions/constvar.FileType"
+                },
+                "id": {
+                    "type": "integer"
+                }
+            }
+        },
         "models.Company": {
             "type": "object",
             "properties": {
@@ -2567,6 +2605,18 @@
                     "description": "鏁伴噺",
                     "type": "number"
                 },
+                "attachmentIDs": {
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "attachmentList": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Attachment"
+                    }
+                },
                 "barcode": {
                     "description": "鏉$爜",
                     "type": "string"
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index c2d1ffe..b41ed10 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -33,6 +33,20 @@
     - CostingMethodStandardPrice
     - CostingMethodFIFO
     - CostingMethodAverageCost
+  constvar.FileType:
+    enum:
+    - file
+    - picture
+    - thumbnail
+    type: string
+    x-enum-comments:
+      FileType_File: 鏂囦欢
+      FileType_Picture: 鍥剧墖
+      FileType_Thumbnail: 缂╃暐鍥�
+    x-enum-varnames:
+    - FileType_File
+    - FileType_Picture
+    - FileType_Thumbnail
   constvar.ForceRemovalStrategy:
     enum:
     - 1
@@ -203,6 +217,19 @@
     - WhetherTypeAsk
     - WhetherTypeAlways
     - ReservationNever
+  models.Attachment:
+    properties:
+      FileUrl:
+        type: string
+      ext:
+        type: string
+      fileName:
+        type: string
+      fileType:
+        $ref: '#/definitions/constvar.FileType'
+      id:
+        type: integer
+    type: object
   models.Company:
     properties:
       createTime:
@@ -302,6 +329,14 @@
       amount:
         description: 鏁伴噺
         type: number
+      attachmentIDs:
+        items:
+          type: integer
+        type: array
+      attachmentList:
+        items:
+          $ref: '#/definitions/models.Attachment'
+        type: array
       barcode:
         description: 鏉$爜
         type: string
diff --git a/models/material.go b/models/material.go
index 5084258..69c33d0 100644
--- a/models/material.go
+++ b/models/material.go
@@ -341,7 +341,7 @@
 		db      = slf.build()
 	)
 
-	if err := db.Count(&total).Error; err != nil {
+	if err := db.Model(&Material{}).Count(&total).Error; err != nil {
 		return records, total, fmt.Errorf("find count err: %v", err)
 	}
 	if slf.PageNum*slf.PageSize > 0 {
diff --git a/utils/image/image.go b/utils/image/image.go
index 237bae9..7491a7f 100644
--- a/utils/image/image.go
+++ b/utils/image/image.go
@@ -44,7 +44,13 @@
 			b = sz.Y
 		}
 
-		thumbnailImg = canvas.(*image.YCbCr).SubImage(image.Rect(l, t, r, b)).(*image.YCbCr)
+		if ycbcr, ok := canvas.(*image.YCbCr); ok {
+			thumbnailImg = ycbcr.SubImage(image.Rect(l, t, r, b)).(*image.YCbCr)
+		} else if rgba, ok := canvas.(*image.RGBA); ok {
+			thumbnailImg = rgba.SubImage(image.Rect(l, t, r, b)).(*image.RGBA)
+		} else {
+			return nil, errors.New("鏈瘑鍒殑鍥剧墖鑹插僵绫诲瀷")
+		}
 	} else {
 		w := width
 		h := height

--
Gitblit v1.8.0