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
hs_err_pid*

20
.vscode/launch.json vendored
View File

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

15
.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
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -4,11 +4,11 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@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){
super(message);
}
public ResourceNotFoundException(String message) {
super(message);
}
}

View File

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

View File

@ -7,306 +7,300 @@ import java.util.Objects;
@Table(name = "tbl_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;
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 Member() {
}
public void setMemberSrl(long memberSrl) {
this.memberSrl = memberSrl;
}
@Id
@Column(name = "member_srl", nullable = false)
public long getMemberSrl() {
return memberSrl;
}
@Basic
@Column(name = "user_id", nullable = false, length = 80)
public String getUserId() {
return userId;
}
public void setMemberSrl(long memberSrl) {
this.memberSrl = memberSrl;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Basic
@Column(name = "user_id", nullable = false, length = 80)
public String getUserId() {
return userId;
}
@Basic
@Column(name = "email_address", nullable = false, length = 250)
public String getEmailAddress() {
return emailAddress;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
@Basic
@Column(name = "email_address", nullable = false, length = 250)
public String getEmailAddress() {
return emailAddress;
}
@Basic
@Column(name = "password", nullable = false, length = 60)
public String getPassword() {
return password;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public void setPassword(String password) {
this.password = password;
}
@Basic
@Column(name = "password", nullable = false, length = 60)
public String getPassword() {
return password;
}
@Basic
@Column(name = "email_id", nullable = false, length = 80)
public String getEmailId() {
return emailId;
}
public void setPassword(String password) {
this.password = password;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
@Basic
@Column(name = "email_id", nullable = false, length = 80)
public String getEmailId() {
return emailId;
}
@Basic
@Column(name = "email_host", nullable = true, length = 160)
public String getEmailHost() {
return emailHost;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public void setEmailHost(String emailHost) {
this.emailHost = emailHost;
}
@Basic
@Column(name = "email_host", nullable = true, length = 160)
public String getEmailHost() {
return emailHost;
}
@Basic
@Column(name = "user_name", nullable = false, length = 40)
public String getUserName() {
return userName;
}
public void setEmailHost(String emailHost) {
this.emailHost = emailHost;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Basic
@Column(name = "user_name", nullable = false, length = 40)
public String getUserName() {
return userName;
}
@Basic
@Column(name = "nick_name", nullable = false, length = 40)
public String getNickName() {
return nickName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
@Basic
@Column(name = "nick_name", nullable = false, length = 40)
public String getNickName() {
return nickName;
}
@Basic
@Column(name = "find_account_question", nullable = true)
public Long getFindAccountQuestion() {
return findAccountQuestion;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public void setFindAccountQuestion(Long findAccountQuestion) {
this.findAccountQuestion = findAccountQuestion;
}
@Basic
@Column(name = "find_account_question", nullable = true)
public Long getFindAccountQuestion() {
return findAccountQuestion;
}
@Basic
@Column(name = "find_account_answer", nullable = true, length = 250)
public String getFindAccountAnswer() {
return findAccountAnswer;
}
public void setFindAccountQuestion(Long findAccountQuestion) {
this.findAccountQuestion = findAccountQuestion;
}
public void setFindAccountAnswer(String findAccountAnswer) {
this.findAccountAnswer = findAccountAnswer;
}
@Basic
@Column(name = "find_account_answer", nullable = true, length = 250)
public String getFindAccountAnswer() {
return findAccountAnswer;
}
@Basic
@Column(name = "homepage", nullable = true, length = 250)
public String getHomepage() {
return homepage;
}
public void setFindAccountAnswer(String findAccountAnswer) {
this.findAccountAnswer = findAccountAnswer;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
@Basic
@Column(name = "homepage", nullable = true, length = 250)
public String getHomepage() {
return homepage;
}
@Basic
@Column(name = "blog", nullable = true, length = 250)
public String getBlog() {
return blog;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public void setBlog(String blog) {
this.blog = blog;
}
@Basic
@Column(name = "blog", nullable = true, length = 250)
public String getBlog() {
return blog;
}
@Basic
@Column(name = "birthday", nullable = true, length = 8)
public String getBirthday() {
return birthday;
}
public void setBlog(String blog) {
this.blog = blog;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
@Basic
@Column(name = "birthday", nullable = true, length = 8)
public String getBirthday() {
return birthday;
}
@Basic
@Column(name = "allow_mailing", nullable = false, length = 1)
public String getAllowMailing() {
return allowMailing;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public void setAllowMailing(String allowMailing) {
this.allowMailing = allowMailing;
}
@Basic
@Column(name = "allow_mailing", nullable = false, length = 1)
public String getAllowMailing() {
return allowMailing;
}
@Basic
@Column(name = "allow_message", nullable = false, length = 1)
public String getAllowMessage() {
return allowMessage;
}
public void setAllowMailing(String allowMailing) {
this.allowMailing = allowMailing;
}
public void setAllowMessage(String allowMessage) {
this.allowMessage = allowMessage;
}
@Basic
@Column(name = "allow_message", nullable = false, length = 1)
public String getAllowMessage() {
return allowMessage;
}
@Basic
@Column(name = "denied", nullable = true, length = 1)
public String getDenied() {
return denied;
}
public void setAllowMessage(String allowMessage) {
this.allowMessage = allowMessage;
}
public void setDenied(String denied) {
this.denied = denied;
}
@Basic
@Column(name = "denied", nullable = true, length = 1)
public String getDenied() {
return denied;
}
@Basic
@Column(name = "limit_date", nullable = true, length = 14)
public String getLimitDate() {
return limitDate;
}
public void setDenied(String denied) {
this.denied = denied;
}
public void setLimitDate(String limitDate) {
this.limitDate = limitDate;
}
@Basic
@Column(name = "limit_date", nullable = true, length = 14)
public String getLimitDate() {
return limitDate;
}
@Basic
@Column(name = "regdate", nullable = true, length = 14)
public String getRegdate() {
return regdate;
}
public void setLimitDate(String limitDate) {
this.limitDate = limitDate;
}
public void setRegdate(String regdate) {
this.regdate = regdate;
}
@Basic
@Column(name = "regdate", nullable = true, length = 14)
public String getRegdate() {
return regdate;
}
@Basic
@Column(name = "last_login", nullable = true, length = 14)
public String getLastLogin() {
return lastLogin;
}
public void setRegdate(String regdate) {
this.regdate = regdate;
}
public void setLastLogin(String lastLogin) {
this.lastLogin = lastLogin;
}
@Basic
@Column(name = "last_login", nullable = true, length = 14)
public String getLastLogin() {
return lastLogin;
}
@Basic
@Column(name = "change_password_date", nullable = true, length = 14)
public String getChangePasswordDate() {
return changePasswordDate;
}
public void setLastLogin(String lastLogin) {
this.lastLogin = lastLogin;
}
public void setChangePasswordDate(String changePasswordDate) {
this.changePasswordDate = changePasswordDate;
}
@Basic
@Column(name = "change_password_date", nullable = true, length = 14)
public String getChangePasswordDate() {
return changePasswordDate;
}
@Basic
@Column(name = "is_admin", nullable = true, length = 1)
public String getIsAdmin() {
return isAdmin;
}
public void setChangePasswordDate(String changePasswordDate) {
this.changePasswordDate = changePasswordDate;
}
public void setIsAdmin(String isAdmin) {
this.isAdmin = isAdmin;
}
@Basic
@Column(name = "is_admin", nullable = true, length = 1)
public String getIsAdmin() {
return isAdmin;
}
@Basic
@Column(name = "description", columnDefinition = "text") // nullable = true, length = -1
public String getDescription() {
return description;
}
public void setIsAdmin(String isAdmin) {
this.isAdmin = isAdmin;
}
public void setDescription(String description) {
this.description = description;
}
@Basic
@Column(name = "description", columnDefinition = "text") // nullable = true, length = -1
public String getDescription() {
return description;
}
@Basic
@Column(name = "extra_vars", columnDefinition = "text") // nullable = true, length = -1
public String getExtraVars() {
return extraVars;
}
public void setDescription(String description) {
this.description = description;
}
public void setExtraVars(String extraVars) {
this.extraVars = extraVars;
}
@Basic
@Column(name = "extra_vars", columnDefinition = "text") // nullable = true, length = -1
public String getExtraVars() {
return extraVars;
}
@Basic
@Column(name = "list_order", nullable = false)
public long getListOrder() {
return listOrder;
}
public void setExtraVars(String extraVars) {
this.extraVars = extraVars;
}
public void setListOrder(long listOrder) {
this.listOrder = listOrder;
}
@Basic
@Column(name = "list_order", nullable = false)
public long getListOrder() {
return 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);
}
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);
}
@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