using Edu.Common.Enum.User;
using Edu.Model.Entity.User;
using Edu.Model.ViewModel.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Edu.Repository.User
{
    /// <summary>
    /// 工作流指定成员
    /// </summary>
    public partial class Rb_Workflow_AuditUserRepository : BaseRepository<Rb_Workflow_Audituser>
    {
        /// <summary>
        /// 获取审核条件下所有的抄送人
        /// </summary>
        /// <param name="ConditionId"></param>
        /// <returns></returns>
        public List<Rb_Workflow_Audituser_Extend> GetDefaultAuditUser(int ConditionId) {
            return Get<Rb_Workflow_Audituser_Extend>($@"select au.*,e.EmName,e.EmAccount,e.EmLoginMobile from Rb_Workflow_Audituser au left join rb_employee e on au.EmployeeId=e.EmployeeId where au.EmType=2 and au.AuditId={ConditionId}").ToList();
        }

        /// <summary>
        /// 获取审核条件下所有的指定成员
        /// </summary>
        /// <param name="AuditId"></param>
        /// <returns></returns>
        public List<Rb_Workflow_Audituser_Extend> GetConditionAuditUser(int AuditId)
        {
            return Get<Rb_Workflow_Audituser_Extend>($@"select au.*,e.EmName,e.EmAccount,e.EmLoginMobile from Rb_Workflow_Audituser au left join rb_employee e on au.EmployeeId=e.EmployeeId where au.EmType=1 and au.AuditId={AuditId}").ToList();
        }

        /// <summary>
        /// 获取审核条件下所有的抄送人
        /// </summary>
        /// <param name="TemplateId"></param>
        /// <returns></returns>
        public List<Rb_Workflow_Audituser_Extend> GetAllAuditUser(int TemplateId)
        {
            return Get<Rb_Workflow_Audituser_Extend>($@"select au.*,e.EmName,e.EmAccount,e.EmLoginMobile from rb_workflow_condition c left join Rb_Workflow_Audituser au on c.Id=au.AuditId left join rb_employee e on au.EmployeeId=e.EmployeeId where au.EmType=2 and c.TemplateId={TemplateId}").ToList();
        }
    }
}
