1.添加分页工具类

2.打印模板关联到客户
3.对非数据库字段添加注解
master
x_z 3 years ago
parent cec467a4be
commit bcc101718e

@ -1,5 +1,7 @@
package com.glxp.udi.admin.controller.param;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.common.res.BaseResponse;
@ -8,9 +10,9 @@ import com.glxp.udi.admin.req.param.SystemPDFTemplateRequest;
import com.glxp.udi.admin.req.param.SystemPDFTemplateSaveRequest;
import com.glxp.udi.admin.res.PageSimpleResponse;
import com.glxp.udi.admin.res.param.SystemPDFTemplateResponse;
import com.glxp.udi.admin.res.param.SystemPDFTemplateSelectResponse;
import com.glxp.udi.admin.service.param.SystemPDFTemplateService;
import com.glxp.udi.admin.util.JasperUtils;
import com.glxp.udi.admin.util.PageUtil;
import com.glxp.udi.common.enums.ResultEnum;
import com.glxp.udi.common.util.ResultVOUtils;
import org.apache.commons.lang3.StringUtils;
@ -24,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -55,23 +58,26 @@ public class SystemPDFTemplateController {
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("system/pdf/template/list")
@GetMapping("/system/pdf/template/pdfTemplates")
public BaseResponse pdfTemplates(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "100") Integer limit) {
Page<SystemPDFTemplateEntity> pageResult = systemPDFTemplateService.listPDFTemplates(page, limit);
PageSimpleResponse<SystemPDFTemplateSelectResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageResult.getTotal());
List<SystemPDFTemplateSelectResponse> systemPDFTemplateSelectResponses = pageResult.getRecords().stream().map(e -> {
SystemPDFTemplateSelectResponse systemPDFTemplateSelectResponse = new SystemPDFTemplateSelectResponse();
BeanUtils.copyProperties(e, systemPDFTemplateSelectResponse);
systemPDFTemplateSelectResponse.setIdStr(String.valueOf(e.getId()));
return systemPDFTemplateSelectResponse;
}).collect(Collectors.toList());
pageSimpleResponse.setList(systemPDFTemplateSelectResponses);
return ResultVOUtils.success(pageSimpleResponse);
/**
*
*
* @param systemPDFTemplateRequest
* @return
*/
@PostMapping("/system/pdf/template/customerTemplates")
public BaseResponse customerTemplates(@RequestBody SystemPDFTemplateRequest systemPDFTemplateRequest) {
IPage<SystemPDFTemplateEntity> page = systemPDFTemplateService.findCustomerTemplates(systemPDFTemplateRequest);
List<SystemPDFTemplateResponse> systemPDFTemplateResponses =new ArrayList<>(page.getRecords().size());
if (page.getTotal() > 0) {
page.getRecords().forEach(systemPDFTemplateEntity -> {
SystemPDFTemplateResponse systemPDFTemplateResponse = new SystemPDFTemplateResponse();
BeanUtil.copyProperties(systemPDFTemplateEntity, systemPDFTemplateResponse);
systemPDFTemplateResponses.add(systemPDFTemplateResponse);
});
}
return ResultVOUtils.success(PageUtil.page(page, systemPDFTemplateResponses));
}
@AuthRuleAnnotation("system/pdf/template/save")
@PostMapping("/system/pdf/template/save")
@ -95,7 +101,6 @@ public class SystemPDFTemplateController {
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
return ResultVOUtils.success();
}

@ -27,4 +27,5 @@ public interface SystemPDFTemplateDao extends BaseMapper<SystemPDFTemplateEntity
* @return
*/
int countByName(@Param("name") String name);
}

@ -1,5 +1,6 @@
package com.glxp.udi.admin.entity.auth;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -43,6 +44,7 @@ public class UserRegisterEntity {
private String comments;
@TableField(exist = false)
private int checkCode;
private String areaCode;

@ -22,4 +22,6 @@ public class SystemPDFTemplateRequest extends ListPageRequest {
private String remark;
private Date create_time;
private Date update_time;
private String customerId;
}

@ -2,6 +2,7 @@ package com.glxp.udi.admin.service.param;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.param.SystemPDFTemplateDao;
import com.glxp.udi.admin.entity.param.SystemPDFTemplateEntity;
@ -65,8 +66,25 @@ public class SystemPDFTemplateService {
wrapper.like(StrUtil.isNotBlank(systemPDFTemplateRequest.getName()), "name", systemPDFTemplateRequest.getName())
.eq(null != systemPDFTemplateRequest.getModule(), "module", systemPDFTemplateRequest.getModule())
.eq(null != systemPDFTemplateRequest.getId(), "id", systemPDFTemplateRequest.getId())
.eq(StrUtil.isNotBlank(systemPDFTemplateRequest.getCustomerId()), "customerId", systemPDFTemplateRequest.getCustomerId())
.orderByDesc("update_time");
return wrapper;
}
/**
*
*
* @param systemPDFTemplateRequest
* @return
*/
public IPage<SystemPDFTemplateEntity> findCustomerTemplates(SystemPDFTemplateRequest systemPDFTemplateRequest) {
QueryWrapper<SystemPDFTemplateEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(systemPDFTemplateRequest.getCustomerId()), "customerId", systemPDFTemplateRequest.getCustomerId())
.or()
.isNull("customerId");
IPage<SystemPDFTemplateEntity> page = new Page<>(systemPDFTemplateRequest.getPage(), systemPDFTemplateRequest.getLimit());
return systemPDFTemplateDao.selectPage(page, wrapper);
}
}

@ -0,0 +1,43 @@
package com.glxp.udi.admin.util;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.glxp.udi.admin.res.PageSimpleResponse;
import java.util.List;
/**
*
*/
public class PageUtil {
/**
* mybatis-plus
*
* @param page mybatis-plus
* @param <T>
* @return
*/
public static <T> PageSimpleResponse<T> page(IPage<T> page) {
PageSimpleResponse<T> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(page.getRecords());
return pageSimpleResponse;
}
/**
* mybatis-plus
*
* @param page mybatis-plus
* @param list
* @param <T>
* @param <V>
* @return
*/
public static <T, V> PageSimpleResponse<V> page(IPage<T> page, List<V> list) {
PageSimpleResponse<V> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(list);
return pageSimpleResponse;
}
}
Loading…
Cancel
Save