From adb8a4d6c2806beae1ac97af7f71c8a3ce3ed0c9 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期二, 23 四月 2024 15:25:13 +0800
Subject: [PATCH] 修改考勤信息

---
 controllers/attendance_controller.go      |   31 +++++
 docs/swagger.yaml                         |   61 +++++++++
 docs/docs.go                              |   92 ++++++++++++++-
 docs/swagger.json                         |   92 ++++++++++++++-
 controllers/request/attendance_request.go |   12 ++
 models/attendance_manage.go               |   18 +++
 router/router.go                          |    1 
 7 files changed, 286 insertions(+), 21 deletions(-)

diff --git a/controllers/attendance_controller.go b/controllers/attendance_controller.go
index edc8dec..709151e 100644
--- a/controllers/attendance_controller.go
+++ b/controllers/attendance_controller.go
@@ -186,6 +186,37 @@
 	util.ResponseFormatList(c, code.Success, manages, total)
 }
 
+// UpdateAttendance
+//
+//	@Tags		鑰冨嫟绠$悊
+//	@Summary	鏇存柊鑰冨嫟
+//	@Produce	application/json
+//	@Param		object	body		request.UpdateAttendance	true	"鍙傛暟"
+//	@Param     	Authorization	header string true "token"
+//	@Success	200		{object}	util.Response		"鎴愬姛"
+//	@Router		/api-jl/v1/attendance/updateAttendance [post]
+func (slf AttendanceController) UpdateAttendance(c *gin.Context) {
+	var params request.UpdateAttendance
+	err := c.BindJSON(&params)
+	if err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+		return
+	}
+	if params.Date == "" || params.WorkerId == "" {
+		util.ResponseFormat(c, code.RequestParamError, "浜哄憳id鍜岃�冨嫟鏃ユ湡涓嶈兘涓虹┖")
+		return
+	}
+	m := make(map[string]interface{})
+	m["status"] = params.Status
+	m["overTimeDuration"] = params.OverTimeDuration
+	err = models.NewAttendanceManageSearch().SetDate(params.Date).SetWorkerId(params.WorkerId).UpdateByMap(m)
+	if err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鏇存柊澶辫触")
+		return
+	}
+	util.ResponseFormat(c, code.Success, "鏇存柊鎴愬姛")
+}
+
 // GetAttendanceStatistic
 //
 //	@Tags		鑰冨嫟绠$悊
diff --git a/controllers/request/attendance_request.go b/controllers/request/attendance_request.go
index 27163c5..f492dbc 100644
--- a/controllers/request/attendance_request.go
+++ b/controllers/request/attendance_request.go
@@ -1,5 +1,10 @@
 package request
 
+import (
+	"github.com/shopspring/decimal"
+	"silkserver/constvar"
+)
+
 type GetAttendanceList struct {
 	PageInfo
 	Keyword string `json:"keyword"`
@@ -12,3 +17,10 @@
 type GetAttendanceStatistic struct {
 	Month string `json:"month"` //鏈堜唤
 }
+
+type UpdateAttendance struct {
+	Date             string                    `json:"date"`             //鏃ユ湡
+	WorkerId         string                    `json:"workerId"`         //浜哄憳id
+	Status           constvar.AttendanceStatus `json:"status"`           //鐘舵��
+	OverTimeDuration decimal.Decimal           `json:"overTimeDuration"` //鍔犵彮鏃堕暱
+}
diff --git a/docs/docs.go b/docs/docs.go
index 5a49f1f..f4e0312 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -238,6 +238,43 @@
                 }
             }
         },
