Ejemplo n.º 1
0
        /// <summary>
        /// 广告计划
        /// </summary>
        /// <returns></returns>
        public JsonResult GetAdPlanList()
        {
            try
            {
                int page  = !string.IsNullOrEmpty(Request["page"]) ? Convert.ToInt32(Request["page"]) : 1;
                int limit = !string.IsNullOrEmpty(Request["limit"]) ? Convert.ToInt32(Request["limit"]) : 10;

                var ADName          = Request["ADName"] ?? "";
                var BusinessPlanID  = Request["BusinessPlanID"] ?? "";
                var startLaunchTime = Request["startLaunchTime"] ?? "";
                var endLaunchTime   = Request["endLaunchTime"] ?? "";
                var Status          = Request["Status"] ?? "";
                var ADPlanID        = Request["ADPlanID"] ?? "";
                var NewAdPlanID     = Request["NewAdPlanID"] ?? "";

                var paramRequest = new CreativePlanRequest
                {
                    PageIndex       = page,
                    PageSize        = limit,
                    ADName          = ADName,
                    BusinessPlanID  = BusinessPlanID,
                    endLaunchTime   = endLaunchTime,
                    startLaunchTime = startLaunchTime,
                    Status          = Status,
                    IsAdmin         = true,
                    NewAdPlanID     = NewAdPlanID,
                    AdPlanID        = ADPlanID
                };
                if (paramRequest.PageIndex == 0)
                {
                    paramRequest.PageIndex = 1;
                }
                else
                {
                    paramRequest.PageIndex = (paramRequest.PageIndex / 10) + 1;
                }

                var result = creativePlanLogic.QueryUserListPage(paramRequest);
                if (result != null && result.count > 0)
                {
                    result.msg  = "SUCCESS";
                    result.code = 0;
                }
                return(Json(result));
            }
            catch (Exception ex)
            {
                LogWriter.error($"GetAdPlanList=>获取广告信息异常:{ex.ToString() + ex.Message}");
                return(Json(new CreativePlanPageResponse()
                {
                    code = -1, msg = "未查询到数据"
                }));
            }
        }
        public CreativePlanPageResponse QueryUserListPage(CreativePlanRequest request)
        {
            int total    = 0;
            var pageList = CreativePlanQuery.QueryCreativePlan(request, out total);

            CreativePlanPageResponse page = new CreativePlanPageResponse();

            if (pageList != null && pageList.Count > 0)
            {
                page.count = total;
                page.data  = pageList.ToList();
                return(page);
            }
            return(page);
        }
Ejemplo n.º 3
0
        public List <CreativePlanEntity> QueryCreativePlan(CreativePlanRequest request, out int total)
        {
            total = 0;
            List <CreativePlanEntity> list = new List <CreativePlanEntity>();
            StringBuilder             sq   = new StringBuilder();

            sq.Append(" select * from ( ");
            sq.Append(" select {2} ");
            sq.Append(" from dbo.tblAdvertisingPlan a with(nolock) ");
            sq.Append(" where {0} ");
            sq.Append(" ) c where {1} ");
            DynamicParameters dp      = new DynamicParameters();
            string            where_1 = " 1=1 ";

            if (!string.IsNullOrWhiteSpace(request.ADName))
            {
                where_1 += " and a.ADName=@ADName";
                dp.Add("ADName", request.ADName, DbType.String);
            }
            if (!string.IsNullOrWhiteSpace(request.BusinessPlanID))
            {
                where_1 += " and a.BusinessPlanID=@BusinessPlanID";
                dp.Add("BusinessPlanID", request.BusinessPlanID, DbType.String);
            }
            if (!string.IsNullOrWhiteSpace(request.Status))
            {
                where_1 += " and a.Status=@Status";
                dp.Add("Status", request.Status, DbType.String);
            }
            if (!string.IsNullOrWhiteSpace(request.startLaunchTime))
            {
                where_1 += " and a.LaunchTime>@startLaunchTime";
                dp.Add("startLaunchTime", request.startLaunchTime, DbType.String);
            }
            if (!string.IsNullOrWhiteSpace(request.endLaunchTime))
            {
                where_1 += " and a.LaunchTime<=@endLaunchTime";
                dp.Add("endLaunchTime", request.endLaunchTime, DbType.String);
            }
            if (!request.IsAdmin)
            {
                where_1 += " and a.UserManageId=@UserManageId";
                dp.Add("UserManageId", request.UserManageId, DbType.Int32);
            }
            if (!string.IsNullOrWhiteSpace(request.NewAdPlanID))
            {
                where_1 += " and a.NewAdPlanID=@NewAdPlanID";
                dp.Add("NewAdPlanID", request.NewAdPlanID, DbType.String);
            }
            if (!string.IsNullOrWhiteSpace(request.AdPlanID))
            {
                where_1 += " and a.AdPlanID=@AdPlanID";
                dp.Add("AdPlanID", request.AdPlanID, DbType.String);
            }

            where_1 += " and a.IsDelete=0 ";

            dp.Add("PageIndex", request.PageIndex, DbType.Int32, ParameterDirection.Input);
            dp.Add("PageSize", request.PageSize, DbType.Int32, ParameterDirection.Input);

            string sql_list = string.Format(sq.ToString(), where_1, " c.Num > (@PageIndex - 1) * @PageSize and c.Num <= @PageIndex * @PageSize", "ROW_NUMBER() over(order by a.CreateTime desc) as Num,* ");

            string sql_count = string.Format(sq.ToString(), where_1, "1=1", "count(0) as nums");

            using (IDbConnection conn = new SqlConnection(DBConnectionStringConfig.Default.JMGGConnectionString))
            {
                total = conn.Query <int>(sql_count, dp).FirstOrDefault();
                list  = conn.Query <CreativePlanEntity>(sql_list, dp).ToList();
            }
            return(list);
        }