package com.zcloud.basic.info.domain.model;

import com.alibaba.cola.domain.Entity;
import com.jjb.saas.framework.domain.model.BaseE;
import com.zcloud.gbscommon.utils.Tools;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * web-domain
 *
 * @Author zhaokai
 * @Date 2025-10-30 10:10:48
 */
@Data
@Entity
@EqualsAndHashCode(callSuper = true)
public class DepartmentE extends BaseE {

    //部门id
    private String departmentId;
    //名称
    private String name;
    //父部门id
    private Long parentId;
    //所属企业
    private Long corpinfoId;
    //部门级别编码
    private String level;
    //部门级别名称
    private String levelName;
    //部门排序
    private Integer depOrder;
    //是否监管部门 0-否  1-是
    private Integer superviseFlag;
    //是否安全管理部门 0-否 1-是
    private Integer securityFlag;
    private String departmentFunction;

    /**
     * 初始化添加部门关联部门行为
     * @param departmentIdsString
     * @param superviseDepartmentId
     * @return
     */
    public List<DepartmentSuperviseE> initAdd(List<Long> departmentIdsString, Long superviseDepartmentId) {
        List<DepartmentSuperviseE> departmentSuperviseEList = new ArrayList<>();
        departmentIdsString.forEach(departmentId -> {
            DepartmentSuperviseE departmentSuperviseE = new DepartmentSuperviseE();
            departmentSuperviseE.setSuperviseId(Tools.get32UUID());
            departmentSuperviseE.setDepartmentId(departmentId);
            departmentSuperviseE.setSuperviseDepartmentId(superviseDepartmentId);
            departmentSuperviseEList.add(departmentSuperviseE);
        });
        return departmentSuperviseEList;
    }


    public void initCorpInfo(Long corpInfoId, String corpName) {
        this.setId(corpInfoId);
        this.setCorpinfoId(corpInfoId);
        this.setParentId(0L);
        this.setTenantId(corpInfoId);
        this.setOrgId(corpInfoId);
        this.setName(corpName);
    }
}

