package com.ruoyi.demo.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.demo.entity.*;
import com.ruoyi.demo.entity.vo.WdInfoVo;
import com.ruoyi.demo.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/recycle/wd")
public class WdRecycleController {


    @Autowired
    WdRecycleService wdRecycleService;

    @Autowired
    StoreWdService storeWdService;

    @Autowired
    HouseWdService houseWdService;

    @Autowired
    BuildWdService buildWdService;

    @Autowired
    TrafficWdService trafficWdService;

    @Autowired
    EnterpriseWdService enterpriseWdService;


    //获取网点回收站列表
    @GetMapping("/list")
    public R list(WdInfoVo wdInfoVo){
        HashMap<String, Object> list = wdRecycleService.list(wdInfoVo);
        return R.ok(list);
    }

    //获取门店网点类型明细
    @GetMapping("/storeWdInfo")
    public R storeWdInfo(String wdId){
        StoreWd storeWd = storeWdService.storeWdInfo(wdId);
        return R.ok(storeWd);
    }

    //获取小区网点类型明细
    @GetMapping("/houseWdInfo")
    public R houseWddInfo(String wdId){
        HouseWd houseWd = houseWdService.houseWddInfo(wdId);
        return R.ok(houseWd);
    }

    //获取楼宇网点类型明细
    @GetMapping("/buildWdInfo")
    public R buildWdInfo(String wdId){
        BuildWd buildWd = buildWdService.buildWdInfo(wdId);
        return R.ok(buildWd);
    }

    //获取交通设施网点类型明细
    @GetMapping("/trafficWdInfo")
    public R trafficWdInfo(String wdId){
        TrafficWd trafficWd = trafficWdService.trafficWdInfo(wdId);
        return R.ok(trafficWd);
    }

    //获取公司网点类型明细
    @GetMapping("/enterpriseWdInfo")
    public R enterpriseWdInfo(String wdId){
        EnterpriseWd enterpriseWd = enterpriseWdService.enterpriseWdInfo(wdId);
        return R.ok(enterpriseWd);
    }

    //移除
    @DeleteMapping("/deleteWd/{wdId}")
    public R deleteWd(@PathVariable("wdId") String wdId){
        wdRecycleService.deleteWd(wdId);
        return R.ok();
    }

    //恢复
    @PutMapping("/recoverWd")
    public R recoverWd(@RequestBody HashMap<String,String> hashMap){
        if (hashMap.get("wdId") == null)
            return R.fail(400,"wdId不能为空");

        wdRecycleService.recoverWd(hashMap.get("wdId"));
        return R.ok();
    }



}
