
package com.jeelowcode.core.framework.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jeelowcode.core.framework.entity.ReportEntity;
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
import com.jeelowcode.framework.utils.annotation.JeelowCodeCache;

/**
 * 报表相关
 */
@DS(JeeLowCodeBaseConstant.DS_JEELOWCODE)
public interface ReportMapper extends BaseMapper<ReportEntity> {

    @JeelowCodeCache(cacheNames = "'FormReportMapperMapper:getById:' + #reportId", reflexClass = ReportEntity.class)
    default ReportEntity getById(Long reportId) {
        LambdaQueryWrapper<ReportEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ReportEntity::getId, reportId);
        return this.selectOne(wrapper);
    }

    @JeelowCodeCache(cacheNames = "'FormReportMapperMapper:getByCode:' + #reportCode", reflexClass = ReportEntity.class)
    default ReportEntity getByCode(String reportCode) {
        LambdaQueryWrapper<ReportEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ReportEntity::getReportCode, reportCode);
        return this.selectOne(wrapper);
    }

}
