Search in sources :

Example 1 with TemplateTransfer

use of ruangong.root.bean.TemplateTransfer in project RG by ADrWondertainment.

the class TemplateServiceImpl method getTemplatesInPages.

@Override
public Result getTemplatesInPages(Integer id, Integer pageNum, Integer size) {
    IPage<Template> page = new Page(pageNum, size);
    QueryWrapper<Template> query = Wrappers.query();
    query.eq("uid", id);
    IPage<Template> templateIPage = templateMapper.selectPage(page, query);
    if (templateIPage == null) {
        throw new BackException(ErrorCode.TEMPLATE_SELECT_FAILURE, "分页数据查询失败");
    }
    List<Template> records = templateIPage.getRecords();
    List<TemplateTransfer> transfers = new ArrayList<>();
    for (Template t : records) {
        TemplateTransfer temp = new TemplateTransfer();
        temp.setId(t.getId());
        temp.setUid(t.getUid());
        temp.setName(t.getName());
        temp.setTime(t.getTime());
        temp.setLength(t.getLength());
        temp.setDescription(t.getDescription());
        temp.setData(JSONUtil.parseObj(t.getData()));
        transfers.add(temp);
    }
    JSONArray jsonArray = JSONUtil.parseArray(transfers);
    ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
    return result;
}
Also used : BackException(ruangong.root.exception.BackException) TemplateTransfer(ruangong.root.bean.TemplateTransfer) ArrayList(java.util.ArrayList) JSONArray(cn.hutool.json.JSONArray) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) JsonBeanTemplate(ruangong.root.bean.JsonBeanTemplate) Template(ruangong.root.bean.Template)

Aggregations

JSONArray (cn.hutool.json.JSONArray)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 ArrayList (java.util.ArrayList)1 JsonBeanTemplate (ruangong.root.bean.JsonBeanTemplate)1 Template (ruangong.root.bean.Template)1 TemplateTransfer (ruangong.root.bean.TemplateTransfer)1 BackException (ruangong.root.exception.BackException)1