+        "/api-jl/v1/attendance/updateAttendance": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鑰冨嫟绠$悊"
+                ],
+                "summary": "鏇存柊鑰冨嫟",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateAttendance"
+                        }
+                    },
+                    {
+                        "type": "string",
+                        "description": "token",
+                        "name": "Authorization",
+                        "in": "header",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "鎴愬姛",
+                        "schema": {
+                            "$ref": "#/definitions/util.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api-jl/v1/fineness/changeYieldRegister": {
             "post": {
                 "produces": [
@@ -2954,10 +2991,6 @@
                 "id": {
                     "type": "integer"
                 },
-                "name": {
-                    "description": "杞﹂棿",
-                    "type": "string"
-                },
                 "startDate": {
                     "description": "寮�濮嬫棩鏈�",
                     "type": "string"
@@ -2981,9 +3014,17 @@
                     "description": "宸ヤ汉ID",
                     "type": "string"
                 },
+                "workshop": {
+                    "description": "杞﹂棿缂栧彿",
+                    "type": "string"
+                },
                 "workshopGroup": {
                     "description": "杞︾粍",
                     "type": "integer"
+                },
+                "workshopName": {
+                    "description": "杞﹂棿鍚嶇О",
+                    "type": "string"
                 }
             }
         },
@@ -3333,7 +3374,8 @@
                 "startWorkerPosition",
                 "workerId",
                 "workshop",
-                "workshopGroup"
+                "workshopGroup",
+                "workshopName"
             ],
             "properties": {
                 "endDate": {
@@ -3357,12 +3399,16 @@
                     "type": "string"
                 },
                 "workshop": {
-                    "description": "杞﹂棿",
+                    "description": "杞﹂棿缂栧彿",
                     "type": "string"
                 },
                 "workshopGroup": {
                     "description": "杞︾粍",
                     "type": "integer"
+                },
+                "workshopName": {
+                    "description": "杞﹂棿鍚嶇О",
+                    "type": "string"
                 }
             }
         },
@@ -3680,6 +3726,31 @@
                 }
             }
         },
+        "request.UpdateAttendance": {
+            "type": "object",
+            "properties": {
+                "date": {
+                    "description": "鏃ユ湡",
+                    "type": "string"
+                },
+                "overTimeDuration": {
+                    "description": "鍔犵彮鏃堕暱",
+                    "type": "number"
+                },
+                "status": {
+                    "description": "鐘舵��",
+                    "allOf": [
+                        {
+                            "$ref": "#/definitions/constvar.AttendanceStatus"
+                        }
+                    ]
+                },
+                "workerId": {
+                    "description": "浜哄憳id",
+                    "type": "string"
+                }
+            }
+        },
         "request.UpdateDict": {
             "type": "object",
             "properties": {
@@ -3737,7 +3808,8 @@
                 "startWorkerPosition",
                 "workerId",
                 "workshop",
-                "workshopGroup"
+                "workshopGroup",
+                "workshopName"
             ],
             "properties": {
                 "endDate": {
@@ -3764,12 +3836,16 @@
                     "type": "string"
                 },
                 "workshop": {
-                    "description": "杞﹂棿",
+                    "description": "杞﹂棿缂栧彿",
                     "type": "string"
                 },
                 "workshopGroup": {
                     "description": "杞︾粍",
                     "type": "integer"
+                },
+                "workshopName": {
+                    "description": "杞﹂棿鍚嶇О",
+                    "type": "string"
                 }
             }
         },
diff --git a/docs/swagger.json b/docs/swagger.json
index cdb5d20..55fc2f0 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -226,6 +226,43 @@
                 }
             }
         },
