enhance(types):日期区间范围增加常用方法的易用性。
This commit is contained in:
parent
b244fd5823
commit
fb388c53c7
|
@ -91,9 +91,10 @@ func (dr *DateRange) UnmarshalJSON(data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateRange) SetLower(lower Date, bound pgtype.BoundType) {
|
func (dr *DateRange) SetLower(lower Date, bound ...pgtype.BoundType) {
|
||||||
|
bound = append(bound, pgtype.Inclusive)
|
||||||
dr.Range.Lower = lower
|
dr.Range.Lower = lower
|
||||||
dr.Range.LowerType = bound
|
dr.Range.LowerType = bound[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateRange) SetLowerUnbounded() {
|
func (dr *DateRange) SetLowerUnbounded() {
|
||||||
|
@ -101,9 +102,10 @@ func (dr *DateRange) SetLowerUnbounded() {
|
||||||
dr.Range.LowerType = pgtype.Unbounded
|
dr.Range.LowerType = pgtype.Unbounded
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateRange) SetUpper(upper Date, bound pgtype.BoundType) {
|
func (dr *DateRange) SetUpper(upper Date, bound ...pgtype.BoundType) {
|
||||||
|
bound = append(bound, pgtype.Inclusive)
|
||||||
dr.Range.Upper = upper
|
dr.Range.Upper = upper
|
||||||
dr.Range.UpperType = bound
|
dr.Range.UpperType = bound[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateRange) SetUpperUnbounded() {
|
func (dr *DateRange) SetUpperUnbounded() {
|
||||||
|
|
|
@ -91,9 +91,10 @@ func (dr *DateTimeRange) UnmarshalJSON(data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateTimeRange) SetLower(lower DateTime, bound pgtype.BoundType) {
|
func (dr *DateTimeRange) SetLower(lower DateTime, bound ...pgtype.BoundType) {
|
||||||
|
bound = append(bound, pgtype.Inclusive)
|
||||||
dr.Range.Lower = lower
|
dr.Range.Lower = lower
|
||||||
dr.Range.LowerType = bound
|
dr.Range.LowerType = bound[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateTimeRange) SetLowerUnbounded() {
|
func (dr *DateTimeRange) SetLowerUnbounded() {
|
||||||
|
@ -101,9 +102,10 @@ func (dr *DateTimeRange) SetLowerUnbounded() {
|
||||||
dr.Range.LowerType = pgtype.Unbounded
|
dr.Range.LowerType = pgtype.Unbounded
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateTimeRange) SetUpper(upper DateTime, bound pgtype.BoundType) {
|
func (dr *DateTimeRange) SetUpper(upper DateTime, bound ...pgtype.BoundType) {
|
||||||
|
bound = append(bound, pgtype.Inclusive)
|
||||||
dr.Range.Upper = upper
|
dr.Range.Upper = upper
|
||||||
dr.Range.UpperType = bound
|
dr.Range.UpperType = bound[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DateTimeRange) SetUpperUnbounded() {
|
func (dr *DateTimeRange) SetUpperUnbounded() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user