Пример #1
0
        /// <summary>
        /// 获取俱乐部的消息
        /// </summary>
        /// <returns></returns>
        public _Response GetClubInfo(string json)
        {
            JObject obj = JObject.Parse(json);

            int clubid = Convert.ToInt32(obj["nClubId"]);

            T_Club club = this._club.GetClubinfo(clubid);

            _Response result = new _Response(true);

            result.body = club;

            return(result);
        }
Пример #2
0
        /// <summary>
        /// 查询俱乐部
        /// </summary>
        /// <returns></returns>
        public List <T_Club> GetClubPage(T_Club model)
        {
            using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr))
            {
                DynamicParameters param = new DynamicParameters();
                StringBuilder     sb    = new StringBuilder();
                sb.Append(" SELECT c.*,u.nickName as creatName FROM t_club c LEFT JOIN t_user u on c.creatorId=u.userId WHERE 1=1 ");

                if (!string.IsNullOrEmpty(model.startDate))
                {
                    sb.Append(" and createTime>=@startDate ");
                    param.Add("@startDate", model.startDate);
                }
                if (!string.IsNullOrEmpty(model.endDate))
                {
                    sb.Append(" and createTime<=@endDate ");
                    param.Add("@endDate", model.endDate);
                }

                if (!string.IsNullOrEmpty(model.clubName))
                {
                    sb.Append(" and clubName like @clubName and city like @clubName");
                    param.Add("@clubName", "%" + model.clubName + "%");
                }
                if (!string.IsNullOrWhiteSpace(model.orderBy))
                {
                    sb.Append("  order by " + model.orderBy);
                }
                //获取总记录数
                string sqlCount = sb.ToString().Replace(" SELECT c.*,u.nickName as creatName ", "select count(1) totalCount ");

                //分页
                if (model.pageIndex >= 0 && model.pageSize > 0)
                {
                    sb.Append(" limit " + ((model.pageIndex - 1) * model.pageSize) + "," + model.pageSize);
                }
                //分页记录列表
                var list = conn.Query <T_Club>(sb.ToString(), param).ToList();
                if (list != null && list.Count() > 0)
                {
                    //总记录数列表
                    dynamic identity = conn.Query(sqlCount, param).Single();
                    list[0].totalCount = Convert.ToInt64(identity.totalCount);
                    list[0].pageIndex  = model.pageIndex;
                    list[0].pageSize   = model.pageSize;
                }
                return(list);
            }
        }
Пример #3
0
        public ActionResult GetClubPage(string pagination, string sdate, string edate, string keyword)
        {
            Pagination paginationobj = pagination.ToObject <Pagination>();
            T_Club     model         = new T_Club();

            model.pageIndex  = paginationobj.page;
            model.pageSize   = paginationobj.rows;
            model.totalCount = paginationobj.total;
            model.startDate  = sdate;
            model.endDate    = edate;
            model.clubName   = keyword;
            model.orderBy    = paginationobj.sidx + " " + paginationobj.sord;

            List <T_Club> list     = this._club.GetClubPage(model);
            var           jsonData = new
            {
                rows    = list,
                total   = list.Count > 0 ? list[0].total : 0,
                page    = paginationobj.page,
                records = list.Count > 0 ? list[0].totalCount : 0
            };

            return(Success(jsonData));
        }