package com.dk.mdm.service.sale;

import com.dk.common.infrastructure.annotaiton.Pagination;
import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultUtil;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.sale.OrderItem;
import com.dk.mdm.mapper.sale.OrderItemMapper;
import com.dk.common.service.BaseService;
import com.dk.common.mapper.BaseMapper;
import com.dk.mdm.model.query.sale.OrderItemQuery;
import com.dk.mdm.model.response.sale.OrderItemResponse;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderItemService extends BaseService<OrderItem> {

	@Override
	public String getPrimaryKey() {
		return "item_id";
	}

	@Override
	public BaseMapper<OrderItem> getRepository() {
		return orderItemMapper;
	}

	@Autowired
	private OrderItemMapper orderItemMapper;

	/**
	 * @desc   : 以销定采查询销售订单接口
	 * @author : 常皓宁
	 * @date   : 2024/3/29 16:26
	 */
	@Pagination
	public ResponseResultVO<PageList<OrderItemResponse>> purchaseBasedOnSaleSelectOrder(OrderItemQuery orderItemQuery) {
		//查询销售订单
		List<OrderItemResponse> items = orderItemMapper.purchaseBasedOnSaleSelectByCond(orderItemQuery);
		Long  count = orderItemMapper.purchaseBasedOnSaleContByCond(orderItemQuery);
		return ResponseResultUtil.success(new PageList<>(items, count));
	}

}
