package com.sa.ibiz.demo.demo.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.WFStepActor;
import com.sa.ibiz.demo.demo.service.WFStepActorService;
import com.sa.ibiz.demo.demo.service.dto.WFStepActorSearchFilter;
import com.sa.ibiz.demo.ibizutil.errors.BadRequestAlertException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigInteger;
import java.util.List;

@RestController
@RequestMapping("/demo/wfstepactor")
public class WFStepActorResource
{
	@Autowired
	private WFStepActorService service;


	@GetMapping(value = "/{id}")
	public ResponseEntity<WFStepActor> get(@Validated @PathVariable String id){
		WFStepActor data=new WFStepActor();
		data.setWfstepactorid(id);;
		data=service.get(data);
		if(data==null)
			throw new BadRequestAlertException("工作流步骤操作者[get]操作发生错误","WFStepActor",id.toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/getDraft")
	public ResponseEntity<WFStepActor> getDraft(@Validated @RequestBody WFStepActor data){
		boolean bRt=service.getDraft(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流步骤操作者[getDraft]操作发生错误","WFStepActor","");
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/remindSave")
	public ResponseEntity<WFStepActor> remindSave(@Validated @RequestBody WFStepActor data){
		service.remindSave(data);
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/checkKey")
	public ResponseEntity<WFStepActor> checkKey(@Validated @RequestBody WFStepActor data){
		boolean bRt=service.checkKey(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流步骤操作者[checkKey]操作发生错误","WFStepActor",data.getWfstepactorid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/update")
	public ResponseEntity<WFStepActor> update(@Validated @RequestBody WFStepActor data){
		boolean bRt=service.update(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流步骤操作者[update]操作发生错误","WFStepActor",data.getWfstepactorid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/remove")
	public ResponseEntity<WFStepActor> remove(@Validated @RequestBody WFStepActor data){
		boolean bRt=service.remove(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流步骤操作者[remove]操作发生错误","WFStepActor",data.getWfstepactorid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/create")
	public ResponseEntity<WFStepActor> create(@Validated @RequestBody WFStepActor data){
		boolean bRt=service.create(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流步骤操作者[create]操作发生错误","WFStepActor",data.getWfstepactorid().toString());
		return ResponseEntity.ok().body(data);
	}
    @PostMapping(value="/searchdefault")
	public ResponseEntity<Page<WFStepActor>> searchDefaultPage(@Validated @RequestBody WFStepActorSearchFilter filter){
		Page<WFStepActor> searchResult = service.searchDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listdefault")
	public ResponseEntity<List<WFStepActor>> listDefault(@Validated @RequestBody WFStepActorSearchFilter filter){
		List<WFStepActor> searchResult = service.listDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}
}
