fix
wangpengfei
2023-08-18 9a7e0a7da01a9f9625ceaca0c61a59c540c6438f
api/v1/followRecord.go
@@ -6,8 +6,8 @@
   "aps_crm/model/response"
   "aps_crm/pkg/contextx"
   "aps_crm/pkg/ecode"
   "errors"
   "github.com/gin-gonic/gin"
   "strconv"
   "time"
)
@@ -43,46 +43,22 @@
   ctx.Ok()
}
// List
//
//   @Tags      FollowRecord
//   @Summary   获取跟进记录列表
//   @Produce   application/json
//   @Success   200   {object}   contextx.Response{data=response.FollowRecordResponse}
//   @Router      /api/followRecord/list [get]
func (fr *FollowRecordApi) List(c *gin.Context) {
   ctx, ok := contextx.NewContext(c, nil)
   if !ok {
      return
   }
   errCode, followRecordList := followRecordService.GetFollowRecordList()
   if errCode != ecode.OK {
      ctx.Fail(errCode)
      return
   }
   ctx.OkWithDetailed(response.FollowRecordResponse{
      List: followRecordList,
   })
}
// Delete
//
//   @Tags      FollowRecord
//   @Summary   删除跟进记录
//   @Produce   application/json
//   @Param      id   path      string   true   "跟进记录id"
//   @Param      object   body      request.DeleteFollowRecord true   "查询参数"
//   @Success   200   {object}   contextx.Response{}
//   @Router      /api/followRecord/delete/{id} [delete]
//   @Router      /api/followRecord/delete [delete]
func (fr *FollowRecordApi) Delete(c *gin.Context) {
   ctx, ok := contextx.NewContext(c, nil)
   var params request.DeleteFollowRecord
   ctx, ok := contextx.NewContext(c, &params)
   if !ok {
      return
   }
   id, _ := strconv.Atoi(c.Param("id"))
   errCode := followRecordService.DeleteFollowRecord(id)
   errCode := followRecordService.DeleteFollowRecord(params.Ids)
   if errCode != ecode.OK {
      ctx.Fail(errCode)
      return
@@ -197,25 +173,62 @@
// checkTimeFormat
// 检查时间格式
func checkTimeFormat(t string) (time.Time, error) {
func checkTimeFormat(t string) (*model.CustomTime, error) {
   if t == "" {
      t = "1900-01-01T00:00:00+08:00"
      return nil, nil
   }
   location, err := time.LoadLocation("Asia/Shanghai")
   if err != nil {
      return time.Time{}, err
      return nil, err
   }
   tt, err := time.Parse("2006-01-02T15:04:05.000Z", t)
   tt, err := time.Parse("2006-01-02", t)
   if err == nil {
      return tt.In(location), nil
      ret := tt.In(location)
      tmp := model.CustomTime(ret)
      return &tmp, nil
   }
   tt, err = time.Parse("2006-01-02T15:04:05-07:00", t)
   tt, err = time.Parse("2006-01-02 15:04:05", t)
   if err == nil {
      return tt.In(location), nil
      ret := tt.In(location)
      tmp := model.CustomTime(ret)
      return &tmp, nil
   }
   return time.Time{}, err
   //tt, err = time.Parse("2006-01-02T15:04:05-07:00", t)
   //if err == nil {
   //   ret := tt.In(location)
   //   return &ret, nil
   //}
   return nil, errors.New("invalid time format")
}
// List
//
//   @Tags      FollowRecord
//   @Summary   回访记录列表
//   @Produce   application/json
//   @Param      object   body      request.GetFollowRecordList   true   "参数"
//   @Success   200      {object}   contextx.Response{data=response.FollowRecordResponse}
//   @Router      /api/followRecord/list [post]
func (fr *FollowRecordApi) List(c *gin.Context) {
   var params request.GetFollowRecordList
   ctx, ok := contextx.NewContext(c, &params)
   if !ok {
      return
   }
   followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.SearchMap)
   if errCode != ecode.OK {
      ctx.Fail(errCode)
      return
   }
   ctx.OkWithDetailed(response.FollowRecordResponse{
      List:  followRecords,
      Count: int(total),
   })
}