using InSituLaboratory.Entities; using InSituLaboratory.IService; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InSituLaboratory.Service { public class UserService : BaseService, IUserService { public UserService(DbContext context) : base(context) { } /// /// 登录 /// /// /// /// public SysUser Login(string username, string password) { var users = this.Set() .Include(u => u.Roles) .Where(u => u.UserName == username && u.Password == password) .ToList(); return users.FirstOrDefault(); } /// /// 新增用户检查用户名是否存在 /// /// /// public bool CheckUserName(string userName) { return this.Query(u => u.UserName == userName).Count() > 0; } /// /// 根据搜索关键词进行数据检索 /// /// /// public IEnumerable GetUsers(string key) { // 需要将搜索关键词加入判断。。。。。。 return this.Set() .Include(r => r.Roles) .Where(m => string.IsNullOrEmpty(key) || m.UserName.Contains(key) || m.RealName.Contains(key) || m.Address.Contains(key) ); } } }