1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using Attribute;
- using Model;
- using Service;
- namespace Services
- {
-
-
-
- [AppService(ServiceType = typeof(ISysUserPostService), ServiceLifetime = LifeTime.Transient)]
- public class SysUserPostService : BaseService<SysUserPost>, ISysUserPostService
- {
-
-
-
-
- public void InsertUserPost(SysUser user)
- {
-
- List<SysUserPost> list = new();
- foreach (var item in user.PostIds)
- {
- list.Add(new SysUserPost() { PostId = item, UserId = user.userId });
- }
- InsertRange(list);
- }
-
-
-
-
-
- public List<long> GetUserPostsByUserId(long userId)
- {
- var list = GetList(f => f.UserId == userId);
- return list.Select(x => x.PostId).ToList();
- }
-
-
-
-
-
- public string GetPostsStrByUserId(long userId)
- {
- var list = SelectPostsByUserId(userId);
- return string.Join(',', list.Select(x => x.postName));
- }
- public bool Delete(long userId)
- {
- return Delete(x => x.UserId == userId);
- }
-
-
-
-
-
- public List<SysPost> SelectPostsByUserId(long userId)
- {
- return Context.Queryable<SysPost, SysUserPost>((p, up) => new JoinQueryInfos(
- JoinType.Left, up.PostId == p.postId
- )).Where((p, up) => up.UserId == userId)
- .Select<SysPost>().ToList();
- }
- }
- }
|