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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.WFWorkList;
import com.sa.ibiz.demo.demo.service.WFWorkListService;
import com.sa.ibiz.demo.demo.service.dto.WFWorkListSearchFilter;
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/wfworklist")
public class WFWorkListResource
{
	@Autowired
	private WFWorkListService service;


	@PostMapping(value = "/create")
	public ResponseEntity<WFWorkList> create(@Validated @RequestBody WFWorkList data){
		boolean bRt=service.create(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流工作列表[create]操作发生错误","WFWorkList",data.getWfworklistid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/update")
	public ResponseEntity<WFWorkList> update(@Validated @RequestBody WFWorkList data){
		boolean bRt=service.update(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流工作列表[update]操作发生错误","WFWorkList",data.getWfworklistid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/getDraft")
	public ResponseEntity<WFWorkList> getDraft(@Validated @RequestBody WFWorkList data){
		boolean bRt=service.getDraft(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流工作列表[getDraft]操作发生错误","WFWorkList","");
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/checkKey")
	public ResponseEntity<WFWorkList> checkKey(@Validated @RequestBody WFWorkList data){
		boolean bRt=service.checkKey(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流工作列表[checkKey]操作发生错误","WFWorkList",data.getWfworklistid().toString());
		return ResponseEntity.ok().body(data);
	}
	@GetMapping(value = "/{id}")
	public ResponseEntity<WFWorkList> get(@Validated @PathVariable String id){
		WFWorkList data=new WFWorkList();
		data.setWfworklistid(id);;
		data=service.get(data);
		if(data==null)
			throw new BadRequestAlertException("工作流工作列表[get]操作发生错误","WFWorkList",id.toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/remove")
	public ResponseEntity<WFWorkList> remove(@Validated @RequestBody WFWorkList data){
		boolean bRt=service.remove(data);
		if(!bRt)
			throw new BadRequestAlertException("工作流工作列表[remove]操作发生错误","WFWorkList",data.getWfworklistid().toString());
		return ResponseEntity.ok().body(data);
	}
    @PostMapping(value="/searchmydb")
	public ResponseEntity<Page<WFWorkList>> searchMyDBPage(@Validated @RequestBody WFWorkListSearchFilter filter){
		Page<WFWorkList> searchResult = service.searchMyDB(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listmydb")
	public ResponseEntity<List<WFWorkList>> listMyDB(@Validated @RequestBody WFWorkListSearchFilter filter){
		List<WFWorkList> searchResult = service.listMyDB(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchdefault")
	public ResponseEntity<Page<WFWorkList>> searchDefaultPage(@Validated @RequestBody WFWorkListSearchFilter filter){
		Page<WFWorkList> searchResult = service.searchDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}

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