This commit is contained in:
crusader 2019-07-17 21:07:59 +09:00
parent 06200f712b
commit e10599a50c
15 changed files with 312 additions and 332 deletions

1
.gitignore vendored
View File

@ -195,4 +195,3 @@ local.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*

18
.vscode/launch.json vendored
View File

@ -1,11 +1,11 @@
{ {
"configurations": [ "configurations": [
{ {
"type": "java", "type": "java",
"name": "CodeLens (Launch) - Application", "name": "CodeLens (Launch) - Application",
"request": "launch", "request": "launch",
"mainClass": "com.loafle.totopia.Application", "mainClass": "com.loafle.totopia.Application",
"projectName": "gs-rest-service" "projectName": "gs-rest-service"
} }
] ]
} }

13
.vscode/settings.json vendored
View File

@ -1,3 +1,14 @@
{ {
"java.configuration.updateBuildConfiguration": "automatic" "editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.autoClosingBrackets": "languageDefined",
"editor.trimAutoWhitespace": true,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"git.ignoreLimitWarning": true,
"prettier.singleQuote": true,
"debug.node.autoAttach": "on",
"java.configuration.updateBuildConfiguration": "automatic"
} }

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class Application { public class Application {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(Application.class, args);
} }
} }

View File

@ -4,11 +4,11 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.NOT_FOUND) @ResponseStatus(value = HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends Exception{ public class ResourceNotFoundException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public ResourceNotFoundException(String message){ public ResourceNotFoundException(String message) {
super(message); super(message);
} }
} }

View File

@ -15,52 +15,50 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/api/v1") @RequestMapping("/api/v1")
public class MemberController { public class MemberController {
@Autowired @Autowired
private MemberRepository memberRepository; private MemberRepository memberRepository;
@GetMapping("/members") @GetMapping("/members")
public List<Member> getAllMembers() { public List<Member> getAllMembers() {
return memberRepository.findAll(); return memberRepository.findAll();
} }
@GetMapping("/members/{id}") @GetMapping("/members/{id}")
public ResponseEntity<Member> getMemberById(@PathVariable(value = "id") Long memberId) public ResponseEntity<Member> getMemberById(@PathVariable(value = "id") Long memberId)
throws ResourceNotFoundException { throws ResourceNotFoundException {
Member member = memberRepository.findById(memberId) Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new ResourceNotFoundException("Member not found for this id :: " + memberId)); .orElseThrow(() -> new ResourceNotFoundException("Member not found for this id :: " + memberId));
return ResponseEntity.ok().body(member); return ResponseEntity.ok().body(member);
} }
@PostMapping(path = "/members", produces = MediaType.APPLICATION_JSON_VALUE) @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);
} }
@PutMapping("/members/{id}") @PutMapping("/members/{id}")
public ResponseEntity<Member> updateMember(@PathVariable(value = "id") Long memberId, public ResponseEntity<Member> updateMember(@PathVariable(value = "id") Long memberId,
@Valid @RequestBody Member memberDetails) throws ResourceNotFoundException { @Valid @RequestBody Member memberDetails) throws ResourceNotFoundException {
Member member = memberRepository.findById(memberId) Member member = memberRepository.findById(memberId)
.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());
final Member updatedMember = memberRepository.save(member); final Member updatedMember = memberRepository.save(member);
return ResponseEntity.ok(updatedMember); return ResponseEntity.ok(updatedMember);
} }
@DeleteMapping("/members/{id}") @DeleteMapping("/members/{id}")
public Map<String, Boolean> deleteMember(@PathVariable(value = "id") Long memberId) public Map<String, Boolean> deleteMember(@PathVariable(value = "id") Long memberId) throws ResourceNotFoundException {
throws ResourceNotFoundException { Member member = memberRepository.findById(memberId)
Member member = memberRepository.findById(memberId) .orElseThrow(() -> new ResourceNotFoundException("Member not found for this id :: " + memberId));
.orElseThrow(() -> new ResourceNotFoundException("Member not found for this id :: " + memberId));
memberRepository.delete(member); memberRepository.delete(member);
Map<String, Boolean> response = new HashMap<>(); Map<String, Boolean> response = new HashMap<>();
response.put("deleted", Boolean.TRUE); response.put("deleted", Boolean.TRUE);
return response; return response;
} }
} }

View File

