Пример #1
0
        /// <summary>
        /// 添加角色信息
        /// </summary>
        /// <param name="postRole"></param>
        /// <returns></returns>
        public int PostRole(PostRoleModel postRole)
        {
            using (IDbConnection coon = new SqlConnection(conStr))
            {
                var sql    = @"EXEC dbo.p_RoleAdd @roleName,
                                                @roleDescribe,
                                                @creatorId,
                                                @privilegeId ";
                var result = coon.Execute(sql, new { roleName = postRole.RoleName, roleDescribe = postRole.RoleDescribe, creatorId = postRole.CreatorId, privilegeId = postRole.PrivilegeId });

                return(result);
            }
        }
Пример #2
0
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public int DeleteRole(PostRoleModel post)
        {
            int result;

            using (IDbConnection coon = new SqlConnection(conStr))
            {
                string sql = @"UPDATE dbo.RoleInfo SET UpdateTime = GETDATE(),UpdatorId = @updatorid,Status = 0 WHERE RoleId = @roleid";

                result = coon.Execute(sql, new { updatorid = post.UpdatorId, roleid = post.RoleId });

                return(result);
            }
        }
Пример #3
0
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public PostRoleModel GetRoleById(int RoleId)
        {
            using (IDbConnection coon = new SqlConnection(conStr))
            {
                PostRoleModel info = new PostRoleModel();

                string sql = @"SELECT ri.RoleName,p.PrivilegeId FROM dbo.RoleInfo ri 
                                JOIN RolePrivilegeMapInfo rp ON rp.RoleId = ri.RoleId
                                JOIN dbo.PrivilegeInfo p ON p.PrivilegeId = rp.PrivilegeId WHERE ri.RoleId = @roleId";

                info = coon.QueryFirstOrDefault <PostRoleModel>(sql, new { roleId = RoleId });
                return(info);
            }
        }
Пример #4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public int UpdateRole(PostRoleModel post)
        {
            int result;

            using (IDbConnection coon = new SqlConnection(conStr))
            {
                string sql = @"EXEC dbo.p_UpdRole @roleId,
                                                    @roleName,
                                                    @privilegeId,
                                                    @updatorId ";

                result = coon.Query <PostRoleModel>(sql, new { roleId = post.RoleId, roleName = post.RoleName, privilegeId = post.PrivilegeId, updatorId = post.UpdatorId }).Count();

                return(result);
            }
        }