package com.ruoyi.demo.controller;

import com.github.pagehelper.PageInfo;

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

import java.util.HashMap;

@RestController
@RequestMapping("/recycle/brand")
public class BrandRecycleController {
    @Autowired
    BrandRecycleService brandRecycleService;

    @GetMapping("/list")
    public R list(BrandVo brandVo){
        PageInfo<Brand> list = brandRecycleService.list(brandVo);
        return R.ok(list);
    }

    //移除
    @DeleteMapping("/deleteBrand/{brandId}")
    public R deleteBrand(@PathVariable("brandId") String brandId){
        brandRecycleService.deleteBrand(brandId);
        return R.ok();
    }

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

        brandRecycleService.recoverBrand(hashMap.get("brandId"));
        return R.ok();
    }

}
