|
|
|
@ -2,7 +2,8 @@ var express = require('express');
|
|
|
|
|
var router = express.Router();
|
|
|
|
|
const {
|
|
|
|
|
loginService,
|
|
|
|
|
updateUserInfoService
|
|
|
|
|
updateUserInfoService,
|
|
|
|
|
getUserInfoService
|
|
|
|
|
} = require("../services/userService")
|
|
|
|
|
const {
|
|
|
|
|
formatResponse,
|
|
|
|
@ -29,27 +30,16 @@ router.get("/whoami", async function (req, res, next) {
|
|
|
|
|
//获取token,然后进行解析
|
|
|
|
|
const {
|
|
|
|
|
loginId,
|
|
|
|
|
sex,
|
|
|
|
|
brithday,
|
|
|
|
|
region,
|
|
|
|
|
number
|
|
|
|
|
} = analysisToken(req.get("authorization"))
|
|
|
|
|
|
|
|
|
|
res.send(formatResponse(0, "", {
|
|
|
|
|
loginId,
|
|
|
|
|
sex,
|
|
|
|
|
brithday,
|
|
|
|
|
region,
|
|
|
|
|
number
|
|
|
|
|
}))
|
|
|
|
|
const {
|
|
|
|
|
loginPwd,
|
|
|
|
|
...data
|
|
|
|
|
} = await getUserInfoService(loginId)
|
|
|
|
|
res.send(formatResponse(0, "", data))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
router.put("/", async function (req, res, next) {
|
|
|
|
|
const {
|
|
|
|
|
token,
|
|
|
|
|
data
|
|
|
|
|
} = await updateUserInfoService(req.body)
|
|
|
|
|
res.setHeader("authentication", token)
|
|
|
|
|
const data = await updateUserInfoService(req.body)
|
|
|
|
|
res.send(formatResponse(0, "", data))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|