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
b681b6e8
Commit
b681b6e8
authored
Apr 21, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ageFilter
parent
2dbbdcde
Pipeline
#21956
passed with stage
in 3 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
8 deletions
+110
-8
courseV5AgeToFilter.js
app/model/class/v5/courseV5AgeToFilter.js
+48
-0
courseV5AgeToReportColumnDetail.js
app/model/class/v5/courseV5AgeToReportColumnDetail.js
+42
-0
report.js
app/service/course/v5/report.js
+20
-8
No files found.
app/model/class/v5/courseV5AgeToFilter.js
0 → 100644
View file @
b681b6e8
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5AgeToFilter
=
app
.
classModel
.
define
(
'course_v5_age_to_filter'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
age_id
:
INTEGER
,
cat_id
:
INTEGER
,
type
:
INTEGER
,
column_type
:
INTEGER
,
column
:
STRING
,
column_option
:
INTEGER
,
column_value
:
STRING
,
column_score
:
INTEGER
,
status
:
INTEGER
,
is_deleted
:
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_age_to_filter'
,
});
return
CourseV5AgeToFilter
;
};
app/model/class/v5/courseV5AgeToReportColumnDetail.js
0 → 100644
View file @
b681b6e8
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5AgeToReportColumnDetail
=
app
.
classModel
.
define
(
'course_v5_age_to_report_column_detail'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
age_id
:
INTEGER
,
report_column_detail_id
:
INTEGER
,
status
:
INTEGER
,
is_deleted
:
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_age_to_report_column_detail'
,
});
return
CourseV5AgeToReportColumnDetail
;
};
app/service/course/v5/report.js
View file @
b681b6e8
...
...
@@ -86,8 +86,13 @@ class ReportService extends Service {
}
const
category
=
await
ctx
.
classModel
.
V5
.
CourseV5Category
.
findOne
({
where
:
{
id
:
userReportInfo
.
cat_id
},
attributes
:
[
'name'
,
'url'
]
});
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
userReportInfo
.
user_uuid
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'user_uuid'
,
'baby_sex'
,
'baby_name'
,
'baby_age'
]
});
// 获取年龄对应的报告选项
const
ageToReport
=
await
ctx
.
classModel
.
V5
.
CourseV5AgeToReportColumnDetail
.
findAll
({
where
:
{
age_id
:
userBabyInfo
.
baby_age
,
status
:
1
,
is_deleted
:
0
}
});
const
ageReportColumnDetailList
=
await
ctx
.
classModel
.
V5
.
CourseV5ReportColumnDetail
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'report_column_detail_id'
,
ageToReport
)
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'report_column_id'
,
'sub_title'
,
'level'
,
'content'
,
'advice'
],
raw
:
true
});
let
reportColumnDetailList
=
ctx
.
isEmpty
(
userReportInfo
.
report_column_detail_ids
)
?
[]
:
await
ctx
.
classModel
.
V5
.
CourseV5ReportColumnDetail
.
findAll
({
where
:
{
id
:
{
$in
:
eval
(
userReportInfo
.
report_column_detail_ids
)
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'report_column_id'
,
'sub_title'
,
'level'
,
'content'
,
'advice'
],
raw
:
true
});
reportColumnDetailList
=
_
.
concat
(
reportColumnDetailList
,
ageReportColumnDetailList
);
const
reportColumnList
=
await
ctx
.
classModel
.
V5
.
CourseV5ReportColumn
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'report_column_id'
,
reportColumnDetailList
)
}
},
order
:
[[
'sort'
,
'asc'
]],
attributes
:
[
'id'
,
'title'
],
raw
:
true
});
reportColumnDetailList
=
_
.
groupBy
(
reportColumnDetailList
,
'report_column_id'
);
...
...
@@ -104,9 +109,8 @@ class ReportService extends Service {
}
const
tags
=
await
this
.
getReportTags
(
userReportInfo
);
const
recommendClassList
=
await
this
.
getRecommendClassListByReport
(
userReportInfo
.
answer
);
const
recommendClassList
=
await
this
.
getRecommendClassListByReport
(
userReportInfo
.
answer
,
userReportInfo
.
user_uuid
,
userReportInfo
.
cat_id
);
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
userReportInfo
.
user_uuid
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'user_uuid'
,
'baby_sex'
,
'baby_name'
]
});
const
ret
=
{
category
:
ctx
.
isEmpty
(
category
)
?
{}
:
category
,
...
...
@@ -128,8 +132,13 @@ class ReportService extends Service {
}
const
category
=
await
ctx
.
classModel
.
V5
.
CourseV5Category
.
findOne
({
where
:
{
id
:
userReportInfo
.
cat_id
},
attributes
:
[
'name'
,
'url'
]
});
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
userReportInfo
.
user_uuid
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'user_uuid'
,
'baby_sex'
,
'baby_name'
,
'baby_age'
]
});
// 获取年龄对应的报告选项
const
ageToReport
=
await
ctx
.
classModel
.
V5
.
CourseV5AgeToReportColumnDetail
.
findAll
({
where
:
{
age_id
:
userBabyInfo
.
baby_age
,
status
:
1
,
is_deleted
:
0
}
});
const
ageReportColumnDetailList
=
await
ctx
.
classModel
.
V5
.
CourseV5ReportColumnDetail
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'report_column_detail_id'
,
ageToReport
)
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'report_column_id'
,
'sub_title'
,
'level'
,
'content'
,
'advice'
],
raw
:
true
});
let
reportColumnDetailList
=
ctx
.
isEmpty
(
userReportInfo
.
report_column_detail_ids
)
?
[]
:
await
ctx
.
classModel
.
V5
.
CourseV5ReportColumnDetail
.
findAll
({
where
:
{
id
:
{
$in
:
eval
(
userReportInfo
.
report_column_detail_ids
)
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'report_column_id'
,
'sub_title'
,
'level'
,
'content'
,
'advice'
],
raw
:
true
});
reportColumnDetailList
=
_
.
concat
(
reportColumnDetailList
,
ageReportColumnDetailList
);
const
reportColumnList
=
await
ctx
.
classModel
.
V5
.
CourseV5ReportColumn
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'report_column_id'
,
reportColumnDetailList
)
}
},
order
:
[[
'sort'
,
'asc'
]],
attributes
:
[
'id'
,
'title'
],
raw
:
true
});
reportColumnDetailList
=
_
.
groupBy
(
reportColumnDetailList
,
'report_column_id'
);
...
...
@@ -146,9 +155,7 @@ class ReportService extends Service {
}
const
tags
=
await
this
.
getReportTags
(
userReportInfo
);
const
recommendClassList
=
await
this
.
getRecommendClassListByReport
(
userReportInfo
.
answer
);
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
userReportInfo
.
user_uuid
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'user_uuid'
,
'baby_sex'
,
'baby_name'
]
});
const
recommendClassList
=
await
this
.
getRecommendClassListByReport
(
userReportInfo
.
answer
,
userReportInfo
.
user_uuid
,
userReportInfo
.
cat_id
);
const
ret
=
{
category
:
ctx
.
isEmpty
(
category
)
?
{}
:
category
,
...
...
@@ -236,7 +243,7 @@ class ReportService extends Service {
}
// 获取推荐课程
async
getRecommendClassListByReport
(
data
)
{
async
getRecommendClassListByReport
(
data
,
userId
,
catId
)
{
const
{
ctx
}
=
this
;
// const data = eval(input.data);
data
=
eval
(
data
);
...
...
@@ -248,7 +255,12 @@ class ReportService extends Service {
}
// 获取所有回答筛选相关信息
const
answerFilterList
=
await
ctx
.
classModel
.
V5
.
CourseV5AnswerToFilter
.
findAll
({
where
:
{
answer_id
:
{
$in
:
answerIds
},
status
:
1
,
is_deleted
:
0
},
raw
:
true
});
let
answerFilterList
=
await
ctx
.
classModel
.
V5
.
CourseV5AnswerToFilter
.
findAll
({
where
:
{
answer_id
:
{
$in
:
answerIds
},
status
:
1
,
is_deleted
:
0
},
raw
:
true
});
// 获取年龄对应筛选信息
const
userBabyInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5UserBaby
.
findOne
({
where
:
{
user_uuid
:
userId
,
status
:
1
,
is_deleted
:
0
}
});
const
babyAge
=
ctx
.
isEmpty
(
userBabyInfo
)
?
0
:
userBabyInfo
.
baby_age
;
const
ageFilterList
=
await
ctx
.
classModel
.
V5
.
CourseV5AgeToFilter
.
findAll
({
where
:
{
age_id
:
babyAge
,
cat_id
:
catId
,
status
:
1
,
is_deleted
:
0
},
raw
:
true
});
answerFilterList
=
_
.
concat
(
answerFilterList
,
ageFilterList
);
// 先做筛选
const
where
=
await
this
.
classFilter
(
answerFilterList
);
...
...
@@ -557,7 +569,7 @@ class ReportService extends Service {
const
handle
=
[];
for
(
const
i
in
results
)
{
handle
.
push
(
this
.
getRecommendClassListByReport
(
results
[
i
].
answer
));
handle
.
push
(
this
.
getRecommendClassListByReport
(
results
[
i
].
answer
,
ctx
.
userUuid
,
results
[
i
].
category
.
id
));
}
const
handleResult
=
await
Promise
.
all
(
handle
).
then
(
result
=>
{
return
result
;
...
...
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