Commit a8cecf99 authored by neo's avatar neo

[dev] delete Database Agent for create db

parent 30419404
package pwc.taxtech.atms.agent;
import com.mysql.jdbc.MysqlErrorNumbers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.sql.SQLException;
import static pwc.taxtech.atms.constant.Constant.CREATE_DB_EXISTS;
import static pwc.taxtech.atms.constant.Constant.CREATE_DB_FAILED;
import static pwc.taxtech.atms.constant.Constant.CREATE_DB_SUCCESS;
@Service
public class DatabaseAgent {
private static Logger LOGGER = LoggerFactory.getLogger(DatabaseAgent.class);
@Autowired
private JdbcTemplate jdbcTemplate;
public int createDatabase(String dbName) {
try {
jdbcTemplate.execute("CREATE DATABASE " + dbName + " default charset utf8mb4 COLLATE utf8mb4_general_ci");
return CREATE_DB_SUCCESS;
} catch (Exception exception) {
if (exception.getCause() instanceof SQLException) {
SQLException ex = (SQLException) exception.getCause();
if (ex.getErrorCode() == MysqlErrorNumbers.ER_DB_CREATE_EXISTS) {
LOGGER.warn("db is exists {}", dbName);
return CREATE_DB_EXISTS;
}
}
LOGGER.warn("Unknown Exception {}", exception.getMessage(), exception);
return CREATE_DB_FAILED;
}
}
}
......@@ -2,22 +2,14 @@ package pwc.taxtech.atms.service.impl;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.reflections.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.agent.DatabaseAgent;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.OperateLogType;
import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper;
import pwc.taxtech.atms.dao.ProjectClientMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
......@@ -25,39 +17,28 @@ import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.ServiceTypeMapper;
import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dpo.ProjectDisplayDto;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.ProjectClientDto;
import pwc.taxtech.atms.dto.ServiceTypeDto;
import pwc.taxtech.atms.dto.TemplateGroupDto;
import pwc.taxtech.atms.dto.taxadmin.AddProjectResult;
import pwc.taxtech.atms.dpo.ProjectDisplayDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectYearParam;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.entity.ProjectClientExample.Criteria;
import pwc.taxtech.atms.service.OperationLogService;
import pwc.taxtech.atms.service.ProjectService;
import pwc.taxtech.atms.vat.dao.VatStandardAccountMapper;
import pwc.taxtech.atms.vat.entity.VatStandardAccount;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.constant.Constant.*;
@Service
public class ProjectServiceImpl implements ProjectService {
/**
......@@ -86,9 +67,6 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired
private OperationLogService operationLogService;
@Autowired
private DatabaseAgent databaseAgent;
@Autowired
private SqlSessionTemplate dynamicSqlSessionTemplate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment