From 9a6f361b3aded9a4a0a4edb3f57d5504809f536a Mon Sep 17 00:00:00 2001 From: jinyoungchoi95 Date: Thu, 5 Aug 2021 12:00:59 +0900 Subject: [PATCH 01/13] chore: test.gradle coverage change - line coverage : 0.7 > 0.5 - method coverage : 1.0 > delete --- test.gradle | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test.gradle b/test.gradle index 343093fe..e46ca6b8 100644 --- a/test.gradle +++ b/test.gradle @@ -21,14 +21,9 @@ jacocoTestCoverageVerification { limit { counter = 'LINE' value = 'COVEREDRATIO' - minimum = 0.7 + minimum = 0.5 } - limit { - counter = 'METHOD' - value = 'COVEREDRATIO' - minimum = 1.0 - } } rule { enabled = true; From 91cddf0ddd29f06c21c8bdd4efc3759515180a25 Mon Sep 17 00:00:00 2001 From: jinyoungchoi95 Date: Thu, 5 Aug 2021 19:38:01 +0900 Subject: [PATCH 02/13] chore: build.yml push, pr branch retouch --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55af4a62..20f18133 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: build on: push: - branches: [ main, chance0523, com8599, DolphaGo, hoony-lab, jinyoungchoi95, JunHo-YH, povia, sujl95 , kwj1270 ] + branches: [ main, chance0523, com8599, DolphaGo, hoony-lab, jinyoungchoi95, povia , kwj1270 , ERrorASER ] pull_request: - branches: [ main, chance0523, com8599, DolphaGo, hoony-lab, jinyoungchoi95, JunHo-YH, povia, sujl95 , kwj1270 ] + branches: [ main, chance0523, com8599, DolphaGo, hoony-lab, jinyoungchoi95, povia , kwj1270 , ERrorASER ] jobs: build: From 94ef3b8ba1cc1ac0beb44e0750089629aeb6c7cd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Aug 2021 17:42:01 +0900 Subject: [PATCH 03/13] https://github.com/real-world-study/realworld/issues/6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: UserBean, UserController, Swagger, 등 기본 에셋 추가 --- build.gradle | 6 + .../study/realworld/RealworldApplication.java | 6 +- .../com/study/realworld/bean/UserBean.java | 41 + .../com/study/realworld/common/Errors.java | 31 + .../java/com/study/realworld/common/Func.java | 52 + .../realworld/controller/ControllerBase.java | 9 + .../realworld/controller/UserController.java | 52 + .../com/study/realworld/dao/PSSetDao.java | 1604 +++++++++++++++++ .../com/study/realworld/dao/ResultDao.java | 187 ++ .../study/realworld/secure/GUIDGenerator.java | 33 + .../study/realworld/secure/IGenerator.java | 9 + .../realworld/secure/SecureGUIDGenerator.java | 29 + .../study/realworld/secure/SecurityFunc.java | 132 ++ .../realworld/swagger/SwaggerConfig.java | 51 + 14 files changed, 2241 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/study/realworld/bean/UserBean.java create mode 100644 src/main/java/com/study/realworld/common/Errors.java create mode 100644 src/main/java/com/study/realworld/common/Func.java create mode 100644 src/main/java/com/study/realworld/controller/ControllerBase.java create mode 100644 src/main/java/com/study/realworld/controller/UserController.java create mode 100644 src/main/java/com/study/realworld/dao/PSSetDao.java create mode 100644 src/main/java/com/study/realworld/dao/ResultDao.java create mode 100644 src/main/java/com/study/realworld/secure/GUIDGenerator.java create mode 100644 src/main/java/com/study/realworld/secure/IGenerator.java create mode 100644 src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java create mode 100644 src/main/java/com/study/realworld/secure/SecurityFunc.java create mode 100644 src/main/java/com/study/realworld/swagger/SwaggerConfig.java diff --git a/build.gradle b/build.gradle index 716829db..d6edc244 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,12 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' runtimeOnly 'com.h2database:h2' testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation group: 'com.google.code.gson', name: 'gson', version: '2.7' + implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3' + + //swagger + implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2' + implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2' } apply from: 'test.gradle' diff --git a/src/main/java/com/study/realworld/RealworldApplication.java b/src/main/java/com/study/realworld/RealworldApplication.java index 1e52f3d0..02fb5548 100644 --- a/src/main/java/com/study/realworld/RealworldApplication.java +++ b/src/main/java/com/study/realworld/RealworldApplication.java @@ -1,7 +1,12 @@ package com.study.realworld; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; + +import java.util.Arrays; @SpringBootApplication public class RealworldApplication { @@ -9,5 +14,4 @@ public class RealworldApplication { public static void main(String[] args) { SpringApplication.run(RealworldApplication.class, args); } - } diff --git a/src/main/java/com/study/realworld/bean/UserBean.java b/src/main/java/com/study/realworld/bean/UserBean.java new file mode 100644 index 00000000..220e7939 --- /dev/null +++ b/src/main/java/com/study/realworld/bean/UserBean.java @@ -0,0 +1,41 @@ +package com.study.realworld.bean; + +import com.study.realworld.dao.PSSetDao; +import com.study.realworld.dao.ResultDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Component; + +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Map; + +@Component +public class UserBean { + private final JdbcTemplate jdbcTemplate; + + @Autowired + public UserBean(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } + + public boolean checkSameName(String username) { //같은 닉네임의 유저가 있는지 확인 + final String query = "select EXISTS(select id from USER where USERNAME=?)"; + return (boolean) jdbcTemplate.query(query, new PSSetDao.PSSForString(username), new ResultDao.RSEForBoolean()); + } + + public boolean checkSameEmail(String email) { //같은 이메일의 유저가 있는지 확인 + final String query = "select EXISTS(select id from USER where email=?)"; + return (boolean) jdbcTemplate.query(query, new PSSetDao.PSSForString(email), new ResultDao.RSEForBoolean()); + } + + public int registUser(String username, String email, String password) { //신규 유저 삽입 + final String query = "insert into USER(USERNAME, EMAIL, PASSWORD) values (?, ?, ?)"; + return jdbcTemplate.update(query, new PSSetDao.PSSForTripleString(username, email, password)); + } + + public Map getUsers(String email) { + final String query = "select email,username,bio,image from USER where email=?"; + return (Map) jdbcTemplate.query(query, new PSSetDao.PSSForString(email), new ResultDao.RSEForResult()); + } +} diff --git a/src/main/java/com/study/realworld/common/Errors.java b/src/main/java/com/study/realworld/common/Errors.java new file mode 100644 index 00000000..b5027243 --- /dev/null +++ b/src/main/java/com/study/realworld/common/Errors.java @@ -0,0 +1,31 @@ +package com.study.realworld.common; + +public enum Errors { + EXCEPTION (-1, "통신중 에러가 발생했습니다."), + NONE (0, "이상없음"), + INVALID_REQUEST (1, "잘못된 요청입니다."), + DB (2, "데이터 베이스 오류입니다."), + SAME_NICKNAME (3, "동일 닉네임유저가 존재합니다."), + SAME_EMAIL (4, "동일 이메일유저가 존재합니다."), + + NOT_FOUND_SESSION_USER (10000, "유저 정보를 찾을 수 없습니다."), + +// mobile auth + SQLEXCEPTION (-2, "서버와 통신중 에러가 발생했습니다."), + ; + + private int code; + private String desc; + Errors(int code, String desc) { + this.code = code; + this.desc = desc; + } + public int getCode() { return code; } + public String getDesc() { return desc; } + public static Errors parse(int code) { + for( Errors e : Errors.values() ) { + if( code == e.getCode() ) { return e; } + } + return INVALID_REQUEST; + } +} \ No newline at end of file diff --git a/src/main/java/com/study/realworld/common/Func.java b/src/main/java/com/study/realworld/common/Func.java new file mode 100644 index 00000000..feb7961f --- /dev/null +++ b/src/main/java/com/study/realworld/common/Func.java @@ -0,0 +1,52 @@ +package com.study.realworld.common; + +import com.google.gson.JsonObject; +import com.study.realworld.secure.SecurityFunc; + +import java.security.Key; + +public class Func { + public static String getErrorJson( Errors error, Object...objects ) { + JsonObject json = new JsonObject(); + + json.addProperty("E", String.valueOf(error.getCode())); + + if(objects != null && objects.length > 0) { + for(int i = 0; i < objects.length; i = i + 2) { + json.addProperty(String.valueOf(objects[i]), String.valueOf(objects[i + 1])); + } + } + System.out.println(error.name() + " - " + error.getCode() + " - " + error.getDesc()); + + return json.toString(); + } + public static String getResultJson( JsonObject result ) { + JsonObject json = new JsonObject(); + + json.add("R", result); + + return result.toString(); + } + public static String getZipJson( String bin ) { + JsonObject json = new JsonObject(); + + json.addProperty("Z", bin); + + return json.toString(); + } + + public static class RseBinJson { + JsonObject R; + } + + public static String getBinJson(JsonObject result, Key key) { + RseBinJson rse = new RseBinJson(); + rse.R = result; + + JsonObject json = new JsonObject(); + + json.addProperty("B", SecurityFunc.encryptData(SecurityFunc.AES_ALGORITHM, key, rse)); + + return json.toString(); + } +} diff --git a/src/main/java/com/study/realworld/controller/ControllerBase.java b/src/main/java/com/study/realworld/controller/ControllerBase.java new file mode 100644 index 00000000..461c1d85 --- /dev/null +++ b/src/main/java/com/study/realworld/controller/ControllerBase.java @@ -0,0 +1,9 @@ +package com.study.realworld.controller; + +import com.google.gson.JsonObject; + +public interface ControllerBase { + default String getString(JsonObject jsonObject, String name) { + return jsonObject.get(name).toString(); + } +} diff --git a/src/main/java/com/study/realworld/controller/UserController.java b/src/main/java/com/study/realworld/controller/UserController.java new file mode 100644 index 00000000..82b29e4e --- /dev/null +++ b/src/main/java/com/study/realworld/controller/UserController.java @@ -0,0 +1,52 @@ +package com.study.realworld.controller; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.study.realworld.bean.UserBean; +import com.study.realworld.common.Errors; +import com.study.realworld.common.Func; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequestMapping("/api") +public class UserController implements ControllerBase{ + public UserBean userBean; + + @Autowired + public UserController(UserBean userBean) { + this.userBean = userBean; + } + + @ApiOperation(value = "사용자 등록", notes = "사용자 등록") + @PostMapping("/users") //post 등록 api + public String users(@RequestBody Map param) { + JsonObject user = new Gson().toJsonTree(param).getAsJsonObject(); + if (userBean.checkSameName(getString((JsonObject) user.get("user"), "username"))) { //닉네임 체크 + return Func.getErrorJson(Errors.SAME_NICKNAME); + } else if (userBean.checkSameEmail(getString((JsonObject) user.get("user"), "email"))) { //email 체크 + return Func.getErrorJson(Errors.SAME_EMAIL); + } + + if ( userBean.registUser(getString((JsonObject) user.get("user"), "username"), getString((JsonObject) user.get("user"), "email"), getString((JsonObject) user.get("user"), "password")) < 0 ) { + //등록하다가 에러났을경우 + return Func.getErrorJson(Errors.DB); + } + + Map users = userBean.getUsers(getString((JsonObject) user.get("user"), "email")); + if ( users == null ) { + return Func.getErrorJson(Errors.INVALID_REQUEST); + } + JsonObject jsonObject = new Gson().toJsonTree(users).getAsJsonObject(); + JsonObject result = new JsonObject(); + result.add("user", jsonObject); + + return Func.getResultJson(result); + } +} diff --git a/src/main/java/com/study/realworld/dao/PSSetDao.java b/src/main/java/com/study/realworld/dao/PSSetDao.java new file mode 100644 index 00000000..e7781978 --- /dev/null +++ b/src/main/java/com/study/realworld/dao/PSSetDao.java @@ -0,0 +1,1604 @@ +package com.study.realworld.dao; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.springframework.jdbc.core.PreparedStatementSetter; + +public class PSSetDao { + public static class PSSForString implements PreparedStatementSetter { + private String lValue; + + public PSSForString(String l_value) { + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.lValue); + } + } + + public static class PSSForDoubleString implements PreparedStatementSetter { + private String rValue; + private String sValue; + + public PSSForDoubleString(String r_value, String s_value) { + this.rValue = r_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + + } + } + + public static class PSSForTripleString implements PreparedStatementSetter { + private String rValue; + private String sValue; + private String tValue; + + public PSSForTripleString(String r_value, String s_value, String t_value) { + this.rValue = r_value; + this.sValue = s_value; + this.tValue = t_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setString(3, this.tValue); + + } + } + + public static class PSSForFourString implements PreparedStatementSetter { + private String v1; + private String v2; + private String v3; + private String v4; + + public PSSForFourString(String v1, String v2, String v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + } + } + + public static class PSSForFiveString implements PreparedStatementSetter { + private String v1; + private String v2; + private String v3; + private String v4; + private String v5; + + public PSSForFiveString(String v1, String v2, String v3, String v4, String v5) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + ps.setString(5, this.v5); + } + } + + public static class PSSForTripleStringLong implements PreparedStatementSetter { + private String rValue; + private String sValue; + private String tValue; + private long l_value; + + public PSSForTripleStringLong(String r_value, String s_value, String t_value, long l_value) { + this.rValue = r_value; + this.sValue = s_value; + this.tValue = t_value; + this.l_value = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setString(3, this.tValue); + ps.setLong(4, this.l_value); + + } + } + + public static class PSSForDoubleStringInt implements PreparedStatementSetter { + private String rValue; + private String sValue; + private int iValue; + + public PSSForDoubleStringInt(String r_value, String s_value, int i_value) { + this.rValue = r_value; + this.sValue = s_value; + this.iValue = i_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setInt(3, this.iValue); + + } + } + + public static class PSSForDoubleStringDoubleInt implements PreparedStatementSetter { + private String v1; + private String v2; + private int v3; + private int v4; + + public PSSForDoubleStringDoubleInt(String v1, String v2, int v3, int v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.v1); + ps.setString(2, this.v2); + ps.setInt(3, this.v3); + ps.setInt(4, this.v4); + + } + } + + public static class PSSForDoubleStringLong implements PreparedStatementSetter { + private String rValue; + private String sValue; + private long iValue; + + public PSSForDoubleStringLong(String r_value, String s_value, long i_value) { + this.rValue = r_value; + this.sValue = s_value; + this.iValue = i_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setLong(3, this.iValue); + + } + } + + public static class PSSForIntBytes implements PreparedStatementSetter { + private int v1; + private Byte value[]; + + public PSSForIntBytes(int v1, Byte... value) { + this.v1 = v1; + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + + ps.setInt(1, this.v1); + for( int i = 1 ; i <= value.length ; i++ ) { + ps.setByte((i+1), this.value[i]); + } + } + } + + public static class PSSForInts implements PreparedStatementSetter { + private Integer value[]; + + public PSSForInts(Integer... value) { + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + + for( int i = 0 ; i < value.length ; i++ ) { + ps.setInt((i+1), this.value[i]); + } + } + } + + public static class PSSForStrings implements PreparedStatementSetter { + private String value[]; + + public PSSForStrings(String... value) { + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + + for( int i = 0 ; i < value.length ; i++ ) { + ps.setString((i+1), this.value[i]); + } + } + } + + public static class PSSForIntStrings implements PreparedStatementSetter { + private int v1; + private String value[]; + + public PSSForIntStrings(int v1, String... value) { + this.v1 = v1; + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + ps.setInt(pos++, this.v1); + for( int i = 0 ; i < value.length ; i++ ) { + ps.setString(pos++, this.value[i]); + } + } + } + + public static class PSSForInt implements PreparedStatementSetter { + private int lValue; + + public PSSForInt(int l_value) { + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + } + } + + public static class PSSForDoubleInt implements PreparedStatementSetter { + private int lValue; + private int rValue; + + public PSSForDoubleInt(int l_value, int r_value) { + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + } + } + + public static class PSSForDoubleIntString implements PreparedStatementSetter { + private int lValue; + private int rValue; + private String tValue; + + public PSSForDoubleIntString(int l_value, int r_value, String t_value) { + this.lValue = l_value; + this.rValue = r_value; + this.tValue = t_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.tValue); + } + } + + public static class PSSForTirpleIntString implements PreparedStatementSetter { + private int v1; + private int v2; + private int v3; + private String v4; + + public PSSForTirpleIntString(int v1, int v2, int v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setInt(2, this.v2); + ps.setInt(3, this.v3); + ps.setString(4, this.v4); + } + } + + public static class PSSForDoubleIntDoubleString implements PreparedStatementSetter { + private int lValue; + private int rValue; + private String tValue; + private String sValue; + + public PSSForDoubleIntDoubleString(int l_value, int r_value, String t_value, String s_value) { + this.lValue = l_value; + this.rValue = r_value; + this.tValue = t_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.tValue); + ps.setString(4, this.sValue); + } + } + + public static class PSSForLongDoubleInt implements PreparedStatementSetter { + private long aValue; + private int lValue; + private int rValue; + + public PSSForLongDoubleInt(long a_value, int l_value, int r_value) { + this.aValue = a_value; + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.aValue); + ps.setInt(2, this.lValue); + ps.setInt(3, this.rValue); + } + } + + public static class PSSForDoubleIntLong implements PreparedStatementSetter { + private int lValue; + private int rValue; + private long vValue; + + public PSSForDoubleIntLong(int l_value, int r_value, long v_value) { + this.lValue = l_value; + this.rValue = r_value; + this.vValue = v_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setLong(3, this.vValue); + } + } + + public static class PSSForStringDoubleInt implements PreparedStatementSetter { + private String sValue; + private int lValue; + private int rValue; + + public PSSForStringDoubleInt(String s_value, int l_value, int r_value) { + this.sValue = s_value; + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.lValue); + ps.setInt(3, this.rValue); + } + } + + public static class PSSForStringTripleInt implements PreparedStatementSetter { + private String sValue; + private int value1; + private int value2; + private int value3; + + public PSSForStringTripleInt(String s_value, int value1, int value2, int value3) { + this.sValue = s_value; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.value1); + ps.setInt(3, this.value2); + ps.setInt(4, this.value3); + } + } + + public static class PSSForLongTripleInt implements PreparedStatementSetter { + private long value0; + private int value1; + private int value2; + private int value3; + + public PSSForLongTripleInt(long value0, int value1, int value2, int value3) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.value0); + ps.setInt(2, this.value1); + ps.setInt(3, this.value2); + ps.setInt(4, this.value3); + } + } + + public static class PSSForTripleInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + + public PSSForTripleInt(int value1, int value2, int value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + } + } + + public static class PSSForDoubleIntLongString implements PreparedStatementSetter { + private int v1; + private int v2; + private long v3; + private String v4; + + public PSSForDoubleIntLongString(int v1, int v2, long v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setInt(2, this.v2); + ps.setLong(3, this.v3); + ps.setString(4, this.v4); + } + } + + public static class PSSForTripleIntLongString implements PreparedStatementSetter { + private int v1; + private int v2; + private int v3; + private long v4; + private String v5; + + public PSSForTripleIntLongString(int v1, int v2, int v3, long v4, String v5) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setInt(2, this.v2); + ps.setInt(3, this.v3); + ps.setLong(4, this.v4); + ps.setString(5, this.v5); + } + } + + public static class PSSForTripleIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + + public PSSForTripleIntString(int value1, int value2, int value3, String value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + } + } + + public static class PSSForTripleIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + private String value5; + + public PSSForTripleIntDoubleString(int value1, int value2, int value3, String value4, String value5) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + } + } + + public static class PSSForTripleIntFourString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + private String value5; + private String value6; + private String value7; + + public PSSForTripleIntFourString(int value1, int value2, int value3, String value4, String value5, String value6, String value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + ps.setString(6, this.value6); + ps.setString(7, this.value7); + } + } + + public static class PSSForIntStringInt implements PreparedStatementSetter { + private int value1; + private String value2; + private int value3; + + public PSSForIntStringInt(int value1, String value2, int value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setString(2, this.value2); + ps.setInt(3, this.value3); + } + } + + public static class PSSForDoubleIntTripleStringInt implements PreparedStatementSetter { + private int value1; + private int value2; + private String value3; + private String value4; + private String value5; + private int value6; + + public PSSForDoubleIntTripleStringInt(int value1, int value2, String value3, String value4, String value5, int value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setString(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + ps.setInt(6, this.value6); + } + } + + public static class PSSForTripleIntTripleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + private String value5; + private String value6; + + public PSSForTripleIntTripleString(int value1, int value2, int value3, String value4, String value5, String value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + ps.setString(6, this.value6); + } + } + + public static class PSSForFourInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + + public PSSForFourInt(int value1, int value2, int value3, int value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + } + } + + public static class PSSForFourIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private String value5; + + public PSSForFourIntString(int value1, int value2, int value3, int value4, String value5) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setString(5, this.value5); + } + } + + public static class PSSForFourIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private String value5; + private String value6; + + public PSSForFourIntDoubleString(int value1, int value2, int value3, int value4, String value5, String value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setString(5, this.value5); + ps.setString(6, this.value6); + } + } + + public static class PSSForFiveInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + + public PSSForFiveInt(int value1, int value2, int value3, int value4, int value5) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + } + } + + public static class PSSForFiveIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private String value6; + + public PSSForFiveIntString(int value1, int value2, int value3, int value4, int value5, String value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setString(6, this.value6); + } + } + + public static class PSSForFiveIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private String value6; + private String value7; + + public PSSForFiveIntDoubleString(int value1, int value2, int value3, int value4, int value5, String value6, String value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setString(6, this.value6); + ps.setString(7, this.value7); + } + } + + public static class PSSForSixInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + + public PSSForSixInt(int value1, int value2, int value3, int value4, int value5, int value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + } + } + + + public static class PSSForSixIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private String value7; + + public PSSForSixIntString(int value1, int value2, int value3, int value4, int value5, int value6, String value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setString(7, this.value7); + } + } + + public static class PSSForSixIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private String value7; + private String value8; + + public PSSForSixIntDoubleString(int value1, int value2, int value3, int value4, int value5, int value6, String value7, String value8) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setString(7, this.value7); + ps.setString(8, this.value8); + } + } + + public static class PSSForSevenIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + private String value8; + + public PSSForSevenIntString(int value1, int value2, int value3, int value4, int value5, int value6, int value7, String value8) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + ps.setString(8, this.value8); + } + } + + + public static class PSSForSevenInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + + public PSSForSevenInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + } + } + + public static class PSSForEightInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + private int value8; + + public PSSForEightInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + ps.setInt(8, this.value8); + } + } + + public static class PSSForNineInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + private int value8; + private int value9; + + public PSSForNineInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + this.value9 = value9; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + ps.setInt(8, this.value8); + ps.setInt(9, this.value9); + } + } + + public static class PSSForLongInt implements PreparedStatementSetter { + private long lValue; + private int rValue; + + public PSSForLongInt(long l_value, int r_value) { + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + ps.setInt(2, this.rValue); + } + } + + public static class PSSForLongIntLong implements PreparedStatementSetter { + private long v1; + private int v2; + private long v3; + + public PSSForLongIntLong(long v1, int v2, long v3) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.v1); + ps.setInt(2, this.v2); + ps.setLong(3, this.v3); + } + } + + public static class PSSForLongIntString implements PreparedStatementSetter { + private long lValue; + private int rValue; + private String sValue; + + public PSSForLongIntString(long l_value, int r_value, String s_value) { + this.lValue = l_value; + this.rValue = r_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.sValue); + } + } + + public static class PSSForLongStringLong implements PreparedStatementSetter { + private long value1; + private String value2; + private long value3; + + public PSSForLongStringLong(long value1, String value2, long value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.value1); + ps.setString(2, this.value2); + ps.setLong(3, this.value3); + } + } + + public static class PSSForIntLong implements PreparedStatementSetter { + private int rValue; + private long lValue; + + public PSSForIntLong(int r_value, long l_value) { + this.rValue = r_value; + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.rValue); + ps.setLong(2, this.lValue); + } + } + + public static class PSSForLong implements PreparedStatementSetter { + private long lValue; + + public PSSForLong(long l_value) { + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + } + } + + public static class PSSForDoubleLong implements PreparedStatementSetter { + private long lValue; + private long rValue; + + public PSSForDoubleLong(long l_value, long r_value) { + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + ps.setLong(2, this.rValue); + } + } + + public static class PSSForIntString implements PreparedStatementSetter { + private int rValue; + private String sValue; + + public PSSForIntString(int r_value, String s_value) { + this.rValue = r_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.rValue); + ps.setString(2, this.sValue); + } + } + + public static class PSSForIntDoubleString implements PreparedStatementSetter { + private int rValue; + private String sValue1; + private String sValue2; + + public PSSForIntDoubleString(int r_value, String s_value1, String s_value2) { + this.rValue = r_value; + this.sValue1 = s_value1; + this.sValue2 = s_value2; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.rValue); + ps.setString(2, this.sValue1); + ps.setString(3, this.sValue2); + } + } + + public static class PSSForIntTripleString implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private String v4; + + public PSSForIntTripleString(int v1, String v2, String v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(3, this.v4); + } + } + + public static class PSSForIntStringDoubleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private int v3; + private int v4; + + public PSSForIntStringDoubleInt(int v1, String v2, int v3, int v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setInt(3, this.v3); + ps.setInt(4, this.v4); + } + } + + public static class PSSForIntDoubleStringDoubleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private int v4; + private int v5; + + public PSSForIntDoubleStringDoubleInt(int v1, String v2, String v3, int v4, int v5) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setInt(4, this.v4); + ps.setInt(5, this.v5); + } + } + + public static class PSSForIntTripleStringDoubleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private String v4; + private int v5; + private int v6; + + public PSSForIntTripleStringDoubleInt(int v1, String v2, String v3, String v4, int v5, int v6) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + this.v6 = v6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + ps.setInt(5, this.v5); + ps.setInt(6, this.v6); + } + } + + public static class PSSForIntDoubleStringTripleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private int v4; + private int v5; + private int v6; + + public PSSForIntDoubleStringTripleInt(int v1, String v2, String v3, int v4, int v5, int v6) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + this.v6 = v6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setInt(4, this.v4); + ps.setInt(5, this.v5); + ps.setInt(6, this.v6); + } + } + + public static class PSSForIntFiveString implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private String v4; + private String v5; + private String v6; + + public PSSForIntFiveString(int v1, String v2, String v3, String v4, String v5, String v6) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + this.v6 = v6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + ps.setString(5, this.v5); + ps.setString(6, this.v6); + } + } + + public static class PSSForStringInt implements PreparedStatementSetter { + private String sValue; + private int rValue; + + public PSSForStringInt(String s_value, int r_value) { + this.sValue = s_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.rValue); + } + } + public static class PSSForDoubleStringDoubleIntString implements PreparedStatementSetter { + private String sValue1; + private String sValue2; + private String sValue3; + private int rValue1; + private int rValue2; + + public PSSForDoubleStringDoubleIntString(String sValue1,String sValue2, int rValue1, int rValue2,String sValue3) { + this.sValue1 = sValue1; + this.sValue2 = sValue2; + this.sValue3 = sValue3; + this.rValue1 = rValue1; + this.rValue2 = rValue2; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue1); + ps.setString(2, this.sValue2); + ps.setInt(3, this.rValue1); + ps.setInt(4, this.rValue2); + ps.setString(5, this.sValue3); + } + } + + public static class PSSForStringLong implements PreparedStatementSetter { + private String sValue; + private long rValue; + + public PSSForStringLong(String s_value, long r_value) { + this.sValue = s_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setLong(2, this.rValue); + } + } + + public static class PSSForStringIntLong implements PreparedStatementSetter { + private String value1; + private int value2; + private long value3; + + public PSSForStringIntLong(String value1, int value2, long value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setInt(2, this.value2); + ps.setLong(3, this.value3); + } + } + + public static class PSSForStringDoubleIntLong implements PreparedStatementSetter { + private String value1; + private int value2; + private int value3; + private long value4; + + public PSSForStringDoubleIntLong(String value1, int value2, int value3, long value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setLong(4, this.value4); + } + } + + public static class PSSForStringLongInt implements PreparedStatementSetter { + private String value1; + private long value2; + private int value3; + + public PSSForStringLongInt(String value1, long value2, int value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setLong(2, this.value2); + ps.setInt(3, this.value3); + } + } + + public static class PSSForStringDoubleLongInt implements PreparedStatementSetter { + private String value1; + private long value2; + private long value3; + private int value4; + + public PSSForStringDoubleLongInt(String value1, long value2, long value3, int value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setLong(2, this.value2); + ps.setLong(3, this.value3); + ps.setInt(4, this.value4); + } + } + + public static class PSSForStringIntString implements PreparedStatementSetter { + private String sValue; + private int rValue; + private String tValue; + + public PSSForStringIntString(String s_value, int r_value, String t_value) { + this.sValue = s_value; + this.rValue = r_value; + this.tValue = t_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.tValue); + } + } + + public static class PSSForSIIS implements PreparedStatementSetter { + private String s1; + private int i1; + private int i2; + private String s2; + + public PSSForSIIS(String s1, int i1, int i2, String s2) { + this.s1 = s1; + this.i1 = i1; + this.i2 = i2; + this.s2 = s2; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.s1); + ps.setInt(2, this.i1); + ps.setInt(3, this.i2); + ps.setString(4, this.s2); + } + } + + public static class PSSForStringInts implements PreparedStatementSetter { + private String s1; + private Integer ints[]; + + public PSSForStringInts(String s1, Integer...ints) { + this.s1 = s1; + this.ints = ints; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int count = 1; + ps.setString(count++, this.s1); + for( int i = 0 ; i < ints.length ; i++ ) { + ps.setInt(count++, this.ints[i]); + } + } + } + + public static class PSSForIntsStrings implements PreparedStatementSetter { + int intCount; + int stringCount; + Object objects[]; + + public PSSForIntsStrings(int intCount, int stringCount, Object...objects) { + this.intCount = intCount; + this.stringCount = stringCount; + this.objects = objects; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + for( int i = 0 ; i < intCount ; i++ ) ps.setInt(pos++, (Integer)objects[i]); + for( int i = 0 ; i < stringCount ; i++ ) ps.setString(pos++, (String)objects[i+intCount]); + } + } + + public static class PSSForStringsInts implements PreparedStatementSetter { + int stringCount; + int intCount; + Object objects[]; + + public PSSForStringsInts(int stringCount, int intCount, Object...objects) { + this.stringCount = stringCount; + this.intCount = intCount; + this.objects = objects; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + for( int i = 0 ; i < stringCount ; i++ ) ps.setString(pos++, (String)objects[i]); + for( int i = 0 ; i < intCount ; i++ ) ps.setInt(pos++, (Integer)objects[i+stringCount]); + } + } + + public static class PSSForIntStringInts implements PreparedStatementSetter { + private int i1; + private String s1; + private Integer ints[]; + + public PSSForIntStringInts(int i1, String s1, Integer...ints) { + this.i1 = i1; + this.s1 = s1; + this.ints = ints; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int count = 1; + ps.setInt(count++, this.i1); + ps.setString(count++, this.s1); + for( int i = 0 ; i < ints.length ; i++ ) { + ps.setInt(count++, this.ints[i]); + } + } + } + + public static class PSSForTripleIntStrings implements PreparedStatementSetter { + private int v1; + private int v2; + private int v3; + private String strings[]; + + public PSSForTripleIntStrings(int v1, int v2, int v3, String...strings) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.strings = strings; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int count = 1; + ps.setInt(count++, this.v1); + ps.setInt(count++, this.v2); + ps.setInt(count++, this.v3); + for( int i = 0 ; i < strings.length ; i++ ) { + ps.setString(count++, this.strings[i]); + } + } + } + + public static class PSSForStringsIntsStrings implements PreparedStatementSetter { + int stringCount; + int intCount; + int stringCount2; + Object objects[]; + + public PSSForStringsIntsStrings(int stringCount, int intCount, int stringCount2, Object...objects) { + this.stringCount = stringCount; + this.intCount = intCount; + this.stringCount2 = stringCount2; + this.objects = objects; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + for( int i = 0 ; i < stringCount ; i++ ) ps.setString(pos++, (String)objects[i]); + for( int i = 0 ; i < intCount ; i++ ) ps.setInt(pos++, (Integer)objects[i+stringCount]); + for( int i = 0 ; i < stringCount2 ; i++ ) ps.setString(pos++, (String)objects[i+stringCount+intCount]); + } + } + +} diff --git a/src/main/java/com/study/realworld/dao/ResultDao.java b/src/main/java/com/study/realworld/dao/ResultDao.java new file mode 100644 index 00000000..1f28525e --- /dev/null +++ b/src/main/java/com/study/realworld/dao/ResultDao.java @@ -0,0 +1,187 @@ +package com.study.realworld.dao; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.ResultSetExtractor; + +public class ResultDao { + public static class RSEForResult implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int z; + Map row = null; + + if (rs.next() == true) { + rsMeta = rs.getMetaData(); + + row = new HashMap(); + + rs.first(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + } + + return row; + } + } + + @SuppressWarnings("unchecked") + public static class RSEForResultSet implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int size; + int i; + int z; + Map [] row = null; + + rsMeta = rs.getMetaData(); + + rs.last(); + + size = rs.getRow(); + + if (size > 0) { + row = new Map[size]; + + rs.first(); + + for (i = 0; i < size; i++) { + row[i] = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row[i].put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + + rs.next(); + } + } + + return row; + } + } + + public static class RSEForResultListSet implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int size; + int i; + int z; + List> list = null; + + rsMeta = rs.getMetaData(); + + rs.last(); + + size = rs.getRow(); + + if (size > 0) { + list = new ArrayList>(); + + rs.first(); + + for (i = 0; i < size; i++) { + Map row = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + list.add(row); + + rs.next(); + } + } + + return list; + } + } + + public static class RSEForInt implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getInt(1); + } else { + return 0; + } + } + } + + public static class RSEForString implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getString(1); + } else { + return null; + } + } + } + + public static class RSEForBoolean implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getBoolean(1); + } else { + return false; + } + } + } + + public static class RSEForIntList implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + List lst = new ArrayList(); + + for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + lst.add(rs.getInt(i)); + } + + return lst; + } else { + return null; + } + } + } + + + public static class RSEForStringList implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + List lst = new ArrayList(); + + for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + lst.add(rs.getString(i)); + } + + return lst; + } else { + return null; + } + } + } + + public static class RSEForIntListFromRows implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + List lst = new ArrayList(); + + while (rs.next()) { + lst.add(rs.getInt(1)); + } + + return lst; + } + } +} diff --git a/src/main/java/com/study/realworld/secure/GUIDGenerator.java b/src/main/java/com/study/realworld/secure/GUIDGenerator.java new file mode 100644 index 00000000..442e4702 --- /dev/null +++ b/src/main/java/com/study/realworld/secure/GUIDGenerator.java @@ -0,0 +1,33 @@ +package com.study.realworld.secure; + +import java.util.Random; + +public class GUIDGenerator implements IGenerator { + + protected final int _length; + protected final Random _random; + + public GUIDGenerator(int length) throws Exception { + if( length < 1 ) throw new IllegalArgumentException("length < 1: " + length); + _length = length; + _random = makeRand(); + } + + protected Random makeRand() { + return new Random(); + } + + @Override + public String generate() { + StringBuilder guid = new StringBuilder(_length); + for( int i = 0 ; i < _length ; i++ ) guid.append( _upper.charAt( _random.nextInt(_upper.length()) ) ); + return guid.toString(); + } + + @Override + public String generateHex() { + StringBuilder guid = new StringBuilder(_length); + for( int i = 0 ; i < _length ; i++ ) guid.append( _upperHex.charAt( _random.nextInt(_upperHex.length()) ) ); + return guid.toString(); + } +} diff --git a/src/main/java/com/study/realworld/secure/IGenerator.java b/src/main/java/com/study/realworld/secure/IGenerator.java new file mode 100644 index 00000000..89ca3ee6 --- /dev/null +++ b/src/main/java/com/study/realworld/secure/IGenerator.java @@ -0,0 +1,9 @@ +package com.study.realworld.secure; + +public interface IGenerator { + static final String _upper = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static final String _upperHex = "0123456789ABCDEF"; + + String generate(); + String generateHex(); +} \ No newline at end of file diff --git a/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java b/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java new file mode 100644 index 00000000..843726f7 --- /dev/null +++ b/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java @@ -0,0 +1,29 @@ +package com.study.realworld.secure; + +import java.security.SecureRandom; + +public class SecureGUIDGenerator extends GUIDGenerator { + public SecureGUIDGenerator(int length) throws Exception { + super(length); + } + + protected SecureRandom makeRand() { + return new SecureRandom(); + } + + public static String gen(int length) { + try { + return new SecureGUIDGenerator(length).generate(); + } catch (Exception e) { + return null; + } + } + + public static String genHex(int length) { + try { + return new SecureGUIDGenerator(length).generateHex(); + } catch (Exception e) { + return null; + } + } +} diff --git a/src/main/java/com/study/realworld/secure/SecurityFunc.java b/src/main/java/com/study/realworld/secure/SecurityFunc.java new file mode 100644 index 00000000..c471e16b --- /dev/null +++ b/src/main/java/com/study/realworld/secure/SecurityFunc.java @@ -0,0 +1,132 @@ +package com.study.realworld.secure; + +import java.io.PrintWriter; +import java.math.BigInteger; +import java.security.Key; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.RSAPublicKeySpec; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import javax.servlet.http.HttpSession; +import javax.xml.bind.DatatypeConverter; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; + +import com.study.realworld.common.Func; + +public class SecurityFunc { + public static final String RSA_ALGORITHM = "RSA"; + public static final String AES_ALGORITHM = "AES"; + public static String AES_ALGORITHM_ENCRYPT = "AES/ECB/PKCS5Padding"; + + private static final String SESSION_SECURITY_KEY = "SECURITY_KEY"; + private static final int AES_LEN = 16; + + public static String encryptData(final String algorithm, final Key key, final T data) { + String json = new Gson().toJson(data); + if( null == json ) return null; + + try { + return encrypt(algorithm, key, json); + } + catch ( Exception e ) { + e.printStackTrace(); + } + return null; + } + + public static String encrypt(final String algorithm, final Key key, final String data) throws Exception { + return encrypt(algorithm, key, data.getBytes("utf-8")); + } + + public static String encrypt(final String algorithm, final Key key, final byte[] bytes) throws Exception { + + String cipherAlgorithm = algorithm; + + if( algorithm.equals(AES_ALGORITHM) ) { + cipherAlgorithm = AES_ALGORITHM_ENCRYPT; + } + + Cipher cipher = Cipher.getInstance(cipherAlgorithm); + cipher.init(Cipher.ENCRYPT_MODE, key); + + byte[] encryptBytes = cipher.doFinal(bytes); + + return DatatypeConverter.printHexBinary(encryptBytes); + } + + public static T decryptData(final Key key, final String bin, final Class classOfT) throws Exception { + return SecurityFunc.decryptData(SecurityFunc.AES_ALGORITHM, key, bin, classOfT); + } + + public static T decryptData(final String algorithm, final Key key, final String bin, final Class classOfT) throws Exception { + String json = decrypt(algorithm, key, bin); + if( null == json ) return null; + + return new Gson().fromJson(json, classOfT); + } + + public static String decrypt(final String algorithm, Key key, String binData) throws Exception { + + byte[] bytes = DatatypeConverter.parseHexBinary(binData); + + if( null == bytes ) return null; + + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.DECRYPT_MODE, key); + + byte[] decryptedBytes = cipher.doFinal(bytes); + + return new String(decryptedBytes, "utf-8"); + } + + public static Key generateKey(String algorithm, byte[] keyData) throws NoSuchAlgorithmException { + return new SecretKeySpec(keyData, algorithm); + } + + public static Key generateRSAKey(String modulus, String exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { + return generateRSAKey(new BigInteger(modulus, 16), new BigInteger(exponent, 16)); + } + + public static Key generateRSAKey(BigInteger modulus, BigInteger exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { + RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(modulus, exponent); + + KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); + + return keyFactory.generatePublic(pubKeySpec); + } + + public static class ResKey { + String key; + public ResKey(String key) { + this.key = key; + } + } + + public static void reqKey(HttpSession session, String modulus, String exponent, PrintWriter out) throws Exception { + Key aeskey = (Key) session.getAttribute( SESSION_SECURITY_KEY ); + if (null == aeskey) { + String strHex = SecureGUIDGenerator.genHex(AES_LEN); + aeskey = generateKey(SecurityFunc.AES_ALGORITHM, strHex.getBytes()); + session.setAttribute(SESSION_SECURITY_KEY, aeskey); + } + + String strAseKey = DatatypeConverter.printHexBinary(aeskey.getEncoded()); + + Key rsaPubKey = generateRSAKey(modulus, exponent); + + String bin = SecurityFunc.encryptData(RSA_ALGORITHM, rsaPubKey, new ResKey(strAseKey)); + + JsonObject result = new JsonObject(); + result.addProperty("bin", bin); + out.write(Func.getResultJson(result)); + } + + public static Key getKey( HttpSession session ) throws Exception { + return (Key) session.getAttribute( SESSION_SECURITY_KEY ); + } +} \ No newline at end of file diff --git a/src/main/java/com/study/realworld/swagger/SwaggerConfig.java b/src/main/java/com/study/realworld/swagger/SwaggerConfig.java new file mode 100644 index 00000000..530ddf1d --- /dev/null +++ b/src/main/java/com/study/realworld/swagger/SwaggerConfig.java @@ -0,0 +1,51 @@ +package com.study.realworld.swagger; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.HashSet; +import java.util.Set; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("Demo") + .description("API EXAMPLE") + .version("1.0") + .build(); + } + + private Set getConsumeContentTypes() { + Set consumes = new HashSet<>(); + consumes.add("application/json;charset=UTF-8"); + consumes.add("application/x-www-form-urlencoded"); + return consumes; + } + + private Set getProduceContentTypes() { + Set produces = new HashSet<>(); + produces.add("application/json;charset=UTF-8"); + return produces; + } + + @Bean + public Docket commonApi() { + return new Docket(DocumentationType.SWAGGER_2) + .consumes(getConsumeContentTypes()) + .produces(getProduceContentTypes()) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.ant("/api/**")) + .build(); + } +} From c04e473d90050f8aced9e36bfe667f8e173e7bb2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Aug 2021 12:33:26 +0900 Subject: [PATCH 04/13] =?UTF-8?q?getUsers=20=EC=A3=BC=EC=84=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/study/realworld/bean/UserBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/study/realworld/bean/UserBean.java b/src/main/java/com/study/realworld/bean/UserBean.java index 220e7939..320b3251 100644 --- a/src/main/java/com/study/realworld/bean/UserBean.java +++ b/src/main/java/com/study/realworld/bean/UserBean.java @@ -34,7 +34,7 @@ public int registUser(String username, String email, String password) { //신규 return jdbcTemplate.update(query, new PSSetDao.PSSForTripleString(username, email, password)); } - public Map getUsers(String email) { + public Map getUsers(String email) { //getUsers final String query = "select email,username,bio,image from USER where email=?"; return (Map) jdbcTemplate.query(query, new PSSetDao.PSSForString(email), new ResultDao.RSEForResult()); } From 1f7101bf54f5f621387b4af42e2e8c0a4502cfd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Aug 2021 16:49:22 +0900 Subject: [PATCH 05/13] =?UTF-8?q?[#6]=20refactor:=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EB=B6=84=EB=A6=AC,=20map=EB=8C=80=EC=8B=A0=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EB=A1=9C=20=EB=B6=88=EB=9F=AC=EC=98=A4?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/study/realworld/bean/User.java | 41 +++++++++++++++ .../realworld/controller/ControllerBase.java | 9 ---- .../realworld/controller/UserController.java | 37 +++----------- .../{bean/UserBean.java => dao/UserDao.java} | 11 ++-- .../study/realworld/service/UserService.java | 50 +++++++++++++++++++ 5 files changed, 105 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/study/realworld/bean/User.java delete mode 100644 src/main/java/com/study/realworld/controller/ControllerBase.java rename src/main/java/com/study/realworld/{bean/UserBean.java => dao/UserDao.java} (79%) create mode 100644 src/main/java/com/study/realworld/service/UserService.java diff --git a/src/main/java/com/study/realworld/bean/User.java b/src/main/java/com/study/realworld/bean/User.java new file mode 100644 index 00000000..4d3a2e6e --- /dev/null +++ b/src/main/java/com/study/realworld/bean/User.java @@ -0,0 +1,41 @@ +package com.study.realworld.bean; + +public class User { + private String email; + private String token; + private String username; + private String bio; + private String image; + + public User(String email, String username, String bio, String image) { + this.email = email; + this.username = username; + this.bio = bio; + this.image = image; + } + + public void setToken(String token) { + this.token = token; + } + + public String getEmail() { + return email; + } + + public String getToken() { + return token; + } + + public String getUsername() { + return username; + } + + public String getBio() { + return bio; + } + + public String getImage() { + return image; + } + +} diff --git a/src/main/java/com/study/realworld/controller/ControllerBase.java b/src/main/java/com/study/realworld/controller/ControllerBase.java deleted file mode 100644 index 461c1d85..00000000 --- a/src/main/java/com/study/realworld/controller/ControllerBase.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.study.realworld.controller; - -import com.google.gson.JsonObject; - -public interface ControllerBase { - default String getString(JsonObject jsonObject, String name) { - return jsonObject.get(name).toString(); - } -} diff --git a/src/main/java/com/study/realworld/controller/UserController.java b/src/main/java/com/study/realworld/controller/UserController.java index 82b29e4e..47d986f0 100644 --- a/src/main/java/com/study/realworld/controller/UserController.java +++ b/src/main/java/com/study/realworld/controller/UserController.java @@ -1,10 +1,14 @@ package com.study.realworld.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.study.realworld.bean.UserBean; +import com.study.realworld.bean.User; +import com.study.realworld.dao.UserDao; import com.study.realworld.common.Errors; import com.study.realworld.common.Func; +import com.study.realworld.service.UserService; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -16,37 +20,12 @@ @RestController @RequestMapping("/api") -public class UserController implements ControllerBase{ - public UserBean userBean; - - @Autowired - public UserController(UserBean userBean) { - this.userBean = userBean; - } +public class UserController{ @ApiOperation(value = "사용자 등록", notes = "사용자 등록") @PostMapping("/users") //post 등록 api - public String users(@RequestBody Map param) { + public String users(@RequestBody Map param) throws JsonProcessingException { JsonObject user = new Gson().toJsonTree(param).getAsJsonObject(); - if (userBean.checkSameName(getString((JsonObject) user.get("user"), "username"))) { //닉네임 체크 - return Func.getErrorJson(Errors.SAME_NICKNAME); - } else if (userBean.checkSameEmail(getString((JsonObject) user.get("user"), "email"))) { //email 체크 - return Func.getErrorJson(Errors.SAME_EMAIL); - } - - if ( userBean.registUser(getString((JsonObject) user.get("user"), "username"), getString((JsonObject) user.get("user"), "email"), getString((JsonObject) user.get("user"), "password")) < 0 ) { - //등록하다가 에러났을경우 - return Func.getErrorJson(Errors.DB); - } - - Map users = userBean.getUsers(getString((JsonObject) user.get("user"), "email")); - if ( users == null ) { - return Func.getErrorJson(Errors.INVALID_REQUEST); - } - JsonObject jsonObject = new Gson().toJsonTree(users).getAsJsonObject(); - JsonObject result = new JsonObject(); - result.add("user", jsonObject); - - return Func.getResultJson(result); + return UserService.users((JsonObject) user.get("user")); } } diff --git a/src/main/java/com/study/realworld/bean/UserBean.java b/src/main/java/com/study/realworld/dao/UserDao.java similarity index 79% rename from src/main/java/com/study/realworld/bean/UserBean.java rename to src/main/java/com/study/realworld/dao/UserDao.java index 320b3251..4b421ff6 100644 --- a/src/main/java/com/study/realworld/bean/UserBean.java +++ b/src/main/java/com/study/realworld/dao/UserDao.java @@ -1,5 +1,6 @@ -package com.study.realworld.bean; +package com.study.realworld.dao; +import com.study.realworld.bean.User; import com.study.realworld.dao.PSSetDao; import com.study.realworld.dao.ResultDao; import org.springframework.beans.factory.annotation.Autowired; @@ -11,11 +12,11 @@ import java.util.Map; @Component -public class UserBean { +public class UserDao { private final JdbcTemplate jdbcTemplate; @Autowired - public UserBean(JdbcTemplate jdbcTemplate) { + public UserDao(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } @@ -34,8 +35,8 @@ public int registUser(String username, String email, String password) { //신규 return jdbcTemplate.update(query, new PSSetDao.PSSForTripleString(username, email, password)); } - public Map getUsers(String email) { //getUsers + public User getUsers(String email) { //getUsers final String query = "select email,username,bio,image from USER where email=?"; - return (Map) jdbcTemplate.query(query, new PSSetDao.PSSForString(email), new ResultDao.RSEForResult()); + return jdbcTemplate.queryForObject(query, (rs, rowNum) -> new User(rs.getString("email"), rs.getString("username"), rs.getString("bio"), rs.getString("image")), email); } } diff --git a/src/main/java/com/study/realworld/service/UserService.java b/src/main/java/com/study/realworld/service/UserService.java new file mode 100644 index 00000000..b1c1f809 --- /dev/null +++ b/src/main/java/com/study/realworld/service/UserService.java @@ -0,0 +1,50 @@ +package com.study.realworld.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonObject; +import com.study.realworld.bean.User; +import com.study.realworld.common.Errors; +import com.study.realworld.common.Func; +import com.study.realworld.dao.UserDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserService { + private static UserDao userDao; + + @Autowired + public UserService(UserDao userDao) { + this.userDao = userDao; + } + + public static String users(JsonObject user) throws JsonProcessingException { + if (userDao.checkSameName(getString(user, "username"))) { //닉네임 체크 + return Func.getErrorJson(Errors.SAME_NICKNAME); + } else if (userDao.checkSameEmail(getString(user, "email"))) { //email 체크 + return Func.getErrorJson(Errors.SAME_EMAIL); + } + + if ( userDao.registUser(getString(user, "username"), + getString(user, "email"), + getString(user, "password")) < 0 ) { + //등록하다가 에러났을경우 + return Func.getErrorJson(Errors.DB); + } + + User users = userDao.getUsers(getString(user, "email")); + if ( users == null ) { + return Func.getErrorJson(Errors.INVALID_REQUEST); + } + JsonObject result = new JsonObject(); + ObjectMapper objectMapper = new ObjectMapper(); + result.addProperty("user", objectMapper.writeValueAsString(users)); + + return Func.getResultJson(result); + } + + static String getString(JsonObject jsonObject, String name) { + return jsonObject.get(name).toString(); + } +} From d2a8e48ee30dbae1b7ce9149453874fa6609dd04 Mon Sep 17 00:00:00 2001 From: com8599 Date: Mon, 9 Aug 2021 17:06:16 +0900 Subject: [PATCH 06/13] =?UTF-8?q?[#6]=20refactor:=20depth=202=20=EC=9D=B4?= =?UTF-8?q?=ED=95=98=EB=A1=9C=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 최진영 --- src/main/java/com/study/realworld/common/Func.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/study/realworld/common/Func.java b/src/main/java/com/study/realworld/common/Func.java index feb7961f..d7da2a0b 100644 --- a/src/main/java/com/study/realworld/common/Func.java +++ b/src/main/java/com/study/realworld/common/Func.java @@ -11,10 +11,12 @@ public static String getErrorJson( Errors error, Object...objects ) { json.addProperty("E", String.valueOf(error.getCode())); - if(objects != null && objects.length > 0) { - for(int i = 0; i < objects.length; i = i + 2) { - json.addProperty(String.valueOf(objects[i]), String.valueOf(objects[i + 1])); - } + if(objects == null && objects.length == 0) { + return json.toString(); + } + + for(int i = 0; i < objects.length; i = i + 2) { + json.addProperty(String.valueOf(objects[i]), String.valueOf(objects[i + 1])); } System.out.println(error.name() + " - " + error.getCode() + " - " + error.getDesc()); From 892214adaafaecbe5e77b67bc5035f8b3fcc7faa Mon Sep 17 00:00:00 2001 From: com8599 Date: Mon, 9 Aug 2021 17:10:59 +0900 Subject: [PATCH 07/13] =?UTF-8?q?[#6]=20refactor:=20=EC=83=81=EC=88=98-?= =?UTF-8?q?=EC=9E=90=EB=B0=94=EC=BB=A8=EB=B2=A4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 상수에 대한 자바 컨벤션은 항상 대문자 스네이크 이다. Co-authored-by: 최진영 --- src/main/java/com/study/realworld/secure/IGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/study/realworld/secure/IGenerator.java b/src/main/java/com/study/realworld/secure/IGenerator.java index 89ca3ee6..56ba709f 100644 --- a/src/main/java/com/study/realworld/secure/IGenerator.java +++ b/src/main/java/com/study/realworld/secure/IGenerator.java @@ -1,9 +1,9 @@ package com.study.realworld.secure; public interface IGenerator { - static final String _upper = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - static final String _upperHex = "0123456789ABCDEF"; + static final String UPPER = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static final String UPPER_HEX = "0123456789ABCDEF"; String generate(); String generateHex(); -} \ No newline at end of file +} From c93206521cfb0074079f77280a1c569cf9145066 Mon Sep 17 00:00:00 2001 From: com8599 Date: Mon, 9 Aug 2021 17:11:47 +0900 Subject: [PATCH 08/13] =?UTF-8?q?[#6]=20refactor:=20=EB=B3=80=EC=88=98-?= =?UTF-8?q?=EC=9E=90=EB=B0=94=EC=BB=A8=EB=B2=A4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 변수명에는 언더바를 쓰지않는것이 자바컨벤션입니다. Co-authored-by: 최진영 --- src/main/java/com/study/realworld/secure/GUIDGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/study/realworld/secure/GUIDGenerator.java b/src/main/java/com/study/realworld/secure/GUIDGenerator.java index 442e4702..1a7d2c64 100644 --- a/src/main/java/com/study/realworld/secure/GUIDGenerator.java +++ b/src/main/java/com/study/realworld/secure/GUIDGenerator.java @@ -4,8 +4,8 @@ public class GUIDGenerator implements IGenerator { - protected final int _length; - protected final Random _random; + protected final int length; + protected final Random random; public GUIDGenerator(int length) throws Exception { if( length < 1 ) throw new IllegalArgumentException("length < 1: " + length); From 803a1b819ed8553120b449ce5f848f0e8cf4cd27 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Aug 2021 17:30:09 +0900 Subject: [PATCH 09/13] =?UTF-8?q?[#6]=20refactor:=20=EC=9E=90=EB=B0=94?= =?UTF-8?q?=EC=BB=A8=EB=B2=A4=EC=85=98=20=EA=B7=9C=EC=B9=99=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EC=B6=B0=EC=84=9C=20=EC=A0=84=EC=B2=B4=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/study/realworld/common/Errors.java | 63 +- .../java/com/study/realworld/common/Func.java | 33 +- .../realworld/controller/UserController.java | 9 +- .../com/study/realworld/dao/PSSetDao.java | 3189 +++++++++-------- .../com/study/realworld/dao/ResultDao.java | 344 +- .../java/com/study/realworld/dao/UserDao.java | 2 + .../study/realworld/secure/GUIDGenerator.java | 18 +- .../study/realworld/secure/IGenerator.java | 7 +- .../realworld/secure/SecureGUIDGenerator.java | 46 +- .../study/realworld/secure/SecurityFunc.java | 220 +- .../study/realworld/service/UserService.java | 10 +- 11 files changed, 1969 insertions(+), 1972 deletions(-) diff --git a/src/main/java/com/study/realworld/common/Errors.java b/src/main/java/com/study/realworld/common/Errors.java index b5027243..9d089a81 100644 --- a/src/main/java/com/study/realworld/common/Errors.java +++ b/src/main/java/com/study/realworld/common/Errors.java @@ -1,31 +1,40 @@ package com.study.realworld.common; public enum Errors { - EXCEPTION (-1, "통신중 에러가 발생했습니다."), - NONE (0, "이상없음"), - INVALID_REQUEST (1, "잘못된 요청입니다."), - DB (2, "데이터 베이스 오류입니다."), - SAME_NICKNAME (3, "동일 닉네임유저가 존재합니다."), - SAME_EMAIL (4, "동일 이메일유저가 존재합니다."), - - NOT_FOUND_SESSION_USER (10000, "유저 정보를 찾을 수 없습니다."), - -// mobile auth - SQLEXCEPTION (-2, "서버와 통신중 에러가 발생했습니다."), - ; - - private int code; - private String desc; - Errors(int code, String desc) { - this.code = code; - this.desc = desc; - } - public int getCode() { return code; } - public String getDesc() { return desc; } - public static Errors parse(int code) { - for( Errors e : Errors.values() ) { - if( code == e.getCode() ) { return e; } - } - return INVALID_REQUEST; - } + EXCEPTION(-1, "통신중 에러가 발생했습니다."), + NONE(0, "이상없음"), + INVALID_REQUEST(1, "잘못된 요청입니다."), + DB(2, "데이터 베이스 오류입니다."), + SAME_NICKNAME(3, "동일 닉네임유저가 존재합니다."), + SAME_EMAIL(4, "동일 이메일유저가 존재합니다."), + + NOT_FOUND_SESSION_USER(10000, "유저 정보를 찾을 수 없습니다."), + + SQLEXCEPTION(-2, "서버와 통신중 에러가 발생했습니다."), + ; + + private int code; + private String desc; + + Errors(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + public static Errors parse(int code) { + for (Errors e : Errors.values()) { + if (code == e.getCode()) { + return e; + } + } + return INVALID_REQUEST; + } } \ No newline at end of file diff --git a/src/main/java/com/study/realworld/common/Func.java b/src/main/java/com/study/realworld/common/Func.java index d7da2a0b..0a06fa38 100644 --- a/src/main/java/com/study/realworld/common/Func.java +++ b/src/main/java/com/study/realworld/common/Func.java @@ -6,49 +6,28 @@ import java.security.Key; public class Func { - public static String getErrorJson( Errors error, Object...objects ) { + public static String getErrorJson(Errors error, Object... objects) { JsonObject json = new JsonObject(); json.addProperty("E", String.valueOf(error.getCode())); - if(objects == null && objects.length == 0) { + if (objects == null && objects.length == 0) { return json.toString(); } - - for(int i = 0; i < objects.length; i = i + 2) { + + for (int i = 0; i < objects.length; i = i + 2) { json.addProperty(String.valueOf(objects[i]), String.valueOf(objects[i + 1])); } System.out.println(error.name() + " - " + error.getCode() + " - " + error.getDesc()); return json.toString(); } - public static String getResultJson( JsonObject result ) { + + public static String getResultJson(JsonObject result) { JsonObject json = new JsonObject(); json.add("R", result); return result.toString(); } - public static String getZipJson( String bin ) { - JsonObject json = new JsonObject(); - - json.addProperty("Z", bin); - - return json.toString(); - } - - public static class RseBinJson { - JsonObject R; - } - - public static String getBinJson(JsonObject result, Key key) { - RseBinJson rse = new RseBinJson(); - rse.R = result; - - JsonObject json = new JsonObject(); - - json.addProperty("B", SecurityFunc.encryptData(SecurityFunc.AES_ALGORITHM, key, rse)); - - return json.toString(); - } } diff --git a/src/main/java/com/study/realworld/controller/UserController.java b/src/main/java/com/study/realworld/controller/UserController.java index 47d986f0..b5c9e1b0 100644 --- a/src/main/java/com/study/realworld/controller/UserController.java +++ b/src/main/java/com/study/realworld/controller/UserController.java @@ -20,12 +20,17 @@ @RestController @RequestMapping("/api") -public class UserController{ +public class UserController { + UserService userService; + + public UserController(UserService userService) { + this.userService = userService; + } @ApiOperation(value = "사용자 등록", notes = "사용자 등록") @PostMapping("/users") //post 등록 api public String users(@RequestBody Map param) throws JsonProcessingException { JsonObject user = new Gson().toJsonTree(param).getAsJsonObject(); - return UserService.users((JsonObject) user.get("user")); + return userService.users((JsonObject) user.get("user")); } } diff --git a/src/main/java/com/study/realworld/dao/PSSetDao.java b/src/main/java/com/study/realworld/dao/PSSetDao.java index e7781978..2becb537 100644 --- a/src/main/java/com/study/realworld/dao/PSSetDao.java +++ b/src/main/java/com/study/realworld/dao/PSSetDao.java @@ -6,1599 +6,1600 @@ import org.springframework.jdbc.core.PreparedStatementSetter; public class PSSetDao { - public static class PSSForString implements PreparedStatementSetter { - private String lValue; - - public PSSForString(String l_value) { - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.lValue); - } - } - - public static class PSSForDoubleString implements PreparedStatementSetter { - private String rValue; - private String sValue; - - public PSSForDoubleString(String r_value, String s_value) { - this.rValue = r_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - - } - } - - public static class PSSForTripleString implements PreparedStatementSetter { - private String rValue; - private String sValue; - private String tValue; - - public PSSForTripleString(String r_value, String s_value, String t_value) { - this.rValue = r_value; - this.sValue = s_value; - this.tValue = t_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setString(3, this.tValue); - - } - } - - public static class PSSForFourString implements PreparedStatementSetter { - private String v1; - private String v2; - private String v3; - private String v4; - - public PSSForFourString(String v1, String v2, String v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - } - } - - public static class PSSForFiveString implements PreparedStatementSetter { - private String v1; - private String v2; - private String v3; - private String v4; - private String v5; - - public PSSForFiveString(String v1, String v2, String v3, String v4, String v5) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - ps.setString(5, this.v5); - } - } - - public static class PSSForTripleStringLong implements PreparedStatementSetter { - private String rValue; - private String sValue; - private String tValue; - private long l_value; - - public PSSForTripleStringLong(String r_value, String s_value, String t_value, long l_value) { - this.rValue = r_value; - this.sValue = s_value; - this.tValue = t_value; - this.l_value = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setString(3, this.tValue); - ps.setLong(4, this.l_value); - - } - } - - public static class PSSForDoubleStringInt implements PreparedStatementSetter { - private String rValue; - private String sValue; - private int iValue; - - public PSSForDoubleStringInt(String r_value, String s_value, int i_value) { - this.rValue = r_value; - this.sValue = s_value; - this.iValue = i_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setInt(3, this.iValue); - - } - } - - public static class PSSForDoubleStringDoubleInt implements PreparedStatementSetter { - private String v1; - private String v2; - private int v3; - private int v4; - - public PSSForDoubleStringDoubleInt(String v1, String v2, int v3, int v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.v1); - ps.setString(2, this.v2); - ps.setInt(3, this.v3); - ps.setInt(4, this.v4); - - } - } - - public static class PSSForDoubleStringLong implements PreparedStatementSetter { - private String rValue; - private String sValue; - private long iValue; - - public PSSForDoubleStringLong(String r_value, String s_value, long i_value) { - this.rValue = r_value; - this.sValue = s_value; - this.iValue = i_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setLong(3, this.iValue); - - } - } - - public static class PSSForIntBytes implements PreparedStatementSetter { - private int v1; - private Byte value[]; - - public PSSForIntBytes(int v1, Byte... value) { - this.v1 = v1; - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - - ps.setInt(1, this.v1); - for( int i = 1 ; i <= value.length ; i++ ) { - ps.setByte((i+1), this.value[i]); - } - } - } - - public static class PSSForInts implements PreparedStatementSetter { - private Integer value[]; - - public PSSForInts(Integer... value) { - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - - for( int i = 0 ; i < value.length ; i++ ) { - ps.setInt((i+1), this.value[i]); - } - } - } - - public static class PSSForStrings implements PreparedStatementSetter { - private String value[]; - - public PSSForStrings(String... value) { - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - - for( int i = 0 ; i < value.length ; i++ ) { - ps.setString((i+1), this.value[i]); - } - } - } - - public static class PSSForIntStrings implements PreparedStatementSetter { - private int v1; - private String value[]; - - public PSSForIntStrings(int v1, String... value) { - this.v1 = v1; - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int pos = 1; - - ps.setInt(pos++, this.v1); - for( int i = 0 ; i < value.length ; i++ ) { - ps.setString(pos++, this.value[i]); - } - } - } - - public static class PSSForInt implements PreparedStatementSetter { - private int lValue; - - public PSSForInt(int l_value) { - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - } - } - - public static class PSSForDoubleInt implements PreparedStatementSetter { - private int lValue; - private int rValue; - - public PSSForDoubleInt(int l_value, int r_value) { - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - } - } - - public static class PSSForDoubleIntString implements PreparedStatementSetter { - private int lValue; - private int rValue; - private String tValue; - - public PSSForDoubleIntString(int l_value, int r_value, String t_value) { - this.lValue = l_value; - this.rValue = r_value; - this.tValue = t_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.tValue); - } - } - - public static class PSSForTirpleIntString implements PreparedStatementSetter { - private int v1; - private int v2; - private int v3; - private String v4; - - public PSSForTirpleIntString(int v1, int v2, int v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setInt(2, this.v2); - ps.setInt(3, this.v3); - ps.setString(4, this.v4); - } - } - - public static class PSSForDoubleIntDoubleString implements PreparedStatementSetter { - private int lValue; - private int rValue; - private String tValue; - private String sValue; - - public PSSForDoubleIntDoubleString(int l_value, int r_value, String t_value, String s_value) { - this.lValue = l_value; - this.rValue = r_value; - this.tValue = t_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.tValue); - ps.setString(4, this.sValue); - } - } - - public static class PSSForLongDoubleInt implements PreparedStatementSetter { - private long aValue; - private int lValue; - private int rValue; - - public PSSForLongDoubleInt(long a_value, int l_value, int r_value) { - this.aValue = a_value; - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.aValue); - ps.setInt(2, this.lValue); - ps.setInt(3, this.rValue); - } - } - - public static class PSSForDoubleIntLong implements PreparedStatementSetter { - private int lValue; - private int rValue; - private long vValue; - - public PSSForDoubleIntLong(int l_value, int r_value, long v_value) { - this.lValue = l_value; - this.rValue = r_value; - this.vValue = v_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setLong(3, this.vValue); - } - } - - public static class PSSForStringDoubleInt implements PreparedStatementSetter { - private String sValue; - private int lValue; - private int rValue; - - public PSSForStringDoubleInt(String s_value, int l_value, int r_value) { - this.sValue = s_value; - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.lValue); - ps.setInt(3, this.rValue); - } - } - - public static class PSSForStringTripleInt implements PreparedStatementSetter { - private String sValue; - private int value1; - private int value2; - private int value3; - - public PSSForStringTripleInt(String s_value, int value1, int value2, int value3) { - this.sValue = s_value; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.value1); - ps.setInt(3, this.value2); - ps.setInt(4, this.value3); - } - } - - public static class PSSForLongTripleInt implements PreparedStatementSetter { - private long value0; - private int value1; - private int value2; - private int value3; - - public PSSForLongTripleInt(long value0, int value1, int value2, int value3) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.value0); - ps.setInt(2, this.value1); - ps.setInt(3, this.value2); - ps.setInt(4, this.value3); - } - } - - public static class PSSForTripleInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - - public PSSForTripleInt(int value1, int value2, int value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - } - } - - public static class PSSForDoubleIntLongString implements PreparedStatementSetter { - private int v1; - private int v2; - private long v3; - private String v4; - - public PSSForDoubleIntLongString(int v1, int v2, long v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setInt(2, this.v2); - ps.setLong(3, this.v3); - ps.setString(4, this.v4); - } - } - - public static class PSSForTripleIntLongString implements PreparedStatementSetter { - private int v1; - private int v2; - private int v3; - private long v4; - private String v5; - - public PSSForTripleIntLongString(int v1, int v2, int v3, long v4, String v5) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setInt(2, this.v2); - ps.setInt(3, this.v3); - ps.setLong(4, this.v4); - ps.setString(5, this.v5); - } - } - - public static class PSSForTripleIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - - public PSSForTripleIntString(int value1, int value2, int value3, String value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - } - } - - public static class PSSForTripleIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - private String value5; - - public PSSForTripleIntDoubleString(int value1, int value2, int value3, String value4, String value5) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - } - } - - public static class PSSForTripleIntFourString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - private String value5; - private String value6; - private String value7; - - public PSSForTripleIntFourString(int value1, int value2, int value3, String value4, String value5, String value6, String value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - ps.setString(6, this.value6); - ps.setString(7, this.value7); - } - } - - public static class PSSForIntStringInt implements PreparedStatementSetter { - private int value1; - private String value2; - private int value3; - - public PSSForIntStringInt(int value1, String value2, int value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setString(2, this.value2); - ps.setInt(3, this.value3); - } - } - - public static class PSSForDoubleIntTripleStringInt implements PreparedStatementSetter { - private int value1; - private int value2; - private String value3; - private String value4; - private String value5; - private int value6; - - public PSSForDoubleIntTripleStringInt(int value1, int value2, String value3, String value4, String value5, int value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setString(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - ps.setInt(6, this.value6); - } - } - - public static class PSSForTripleIntTripleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - private String value5; - private String value6; - - public PSSForTripleIntTripleString(int value1, int value2, int value3, String value4, String value5, String value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - ps.setString(6, this.value6); - } - } - - public static class PSSForFourInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - - public PSSForFourInt(int value1, int value2, int value3, int value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - } - } - - public static class PSSForFourIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private String value5; - - public PSSForFourIntString(int value1, int value2, int value3, int value4, String value5) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setString(5, this.value5); - } - } - - public static class PSSForFourIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private String value5; - private String value6; - - public PSSForFourIntDoubleString(int value1, int value2, int value3, int value4, String value5, String value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setString(5, this.value5); - ps.setString(6, this.value6); - } - } - - public static class PSSForFiveInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - - public PSSForFiveInt(int value1, int value2, int value3, int value4, int value5) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - } - } - - public static class PSSForFiveIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private String value6; - - public PSSForFiveIntString(int value1, int value2, int value3, int value4, int value5, String value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setString(6, this.value6); - } - } - - public static class PSSForFiveIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private String value6; - private String value7; - - public PSSForFiveIntDoubleString(int value1, int value2, int value3, int value4, int value5, String value6, String value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setString(6, this.value6); - ps.setString(7, this.value7); - } - } - - public static class PSSForSixInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - - public PSSForSixInt(int value1, int value2, int value3, int value4, int value5, int value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - } - } - - - public static class PSSForSixIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private String value7; - - public PSSForSixIntString(int value1, int value2, int value3, int value4, int value5, int value6, String value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setString(7, this.value7); - } - } - - public static class PSSForSixIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private String value7; - private String value8; - - public PSSForSixIntDoubleString(int value1, int value2, int value3, int value4, int value5, int value6, String value7, String value8) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setString(7, this.value7); - ps.setString(8, this.value8); - } - } - - public static class PSSForSevenIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - private String value8; - - public PSSForSevenIntString(int value1, int value2, int value3, int value4, int value5, int value6, int value7, String value8) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - ps.setString(8, this.value8); - } - } - - - public static class PSSForSevenInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - - public PSSForSevenInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - } - } - - public static class PSSForEightInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - private int value8; - - public PSSForEightInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - ps.setInt(8, this.value8); - } - } - - public static class PSSForNineInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - private int value8; - private int value9; - - public PSSForNineInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - this.value9 = value9; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - ps.setInt(8, this.value8); - ps.setInt(9, this.value9); - } - } - - public static class PSSForLongInt implements PreparedStatementSetter { - private long lValue; - private int rValue; - - public PSSForLongInt(long l_value, int r_value) { - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - ps.setInt(2, this.rValue); - } - } - - public static class PSSForLongIntLong implements PreparedStatementSetter { - private long v1; - private int v2; - private long v3; - - public PSSForLongIntLong(long v1, int v2, long v3) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.v1); - ps.setInt(2, this.v2); - ps.setLong(3, this.v3); - } - } - - public static class PSSForLongIntString implements PreparedStatementSetter { - private long lValue; - private int rValue; - private String sValue; - - public PSSForLongIntString(long l_value, int r_value, String s_value) { - this.lValue = l_value; - this.rValue = r_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.sValue); - } - } - - public static class PSSForLongStringLong implements PreparedStatementSetter { - private long value1; - private String value2; - private long value3; - - public PSSForLongStringLong(long value1, String value2, long value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.value1); - ps.setString(2, this.value2); - ps.setLong(3, this.value3); - } - } - - public static class PSSForIntLong implements PreparedStatementSetter { - private int rValue; - private long lValue; - - public PSSForIntLong(int r_value, long l_value) { - this.rValue = r_value; - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.rValue); - ps.setLong(2, this.lValue); - } - } - - public static class PSSForLong implements PreparedStatementSetter { - private long lValue; - - public PSSForLong(long l_value) { - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - } - } - - public static class PSSForDoubleLong implements PreparedStatementSetter { - private long lValue; - private long rValue; - - public PSSForDoubleLong(long l_value, long r_value) { - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - ps.setLong(2, this.rValue); - } - } - - public static class PSSForIntString implements PreparedStatementSetter { - private int rValue; - private String sValue; - - public PSSForIntString(int r_value, String s_value) { - this.rValue = r_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.rValue); - ps.setString(2, this.sValue); - } - } - - public static class PSSForIntDoubleString implements PreparedStatementSetter { - private int rValue; - private String sValue1; - private String sValue2; - - public PSSForIntDoubleString(int r_value, String s_value1, String s_value2) { - this.rValue = r_value; - this.sValue1 = s_value1; - this.sValue2 = s_value2; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.rValue); - ps.setString(2, this.sValue1); - ps.setString(3, this.sValue2); - } - } - - public static class PSSForIntTripleString implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private String v4; - - public PSSForIntTripleString(int v1, String v2, String v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(3, this.v4); - } - } - - public static class PSSForIntStringDoubleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private int v3; - private int v4; - - public PSSForIntStringDoubleInt(int v1, String v2, int v3, int v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setInt(3, this.v3); - ps.setInt(4, this.v4); - } - } - - public static class PSSForIntDoubleStringDoubleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private int v4; - private int v5; - - public PSSForIntDoubleStringDoubleInt(int v1, String v2, String v3, int v4, int v5) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setInt(4, this.v4); - ps.setInt(5, this.v5); - } - } - - public static class PSSForIntTripleStringDoubleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private String v4; - private int v5; - private int v6; - - public PSSForIntTripleStringDoubleInt(int v1, String v2, String v3, String v4, int v5, int v6) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - this.v6 = v6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - ps.setInt(5, this.v5); - ps.setInt(6, this.v6); - } - } - - public static class PSSForIntDoubleStringTripleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private int v4; - private int v5; - private int v6; - - public PSSForIntDoubleStringTripleInt(int v1, String v2, String v3, int v4, int v5, int v6) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - this.v6 = v6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setInt(4, this.v4); - ps.setInt(5, this.v5); - ps.setInt(6, this.v6); - } - } - - public static class PSSForIntFiveString implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private String v4; - private String v5; - private String v6; - - public PSSForIntFiveString(int v1, String v2, String v3, String v4, String v5, String v6) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - this.v6 = v6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - ps.setString(5, this.v5); - ps.setString(6, this.v6); - } - } - - public static class PSSForStringInt implements PreparedStatementSetter { - private String sValue; - private int rValue; - - public PSSForStringInt(String s_value, int r_value) { - this.sValue = s_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.rValue); - } - } - public static class PSSForDoubleStringDoubleIntString implements PreparedStatementSetter { - private String sValue1; - private String sValue2; - private String sValue3; - private int rValue1; - private int rValue2; - - public PSSForDoubleStringDoubleIntString(String sValue1,String sValue2, int rValue1, int rValue2,String sValue3) { - this.sValue1 = sValue1; - this.sValue2 = sValue2; - this.sValue3 = sValue3; - this.rValue1 = rValue1; - this.rValue2 = rValue2; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue1); - ps.setString(2, this.sValue2); - ps.setInt(3, this.rValue1); - ps.setInt(4, this.rValue2); - ps.setString(5, this.sValue3); - } - } - - public static class PSSForStringLong implements PreparedStatementSetter { - private String sValue; - private long rValue; - - public PSSForStringLong(String s_value, long r_value) { - this.sValue = s_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setLong(2, this.rValue); - } - } - - public static class PSSForStringIntLong implements PreparedStatementSetter { - private String value1; - private int value2; - private long value3; - - public PSSForStringIntLong(String value1, int value2, long value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setInt(2, this.value2); - ps.setLong(3, this.value3); - } - } - - public static class PSSForStringDoubleIntLong implements PreparedStatementSetter { - private String value1; - private int value2; - private int value3; - private long value4; - - public PSSForStringDoubleIntLong(String value1, int value2, int value3, long value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setLong(4, this.value4); - } - } - - public static class PSSForStringLongInt implements PreparedStatementSetter { - private String value1; - private long value2; - private int value3; - - public PSSForStringLongInt(String value1, long value2, int value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setLong(2, this.value2); - ps.setInt(3, this.value3); - } - } - - public static class PSSForStringDoubleLongInt implements PreparedStatementSetter { - private String value1; - private long value2; - private long value3; - private int value4; - - public PSSForStringDoubleLongInt(String value1, long value2, long value3, int value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setLong(2, this.value2); - ps.setLong(3, this.value3); - ps.setInt(4, this.value4); - } - } - - public static class PSSForStringIntString implements PreparedStatementSetter { - private String sValue; - private int rValue; - private String tValue; - - public PSSForStringIntString(String s_value, int r_value, String t_value) { - this.sValue = s_value; - this.rValue = r_value; - this.tValue = t_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.tValue); - } - } - - public static class PSSForSIIS implements PreparedStatementSetter { - private String s1; - private int i1; - private int i2; - private String s2; - - public PSSForSIIS(String s1, int i1, int i2, String s2) { - this.s1 = s1; - this.i1 = i1; - this.i2 = i2; - this.s2 = s2; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.s1); - ps.setInt(2, this.i1); - ps.setInt(3, this.i2); - ps.setString(4, this.s2); - } - } - - public static class PSSForStringInts implements PreparedStatementSetter { - private String s1; - private Integer ints[]; - - public PSSForStringInts(String s1, Integer...ints) { - this.s1 = s1; - this.ints = ints; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int count = 1; - ps.setString(count++, this.s1); - for( int i = 0 ; i < ints.length ; i++ ) { - ps.setInt(count++, this.ints[i]); - } - } - } - - public static class PSSForIntsStrings implements PreparedStatementSetter { - int intCount; - int stringCount; - Object objects[]; - - public PSSForIntsStrings(int intCount, int stringCount, Object...objects) { - this.intCount = intCount; - this.stringCount = stringCount; - this.objects = objects; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int pos = 1; - - for( int i = 0 ; i < intCount ; i++ ) ps.setInt(pos++, (Integer)objects[i]); - for( int i = 0 ; i < stringCount ; i++ ) ps.setString(pos++, (String)objects[i+intCount]); - } - } - - public static class PSSForStringsInts implements PreparedStatementSetter { - int stringCount; - int intCount; - Object objects[]; - - public PSSForStringsInts(int stringCount, int intCount, Object...objects) { - this.stringCount = stringCount; - this.intCount = intCount; - this.objects = objects; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int pos = 1; - - for( int i = 0 ; i < stringCount ; i++ ) ps.setString(pos++, (String)objects[i]); - for( int i = 0 ; i < intCount ; i++ ) ps.setInt(pos++, (Integer)objects[i+stringCount]); - } - } - - public static class PSSForIntStringInts implements PreparedStatementSetter { - private int i1; - private String s1; - private Integer ints[]; - - public PSSForIntStringInts(int i1, String s1, Integer...ints) { - this.i1 = i1; - this.s1 = s1; - this.ints = ints; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int count = 1; - ps.setInt(count++, this.i1); - ps.setString(count++, this.s1); - for( int i = 0 ; i < ints.length ; i++ ) { - ps.setInt(count++, this.ints[i]); - } - } - } - - public static class PSSForTripleIntStrings implements PreparedStatementSetter { - private int v1; - private int v2; - private int v3; - private String strings[]; - - public PSSForTripleIntStrings(int v1, int v2, int v3, String...strings) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.strings = strings; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int count = 1; - ps.setInt(count++, this.v1); - ps.setInt(count++, this.v2); - ps.setInt(count++, this.v3); - for( int i = 0 ; i < strings.length ; i++ ) { - ps.setString(count++, this.strings[i]); - } - } - } - - public static class PSSForStringsIntsStrings implements PreparedStatementSetter { - int stringCount; - int intCount; - int stringCount2; - Object objects[]; - - public PSSForStringsIntsStrings(int stringCount, int intCount, int stringCount2, Object...objects) { - this.stringCount = stringCount; - this.intCount = intCount; - this.stringCount2 = stringCount2; - this.objects = objects; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int pos = 1; - - for( int i = 0 ; i < stringCount ; i++ ) ps.setString(pos++, (String)objects[i]); - for( int i = 0 ; i < intCount ; i++ ) ps.setInt(pos++, (Integer)objects[i+stringCount]); - for( int i = 0 ; i < stringCount2 ; i++ ) ps.setString(pos++, (String)objects[i+stringCount+intCount]); - } - } + public static class PSSForString implements PreparedStatementSetter { + private String lValue; + + public PSSForString(String l_value) { + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.lValue); + } + } + + public static class PSSForDoubleString implements PreparedStatementSetter { + private String rValue; + private String sValue; + + public PSSForDoubleString(String r_value, String s_value) { + this.rValue = r_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + + } + } + + public static class PSSForTripleString implements PreparedStatementSetter { + private String rValue; + private String sValue; + private String tValue; + + public PSSForTripleString(String r_value, String s_value, String t_value) { + this.rValue = r_value; + this.sValue = s_value; + this.tValue = t_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setString(3, this.tValue); + + } + } + + public static class PSSForFourString implements PreparedStatementSetter { + private String v1; + private String v2; + private String v3; + private String v4; + + public PSSForFourString(String v1, String v2, String v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + } + } + + public static class PSSForFiveString implements PreparedStatementSetter { + private String v1; + private String v2; + private String v3; + private String v4; + private String v5; + + public PSSForFiveString(String v1, String v2, String v3, String v4, String v5) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + ps.setString(5, this.v5); + } + } + + public static class PSSForTripleStringLong implements PreparedStatementSetter { + private String rValue; + private String sValue; + private String tValue; + private long l_value; + + public PSSForTripleStringLong(String r_value, String s_value, String t_value, long l_value) { + this.rValue = r_value; + this.sValue = s_value; + this.tValue = t_value; + this.l_value = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setString(3, this.tValue); + ps.setLong(4, this.l_value); + + } + } + + public static class PSSForDoubleStringInt implements PreparedStatementSetter { + private String rValue; + private String sValue; + private int iValue; + + public PSSForDoubleStringInt(String r_value, String s_value, int i_value) { + this.rValue = r_value; + this.sValue = s_value; + this.iValue = i_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setInt(3, this.iValue); + + } + } + + public static class PSSForDoubleStringDoubleInt implements PreparedStatementSetter { + private String v1; + private String v2; + private int v3; + private int v4; + + public PSSForDoubleStringDoubleInt(String v1, String v2, int v3, int v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.v1); + ps.setString(2, this.v2); + ps.setInt(3, this.v3); + ps.setInt(4, this.v4); + + } + } + + public static class PSSForDoubleStringLong implements PreparedStatementSetter { + private String rValue; + private String sValue; + private long iValue; + + public PSSForDoubleStringLong(String r_value, String s_value, long i_value) { + this.rValue = r_value; + this.sValue = s_value; + this.iValue = i_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.rValue); + ps.setString(2, this.sValue); + ps.setLong(3, this.iValue); + + } + } + + public static class PSSForIntBytes implements PreparedStatementSetter { + private int v1; + private Byte value[]; + + public PSSForIntBytes(int v1, Byte... value) { + this.v1 = v1; + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + + ps.setInt(1, this.v1); + for (int i = 1; i <= value.length; i++) { + ps.setByte((i + 1), this.value[i]); + } + } + } + + public static class PSSForInts implements PreparedStatementSetter { + private Integer value[]; + + public PSSForInts(Integer... value) { + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + + for (int i = 0; i < value.length; i++) { + ps.setInt((i + 1), this.value[i]); + } + } + } + + public static class PSSForStrings implements PreparedStatementSetter { + private String value[]; + + public PSSForStrings(String... value) { + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + + for (int i = 0; i < value.length; i++) { + ps.setString((i + 1), this.value[i]); + } + } + } + + public static class PSSForIntStrings implements PreparedStatementSetter { + private int v1; + private String value[]; + + public PSSForIntStrings(int v1, String... value) { + this.v1 = v1; + this.value = value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + ps.setInt(pos++, this.v1); + for (int i = 0; i < value.length; i++) { + ps.setString(pos++, this.value[i]); + } + } + } + + public static class PSSForInt implements PreparedStatementSetter { + private int lValue; + + public PSSForInt(int l_value) { + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + } + } + + public static class PSSForDoubleInt implements PreparedStatementSetter { + private int lValue; + private int rValue; + + public PSSForDoubleInt(int l_value, int r_value) { + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + } + } + + public static class PSSForDoubleIntString implements PreparedStatementSetter { + private int lValue; + private int rValue; + private String tValue; + + public PSSForDoubleIntString(int l_value, int r_value, String t_value) { + this.lValue = l_value; + this.rValue = r_value; + this.tValue = t_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.tValue); + } + } + + public static class PSSForTirpleIntString implements PreparedStatementSetter { + private int v1; + private int v2; + private int v3; + private String v4; + + public PSSForTirpleIntString(int v1, int v2, int v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setInt(2, this.v2); + ps.setInt(3, this.v3); + ps.setString(4, this.v4); + } + } + + public static class PSSForDoubleIntDoubleString implements PreparedStatementSetter { + private int lValue; + private int rValue; + private String tValue; + private String sValue; + + public PSSForDoubleIntDoubleString(int l_value, int r_value, String t_value, String s_value) { + this.lValue = l_value; + this.rValue = r_value; + this.tValue = t_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.tValue); + ps.setString(4, this.sValue); + } + } + + public static class PSSForLongDoubleInt implements PreparedStatementSetter { + private long aValue; + private int lValue; + private int rValue; + + public PSSForLongDoubleInt(long a_value, int l_value, int r_value) { + this.aValue = a_value; + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.aValue); + ps.setInt(2, this.lValue); + ps.setInt(3, this.rValue); + } + } + + public static class PSSForDoubleIntLong implements PreparedStatementSetter { + private int lValue; + private int rValue; + private long vValue; + + public PSSForDoubleIntLong(int l_value, int r_value, long v_value) { + this.lValue = l_value; + this.rValue = r_value; + this.vValue = v_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setLong(3, this.vValue); + } + } + + public static class PSSForStringDoubleInt implements PreparedStatementSetter { + private String sValue; + private int lValue; + private int rValue; + + public PSSForStringDoubleInt(String s_value, int l_value, int r_value) { + this.sValue = s_value; + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.lValue); + ps.setInt(3, this.rValue); + } + } + + public static class PSSForStringTripleInt implements PreparedStatementSetter { + private String sValue; + private int value1; + private int value2; + private int value3; + + public PSSForStringTripleInt(String s_value, int value1, int value2, int value3) { + this.sValue = s_value; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.value1); + ps.setInt(3, this.value2); + ps.setInt(4, this.value3); + } + } + + public static class PSSForLongTripleInt implements PreparedStatementSetter { + private long value0; + private int value1; + private int value2; + private int value3; + + public PSSForLongTripleInt(long value0, int value1, int value2, int value3) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.value0); + ps.setInt(2, this.value1); + ps.setInt(3, this.value2); + ps.setInt(4, this.value3); + } + } + + public static class PSSForTripleInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + + public PSSForTripleInt(int value1, int value2, int value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + } + } + + public static class PSSForDoubleIntLongString implements PreparedStatementSetter { + private int v1; + private int v2; + private long v3; + private String v4; + + public PSSForDoubleIntLongString(int v1, int v2, long v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setInt(2, this.v2); + ps.setLong(3, this.v3); + ps.setString(4, this.v4); + } + } + + public static class PSSForTripleIntLongString implements PreparedStatementSetter { + private int v1; + private int v2; + private int v3; + private long v4; + private String v5; + + public PSSForTripleIntLongString(int v1, int v2, int v3, long v4, String v5) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setInt(2, this.v2); + ps.setInt(3, this.v3); + ps.setLong(4, this.v4); + ps.setString(5, this.v5); + } + } + + public static class PSSForTripleIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + + public PSSForTripleIntString(int value1, int value2, int value3, String value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + } + } + + public static class PSSForTripleIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + private String value5; + + public PSSForTripleIntDoubleString(int value1, int value2, int value3, String value4, String value5) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + } + } + + public static class PSSForTripleIntFourString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + private String value5; + private String value6; + private String value7; + + public PSSForTripleIntFourString(int value1, int value2, int value3, String value4, String value5, String value6, String value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + ps.setString(6, this.value6); + ps.setString(7, this.value7); + } + } + + public static class PSSForIntStringInt implements PreparedStatementSetter { + private int value1; + private String value2; + private int value3; + + public PSSForIntStringInt(int value1, String value2, int value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setString(2, this.value2); + ps.setInt(3, this.value3); + } + } + + public static class PSSForDoubleIntTripleStringInt implements PreparedStatementSetter { + private int value1; + private int value2; + private String value3; + private String value4; + private String value5; + private int value6; + + public PSSForDoubleIntTripleStringInt(int value1, int value2, String value3, String value4, String value5, int value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setString(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + ps.setInt(6, this.value6); + } + } + + public static class PSSForTripleIntTripleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private String value4; + private String value5; + private String value6; + + public PSSForTripleIntTripleString(int value1, int value2, int value3, String value4, String value5, String value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setString(4, this.value4); + ps.setString(5, this.value5); + ps.setString(6, this.value6); + } + } + + public static class PSSForFourInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + + public PSSForFourInt(int value1, int value2, int value3, int value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + } + } + + public static class PSSForFourIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private String value5; + + public PSSForFourIntString(int value1, int value2, int value3, int value4, String value5) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setString(5, this.value5); + } + } + + public static class PSSForFourIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private String value5; + private String value6; + + public PSSForFourIntDoubleString(int value1, int value2, int value3, int value4, String value5, String value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setString(5, this.value5); + ps.setString(6, this.value6); + } + } + + public static class PSSForFiveInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + + public PSSForFiveInt(int value1, int value2, int value3, int value4, int value5) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + } + } + + public static class PSSForFiveIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private String value6; + + public PSSForFiveIntString(int value1, int value2, int value3, int value4, int value5, String value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setString(6, this.value6); + } + } + + public static class PSSForFiveIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private String value6; + private String value7; + + public PSSForFiveIntDoubleString(int value1, int value2, int value3, int value4, int value5, String value6, String value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setString(6, this.value6); + ps.setString(7, this.value7); + } + } + + public static class PSSForSixInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + + public PSSForSixInt(int value1, int value2, int value3, int value4, int value5, int value6) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + } + } + + + public static class PSSForSixIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private String value7; + + public PSSForSixIntString(int value1, int value2, int value3, int value4, int value5, int value6, String value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setString(7, this.value7); + } + } + + public static class PSSForSixIntDoubleString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private String value7; + private String value8; + + public PSSForSixIntDoubleString(int value1, int value2, int value3, int value4, int value5, int value6, String value7, String value8) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setString(7, this.value7); + ps.setString(8, this.value8); + } + } + + public static class PSSForSevenIntString implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + private String value8; + + public PSSForSevenIntString(int value1, int value2, int value3, int value4, int value5, int value6, int value7, String value8) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + ps.setString(8, this.value8); + } + } + + + public static class PSSForSevenInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + + public PSSForSevenInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + } + } + + public static class PSSForEightInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + private int value8; + + public PSSForEightInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + ps.setInt(8, this.value8); + } + } + + public static class PSSForNineInt implements PreparedStatementSetter { + private int value1; + private int value2; + private int value3; + private int value4; + private int value5; + private int value6; + private int value7; + private int value8; + private int value9; + + public PSSForNineInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + this.value7 = value7; + this.value8 = value8; + this.value9 = value9; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setInt(4, this.value4); + ps.setInt(5, this.value5); + ps.setInt(6, this.value6); + ps.setInt(7, this.value7); + ps.setInt(8, this.value8); + ps.setInt(9, this.value9); + } + } + + public static class PSSForLongInt implements PreparedStatementSetter { + private long lValue; + private int rValue; + + public PSSForLongInt(long l_value, int r_value) { + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + ps.setInt(2, this.rValue); + } + } + + public static class PSSForLongIntLong implements PreparedStatementSetter { + private long v1; + private int v2; + private long v3; + + public PSSForLongIntLong(long v1, int v2, long v3) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.v1); + ps.setInt(2, this.v2); + ps.setLong(3, this.v3); + } + } + + public static class PSSForLongIntString implements PreparedStatementSetter { + private long lValue; + private int rValue; + private String sValue; + + public PSSForLongIntString(long l_value, int r_value, String s_value) { + this.lValue = l_value; + this.rValue = r_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.sValue); + } + } + + public static class PSSForLongStringLong implements PreparedStatementSetter { + private long value1; + private String value2; + private long value3; + + public PSSForLongStringLong(long value1, String value2, long value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.value1); + ps.setString(2, this.value2); + ps.setLong(3, this.value3); + } + } + + public static class PSSForIntLong implements PreparedStatementSetter { + private int rValue; + private long lValue; + + public PSSForIntLong(int r_value, long l_value) { + this.rValue = r_value; + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.rValue); + ps.setLong(2, this.lValue); + } + } + + public static class PSSForLong implements PreparedStatementSetter { + private long lValue; + + public PSSForLong(long l_value) { + this.lValue = l_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + } + } + + public static class PSSForDoubleLong implements PreparedStatementSetter { + private long lValue; + private long rValue; + + public PSSForDoubleLong(long l_value, long r_value) { + this.lValue = l_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setLong(1, this.lValue); + ps.setLong(2, this.rValue); + } + } + + public static class PSSForIntString implements PreparedStatementSetter { + private int rValue; + private String sValue; + + public PSSForIntString(int r_value, String s_value) { + this.rValue = r_value; + this.sValue = s_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.rValue); + ps.setString(2, this.sValue); + } + } + + public static class PSSForIntDoubleString implements PreparedStatementSetter { + private int rValue; + private String sValue1; + private String sValue2; + + public PSSForIntDoubleString(int r_value, String s_value1, String s_value2) { + this.rValue = r_value; + this.sValue1 = s_value1; + this.sValue2 = s_value2; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.rValue); + ps.setString(2, this.sValue1); + ps.setString(3, this.sValue2); + } + } + + public static class PSSForIntTripleString implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private String v4; + + public PSSForIntTripleString(int v1, String v2, String v3, String v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(3, this.v4); + } + } + + public static class PSSForIntStringDoubleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private int v3; + private int v4; + + public PSSForIntStringDoubleInt(int v1, String v2, int v3, int v4) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setInt(3, this.v3); + ps.setInt(4, this.v4); + } + } + + public static class PSSForIntDoubleStringDoubleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private int v4; + private int v5; + + public PSSForIntDoubleStringDoubleInt(int v1, String v2, String v3, int v4, int v5) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setInt(4, this.v4); + ps.setInt(5, this.v5); + } + } + + public static class PSSForIntTripleStringDoubleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private String v4; + private int v5; + private int v6; + + public PSSForIntTripleStringDoubleInt(int v1, String v2, String v3, String v4, int v5, int v6) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + this.v6 = v6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + ps.setInt(5, this.v5); + ps.setInt(6, this.v6); + } + } + + public static class PSSForIntDoubleStringTripleInt implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private int v4; + private int v5; + private int v6; + + public PSSForIntDoubleStringTripleInt(int v1, String v2, String v3, int v4, int v5, int v6) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + this.v6 = v6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setInt(4, this.v4); + ps.setInt(5, this.v5); + ps.setInt(6, this.v6); + } + } + + public static class PSSForIntFiveString implements PreparedStatementSetter { + private int v1; + private String v2; + private String v3; + private String v4; + private String v5; + private String v6; + + public PSSForIntFiveString(int v1, String v2, String v3, String v4, String v5, String v6) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.v4 = v4; + this.v5 = v5; + this.v6 = v6; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setInt(1, this.v1); + ps.setString(2, this.v2); + ps.setString(3, this.v3); + ps.setString(4, this.v4); + ps.setString(5, this.v5); + ps.setString(6, this.v6); + } + } + + public static class PSSForStringInt implements PreparedStatementSetter { + private String sValue; + private int rValue; + + public PSSForStringInt(String s_value, int r_value) { + this.sValue = s_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.rValue); + } + } + + public static class PSSForDoubleStringDoubleIntString implements PreparedStatementSetter { + private String sValue1; + private String sValue2; + private String sValue3; + private int rValue1; + private int rValue2; + + public PSSForDoubleStringDoubleIntString(String sValue1, String sValue2, int rValue1, int rValue2, String sValue3) { + this.sValue1 = sValue1; + this.sValue2 = sValue2; + this.sValue3 = sValue3; + this.rValue1 = rValue1; + this.rValue2 = rValue2; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue1); + ps.setString(2, this.sValue2); + ps.setInt(3, this.rValue1); + ps.setInt(4, this.rValue2); + ps.setString(5, this.sValue3); + } + } + + public static class PSSForStringLong implements PreparedStatementSetter { + private String sValue; + private long rValue; + + public PSSForStringLong(String s_value, long r_value) { + this.sValue = s_value; + this.rValue = r_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setLong(2, this.rValue); + } + } + + public static class PSSForStringIntLong implements PreparedStatementSetter { + private String value1; + private int value2; + private long value3; + + public PSSForStringIntLong(String value1, int value2, long value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setInt(2, this.value2); + ps.setLong(3, this.value3); + } + } + + public static class PSSForStringDoubleIntLong implements PreparedStatementSetter { + private String value1; + private int value2; + private int value3; + private long value4; + + public PSSForStringDoubleIntLong(String value1, int value2, int value3, long value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setInt(2, this.value2); + ps.setInt(3, this.value3); + ps.setLong(4, this.value4); + } + } + + public static class PSSForStringLongInt implements PreparedStatementSetter { + private String value1; + private long value2; + private int value3; + + public PSSForStringLongInt(String value1, long value2, int value3) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setLong(2, this.value2); + ps.setInt(3, this.value3); + } + } + + public static class PSSForStringDoubleLongInt implements PreparedStatementSetter { + private String value1; + private long value2; + private long value3; + private int value4; + + public PSSForStringDoubleLongInt(String value1, long value2, long value3, int value4) { + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.value1); + ps.setLong(2, this.value2); + ps.setLong(3, this.value3); + ps.setInt(4, this.value4); + } + } + + public static class PSSForStringIntString implements PreparedStatementSetter { + private String sValue; + private int rValue; + private String tValue; + + public PSSForStringIntString(String s_value, int r_value, String t_value) { + this.sValue = s_value; + this.rValue = r_value; + this.tValue = t_value; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.sValue); + ps.setInt(2, this.rValue); + ps.setString(3, this.tValue); + } + } + + public static class PSSForSIIS implements PreparedStatementSetter { + private String s1; + private int i1; + private int i2; + private String s2; + + public PSSForSIIS(String s1, int i1, int i2, String s2) { + this.s1 = s1; + this.i1 = i1; + this.i2 = i2; + this.s2 = s2; + } + + public void setValues(PreparedStatement ps) throws SQLException { + ps.setString(1, this.s1); + ps.setInt(2, this.i1); + ps.setInt(3, this.i2); + ps.setString(4, this.s2); + } + } + + public static class PSSForStringInts implements PreparedStatementSetter { + private String s1; + private Integer ints[]; + + public PSSForStringInts(String s1, Integer... ints) { + this.s1 = s1; + this.ints = ints; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int count = 1; + ps.setString(count++, this.s1); + for (int i = 0; i < ints.length; i++) { + ps.setInt(count++, this.ints[i]); + } + } + } + + public static class PSSForIntsStrings implements PreparedStatementSetter { + int intCount; + int stringCount; + Object objects[]; + + public PSSForIntsStrings(int intCount, int stringCount, Object... objects) { + this.intCount = intCount; + this.stringCount = stringCount; + this.objects = objects; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + for (int i = 0; i < intCount; i++) ps.setInt(pos++, (Integer) objects[i]); + for (int i = 0; i < stringCount; i++) ps.setString(pos++, (String) objects[i + intCount]); + } + } + + public static class PSSForStringsInts implements PreparedStatementSetter { + int stringCount; + int intCount; + Object objects[]; + + public PSSForStringsInts(int stringCount, int intCount, Object... objects) { + this.stringCount = stringCount; + this.intCount = intCount; + this.objects = objects; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + for (int i = 0; i < stringCount; i++) ps.setString(pos++, (String) objects[i]); + for (int i = 0; i < intCount; i++) ps.setInt(pos++, (Integer) objects[i + stringCount]); + } + } + + public static class PSSForIntStringInts implements PreparedStatementSetter { + private int i1; + private String s1; + private Integer ints[]; + + public PSSForIntStringInts(int i1, String s1, Integer... ints) { + this.i1 = i1; + this.s1 = s1; + this.ints = ints; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int count = 1; + ps.setInt(count++, this.i1); + ps.setString(count++, this.s1); + for (int i = 0; i < ints.length; i++) { + ps.setInt(count++, this.ints[i]); + } + } + } + + public static class PSSForTripleIntStrings implements PreparedStatementSetter { + private int v1; + private int v2; + private int v3; + private String strings[]; + + public PSSForTripleIntStrings(int v1, int v2, int v3, String... strings) { + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + this.strings = strings; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int count = 1; + ps.setInt(count++, this.v1); + ps.setInt(count++, this.v2); + ps.setInt(count++, this.v3); + for (int i = 0; i < strings.length; i++) { + ps.setString(count++, this.strings[i]); + } + } + } + + public static class PSSForStringsIntsStrings implements PreparedStatementSetter { + int stringCount; + int intCount; + int stringCount2; + Object objects[]; + + public PSSForStringsIntsStrings(int stringCount, int intCount, int stringCount2, Object... objects) { + this.stringCount = stringCount; + this.intCount = intCount; + this.stringCount2 = stringCount2; + this.objects = objects; + } + + public void setValues(PreparedStatement ps) throws SQLException { + int pos = 1; + + for (int i = 0; i < stringCount; i++) ps.setString(pos++, (String) objects[i]); + for (int i = 0; i < intCount; i++) ps.setInt(pos++, (Integer) objects[i + stringCount]); + for (int i = 0; i < stringCount2; i++) ps.setString(pos++, (String) objects[i + stringCount + intCount]); + } + } } diff --git a/src/main/java/com/study/realworld/dao/ResultDao.java b/src/main/java/com/study/realworld/dao/ResultDao.java index 1f28525e..f3a7c0ac 100644 --- a/src/main/java/com/study/realworld/dao/ResultDao.java +++ b/src/main/java/com/study/realworld/dao/ResultDao.java @@ -12,176 +12,176 @@ import org.springframework.jdbc.core.ResultSetExtractor; public class ResultDao { - public static class RSEForResult implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, DataAccessException { - ResultSetMetaData rsMeta; - int z; - Map row = null; - - if (rs.next() == true) { - rsMeta = rs.getMetaData(); - - row = new HashMap(); - - rs.first(); - - for (z = 1; z <= rsMeta.getColumnCount(); z++) { - row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); - } - } - - return row; - } - } - - @SuppressWarnings("unchecked") - public static class RSEForResultSet implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, DataAccessException { - ResultSetMetaData rsMeta; - int size; - int i; - int z; - Map [] row = null; - - rsMeta = rs.getMetaData(); - - rs.last(); - - size = rs.getRow(); - - if (size > 0) { - row = new Map[size]; - - rs.first(); - - for (i = 0; i < size; i++) { - row[i] = new HashMap(); - - for (z = 1; z <= rsMeta.getColumnCount(); z++) { - row[i].put(rsMeta.getColumnLabel(z), rs.getObject(z)); - } - - rs.next(); - } - } - - return row; - } - } - - public static class RSEForResultListSet implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, DataAccessException { - ResultSetMetaData rsMeta; - int size; - int i; - int z; - List> list = null; - - rsMeta = rs.getMetaData(); - - rs.last(); - - size = rs.getRow(); - - if (size > 0) { - list = new ArrayList>(); - - rs.first(); - - for (i = 0; i < size; i++) { - Map row = new HashMap(); - - for (z = 1; z <= rsMeta.getColumnCount(); z++) { - row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); - } - list.add(row); - - rs.next(); - } - } - - return list; - } - } - - public static class RSEForInt implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - return rs.getInt(1); - } else { - return 0; - } - } - } - - public static class RSEForString implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - return rs.getString(1); - } else { - return null; - } - } - } - - public static class RSEForBoolean implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - return rs.getBoolean(1); - } else { - return false; - } - } - } - - public static class RSEForIntList implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - List lst = new ArrayList(); - - for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { - lst.add(rs.getInt(i)); - } - - return lst; - } else { - return null; - } - } - } - - - public static class RSEForStringList implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - List lst = new ArrayList(); - - for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { - lst.add(rs.getString(i)); - } - - return lst; - } else { - return null; - } - } - } - - public static class RSEForIntListFromRows implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - List lst = new ArrayList(); - - while (rs.next()) { - lst.add(rs.getInt(1)); - } - - return lst; - } - } + public static class RSEForResult implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int z; + Map row = null; + + if (rs.next() == true) { + rsMeta = rs.getMetaData(); + + row = new HashMap(); + + rs.first(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + } + + return row; + } + } + + @SuppressWarnings("unchecked") + public static class RSEForResultSet implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int size; + int i; + int z; + Map[] row = null; + + rsMeta = rs.getMetaData(); + + rs.last(); + + size = rs.getRow(); + + if (size > 0) { + row = new Map[size]; + + rs.first(); + + for (i = 0; i < size; i++) { + row[i] = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row[i].put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + + rs.next(); + } + } + + return row; + } + } + + public static class RSEForResultListSet implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int size; + int i; + int z; + List> list = null; + + rsMeta = rs.getMetaData(); + + rs.last(); + + size = rs.getRow(); + + if (size > 0) { + list = new ArrayList>(); + + rs.first(); + + for (i = 0; i < size; i++) { + Map row = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + list.add(row); + + rs.next(); + } + } + + return list; + } + } + + public static class RSEForInt implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getInt(1); + } else { + return 0; + } + } + } + + public static class RSEForString implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getString(1); + } else { + return null; + } + } + } + + public static class RSEForBoolean implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getBoolean(1); + } else { + return false; + } + } + } + + public static class RSEForIntList implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + List lst = new ArrayList(); + + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + lst.add(rs.getInt(i)); + } + + return lst; + } else { + return null; + } + } + } + + + public static class RSEForStringList implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + List lst = new ArrayList(); + + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + lst.add(rs.getString(i)); + } + + return lst; + } else { + return null; + } + } + } + + public static class RSEForIntListFromRows implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + List lst = new ArrayList(); + + while (rs.next()) { + lst.add(rs.getInt(1)); + } + + return lst; + } + } } diff --git a/src/main/java/com/study/realworld/dao/UserDao.java b/src/main/java/com/study/realworld/dao/UserDao.java index 4b421ff6..3a6be751 100644 --- a/src/main/java/com/study/realworld/dao/UserDao.java +++ b/src/main/java/com/study/realworld/dao/UserDao.java @@ -6,12 +6,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; import java.sql.ResultSet; import java.sql.Statement; import java.util.Map; @Component +@Repository public class UserDao { private final JdbcTemplate jdbcTemplate; diff --git a/src/main/java/com/study/realworld/secure/GUIDGenerator.java b/src/main/java/com/study/realworld/secure/GUIDGenerator.java index 1a7d2c64..400fbef5 100644 --- a/src/main/java/com/study/realworld/secure/GUIDGenerator.java +++ b/src/main/java/com/study/realworld/secure/GUIDGenerator.java @@ -7,27 +7,27 @@ public class GUIDGenerator implements IGenerator { protected final int length; protected final Random random; - public GUIDGenerator(int length) throws Exception { - if( length < 1 ) throw new IllegalArgumentException("length < 1: " + length); - _length = length; - _random = makeRand(); + public GUIDGenerator(int lng) throws Exception { + if( lng < 1 ) throw new IllegalArgumentException("length < 1: " + lng); + length = lng; + random = makeRand(); } - + protected Random makeRand() { return new Random(); } @Override public String generate() { - StringBuilder guid = new StringBuilder(_length); - for( int i = 0 ; i < _length ; i++ ) guid.append( _upper.charAt( _random.nextInt(_upper.length()) ) ); + StringBuilder guid = new StringBuilder(length); + for( int i = 0 ; i < length ; i++ ) guid.append( UPPER.charAt( random.nextInt(UPPER.length()) ) ); return guid.toString(); } @Override public String generateHex() { - StringBuilder guid = new StringBuilder(_length); - for( int i = 0 ; i < _length ; i++ ) guid.append( _upperHex.charAt( _random.nextInt(_upperHex.length()) ) ); + StringBuilder guid = new StringBuilder(length); + for( int i = 0 ; i < length ; i++ ) guid.append( UPPER_HEX.charAt( random.nextInt(UPPER_HEX.length()) ) ); return guid.toString(); } } diff --git a/src/main/java/com/study/realworld/secure/IGenerator.java b/src/main/java/com/study/realworld/secure/IGenerator.java index 56ba709f..93ad1962 100644 --- a/src/main/java/com/study/realworld/secure/IGenerator.java +++ b/src/main/java/com/study/realworld/secure/IGenerator.java @@ -1,9 +1,10 @@ package com.study.realworld.secure; public interface IGenerator { - static final String UPPER = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - static final String UPPER_HEX = "0123456789ABCDEF"; + static final String UPPER = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static final String UPPER_HEX = "0123456789ABCDEF"; + + String generate(); - String generate(); String generateHex(); } diff --git a/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java b/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java index 843726f7..ad5e0621 100644 --- a/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java +++ b/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java @@ -3,27 +3,27 @@ import java.security.SecureRandom; public class SecureGUIDGenerator extends GUIDGenerator { - public SecureGUIDGenerator(int length) throws Exception { - super(length); - } - - protected SecureRandom makeRand() { - return new SecureRandom(); - } - - public static String gen(int length) { - try { - return new SecureGUIDGenerator(length).generate(); - } catch (Exception e) { - return null; - } - } - - public static String genHex(int length) { - try { - return new SecureGUIDGenerator(length).generateHex(); - } catch (Exception e) { - return null; - } - } + public SecureGUIDGenerator(int length) throws Exception { + super(length); + } + + protected SecureRandom makeRand() { + return new SecureRandom(); + } + + public static String gen(int length) { + try { + return new SecureGUIDGenerator(length).generate(); + } catch (Exception e) { + return null; + } + } + + public static String genHex(int length) { + try { + return new SecureGUIDGenerator(length).generateHex(); + } catch (Exception e) { + return null; + } + } } diff --git a/src/main/java/com/study/realworld/secure/SecurityFunc.java b/src/main/java/com/study/realworld/secure/SecurityFunc.java index c471e16b..effccaef 100644 --- a/src/main/java/com/study/realworld/secure/SecurityFunc.java +++ b/src/main/java/com/study/realworld/secure/SecurityFunc.java @@ -19,114 +19,114 @@ import com.study.realworld.common.Func; public class SecurityFunc { - public static final String RSA_ALGORITHM = "RSA"; - public static final String AES_ALGORITHM = "AES"; - public static String AES_ALGORITHM_ENCRYPT = "AES/ECB/PKCS5Padding"; - - private static final String SESSION_SECURITY_KEY = "SECURITY_KEY"; - private static final int AES_LEN = 16; - - public static String encryptData(final String algorithm, final Key key, final T data) { - String json = new Gson().toJson(data); - if( null == json ) return null; - - try { - return encrypt(algorithm, key, json); - } - catch ( Exception e ) { - e.printStackTrace(); - } - return null; - } - - public static String encrypt(final String algorithm, final Key key, final String data) throws Exception { - return encrypt(algorithm, key, data.getBytes("utf-8")); - } - - public static String encrypt(final String algorithm, final Key key, final byte[] bytes) throws Exception { - - String cipherAlgorithm = algorithm; - - if( algorithm.equals(AES_ALGORITHM) ) { - cipherAlgorithm = AES_ALGORITHM_ENCRYPT; - } - - Cipher cipher = Cipher.getInstance(cipherAlgorithm); - cipher.init(Cipher.ENCRYPT_MODE, key); - - byte[] encryptBytes = cipher.doFinal(bytes); - - return DatatypeConverter.printHexBinary(encryptBytes); - } - - public static T decryptData(final Key key, final String bin, final Class classOfT) throws Exception { - return SecurityFunc.decryptData(SecurityFunc.AES_ALGORITHM, key, bin, classOfT); - } - - public static T decryptData(final String algorithm, final Key key, final String bin, final Class classOfT) throws Exception { - String json = decrypt(algorithm, key, bin); - if( null == json ) return null; - - return new Gson().fromJson(json, classOfT); - } - - public static String decrypt(final String algorithm, Key key, String binData) throws Exception { - - byte[] bytes = DatatypeConverter.parseHexBinary(binData); - - if( null == bytes ) return null; - - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.DECRYPT_MODE, key); - - byte[] decryptedBytes = cipher.doFinal(bytes); - - return new String(decryptedBytes, "utf-8"); - } - - public static Key generateKey(String algorithm, byte[] keyData) throws NoSuchAlgorithmException { - return new SecretKeySpec(keyData, algorithm); - } - - public static Key generateRSAKey(String modulus, String exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { - return generateRSAKey(new BigInteger(modulus, 16), new BigInteger(exponent, 16)); - } - - public static Key generateRSAKey(BigInteger modulus, BigInteger exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { - RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(modulus, exponent); - - KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); - - return keyFactory.generatePublic(pubKeySpec); - } - - public static class ResKey { - String key; - public ResKey(String key) { - this.key = key; - } - } - - public static void reqKey(HttpSession session, String modulus, String exponent, PrintWriter out) throws Exception { - Key aeskey = (Key) session.getAttribute( SESSION_SECURITY_KEY ); - if (null == aeskey) { - String strHex = SecureGUIDGenerator.genHex(AES_LEN); - aeskey = generateKey(SecurityFunc.AES_ALGORITHM, strHex.getBytes()); - session.setAttribute(SESSION_SECURITY_KEY, aeskey); - } - - String strAseKey = DatatypeConverter.printHexBinary(aeskey.getEncoded()); - - Key rsaPubKey = generateRSAKey(modulus, exponent); - - String bin = SecurityFunc.encryptData(RSA_ALGORITHM, rsaPubKey, new ResKey(strAseKey)); - - JsonObject result = new JsonObject(); - result.addProperty("bin", bin); - out.write(Func.getResultJson(result)); - } - - public static Key getKey( HttpSession session ) throws Exception { - return (Key) session.getAttribute( SESSION_SECURITY_KEY ); - } + public static final String RSA_ALGORITHM = "RSA"; + public static final String AES_ALGORITHM = "AES"; + public static String AES_ALGORITHM_ENCRYPT = "AES/ECB/PKCS5Padding"; + + private static final String SESSION_SECURITY_KEY = "SECURITY_KEY"; + private static final int AES_LEN = 16; + + public static String encryptData(final String algorithm, final Key key, final T data) { + String json = new Gson().toJson(data); + if (null == json) return null; + + try { + return encrypt(algorithm, key, json); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String encrypt(final String algorithm, final Key key, final String data) throws Exception { + return encrypt(algorithm, key, data.getBytes("utf-8")); + } + + public static String encrypt(final String algorithm, final Key key, final byte[] bytes) throws Exception { + + String cipherAlgorithm = algorithm; + + if (algorithm.equals(AES_ALGORITHM)) { + cipherAlgorithm = AES_ALGORITHM_ENCRYPT; + } + + Cipher cipher = Cipher.getInstance(cipherAlgorithm); + cipher.init(Cipher.ENCRYPT_MODE, key); + + byte[] encryptBytes = cipher.doFinal(bytes); + + return DatatypeConverter.printHexBinary(encryptBytes); + } + + public static T decryptData(final Key key, final String bin, final Class classOfT) throws Exception { + return SecurityFunc.decryptData(SecurityFunc.AES_ALGORITHM, key, bin, classOfT); + } + + public static T decryptData(final String algorithm, final Key key, final String bin, final Class classOfT) throws Exception { + String json = decrypt(algorithm, key, bin); + if (null == json) return null; + + return new Gson().fromJson(json, classOfT); + } + + public static String decrypt(final String algorithm, Key key, String binData) throws Exception { + + byte[] bytes = DatatypeConverter.parseHexBinary(binData); + + if (null == bytes) return null; + + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.DECRYPT_MODE, key); + + byte[] decryptedBytes = cipher.doFinal(bytes); + + return new String(decryptedBytes, "utf-8"); + } + + public static Key generateKey(String algorithm, byte[] keyData) throws NoSuchAlgorithmException { + return new SecretKeySpec(keyData, algorithm); + } + + public static Key generateRSAKey(String modulus, String exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { + return generateRSAKey(new BigInteger(modulus, 16), new BigInteger(exponent, 16)); + } + + public static Key generateRSAKey(BigInteger modulus, BigInteger exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { + RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(modulus, exponent); + + KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); + + return keyFactory.generatePublic(pubKeySpec); + } + + public static class ResKey { + String key; + + public ResKey(String key) { + this.key = key; + } + } + + public static void reqKey(HttpSession session, String modulus, String exponent, PrintWriter out) throws Exception { + Key aeskey = (Key) session.getAttribute(SESSION_SECURITY_KEY); + if (null == aeskey) { + String strHex = SecureGUIDGenerator.genHex(AES_LEN); + aeskey = generateKey(SecurityFunc.AES_ALGORITHM, strHex.getBytes()); + session.setAttribute(SESSION_SECURITY_KEY, aeskey); + } + + String strAseKey = DatatypeConverter.printHexBinary(aeskey.getEncoded()); + + Key rsaPubKey = generateRSAKey(modulus, exponent); + + String bin = SecurityFunc.encryptData(RSA_ALGORITHM, rsaPubKey, new ResKey(strAseKey)); + + JsonObject result = new JsonObject(); + result.addProperty("bin", bin); + out.write(Func.getResultJson(result)); + } + + public static Key getKey(HttpSession session) throws Exception { + return (Key) session.getAttribute(SESSION_SECURITY_KEY); + } } \ No newline at end of file diff --git a/src/main/java/com/study/realworld/service/UserService.java b/src/main/java/com/study/realworld/service/UserService.java index b1c1f809..92312da8 100644 --- a/src/main/java/com/study/realworld/service/UserService.java +++ b/src/main/java/com/study/realworld/service/UserService.java @@ -7,19 +7,19 @@ import com.study.realworld.common.Errors; import com.study.realworld.common.Func; import com.study.realworld.dao.UserDao; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; @Service +@Repository public class UserService { - private static UserDao userDao; + private final UserDao userDao; - @Autowired public UserService(UserDao userDao) { this.userDao = userDao; } - public static String users(JsonObject user) throws JsonProcessingException { + public String users(JsonObject user) throws JsonProcessingException { if (userDao.checkSameName(getString(user, "username"))) { //닉네임 체크 return Func.getErrorJson(Errors.SAME_NICKNAME); } else if (userDao.checkSameEmail(getString(user, "email"))) { //email 체크 @@ -44,7 +44,7 @@ public static String users(JsonObject user) throws JsonProcessingException { return Func.getResultJson(result); } - static String getString(JsonObject jsonObject, String name) { + String getString(JsonObject jsonObject, String name) { return jsonObject.get(name).toString(); } } From d96caed7918795bb0092ffc17aae989eee7d076d Mon Sep 17 00:00:00 2001 From: com8599 Date: Mon, 9 Aug 2021 18:08:03 +0900 Subject: [PATCH 10/13] =?UTF-8?q?[#6]=20refactor:=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=A4=91=EB=B3=B5=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Repository안에 @Component가 있습니다! 주의주의! Co-authored-by: 최진영 --- src/main/java/com/study/realworld/dao/UserDao.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/study/realworld/dao/UserDao.java b/src/main/java/com/study/realworld/dao/UserDao.java index 3a6be751..4250564c 100644 --- a/src/main/java/com/study/realworld/dao/UserDao.java +++ b/src/main/java/com/study/realworld/dao/UserDao.java @@ -12,7 +12,6 @@ import java.sql.Statement; import java.util.Map; -@Component @Repository public class UserDao { private final JdbcTemplate jdbcTemplate; From 071157e67951a21d1fabb8994cbedbdd575dd1f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Aug 2021 18:52:41 +0900 Subject: [PATCH 11/13] =?UTF-8?q?[#6]=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD,=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C,=20=EC=9D=B4=EB=AF=B8=20=EC=9E=88=EB=8A=94?= =?UTF-8?q?=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=91=EA=B7=BC=20=EC=A7=80?= =?UTF-8?q?=EC=96=91=EC=A0=81=EC=9D=B8=20=EC=BD=94=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/study/realworld/common/Func.java | 3 - .../realworld/controller/UserController.java | 6 - .../java/com/study/realworld/dao/UserDao.java | 14 +- .../realworld/{bean => domain}/User.java | 2 +- .../study/realworld/secure/GUIDGenerator.java | 33 ----- .../study/realworld/secure/IGenerator.java | 10 -- .../realworld/secure/SecureGUIDGenerator.java | 29 ---- .../study/realworld/secure/SecurityFunc.java | 132 ------------------ .../study/realworld/service/UserService.java | 20 +-- 9 files changed, 7 insertions(+), 242 deletions(-) rename src/main/java/com/study/realworld/{bean => domain}/User.java (95%) delete mode 100644 src/main/java/com/study/realworld/secure/GUIDGenerator.java delete mode 100644 src/main/java/com/study/realworld/secure/IGenerator.java delete mode 100644 src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java delete mode 100644 src/main/java/com/study/realworld/secure/SecurityFunc.java diff --git a/src/main/java/com/study/realworld/common/Func.java b/src/main/java/com/study/realworld/common/Func.java index 0a06fa38..d00abecc 100644 --- a/src/main/java/com/study/realworld/common/Func.java +++ b/src/main/java/com/study/realworld/common/Func.java @@ -1,9 +1,6 @@ package com.study.realworld.common; import com.google.gson.JsonObject; -import com.study.realworld.secure.SecurityFunc; - -import java.security.Key; public class Func { public static String getErrorJson(Errors error, Object... objects) { diff --git a/src/main/java/com/study/realworld/controller/UserController.java b/src/main/java/com/study/realworld/controller/UserController.java index b5c9e1b0..e3b9f6b0 100644 --- a/src/main/java/com/study/realworld/controller/UserController.java +++ b/src/main/java/com/study/realworld/controller/UserController.java @@ -1,16 +1,10 @@ package com.study.realworld.controller; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.study.realworld.bean.User; -import com.study.realworld.dao.UserDao; -import com.study.realworld.common.Errors; -import com.study.realworld.common.Func; import com.study.realworld.service.UserService; import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/main/java/com/study/realworld/dao/UserDao.java b/src/main/java/com/study/realworld/dao/UserDao.java index 4250564c..ba00f4c2 100644 --- a/src/main/java/com/study/realworld/dao/UserDao.java +++ b/src/main/java/com/study/realworld/dao/UserDao.java @@ -1,17 +1,10 @@ package com.study.realworld.dao; -import com.study.realworld.bean.User; -import com.study.realworld.dao.PSSetDao; -import com.study.realworld.dao.ResultDao; +import com.study.realworld.domain.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Component; import org.springframework.stereotype.Repository; -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.Map; - @Repository public class UserDao { private final JdbcTemplate jdbcTemplate; @@ -35,9 +28,4 @@ public int registUser(String username, String email, String password) { //신규 final String query = "insert into USER(USERNAME, EMAIL, PASSWORD) values (?, ?, ?)"; return jdbcTemplate.update(query, new PSSetDao.PSSForTripleString(username, email, password)); } - - public User getUsers(String email) { //getUsers - final String query = "select email,username,bio,image from USER where email=?"; - return jdbcTemplate.queryForObject(query, (rs, rowNum) -> new User(rs.getString("email"), rs.getString("username"), rs.getString("bio"), rs.getString("image")), email); - } } diff --git a/src/main/java/com/study/realworld/bean/User.java b/src/main/java/com/study/realworld/domain/User.java similarity index 95% rename from src/main/java/com/study/realworld/bean/User.java rename to src/main/java/com/study/realworld/domain/User.java index 4d3a2e6e..f190ec56 100644 --- a/src/main/java/com/study/realworld/bean/User.java +++ b/src/main/java/com/study/realworld/domain/User.java @@ -1,4 +1,4 @@ -package com.study.realworld.bean; +package com.study.realworld.domain; public class User { private String email; diff --git a/src/main/java/com/study/realworld/secure/GUIDGenerator.java b/src/main/java/com/study/realworld/secure/GUIDGenerator.java deleted file mode 100644 index 400fbef5..00000000 --- a/src/main/java/com/study/realworld/secure/GUIDGenerator.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.study.realworld.secure; - -import java.util.Random; - -public class GUIDGenerator implements IGenerator { - - protected final int length; - protected final Random random; - - public GUIDGenerator(int lng) throws Exception { - if( lng < 1 ) throw new IllegalArgumentException("length < 1: " + lng); - length = lng; - random = makeRand(); - } - - protected Random makeRand() { - return new Random(); - } - - @Override - public String generate() { - StringBuilder guid = new StringBuilder(length); - for( int i = 0 ; i < length ; i++ ) guid.append( UPPER.charAt( random.nextInt(UPPER.length()) ) ); - return guid.toString(); - } - - @Override - public String generateHex() { - StringBuilder guid = new StringBuilder(length); - for( int i = 0 ; i < length ; i++ ) guid.append( UPPER_HEX.charAt( random.nextInt(UPPER_HEX.length()) ) ); - return guid.toString(); - } -} diff --git a/src/main/java/com/study/realworld/secure/IGenerator.java b/src/main/java/com/study/realworld/secure/IGenerator.java deleted file mode 100644 index 93ad1962..00000000 --- a/src/main/java/com/study/realworld/secure/IGenerator.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.study.realworld.secure; - -public interface IGenerator { - static final String UPPER = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - static final String UPPER_HEX = "0123456789ABCDEF"; - - String generate(); - - String generateHex(); -} diff --git a/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java b/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java deleted file mode 100644 index ad5e0621..00000000 --- a/src/main/java/com/study/realworld/secure/SecureGUIDGenerator.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.study.realworld.secure; - -import java.security.SecureRandom; - -public class SecureGUIDGenerator extends GUIDGenerator { - public SecureGUIDGenerator(int length) throws Exception { - super(length); - } - - protected SecureRandom makeRand() { - return new SecureRandom(); - } - - public static String gen(int length) { - try { - return new SecureGUIDGenerator(length).generate(); - } catch (Exception e) { - return null; - } - } - - public static String genHex(int length) { - try { - return new SecureGUIDGenerator(length).generateHex(); - } catch (Exception e) { - return null; - } - } -} diff --git a/src/main/java/com/study/realworld/secure/SecurityFunc.java b/src/main/java/com/study/realworld/secure/SecurityFunc.java deleted file mode 100644 index effccaef..00000000 --- a/src/main/java/com/study/realworld/secure/SecurityFunc.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.study.realworld.secure; - -import java.io.PrintWriter; -import java.math.BigInteger; -import java.security.Key; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.RSAPublicKeySpec; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; -import javax.servlet.http.HttpSession; -import javax.xml.bind.DatatypeConverter; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import com.study.realworld.common.Func; - -public class SecurityFunc { - public static final String RSA_ALGORITHM = "RSA"; - public static final String AES_ALGORITHM = "AES"; - public static String AES_ALGORITHM_ENCRYPT = "AES/ECB/PKCS5Padding"; - - private static final String SESSION_SECURITY_KEY = "SECURITY_KEY"; - private static final int AES_LEN = 16; - - public static String encryptData(final String algorithm, final Key key, final T data) { - String json = new Gson().toJson(data); - if (null == json) return null; - - try { - return encrypt(algorithm, key, json); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static String encrypt(final String algorithm, final Key key, final String data) throws Exception { - return encrypt(algorithm, key, data.getBytes("utf-8")); - } - - public static String encrypt(final String algorithm, final Key key, final byte[] bytes) throws Exception { - - String cipherAlgorithm = algorithm; - - if (algorithm.equals(AES_ALGORITHM)) { - cipherAlgorithm = AES_ALGORITHM_ENCRYPT; - } - - Cipher cipher = Cipher.getInstance(cipherAlgorithm); - cipher.init(Cipher.ENCRYPT_MODE, key); - - byte[] encryptBytes = cipher.doFinal(bytes); - - return DatatypeConverter.printHexBinary(encryptBytes); - } - - public static T decryptData(final Key key, final String bin, final Class classOfT) throws Exception { - return SecurityFunc.decryptData(SecurityFunc.AES_ALGORITHM, key, bin, classOfT); - } - - public static T decryptData(final String algorithm, final Key key, final String bin, final Class classOfT) throws Exception { - String json = decrypt(algorithm, key, bin); - if (null == json) return null; - - return new Gson().fromJson(json, classOfT); - } - - public static String decrypt(final String algorithm, Key key, String binData) throws Exception { - - byte[] bytes = DatatypeConverter.parseHexBinary(binData); - - if (null == bytes) return null; - - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.DECRYPT_MODE, key); - - byte[] decryptedBytes = cipher.doFinal(bytes); - - return new String(decryptedBytes, "utf-8"); - } - - public static Key generateKey(String algorithm, byte[] keyData) throws NoSuchAlgorithmException { - return new SecretKeySpec(keyData, algorithm); - } - - public static Key generateRSAKey(String modulus, String exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { - return generateRSAKey(new BigInteger(modulus, 16), new BigInteger(exponent, 16)); - } - - public static Key generateRSAKey(BigInteger modulus, BigInteger exponent) throws NoSuchAlgorithmException, InvalidKeySpecException { - RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(modulus, exponent); - - KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); - - return keyFactory.generatePublic(pubKeySpec); - } - - public static class ResKey { - String key; - - public ResKey(String key) { - this.key = key; - } - } - - public static void reqKey(HttpSession session, String modulus, String exponent, PrintWriter out) throws Exception { - Key aeskey = (Key) session.getAttribute(SESSION_SECURITY_KEY); - if (null == aeskey) { - String strHex = SecureGUIDGenerator.genHex(AES_LEN); - aeskey = generateKey(SecurityFunc.AES_ALGORITHM, strHex.getBytes()); - session.setAttribute(SESSION_SECURITY_KEY, aeskey); - } - - String strAseKey = DatatypeConverter.printHexBinary(aeskey.getEncoded()); - - Key rsaPubKey = generateRSAKey(modulus, exponent); - - String bin = SecurityFunc.encryptData(RSA_ALGORITHM, rsaPubKey, new ResKey(strAseKey)); - - JsonObject result = new JsonObject(); - result.addProperty("bin", bin); - out.write(Func.getResultJson(result)); - } - - public static Key getKey(HttpSession session) throws Exception { - return (Key) session.getAttribute(SESSION_SECURITY_KEY); - } -} \ No newline at end of file diff --git a/src/main/java/com/study/realworld/service/UserService.java b/src/main/java/com/study/realworld/service/UserService.java index 92312da8..9947b934 100644 --- a/src/main/java/com/study/realworld/service/UserService.java +++ b/src/main/java/com/study/realworld/service/UserService.java @@ -1,17 +1,12 @@ package com.study.realworld.service; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonObject; -import com.study.realworld.bean.User; import com.study.realworld.common.Errors; import com.study.realworld.common.Func; import com.study.realworld.dao.UserDao; -import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; @Service -@Repository public class UserService { private final UserDao userDao; @@ -19,31 +14,26 @@ public UserService(UserDao userDao) { this.userDao = userDao; } - public String users(JsonObject user) throws JsonProcessingException { + public String users(JsonObject user) { if (userDao.checkSameName(getString(user, "username"))) { //닉네임 체크 return Func.getErrorJson(Errors.SAME_NICKNAME); } else if (userDao.checkSameEmail(getString(user, "email"))) { //email 체크 return Func.getErrorJson(Errors.SAME_EMAIL); } - if ( userDao.registUser(getString(user, "username"), + if (userDao.registUser(getString(user, "username"), getString(user, "email"), - getString(user, "password")) < 0 ) { + getString(user, "password")) < 0) { //등록하다가 에러났을경우 return Func.getErrorJson(Errors.DB); } - User users = userDao.getUsers(getString(user, "email")); - if ( users == null ) { - return Func.getErrorJson(Errors.INVALID_REQUEST); - } JsonObject result = new JsonObject(); - ObjectMapper objectMapper = new ObjectMapper(); - result.addProperty("user", objectMapper.writeValueAsString(users)); + result.add("user", user); return Func.getResultJson(result); } - + String getString(JsonObject jsonObject, String name) { return jsonObject.get(name).toString(); } From a19bb8b64a6060485d51b7be19cd9ee543cd3b44 Mon Sep 17 00:00:00 2001 From: com8599 Date: Tue, 10 Aug 2021 17:40:14 +0900 Subject: [PATCH 12/13] [#6] unused import removing, Errors>>ErrorCode, underbar Add, Func>>JsonFunc, follow Java's conventions, pssetdao make short, resultdao remove --- .../common/{Errors.java => ErrorCode.java} | 8 +- .../common/{Func.java => JsonFunc.java} | 10 +- .../realworld/controller/UserController.java | 11 +- .../com/study/realworld/dao/PSSetDao.java | 1567 +---------------- .../com/study/realworld/dao/ResultDao.java | 187 -- .../java/com/study/realworld/dao/UserDao.java | 16 +- .../java/com/study/realworld/domain/User.java | 1 + .../study/realworld/service/UserService.java | 22 +- 8 files changed, 54 insertions(+), 1768 deletions(-) rename src/main/java/com/study/realworld/common/{Errors.java => ErrorCode.java} (84%) rename src/main/java/com/study/realworld/common/{Func.java => JsonFunc.java} (62%) delete mode 100644 src/main/java/com/study/realworld/dao/ResultDao.java diff --git a/src/main/java/com/study/realworld/common/Errors.java b/src/main/java/com/study/realworld/common/ErrorCode.java similarity index 84% rename from src/main/java/com/study/realworld/common/Errors.java rename to src/main/java/com/study/realworld/common/ErrorCode.java index 9d089a81..e6bad190 100644 --- a/src/main/java/com/study/realworld/common/Errors.java +++ b/src/main/java/com/study/realworld/common/ErrorCode.java @@ -1,6 +1,6 @@ package com.study.realworld.common; -public enum Errors { +public enum ErrorCode { EXCEPTION(-1, "통신중 에러가 발생했습니다."), NONE(0, "이상없음"), INVALID_REQUEST(1, "잘못된 요청입니다."), @@ -16,7 +16,7 @@ public enum Errors { private int code; private String desc; - Errors(int code, String desc) { + ErrorCode(int code, String desc) { this.code = code; this.desc = desc; } @@ -29,8 +29,8 @@ public String getDesc() { return desc; } - public static Errors parse(int code) { - for (Errors e : Errors.values()) { + public static ErrorCode parse(int code) { + for (ErrorCode e : ErrorCode.values()) { if (code == e.getCode()) { return e; } diff --git a/src/main/java/com/study/realworld/common/Func.java b/src/main/java/com/study/realworld/common/JsonFunc.java similarity index 62% rename from src/main/java/com/study/realworld/common/Func.java rename to src/main/java/com/study/realworld/common/JsonFunc.java index d00abecc..908bdc7f 100644 --- a/src/main/java/com/study/realworld/common/Func.java +++ b/src/main/java/com/study/realworld/common/JsonFunc.java @@ -2,20 +2,20 @@ import com.google.gson.JsonObject; -public class Func { - public static String getErrorJson(Errors error, Object... objects) { +public class JsonFunc { + public static String getErrorJson(ErrorCode errorCode, Object... objects) { JsonObject json = new JsonObject(); - json.addProperty("E", String.valueOf(error.getCode())); + json.addProperty("E", String.valueOf(errorCode.getCode())); - if (objects == null && objects.length == 0) { + if (objects == null || objects.length == 0) { return json.toString(); } for (int i = 0; i < objects.length; i = i + 2) { json.addProperty(String.valueOf(objects[i]), String.valueOf(objects[i + 1])); } - System.out.println(error.name() + " - " + error.getCode() + " - " + error.getDesc()); + System.out.println(errorCode.name() + " - " + errorCode.getCode() + " - " + errorCode.getDesc()); return json.toString(); } diff --git a/src/main/java/com/study/realworld/controller/UserController.java b/src/main/java/com/study/realworld/controller/UserController.java index e3b9f6b0..393b7e09 100644 --- a/src/main/java/com/study/realworld/controller/UserController.java +++ b/src/main/java/com/study/realworld/controller/UserController.java @@ -1,8 +1,9 @@ package com.study.realworld.controller; -import com.fasterxml.jackson.core.JsonProcessingException; import com.google.gson.Gson; import com.google.gson.JsonObject; +import com.study.realworld.common.ErrorCode; +import com.study.realworld.common.JsonFunc; import com.study.realworld.service.UserService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; @@ -23,8 +24,12 @@ public UserController(UserService userService) { @ApiOperation(value = "사용자 등록", notes = "사용자 등록") @PostMapping("/users") //post 등록 api - public String users(@RequestBody Map param) throws JsonProcessingException { + public String users(@RequestBody Map param) { JsonObject user = new Gson().toJsonTree(param).getAsJsonObject(); - return userService.users((JsonObject) user.get("user")); + Object result = userService.users((JsonObject) user.get("user")); + if (result instanceof ErrorCode) { + return JsonFunc.getErrorJson((ErrorCode) result); + } + return JsonFunc.getResultJson(user); } } diff --git a/src/main/java/com/study/realworld/dao/PSSetDao.java b/src/main/java/com/study/realworld/dao/PSSetDao.java index 2becb537..1039d2a2 100644 --- a/src/main/java/com/study/realworld/dao/PSSetDao.java +++ b/src/main/java/com/study/realworld/dao/PSSetDao.java @@ -1,1498 +1,37 @@ package com.study.realworld.dao; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import org.springframework.jdbc.core.PreparedStatementSetter; - -public class PSSetDao { - public static class PSSForString implements PreparedStatementSetter { - private String lValue; - - public PSSForString(String l_value) { - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.lValue); - } - } - - public static class PSSForDoubleString implements PreparedStatementSetter { - private String rValue; - private String sValue; - - public PSSForDoubleString(String r_value, String s_value) { - this.rValue = r_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - - } - } - - public static class PSSForTripleString implements PreparedStatementSetter { - private String rValue; - private String sValue; - private String tValue; - - public PSSForTripleString(String r_value, String s_value, String t_value) { - this.rValue = r_value; - this.sValue = s_value; - this.tValue = t_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setString(3, this.tValue); - - } - } - - public static class PSSForFourString implements PreparedStatementSetter { - private String v1; - private String v2; - private String v3; - private String v4; - - public PSSForFourString(String v1, String v2, String v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - } - } - - public static class PSSForFiveString implements PreparedStatementSetter { - private String v1; - private String v2; - private String v3; - private String v4; - private String v5; - - public PSSForFiveString(String v1, String v2, String v3, String v4, String v5) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - ps.setString(5, this.v5); - } - } - - public static class PSSForTripleStringLong implements PreparedStatementSetter { - private String rValue; - private String sValue; - private String tValue; - private long l_value; - - public PSSForTripleStringLong(String r_value, String s_value, String t_value, long l_value) { - this.rValue = r_value; - this.sValue = s_value; - this.tValue = t_value; - this.l_value = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setString(3, this.tValue); - ps.setLong(4, this.l_value); - - } - } - - public static class PSSForDoubleStringInt implements PreparedStatementSetter { - private String rValue; - private String sValue; - private int iValue; - - public PSSForDoubleStringInt(String r_value, String s_value, int i_value) { - this.rValue = r_value; - this.sValue = s_value; - this.iValue = i_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setInt(3, this.iValue); - - } - } - - public static class PSSForDoubleStringDoubleInt implements PreparedStatementSetter { - private String v1; - private String v2; - private int v3; - private int v4; - - public PSSForDoubleStringDoubleInt(String v1, String v2, int v3, int v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.v1); - ps.setString(2, this.v2); - ps.setInt(3, this.v3); - ps.setInt(4, this.v4); - - } - } - - public static class PSSForDoubleStringLong implements PreparedStatementSetter { - private String rValue; - private String sValue; - private long iValue; - - public PSSForDoubleStringLong(String r_value, String s_value, long i_value) { - this.rValue = r_value; - this.sValue = s_value; - this.iValue = i_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.rValue); - ps.setString(2, this.sValue); - ps.setLong(3, this.iValue); - - } - } - - public static class PSSForIntBytes implements PreparedStatementSetter { - private int v1; - private Byte value[]; - - public PSSForIntBytes(int v1, Byte... value) { - this.v1 = v1; - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - - ps.setInt(1, this.v1); - for (int i = 1; i <= value.length; i++) { - ps.setByte((i + 1), this.value[i]); - } - } - } - - public static class PSSForInts implements PreparedStatementSetter { - private Integer value[]; - - public PSSForInts(Integer... value) { - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - - for (int i = 0; i < value.length; i++) { - ps.setInt((i + 1), this.value[i]); - } - } - } - - public static class PSSForStrings implements PreparedStatementSetter { - private String value[]; - - public PSSForStrings(String... value) { - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - - for (int i = 0; i < value.length; i++) { - ps.setString((i + 1), this.value[i]); - } - } - } - - public static class PSSForIntStrings implements PreparedStatementSetter { - private int v1; - private String value[]; - - public PSSForIntStrings(int v1, String... value) { - this.v1 = v1; - this.value = value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int pos = 1; - - ps.setInt(pos++, this.v1); - for (int i = 0; i < value.length; i++) { - ps.setString(pos++, this.value[i]); - } - } - } - - public static class PSSForInt implements PreparedStatementSetter { - private int lValue; - - public PSSForInt(int l_value) { - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - } - } - - public static class PSSForDoubleInt implements PreparedStatementSetter { - private int lValue; - private int rValue; - - public PSSForDoubleInt(int l_value, int r_value) { - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - } - } - - public static class PSSForDoubleIntString implements PreparedStatementSetter { - private int lValue; - private int rValue; - private String tValue; - - public PSSForDoubleIntString(int l_value, int r_value, String t_value) { - this.lValue = l_value; - this.rValue = r_value; - this.tValue = t_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.tValue); - } - } - - public static class PSSForTirpleIntString implements PreparedStatementSetter { - private int v1; - private int v2; - private int v3; - private String v4; - - public PSSForTirpleIntString(int v1, int v2, int v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setInt(2, this.v2); - ps.setInt(3, this.v3); - ps.setString(4, this.v4); - } - } - - public static class PSSForDoubleIntDoubleString implements PreparedStatementSetter { - private int lValue; - private int rValue; - private String tValue; - private String sValue; - - public PSSForDoubleIntDoubleString(int l_value, int r_value, String t_value, String s_value) { - this.lValue = l_value; - this.rValue = r_value; - this.tValue = t_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.tValue); - ps.setString(4, this.sValue); - } - } - - public static class PSSForLongDoubleInt implements PreparedStatementSetter { - private long aValue; - private int lValue; - private int rValue; - - public PSSForLongDoubleInt(long a_value, int l_value, int r_value) { - this.aValue = a_value; - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.aValue); - ps.setInt(2, this.lValue); - ps.setInt(3, this.rValue); - } - } - - public static class PSSForDoubleIntLong implements PreparedStatementSetter { - private int lValue; - private int rValue; - private long vValue; - - public PSSForDoubleIntLong(int l_value, int r_value, long v_value) { - this.lValue = l_value; - this.rValue = r_value; - this.vValue = v_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setLong(3, this.vValue); - } - } - - public static class PSSForStringDoubleInt implements PreparedStatementSetter { - private String sValue; - private int lValue; - private int rValue; - - public PSSForStringDoubleInt(String s_value, int l_value, int r_value) { - this.sValue = s_value; - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.lValue); - ps.setInt(3, this.rValue); - } - } - - public static class PSSForStringTripleInt implements PreparedStatementSetter { - private String sValue; - private int value1; - private int value2; - private int value3; - - public PSSForStringTripleInt(String s_value, int value1, int value2, int value3) { - this.sValue = s_value; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.value1); - ps.setInt(3, this.value2); - ps.setInt(4, this.value3); - } - } - - public static class PSSForLongTripleInt implements PreparedStatementSetter { - private long value0; - private int value1; - private int value2; - private int value3; - - public PSSForLongTripleInt(long value0, int value1, int value2, int value3) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.value0); - ps.setInt(2, this.value1); - ps.setInt(3, this.value2); - ps.setInt(4, this.value3); - } - } - - public static class PSSForTripleInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - - public PSSForTripleInt(int value1, int value2, int value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - } - } - - public static class PSSForDoubleIntLongString implements PreparedStatementSetter { - private int v1; - private int v2; - private long v3; - private String v4; - - public PSSForDoubleIntLongString(int v1, int v2, long v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setInt(2, this.v2); - ps.setLong(3, this.v3); - ps.setString(4, this.v4); - } - } - - public static class PSSForTripleIntLongString implements PreparedStatementSetter { - private int v1; - private int v2; - private int v3; - private long v4; - private String v5; - - public PSSForTripleIntLongString(int v1, int v2, int v3, long v4, String v5) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setInt(2, this.v2); - ps.setInt(3, this.v3); - ps.setLong(4, this.v4); - ps.setString(5, this.v5); - } - } - - public static class PSSForTripleIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - - public PSSForTripleIntString(int value1, int value2, int value3, String value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - } - } - - public static class PSSForTripleIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - private String value5; - - public PSSForTripleIntDoubleString(int value1, int value2, int value3, String value4, String value5) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - } - } - - public static class PSSForTripleIntFourString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - private String value5; - private String value6; - private String value7; - - public PSSForTripleIntFourString(int value1, int value2, int value3, String value4, String value5, String value6, String value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - ps.setString(6, this.value6); - ps.setString(7, this.value7); - } - } - - public static class PSSForIntStringInt implements PreparedStatementSetter { - private int value1; - private String value2; - private int value3; - - public PSSForIntStringInt(int value1, String value2, int value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setString(2, this.value2); - ps.setInt(3, this.value3); - } - } - - public static class PSSForDoubleIntTripleStringInt implements PreparedStatementSetter { - private int value1; - private int value2; - private String value3; - private String value4; - private String value5; - private int value6; - - public PSSForDoubleIntTripleStringInt(int value1, int value2, String value3, String value4, String value5, int value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setString(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - ps.setInt(6, this.value6); - } - } - - public static class PSSForTripleIntTripleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private String value4; - private String value5; - private String value6; - - public PSSForTripleIntTripleString(int value1, int value2, int value3, String value4, String value5, String value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setString(4, this.value4); - ps.setString(5, this.value5); - ps.setString(6, this.value6); - } - } - - public static class PSSForFourInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - - public PSSForFourInt(int value1, int value2, int value3, int value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - } - } - - public static class PSSForFourIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private String value5; - - public PSSForFourIntString(int value1, int value2, int value3, int value4, String value5) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setString(5, this.value5); - } - } - - public static class PSSForFourIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private String value5; - private String value6; - - public PSSForFourIntDoubleString(int value1, int value2, int value3, int value4, String value5, String value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setString(5, this.value5); - ps.setString(6, this.value6); - } - } - - public static class PSSForFiveInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - - public PSSForFiveInt(int value1, int value2, int value3, int value4, int value5) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - } - } - - public static class PSSForFiveIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private String value6; - - public PSSForFiveIntString(int value1, int value2, int value3, int value4, int value5, String value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setString(6, this.value6); - } - } - - public static class PSSForFiveIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private String value6; - private String value7; - - public PSSForFiveIntDoubleString(int value1, int value2, int value3, int value4, int value5, String value6, String value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setString(6, this.value6); - ps.setString(7, this.value7); - } - } - - public static class PSSForSixInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - - public PSSForSixInt(int value1, int value2, int value3, int value4, int value5, int value6) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - } - } - - - public static class PSSForSixIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private String value7; - - public PSSForSixIntString(int value1, int value2, int value3, int value4, int value5, int value6, String value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setString(7, this.value7); - } - } - - public static class PSSForSixIntDoubleString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private String value7; - private String value8; - - public PSSForSixIntDoubleString(int value1, int value2, int value3, int value4, int value5, int value6, String value7, String value8) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setString(7, this.value7); - ps.setString(8, this.value8); - } - } - - public static class PSSForSevenIntString implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - private String value8; - - public PSSForSevenIntString(int value1, int value2, int value3, int value4, int value5, int value6, int value7, String value8) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - ps.setString(8, this.value8); - } - } - - - public static class PSSForSevenInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - - public PSSForSevenInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - } - } - - public static class PSSForEightInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - private int value8; - - public PSSForEightInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - ps.setInt(8, this.value8); - } - } - - public static class PSSForNineInt implements PreparedStatementSetter { - private int value1; - private int value2; - private int value3; - private int value4; - private int value5; - private int value6; - private int value7; - private int value8; - private int value9; - - public PSSForNineInt(int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - this.value7 = value7; - this.value8 = value8; - this.value9 = value9; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setInt(4, this.value4); - ps.setInt(5, this.value5); - ps.setInt(6, this.value6); - ps.setInt(7, this.value7); - ps.setInt(8, this.value8); - ps.setInt(9, this.value9); - } - } - - public static class PSSForLongInt implements PreparedStatementSetter { - private long lValue; - private int rValue; - - public PSSForLongInt(long l_value, int r_value) { - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - ps.setInt(2, this.rValue); - } - } - - public static class PSSForLongIntLong implements PreparedStatementSetter { - private long v1; - private int v2; - private long v3; - - public PSSForLongIntLong(long v1, int v2, long v3) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.v1); - ps.setInt(2, this.v2); - ps.setLong(3, this.v3); - } - } - - public static class PSSForLongIntString implements PreparedStatementSetter { - private long lValue; - private int rValue; - private String sValue; - - public PSSForLongIntString(long l_value, int r_value, String s_value) { - this.lValue = l_value; - this.rValue = r_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.sValue); - } - } - - public static class PSSForLongStringLong implements PreparedStatementSetter { - private long value1; - private String value2; - private long value3; - - public PSSForLongStringLong(long value1, String value2, long value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.value1); - ps.setString(2, this.value2); - ps.setLong(3, this.value3); - } - } - - public static class PSSForIntLong implements PreparedStatementSetter { - private int rValue; - private long lValue; - - public PSSForIntLong(int r_value, long l_value) { - this.rValue = r_value; - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.rValue); - ps.setLong(2, this.lValue); - } - } - - public static class PSSForLong implements PreparedStatementSetter { - private long lValue; - - public PSSForLong(long l_value) { - this.lValue = l_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - } - } - - public static class PSSForDoubleLong implements PreparedStatementSetter { - private long lValue; - private long rValue; - - public PSSForDoubleLong(long l_value, long r_value) { - this.lValue = l_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setLong(1, this.lValue); - ps.setLong(2, this.rValue); - } - } - - public static class PSSForIntString implements PreparedStatementSetter { - private int rValue; - private String sValue; - - public PSSForIntString(int r_value, String s_value) { - this.rValue = r_value; - this.sValue = s_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.rValue); - ps.setString(2, this.sValue); - } - } - - public static class PSSForIntDoubleString implements PreparedStatementSetter { - private int rValue; - private String sValue1; - private String sValue2; - - public PSSForIntDoubleString(int r_value, String s_value1, String s_value2) { - this.rValue = r_value; - this.sValue1 = s_value1; - this.sValue2 = s_value2; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.rValue); - ps.setString(2, this.sValue1); - ps.setString(3, this.sValue2); - } - } - - public static class PSSForIntTripleString implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private String v4; - - public PSSForIntTripleString(int v1, String v2, String v3, String v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(3, this.v4); - } - } - - public static class PSSForIntStringDoubleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private int v3; - private int v4; - - public PSSForIntStringDoubleInt(int v1, String v2, int v3, int v4) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setInt(3, this.v3); - ps.setInt(4, this.v4); - } - } - - public static class PSSForIntDoubleStringDoubleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private int v4; - private int v5; - - public PSSForIntDoubleStringDoubleInt(int v1, String v2, String v3, int v4, int v5) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setInt(4, this.v4); - ps.setInt(5, this.v5); - } - } - - public static class PSSForIntTripleStringDoubleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private String v4; - private int v5; - private int v6; - - public PSSForIntTripleStringDoubleInt(int v1, String v2, String v3, String v4, int v5, int v6) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - this.v6 = v6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - ps.setInt(5, this.v5); - ps.setInt(6, this.v6); - } - } - - public static class PSSForIntDoubleStringTripleInt implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private int v4; - private int v5; - private int v6; - - public PSSForIntDoubleStringTripleInt(int v1, String v2, String v3, int v4, int v5, int v6) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - this.v6 = v6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setInt(4, this.v4); - ps.setInt(5, this.v5); - ps.setInt(6, this.v6); - } - } - - public static class PSSForIntFiveString implements PreparedStatementSetter { - private int v1; - private String v2; - private String v3; - private String v4; - private String v5; - private String v6; - - public PSSForIntFiveString(int v1, String v2, String v3, String v4, String v5, String v6) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.v4 = v4; - this.v5 = v5; - this.v6 = v6; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setInt(1, this.v1); - ps.setString(2, this.v2); - ps.setString(3, this.v3); - ps.setString(4, this.v4); - ps.setString(5, this.v5); - ps.setString(6, this.v6); - } - } - - public static class PSSForStringInt implements PreparedStatementSetter { - private String sValue; - private int rValue; - - public PSSForStringInt(String s_value, int r_value) { - this.sValue = s_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.rValue); - } - } - - public static class PSSForDoubleStringDoubleIntString implements PreparedStatementSetter { - private String sValue1; - private String sValue2; - private String sValue3; - private int rValue1; - private int rValue2; - - public PSSForDoubleStringDoubleIntString(String sValue1, String sValue2, int rValue1, int rValue2, String sValue3) { - this.sValue1 = sValue1; - this.sValue2 = sValue2; - this.sValue3 = sValue3; - this.rValue1 = rValue1; - this.rValue2 = rValue2; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue1); - ps.setString(2, this.sValue2); - ps.setInt(3, this.rValue1); - ps.setInt(4, this.rValue2); - ps.setString(5, this.sValue3); - } - } - - public static class PSSForStringLong implements PreparedStatementSetter { - private String sValue; - private long rValue; - - public PSSForStringLong(String s_value, long r_value) { - this.sValue = s_value; - this.rValue = r_value; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setLong(2, this.rValue); - } - } - - public static class PSSForStringIntLong implements PreparedStatementSetter { - private String value1; - private int value2; - private long value3; - - public PSSForStringIntLong(String value1, int value2, long value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setInt(2, this.value2); - ps.setLong(3, this.value3); - } - } - - public static class PSSForStringDoubleIntLong implements PreparedStatementSetter { - private String value1; - private int value2; - private int value3; - private long value4; - - public PSSForStringDoubleIntLong(String value1, int value2, int value3, long value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - } - - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setInt(2, this.value2); - ps.setInt(3, this.value3); - ps.setLong(4, this.value4); - } - } - - public static class PSSForStringLongInt implements PreparedStatementSetter { - private String value1; - private long value2; - private int value3; - - public PSSForStringLongInt(String value1, long value2, int value3) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - } +import org.springframework.jdbc.core.PreparedStatementSetter; - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setLong(2, this.value2); - ps.setInt(3, this.value3); - } - } +import java.sql.PreparedStatement; +import java.sql.SQLException; - public static class PSSForStringDoubleLongInt implements PreparedStatementSetter { - private String value1; - private long value2; - private long value3; - private int value4; +public class PSSetDao { + public static class PSSForInts implements PreparedStatementSetter { + private Integer[] value; - public PSSForStringDoubleLongInt(String value1, long value2, long value3, int value4) { - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; + public PSSForInts(Integer... value) { + this.value = value; } public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.value1); - ps.setLong(2, this.value2); - ps.setLong(3, this.value3); - ps.setInt(4, this.value4); - } - } - - public static class PSSForStringIntString implements PreparedStatementSetter { - private String sValue; - private int rValue; - private String tValue; - - public PSSForStringIntString(String s_value, int r_value, String t_value) { - this.sValue = s_value; - this.rValue = r_value; - this.tValue = t_value; - } - public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.sValue); - ps.setInt(2, this.rValue); - ps.setString(3, this.tValue); + for (int i = 0; i < value.length; i++) { + ps.setInt((i + 1), this.value[i]); + } } } - public static class PSSForSIIS implements PreparedStatementSetter { - private String s1; - private int i1; - private int i2; - private String s2; + public static class PSSForStrings implements PreparedStatementSetter { + private String[] value; - public PSSForSIIS(String s1, int i1, int i2, String s2) { - this.s1 = s1; - this.i1 = i1; - this.i2 = i2; - this.s2 = s2; + public PSSForStrings(String... value) { + this.value = value; } public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, this.s1); - ps.setInt(2, this.i1); - ps.setInt(3, this.i2); - ps.setString(4, this.s2); - } - } - - public static class PSSForStringInts implements PreparedStatementSetter { - private String s1; - private Integer ints[]; - - public PSSForStringInts(String s1, Integer... ints) { - this.s1 = s1; - this.ints = ints; - } - public void setValues(PreparedStatement ps) throws SQLException { - int count = 1; - ps.setString(count++, this.s1); - for (int i = 0; i < ints.length; i++) { - ps.setInt(count++, this.ints[i]); + for (int i = 0; i < value.length; i++) { + ps.setString((i + 1), this.value[i]); } } } @@ -1500,7 +39,7 @@ public void setValues(PreparedStatement ps) throws SQLException { public static class PSSForIntsStrings implements PreparedStatementSetter { int intCount; int stringCount; - Object objects[]; + Object[] objects; public PSSForIntsStrings(int intCount, int stringCount, Object... objects) { this.intCount = intCount; @@ -1519,7 +58,7 @@ public void setValues(PreparedStatement ps) throws SQLException { public static class PSSForStringsInts implements PreparedStatementSetter { int stringCount; int intCount; - Object objects[]; + Object[] objects; public PSSForStringsInts(int stringCount, int intCount, Object... objects) { this.stringCount = stringCount; @@ -1534,72 +73,4 @@ public void setValues(PreparedStatement ps) throws SQLException { for (int i = 0; i < intCount; i++) ps.setInt(pos++, (Integer) objects[i + stringCount]); } } - - public static class PSSForIntStringInts implements PreparedStatementSetter { - private int i1; - private String s1; - private Integer ints[]; - - public PSSForIntStringInts(int i1, String s1, Integer... ints) { - this.i1 = i1; - this.s1 = s1; - this.ints = ints; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int count = 1; - ps.setInt(count++, this.i1); - ps.setString(count++, this.s1); - for (int i = 0; i < ints.length; i++) { - ps.setInt(count++, this.ints[i]); - } - } - } - - public static class PSSForTripleIntStrings implements PreparedStatementSetter { - private int v1; - private int v2; - private int v3; - private String strings[]; - - public PSSForTripleIntStrings(int v1, int v2, int v3, String... strings) { - this.v1 = v1; - this.v2 = v2; - this.v3 = v3; - this.strings = strings; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int count = 1; - ps.setInt(count++, this.v1); - ps.setInt(count++, this.v2); - ps.setInt(count++, this.v3); - for (int i = 0; i < strings.length; i++) { - ps.setString(count++, this.strings[i]); - } - } - } - - public static class PSSForStringsIntsStrings implements PreparedStatementSetter { - int stringCount; - int intCount; - int stringCount2; - Object objects[]; - - public PSSForStringsIntsStrings(int stringCount, int intCount, int stringCount2, Object... objects) { - this.stringCount = stringCount; - this.intCount = intCount; - this.stringCount2 = stringCount2; - this.objects = objects; - } - - public void setValues(PreparedStatement ps) throws SQLException { - int pos = 1; - - for (int i = 0; i < stringCount; i++) ps.setString(pos++, (String) objects[i]); - for (int i = 0; i < intCount; i++) ps.setInt(pos++, (Integer) objects[i + stringCount]); - for (int i = 0; i < stringCount2; i++) ps.setString(pos++, (String) objects[i + stringCount + intCount]); - } - } - } diff --git a/src/main/java/com/study/realworld/dao/ResultDao.java b/src/main/java/com/study/realworld/dao/ResultDao.java deleted file mode 100644 index f3a7c0ac..00000000 --- a/src/main/java/com/study/realworld/dao/ResultDao.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.study.realworld.dao; - -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.ResultSetExtractor; - -public class ResultDao { - public static class RSEForResult implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, DataAccessException { - ResultSetMetaData rsMeta; - int z; - Map row = null; - - if (rs.next() == true) { - rsMeta = rs.getMetaData(); - - row = new HashMap(); - - rs.first(); - - for (z = 1; z <= rsMeta.getColumnCount(); z++) { - row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); - } - } - - return row; - } - } - - @SuppressWarnings("unchecked") - public static class RSEForResultSet implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, DataAccessException { - ResultSetMetaData rsMeta; - int size; - int i; - int z; - Map[] row = null; - - rsMeta = rs.getMetaData(); - - rs.last(); - - size = rs.getRow(); - - if (size > 0) { - row = new Map[size]; - - rs.first(); - - for (i = 0; i < size; i++) { - row[i] = new HashMap(); - - for (z = 1; z <= rsMeta.getColumnCount(); z++) { - row[i].put(rsMeta.getColumnLabel(z), rs.getObject(z)); - } - - rs.next(); - } - } - - return row; - } - } - - public static class RSEForResultListSet implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, DataAccessException { - ResultSetMetaData rsMeta; - int size; - int i; - int z; - List> list = null; - - rsMeta = rs.getMetaData(); - - rs.last(); - - size = rs.getRow(); - - if (size > 0) { - list = new ArrayList>(); - - rs.first(); - - for (i = 0; i < size; i++) { - Map row = new HashMap(); - - for (z = 1; z <= rsMeta.getColumnCount(); z++) { - row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); - } - list.add(row); - - rs.next(); - } - } - - return list; - } - } - - public static class RSEForInt implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - return rs.getInt(1); - } else { - return 0; - } - } - } - - public static class RSEForString implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - return rs.getString(1); - } else { - return null; - } - } - } - - public static class RSEForBoolean implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - return rs.getBoolean(1); - } else { - return false; - } - } - } - - public static class RSEForIntList implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - List lst = new ArrayList(); - - for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { - lst.add(rs.getInt(i)); - } - - return lst; - } else { - return null; - } - } - } - - - public static class RSEForStringList implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - if (rs.next() == true) { - List lst = new ArrayList(); - - for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { - lst.add(rs.getString(i)); - } - - return lst; - } else { - return null; - } - } - } - - public static class RSEForIntListFromRows implements ResultSetExtractor { - public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { - List lst = new ArrayList(); - - while (rs.next()) { - lst.add(rs.getInt(1)); - } - - return lst; - } - } -} diff --git a/src/main/java/com/study/realworld/dao/UserDao.java b/src/main/java/com/study/realworld/dao/UserDao.java index ba00f4c2..91c69fe0 100644 --- a/src/main/java/com/study/realworld/dao/UserDao.java +++ b/src/main/java/com/study/realworld/dao/UserDao.java @@ -14,18 +14,18 @@ public UserDao(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } - public boolean checkSameName(String username) { //같은 닉네임의 유저가 있는지 확인 - final String query = "select EXISTS(select id from USER where USERNAME=?)"; - return (boolean) jdbcTemplate.query(query, new PSSetDao.PSSForString(username), new ResultDao.RSEForBoolean()); + public User getUserByName(String username) { //같은 닉네임의 유저가 있는지 확인 + final String query = "select id from USER where USERNAME=?"; + return jdbcTemplate.queryForObject(query, User.class, username); } - public boolean checkSameEmail(String email) { //같은 이메일의 유저가 있는지 확인 - final String query = "select EXISTS(select id from USER where email=?)"; - return (boolean) jdbcTemplate.query(query, new PSSetDao.PSSForString(email), new ResultDao.RSEForBoolean()); + public User getUserByEmail(String email) { //같은 이메일의 유저가 있는지 확인 + final String query = "select id from USER where email=?"; + return jdbcTemplate.queryForObject(query, User.class, email); } - public int registUser(String username, String email, String password) { //신규 유저 삽입 + public int insertUser(String username, String email, String password) { //신규 유저 삽입 final String query = "insert into USER(USERNAME, EMAIL, PASSWORD) values (?, ?, ?)"; - return jdbcTemplate.update(query, new PSSetDao.PSSForTripleString(username, email, password)); + return jdbcTemplate.update(query, new PSSetDao.PSSForStrings(username, email, password)); } } diff --git a/src/main/java/com/study/realworld/domain/User.java b/src/main/java/com/study/realworld/domain/User.java index f190ec56..1ccc8cc2 100644 --- a/src/main/java/com/study/realworld/domain/User.java +++ b/src/main/java/com/study/realworld/domain/User.java @@ -1,6 +1,7 @@ package com.study.realworld.domain; public class User { + private Long id; private String email; private String token; private String username; diff --git a/src/main/java/com/study/realworld/service/UserService.java b/src/main/java/com/study/realworld/service/UserService.java index 9947b934..b345173a 100644 --- a/src/main/java/com/study/realworld/service/UserService.java +++ b/src/main/java/com/study/realworld/service/UserService.java @@ -1,8 +1,7 @@ package com.study.realworld.service; import com.google.gson.JsonObject; -import com.study.realworld.common.Errors; -import com.study.realworld.common.Func; +import com.study.realworld.common.ErrorCode; import com.study.realworld.dao.UserDao; import org.springframework.stereotype.Service; @@ -14,24 +13,21 @@ public UserService(UserDao userDao) { this.userDao = userDao; } - public String users(JsonObject user) { - if (userDao.checkSameName(getString(user, "username"))) { //닉네임 체크 - return Func.getErrorJson(Errors.SAME_NICKNAME); - } else if (userDao.checkSameEmail(getString(user, "email"))) { //email 체크 - return Func.getErrorJson(Errors.SAME_EMAIL); + public Object users(JsonObject user) { + if (userDao.getUserByName(getString(user, "username")) != null) { //닉네임 체크 + return ErrorCode.SAME_NICKNAME; + } else if (userDao.getUserByEmail(getString(user, "email")) != null) { //email 체크 + return ErrorCode.SAME_EMAIL; } - if (userDao.registUser(getString(user, "username"), + if (userDao.insertUser(getString(user, "username"), getString(user, "email"), getString(user, "password")) < 0) { //등록하다가 에러났을경우 - return Func.getErrorJson(Errors.DB); + return ErrorCode.DB; } - JsonObject result = new JsonObject(); - result.add("user", user); - - return Func.getResultJson(result); + return user; } String getString(JsonObject jsonObject, String name) { From 7ee006317195d4565ca306551acfdcc562b232de Mon Sep 17 00:00:00 2001 From: com8599 Date: Wed, 11 Aug 2021 14:50:52 +0900 Subject: [PATCH 13/13] [#6] ptmt issue complete, return by User --- build.gradle | 1 + .../com/study/realworld/common/JsonFunc.java | 10 +- .../realworld/controller/UserController.java | 13 +- .../com/study/realworld/dao/ResultDao.java | 210 ++++++++++++++++++ .../java/com/study/realworld/dao/UserDao.java | 19 +- .../java/com/study/realworld/domain/User.java | 21 +- .../study/realworld/service/UserService.java | 16 +- 7 files changed, 261 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/study/realworld/dao/ResultDao.java diff --git a/build.gradle b/build.gradle index d6edc244..59553010 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.projectlombok:lombok:1.18.18' runtimeOnly 'com.h2database:h2' testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation group: 'com.google.code.gson', name: 'gson', version: '2.7' diff --git a/src/main/java/com/study/realworld/common/JsonFunc.java b/src/main/java/com/study/realworld/common/JsonFunc.java index 908bdc7f..5b9d8f2c 100644 --- a/src/main/java/com/study/realworld/common/JsonFunc.java +++ b/src/main/java/com/study/realworld/common/JsonFunc.java @@ -1,6 +1,9 @@ package com.study.realworld.common; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonObject; +import com.google.gson.JsonParser; public class JsonFunc { public static String getErrorJson(ErrorCode errorCode, Object... objects) { @@ -20,11 +23,12 @@ public static String getErrorJson(ErrorCode errorCode, Object... objects) { return json.toString(); } - public static String getResultJson(JsonObject result) { + public static String getResultJson(Object result) throws JsonProcessingException { JsonObject json = new JsonObject(); - json.add("R", result); + ObjectMapper objectMapper = new ObjectMapper(); + json.add("R", new JsonParser().parse(objectMapper.writeValueAsString(result))); - return result.toString(); + return json.toString(); } } diff --git a/src/main/java/com/study/realworld/controller/UserController.java b/src/main/java/com/study/realworld/controller/UserController.java index 393b7e09..d292f33a 100644 --- a/src/main/java/com/study/realworld/controller/UserController.java +++ b/src/main/java/com/study/realworld/controller/UserController.java @@ -1,18 +1,16 @@ package com.study.realworld.controller; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; import com.study.realworld.common.ErrorCode; import com.study.realworld.common.JsonFunc; +import com.study.realworld.domain.User; import com.study.realworld.service.UserService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Map; - @RestController @RequestMapping("/api") public class UserController { @@ -24,9 +22,8 @@ public UserController(UserService userService) { @ApiOperation(value = "사용자 등록", notes = "사용자 등록") @PostMapping("/users") //post 등록 api - public String users(@RequestBody Map param) { - JsonObject user = new Gson().toJsonTree(param).getAsJsonObject(); - Object result = userService.users((JsonObject) user.get("user")); + public String users(@JsonProperty("user") User user) throws JsonProcessingException { + Object result = userService.users(user); if (result instanceof ErrorCode) { return JsonFunc.getErrorJson((ErrorCode) result); } diff --git a/src/main/java/com/study/realworld/dao/ResultDao.java b/src/main/java/com/study/realworld/dao/ResultDao.java new file mode 100644 index 00000000..44ae8a63 --- /dev/null +++ b/src/main/java/com/study/realworld/dao/ResultDao.java @@ -0,0 +1,210 @@ +package com.study.realworld.dao; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.study.realworld.domain.User; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.ResultSetExtractor; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ResultDao { + public static class RSEForResult implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int z; + Map row = null; + + if (rs.next() == true) { + rsMeta = rs.getMetaData(); + + row = new HashMap(); + + rs.first(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + } + + return row; + } + } + + public static class RSEForResultSet implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int size; + int i; + int z; + Map[] row = null; + + rsMeta = rs.getMetaData(); + + rs.last(); + + size = rs.getRow(); + + if (size > 0) { + row = new Map[size]; + + rs.first(); + + for (i = 0; i < size; i++) { + row[i] = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row[i].put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + + rs.next(); + } + } + + return row; + } + } + + public static class RSEForResultListSet implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, DataAccessException { + ResultSetMetaData rsMeta; + int size; + int i; + int z; + List> list = null; + + rsMeta = rs.getMetaData(); + + rs.last(); + + size = rs.getRow(); + + if (size > 0) { + list = new ArrayList>(); + + rs.first(); + + for (i = 0; i < size; i++) { + Map row = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + list.add(row); + + rs.next(); + } + } + + return list; + } + } + + public static class RSEForInt implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getInt(1); + } else { + return 0; + } + } + } + + public static class RSEForString implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getString(1); + } else { + return null; + } + } + } + + public static class RSEForBoolean implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + return rs.getBoolean(1); + } else { + return false; + } + } + } + + public static class RSEForIntList implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + List lst = new ArrayList(); + + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + lst.add(rs.getInt(i)); + } + + return lst; + } else { + return null; + } + } + } + + + public static class RSEForStringList implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + if (rs.next() == true) { + List lst = new ArrayList(); + + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + lst.add(rs.getString(i)); + } + + return lst; + } else { + return null; + } + } + } + + public static class RSEForIntListFromRows implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + List lst = new ArrayList(); + + while (rs.next()) { + lst.add(rs.getInt(1)); + } + + return lst; + } + } + + static class RSEForUser implements ResultSetExtractor { + public Object extractData(ResultSet rs) throws SQLException, + DataAccessException { + ResultSetMetaData rsMeta; + int z; + Map row = null; + + if (rs.next() == true) { + rsMeta = rs.getMetaData(); + + row = new HashMap(); + + for (z = 1; z <= rsMeta.getColumnCount(); z++) { + row.put(rsMeta.getColumnLabel(z), rs.getObject(z)); + } + } + if (row == null) + return null; + return new ObjectMapper().convertValue(row, User.class); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/study/realworld/dao/UserDao.java b/src/main/java/com/study/realworld/dao/UserDao.java index 91c69fe0..0e69d873 100644 --- a/src/main/java/com/study/realworld/dao/UserDao.java +++ b/src/main/java/com/study/realworld/dao/UserDao.java @@ -2,9 +2,14 @@ import com.study.realworld.domain.User; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; +import java.util.Optional; + +import static java.util.Optional.ofNullable; + @Repository public class UserDao { private final JdbcTemplate jdbcTemplate; @@ -14,14 +19,16 @@ public UserDao(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } - public User getUserByName(String username) { //같은 닉네임의 유저가 있는지 확인 - final String query = "select id from USER where USERNAME=?"; - return jdbcTemplate.queryForObject(query, User.class, username); + public Optional getUserByName(String username) throws EmptyResultDataAccessException { //같은 닉네임의 유저가 있는지 확인 + final String query = "select id, email, username, password, bio, image from USER where USERNAME=?"; + User user = (User) jdbcTemplate.query(query, new PSSetDao.PSSForStrings(username), new ResultDao.RSEForUser()); + return ofNullable(user); } - public User getUserByEmail(String email) { //같은 이메일의 유저가 있는지 확인 - final String query = "select id from USER where email=?"; - return jdbcTemplate.queryForObject(query, User.class, email); + public Optional getUserByEmail(String email) { //같은 이메일의 유저가 있는지 확인 + final String query = "select id, email, username, password, bio, image from USER where EMAIL=?"; + User user = (User) jdbcTemplate.query(query, new PSSetDao.PSSForStrings(email), new ResultDao.RSEForUser()); + return ofNullable(user); } public int insertUser(String username, String email, String password) { //신규 유저 삽입 diff --git a/src/main/java/com/study/realworld/domain/User.java b/src/main/java/com/study/realworld/domain/User.java index 1ccc8cc2..501218d6 100644 --- a/src/main/java/com/study/realworld/domain/User.java +++ b/src/main/java/com/study/realworld/domain/User.java @@ -1,16 +1,27 @@ package com.study.realworld.domain; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data public class User { private Long id; private String email; private String token; private String username; + private String password; private String bio; private String image; - public User(String email, String username, String bio, String image) { + @JsonCreator + public User(@JsonProperty("ID") Long id, @JsonProperty("EMAIL") String email, @JsonProperty("USERNAME") String username, + @JsonProperty("PASSWORD") String password, @JsonProperty("BIO") String bio, @JsonProperty("IMAGE") String image) { + this.id = id; this.email = email; this.username = username; + this.password = password; this.bio = bio; this.image = image; } @@ -19,6 +30,10 @@ public void setToken(String token) { this.token = token; } + public Long getId() { + return id; + } + public String getEmail() { return email; } @@ -31,6 +46,10 @@ public String getUsername() { return username; } + public String getPassword() { + return password; + } + public String getBio() { return bio; } diff --git a/src/main/java/com/study/realworld/service/UserService.java b/src/main/java/com/study/realworld/service/UserService.java index b345173a..f406c006 100644 --- a/src/main/java/com/study/realworld/service/UserService.java +++ b/src/main/java/com/study/realworld/service/UserService.java @@ -1,8 +1,8 @@ package com.study.realworld.service; -import com.google.gson.JsonObject; import com.study.realworld.common.ErrorCode; import com.study.realworld.dao.UserDao; +import com.study.realworld.domain.User; import org.springframework.stereotype.Service; @Service @@ -13,24 +13,18 @@ public UserService(UserDao userDao) { this.userDao = userDao; } - public Object users(JsonObject user) { - if (userDao.getUserByName(getString(user, "username")) != null) { //닉네임 체크 + public Object users(User user) { + if (!userDao.getUserByName(user.getUsername()).isEmpty()) { //닉네임 체크 return ErrorCode.SAME_NICKNAME; - } else if (userDao.getUserByEmail(getString(user, "email")) != null) { //email 체크 + } else if (!userDao.getUserByEmail(user.getEmail()).isEmpty()) { //email 체크 return ErrorCode.SAME_EMAIL; } - if (userDao.insertUser(getString(user, "username"), - getString(user, "email"), - getString(user, "password")) < 0) { + if (userDao.insertUser(user.getUsername(), user.getEmail(), user.getPassword()) < 0) { //등록하다가 에러났을경우 return ErrorCode.DB; } return user; } - - String getString(JsonObject jsonObject, String name) { - return jsonObject.get(name).toString(); - } }