保存
This commit is contained in:
20
mail-worker/src/api/account-api.js
Normal file
20
mail-worker/src/api/account-api.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import app from '../hono/hono';
|
||||
import accountService from '../service/account-service';
|
||||
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));
|
||||
return c.json(result.ok(list));
|
||||
});
|
||||
|
||||
app.delete('/account/delete', async (c) => {
|
||||
await accountService.delete(c, c.req.query(), await 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));
|
||||
return c.json(result.ok(account));
|
||||
});
|
||||
|
||||
26
mail-worker/src/api/email-api.js
Normal file
26
mail-worker/src/api/email-api.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import app from '../hono/hono';
|
||||
import emailService from '../service/email-service';
|
||||
import result from '../model/result';
|
||||
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));
|
||||
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));
|
||||
return c.json(result.ok(list));
|
||||
})
|
||||
|
||||
app.delete('/email/delete', async (c) => {
|
||||
await emailService.delete(c, c.req.query(), await 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));
|
||||
return c.json(result.ok(attList));
|
||||
})
|
||||
|
||||
19
mail-worker/src/api/login-api.js
Normal file
19
mail-worker/src/api/login-api.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import app from '../hono/hono';
|
||||
import loginService from '../service/login-service';
|
||||
import result from '../model/result';
|
||||
import userContext from '../security/user-context';
|
||||
|
||||
app.post('/login', async (c) => {
|
||||
const token = await loginService.login(c, await c.req.json());
|
||||
return c.json(result.ok({ token: token }));
|
||||
});
|
||||
|
||||
app.post('/register', async (c) => {
|
||||
const jwt = await loginService.register(c, await c.req.json());
|
||||
return c.json(result.ok(jwt));
|
||||
});
|
||||
|
||||
app.delete('/logout', async (c) => {
|
||||
await loginService.logout(c, await userContext.getUserId(c));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
13
mail-worker/src/api/setting-api.js
Normal file
13
mail-worker/src/api/setting-api.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import app from '../hono/hono';
|
||||
import result from '../model/result';
|
||||
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);
|
||||
return c.json(result.ok(setting));
|
||||
})
|
||||
19
mail-worker/src/api/star-api.js
Normal file
19
mail-worker/src/api/star-api.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import app from '../hono/hono';
|
||||
import startService 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));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
|
||||
app.get('/star/list', async (c) => {
|
||||
const data = await startService.list(c, c.req.query(), await 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));
|
||||
return c.json(result.ok());
|
||||
});
|
||||
1
mail-worker/src/api/test-api.js
Normal file
1
mail-worker/src/api/test-api.js
Normal file
@@ -0,0 +1 @@
|
||||
import app from '../hono/hono';
|
||||
23
mail-worker/src/api/user-api.js
Normal file
23
mail-worker/src/api/user-api.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import app from '../hono/hono';
|
||||
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));
|
||||
return c.json(result.ok());
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user