|
|
@@ -40,26 +40,26 @@ func (s *scheduleService) GetList(req *model.ScheduleSearchReq) (total int, sche
|
|
|
Model := s.Dao.M.InnerJoin("plat_schedule_attendee", "plat_schedule.id=plat_schedule_attendee.sch_id")
|
|
|
where := ""
|
|
|
if req.DataType == "10" {
|
|
|
- where = fmt.Sprintf("plat_schedule_attendee.user_id=%v", s.GetCxtUserId())
|
|
|
- Model = Model.Where("plat_schedule_attendee.user_id = ", s.GetCxtUserId())
|
|
|
+ where = fmt.Sprintf("plat_schedule_attendee.user_unionId='%v'", s.GetCxtUserDingtalkId())
|
|
|
+ Model = Model.Where("plat_schedule_attendee.user_unionId=?", s.GetCxtUserDingtalkId())
|
|
|
} else {
|
|
|
- where = fmt.Sprintf("plat_schedule.user_id=%v", s.GetCxtUserId())
|
|
|
- Model = Model.Where("plat_schedule.user_id = ", s.GetCxtUserId())
|
|
|
+ where = fmt.Sprintf("plat_schedule.user_unionId='%v'", s.GetCxtUserDingtalkId())
|
|
|
+ Model = Model.Where("plat_schedule.user_unionId=?", s.GetCxtUserDingtalkId())
|
|
|
}
|
|
|
if req.SchDate != nil {
|
|
|
schDate := gconv.String(req.SchDate)
|
|
|
begin := strings.Split(schDate, " ")[0] + " 00:00:00"
|
|
|
end := strings.Split(schDate, " ")[0] + " 23:59:59"
|
|
|
Model = Model.Where("plat_schedule.sch_date >= ? AND plat_schedule.sch_date <= ? ", begin, end)
|
|
|
- where += fmt.Sprintf(" AND plat_schedule.sch_date >= %v AND plat_schedule.sch_date <= %v", begin, end)
|
|
|
+ where += fmt.Sprintf(" AND plat_schedule.sch_date >= '%v' AND plat_schedule.sch_date <= '%v'", begin, end)
|
|
|
}
|
|
|
if req.BeginTime != "" && req.EndTime != "" {
|
|
|
begin := strings.Split(req.BeginTime, " ")[0] + " 00:00:00"
|
|
|
end := strings.Split(req.EndTime, " ")[0] + " 23:59:59"
|
|
|
Model = Model.Where("plat_schedule.sch_date >= ? AND plat_schedule.sch_date <= ? ", begin, end)
|
|
|
- where += fmt.Sprintf(" AND plat_schedule.sch_date >= %v AND plat_schedule.sch_date <= %v", begin, end)
|
|
|
+ where += fmt.Sprintf(" AND plat_schedule.sch_date >= '%v' AND plat_schedule.sch_date <= '%v'", begin, end)
|
|
|
}
|
|
|
- total, err = Model.Count()
|
|
|
+ total, err = Model.Group("plat_schedule.id").Count()
|
|
|
if err != nil {
|
|
|
err = myerrors.DbError("获取总行数失败")
|
|
|
return
|
|
|
@@ -129,10 +129,13 @@ func (s *scheduleService) Create(req *model.AddScheduleSeq) (insertId int64, err
|
|
|
param.Summary = schedule.SchTitle
|
|
|
param.Description = schedule.SchContent
|
|
|
param.BeginTime = fmt.Sprintf("%vT%v+08:00", req.SchDate.Format("Y-m-d"), req.SchDate.Format("H:i:s"))
|
|
|
+ param.BeginDate = req.SchDate.Format("Y-m-d")
|
|
|
param.EndTime = fmt.Sprintf("%vT%v+08:00", req.SchDateEnd.Format("Y-m-d"), req.SchDateEnd.Format("H:i:s"))
|
|
|
+ param.EndDate = req.SchDateEnd.Format("Y-m-d")
|
|
|
param.UserIds = req.UserIds
|
|
|
|
|
|
param.UserId = s.GetCxtUserDingtalkId()
|
|
|
+ param.SchType = schedule.SchType
|
|
|
|
|
|
// 记录日志
|
|
|
dingtalk_log.Create(s.Ctx, "10", gconv.String(¶m))
|
|
|
@@ -299,11 +302,19 @@ func (s *scheduleService) addScheduleByDing(rsp *calendar.GetEventResponse) erro
|
|
|
if rsp.Description != nil {
|
|
|
schedule.SchContent = *rsp.Description
|
|
|
}
|
|
|
- if rsp.Start != nil && rsp.Start.DateTime != nil {
|
|
|
- schedule.SchDate = gtime.NewFromStr(*rsp.Start.DateTime)
|
|
|
+ if rsp.Start != nil {
|
|
|
+ if rsp.Start.DateTime != nil {
|
|
|
+ schedule.SchDate = gtime.NewFromStr(*rsp.Start.DateTime)
|
|
|
+ } else if rsp.Start.Date != nil {
|
|
|
+ schedule.SchDate = gtime.NewFromStr(*rsp.Start.Date + " 00:00:00")
|
|
|
+ }
|
|
|
}
|
|
|
- if rsp.End != nil && rsp.End.DateTime != nil {
|
|
|
- schedule.SchDateEnd = gtime.NewFromStr(*rsp.End.DateTime)
|
|
|
+ if rsp.End != nil {
|
|
|
+ if rsp.End.DateTime != nil {
|
|
|
+ schedule.SchDateEnd = gtime.NewFromStr(*rsp.End.DateTime)
|
|
|
+ } else if rsp.End.Date != nil {
|
|
|
+ schedule.SchDateEnd = gtime.NewFromStr(*rsp.End.Date + " 00:00:00")
|
|
|
+ }
|
|
|
}
|
|
|
schedule.UserId = 0 // TODO 获取系统的用户Id
|
|
|
if rsp.Organizer != nil && rsp.Organizer.Id != nil {
|
|
|
@@ -315,6 +326,11 @@ func (s *scheduleService) addScheduleByDing(rsp *calendar.GetEventResponse) erro
|
|
|
if rsp.Id != nil {
|
|
|
schedule.DingScheduleId = *rsp.Id
|
|
|
}
|
|
|
+ if rsp.IsAllDay != nil && *rsp.IsAllDay {
|
|
|
+ schedule.SchType = "20"
|
|
|
+ } else {
|
|
|
+ schedule.SchType = "10"
|
|
|
+ }
|
|
|
|
|
|
insertId, err := s.Dao.InsertAndGetId(schedule)
|
|
|
if err != nil {
|
|
|
@@ -348,11 +364,19 @@ func updateScheduleByDing(rsp *calendar.GetEventResponse, schedule *model.PlatSc
|
|
|
if rsp.Description != nil {
|
|
|
schedule.SchContent = *rsp.Description
|
|
|
}
|
|
|
- if rsp.Start != nil && rsp.Start.DateTime != nil {
|
|
|
- schedule.SchDate = gtime.NewFromStr(*rsp.Start.DateTime)
|
|
|
+ if rsp.Start != nil {
|
|
|
+ if rsp.Start.DateTime != nil {
|
|
|
+ schedule.SchDate = gtime.NewFromStr(*rsp.Start.DateTime)
|
|
|
+ } else if rsp.Start.Date != nil {
|
|
|
+ schedule.SchDate = gtime.NewFromStr(*rsp.Start.Date + " 00:00:00")
|
|
|
+ }
|
|
|
}
|
|
|
- if rsp.End != nil && rsp.End.DateTime != nil {
|
|
|
- schedule.SchDateEnd = gtime.NewFromStr(*rsp.End.DateTime)
|
|
|
+ if rsp.End != nil {
|
|
|
+ if rsp.End.DateTime != nil {
|
|
|
+ schedule.SchDateEnd = gtime.NewFromStr(*rsp.End.DateTime)
|
|
|
+ } else if rsp.End.Date != nil {
|
|
|
+ schedule.SchDateEnd = gtime.NewFromStr(*rsp.End.Date + " 00:00:00")
|
|
|
+ }
|
|
|
}
|
|
|
schedule.UserId = 0 // TODO 获取系统的用户Id
|
|
|
if rsp.Organizer != nil && rsp.Organizer.Id != nil {
|
|
|
@@ -361,4 +385,9 @@ func updateScheduleByDing(rsp *calendar.GetEventResponse, schedule *model.PlatSc
|
|
|
if rsp.Organizer != nil && rsp.Organizer.DisplayName != nil {
|
|
|
schedule.UserName = *rsp.Organizer.DisplayName
|
|
|
}
|
|
|
+ if rsp.IsAllDay != nil && *rsp.IsAllDay {
|
|
|
+ schedule.SchType = "20"
|
|
|
+ } else {
|
|
|
+ schedule.SchType = "10"
|
|
|
+ }
|
|
|
}
|