diff --git a/code/api/app/lib/controllers/user.js b/code/api/app/lib/controllers/user.js index 3ddb594..8a80fb4 100644 --- a/code/api/app/lib/controllers/user.js +++ b/code/api/app/lib/controllers/user.js @@ -21,6 +21,33 @@ async function message (ctx) { } } +async function accord (ctx) { + try { + const { models } = ctx.fs.dc; + const { userId } = ctx.params + + const data = ctx.request.body + + const { action, data: params } = data + if (action == 'create') { + await models.User.create(params) + } else { + await models.User.update(params, { + where: { + id: { $in: String(params.id).split(',') } + } + }) + } + + ctx.status = 204; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = {} + } +} + module.exports = { - message + message, + accord }; \ No newline at end of file diff --git a/code/api/app/lib/routes/user/index.js b/code/api/app/lib/routes/user/index.js index d494c84..282bffe 100644 --- a/code/api/app/lib/routes/user/index.js +++ b/code/api/app/lib/routes/user/index.js @@ -5,4 +5,7 @@ const user = require('../../controllers/user'); module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/user/:userId/message'] = { content: '用户信息', visible: true }; router.get('/user/:userId/message', user.message); + + app.fs.api.logAttr['GET/user/accord'] = { content: '同步用户信息', visible: true }; + router.put('/user/accord', user.accord); };