File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,16 @@ module.exports = {
14
14
await next ( ) ;
15
15
} ,
16
16
17
+ async getAllEmptyKeysCount ( ctx , next ) {
18
+ try {
19
+ const data = await Key . findAllByEmail ( null )
20
+ ctx . body = { msg : 1001 , data }
21
+ } catch ( err ) {
22
+ ctx . body = { code : - 1 , msg : 1000 , }
23
+ }
24
+ await next ( ) ;
25
+ } ,
26
+
17
27
async createKey ( ctx , next ) {
18
28
const req = ctx . request . body
19
29
if ( ! req . key ) {
Original file line number Diff line number Diff line change @@ -55,6 +55,19 @@ class Key extends Model {
55
55
} )
56
56
}
57
57
58
+ /**
59
+ * @description : 根据email查找所有key
60
+ * @param {* } id
61
+ * @return {* }
62
+ */
63
+ static async findAllByEmail ( email ) {
64
+ return await this . findAndCountAll ( {
65
+ where : {
66
+ email
67
+ }
68
+ } )
69
+ }
70
+
58
71
}
59
72
// 初始化表结构
60
73
Key . init (
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ const Key = require('../controllers/key')
3
3
4
4
router . get ( '/getAllKeys' , Key . getAllKeys )
5
5
6
+ router . get ( '/getAllEmptyKeysCount' , Key . getAllEmptyKeysCount )
7
+
6
8
router . post ( '/createKey' , Key . createKey )
7
9
8
10
router . post ( '/sendKey' , Key . sendKey )
Original file line number Diff line number Diff line change 9
9
<li >最终解释权归金庸群侠传3D重制版开源社区所有。</li >
10
10
</ul >
11
11
</a-form-item >
12
+ <a-form-item label =" 剩余码数" >
13
+ {{ count }}
14
+ </a-form-item >
12
15
<a-form-item v-for =" (question, index) in questions" :key =" question.id" :label =" `题目${index + 1}`" >
13
16
<div >{{ question.topic }}</div >
14
17
<a-radio-group v-model =" answers[index]" >
58
61
</template >
59
62
60
63
<script >
61
- import ' no-debugger'
64
+ // import 'no-debugger'
62
65
import axios from ' axios'
63
66
export default {
64
67
name: ' App' ,
65
68
data () {
66
69
return {
67
70
questions: [],
68
71
answers: [],
69
- form: this .$form .createForm (this )
72
+ form: this .$form .createForm (this ),
73
+ count: 0
70
74
}
71
75
},
72
76
mounted () {
77
+ this .handleAllEmptyKeysCount ()
73
78
this .handleQuestion ()
74
79
},
75
80
methods: {
81
+ handleAllEmptyKeysCount () {
82
+ axios .get (' /api/getAllEmptyKeysCount' )
83
+ .then ((response ) => {
84
+ const { data: { data: { count } } } = response
85
+ this .count = count
86
+ })
87
+ },
76
88
handleQuestion () {
77
89
axios .get (' /api/getAllQuestions' )
78
90
.then ((response ) => {
You can’t perform that action at this time.
0 commit comments