package com.ruoyi.xq.dto.app.dynamic;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDate;

@Data
public class DynamicQuery {
    @Schema(hidden = true)
    private LocalDate birthdayBegin;
    @Schema(hidden = true)
    private LocalDate birthdayEnd;


    @Schema(description = "性别 1-女 2-男")
    private Integer gender;

    @Schema(description = "年龄-开始")
    private Integer ageBegin;
    @Schema(description = "年龄-结束")
    private Integer ageEnd;

    @Schema(description = "居住地")
    private Integer residenceCode;

    @Schema(description = "1-最新发布 2-热门动态")
    private Integer sortBy = 1;

    public void initBirthdayByAge(){
        if(this.ageBegin != null && this.ageBegin > 0){
            this.birthdayEnd = LocalDate.now().plusYears(-ageBegin);
        }
        if(this.ageEnd != null && this.ageEnd > 0){
            this.birthdayBegin= LocalDate.now().plusYears(-ageEnd);
        }
    }


}
