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

import com.prolog.cs.biz.inbound.dto.PageParam;
import com.prolog.cs.biz.inbound.dto.rqc.WmsInRqcStRuleDTO;
import com.prolog.cs.biz.inbound.service.rqc.WmsInRqcStRuleService;
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("/wmsInRqcStRule")
public class WmsInRqcStRuleController {

	@Resource
	private WmsInRqcStRuleService wmsInRqcStRuleService;

	/**
	 * 新增抽检规则
	 */
	@ApiOperation("新增")
	@PostMapping("/add")
	public RestMessage<Object> add(@RequestBody WmsInRqcStRuleDTO wmsInRqcStRuleDTO) {
		return RestMessage.newInstance(true, "addSuccess", wmsInRqcStRuleService.add(wmsInRqcStRuleDTO));
	}

	/**
	 * 编辑抽检规则
	 */
	@ApiOperation("编辑")
	@PostMapping("/edit")
	public RestMessage<Object> edit(@RequestBody WmsInRqcStRuleDTO wmsInRqcStRuleDTO) {
		return RestMessage.newInstance(true, "editSuccess", wmsInRqcStRuleService.edit(null, wmsInRqcStRuleDTO));
	}

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

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

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

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

	/**
	 * 条件查询所有
	 */
	@ApiOperation("条件查询所有")
	@PostMapping("/findAll")
	public RestMessage<List<WmsInRqcStRuleDTO>> findAll(
			@RequestBody(required = false) WmsInRqcStRuleDTO wmsInRqcStRuleDTO) {
		return RestMessage.newInstance(true, "listAllSuccess", wmsInRqcStRuleService.findAll(wmsInRqcStRuleDTO));
	}

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

	/**
	 * 规则上移,下移
	 */
	@ApiOperation("规则上移,下移")
	@GetMapping("/move")
	public RestMessage<Object> move(String pkId, String moveType) {
		return RestMessage.newInstance(true, "moveSuccess", wmsInRqcStRuleService.move(pkId, moveType));
	}
}
