123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940 |
- 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"
- )
- func BaseConfToBool(data int64) v1.HouseRentBaseConf {
- conf := v1.HouseRentBaseConf{}
- one := int64(1)
- if data&one > 0 {
- conf.Bed = true
- }
- if data&(one<<1) > 0 {
- conf.Gas = true
- }
- if data&(one<<2) > 0 {
- conf.WarmGas = true
- }
- if data&(one<<3) > 0 {
- conf.Broadband = true
- }
- if data&(one<<4) > 0 {
- conf.Refragerator = true
- }
- if data&(one<<5) > 0 {
- conf.Wardobe = true
- }
- if data&(one<<6) > 0 {
- conf.Sofa = true
- }
- if data&(one<<7) > 0 {
- conf.Aircondition = true
- }
- if data&(one<<8) > 0 {
- conf.Tv = true
- }
- if data&(one<<9) > 0 {
- conf.Heater = true
- }
- if data&(one<<10) > 0 {
- conf.Warshing = true
- }
- return conf
- }
- func SpecialConfToBool(data int64) v1.HouseRentSpecialConf {
- conf := v1.HouseRentSpecialConf{}
- one := int64(1)
- if data&one > 0 {
- conf.IntelligentLock = true
- }
- if data&(one<<1) > 0 {
- conf.Wifi = true
- }
- if data&(one<<2) > 0 {
- conf.Metro = true
- }
- if data&(one<<3) > 0 {
- conf.ParkSpace = true
- }
- if data&(one<<4) > 0 {
- conf.IndependentWc = true
- }
- if data&(one<<5) > 0 {
- conf.PrivateBalcony = true
- }
- if data&(one<<6) > 0 {
- conf.FirstRent = true
- }
- return conf
- }
- func BaseConfToBitmap(conf *v1.HouseRentBaseConf) int64 {
- ret := int64(0)
- one := int64(1)
- if conf.Bed {
- ret = ret | (one)
- }
- if conf.Gas {
- ret = ret | (one << 1)
- }
- if conf.WarmGas {
- ret = ret | (one << 2)
- }
- if conf.Broadband {
- ret = ret | (one << 3)
- }
- if conf.Refragerator {
- ret = ret | (one << 4)
- }
- if conf.Wardobe {
- ret = ret | (one << 5)
- }
- if conf.Sofa {
- ret = ret | (one << 6)
- }
- if conf.Aircondition {
- ret = ret | (one << 7)
- }
- if conf.Tv {
- ret = ret | (one << 8)
- }
- if conf.Heater {
- ret = ret | (one << 9)
- }
- if conf.Warshing {
- ret = ret | (one << 10)
- }
- return ret
- }
- func SpecialConfToBitmap(conf *v1.HouseRentSpecialConf) int64 {
- ret := int64(0)
- one := int64(1)
- if conf.IntelligentLock {
- ret = ret | (one)
- }
- if conf.Wifi {
- ret = ret | (one << 1)
- }
- if conf.Metro {
- ret = ret | (one << 2)
- }
- if conf.ParkSpace {
- ret = ret | (one << 3)
- }
- if conf.IndependentWc {
- ret = ret | (one << 4)
- }
- if conf.PrivateBalcony {
- ret = ret | (one << 5)
- }
- if conf.FirstRent {
- ret = ret | (one << 6)
- }
- return ret
- }
- ///
- // @Summary 租房列表
- // @Description 租房列表
- // @Tags 房屋租赁
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param province_code query string false "省份代码"
- // @Param city_code query string false "城市代码"
- // @Param area_code query string false "区域代码"
- // @Param street_code query string false "街道代码"
- // @Param room_count query int false "几室"
- // @Param hall_count query int false "几厅"
- // @Param wc_count query int false "几卫"
- // @Param rent_price_greater query string false "租金大于"
- // @Param rent_price_less query string false "租金小于"
- // @Param approve_status query int false "审核状态 0 不过滤 1 待审核 2 通过 3 未通过"
- // @Param page query int false " "
- // @Param page_size query int false " "
- // @Param base_conf query int false "从低bit到高bit分别表示床 天然气 暖气 宽带 冰箱 衣柜 沙发 空调 电视机 热水器 洗衣机"
- // @Param special_conf query int false "从低到高分别表示 智能门锁 wifi 近地铁 停车位 独卫 私人阳台 首次出租"
- // @Success 200 {object} v1.HouseRentListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house [get]
- func (c *Controller) HouseRentList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentListQuery, 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.HouseRentListResponse{}
- rpcReq := &v1.GardenHouseRentListRequest{
- GardenId: tokenInfo.GardenId,
- ProvinceCode: req.ProvinceCode,
- CityCode: req.CityCode,
- AreaCode: req.AreaCode,
- StreetCode: req.StreetCode,
- RoomCount: req.RoomCount,
- HallCount: req.HallCount,
- WcCount: req.WcCount,
- RentPriceGreater: req.RentPriceGreater,
- RentPriceLess: req.RentPriceLess,
- ApproveStatus: req.ApproveStatus,
- Page: req.Page,
- PageSize: req.PageSize,
- //BaseConf:
- //SpecialConf
- }
- //baseConf := BaseConfToBool(req.BaseConf)
- //specialConf := SpecialConfToBool(req.SpecialConf)
- rpcReq.BaseConf = req.BaseConf
- rpcReq.SpecialConf = req.SpecialConf
- rpcRsp, err := pb.Garden.GardenHouseRentList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.GardenHouseRentList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.HouseRentItem, 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.HouseRentApplyBody true " "
- // @Success 200 {object} v1.HouseRentApplyResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house [post]
- func (c *Controller) HouseRentApply(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentApplyRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentApplyBody)
- 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.HouseRentApplyResponse{}
- rpcReq := &v1.HouseRentApplyRequest{
- GardenId: tokenInfo.GardenId,
- WcCount: req.WcCount,
- HouseId: req.HouseId,
- // 朝向
- Direction: req.Direction,
- // 1 精装 2 简装 3 清水
- Decorating: req.Decorating,
- // 联系人
- Contacter: req.Contacter,
- // 联系人电话
- ContactPhone: req.ContactPhone,
- // 1 月付 2 季付 3 半年付 4 年付
- PayTimeType: req.PayTimeType,
- // 1 整租 2 合租 3 转租
- RentType: req.RentType,
- // 1 全部 2 主卧 3 次卧
- RoomType: req.RoomType,
- // 房间面积
- RoomArea: req.RoomArea,
- // 月租
- RentPrice: req.RentPrice,
- // 押金
- Desposit: req.Desposit,
- // 可入住时间
- InTime: req.InTime,
- // 服务费
- ServicePrice: req.ServicePrice,
- // 中介费
- IntermediaryPrice: req.IntermediaryPrice,
- // 简介
- Desc: req.Desc,
- // 房屋图片
- HousePic: req.HousePic,
- // 房屋证件图片
- CertPic: req.CertPic,
- // 是否直接通过审核
- Approve: true,
- //BaseConf:
- //SpecialConf
- }
- //baseConf := BaseConfToBool(req.BaseConf)
- //specialConf := SpecialConfToBool(req.SpecialConf)
- rpcReq.BaseConf = req.BaseConf
- rpcReq.SpecialConf = req.SpecialConf
- rpcRsp, err := pb.Household.HouseRentApply(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentApply"),
- 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.HouseRentUpdateBody true " "
- // @Success 200 {object} v1.HouseRentUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house [put]
- func (c *Controller) HouseRentUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentUpdateBody)
- 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.HouseRentUpdateResponse{}
- rpcReq := &v1.HouseRentUpdateRequest{
- GardenId: tokenInfo.GardenId,
- Id: req.Id,
- WcCount: req.WcCount,
- HouseId: req.HouseId,
- // 朝向
- Direction: req.Direction,
- // 1 精装 2 简装 3 清水
- Decorating: req.Decorating,
- // 联系人
- Contacter: req.Contacter,
- // 联系人电话
- ContactPhone: req.ContactPhone,
- // 1 月付 2 季付 3 半年付 4 年付
- PayTimeType: req.PayTimeType,
- // 1 整租 2 合租 3 转租
- RentType: req.RentType,
- // 1 全部 2 主卧 3 次卧
- RoomType: req.RoomType,
- // 房间面积
- RoomArea: req.RoomArea,
- // 月租
- RentPrice: req.RentPrice,
- // 押金
- Desposit: req.Desposit,
- // 可入住时间
- InTime: req.InTime,
- // 服务费
- ServicePrice: req.ServicePrice,
- // 中介费
- IntermediaryPrice: req.IntermediaryPrice,
- // 简介
- Desc: req.Desc,
- // 房屋图片
- HousePic: req.HousePic,
- // 房屋证件图片
- CertPic: req.CertPic,
- }
- //baseConf := BaseConfToBool(req.BaseConf)
- //specialConf := SpecialConfToBool(req.SpecialConf)
- rpcReq.BaseConf = req.BaseConf
- rpcReq.SpecialConf = req.SpecialConf
- _, err = pb.Household.HouseRentUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentUpdate"),
- 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 body body v1.HouseRentApproveBody true " "
- // @Success 200 {object} v1.HouseRentApproveResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/approve [put]
- func (c *Controller) HouseRentApprove(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentApproveRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentApproveBody)
- 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.HouseRentApproveResponse{}
- rpcReq := &v1.HouseRentApproveRequest{
- GardenId: tokenInfo.GardenId,
- Id: req.Id,
- Status: req.Status,
- Feedback: req.Feedback,
- }
- _, err = pb.Household.HouseRentApprove(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentApprove"),
- 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 body body v1.HouseRentDownBody true " "
- // @Success 200 {object} v1.HouseRentDownResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/down [put]
- func (c *Controller) HouseRentDown(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentDownRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentDownBody)
- 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.HouseRentDownResponse{}
- rpcReq := &v1.HouseRentDownRequest{
- GardenId: tokenInfo.GardenId,
- Id: req.Id,
- }
- _, err = pb.Household.HouseRentDown(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentDown"),
- 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 body body v1.HouseRentAddManagerBody true " "
- // @Success 200 {object} v1.HouseRentAddManagerResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/manager [post]
- func (c *Controller) HouseRentAddManager(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentAddManagerRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentAddManagerBody)
- 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.HouseRentAddManagerResponse{}
- rpcReq := &v1.HouseRentAddManagerRequest{
- GardenId: tokenInfo.GardenId,
- RentId: req.RentId,
- ManagerUid: req.ManagerUid,
- }
- _, err = pb.Garden.HouseRentAddManager(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseRentAddManager"),
- 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 id query int true "经纪人与房屋的关系id"
- // @Success 200 {object} v1.HouseRentDelManagerResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/manager [delete]
- func (c *Controller) HouseRentDelManager(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentDelManagerRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentDelManagerQuery, 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.HouseRentDelManagerResponse{}
- rpcReq := &v1.HouseRentDelManagerRequest{
- GardenId: tokenInfo.GardenId,
- Id: req.Id,
- }
- _, err = pb.Garden.HouseRentDelManager(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseRentDelManager"),
- 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 rent_id query int true "租房信息id"
- // @Success 200 {object} v1.HouseRentManagerListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/manager [get]
- func (c *Controller) HouseRentManagerList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentManagerListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentManagerListQuery, 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.HouseRentManagerListResponse{}
- rpcReq := &v1.HouseRentManagerListRequest{
- GardenId: tokenInfo.GardenId,
- RentId: req.RentId,
- }
- rpcRsp, err := pb.Garden.HouseRentManagerList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseRentManagerList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.HouseRentManagerItem, 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 house_name query string false "房屋全称"
- // @Param name query string false "联系人"
- // @Param phone query string false "联系人电话"
- // @Param rent_id query int false "租房信息id"
- // @Param page query int false " "
- // @Param page_size query int false " "
- // @Success 200 {object} v1.HouseRentAppointmentListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/appointment [get]
- func (c *Controller) HouseRentAppointmentList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentAppointmentListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentAppointmentListQuery, 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.HouseRentAppointmentListResponse{}
- rpcReq := &v1.HouseRentAppointmentListRequest{
- GardenId: tokenInfo.GardenId,
- RentId: req.RentId,
- HouseName: req.HouseName,
- Page: req.Page,
- PageSize: req.PageSize,
- Name: req.Name,
- Phone: req.Phone,
- }
- rpcRsp, err := pb.Household.HouseRentAppointmentList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentAppointmentList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.HouseRentAppointmentItem, 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 false "预约记录id"
- // @Success 200 {object} v1.HouseRentAppointmentDelResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/appointment [delete]
- func (c *Controller) HouseRentAppointmentDel(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentAppointmentDelRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentAppointmentDelQuery, 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.HouseRentAppointmentDelResponse{}
- rpcReq := &v1.HouseRentAppointmentDelRequest{
- GardenId: tokenInfo.GardenId,
- Id: req.Id,
- }
- _, err = pb.Household.HouseRentAppointmentDel(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentAppointmentDel"),
- 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 body body v1.HouseRentAppointmentStatusBody true "信息"
- // @Success 200 {object} v1.HouseRentAppointmentStatusResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/rent/house/appointment [put]
- func (c *Controller) HouseRentAppointmentStatus(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseRentAppointmentStatusRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentAppointmentStatusBody)
- 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.HouseRentAppointmentStatusResponse{}
- rpcReq := &v1.HouseRentAppointmentStatusRequest{
- GardenId: tokenInfo.GardenId,
- Id: req.Id,
- Status: req.Status,
- Feedback: req.Feedback,
- }
- _, err = pb.Household.HouseRentAppointmentStatus(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Household.HouseRentAppointmentStatus"),
- 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)
- }
|