package com.ruoyi.wx.web.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.recovery.domain.RecStall;
import com.ruoyi.wx.web.domain.dto.RecycleDto;
import com.ruoyi.wx.web.domain.vo.RecycleVo;
import com.ruoyi.wx.web.service.IWxRecycleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 回收页服务
 */
@RestController
@RequestMapping("/wx/recycle")
@Slf4j
public class WxRecycleController {
    @Autowired
    private IWxRecycleService wxRecycleService;

    @GetMapping("/index")
    public AjaxResult getIndex() {
        try {
            return wxRecycleService.getIndex();
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    // 首次查询3种类型
    @GetMapping("/info/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        try {
            List<RecycleVo> recycleVoList = wxRecycleService.getInfoList(id);
            return AjaxResult.success(recycleVoList);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }

    // 精确根据城市、类型和档口类型来查询
    @PostMapping("/info")
    public AjaxResult cityList(@RequestBody RecycleDto recycleDto) {
        try {
            List<RecStall> recycleVoList = wxRecycleService.getCityRecycle(recycleDto);
            return AjaxResult.success(recycleVoList);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }
}
