using ASHermed.SinoInterface.Api.ContractModel;
using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.IRepository;
using ASHermed.SinoInterface.Repository.MySql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASHermed.SinoInterface.Api.MySqlRepository
{
    public class SysRepository : BaseRepositoryToASHermed_SinoInterface<Sys_User>, ISysRepository
    {
        public List<Sys_User> GetSysHelpers(string role)
        {
            var selectSql = new StringBuilder();
            var parms = new Dictionary<string, object>();
            selectSql.Append(@"select * from sys_user where RoleName = @RoleName");
            parms.Add("@RoleName", role);
            var result = Query<Sys_User>(selectSql.ToString(), parms);
            return result?.ToList();
        }


        /// <summary>
        /// 获取所有的用户
        /// </summary>
        /// <returns></returns>
        public List<Sys_User> GetSysUserList()
        {
            var selectSql = new StringBuilder();
            selectSql.Append(@"select * from sys_user where  `Status`=1");
            var result = Query<Sys_User>(selectSql.ToString());
            return result?.ToList();

        }

        public Sys_User SelectDocListByHealthClub()
        {
            var selectSql = new StringBuilder();
            selectSql.Append(@"select * from sys_user where IsHealthClub =true and `Status`=1");
            var result = Query<Sys_User>(selectSql.ToString());
            return result?.FirstOrDefault();
        }

    }
}
