package com.activiti6.controller.activiti;


import com.activiti6.domain.AjaxResult;
import com.activiti6.domain.FormdataForm;
import com.activiti6.domain.MyFormData;
import com.activiti6.domain.TableDataInfo;
import com.activiti6.service.activiti.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
    private MyFormDataService myFormDataService;

    @PutMapping
    public AjaxResult add(@RequestBody FormdataForm myFormData) {
        myFormDataService.add(myFormData, myFormData.getUserId());
        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();
    }
}
