package com.tashow.cloud.user.service.user;

import com.tashow.cloud.user.dal.dataobject.user.UserMemberAddressDO;
import com.tashow.cloud.user.dal.mysql.user.UserMemberAddressMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * 会员地址 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class UserMemberAddressServiceImpl implements UserMemberAddressService {

    @Resource
    private UserMemberAddressMapper memberAddressMapper;


    @Override
    public void deleteMemberAddress(Long id) {
        // 校验存在
        validateMemberAddressExists(id);
        // 删除
        memberAddressMapper.deleteById(id);
    }

    private void validateMemberAddressExists(Long id) {
        if (memberAddressMapper.selectById(id) == null) {
//            throw exception(MEMBER_ADDRESS_NOT_EXISTS);
        }
    }

    @Override
    public UserMemberAddressDO getMemberAddress(Long id) {
        return memberAddressMapper.selectById(id);
    }

}