package cn.iocoder.yudao.module.inspection.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.core.controller.BaseController;
import cn.iocoder.yudao.module.inspection.entity.ShopInspectionCategory;
import cn.iocoder.yudao.module.inspection.service.ShopInspectionCategoryService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

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

/**
 * (ShopInspectionCategory)表控制层
 *
 * @author makejava
 * @since 2023-08-01 19:59:23
 */
@RestController
@RequestMapping("/admin-api/system/shopInspectionCategory")
public class ShopInspectionCategoryController  extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ShopInspectionCategoryService shopInspectionCategoryService;

    /**
     * 分页查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping("/list")
    public CommonResult list(ShopInspectionCategory shopInspectionCategory,@RequestParam("pageNum")Integer pageNum,@RequestParam("pageSize")Integer pageSize)
    {
        PageParam pageParam = new PageParam();
        pageParam.setPageNo(pageNum);
        pageParam.setPageSize(pageSize);
        PageResult<ShopInspectionCategory>  res =  this.shopInspectionCategoryService.listVo(shopInspectionCategory,pageParam);
        return CommonResult.success(res);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/getById")
    public CommonResult selectOne(@Param("id") Long id) {
        return CommonResult.success(this.shopInspectionCategoryService.getByIdVo(id));
    }

    /**
     * 新增数据
     *
     * @param shopInspectionCategory 实体对象
     * @return 新增结果
     */
    @PostMapping("/add")
    public CommonResult add(@RequestBody ShopInspectionCategory shopInspectionCategory) {
        this.shopInspectionCategoryService.saveVo(shopInspectionCategory);
        return success();
    }

    /**
     * 修改数据
     *
     * @param shopInspectionCategory 实体对象
     * @return 修改结果
     */
    @PostMapping("/edit")
    public CommonResult update(@RequestBody ShopInspectionCategory shopInspectionCategory) {
        this.shopInspectionCategoryService.updateByIdVo(shopInspectionCategory);
        return success();
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @PostMapping("/del")
    public CommonResult delete(@RequestParam("idList") List<Long> idList) throws Exception {
        this.shopInspectionCategoryService.removeByIdsVo(idList);
        return success();
    }
}

