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