From db38b24898e99794369ae6a78ab43089b4c5cfef Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期三, 24 四月 2024 13:59:15 +0800
Subject: [PATCH] 考勤修改

---
 controllers/attendance_controller.go        |   49 ++++++++++++----
 controllers/response/attendance_response.go |    1 
 docs/swagger.yaml                           |   24 ++++++++
 docs/docs.go                                |   32 ++++++++++
 docs/swagger.json                           |   32 ++++++++++
 controllers/request/attendance_request.go   |    7 ++
 6 files changed, 133 insertions(+), 12 deletions(-)

diff --git a/controllers/attendance_controller.go b/controllers/attendance_controller.go
index ed10c34..4a5978d 100644
--- a/controllers/attendance_controller.go
+++ b/controllers/attendance_controller.go
@@ -12,6 +12,7 @@
 	"silkserver/middleware"
 	"silkserver/models"
 	"silkserver/pkg/logx"
+	"silkserver/pkg/structx"
 	"silkserver/pkg/timex"
 	"time"
 )
@@ -229,14 +230,37 @@
 		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)
+	count, err := models.NewAttendanceManageSearch().SetDate(params.Date).SetWorkerId(params.WorkerId).Count()
 	if err != nil {
-		util.ResponseFormat(c, code.RequestParamError, "鏇存柊澶辫触")
+		util.ResponseFormat(c, code.RequestParamError, err)
 		return
 	}
+	if count > 0 {
+		m := make(map[string]interface{})
+		m["status"] = params.Status
+		m["over_time_duration"] = params.OverTimeDuration
+		err = models.NewAttendanceManageSearch().SetDate(params.Date).SetWorkerId(params.WorkerId).UpdateByMap(m)
+		if err != nil {
+			util.ResponseFormat(c, code.RequestParamError, "鏇存柊澶辫触")
+			return
+		}
+	} else {
+		var manage models.AttendanceManage
+		err = structx.AssignTo(params, &manage)
+		if err != nil {
+			util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲澶辫触")
+			return
+		}
+		info := middleware.GetUserInfo(c)
+		manage.AddPeople = info.NickName
+		manage.CreateTime = timex.TimeToString2(time.Now())
+		err = models.NewAttendanceManageSearch().Create(&manage)
+		if err != nil {
+			util.ResponseFormat(c, code.RequestParamError, "鏇存柊澶辫触")
+			return
+		}
+	}
+
 	util.ResponseFormat(c, code.Success, "鏇存柊鎴愬姛")
 }
 
@@ -268,13 +292,6 @@
 	}
 	year, month, _ := location.Date()
 	date := timex.GetDate(year, month)
-	var details []response.AttendanceDetail
-	for i := 1; i <= date; i++ {
-		var ad response.AttendanceDetail
-		ad.Date = i
-		ad.Status = constvar.Vacation
-		details = append(details, ad)
-	}
 
 	manages, err := models.NewAttendanceManageSearch().SetMonth(params.Month).SetPreload(true).FindNotTotal()
 	if err != nil {
@@ -292,6 +309,14 @@
 			as.WorkerName = manage.WorkerName
 			as.WorkType = manage.WorkType.WorkName
 			as.Month = params.Month
+			as.WorkTypeId = manage.WorkTypeId
+			var details []response.AttendanceDetail
+			for i := 1; i <= date; i++ {
+				var ad response.AttendanceDetail
+				ad.Date = i
+				ad.Status = constvar.Vacation
+				details = append(details, ad)
+			}
 			as.Details = details
 		}
 		as.WeekdayOverTime = as.WeekdayOverTime.Add(manage.OverTimeDuration)
diff --git a/controllers/request/attendance_request.go b/controllers/request/attendance_request.go
index 493c9b8..336361b 100644
--- a/controllers/request/attendance_request.go
+++ b/controllers/request/attendance_request.go
@@ -27,4 +27,11 @@
 	WorkerId         string                    `json:"workerId"`         //浜哄憳id
 	Status           constvar.AttendanceStatus `json:"status"`           //鐘舵��
 	OverTimeDuration decimal.Decimal           `json:"overTimeDuration"` //鍔犵彮鏃堕暱
+	WorkerName       string                    `json:"workerName"`       //浜哄憳濮撳悕
+	StartWorkTime    string                    `json:"startWorkTime"`    //涓婄彮鎵撳崱鏃堕棿
+	EndWorkTime      string                    `json:"endWorkTime"`      //涓嬬彮鎵撳崱鏃堕棿
+	Classes          string                    `json:"classes"`          //鐝
+	ClassesStartTime string                    `json:"classesStartTime"` //鐝寮�濮嬫椂闂�
+	ClassesEndTime   string                    `json:"classesEndTime"`   //鐝涓嬬彮鏃堕棿
+	WorkTypeId       uint                      `json:"workTypeId"`       //宸ョid
 }
