package com.xiaoniu.system.platformusers.user.dto;

import com.xiaoniu.common.core.resdata.BaseQueryDTO;
import com.xiaoniu.common.core.utils.StringUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author haoxuyang
 * @Date 2024/10/19 17:40
 */
@Data
@Schema(description = "平台用户查询参数DTO")
public class ClientUserListQueryDTO extends BaseQueryDTO {

    @Schema(description = "用户昵称")
    private String nickName;

    @Schema(description = "用户手机号")
    private String phoneNumber;

    @Schema(description = "开始时间")
    private String beginTime;

    @Schema(description = "结束时间")
    private String endTime;

    @Schema(description = "用户类型")
    private String userType;

    @Schema(description = "用户标签")
    private String userLabel;

    @Schema(description = "排序字段")
    private String sortCol;

    @Schema(description = "排序类型 1升序 2降序")
    private String sortType = "1";

    public String getSortCol() {
        if (StringUtils.isNotNull(sortCol)) {
            String regex = "([A-Z])";
            Matcher matcher = Pattern.compile(regex).matcher(sortCol);
            while (matcher.find()) {
                String target = matcher.group();
                sortCol = sortCol.replaceAll(target, "_" + target.toLowerCase());
            }
        }
        return sortCol;
    }
}
