package com.ruoyi.demo.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.demo.entity.Commercial;
import com.ruoyi.demo.entity.vo.CommercialVo;
import com.ruoyi.demo.service.CommericalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/commercial")
public class CommercialController {
    @Autowired
    CommericalService commericalService;

    @PostMapping("/addCommercial")
    public R addCommercial(@RequestBody CommercialVo commercialVo){
        commericalService.addCommercial(commercialVo);
        return R.ok();
    }

    @DeleteMapping("/deleteCommercial")
    public R deleteCommercial(String[] commercialIds){
        commericalService.deleteCommercial(commercialIds);
        return R.ok();
    }

    @GetMapping("/getCommercial")
    public R getCommercial(String commercialId){
        Commercial commercial = commericalService.getCommercial(commercialId);
        return R.ok(commercial);
    }

    @GetMapping("/getCommercialList")
    public R getCommercialList(CommercialVo commercialVo){
        HashMap commercialList = commericalService.getCommercialList(commercialVo);
        return R.ok(commercialList);
    }

    @GetMapping("/getCommercialName")
    public R getCommercialName(){
        List<Commercial> commercialName = commericalService.getCommercialName();
        return R.ok(commercialName);
    }
}
