mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-10 16:12:50 +00:00
add cursor rules
This commit is contained in:
parent
5d9708015a
commit
2fcc7cdb39
@ -161,7 +161,7 @@ export class AppDemoGoodsController extends BaseController {
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| --------- | ------ | ------------------------------------------------------------------ |
|
||||
| entity | Class | 实体类 |
|
||||
| entity | Class | 实体类,注意不能写表名 |
|
||||
| alias | String | 别名,如果有关联表默认主表的别名为`a`, 其他表一般按 b、c、d...设置 |
|
||||
| condition | String | 关联条件 |
|
||||
| type | String | 内关联: 'innerJoin', 左关联:'leftJoin' |
|
||||
|
||||
@ -8,7 +8,7 @@ globs:
|
||||
|
||||
中文文档:](httpsom)
|
||||
|
||||
官方文档:[https://typeorm.io](https:/据库文档:[https://www.midwayjs.org/docs/extensions/orm](https://www.midwayjs.org/docs/extensions/orm)
|
||||
官方文档:[https://typeorm.io](mdc:https:/据库文档:[https:/www.midwayjs.org/docs/extensions/orm](https:/www.midwayjs.org/docs/extensions/orm)
|
||||
|
||||
## 数据库配置
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ globs:
|
||||
```ts
|
||||
├── modules
|
||||
│ └── base(基础的权限管理系统)
|
||||
│ │ └── controller(api接口, 用法参考 [controller.mdc](mdc:.cursor/rules/controller.mdc) )
|
||||
│ │ └── controller(api接口, 用法参考 [controller.mdc](mdc:.cursor/rules/controller.mdc) ,必要时需要创建关联查询, 配置pageQueryOp)
|
||||
│ │ │ └── admin(后台管理接口)
|
||||
│ │ │ └── app(应用接口,如小程序APP等)
|
||||
│ │ └── dto(可选,参数校验)
|
||||
@ -25,6 +25,23 @@ globs:
|
||||
|
||||
```
|
||||
|
||||
创建模块一般需要创建`controller`、`entity`、`service`,
|
||||
如果entity文件夹没有子文件夹,那么引用BaseEntity是
|
||||
|
||||
- 引用BaseEntity固定为
|
||||
|
||||
```ts
|
||||
import { BaseEntity } from '../../modules/base/entity/base';
|
||||
```
|
||||
|
||||
错误示例
|
||||
|
||||
```ts
|
||||
import { BaseEntity } from '../../../modules/base/entity/base';
|
||||
```
|
||||
|
||||
多了一个层级
|
||||
|
||||
## 模块配置
|
||||
|
||||
#### config.ts
|
||||
|
||||
15
.cursorrules
15
.cursorrules
@ -1,5 +1,5 @@
|
||||
# 项目背景
|
||||
- 数据库:MySQL、Sqlite、Postgres、Typeorm(0.3.20)
|
||||
- 数据库:MySQL、Sqlite、Postgres、Typeorm(0.3.20版本, 不使用外键方式,如@ManyToOne、@OneToMany等)
|
||||
- 语言:TypeScript、JavaScript、CommonJS
|
||||
- 框架:Koa.js、midway.js、cool-admin-midway
|
||||
- 项目版本:8.x
|
||||
@ -37,4 +37,15 @@
|
||||
|
||||
# 其它
|
||||
|
||||
- 始终使用中文回复,包括代码注释等
|
||||
- 始终使用中文回复,包括代码注释等
|
||||
- `@midwayjs/decorator`,已弃用,使用`@midwayjs/core`
|
||||
- 不要使用自定义sql来操作数据库,而是使用typeorm的api,统计相关的可以考虑使用原生sql
|
||||
- Controller中不允许重写`add`、`delete`、`update`、`info`、`list`、`page`方法
|
||||
- Controller的关联查询一般写在pageQueryOp中,必要时需要创建关联查询
|
||||
- Entity字段使用驼峰命名,如:studentNo
|
||||
- Entity不允许使用@ManyToOne、@OneToMany等外键关系
|
||||
- Entity的BaseEntity引用固定为:`import { BaseEntity } from '../../base/entity/base';`,禁止修改层级
|
||||
- 创建api接口时,不要多层级如:`/student/detail`,改为`/studentDetail`,用驼峰法;
|
||||
- 本项目是版本8.x,所有代码都需要按照新的写法进行编写,如Entity字典的配置
|
||||
- 文件的命名不要使用驼峰法,而是使用下划线法,如:student_info.entity.ts,另外禁止太啰嗦,比如:student模块下的学生信息,不要写成:student_info, 而是写成info.ts,班级信息:class.ts,不要写成student_class.ts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user