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
4d3c8226
Commit
4d3c8226
authored
Jun 09, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add backClassList && fix classInfo
parent
2c4bb343
Pipeline
#24778
passed with stage
in 4 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
0 deletions
+53
-0
back.js
app/controller/course/back.js
+9
-0
courseV5Institution.js
app/model/class/v5/courseV5Institution.js
+1
-0
course.js
app/router/course.js
+1
-0
back.js
app/service/course/back.js
+36
-0
institution.js
app/service/course/v5/institution.js
+6
-0
No files found.
app/controller/course/back.js
View file @
4d3c8226
...
...
@@ -66,6 +66,15 @@ class BackController extends Controller {
const
ret
=
await
service
.
course
.
back
.
addRedeemCode
(
params
);
ctx
.
success
(
ret
);
}
// 获取课程列表
async
getClassList
()
{
const
{
ctx
,
service
}
=
this
;
const
ret
=
await
service
.
course
.
back
.
getClassList
();
ctx
.
success
(
ret
);
}
}
module
.
exports
=
BackController
;
app/model/class/v5/courseV5Institution.js
View file @
4d3c8226
...
...
@@ -16,6 +16,7 @@ module.exports = app => {
name
:
STRING
,
logo
:
STRING
,
description
:
TEXT
,
title
:
STRING
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
created_time
:
{
...
...
app/router/course.js
View file @
4d3c8226
...
...
@@ -9,4 +9,5 @@ module.exports = app => {
router
.
get
(
'third'
,
'/order'
,
auth
,
'course.back.getOrderList'
);
router
.
get
(
'third'
,
'/redeem'
,
auth
,
'course.back.getRedeemCodeList'
);
router
.
post
(
'third'
,
'/redeem'
,
auth
,
'course.back.addRedeemCode'
);
router
.
get
(
'third'
,
'/class'
,
auth
,
'course.back.getClassList'
);
};
app/service/course/back.js
View file @
4d3c8226
...
...
@@ -234,6 +234,42 @@ class BackService extends Service {
}
return
ret
;
}
// 获取机构和课程
async
getClassList
()
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
const
userInfo
=
await
ctx
.
classModel
.
CourseBackUser
.
findOne
({
where
:
{
id
:
userUuid
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
userInfo
))
{
ctx
.
failed
(
'用户异常'
);
}
const
filter
=
userInfo
.
is_admin
===
0
?
{
where
:
{
id
:
userInfo
.
institution_id
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
}
:
{
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
]
};
const
institutionList
=
await
ctx
.
classModel
.
V5
.
CourseV5Institution
.
findAll
(
filter
);
if
(
ctx
.
isEmpty
(
institutionList
))
{
return
{
list
:
[],
};
}
let
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
institution_id
:
{
$in
:
R
.
pluck
(
'id'
,
institutionList
)
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
]
});
classList
=
_
.
groupBy
(
classList
,
'institution_id'
);
const
results
=
[];
for
(
const
v
of
institutionList
)
{
results
.
push
({
id
:
v
.
id
,
name
:
v
.
name
,
class
:
ctx
.
isEmpty
(
classList
[
v
.
id
])
?
[]
:
classList
[
v
.
id
],
});
}
return
{
list
:
results
,
};
}
}
module
.
exports
=
BackService
;
app/service/course/v5/institution.js
View file @
4d3c8226
...
...
@@ -143,6 +143,10 @@ class InstitutionSubService extends Service {
const
typeList
=
await
ctx
.
classModel
.
V5
.
CourseV5ClassToType
.
findAll
({
where
:
{
class_id
:
id
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'type_id'
]
});
const
type
=
await
ctx
.
classModel
.
V5
.
CourseV5Type
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'type_id'
,
typeList
)
}
},
attributes
:
[
'id'
,
'name'
]
});
// 授课频次
const
frequencyList
=
await
ctx
.
classModel
.
V5
.
CourseV5ClassToFrequency
.
findAll
({
where
:
{
class_id
:
id
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'frequency_id'
]
});
const
frequency
=
await
ctx
.
classModel
.
V5
.
CourseV5Frequency
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'frequency_id'
,
frequencyList
)
}
},
attributes
:
[
'id'
,
'name'
]
});
const
columns
=
[];
for
(
const
v
of
classColumns
)
{
if
(
!
ctx
.
isEmpty
(
columnList
[
v
.
column_id
]))
{
...
...
@@ -178,8 +182,10 @@ class InstitutionSubService extends Service {
classInfo
.
institution_name
=
ctx
.
isEmpty
(
institution
)
?
''
:
institution
.
name
;
classInfo
.
institution_logo
=
ctx
.
isEmpty
(
institution
)
?
''
:
institution
.
logo
;
classInfo
.
institution_description
=
ctx
.
isEmpty
(
institution
)
?
''
:
institution
.
description
;
classInfo
.
institution_title
=
ctx
.
isEmpty
(
institution
)
?
''
:
institution
.
title
;
classInfo
.
pay_count
+=
orderCount
;
classInfo
.
video_count
=
videoCount
;
classInfo
.
frequency
=
frequency
;
return
classInfo
;
}
...
...
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