Пример #1
0
 public JResult GetAllMenu(BaseMenuModel model)
 {
     return _baseservice.GetAllMenu(model);
 }
Пример #2
0
 public JResult AddMenu(BaseMenuModel model)
 {
     return _baseservice.AddMenu(model);
 }
Пример #3
0
 public JResult UpdateMenu(BaseMenuModel model)
 {
     return _baseservice.UpdateMenu(model);
 }
Пример #4
0
        /// <summary>
        /// 获取所有菜单
        /// </summary>
        /// <returns></returns>
        public IEnumerable<MenuViewMode> GetAllMenu(BaseMenuModel model)
        {
            StringBuilder sqlwhere = new StringBuilder();
            //层级
            if (model.level != null)
            {
                sqlwhere.AppendFormat(" and level ={0} ", model.level);
            }
            //innerid
            if (!string.IsNullOrWhiteSpace(model.innerid))
            {
                sqlwhere.AppendFormat(" and innerid ='{0}' ", model.innerid);
            }
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"select innerid, ifnull(code,'') as code,ifnull(name,'') as name, ifnull(url,'') as url, sort, parentid, level, openmode, isenabled, ifnull(remark,'') as remark, createdtime, modifiedtime,
                            icon, submenu from sys_menu where isenabled=1 {0} order by modifiedtime desc ;", sqlwhere.ToString());

            var menuList = Helper.Query<MenuViewMode>(sql.ToString());
            return menuList;
        }
Пример #5
0
 /// <summary>
 /// 添加菜单
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddMenu(BaseMenuModel model)
 {
     const string sql = @"INSERT INTO `sys_menu`
                         (`innerid`, `code`, `name`, `url`, `sort`, `parentid`, `level`, `openmode`, `isenabled`, `remark`, `createdtime`, `modifiedtime`, `icon`, `submenu`)
                         VALUES
                         (uuid(), @code, @name, @url, @sort, @parentid, @level, @openmode, 1, @remark, now(), now(), @icon, @submenu);";
     using (var conn = Helper.GetConnection())
     {
         try
         {
             conn.Execute(sql, model);
             return 1;
         }
         catch (Exception ex)
         {
             return 0;
         }
     }
 }
Пример #6
0
 /// <summary>
 /// 更新菜单信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateMenu(BaseMenuModel model)
 {
     var sql = new StringBuilder("update `sys_menu` set ");
     sql.Append(Helper.CreateField(model).Trim().TrimEnd(','));
     sql.Append(" where innerid = @innerid");
     int result;
     try
     {
         result = Helper.Execute(sql.ToString(), model);
     }
     catch (Exception ex)
     {
         result = 0;
     }
     return result;
 }