123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- 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 page query int false " "
- // @Param page_size query int false " "
- // @Param garden_id query int true " "
- // @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.GetJwtTokenInfo(ctx)
- //if err != nil {
- // return err
- //}
- // 响应数据
- resp := param_v1.RepairClassListResponse{}
- rpcReq := &v1.RepairClassListRequest{
- GardenId: req.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.GetJwtTokenInfo(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.RepairOrderAddResponse{}
- rpcReq := &v1.RepairOrderAddRequest{
- GardenId: req.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,
- HouseholdUid: tokenInfo.Uid,
- }
- 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)
- 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.GetJwtTokenInfo(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.RepairOrderUpdateResponse{}
- rpcReq := &v1.RepairOrderUpdateRequest{
- GardenId: req.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: tokenInfo.Uid,
- }
- _, 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)
- 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 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.GetJwtTokenInfo(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.RepairOrderListResponse{}
- rpcReq := &v1.RepairOrderListRequest{
- GardenId: req.GardenId,
- PageSize: req.PageSize,
- Page: req.Page,
- ClassId: req.ClassId,
- ApplyPeoplePhone: req.ApplyPeoplePhone,
- ApplyPeople: req.ApplyPeople,
- Status: req.Status,
- HouseholdUid: 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 " "
- // @Param garden_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.GetJwtTokenInfo(ctx)
- //if err != nil {
- // return err
- //}
- // 响应数据
- resp := param_v1.RepairOrderInfoResponse{}
- rpcReq := &v1.RepairOrderInfoRequest{
- GardenId: req.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.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.GetJwtTokenInfo(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.RepairOrderReturnVisitResponse{}
- rpcReq := &v1.RepairOrderReturnVisitRequest{
- GardenId: req.GardenId,
- Id: req.Id,
- ReturnVisitLevel: req.ReturnVisitLevel,
- ReturnVisitContent: req.ReturnVisitContent,
- HouseholdUid: tokenInfo.Uid,
- }
- _, 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)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
|