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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.DataSyncOut2;
import com.sa.ibiz.demo.demo.service.DataSyncOut2Service;
import com.sa.ibiz.demo.demo.service.dto.DataSyncOut2SearchFilter;
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/datasyncout2")
public class DataSyncOut2Resource
{
	@Autowired
	private DataSyncOut2Service service;


	@PostMapping(value = "/create")
	public ResponseEntity<DataSyncOut2> create(@Validated @RequestBody DataSyncOut2 data){
		boolean bRt=service.create(data);
		if(!bRt)
			throw new BadRequestAlertException("数据同步发送队列2[create]操作发生错误","DataSyncOut2",data.getDatasyncout2id().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/getDraft")
	public ResponseEntity<DataSyncOut2> getDraft(@Validated @RequestBody DataSyncOut2 data){
		boolean bRt=service.getDraft(data);
		if(!bRt)
			throw new BadRequestAlertException("数据同步发送队列2[getDraft]操作发生错误","DataSyncOut2","");
		return ResponseEntity.ok().body(data);
	}
	@GetMapping(value = "/{id}")
	public ResponseEntity<DataSyncOut2> get(@Validated @PathVariable String id){
		DataSyncOut2 data=new DataSyncOut2();
		data.setDatasyncout2id(id);;
		data=service.get(data);
		if(data==null)
			throw new BadRequestAlertException("数据同步发送队列2[get]操作发生错误","DataSyncOut2",id.toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/remove")
	public ResponseEntity<DataSyncOut2> remove(@Validated @RequestBody DataSyncOut2 data){
		boolean bRt=service.remove(data);
		if(!bRt)
			throw new BadRequestAlertException("数据同步发送队列2[remove]操作发生错误","DataSyncOut2",data.getDatasyncout2id().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/checkKey")
	public ResponseEntity<DataSyncOut2> checkKey(@Validated @RequestBody DataSyncOut2 data){
		boolean bRt=service.checkKey(data);
		if(!bRt)
			throw new BadRequestAlertException("数据同步发送队列2[checkKey]操作发生错误","DataSyncOut2",data.getDatasyncout2id().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/update")
	public ResponseEntity<DataSyncOut2> update(@Validated @RequestBody DataSyncOut2 data){
		boolean bRt=service.update(data);
		if(!bRt)
			throw new BadRequestAlertException("数据同步发送队列2[update]操作发生错误","DataSyncOut2",data.getDatasyncout2id().toString());
		return ResponseEntity.ok().body(data);
	}
    @PostMapping(value="/searchdefault")
	public ResponseEntity<Page<DataSyncOut2>> searchDefaultPage(@Validated @RequestBody DataSyncOut2SearchFilter filter){
		Page<DataSyncOut2> searchResult = service.searchDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}

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