feat: add batch schedule dto and repository methods
This commit is contained in:
@@ -67,3 +67,13 @@ type AgentTeamScheduleCalendarRequest struct {
|
||||
EndAt string `json:"endAt"`
|
||||
TeamID int64 `json:"teamId"`
|
||||
}
|
||||
|
||||
type AgentTeamScheduleBatchRequest struct {
|
||||
TeamIDs []int64 `json:"teamIds"`
|
||||
StartDate string `json:"startDate"`
|
||||
EndDate string `json:"endDate"`
|
||||
Weekdays []int `json:"weekdays"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
@@ -41,3 +41,25 @@ type AgentTeamScheduleResponse struct {
|
||||
EndAt string `json:"endAt"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
type AgentTeamScheduleBatchPreviewResponse struct {
|
||||
Total int `json:"total"`
|
||||
Conflict bool `json:"conflict"`
|
||||
Items []AgentTeamScheduleBatchPreviewItem `json:"items"`
|
||||
}
|
||||
|
||||
type AgentTeamScheduleBatchPreviewItem struct {
|
||||
TeamID int64 `json:"teamId"`
|
||||
TeamName string `json:"teamName"`
|
||||
Date string `json:"date"`
|
||||
Weekday int `json:"weekday"`
|
||||
StartAt string `json:"startAt"`
|
||||
EndAt string `json:"endAt"`
|
||||
Remark string `json:"remark"`
|
||||
Conflict bool `json:"conflict"`
|
||||
ConflictReason string `json:"conflictReason"`
|
||||
}
|
||||
|
||||
type AgentTeamScheduleBatchGenerateResponse struct {
|
||||
Created int `json:"created"`
|
||||
}
|
||||
|
||||
@@ -49,6 +49,26 @@ func (r *agentTeamScheduleRepository) FindByTimeRange(db *gorm.DB, startAt, endA
|
||||
return
|
||||
}
|
||||
|
||||
func (r *agentTeamScheduleRepository) FindOverlappingByTeamIDsAndTimeRange(db *gorm.DB, teamIDs []int64, startAt, endAt time.Time) (list []models.AgentTeamSchedule) {
|
||||
if len(teamIDs) == 0 {
|
||||
return
|
||||
}
|
||||
db.Model(&models.AgentTeamSchedule{}).
|
||||
Where("team_id IN ? AND start_at < ? AND end_at > ?", teamIDs, endAt, startAt).
|
||||
Order("team_id ASC").
|
||||
Order("start_at ASC").
|
||||
Order("id ASC").
|
||||
Find(&list)
|
||||
return
|
||||
}
|
||||
|
||||
func (r *agentTeamScheduleRepository) CreateBatch(db *gorm.DB, list []models.AgentTeamSchedule) error {
|
||||
if len(list) == 0 {
|
||||
return nil
|
||||
}
|
||||
return db.Create(&list).Error
|
||||
}
|
||||
|
||||
func (r *agentTeamScheduleRepository) FindOne(db *gorm.DB, cnd *sqls.Cnd) *models.AgentTeamSchedule {
|
||||
ret := &models.AgentTeamSchedule{}
|
||||
if err := cnd.FindOne(db, &ret); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user