member insert

This commit is contained in:
geekH 2019-07-17 17:09:42 +09:00
parent 1f0fa4dbbf
commit 06200f712b
11 changed files with 531 additions and 17 deletions

198
.gitignore vendored Normal file
View File

@ -0,0 +1,198 @@
# Created by .ignore support plugin (hsz.mobi)
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### Windows template
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Eclipse template
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

View File

@ -11,15 +11,9 @@ import com.loafle.totopia.member.dao.MemberRepository;
import com.loafle.totopia.member.model.Member; import com.loafle.totopia.member.model.Member;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@ -41,7 +35,7 @@ public class MemberController {
return ResponseEntity.ok().body(member); return ResponseEntity.ok().body(member);
} }
@PostMapping("/members") @PostMapping(path = "/members", produces = MediaType.APPLICATION_JSON_VALUE)
public Member createMember(@Valid @RequestBody Member member) { public Member createMember(@Valid @RequestBody Member member) {
return memberRepository.save(member); return memberRepository.save(member);
} }
@ -53,8 +47,7 @@ public class MemberController {
.orElseThrow(() -> new ResourceNotFoundException("Member not found for this id :: " + memberId)); .orElseThrow(() -> new ResourceNotFoundException("Member not found for this id :: " + memberId));
member.setEmailId(memberDetails.getEmailId()); member.setEmailId(memberDetails.getEmailId());
member.setLastName(memberDetails.getLastName());
member.setFirstName(memberDetails.getFirstName());
final Member updatedMember = memberRepository.save(member); final Member updatedMember = memberRepository.save(member);
return ResponseEntity.ok(updatedMember); return ResponseEntity.ok(updatedMember);
} }

View File

@ -3,7 +3,9 @@ package com.loafle.totopia.member.dao;
import com.loafle.totopia.member.model.Member; import com.loafle.totopia.member.model.Member;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface MemberRepository extends JpaRepository<Member, Long> { public interface MemberRepository extends JpaRepository<Member, Long> {
} }

View File

