.Net写的比较清晰的接口

尼玛,隔行如隔山。
.Net真操蛋。

        /// <summary>
        ///  加入群
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult AgreeJoinGroup(string appType, int applyerId,int groupId)
        {
            var group = _groupService.GetGroupById(groupId);
            // 判断群是否存在
            if (null == group)
            {
                return Json(new { result = false, msg = "群不存在" });
            }

            // 判断群是否解散
            if (group.IsDismiss)
            {
                return Json(new { result = false, msg = "群已解散" });
            }

            // 判断用户是否已经在群中
            bool isInGroup = _groupMemberService.CheckMemberInGroup(groupId, applyerId);
            if (isInGroup)
            {
                return Json(new { result = false, msg = "已是群成员" });
            }

            // 加入群中
            GroupMember member = new GroupMember()
            {
                GroupId = groupId,
                CustomerId = applyerId,
                CreatedOn = DateTime.Now,
                LastUpdateOn = DateTime.Now,
                IsGag = false,
                IsQuit = false
            };
            _groupMemberService.InsertGroupMember(member);


            return Json(new { result = true, msg = "操作成功" });
        }

这个接口算是比较清晰的了。思路清晰了,代码才能清晰,否则就是一团乱麻,剪不断,理还乱。

原文地址:https://www.cnblogs.com/jiqing9006/p/6862759.html