Skip to content

Commit

Permalink
[wip] Adding draft API(support-project#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-okumura-isp committed May 1, 2021
1 parent 8c222d7 commit b4608be
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.support.project.knowledge.control.api;

import net.arnx.jsonic.JSONException;

import java.util.ArrayList;
import java.util.List;

import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.common.util.PropertyUtil;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.dao.DraftKnowledgesDao;
import org.support.project.knowledge.entity.DraftKnowledgesEntity;
import org.support.project.knowledge.vo.api.Draft;
import org.support.project.web.bean.ApiParams;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.common.HttpStatus;
import org.support.project.web.control.GetApiControl;
import org.support.project.web.control.service.Delete;
import org.support.project.web.control.service.Get;
import org.support.project.web.control.service.Post;
import org.support.project.web.control.service.Put;
import org.support.project.web.exception.InvalidParamException;
import org.support.project.web.filter.ControlManagerFilter;

@DI(instance = Instance.Prototype)
public class DraftsControl extends GetApiControl {
private static Log LOG = LogFactory.getLog(ControlManagerFilter.class);

@Get(path="api/drafts", publishToken="")
public Boundary index() {
return get();
}

@Override
public Boundary getList(ApiParams params) {
List<DraftKnowledgesEntity> draftsEntity = DraftKnowledgesDao.get().selectOnUser(super.getLoginUserId());
List<Draft> results = new ArrayList<>();

for (DraftKnowledgesEntity draftEntity : draftsEntity) {
Draft draft = new Draft();
PropertyUtil.copyPropertyValue(draftEntity, draft);
results.add(draft);
}

return send(HttpStatus.SC_200_OK, results);
}

@Override
public Boundary getSingle(String id) {
// TODO Auto-generated method stub
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public List<DraftKnowledgesEntity> selectOnUser(Integer loginUserId, int limit,
return super.executeQueryList(sql, DraftKnowledgesEntity.class, loginUserId, limit, offset);
}

@Aspect(advice = org.support.project.ormapping.transaction.Transaction.class)
public List<DraftKnowledgesEntity> selectOnUser(Integer loginUserId) {
String sql = "SELECT * FROM DRAFT_KNOWLEDGES WHERE INSERT_USER = ?";
return super.executeQueryList(sql, DraftKnowledgesEntity.class, loginUserId);
}

@Aspect(advice = org.support.project.ormapping.transaction.Transaction.class)
public DraftKnowledgesEntity selectOnKnowledgeAndUser(Long knowledgeId, Integer loginUserId) {
String sql = "SELECT * FROM DRAFT_KNOWLEDGES WHERE INSERT_USER = ? AND KNOWLEDGE_ID = ?";
Expand Down
120 changes: 120 additions & 0 deletions src/main/java/org/support/project/knowledge/vo/api/Draft.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package org.support.project.knowledge.vo.api;

import java.sql.Timestamp;

public class Draft {
/** 下書きID */
private Long draftId;
/** ナレッジID */
private Long knowledgeId;
/** タイトル */
private String title;
/** 内容 */
private String content;
/** 公開区分 */
private Integer publicFlag;
/** 公開対象 */
private String accesses;
/** 共同編集対象 */
private String editors;
/** タグ名称一覧 */
private String tagNames;
/** テンプレートの種類ID */
private Integer typeId;
/** 登録ユーザ */
private Integer insertUser;
/** 登録日時 */
private Timestamp insertDatetime;
/** 更新ユーザ */
private Integer updateUser;
/** 更新日時 */
private Timestamp updateDatetime;
/** 削除フラグ */
private Integer deleteFlag;

public Long getDraftId() {
return draftId;
}
public void setDraftId(Long draftId) {
this.draftId = draftId;
}
public Long getKnowledgeId() {
return knowledgeId;
}
public void setKnowledgeId(Long knowledgeId) {
this.knowledgeId = knowledgeId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getPublicFlag() {
return publicFlag;
}
public void setPublicFlag(Integer publicFlag) {
this.publicFlag = publicFlag;
}
public String getAccesses() {
return accesses;
}
public void setAccesses(String accesses) {
this.accesses = accesses;
}
public String getEditors() {
return editors;
}
public void setEditors(String editors) {
this.editors = editors;
}
public String getTagNames() {
return tagNames;
}
public void setTagNames(String tagNames) {
this.tagNames = tagNames;
}
public Integer getTypeId() {
return typeId;
}
public void setTypeId(Integer typeId) {
this.typeId = typeId;
}
public Integer getInsertUser() {
return insertUser;
}
public void setInsertUser(Integer insertUser) {
this.insertUser = insertUser;
}
public Timestamp getInsertDatetime() {
return insertDatetime;
}
public void setInsertDatetime(Timestamp insertDatetime) {
this.insertDatetime = insertDatetime;
}
public Integer getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Integer updateUser) {
this.updateUser = updateUser;
}
public Timestamp getUpdateDatetime() {
return updateDatetime;
}
public void setUpdateDatetime(Timestamp updateDatetime) {
this.updateDatetime = updateDatetime;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
}

0 comments on commit b4608be

Please sign in to comment.