From c4c7d2598d2eeb10aa6f4c8c82144846160e321f Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期一, 21 八月 2023 10:16:48 +0800 Subject: [PATCH] fix --- api/v1/followRecord.go | 42 ++++++++++++++++++++++++++---------------- 1 files changed, 26 insertions(+), 16 deletions(-) diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go index e6c2f4c..0960dcf 100644 --- a/api/v1/followRecord.go +++ b/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" ) @@ -48,17 +48,17 @@ // @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, ¶ms) 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 @@ -173,27 +173,37 @@ // 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 @@ -211,7 +221,7 @@ return } - followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword) + followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.SearchMap) if errCode != ecode.OK { ctx.Fail(errCode) return @@ -221,4 +231,4 @@ List: followRecords, Count: int(total), }) -} \ No newline at end of file +} -- Gitblit v1.8.0