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

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

/**
 * 会员信息 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class UserMemberServiceImpl implements UserMemberService {

    @Resource
    private UserMemberMapper memberMapper;


    @Override
    public void deleteMember(Long id) {
        // 校验存在
        validateMemberExists(id);
        // 删除
        memberMapper.deleteById(id);
    }

    private void validateMemberExists(Long id) {
        if (memberMapper.selectById(id) == null) {
//            throw exception(MEMBER_NOT_EXISTS);
        }
    }

    @Override
    public UserMemberDO getMember(Long id) {
        return memberMapper.selectById(id);
    }

}