@ -7,306 +7,300 @@ import java.util.Objects;
@Table(name = "tbl_member") @Table(name = "tbl_member")
public class Member { public class Member {
private long memberSrl; private long memberSrl;
private String userId; private String userId;
private String emailAddress; private String emailAddress;
private String password; private String password;
private String emailId; private String emailId;
private String emailHost; private String emailHost;
private String userName; private String userName;
private String nickName; private String nickName;
private Long findAccountQuestion; private Long findAccountQuestion;
private String findAccountAnswer; private String findAccountAnswer;
private String homepage; private String homepage;
private String blog; private String blog;
private String birthday; private String birthday;
private String allowMailing; private String allowMailing;
private String allowMessage; private String allowMessage;
private String denied; private String denied;
private String limitDate; private String limitDate;
private String regdate; private String regdate;
private String lastLogin; private String lastLogin;
private String changePasswordDate; private String changePasswordDate;
private String isAdmin; private String isAdmin;
private String description; private String description;
private String extraVars; private String extraVars;
private long listOrder; private long listOrder;
public Member() {} public Member() {
@Id }
@Column(name = "member_srl", nullable = false)
public long getMemberSrl() {
return memberSrl;
}
public void setMemberSrl(long memberSrl) { @Id
this.memberSrl = memberSrl; @Column(name = "member_srl", nullable = false)
} public long getMemberSrl() {
return memberSrl;
}
@Basic public void setMemberSrl(long memberSrl) {
@Column(name = "user_id", nullable = false, length = 80) this.memberSrl = memberSrl;
public String getUserId() { }
return userId;
}
public void setUserId(String userId) { @Basic
this.userId = userId; @Column(name = "user_id", nullable = false, length = 80)
} public String getUserId() {
return userId;
}
@Basic public void setUserId(String userId) {
@Column(name = "email_address", nullable = false, length = 250) this.userId = userId;
public String getEmailAddress() { }
return emailAddress;
}
public void setEmailAddress(String emailAddress) { @Basic
this.emailAddress = emailAddress; @Column(name = "email_address", nullable = false, length = 250)
} public String getEmailAddress() {
return emailAddress;
}
@Basic public void setEmailAddress(String emailAddress) {
@Column(name = "password", nullable = false, length = 60) this.emailAddress = emailAddress;
public String getPassword() { }
return password;
}
public void setPassword(String password) { @Basic
this.password = password; @Column(name = "password", nullable = false, length = 60)
} public String getPassword() {
return password;
}
@Basic public void setPassword(String password) {
@Column(name = "email_id", nullable = false, length = 80) this.password = password;
public String getEmailId() { }
return emailId;
}
public void setEmailId(String emailId) { @Basic
this.emailId = emailId; @Column(name = "email_id", nullable = false, length = 80)
} public String getEmailId() {
return emailId;
}
@Basic public void setEmailId(String emailId) {
@Column(name = "email_host", nullable = true, length = 160) this.emailId = emailId;
public String getEmailHost() { }
return emailHost;
}
public void setEmailHost(String emailHost) { @Basic
this.emailHost = emailHost; @Column(name = "email_host", nullable = true, length = 160)
} public String getEmailHost() {
return emailHost;
}
@Basic public void setEmailHost(String emailHost) {
@Column(name = "user_name", nullable = false, length = 40) this.emailHost = emailHost;
public String getUserName() { }
return userName;
}
public void setUserName(String userName) { @Basic
this.userName = userName; @Column(name = "user_name", nullable = false, length = 40)
} public String getUserName() {
return userName;
}
@Basic public void setUserName(String userName) {
@Column(name = "nick_name", nullable = false, length = 40) this.userName = userName;
public String getNickName() { }
return nickName;
}
public void setNickName(String nickName) { @Basic
this.nickName = nickName; @Column(name = "nick_name", nullable = false, length = 40)
} public String getNickName() {
return nickName;
}
@Basic public void setNickName(String nickName) {
@Column(name = "find_account_question", nullable = true) this.nickName = nickName;
public Long getFindAccountQuestion() { }
return findAccountQuestion;
}
public void setFindAccountQuestion(Long findAccountQuestion) { @Basic
this.findAccountQuestion = findAccountQuestion; @Column(name = "find_account_question", nullable = true)
} public Long getFindAccountQuestion() {
return findAccountQuestion;
}
@Basic public void setFindAccountQuestion(Long findAccountQuestion) {
@Column(name = "find_account_answer", nullable = true, length = 250) this.findAccountQuestion = findAccountQuestion;
public String getFindAccountAnswer() { }
return findAccountAnswer;
}
public void setFindAccountAnswer(String findAccountAnswer) { @Basic
this.findAccountAnswer = findAccountAnswer; @Column(name = "find_account_answer", nullable = true, length = 250)
} public String getFindAccountAnswer() {
return findAccountAnswer;
}
@Basic public void setFindAccountAnswer(String findAccountAnswer) {
@Column(name = "homepage", nullable = true, length = 250) this.findAccountAnswer = findAccountAnswer;
public String getHomepage() { }
return homepage;
}
public void setHomepage(String homepage) { @Basic
this.homepage = homepage; @Column(name = "homepage", nullable = true, length = 250)
} public String getHomepage() {
return homepage;
}
@Basic public void setHomepage(String homepage) {
@Column(name = "blog", nullable = true, length = 250) this.homepage = homepage;
public String getBlog() { }
return blog;
}
public void setBlog(String blog) { @Basic
this.blog = blog; @Column(name = "blog", nullable = true, length = 250)
} public String getBlog() {
return blog;
}
@Basic public void setBlog(String blog) {
@Column(name = "birthday", nullable = true, length = 8) this.blog = blog;
public String getBirthday() { }
return birthday;
}
public void setBirthday(String birthday) { @Basic
this.birthday = birthday; @Column(name = "birthday", nullable = true, length = 8)
} public String getBirthday() {
return birthday;
}
@Basic public void setBirthday(String birthday) {
@Column(name = "allow_mailing", nullable = false, length = 1) this.birthday = birthday;
public String getAllowMailing() { }
return allowMailing;
}
public void setAllowMailing(String allowMailing) { @Basic
this.allowMailing = allowMailing; @Column(name = "allow_mailing", nullable = false, length = 1)
} public String getAllowMailing() {
return allowMailing;
}
@Basic public void setAllowMailing(String allowMailing) {
@Column(name = "allow_message", nullable = false, length = 1) this.allowMailing = allowMailing;
public String getAllowMessage() { }
return allowMessage;
}
public void setAllowMessage(String allowMessage) { @Basic
this.allowMessage = allowMessage; @Column(name = "allow_message", nullable = false, length = 1)
} public String getAllowMessage() {
return allowMessage;
}
@Basic public void setAllowMessage(String allowMessage) {
@Column(name = "denied", nullable = true, length = 1) this.allowMessage = allowMessage;
public String getDenied() { }
return denied;
}
public void setDenied(String denied) { @Basic
this.denied = denied; @Column(name = "denied", nullable = true, length = 1)
} public String getDenied() {
return denied;
}
@Basic public void setDenied(String denied) {
@Column(name = "limit_date", nullable = true, length = 14) this.denied = denied;
public String getLimitDate() { }
return limitDate;
}
public void setLimitDate(String limitDate) { @Basic
this.limitDate = limitDate; @Column(name = "limit_date", nullable = true, length = 14)
} public String getLimitDate() {
return limitDate;
}
@Basic public void setLimitDate(String limitDate) {
@Column(name = "regdate", nullable = true, length = 14) this.limitDate = limitDate;
public String getRegdate() { }
return regdate;
}
public void setRegdate(String regdate) { @Basic
this.regdate = regdate; @Column(name = "regdate", nullable = true, length = 14)
} public String getRegdate() {
return regdate;
}
@Basic public void setRegdate(String regdate) {
@Column(name = "last_login", nullable = true, length = 14) this.regdate = regdate;
public String getLastLogin() { }
return lastLogin;
}
public void setLastLogin(String lastLogin) { @Basic
this.lastLogin = lastLogin; @Column(name = "last_login", nullable = true, length = 14)
} public String getLastLogin() {
return lastLogin;
}
@Basic public void setLastLogin(String lastLogin) {
@Column(name = "change_password_date", nullable = true, length = 14) this.lastLogin = lastLogin;
public String getChangePasswordDate() { }
return changePasswordDate;
}
public void setChangePasswordDate(String changePasswordDate) { @Basic
this.changePasswordDate = changePasswordDate; @Column(name = "change_password_date", nullable = true, length = 14)
} public String getChangePasswordDate() {
return changePasswordDate;
}
@Basic public void setChangePasswordDate(String changePasswordDate) {
@Column(name = "is_admin", nullable = true, length = 1) this.changePasswordDate = changePasswordDate;
public String getIsAdmin() { }
return isAdmin;
}
public void setIsAdmin(String isAdmin) { @Basic
this.isAdmin = isAdmin; @Column(name = "is_admin", nullable = true, length = 1)
} public String getIsAdmin() {
return isAdmin;
}
@Basic public void setIsAdmin(String isAdmin) {
@Column(name = "description", columnDefinition = "text") // nullable = true, length = -1 this.isAdmin = isAdmin;
public String getDescription() { }
return description;
}
public void setDescription(String description) { @Basic
this.description = description; @Column(name = "description", columnDefinition = "text") // nullable = true, length = -1
} public String getDescription() {
return description;
}
@Basic public void setDescription(String description) {
@Column(name = "extra_vars", columnDefinition = "text") // nullable = true, length = -1 this.description = description;
public String getExtraVars() { }
return extraVars;
}
public void setExtraVars(String extraVars) { @Basic
this.extraVars = extraVars; @Column(name = "extra_vars", columnDefinition = "text") // nullable = true, length = -1
} public String getExtraVars() {
return extraVars;
}
@Basic public void setExtraVars(String extraVars) {
@Column(name = "list_order", nullable = false) this.extraVars = extraVars;
public long getListOrder() { }
return listOrder;
}
public void setListOrder(long listOrder) { @Basic
this.listOrder = listOrder; @Column(name = "list_order", nullable = false)
} public long getListOrder() {
return listOrder;
}
@Override public void setListOrder(long listOrder) {
public boolean equals(Object o) { this.listOrder = listOrder;
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 @Override
public int hashCode() { public boolean equals(Object o) {
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); 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,18 +0,0 @@
spring.datasource.url=jdbc:postgresql://localhost:54320/postgres
spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.show-sql=true
## Hibernate Properties
# 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.temp.use_jdbc_metadata_defaults=false
# Hibernate ddl auto (create, create-drop, validate, 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 +0,0 @@
/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/member/controller/MemberController.java
/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/member/dao/MemberRepository.java
/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/Application.java
/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/member/model/Member.java