This commit is contained in:
啊平 2021-01-27 17:55:00 +08:00
parent 2a501ed8e9
commit ac8b7c62fc
5 changed files with 13 additions and 33 deletions

View File

@ -1,10 +1,10 @@
import { App, Configuration } from '@midwayjs/decorator';
import { ILifeCycle, IMidwayContainer } from '@midwayjs/core';
import * as orm from '@midwayjs/orm';
import * as cool from '@midwayjs/cool-core';
import { listModule } from '@midwayjs/decorator';
import { Application } from 'egg';
import * as moment from 'moment';
import * as cool from '@midwayjs/cool-core';
@Configuration({
imports: [

View File

@ -1,12 +1,12 @@
import { BaseController } from '@midwayjs/cool-core';
import { Controller, Get, Query, Provide } from '@midwayjs/decorator';
import { User } from '../model/user';
import { Repository } from 'typeorm';
import { InjectEntityModel } from '@midwayjs/orm';
import { BaseController } from '@midwayjs/cool-core';
@Provide()
@Controller('/test')
export class HomeController extends BaseController {
export class HomeController extends BaseController{
@InjectEntityModel(User)
userModel: Repository<User>
@ -15,4 +15,10 @@ export class HomeController extends BaseController {
return this.userModel;
}
// 根据ID 获得单条信息
@Get("/info")
async info(@Query() id) {
return id;
}
}

View File

@ -1,24 +0,0 @@
import { EntityModel } from '@midwayjs/orm';
import { Column, Index } from 'typeorm';
import { BaseModel } from '@midwayjs/cool-core';
/**
*
*/
@EntityModel('sys_role')
export class SysRole extends BaseModel{
// 名称
@Column()
userId: string;
// 名称
@Index({ unique: true })
@Column()
name: string;
// 角色标签
@Index({ unique: true })
@Column({ nullable: true, length: 50 })
label: string;
// 备注
@Column({ nullable: true })
remark: string;
}

View File

@ -1,10 +1,9 @@
import { BaseModel } from '@midwayjs/cool-core';
import { EntityModel } from '@midwayjs/orm';
import { PrimaryGeneratedColumn, Column } from 'typeorm';
import { Column } from 'typeorm';
@EntityModel('user')
export class User {
@PrimaryGeneratedColumn({ name: "id" })
id: number;
export class User extends BaseModel{
@Column({ name: "name" })
name: string;

View File

@ -1,9 +1,8 @@
import { Provide } from '@midwayjs/decorator';
import { IUserOptions } from '../interface';
import { BaseService } from '@midwayjs/cool-core'
@Provide()
export class UserService extends BaseService {
export class UserService {
async getUser(options: IUserOptions) {
return {