@ -1,5 +1,312 @@
package com.loafle.totopia.member.model; package com.loafle.totopia.member.model;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "tbl_member")
public class Member { public class Member {
private long memberSrl;
private String userId;
private String emailAddress;
private String password;
private String emailId;
private String emailHost;
private String userName;
private String nickName;
private Long findAccountQuestion;
private String findAccountAnswer;
private String homepage;
private String blog;
private String birthday;
private String allowMailing;
private String allowMessage;
private String denied;
private String limitDate;
private String regdate;
private String lastLogin;
private String changePasswordDate;
private String isAdmin;
private String description;
private String extraVars;
private long listOrder;
public Member() {}
@Id
@Column(name = "member_srl", nullable = false)
public long getMemberSrl() {
return memberSrl;
}
public void setMemberSrl(long memberSrl) {
this.memberSrl = memberSrl;
}
@Basic
@Column(name = "user_id", nullable = false, length = 80)
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Basic
@Column(name = "email_address", nullable = false, length = 250)
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
@Basic
@Column(name = "password", nullable = false, length = 60)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Basic
@Column(name = "email_id", nullable = false, length = 80)
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
@Basic
@Column(name = "email_host", nullable = true, length = 160)
public String getEmailHost() {
return emailHost;
}
public void setEmailHost(String emailHost) {
this.emailHost = emailHost;
}
@Basic
@Column(name = "user_name", nullable = false, length = 40)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Basic
@Column(name = "nick_name", nullable = false, length = 40)
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
@Basic
@Column(name = "find_account_question", nullable = true)
public Long getFindAccountQuestion() {
return findAccountQuestion;
}
public void setFindAccountQuestion(Long findAccountQuestion) {
this.findAccountQuestion = findAccountQuestion;
}
@Basic
@Column(name = "find_account_answer", nullable = true, length = 250)
public String getFindAccountAnswer() {
return findAccountAnswer;
}
public void setFindAccountAnswer(String findAccountAnswer) {
this.findAccountAnswer = findAccountAnswer;
}
@Basic
@Column(name = "homepage", nullable = true, length = 250)
public String getHomepage() {
return homepage;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
@Basic
@Column(name = "blog", nullable = true, length = 250)
public String getBlog() {
return blog;
}
public void setBlog(String blog) {
this.blog = blog;
}
@Basic
@Column(name = "birthday", nullable = true, length = 8)
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
@Basic
@Column(name = "allow_mailing", nullable = false, length = 1)
public String getAllowMailing() {
return allowMailing;
}
public void setAllowMailing(String allowMailing) {
this.allowMailing = allowMailing;
}
@Basic
@Column(name = "allow_message", nullable = false, length = 1)
public String getAllowMessage() {
return allowMessage;
}
public void setAllowMessage(String allowMessage) {
this.allowMessage = allowMessage;
}
@Basic
@Column(name = "denied", nullable = true, length = 1)
public String getDenied() {
return denied;
}
public void setDenied(String denied) {
this.denied = denied;
}
@Basic
@Column(name = "limit_date", nullable = true, length = 14)
public String getLimitDate() {
return limitDate;
}
public void setLimitDate(String limitDate) {
this.limitDate = limitDate;
}
@Basic
@Column(name = "regdate", nullable = true, length = 14)
public String getRegdate() {
return regdate;
}
public void setRegdate(String regdate) {
this.regdate = regdate;
}
@Basic
@Column(name = "last_login", nullable = true, length = 14)
public String getLastLogin() {
return lastLogin;
}
public void setLastLogin(String lastLogin) {
this.lastLogin = lastLogin;
}
@Basic
@Column(name = "change_password_date", nullable = true, length = 14)
public String getChangePasswordDate() {
return changePasswordDate;
}
public void setChangePasswordDate(String changePasswordDate) {
this.changePasswordDate = changePasswordDate;
}
@Basic
@Column(name = "is_admin", nullable = true, length = 1)
public String getIsAdmin() {
return isAdmin;
}
public void setIsAdmin(String isAdmin) {
this.isAdmin = isAdmin;
}
@Basic
@Column(name = "description", columnDefinition = "text") // nullable = true, length = -1
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Basic
@Column(name = "extra_vars", columnDefinition = "text") // nullable = true, length = -1
public String getExtraVars() {
return extraVars;
}
public void setExtraVars(String extraVars) {
this.extraVars = extraVars;
}
@Basic
@Column(name = "list_order", nullable = false)
public long getListOrder() {
return listOrder;
}
public void setListOrder(long listOrder) {
this.listOrder = listOrder;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Member xeMember = (Member) o;
return memberSrl == xeMember.memberSrl &&
listOrder == xeMember.listOrder &&
Objects.equals(userId, xeMember.userId) &&
Objects.equals(emailAddress, xeMember.emailAddress) &&
Objects.equals(password, xeMember.password) &&
Objects.equals(emailId, xeMember.emailId) &&
Objects.equals(emailHost, xeMember.emailHost) &&
Objects.equals(userName, xeMember.userName) &&
Objects.equals(nickName, xeMember.nickName) &&
Objects.equals(findAccountQuestion, xeMember.findAccountQuestion) &&
Objects.equals(findAccountAnswer, xeMember.findAccountAnswer) &&
Objects.equals(homepage, xeMember.homepage) &&
Objects.equals(blog, xeMember.blog) &&
Objects.equals(birthday, xeMember.birthday) &&
Objects.equals(allowMailing, xeMember.allowMailing) &&
Objects.equals(allowMessage, xeMember.allowMessage) &&
Objects.equals(denied, xeMember.denied) &&
Objects.equals(limitDate, xeMember.limitDate) &&
Objects.equals(regdate, xeMember.regdate) &&
Objects.equals(lastLogin, xeMember.lastLogin) &&
Objects.equals(changePasswordDate, xeMember.changePasswordDate) &&
Objects.equals(isAdmin, xeMember.isAdmin) &&
Objects.equals(description, xeMember.description) &&
Objects.equals(extraVars, xeMember.extraVars);
}
@Override
public int hashCode() {
return Objects.hash(memberSrl, userId, emailAddress, password, emailId, emailHost, userName, nickName, findAccountQuestion, findAccountAnswer, homepage, blog, birthday, allowMailing, allowMessage, denied, limitDate, regdate, lastLogin, changePasswordDate, isAdmin, description, extraVars, listOrder);
}
} }

View File

@ -1,4 +1,4 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/employees spring.datasource.url=jdbc:postgresql://localhost:54320/postgres
spring.datasource.username=postgres spring.datasource.username=postgres
spring.datasource.password=root spring.datasource.password=root
spring.jpa.show-sql=true spring.jpa.show-sql=true
@ -6,6 +6,13 @@ spring.jpa.show-sql=true
## Hibernate Properties ## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database # The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
# Hibernate ddl auto (create, create-drop, validate, update) # Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.jpa.database=postgresql
logging.level.root=info
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger.%M - %msg%n
server.port=8282

View File

@ -1,4 +1,4 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/employees spring.datasource.url=jdbc:postgresql://localhost:54320/postgres
spring.datasource.username=postgres spring.datasource.username=postgres
spring.datasource.password=root spring.datasource.password=root
spring.jpa.show-sql=true spring.jpa.show-sql=true
@ -6,6 +6,13 @@ spring.jpa.show-sql=true
## Hibernate Properties ## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database # The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
# Hibernate ddl auto (create, create-drop, validate, update) # Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.jpa.database=postgresql
logging.level.root=info
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger.%M - %msg%n
server.port=8282