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

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
import com.yonge.cooleshow.common.enums.ESettlementFrom;
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;

/**
 * 机构表
 * 2023-07-21 17:26:59
 */
@ApiModel(value = "TenantInfoWrapper对象", description = "机构表查询对象")
public class TenantInfoWrapper {

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" TenantInfoQuery-机构表")
    public static class TenantInfoQuery implements QueryInfo {

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

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

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

        @ApiModelProperty("省份编码")
        private Integer provinceCode;

        @ApiModelProperty("城市编码")
        private Integer cityCode;

        @ApiModelProperty("地区街道编码")
        private Integer regionCode;

        @ApiModelProperty("启用/停用")
        private Boolean enableFlag;

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

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

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


    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" TenantInfo-机构表分页响应")
    public static class TenantInfo {
        @ApiModelProperty("id")
        private long id;

        @ApiModelProperty("机构名称")
        private String name;

        @ApiModelProperty("logo")
        private String logo;

        @ApiModelProperty("简介")
        private String briefIntroduction;

        /*@ApiModelProperty("所属地区")
        private String area;*/

        @ApiModelProperty("联系人")
        private String userName;

        @ApiModelProperty("联系方式")
        private String phone;

        @ApiModelProperty("教师数量")
        private Integer teacherCounts;

        @ApiModelProperty("学生数量")
        private Integer studentCounts;

        @ApiModelProperty("省份编码")
        private Integer provinceCode;

        @ApiModelProperty("城市编码")
        private Integer cityCode;

        @ApiModelProperty("地区街道编码")
        private Integer regionCode;

        @ApiModelProperty("省份名称")
        private String provinceName;

        @ApiModelProperty("城市名称")
        private String cityName;

        @ApiModelProperty("地区街道名称")
        private String regionName;

        @ApiModelProperty("审核状态 DOING、审核中 PASS、通过 UNPASS、不通过")
        @TableField(value = "status_")
        private AuthStatusEnum status;

        @ApiModelProperty("机构入驻申请记录")
        private Long tenantApplyRecordId;

        @ApiModelProperty("审核人")
        private Long verifyUserId;

        @ApiModelProperty("审核理由")
        private String reason;

        @ApiModelProperty("审核时间")
        private Date createTime;

        @ApiModelProperty("更新时间")
        private Date updateTime;

        @ApiModelProperty("启用/冻结")
        private Boolean enableFlag;

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

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

    @ApiModel("启用/冻结")
    @Data
    public static class UpdateStatus {

        @ApiModelProperty("id")
        private Long id;

        @ApiModelProperty("true:启用/false:冻结")
        private Boolean enableFlag;

        @ApiModelProperty("结算方式")
        private ESettlementFrom settlement;
    }

    @Data
    public static class UserCount {

        private Long tenantId;

        private Integer count;

    }

}