package cn.sikey.hmd.service.plans;

import cn.sikey.hmd.api.hmd.vo.plans.PlansRespVO;
import cn.sikey.hmd.convert.PlansConvert;
import cn.sikey.hmd.dal.dataobject.PlansDO;
import cn.sikey.hmd.dal.mysql.PlansMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: qin
 * @Date: 2025/3/31
 * @Description: 套餐
 */
@Service
@Slf4j
public class PlansServiceImpl implements PlansService {

    @Resource
    private PlansMapper plansMapper;

    /**
     * 查询套餐
     *
     * @param validity 有效期
     * @return
     */
    @Override
    public PlansRespVO queryPlans(int validity) {
        PlansDO plansDO = plansMapper.queryPlansDO(validity);
        return PlansConvert.INSTANCE.convertPlansRespVO(plansDO);
    }

    /**
     * 查询套餐
     *
     * @param id 套餐编码
     * @return
     */
    @Override
    public PlansRespVO queryPlansById(Long id) {
        PlansDO plansDO = plansMapper.selectById(id);
        return PlansConvert.INSTANCE.convertPlansRespVO(plansDO);
    }
}
