package com.ruoyi.frequency.relationaddress.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.frequency.relationaddress.entity.RelationAddress;
import com.ruoyi.frequency.relationaddress.mapper.RelationAddressMapper;
import com.ruoyi.frequency.relationaddress.service.RelationAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地址与相关对象关联;如订单关联地址等Service业务层处理
 *
 * @author liwenlong
 * @date 2023-07-20
 */
@Service
public class RelationAddressServiceImpl extends ServiceImpl<RelationAddressMapper, RelationAddress>  implements RelationAddressService
{
    @Autowired
    private RelationAddressMapper relationAddressMapper;

    /**
     * 查询地址与相关对象关联;如订单关联地址等
     *
     * @param id 地址与相关对象关联;如订单关联地址等主键
     * @return 地址与相关对象关联;如订单关联地址等
     */
    @Override
    public RelationAddress selectRelationAddressById(Long id)
    {
        return relationAddressMapper.selectRelationAddressById(id);
    }

    /**
     * 查询地址与相关对象关联;如订单关联地址等列表
     *
     * @param relationAddress 地址与相关对象关联;如订单关联地址等
     * @return 地址与相关对象关联;如订单关联地址等
     */
    @Override
    public List<RelationAddress> selectRelationAddressList(RelationAddress relationAddress)
    {
        return relationAddressMapper.selectRelationAddressList(relationAddress);
    }

    /**
     * 新增地址与相关对象关联;如订单关联地址等
     *
     * @param relationAddress 地址与相关对象关联;如订单关联地址等
     * @return 结果
     */
    @Override
    public int insertRelationAddress(RelationAddress relationAddress)
    {
        relationAddress.setCreateTime(DateUtils.getNowDate());
        return relationAddressMapper.insertRelationAddress(relationAddress);
    }

    /**
     * 修改地址与相关对象关联;如订单关联地址等
     *
     * @param relationAddress 地址与相关对象关联;如订单关联地址等
     * @return 结果
     */
    @Override
    public int updateRelationAddress(RelationAddress relationAddress)
    {
        relationAddress.setUpdateTime(DateUtils.getNowDate());
        return relationAddressMapper.updateRelationAddress(relationAddress);
    }

    /**
     * 批量删除地址与相关对象关联;如订单关联地址等
     *
     * @param ids 需要删除的地址与相关对象关联;如订单关联地址等主键
     * @return 结果
     */
    @Override
    public int deleteRelationAddressByIds(Long[] ids)
    {
        return relationAddressMapper.deleteRelationAddressByIds(ids);
    }

    /**
     * 删除地址与相关对象关联;如订单关联地址等信息
     *
     * @param id 地址与相关对象关联;如订单关联地址等主键
     * @return 结果
     */
    @Override
    public int deleteRelationAddressById(Long id)
    {
        return relationAddressMapper.deleteRelationAddressById(id);
    }
}
