1.添加分页工具类

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

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

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

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

@ -22,4 +22,6 @@ public class SystemPDFTemplateRequest extends ListPageRequest {
private String remark; private String remark;
private Date create_time; private Date create_time;
private Date update_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 cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.param.SystemPDFTemplateDao; import com.glxp.udi.admin.dao.param.SystemPDFTemplateDao;
import com.glxp.udi.admin.entity.param.SystemPDFTemplateEntity; import com.glxp.udi.admin.entity.param.SystemPDFTemplateEntity;
@ -65,8 +66,25 @@ public class SystemPDFTemplateService {
wrapper.like(StrUtil.isNotBlank(systemPDFTemplateRequest.getName()), "name", systemPDFTemplateRequest.getName()) wrapper.like(StrUtil.isNotBlank(systemPDFTemplateRequest.getName()), "name", systemPDFTemplateRequest.getName())
.eq(null != systemPDFTemplateRequest.getModule(), "module", systemPDFTemplateRequest.getModule()) .eq(null != systemPDFTemplateRequest.getModule(), "module", systemPDFTemplateRequest.getModule())
.eq(null != systemPDFTemplateRequest.getId(), "id", systemPDFTemplateRequest.getId()) .eq(null != systemPDFTemplateRequest.getId(), "id", systemPDFTemplateRequest.getId())
.eq(StrUtil.isNotBlank(systemPDFTemplateRequest.getCustomerId()), "customerId", systemPDFTemplateRequest.getCustomerId())
.orderByDesc("update_time"); .orderByDesc("update_time");
return wrapper; 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