package com.prolog.cs.biz.inbound.controller.rcv;

import com.prolog.cs.biz.inbound.constant.ValidatorGroup.validAdd;
import com.prolog.cs.biz.inbound.dto.PageParam;
import com.prolog.cs.biz.inbound.dto.rcv.RcvHeadersSrcBillsDTO;
import com.prolog.cs.biz.inbound.service.rcv.RcvHeadersSrcBillsService;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @Description // TODO 
 * @Date 2021-03-24 
 */

@Api(tags = "收货(入库)原始单(ASN)明细")
@RestController
@RequestMapping("/rcvHeadersSrcBills/v1.0")
public class RcvHeadersSrcBillsController {

	@Resource
	private RcvHeadersSrcBillsService rcvHeadersSrcBillsService;

	/**
	* // TODO
	*/
	@ApiOperation("添加")
	@PostMapping("/add")
	public RestMessage<Object> add(@Validated(validAdd.class) @RequestBody RcvHeadersSrcBillsDTO rcvHeadersSrcBillsDTO){
		return RestMessage.newInstance(true, "addSuccess", rcvHeadersSrcBillsService.add(rcvHeadersSrcBillsDTO));
	}

	/**
	* // TODO
	*/
	@ApiOperation("条件分页")
	@GetMapping("/page")
	public RestMessage<Page<RcvHeadersSrcBillsDTO>> list(RcvHeadersSrcBillsDTO rcvHeadersSrcBillsDTO,PageParam pageParam) throws Exception {
		return RestMessage.newInstance(true, "pageSuccess", rcvHeadersSrcBillsService.findList(rcvHeadersSrcBillsDTO,pageParam));
	}

	/**
	* // TODO
	*/
	@ApiOperation("批量添加")
	@PostMapping("/batchAdd")
	public RestMessage<Object> batchAdd(@NotEmpty(message = "collection is empty") @RequestBody List<RcvHeadersSrcBillsDTO> rcvHeadersSrcBillsDTOList) {
		return RestMessage.newInstance(true, "batchAddSuccess", rcvHeadersSrcBillsService.batchAdd(rcvHeadersSrcBillsDTOList));
	}

	/**
	* // TODO
	*/
	@ApiOperation("详情(主键id)")
	@GetMapping("/findByPkId")
	public RestMessage<RcvHeadersSrcBillsDTO> findByPkId(@NotEmpty(message = "pkId is empty") String pkId){
		return RestMessage.newInstance(true, "findByPkIdSuccess", rcvHeadersSrcBillsService.findByPkId(pkId));
	}
}
