Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
[#29] 프로필 구현 (#36)
Browse files Browse the repository at this point in the history
* #29 프로필 구현
- 프로필 VO 추가

* #29 프로필 구현
- 기본 view 페이지 구축

* #29 프로필 구현
- 주석 수정

* #29 프로필 구현
- User.UserId 객체화
- Profile.hobbies 구조 변경
  - List<> 객체를 하나의 필드에 넣으려고 했지만, 지원하지 않고 Collection은 custom 지원X
  - oneToMany table 구조로 hobbies 테이블 추가

* #29 프로필 구현
- User.UserId 객체화 제거 (잠시 보류)
  - conflict 너무 많이 날거 같아서 다른 PR 머지후에 작업할게요

* #29 프로필 구현
- Profile API 추가
- 회원 활동중으로 변경될때 프로필 생성 로직 추가

* #29 프로필 구현
- Profile API 추가
- 회원 활동중으로 변경될때 프로필 생성 로직 추가
  • Loading branch information
bearics authored Nov 22, 2021
1 parent dd88573 commit e90a788
Show file tree
Hide file tree
Showing 27 changed files with 624 additions and 50 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ project(":user-api") {
project(":front") {
dependencies {
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
}
}

Expand Down
17 changes: 0 additions & 17 deletions front/src/main/kotlin/com/sns/front/controller/HomeController.kt

This file was deleted.

31 changes: 31 additions & 0 deletions front/src/main/kotlin/com/sns/front/controller/UserController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.sns.front.controller

import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping

/**
* User 관련된 페이지 모음
* @author Hyounglin Jun
*/
@Controller
class UserController {
@GetMapping("/home")
fun home(): String {
return "pages/home"
}

@GetMapping("/login")
fun login(): String {
return "pages/login"
}

@GetMapping("/register")
fun register(): String {
return "pages/register"
}

@GetMapping("/profile")
fun profile(): String {
return "pages/profile"
}
}
12 changes: 12 additions & 0 deletions front/src/main/resources/templates/fragments/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="footerFragment">
<footer class="footer">
<div class="content has-text-centered">
<p>
DDD 학습용으로 제작되었습니다.
</p>
</div>
</footer>
</th:block>
</html>
13 changes: 13 additions & 0 deletions front/src/main/resources/templates/fragments/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="headFragment">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>DDD Juniors</title>
<!-- CSS 로드 시작 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<!-- CSS 로드 끝 -->
</head>
</th:block>
</html>
60 changes: 60 additions & 0 deletions front/src/main/resources/templates/fragments/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="headerFragment(param1)">
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item is-Info" th:href="@{/home}">
DDD
</a>

<a role=" button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>

<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" th:href="@{/home}">
Home
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
More
</a>

<div class="navbar-dropdown">
<a class="navbar-item">
About
</a>
<a class="navbar-item">
Jobs
</a>
<a class="navbar-item">
Contact
</a>
<hr class="navbar-divider">
<a class="navbar-item">
Report an issue
</a>
</div>
</div>
</div>

<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary" th:href="@{/register}">
<strong>Sign up</strong>
</a>
<a class="button is-light" th:href="@{/login}">
Log in
</a>
</div>
</div>
</div>
</div>
</nav>
</th:block>
</html>
11 changes: 0 additions & 11 deletions front/src/main/resources/templates/home/home.html

This file was deleted.

17 changes: 17 additions & 0 deletions front/src/main/resources/templates/layouts/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lagn="ko"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<th:block th:replace="fragments/head :: headFragment"></th:block>
<body>
<!-- 최대 크기 제한 -->
<div class="container is-max-desktop">
<th:block th:replace="fragments/header :: headerFragment('Header')"></th:block>
<section class="section">
<th:block layout:fragment="content"></th:block>
</section>

<th:block th:replace="fragments/footer :: footerFragment"></th:block>
</div>
</body>
</html>
11 changes: 11 additions & 0 deletions front/src/main/resources/templates/pages/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layouts/layout}">
<!-- Page Content -->
<th:block layout:fragment="content">
<div class="notification is-primary">
Home 입니다
</div>
</th:block>
</html>
34 changes: 34 additions & 0 deletions front/src/main/resources/templates/pages/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layouts/layout}">
<!-- Page Content -->
<th:block layout:fragment="content">
<div class="field">
<p class="control has-icons-left has-icons-right">
<input class="input" type="email" placeholder="Email">
<span class="icon is-small is-left">
<i class="fas fa-envelope"></i>
</span>
<span class="icon is-small is-right">
<i class="fas fa-check"></i>
</span>
</p>
</div>
<div class="field">
<p class="control has-icons-left">
<input class="input" type="password" placeholder="Password">
<span class="icon is-small is-left">
<i class="fas fa-lock"></i>
</span>
</p>
</div>
<div class="field">
<p class="control">
<button class="button is-success">
Login
</button>
</p>
</div>
</th:block>
</html>
31 changes: 31 additions & 0 deletions front/src/main/resources/templates/pages/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layouts/layout}">
<!-- Page Content -->
<th:block layout:fragment="content">
<div class="card">
<div class="card-content">
<div class="media">
<div class="media-left">
<figure class="image is-48x48">
<img src="https://bulma.io/images/placeholders/96x96.png" alt="Placeholder image">
</figure>
</div>
<div class="media-content">
<p class="title is-4">John Smith</p>
<p class="subtitle is-6">@johnsmith</p>
</div>
</div>

