package com.xingxi.business.UserAddress.service.impl;

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.business.UserAddress.domain.UserAddress;
import com.xingxi.business.UserAddress.mapper.UserAddressMapper;
import com.xingxi.business.UserAddress.service.IUserAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户地址Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class UserAddressServiceImpl implements IUserAddressService {
    @Resource
    private UserAddressMapper userAddressMapper;

    /**
     * 查询用户地址
     *
     * @param userAddressId 用户地址主键
     * @return 用户地址
     */
    @Override
    public UserAddress selectUserAddressByUserAddressId(Long userAddressId) {
        return userAddressMapper.selectUserAddressByUserAddressId(userAddressId);
    }

    /**
     * 查询用户地址列表
     *
     * @param userAddress 用户地址
     * @return 用户地址
     */
    @Override
    public List<UserAddress> selectUserAddressList(UserAddress userAddress) {
        return userAddressMapper.selectUserAddressList(userAddress);
    }

    /**
     * 新增用户地址
     *
     * @param userAddress 用户地址
     * @return 结果
     */
    @Override
    public int insertUserAddress(UserAddress userAddress) {
        userAddress.setCreateTime(DateUtils.getNowDate());
        return userAddressMapper.insertUserAddress(userAddress);
    }

    /**
     * 新增用户地址
     *
     * @param userAddressList 用户地址
     * @return 结果
     */
    @Override
    public int batchInsertUserAddress(List<UserAddress> userAddressList) {
        return userAddressMapper.batchInsertUserAddress(userAddressList);
    }

    /**
     * 修改用户地址
     *
     * @param userAddress 用户地址
     * @return 结果
     */
    @Override
    public int updateUserAddress(UserAddress userAddress) {
        userAddress.setUpdateTime(DateUtils.getNowDate());
        return userAddressMapper.updateUserAddress(userAddress);
    }

    /**
     * 批量删除用户地址
     *
     * @param userAddressIds 需要删除的用户地址主键
     * @return 结果
     */
    @Override
    public int deleteUserAddressByUserAddressIds(String userAddressIds) {
        return userAddressMapper.deleteUserAddressByUserAddressIds(Convert.toStrArray(userAddressIds));
    }

    /**
     * 删除用户地址信息
     *
     * @param userAddressId 用户地址主键
     * @return 结果
     */
    @Override
    public int deleteUserAddressByUserAddressId(Long userAddressId) {
        return userAddressMapper.deleteUserAddressByUserAddressId(userAddressId);
    }

    /**
     * 逻辑删除用户地址
     *
     * @param userAddressId 用户地址主键
     * @return 结果
     */
    @Override
    public int logicDeleteUserAddressByUserAddressId(Long userAddressId) {
        return userAddressMapper.logicDeleteUserAddressByUserAddressId(userAddressId);
    }

    /**
     * 逻辑批量删除用户地址
     *
     * @param userAddressIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteUserAddressByUserAddressIds(String[] userAddressIds) {
        return userAddressMapper.logicDeleteUserAddressByUserAddressIds(userAddressIds);
    }

    /**
     * 逻辑批量删除用户地址
     *
     * @param userAddress 用户地址
     * @return 结果
     */
    @Override
    public int logicDeleteUserAddressByCondition(UserAddress userAddress) {
        return userAddressMapper.logicDeleteUserAddressByCondition(userAddress);
    }
}
