File tree Expand file tree Collapse file tree 3 files changed +80
-3
lines changed Expand file tree Collapse file tree 3 files changed +80
-3
lines changed Original file line number Diff line number Diff line change 1
1
2
2
3
3
import { CourseModel , LessonModel } from "../model/model" ;
4
+ import * as Bluebird from "bluebird" ;
5
+ import { CourseDetail } from "../../shared/model/course-detail" ;
6
+ import { createCourseDetail } from "../../shared/model/createCourseDetail" ;
4
7
5
- export function findCourseDetail ( courseId :number ) {
8
+
9
+ export function findCourseDetail ( courseId :number ) : Bluebird < CourseDetail > {
6
10
7
11
return CourseModel . findById ( courseId , {
8
12
include : [
9
13
{
10
14
model : LessonModel
11
15
}
12
16
]
13
- } ) ;
17
+ } )
18
+ . then ( createCourseDetail ) ;
14
19
}
Original file line number Diff line number Diff line change
1
+
2
+
3
+
4
+ import { CourseDetail } from "./course-detail" ;
5
+
6
+
7
+ export function createCourseDetail ( {
8
+ id,
9
+ url,
10
+ description,
11
+ iconUrl,
12
+ courseListIcon,
13
+ seqNo,
14
+ longDescription,
15
+ comingSoon,
16
+ isNew,
17
+ isOngoing,
18
+ Lessons} :any ) :CourseDetail {
19
+
20
+ return {
21
+ id,
22
+ url,
23
+ description,
24
+ iconUrl,
25
+ courseListIcon,
26
+ seqNo,
27
+ longDescription,
28
+ comingSoon,
29
+ isNew,
30
+ isOngoing,
31
+ lessons : Lessons . map ( createLessonFromDbModel )
32
+ } ;
33
+
34
+ }
35
+
36
+ function createLessonFromDbModel ( {
37
+ id,
38
+ url,
39
+ description,
40
+ duration,
41
+ seqNo,
42
+ courseId,
43
+ pro,
44
+ tags
45
+ } :any ) {
46
+ return {
47
+ id,
48
+ url,
49
+ description,
50
+ duration,
51
+ seqNo,
52
+ courseId,
53
+ pro,
54
+ tags
55
+ }
56
+ }
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
Original file line number Diff line number Diff line change @@ -8,4 +8,8 @@ export interface Lesson {
8
8
courseId : string ;
9
9
pro : boolean ;
10
10
tags ?: string ;
11
- }
11
+ }
12
+
13
+
14
+
15
+
You can’t perform that action at this time.
0 commit comments