package org.xyzh.api.system.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.xyzh.common.vo.BaseVO;
import org.xyzh.common.dto.sys.TbSysDeptDTO;
import org.xyzh.common.dto.sys.TbSysRoleDTO;
import org.xyzh.common.dto.sys.TbSysDeptRoleDTO;

/**
 * @description    用户部门角色视图对象
 * @filename    UserDeptRoleVO.java
 * @author    yslg
 * @copyright yslg
 * @since 2025-11-04
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "用户部门角色视图对象")
public class UserDeptRoleVO extends BaseVO {
    
    // TbSysUserDTO对应字段
    @Schema(description = "用户ID")
    private String userId;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "手机")
    private String phone;

    @Schema(description = "微信ID")
    private String wechatId;

    @Schema(description = "用户状态")
    private String status;

    @Schema(description = "用户类型")
    private String userType;

    // TbSysUserInfoDTO对应字段
    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "用户名")
    private String username;

    @Schema(description = "性别")
    private Integer gender;

    @Schema(description = "等级")
    private Integer level;

    @Schema(description = "身份证号")
    private String idCard;

    @Schema(description = "地址")
    private String address;

    // TbSysDeptDTO对应字段
    @Schema(description = "部门ID")
    private String deptId;
    
    @Schema(description = "部门名称")
    private String deptName;
    
    @Schema(description = "父级部门ID")
    private String parentId;
    
    @Schema(description = "部门描述")
    private String deptDescription;

    // TbSysRoleDTO对应字段（SysRoleVO的字段）
    @Schema(description = "角色ID")
    private String roleId;

    @Schema(description = "角色名称")
    private String roleName;

    @Schema(description = "角色描述")
    private String roleDescription;

    @Schema(description = "角色作用域")
    private String scope;

    @Schema(description = "所属部门ID")
    private String ownerDeptId;

    @Schema(description = "角色状态")
    private Boolean roleStatus;


    public static TbSysDeptDTO toDeptDTO(UserDeptRoleVO vo) {
        if (vo == null) {
            return null;
        }
        TbSysDeptDTO dto = new TbSysDeptDTO();
        dto.setDeptId(vo.getDeptId());
        dto.setName(vo.getDeptName());
        dto.setParentId(vo.getParentId());
        dto.setDescription(vo.getDeptDescription());
        dto.setOptsn(vo.getOptsn());
        dto.setCreator(vo.getCreator());
        dto.setUpdater(vo.getUpdater());
        dto.setDeptPath(vo.getDeptPath());
        dto.setRemark(vo.getRemark());
        dto.setCreateTime(vo.getCreateTime());
        dto.setUpdateTime(vo.getUpdateTime());
        dto.setDeleteTime(vo.getDeleteTime());
        dto.setDeleted(vo.getDeleted());
        return dto;
    }

    public static TbSysRoleDTO toRoleDTO(UserDeptRoleVO vo) {
        if (vo == null) {
            return null;
        }
        TbSysRoleDTO dto = new TbSysRoleDTO();
        dto.setRoleId(vo.getRoleId());
        dto.setName(vo.getRoleName());
        dto.setDescription(vo.getRoleDescription());
        dto.setScope(vo.getScope());
        dto.setOwnerDeptId(vo.getOwnerDeptId());
        dto.setStatus(vo.getRoleStatus());
        dto.setOptsn(vo.getOptsn());
        dto.setCreator(vo.getCreator());
        dto.setUpdater(vo.getUpdater());
        dto.setDeptPath(vo.getDeptPath());
        dto.setRemark(vo.getRemark());
        dto.setCreateTime(vo.getCreateTime());
        dto.setUpdateTime(vo.getUpdateTime());
        dto.setDeleteTime(vo.getDeleteTime());
        dto.setDeleted(vo.getDeleted());
        return dto;
    }

    public static TbSysDeptRoleDTO toDeptRoleDTO(UserDeptRoleVO vo) {
        if (vo == null) {
            return null;
        }
        TbSysDeptRoleDTO dto = new TbSysDeptRoleDTO();
        dto.setDeptId(vo.getDeptId());
        dto.setRoleId(vo.getRoleId());
        dto.setOptsn(vo.getOptsn());
        dto.setCreator(vo.getCreator());
        dto.setUpdater(vo.getUpdater());
        dto.setDeptPath(vo.getDeptPath());
        dto.setRemark(vo.getRemark());
        dto.setCreateTime(vo.getCreateTime());
        dto.setUpdateTime(vo.getUpdateTime());
        dto.setDeleteTime(vo.getDeleteTime());
        dto.setDeleted(vo.getDeleted());
        return dto;
    }

    public static UserDeptRoleVO fromPermission(PermissionVO permissionVO) {
        if (permissionVO == null) {
            return null;
        }
        UserDeptRoleVO vo = new UserDeptRoleVO();
        vo.setDeptId(permissionVO.getDeptId());
        vo.setDeptName(permissionVO.getDeptName());
        vo.setParentId(permissionVO.getDeptParentId());
        vo.setDeptDescription(permissionVO.getDeptDescription());
        vo.setRoleId(permissionVO.getRoleId());
        vo.setRoleName(permissionVO.getRoleName());
        vo.setRoleDescription(permissionVO.getRoleDescription());
        vo.setScope(permissionVO.getRoleScope());
        vo.setOwnerDeptId(permissionVO.getRoleOwnerDeptId());
        vo.setRoleStatus(permissionVO.getRoleStatus());
        vo.setOptsn(permissionVO.getOptsn());
        vo.setCreator(permissionVO.getCreator());
        vo.setUpdater(permissionVO.getUpdater());
        vo.setDeptPath(permissionVO.getDeptPath());
        vo.setRemark(permissionVO.getRemark());
        vo.setCreateTime(permissionVO.getCreateTime());
        vo.setUpdateTime(permissionVO.getUpdateTime());
        vo.setDeleteTime(permissionVO.getDeleteTime());
        vo.setDeleted(permissionVO.getDeleted());
        return vo;
    }
}