package beilv.usermembershipcard.service.impl;

import beilv.common.core.text.Convert;
import beilv.common.utils.DateUtils;
import beilv.common.utils.uuid.IdUtils;
import beilv.usermembershipcard.domain.UserMembershipCard;
import beilv.usermembershipcard.mapper.UserMembershipCardMapper;
import beilv.usermembershipcard.service.IUserMembershipCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户会员卡Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-02
 */
@Service
public class UserMembershipCardServiceImpl implements IUserMembershipCardService {
    @Autowired
    private UserMembershipCardMapper userMembershipCardMapper;

    /**
     * 查询用户会员卡
     *
     * @param id 用户会员卡主键
     * @return 用户会员卡
     */
    @Override
    public UserMembershipCard selectUserMembershipCardById(Long id) {
        return userMembershipCardMapper.selectUserMembershipCardById(id);
    }

    /**
     * 查询用户会员卡列表
     *
     * @param userMembershipCard 用户会员卡
     * @return 用户会员卡
     */
    @Override
    public List<UserMembershipCard> selectUserMembershipCardList(UserMembershipCard userMembershipCard) {
        return userMembershipCardMapper.selectUserMembershipCardList(userMembershipCard);
    }

    /**
     * 新增用户会员卡
     *
     * @param userMembershipCard 用户会员卡
     * @return 结果
     */
    @Override
    public int insertUserMembershipCard(UserMembershipCard userMembershipCard) {
        userMembershipCard.setCreateTime(DateUtils.getNowDate());
        return userMembershipCardMapper.insertUserMembershipCard(userMembershipCard);
    }

    /**
     * 修改用户会员卡
     *
     * @param userMembershipCard 用户会员卡
     * @return 结果
     */
    @Override
    public int updateUserMembershipCard(UserMembershipCard userMembershipCard) {
        userMembershipCard.setUpdateTime(DateUtils.getNowDate());
        return userMembershipCardMapper.updateUserMembershipCard(userMembershipCard);
    }

    /**
     * 批量删除用户会员卡
     *
     * @param ids 需要删除的用户会员卡主键
     * @return 结果
     */
    @Override
    public int deleteUserMembershipCardByIds(String ids) {
        return userMembershipCardMapper.deleteUserMembershipCardByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户会员卡信息
     *
     * @param id 用户会员卡主键
     * @return 结果
     */
    @Override
    public int deleteUserMembershipCardById(Long id) {
        return userMembershipCardMapper.deleteUserMembershipCardById(id);
    }
}
