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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.domain.OrgSector;
import com.sa.ibiz.demo.demo.service.OrgSectorService;
import com.sa.ibiz.demo.demo.service.dto.OrgSectorSearchFilter;
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/orgsector")
public class OrgSectorResource
{
	@Autowired
	private OrgSectorService service;


	@PostMapping(value = "/create")
	public ResponseEntity<OrgSector> create(@Validated @RequestBody OrgSector data){
		boolean bRt=service.create(data);
		if(!bRt)
			throw new BadRequestAlertException("组织部门[create]操作发生错误","OrgSector",data.getOrgsectorid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/remove")
	public ResponseEntity<OrgSector> remove(@Validated @RequestBody OrgSector data){
		boolean bRt=service.remove(data);
		if(!bRt)
			throw new BadRequestAlertException("组织部门[remove]操作发生错误","OrgSector",data.getOrgsectorid().toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/initUserObject")
	public ResponseEntity<OrgSector> initUserObject(@Validated @RequestBody OrgSector data){
		service.initUserObject(data);
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/update")
	public ResponseEntity<OrgSector> update(@Validated @RequestBody OrgSector data){
		boolean bRt=service.update(data);
		if(!bRt)
			throw new BadRequestAlertException("组织部门[update]操作发生错误","OrgSector",data.getOrgsectorid().toString());
		return ResponseEntity.ok().body(data);
	}
	@GetMapping(value = "/{id}")
	public ResponseEntity<OrgSector> get(@Validated @PathVariable String id){
		OrgSector data=new OrgSector();
		data.setOrgsectorid(id);;
		data=service.get(data);
		if(data==null)
			throw new BadRequestAlertException("组织部门[get]操作发生错误","OrgSector",id.toString());
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/getDraft")
	public ResponseEntity<OrgSector> getDraft(@Validated @RequestBody OrgSector data){
		boolean bRt=service.getDraft(data);
		if(!bRt)
			throw new BadRequestAlertException("组织部门[getDraft]操作发生错误","OrgSector","");
		return ResponseEntity.ok().body(data);
	}
	@PostMapping(value = "/checkKey")
	public ResponseEntity<OrgSector> checkKey(@Validated @RequestBody OrgSector data){
		boolean bRt=service.checkKey(data);
		if(!bRt)
			throw new BadRequestAlertException("组织部门[checkKey]操作发生错误","OrgSector",data.getOrgsectorid().toString());
		return ResponseEntity.ok().body(data);
	}
    @PostMapping(value="/searchuserorg")
	public ResponseEntity<Page<OrgSector>> searchUserOrgPage(@Validated @RequestBody OrgSectorSearchFilter filter){
		Page<OrgSector> searchResult = service.searchUserOrg(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listuserorg")
	public ResponseEntity<List<OrgSector>> listUserOrg(@Validated @RequestBody OrgSectorSearchFilter filter){
		List<OrgSector> searchResult = service.listUserOrg(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchdefault")
	public ResponseEntity<Page<OrgSector>> searchDefaultPage(@Validated @RequestBody OrgSectorSearchFilter filter){
		Page<OrgSector> searchResult = service.searchDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listdefault")
	public ResponseEntity<List<OrgSector>> listDefault(@Validated @RequestBody OrgSectorSearchFilter filter){
		List<OrgSector> searchResult = service.listDefault(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchcurchild")
	public ResponseEntity<Page<OrgSector>> searchCurChildPage(@Validated @RequestBody OrgSectorSearchFilter filter){
		Page<OrgSector> searchResult = service.searchCurChild(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listcurchild")
	public ResponseEntity<List<OrgSector>> listCurChild(@Validated @RequestBody OrgSectorSearchFilter filter){
		List<OrgSector> searchResult = service.listCurChild(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchuserorgsector")
	public ResponseEntity<Page<OrgSector>> searchUserOrgSectorPage(@Validated @RequestBody OrgSectorSearchFilter filter){
		Page<OrgSector> searchResult = service.searchUserOrgSector(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listuserorgsector")
	public ResponseEntity<List<OrgSector>> listUserOrgSector(@Validated @RequestBody OrgSectorSearchFilter filter){
		List<OrgSector> searchResult = service.listUserOrgSector(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchorgroot")
	public ResponseEntity<Page<OrgSector>> searchOrgRootPage(@Validated @RequestBody OrgSectorSearchFilter filter){
		Page<OrgSector> searchResult = service.searchOrgRoot(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listorgroot")
	public ResponseEntity<List<OrgSector>> listOrgRoot(@Validated @RequestBody OrgSectorSearchFilter filter){
		List<OrgSector> searchResult = service.listOrgRoot(filter);
		return ResponseEntity.ok().body(searchResult);
	}
    @PostMapping(value="/searchcurorg")
	public ResponseEntity<Page<OrgSector>> searchCurOrgPage(@Validated @RequestBody OrgSectorSearchFilter filter){
		Page<OrgSector> searchResult = service.searchCurOrg(filter);
		return ResponseEntity.ok().body(searchResult);
	}

	@PostMapping(value="/listcurorg")
	public ResponseEntity<List<OrgSector>> listCurOrg(@Validated @RequestBody OrgSectorSearchFilter filter){
		List<OrgSector> searchResult = service.listCurOrg(filter);
		return ResponseEntity.ok().body(searchResult);
	}
}
