package v1 import ( "aps_crm/model" "aps_crm/model/request" "aps_crm/model/response" "aps_crm/pkg/contextx" "aps_crm/pkg/ecode" "github.com/gin-gonic/gin" "strconv" ) type AccountIdApi struct{} // Add // // @Tags AccountId // @Summary 添加账户 // @Produce application/json // @Param object body request.AddAccountId true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/accountId/add [post] func (s *AccountIdApi) Add(c *gin.Context) { var params request.AddAccountId ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } accountId := new(model.AccountId) accountId.Name = params.Name errCode := accountIdService.AddAccountId(accountId) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // Delete // // @Tags AccountId // @Summary 删除账户 // @Produce application/json // @Param id path int true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/accountId/delete/{id} [delete] func (s *AccountIdApi) Delete(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } id, _ := strconv.Atoi(c.Param("id")) errCode := accountIdService.DeleteAccountId(id) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // Update // // @Tags AccountId // @Summary 更新账户 // @Produce application/json // @Param object body request.UpdateAccountIds true "查询参数" // @Success 200 {object} contextx.Response{} // @Router /api/accountId/update [put] func (s *AccountIdApi) Update(c *gin.Context) { var params request.UpdateAccountIds ctx, ok := contextx.NewContext(c, ¶ms) if !ok { return } errCode := accountIdService.UpdateAccountId(params.AccountIds) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.Ok() } // List // // @Tags AccountId // @Summary 获取账户列表 // @Produce application/json // @Success 200 {object} contextx.Response{data=response.AccountIdResponse} // @Router /api/accountId/list [get] func (s *AccountIdApi) List(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) if !ok { return } accountIds, errCode := accountIdService.GetAccountIdList() if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.OkWithDetailed(response.AccountIdResponse{ List: accountIds, }) }