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
fc05270e
Commit
fc05270e
authored
Jul 16, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs
parent
a2e913ea
Pipeline
#26455
passed with stage
in 8 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
institution.js
app/service/course/v5/institution.js
+35
-2
user.js
app/service/course/v5/user.js
+5
-2
No files found.
app/service/course/v5/institution.js
View file @
fc05270e
...
...
@@ -387,11 +387,44 @@ class InstitutionSubService extends Service {
async
getSearchRecommend
(
input
)
{
const
{
ctx
}
=
this
;
const
word
=
input
.
word
||
''
;
const
limit
=
10
;
const
offset
=
0
;
const
filter
=
{
where
:
{
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
limit
,
offset
,
attributes
:
[
'id'
,
'name'
],
raw
:
true
};
let
filterIds
=
[];
let
flag
=
false
;
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
word
}
%`
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
,
limit
,
offset
});
// 年龄筛选
if
(
!
ctx
.
isEmpty
(
input
.
age
))
{
const
filterByAge
=
await
ctx
.
classModel
.
V5
.
CourseV5ClassToAge
.
findAll
({
where
:
{
age_id
:
input
.
age
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'class_id'
]
});
filterIds
=
R
.
pluck
(
'class_id'
,
filterByAge
);
flag
=
true
;
}
// 科目类型
if
(
!
ctx
.
isEmpty
(
input
.
category
))
{
const
filterByCategory
=
await
ctx
.
classModel
.
V5
.
CourseV5ClassToCat
.
findAll
({
where
:
{
cat_id
:
input
.
category
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'class_id'
]
});
filterIds
=
flag
?
_
.
intersection
(
filterIds
,
R
.
pluck
(
'class_id'
,
filterByCategory
))
:
R
.
pluck
(
'class_id'
,
filterByCategory
);
flag
=
true
;
}
// 课程状态
if
(
!
ctx
.
isEmpty
(
input
.
mode
))
{
filter
.
where
.
mode
=
input
.
mode
;
}
// 课程类型
if
(
!
ctx
.
isEmpty
(
input
.
price_type
))
{
filter
.
where
.
price_type
=
input
.
price_type
;
}
// 搜索
if
(
!
ctx
.
isEmpty
(
input
.
word
))
{
// 先查询机构名称的
const
institutionList
=
await
ctx
.
classModel
.
V5
.
CourseV5Institution
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
input
.
word
}
%`
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
const
institutionIds
=
R
.
pluck
(
'id'
,
institutionList
);
filter
.
where
.
$or
=
[{
name
:
{
$like
:
`%
${
input
.
word
}
%`
}
},
{
institution_id
:
{
$in
:
institutionIds
}
}];
}
if
(
flag
)
{
filter
.
where
.
id
=
{
$in
:
filterIds
};
}
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
(
filter
);
const
ret
=
{
list
:
classList
};
return
ret
;
}
...
...
app/service/course/v5/user.js
View file @
fc05270e
...
...
@@ -19,13 +19,15 @@ class UserService extends Service {
ctx
.
failed
(
'手机号不正确'
);
}
const
redisCode
=
await
ctx
.
app
.
memcache
.
get
(
`course_verify_code_
${
phone
}
`
);
if
(
!
ctx
.
isEmpty
(
redisCode
))
{
// const redisCode = await ctx.app.memcache.get(`course_verify_code_${phone}`);
const
redisCheck
=
await
ctx
.
app
.
memcache
.
get
(
`course_verify_code_check_
${
phone
}
`
);
if
(
!
ctx
.
isEmpty
(
redisCheck
))
{
ctx
.
failed
(
'请勿频繁操作'
);
}
if
(
ctx
.
app
.
config
.
env
===
'local'
)
{
await
ctx
.
app
.
memcache
.
set
(
`course_verify_code_
${
phone
}
`
,
'12345'
,
300
);
await
ctx
.
app
.
memcache
.
set
(
`course_verify_code_check_
${
phone
}
`
,
'1'
,
59
);
return
{
result
:
true
};
}
...
...
@@ -49,6 +51,7 @@ class UserService extends Service {
if
(
ret
.
status
===
201
||
ret
.
status
===
200
)
{
await
ctx
.
app
.
memcache
.
set
(
`course_verify_code_
${
phone
}
`
,
code
,
300
);
await
ctx
.
app
.
memcache
.
set
(
`course_verify_code_check_
${
phone
}
`
,
'1'
,
59
);
}
else
{
ctx
.
logger
.
info
(
'course_send_verify_code_error: '
+
JSON
.
stringify
(
ret
.
data
));
ctx
.
failed
(
'发送验证码失败'
);
...
...
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