package com.yonge.cooleshow.biz.dal.wrapper;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.yonge.cooleshow.common.enums.ECooperateTenantNature;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;
import java.util.Optional;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 合作机构
 * 2023-11-06 14:05:19
 */
@ApiModel(value = "CooperateTenantWrapper对象", description = "合作机构查询对象")
public class CooperateTenantWrapper {

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" CooperateTenantQuery-合作机构")
    public static class CooperateTenantQuery implements QueryInfo {

        @ApiModelProperty("当前页")
        private Integer page;

        @ApiModelProperty("分页行数")
        private Integer rows;

        @ApiModelProperty("关键字匹配")
        private String keyword;

        @ApiModelProperty("合作机构性质")
        private ECooperateTenantNature cooperateTenantNature;

        @ApiModelProperty("提交开始时间")
        private Date submitStartTime;

        @ApiModelProperty("提交结束时间")
        private Date submitEndTime;

        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static CooperateTenantQuery from(String json) {
            return JSON.parseObject(json, CooperateTenantQuery.class);
        }
    }

    @Data
    @ApiModel(" CooperateTenant-合作机构")
    public static class CooperateTenant {

        @ApiModelProperty("合作机构名称")
        @NotNull(message = "合作机构名称不能为空")
        private String cooperateTenantName;

        @ApiModelProperty("合作机构性质")
        @NotNull(message = "合作机构性质不能错误")
        private ECooperateTenantNature cooperateTenantNature;

        @ApiModelProperty("联系人")
        @NotNull(message = "联系人不能为空")
        private String contacts;

        @ApiModelProperty("手机号")
        @Pattern(regexp = "^1\\d{10}$", message = "手机号码格式错误")
        private String phone;

        @ApiModelProperty("验证码")
        @NotNull(message = "验证码不能为空")
        private String code;

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static CooperateTenant from(String json) {
            return JSON.parseObject(json, CooperateTenant.class);
        }
    }

}