Package com.skyline.wo.mapper

Source Code of com.skyline.wo.mapper.ArticleMapper

package com.skyline.wo.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.wo.model.Article;

/**
* AricleMapper mapping the record to Article
*
* @author Jairus Chan
* @version 0.1
*/
public class ArticleMapper implements RowMapper<Article> {

  private static final ArticleMapper MAPPER = new ArticleMapper();

  private static final String COLUMN_ID = "id";
  private static final String COLUMN_DIGEST = "digest";
  private static final String COLUMN_TITLE = "title";
  private static final String COLUMN_CONTENT = "content";
  private static final String COLUMN_OWNER_ID = "ownerId";
  private static final String COLUMN_OWNER_NICKNAME = "ownerNickname";
  private static final String COLUMN_OWNER_PORTRAIT = "ownerPortrait";
  private static final String COLUMN_CATEGORY_ID = "categoryId";
  private static final String COLUMN_CATEGORY_NAME = "categoryName";
  private static final String COLUMN_COMMENT_NUM = "commentNum";
  private static final String COLUMN_VISIT_NUM = "visitNum";
  private static final String COLUMN_UP = "up";
  private static final String COLUMN_DOWN = "down";
  private static final String COLUMN_SHARE_NUM = "shareNum";
  private static final String COLUMN_CREATE_TIME = "createTime";
  private static final String COLUMN_UPATE_TIME = "updateTime";
  private static final String COLUMN_AUTHORITY = "authority";
 
  public static ArticleMapper getMapper() {
    return MAPPER;
  }

  public Article mapRow(ResultSet rs, int rowNum) throws SQLException {
    Article article = new Article();
    article.setAuthority(rs.getInt(COLUMN_AUTHORITY));
    article.setCommentNum(rs.getInt(COLUMN_COMMENT_NUM));
    article.setContent(rs.getString(COLUMN_CONTENT));
    article.setCategoryId(rs.getLong(COLUMN_CATEGORY_ID));
    article.setCategoryName(rs.getString(COLUMN_CATEGORY_NAME));
    article.setDigest(rs.getString(COLUMN_DIGEST));
    article.setCreateTime(rs.getTimestamp(COLUMN_CREATE_TIME));
    article.setId(rs.getLong(COLUMN_ID));
    article.setOwnerId(rs.getLong(COLUMN_OWNER_ID));
    article.setOwnerNickname(rs.getString(COLUMN_OWNER_NICKNAME));
    article.setOwnerPortrait(rs.getString(COLUMN_OWNER_PORTRAIT));
    article.setVisitNum(rs.getInt(COLUMN_VISIT_NUM));
    article.setShareNum(rs.getInt(COLUMN_SHARE_NUM));
    article.setTitle(rs.getString(COLUMN_TITLE));
    article.setUpdateTime(rs.getTimestamp(COLUMN_UPATE_TIME));
    article.setUp(rs.getInt(COLUMN_UP));
    article.setDown(rs.getInt(COLUMN_DOWN));
    return article;
  }
}
TOP

Related Classes of com.skyline.wo.mapper.ArticleMapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.