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
582a80d2
Commit
582a80d2
authored
Feb 21, 2020
by
Aria
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
onlineClass add age, type filter
parent
fbe61bee
Pipeline
#19503
passed with stage
in 57 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
480 additions
and
28 deletions
+480
-28
courseOnlineAge.js
app/model/class/v4/courseOnlineAge.js
+101
-0
courseOnlineClassToAge.js
app/model/class/v4/courseOnlineClassToAge.js
+101
-0
courseOnlineClassToCat.js
app/model/class/v4/courseOnlineClassToCat.js
+21
-21
courseOnlineClassToType.js
app/model/class/v4/courseOnlineClassToType.js
+101
-0
courseOnlineType.js
app/model/class/v4/courseOnlineType.js
+101
-0
online.js
app/service/course/v4/online.js
+55
-7
No files found.
app/model/class/v4/courseOnlineAge.js
0 → 100644
View file @
582a80d2
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
ENUM
}
=
app
.
Sequelize
;
const
CourseOnlineAge
=
app
.
classModel
.
define
(
'course_online_age'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
name
:
STRING
,
status
:
ENUM
(
'offline'
,
'online'
),
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_online_age'
,
});
CourseOnlineAge
.
one
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseOnlineAge
.
findOne
({
attributes
,
where
,
});
};
CourseOnlineAge
.
all
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseOnlineAge
.
findAll
({
attributes
,
where
,
order
,
});
};
CourseOnlineAge
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
,
order
,
attributes
,
};
const
{
count
,
rows
}
=
await
CourseOnlineAge
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
};
CourseOnlineAge
.
add
=
async
data
=>
{
try
{
// 返回promise对象实力 instance
const
res
=
await
CourseOnlineAge
.
create
(
data
);
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
};
CourseOnlineAge
.
edit
=
async
data
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseOnlineAge
.
update
(
params
,
{
where
});
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
};
return
CourseOnlineAge
;
};
app/model/class/v4/courseOnlineClassToAge.js
0 → 100644
View file @
582a80d2
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseOnlineClassToAge
=
app
.
classModel
.
define
(
'course_online_class_to_age'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
class_id
:
INTEGER
,
age_id
:
INTEGER
,
status
:
ENUM
(
'offline'
,
'online'
),
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_online_class_to_age'
,
});
CourseOnlineClassToAge
.
one
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseOnlineClassToAge
.
findOne
({
attributes
,
where
,
});
};
CourseOnlineClassToAge
.
all
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseOnlineClassToAge
.
findAll
({
attributes
,
where
,
order
,
});
};
CourseOnlineClassToAge
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
,
order
,
attributes
,
};
const
{
count
,
rows
}
=
await
CourseOnlineClassToAge
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
};
CourseOnlineClassToAge
.
add
=
async
data
=>
{
try
{
// 返回promise对象实力 instance
const
res
=
await
CourseOnlineClassToAge
.
create
(
data
);
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
};
CourseOnlineClassToAge
.
edit
=
async
data
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseOnlineClassToAge
.
update
(
params
,
{
where
});
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
};
return
CourseOnlineClassToAge
;
};
app/model/class/v4/courseOnlineClassToCat.js
View file @
582a80d2
'use strict'
;
'use strict'
;
'use strict'
;
const
moment
=
require
(
'moment'
);
const
moment
=
require
(
'moment'
);
...
@@ -10,7 +10,7 @@ module.exports = app => {
...
@@ -10,7 +10,7 @@ module.exports = app => {
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
autoIncrement
:
true
autoIncrement
:
true
,
},
},
class_id
:
INTEGER
,
class_id
:
INTEGER
,
cat_id
:
INTEGER
,
cat_id
:
INTEGER
,
...
@@ -37,25 +37,25 @@ module.exports = app => {
...
@@ -37,25 +37,25 @@ module.exports = app => {
tableName
:
'course_online_class_to_cat'
,
tableName
:
'course_online_class_to_cat'
,
});
});
CourseOnlineClassToCat
.
one
=
async
(
data
)
=>
{
CourseOnlineClassToCat
.
one
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseOnlineClassToCat
.
findOne
({
return
await
CourseOnlineClassToCat
.
findOne
({
attributes
:
attributes
,
attributes
,
where
:
where
,
where
,
});
});
}
};
CourseOnlineClassToCat
.
all
=
async
(
data
)
=>
{
CourseOnlineClassToCat
.
all
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseOnlineClassToCat
.
findAll
({
return
await
CourseOnlineClassToCat
.
findAll
({
attributes
:
attributes
,
attributes
,
where
:
where
,
where
,
order
,
order
,
});
});
}
};
CourseOnlineClassToCat
.
list
=
async
(
data
=
{})
=>
{
CourseOnlineClassToCat
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
...
@@ -66,35 +66,35 @@ module.exports = app => {
...
@@ -66,35 +66,35 @@ module.exports = app => {
const
condition
=
{
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
offset
:
(
page
-
1
)
*
limit
,
limit
,
limit
,
where
:
where
,
where
,
order
:
order
,
order
,
attributes
:
attributes
,
attributes
,
};
};
const
{
count
,
rows
}
=
await
CourseOnlineClassToCat
.
findAndCountAll
(
condition
);
const
{
count
,
rows
}
=
await
CourseOnlineClassToCat
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
return
{
page
,
count
,
rows
};
}
};
CourseOnlineClassToCat
.
add
=
async
(
data
)
=>
{
CourseOnlineClassToCat
.
add
=
async
data
=>
{
try
{
try
{
//返回promise对象实力 instance
// 返回promise对象实力 instance
const
res
=
await
CourseOnlineClassToCat
.
create
(
data
);
const
res
=
await
CourseOnlineClassToCat
.
create
(
data
);
//
从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
//
从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
return
res
.
id
;
}
catch
(
error
)
{
}
catch
(
error
)
{
throw
(
error
);
throw
(
error
);
}
}
}
};
CourseOnlineClassToCat
.
edit
=
async
(
data
)
=>
{
CourseOnlineClassToCat
.
edit
=
async
data
=>
{
const
where
=
data
.
where
;
const
where
=
data
.
where
;
const
params
=
data
.
params
;
const
params
=
data
.
params
;
try
{
try
{
const
res
=
await
CourseOnlineClassToCat
.
update
(
params
,
{
where
:
where
})
const
res
=
await
CourseOnlineClassToCat
.
update
(
params
,
{
where
});
return
res
;
return
res
;
}
catch
(
error
)
{
}
catch
(
error
)
{
throw
(
error
);
throw
(
error
);
}
}
}
};
return
CourseOnlineClassToCat
;
return
CourseOnlineClassToCat
;
...
...
app/model/class/v4/courseOnlineClassToType.js
0 → 100644
View file @
582a80d2
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseOnlineClassToType
=
app
.
classModel
.
define
(
'course_online_class_to_type'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
class_id
:
INTEGER
,
type_id
:
INTEGER
,
status
:
ENUM
(
'offline'
,
'online'
),
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_online_class_to_type'
,
});
CourseOnlineClassToType
.
one
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseOnlineClassToType
.
findOne
({
attributes
,
where
,
});
};
CourseOnlineClassToType
.
all
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseOnlineClassToType
.
findAll
({
attributes
,
where
,
order
,
});
};
CourseOnlineClassToType
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
,
order
,
attributes
,
};
const
{
count
,
rows
}
=
await
CourseOnlineClassToType
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
};
CourseOnlineClassToType
.
add
=
async
data
=>
{
try
{
// 返回promise对象实力 instance
const
res
=
await
CourseOnlineClassToType
.
create
(
data
);
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
};
CourseOnlineClassToType
.
edit
=
async
data
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseOnlineClassToType
.
update
(
params
,
{
where
});
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
};
return
CourseOnlineClassToType
;
};
app/model/class/v4/courseOnlineType.js
0 → 100644
View file @
582a80d2
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
ENUM
}
=
app
.
Sequelize
;
const
CourseOnlineType
=
app
.
classModel
.
define
(
'course_online_type'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
name
:
STRING
,
status
:
ENUM
(
'offline'
,
'online'
),
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_online_type'
,
});
CourseOnlineType
.
one
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseOnlineType
.
findOne
({
attributes
,
where
,
});
};
CourseOnlineType
.
all
=
async
data
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseOnlineType
.
findAll
({
attributes
,
where
,
order
,
});
};
CourseOnlineType
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
,
order
,
attributes
,
};
const
{
count
,
rows
}
=
await
CourseOnlineType
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
};
CourseOnlineType
.
add
=
async
data
=>
{
try
{
// 返回promise对象实力 instance
const
res
=
await
CourseOnlineType
.
create
(
data
);
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
};
CourseOnlineType
.
edit
=
async
data
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseOnlineType
.
update
(
params
,
{
where
});
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
};
return
CourseOnlineType
;
};
app/service/course/v4/online.js
View file @
582a80d2
...
@@ -14,11 +14,13 @@ class OnlineService extends Service {
...
@@ -14,11 +14,13 @@ class OnlineService extends Service {
let
cats
=
await
ctx
.
classModel
.
V4
.
CourseOnlineCat
.
findAll
({
where
:
{
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
let
cats
=
await
ctx
.
classModel
.
V4
.
CourseOnlineCat
.
findAll
({
where
:
{
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
cats
=
[{
id
:
0
,
name
:
'全部'
}].
concat
(
cats
);
cats
=
[{
id
:
0
,
name
:
'全部'
}].
concat
(
cats
);
// 年龄段
// 年龄段
const
ages
=
[
'全部'
,
'学龄前'
,
'幼儿园'
,
'小学'
,
'初中'
,
'高中'
];
let
ages
=
await
ctx
.
classModel
.
V4
.
CourseOnlineAge
.
findAll
({
where
:
{
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
ages
=
[{
id
:
0
,
name
:
'全部'
}].
concat
(
cats
);
// 课程状态
// 课程状态
const
mode
=
[{
id
:
0
,
name
:
'全部'
},
{
id
:
1
,
name
:
'直播'
},
{
id
:
2
,
name
:
'录播'
}];
const
mode
=
[{
id
:
0
,
name
:
'全部'
},
{
id
:
1
,
name
:
'直播'
},
{
id
:
2
,
name
:
'录播'
}];
// 课程班型
// 课程班型
const
type
=
[
'全部'
,
'1对1'
,
'1对多'
,
'讲座'
];
let
type
=
await
ctx
.
classModel
.
V4
.
CourseOnlineType
.
findAll
({
where
:
{
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
type
=
[{
id
:
0
,
name
:
'全部'
}].
concat
(
cats
);
const
options
=
{
const
options
=
{
cats
,
cats
,
...
@@ -57,6 +59,16 @@ class OnlineService extends Service {
...
@@ -57,6 +59,16 @@ class OnlineService extends Service {
const
catIds
=
R
.
pluck
(
'cat_id'
,
classCats
);
const
catIds
=
R
.
pluck
(
'cat_id'
,
classCats
);
const
cats
=
await
ctx
.
classModel
.
V4
.
CourseOnlineCat
.
findAll
({
where
:
{
id
:
{
$in
:
catIds
}
},
attributes
:
[
'id'
,
'name'
]
});
const
cats
=
await
ctx
.
classModel
.
V4
.
CourseOnlineCat
.
findAll
({
where
:
{
id
:
{
$in
:
catIds
}
},
attributes
:
[
'id'
,
'name'
]
});
// 年龄段
const
classAges
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToAge
.
findAll
({
where
:
{
class_id
:
id
,
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'age_id'
]
});
const
ageIds
=
R
.
pluck
(
'age_id'
,
classAges
);
const
ages
=
await
ctx
.
classModel
.
V4
.
CourseOnlineAge
.
findAll
({
where
:
{
id
:
{
$in
:
ageIds
}
},
attributes
:
[
'id'
,
'name'
]
});
// 班型
const
classTypes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToType
.
findAll
({
where
:
{
class_id
:
id
,
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'type_id'
]
});
const
typeIds
=
R
.
pluck
(
'type_id'
,
classTypes
);
const
type
=
await
ctx
.
classModel
.
V4
.
CourseOnlineType
.
findAll
({
where
:
{
id
:
{
$in
:
typeIds
}
},
attributes
:
[
'id'
,
'name'
]
});
// 收藏信息
// 收藏信息
const
uuid
=
ctx
.
headers
.
uuid
||
''
;
const
uuid
=
ctx
.
headers
.
uuid
||
''
;
const
userCollect
=
await
ctx
.
classModel
.
V4
.
CourseUserCollection
.
findOne
({
where
:
{
user_uuid
:
uuid
,
type
:
3
,
type_id
:
id
,
is_deleted
:
0
}
});
const
userCollect
=
await
ctx
.
classModel
.
V4
.
CourseUserCollection
.
findOne
({
where
:
{
user_uuid
:
uuid
,
type
:
3
,
type_id
:
id
,
is_deleted
:
0
}
});
...
@@ -73,7 +85,8 @@ class OnlineService extends Service {
...
@@ -73,7 +85,8 @@ class OnlineService extends Service {
phone
:
ctx
.
isEmpty
(
area
)
?
''
:
area
.
phone
,
phone
:
ctx
.
isEmpty
(
area
)
?
''
:
area
.
phone
,
travel_tips
:
ctx
.
isEmpty
(
area
)
?
''
:
area
.
travel_tips
,
travel_tips
:
ctx
.
isEmpty
(
area
)
?
''
:
area
.
travel_tips
,
price
:
classInfo
.
price
,
price
:
classInfo
.
price
,
type
:
classInfo
.
type
,
type
,
ages
,
mode
:
await
this
.
getClassModelInfo
(
classInfo
.
mode
),
mode
:
await
this
.
getClassModelInfo
(
classInfo
.
mode
),
time
:
classInfo
.
time
,
time
:
classInfo
.
time
,
channel
:
classInfo
.
channel
,
channel
:
classInfo
.
channel
,
...
@@ -95,13 +108,26 @@ class OnlineService extends Service {
...
@@ -95,13 +108,26 @@ class OnlineService extends Service {
const
{
type
,
mode
,
age
,
cat
}
=
input
;
const
{
type
,
mode
,
age
,
cat
}
=
input
;
const
filter
=
{
where
:
{
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'institution_id'
,
'desc'
]],
limit
,
offset
,
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'price'
,
'type'
,
'age'
,
'mode'
,
'time'
,
'created_time'
]
};
const
filter
=
{
where
:
{
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'institution_id'
,
'desc'
]],
limit
,
offset
,
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'price'
,
'type'
,
'age'
,
'mode'
,
'time'
,
'created_time'
]
};
// 年龄段筛选
// 年龄段筛选
let
ids
=
[];
let
flag
=
false
;
if
(
!
ctx
.
isEmpty
(
age
))
{
if
(
!
ctx
.
isEmpty
(
age
))
{
filter
.
where
.
age
=
age
;
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToAge
.
findAll
({
where
:
{
age_id
:
age
,
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
]
});
if
(
flag
)
{
ids
=
_
.
intersection
(
ids
,
R
.
pluck
(
'class_id'
,
classes
));
}
else
{
flag
=
true
;
ids
=
R
.
pluck
(
'class_id'
,
classes
);
}
}
}
// 课程类型筛选
// 课程类型筛选
if
(
!
ctx
.
isEmpty
(
cat
)
&&
Number
(
cat
)
>
0
)
{
if
(
!
ctx
.
isEmpty
(
cat
)
&&
Number
(
cat
)
>
0
)
{
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToCat
.
findAll
({
where
:
{
cat_id
:
cat
,
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
]
});
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToCat
.
findAll
({
where
:
{
cat_id
:
cat
,
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
]
});
filter
.
where
.
id
=
{
$in
:
R
.
pluck
(
'class_id'
,
classes
)
};
if
(
flag
)
{
ids
=
_
.
intersection
(
ids
,
R
.
pluck
(
'class_id'
,
classes
));
}
else
{
flag
=
true
;
ids
=
R
.
pluck
(
'class_id'
,
classes
);
}
}
}
// 课程状态筛选
// 课程状态筛选
if
(
!
ctx
.
isEmpty
(
mode
))
{
if
(
!
ctx
.
isEmpty
(
mode
))
{
...
@@ -109,7 +135,13 @@ class OnlineService extends Service {
...
@@ -109,7 +135,13 @@ class OnlineService extends Service {
}
}
// 课程班型筛选
// 课程班型筛选
if
(
!
ctx
.
isEmpty
(
type
))
{
if
(
!
ctx
.
isEmpty
(
type
))
{
filter
.
where
.
type
=
type
;
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToType
.
findAll
({
where
:
{
type_id
:
type
,
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
]
});
if
(
flag
)
{
ids
=
_
.
intersection
(
ids
,
R
.
pluck
(
'class_id'
,
classes
));
}
else
{
flag
=
true
;
ids
=
R
.
pluck
(
'class_id'
,
classes
);
}
}
}
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClass
.
findAndCountAll
(
filter
);
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClass
.
findAndCountAll
(
filter
);
...
@@ -131,6 +163,22 @@ class OnlineService extends Service {
...
@@ -131,6 +163,22 @@ class OnlineService extends Service {
}
}
classCats
=
_
.
groupBy
(
classCats
,
'class_id'
);
classCats
=
_
.
groupBy
(
classCats
,
'class_id'
);
// 班型
const
classToTypes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassTotype
.
findAll
({
where
:
{
class_id
:
{
$in
:
classIds
},
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
,
'type_id'
]
});
const
typeIds
=
R
.
pluck
(
'type_id'
,
classToTypes
);
let
types
=
await
ctx
.
classModel
.
V4
.
CourseOnlineType
.
findAll
({
where
:
{
id
:
{
$in
:
typeIds
}
}
});
types
=
_
.
groupBy
(
types
,
'id'
);
let
classTypes
=
[];
for
(
const
v
of
classToTypes
)
{
const
tmp
=
{
id
:
v
.
type_id
,
class_id
:
v
.
class_id
,
name
:
ctx
.
isEmpty
(
types
[
v
.
type_id
])
?
''
:
types
[
v
.
type_id
][
0
].
name
,
};
classTypes
.
push
(
tmp
);
}
classTypes
=
_
.
groupBy
(
classTypes
,
'class_id'
);
// 机构
// 机构
const
institutionIds
=
R
.
pluck
(
'institution_id'
,
classes
.
rows
);
const
institutionIds
=
R
.
pluck
(
'institution_id'
,
classes
.
rows
);
let
institutions
=
await
ctx
.
classModel
.
V4
.
CourseOnlineInstitution
.
findAll
({
where
:
{
id
:
{
$in
:
institutionIds
}
},
attributes
:
[
'id'
,
'name'
,
'logo'
]
});
let
institutions
=
await
ctx
.
classModel
.
V4
.
CourseOnlineInstitution
.
findAll
({
where
:
{
id
:
{
$in
:
institutionIds
}
},
attributes
:
[
'id'
,
'name'
,
'logo'
]
});
...
@@ -144,7 +192,7 @@ class OnlineService extends Service {
...
@@ -144,7 +192,7 @@ class OnlineService extends Service {
institution_id
:
v
.
institution_id
,
institution_id
:
v
.
institution_id
,
institution_name
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
name
,
institution_name
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
name
,
logo
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
logo
,
logo
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
logo
,
type
:
v
.
type
,
type
:
ctx
.
isEmpty
(
classTypes
[
v
.
id
])
?
[]
:
classTypes
[
v
.
id
]
,
mode
:
await
this
.
getClassModelInfo
(
v
.
mode
),
mode
:
await
this
.
getClassModelInfo
(
v
.
mode
),
price
:
v
.
price
,
price
:
v
.
price
,
time
:
v
.
time
,
time
:
v
.
time
,
...
...
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