Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xuexin_h5
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data_server
xuexin_h5
Commits
b37f03a9
Commit
b37f03a9
authored
May 17, 2019
by
何娜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
学信 注册
parent
e8520821
Pipeline
#7726
passed with stage
in 3 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
167 additions
and
0 deletions
+167
-0
verifyAppKey.js
app/middleware/verifyAppKey.js
+13
-0
register.js
app/model/register.js
+94
-0
registerOrder.js
app/service/registerOrder.js
+60
-0
No files found.
app/middleware/verifyAppKey.js
0 → 100644
View file @
b37f03a9
'use strict'
;
module
.
exports
=
(
options
,
app
)
=>
{
return
async
function
(
ctx
,
next
)
{
const
{
appKey
}
=
ctx
.
request
.
body
;
// 可以在这里增加验签的功能;
if
(
appKey
&&
ctx
.
app
.
appKeyArr
.
includes
(
appKey
))
{
await
next
();
}
else
{
ctx
.
throw
(
400
,
'无效的appKey'
);
}
};
};
app/model/register.js
0 → 100644
View file @
b37f03a9
'use strict'
;
module
.
exports
=
app
=>
{
const
{
DataTypes
}
=
app
.
Sequelize
;
const
Register
=
app
.
model
.
define
(
'register'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
autoIncrement
:
true
,
primaryKey
:
true
,
field
:
'id'
,
},
orderId
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
false
,
defaultValue
:
''
,
primaryKey
:
true
,
field
:
'orderId'
,
},
taskId
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
false
,
defaultValue
:
''
,
field
:
'taskId'
,
},
appkey
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
field
:
'appKey'
,
},
status
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
defaultValue
:
''
,
field
:
'status'
,
},
note
:
{
type
:
DataTypes
.
STRING
(
8000
),
allowNull
:
true
,
defaultValue
:
''
,
field
:
'note'
,
get
()
{
const
note
=
this
.
getDataValue
(
'note'
);
if
(
note
)
{
try
{
return
JSON
.
parse
(
note
);
}
catch
(
error
)
{
return
{};
}
}
return
{};
},
set
(
val
)
{
this
.
setDataValue
(
'note'
,
JSON
.
stringify
(
val
));
},
},
created_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
,
defaultValue
:
app
.
Sequelize
.
literal
(
'CURRENT_TIMESTAMP'
),
field
:
'createDate'
,
},
updated_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
false
,
defaultValue
:
app
.
Sequelize
.
literal
(
'CURRENT_TIMESTAMP'
),
field
:
'updateDate'
,
},
text1
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
defaultValue
:
''
,
field
:
'text1'
,
},
text2
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
defaultValue
:
''
,
field
:
'text2'
,
},
text3
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
defaultValue
:
''
,
field
:
'text3'
,
},
},
{
tableName
:
'xuexin_register_status'
,
// timestamps: false,
});
return
Register
;
};
app/service/registerOrder.js
0 → 100644
View file @
b37f03a9
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
OrderService
extends
Service
{
async
getOneByOrderId
(
orderId
)
{
const
{
ctx
}
=
this
;
const
order
=
await
ctx
.
model
.
Register
.
findOne
({
where
:
{
orderId
},
});
return
order
;
}
async
getOneByTaskId
(
taskId
)
{
const
{
ctx
}
=
this
;
const
order
=
await
ctx
.
model
.
Register
.
findOne
({
where
:
{
taskId
},
});
return
order
;
}
async
create
(
params
)
{
const
{
ctx
}
=
this
;
const
order
=
await
ctx
.
model
.
Register
.
findOne
({
where
:
{
orderId
:
params
.
orderId
},
});
if
(
order
)
{
ctx
.
throw
(
400
,
{
message
:
'already have order'
});
}
await
ctx
.
model
.
Register
.
create
(
params
);
return
order
;
}
async
update
(
params
)
{
const
{
ctx
}
=
this
;
const
order
=
await
ctx
.
model
.
Register
.
findAll
({
where
:
{
orderId
:
params
.
orderId
},
order
:
[[
'createDate'
,
'DESC'
]],
});
if
(
order
.
length
===
0
)
{
ctx
.
throw
(
400
,
{
message
:
'no order'
});
return
;
}
for
(
const
item
of
order
)
{
if
(
item
.
status
===
'success'
)
{
ctx
.
throw
(
400
,
{
message
:
'orderId success'
});
return
;
}
}
const
{
appKey
,
taskId
,
notifyUrl
,
backUrl
,
userId
}
=
order
[
0
];
if
(
taskId
)
{
await
ctx
.
model
.
Register
.
create
({
appKey
,
status
:
'init'
,
notifyUrl
,
backUrl
,
userId
,
...
params
})
}
else
{
await
order
[
0
].
update
(
params
);
}
return
order
[
0
];
}
}
module
.
exports
=
OrderService
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment