
package com.lideeyunji.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.lideeyunji.core.framework.entity.ReportFieldEntity;
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import com.lideeyunji.tool.framework.yunji.annotation.lideeYunjiCache;
import com.lideeyunji.tool.framework.yunji.constant.lideeRedisConstants;

import java.util.List;

/**
 * 报表相关-字段
 */
@DS(lideeYunJiBaseConstant.DS_lideeyunji)
public interface ReportFieldMapper extends BaseMapper<ReportFieldEntity> {

    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_REPORT+":field:getByDbReportId:' + #reportId", reflexClass = ReportFieldEntity.class)
    default List<ReportFieldEntity> getByDbReportId(Long reportId){
        LambdaQueryWrapper<ReportFieldEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ReportFieldEntity::getReportId, reportId);
        wrapper.orderByAsc(ReportFieldEntity::getSortNum);
        List<ReportFieldEntity> list = this.selectList(wrapper);
        return list;
    }

}
