RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/xin-lai/CodeSpirit

Cursor rule

.cursor/rules/dto.mdc

CodeSpirit DTO 开发规范 - 数据传输对象的特性、验证、映射和多语言支持

Cursor rules

Quality

50/100

Scores the file, not the repository.

Length

177 words

5 headings · 2 code blocks

Repository

56

— · pushed 134 days ago

Last changed

3 days ago

First indexed 3 days ago.
xin-lai/CodeSpirit/.cursor/rules/dto.mdcRawGitHub
1---
2description: CodeSpirit DTO 开发规范 - 数据传输对象的特性、验证、映射和多语言支持
3globs:
4 - "*Dto.cs"
5 - "**/Dtos/**/*.cs"
6alwaysApply: false
7---
8 
9# DTO 类规则
10 
11## 属性特性要求
12 
131. **所有属性必须添加 Display 特性(支持多语言)**
142. **Create/Update DTO 必须添加验证特性**
153. 列表 DTO 应参考 [UserDto.cs](mdc:Src/CodeSpirit.IdentityApi/Dtos/User/UserDto.cs) 添加必要的列特性
164. 查询 DTO 必须继承自 [QueryDtoBase.cs](mdc:Src/CodeSpirit.Core/Dtos/QueryDtoBase.cs),并添加常见的查询逻辑,可以参考 [UserQueryDto.cs](mdc:Src/CodeSpirit.IdentityApi/Dtos/User/UserQueryDto.cs)
175. DTO 添加完成后,应添加或完善 DTO 映射文件,处理好映射关系,参考 [UserProfile.cs](mdc:Src/CodeSpirit.IdentityApi/MappingProfiles/UserProfile.cs)
186. BatchImportItemDto 需要添加 JsonProperty 特性,propertyName 与 DisplayName 一致,参考 [UserBatchImportItemDto.cs](mdc:Src/CodeSpirit.IdentityApi/Dtos/User/UserBatchImportItemDto.cs)
197. 如果需要显示用户信息,请使用聚合器字段特性 [AggregateFieldAttribute.cs](mdc:Src/CodeSpirit.Core/Attributes/AggregateFieldAttribute.cs),参考 [CodeSpirit.Aggregator聚合器使用指南.md](mdc:Docs/CodeSpirit.Aggregator聚合器使用指南.md)
20 
21## 查询 DTO 中枚举字段
22 
23**枚举筛选字段仅需 `[DisplayName]`,不要使用 `[AmisSelectField]`。**
24 
25SearchFieldHelper 会自动为枚举类型生成 Select 下拉选项,选项文案来自枚举值的 `[Display(Name = "...")]` 特性。若添加 `AmisSelectField`(无论 Source 或 Options),会覆盖该自动行为,导致重复配置或硬编码。
26 
27```csharp
28// ✅ 正确:仅 DisplayName,框架自动生成选项
29[DisplayName("状态")]
30public QuestionStatus? Status { get; set; }
31 
32// ❌ 错误:不要为枚举添加 AmisSelectField
33[AmisSelectField(Options = "1:草稿,2:已发布,3:已归档")] // 硬编码,无法多语言
34[AmisSelectField(Source = "${ROOT_API}/api/.../status-options")] // 过度设计,枚举无需 API
35```
36 
37参考:[QuestionQueryDto.cs](mdc:Src/ApiServices/CodeSpirit.ExamApi/Dtos/Question/QuestionQueryDto.cs) 中的 Type、Difficulty、Status 字段。
38 
39## 多语言写法示例
40 
41```csharp
42using CodeSpirit.Localization.Resources;
43 
44public class CreateQuestionDto
45{
46 [Display(Name = "Content", ResourceType = typeof(DisplayResources))]
47 [Required(ErrorMessageResourceType = typeof(ValidationResources),
48 ErrorMessageResourceName = "Required")]
49 [StringLength(2000,
50 ErrorMessageResourceType = typeof(ValidationResources),
51 ErrorMessageResourceName = "StringLengthMax")]
52 public string Content { get; set; } = string.Empty;
53
54 [Display(Name = "Score", ResourceType = typeof(DisplayResources))]
55 [Range(0, 100,
56 ErrorMessageResourceType = typeof(ValidationResources),
57 ErrorMessageResourceName = "Range")]
58 public decimal Score { get; set; }
59}
60```
61 
62## 参考文件
63 
64- 列表 DTO: [UserDto.cs](mdc:Src/CodeSpirit.IdentityApi/Dtos/User/UserDto.cs)
65- 查询 DTO: [UserQueryDto.cs](mdc:Src/CodeSpirit.IdentityApi/Dtos/User/UserQueryDto.cs)
66- 查询 DTO 枚举字段: [QuestionQueryDto.cs](mdc:Src/ApiServices/CodeSpirit.ExamApi/Dtos/Question/QuestionQueryDto.cs)
67- 映射配置: [UserProfile.cs](mdc:Src/CodeSpirit.IdentityApi/MappingProfiles/UserProfile.cs)
68- 批量导入: [UserBatchImportItemDto.cs](mdc:Src/CodeSpirit.IdentityApi/Dtos/User/UserBatchImportItemDto.cs)
69 

