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

    public <T> T getSystemConfigByName(String name, Class<T> t) {
        SystemConfig baseConfig = this.baseMapper.selectOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::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("getSystemConfigByName error", e);
        };
        return null;
    }

    public Map<String, String> getMapByName(String name) {
        SystemConfig baseConfig = this.baseMapper.selectOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getCategoryKey, name));
        if (Objects.isNull(baseConfig)) {
            return new HashMap<>();
        }
        Binder.bindRelations(baseConfig);
        // 将baseConfig.getItems转为Map对象。
        Map<String, String> configMap = baseConfig
            .getItems()
            .stream()
            .collect(Collectors.toMap(CommonFieldData::getName, CommonFieldData::getValue, (k1, k2) -> k1));
        // 将configMap转为对应的对象。
        return configMap;
    }
    <%_ } else { _%>
    <%_ } _%>
<%_ } _%>
