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
0b686c64
Commit
0b686c64
authored
Nov 20, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix user search
parent
11b7e488
Pipeline
#16755
passed with stage
in 50 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
29 deletions
+30
-29
course_institution.js
app/model/class/course_institution.js
+1
-1
institution.js
app/service/course/institution.js
+2
-2
institution.js
app/service/course/v2/institution.js
+27
-26
No files found.
app/model/class/course_institution.js
View file @
0b686c64
...
...
@@ -7,7 +7,7 @@ module.exports = app => {
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseArea
=
app
.
classModel
.
define
(
'course_area'
);
const
CourseArea
=
app
.
classModel
.
define
(
'course_
old_
area'
);
const
CourseInstitution
=
app
.
classModel
.
define
(
'course_old_institution'
,
{
id
:
{
...
...
app/service/course/institution.js
View file @
0b686c64
...
...
@@ -317,8 +317,8 @@ class InstitutionService extends Service {
const
ret
=
[];
for
(
const
i
in
institutions
)
{
const
institution
=
institutions
[
i
];
if
(
!
institution
.
course_
areas
||
institution
.
course
_areas
.
length
===
0
)
continue
;
const
course_areas
=
institution
.
course_areas
;
if
(
!
institution
.
course_
old_areas
||
institution
.
course_old
_areas
.
length
===
0
)
continue
;
const
course_areas
=
institution
.
course_
old_
areas
;
for
(
const
j
in
course_areas
)
{
const
course_area
=
course_areas
[
j
];
ret
.
push
({
...
...
app/service/course/v2/institution.js
View file @
0b686c64
...
...
@@ -18,7 +18,7 @@ class InstitutionSubService extends Service {
for
(
const
v
of
AllCats
)
{
if
(
v
.
parent_id
===
0
)
{
rootCats
[
v
.
id
]
=
v
.
dataValues
;
rootCats
[
v
.
id
].
child
=
[{
id
:
0
,
value
:
v
.
id
,
name
:
'全部'
,
parent_id
:
0
,
image
:
'http://r.51gjj.com/webpublic/images/20191118/s6yRUsc5kclyu.png'
,
active_image
:
'http://r.51gjj.com/webpublic/images/20191118/zYHkYp85vxk5m.png'
,
color
:
''
,
tips
:
''
,
status
:
'online'
,
is_deleted
:
0
}];
rootCats
[
v
.
id
].
child
=
[{
id
:
0
,
value
:
v
.
id
,
name
:
'全部'
,
parent_id
:
0
,
image
:
'http://r.51gjj.com/webpublic/images/20191118/s6yRUsc5kclyu.png'
,
active_image
:
'http://r.51gjj.com/webpublic/images/20191118/zYHkYp85vxk5m.png'
,
color
:
''
,
tips
:
''
,
status
:
'online'
,
is_deleted
:
0
}];
}
}
...
...
@@ -439,11 +439,12 @@ class InstitutionSubService extends Service {
async
getUserSearch
()
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
const
search
=
await
ctx
.
classModel
.
V2
.
CourseUserSearch
.
findAll
({
where
:
{
status
:
'online'
,
user_uuid
:
userUuid
}
});
const
search
=
await
ctx
.
classModel
.
V2
.
CourseUserSearch
.
findAll
({
where
:
{
status
:
'online'
,
user_uuid
:
userUuid
},
limit
:
10
,
order
:
[[
'id'
],
[
'desc'
]]
});
const
result
=
_
.
uniq
(
R
.
pluck
(
'content'
,
search
));
const
ret
=
{
results
:
R
.
pluck
(
'content'
,
search
)
,
count
:
search
.
length
,
results
:
result
,
count
:
result
.
length
,
};
return
ret
;
...
...
@@ -561,20 +562,20 @@ class InstitutionSubService extends Service {
const
limit
=
Number
(
input
.
limit
)
||
10
;
const
offset
=
(
page
-
1
)
*
limit
;
const
institutionId
=
Number
(
input
.
institution_id
)
||
0
;
const
teachers
=
await
ctx
.
classModel
.
V2
.
CourseTeacher
.
findAndCountAll
({
where
:
{
institution_id
:
institutionId
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
,
offset
,
limit
});
const
teachers
=
await
ctx
.
classModel
.
V2
.
CourseTeacher
.
findAndCountAll
({
where
:
{
institution_id
:
institutionId
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
,
offset
,
limit
});
const
ret
=
{
results
:
teachers
.
rows
,
count
:
teachers
.
count
,
}
}
;
return
ret
;
}
//教师详情
//
教师详情
async
getTeacher
(
id
)
{
const
{
ctx
}
=
this
;
const
teacher
=
await
ctx
.
classModel
.
V2
.
CourseTeacher
.
findOne
({
where
:
{
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
const
{
ctx
}
=
this
;
const
teacher
=
await
ctx
.
classModel
.
V2
.
CourseTeacher
.
findOne
({
where
:
{
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
if
(
ctx
.
isEmpty
(
teacher
))
{
ctx
.
failed
(
'数据不存在'
);
}
...
...
@@ -587,7 +588,7 @@ class InstitutionSubService extends Service {
}
//课程列表
//
课程列表
async
getClasses
(
input
)
{
const
{
ctx
}
=
this
;
const
page
=
Number
(
input
.
page
)
||
1
;
...
...
@@ -595,11 +596,11 @@ class InstitutionSubService extends Service {
const
offset
=
(
page
-
1
)
*
limit
;
const
institutionId
=
Number
(
input
.
institution_id
)
||
0
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'type'
,
'price'
,
'status'
,
'is_deleted'
];
const
classes
=
await
ctx
.
classModel
.
V2
.
CourseClass
.
findAndCountAll
({
where
:
{
institution_id
:
institutionId
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
,
offset
,
limit
,
attributes
});
const
classes
=
await
ctx
.
classModel
.
V2
.
CourseClass
.
findAndCountAll
({
where
:
{
institution_id
:
institutionId
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
,
offset
,
limit
,
attributes
});
const
classIds
=
R
.
pluck
(
'id'
,
classes
.
rows
);
//课程图片
const
classImages
=
await
ctx
.
classModel
.
V2
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
{
$in
:
classIds
},
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
//
课程图片
const
classImages
=
await
ctx
.
classModel
.
V2
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
{
$in
:
classIds
},
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
for
(
const
i
in
classes
.
rows
)
{
let
images
=
[];
for
(
const
v
of
classImages
)
{
...
...
@@ -607,45 +608,45 @@ class InstitutionSubService extends Service {
images
.
push
(
v
);
}
}
images
=
_
.
orderBy
(
images
,
[
'is_cover'
,
'sort'
],
[
'desc'
,
'asc'
]);
images
=
_
.
orderBy
(
images
,
[
'is_cover'
,
'sort'
],
[
'desc'
,
'asc'
]);
classes
.
rows
[
i
].
image
=
images
.
length
>
0
?
images
[
0
]
:
{};
}
const
ret
=
{
results
:
classes
.
rows
,
count
:
classes
.
count
,
}
}
;
return
ret
;
}
//课程详情
//
课程详情
async
getClass
(
id
)
{
const
{
ctx
}
=
this
;
const
classInfo
=
await
ctx
.
classModel
.
V2
.
CourseClass
.
findOne
({
where
:
{
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
const
{
ctx
}
=
this
;
const
classInfo
=
await
ctx
.
classModel
.
V2
.
CourseClass
.
findOne
({
where
:
{
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
if
(
ctx
.
isEmpty
(
classInfo
))
{
ctx
.
failed
(
'数据不存在'
);
}
//课程图片
let
images
=
await
ctx
.
classModel
.
V2
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
//去重
images
=
_
.
uniqBy
(
images
,
function
(
v
)
{
return
(
v
.
is_image
===
1
?
v
.
image_url
:
v
.
video_url
)
});
images
=
_
.
orderBy
(
images
,
[
'sort'
],
[
'asc'
]);
//
课程图片
let
images
=
await
ctx
.
classModel
.
V2
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
//
去重
images
=
_
.
uniqBy
(
images
,
function
(
v
)
{
return
(
v
.
is_image
===
1
?
v
.
image_url
:
v
.
video_url
)
;
});
images
=
_
.
orderBy
(
images
,
[
'sort'
],
[
'asc'
]);
classInfo
.
images
=
images
;
return
classInfo
;
}
//用户收藏机构列表
//
用户收藏机构列表
async
getUserCollectedInstitutions
(
input
)
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
const
userCollection
=
await
ctx
.
classModel
.
V2
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
userUuid
,
is_deleted
:
0
},
raw
:
true
});
const
userCollection
=
await
ctx
.
classModel
.
V2
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
userUuid
,
is_deleted
:
0
},
raw
:
true
});
const
institutionIds
=
R
.
pluck
(
'institution_id'
,
userCollection
);
const
institutionList
=
await
ctx
.
classModel
.
V2
.
CourseInstitution
.
findAll
({
where
:
{
id
:
{
$in
:
institutionIds
},
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
const
institutionList
=
await
ctx
.
classModel
.
V2
.
CourseInstitution
.
findAll
({
where
:
{
id
:
{
$in
:
institutionIds
},
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
const
ret
=
await
this
.
formatInstitutionList
(
institutionList
,
input
);
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