<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Phasellus nec iaculis mauris. <a>@bulmaio</a>.
<a href="#">#css</a> <a href="#">#responsive</a>
<br>
<time datetime="2016-1-1">11:09 PM - 1 Jan 2016</time>
</div>
</div>
</div>
</th:block>
</html>
92 changes: 92 additions & 0 deletions front/src/main/resources/templates/pages/register.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layouts/layout}">
<!-- Page Content -->
<th:block layout:fragment="content">
<div class="field">
<label class="label">Name</label>
<div class="control">
<input class="input" type="text" placeholder="Text input">
</div>
</div>

<div class="field">
<label class="label">Username</label>
<div class="control has-icons-left has-icons-right">
<input class="input is-success" type="text" placeholder="Text input" value="bulma">
<span class="icon is-small is-left">
<i class="fas fa-user"></i>
</span>
<span class="icon is-small is-right">
<i class="fas fa-check"></i>
</span>
</div>
<p class="help is-success">This username is available</p>
</div>

<div class="field">
<label class="label">Email</label>
<div class="control has-icons-left has-icons-right">
<input class="input is-danger" type="email" placeholder="Email input" value="hello@">
<span class="icon is-small is-left">
<i class="fas fa-envelope"></i>
</span>
<span class="icon is-small is-right">
<i class="fas fa-exclamation-triangle"></i>
</span>
</div>
<p class="help is-danger">This email is invalid</p>
</div>

<div class="field">
<label class="label">Subject</label>
<div class="control">
<div class="select">
<select>
<option>Select dropdown</option>
<option>With options</option>
</select>
</div>
</div>
</div>

<div class="field">
<label class="label">Message</label>
<div class="control">
<textarea class="textarea" placeholder="Textarea"></textarea>
</div>
</div>

<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox">
I agree to the <a href="#">terms and conditions</a>
</label>
</div>
</div>

<div class="field">
<div class="control">
<label class="radio">
<input type="radio" name="question">
Yes
</label>
<label class="radio">
<input type="radio" name="question">
No
</label>
</div>
</div>

<div class="field is-grouped">
<div class="control">
<button class="button is-link">Submit</button>
</div>
<div class="control">
<button class="button is-link is-light">Cancel</button>
</div>
</div>
</th:block>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sns.user.component.user.application

import com.sns.user.component.user.domains.Profile
import com.sns.user.component.user.repositories.ProfileRepository
import org.springframework.stereotype.Service

/**
* @author Hyounglin Jun
*/
@Service
class ProfileCommandService(
val profileRepository: ProfileRepository,
) {
fun create(
userId: String,
): Profile {

val profile = Profile.create(userId)

profileRepository.save(profile)
return profile
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.sns.user.component.user.application

import com.sns.user.component.user.domains.Profile
import com.sns.user.component.user.repositories.ProfileRepository
import org.springframework.stereotype.Service
import java.util.*

/**
* @author Hyounglin Jun
*/
@Service
class ProfileQueryService(
val profileRepository: ProfileRepository,
) {
fun getById(userId: String): Optional<Profile> = profileRepository.findById(userId)
}
Loading

0 comments on commit e90a788

Please sign in to comment.