.Net写的比较清晰的接口
2024-08-31 15:49:10
尼玛,隔行如隔山。
.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 = "操作成功" });
}
这个接口算是比较清晰的了。思路清晰了,代码才能清晰,否则就是一团乱麻,剪不断,理还乱。
最新文章
- Objective-C开发编码规范【转载】
- ios视图frame和bounds的对比
- bdb log file 预设长度的性能优化
- Netty学习四:Channel
- LOB字段存放在指定表空间 清理CLOB字段及压缩CLOB空间
- Google Code Jam 2009, Round 1C C. Bribe the Prisoners (记忆化dp)
- Apache OFBiz
- CentOS 6.3中安装OpenCV2.3.1
- 用N2N搭建简单的VPN
- transfer-webpack-plugin最简使用示例
- 【转】简单理解Vue中的nextTick
- 【MYSQL】MYSQL报错解决方法: Warning: (3719, ";&#39;utf8&#39; is currently an alias for the character set UTF8MB3, but will be an alias for UTF8M B4 in a future release.";
- MySql cmd下的学习笔记 —— 有关视图的操作(建立表)
- Linux Bash Shell字符串分割substring等(转)
- sublime插件安装及常用插件配置
- typedef那回事儿
- js 不固定传参
- 洛谷 P1503 鬼子进村 解题报告
- python注解(装饰器)的用法
- DNA Pairing-freecodecamp算法题目