feat:系统UI优化初版

This commit is contained in:
2026-08-07 17:08:19 +08:00
parent 956a76ac63
commit 4cf4e45ea2
16 changed files with 2500 additions and 555 deletions
@@ -84,7 +84,7 @@ public class LearningCourseDisplayController {
/**
* 查询课程展示列表。
* pageForm 传分页页码和每页条数;keyword、courseTypeId、recommendFlag 分别用于关键词、分类和推荐标识筛选;
* sortType 支持 default(综合排序)和 view_count(观看次数倒序)。返回值为 Pagination,list 中包含课程基础字段、课节数、总时长观看次数。
* sortType 支持 default(综合排序)和 view_count(观看次数倒序)。返回值为 Pagination,list 中包含课程基础字段、课节数、总时长观看次数和当前用户学习进度
*/
public Result pageData(PageForm pageForm, String keyword, String courseTypeId, String recommendFlag, String sortType) {
Cnd cnd = Cnd.where("c.status", "=", "published");
@@ -112,6 +112,9 @@ public class LearningCourseDisplayController {
SELECT c.id, c.courseName, c.courseIntro, c.startTime, c.endTime, c.openType, c.cover,
c.recommendFlags, c.courseTypeId, c.lecturerName, c.sortNum,
COALESCE(c.viewCount, 0) AS viewCount, t.typeName AS courseTypeName,
COALESCE((SELECT ROUND(AVG(IFNULL(sr.progressPercent, 0)))
FROM learning_study_record sr
WHERE sr.courseId = c.id AND sr.userId = @userId), 0) AS progressPercent,
(SELECT COUNT(1) FROM learning_outline_resource r
WHERE r.courseId = c.id AND r.status = 'enabled') AS resourceCount,
COALESCE((SELECT SUM(r.durationSeconds) FROM learning_outline_resource r
@@ -122,6 +125,7 @@ public class LearningCourseDisplayController {
ORDER BY $orderBy
""");
listSql.setCondition(cnd);
listSql.params().set("userId", SecurityUtil.getUserId());
// 排序字段由固定选项映射,禁止将前端参数直接拼接进SQL。
listSql.setVar("orderBy", "view_count".equals(sortType)
? "COALESCE(c.viewCount, 0) DESC, c.sortNum ASC, c.createdAt DESC"
@@ -0,0 +1,98 @@
package com.budwk.app.zhgh.spread.h5controller;
import cn.dev33.satoken.annotation.SaCheckLogin;
import com.budwk.app.base.param.PageForm;
import com.budwk.app.base.result.Result;
import com.budwk.app.zhgh.spread.service.SpreadCategoryService;
import com.budwk.app.zhgh.spread.service.SpreadContentService;
import io.swagger.annotations.ApiOperation;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
/**
* 风采墙 H5 展示控制器,提供栏目、列表和内容详情预览。
*/
@IocBean
@Ok("json:full")
@At("/platform/h5/spread")
public class H5SpreadDisplayController {
@Inject
private SpreadCategoryService categoryService;
@Inject
private SpreadContentService contentService;
/**
* 打开风采墙 H5 预览页面。
*/
@At("")
@Ok("beetl:/platform/zhghh5/spread/display/index.html")
@SaCheckLogin
public void index() {
}
/**
* 查询 H5 端可见栏目树。
*
* @return 按层级组织的可见栏目
*/
@At
@SaCheckLogin
@ApiOperation("H5可见栏目树")
public Result categoryTree() {
return Result.success(categoryService.categoryTree(true));
}
/**
* 查询指定栏目及其子栏目的已发布内容。
*
* @param pageForm 分页参数
* @param categoryId 栏目 ID
* @param title 标题模糊查询条件
* @return 已发布内容分页数据
*/
@At
@SaCheckLogin
@ApiOperation("H5已发布内容分页")
public Result pageData(PageForm pageForm, String categoryId, String title) {
return Result.success(contentService.pagePublished(pageForm, categoryId, title));
}
/**
* 查询 H5 内容详情。
*
* @param id 内容 ID
* @return 内容详情
*/
@At
@SaCheckLogin
@ApiOperation("H5内容详情")
public Result detailData(String id) {
try {
return Result.success(contentService.getContent(id));
} catch (RuntimeException e) {
return Result.error(e.getMessage());
}
}
/**
* 登记 H5 内容浏览量。
*
* @param id 内容 ID
* @return 操作结果
*/
@At
@SaCheckLogin
@ApiOperation("H5增加浏览量")
public Result addView(String id) {
try {
contentService.addViewCount(id);
return Result.success();
} catch (RuntimeException e) {
return Result.error(e.getMessage());
}
}
}
@@ -16,6 +16,16 @@ public interface SpreadContentService extends BaseService<SpreadContent> {
Pagination<NutMap> pagePublished(PageForm pageForm, String categoryId);
/**
* 分页查询指定栏目中标题匹配的已发布内容。
*
* @param pageForm 分页参数
* @param categoryId 栏目 ID,查询时包含该栏目的直接子栏目
* @param title 标题模糊查询条件
* @return 已发布内容分页数据
*/
Pagination<NutMap> pagePublished(PageForm pageForm, String categoryId, String title);
SpreadContent getContent(String id);
void saveContent(SpreadContent content);
@@ -62,8 +62,22 @@ public class SpreadContentServiceImpl extends BaseServiceImpl<SpreadContent> imp
@Override
public Pagination<NutMap> pagePublished(PageForm pageForm, String categoryId) {
return pagePublished(pageForm, categoryId, null);
}
/**
* 分页查询指定栏目中标题匹配的已发布内容。
*
* @param pageForm 分页参数
* @param categoryId 栏目 ID,查询时包含该栏目的直接子栏目
* @param title 标题模糊查询条件
* @return 已发布内容分页数据
*/
@Override
public Pagination<NutMap> pagePublished(PageForm pageForm, String categoryId, String title) {
SpreadContentQuery query = new SpreadContentQuery();
query.setCategoryId(categoryId);
query.setTitle(title);
query.setIsPublished(1);
Cnd cnd = buildCondition(query);
Sql countSql = Sqls.create("SELECT COUNT(1) FROM spread_content c $condition");