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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.DataSyncIn2;
import com.sa.ibiz.demo.demo.service.DataSyncIn2Service;
import com.sa.ibiz.demo.demo.service.dto.DataSyncIn2SearchFilter;
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/datasyncin2")
public class DataSyncIn2Resource
{
	@Autowired
	private DataSyncIn2Service service;


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

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