package com.yc.ship.module.trade.dal.mysql.order;

import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderCountryDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 订单关联国籍数据 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface TradeOrderCountryMapper extends BaseMapperX<TradeOrderCountryDO> {


    default List<TradeOrderCountryDO> selectListByOrderIds(List<Long> orderIds) {
        return selectList(new LambdaQueryWrapperX<TradeOrderCountryDO>()
                .in(TradeOrderCountryDO::getOrderId, orderIds));
    }

    default List<TradeOrderCountryDO> selectListByOrderId(Long id) {
        return selectList(new LambdaQueryWrapperX<TradeOrderCountryDO>()
                .eq(TradeOrderCountryDO::getOrderId, id));
    }
    @Update("UPDATE trade_order_country SET deleted = #{deleted},update_time = now() WHERE order_id = #{orderId}")
    @TenantIgnore
    void updateDeleted(@Param("orderId") Long orderId, @Param("deleted")  int deleted);
}