Esempio n. 1
0
  public String search() {
    // 类型
    List<Coursetypeinfo> typeList = coursetypeinfoService.findAllType();
    ServletActionContext.getRequest().setAttribute("typeList", typeList);
    Userinfo userinfo = this.getSessionUser();
    if (userinfo == null) return "success";
    userId = userinfo.getUserId();
    List<Studyrecordinfo> list = new ArrayList<Studyrecordinfo>();
    if (courseType != null && !"".equals(courseType.trim()))
      courseType =
          coursetypeinfoService
              .findByCourseTypeId(Integer.parseInt(courseType))
              .get(0)
              .getCourseType();
    //	System.out.println(courseType+"::"+courseName);
    if (courseName.equals("") && courseType.equals("")) {
      list = usercourseinfoService.getlastCourse(userId);
    } else if (courseName.equals("") && !courseType.equals("")) {
      list = usercourseinfoService.getlastCourseByCourseType(courseType, userId);
    } else if (!courseName.equals("") && courseType.equals("")) {

      list = usercourseinfoService.getlastCourseByCourseName(courseName, userId);
    } else {
      list = usercourseinfoService.getlastCourseByAll(courseName, courseType, userId);
    }
    List<Studyrecordinfo> end = new ArrayList<Studyrecordinfo>();
    if (list != null) {
      dataCount = list.size();
    } else {
      dataCount = 0;
      infolist = null;
      end = null;
    }
    all = dataCount;
    // System.out.println(":::"+usercourseinfoService.getStudyRecord(userId).get(0).getCourseName());
    if (pageStart == null || pageStart <= 0) {
      pageStart = 1;
    }
    page = new Page(dataCount, pageStart);
    if (pageStart > page.getPageCount()) {
      pageStart = page.getPageCount();
      page = new Page(dataCount, pageStart);
    }
    int lenth = ((pageStart - 1) * page.getPageRecordNum() + page.getPageRecordNum());
    if (dataCount == 0) {
      infolist = null;
    } else {
      if (dataCount > lenth) {
        //		System.out.println((pageStart -1 ) * page.getPageRecordNum()+","+ ((pageStart -1 ) *
        // page.getPageRecordNum()+page.getPageRecordNum())+":::");
        infolist = list.subList((pageStart - 1) * page.getPageRecordNum(), lenth);
      } else infolist = list.subList((pageStart - 1) * page.getPageRecordNum(), dataCount);
      //	System.out.println(infolist.get(0).getCourseName());
      if (dataCount % 10 == 0) dataCount = dataCount / 10;
      else dataCount = dataCount / 10 + 1;
    }
    return "success";
  }
Esempio n. 2
0
  public String execute() {

    Userinfo userinfo = this.getSessionUser();
    if (userinfo == null) return "success";
    userId = userinfo.getUserId();
    List<Studyrecordinfo> list = usercourseinfoService.getlastCourse(userId);
    if (list != null) {
      dataCount = list.size();
    } else {
      dataCount = 0;
      infolist = null;
    }
    all = dataCount;
    // System.out.println(":::"+usercourseinfoService.getStudyRecord(userId).get(0).getCourseName());
    if (pageStart == null || pageStart <= 0) {
      pageStart = 1;
    }
    page = new Page(dataCount, pageStart);
    if (pageStart > page.getPageCount()) {
      pageStart = page.getPageCount();
      page = new Page(dataCount, pageStart);
    }
    int lenth = ((pageStart - 1) * page.getPageRecordNum() + page.getPageRecordNum());
    if (dataCount == 0) {
      infolist = null;
    } else {
      if (dataCount > lenth) {
        //		System.out.println((pageStart -1 ) * page.getPageRecordNum()+","+ ((pageStart -1 ) *
        // page.getPageRecordNum()+page.getPageRecordNum())+":::");
        infolist = list.subList((pageStart - 1) * page.getPageRecordNum(), lenth);
      } else infolist = list.subList((pageStart - 1) * page.getPageRecordNum(), dataCount);
      System.out.println(infolist.get(0).getCourseName());
      if (dataCount % 10 == 0) dataCount = dataCount / 10;
      else dataCount = dataCount / 10 + 1;
    }
    List<Coursetypeinfo> typeList = coursetypeinfoService.findAllType();
    ServletActionContext.getRequest().setAttribute("typeList", typeList);
    return "success";
  }