<%_ if (position === 'import') { _%>
  <%_ if (ormTool === 'mybatis') { _%>
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  <%_ } else { _%>
  <%_ } _%>
<%_ } _%>
<%_ if (position === 'method') { _%>
    <%_ if (ormTool === 'mybatis') { _%>

    public <T> T getSiteConfigByName(String name, Class<T> t) {
        SiteConfig baseConfig = this.baseMapper.selectOne(new LambdaQueryWrapper<SiteConfig>().eq(SiteConfig::getCategoryKey, name));
        if (Objects.isNull(baseConfig)) {
            return null;
        }
        Binder.bindRelations(baseConfig);
        // 将baseConfig.getItems转为Map对象。
        Map<String, String> configMap = baseConfig.getItems().stream().collect(Collectors.toMap(CommonFieldData::getName, CommonFieldData::getValue, (k1, k2) -> k1));
        // 将configMap转为对应的对象。
        try {
            return BeanUtil.toBean(configMap, t);
        } catch (Exception e) {
            log.error("getSiteConfigByName error", e);
        };
        return null;
    }
    <%_ } else { _%>
    <%_ } _%>
<%_ } _%>
