Browse Source

🐞 fix: 修复补卡接口可无限添加补卡记录的bug

Pchen. 8 months ago
parent
commit
8de7bc83e2
1 changed files with 7 additions and 6 deletions
  1. 7 6
      apis/ClockIn/SupplementRecord.js

+ 7 - 6
apis/ClockIn/SupplementRecord.js

@@ -43,7 +43,7 @@ class SupplementRecord extends API {
             if (!projectData.length) {
                 return res.json({
                     ...BaseStdResponse.DATABASE_ERR,
-                    endpoint: 154754511
+                    endpoint: 1544511
                 });
             }
 
@@ -70,7 +70,7 @@ class SupplementRecord extends API {
             if (!userUUIDData.length) {
                 return res.json({
                     ...BaseStdResponse.DATABASE_ERR,
-                    endpoint: 154754511,
+                    endpoint: 154711,
                     msg: '未找到用户'
                 });
             }
@@ -92,7 +92,7 @@ class SupplementRecord extends API {
             `;
             const records = await db.query(sqlCheckRecords, [project_id, userUUID]);
 
-            if (records.some(record => this.hasRecord(item, record, user))) {
+            if (records.length !== 0 && this.hasRecord(item, records, userUUID)) {
                 return res.json({
                     ...BaseStdResponse.ERR,
                     endpoint: 513523,
@@ -110,7 +110,7 @@ class SupplementRecord extends API {
                 project_id,
                 userUUID,
                 new Date().getTime(),
-                `${userInfo.name}补卡`
+                `${userInfo.username}补卡`
             ]);
 
             if (result.affectedRows !== 1) {
@@ -126,9 +126,10 @@ class SupplementRecord extends API {
 
         } catch (error) {
             res.json({
-                ...BaseStdResponse.DATABASE_ERR,
-                endpoint: 154754511
+                ...BaseStdResponse.ERR,
+                endpoint: 154511
             });
+            this.logger.error(`添加补卡记录时出错!${error.stack}`)
         }
     }