Skip to content

Commit

Permalink
Merge pull request #38 from TEAM-CLIP/feature/admin/store/active-time
Browse files Browse the repository at this point in the history
feat: 가게 운영 시간 관리 페이지 추가
  • Loading branch information
tlarbals824 authored Nov 3, 2024
2 parents 61cd662 + 9f753df commit c3c7c1a
Show file tree
Hide file tree
Showing 15 changed files with 536 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clip.admin
package com.clip.admin.controller

import com.clip.admin.dto.CreateDiscountPolicyRequest
import com.clip.admin.dto.GetDiscountPolicyInfoResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clip.admin
package com.clip.admin.controller

import com.clip.admin.dto.CreateMenuRequest
import com.clip.admin.dto.GetStoreMenuInfoResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.clip.admin.controller

import com.clip.admin.dto.CreateActiveTimeRequest
import com.clip.admin.dto.GetActiveTimeInfoResponse
import com.clip.admin.dto.UpdateActiveTimeRequest
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.*
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.LocalTime

@Controller
@RequestMapping("/store/{id}/active-time")
class StoreActiveTimeController {

@GetMapping
@ResponseBody
fun getStoreActiveTime(
@PathVariable id: String
): List<GetActiveTimeInfoResponse> {
return listOf(
GetActiveTimeInfoResponse(
"1",
DayOfWeek.MONDAY,
LocalTime.MIN,
LocalTime.MAX,
false
),
GetActiveTimeInfoResponse(
"2",
DayOfWeek.TUESDAY,
LocalTime.MIN,
LocalTime.MAX,
true
),
GetActiveTimeInfoResponse(
"3",
DayOfWeek.WEDNESDAY,
LocalTime.MIN,
LocalTime.MAX,
false
),
GetActiveTimeInfoResponse(
"4",
DayOfWeek.THURSDAY,
LocalTime.MIN,
LocalTime.MAX,
true
),
GetActiveTimeInfoResponse(
"5",
DayOfWeek.FRIDAY,
LocalTime.MIN,
LocalTime.MAX,
true
),
GetActiveTimeInfoResponse(
"6",
DayOfWeek.SATURDAY,
LocalTime.MIN,
LocalTime.MAX,
true
),
GetActiveTimeInfoResponse(
"7",
DayOfWeek.SUNDAY,
LocalTime.MIN,
LocalTime.MAX,
true
),
)
}

@GetMapping("/{activeTimeId}")
@ResponseBody
fun getStoreActiveTimeDetail(
@PathVariable activeTimeId: String,
@PathVariable id: String
): GetActiveTimeInfoResponse {
val now = LocalDate.now()
return GetActiveTimeInfoResponse(
activeTimeId,
DayOfWeek.MONDAY,
LocalTime.MIN,
LocalTime.MAX,
false
)
}

@GetMapping("/type")
@ResponseBody
fun getStoreActiveTimeType(@PathVariable id: String) = DayOfWeek.entries.map { it.name }

@PostMapping
@ResponseBody
fun createStoreActiveTime(
@PathVariable id: String,
@RequestBody request: CreateActiveTimeRequest
) {
println("create store active time: $request")
}

@PutMapping("/{activeTimeId}")
@ResponseBody
fun updateStoreActiveTime(
@PathVariable id: String,
@PathVariable activeTimeId: String,
@RequestBody request: UpdateActiveTimeRequest
) {
println("update store active time: $request")
}


@DeleteMapping("/{activeTimeId}")
@ResponseBody
fun deleteStoreActiveTime(
@PathVariable activeTimeId: String,
@PathVariable id: String
) {
println("delete store active time")
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clip.admin
package com.clip.admin.controller

import com.clip.admin.dto.CreateContactRequest
import com.clip.admin.dto.GetStoreContactInfoResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clip.admin
package com.clip.admin.controller

import com.clip.admin.dto.GetStoreCategoryResponse
import com.clip.admin.dto.GetStoreDetailInfoResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.clip.admin.dto

import java.time.DayOfWeek
import java.time.LocalDateTime
import java.time.LocalTime

data class CreateActiveTimeRequest(
val dayOfWeek: DayOfWeek,
val startAt: LocalTime,
val endAt: LocalTime,
val isActive: Boolean
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.clip.admin.dto

import java.time.DayOfWeek
import java.time.LocalDateTime
import java.time.LocalTime

data class GetActiveTimeInfoResponse(
val id: String,
val dayOfWeek: DayOfWeek,
val startAt: LocalTime,
val endAt: LocalTime,
val isActive: Boolean
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.clip.admin.dto

import java.time.DayOfWeek
import java.time.LocalDateTime
import java.time.LocalTime

data class UpdateActiveTimeRequest(
val dayOfWeek: DayOfWeek,
val startAt: LocalTime,
val endAt: LocalTime,
val isActive: Boolean
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ const StoreUpdate = {
StoreContact.init(storeData.id);
// 가게 할인 조회
StoreDiscount.init(storeData.id);
// 가게 영업시간 조회
StoreActiveTime.init(storeData.id);


this.updateImagePreview(storeData.imgUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const StoreActiveTimeApi = {
endpoints: {
list: (storeId) => `/store/${storeId}/active-time`,
create: (storeId) => `/store/${storeId}/active-time`,
detail: (storeId, activeTimeId) => `/store/${storeId}/active-time/${activeTimeId}`,
update: (storeId, activeTimeId) => `/store/${storeId}/active-time/${activeTimeId}`,
delete: (storeId, activeTimeId) => `/store/${storeId}/active-time/${activeTimeId}`,
type: (storeId) => `/store/${storeId}/active-time/type`
},

async getActiveTimes(storeId) {
const response = await fetch(this.endpoints.list(storeId));
if (!response.ok) throw new Error('영업시간 목록을 불러오는데 실패했습니다.');
return await response.json();
},

async getActiveTime(storeId, activeTimeId) {
const response = await fetch(this.endpoints.detail(storeId, activeTimeId));
if (!response.ok) throw new Error('영업시간 정보를 불러오는데 실패했습니다.');
return await response.json();
},

async createActiveTime(storeId, activeTimeData) {
const response = await fetch(this.endpoints.create(storeId), {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(activeTimeData)
});
if (!response.ok) throw new Error('영업시간 추가에 실패했습니다.');
},

async updateActiveTime(storeId, activeTimeId, activeTimeData) {
const response = await fetch(this.endpoints.update(storeId, activeTimeId), {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(activeTimeData)
});
if (!response.ok) throw new Error('영업시간 수정에 실패했습니다.');
},

async deleteActiveTime(storeId, activeTimeId) {
const response = await fetch(this.endpoints.delete(storeId, activeTimeId), {
method: 'DELETE'
});
if (!response.ok) throw new Error('영업시간 삭제에 실패했습니다.');
return true;
},

async getActiveTimeTypes(storeId) {
const response = await fetch(this.endpoints.type(storeId));
if (!response.ok) throw new Error('영업시간 유형을 불러오는데 실패했습니다.');
return await response.json();
}

}
Loading

0 comments on commit c3c7c1a

Please sign in to comment.