Skip to content

Commit

Permalink
게시물에 updateDate 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wjxor committed Jul 17, 2021
1 parent c3bc0f1 commit de68a9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public UsrArticleController() {
articles = new ArrayList<>();

// 게시물 2개 생성
articles.add(new Article(++articlesLastId, "2020-12-12 12:12:12", "제목1", "내용1"));
articles.add(new Article(++articlesLastId, "2020-12-12 12:12:12", "제목2", "내용2"));
articles.add(new Article(++articlesLastId, "2020-12-12 12:12:12", "2020-12-12 12:12:12", "제목1", "내용1"));
articles.add(new Article(++articlesLastId, "2020-12-12 12:12:12", "2020-12-12 12:12:12", "제목2", "내용2"));
}

@RequestMapping("/usr/article/detail")
Expand All @@ -43,11 +43,11 @@ public List<Article> showList() {

@RequestMapping("/usr/article/doAdd")
@ResponseBody
public Map<String, Object> doAdd(String title, String body) {

public Map<String, Object> doAdd(String title, String body) {
String regDate = Util.getNowDateStr();
String updateDate = regDate;

articles.add(new Article(++articlesLastId, regDate, title, body));
articles.add(new Article(++articlesLastId, regDate, updateDate, title, body));

Map<String, Object> rs = new HashMap<>();
rs.put("resultCode", "S-1");
Expand Down Expand Up @@ -116,6 +116,7 @@ public Map<String, Object> doModify(int id, String title, String body) {
return rs;
}

selArticle.setUpdateDate(Util.getNowDateStr());
selArticle.setTitle(title);
selArticle.setBody(body);

Expand Down
17 changes: 14 additions & 3 deletions src/main/java/com/wjxor/untact/dto/Article.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
package com.wjxor.untact.dto;

public class Article {

private int id;
private String regDate;
private String updateDate;
private String title;
private String body;

public Article(int id, String regDate, String title, String body) {
public Article(int id, String regDate,String updateDate, String title, String body) {
this.id = id;
this.regDate = regDate;
this.updateDate = updateDate;
this.title = title;
this.body = body;
}

@Override
public String toString() {
return "Article [id=" + id + ", regDate=" + regDate + ", title=" + title + ", body=" + body + "]";
return "Article [id=" + id + ", regDate=" + regDate + ", updateDate=" + updateDate + ", title=" + title
+ ", body=" + body + "]";
}


public int getId() {
return id;
}
Expand All @@ -34,6 +37,14 @@ public String getRegDate() {
public void setRegDate(String regDate) {
this.regDate = regDate;
}

public String getUpdateDate() {
return updateDate;
}

public void setUpdateDate(String updateDate) {
this.updateDate = updateDate;
}

public String getTitle() {
return title;
Expand Down

0 comments on commit de68a9c

Please sign in to comment.