Commit afb1faf4 authored by 陈祥烨's avatar 陈祥烨

ip

parent 0eaf0df8
...@@ -15,6 +15,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -15,6 +15,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
...@@ -124,7 +125,7 @@ public class DataBaseLinkResource { ...@@ -124,7 +125,7 @@ public class DataBaseLinkResource {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/agency/list") @GetMapping(value = "/agency/list")
@ApiOperation(httpMethod = "GET", value = "机构列表查询", notes = "列表查询") @ApiOperation(httpMethod = "GET", value = "机构列表查询", notes = "列表查询")
public ResponseModel<List<AgencyModel>> queryForList() throws SQLException { public ResponseModel<List<AgencyModel>> queryForList() throws SQLException, IOException {
return ResponseHelper.buildResponse(dataBaseLinkService.queryForAgencyList()); return ResponseHelper.buildResponse(dataBaseLinkService.queryForAgencyList());
} }
......
...@@ -14,6 +14,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -14,6 +14,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -83,10 +84,8 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase ...@@ -83,10 +84,8 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
/** /**
* 机构列表查询 * 机构列表查询
*/ */
public List<AgencyModel> queryForAgencyList() throws SQLException { public List<AgencyModel> queryForAgencyList() throws SQLException, IOException {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); Connection connection = this.connectNewDatabase(this.queryModelByParams(DataBaseUtils.getIp()));
HttpServletRequest request = requestAttributes.getRequest();
Connection connection = this.connectNewDatabase(this.queryModelByParams(request.getLocalAddr()));
List<Map<String, Object>> maps = List<Map<String, Object>> maps =
DataBaseUtils.getMaps("SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;", connection); DataBaseUtils.getMaps("SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;", connection);
connection.close(); connection.close();
......
...@@ -5,11 +5,10 @@ import com.yeejoin.amos.api.tool.face.orm.entity.TableColumn; ...@@ -5,11 +5,10 @@ import com.yeejoin.amos.api.tool.face.orm.entity.TableColumn;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DataBaseUtils { public class DataBaseUtils {
...@@ -147,5 +146,13 @@ public class DataBaseUtils { ...@@ -147,5 +146,13 @@ public class DataBaseUtils {
return sql; return sql;
} }
public static String getIp() throws IOException {
InputStream inputStream = ClassLoader.getSystemResourceAsStream("config/application-dev.properties");
Properties properties = new Properties();
properties.load(inputStream);
properties.list(System.out);
return properties.getProperty("eureka.instance.hostname");
}
} }
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