Ejemplo n.º 1
0
        public async Task <GetCourseListResponseDto> GetCourseListAsync(GetCourseListRequestDto request)
        {
            var orderbySql = "creation_date desc";

            if (!string.IsNullOrWhiteSpace(request.SortField))
            {
                orderbySql = $"{request.SortField} {(request.IsAscending ? "asc" : "desc")}";
            }
            var sqlWhere = $@"1 = 1";

            if (!string.IsNullOrWhiteSpace(request.Keyword))
            {
                sqlWhere = $"{sqlWhere} AND (title like @Keyword  OR summary like @Keyword)";
            }
            var sql = $@"
SELECT * FROM(
	SELECT
	a.*,
	b.nick_name,
	( SELECT count( 1 ) FROM t_consumer_article_view __s WHERE a.course_guid = __s.target_guid GROUP BY target_guid ) AS visit_count,
	( SELECT count( 1 ) FROM t_consumer_collection __s where a.course_guid = __s.target_guid  GROUP BY target_guid ) AS collection 
FROM
	t_utility_course a
	LEFT JOIN t_utility_user b ON a.author_guid = b.user_guid
) T 
WHERE
	{sqlWhere}
ORDER BY
	{orderbySql}
";

            request.Keyword = $"%{request.Keyword}%";
            return(await MySqlHelper.QueryByPageAsync <GetCourseListRequestDto, GetCourseListResponseDto, GetCourseListItemDto>(sql, request));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetCourseListAsync([FromBody] GetCourseListRequestDto request)
        {
            var response = await new CourseBiz().GetCourseListAsync(request);

            return(Success(response));
        }