Sections

  • DTO 类规则
  • 属性特性要求
  • 查询 DTO 中枚举字段
  • 多语言写法示例
  • 参考文件

Stack — with the evidence

csharp

(1.00)

react

(0.70)

typescript

(0.60)

dotnet

(0.60)

kubernetes

(0.60)

github-actions

(0.60)

javascript

(0.50)

Glob targeting

  • *Dto.cs
  • **/Dtos/**/*.cs

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
xin-lai
Language
—
License
—
Archived
no

All configs in this repo

Also in xin-lai/CodeSpirit

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
xin-lai/CodeSpirit.cursor/rules/js.mdc · 56Cursor rulescsharpreact+5apidocs46/1003 days ago
xin-lai/CodeSpirit.cursor/rules/ai-development.mdc · 56Cursor rulescsharpreact+5api46/1003 days ago
xin-lai/CodeSpirit.cursor/rules/all.mdc · 56Cursor rulescsharpreact+5testing-strategyapi50/1003 days ago
xin-lai/CodeSpirit.cursor/rules/amis-cards.mdc · 56Cursor rulescsharpreact+5no sections54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/api-design.mdc · 56Cursor rulescsharpreact+5no sections54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/controller.mdc · 56Cursor rulescsharpreact+5api54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/cs.mdc · 56Cursor rulescsharpreact+5no sections25/1003 days ago
xin-lai/CodeSpirit.cursor/rules/csproj.mdc · 56Cursor rulescsharpreact+5api54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/css.mdc · 56Cursor rulescsharpreact+5ui54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/database.mdc · 56Cursor rulescsharpreact+5no sections74/1003 days ago
xin-lai/CodeSpirit.cursor/rules/dependency-injection.mdc · 56Cursor rulescsharpreact+5api54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/enum.mdc · 56Cursor rulescsharpreact+5no sections50/1003 days ago
xin-lai/CodeSpirit.cursor/rules/i18n.mdc · 56Cursor rulescsharpreact+5no sections50/1003 days ago
xin-lai/CodeSpirit.cursor/rules/naming-conventions.mdc · 56Cursor rulescsharpreact+5no sections50/1003 days ago
xin-lai/CodeSpirit.cursor/rules/package-management.mdc · 56Cursor rulescsharpreact+5no sections74/1003 days ago
xin-lai/CodeSpirit.cursor/rules/performance.mdc · 56Cursor rulescsharpreact+5no sections54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/project-structure.mdc · 56Cursor rulescsharpreact+5api54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/security.mdc · 56Cursor rulescsharpreact+5database54/1003 days ago
xin-lai/CodeSpirit.cursor/rules/service.mdc · 56Cursor rulescsharpreact+5no sections50/1003 days ago
xin-lai/CodeSpirit.cursor/rules/startup-framework.mdc · 56Cursor rulescsharpreact+5api54/1003 days ago
Diff against .cursor/rules/js.mdc Diff against .cursor/rules/ai-development.mdc Diff against .cursor/rules/all.mdc Diff against .cursor/rules/amis-cards.mdc Diff against .cursor/rules/api-design.mdc Diff against .cursor/rules/controller.mdc Diff against .cursor/rules/cs.mdc Diff against .cursor/rules/csproj.mdc Diff against .cursor/rules/css.mdc Diff against .cursor/rules/database.mdc Diff against .cursor/rules/dependency-injection.mdc Diff against .cursor/rules/enum.mdc Diff against .cursor/rules/i18n.mdc Diff against .cursor/rules/naming-conventions.mdc Diff against .cursor/rules/package-management.mdc Diff against .cursor/rules/performance.mdc Diff against .cursor/rules/project-structure.mdc Diff against .cursor/rules/security.mdc Diff against .cursor/rules/service.mdc Diff against .cursor/rules/startup-framework.mdc

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126Cursor rulesgobun+5setupbuildtestlint-format+6100/1003 days ago
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
markstev/mark-starter.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+14setuptestlint-formatstyle+699/1003 days ago
Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+13setuptestlint-formatstyle+799/1003 days ago
deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1Cursor rulestypescriptnextjs+5setuptestlint-formatstyle+799/1003 days ago
dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+15setuptestlint-formatstyle+799/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack