package com.xxfc.platform.app.rest;

import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.xxfc.platform.app.biz.CofigBiz;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.campsite.feign.CampsiteFeign;
import com.xxfc.platform.tour.feign.TourFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("home")
@IgnoreClientToken
@Slf4j
public class AppHomeController extends BaseController<CofigBiz,Cofig> {


    @Autowired
    CampsiteFeign campsiteFeign;

    @Autowired
    TourFeign tourFeign;

    @RequestMapping(value ="/app/unauth/goodList",method = RequestMethod.GET)
    @IgnoreUserToken
    public ObjectRestResponse<List<GoodDataVO>> goodList(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "limit",defaultValue = "4") Integer limit,
            @RequestParam(value = "type",defaultValue = "1") Integer type
    ){
        List<GoodDataVO> list=new ArrayList<>();
        if (type==2){
            list=tourFeign.goodList(page,limit);
        }else if (type==3){
            list=campsiteFeign.goodList(page,limit);
        }
        return  new ObjectRestResponse<>().rel(true).data(list);
    }
}