package com.fs.store.service.impl;

import java.util.List;
import com.fs.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.store.mapper.FsUserAddressMapper;
import com.fs.store.domain.FsUserAddress;
import com.fs.store.service.IFsUserAddressService;

/**
 * 用户地址Service业务层处理
 * 
 * @author fs
 * @date 2022-03-15
 */
@Service
public class FsUserAddressServiceImpl implements IFsUserAddressService 
{
    @Autowired
    private FsUserAddressMapper fsUserAddressMapper;

    /**
     * 查询用户地址
     * 
     * @param id 用户地址ID
     * @return 用户地址
     */
    @Override
    public FsUserAddress selectFsUserAddressById(Long id)
    {
        return fsUserAddressMapper.selectFsUserAddressById(id);
    }

    /**
     * 查询用户地址列表
     * 
     * @param fsUserAddress 用户地址
     * @return 用户地址
     */
    @Override
    public List<FsUserAddress> selectFsUserAddressList(FsUserAddress fsUserAddress)
    {
        return fsUserAddressMapper.selectFsUserAddressList(fsUserAddress);
    }

    /**
     * 新增用户地址
     * 
     * @param fsUserAddress 用户地址
     * @return 结果
     */
    @Override
    public int insertFsUserAddress(FsUserAddress fsUserAddress)
    {
        fsUserAddress.setDetail(fsUserAddress.getDetail().trim());
        fsUserAddress.setCreateTime(DateUtils.getNowDate());
        return fsUserAddressMapper.insertFsUserAddress(fsUserAddress);
    }

    /**
     * 修改用户地址
     * 
     * @param fsUserAddress 用户地址
     * @return 结果
     */
    @Override
    public int updateFsUserAddress(FsUserAddress fsUserAddress)
    {
        fsUserAddress.setDetail(fsUserAddress.getDetail().trim());
        fsUserAddress.setUpdateTime(DateUtils.getNowDate());
        return fsUserAddressMapper.updateFsUserAddress(fsUserAddress);
    }

    /**
     * 批量删除用户地址
     * 
     * @param ids 需要删除的用户地址ID
     * @return 结果
     */
    @Override
    public int deleteFsUserAddressByIds(Long[] ids)
    {
        return fsUserAddressMapper.deleteFsUserAddressByIds(ids);
    }

    /**
     * 删除用户地址信息
     * 
     * @param id 用户地址ID
     * @return 结果
     */
    @Override
    public int deleteFsUserAddressById(Long id)
    {
        return fsUserAddressMapper.deleteFsUserAddressById(id);
    }

    @Override
    public int clearIsDefalut(long userId) {
        return fsUserAddressMapper.clearIsDefalut(userId);
    }

    @Override
    public Integer selectFsUserAddressCountsByUserId(long userId) {
        return fsUserAddressMapper.selectFsUserAddressCountsByUserId(userId);
    }

    @Override
    public Integer delAllAddress(Long userId) {
        return fsUserAddressMapper.delAllAddress(userId);
    }
}
