| | |
| | | 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 |
| | |
| | | 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, errCode := contactService.GetContactList(params.Page, params.PageSize, params.Keyword) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ContactResponse{ |
| | | List: contacts, |
| | | Count: len(contacts), |
| | | }) |
| | | } |