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

import com.prolog.cs.biz.inbound.constant.ValidatorGroup.validAdd;
import com.prolog.cs.biz.inbound.constant.ValidatorGroup.validEdit;
import com.prolog.cs.biz.inbound.dto.PageParam;
import com.prolog.cs.biz.inbound.dto.rqc.RqcLinePicDTO;
import com.prolog.cs.biz.inbound.service.rqc.RqcLinePicService;
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 = "质检单图片")
@RestController
@RequestMapping("/rqcLinePic")
public class RqcLinePicController {

	@Resource
	private RqcLinePicService rqcLinePicService;

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

	/**
	* // TODO
	*/
	@ApiOperation("编辑")
	@PostMapping("/edit")
	public RestMessage<Object> edit(@Validated(validEdit.class) @RequestBody RqcLinePicDTO rqcLinePicDTO){
		return RestMessage.newInstance(true, "editSuccess", rqcLinePicService.edit(null,rqcLinePicDTO));
	}

	/**
	* // TODO
	*/
	@ApiOperation("删除(主键id集合)")
	@PostMapping("/delIds")
	public RestMessage<Object> delIds(@NotEmpty(message = "collection is empty") @RequestBody List<String> pkIdList) {
		return RestMessage.newInstance(true, "delIdsSuccess", rqcLinePicService.delIds(pkIdList));
	}

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

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

	/**
	* // TODO
	*/
	@ApiOperation("批量编辑")
	@PostMapping("/batchEdit")
	public RestMessage<Object> batchEdit(@NotEmpty(message = "collection is empty")@RequestBody List<RqcLinePicDTO> rqcLinePicDTOList) {
		return RestMessage.newInstance(true, "batchEditSuccess", rqcLinePicService.batchEdit(rqcLinePicDTOList));
	}

//	/**
//	* // TODO
//	*/
//	@ApiOperation("condition findAll")
//	@PostMapping("/findAll")
//	public RestMessage<List<RqcLinePicDTO>> findAll(@RequestBody(required = false) RqcLinePicDTO rqcLinePicDTO) {
//		return RestMessage.newInstance(true, "listAllSuccess", rqcLinePicService.findAll(rqcLinePicDTO));
//	}
	/**
	* // TODO
	*/
	@ApiOperation("详情(主键id)")
	@GetMapping("/findByPkId")
	public RestMessage<RqcLinePicDTO> findByPkId(@NotEmpty(message = "pkId is empty") String pkId){
		return RestMessage.newInstance(true, "findByPkIdSuccess", rqcLinePicService.findByPkId(pkId));
	}
}
