分类选择

This commit is contained in:
zhujunjieit 2019-01-22 23:52:46 +08:00
parent 95c093403b
commit 5b6fc219e3
3 changed files with 68 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,5 +1,6 @@
package com.ruoyi.cms.controller;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.exam.domain.ExamPractice;
@ -7,6 +8,7 @@ import com.ruoyi.exam.service.IExamPracticeService;
import com.ruoyi.framework.web.util.ShiroUtils;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.train.course.domain.TrainCourse;
import com.ruoyi.train.course.domain.TrainCourseCategory;
import com.ruoyi.train.course.domain.TrainCourseSection;
import com.ruoyi.train.course.domain.TrainCourseVO;
import com.ruoyi.train.course.service.ITrainCourseCategoryService;
@ -17,14 +19,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
@ -52,12 +53,38 @@ public class CmsController {
@Autowired
private IExamPracticeService examPracticeService;
@RequestMapping({"","/index","/index.html"})
@RequestMapping({"", "/index", "/index.html"})
@GetMapping()
public String user(TrainCourseVO trainCourse, ModelMap map) {
List<TrainCourseVO> list = trainCourseService.selectTrainCoursePage( trainCourse );
public String index(String parentIds, ModelMap map) {
TrainCourseVO trainCourseVO = new TrainCourseVO();
//三级分类列表根据parentIds判断
TrainCourseCategory courseCategory = new TrainCourseCategory();
courseCategory.setParentId( (long) 100 );
List<TrainCourseCategory> courseCategories1 = trainCourseCategoryService.selectCategoryList( courseCategory );
List<TrainCourseCategory> courseCategories2 = new ArrayList<>();
List<TrainCourseCategory> courseCategories3 = new ArrayList<>();
if (StrUtil.isNotBlank( parentIds ) && parentIds.split( "," ).length >= 3) {//二级分类
Long parentId = new Long( parentIds.split( "," )[2] );
courseCategory.setParentId( parentId );
courseCategories2 = trainCourseCategoryService.selectCategoryList( courseCategory );
}
if (StrUtil.isNotBlank( parentIds ) && parentIds.split( "," ).length >= 4) {//三级分类
Long parentId = new Long( parentIds.split( "," )[3] );
courseCategory.setParentId( parentId );
courseCategories3 = trainCourseCategoryService.selectCategoryList( courseCategory );
}
if (StrUtil.isNotBlank( parentIds )) {
trainCourseVO.setTrainCourseCategoryId( new Integer( parentIds.split( "," )[parentIds.split( "," ).length - 1] ) );
//当前选中的分类id
map.put( "selectCategoryId", parentIds.split( "," )[parentIds.split( "," ).length - 1] );
}
List<TrainCourseVO> list = trainCourseService.selectTrainCoursePage( trainCourseVO );
map.put( "trainCourse", list );
map.put( "user", ShiroUtils.getSysUser() );
//三级分类列表
map.put( "courseCategories1", courseCategories1 );
map.put( "courseCategories2", courseCategories2 );
map.put( "courseCategories3", courseCategories3 );
return prefix + "/index";
}
@ -77,10 +104,11 @@ public class CmsController {
map.put( "user", ShiroUtils.getSysUser() );
return prefix + "/course/courseInfo";
}
@RequestMapping("/course/courseSections.html/{id}")
@GetMapping()
public String courseSections(@PathVariable("id") Integer id, ModelMap map) {
TrainCourseSection tcs= trainCourseSectionService.selectById( id );
TrainCourseSection tcs = trainCourseSectionService.selectById( id );
TrainCourseSection trainCourseSection = new TrainCourseSection();
trainCourseSection.setTrainCourseId( tcs.getTrainCourseId() );
List<TrainCourseSection> trainCourseSections = trainCourseSectionService.selectTrainCourseSectionList( trainCourseSection );

View File

@ -135,6 +135,17 @@
border-radius: 30px;
overflow: hidden;
}
.filterbox{/*! border:1px solid #ebebeb; */border-radius:4px;background: #fff;margin-top: 40px}
.filterbox ul{ background-color:white; text-indent:20px;border-radius:3px;}
.filterbox li{ position: relative;border-top:1px dashed #ebebeb;padding: 15px 15px 15px 0;margin-left: 140px;}
.filterbox li:first-child{border-top:0px;}
.filterbox li span{width: 140px;font-size: 16px;line-height:34px;position: absolute;left:-150px;top:15px; color:#fff;background:url(web/res/images/icon-1.png) #ff9f37 no-repeat right center;}
.filterbox li a{float: left;margin:0px 15px 0px 0;font-size: 14px;color: #828282;line-height: 34px;}
.filterbox li a.curr,
.filterbox li a:hover{color:#0288d1;}
.filterbox li:after{content:".";display:block;height:0;clear:both;visibility:hidden}
.filterbox .path-now{font-size: 16px;color: #333;margin-bottom:20px;}
</style>
<div class="fly-header layui-bg-black" th:fragment="top">
@ -187,6 +198,27 @@
</div>
</div>
<div class="layui-container">
<section class="filterbox">
<ul>
<li field="classid"><span>选择分类:</span>
<a th:href="@{/web}" th:class="${#strings.isEmpty(selectCategoryId)}?'curr':''">不限</a>
<a th:each="category:${courseCategories1}" th:href="@{'/web?parentIds='+${category.parentIds}+','+${category.id}}" th:text="${category.name}"
th:class="${category.id}==${selectCategoryId}?'curr':''"></a>
</li>
<li field="classid"><span>选择分类:</span>
<a th:if="${#lists.size(courseCategories3)}>0" th:href="@{'/web?parentIds='+${courseCategories2[0].parentIds}}">不限</a>
<a th:if="${#lists.size(courseCategories3)}==0" th:href="@{'/web'}">不限</a>
<a th:each="category:${courseCategories2}" th:href="@{'/web?parentIds='+${category.parentIds}+','+${category.id}}" th:text="${category.name}" th:class="${category.id}==${selectCategoryId}?'curr':''"></a>
</li>
<li field="classid"><span>选择分类:</span>
<a th:if="${#lists.size(courseCategories3)}>0" th:href="@{'/web?parentIds='+${courseCategories3[0].parentIds}}">不限</a>
<a th:if="${#lists.size(courseCategories3)}==0" th:href="@{'/web'}">不限</a>
<a th:each="category:${courseCategories3}" th:href="@{'/web?parentIds='+${category.parentIds}+','+${category.id}}" th:text="${category.name}" th:class="${category.id}==${selectCategoryId}?'curr':''"></a>
</li>
</ul>
</section>
<div class="title">
<em></em>
<span>所有课程</span>
@ -200,7 +232,7 @@
<img th:if="${#strings.isEmpty(course.cover)}" th:src="@{/web/res/images/no_img.png}" th:alt="${course.name}" width="100%" height="180px">
<img th:if="${not #strings.isEmpty(course.cover)}" th:src="${course.cover}" th:alt="${course.name}" width="100%" height="180px">
<p class="in01">
<span class="f20 c77b" th:text="${course.name}">安全测试基础课程</span>
<span class="f20 c77b" th:text="${course.name}"></span>
<span class="cfff"></span>
</p>
</a>