Browse Source

🎈 perf: 增加日志输出

Pchen. 5 months ago
parent
commit
64784c06d9

+ 5 - 3
apis/Corn/StartLepao.js

@@ -40,7 +40,7 @@ class StartLepao extends API {
 
             for (const item of r) {
                 const { name, create_user, student_num, token, uid, school_id, state } = item
-                this.logger.info(`${name}(${student_num})开始乐跑`)
+                this.logger.info(`${name}(${student_num})开始补充乐跑`)
 
                 const isSuccess = await Redis.get(`lepaoSuccess:${student_num}`)
                 if (isSuccess) {
@@ -50,11 +50,13 @@ class StartLepao extends API {
 
                 try {
                     await lepao.beginLepao(create_user, student_num, token, uid, school_id, state)
-                    this.logger.info(`${name}(${student_num})乐跑完成`)
+                    this.logger.info(`${name}(${student_num})补充乐跑完成`)
                 } catch (err) {
-                    this.logger.error(`${name}(${student_num})乐跑失败:${err.message || err}`)
+                    this.logger.error(`${name}(${student_num})补充乐跑失败:${err.message || err}`)
                 }
             }
+
+            this.logger.info('补充乐跑任务执行完毕')
         } catch (error) {
             this.logger.error(error)
         }

+ 9 - 10
apis/Lepao/Account/AddAccount.js

@@ -33,12 +33,11 @@ class AddAccount extends API {
     }
 
     async onRequest(req, res) {
-        let { uuid, session, student_num, email, id, area, auto_time, auto_run, notes } = req.body
+        let { uuid, session, student_num, email, id, area, auto_time, auto_run, target_count, notes } = req.body
 
-        if ([uuid, session, student_num, email, auto_time].some(value => value === '' || value === null || value === undefined))
+        if ([uuid, session, student_num, email, auto_time, target_count].some(value => value === '' || value === null || value === undefined))
             return res.json({
-                ...BaseStdResponse.MISSING_PARAMETER,
-                endpoint: 1513126
+                ...BaseStdResponse.MISSING_PARAMETER
             })
 
         if (!await AccessControl.checkSession(uuid, session))
@@ -67,14 +66,14 @@ class AddAccount extends API {
 
         if (!id) {
             if (countRows.length !== 0) {
-                sql = 'UPDATE lepao_account SET create_user = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, create_time = ?, notes = ? WHERE id = ?'
-                r = await db.query(sql, [uuid, email, area, auto_time, auto_run, time, notes ?? '', countRows[0].id])
+                sql = 'UPDATE lepao_account SET create_user = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, target_count = ?, create_time = ?, notes = ? WHERE id = ?'
+                r = await db.query(sql, [uuid, email, area, auto_time, auto_run, target_count, time, notes ?? '', countRows[0].id])
             }
             else {
                 const face_code = await this.generateCode()
 
-                sql = 'INSERT INTO lepao_account (student_num, email, area, auto_time, auto_run, create_user, create_time, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
-                r = await db.query(sql, [student_num, email, area, auto_time, auto_run, uuid, time, notes ?? ''])
+                sql = 'INSERT INTO lepao_account (student_num, email, area, auto_time, auto_run, target_count, create_user, create_time, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
+                r = await db.query(sql, [student_num, email, area, auto_time, auto_run, target_count, uuid, time, notes ?? ''])
 
                 let faceSql = 'INSERT INTO lepao_face (student_num, face_code) VALUES (?, ?)'
                 let faceRows = await db.query(faceSql, [student_num, face_code])
@@ -82,8 +81,8 @@ class AddAccount extends API {
                     return res.json({ ...BaseStdResponse.ERR, msg: '添加乐跑账号失败!数据库错误' })
             }
         } else {
-            sql = 'UPDATE lepao_account SET student_num = ?, email = ?, area = ?, auto_time = ?, auto_run = ?, notes = ? WHERE id = ?'
-            r = await db.query(sql, [student_num, email, area, auto_time, auto_run, notes ?? '', id])
+            sql = 'UPDATE lepao_account SET student_num = ?, email = ?, area = ?, auto_time = ?, target_count = ?, auto_run = ?, notes = ? WHERE id = ?'
+            r = await db.query(sql, [student_num, email, area, auto_time, target_count, auto_run, notes ?? '', id])
         }
 
         try {

+ 1 - 0
apis/Lepao/Account/Admin/GetAccountList.js

@@ -72,6 +72,7 @@ class GetAccountList extends API {
                     l.today_auto_time,
                     l.state,
                     l.notes,
+                    l.target_count,
                     f.face_code,
                     f.state AS face_state,
                     f.create_time AS face_time,

+ 1 - 0
apis/Lepao/Account/GetAccount.js

@@ -62,6 +62,7 @@ class GetAccount extends API {
                     l.auto_run,
                     l.today_auto_time,
                     l.notes,
+                    l.target_count,
                     f.face_code,
                     f.create_time AS face_time,
                     f.state AS face_state