|
@@ -0,0 +1,65 @@
|
|
|
+using System.Threading.Tasks;
|
|
|
+using GxPress.Auth;
|
|
|
+using GxPress.Repository.Interface;
|
|
|
+using GxPress.Request.App.Group;
|
|
|
+using GxPress.Request.App.GroupUser;
|
|
|
+using GxPress.Result.App.Group;
|
|
|
+using GxPress.Service.Interface.Group;
|
|
|
+using GxPress.Service.Interface.Topic;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+
|
|
|
+namespace GxPress.Api.WebControllers
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 导航数据
|
|
|
+ /// </summary>
|
|
|
+ [Route("api/web/group")]
|
|
|
+ [ApiController]
|
|
|
+ [Authorize]
|
|
|
+ public class WebGroupController : Controller
|
|
|
+ {
|
|
|
+
|
|
|
+ private readonly IGroupRepository _groupRepository;
|
|
|
+ private readonly IGroupUserRepository _groupUserRepository;
|
|
|
+ private readonly IGroupFolderRepository _groupFolderRepository;
|
|
|
+ private readonly IGroupService _groupService;
|
|
|
+ private readonly ILoginContext _loginContext;
|
|
|
+ private readonly ITopicRepository _topicRepository;
|
|
|
+ private readonly ITopicService _topicService;
|
|
|
+ public WebGroupController(IGroupRepository groupRepository,
|
|
|
+ IGroupFolderRepository groupFolderRepository, IGroupUserRepository groupUserRepository,
|
|
|
+ ILoginContext loginContext, IGroupService groupService, ITopicRepository topicRepository, ITopicService topicService)
|
|
|
+ {
|
|
|
+ _groupFolderRepository = groupFolderRepository;
|
|
|
+ _groupRepository = groupRepository;
|
|
|
+ _groupUserRepository = groupUserRepository;
|
|
|
+ _loginContext = loginContext;
|
|
|
+ _groupService = groupService;
|
|
|
+ _topicRepository = topicRepository;
|
|
|
+ _topicService = topicService;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 新建小组
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPut("insert")]
|
|
|
+ public async Task<GroupDetailResult> Insert(GroupInRequest request)
|
|
|
+ {
|
|
|
+ request.UserId = _loginContext.AccountId;
|
|
|
+ var result = await _groupService.InsertGroup(request);
|
|
|
+ //插入小组用户
|
|
|
+ if (result.Id > 0 && request.UserIds.Count > 0)
|
|
|
+ {
|
|
|
+ var groupUserInRequest = new GroupUserInRequest();
|
|
|
+ groupUserInRequest.UserId = request.UserId;
|
|
|
+ groupUserInRequest.UserIds = request.UserIds;
|
|
|
+ groupUserInRequest.SourceType = 2;
|
|
|
+ groupUserInRequest.GroupId = result.Id;
|
|
|
+ await _groupService.InsertsAsync(groupUserInRequest);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|