当前位置:网站首页>Design idea of initializing page input parameters
Design idea of initializing page input parameters
2022-07-23 15:59:00 【The snail rushed hard】
Recently, I am refactoring old code , In the process of writing, it is found that if the previous logic encounters no input parameters pageNo Meeting Npe, So I want to find out how to deal with the company's projects page There are two types of participants as follows
- Use ternary expressions to directly determine whether null, Then assign a value
- Use mapStruct Assignment initialization AO
But I think both of them are a little troublesome , What I want is to generate and initialize on demand page Parameters are good , So we have the following design
Create a new BaseDTO Used to be inherited
@Data
public class BasePageDTO {
private Integer pageNo;
private Integer pageSize;
}
Put your dto Inherit this BaseDTO, Because the code specification stipulates that bean It directly assigns the default value of the attribute , So our dto In succession BasePageDTO It needs one step of processing , I have a new one PageUtil Tool class , The code is as follows
@Component
public class PageUtil {
public static void buildPage(BasePageDTO pageDTO){
if (Objects.isNull(pageDTO.getPageNo())){
pageDTO.setPageNo(1);
}
if (Objects.isNull(pageDTO.getPageSize())){
pageDTO.setPageSize(20);
}
}
}
Finally, I need to initialize page Call this method directly when setting parameters ,page Parameters are fine 
边栏推荐
- Application of ERP management system in equipment manufacturing enterprise management
- 关于初始化page入参的设计思路
- aws篇4 一机一密
- Harbor image warehouse
- String and integer convert each other
- ESP8266 NodeMCU 闪存文件系统(SPIFFS)
- Php:filter pseudo protocol [bsidescf 2020]had a bad day
- 【运维】ssh tunneling 依靠ssh的22端口实现访问远程服务器的接口服务
- Exclusive interview | open source Summer Star Niu Xuewei
- ten thousand and one hundred
猜你喜欢
随机推荐
自定义封装弹出框(带进度条)
C语言经典例题-两个分数相加
Day14 function module
3D数学 - 矢量
在多个数字(有重复)中找到最小值以及所在位置
Bubble sort - just read one
SCA在得物DevSecOps平台上应用
上课作业(5)——#576. 饥饿的牛(hunger)
[untitled]
(BFS)模板+例题(走迷宫,八数码)
day1
Harbor image warehouse
Redis master-slave replication
C语言经典例题-switch case语句转换日期格式
C语言书写规范
946. 验证栈序列 ●● & 剑指 Offer 31. 栈的压入、弹出序列 ●●
作为测试人员,不能不懂的adb命令和操作
Find the minimum value and location in multiple numbers (with repetition)
CS5363,CS5350,CS5328几款太阳能板电池充电管理IC的功能特性与参数对比
虚拟主播、偶像代言产品出问题谁负责?律师解析









