package cn.iocoder.yudao.module.jx.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.jx.core.controller.BaseController;
import cn.iocoder.yudao.module.jx.domain.SopeNess;
import cn.iocoder.yudao.module.jx.service.ISopeNessService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 经营范围Controller
 *
 * @author ruoyi
 * @date 2024-05-23
 */
@RestController
@RequestMapping("/system/ness")
public class SopeNessController extends BaseController
{
    @Autowired
    private ISopeNessService sopeNessService;

    /**
     * 查询经营范围列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(SopeNess sopeNess)
    {
        Page<SopeNess> page = new Page<>(sopeNess.getPageNum(), sopeNess.getPageSize());
        IPage<SopeNess> sopeNessIPage = sopeNessService.selectSopeNessList(sopeNess, page);
        return CommonResult.success(sopeNessIPage);
        //return getDataTable(list);
    }

    /**
     * 导出经营范围列表
     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SopeNess sopeNess)
//    {
//
//        List<SopeNess> list = sopeNessService.selectSopeNessList(sopeNess);
//        ExcelUtil<SopeNess> util = new ExcelUtil<SopeNess>(SopeNess.class);
//        util.exportExcel(response, list, "经营范围数据");
//    }

    /**
     * 获取经营范围详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(sopeNessService.selectSopeNessById(id));
    }

    /**
     * 新增经营范围
     */
    @PostMapping
    public CommonResult add(@RequestBody SopeNess sopeNess)
    {
        return toAjax(sopeNessService.insertSopeNess(sopeNess));
    }

    /**
     * 修改经营范围
     */
    @PutMapping
    public CommonResult edit(@RequestBody SopeNess sopeNess)
    {
        return toAjax(sopeNessService.updateSopeNess(sopeNess));
    }

    /**
     * 删除经营范围
     */
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sopeNessService.deleteSopeNessByIds(ids));
    }
}
