using Infrastructure.Attribute; using System; using System.Collections.Generic; using System.Linq; using System.Text; using ARW.Model.System; using ARW.Repository.System; using ARW.Service.System.IService; namespace ARW.Service.System { /// /// 用户岗位 /// [AppService(ServiceType = typeof(ISysUserPostService), ServiceLifetime = LifeTime.Transient)] public class SysUserPostService : ISysUserPostService { private SysUserPostRepository UserPostRepository; public SysUserPostService(SysUserPostRepository userPostRepository) { UserPostRepository = userPostRepository; } /// /// 新增用户岗位信息 /// /// public void InsertUserPost(SysUser user) { // 新增用户与岗位管理 List list = new List(); foreach (var item in user.PostIds) { list.Add(new SysUserPost() { PostId = item, UserId = user.UserId }); } UserPostRepository.Insert(list); } /// /// 查询用户岗位集合 /// /// /// public List GetUserPostsByUserId(long userId) { var list = UserPostRepository.GetList(f => f.UserId == userId); return list.Select(x => x.PostId).ToList(); } /// /// 获取用户岗位 /// /// /// public string GetPostsStrByUserId(long userId) { var list = UserPostRepository.SelectPostsByUserId(userId); return string.Join(',', list.Select(x => x.PostName)); } public bool Delete(long userId) { return UserPostRepository.Delete(x => x.UserId == userId); } } }