Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
lani009 committed Jun 2, 2021
1 parent 80aaf65 commit fb00511
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 109 deletions.
4 changes: 3 additions & 1 deletion jmt_webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
.vscode/
*.http
pk.txt
kakaoKey.txt
kakaoKey.txt
.idea
*.iml
3 changes: 3 additions & 0 deletions jmt_webapp/src/main/java/entity/Dept.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class Dept extends Organization {

public Dept(String organizationCode, String organizationName) {
super(organizationCode, organizationName);
if (super.organizationCode.length() != 7) {
throw new IllegalArgumentException();
}
}

}
3 changes: 3 additions & 0 deletions jmt_webapp/src/main/java/entity/DeptDiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class DeptDiv extends Organization {

public DeptDiv(String organizationCode, String organizationName) {
super(organizationCode, organizationName);
if (super.organizationCode.length() != 2) {
throw new IllegalArgumentException();
}
}

}
3 changes: 3 additions & 0 deletions jmt_webapp/src/main/java/entity/GovofcDiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class GovofcDiv extends Organization {

public GovofcDiv(String organizationCode, String organizationName) {
super(organizationCode, organizationName);
if (super.organizationCode.length() != 4) {
throw new IllegalArgumentException();
}
}

}
3 changes: 3 additions & 0 deletions jmt_webapp/src/main/java/entity/HgdeptDiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class HgdeptDiv extends Organization {

public HgdeptDiv(String organizationCode, String organizationName) {
super(organizationCode, organizationName);
if (super.organizationCode.length() != 4) {
throw new IllegalArgumentException();
}
}

}
4 changes: 2 additions & 2 deletions jmt_webapp/src/main/java/entity/Organization.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public abstract class Organization {
/**
* 조직 코드
*/
private String organizationCode;
protected String organizationCode;
/**
* 조직 이름
*/
private String organizationName;
protected String organizationName;

protected Organization(String organizationCode, String organizationName) {
this.organizationCode = organizationCode;
Expand Down
3 changes: 3 additions & 0 deletions jmt_webapp/src/main/java/entity/Place.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class Place {
private int likeCount;

public Place(String bizNo, String placeName, int likeCount) {
if (bizNo.length() != 10) {
throw new IllegalArgumentException("BizNo length != 10");
}
this.bizNo = bizNo;
this.placeName = placeName;
this.likeCount = likeCount;
Expand Down
24 changes: 11 additions & 13 deletions jmt_webapp/src/main/java/jdbc/DBCPInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

public class DBCPInit extends HttpServlet {
// TODO web.xml 해결해야함.

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;

public DBCPInit() {
super();
Expand All @@ -32,20 +30,20 @@ public void init() throws ServletException {
initConnectionPool();
}

@SuppressWarnings({"unchecked", "rawtype"})
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initConnectionPool() {

try {
File file = new File("../webapps/ROOT/WEB-INF/resources/pk.txt");
FileInputStream is = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
File file = new File("../webapps/ROOT/WEB-INF/resources/pk.txt");
FileInputStream is = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String jdbcUrl = br.readLine();
String username = "pi";
String pw = br.readLine();
br.close();
is.close();
isr.close();
br.close();
is.close();
isr.close();

ConnectionFactory connFactory = new DriverManagerConnectionFactory(jdbcUrl, username, pw);
PoolableConnectionFactory poolableConnFactory = new PoolableConnectionFactory(connFactory, null);
Expand All @@ -57,8 +55,8 @@ private void initConnectionPool() {
poolConfig.setMinIdle(4);
poolConfig.setMaxTotal(50);

GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<PoolableConnection>(
poolableConnFactory, poolConfig);
GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnFactory,
poolConfig);
poolableConnFactory.setPool(connectionPool);

Class.forName("org.apache.commons.dbcp2.PoolingDriver");
Expand Down
168 changes: 82 additions & 86 deletions jmt_webapp/src/main/webapp/restful/get/category/GetCategory.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,122 +15,118 @@
<%@page import="entity.Place"%>
<%
response.setHeader("Access-Control-Allow-Origin", "*");
try{
// 상위개념이 선택되었을 때, 카테고리 선택
// 상위가 null 이면 하위도 무조건 null
String deptDiv= null;
String govofcDiv = null;
String hgdeptDiv = null;
String dept= null;
Organization organizationDept;
Organization organizationGovofcDiv;
Organization organizationDeptDiv;
Organization organizationHgdeptDiv;
if(request.getParameter("deptDiv")==null){
deptDiv = "";
organizationDeptDiv = new DeptDiv(null, null);
}else{
deptDiv = request.getParameter("deptDiv");
organizationDeptDiv = new DeptDiv(null, deptDiv);
}
if(request.getParameter("govofcDiv")==null){
govofcDiv = "";
organizationGovofcDiv = new GovofcDiv(null, null);
}else{
govofcDiv = request.getParameter("govofcDiv");
organizationGovofcDiv = new GovofcDiv(null, govofcDiv);
}
if(request.getParameter("hgdeptDiv")==null){
hgdeptDiv = "";
organizationHgdeptDiv = new HgdeptDiv(null, null);
}else{
hgdeptDiv = request.getParameter("hgdeptDiv");
organizationHgdeptDiv = new HgdeptDiv(null, hgdeptDiv);
}
if(request.getParameter("dept")==null){
dept = "";
organizationDept = new Dept(null, null);
}else{
dept = request.getParameter("dept");
organizationDept = new Dept(null, dept);
}
List<Organization> list = new ArrayList<>();
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
if (deptDiv.equals("")) {
list = OrganizationDAO.getInstance()
.getAllOrganization((Class<Organization>) organizationDeptDiv.getClass());
for (int i = 0; i < list.size(); i++) {
jsonArray.add((list.get(i)).getOrganizationName());
try{
// 상위개념이 선택되었을 때, 카테고리 선택
// 상위가 null 이면 하위도 무조건 null
String deptDiv = null;
String govofcDiv = null;
String hgdeptDiv = null;
String dept = null;
Organization organizationDept;
Organization organizationGovofcDiv;
Organization organizationDeptDiv;
Organization organizationHgdeptDiv;
if (request.getParameter("deptDiv") == null) {
deptDiv = "";
organizationDeptDiv = new DeptDiv(null, null);
} else {
deptDiv = request.getParameter("deptDiv");
organizationDeptDiv = new DeptDiv(null, deptDiv);
}
if (request.getParameter("govofcDiv") == null) {
govofcDiv = "";
organizationGovofcDiv = new GovofcDiv(null, null);
} else {
govofcDiv = request.getParameter("govofcDiv");
organizationGovofcDiv = new GovofcDiv(null, govofcDiv);
}
jsonObject.put("deptDiv", jsonArray);
System.out.println(jsonObject.toJSONString());
if (request.getParameter("hgdeptDiv") == null) {
hgdeptDiv = "";
organizationHgdeptDiv = new HgdeptDiv(null, null);
} else {
hgdeptDiv = request.getParameter("hgdeptDiv");
organizationHgdeptDiv = new HgdeptDiv(null, hgdeptDiv);
}
} else if (deptDiv != "") {
if (request.getParameter("dept") == null) {
dept = "";
organizationDept = new Dept(null, null);
} else {
dept = request.getParameter("dept");
organizationDept = new Dept(null, dept);
}
if (govofcDiv == "") {
List<Organization> list = new ArrayList<>();
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
if (deptDiv.equals("")) {
list = OrganizationDAO.getInstance()
.getAllOrganization((Class<Organization>) organizationDeptDiv.getClass());
list = OrganizationDAO.getInstance().getChildrenOf(organizationDeptDiv,organizationGovofcDiv,organizationHgdeptDiv,organizationDept);
for (int i = 0; i < list.size(); i++) {
jsonArray.add((list.get(i)).getOrganizationName());
}
jsonObject.put("govofcDiv", jsonArray);
jsonObject.put("deptDiv", jsonArray);
System.out.println(jsonObject.toJSONString());
} else if (govofcDiv != "") {
} else if (deptDiv != "") {
if (hgdeptDiv == "") {
if (govofcDiv == "") {
list = OrganizationDAO.getInstance().getChildrenOf(organizationDeptDiv,organizationGovofcDiv,organizationHgdeptDiv,organizationDept);
for (int i = 0; i < list.size(); i++) {
jsonArray.add((list.get(i)).getOrganizationName());
}
jsonObject.put("hgdeptDiv", jsonArray);
jsonObject.put("govofcDiv", jsonArray);
System.out.println(jsonObject.toJSONString());
} else if (hgdeptDiv != "") {
list = OrganizationDAO.getInstance().getChildrenOf(organizationDeptDiv,organizationGovofcDiv,organizationHgdeptDiv,organizationDept);
for (int i = 0; i < list.size(); i++) {
jsonArray.add((list.get(i)).getOrganizationName());
}
} else if (govofcDiv != "") {
jsonObject.put("dept", jsonArray);
if (hgdeptDiv == "") {
list = OrganizationDAO.getInstance().getChildrenOf(organizationDeptDiv,organizationGovofcDiv,organizationHgdeptDiv,organizationDept);
for (int i = 0; i < list.size(); i++) {
jsonArray.add((list.get(i)).getOrganizationName());
}
jsonObject.put("hgdeptDiv", jsonArray);
System.out.println(jsonObject.toJSONString());
} else if (hgdeptDiv != "") {
list = OrganizationDAO.getInstance().getChildrenOf(organizationDeptDiv,organizationGovofcDiv,organizationHgdeptDiv,organizationDept);
for (int i = 0; i < list.size(); i++) {
jsonArray.add((list.get(i)).getOrganizationName());
}
jsonObject.put("dept", jsonArray);
System.out.println(jsonObject.toJSONString());
}
System.out.println(jsonObject.toJSONString());
}
}
}
// json 변환
// json 변환
out.print(jsonObject);
out.print(jsonObject);
}catch(Exception e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
%>
2 changes: 1 addition & 1 deletion jmt_webapp/src/main/webapp/restful/get/top10/GetTop10.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ try{
String govofcDiv = request.getParameter("govofcDiv");
String hgdeptDiv = request.getParameter("hgdeptDiv");
String dept = request.getParameter("dept");
String startDate= null;
String startDate = null;
String endDate = null;
if(request.getParameter("startDate")==null){
startDate = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<%@ page language="java" contentType="application/json; charset=utf-8"%>
<%@ page language="java" contentType="application/json; charset=utf-8"%>
<%@page import="entity.Place"%>
<%@page import="dao.impl.PlaceDAO"%>
<%@page import="dao.test.PlaceTestDAO"%>
<%
response.setHeader("Access-Control-Allow-Origin", "*");
try{
try {
String bizNo = request.getParameter("bizNo");
Place place = new Place(bizNo, null , 0);
PlaceDAO.getInstance().updateLikeCount(place);
response.setStatus(200);
}catch(Exception e){
} catch(Exception e) {
e.printStackTrace();
response.sendError(400, "데이터베이스에 존재하지 않음");
}
Expand Down

0 comments on commit fb00511

Please sign in to comment.