Beispiel #1
0
        /// <summary>
        /// 依标识码查询按钮,不存在返回NULL
        /// </summary>
        /// <param name="buttonCode"></param>
        /// <returns></returns>
        public TRightsButton GetButtonByCode(string buttonCode)
        {
            TRightsButton result = null;

            using (var conn = DapperHelper.CreateConnection())
            {
                result = conn.Query <TRightsButton>(@"SELECT * FROM dbo.t_rights_button WHERE code= @Code;", new { @Code = buttonCode }).FirstOrDefault();
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="item">待更新的记录</param>
        /// <returns></returns>
        public bool Update(TRightsButton item)
        {
            using (var conn = DapperHelper.CreateConnection())
            {
                var effectedRows = conn.Execute(@"UPDATE dbo.t_rights_button SET name=@Name, icon= @Icon, sort=@Sort, last_updated_by= @LastUpdatedBy, last_updated_time= @LastUpdatedTime WHERE id= @Id;", item);
                if (effectedRows > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="item">待插入的记录</param>
        public bool Insert(TRightsButton item)
        {
            using (var conn = DapperHelper.CreateConnection())
            {
                var effectedRows = conn.Execute(@"INSERT INTO dbo.t_rights_button VALUES (@Name ,@Code ,@Icon ,@Sort ,@CreatedBy ,@CreatedTime ,@LastUpdatedBy ,@LastUpdatedTime);", item);
                if (effectedRows > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
        /// <summary>
        /// 新增按钮
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ServiceResult <bool> AddButton(AddButtonRequest request, TRightsUser loginInfo)
        {
            //校验按钮名称和标识码
            var result = new ServiceResult <bool>
            {
                ReturnCode = ReturnCodeType.Error
            };

            var buttonByName = _btnDao.GetButtonByName(request.Name);

            if (buttonByName != null)
            {
                result.Message = "已存在相同名称的按钮!";
                return(result);
            }

            var buttonByCode = _btnDao.GetButtonByCode(request.Code);

            if (buttonByCode != null)
            {
                result.Message = "已存在相同标识码的按钮!";
                return(result);
            }

            var currentTime = DateTime.Now;
            var btn         = new TRightsButton
            {
                Name            = request.Name,
                Code            = request.Code,
                Icon            = request.Icon,
                Sort            = request.Sort,
                CreatedBy       = loginInfo.Id,
                CreatedTime     = currentTime,
                LastUpdatedBy   = loginInfo.Id,
                LastUpdatedTime = currentTime
            };
            var rs = _btnDao.Insert(btn);

            if (rs == true)
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = true;
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// 依id查询
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public TRightsButton GetById(int id)
        {
            var result = new TRightsButton();

            using (var conn = DapperHelper.CreateConnection())
            {
                result = conn.Query <TRightsButton>(@"SELECT  btn.created_by AS CreatedBy ,
                                                            btn.created_time AS CreatedTime ,
                                                            btn.last_updated_by AS LastUpdatedBy ,
                                                            btn.last_updated_time AS LastUpdatedTime ,
                                                            *
                                                    FROM    dbo.t_rights_button AS btn
                                                    WHERE   btn.id = @Id;", new { @Id = id }).FirstOrDefault();
            }

            return(result);
        }