# 功能需求规格文档:课程管理 > 本模板用于描述业务功能需求,技能将根据此文档生成后端 + 前端代码。 > 请按此格式填写,结构化描述越完整,代码生成质量越高。 --- ## 1. 基础信息 | 属性 | 值 | |------|-----| | 功能中文名 | 课程管理 | | 功能简写 | course | | 所属模块 | ruoyi-modules/ruoyi-ecs | | 主表名 | t_ecs_course | | 从表名 | t_ecs_course_teacher | | 是否多租户 | 是 | | 数据库类型 | kingbase | | 描述 | 管理课程信息,支持多教师关联 | --- ## 2. 接口清单 ### 2.1 主表接口 | 接口 | HTTP | 路径(后端) | 前端路径 | 权限字符 | |------|------|-------------|----------|----------| | 列表 | GET | /course/list | /ecs/course/list | ecs:course:list | | 详情 | GET | /course/{id} | /ecs/course/{id} | ecs:course:query | | 新增 | POST | /course/ | /ecs/course/ | ecs:course:add | | 编辑 | PUT | /course/ | /ecs/course/ | ecs:course:edit | | 删除 | DELETE | /course/{ids} | /ecs/course/{ids} | ecs:course:remove | | 导出模板 | POST | /course/exportTemplate | /ecs/course/exportTemplate | ecs:course:export | | 导入数据 | POST | /course/importData | /ecs/course/importData | ecs:course:import | | 导出数据 | POST | /course/export | /ecs/course/export | ecs:course:export | ### 2.2 补充接口(如有) > 无 --- ## 3. 字段属性速查表 | 属性 | 含义 | 可选值 | 说明 | |------|------|--------|------| | `fieldName` | 字段名(驼峰) | — | 代码变量名 | | `columnName` | 列名(下划线) | — | 数据库列名 | | `fieldType` | Java类型 | String/Long/Integer/BigDecimal/Date | | | `inDb` | 是否在表中存在 | true/false | false=纯前端计算字段 | | `inTable` | 列表是否显示 | true/false | 生成表格列 | | `inQuery` | 是否查询字段 | true/false | 生成搜索条件 | | `queryType` | 查询方式 | eq/like/between | 精确/模糊/范围 | | `inForm` | 是否表单字段 | true/false | 生成表单项 | | `inAdd` | 新增表单显示 | true/false | | | `inEdit` | 编辑表单显示 | true/false | | | `required` | 是否必填 | true/false | 生成校验注解 | | `dictType` | 字典类型 | 字典标识 | 有值=字典下拉,否则普通输入 | | `relation` | 关联选择配置 | 对象 | 有值=弹出选择框 | | `component` | 前端组件类型 | input/select/inputNumber/datetime/textarea | 默认根据类型推断 | | `width` | 表格列宽 | 数字(px) | 默认auto | | `sort` | 排序 | 数字 | 越小越靠前 | | `excelExport` | Excel导出 | true/false | 默认true | ### 关联选择 relation 格式 ```yaml relation: table: {关联表名} idField: {回填ID字段} nameField: {显示名称字段} title: 选择{实体名} path: /{模块}/{实体}/{路径} ``` --- ## 4. 字段清单 ### 4.1 主表 `t_ecs_course` ```yaml fields: # ---------- 主键 ---------- - fieldName: courseId columnName: course_id fieldType: Long inDb: true inTable: false inForm: false remark: 主键,编辑时传递 # ---------- 业务字段 ---------- - fieldName: courseName columnName: course_name fieldType: String inDb: true inTable: true # 列表显示 inQuery: true # 作为查询条件 queryType: like # 模糊查询 inForm: true # 表单显示 inAdd: true inEdit: true required: true # 必填 component: input width: 200 sort: 1 excelExport: true remark: 课程名称 - fieldName: courseCode columnName: course_code fieldType: String inDb: true inTable: true # 列表显示 inQuery: true # 作为查询条件 queryType: like # 模糊查询 inForm: true # 表单显示 inAdd: true inEdit: true required: true # 必填 component: input width: 150 sort: 2 excelExport: true remark: 课程编码 - fieldName: courseType columnName: course_type fieldType: Integer inDb: true inTable: true # 列表显示 inQuery: true # 作为查询条件 queryType: eq # 精确查询 inForm: true # 表单显示 inAdd: true inEdit: true required: true # 必填 dictType: course_type # 字典下拉 component: select width: 100 sort: 3 excelExport: true remark: 课程类型:0-选修课,1-必修课 - fieldName: credit columnName: credit fieldType: BigDecimal inDb: true inTable: true # 列表显示 inQuery: false inForm: true # 表单显示 inAdd: true inEdit: true required: true # 必填 component: inputNumber width: 100 sort: 4 excelExport: true remark: 学分 - fieldName: hours columnName: hours fieldType: Integer inDb: true inTable: true # 列表显示 inQuery: false inForm: true # 表单显示 inAdd: true inEdit: true required: true # 必填 component: inputNumber width: 100 sort: 5 excelExport: true remark: 学时 # ---------- VO承载字段(讲师姓名拼接串) ---------- - fieldName: teacherNames columnName: teacher_names fieldType: String inDb: false # 纯VO字段,数据库无此列 inTable: true # 列表显示 inQuery: false inForm: false excelExport: true remark: 讲师姓名拼接串(如:张三、李四、王五),由关联表查询拼接 # ---------- 第三方同步字段 ---------- - fieldName: otherId columnName: other_id fieldType: String inDb: true inTable: false # 列表不显示 inQuery: false inForm: false # 表单不显示 excelExport: false remark: 第三方标识符,仅同步用 - fieldName: dataSource columnName: data_source fieldType: Integer inDb: true inTable: false # 不显示列 inQuery: false # 不作为查询条件 inForm: false # 不在表单中显示,默认值由后台处理 inAdd: false inEdit: false lockRule: # 操作锁定规则:dataSource=1 时禁止编辑和删除 lockValue: 1 lockActions: - edit - delete tip: 第三方数据不可操作 width: 120 sort: 6 excelExport: true remark: 数据来源:0-平台录入,1-第三方同步 # ---------- 公共字段(所有表统一包含,建表时自动追加) ---------- # 通用字段定义: # | 字段 | Java类型 | 说明 | # | ------------- | --------------- | ------------------ | # | del_flag | Integer | 逻辑删除:0-未删除,1-已删除 | # | create_dept | Long | 创建部门 | # | create_by | Long | 创建者 | # | create_time | Date | 创建时间 | # | update_by | Long | 最后修改者 | # | update_time | Date | 最后修改时间 | # | tenant_id | Long | 租户ID(仅多租户表包含) | - fieldName: delFlag columnName: del_flag fieldType: Integer inDb: true inTable: false inForm: false - fieldName: tenantId columnName: tenant_id fieldType: Long inDb: true inTable: false inForm: false - fieldName: createTime columnName: create_time fieldType: Date inDb: true inTable: true # 列表显示 inQuery: false inForm: false component: datetime width: 180 sort: 99 excelExport: true ``` ### 4.2 从表 `t_ecs_course_teacher` > 课程-教师关联表,支持一门课程关联多个教师 ```yaml fields: - fieldName: id columnName: id fieldType: Long inDb: true inTable: false inForm: false remark: 主键 - fieldName: courseId columnName: course_id fieldType: Long inDb: true inTable: false inForm: false remark: 课程ID,关联主表 - fieldName: teacherId columnName: teacher_id fieldType: Long inDb: true inTable: false # 列表不显示ID inQuery: false inForm: true # 表单显示 inAdd: true inEdit: true required: true relation: table: t_ecs_teacher idField: teacher_id nameField: teacher_name title: 选择教师 path: /ecs/teacher/selectTeacher component: teacherSelect sort: 1 remark: 教师ID,关联教师信息表 - fieldName: teacherName columnName: teacher_name fieldType: String inDb: true inTable: true # 列表显示教师姓名 inQuery: false inForm: false # 表单不直接编辑,通过关联选择回填 sort: 2 excelExport: true remark: 教师姓名(冗余),由关联选择回填 - fieldName: createTime columnName: create_time fieldType: Date inDb: true inTable: false inQuery: false inForm: false ``` --- ## 5. VO 结构 ### 5.1 主表列表 VO ```yaml CourseVo: - courseId - courseName - courseCode - courseType - credit - hours - teacherNames # 讲师姓名拼接串 - dataSource # 操作锁定判断(lockRule) - createTime ``` ### 5.2 主表明细 VO(包含从表) ```yaml CourseDetailVo: includes: CourseVo additional: - teacherList: List # 课程教师关联列表 ``` ### 5.3 从表 VO ```yaml CourseTeacherVo: - id - courseId - teacherId - teacherName - createTime ``` --- ## 6. 特殊需求 ```yaml special: excelImport: true excelExport: true importRules: - fieldName: courseName required: true unique: false - fieldName: courseCode required: true unique: true # 课程编码唯一校验 - fieldName: courseType required: true unique: false - fieldName: credit required: true unique: false min: 0.5 max: 20 - fieldName: hours required: true unique: false min: 1 max: 9999 - fieldName: dataSource required: true unique: false # 从表参与导入(教师信息单独导入) subTableImport: true subTableExport: true dubboExpose: true dubboServiceName: RemoteCourseService ``` --- ## 7. 字典项(如有) | 字典类型 | 枚举值 | 说明 | |----------|--------|------| | `course_type` | 0=选修课, 1=必修课 | 课程类型 | | `data_source` | 0=平台录入, 1=第三方同步 | 数据来源 | --- ## 8. 建表语句 > 数据库类型:kingbase(人大金仓) > > **通用字段**:所有表统一包含以下字段(建表语句自动追加,无需在字段清单中重复): > > | 字段 | 类型 | 说明 | > | ------------- | -------------------- | ------------------ | > | del_flag | character(1 char) | 逻辑删除:0-未删除,1-已删除 | > | create_dept | bigint | 创建部门 | > | create_by | bigint | 创建者 | > | create_time | timestamp | 创建时间 | > | update_by | bigint | 最后修改者 | > | update_time | timestamp | 最后修改时间 | > > 多租户表额外包含: > > | 字段 | 类型 | 说明 | > | ------------- | -------------------- | ------------------ | > | tenant_id | bigint | 租户ID | ### 8.1 主表 `t_ecs_course` ```sql -- 课程信息表 CREATE TABLE "dbo"."t_ecs_course" ( "course_id" bigint NOT NULL, "course_name" character varying(255 char) NOT NULL DEFAULT ''::varchar, "course_code" character varying(255 char) NOT NULL DEFAULT ''::varchar, "course_type" integer NOT NULL DEFAULT '0'::bpchar, "credit" numeric(10,2) NOT NULL DEFAULT 0, "hours" integer NOT NULL DEFAULT 0, "other_id" character varying(255 char) DEFAULT ''::varchar, "data_source" integer NOT NULL DEFAULT '0'::bpchar, "del_flag" character(1 char) NOT NULL DEFAULT '0'::bpchar, "create_dept" bigint, "create_by" bigint, "create_time" timestamp, "update_by" bigint, "update_time" timestamp, "tenant_id" bigint, CONSTRAINT "t_ecs_course_pkey" PRIMARY KEY ("course_id") ); -- 表注释 ALTER TABLE "dbo"."t_ecs_course" COMMENT '课程信息表'; -- 列注释 ALTER TABLE "dbo"."t_ecs_course" MODIFY "course_id" COMMENT '课程ID,主键'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "course_name" COMMENT '课程名称'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "course_code" COMMENT '课程编码'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "course_type" COMMENT '课程类型:0-选修课,1-必修课'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "credit" COMMENT '学分'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "hours" COMMENT '学时'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "other_id" COMMENT '第三方标识符,仅同步用'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "data_source" COMMENT '数据来源:0-平台录入,1-第三方同步'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "del_flag" COMMENT '删除标志:0-正常,1-删除'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "create_dept" COMMENT '创建部门'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "create_by" COMMENT '创建者'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "create_time" COMMENT '创建时间'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "update_by" COMMENT '更新者'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "update_time" COMMENT '更新时间'; ALTER TABLE "dbo"."t_ecs_course" MODIFY "tenant_id" COMMENT '租户编号'; ``` ### 8.2 从表 `t_ecs_course_teacher` ```sql -- 课程-教师关联表 CREATE TABLE "dbo"."t_ecs_course_teacher" ( "id" bigint NOT NULL, "course_id" bigint NOT NULL, "teacher_id" bigint NOT NULL, "teacher_name" character varying(255 char) DEFAULT ''::varchar, "del_flag" character(1 char) NOT NULL DEFAULT '0'::bpchar, "create_dept" bigint, "create_by" bigint, "create_time" timestamp, "update_by" bigint, "update_time" timestamp, "tenant_id" bigint, CONSTRAINT "t_ecs_course_teacher_pkey" PRIMARY KEY ("id") ); -- 表注释 ALTER TABLE "dbo"."t_ecs_course_teacher" COMMENT '课程-教师关联表'; -- 列注释 ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "id" COMMENT '主键'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "course_id" COMMENT '课程ID,关联主表'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "teacher_id" COMMENT '教师ID,关联教师信息表'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "teacher_name" COMMENT '教师姓名(冗余),由关联选择回填'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "del_flag" COMMENT '删除标志:0-正常,1-删除'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "create_dept" COMMENT '创建部门'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "create_by" COMMENT '创建者'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "create_time" COMMENT '创建时间'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "update_by" COMMENT '更新者'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "update_time" COMMENT '更新时间'; ALTER TABLE "dbo"."t_ecs_course_teacher" MODIFY "tenant_id" COMMENT '租户编号'; ``` --- ## 9. 备注 1. **教师关联设计**:课程与教师为多对多关系,通过中间表 `t_ecs_course_teacher` 关联,课程列表中 `teacherNames` 字段由 SQL 拼接关联表的教师姓名得到。 2. **讲师姓名拼接逻辑**(后端实现): ```sql SELECT c.*, GROUP_CONCAT(ct.teacher_name ORDER BY ct.id SEPARATOR '、') AS teacher_names FROM t_ecs_course c LEFT JOIN t_ecs_course_teacher ct ON c.course_id = ct.course_id AND ct.del_flag = 0 WHERE c.del_flag = 0 GROUP BY c.course_id ``` 3. **表单教师选择**:新增/编辑课程时,通过关联弹出框选择教师,选中后回填 `teacherId` 到中间表,`teacherName` 冗余存储。 4. **删除关联**:删除课程时,中间表关联数据随主表一起逻辑删除(`del_flag=1`)。 5. **导入说明**:Excel 导入时,教师信息单独处理,需先导入课程基础信息,再导入教师关联关系。 6. **操作锁定规则**:`dataSource` 字段值为 `1`(第三方同步)时,前端操作列隐藏编辑和删除按钮,显示锁定图标和提示"第三方数据不可操作";值为 `0`(平台录入)时正常显示操作按钮。