package com.pcloud.book.skill.facade.request;

import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.skill.entity.PcloudGroupActivity;
import com.pcloud.common.utils.string.StringUtil;

import org.springframework.beans.BeanUtils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 保存共读活动
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("新增共读活动")
public class SaveGroupActivityRequestVO extends BaseTempletClassify {

    private static final long serialVersionUID = -5370056714391879364L;

    @ApiModelProperty("编号")
    private String number;

    @ApiModelProperty("第三方入群链接")
    private String groupExtLink;

    @ApiModelProperty("群类型 0官方群 1第三方入群指引")
    private Integer groupType;

    @ApiModelProperty("共度名称")
    private String name;

    @ApiModelProperty("描述")
    private String desc;

    @ApiModelProperty("群图片，加群方式为图片时有效")
    private String groupPic;

    @ApiModelProperty("加群类型（0：邀请 1：图片）")
    private Integer joinType;

    @ApiModelProperty("专业标签")
    private Long proLabelId;

    @ApiModelProperty("深度标签")
    private Long depLabelId;

    @ApiModelProperty("目的标签")
    private Long purLabelId;

    @ApiModelProperty("群分类id")
    private Long bookGroupClassifyId;

    public void checkParam() {
        if (StringUtil.isBlank(this.getName())
                || null == this.getProLabelId() || null == this.getDepLabelId()
                || null == this.getPurLabelId()
                || null == this.getGroupType()) {
            throw new BookBizException(BookBizException.PARAM_IS_NULL, "请求参数缺失");
        }
        if("0".equals(this.getGroupType())){
            if (null == this.getJoinType()
                    || null == this.getBookGroupClassifyId()) {
                throw new BookBizException(BookBizException.PARAM_IS_NULL, "请求参数缺失");
            }
        }
    }

    /**
     * 转换实体映射
     */
    public PcloudGroupActivity getEntity() {
        PcloudGroupActivity pcloudGroupActivity = new PcloudGroupActivity();
        BeanUtils.copyProperties(this, pcloudGroupActivity);
        return pcloudGroupActivity;
    }

}
