本项目全部使用一种新的语言和框架叫 NASL,NaturalTS 是它的 TS 表示,可以认为 NaturalTS = NASL。它的语法和 TypeScript、React 以及 Vue 的 TSX 写法有很多相似的地方,使用的组件库是略微改造过的 Element Plus。
逻辑和表达式部分,请务必在对 NASL - NaturalTS 语言有了解的情况下再进行书写。否则请先阅读 nasl-book 里的相关内容。
前端页面部分,请你在书写时尽量回忆 Vue 的 TSX 写法和 Element Plus 的 API,但也要注意 NaturalTS 特有的区别。
注意:在 markdown 文件中为了描述方便,用<file path="...">...content...</file>包裹表示src路径下需要写的文件路径和内容。如果直接是 src 目录中的文件,则不需要包裹 file 标签或代码块标记。
@EntityProperty({
title: "创建时间",
generationRule: 'auto'
})
createdTime: DateTime;
@EntityProperty({
title: "更新时间",
generationRule: 'auto'
})
updatedTime: DateTime;
@EntityProperty({
title: "创建者",
generationRule: 'auto'
})
createdBy: String;
@EntityProperty({
title: "更新者",
generationRule: 'auto'
})
updatedBy: String;
@EntityProperty({
title: "名称",
required: true
})
name: String;
@EntityProperty({
title: "地址"
})
address: String = '';
} export const SchoolEntity = createEntity();
@Entity({ title: "学生", description: "记录学生信息及其所属学校关联", directory: "education_system(教育系统)" }) export class Student { @EntityProperty({ title: "主键", primaryKey: true, generationRule: 'auto' }) id: Integer;@EntityProperty({
title: "创建时间",
generationRule: 'auto'
})
createdTime: DateTime;
@EntityProperty({
title: "更新时间",
generationRule: 'auto'
})
updatedTime: DateTime;
@EntityProperty({
title: "创建者",
generationRule: 'auto'
})
createdBy: String;
@EntityProperty({
title: "更新者",
generationRule: 'auto'
})
updatedBy: String;
@EntityProperty({
title: "姓名",
required: true
})
name: String;
@EntityProperty({
title: "年龄"
})
age: Integer;
@EntityProperty({
title: "状态",
required: true
})
status: app.enums.StudentStatus = app.enums.StudentStatus['READING'];
@EntityProperty({
title: "学校"
})
@EntityRelation<app.dataSources.defaultDS.entities.School['id']>('PROTECT')
schoolId: Integer;
} export const StudentEntity = createEntity();
@Enum({ title: "学生状态", directory: "education_system(教育系统)" }) export class StudentStatus extends BaseEnum { static readonly READING = new StudentStatus('READING', '在读'); static readonly GRADUATED = new StudentStatus('GRADUATED', '毕业'); }// 每个逻辑的命名规则如下:[逻辑的用途名][引用的组件名][根据情况唯一标识(可选)]
$Logic({ title: '获取学生列表', description: '从数据库中获取学生列表', directory: 'student_management(学生管理)', returnDescription: '学生列表分页结果' }) export declare function loadStudent_eltable1( /** 页码 */ page: Integer, /** 每页条数 */ size: Integer, /** 排序字段 */ sort: String, /** 排序方向 */ order: String, /** 学生过滤条件 */ filter: app.dataSources.defaultDS.entities.Student ): { /** 学生和学校关联列表 */ list: List<{ /** 学生信息 */ student: app.dataSources.defaultDS.entities.Student, /** 学校信息 */ school: app.dataSources.defaultDS.entities.School }>, /** 总条数 */ total: Integer }; $Logic({ title: '获取学生列表(含过滤)', description: '从数据库中获取学生列表(含学校名称过滤)', directory: 'student_management(学生管理)', returnDescription: '学生列表分页结果' }) export declare function loadStudentForTable( /** 页码 */ page: Integer, /** 每页条数 */ size: Integer, /** 排序字段 */ sort: String, /** 排序方向 */ order: String, /** 学生过滤条件 */ filter: app.dataSources.defaultDS.entities.Student, /** 学校名称过滤 */ filterSchoolName: String ): { /** 学生和学校关联列表 */ list: List<{ /** 学生信息 */ student: app.dataSources.defaultDS.entities.Student, /** 学校信息 */ school: app.dataSources.defaultDS.entities.School }>, /** 总条数 */ total: Integer }; $Logic({ title: '获取学校列表', description: '从数据库中获取学校列表用于选择框', directory: 'student_management(学生管理)', returnDescription: '学校列表结果' }) export declare function loadStudentSchool_elselect1(): List<{ /** 学校信息 */ school: app.dataSources.defaultDS.entities.School }>; $View({ title: "学生管理", description: "学生信息的增删改查及关联学校管理", crumb: "学生管理", auth: false, isIndex: false, }) export declare function student( /** 页面参数 */ param1: String );