mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-14 19:22:50 +00:00
发布6.x
This commit is contained in:
parent
06c8c7975d
commit
fac7f82c3d
43
README.md
43
README.md
@ -45,22 +45,30 @@
|
|||||||
|
|
||||||
#### 修改数据库配置,配置文件位于`src/config/config.local.ts`
|
#### 修改数据库配置,配置文件位于`src/config/config.local.ts`
|
||||||
|
|
||||||
数据库为 mysql(`>=5.7版本`),node 版本(`>=12.x`),首次启动会自动初始化并导入数据
|
数据库为 mysql(`>=5.7版本`),建议 8.0,node 版本(`>=12.x`),首次启动会自动初始化并导入数据
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
orm: {
|
typeorm: {
|
||||||
type: 'mysql',
|
dataSource: {
|
||||||
host: '127.0.0.1',
|
default: {
|
||||||
port: 3306,
|
type: 'mysql',
|
||||||
username: 'root',
|
host: '127.0.0.1',
|
||||||
password: '123456',
|
port: 3306,
|
||||||
database: 'cool',
|
username: 'root',
|
||||||
// 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
|
password: '123456',
|
||||||
synchronize: true,
|
database: 'cool',
|
||||||
// 打印日志
|
// 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
|
||||||
logging: true,
|
synchronize: true,
|
||||||
// 字符集
|
// 打印日志
|
||||||
charset: 'utf8mb4',
|
logging: false,
|
||||||
|
// 字符集
|
||||||
|
charset: 'utf8mb4',
|
||||||
|
// 是否开启缓存
|
||||||
|
cache: true,
|
||||||
|
// 实体路径
|
||||||
|
entities: ['**/modules/*/entity'],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -83,14 +91,13 @@ $ open http://localhost:8001/
|
|||||||
`src/modules/demo/entity/goods.ts`,项目启动数据库会自动创建该表,无需手动创建
|
`src/modules/demo/entity/goods.ts`,项目启动数据库会自动创建该表,无需手动创建
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { EntityModel } from '@midwayjs/orm';
|
|
||||||
import { BaseEntity } from '@cool-midway/core';
|
import { BaseEntity } from '@cool-midway/core';
|
||||||
import { Column } from 'typeorm';
|
import { Column, Entity, Index } from 'typeorm';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品
|
* 商品
|
||||||
*/
|
*/
|
||||||
@EntityModel('demo_app_goods')
|
@Entity('demo_app_goods')
|
||||||
export class DemoAppGoodsEntity extends BaseEntity {
|
export class DemoAppGoodsEntity extends BaseEntity {
|
||||||
@Column({ comment: '标题' })
|
@Column({ comment: '标题' })
|
||||||
title: string;
|
title: string;
|
||||||
@ -108,14 +115,12 @@ export class DemoAppGoodsEntity extends BaseEntity {
|
|||||||
`src/modules/demo/controller/app/goods.ts`,快速编写 6 个 api 接口
|
`src/modules/demo/controller/app/goods.ts`,快速编写 6 个 api 接口
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Provide } from '@midwayjs/decorator';
|
|
||||||
import { CoolController, BaseController } from '@cool-midway/core';
|
import { CoolController, BaseController } from '@cool-midway/core';
|
||||||
import { DemoAppGoodsEntity } from '../../entity/goods';
|
import { DemoAppGoodsEntity } from '../../entity/goods';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品
|
* 商品
|
||||||
*/
|
*/
|
||||||
@Provide()
|
|
||||||
@CoolController({
|
@CoolController({
|
||||||
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
||||||
entity: DemoAppGoodsEntity,
|
entity: DemoAppGoodsEntity,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user