package com.om.controller.admin;


import com.om.entity.dto.BrandQueryPageDTO;
import com.om.entity.dto.DistributorDTO;
import com.om.entity.dto.DistributorQueryPageDTO;
import com.om.entity.vo.BrandQueryPageVO;
import com.om.entity.vo.BrandVO;
import com.om.entity.vo.DistributorQueryPageVO;
import com.om.entity.vo.DistributorVO;
import com.om.service.IDistributorService;
import com.om.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 修理厂信息表 前端控制器
 * </p>
 *
 * @author bmmx
 * @since 2024-02-08
 */
@RestController
@Api(tags = "维修厂管理相关接口")
@RequestMapping("/web/distributor/info")
public class DistributorController {

    @Resource
    private IDistributorService distributorService;


    @PostMapping("/create")
    @ApiOperation("新增维修厂信息")
    public Result createDistributor(@RequestBody DistributorDTO dto){
        return distributorService.createDistributor(dto);
    }

    @GetMapping("/getById")
    @ApiOperation("根据id查询维修厂信息")
    public Result<DistributorVO> queryDistributorById(@RequestParam Integer id){
        return distributorService.queryDistributorById(id);
    }

    @GetMapping("/delete")
    @ApiOperation("根据id删除维修厂信息")
    public Result deleteDistributorById(@RequestParam Integer id){
        return distributorService.deleteDistributorById(id);
    }


    @GetMapping("/list")
    @ApiOperation("查询维修厂信息列表")
    public Result<List<DistributorVO>> queryList(){
        return distributorService.queryList();
    }

    @GetMapping("/upStatus")
    @ApiOperation("修改状态")
    public Result upStatus(@RequestParam Integer id ,@RequestParam Integer status){
        return distributorService.upStatus(id,status);
    }

    @PostMapping("/updateById")
    @ApiOperation("修改维修厂信息")
    public Result updateDistributor(@RequestBody DistributorDTO dto){
        return distributorService.updateDistributor(dto);
    }

    @PostMapping("/listPage")
    @ApiOperation("分页查询维修厂信息列表")
    public Result<DistributorQueryPageVO> queryPageList(@RequestBody DistributorQueryPageDTO dto) {
        return distributorService.queryPageList(dto);
    }
}
