新增全部用户查看删除邮箱

This commit is contained in:
eoao
2025-09-21 19:20:00 +08:00
parent 457304eafb
commit 82bd308d56
21 changed files with 244 additions and 77 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,7 @@ import app from '../hono/hono';
import userService from '../service/user-service';
import result from '../model/result';
import userContext from '../security/user-context';
import accountService from '../service/account-service';
app.delete('/user/delete', async (c) => {
await userService.physicsDelete(c, c.req.query());
@@ -42,3 +43,15 @@ app.put('/user/restore', async (c) => {
await userService.restore(c, await c.req.json());
return c.json(result.ok());
});
app.get('/user/allAccount', async (c) => {
const data = await accountService.allAccount(c, c.req.query());
return c.json(result.ok(data));
});
app.delete('/user/deleteAccount', async (c) => {
await accountService.physicsDelete(c, c.req.query());
return c.json(result.ok());
});

View File

@@ -43,6 +43,8 @@ const requirePerms = [
'/user/list',
'/user/resetSendCount',
'/user/add',
'/user/deleteAccount',
'/user/allAccount',
'/regKey/add',
'/regKey/list',
'/regKey/delete',
@@ -61,13 +63,13 @@ const premKey = {
'role:set': ['/role/set','/role/setDefault'],
'role:query': ['/role/list', '/role/tree'],
'role:delete': ['/role/delete'],
'user:query': ['/user/list'],
'user:query': ['/user/list','/user/allAccount'],
'user:add': ['/user/add'],
'user:reset-send': ['/user/resetSendCount'],
'user:set-pwd': ['/user/setPwd'],
'user:set-status': ['/user/setStatus'],
'user:set-type': ['/user/setType'],
'user:delete': ['/user/delete'],
'user:delete': ['/user/delete','/user/deleteAccount'],
'all-email:query': ['/allEmail/list'],
'all-email:delete': ['/allEmail/delete','/allEmail/batchDelete'],
'setting:query': ['/setting/query'],

View File

@@ -5,7 +5,7 @@ import userService from './user-service';
import emailService from './email-service';
import orm from '../entity/orm';
import account from '../entity/account';
import { and, asc, eq, gt, inArray, count, sql } from 'drizzle-orm';
import { and, asc, eq, gt, inArray, count, sql, ne } from 'drizzle-orm';
import { isDel, settingConst } from '../const/entity-const';
import settingService from './setting-service';
import turnstileService from './turnstile-service';
@@ -195,7 +195,37 @@ const accountService = {
throw new BizError(t('usernameLengthLimit'));
}
await orm(c).update(account).set({name}).where(and(eq(account.userId, userId),eq(account.accountId, accountId))).run();
},
async allAccount(c, params) {
let { userId, num, size } = params
userId = Number(userId)
num = Number(num)
size = Number(size)
if (size > 30) {
size = 30;
}
num = (num - 1) * size;
const userRow = await userService.selectByIdIncludeDel(c, userId);
const list = await orm(c).select().from(account).where(and(eq(account.userId, userId),ne(account.email,userRow.email))).limit(size).offset(num);
const { total } = await orm(c).select({ total: count() }).from(account).where(eq(account.userId, userId)).get();
return { list, total }
},
async physicsDelete(c, params) {
const { accountId } = params
await emailService.physicsDeleteByAccountId(c, accountId)
await orm(c).delete(account).where(eq(account.accountId, accountId)).run();
}
};
export default accountService;

View File

@@ -191,6 +191,11 @@ const attService = {
await r2Service.delete(c, batch);
}
},
async removeByAccountId(c, accountId) {
console.log(accountId)
await this.removeAttByField(c, "account_id", [accountId])
}
};

View File

@@ -655,6 +655,11 @@ const emailService = {
await attService.removeByEmailIds(c, emailIds);
await orm(c).delete(email).where(conditions.length > 1 ? and(...conditions) : conditions[0]).run();
},
async physicsDeleteByAccountId(c, accountId) {
await attService.removeByAccountId(c, accountId);
await orm(c).delete(email).where(eq(email.accountId, accountId)).run();
}
};

View File

@@ -74,6 +74,10 @@ const userService = {
return orm(c).select().from(user).where(sql`${user.email} COLLATE NOCASE = ${email}`).get();
},
selectByIdIncludeDel(c, userId) {
return orm(c).select().from(user).where(eq(user.userId, userId)).get();
},
selectById(c, userId) {
return orm(c).select().from(user).where(
and(