
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.ReportFieldEntity;
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
import com.jeelowcode.framework.utils.annotation.JeelowCodeCache;

import java.util.List;

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

    @JeelowCodeCache(cacheNames = "'ReportFieldMapper: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;
    }

}
