house_rent.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. package v1
  2. import (
  3. "git.getensh.com/common/gopkgs/logger"
  4. "git.getensh.com/common/gopkgs/tasker/httptasker"
  5. "git.getensh.com/common/gopkgs/util"
  6. "github.com/gin-gonic/gin"
  7. "go.uber.org/zap"
  8. "net/http"
  9. "property-applete-gateway/errors"
  10. param_v1 "property-applete-gateway/param/v1"
  11. "property-applete-gateway/pb"
  12. "property-applete-gateway/pb/v1"
  13. "property-applete-gateway/utils"
  14. )
  15. func BaseConfToBool(data int64) v1.HouseRentBaseConf {
  16. conf := v1.HouseRentBaseConf{}
  17. one := int64(1)
  18. if data & one > 0 {
  19. conf.Bed = true
  20. }
  21. if data & (one << 1) > 0{
  22. conf.Gas = true
  23. }
  24. if data & (one << 2) > 0{
  25. conf.WarmGas = true
  26. }
  27. if data & (one << 3) > 0{
  28. conf.Broadband = true
  29. }
  30. if data & (one << 4) > 0{
  31. conf.Refragerator = true
  32. }
  33. if data & (one << 5) > 0{
  34. conf.Wardobe = true
  35. }
  36. if data & (one << 6) > 0{
  37. conf.Sofa = true
  38. }
  39. if data & (one << 7) > 0{
  40. conf.Aircondition = true
  41. }
  42. if data & (one << 8) > 0{
  43. conf.Tv = true
  44. }
  45. if data & (one << 9) > 0{
  46. conf.Heater = true
  47. }
  48. if data & (one << 10) > 0{
  49. conf.Warshing = true
  50. }
  51. return conf
  52. }
  53. func SpecialConfToBool(data int64) v1.HouseRentSpecialConf {
  54. conf := v1.HouseRentSpecialConf{}
  55. one := int64(1)
  56. if data & one > 0 {
  57. conf.IntelligentLock = true
  58. }
  59. if data & (one << 1) > 0{
  60. conf.Wifi = true
  61. }
  62. if data & (one << 2) > 0{
  63. conf.Metro = true
  64. }
  65. if data & (one << 3) > 0{
  66. conf.ParkSpace = true
  67. }
  68. if data & (one << 4) > 0{
  69. conf.IndependentWc = true
  70. }
  71. if data & (one << 5) > 0{
  72. conf.PrivateBalcony = true
  73. }
  74. if data & (one << 6) > 0{
  75. conf.FirstRent = true
  76. }
  77. return conf
  78. }
  79. func BaseConfToBitmap(conf *v1.HouseRentBaseConf) int64 {
  80. ret := int64(0)
  81. one := int64(1)
  82. if conf.Bed {
  83. ret = ret |(one)
  84. }
  85. if conf.Gas {
  86. ret = ret |(one << 1)
  87. }
  88. if conf.WarmGas {
  89. ret = ret |(one << 2)
  90. }
  91. if conf.Broadband {
  92. ret = ret |(one << 3)
  93. }
  94. if conf.Refragerator {
  95. ret = ret |(one << 4)
  96. }
  97. if conf.Wardobe {
  98. ret = ret |(one << 5)
  99. }
  100. if conf.Sofa {
  101. ret = ret |(one << 6)
  102. }
  103. if conf.Aircondition {
  104. ret = ret |(one << 7)
  105. }
  106. if conf.Tv {
  107. ret = ret |(one << 8)
  108. }
  109. if conf.Heater {
  110. ret = ret |(one << 9)
  111. }
  112. if conf.Warshing {
  113. ret = ret |(one << 10)
  114. }
  115. return ret
  116. }
  117. func SpecialConfToBitmap(conf *v1.HouseRentSpecialConf) int64 {
  118. ret := int64(0)
  119. one := int64(1)
  120. if conf.IntelligentLock {
  121. ret = ret |(one)
  122. }
  123. if conf.Wifi {
  124. ret = ret |(one << 1)
  125. }
  126. if conf.Metro {
  127. ret = ret |(one << 2)
  128. }
  129. if conf.ParkSpace {
  130. ret = ret |(one << 3)
  131. }
  132. if conf.IndependentWc {
  133. ret = ret |(one << 4)
  134. }
  135. if conf.PrivateBalcony {
  136. ret = ret |(one << 5)
  137. }
  138. if conf.FirstRent {
  139. ret = ret |(one << 6)
  140. }
  141. return ret
  142. }
  143. ///
  144. // @Summary 租房列表
  145. // @Description 租房列表
  146. // @Tags 房屋租赁
  147. // @Accept json
  148. // @Produce json
  149. // @Param token header string true "token"
  150. // @Param province_code query string false "省份代码"
  151. // @Param city_code query string false "城市代码"
  152. // @Param area_code query string false "区域代码"
  153. // @Param street_code query string false "街道代码"
  154. // @Param room_count query int false "几室"
  155. // @Param hall_count query int false "几厅"
  156. // @Param wc_count query int false "几卫"
  157. // @Param rent_price_greater query string false "租金大于"
  158. // @Param rent_price_less query string false "租金小于"
  159. // @Param approve_status query int false "审核状态 0 不过滤 1 待审核 2 通过 3 未通过"
  160. // @Param page query int false " "
  161. // @Param page_size query int false " "
  162. // @Param base_conf query int false "从低bit到高bit分别表示床 天然气 暖气 宽带 冰箱 衣柜 沙发 空调 电视机 热水器 洗衣机"
  163. // @Param special_conf query int false "从低到高分别表示 智能门锁 wifi 近地铁 停车位 独卫 私人阳台 首次出租"
  164. // @Success 200 {object} v1.HouseRentListResponse
  165. // @Failure 500 {object} base.HTTPError
  166. // @Router /api/v1/rent/house [get]
  167. func (c *Controller) HouseRentList(ctx *gin.Context) {
  168. // 解析参数
  169. req := &param_v1.HouseRentListRequest{}
  170. parseParamTask := func() error {
  171. err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentListQuery, nil)
  172. if err != nil {
  173. logger.Error("func",
  174. zap.String("call", "util.ShouldBind"),
  175. zap.String("error", err.Error()))
  176. return errors.ParamsError
  177. }
  178. return nil
  179. }
  180. // 业务处理
  181. handleServiceTask := func() error {
  182. tokenInfo, err := utils.GetSubjectValue(ctx)
  183. if err != nil {
  184. return err
  185. }
  186. // 响应数据
  187. resp := param_v1.HouseRentListResponse{}
  188. rpcReq := &v1.GardenHouseRentListRequest{
  189. GardenId:tokenInfo.GardenId,
  190. ProvinceCode:req.ProvinceCode,
  191. CityCode:req.CityCode,
  192. AreaCode:req.AreaCode,
  193. StreetCode:req.StreetCode,
  194. RoomCount:req.RoomCount,
  195. HallCount:req.HallCount,
  196. WcCount:req.WcCount,
  197. RentPriceGreater:req.RentPriceGreater,
  198. RentPriceLess:req.RentPriceLess,
  199. ApproveStatus:req.ApproveStatus,
  200. Page:req.Page,
  201. PageSize:req.PageSize,
  202. //BaseConf:
  203. //SpecialConf
  204. }
  205. //baseConf := BaseConfToBool(req.BaseConf)
  206. //specialConf := SpecialConfToBool(req.SpecialConf)
  207. rpcReq.BaseConf = req.BaseConf
  208. rpcReq.SpecialConf = req.SpecialConf
  209. rpcRsp, err := pb.Garden.GardenHouseRentList(ctx, rpcReq)
  210. if err != nil {
  211. s, _ := json.MarshalToString(req)
  212. logger.Error("func",
  213. zap.String("call", "pb.Garden.GardenHouseRentList"),
  214. zap.String("params", s),
  215. zap.String("error", err.Error()))
  216. return errors.ErrorTransForm(err)
  217. }
  218. if rpcRsp.List == nil {
  219. rpcRsp.List = make([]*v1.HouseRentItem, 0)
  220. }
  221. resp.Data = *rpcRsp
  222. ctx.JSON(http.StatusOK, resp)
  223. return nil
  224. }
  225. // 执行任务
  226. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  227. }
  228. ///
  229. // @Summary 发布房源
  230. // @Description 发布房源
  231. // @Tags 房屋租赁
  232. // @Accept json
  233. // @Produce json
  234. // @Param token header string true "token"
  235. // @Param body body v1.HouseRentApplyBody true " "
  236. // @Success 200 {object} v1.HouseRentApplyResponse
  237. // @Failure 500 {object} base.HTTPError
  238. // @Router /api/v1/rent/house [post]
  239. func (c *Controller) HouseRentApply(ctx *gin.Context) {
  240. // 解析参数
  241. req := &param_v1.HouseRentApplyRequest{}
  242. parseParamTask := func() error {
  243. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentApplyBody)
  244. if err != nil {
  245. logger.Error("func",
  246. zap.String("call", "util.ShouldBind"),
  247. zap.String("error", err.Error()))
  248. return errors.ParamsError
  249. }
  250. return nil
  251. }
  252. // 业务处理
  253. handleServiceTask := func() error {
  254. tokenInfo, err := utils.GetSubjectValue(ctx)
  255. if err != nil {
  256. return err
  257. }
  258. // 响应数据
  259. resp := param_v1.HouseRentApplyResponse{}
  260. rpcReq := &v1.HouseRentApplyRequest{
  261. GardenId:tokenInfo.GardenId,
  262. WcCount:req.WcCount,
  263. HouseId:req.HouseId,
  264. // 朝向
  265. Direction:req.Direction,
  266. // 1 精装 2 简装 3 清水
  267. Decorating:req.Decorating,
  268. // 联系人
  269. Contacter:req.Contacter,
  270. // 联系人电话
  271. ContactPhone:req.ContactPhone,
  272. // 1 月付 2 季付 3 半年付 4 年付
  273. PayTimeType:req.PayTimeType,
  274. // 1 整租 2 合租 3 转租
  275. RentType:req.RentType,
  276. // 1 全部 2 主卧 3 次卧
  277. RoomType:req.RoomType,
  278. // 房间面积
  279. RoomArea:req.RoomArea,
  280. // 月租
  281. RentPrice:req.RentPrice,
  282. // 押金
  283. Desposit:req.Desposit,
  284. // 可入住时间
  285. InTime:req.InTime,
  286. // 服务费
  287. ServicePrice:req.ServicePrice,
  288. // 中介费
  289. IntermediaryPrice:req.IntermediaryPrice,
  290. // 简介
  291. Desc:req.Desc,
  292. // 房屋图片
  293. HousePic:req.HousePic,
  294. // 房屋证件图片
  295. CertPic:req.CertPic,
  296. // 是否直接通过审核
  297. Approve:true,
  298. //BaseConf:
  299. //SpecialConf
  300. }
  301. //baseConf := BaseConfToBool(req.BaseConf)
  302. //specialConf := SpecialConfToBool(req.SpecialConf)
  303. rpcReq.BaseConf = req.BaseConf
  304. rpcReq.SpecialConf = req.SpecialConf
  305. rpcRsp, err := pb.Household.HouseRentApply(ctx, rpcReq)
  306. if err != nil {
  307. s, _ := json.MarshalToString(req)
  308. logger.Error("func",
  309. zap.String("call", "pb.Household.HouseRentApply"),
  310. zap.String("params", s),
  311. zap.String("error", err.Error()))
  312. return errors.ErrorTransForm(err)
  313. }
  314. resp.Data = *rpcRsp
  315. ctx.JSON(http.StatusOK, resp)
  316. return nil
  317. }
  318. // 执行任务
  319. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  320. }
  321. //
  322. // @Summary 修改信息
  323. // @Description 修改信息
  324. // @Tags 房屋租赁
  325. // @Accept json
  326. // @Produce json
  327. // @Param token header string true "token"
  328. // @Param body body v1.HouseRentUpdateBody true " "
  329. // @Success 200 {object} v1.HouseRentUpdateResponse
  330. // @Failure 500 {object} base.HTTPError
  331. // @Router /api/v1/rent/house [put]
  332. func (c *Controller) HouseRentUpdate(ctx *gin.Context) {
  333. // 解析参数
  334. req := &param_v1.HouseRentUpdateRequest{}
  335. parseParamTask := func() error {
  336. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentUpdateBody)
  337. if err != nil {
  338. logger.Error("func",
  339. zap.String("call", "util.ShouldBind"),
  340. zap.String("error", err.Error()))
  341. return errors.ParamsError
  342. }
  343. return nil
  344. }
  345. // 业务处理
  346. handleServiceTask := func() error {
  347. tokenInfo, err := utils.GetSubjectValue(ctx)
  348. if err != nil {
  349. return err
  350. }
  351. // 响应数据
  352. resp := param_v1.HouseRentUpdateResponse{}
  353. rpcReq := &v1.HouseRentUpdateRequest{
  354. GardenId:tokenInfo.GardenId,
  355. Id:req.Id,
  356. WcCount:req.WcCount,
  357. HouseId:req.HouseId,
  358. // 朝向
  359. Direction:req.Direction,
  360. // 1 精装 2 简装 3 清水
  361. Decorating:req.Decorating,
  362. // 联系人
  363. Contacter:req.Contacter,
  364. // 联系人电话
  365. ContactPhone:req.ContactPhone,
  366. // 1 月付 2 季付 3 半年付 4 年付
  367. PayTimeType:req.PayTimeType,
  368. // 1 整租 2 合租 3 转租
  369. RentType:req.RentType,
  370. // 1 全部 2 主卧 3 次卧
  371. RoomType:req.RoomType,
  372. // 房间面积
  373. RoomArea:req.RoomArea,
  374. // 月租
  375. RentPrice:req.RentPrice,
  376. // 押金
  377. Desposit:req.Desposit,
  378. // 可入住时间
  379. InTime:req.InTime,
  380. // 服务费
  381. ServicePrice:req.ServicePrice,
  382. // 中介费
  383. IntermediaryPrice:req.IntermediaryPrice,
  384. // 简介
  385. Desc:req.Desc,
  386. // 房屋图片
  387. HousePic:req.HousePic,
  388. // 房屋证件图片
  389. CertPic:req.CertPic,
  390. }
  391. //baseConf := BaseConfToBool(req.BaseConf)
  392. //specialConf := SpecialConfToBool(req.SpecialConf)
  393. rpcReq.BaseConf = req.BaseConf
  394. rpcReq.SpecialConf = req.SpecialConf
  395. _, err = pb.Household.HouseRentUpdate(ctx, rpcReq)
  396. if err != nil {
  397. s, _ := json.MarshalToString(req)
  398. logger.Error("func",
  399. zap.String("call", "pb.Household.HouseRentUpdate"),
  400. zap.String("params", s),
  401. zap.String("error", err.Error()))
  402. return errors.ErrorTransForm(err)
  403. }
  404. ctx.JSON(http.StatusOK, resp)
  405. return nil
  406. }
  407. // 执行任务
  408. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  409. }
  410. //
  411. // @Summary 审核
  412. // @Description 审核
  413. // @Tags 房屋租赁
  414. // @Accept json
  415. // @Produce json
  416. // @Param token header string true "token"
  417. // @Param body body v1.HouseRentApproveBody true " "
  418. // @Success 200 {object} v1.HouseRentApproveResponse
  419. // @Failure 500 {object} base.HTTPError
  420. // @Router /api/v1/rent/house/approve [put]
  421. func (c *Controller) HouseRentApprove(ctx *gin.Context) {
  422. // 解析参数
  423. req := &param_v1.HouseRentApproveRequest{}
  424. parseParamTask := func() error {
  425. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentApproveBody)
  426. if err != nil {
  427. logger.Error("func",
  428. zap.String("call", "util.ShouldBind"),
  429. zap.String("error", err.Error()))
  430. return errors.ParamsError
  431. }
  432. return nil
  433. }
  434. // 业务处理
  435. handleServiceTask := func() error {
  436. tokenInfo, err := utils.GetSubjectValue(ctx)
  437. if err != nil {
  438. return err
  439. }
  440. // 响应数据
  441. resp := param_v1.HouseRentApproveResponse{}
  442. rpcReq := &v1.HouseRentApproveRequest{
  443. GardenId:tokenInfo.GardenId,
  444. Id:req.Id,
  445. Status:req.Status,
  446. Feedback:req.Feedback,
  447. }
  448. _, err = pb.Household.HouseRentApprove(ctx, rpcReq)
  449. if err != nil {
  450. s, _ := json.MarshalToString(req)
  451. logger.Error("func",
  452. zap.String("call", "pb.Household.HouseRentApprove"),
  453. zap.String("params", s),
  454. zap.String("error", err.Error()))
  455. return errors.ErrorTransForm(err)
  456. }
  457. ctx.JSON(http.StatusOK, resp)
  458. return nil
  459. }
  460. // 执行任务
  461. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  462. }
  463. //
  464. // @Summary 下架
  465. // @Description 下架
  466. // @Tags 房屋租赁
  467. // @Accept json
  468. // @Produce json
  469. // @Param token header string true "token"
  470. // @Param body body v1.HouseRentDownBody true " "
  471. // @Success 200 {object} v1.HouseRentDownResponse
  472. // @Failure 500 {object} base.HTTPError
  473. // @Router /api/v1/rent/house/down [put]
  474. func (c *Controller) HouseRentDown(ctx *gin.Context) {
  475. // 解析参数
  476. req := &param_v1.HouseRentDownRequest{}
  477. parseParamTask := func() error {
  478. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentDownBody)
  479. if err != nil {
  480. logger.Error("func",
  481. zap.String("call", "util.ShouldBind"),
  482. zap.String("error", err.Error()))
  483. return errors.ParamsError
  484. }
  485. return nil
  486. }
  487. // 业务处理
  488. handleServiceTask := func() error {
  489. tokenInfo, err := utils.GetSubjectValue(ctx)
  490. if err != nil {
  491. return err
  492. }
  493. // 响应数据
  494. resp := param_v1.HouseRentDownResponse{}
  495. rpcReq := &v1.HouseRentDownRequest{
  496. GardenId:tokenInfo.GardenId,
  497. Id:req.Id,
  498. }
  499. _, err = pb.Household.HouseRentDown(ctx, rpcReq)
  500. if err != nil {
  501. s, _ := json.MarshalToString(req)
  502. logger.Error("func",
  503. zap.String("call", "pb.Household.HouseRentDown"),
  504. zap.String("params", s),
  505. zap.String("error", err.Error()))
  506. return errors.ErrorTransForm(err)
  507. }
  508. ctx.JSON(http.StatusOK, resp)
  509. return nil
  510. }
  511. // 执行任务
  512. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  513. }
  514. //
  515. // @Summary 添加经纪人
  516. // @Description 添加经纪人
  517. // @Tags 房屋租赁
  518. // @Accept json
  519. // @Produce json
  520. // @Param token header string true "token"
  521. // @Param body body v1.HouseRentAddManagerBody true " "
  522. // @Success 200 {object} v1.HouseRentAddManagerResponse
  523. // @Failure 500 {object} base.HTTPError
  524. // @Router /api/v1/rent/house/manager [post]
  525. func (c *Controller) HouseRentAddManager(ctx *gin.Context) {
  526. // 解析参数
  527. req := &param_v1.HouseRentAddManagerRequest{}
  528. parseParamTask := func() error {
  529. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseRentAddManagerBody)
  530. if err != nil {
  531. logger.Error("func",
  532. zap.String("call", "util.ShouldBind"),
  533. zap.String("error", err.Error()))
  534. return errors.ParamsError
  535. }
  536. return nil
  537. }
  538. // 业务处理
  539. handleServiceTask := func() error {
  540. tokenInfo, err := utils.GetSubjectValue(ctx)
  541. if err != nil {
  542. return err
  543. }
  544. // 响应数据
  545. resp := param_v1.HouseRentAddManagerResponse{}
  546. rpcReq := &v1.HouseRentAddManagerRequest{
  547. GardenId:tokenInfo.GardenId,
  548. RentId:req.RentId,
  549. ManagerUid:req.ManagerUid,
  550. }
  551. _, err = pb.Garden.HouseRentAddManager(ctx, rpcReq)
  552. if err != nil {
  553. s, _ := json.MarshalToString(req)
  554. logger.Error("func",
  555. zap.String("call", "pb.Garden.HouseRentAddManager"),
  556. zap.String("params", s),
  557. zap.String("error", err.Error()))
  558. return errors.ErrorTransForm(err)
  559. }
  560. ctx.JSON(http.StatusOK, resp)
  561. return nil
  562. }
  563. // 执行任务
  564. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  565. }
  566. //
  567. // @Summary 删除经纪人
  568. // @Description 删除经纪人
  569. // @Tags 房屋租赁
  570. // @Accept json
  571. // @Produce json
  572. // @Param token header string true "token"
  573. // @Param id query int true "经纪人与房屋的关系id"
  574. // @Success 200 {object} v1.HouseRentDelManagerResponse
  575. // @Failure 500 {object} base.HTTPError
  576. // @Router /api/v1/rent/house/manager [delete]
  577. func (c *Controller) HouseRentDelManager(ctx *gin.Context) {
  578. // 解析参数
  579. req := &param_v1.HouseRentDelManagerRequest{}
  580. parseParamTask := func() error {
  581. err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentDelManagerQuery,nil)
  582. if err != nil {
  583. logger.Error("func",
  584. zap.String("call", "util.ShouldBind"),
  585. zap.String("error", err.Error()))
  586. return errors.ParamsError
  587. }
  588. return nil
  589. }
  590. // 业务处理
  591. handleServiceTask := func() error {
  592. tokenInfo, err := utils.GetSubjectValue(ctx)
  593. if err != nil {
  594. return err
  595. }
  596. // 响应数据
  597. resp := param_v1.HouseRentDelManagerResponse{}
  598. rpcReq := &v1.HouseRentDelManagerRequest{
  599. GardenId:tokenInfo.GardenId,
  600. Id:req.Id,
  601. }
  602. _, err = pb.Garden.HouseRentDelManager(ctx, rpcReq)
  603. if err != nil {
  604. s, _ := json.MarshalToString(req)
  605. logger.Error("func",
  606. zap.String("call", "pb.Garden.HouseRentDelManager"),
  607. zap.String("params", s),
  608. zap.String("error", err.Error()))
  609. return errors.ErrorTransForm(err)
  610. }
  611. ctx.JSON(http.StatusOK, resp)
  612. return nil
  613. }
  614. // 执行任务
  615. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  616. }
  617. //
  618. // @Summary 房屋的经纪人列表
  619. // @Description 房屋的经纪人列表
  620. // @Tags 房屋租赁
  621. // @Accept json
  622. // @Produce json
  623. // @Param token header string true "token"
  624. // @Param rent_id query int true "租房信息id"
  625. // @Success 200 {object} v1.HouseRentManagerListResponse
  626. // @Failure 500 {object} base.HTTPError
  627. // @Router /api/v1/rent/house/manager [get]
  628. func (c *Controller) HouseRentManagerList(ctx *gin.Context) {
  629. // 解析参数
  630. req := &param_v1.HouseRentManagerListRequest{}
  631. parseParamTask := func() error {
  632. err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentManagerListQuery,nil)
  633. if err != nil {
  634. logger.Error("func",
  635. zap.String("call", "util.ShouldBind"),
  636. zap.String("error", err.Error()))
  637. return errors.ParamsError
  638. }
  639. return nil
  640. }
  641. // 业务处理
  642. handleServiceTask := func() error {
  643. tokenInfo, err := utils.GetSubjectValue(ctx)
  644. if err != nil {
  645. return err
  646. }
  647. // 响应数据
  648. resp := param_v1.HouseRentManagerListResponse{}
  649. rpcReq := &v1.HouseRentManagerListRequest{
  650. GardenId:tokenInfo.GardenId,
  651. RentId:req.RentId,
  652. }
  653. rpcRsp, err := pb.Garden.HouseRentManagerList(ctx, rpcReq)
  654. if err != nil {
  655. s, _ := json.MarshalToString(req)
  656. logger.Error("func",
  657. zap.String("call", "pb.Garden.HouseRentManagerList"),
  658. zap.String("params", s),
  659. zap.String("error", err.Error()))
  660. return errors.ErrorTransForm(err)
  661. }
  662. if rpcRsp.List == nil {
  663. rpcRsp.List = make([]*v1.HouseRentManagerItem, 0)
  664. }
  665. resp.Data = *rpcRsp
  666. ctx.JSON(http.StatusOK, resp)
  667. return nil
  668. }
  669. // 执行任务
  670. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  671. }
  672. //
  673. // @Summary 租房预约记录
  674. // @Description 租房预约记录
  675. // @Tags 房屋租赁
  676. // @Accept json
  677. // @Produce json
  678. // @Param token header string true "token"
  679. // @Param house_name query string false "房屋全称"
  680. // @Param rent_id query int false "租房信息id"
  681. // @Param page query int false " "
  682. // @Param page_size query int false " "
  683. // @Success 200 {object} v1.HouseRentAppointmentListResponse
  684. // @Failure 500 {object} base.HTTPError
  685. // @Router /api/v1/rent/house/appointment [get]
  686. func (c *Controller) HouseRentAppointmentList(ctx *gin.Context) {
  687. // 解析参数
  688. req := &param_v1.HouseRentAppointmentListRequest{}
  689. parseParamTask := func() error {
  690. err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentAppointmentListQuery, nil)
  691. if err != nil {
  692. logger.Error("func",
  693. zap.String("call", "util.ShouldBind"),
  694. zap.String("error", err.Error()))
  695. return errors.ParamsError
  696. }
  697. return nil
  698. }
  699. // 业务处理
  700. handleServiceTask := func() error {
  701. tokenInfo, err := utils.GetSubjectValue(ctx)
  702. if err != nil {
  703. return err
  704. }
  705. // 响应数据
  706. resp := param_v1.HouseRentAppointmentListResponse{}
  707. rpcReq := &v1.HouseRentAppointmentListRequest{
  708. GardenId:tokenInfo.GardenId,
  709. RentId:req.RentId,
  710. HouseName:req.HouseName,
  711. Page:req.Page,
  712. PageSize:req.PageSize,
  713. }
  714. rpcRsp, err := pb.Garden.HouseRentAppointmentList(ctx, rpcReq)
  715. if err != nil {
  716. s, _ := json.MarshalToString(req)
  717. logger.Error("func",
  718. zap.String("call", "pb.Garden.HouseRentAppointmentList"),
  719. zap.String("params", s),
  720. zap.String("error", err.Error()))
  721. return errors.ErrorTransForm(err)
  722. }
  723. if rpcRsp.List == nil {
  724. rpcRsp.List = make([]*v1.HouseRentAppointmentItem, 0)
  725. }
  726. resp.Data = *rpcRsp
  727. ctx.JSON(http.StatusOK, resp)
  728. return nil
  729. }
  730. // 执行任务
  731. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  732. }
  733. //
  734. // @Summary 删除租房预约记录
  735. // @Description 删除租房预约记录
  736. // @Tags 房屋租赁
  737. // @Accept json
  738. // @Produce json
  739. // @Param token header string true "token"
  740. // @Param id query int false "预约记录id"
  741. // @Success 200 {object} v1.HouseRentAppointmentDelResponse
  742. // @Failure 500 {object} base.HTTPError
  743. // @Router /api/v1/rent/house/appointment [delete]
  744. func (c *Controller) HouseRentAppointmentDel(ctx *gin.Context) {
  745. // 解析参数
  746. req := &param_v1.HouseRentAppointmentDelRequest{}
  747. parseParamTask := func() error {
  748. err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseRentAppointmentDelQuery, nil)
  749. if err != nil {
  750. logger.Error("func",
  751. zap.String("call", "util.ShouldBind"),
  752. zap.String("error", err.Error()))
  753. return errors.ParamsError
  754. }
  755. return nil
  756. }
  757. // 业务处理
  758. handleServiceTask := func() error {
  759. tokenInfo, err := utils.GetSubjectValue(ctx)
  760. if err != nil {
  761. return err
  762. }
  763. // 响应数据
  764. resp := param_v1.HouseRentAppointmentDelResponse{}
  765. rpcReq := &v1.HouseRentAppointmentDelRequest{
  766. GardenId:tokenInfo.GardenId,
  767. Id:req.Id,
  768. }
  769. _, err = pb.Garden.HouseRentAppointmentDel(ctx, rpcReq)
  770. if err != nil {
  771. s, _ := json.MarshalToString(req)
  772. logger.Error("func",
  773. zap.String("call", "pb.Garden.HouseRentAppointmentDel"),
  774. zap.String("params", s),
  775. zap.String("error", err.Error()))
  776. return errors.ErrorTransForm(err)
  777. }
  778. ctx.JSON(http.StatusOK, resp)
  779. return nil
  780. }
  781. // 执行任务
  782. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  783. }