Search in sources :

Example 1 with TbThanksExample

use of cn.exrick.manager.pojo.TbThanksExample in project xmall by Exrick.

the class ThanksServiceImpl method countThanks.

@Override
public Long countThanks() {
    TbThanksExample example = new TbThanksExample();
    Long result = tbThanksMapper.countByExample(example);
    if (result == null) {
        throw new XmallException("统计捐赠数目失败");
    }
    return result;
}
Also used : TbThanksExample(cn.exrick.manager.pojo.TbThanksExample) XmallException(cn.exrick.common.exception.XmallException)

Example 2 with TbThanksExample

use of cn.exrick.manager.pojo.TbThanksExample in project xmall by Exrick.

the class ThanksServiceImpl method getThanksList.

@Override
public DataTablesResult getThanksList() {
    DataTablesResult result = new DataTablesResult();
    TbThanksExample example = new TbThanksExample();
    List<TbThanks> list = tbThanksMapper.selectByExample(example);
    if (list == null) {
        throw new XmallException("获取捐赠列表失败");
    }
    result.setSuccess(true);
    result.setData(list);
    return result;
}
Also used : TbThanks(cn.exrick.manager.pojo.TbThanks) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) TbThanksExample(cn.exrick.manager.pojo.TbThanksExample) XmallException(cn.exrick.common.exception.XmallException)

Example 3 with TbThanksExample

use of cn.exrick.manager.pojo.TbThanksExample in project xmall by Exrick.

the class ThanksServiceImpl method getThanksListByPage.

@Override
public DataTablesResult getThanksListByPage(int page, int size) {
    DataTablesResult result = new DataTablesResult();
    TbThanksExample example = new TbThanksExample();
    if (page <= 0) {
        page = 1;
    }
    PageHelper.startPage(page, size);
    List<TbThanks> list = tbThanksMapper.selectByExample(example);
    if (list == null) {
        throw new XmallException("获取捐赠列表失败");
    }
    PageInfo<TbThanks> pageInfo = new PageInfo<>(list);
    for (TbThanks tbThanks : list) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = null;
        try {
            date = dateFormat.format(tbThanks.getDate());
        } catch (Exception e) {
            e.printStackTrace();
        }
        tbThanks.setTime(date);
        tbThanks.setEmail(null);
    }
    result.setSuccess(true);
    result.setRecordsTotal((int) pageInfo.getTotal());
    result.setData(list);
    return result;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) TbThanks(cn.exrick.manager.pojo.TbThanks) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) TbThanksExample(cn.exrick.manager.pojo.TbThanksExample) XmallException(cn.exrick.common.exception.XmallException) SimpleDateFormat(java.text.SimpleDateFormat) XmallException(cn.exrick.common.exception.XmallException) ParseException(java.text.ParseException)

Aggregations

XmallException (cn.exrick.common.exception.XmallException)3 TbThanksExample (cn.exrick.manager.pojo.TbThanksExample)3 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)2 TbThanks (cn.exrick.manager.pojo.TbThanks)2 PageInfo (com.github.pagehelper.PageInfo)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1