package com.ruoyi.web.work.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.work.domain.Packages;
import com.ruoyi.web.work.domain.dto.PackagesDto;
import com.ruoyi.web.work.domain.vo.PackagesListVo;
import com.ruoyi.web.work.service.IPackagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.rmi.ServerException;
import java.util.List;

/**
 * 接包管理
 *
 * @author lsw
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/app/packages")
public class Api_PackagesController extends BaseController {
    @Autowired
    private IPackagesService packagesService;

    @GetMapping("/list")
    public TableDataInfo list(Packages packages) {
        startPage();
        List<PackagesListVo> list = packagesService.selectPackagesList(packages);
        return getDataTable(list);
    }

    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody Packages packages) throws ServerException {
        return packagesService.add(packages);
    }

    @PostMapping("/voucher")
    public AjaxResult voucher(@Validated @RequestBody PackagesDto dto) throws ServerException {
        return packagesService.voucher(dto);
    }
}
