๐ข ์ฃผ์ํ์ฌ GEOPLAN
๐
๊ธฐ๊ฐ : 2021.07.01 ~ 2021.08.31
โณ AM 09:30 ~ PM 18:30
๐๋ฐฐ์ฐ๊ณ ์๋๊ฒ... Spring Framework, Android, IoT, MariaDB, UI/UX
- ๋ถ์ ๋ฐฐ์ / ํ์ฌ ์๊ฐ ๋ฐ ํ๋ก์ ํธ ์์ด๋์ด ์๊ฐ
- Google Smart Home๊ณผ Assistant๊ฐ์ ๊ด๊ณ ๋ฐ ๋์์๋ฆฌ ํ์ (์ฐธ๊ณ )
- AoA(Angle of Arrival), RTLS(Real Time Location System) ๊ธฐ์ ๊ณต๋ถ(์ฐธ๊ณ )
- Location device๋ก ๋์ฒดํ์ฌ ๊ตฌํํ ์ ์๋ ์์ด๋์ด ์๊ฐ
- cloud computing study
- ์ง ์ธ๋ถ์์ ์ง ์์ cloud๋ฅผ ์ ๊ทผ ๊ฐ๋ฅํ๊ฒ ํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผํ ์ง (๊ณ ์ ip๋ง์ผ๋ก ๋ ๊น?)
- Smart Home Study
- ๋ค์์ฃผ ๋ฐํ PPT ๋ง๋ค๊ธฐ
- ๊ฐ๋ฐ๋ถ์ฅ๋ ํผ๋๋ฐฑ
- Hole Punching ๊ธฐ์ ๊ณต๋ถ (์ฐธ๊ณ )
- Smart Home Map ๊ธฐ๋ฅ ๊ตฌํ (Device์์ ์ง ๋๋ฉด๊ณผ ๊ฐ๊ตฌ ์์น ํฌํจ + ์ฌ์ฉ์์ ์ค์๊ฐ ๋์ )
- ๊ธฐ์กด ์์ฑ ์ ์ด์์ ์์น ๊ธฐ๋ฐ ์๋ํ๋ก ๋์ฒดํ ๊ฒ์ธ๋ฐ ์ด๋ป๊ฒ ๊ตฌํํ๋ฉด ์ข์์ง
- ๋ด์ผ ์ฐ๊ตฌ์๋ UI/UX ๊ณํ ์ค๋ช
- ์ฐ๊ตฌ์๋ UI/UX ๊ณํ์ ์ค๋ช ๋ฐ ํผ๋๋ฐฑ
- Webhook ๊ธฐ์ ๊ณต๋ถ
- UWB, Beacon ๊ฐ๋ ํ์
- api ์ฐ๋ ๊ฐ๋ฐ
- SYNC, QUERY, EXECUTE, DISCONNECT intent ์ JSON ์ฝ๋ ๋ถ์
- Google API Search
- SmartThings ์์๋ณด๊ธฐ
- SmartThings API ๊ณต๋ถ
- 7์ผ๊ฐ ์คํฐ๋ & ๊ฐ๋ฐ ๋ด์ฉ ๋ฐํ ๋ฐ ํผ๋๋ฐฑ(๋ถ์ฅ๋, ๋ํ๋, ๊ฐ๋ฐํ์ฅ๋)
- UI/UX ์์ ์ ํ์ธ
- OAuth, SmartThings Rooms ๋ด๋ณด๊ธฐ
- API ์ฐ๋ ๋ฐ DB
- Google Open API ๊ฐ์ ธ์ ํ๋ฉด์ ๋์ฐ๊ธฐ
- ๋ฐ์ดํฐ DB ์ ์ฅ ๋ฐ ์ฐ๋
- Spring Server ๊ฐ๋ฐ์ ์์ ๊ธฐ์ด์ ์ธ ๋ถ๋ถ ๋ค์ ๊ณต๋ถํด์ค๊ธฐ
- Android UI ์์
- DB ์ค๊ณ
- Android UI ์์
- MariDB ์ค์น
- Android UI ์์
- DB Table ์ค๊ณ ์ ์๊ตฌ์ฌํญ ๋ถ์
- Database ํ ์ด๋ธ ์ค๊ณ
- DB ๊ฐ๋ ๊ณต๋ถํ๊ธฐ
Tool(IDE) | ๊ฐ๋ฐ ๋ด์ฉ | ํค์๋ |
---|---|---|
STS | Spring jdbc๋ฅผ ์ด์ฉํด์ mariaDB(HeidiSQL)๊ฐ JSon ํํ๋ก ๋ถ๋ฌ์ค๊ธฐ | Spring STS gradle JDBC JSON |
Android Studio | STS์ App ์ฐ๋(๊ณํ) | . |
MariaDB(HeidiSQL) | table์ค๊ณ(์งํ์ค) | ํ๋ก์ ํธ ์๊ตฌ์ฌํญ |
- ๋ด ์ฝ๋
@Component public class UserDao { @Autowired private JdbcTemplate jdbcTemplate; public Map<String, Object> getName(int seq) throws Exception { String sql = "SELCET * FROM smart_home"; return jdbcTemplate.queryForMap(sql); } } @Autowired public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); }
- ๋ด ์ฝ๋
@Controller @RequiredArgsConstructor @RequestMapping(value="/test2") public class Test2Controller { @Autowired UserDao userdao; @RequestMapping(method={RequestMethod.GET, RequestMethod.POST}) public @ResponseBody String isTest() { return "Test"; } @RequestMapping(value="/checkNetwork", method={RequestMethod.GET, RequestMethod.POST}) public @ResponseBody String checkNetwork() { return "Network Connection"; } @RequestMapping(value="/checkUserDao", method={RequestMethod.GET, RequestMethod.POST}) public @ResponseBody String checkNetwork() { return userdao.getName(0); } }
- ๋ด ์ฝ๋
package kr.co.geoplan.smarthome.config; import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.boot.CommandLineRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import lombok.AllArgsConstructor; @AllArgsConstructor @Configuration public class DBConfig { private final String DRIVER = "com.mariadb.jdbc.Driver"; private final String URL = "geoplan.iptime.org"; private String username = "****"; private String password = "****"; @Bean public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(DRIVER); dataSource.setUrl(URL); dataSource.setUsername(username); dataSource.setPassword(password); return dataSource; } }
Annotation(@)์ ์ฌ์ ์ ์๋ฏธ๋ก๋ ์ฃผ์์ด๋ผ๋ ๋ป์ด๋ค.
์๋ฐ์์ Annotation์ ์ฝ๋ ์ฌ์ด์ ์ฃผ์์ฒ๋ผ ์ฐ์ด๋ฉฐ ํน๋ณํ ์๋ฏธ, ๊ธฐ๋ฅ์ ์ํํ๋๋ก ํ๋ ๊ธฐ์ ์ด๋ค.
์ฆ, ํ๋ก๊ทธ๋จ์๊ฒ ์ถ๊ฐ์ ์ธ ์ ๋ณด๋ฅผ ์ ๊ณตํด์ฃผ๋ ๋ฉํ๋ฐ์ดํฐ๋ผ๊ณ ๋ณผ ์ ์๋ค.
๐ฅ ์ฉ๋
- ์ปดํ์ผ๋ฌ์๊ฒ ์ฝ๋ ์์ฑ ๋ฌธ๋ฒ ์๋ฌ๋ฅผ ์ฒดํฌํ๋๋ก ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ค.
- ์ํํธ์จ์ด ๊ฐ๋ฐ ํด์ด ๋น๋๋ ๋ฐฐ์น์ ์ฝ๋๋ฅผ ์๋์ผ๋ก ์์ฑํ ์ ์๋๋ก ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ค.
- ์คํ์(๋ฐํ์์) ํน์ ๊ธฐ๋ฅ์ ์คํํ๋๋ก ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ค.
๐ Annotation ์ข ๋ฅ
- ์ด๋ ธํ ์ด์ @Autowired @Bean @Repository ๊ฒ์ํด๋ณด๊ธฐ
- ์ค๋ฅํด๊ฒฐ? DAO ๋ถ๋ฌ์ค๋ ๋ถ๋ถ UserDao userdao = new UserDao() x -> ์ ์ญ๋ณ์๋ก ๋นผ๊ณ @Autowired ์ด๋ ธํ ์ด์ ์ถ๊ฐ UserDao userdao; ์ผ๋ก ์์ ํ๋๊น Bean ์ธ์ ์ ์ ๋จ (์ฐธ๊ณ )
Tool(IDE) | ๊ฐ๋ฐ ๋ด์ฉ | ํค์๋ |
---|---|---|
Postman | Cookie ์์ฑํด์ ๋ณด์ ์ธ์ฆ์์ฒญ ์์ด Controller ์ ๊ทผํ๋๋ก ํ๊ธฐ | Cookie Session Config Http |
MariaDB(HeidiSQL) | LoginController ๊ฐ JSON ํ์์ผ๋ก ์ ๋ ฅํด์ DB์ ๋ก๊ทธ์ธ ์ ๋ณด ์ ์ฅํ๊ธฐ | Controller Postman HeidiSQL UserDTO |
- ๋ด ์ฝ๋
Map<String, Object> result = Maps.newHashMap(); try { LoginResult loginResult = userService.checkLogin(loginDTO); //๋ก๊ทธ์ธ SUCCESS์ ์ธ์ ์์ฑ if (loginResult == LoginResult.SUCCESS) { UserSessionDTO session = userService.makeSessionId(loginDTO.getEmail()); Cookie cookie = new Cookie(Const.SESSION_KEY, session.getSessionId()); res.addCookie(cookie); } //๋ก๊ทธ์ธ SUCCESS์ธ ๋ ๋ก๊ทธ์ธ๊ฒฐ๊ณผ๋ฅผ ์ ๋ฌ๋งํ๋ค. result.put("data", loginResult); } catch (Exception e) { e.printStackTrace(); result.put("error", "SERVER ERROR"); } return result;
- ๋ด ์ฝ๋
http .authorizeRequests() .antMatchers("/").permitAll() .antMatchers("/login/**").permitAll() //.antMatchers("/test/**").permitAll() .anyRequest() .fullyAuthenticated();
Tool(IDE) | ๊ฐ๋ฐ ๋ด์ฉ | ํค์๋ |
---|---|---|
Android Studio | retrofit library ์ฌ์ฉํ์ฌ ์๋ฒ์์ dto ์ ๋ณด ๋ถ๋ฌ์ android app์ ์ถ๋ ฅํ๊ธฐ | retrofit spring android |
Android Studio | UI์ ์ |
-
๋ด ์ฝ๋
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_json_test); tv = findViewById(R.id.tvResult1); b = findViewById(R.id.button2); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doJSONParser(); } }); }
void doJSONParser() { LoginDTO loginInfo = getLoginInfo(); retrofitService = RetrofitClient.getClient().create(RetrofitService.class); retrofitService.login(loginInfo).enqueue(new ResultDataCallback(this) { @Override public void onFailure(Call<ResultData> call, Throwable t) { //int j = 0; dubug test } @Override public void onSuccess(Call<ResultData> call, Response<ResultData> response) { ResultData result = response.body(); //assert result != null; String vs = (String) result.getData(); LoginResult rs = LoginResult.valueOf(vs); if(true) { tv.setText(loginInfo.toString()); } } }); //tv.setText(loginInfo.toString()); }
private LoginDTO getLoginInfo() { LoginDTO loginDTO = new LoginDTO(); loginDTO.setEmail(email); loginDTO.setPassword(pw); loginDTO.setJoinType(joinType); //tv.setText(loginDTO.toString()); return loginDTO; }
๐ฅ๐ฅ ์ฃผ์์ฌํญ
- ์คํํ๊ธฐ ์ ์ ipํ์ธ
- Debug ํ๋ฉด์ ํ์ธํ๊ธฐ!!
Tool(IDE) | ๊ฐ๋ฐ ๋ด์ฉ | ํค์๋ |
---|---|---|
Android Studio | retrofit library ์ฌ์ฉํ์ฌ ๋ฐ๋๋ก ์๋ฒ๋ฅผ ํตํด DB์ ์ ๊ทผํ์ฌ ๊ฐ ๋ณ๊ฒฝํ๊ธฐ | retrofit spring android |
Android Studio | UI์ ์ |