diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/dao/QuestionMapper.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/dao/QuestionMapper.java new file mode 100644 index 0000000..9048956 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/dao/QuestionMapper.java @@ -0,0 +1,8 @@ +package com.tamguo.modules.tiku.dao; + +import com.tamguo.config.dao.SuperMapper; +import com.tamguo.modules.tiku.model.QuestionEntity; + +public interface QuestionMapper extends SuperMapper{ + +} diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/model/QuestionEntity.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/model/QuestionEntity.java new file mode 100644 index 0000000..523caee --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/model/QuestionEntity.java @@ -0,0 +1,159 @@ +package com.tamguo.modules.tiku.model; + +import java.io.Serializable; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableName; +import com.tamguo.config.dao.SuperEntity; + +/** + * The persistent class for the tiku_question database table. + * + */ +@TableName(value="tiku_question") +public class QuestionEntity extends SuperEntity implements Serializable { + private static final long serialVersionUID = 1L; + + private String analysis; + private String paperId; + private String answer; + private String chapterId; + private String questionType; + private String content; + private String subjectId; + private String courseId; + private String reviewPoint; + private String year; + private String score; + private String auditStatus; + + @TableField(exist=false) + private String courseName; + @TableField(exist=false) + private String chapterName; + @TableField(exist=false) + private String subjectName; + + public QuestionEntity() { + } + + public String getAnalysis() { + return this.analysis; + } + + public void setAnalysis(String analysis) { + this.analysis = analysis; + } + + public String getAnswer() { + return this.answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public String getChapterId() { + return this.chapterId; + } + + public void setChapterId(String chapterId) { + this.chapterId = chapterId; + } + + public String getQuestionType() { + return this.questionType; + } + + public void setQuestionType(String questionType) { + this.questionType = questionType; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getReviewPoint() { + return reviewPoint; + } + + public void setReviewPoint(String reviewPoint) { + this.reviewPoint = reviewPoint; + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getScore() { + return score; + } + + public void setScore(String score) { + this.score = score; + } + + public String getPaperId() { + return paperId; + } + + public void setPaperId(String paperId) { + this.paperId = paperId; + } + + public String getCourseId() { + return courseId; + } + + public void setCourseId(String courseId) { + this.courseId = courseId; + } + + public String getCourseName() { + return courseName; + } + + public void setCourseName(String courseName) { + this.courseName = courseName; + } + + public String getChapterName() { + return chapterName; + } + + public void setChapterName(String chapterName) { + this.chapterName = chapterName; + } + + public String getSubjectId() { + return subjectId; + } + + public void setSubjectId(String subjectId) { + this.subjectId = subjectId; + } + + public String getSubjectName() { + return subjectName; + } + + public void setSubjectName(String subjectName) { + this.subjectName = subjectName; + } + + public String getAuditStatus() { + return auditStatus; + } + + public void setAuditStatus(String auditStatus) { + this.auditStatus = auditStatus; + } + +} \ No newline at end of file diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java index b120c28..5268619 100644 --- a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java @@ -2,9 +2,10 @@ package com.tamguo.modules.tiku.service; import java.util.List; +import com.baomidou.mybatisplus.service.IService; import com.tamguo.modules.tiku.model.PaperEntity; -public interface IPaperService { +public interface IPaperService extends IService{ List findHistoryPaper(); diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java new file mode 100644 index 0000000..b261fb6 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java @@ -0,0 +1,8 @@ +package com.tamguo.modules.tiku.service; + +import com.baomidou.mybatisplus.service.IService; +import com.tamguo.modules.tiku.model.QuestionEntity; + +public interface IQuestionService extends IService{ + +} diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/QuestionServiceImpl.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/QuestionServiceImpl.java new file mode 100644 index 0000000..0eea176 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/QuestionServiceImpl.java @@ -0,0 +1,12 @@ +package com.tamguo.modules.tiku.service.impl; + +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.tamguo.modules.tiku.dao.QuestionMapper; +import com.tamguo.modules.tiku.model.QuestionEntity; +import com.tamguo.modules.tiku.service.IQuestionService; + +@Service +public class QuestionServiceImpl extends ServiceImpl implements IQuestionService{ + +} diff --git a/tamguo-tms/src/main/java/com/tamguo/utils/PageUtils.java b/tamguo-tms/src/main/java/com/tamguo/utils/PageUtils.java new file mode 100644 index 0000000..9b4bbf0 --- /dev/null +++ b/tamguo-tms/src/main/java/com/tamguo/utils/PageUtils.java @@ -0,0 +1,151 @@ +package com.tamguo.utils; + +import java.util.ArrayList; +import java.util.List; + +import com.baomidou.mybatisplus.plugins.Page; + +public class PageUtils { + + // 是否下一页按钮 + private Boolean isShowNextBtn = false; + + // 是否上一页按钮 + private Boolean isShowPreBtn = false; + + // 当前页 + private String currPageNum; + + // 页码列表 + private List pageNums; + + // 总页数 + private String totalPage; + + // 总数量 + private String total; + + // 数据 + private List list; + + public static PageUtils getPage(Page page){ + PageUtils pg = new PageUtils(); + if(page.getCurrent() > 1){ + pg.setIsShowPreBtn(true); + } + if(page.getCurrent() < page.getPages()){ + pg.setIsShowNextBtn(true); + } + List pgNums = new ArrayList<>(); + if(page.getPages() > 1){ + if(page.getPages() > 10){ + pgNums.add("1"); + pgNums.add("2"); + pgNums.add("3"); + pgNums.add("..."); + if(page.getCurrent() == page.getPages()){ + pgNums.add(((Integer)(page.getCurrent() - 2)).toString()); + pgNums.add(((Integer)(page.getCurrent() - 1)).toString()); + pgNums.add(((Integer)page.getCurrent()).toString()); + }else{ + pgNums.add(((Integer)(page.getCurrent() - 1)).toString()); + pgNums.add(((Integer)page.getCurrent()).toString()); + pgNums.add(((Integer)(page.getCurrent() + 1)).toString()); + } + }else{ + Integer n = 1; + if(page.getTotal() > 0){ + while(true){ + pgNums.add(n.toString()); + if(n >= page.getPages()){ + break; + } + n ++; + } + } + } + } else { + Integer n = 1; + if(page.getTotal() > 0){ + while(true){ + pgNums.add(n.toString()); + if(n >= page.getPages()){ + break; + } + n ++; + } + } + } + pg.setPageNums(pgNums); + pg.setList(page.getRecords()); + pg.setCurrPageNum(((Integer)page.getCurrent()).toString()); + pg.setTotal(((Integer)page.getTotal()).toString()); + pg.setTotalPage(((Integer)page.getPages()).toString()); + return pg; + } + + + public Boolean getIsShowNextBtn() { + return isShowNextBtn; + } + + public void setIsShowNextBtn(Boolean isShowNextBtn) { + this.isShowNextBtn = isShowNextBtn; + } + + public List getPageNums() { + return pageNums; + } + + public void setPageNums(List pageNums) { + this.pageNums = pageNums; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + + public Boolean getIsShowPreBtn() { + return isShowPreBtn; + } + + + public void setIsShowPreBtn(Boolean isShowPreBtn) { + this.isShowPreBtn = isShowPreBtn; + } + + + public String getCurrPageNum() { + return currPageNum; + } + + + public void setCurrPageNum(String currPageNum) { + this.currPageNum = currPageNum; + } + + + public String getTotalPage() { + return totalPage; + } + + + public void setTotalPage(String totalPage) { + this.totalPage = totalPage; + } + + + public String getTotal() { + return total; + } + + + public void setTotal(String total) { + this.total = total; + } +} \ No newline at end of file diff --git a/tamguo-tms/src/main/java/com/tamguo/web/tiku/PaperController.java b/tamguo-tms/src/main/java/com/tamguo/web/tiku/PaperController.java new file mode 100644 index 0000000..c7bd29c --- /dev/null +++ b/tamguo-tms/src/main/java/com/tamguo/web/tiku/PaperController.java @@ -0,0 +1,119 @@ +package com.tamguo.web.tiku; + +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +import com.baomidou.mybatisplus.mapper.Condition; +import com.baomidou.mybatisplus.plugins.Page; +import com.tamguo.common.utils.SystemConstant; +import com.tamguo.modules.sys.model.SysAreaEntity; +import com.tamguo.modules.sys.service.ISysAreaService; +import com.tamguo.modules.tiku.model.CourseEntity; +import com.tamguo.modules.tiku.model.PaperEntity; +import com.tamguo.modules.tiku.model.SubjectEntity; +import com.tamguo.modules.tiku.service.ICourseService; +import com.tamguo.modules.tiku.service.IPaperService; +import com.tamguo.modules.tiku.service.IQuestionService; +import com.tamguo.modules.tiku.service.ISubjectService; +import com.tamguo.utils.PageUtils; + +/** + * Controller - 试卷 + * + * @author candy.tam + * + */ +@Controller +public class PaperController { + + @Autowired + private ICourseService iCourseService; + @Autowired + private ISysAreaService iSysAreaService; + @Autowired + private IPaperService iPaperService; + @Autowired + private IQuestionService iQuestionService; + @Autowired + private ISubjectService iSubjectService; + + @SuppressWarnings("unchecked") + @RequestMapping(value = {"paperlist/{subjectId}-{courseId}-{paperType}-{year}-{area}-{pageNum}.html"}, method = RequestMethod.GET) + public ModelAndView indexAction(@PathVariable String subjectId , @PathVariable String courseId , @PathVariable String paperType, + @PathVariable String year , @PathVariable String area , @PathVariable Integer pageNum, ModelAndView model) { + try { + model.setViewName("paperlist"); + + CourseEntity course = iCourseService.selectById(courseId); + List courseList = iCourseService.selectList(Condition.create().eq("subject_id", subjectId)); + SubjectEntity subject = iSubjectService.selectById(subjectId); + List areaList = iSysAreaService.selectList(Condition.create().eq("tree_level", "0")); + + Page page = new Page<>(pageNum , 10); + Condition condition = Condition.create(); + if(!StringUtils.isEmpty(subjectId) && !"0".equals(subjectId)) { + condition.eq("subject_id", subjectId); + } + if(!StringUtils.isEmpty(paperType) && !"0".equals(paperType)) { + condition.eq("type", paperType); + } + if(!StringUtils.isEmpty(year) && !"0".equals(year)) { + condition.eq("year", year); + } + if(!StringUtils.isEmpty(area) && !"0".equals(area)) { + condition.eq("area_id", area); + } + PageUtils result = PageUtils.getPage(iPaperService.selectPage(page , condition)); + if(courseList.size() > 0) { + course = courseList.get(0); + } + Integer total = iPaperService.selectCount(Condition.EMPTY); + model.addObject("courseList", courseList); + model.addObject("subject", subject); + model.addObject("course", course); + model.addObject("areaList", areaList); + model.addObject("paperPage" , result); + model.addObject("total" , total); + model.addObject("courseId", courseId); + model.addObject("paperType", paperType); + model.addObject("year", year); + model.addObject("area", area); + return model; + } catch (Exception e) { + model.setViewName("404"); + return model; + } + + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = {"/paper/{paperId}.html"}, method = RequestMethod.GET) + public ModelAndView indexAction(@PathVariable String paperId , ModelAndView model){ + try { + model.setViewName("paper"); + PaperEntity paper = iPaperService.selectById(paperId); + model.addObject("paper", paper); + model.addObject("subject", StringUtils.isEmpty(paper.getSubjectId()) ? null : iSubjectService.selectById(paper.getSubjectId())); + model.addObject("course", StringUtils.isEmpty(paper.getCourseId()) ? null : iCourseService.selectById(paper.getCourseId())); + model.addObject("questionList", iQuestionService.selectList(Condition.create().eq("paper_id", paperId))); + + // 获取推荐试卷 + model.addObject("zhentiPaperList", iPaperService.selectList(Condition.create().eq("subject_id", paper.getSubjectId()).eq("type",SystemConstant.ZHENGTI_PAPER_ID))); + model.addObject("moniPaperList", iPaperService.selectList(Condition.create().eq("subject_id", paper.getSubjectId()).eq("type",SystemConstant.MONI_PAPER_ID))); + model.addObject("yatiPaperList", iPaperService.selectList(Condition.create().eq("subject_id", paper.getSubjectId()).eq("type",SystemConstant.YATI_PAPER_ID))); + model.addObject("hotPaperList", iPaperService.selectList(Condition.create().eq("subject_id", paper.getSubjectId()).eq("course_id", paper.getCourseId()))); + return model; + } catch (Exception e) { + model.setViewName("404"); + return model; + } + + } + +} diff --git a/tamguo-tms/src/main/java/com/tamguo/web/tiku/QuestionContrller.java b/tamguo-tms/src/main/java/com/tamguo/web/tiku/QuestionContrller.java new file mode 100644 index 0000000..482a6b0 --- /dev/null +++ b/tamguo-tms/src/main/java/com/tamguo/web/tiku/QuestionContrller.java @@ -0,0 +1,99 @@ +package com.tamguo.web.tiku; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; + +import com.baomidou.mybatisplus.mapper.Condition; +import com.baomidou.mybatisplus.plugins.Page; +import com.tamguo.common.utils.Result; +import com.tamguo.modules.tiku.model.ChapterEntity; +import com.tamguo.modules.tiku.model.CourseEntity; +import com.tamguo.modules.tiku.model.QuestionEntity; +import com.tamguo.modules.tiku.model.SubjectEntity; +import com.tamguo.modules.tiku.service.IChapterService; +import com.tamguo.modules.tiku.service.ICourseService; +import com.tamguo.modules.tiku.service.IQuestionService; +import com.tamguo.modules.tiku.service.ISubjectService; + +@Controller +public class QuestionContrller { + + @Autowired + private IQuestionService iQuestionService; + @Autowired + private IChapterService iChapterService; + @Autowired + private ISubjectService iSubjectService; + @Autowired + private ICourseService iCourseService; + + @SuppressWarnings("unchecked") + @RequestMapping(value = {"questionlist/{chapterId}-{offset}-{limit}"}, method = RequestMethod.GET) + public ModelAndView questionList(@PathVariable String chapterId , @PathVariable Integer offset , + @PathVariable Integer limit , ModelAndView model){ + try { + model.setViewName("questionList"); + + ChapterEntity chapter = iChapterService.selectById(chapterId); + CourseEntity course = iCourseService.selectById(chapter.getCourseId()); + SubjectEntity subject = iSubjectService.selectById(course.getSubjectId()); + ChapterEntity parentChapter = iChapterService.selectById(chapter.getParentId()); + ChapterEntity nextChapter = iChapterService.selectById(chapter.getParentId()); + + Page page = new Page<>(); + page.setCurrent(offset); + page.setSize(limit); + Page questionList = iQuestionService.selectPage(page , Condition.create().eq("chapter_id", chapterId)); + model.addObject("subject", subject); + model.addObject("course", course); + model.addObject("chapter", chapter); + model.addObject("parentChapter" , parentChapter); + model.addObject("nextChapter" , nextChapter); + model.addObject("questionList", questionList); + model.addObject("subjectId", course.getSubjectId()); + model.addObject("courseId", course.getId()); + return model; + } catch (Exception e) { + model.setViewName("404"); + return model; + } + + } + + /** + * 直接访问题目 + * @param uid + * @param model + * @return + */ + @SuppressWarnings("unchecked") + @RequestMapping(value = {"/question/{uid}.html"}, method = RequestMethod.GET) + public ModelAndView question(@PathVariable String uid , ModelAndView model){ + try { + model.setViewName("question"); + QuestionEntity question = iQuestionService.selectById(uid); + question.setQuestionType(question.getQuestionType()); + model.addObject("question", question); + + // 推荐试题 + model.addObject("featuredQuestionList", iQuestionService.selectList(Condition.create().eq("subject_id", question.getSubjectId()).eq("course_id", question.getCourseId()))); + return model; + } catch (Exception e) { + model.setViewName("404"); + return model; + } + + } + + @RequestMapping(value = {"question/getQuestion/{uid}"}, method = RequestMethod.GET) + @ResponseBody + public Result getQuestion(@PathVariable String uid , ModelAndView model){ + return Result.successResult(iQuestionService.selectById(uid)); + } + +} diff --git a/tamguo-tms/src/main/resources/templates/index.html b/tamguo-tms/src/main/resources/templates/index.html index 265bfa3..20dcb5e 100644 --- a/tamguo-tms/src/main/resources/templates/index.html +++ b/tamguo-tms/src/main/resources/templates/index.html @@ -107,14 +107,14 @@

试卷资源 一考知底,高分必刷,全面提分 当前位置: - 更多地区 > + 更多地区 >

历年真题 - 更多真题试卷 > + 更多真题试卷 >

- 探果题库 + 探果题库 - 社会工作师 + 社会工作师 - 综合能力(中级) + 综合能力(中级) 中国社会工作在不同发展阶段的特点
@@ -212,7 +212,7 @@ - - - + + + diff --git a/tamguo-tms/src/main/resources/templates/paperlist.html b/tamguo-tms/src/main/resources/templates/paperlist.html index 83ef097..5017982 100644 --- a/tamguo-tms/src/main/resources/templates/paperlist.html +++ b/tamguo-tms/src/main/resources/templates/paperlist.html @@ -5,13 +5,13 @@ 探果题库_聪明的学生都在这里 - - - - - - - + + + + + + + @@ -24,24 +24,24 @@ @@ -119,11 +119,11 @@ 地区: @@ -135,8 +135,8 @@
全部试卷
@@ -159,15 +159,15 @@ @@ -190,8 +190,8 @@
- 探果题库 > - 高考 + 探果题库 > + 高考 理科数学
@@ -205,6 +205,6 @@ - - + + diff --git a/tamguo-tms/src/main/resources/templates/question.html b/tamguo-tms/src/main/resources/templates/question.html index 60d648b..ccdd8df 100644 --- a/tamguo-tms/src/main/resources/templates/question.html +++ b/tamguo-tms/src/main/resources/templates/question.html @@ -7,13 +7,13 @@ - - - - - - - + + + + + + + @@ -47,7 +47,7 @@

相关例题

@@ -127,6 +127,6 @@ - - + +