@l1go/console-core
v0.0.12
Published
```js import * as consoleCore from '@l1go/console-core'
Downloads
9
Readme
修改configuration.ts
import * as consoleCore from '@l1go/console-core'
@Configuration({
imports: [
consoleCore,
],
importConfigs: ["./config"],
})
this.app.use(await this.app.generateMiddleware('consoleMiddleware'));
登录接口
@Provide()
@Controller('/console')
export class ConsoleLoginController {
@Inject()
ctx: Context;
@Logger()
coreLogger: ILogger;
@Inject()
userService: UserService;
@Post('/api/login')
@Validate()
async login(@Body(ALL) user: UserLoginInput) {
try {
const result = await this.userService.login(user);
if (result) {
let u = {
role: 'user'
}
this.ctx.session.user = u
return { success: true, message: "OK" };
}
return { success: false, message: result.message };
} catch (error) {
if (error instanceof ValidationError) {
return { success: false, message: "Params Validation Error", data: {} };
} else {
this.coreLogger.error(error)
return { success: false, message: "Unknown Errors", data: {} };
}
}
}
}