From b4400a06b5f801bc7a85320680d0b6c45c547ff0 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期五, 28 七月 2023 10:21:33 +0800 Subject: [PATCH] fix --- api/v1/contact.go | 69 ++++++++++++++++++---------------- 1 files changed, 36 insertions(+), 33 deletions(-) diff --git a/api/v1/contact.go b/api/v1/contact.go index 3c0dbc5..2fd3dd4 100644 --- a/api/v1/contact.go +++ b/api/v1/contact.go @@ -66,30 +66,6 @@ ctx.Ok() } -// List -// -// @Tags Contact -// @Summary 鑱旂郴浜哄垪琛� -// @Produce application/json -// @Success 200 {object} contextx.Response{data=response.ContactResponse} -// @Router /api/contact/list [get] -func (con *ContactApi) List(c *gin.Context) { - ctx, ok := contextx.NewContext(c, nil) - if !ok { - return - } - - contacts, errCode := contactService.GetContactList() - if errCode != ecode.OK { - ctx.Fail(errCode) - return - } - - ctx.OkWithDetailed(response.ContactResponse{ - List: contacts, - }) -} - // Update // // @Tags Contact @@ -131,18 +107,18 @@ func checkContactParams(params request.Contact) (int, model.Contact) { var contact model.Contact // name not empty - if params.Name == "" { - return ecode.InvalidParams, contact - } + //if params.Name == "" { + // return ecode.InvalidParams, contact + //} contact.Name = params.Name contact.Phone = params.Phone contact.Email = params.Email // check member id not -1 - if params.MemberId == 0 { - return ecode.InvalidParams, contact - } + //if params.MemberId == 0 { + // return ecode.InvalidParams, contact + //} contact.MemberId = params.MemberId contact.ProvinceId = params.ProvinceId @@ -154,9 +130,9 @@ contact.Desc = params.Desc // check number not empty - if params.Number == "" { - return ecode.InvalidParams, contact - } + //if params.Number == "" { + // return ecode.InvalidParams, contact + //} contact.Number = params.Number t, err := checkTimeFormat(params.Birthday) @@ -168,3 +144,30 @@ contact.IsFirst = params.IsFirst return ecode.OK, contact } + +// List +// +// @Tags Contact +// @Summary 鑱旂郴浜哄垪琛� +// @Produce application/json +// @Param object body request.GetContactList true "鍙傛暟" +// @Success 200 {object} contextx.Response{data=response.ContactResponse} +// @Router /api/contact/list [post] +func (con *ContactApi) List(c *gin.Context) { + var params request.GetContactList + ctx, ok := contextx.NewContext(c, ¶ms) + if !ok { + return + } + + contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.Keyword) + if errCode != ecode.OK { + ctx.Fail(errCode) + return + } + + ctx.OkWithDetailed(response.ContactResponse{ + List: contacts, + Count: int(total), + }) +} \ No newline at end of file -- Gitblit v1.8.0