package v1 import ( "git.getensh.com/common/gopkgs/logger" "git.getensh.com/common/gopkgs/tasker/httptasker" "git.getensh.com/common/gopkgs/util" "github.com/gin-gonic/gin" "go.uber.org/zap" "net/http" "property-household-gateway/errors" param_v1 "property-household-gateway/param/v1" "property-household-gateway/pb" "property-household-gateway/pb/v1" ) // // @Summary 分类列表 // @Description 分类列表 // @Tags 服务电话 // @Accept json // @Produce json // @Param token header string true "token" // @Param page query int false " " // @Param page_size query int false " " // @Param garden_id query int true "小区id" // @Success 200 {object} v1.ServicePhoneClassListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/service_phone/class [get] func (c *Controller) ServicePhoneClassList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ServicePhoneClassListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ServicePhoneClassListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetJwtTokenInfo(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ServicePhoneClassListResponse{} rpcReq := &v1.ServicePhoneClassListRequest{ GardenId:req.GardenId, PageSize:req.PageSize, Page:req.Page, Enable:1, } rpcRsp, err := pb.Garden.ServicePhoneClassList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ServicePhoneClassList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ServicePhoneClassItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 电话列表 // @Description 电话列表 // @Tags 服务电话 // @Accept json // @Produce json // @Param token header string true "token" // @Param page query int false " " // @Param page_size query int false " " // @Param class_id query int false "分类id" // @Param garden_id query int true "小区id" // @Success 200 {object} v1.ServicePhoneListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/service_phone [get] func (c *Controller) ServicePhoneList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ServicePhoneListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ServicePhoneListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetJwtTokenInfo(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ServicePhoneListResponse{} rpcReq := &v1.ServicePhoneListRequest{ GardenId:req.GardenId, PageSize:req.PageSize, Page:req.Page, ClassId:req.ClassId, Enable:1, } rpcRsp, err := pb.Garden.ServicePhoneList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ServicePhoneList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ServicePhoneItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) }