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

import com.prolog.cs.biz.inbound.constant.ValidatorGroup.validAdd;
import com.prolog.cs.biz.inbound.dto.rqc.RqcReLinesDTO;
import com.prolog.cs.biz.inbound.service.rqc.RqcReLinesService;
import com.prolog.cs.biz.inbound.vo.RqcDQueryVO;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.utils.AssertUtils;
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 java.util.List;

/**
 * @Description
 * @Date 2021-04-02
 */

@Api(tags = "复检明细行")
@RestController
@RequestMapping("/rqcReLines")
public class RqcReLinesController {

	@Resource
	private RqcReLinesService rqcReLinesService;

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

	/**
	 *
	 */
	@ApiOperation("批量添加")
	@PostMapping("/batchAdd")
	public RestMessage<Object> batchAdd(@RequestBody List<RqcReLinesDTO> rqcReLinesDTOList) {
		return RestMessage.newInstance(true, "batchAddSuccess", rqcReLinesService.batchAdd(rqcReLinesDTOList));
	}

	/**
	 * // TODO
	 */
	@ApiOperation("详情(主键id)")
	@GetMapping("/findByPkId")
	public RestMessage<RqcReLinesDTO> findByPkId(String pkId) {
		AssertUtils.isNotBlank(pkId, "主键id不可为空");
		return RestMessage.newInstance(true, "findByPkIdSuccess", rqcReLinesService.findByPkId(pkId));
	}

	/**
	 * // TODO
	 */
	@ApiOperation("条件分页")
	@GetMapping("/page")
	public RestMessage<Page<RqcReLinesDTO>> list(RqcDQueryVO rqcDQueryVO) throws Exception {
		return RestMessage.newInstance(true, "pageSuccess", rqcReLinesService.findList(rqcDQueryVO));
	}

//	/**
//	 * 
//	 */
//	@ApiOperation("详情(主键id)")
//	@GetMapping("/findByPkId")
//	public RestMessage<RqcReLinesDTO> findByPkId(@NotEmpty(message = "pkId is empty") String pkId) {
//		return RestMessage.newInstance(true, "findByPkIdSuccess", rqcReLinesService.findByPkId(pkId));
//	}
//	
//	/**
//	 * 
//	 */
//	@ApiOperation("条件分页")
//	@GetMapping("/page")
//	public RestMessage<Page<RqcReLinesDTO>> list(RqcReLinesDTO rqcReLinesDTO, PageParam pageParam) throws Exception {
//		return RestMessage.newInstance(true, "pageSuccess", rqcReLinesService.findList(rqcReLinesDTO, pageParam));
//	}
}
