You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
var express = require('express');
|
|
|
|
|
var router = express.Router();
|
|
|
|
|
const {
|
|
|
|
|
loginService
|
|
|
|
|
} = require("../services/userService")
|
|
|
|
|
const {
|
|
|
|
|
formatResponse
|
|
|
|
|
} = require("../utils/tools")
|
|
|
|
|
|
|
|
|
|
/* GET home page. */
|
|
|
|
|
router.post('/login', async function (req, res, next) {
|
|
|
|
|
//移交service处理
|
|
|
|
|
const result = await loginService(req.body)
|
|
|
|
|
if (result.token) {
|
|
|
|
|
//有token,登陆成功
|
|
|
|
|
res.send(formatResponse(0, "", result.data))
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error("账号或密码错误")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = router;
|