Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
49b9429e
Commit
49b9429e
authored
Apr 13, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add studentWorks
parent
3d38437b
Pipeline
#21640
passed with stage
in 3 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
6 deletions
+72
-6
courseV5StudentWorks.js
app/model/class/v5/courseV5StudentWorks.js
+47
-0
institution.js
app/service/course/v5/institution.js
+25
-6
No files found.
app/model/class/v5/courseV5StudentWorks.js
0 → 100644
View file @
49b9429e
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5StudentWorks
=
app
.
classModel
.
define
(
'course_v5_student_works'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
name
:
STRING
,
class_id
:
INTEGER
,
video_url
:
STRING
,
cover_image
:
STRING
,
description
:
STRING
,
sub_title
:
STRING
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
sort
:
INTEGER
,
created_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_v5_student_works'
,
});
return
CourseV5StudentWorks
;
};
app/service/course/v5/institution.js
View file @
49b9429e
...
...
@@ -87,6 +87,9 @@ class InstitutionSubService extends Service {
// 机构数据
const
institution
=
await
ctx
.
classModel
.
V5
.
CourseV5Institution
.
findOne
({
where
:
{
id
:
classInfo
.
institution_id
}
});
// 学员成果
const
studentWorks
=
await
ctx
.
classModel
.
V5
.
CourseV5StudentWorks
.
findAll
({
where
:
{
class_id
:
id
,
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
]],
attributes
:
[
'id'
,
'name'
,
'sub_title'
,
'description'
,
'video_url'
,
'cover_image'
]
});
const
columns
=
[];
for
(
const
v
of
classColumns
)
{
if
(
!
ctx
.
isEmpty
(
columnList
[
v
.
column_id
]))
{
...
...
@@ -103,6 +106,7 @@ class InstitutionSubService extends Service {
}
classInfo
.
columns
=
columns
;
classInfo
.
student_works
=
studentWorks
;
classInfo
.
institution_name
=
ctx
.
isEmpty
(
institution
)
?
''
:
institution
.
name
;
classInfo
.
institution_description
=
ctx
.
isEmpty
(
institution
)
?
''
:
institution
.
description
;
...
...
@@ -110,15 +114,30 @@ class InstitutionSubService extends Service {
}
// 用户收藏课程列表
async
getUserCollectedClass
es
(
input
)
{
async
getUserCollectedClass
List
(
input
)
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
const
page
=
Number
(
input
.
page
)
||
1
;
const
page_size
=
Number
(
input
.
page_size
)
||
10
;
const
offset
=
(
page
-
1
)
*
page_size
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'logo'
,
'age'
,
'price'
,
'price_type'
,
'mode'
,
'time'
,
'class_amount'
,
'multi_classes'
,
'cycle'
,
'description'
,
'sort'
];
const
filter
=
{
where
:
{
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
page_size
,
offset
,
attributes
};
const
userCollection
=
await
ctx
.
classModel
.
V5
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
userUuid
,
is_deleted
:
0
,
type
:
2
},
raw
:
true
});
const
classIds
=
R
.
pluck
(
'type_id'
,
userCollection
);
input
.
classIds
=
classIds
;
const
ret
=
await
this
.
getClasses
(
input
);
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAndCountAll
(
filter
);
// 用户收藏的课程
const
userCollection
=
await
ctx
.
classModel
.
V5
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
is_deleted
:
0
,
type
:
3
},
raw
:
true
});
const
collectedIds
=
R
.
pluck
(
'type_id'
,
userCollection
);
for
(
const
i
in
classList
.
rows
)
{
classList
.
rows
[
i
].
is_collected
=
collectedIds
.
includes
(
classList
.
rows
[
i
].
id
)
?
1
:
0
;
}
const
ret
=
{
list
:
classList
.
rows
,
total_count
:
classList
.
count
,
page
,
page_size
,
};
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment