private void updateContent(SystemConfig config, String value) {
   if ((config.getContent() == null && value == null) || config.getContent().equals(value)) return;
   config.setContent(value);
   config.setUpdateUser("");
   config.setUpdateTime(new Date());
   systemConfigRepository.update(config);
 }
 private void addConfig(SystemConfig config) {
   config.setUpdateUser("");
   config.setUpdateTime(new Date());
   config.setCreateTime(new Date());
   config.setCreateUser("");
   config.setContent("");
   systemConfigRepository.create(config);
 }
  @Transactional
  public void saveConfig(SystemConfigGroup group) {
    SystemConfigView configView = get();
    List<SystemConfig> configs = buildConfig(group);
    for (SystemConfig config : configs) {
      SystemConfig existConfig = configView.getConfig(config.fullKey());
      if (existConfig == null) {

      } else {
        addConfig(config);
      }
    }
  }
 private List<SystemConfig> buildConfig(SystemConfigGroup group) {
   List<SystemConfig> configs = new ArrayList<>(group.getKeys().size());
   for (SystemConfigKey key : group.getKeys()) {
     SystemConfig config = new SystemConfig();
     config.setGroupName(group.getName());
     config.setGroupText(group.getText());
     config.setGroupOrder(group.getOrder());
     config.setKeyName(key.getName());
     config.setKeyText(key.getText());
     config.setKeyOrder(key.getOrder());
     configs.add(config);
   }
   return configs;
 }
  public List<SystemConfigGroup> findAllGroup() {
    List<SystemConfig> configs = systemConfigRepository.findAll();
    Map<String, SystemConfigGroup> groupMap = new HashMap<>();
    for (SystemConfig config : configs) {
      if (!groupMap.containsKey(config.getGroupName())) {
        groupMap.put(config.getGroupName(), new SystemConfigGroup());
      }
      SystemConfigGroup group = groupMap.get(config.getGroupName());
      group.setName(config.getGroupName());
      group.setText(config.getGroupText());
      group.setOrder(config.getGroupOrder());

      group
          .getKeys()
          .add(
              new SystemConfigKey(
                  config.getKeyName(),
                  config.getKeyText(),
                  config.getContent(),
                  config.getKeyOrder()));
    }
    List<SystemConfigGroup> groups = new ArrayList<>(groupMap.values());
    sortGroup(groups);
    return groups;
  }