-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from TEAM-CLIP/feature/admin/store/active-time
feat: 가게 운영 시간 관리 페이지 추가
- Loading branch information
Showing
15 changed files
with
536 additions
and
4 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...tlin/com/clip/admin/DiscountController.kt → ...ip/admin/controller/DiscountController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/kotlin/com/clip/admin/MenuController.kt → ...m/clip/admin/controller/MenuController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...strap-Module/Admin/src/main/kotlin/com/clip/admin/controller/StoreActiveTimeController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../com/clip/admin/StoreContactController.kt → ...dmin/controller/StoreContactController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../kotlin/com/clip/admin/StoreController.kt → .../clip/admin/controller/StoreController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Bootstrap-Module/Admin/src/main/kotlin/com/clip/admin/dto/CreateActiveTimeRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
Bootstrap-Module/Admin/src/main/kotlin/com/clip/admin/dto/GetActiveTimeInfoResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) { | ||
} |
13 changes: 13 additions & 0 deletions
13
Bootstrap-Module/Admin/src/main/kotlin/com/clip/admin/dto/UpdateActiveTimeRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Bootstrap-Module/Admin/src/main/resources/static/js/store/activetime/StoreActiveTimeApi.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
Oops, something went wrong.