36 lines
		
	
	
		
			534 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			534 B
		
	
	
	
		
			Go
		
	
	
	
package dataTemp
 | 
						||
 | 
						||
// ReqPageBo 分页请求实体
 | 
						||
type ReqPageBo struct {
 | 
						||
	Page  int //页码,从第1页开始
 | 
						||
	Limit int //分页大小
 | 
						||
}
 | 
						||
 | 
						||
// GetOffset 获取便宜量
 | 
						||
func (r *ReqPageBo) GetOffset() int {
 | 
						||
	if r == nil {
 | 
						||
		return 0
 | 
						||
	}
 | 
						||
	offset := (r.Page - 1) * r.Limit
 | 
						||
	if offset < 0 {
 | 
						||
		return 0
 | 
						||
	}
 | 
						||
	return offset
 | 
						||
}
 | 
						||
 | 
						||
// GetSize 获取分页
 | 
						||
func (r *ReqPageBo) GetSize() int {
 | 
						||
	if r == nil {
 | 
						||
		return 20
 | 
						||
	}
 | 
						||
	return r.Limit
 | 
						||
}
 | 
						||
 | 
						||
// GetNum 获取页码
 | 
						||
func (r *ReqPageBo) GetNum() int {
 | 
						||
	if r == nil {
 | 
						||
		return 1
 | 
						||
	}
 | 
						||
	return r.Page
 | 
						||
}
 |