完善团课前后端交互
This commit is contained in:
@@ -45,6 +45,40 @@ export function getTypeLabels(typeId, options = { cache: true, cacheTime: 5 * 60
|
||||
return request.get(`/groupCourse/types/${typeId}/labels`, {}, options)
|
||||
}
|
||||
|
||||
export function searchGroupCourse(params = {}, options = {}) {
|
||||
const {
|
||||
courseName,
|
||||
courseType,
|
||||
startDate,
|
||||
endDate,
|
||||
timePeriod,
|
||||
priceSort,
|
||||
remainingMost,
|
||||
page = 0,
|
||||
size = 10
|
||||
} = params
|
||||
|
||||
const requestBody = { page, size }
|
||||
|
||||
if (courseName) requestBody.courseName = courseName
|
||||
if (courseType) requestBody.courseType = courseType
|
||||
if (startDate) requestBody.startDate = formatDateTime(startDate)
|
||||
if (endDate) requestBody.endDate = formatDateTime(endDate, true)
|
||||
if (timePeriod) requestBody.timePeriod = timePeriod
|
||||
if (priceSort) requestBody.priceSort = priceSort
|
||||
if (remainingMost !== undefined) requestBody.remainingMost = remainingMost
|
||||
|
||||
return request.post('/groupCourse/search', requestBody, options)
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr, isEnd = false) {
|
||||
if (!dateStr) return dateStr
|
||||
if (dateStr.includes('T')) return dateStr
|
||||
return isEnd
|
||||
? `${dateStr}T23:59:59`
|
||||
: `${dateStr}T00:00:00`
|
||||
}
|
||||
|
||||
export function bookGroupCourse(params) {
|
||||
return request.post('/groupCourse/book', params)
|
||||
}
|
||||
@@ -60,6 +94,7 @@ export function getMemberBookings(memberId, options = {}) {
|
||||
export default {
|
||||
getGroupCourseList,
|
||||
getGroupCoursePage,
|
||||
searchGroupCourse,
|
||||
getGroupCourseById,
|
||||
getGroupCourseDetail,
|
||||
createGroupCourse,
|
||||
|
||||
Reference in New Issue
Block a user