package com.ruoyi.interfaces.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.interfaces.core.page.Page;
import com.ruoyi.interfaces.domain.PtServiceReturn;
import com.ruoyi.interfaces.service.PtServiceReturnService;
import io.swagger.annotations.ApiOperation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/pt/service/return")
public class PtServiceReturnController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private PtServiceReturnService ptServiceReturnService;

    @ApiOperation("添加数据")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public AjaxResult insert(PtServiceReturn ptServiceReturn) {
        return AjaxResult.check(ptServiceReturnService.insert(ptServiceReturn) > 0);
    }

    @ApiOperation("添加数据")
    @RequestMapping(value = "/addList", method = RequestMethod.POST)
    public AjaxResult inserts(@RequestBody List<PtServiceReturn> returnList) {
        return AjaxResult.check(ptServiceReturnService.inserts(returnList) > 0);
    }

    @ApiOperation("数据列表")
    @RequestMapping(value = "/list")
    public Page list(@RequestParam String srvId,
                     @RequestParam(required = false, defaultValue = "1") int page,
                     @RequestParam(required = false, defaultValue = "100") int rows) {
        return ptServiceReturnService.list(srvId, page, rows);
    }

    @ApiOperation("数据列表")
    @GetMapping(value = "/list/{srvId}")
    public AjaxResult listBysrvId(@PathVariable String srvId) {
        return AjaxResult.success(ptServiceReturnService.listBysrvId(srvId));
    }

    @ApiOperation("根据主键删除数据")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    public AjaxResult delete(@RequestParam String srvId, @RequestParam String paramCode) {
        return AjaxResult.check(ptServiceReturnService.delete(srvId, paramCode) > 0);
    }
}