+        "/api-jl/v1/attendance/updateAttendance": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "鑰冨嫟绠$悊"
+                ],
+                "summary": "鏇存柊鑰冨嫟",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateAttendance"
+                        }
+                    },
+                    {
+                        "type": "string",
+                        "description": "token",
+                        "name": "Authorization",
+                        "in": "header",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "鎴愬姛",
+                        "schema": {
+                            "$ref": "#/definitions/util.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api-jl/v1/fineness/changeYieldRegister": {
             "post": {
                 "produces": [
@@ -2942,10 +2979,6 @@
                 "id": {
                     "type": "integer"
                 },
-                "name": {
-                    "description": "杞﹂棿",
-                    "type": "string"
-                },
                 "startDate": {
                     "description": "寮�濮嬫棩鏈�",
                     "type": "string"
@@ -2969,9 +3002,17 @@
                     "description": "宸ヤ汉ID",
                     "type": "string"
                 },
+                "workshop": {
+                    "description": "杞﹂棿缂栧彿",
+                    "type": "string"
+                },
                 "workshopGroup": {
                     "description": "杞︾粍",
                     "type": "integer"
+                },
+                "workshopName": {
+                    "description": "杞﹂棿鍚嶇О",
+                    "type": "string"
                 }
             }
         },
@@ -3321,7 +3362,8 @@
                 "startWorkerPosition",
                 "workerId",
                 "workshop",
-                "workshopGroup"
+                "workshopGroup",
+                "workshopName"
             ],
             "properties": {
                 "endDate": {
@@ -3345,12 +3387,16 @@
                     "type": "string"
                 },
                 "workshop": {
-                    "description": "杞﹂棿",
+                    "description": "杞﹂棿缂栧彿",
                     "type": "string"
                 },
                 "workshopGroup": {
                     "description": "杞︾粍",
                     "type": "integer"
+                },
+                "workshopName": {
+                    "description": "杞﹂棿鍚嶇О",
+                    "type": "string"
                 }
             }
         },
@@ -3668,6 +3714,31 @@
                 }
             }
         },
+        "request.UpdateAttendance": {
+            "type": "object",
+            "properties": {
+                "date": {
+                    "description": "鏃ユ湡",
+                    "type": "string"
+                },
+                "overTimeDuration": {
+                    "description": "鍔犵彮鏃堕暱",
+                    "type": "number"
+                },
+                "status": {
+                    "description": "鐘舵��",
+                    "allOf": [
+                        {
+                            "$ref": "#/definitions/constvar.AttendanceStatus"
+                        }
+                    ]
+                },
+                "workerId": {
+                    "description": "浜哄憳id",
+                    "type": "string"
+                }
+            }
+        },
         "request.UpdateDict": {
             "type": "object",
             "properties": {
@@ -3725,7 +3796,8 @@
                 "startWorkerPosition",
                 "workerId",
                 "workshop",
-                "workshopGroup"
+                "workshopGroup",
+                "workshopName"
             ],
             "properties": {
                 "endDate": {
@@ -3752,12 +3824,16 @@
                     "type": "string"
                 },
                 "workshop": {
-                    "description": "杞﹂棿",
+                    "description": "杞﹂棿缂栧彿",
                     "type": "string"
                 },
                 "workshopGroup": {
                     "description": "杞︾粍",
                     "type": "integer"
+                },
+                "workshopName": {
+                    "description": "杞﹂棿鍚嶇О",
+                    "type": "string"
                 }
             }
         },
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 30ea8d3..1b4dca5 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -535,9 +535,6 @@
         type: integer
       id:
         type: integer
-      name:
-        description: 杞﹂棿
-        type: string
       startDate:
         description: 寮�濮嬫棩鏈�
         type: string
@@ -553,9 +550,15 @@
       workerId:
         description: 宸ヤ汉ID
         type: string
+      workshop:
+        description: 杞﹂棿缂栧彿
+        type: string
       workshopGroup:
         description: 杞︾粍
         type: integer
+      workshopName:
+        description: 杞﹂棿鍚嶇О
+        type: string
     type: object
   models.WorkshopManage:
     properties:
@@ -803,11 +806,14 @@
         description: 宸ヤ汉ID
         type: string
       workshop:
-        description: 杞﹂棿
+        description: 杞﹂棿缂栧彿
         type: string
       workshopGroup:
         description: 杞︾粍
         type: integer
+      workshopName:
+        description: 杞﹂棿鍚嶇О
+        type: string
     required:
     - endDate
     - endWorkerPosition
@@ -816,6 +822,7 @@
     - workerId
     - workshop
     - workshopGroup
+    - workshopName
     type: object
   request.ChangeYieldRegister:
     properties:
