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" "property-household-gateway/utils" ) // // @Summary 新增工单 // @Description 新增工单 // @Tags 投诉与建议 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.SuggestionOrderAddBody true "信息" // @Success 200 {object} v1.SuggestionOrderAddResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order [post] func (c *Controller) SuggestionOrderAdd(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderAddRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.SuggestionOrderAddBody) 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.SuggestionOrderAddResponse{} rpcReq := &v1.SuggestionOrderAddRequest{ GardenId: req.GardenId, SuggestionType: req.SuggestionType, // 报修人 ApplyPeople: req.ApplyPeople, // 报修人电话 ApplyPeoplePhone: req.ApplyPeoplePhone, // 上级处理人 //LastUid:tokenInfo.Uid, // 报修内容 ApplyContent: req.ApplyContent, // 报修图片 ApplyPic: req.ApplyPic, HouseholdUid: tokenInfo.Uid, } rpcRsp, err := pb.Garden.SuggestionOrderAdd(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderAdd"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } 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 body body v1.SuggestionOrderUpdateBody true "信息" // @Success 200 {object} v1.SuggestionOrderUpdateResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order [put] func (c *Controller) SuggestionOrderUpdate(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderUpdateRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.SuggestionOrderUpdateBody) 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.SuggestionOrderUpdateResponse{} rpcReq := &v1.SuggestionOrderUpdateRequest{ GardenId: req.GardenId, Id: req.Id, SuggestionType: req.SuggestionType, // 报修人 ApplyPeople: req.ApplyPeople, // 报修人电话 ApplyPeoplePhone: req.ApplyPeoplePhone, // 报修内容 ApplyContent: req.ApplyContent, // 报修图片 ApplyPic: req.ApplyPic, HouseholdUid: tokenInfo.Uid, } _, err = pb.Garden.SuggestionOrderUpdate(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderUpdate"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } 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 status query int false " 1未派单 2 已派单 3 已完结 " // @Param apply_people query string false "报修人" // @Param apply_people_phone query string false "报修人电话" // @Param garden_id query int true " " // @Param suggestion_type query int false "投诉类型 1 投诉 2 建议" // @Success 200 {object} v1.SuggestionOrderListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order [get] func (c *Controller) SuggestionOrderList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.SuggestionOrderListQuery, 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.SuggestionOrderListResponse{} rpcReq := &v1.SuggestionOrderListRequest{ GardenId: req.GardenId, PageSize: req.PageSize, Page: req.Page, SuggestionType: req.SuggestionType, ApplyPeoplePhone: req.ApplyPeoplePhone, ApplyPeople: req.ApplyPeople, Status: req.Status, HouseholdUid: tokenInfo.Uid, } rpcRsp, err := pb.Garden.SuggestionOrderList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.SuggestionOrderItem, 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 id query int true " " // @Param garden_id query int true " " // @Success 200 {object} v1.SuggestionOrderInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order/info [get] func (c *Controller) SuggestionOrderInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.SuggestionOrderInfoQuery, 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.SuggestionOrderInfoResponse{} rpcReq := &v1.SuggestionOrderInfoRequest{ GardenId: req.GardenId, Id: req.Id, } rpcRsp, err := pb.Garden.SuggestionOrderInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderInfo"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.SuggestionOrderPipelineData, 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 body body v1.SuggestionOrderReturnVisitBody true "信息" // @Success 200 {object} v1.SuggestionOrderReturnVisitResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order/return_visit [put] func (c *Controller) SuggestionOrderReturnVisit(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderReturnVisitRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.SuggestionOrderReturnVisitBody) 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.SuggestionOrderReturnVisitResponse{} rpcReq := &v1.SuggestionOrderReturnVisitRequest{ GardenId: req.GardenId, Id: req.Id, ReturnVisitLevel: req.ReturnVisitLevel, ReturnVisitContent: req.ReturnVisitContent, HouseholdUid: tokenInfo.Uid, } _, err = pb.Garden.SuggestionOrderReturnVisit(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderReturnVisit"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) }