新增邮件发送和管理员功能
This commit is contained in:
@@ -4,17 +4,17 @@ import result from '../model/result';
|
||||
import userContext from '../security/user-context';
|
||||
|
||||
app.get('/account/list', async (c) => {
|
||||
const list = await accountService.list(c, c.req.query(), await userContext.getUserId(c));
|
||||
const list = await accountService.list(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok(list));
|
||||
});
|
||||
|
||||
app.delete('/account/delete', async (c) => {
|
||||
await accountService.delete(c, c.req.query(), await userContext.getUserId(c));
|
||||
await accountService.delete(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.post('/account/add', async (c) => {
|
||||
const account = await accountService.add(c, await c.req.json(), await userContext.getUserId(c));
|
||||
const account = await accountService.add(c, await c.req.json(), userContext.getUserId(c));
|
||||
return c.json(result.ok(account));
|
||||
});
|
||||
|
||||
|
||||
@@ -5,22 +5,27 @@ import userContext from '../security/user-context';
|
||||
import attService from '../service/att-service';
|
||||
|
||||
app.get('/email/list', async (c) => {
|
||||
const data = await emailService.list(c, c.req.query(), await userContext.getUserId(c));
|
||||
const data = await emailService.list(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok(data));
|
||||
});
|
||||
|
||||
app.get('/email/latest',async (c) => {
|
||||
const list = await emailService.latest(c, c.req.query(), await userContext.getUserId(c));
|
||||
app.get('/email/latest', async (c) => {
|
||||
const list = await emailService.latest(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok(list));
|
||||
})
|
||||
});
|
||||
|
||||
app.delete('/email/delete', async (c) => {
|
||||
await emailService.delete(c, c.req.query(), await userContext.getUserId(c));
|
||||
await emailService.delete(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.get('/email/attList', async (c) => {
|
||||
const attList = await attService.list(c, c.req.query(), await userContext.getUserId(c));
|
||||
const attList = await attService.list(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok(attList));
|
||||
})
|
||||
});
|
||||
|
||||
app.post('/email/send', async (c) => {
|
||||
const email = await emailService.send(c, await c.req.json(), userContext.getUserId(c));
|
||||
return c.json(result.ok(email));
|
||||
});
|
||||
|
||||
|
||||
6
mail-worker/src/api/init-api.js
Normal file
6
mail-worker/src/api/init-api.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import app from '../hono/hono';
|
||||
import initService from '../service/init-service';
|
||||
|
||||
app.get('/init/:secret', (c) => {
|
||||
return initService.init(c);
|
||||
})
|
||||
@@ -14,6 +14,7 @@ app.post('/register', async (c) => {
|
||||
});
|
||||
|
||||
app.delete('/logout', async (c) => {
|
||||
await loginService.logout(c, await userContext.getUserId(c));
|
||||
await loginService.logout(c, userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
|
||||
21
mail-worker/src/api/my-api.js
Normal file
21
mail-worker/src/api/my-api.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import app from '../hono/hono';
|
||||
import userService from '../service/user-service';
|
||||
import result from '../model/result';
|
||||
import userContext from '../security/user-context';
|
||||
|
||||
app.get('/my/loginUserInfo', async (c) => {
|
||||
const user = await userService.loginUserInfo(c, userContext.getUserId(c));
|
||||
return c.json(result.ok(user));
|
||||
});
|
||||
|
||||
app.put('/my/resetPassword', async (c) => {
|
||||
await userService.resetPassword(c, await c.req.json(), userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.delete('/my/delete', async (c) => {
|
||||
await userService.delete(c, userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
|
||||
16
mail-worker/src/api/r2-api.js
Normal file
16
mail-worker/src/api/r2-api.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import r2Service from '../service/r2-service';
|
||||
import app from '../hono/hono';
|
||||
|
||||
|
||||
app.get('/file/*', async (c) => {
|
||||
const key = c.req.path.split('/file/')[1];
|
||||
const obj = await r2Service.getObj(c, key);
|
||||
return new Response(obj.body, {
|
||||
headers: {
|
||||
'Content-Type': obj.httpMetadata?.contentType || 'application/octet-stream',
|
||||
'Content-Disposition': obj.httpMetadata?.contentDisposition || null
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
10
mail-worker/src/api/resend-api.js
Normal file
10
mail-worker/src/api/resend-api.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import resendService from '../service/resend-service';
|
||||
import app from '../hono/hono';
|
||||
app.post('/webhooks',async (c) => {
|
||||
try {
|
||||
await resendService.webhooks(c, await c.req.json());
|
||||
return c.text('success', 200)
|
||||
} catch (e) {
|
||||
return c.text(e.message, 500)
|
||||
}
|
||||
})
|
||||
44
mail-worker/src/api/role-api.js
Normal file
44
mail-worker/src/api/role-api.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import app from '../hono/hono';
|
||||
import roleService from '../service/role-service';
|
||||
import userContext from '../security/user-context';
|
||||
import result from '../model/result';
|
||||
import permService from '../service/perm-service';
|
||||
|
||||
app.post('/role/add', async (c) => {
|
||||
await roleService.add(c, await c.req.json(), userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.put('/role/setDefault', async (c) => {
|
||||
await roleService.setDefault(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
|
||||
app.put('/role/set', async (c) => {
|
||||
await roleService.setRole(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.get('/role/permTree', async (c) => {
|
||||
const tree = await permService.tree(c);
|
||||
return c.json(result.ok(tree));
|
||||
});
|
||||
|
||||
app.delete('/role/delete', async (c) => {
|
||||
await roleService.delete(c, c.req.query());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.get('/role/list', async (c) => {
|
||||
const roleList = await roleService.roleList(c);
|
||||
return c.json(result.ok(roleList));
|
||||
});
|
||||
|
||||
app.get('/role/selectUse', async (c) => {
|
||||
const roleList = await roleService.roleSelectUse(c);
|
||||
return c.json(result.ok(roleList));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -5,9 +5,19 @@ import settingService from '../service/setting-service';
|
||||
app.put('/setting/set', async (c) => {
|
||||
await settingService.set(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
})
|
||||
});
|
||||
|
||||
app.get('/setting/query', async (c) => {
|
||||
const setting = await settingService.query(c);
|
||||
const setting = await settingService.get(c);
|
||||
return c.json(result.ok(setting));
|
||||
})
|
||||
});
|
||||
|
||||
app.put('/setting/setBackground', async (c) => {
|
||||
const key = await settingService.setBackground(c, await c.req.json());
|
||||
return c.json(result.ok(key));
|
||||
});
|
||||
|
||||
app.delete('/setting/physicsDeleteAll', async (c) => {
|
||||
await settingService.physicsDeleteAll(c);
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import app from '../hono/hono';
|
||||
import startService from '../service/star-service';
|
||||
import starService from '../service/star-service';
|
||||
import userContext from '../security/user-context';
|
||||
import result from '../model/result';
|
||||
|
||||
app.post('/star/add', async (c) => {
|
||||
await startService.add(c, await c.req.json(), await userContext.getUserId(c));
|
||||
await starService.add(c, await c.req.json(), userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.get('/star/list', async (c) => {
|
||||
const data = await startService.list(c, c.req.query(), await userContext.getUserId(c));
|
||||
const data = await starService.list(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok(data));
|
||||
});
|
||||
|
||||
app.delete('/star/cancel', async (c) => {
|
||||
await startService.cancel(c, await c.req.query(), await userContext.getUserId(c));
|
||||
await starService.cancel(c, await c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
13
mail-worker/src/api/sys-email-api.js
Normal file
13
mail-worker/src/api/sys-email-api.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import app from '../hono/hono';
|
||||
import emailService from '../service/email-service';
|
||||
import result from '../model/result';
|
||||
|
||||
app.get('/sys-email/list',async (c) => {
|
||||
const data = await emailService.allList(c, c.req.query());
|
||||
return c.json(result.ok(data));
|
||||
})
|
||||
|
||||
app.delete('/sys-email/delete',async (c) => {
|
||||
const list = await emailService.physicsDelete(c, c.req.query());
|
||||
return c.json(result.ok(list));
|
||||
})
|
||||
@@ -3,21 +3,42 @@ import userService from '../service/user-service';
|
||||
import result from '../model/result';
|
||||
import userContext from '../security/user-context';
|
||||
|
||||
app.get('/user/loginUserInfo', async (c) => {
|
||||
const user = await userService.loginUserInfo(c, await userContext.getUserId(c));
|
||||
return c.json(result.ok(user));
|
||||
});
|
||||
|
||||
app.put('/user/resetPassword', async (c) => {
|
||||
await userService.resetPassword(c, await c.req.json(), await userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.delete('/user/delete', async (c) => {
|
||||
await userService.delete(c, await userContext.getUserId(c));
|
||||
await userService.physicsDelete(c, c.req.query());
|
||||
return c.json(result.ok());
|
||||
})
|
||||
});
|
||||
|
||||
app.put('/user/setPwd', async (c) => {
|
||||
await userService.setPwd(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.put('/user/setStatus', async (c) => {
|
||||
await userService.setStatus(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.put('/user/setType', async (c) => {
|
||||
await userService.setType(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.get('/user/list', async (c) => {
|
||||
const data = await userService.list(c, c.req.query(), userContext.getUserId(c));
|
||||
return c.json(result.ok(data));
|
||||
});
|
||||
|
||||
app.post('/user/add', async (c) => {
|
||||
await userService.add(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.put('/user/resetSendCount', async (c) => {
|
||||
await userService.resetSendCount(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.put('/user/restore', async (c) => {
|
||||
await userService.restore(c, await c.req.json());
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user