1
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
const crud = require("../service/biz_admin_crud");
|
||||
const { getRequestBody } = crud;
|
||||
|
||||
const baseModel = require("../../middleware/baseModel");
|
||||
const tokenLogic = require("../service/biz_token_logic");
|
||||
const audit = require("../service/biz_audit_service");
|
||||
|
||||
module.exports = {
|
||||
"POST /biz_user/page": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
const data = await crud.page("biz_user", body);
|
||||
ctx.success({ rows: data.rows, count: data.count });
|
||||
},
|
||||
"POST /biz_user/add": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
const row = await crud.add("biz_user", body);
|
||||
await audit.logAudit({
|
||||
admin_user_id: audit.pickAdminId(ctx),
|
||||
@@ -24,7 +24,7 @@ module.exports = {
|
||||
ctx.success(row);
|
||||
},
|
||||
"POST /biz_user/edit": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
await crud.edit("biz_user", body);
|
||||
await audit.logAudit({
|
||||
admin_user_id: audit.pickAdminId(ctx),
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
ctx.success({});
|
||||
},
|
||||
"POST /biz_user/del": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
await crud.del("biz_user", body);
|
||||
await audit.logAudit({
|
||||
admin_user_id: audit.pickAdminId(ctx),
|
||||
@@ -73,7 +73,7 @@ module.exports = {
|
||||
ctx.success(rows);
|
||||
},
|
||||
"POST /biz_user/disable": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
const id = body.id;
|
||||
if (id == null) return ctx.fail("缺少 id");
|
||||
await baseModel.biz_user.update({ status: "disabled" }, { where: { id } });
|
||||
@@ -87,7 +87,7 @@ module.exports = {
|
||||
ctx.success({});
|
||||
},
|
||||
"POST /biz_user/enable": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
const id = body.id;
|
||||
if (id == null) return ctx.fail("缺少 id");
|
||||
await baseModel.biz_user.update({ status: "active" }, { where: { id } });
|
||||
@@ -101,12 +101,12 @@ module.exports = {
|
||||
ctx.success({});
|
||||
},
|
||||
"POST /biz_user/export": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
const res = await crud.exportCsv("biz_user", body);
|
||||
ctx.success(res);
|
||||
},
|
||||
"POST /biz_user/revoke_all_tokens": async (ctx) => {
|
||||
const body = getRequestBody(ctx);
|
||||
const body = ctx.getBody();
|
||||
const userId = body.user_id != null ? body.user_id : body.id;
|
||||
if (userId == null) return ctx.fail("缺少 user_id");
|
||||
const n = await tokenLogic.revokeAllForUser(userId);
|
||||
|
||||
Reference in New Issue
Block a user