package org.jeecg.api.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.api.bean.CommonHomeBo;
import org.jeecg.api.bean.HousePageList;
import org.jeecg.api.service.ApiIndexService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.commonHome.entity.CommonHome;
import org.jeecg.modules.commonNews.entity.CommonNews;
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

@Api(tags="项目通用-首页相关")
@RestController
@RequestMapping("/common_index")
@Slf4j
public class ApiIndexController {


    @Resource
    private ApiIndexService apiIndexService;

    //获取通知公告
    @ApiOperation(value="获取通知公告", notes="获取通知公告")
    @GetMapping(value = "/getNotice")
    public Result<?> getNotice()
    {
        return apiIndexService.getNotice();
    }


    //获取租房分类类型
    @ApiOperation(value="获取租房分类类型", notes="获取租房分类类型")
    @GetMapping(value = "/getHouseType")
    public Result<?> getHouseType()
    {
        return apiIndexService.getHouseType();
    }


    //根据租房分类信息获取租房带分页列表信息
    @ApiOperation(value="根据租房分类信息获取租房带分页列表信息", notes="根据租房分类信息获取租房带分页列表信息")
    @GetMapping(value = "/getHousePageList")
    public Result<?> getHousePageList
    (
            HousePageList bean,
//            String priceId,
//            String  areaId,
//            String yearId,
//            String typeId,
            HttpServletRequest req,
            CommonHomeBo bo
    )
    {
        return apiIndexService.getHousePageList(bean, bo, req);
//        return apiIndexService.getHousePageList(bean,priceId,areaId,yearId,typeId,req);
    }


    //根据租房详情id获取房源详情
    @ApiOperation(value="根据租房详情id获取房源详情", notes="根据租房详情id获取房源详情")
    @GetMapping(value = "/getHouseDetail")
    public Result<?> getHouseDetail(String houseId)
    {
        return apiIndexService.getHouseDetail(houseId);
    }


    //查询我发布的房源列表带分页
    @ApiOperation(value="查询我发布的房源列表带分页", notes="查询我发布的房源列表带分页")
    @GetMapping(value = "/getMyHousePageList")
    public Result<?> getMyHousePageList(@RequestHeader("X-Access-Token") String token,HousePageList bean)
    {
        return apiIndexService.getMyHousePageList(token,bean);
    }


    //查询经济人发布的
    @ApiOperation(value="查询经济人发布的", notes="查询经济人发布的")
    @GetMapping(value = "/getMyVipPageList")
    public Result<?> getMyVipPageList(@RequestHeader("X-Access-Token") String token,HousePageList bean)
    {
        return apiIndexService.getMyHousePageList(token,bean);
    }






    //发布或编辑房源
    @ApiOperation(value="发布或编辑房源", notes="发布或编辑房源")
    @PostMapping(value = "/saveOrUpdateHouse")
    public Result<?> saveOrUpdateHouse(@RequestHeader("X-Access-Token") String token, CommonHome home)
    {
        return apiIndexService.saveOrUpdateHouse(token,home);
    }


    //删除房源信息
    @ApiOperation(value="删除房源信息", notes="删除房源信息")
    @GetMapping(value = "/deleteHouse")
    public Result<?> deleteHouse(@RequestHeader("X-Access-Token") String token,String houseId)
    {
        return apiIndexService.deleteHouse(token,houseId);
    }








    //经纪人账号密码登录
    @ApiOperation(value="经纪人账号密码登录", notes="经纪人账号密码登录")
    @PostMapping(value = "/login")
    public Result<?> login(@RequestHeader("X-Access-Token") String token,String username,String password)
    {
        return apiIndexService.login(token,username,password);
    }


    //房东输入邀请码登录
    @ApiOperation(value="房东输入邀请码登录", notes="房东输入邀请码登录")
    @PostMapping(value = "/loginByInviteCode")
    public Result<?> loginByInviteCode(@RequestHeader("X-Access-Token") String token,String inviteCode)
    {
        return apiIndexService.loginByInviteCode(token,inviteCode);
    }

    //获取首页图标的接口
    @ApiOperation(value="获取首页图标的接口", notes="获取首页图标的接口")
    @GetMapping(value = "/getIndexIcon")
    public Result<?> getIndexIcon()
    {
        return apiIndexService.getIndexIcon();
    }


    //获取发现列表页面数据带分页
    @ApiOperation(value="获取发现列表页面数据带分页", notes="获取发现列表页面数据带分页")
    @GetMapping(value = "/getFindPageList")
    public Result<?> getFindPageList(HousePageList bean)
    {
        return apiIndexService.getFindPageList(bean);
    }


    //发布或编辑发现
    @ApiOperation(value="发布或编辑发现", notes="发布或编辑发现")
    @PostMapping(value = "/saveOrUpdateFind")
    public Result<?> saveOrUpdateFind(@RequestHeader("X-Access-Token") String token, CommonNews news)
    {
        return apiIndexService.saveOrUpdateFind(token,news);
    }




    //获取发现列表详情
    @ApiOperation(value="获取发现列表详情", notes="获取发现列表详情")
    @GetMapping(value = "/getFindDetail")
    public Result<?> getFindDetail(String houseId)
    {
        return apiIndexService.getFindDetail(houseId);
    }




}
