123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705 |
- 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)
- }
|