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

import com.prolog.cs.biz.inbound.dto.PageParam;
import com.prolog.cs.biz.inbound.dto.rqc.RqcStDTO;
import com.prolog.cs.biz.inbound.service.rqc.RqcStService;
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.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 抽检策略
 * @Date 2021-12-24
 */

@Api(tags = "抽检策略")
@RestController
@RequestMapping("/wmsInRqcSt")
public class WmsInRqcStController {

	@Resource
	private RqcStService wmsInRqcStService;

	/**
	 * 新增抽检策略
	 */
	@ApiOperation("新增抽检策略")
	@PostMapping("/add")
	public RestMessage<Object> add(@RequestBody RqcStDTO RqcStDTO) {
		return RestMessage.newInstance(true, "addSuccess", wmsInRqcStService.add(RqcStDTO));
	}

	/**
	 * 编辑抽检策略
	 */
	@ApiOperation("编辑抽检策略")
	@PostMapping("/edit")
	public RestMessage<Object> edit(@RequestBody RqcStDTO RqcStDTO) {
		return RestMessage.newInstance(true, "editSuccess", wmsInRqcStService.edit(null, RqcStDTO));
	}

	/**
	 * 删除抽检策略(批量)
	 */
	@ApiOperation("删除抽检策略(批量)")
	@PostMapping("/delIds")
	public RestMessage<Object> delIds(@RequestBody List<String> pkIdList) {
		return RestMessage.newInstance(true, "delIdsSuccess", wmsInRqcStService.delIds(pkIdList));
	}

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

	/**
	 * 批量新增
	 */
	@ApiOperation("批量新增")
	@PostMapping("/batchAdd")
	public RestMessage<Object> batchAdd(@RequestBody List<RqcStDTO> wmsInRqcStDTOList) {
		return RestMessage.newInstance(true, "batchAddSuccess", wmsInRqcStService.batchAdd(wmsInRqcStDTOList));
	}

	/**
	 * 批量编辑
	 */
	@ApiOperation("批量编辑")
	@PostMapping("/batchEdit")
	public RestMessage<Object> batchEdit(@RequestBody List<RqcStDTO> wmsInRqcStDTOList) {
		return RestMessage.newInstance(true, "batchEditSuccess", wmsInRqcStService.batchEdit(wmsInRqcStDTOList));
	}

	/**
	 * 条件查询全部
	 */
	@ApiOperation("条件查询全部")
	@PostMapping("/findAll")
	public RestMessage<List<RqcStDTO>> findAll(@RequestBody(required = false) RqcStDTO RqcStDTO) {
		return RestMessage.newInstance(true, "listAllSuccess", wmsInRqcStService.findAll(RqcStDTO));
	}

	/**
	 * 详情查询(主键id)
	 */
	@ApiOperation("详情查询(主键id)")
	@GetMapping("/findByPkId")
	public RestMessage<RqcStDTO> findByPkId(String pkId) {
		return RestMessage.newInstance(true, "findByPkIdSuccess", wmsInRqcStService.findByPkId(pkId));
	}
}