@@ -1031,6 +1038,22 @@
           $ref: '#/definitions/request.RankStandard'
         type: array
     type: object
+  request.UpdateAttendance:
+    properties:
+      date:
+        description: 鏃ユ湡
+        type: string
+      overTimeDuration:
+        description: 鍔犵彮鏃堕暱
+        type: number
+      status:
+        allOf:
+        - $ref: '#/definitions/constvar.AttendanceStatus'
+        description: 鐘舵��
+      workerId:
+        description: 浜哄憳id
+        type: string
+    type: object
   request.UpdateDict:
     properties:
       dictType:
@@ -1083,11 +1106,14 @@
         description: 宸ヤ汉ID
         type: string
       workshop:
-        description: 杞﹂棿
+        description: 杞﹂棿缂栧彿
         type: string
       workshopGroup:
         description: 杞︾粍
         type: integer
+      workshopName:
+        description: 杞﹂棿鍚嶇О
+        type: string
     required:
     - endDate
     - endWorkerPosition
@@ -1096,6 +1122,7 @@
     - workerId
     - workshop
     - workshopGroup
+    - workshopName
     type: object
   request.YieldRegisterCircleInfo:
     properties:
@@ -1513,6 +1540,30 @@
       summary: 淇濆瓨鍔犵彮瑙勫垯
       tags:
       - 鑰冨嫟绠$悊
+  /api-jl/v1/attendance/updateAttendance:
+    post:
+      parameters:
+      - description: 鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateAttendance'
+      - description: token
+        in: header
+        name: Authorization
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: 鎴愬姛
+          schema:
+            $ref: '#/definitions/util.Response'
+      summary: 鏇存柊鑰冨嫟
+      tags:
+      - 鑰冨嫟绠$悊
   /api-jl/v1/fineness/changeYieldRegister:
     post:
       parameters:
diff --git a/models/attendance_manage.go b/models/attendance_manage.go
index ed14ff0..6663197 100644
--- a/models/attendance_manage.go
+++ b/models/attendance_manage.go
@@ -71,6 +71,16 @@
 	return slf
 }
 
+func (slf *AttendanceManageSearch) SetDate(date string) *AttendanceManageSearch {
+	slf.Date = date
+	return slf
+}
+
+func (slf *AttendanceManageSearch) SetWorkerId(workerId string) *AttendanceManageSearch {
+	slf.WorkerId = workerId
+	return slf
+}
+
 func (slf *AttendanceManageSearch) build() *gorm.DB {
 	var db = slf.Orm.Table(slf.TableName())
 
@@ -86,6 +96,14 @@
 		db = db.Where("date like ?", slf.Month+"%")
 	}
 
+	if slf.Date != "" {
+		db = db.Where("date = ?", slf.Date)
+	}
+
+	if slf.WorkerId != "" {
+		db = db.Where("worker_id = ?", slf.WorkerId)
+	}
+
 	return db
 }
 
diff --git a/router/router.go b/router/router.go
index f7ec6b0..450b567 100644
--- a/router/router.go
+++ b/router/router.go
@@ -107,6 +107,7 @@
 	{
 		attendanceApi.POST("attendanceInput", attendanceController.AttendanceInput)               //鑰冨嫟瀵煎叆
 		attendanceApi.POST("getAttendanceList", attendanceController.GetAttendanceList)           //鑾峰彇鑰冨嫟鍒楄〃
+		attendanceApi.POST("updateAttendance", attendanceController.UpdateAttendance)             //鏇存柊鑰冨嫟
 		attendanceApi.POST("getAttendanceStatistic", attendanceController.GetAttendanceStatistic) //鑾峰彇鑰冨嫟缁熻
 		attendanceApi.DELETE("deleteAttendanceInfo", attendanceController.DeleteAttendanceInfo)   //鍒犻櫎鑰冨嫟淇℃伅
 		attendanceApi.GET("getAttendanceRule", attendanceController.GetAttendanceRule)            //鑾峰彇鍔犵彮瑙勫垯

--
Gitblit v1.8.0