-
Notifications
You must be signed in to change notification settings - Fork 319
Expand file tree
/
Copy pathChoiceQuestionSearchAction.java
More file actions
69 lines (60 loc) · 2.42 KB
/
ChoiceQuestionSearchAction.java
File metadata and controls
69 lines (60 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package cn.lynu.lyq.java_exam.actions;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionSupport;
import cn.lynu.lyq.java_exam.dao.BankQuestionDao;
import cn.lynu.lyq.java_exam.entity.BankChoiceQuestion;
@Component("choiceQuestionSearch")
@Scope("prototype")
@Data
public class ChoiceQuestionSearchAction extends ActionSupport{
private static final long serialVersionUID = -1106576639902301220L;
private final static Logger logger = LoggerFactory.getLogger(ChoiceQuestionSearchAction.class);
private String contentSearch;
private String choiceSearch;
private String answerSearch;
private String answerSearch2;//对于checkbox不选时,不提交的问题,做判断修正
private String knowledgeSearch;
private String CourseSearch;
private List<BankChoiceQuestion> questionList;
private int totalPage;
private int pageIndex;
private static final int PAGE_SIZE = 10;
@Resource
private BankQuestionDao bankQuestionDao;
public int[] choiceChecked;
@Override
public String execute() throws Exception {//初始结果
int totalCnt = bankQuestionDao.countAllChoice();
totalPage = (totalCnt%PAGE_SIZE > 0)?(totalCnt/PAGE_SIZE+1):(totalCnt/PAGE_SIZE);
questionList = bankQuestionDao.findAllChoiceWithPage(pageIndex,PAGE_SIZE);
return SUCCESS;
}
public String executeForSearch(){//搜索后结果
if(answerSearch2!=null && answerSearch2.equals("")){//对于checkbox不选时,不提交的问题,做判断修正
answerSearch = "";
}
logger.debug("contentSearch="+contentSearch);
logger.debug("choiceSearch="+choiceSearch);
logger.debug("answerSearch="+answerSearch);
logger.debug("answerSearch2="+answerSearch2);
logger.debug("knowledgeSearch="+knowledgeSearch);
logger.debug("CourseSearch", CourseSearch);
questionList = bankQuestionDao.findChoiceForSearch(contentSearch,choiceSearch,answerSearch,knowledgeSearch);
return SUCCESS;
}
public String deleteQuestion(){
// bankQuestionDao.delete(bankQuestionDao.findJudgeById(1))
for (int cid:choiceChecked){
logger.info("删除id为"+cid+"的选择题");
bankQuestionDao.delete(bankQuestionDao.findChoiceById(cid));
}
return SUCCESS;
}
}