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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.WFReminder;
import com.sa.ibiz.demo.demo.service.WFReminderService;
import com.sa.ibiz.demo.demo.service.dto.WFReminderSearchFilter;
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/wfreminder")
public class WFReminderResource
{
	@Autowired
	private WFReminderService service;


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

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