using System;
using System.Linq;
using System.Collections.Generic;
using PushPlatform.Data;
using PushPlatform.Data.MvcModels;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;
using Dapper;

namespace PushPlatform.Data.DaoAchieve
{
    public partial class SysMenuDaoAchieve
    {

        #region Dao

        #region 获取项目对应的菜单
        public List<MenuModel> GetMenu(string projectId)
        {
            using (IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(@"SELECT m.Id as Id,m.Menu_Name as MenuName,m.Menu_Url as MenuUrl,m.Menu_Sort as MenuSort
                          from sys_menu m
                                INNER JOIN map_project_menu map ON m.Id = map.MenuId
                         WHERE m.Is_Deleted = 0 AND map.Is_Deleted = 0 AND map.ProjectId = @projectId ORDER BY m.Menu_Sort; ");
                var query = connection.Query<MenuModel>(sb.ToString(), new { projectId = projectId });
                return query.ToList();
            }
        }
        #endregion

        #endregion
    }
}