package com.ruoyi.hezhi.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.hezhi.domain.TbPostAddress;
import com.ruoyi.hezhi.mapper.TbPostAddressMapper;
import com.ruoyi.hezhi.service.ITbPostAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 邮寄地址Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-20
 */
@Service
public class TbPostAddressServiceImpl implements ITbPostAddressService
{
    @Autowired
    private TbPostAddressMapper tbPostAddressMapper;

    /**
     * 查询邮寄地址
     *
     * @param postAddressId 邮寄地址主键
     * @return 邮寄地址
     */
    @Override
    public TbPostAddress selectTbPostAddressByPostAddressId(Long postAddressId)
    {
        return tbPostAddressMapper.selectTbPostAddressByPostAddressId(postAddressId);
    }

    /**
     * 查询邮寄地址列表
     *
     * @param tbPostAddress 邮寄地址
     * @return 邮寄地址
     */
    @Override
    public List<TbPostAddress> selectTbPostAddressList(TbPostAddress tbPostAddress)
    {
        return tbPostAddressMapper.selectTbPostAddressList(tbPostAddress);
    }

    /**
     * 新增邮寄地址
     *
     * @param tbPostAddress 邮寄地址
     * @return 结果
     */
    @Override
    public int insertTbPostAddress(TbPostAddress tbPostAddress)
    {
        tbPostAddress.setCreateTime(DateUtils.getNowDate());
        return tbPostAddressMapper.insertTbPostAddress(tbPostAddress);
    }

    /**
     * 修改邮寄地址
     *
     * @param tbPostAddress 邮寄地址
     * @return 结果
     */
    @Override
    public int updateTbPostAddress(TbPostAddress tbPostAddress)
    {
        tbPostAddress.setUpdateTime(DateUtils.getNowDate());
        return tbPostAddressMapper.updateTbPostAddress(tbPostAddress);
    }

    /**
     * 批量删除邮寄地址
     *
     * @param postAddressIds 需要删除的邮寄地址主键
     * @return 结果
     */
    @Override
    public int deleteTbPostAddressByPostAddressIds(Long[] postAddressIds)
    {
        return tbPostAddressMapper.deleteTbPostAddressByPostAddressIds(postAddressIds);
    }

    /**
     * 删除邮寄地址信息
     *
     * @param postAddressId 邮寄地址主键
     * @return 结果
     */
    @Override
    public int deleteTbPostAddressByPostAddressId(Long postAddressId)
    {
        return tbPostAddressMapper.deleteTbPostAddressByPostAddressId(postAddressId);
    }

    /**
     * 查询邮寄地址
     *
     * @param memberUserId 用户ID
     * @param dataId 相关资源ID
     * @param type 类型（0-全部，1-证书）
     * @return 邮寄地址
     */
    @Override
    public TbPostAddress selectTbPostAddressByMemberUserIdDataId(Long memberUserId, Long dataId, Integer type) {
        return tbPostAddressMapper.selectTbPostAddressByMemberUserIdDataId(memberUserId, dataId, type);
    }
}
