李昊 4 years ago
parent
commit
210349f2d2

+ 3 - 2
GxPress/Api/GxPress.Api/AppControllers/ArticleGroupController.cs

@@ -4,6 +4,7 @@ using GxPress.Auth;
 using GxPress.Entity;
 using GxPress.Repository.Interface;
 using GxPress.Request.ArticleGroup;
+using GxPress.Result.ArticleGroupUser;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 
@@ -21,7 +22,7 @@ namespace GxPress.Api.AppControllers
         private readonly ILoginContext _loginContext;
         public ArticleGroupController(IArticleGroupRepository processGroupRepository, ILoginContext loginContext)
         {
-            
+
             _processGroupRepository = processGroupRepository;
             _loginContext = loginContext;
         }
@@ -30,7 +31,7 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("list")]
-        public async Task<IEnumerable<ArticleGroup>> GetList()
+        public async Task<IEnumerable<ArticleGroupUserListResult>> GetList()
         {
             return await _processGroupRepository.GetListAsync(_loginContext.AccountId);
         }

+ 9 - 3
GxPress/Repository/GxPress.Repository.Implement/ArticleGroupRepository.cs

@@ -9,6 +9,7 @@ using GxPress.Request.ArticleGroup;
 using Microsoft.Extensions.Options;
 using Datory;
 using Dapper;
+using GxPress.Result.ArticleGroupUser;
 
 namespace GxPress.Repository.Implement
 {
@@ -53,14 +54,19 @@ namespace GxPress.Repository.Implement
         {
             return await _repository.UpdateAsync(processGroup);
         }
-        public async Task<IEnumerable<ArticleGroup>> GetListAsync(int userId)
+        public async Task<IEnumerable<ArticleGroupUserListResult>> GetListAsync(int userId)
         {
-            string sql = $@"select * from ccpph.tede_article_group where Id not in(SELECT ArticleGroupId FROM ccpph.tede_article_group_user where UserId={userId}) and IsSystemDefault=0";
+            string sql = $@"select * from tede_article_group where Id not  in(SELECT ArticleGroupId FROM tede_article_group_user where UserId={userId}) and IsSystemDefault=0";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
             var result = await connection.QueryAsync<ArticleGroup>(sql);
-            return result;
+            var list = new List<ArticleGroupUserListResult>();
+            foreach (var item in result)
+            {
+                list.Add(new ArticleGroupUserListResult() { Id = item.Id, UserId = userId, ArticleGroupId = item.Id, ArticleGroupName = item.Name, IsSystemDefault = item.IsSystemDefault });
+            }
+            return list;
         }
 
         /// <summary>

+ 2 - 1
GxPress/Repository/GxPress.Repository.Interface/IArticleGroupRepository.cs

@@ -3,6 +3,7 @@ using System.Threading.Tasks;
 using GxPress.Entity;
 using GxPress.Request.ArticleGroup;
 using Datory;
+using GxPress.Result.ArticleGroupUser;
 
 namespace GxPress.Repository.Interface
 {
@@ -18,7 +19,7 @@ namespace GxPress.Repository.Interface
 
         Task<bool> UpdateAsync(ArticleGroup processGroup);
 
-        Task<IEnumerable<ArticleGroup>> GetListAsync(int userId);
+        Task<IEnumerable<ArticleGroupUserListResult>> GetListAsync(int userId);
 
         /// <summary>
         /// ����