package com.xtd.project.activiti.controller;

import com.xtd.framework.web.controller.BaseController;
import com.xtd.framework.web.domain.AjaxResult;
import com.xtd.framework.web.page.TableDataInfo;
import com.xtd.project.activiti.domain.MyFormData;
import com.xtd.project.activiti.service.MyFormDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/formdata")
public class FormDataController extends BaseController {

    @Autowired
    MyFormDataService myFormDataService;

    @PutMapping
    public AjaxResult add(@RequestBody MyFormData myFormData) {
        myFormDataService.add(myFormData);
        return AjaxResult.success();
    }

    @GetMapping("list")
    public TableDataInfo list(MyFormData myFormData) {
        startPage();
        List<MyFormData> list = myFormDataService.list(myFormData);
        return getDataTable(list);
    }
    @GetMapping("{id}")
    public AjaxResult get(@PathVariable Long id) {
        MyFormData myFormData = myFormDataService.get(id);
        return AjaxResult.success(myFormData);
    }

    @PostMapping
    public AjaxResult update(@RequestBody MyFormData myFormData) {
        myFormDataService.update(myFormData);
        return AjaxResult.success();
    }
    @DeleteMapping
    public AjaxResult delete(@RequestBody List<Long> ids) {
        myFormDataService.delete(ids);
        return AjaxResult.success();
    }
}
