diff --git a/README.md b/README.md new file mode 100644 index 0000000..818d04d --- /dev/null +++ b/README.md @@ -0,0 +1,196 @@ +
+ +cool-admin(nodejs版)一个很酷的后台权限管理系统,开源免费,Ai编码、流程编排、模块化、插件化、极速开发CRUD,方便快速构建迭代后台管理系统,支持原生、docker、普通服务器等多种方式部署 +到 官网 进一步了解。 +
+
+
+
+
+
+#### 项目前端
+
+[https://github.com/cool-team-official/cool-admin-vue](https://github.com/cool-team-official/cool-admin-vue)
+
+或
+
+[https://gitee.com/cool-team-official/cool-admin-vue](https://gitee.com/cool-team-official/cool-admin-vue)
+
+或
+
+[https://gitcode.com/cool_team/cool-admin-vue](https://gitcode.com/cool_team/cool-admin-vue)
+
+## 微信群
+
+
+
+## 运行
+
+#### 修改数据库配置,配置文件位于`src/config/config.local.ts`
+
+以 Mysql 为例,其他数据库请参考[数据库配置文档](https://cool-js.com/admin/node/quick.html#%E6%95%B0%E6%8D%AE%E5%BA%93%E9%85%8D%E7%BD%AE)
+
+Mysql(`>=5.7版本`),建议 8.0,node 版本(`>=18.x`),首次启动会自动初始化并导入数据
+
+```ts
+// mysql,驱动已经内置,无需安装
+typeorm: {
+ dataSource: {
+ default: {
+ type: 'mysql',
+ host: '127.0.0.1',
+ port: 3306,
+ username: 'root',
+ password: '123456',
+ database: 'cool',
+ // 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
+ synchronize: true,
+ // 打印日志
+ logging: false,
+ // 字符集
+ charset: 'utf8mb4',
+ // 是否开启缓存
+ cache: true,
+ // 实体路径
+ entities: ['**/modules/*/entity'],
+ },
+ },
+ },
+```
+
+#### 安装依赖并运行
+
+```bash
+$ npm i
+$ npm run dev
+```
+
+启动完成访问:[http://localhost:8001/](http://localhost:8001)
+
+注: `npm i`如果安装失败可以尝试使用切换您的镜像源,推荐使用[pnpm](https://pnpm.io/)安装
+
+## CURD(快速增删改查)
+
+大部分的后台管理系统,或者 API 服务都是对数据进行管理,所以可以看到大量的 CRUD 场景(增删改查),cool-admin 对此进行了大量地封装,让这块的编码量变得极其地少。
+
+#### 新建一个数据表
+
+`src/modules/demo/entity/goods.ts`,项目启动数据库会自动创建该表,无需手动创建
+
+```ts
+import { BaseEntity } from '../../base/entity/base';
+import { Column, Entity, Index } from 'typeorm';
+
+/**
+ * 商品
+ */
+@Entity('demo_app_goods')
+export class DemoAppGoodsEntity extends BaseEntity {
+ @Column({ comment: '标题' })
+ title: string;
+
+ @Column({ comment: '图片' })
+ pic: string;
+
+ @Column({ comment: '价格', type: 'decimal', precision: 5, scale: 2 })
+ price: number;
+}
+```
+
+#### 编写 api 接口
+
+`src/modules/demo/controller/app/goods.ts`,快速编写 6 个 api 接口
+
+```ts
+import { CoolController, BaseController } from '@cool-midway/core';
+import { DemoAppGoodsEntity } from '../../entity/goods';
+
+/**
+ * 商品
+ */
+@CoolController({
+ api: ['add', 'delete', 'update', 'info', 'list', 'page'],
+ entity: DemoAppGoodsEntity,
+})
+export class DemoAppGoodsController extends BaseController {
+ /**
+ * 其他接口
+ */
+ @Get('/other')
+ async other() {
+ return this.ok('hello, cool-admin!!!');
+ }
+}
+```
+
+这样我们就完成了 6 个接口的编写,对应的接口如下:
+
+- `POST /app/demo/goods/add` 新增
+- `POST /app/demo/goods/delete` 删除
+- `POST /app/demo/goods/update` 更新
+- `GET /app/demo/goods/info` 单个信息
+- `POST /app/demo/goods/list` 列表信息
+- `POST /app/demo/goods/page` 分页查询(包含模糊查询、字段全匹配等)
+
+### 部署
+
+[部署教程](https://node.cool-admin.com/src/guide/deploy.html)
+
+### 内置指令
+
+- 使用 `npm run lint` 来做代码风格检查。
+
+[midway]: https://midwayjs.org
+
+### 低价服务器
+
+[阿里云、腾讯云、华为云低价云服务器,不限新老](https://cool-js.com/service/cloud)