add cursor rules

This commit is contained in:
xiaopeng 2025-02-09 22:10:57 +08:00
parent 5d9708015a
commit 2fcc7cdb39
4 changed files with 33 additions and 5 deletions

View File

@ -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' |

View File

@ -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)
## 数据库配置

View File

@ -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

View File

@ -1,5 +1,5 @@
# 项目背景
- 数据库MySQL、Sqlite、Postgres、Typeorm0.3.20
- 数据库MySQL、Sqlite、Postgres、Typeorm0.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