using APT.Infrastructure.Core;
using APT.BaseData.Domain.ApiModel;
using APT.BaseData.Domain.Entities.FM;
using System;
using System.Collections.Generic;
using APT.Infrastructure.Api;
using APT.BaseData.Domain.Entities.OP;

namespace APT.BaseData.Domain.IServices.FM
{
    /// <summary>
    /// 
    /// </summary>
    public partial interface IFMUserService : ICommonService
    {


        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="pwd">密码</param>
        /// <returns>用户对象</returns>
        List<T_FM_USER> Login(string userName, string pwd);



        /// <summary>
        /// 通过角色获取人员列表
        /// </summary>
        /// <param name="roleIds"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        List<T_FM_USER> GetUsersByRoles(IEnumerable<string> roleIds, Guid? orgId);

        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        UserRoleModel GetRolesByUser(Guid userId, KeywordFilter filter);
        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        UserRoleModel NewGetRolesByUser(Guid userId, KeywordFilter filter);
        UserRoleModel AppGetRolesByUser(Guid userId, KeywordFilter filter);

        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <param name="userIds"></param>
        /// <returns></returns>
        List<UserRoleModel> GetRolesByUser(IEnumerable<Guid> userIds, KeywordFilter filter);



        /// <summary>
        /// 获取部门节点下所有人员信息
        /// </summary>
        /// <param name="BaseDepartMentID"></param>
        /// <returns></returns>
        List<T_FM_USER> GetDownUser(Guid BaseDepartMentID, string[] UserParts = null);


        /// <summary>
        /// 获取组织成员和下属有审批角色的人（负责人、安全员）
        /// </summary>
        /// <param name="DepartMentID"></param>
        /// <returns></returns>
        List<T_FM_USER> GetUserContentNextHead(Guid DepartMentID);


        /// <summary>
        /// 获取登陆者的生产单元
        /// </summary>
        /// <returns></returns>
        List<int> GetMineType(string minType = null);
        /// <summary>
        /// 获取特定岗位的人
        /// </summary>
        /// <param name="Msg"></param>
        /// <param name="postName"></param>
        /// <returns></returns>
        T_FM_USER GetPostUser(ref string Msg, string postName = "人事专员");


        /// <summary>
        /// 获取某个（部门）审批角色对应人
        /// </summary>
        /// <param name="Msg"></param>
        /// <param name="RoleName"></param>
        /// <param name="DEPARTMENT_ID"></param>
        /// <param name="DEPARTMENT_TYPE">FMDepartmentType 部门=0,  车间=1,   班组=2,  公司=3</param>
        /// <returns></returns>
        T_FM_USER GetRoleUser(ref string Msg, string RoleName, Guid? DEPARTMENT_ID, int? DEPARTMENT_TYPE);

        /// <summary>
        /// 获取部门岗位人员
        /// </summary>
        /// <param name="Msg"></param>
        /// <param name="DEPARTMENT_ID"></param>
        /// <param name="POST_ID"></param>
        /// <param name="IsOnly">只返回一个人</param>
        /// <returns></returns>
        List<T_FM_USER> GetDepPostUser(ref string Msg, Guid DEPARTMENT_ID, Guid POST_ID, bool IsOnly);

        /// <summary>
        /// 找安环部人员 默认 安环安全员
        /// </summary>
        /// <param name="UserType">1 NUM 从小到大 找第一个  10 NUM 找老大</param>
        /// <param name="ORG_ID">1</param>
        /// <returns></returns>
        T_FM_USER GetSafeApproveUser(Guid ORG_ID, int UserType = 1);

        /// <summary>
        /// 人员注册 方法统一
        /// 扫码注册提取
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Phone"></param>
        /// <param name="Code">如果没有 取 Phone </param>
        /// <param name="Sex"></param>
        /// <param name="ID_CARD"></param>
        /// <param name="InTime"></param>
        /// <param name="WORKINGYEAR"></param>
        /// <param name="ORG_ID"></param>
        /// <param name="DEPARTMENT_ID"></param>
        /// <param name="POST_ID"></param>
        /// <param name="TENANT">this.Request.Headers["Tenant"]</param>
        /// <param name="alluser"></param>
        /// <param name="newPerson"></param>
        /// <param name="newUser"></param>
        /// <param name="listRole">是否默认角色 或者 原有方式</param>
        /// <param name="Msg"></param>
        /// <returns>200 正常 500 方法自己做提示</returns>
        int RegisterUser(string Name, string Phone, string Code, int Sex, string ID_CARD, DateTime InTime, int WORKINGYEAR, Guid ORG_ID, Guid? DEPARTMENT_ID, Guid? POST_ID, string TENANT, ref T_OP_ALLUSER alluser, ref T_FM_PERSON newPerson, ref T_FM_USER newUser, ref List<T_FM_USER_BELONG_ROLE> listRole, ref string Msg);
    }
}
