You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.8 KiB
44 lines
1.8 KiB
package web.controller;
|
|
|
|
import db.model.bilibili.WordModel;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
import org.hibernate.criterion.Projections;
|
|
import org.hibernate.criterion.Restrictions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.orm.hibernate5.HibernateTransactionManager;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import java.util.List;
|
|
|
|
@Controller
|
|
@RequestMapping("/word")
|
|
public class WordController extends BiliController<WordModel> {
|
|
|
|
@Autowired
|
|
@Qualifier("Tweb.service.BiliService")
|
|
private HibernateTransactionManager hibernateTransactionManager;
|
|
|
|
@RequestMapping
|
|
public String list(@ModelAttribute WordModel queryCommand, @RequestParam(defaultValue = "0") int firstResult, @RequestParam(defaultValue = "0") int maxResults, Model model){
|
|
model.addAttribute("word",super.get(queryCommand, firstResult, maxResults));
|
|
List<String> courseNames=service.find(DetachedCriteria.forClass(WordModel.class).setProjection(Projections.groupProperty("courseName")));
|
|
model.addAttribute("courseNames",courseNames);
|
|
return "word/word";
|
|
}
|
|
|
|
@Override
|
|
protected DetachedCriteria getDetachedCriteria(WordModel queryCommand) {
|
|
if(StringUtils.isNotEmpty(queryCommand.getCourseName())){
|
|
return super.getDetachedCriteria(queryCommand).add(Restrictions.eq("courseName",queryCommand.getCourseName()));
|
|
}else{
|
|
return super.getDetachedCriteria(queryCommand);
|
|
}
|
|
|
|
}
|
|
}
|
|
|