1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- 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-system-gateway/errors"
- param_v1 "property-system-gateway/param/v1"
- "property-system-gateway/pb"
- "property-system-gateway/pb/v1"
- "property-system-gateway/utils"
- )
- //
- // @Summary 添加分类
- // @Description 添加分类
- // @Tags 报事报修
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.RepairClassAddBody true "信息"
- // @Success 200 {object} v1.RepairClassAddResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/class [post]
- func (c *Controller) RepairClassAdd(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairClassAddRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairClassAddBody)
- 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.RepairClassAddResponse{}
- rpcReq := &v1.RepairClassAddRequest{
- GardenId:tokenInfo.GardenId,
- Name:req.Name,
- Enable:req.Enable,
- Area:req.Area,
- }
- rpcRsp, err := pb.Garden.RepairClassAdd(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairClassAdd"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairClassAdd,
- Origin:nil,
- Target:req.RepairClassAddBody,
- 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.RepairClassUpdateBody true "信息"
- // @Success 200 {object} v1.RepairClassUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/class [put]
- func (c *Controller) RepairClassUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairClassUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairClassUpdateBody)
- 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.RepairClassUpdateResponse{}
- rpcReq := &v1.RepairClassUpdateRequest{
- GardenId:tokenInfo.GardenId,
- Name:req.Name,
- Enable:req.Enable,
- Id:req.Id,
- Area:req.Area,
- }
- rpcRsp, err := pb.Garden.RepairClassUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairClassUpdate"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairClassUpdate,
- Origin:rpcRsp.Origin,
- Target:req.RepairClassUpdateBody,
- 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.RepairClassDelResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/class [delete]
- func (c *Controller) RepairClassDel(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairClassDelRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.RepairClassDelQuery, 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.RepairClassDelResponse{}
- rpcReq := &v1.RepairClassDelRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.RepairClassDel(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairClassDel"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairClassDel,
- 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 area query int false "1公区 2室内 "
- // @Success 200 {object} v1.RepairClassListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/class [get]
- func (c *Controller) RepairClassList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairClassListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.RepairClassListQuery, 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.RepairClassListResponse{}
- rpcReq := &v1.RepairClassListRequest{
- GardenId:tokenInfo.GardenId,
- PageSize:req.PageSize,
- Page:req.Page,
- Area:req.Area,
- }
- rpcRsp, err := pb.Garden.RepairClassList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairClassList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.RepairClassItem, 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.RepairOrderAddBody true "信息"
- // @Success 200 {object} v1.RepairOrderAddResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order [post]
- func (c *Controller) RepairOrderAdd(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderAddRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairOrderAddBody)
- 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.RepairOrderAddResponse{}
- rpcReq := &v1.RepairOrderAddRequest{
- GardenId:tokenInfo.GardenId,
- // 分类id
- ClassId:req.ClassId,
- // 报修人
- ApplyPeople:req.ApplyPeople,
- // 报修人电话
- ApplyPeoplePhone:req.ApplyPeoplePhone,
- // 预约时间
- Appointment:req.Appointment,
- // 房屋id
- HouseId:req.HouseId,
- // 上级处理人
- LastUid:tokenInfo.Uid,
- // 报修内容
- ApplyContent:req.ApplyContent,
- // 报修图片
- ApplyPic:req.ApplyPic,
- ByCompany:tokenInfo.ByCompany,
- HouseholdUid:0,
- }
- rpcRsp, err := pb.Garden.RepairOrderAdd(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderAdd"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderAdd,
- Origin:nil,
- Target:req.RepairOrderAddBody,
- 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.RepairOrderUpdateBody true "信息"
- // @Success 200 {object} v1.RepairOrderUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order [put]
- func (c *Controller) RepairOrderUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairOrderUpdateBody)
- 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.RepairOrderUpdateResponse{}
- rpcReq := &v1.RepairOrderUpdateRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- // 分类id
- ClassId:req.ClassId,
- // 报修人
- ApplyPeople:req.ApplyPeople,
- // 报修人电话
- ApplyPeoplePhone:req.ApplyPeoplePhone,
- // 预约时间
- Appointment:req.Appointment,
- // 房屋id
- HouseId:req.HouseId,
- // 报修内容
- ApplyContent:req.ApplyContent,
- // 报修图片
- ApplyPic:req.ApplyPic,
- HouseholdUid:0,
- }
- rpcRsp, err := pb.Garden.RepairOrderUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderUpdate"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderUpdate,
- Origin:rpcRsp.Origin,
- Target:req.RepairOrderUpdateBody,
- 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.RepairOrderDelResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order [delete]
- func (c *Controller) RepairOrderDel(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderDelRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.RepairOrderDelQuery, 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.RepairOrderDelResponse{}
- rpcReq := &v1.RepairOrderDelRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- HouseholdUid:0,
- }
- rpcRsp, err := pb.Garden.RepairOrderDel(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderDel"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderDel,
- 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 class_id query int false "分类id"
- // @Success 200 {object} v1.RepairOrderListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order [get]
- func (c *Controller) RepairOrderList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.RepairOrderListQuery, 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.RepairOrderListResponse{}
- rpcReq := &v1.RepairOrderListRequest{
- GardenId:tokenInfo.GardenId,
- PageSize:req.PageSize,
- Page:req.Page,
- ClassId:req.ClassId,
- ApplyPeoplePhone:req.ApplyPeoplePhone,
- ApplyPeople:req.ApplyPeople,
- Status:req.Status,
- }
- if req.IsMe {
- rpcReq.CurrentUid = tokenInfo.Uid
- }
- rpcRsp, err := pb.Garden.RepairOrderList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.RepairOrderItem, 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.RepairOrderInfoResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order/info [get]
- func (c *Controller) RepairOrderInfo(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderInfoRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.RepairOrderInfoQuery, 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.RepairOrderInfoResponse{}
- rpcReq := &v1.RepairOrderInfoRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.RepairOrderInfo(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderInfo"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.RepairOrderPipelineData, 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.RepairOrderSendBody true "信息"
- // @Success 200 {object} v1.RepairOrderSendResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order/send [put]
- func (c *Controller) RepairOrderSend(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderSendRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairOrderSendBody)
- 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.RepairOrderSendResponse{}
- rpcReq := &v1.RepairOrderSendRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- CurrentUid:req.CurrentUid,
- Feedback:req.Feedback,
- LastUid:tokenInfo.Uid,
- ByCompany:tokenInfo.ByCompany,
- }
- _, err = pb.Garden.RepairOrderSend(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderSend"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderSend,
- Origin:nil,
- Target:req.RepairOrderSendBody,
- 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.RepairOrderFinishBody true "信息"
- // @Success 200 {object} v1.RepairOrderFinishResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order/finish [put]
- func (c *Controller) RepairOrderFinish(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderFinishRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairOrderFinishBody)
- 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.RepairOrderFinishResponse{}
- rpcReq := &v1.RepairOrderFinishRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- Feedback:req.Feedback,
- LastUid:tokenInfo.Uid,
- ByCompany:tokenInfo.ByCompany,
- RepairPic:req.RepairPic,
- }
- _, err = pb.Garden.RepairOrderFinish(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderFinish"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderFinish,
- Origin:nil,
- Target:req.RepairOrderFinishBody,
- 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.RepairOrderBackBody true "信息"
- // @Success 200 {object} v1.RepairOrderBackResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order/back [put]
- func (c *Controller) RepairOrderBack(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderBackRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairOrderBackBody)
- 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.RepairOrderBackResponse{}
- rpcReq := &v1.RepairOrderBackRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- Feedback:req.Feedback,
- LastUid:tokenInfo.Uid,
- ByCompany:tokenInfo.ByCompany,
- }
- _, err = pb.Garden.RepairOrderBack(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderBack"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderBack,
- Origin:nil,
- Target:req.RepairOrderBackBody,
- 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.RepairOrderReturnVisitBody true "信息"
- // @Success 200 {object} v1.RepairOrderReturnVisitResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/repair/order/return_visit [put]
- func (c *Controller) RepairOrderReturnVisit(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.RepairOrderReturnVisitRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.RepairOrderReturnVisitBody)
- 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.RepairOrderReturnVisitResponse{}
- rpcReq := &v1.RepairOrderReturnVisitRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- ReturnVisitLevel:req.ReturnVisitLevel,
- ReturnVisitContent:req.ReturnVisitContent,
- }
- _, err = pb.Garden.RepairOrderReturnVisit(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.RepairOrderReturnVisit"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleRepair,
- Action:ActionRepairOrderReturnVisit,
- Origin:nil,
- Target:req.RepairOrderReturnVisitBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
|