package com.chenyang.nse.bussiness.tools;

import com.chenyang.nse.bussiness.config.HibernateConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DataSourceTools {
   public static String dealSqlFormat(String sql) {
      String result = sql;
      if (HibernateConfig.PEIZHIKUDBTYPE.equals("0")) {
         result = sql.replaceAll("\"", "`").replaceAll("to_date\\(", "str_to_date(").replaceAll("yyyy-MM-dd HH24:MI:SS", "%Y-%m-%d %H:%i:%s");
      } else if (HibernateConfig.PEIZHIKUDBTYPE.equals("1")) {
         result = sql.replaceAll("`", "\"").replaceAll("str_to_date\\(", "to_date(").replaceAll("%Y-%m-%d %H:%i:%s", "yyyy-MM-dd HH24:MI:SS");
      }

      return result;
   }
}