diff --git a/controllers/response/attendance_response.go b/controllers/response/attendance_response.go
index 9aaccba..09a75c9 100644
--- a/controllers/response/attendance_response.go
+++ b/controllers/response/attendance_response.go
@@ -12,6 +12,7 @@
 type AttendanceStatistic struct {
 	WorkerId               string             `json:"workerId"`               //浜哄憳id
 	WorkerName             string             `json:"workerName"`             //浜哄憳濮撳悕
+	WorkTypeId             uint               `json:"workTypeId"`             //宸ョid
 	WorkType               string             `json:"workType"`               //宸ョ
 	Month                  string             `json:"month"`                  //鏈堜唤
 	WeekdayOverTime        decimal.Decimal    `json:"weekdayOverTime"`        //宸ヤ綔鏃ュ姞鐝椂闀�
diff --git a/docs/docs.go b/docs/docs.go
index c5cb506..eb82777 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -3782,13 +3782,33 @@
         "request.UpdateAttendance": {
             "type": "object",
             "properties": {
+                "classes": {
+                    "description": "鐝",
+                    "type": "string"
+                },
+                "classesEndTime": {
+                    "description": "鐝涓嬬彮鏃堕棿",
+                    "type": "string"
+                },
+                "classesStartTime": {
+                    "description": "鐝寮�濮嬫椂闂�",
+                    "type": "string"
+                },
                 "date": {
                     "description": "鏃ユ湡",
+                    "type": "string"
+                },
+                "endWorkTime": {
+                    "description": "涓嬬彮鎵撳崱鏃堕棿",
                     "type": "string"
                 },
                 "overTimeDuration": {
                     "description": "鍔犵彮鏃堕暱",
                     "type": "number"
+                },
+                "startWorkTime": {
+                    "description": "涓婄彮鎵撳崱鏃堕棿",
+                    "type": "string"
                 },
                 "status": {
                     "description": "鐘舵��",
@@ -3798,8 +3818,16 @@
                         }
                     ]
                 },
+                "workTypeId": {
+                    "description": "宸ョid",
+                    "type": "integer"
+                },
                 "workerId": {
                     "description": "浜哄憳id",
+                    "type": "string"
+                },
+                "workerName": {
+                    "description": "浜哄憳濮撳悕",
                     "type": "string"
                 }
             }
@@ -4181,6 +4209,10 @@
                     "description": "宸ョ",
                     "type": "string"
                 },
+                "workTypeId": {
+                    "description": "宸ョid",
+                    "type": "integer"
+                },
                 "workerId": {
                     "description": "浜哄憳id",
                     "type": "string"
diff --git a/docs/swagger.json b/docs/swagger.json
index 140dac5..741cb43 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -3770,13 +3770,33 @@
         "request.UpdateAttendance": {
             "type": "object",
             "properties": {
+                "classes": {
+                    "description": "鐝",
+                    "type": "string"
+                },
+                "classesEndTime": {
+                    "description": "鐝涓嬬彮鏃堕棿",
+                    "type": "string"
+                },
+                "classesStartTime": {
+                    "description": "鐝寮�濮嬫椂闂�",
+                    "type": "string"
+                },
                 "date": {
                     "description": "鏃ユ湡",
+                    "type": "string"
+                },
+                "endWorkTime": {
+                    "description": "涓嬬彮鎵撳崱鏃堕棿",
                     "type": "string"
                 },
                 "overTimeDuration": {
                     "description": "鍔犵彮鏃堕暱",
                     "type": "number"
+                },
+                "startWorkTime": {
+                    "description": "涓婄彮鎵撳崱鏃堕棿",
+                    "type": "string"
                 },
                 "status": {
                     "description": "鐘舵��",
@@ -3786,8 +3806,16 @@
                         }
                     ]
                 },
+                "workTypeId": {
+                    "description": "宸ョid",
+                    "type": "integer"
+                },
                 "workerId": {
                     "description": "浜哄憳id",
+                    "type": "string"
+                },
+                "workerName": {
+                    "description": "浜哄憳濮撳悕",
                     "type": "string"
                 }
             }
@@ -4169,6 +4197,10 @@
                     "description": "宸ョ",
                     "type": "string"
                 },
+                "workTypeId": {
+                    "description": "宸ョid",
+                    "type": "integer"
+                },
                 "workerId": {
                     "description": "浜哄憳id",
                     "type": "string"
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 385f797..9f9d21a 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1056,18 +1056,39 @@
     type: object
   request.UpdateAttendance:
     properties:
+      classes:
+        description: 鐝
+        type: string
+      classesEndTime:
+        description: 鐝涓嬬彮鏃堕棿
+        type: string
+      classesStartTime:
+        description: 鐝寮�濮嬫椂闂�
+        type: string
       date:
         description: 鏃ユ湡
+        type: string
+      endWorkTime:
+        description: 涓嬬彮鎵撳崱鏃堕棿
         type: string
       overTimeDuration:
         description: 鍔犵彮鏃堕暱
         type: number
+      startWorkTime:
+        description: 涓婄彮鎵撳崱鏃堕棿
+        type: string
       status:
         allOf:
         - $ref: '#/definitions/constvar.AttendanceStatus'
         description: 鐘舵��
+      workTypeId:
+        description: 宸ョid
+        type: integer
       workerId:
         description: 浜哄憳id
+        type: string
+      workerName:
+        description: 浜哄憳濮撳悕
         type: string
     type: object
   request.UpdateDict:
@@ -1341,6 +1362,9 @@
       workType:
         description: 宸ョ
         type: string
+      workTypeId:
+        description: 宸ョid
+        type: integer
       workerId:
         description: 浜哄憳id
         type: string

--
Gitblit v1.8.0