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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.WFActor;
import com.sa.ibiz.demo.demo.service.WFActorService;
import com.sa.ibiz.demo.demo.service.dto.WFActorSearchFilter;
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/wfactor")
public class WFActorResource
{
	@Autowired
	private WFActorService service;


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

	@PostMapping(value="/listdefault")
	public ResponseEntity<List<WFActor>> listDefault(@Validated @RequestBody WFActorSearchFilter filter){
		List<WFActor> searchResult = service.listDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchindexder")
	public ResponseEntity<Page<WFActor>> searchIndexDERPage(@Validated @RequestBody WFActorSearchFilter filter){
		Page<WFActor> searchResult = service.searchIndexDER(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listindexder")
	public ResponseEntity<List<WFActor>> listIndexDER(@Validated @RequestBody WFActorSearchFilter filter){
		List<WFActor> searchResult = service.listIndexDER(filter);
		return ResponseEntity.ok().body(searchResult);
	}
}
