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-applete-gateway/errors" param_v1 "property-applete-gateway/param/v1" "property-applete-gateway/pb" "property-applete-gateway/pb/v1" "property-applete-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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderAddResponse{} rpcReq := &v1.SuggestionOrderAddRequest{ GardenId:tokenInfo.GardenId, SuggestionType:req.SuggestionType, // 报修人 ApplyPeople:req.ApplyPeople, // 报修人电话 ApplyPeoplePhone:req.ApplyPeoplePhone, // 上级处理人 LastUid:tokenInfo.Uid, // 报修内容 ApplyContent:req.ApplyContent, // 报修图片 ApplyPic:req.ApplyPic, ByCompany:tokenInfo.ByCompany, HouseholdUid:0, } 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) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderAdd, Origin:nil, Target:req.SuggestionOrderAddBody, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderUpdateResponse{} rpcReq := &v1.SuggestionOrderUpdateRequest{ GardenId:tokenInfo.GardenId, Id:req.Id, SuggestionType:req.SuggestionType, // 报修人 ApplyPeople:req.ApplyPeople, // 报修人电话 ApplyPeoplePhone:req.ApplyPeoplePhone, // 报修内容 ApplyContent:req.ApplyContent, // 报修图片 ApplyPic:req.ApplyPic, HouseholdUid:0, } rpcRsp, 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) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderUpdate, Origin:rpcRsp.Origin, Target:req.SuggestionOrderUpdateBody, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) 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 " " // @Success 200 {object} v1.SuggestionOrderDelResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order [delete] func (c *Controller) SuggestionOrderDel(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderDelRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.SuggestionOrderDelQuery, 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderDelResponse{} rpcReq := &v1.SuggestionOrderDelRequest{ GardenId:tokenInfo.GardenId, Id:req.Id, HouseholdUid:0, } rpcRsp, err := pb.Garden.SuggestionOrderDel(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderDel"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderDel, Origin:rpcRsp.Origin, Target:nil, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) 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 is_me query bool false " 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderListResponse{} rpcReq := &v1.SuggestionOrderListRequest{ GardenId:tokenInfo.GardenId, PageSize:req.PageSize, Page:req.Page, SuggestionType:req.SuggestionType, ApplyPeoplePhone:req.ApplyPeoplePhone, ApplyPeople:req.ApplyPeople, Status:req.Status, } if req.IsMe { rpcReq.CurrentUid = 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 " " // @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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderInfoResponse{} rpcReq := &v1.SuggestionOrderInfoRequest{ GardenId:tokenInfo.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.SuggestionOrderSendBody true "信息" // @Success 200 {object} v1.SuggestionOrderSendResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order/send [put] func (c *Controller) SuggestionOrderSend(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderSendRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.SuggestionOrderSendBody) 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderSendResponse{} rpcReq := &v1.SuggestionOrderSendRequest{ GardenId:tokenInfo.GardenId, Id:req.Id, CurrentUid:req.CurrentUid, Feedback:req.Feedback, LastUid:tokenInfo.Uid, ByCompany:tokenInfo.ByCompany, } _, err = pb.Garden.SuggestionOrderSend(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderSend"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderSend, Origin:nil, Target:req.SuggestionOrderSendBody, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 结单 // @Description 结单 // @Tags 投诉与建议 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.SuggestionOrderFinishBody true "信息" // @Success 200 {object} v1.SuggestionOrderFinishResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order/finish [put] func (c *Controller) SuggestionOrderFinish(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderFinishRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.SuggestionOrderFinishBody) 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderFinishResponse{} rpcReq := &v1.SuggestionOrderFinishRequest{ GardenId:tokenInfo.GardenId, Id:req.Id, Feedback:req.Feedback, LastUid:tokenInfo.Uid, ByCompany:tokenInfo.ByCompany, HandlePic:req.HandlePic, } _, err = pb.Garden.SuggestionOrderFinish(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderFinish"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderFinish, Origin:nil, Target:req.SuggestionOrderFinishBody, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 退单 // @Description 退单 // @Tags 投诉与建议 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.SuggestionOrderBackBody true "信息" // @Success 200 {object} v1.SuggestionOrderBackResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/suggestion/order/back [put] func (c *Controller) SuggestionOrderBack(ctx *gin.Context) { // 解析参数 req := ¶m_v1.SuggestionOrderBackRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.SuggestionOrderBackBody) 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderBackResponse{} rpcReq := &v1.SuggestionOrderBackRequest{ GardenId:tokenInfo.GardenId, Id:req.Id, Feedback:req.Feedback, LastUid:tokenInfo.Uid, ByCompany:tokenInfo.ByCompany, } _, err = pb.Garden.SuggestionOrderBack(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.SuggestionOrderBack"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderBack, Origin:nil, Target:req.SuggestionOrderBackBody, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) 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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.SuggestionOrderReturnVisitResponse{} rpcReq := &v1.SuggestionOrderReturnVisitRequest{ GardenId:tokenInfo.GardenId, Id:req.Id, ReturnVisitLevel:req.ReturnVisitLevel, ReturnVisitContent:req.ReturnVisitContent, } _, 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) logReq := OperationLogRequest{ Module:ModuleSuggestion, Action:ActionSuggestionOrderReturnVisit, Origin:nil, Target:req.SuggestionOrderReturnVisitBody, UserName:tokenInfo.UserName, Uid:tokenInfo.Uid, Cid:tokenInfo.Cid, GardenId:tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) }