Search in sources :

Example 1 with TextbookLogVO

use of com.bc.pmpheep.back.vo.TextbookLogVO in project pmph by BCSquad.

the class TextbookLogServiceImpl method listTextbookLogByTextBookId.

@Override
public PageResult<TextbookLogVO> listTextbookLogByTextBookId(Long textbookId, Integer pageSize, Integer pageNumber, String updaterName) throws CheckedServiceException {
    if (null == textbookId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "书籍为空!");
    }
    Map<String, Object> map = new HashMap<String, Object>(2);
    map.put("textbookId", textbookId);
    updaterName = StringUtil.toAllCheck(updaterName);
    if (null != updaterName) {
        map.put("updaterName", updaterName);
    }
    // 包装参数实体
    PageParameter<Map<String, Object>> pageParameter = new PageParameter<Map<String, Object>>(pageNumber, pageSize, map);
    // 返回实体
    PageResult<TextbookLogVO> pageResult = new PageResult<TextbookLogVO>();
    // 参数拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 获取总数
    Integer total = textbookLogDao.listTotalTextbookLogByTextBookId(pageParameter);
    if (null != total && total > 0) {
        List<TextbookLog> rows = textbookLogDao.listTextbookLogByTextBookId(pageParameter);
        List<TextbookLogVO> newRows = new ArrayList<TextbookLogVO>(rows.size());
        for (TextbookLog textbookLog : rows) {
            Long id = textbookLog.getId();
            String detail = textbookLog.getDetail();
            Timestamp gmtCreate = textbookLog.getGmtCreate();
            detail = detail.replace("{gmt_create}", DateUtil.format(gmtCreate));
            newRows.add(new TextbookLogVO(id, detail));
        }
        pageResult.setRows(newRows);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Timestamp(java.sql.Timestamp) PageResult(com.bc.pmpheep.back.plugin.PageResult) TextbookLog(com.bc.pmpheep.back.po.TextbookLog) TextbookLogVO(com.bc.pmpheep.back.vo.TextbookLogVO) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

PageParameter (com.bc.pmpheep.back.plugin.PageParameter)1 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 TextbookLog (com.bc.pmpheep.back.po.TextbookLog)1 TextbookLogVO (com.bc.pmpheep.back.vo.TextbookLogVO)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1