package com.microservices.zone.member.domain.vo;

import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.zone.member.domain.ZoneMember;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author otto
 */

@Data
@ApiModel("会员聚合申请对象")
public class ZoneMemberApplyVo {
    @ApiModelProperty(value = "会员名称")
    private String name;
    @ApiModelProperty(value = "会员头像")
    private String imageUrl;
    @ApiModelProperty(value = "会员简介")
    private String introduction;
    @ApiModelProperty(value = "申请原因")
    private String remark;


    public ZoneMember toZoneMember() {
        ZoneMember zoneMember = new ZoneMember();
        zoneMember.setName(this.name);
        zoneMember.setImageUrl(this.imageUrl);
        zoneMember.setIntroduction(this.introduction);
        if(StringUtils.isEmpty(remark)){
            throw new ServiceException("申请加入专区会员时，需填写申请原因");
        }
        if(remark.length()>300){
            throw new ServiceException("申请原因长度不能超过300");
        }
        zoneMember.setRemark("【申请原因】："+this.remark);
        return zoneMember;
    }

}
