Commit 80042797 authored by chenjb's avatar chenjb

初始化提交

parents
Pipeline #462 canceled with stages
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>bas-cloud-exam</artifactId>
<groupId>com.ekingwin</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bas-cloud-exam-api</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<artifactId>persistence-api</artifactId>
<groupId>javax.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--使用feign进行get请求时,Get请求被重置为了POST请求导致405问题;
使用 github 的 feign-httpclient 替换 feign默认的httpclient-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>bas-cloud-exam</artifactId>
<groupId>com.ekingwin</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bas-cloud-exam-impl</artifactId>
<dependencies>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-oam-org-model</artifactId>
<version>${bas-oam.version}</version>
<exclusions>
<exclusion>
<artifactId>persistence-api</artifactId>
<groupId>javax.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-exam-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-infrastructure-test</artifactId>
<version>${bas.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.dao;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.mapper.BasMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface QuestionDao extends BasMapper<Question> {
int save(@Param("question") Question question);
List<Question> queryQuestionsBySubjectId(@Param("subjectId") String subjectId);
Question queryQuestionByTestIdAndID(@Param("testId") String testId, @Param("subjectId") String subjectId, @Param("id") String id);
int insertMyAnswer(@Param("answerId") String answerId, @Param("question") Question question);
List<Question> queryQuestionByTestId(@Param("testId") String testId);
List<Question> queryMyAnswerByTestIdAndAnswerBatch(@Param("testId") String testId,
@Param("answerBatch") String answerBatch, @Param("userId") String userId);
List<Question> queryQuestionByTestId(@Param("testId") String testId,
@Param("answerBatch") String answerBatch);
List<Question> queryAnswerByTestIdAndBatchAndUserId(@Param("userId") String userId,
@Param("testId") String testId, @Param("answerBatch") String answerBatch);
int deleteQuestionTest(@Param("testId") String testId);
String getCnnameByEmpuid(@Param("currentUser") String currentUser);
void deleteBySubjectId(@Param("subjectId") String subjectId);
int insertQuestion(@Param("questionTestId") String questionTestId, @Param("question") Question question);
}
package com.ekingwin.bas.cloud.exam.dao;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.mapper.BasMapper;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
public interface ScoreDao extends BasMapper<Score> {
int insertScore(@Param("scoreInfo") Score scoreInfo);
List<Score> queryDoneTestByUserId(@Param("userId") String userId);
List<Score> queryScore(@Param("example") Example example);
}
package com.ekingwin.bas.cloud.exam.dao;
import com.ekingwin.bas.cloud.exam.dto.QuerySubjectVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Subject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SubjectDao {
int save(@Param("subject") Subject subject);
int delete(@Param("id") String id);
List<Subject> query(@Param("querySubjectVO") QuerySubjectVO querySubjectVO);
int updateSubjectInfo(@Param("subject") Subject subject);
int verify(@Param("querySubjectVO") QuerySubjectVO querySubjectVO);
}
package com.ekingwin.bas.cloud.exam.dao;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.mapper.BasMapper;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
public interface TestPaperDao extends BasMapper<TestPapers> {
int insertTest(@Param("test") TestPapers test);
List<TestPapers> queryUndoTestByUserId(@Param("userId") String userId);
List<TestPapers> queryDoneTestByUserid(@Param("userId") String userId);
TestPapers queryTestByTestId(@Param("testId") String testId);
TestPapers queryTestByTestIdAndBatchAndUserId(@Param("userId") String userId, @Param("testId") String testId, @Param("answerBatch") String answerBatch);
int deleteTestPapers(@Param("testId") String testId);
List<TestPapers> selectTestPapers(@Param("example") Example example);
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dao.QuestionDao;
import com.ekingwin.bas.cloud.exam.dao.ScoreDao;
import com.ekingwin.bas.cloud.exam.dao.TestPaperDao;
import com.ekingwin.bas.cloud.exam.dto.ScoreToBpm;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.infra.utils.web.UserUtils;
import com.ekingwin.bas.cloud.org.dto.OrgTreeDto;
import com.ekingwin.bas.cloud.org.manager.IOrganizationManager;
import com.google.common.base.Splitter;
import com.google.common.collect.Maps;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Primary
@Service
public class AnswerServiceImpl implements AnswerService {
@Override
@Transactional
public Map<String, Object> checkAndSaveAnswer(TestPapers test) {
Map<String, Object> map = Maps.newHashMap();
int score = 0;
int count = 0;
String currentUser = UserUtils.getCurrentUser();
//String deptName = questionDao.getDeptName(currentUser);
//获取word模板数据
String post = ""; //岗位名称
String line = ""; //所在条线
String deptName = ""; // 朗基集团总部-控股集团总部-管理信息条线-数据流程中心-软件研发主管
List<OrgTreeDto> treelist = organizationManager.findUserMainOrgWithFlat(currentUser);
for (OrgTreeDto treeDto : treelist) {
if ("3".equals(treeDto.getType())) {
post = treeDto.getName();
} else if ("2".equals(treeDto.getType())) {
line = treeDto.getName();
break;
}
}
deptName = post;
if (deptName.length() > 1) {
deptName += "-" + line;
} else {
deptName = line;
}
String cnname = questionDao.getCnnameByEmpuid(currentUser);
test.setDepartment(deptName == null ? "" : deptName);
// 答题批次
String answerBatch = UUID.randomUUID().toString().replace("-", "");
String testId = test.getTestId();
Integer passScore = testPaperDao.queryTestByTestId(testId).getPassScore();
List<Question> questions = test.getQuestions();
for (Question question : questions) {
// 查询试卷题库对应的试题
Question s = questionDao.queryQuestionByTestIdAndID(testId, question.getSubjectId(), question.getId());
long type = s.getType();
if (1 == type || 3 == type) {
// 比较答案是否一致
if (question.getAnswer().equals(s.getAnswer())) {
score += s.getSingleScore();
question.setSingleScore(s.getSingleScore());
question.setCorrect(1);
} else {
question.setSingleScore(0);
question.setCorrect(0);
}
question.setAnswerBatch(answerBatch);
question.setStuffId(currentUser);
question.setTestId(testId);
question.setCreateBy(currentUser);
// 保存至已答题库内
String answerid = UUID.randomUUID().toString().replace("-", "");
count += questionDao.insertMyAnswer(answerid, question);
}
if (2 == type) {
//提交答案
String answer1 = question.getAnswer();
List<String> list1 = Splitter.on("|").splitToList(answer1);
//标准答案
String answer2 = s.getAnswer();
List<String> list2 = Splitter.on("|").splitToList(answer2);
// 比较答案是否一致
if (list1.containsAll(list2)) {
score += s.getSingleScore();
question.setSingleScore(s.getSingleScore());
question.setCorrect(1);
} else {
question.setSingleScore(0);
question.setCorrect(0);
}
question.setAnswerBatch(answerBatch);
question.setStuffId(currentUser);
question.setTestId(testId);
question.setCreateBy(currentUser);
// 保存至已答题库内
String answerid = UUID.randomUUID().toString().replace("-", "");
count += questionDao.insertMyAnswer(answerid, question);
}
}
Date date = new Date();
// SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-DD HH:mm:ss");
Score scoreInfo = new Score();
// scoreInfo.setStuffId(currentUser);
scoreInfo.setBpmId(test.getBpmId());
scoreInfo.setStuffId(currentUser);
scoreInfo.setStuffName(cnname);
scoreInfo.setTestId(testId);
scoreInfo.setTestName(test.getTestName());
scoreInfo.setAnswerBatch(answerBatch);
scoreInfo.setScore(score);
scoreInfo.setDepartment(test.getDepartment());
//合格状态:0:不合格 1:合格
int qualified = 0;
if (score == 0) {
scoreInfo.setQualified(0);
} else {
if (score >= passScore) {
qualified = 1;
scoreInfo.setQualified(qualified);
} else {
scoreInfo.setQualified(qualified);
}
}
scoreInfo.setCreateTime(date);
// 保存分数信息
String scoreId = UUID.randomUUID().toString().replace("-", "");
scoreInfo.setId(scoreId.trim());
count += scoreDao.insertScore(scoreInfo);
if (!"bpadev".equals(profiles) && !"bpasanxia".equals(profiles) && !"bpajiucaiyun".equals(profiles)
&& !"sxdev".equals(profiles)) {
//推送到BPM
this.scoreToBpm(scoreInfo);
}
map.put("score", score);
map.put("qualified", qualified);
return map;
}
@Override
public String scoreToBpm(Score score) {
ScoreToBpm scoreToBpm = new ScoreToBpm();
//考试人部门
scoreToBpm.setBm(score.getDepartment());
//Bpm流程id
scoreToBpm.setBpaid(score.getBpmId());
//本次考试成绩
scoreToBpm.setCj(score.getScore() + "");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String data;
data = df.format(score.getCreateTime());
//考试结束试卷
scoreToBpm.setKssj(data);
//考生姓名
scoreToBpm.setXm(score.getStuffName());
//考生账号
scoreToBpm.setZh(score.getStuffId());
JSONObject json = JSONObject.fromObject(scoreToBpm);
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//拼写接口报文
RestTemplate restTemplate = new RestTemplate();
//向接口传递数据
//拼写好的报文提交
HttpEntity<JSONObject> he = new HttpEntity<JSONObject>(json, headers);
@SuppressWarnings("rawtypes")
ResponseEntity<Map> resultjson = restTemplate.exchange(scoreToBpmUrl, HttpMethod.POST, he, Map.class);
Map<String, String> result1 = resultjson.getBody();
System.out.println(result1);
} catch (RestClientException e) {
e.printStackTrace();
}
return null;
}
@Resource
private QuestionDao questionDao;
@Resource
private ScoreDao scoreDao;
@Resource
private TestPaperDao testPaperDao;
@Resource
protected IOrganizationManager organizationManager;
@Value("${ScoreToBpm}")
private String scoreToBpmUrl;
@Value("${spring.profiles.active}")
private String profiles;
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dao.QuestionDao;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.cloud.infra.utils.web.UserUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Primary
@Service
@Transactional
public class QuestionsServiceImpl implements QuestionsService {
@Override
public int addQuestions(List<Question> questions) {
int count = 0;
for (Question question : questions) {
// 添加选项前缀 A B C D A对应的ascii码为65
int startChar = 65;
String newContent = "";
String[] questionContents = question.getQuestionContent().split("\\|");
for (String questionContent : questionContents) {
questionContent = (char) startChar + "、" + questionContent;
newContent = newContent + questionContent + "|";
startChar++;
}
newContent = newContent.substring(0, newContent.length() - 1);
question.setQuestionContent(newContent);
String id = UUID.randomUUID().toString().replace("-", "");
question.setId(id);
Date date = new Date();
question.setCreateTime(date);
question.setCreateBy(UserUtils.getCurrentUser());
count += questionDao.save(question);
}
return count;
}
@Override
public int addQuestion(Question question, Boolean diy) {
// 添加选项前缀 A B C D A对应的ascii码为65
int startChar = 65;
String newContent = "";
String[] questionContents = question.getQuestionContent().split("\\|");
for (String questionContent : questionContents) {
if (BooleanUtils.isTrue(diy)) {
questionContent = (char) startChar + "、" + questionContent;
}
newContent = newContent + questionContent + "|";
startChar++;
}
newContent = newContent.substring(0, newContent.length() - 1);
question.setQuestionContent(newContent);
//如果是自定义试题存入未关联试卷的试题库
if (BooleanUtils.isTrue(diy)) {
String questionTestId = UUID.randomUUID().toString().replace("-", "");
question.setId(questionTestId.trim());
question.setCreateTime(new Date());
questionDao.save(question);
}
String questionTestId = UUID.randomUUID().toString().replace("-", "");
question.setCreateTime(new Date());
// 存入关联试卷的试题库
questionDao.insertQuestion(questionTestId, question);
return 0;
}
@Override
public int editQuestions(List<Question> questions) {
int count = 0;
if (questions != null && !questions.isEmpty()) {
for (Question question : questions) {
count += editQuestion(question);
}
}
return count;
}
@Override
public int editQuestion(Question question) {
// 添加选项前缀 A B C D A对应的ascii码为65
int startChar = 65;
String newContent = "";
String[] questionContents = question.getQuestionContent().split("\\|");
for (String questionContent : questionContents) {
questionContent = (char) startChar + "、" + questionContent;
newContent = newContent + questionContent + "|";
startChar++;
}
newContent = newContent.substring(0, newContent.length() - 1);
question.setQuestionContent(newContent);
return questionDao.updateByPrimaryKeySelective(question);
}
@Override
public PageInfo<Question> queryQuestionsBySubjectId(String subjectId, Integer startPage, Integer pageSize) {
PageHelper.startPage(startPage, pageSize);
List<Question> questions = questionDao.queryQuestionsBySubjectId(subjectId);
return new PageInfo<>(questions);
}
@Resource
private QuestionDao questionDao;
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dao.ScoreDao;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.infra.dto.QueryDTO;
import com.ekingwin.bas.cloud.infra.exception.BasException;
import com.ekingwin.bas.cloud.infra.service.BaseService;
import com.ekingwin.bas.cloud.infra.utils.db.PageCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
@Service
@Primary
public class ScoreServiceImpl extends BaseService implements ScoreService {
@Autowired
ScoreDao scoreDao;
/**
* 查询考试信息
*
* @param query
* @return
*/
@Override
public PageCriteria<Score> queryScoreInfo(QueryDTO query) throws BasException {
try {
Example example = buildQuery(query, Score.class);
return query(query, () -> scoreDao.queryScore(example), Score.class);
} catch (Exception e) {
throw new BasException(e.getMessage());
}
}
@Override
public boolean save(Score object) throws BasException {
return false;
}
@Override
public boolean delete(String id) throws BasException {
return false;
}
@Override
public PageCriteria<Score> query(QueryDTO query) throws BasException {
return null;
}
@Override
public Score get(String id) throws BasException {
return null;
}
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dao.SubjectDao;
import com.ekingwin.bas.cloud.exam.dto.QuerySubjectVO;
import com.ekingwin.bas.cloud.exam.dto.SubjectVerifyVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Subject;
import com.ekingwin.bas.cloud.infra.utils.web.UserUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Primary
@Service
public class SubjectServiceImpl implements SubjectService {
@Override
public int addSubject(Subject subject) {
Date date = new Date();
String id = UUID.randomUUID().toString().replace("-", "");
subject.setId(id.trim());
String user = UserUtils.getCurrentUser();
subject.setCreateBy(user);
subject.setCreateTime(date);
subject.setUpdateTime(date);
subject.setDelete(false);
return subjectDao.save(subject);
}
@Override
@Transactional
public int delSubjectById(String ids) {
int count = 0;
String[] id = ids.split(",");
for (String s : id) {
count = subjectDao.delete(s);
}
return count;
}
@Override
public PageInfo<Subject> querySubject(QuerySubjectVO querySubjectVO) {
PageHelper.startPage(querySubjectVO.getStartPage(), querySubjectVO.getPageSize());
List<Subject> subjects = subjectDao.query(querySubjectVO);
PageInfo<Subject> subjectPageInfo = new PageInfo(subjects);
return subjectPageInfo;
}
@Override
public int changeSubjectInfo(Subject subject) {
subject.setUpdateTime(new Date());
int res = subjectDao.updateSubjectInfo(subject);
return res;
}
@Override
public SubjectVerifyVO verify(Subject subject) {
SubjectVerifyVO subjectVerifyVO = new SubjectVerifyVO();
subjectVerifyVO.setSuccess(true);
if(StringUtils.isNotBlank(subject.getSubjectName())) {
QuerySubjectVO querySubjectVO = new QuerySubjectVO();
querySubjectVO.setSubjectId(subject.getId());
querySubjectVO.setSubjectName(subject.getSubjectName());
int namecount = subjectDao.verify(querySubjectVO);
if(namecount>0){
subjectVerifyVO.setSuccess(false);
subjectVerifyVO.setMsg("考试类型名称已存在");
}
}
if(StringUtils.isNotBlank(subject.getSubjectNo())) {
QuerySubjectVO querySubjectVO = new QuerySubjectVO();
querySubjectVO.setSubjectId(subject.getId());
querySubjectVO.setSubjectNo(subject.getSubjectNo());
int count = subjectDao.verify(querySubjectVO);
if(count>0){
subjectVerifyVO.setSuccess(false);
subjectVerifyVO.setMsg("考试类型编号已存在");
return subjectVerifyVO;
}
}
return subjectVerifyVO;
}
@Autowired
SubjectDao subjectDao;
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dao.QuestionDao;
import com.ekingwin.bas.cloud.exam.dao.ScoreDao;
import com.ekingwin.bas.cloud.exam.dao.TestPaperDao;
import com.ekingwin.bas.cloud.exam.dto.QueryTestVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.infra.dto.QueryDTO;
import com.ekingwin.bas.cloud.infra.exception.BasException;
import com.ekingwin.bas.cloud.infra.service.BaseService;
import com.ekingwin.bas.cloud.infra.utils.db.PageCriteria;
import com.ekingwin.bas.cloud.infra.utils.web.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.*;
@Primary
@Service
public class TestPaperServiceImpl extends BaseService implements TestPaperService {
/**
* 创建试卷
*
* @param test
* @return
*/
@Override
@Transactional
public int createTest(TestPapers test) {
String testId = UUID.randomUUID().toString().replace("-", "");
test.setTestId(testId.trim());
test.setIsDelete(false);
Date date = new Date();
test.setCreateTime(date);
String currentUser = UserUtils.getCurrentUser();
test.setCreateBy(currentUser);
int totalScore = 0;
List<Question> questions = test.getQuestions();
for (Question question : questions) {
question.setTestId(test.getTestId());
question.setSubjectId(test.getSubjectId());
question.setCreateBy(currentUser);
questionsService.addQuestion(question, test.getDIY());
totalScore += question.getSingleScore();
}
test.setTotalScore(totalScore);
return testPaperDao.insertTest(test);
}
@Override
public int editTest(TestPapers test) {
// 先删后增
questionDao.deleteQuestionTest(test.getTestId());
questionDao.deleteBySubjectId(test.getSubjectId());
String currentUser = UserUtils.getCurrentUser();
test.setCreateBy(currentUser);
int totalScore = 0;
List<Question> questions = test.getQuestions();
for (Question question : questions) {
question.setTestId(test.getTestId());
question.setSubjectId(test.getSubjectId());
question.setCreateBy(currentUser);
questionsService.editQuestion(question);
totalScore += question.getSingleScore();
}
test.setTotalScore(totalScore);
return testPaperDao.updateByPrimaryKeySelective(test);
}
/**
* 查找所有试卷
*
* @return
*/
@Override
@Transactional
public List<TestPapers> queryMyAllTest() {
ArrayList<TestPapers> tests = new ArrayList<>();
String userId = UserUtils.getCurrentUser();
// 查询未作试题
List<TestPapers> undoTests = testPaperDao.queryUndoTestByUserId(userId);
for (TestPapers undoTest : undoTests) {
undoTest.setDone(false);
// List<Question> questions = questionDao.queryQuestionByTestId(undoTest.getTestId());
// undoTest.setQuestions(questions);
}
// 查询已做试题
List<TestPapers> doneTests = new ArrayList<>();
List<Score> scoreInfos = scoreDao.queryDoneTestByUserId(userId);
for (Score scoreInfo : scoreInfos) {
TestPapers test = testPaperDao.queryTestByTestId(scoreInfo.getTestId());
if (test != null) {
test.setDone(true);
// List<Question> questions = questionDao.queryMyAnswerByTestIdAndAnswerBatch(scoreInfo.getTestId(), scoreInfo.getAnswerBatch(), userId);
// test.setQuestions(questions);
doneTests.add(test);
}
}
tests.addAll(undoTests);
tests.addAll(doneTests);
// 去重
Set<TestPapers> resultSet = new HashSet<>(tests);
tests = new ArrayList<>(resultSet);
return tests;
}
/**
* 查找具体试卷详细内容
*
* @param queryTestVO
* @return
*/
@Override
@Transactional
public TestPapers queryTestDetails(QueryTestVO queryTestVO) {
String userID = UserUtils.getCurrentUser();
List<Question> questions = null;
TestPapers testPapers = null;
// 是否已做
if (queryTestVO.getDone()) {
// 从已做试题库查询
testPapers = testPaperDao.queryTestByTestIdAndBatchAndUserId(userID, queryTestVO.getTestId(), queryTestVO.getAnswerBatch());
testPapers.setDone(true);
questions = questionDao.queryAnswerByTestIdAndBatchAndUserId(userID, queryTestVO.getTestId(), queryTestVO.getAnswerBatch());
} else {
// 从未做试题库查询
testPapers = testPaperDao.queryTestByTestId(queryTestVO.getTestId());
testPapers.setDone(false);
questions = questionDao.queryQuestionByTestId(queryTestVO.getTestId());
}
testPapers.setQuestions(questions);
return testPapers;
}
/**
* 删除试卷
*
* @param ids
* @return
*/
@Transactional
@Override
public int deleteTestPapers(String ids) {
String[] testIds = ids.split(",");
int count = 0;
for (String testId : testIds) {
count += testPaperDao.deleteTestPapers(testId);
count += questionDao.deleteQuestionTest(testId);
}
return count;
}
/**
* 条件查找试卷
*
* @param query
* @return
*/
@Override
public PageCriteria<TestPapers> queryTestPapers(QueryDTO query) throws BasException {
try {
Example example = buildQuery(query, TestPapers.class);
return query(query, () -> testPaperDao.selectTestPapers(example), TestPapers.class);
} catch (Exception e) {
throw new BasException(e.getMessage());
}
}
/**
* 查找试卷具体内容
*
* @param id
* @return
*/
@Override
public TestPapers getTestPapersDetailsInfo(String id) {
TestPapers testPapers = testPaperDao.queryTestByTestId(id);
if (null == testPapers) {
return null;
}
List<Question> questions = questionDao.queryQuestionByTestId(id);
testPapers.setQuestions(questions);
return testPapers;
}
@Override
public boolean save(TestPapers object) throws BasException {
return false;
}
@Override
public boolean delete(String id) throws BasException {
return false;
}
@Override
public PageCriteria<TestPapers> query(QueryDTO query) throws BasException {
return null;
}
@Override
public TestPapers get(String id) throws BasException {
return null;
}
@Resource
TestPaperDao testPaperDao;
@Resource
QuestionDao questionDao;
@Resource
ScoreDao scoreDao;
@Resource
private QuestionsService questionsService;
}
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.BackResult;
import com.ekingwin.bas.cloud.exam.dto.QueryTestVO;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.exam.service.AnswerService;
import com.ekingwin.bas.cloud.exam.service.TestPaperService;
import com.ekingwin.bas.cloud.infra.utils.web.WebUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@Api(tags = "答题接口")
@Controller
@RestController
@RequestMapping("/exam/answer")
public class AnswerController {
/**
* 答题
*/
@ApiOperation("提交试卷并计算分数")
@PostMapping("/answerTest")
public BackResult checkAndSaveAnswer(@RequestBody TestPapers test) {
// if (profiles.contains("longey")) {
// String userName = WebUtils.getRequest().getParameter("username");
// if (StringUtils.isBlank(userName)) {
// userName = (String) WebUtils.getRequest().getSession().getAttribute("ssoclientagent.user");
// }
// WebUtils.getRequest().getSession().setAttribute("userid", userName);
// }
if (test == null || test.getQuestions() == null) {
return new BackResult(400, "试卷为空");
}
Map<String, Object> res = answerService.checkAndSaveAnswer(test);
return new BackResult(200, "答题成功", res);
}
/**
* 查询我的试卷
*/
@ApiOperation("查找自己所有的试卷")
@GetMapping("/queryMyAllTest")
public BackResult queryMyAllTest() {
// if (profiles.contains("longey")) {
// String userName = WebUtils.getRequest().getParameter("username");
// if (StringUtils.isBlank(userName)) {
// userName = (String) WebUtils.getRequest().getSession().getAttribute("ssoclientagent.user");
// }
// WebUtils.getRequest().getSession().setAttribute("userid", userName);
// }
List<TestPapers> tests = testPaperService.queryMyAllTest();
return new BackResult(200, "", tests);
}
/**
* 查询试卷详细信息
*/
@ApiOperation("试卷详细信息")
@PostMapping("/queryTestDetails")
public BackResult queryTestDetails(@RequestBody QueryTestVO queryTestVO, @RequestParam(required = false) String username) {
// if (profiles.contains("longey")) {
// String userName = WebUtils.getRequest().getParameter("username");
// if (StringUtils.isBlank(userName)) {
// userName = (String) WebUtils.getRequest().getSession().getAttribute("ssoclientagent.user");
// }
// WebUtils.getRequest().getSession().setAttribute("userid", userName);
// }
if (queryTestVO == null) {
return new BackResult(400, "查询条件为空");
}
TestPapers test = testPaperService.queryTestDetails(queryTestVO);
return new BackResult(200, "", test);
}
@Autowired
AnswerService answerService;
@Autowired
TestPaperService testPaperService;
// @Value("${spring.profiles.active}")
// private String profiles;
}
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.BackResult;
import com.ekingwin.bas.cloud.exam.dto.QuestionVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.cloud.exam.service.QuestionsService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(tags = "试题接口")
@Controller
@RestController
@RequestMapping("/exam/question")
public class QuestionController {
/**
* 添加试题
*/
@ApiOperation("添加试题")
@PostMapping("/addQuestions")
public BackResult addQuestions(@RequestBody QuestionVO questionVO) {
if (questionVO == null) {
return new BackResult(400, "传入数据为空", null);
}
List<Question> questions = questionVO.getQuestions();
int res = questionsService.addQuestions(questions);
if (res > 0) {
return new BackResult(200, "添加成功", null);
}
return new BackResult(200, "添加失败", null);
}
/**
* 根据科目选择试题
*/
@ApiOperation("根据科目获取试题")
@GetMapping("/queryQuestions/{subjectId}/{startPage}/{pageSize}")
public BackResult queryQuestionsBySubjectId(@PathVariable("subjectId") String subjectId,
@PathVariable("startPage") Integer startPage,
@PathVariable("pageSize") Integer pageSize) {
PageInfo<Question> questions = questionsService.queryQuestionsBySubjectId(subjectId, startPage, pageSize);
return new BackResult(200, "获取成功", questions);
}
/**
* 修改试题
*/
@ApiOperation("修改试题")
@PostMapping("/editQuestions")
public BackResult editQuestions(@RequestBody QuestionVO questionVO) {
if (questionVO == null) {
return new BackResult(400, "传入数据为空", null);
}
List<Question> questions = questionVO.getQuestions();
int res = questionsService.editQuestions(questions);
if (res > 0) {
return new BackResult(200, "修改成功", null);
}
return new BackResult(200, "修改失败", null);
}
@Autowired
QuestionsService questionsService;
}
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.BackResult;
import com.ekingwin.bas.cloud.exam.dto.QuerySubjectVO;
import com.ekingwin.bas.cloud.exam.dto.SubjectVerifyVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Subject;
import com.ekingwin.bas.cloud.exam.service.SubjectService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Api(tags = "科目接口", description = "科目增删改查")
@Controller
@RequestMapping("/exam/subject")
@RestController
public class SubjectController {
/**
* 添加科目
*/
@ApiOperation("添加科目")
@PostMapping("/addSubject")
public BackResult addSubject(@RequestBody Subject subject, @RequestParam(required = false) String username) {
if (subject == null) {
return new BackResult(400, "添加数据为空", false);
}
//验证
SubjectVerifyVO subjectVerifyVO = subjectService.verify(subject);
if (!subjectVerifyVO.isSuccess()) {
return new BackResult(400, subjectVerifyVO.getMsg(), false);
}
int res = subjectService.addSubject(subject);
if (res > 0) {
return new BackResult(200, "添加成功", true);
}
return new BackResult(400, "添加失败", false);
}
/**
* 删除科目
*/
@ApiOperation("根据科目id批量删除")
@GetMapping("/delSubjectById")
public BackResult dleSubjectById(@RequestParam String ids) {
if (StringUtils.isBlank(ids)) {
return new BackResult(200, "删除失败", null);
}
int res = subjectService.delSubjectById(ids);
if (res > 0) {
return new BackResult(200, "删除成功", null);
}
return new BackResult(400, "删除失败", null);
}
/**
* 查找科目
*/
@ApiOperation("分页查找科目")
@PostMapping("/querySubject")
public BackResult querySubjectById(@RequestBody QuerySubjectVO querySubjectVO) {
if (querySubjectVO.getStartPage() == null) {
querySubjectVO.setStartPage(0);
}
if (querySubjectVO.getPageSize() == null || querySubjectVO.getPageSize() == 0) {
querySubjectVO.setPageSize(10);
}
PageInfo<Subject> subjects = subjectService.querySubject(querySubjectVO);
return new BackResult(200, "查询成功", subjects);
}
/**
* 修改科目信息
*
* @param subject
* @return
*/
@ApiOperation("修改科目信息")
@PostMapping("/changeSubjectInfo")
public BackResult changeSubjectInfo(@RequestBody Subject subject) {
if (subject == null) {
return new BackResult(400, false);
}
//验证
SubjectVerifyVO subjectVerifyVO = subjectService.verify(subject);
if (!subjectVerifyVO.isSuccess()) {
return new BackResult(400, subjectVerifyVO.getMsg(), false);
}
int res = subjectService.changeSubjectInfo(subject);
if (res > 0) {
return new BackResult(200, true);
}
return new BackResult(400, false);
}
@Autowired
private SubjectService subjectService;
}
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.BackResult;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.exam.service.ScoreService;
import com.ekingwin.bas.cloud.exam.service.TestPaperService;
import com.ekingwin.bas.cloud.infra.dto.QueryDTO;
import com.ekingwin.bas.cloud.infra.utils.db.PageCriteria;
import com.ekingwin.bas.cloud.infra.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Api(tags = "试卷接口")
@Controller
@RestController
@RequestMapping("/exam/test")
public class TestPaperController extends BaseController {
/**
* 创建试卷
*
* @return
*/
@ApiOperation("创建试卷")
@PostMapping("/createTest")
public BackResult createTest(@RequestBody TestPapers test) {
if (test == null || test.getQuestions() == null) {
return new BackResult(400, "创建试卷为空");
}
int res = testPaperService.createTest(test);
if (res > 0) {
return new BackResult(200, "创建试卷成功");
}
return new BackResult(400, "创建试卷失败");
}
/**
* 查看成绩
*
* @param query
* @return
*/
@ApiOperation("查看考试成绩")
@RequestMapping(value = "/queryScoreInfo", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public BackResult queryScoreInfo(@RequestBody(required = false) QueryDTO query) {
try {
PageCriteria<Score> result = scoreService.queryScoreInfo(query);
return BackResult.successResponse(200, "查询成功", result);
} catch (Exception e) {
e.printStackTrace();
return BackResult.successResponse(500, "查询失败", e.getMessage());
}
}
/**
* 删除试卷
*
* @param ids
* @return
*/
@ApiOperation("删除试卷")
@GetMapping("/deleteTestPapers/{ids}")
public BackResult deleteTestPapers(@PathVariable("ids") String ids) {
if (StringUtils.isBlank(ids)) {
return new BackResult(400, "删除数据不能为空");
}
int res = testPaperService.deleteTestPapers(ids);
if (res > 0) {
return new BackResult(200, "删除成功");
}
return new BackResult(400, "删除失败");
}
/**
* 条件查询试卷
*
* @param query
* @return
*/
@ApiOperation("查询试卷")
@PostMapping(value = "/queryTestPapers", produces = "application/json;charset=UTF-8")
public BackResult queryTestPapers(@RequestBody(required = false) QueryDTO query) {
try {
PageCriteria<TestPapers> testPapersPageInfo = testPaperService.queryTestPapers(query);
return BackResult.successResponse(200, "查询成功", testPapersPageInfo);
} catch (Exception e) {
e.printStackTrace();
return BackResult.successResponse(500, "查询失败", e.getMessage());
}
}
@ApiOperation("根据试卷id查询关联的试题")
@GetMapping("/getTestPapersDetailsInfo/{id}")
public BackResult getTestPapersDetailsInfo(@PathVariable("id") String id) {
if (StringUtils.isBlank(id)) {
return new BackResult(400, "查询数据不能为空");
}
TestPapers testPapers = testPaperService.getTestPapersDetailsInfo(id);
if (null != testPapers) {
return new BackResult(200, "查询成功", testPapers);
} else {
return new BackResult(500, "未查询到数据");
}
}
/**
* 修改试卷
*
* @return
*/
@ApiOperation("修改试卷")
@PostMapping("/editTest")
public BackResult editTest(@RequestBody TestPapers test) {
if (test == null || test.getQuestions() == null) {
return new BackResult(400, "修改试卷为空");
}
for (int i = 0; i < test.getQuestions().size(); i++) {
if (test.getQuestions().get(i).getAnswer() == null || test.getQuestions().get(i).getAnswer().length() == 0) {
return new BackResult(400, "请填写试卷参考答案");
}
if (test.getQuestions().get(i).getSingleScore() == 0) {
return new BackResult(400, "请填写试卷分数");
}
}
int res = testPaperService.editTest(test);
if (res > 0) {
return new BackResult(200, "修改试卷成功");
}
return new BackResult(400, "修改试卷失败");
}
@Autowired
private TestPaperService testPaperService;
@Autowired
private ScoreService scoreService;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ekingwin.bas.cloud.exam.dao.QuestionDao" >
<insert id="save">
insert into bas_exam_question values (#{question.id},#{question.questionTitle},#{question.questionContent},#{question.answer},#{question.singleScore},
#{question.createTime},#{question.createBy},#{question.delete},#{question.subjectId},#{question.type})
</insert>
<select id="queryQuestionsBySubjectId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Question">
SELECT
*
FROM
(
SELECT
q.id AS id,
q.QUESTION_TITLE AS questionTitle,
q.QUESTION_CONTENT AS questionContent,
q.ANSWER AS answer,
q.SINGLE_SCORE AS singleScore,
q.CREATE_TIME AS createTime,
q.CREATE_BY AS createBy,
q.TYPE AS TYPE,
q.ISDELETE AS isDelete,
q.SUBJECT_ID AS subjectId,
s.SUBJECT_NAME AS belongSubject
FROM
bas_exam_question q left join bas_exam_subject s ON q.subject_id = s.id
) a
WHERE
a.subjectId = #{subjectId}
AND a.ISDELETE=0
</select>
<select id="queryQuestionByTestIdAndID" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Question">
select * from bas_exam_question_test where test_id=#{testId} and subject_id=#{subjectId} and id=#{id} and isdelete = 0
</select>
<insert id="insertMyAnswer">
insert into bas_exam_answer values (#{answerId},#{question.testId},#{question.stuffId},#{question.answerBatch},#{question.id},#{question.questionTitle},
#{question.questionContent},#{question.answer},#{question.singleScore},#{question.type},#{question.correct})
</insert>
<update id="deleteQuestionTest">
update BAS_EXAM_QUESTION_TEST set ISDELETE=1 where TEST_ID=#{testId}
</update>
<select id="queryMyAnswerByTestIdAndAnswerBatch" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Question">
select * from bas_exam_answer where test_id=#{testId} and answer_batch=#{answerBatch} and stuff_id=#{userId}
</select>
<select id="queryQuestionByTestId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Question">
select
ID AS id,
TEST_ID AS testId,
QUESTION_TITLE as questionTitle,
QUESTION_CONTENT as questionContent,
ANSWER as answer,
SINGLESCORE as singleScore,
CREATE_TIME as createTime,
CREATE_BY as createBy,
ISDELETE AS isDelete,
TYPE as type,
SUBJECT_ID as subjectId
from
bas_exam_question_test
where test_id=#{testId} and isdelete =0
</select>
<select id="queryAnswerByTestIdAndBatchAndUserId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Question">
select a.TEST_ID as testId,
a.STUFF_ID as stuffId,
a.ANSWER_BATCH as answerBatch,
a.QUESTION_ID as questionId,
a.QUESTION_TITLE as questionTitle,
a.QUESTION_CONTENT as questionContent,
a.MY_ANSWER as answer,
a.MY_SCORE as score,
a.TYPE as type,
a.CORRECT as correct from bas_exam_answer a where a.stuff_id=#{userId} and a.test_id=#{testId} and a.answer_batch=#{answerBatch}
</select>
<select id="getCnnameByEmpuid" resultType="java.lang.String">
select cnname from employee where empuid = #{currentUser}
</select>
<update id="deleteBySubjectId">
update BAS_EXAM_QUESTION set ISDELETE=1 where SUBJECT_ID=#{subjectId}
</update>
<insert id="insertQuestion">
insert into bas_exam_question_test values (
#{question.testId},#{question.questionTitle},#{question.questionContent},
#{question.answer},#{question.singleScore}, #{question.createTime},#{question.createBy},
#{question.isDelete},#{question.subjectId},#{question.type},#{questionTestId},#{question.id})
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ekingwin.bas.cloud.exam.dao.ScoreDao" >
<insert id="insertScore">
insert into bas_exam_score values (#{scoreInfo.id},#{scoreInfo.stuffId},#{scoreInfo.stuffName},#{scoreInfo.testId},#{scoreInfo.testName},
#{scoreInfo.answerBatch},#{scoreInfo.score},#{scoreInfo.qualified},#{scoreInfo.createTime},#{scoreInfo.department})
</insert>
<select id="queryDoneTestByUserId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Score">
SELECT
ID,
STUFF_ID AS stuffId,
STUFF_NAME AS stuffName,
TEST_ID AS testId,
TEST_NAME AS testName,
ANSWER_BATCH as answerBatch,
SCORE AS score,
QUALIFIED AS qualified,
CREATE_TIME AS createTime,
DEPARTMENT
FROM
bas_exam_score
WHERE
stuff_id=#{userId}
and CREATE_TIME in (
select max(CREATE_TIME) from bas_exam_score GROUP BY TEST_ID
)
</select>
<select id="queryScore" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Score">
select * from(
select
s.STUFF_ID AS stuffId,
s.STUFF_NAME AS stuffName,
s.TEST_ID AS testId,
s.TEST_NAME AS testName,
s.ANSWER_BATCH AS answerBatch,
s.SCORE AS score,
if(s.score>t.pass_score,1,0) AS qualified,
s.CREATE_TIME AS createTime,
t.PASS_SCORE AS passScore,
t.CODE_NAME AS codeName,
t.BPM_ID AS bpmId,
s.DEPARTMENT
FROM
BAS_EXAM_SCORE s
left join
BAS_EXAM_TEST t
on
s.TEST_ID=t.TEST_ID
order by s.CREATE_TIME desc
)tag
<where>
<foreach collection="example.oredCriteria" item="criteria">
<if test="criteria.valid">
${@tk.mybatis.mapper.util.OGNL@andOr(criteria)} <trim prefix="(" prefixOverrides="and |or " suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}
</when>
<when test="criterion.singleValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ekingwin.bas.cloud.exam.dao.SubjectDao">
<insert id="save">
insert into bas_exam_subject values (#{subject.id},#{subject.subjectName},#{subject.createBy},#{subject.createTime},
#{subject.updateTime},#{subject.isDelete},#{subject.subjectNo})
</insert>
<update id="updateSubjectInfo">
update BAS_EXAM_SUBJECT set
<if test="subject.subjectName != null and '' != subject.subjectName">
SUBJECT_NAME=#{subject.subjectName},
</if>
<if test="subject.subjectNo != null and '' != subject.subjectNo">
SUBJECT_NO=#{subject.subjectNo},
</if>
UPDATE_TIME=#{subject.updateTime} where ID=#{subject.id}
</update>
<update id="delete">
update BAS_EXAM_SUBJECT SET ISDELETE=1 WHERE ID=#{id}
</update>
<select id="query" resultType="com.ekingwin.bas.cloud.exam.dto.entity.Subject">
select ID as id,
SUBJECT_NAME as subjectName,
CREATE_BY as createBy,
CREATE_TIME as createTime,
UPDATE_TIME as updateTime,
SUBJECT_NO as subjectNo
from bas_exam_subject where ISDELETE=0
<if test="querySubjectVO.subjectId !=null and ''!=querySubjectVO.subjectId">
and ID=#{querySubjectVO.subjectId}
</if>
<if test="querySubjectVO.subjectName !=null and ''!=querySubjectVO.subjectName">
and SUBJECT_NAME LIKE CONCAT('%',#{querySubjectVO.subjectName},'%')
</if>
<if test="querySubjectVO.subjectNo!=null and ''!=querySubjectVO.subjectNo">
and SUBJECT_NO LIKE CONCAT('%',#{querySubjectVO.subjectNo},'%')
</if>
</select>
<select id="verify" resultType="java.lang.Integer">
select count(1) from bas_exam_subject where ISDELETE=0
<if test="querySubjectVO.subjectId !=null and ''!=querySubjectVO.subjectId">
and ID != #{querySubjectVO.subjectId}
</if>
<if test="querySubjectVO.subjectName !=null and ''!=querySubjectVO.subjectName">
and SUBJECT_NAME = #{querySubjectVO.subjectName}
</if>
<if test="querySubjectVO.subjectNo!=null and ''!=querySubjectVO.subjectNo">
and SUBJECT_NO = #{querySubjectVO.subjectNo}
</if>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ekingwin.bas.cloud.exam.dao.TestPaperDao">
<insert id="insertTest">
insert into bas_exam_test values (#{test.testId},#{test.subjectId},#{test.testName},#{test.totalScore},#{test.createTime},
#{test.isDelete},#{test.createBy},#{test.passScore},#{test.codeName},#{test.bpmId})
</insert>
<update id="deleteTestPapers">
update BAS_EXAM_TEST set ISDELETE = 1 where TEST_ID = #{testId}
</update>
<select id="queryUndoTestByUserId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.TestPapers">
select t.TEST_ID as testId,
t.SUBJECT_ID as subjectId,
t.TEST_NAME as testName,
t.TOTAL_SCORE as totalScore,
t.BPM_ID as bpmId,
t.CODE_NAME as codeName,
t.CREATE_TIME as createTime,
t.ISDELETE as idDelete,
t.CREATE_BY as createBy
from bas_exam_test t where t.test_id not in (select distinct s.test_id from bas_exam_score s where stuff_id=#{userId})
and isdelete = 0
order by t.CREATE_TIME desc
</select>
<select id="queryDoneTestByUserid" resultType="com.ekingwin.bas.cloud.exam.dto.entity.TestPapers">
select * from bas_exam_test t where t.test_id not in (select distinct s.test_id from bas_exam_score s where stuff_id=#{userId})
</select>
<select id="queryTestByTestId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.TestPapers">
select TEST_ID as testId,
SUBJECT_ID as subjectId,
TEST_NAME as TestName,
BPM_ID as bpmId,
CODE_NAME as codeName,
TOTAL_SCORE as totalScore,
CREATE_TIME as createTime,
CREATE_BY as createBy,
PASS_SCORE as passScore
from bas_exam_test where test_id=#{testId} and ISDELETE =0
</select>
<select id="queryTestByTestIdAndBatchAndUserId" resultType="com.ekingwin.bas.cloud.exam.dto.entity.TestPapers">
select t.test_id as testId,
t.SUBJECT_ID as subjectId,
t.TEST_NAME as testName,
t.TOTAL_SCORE as totalScore,
t.CREATE_TIME as createTime
from bas_exam_test t where test_id=(select s.test_id from bas_exam_score s where s.stuff_id=#{userId}
and s.test_id=#{testId} and s.answer_batch=#{answerBatch}) and ISDELETE =0
</select>
<select id="selectTestPapers" resultType="com.ekingwin.bas.cloud.exam.dto.entity.TestPapers">
SELECT * FROM (
select
t.TEST_ID as id,
t.SUBJECT_ID as subjectId,
t.TEST_NAME as testName,
t.TOTAL_SCORE as totalScore,
t.PASS_SCORE as passScore,
t.CREATE_TIME as createTime,
t.CREATE_TIME as updateTime,
t.CODE_NAME as codeName,
t.BPM_ID as bpmId,
t.CREATE_BY as createBy,
s.SUBJECT_NAME AS belongSubject,
(select cnname from employee where empuid = t.CREATE_BY) AS cnname,
t.ISDELETE as isDelete
from BAS_EXAM_TEST t left join BAS_EXAM_SUBJECT s on s.ID = t.SUBJECT_ID where t.ISDELETE = 0
order by t.CREATE_TIME desc
) m
<where>
<foreach collection="example.oredCriteria" item="criteria">
<if test="criteria.valid">
${@tk.mybatis.mapper.util.OGNL@andOr(criteria)} <trim prefix="(" prefixOverrides="and |or " suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}
</when>
<when test="criterion.singleValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
${@tk.mybatis.mapper.util.OGNL@andOr(criterion)} ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
</mapper>
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dao.QuestionDao;
import com.ekingwin.bas.cloud.exam.dao.ScoreDao;
import com.ekingwin.bas.cloud.exam.dao.SubjectDao;
import com.ekingwin.bas.cloud.exam.dao.TestPaperDao;
import com.ekingwin.bas.cloud.exam.dto.QueryTestVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.infra.dto.QueryDTO;
import com.ekingwin.bas.cloud.infra.exception.BasException;
import com.ekingwin.bas.cloud.infra.utils.db.PageCriteria;
import com.ekingwin.bas.cloud.org.manager.IOrganizationManager;
import com.ekingwin.bas.cloud.test.BaseCommonTestService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import tk.mybatis.mapper.entity.Config;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.mapperhelper.EntityHelper;
import tk.mybatis.spring.annotation.MapperScan;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
/**
* @author chenjb
* @version 1.0.0
* @ClassName TestPaperServiceImplTest.java
* @Description TODO
* @createTime 2021/6/10 13:59
*/
@Order()
class TestPaperServiceImplTest extends BaseCommonTestService {
@Test
void createTest() {
/*
要明确单元测试中,测试一个指定方法的目标:
一般情况下,你要测试的仅仅是指定方法自身的逻辑,而一个方法应当只实现一个功能;因此我们只需要定义虚拟的输入参数(如果参数是对象,则只需要定义对象中那些在方法逻辑中需要使用到的属性即可),并在调用方法后,获取到方法的返回值,判断该返回值是否符合预期即可;当该方法中调用调用了其他类的方法时,由于我们此时只关注当前方法的逻辑而
*/
//生成一些虚拟的测试数据;这里不需要设置所有的属性值,只需要定义一些测试目标方法中的逻辑需要用到的即可
TestPapers testPapers = new TestPapers();
testPapers.setTotalScore(100);
testPapers.setDIY(true);
testPapers.setPassScore(60);
//比如以下参数在方法逻辑中并没有使用来控制逻辑,所以并不用设置(除非你要用来测试数据库层的写入逻辑)
testPapers.setSubjectId("123");
testPapers.setTestName("测试name");
testPapers.setCodeName("测试code");
testPapers.setBpmId("123");
List<Question> questions = new ArrayList<>();
Question question = new Question();
question.setQuestionContent("A|B|C|D");
question.setSingleScore(50);
question.setType(1);
//比如以下参数在方法逻辑中并没有使用来控制逻辑,所以并不用设置(除非你要用来测试数据库层的写入逻辑)
question.setQuestionTitle("quest1");
question.setAnswer("A");
question.setBelongSubject("123");
question.setSubjectId("123");
questions.add(question);
new Question();
question.setQuestionContent("A|B|C|D");
question.setSingleScore(50);
question.setType(3);
//比如以下参数在方法逻辑中并没有使用来控制逻辑,所以并不用设置(除非你要用来测试数据库层的写入逻辑)
question.setQuestionTitle("quest2");
question.setAnswer("A|B");
question.setBelongSubject("123");
question.setSubjectId("123");
questions.add(question);
testPapers.setQuestions(questions);
//如果我们只测试业务方法的逻辑,不会测试数据库层,所以涉及到的数据库相关操作直接通过打桩模拟返回
//如果过要同时测试数据层的方法,去掉下面的打桩代码,并去掉初始化类中的mockbean声明
Mockito.doReturn(1).when(testPaperDao).insertTest(any());
//由此方法的逻辑可知,该方法中调用了questionsService.addQuestion,这里并未对该方法进行mock,因此这里其实是同时测试了两个方法
//调用测试的目标方法
int i = testPaperService.createTest(testPapers);
Assertions.assertTrue(i > 0);
//getTestPapersDetailsInfo方法中会用到的数据库方法,直接打桩返回
Mockito.doReturn(testPapers).when(testPaperDao).queryTestByTestId(anyString());
Mockito.doReturn(questions).when(questionDao).queryQuestionByTestId(anyString());
//调用测试的目标方法
testPapers = testPaperService.getTestPapersDetailsInfo(testPapers.getTestId());
//断言,判断结果是否符合预期
Assertions.assertNotNull(testPapers);
Assertions.assertEquals(testPapers.getTotalScore(), 100);
Assertions.assertNotNull(testPapers.getQuestions());
Assertions.assertEquals(testPapers.getQuestions().size(), 2);
}
@Test
void queryMyAllTest() {
List<TestPapers> undoList = new ArrayList<>();
TestPapers test = new TestPapers();
test.setTestId("1");
undoList.add(test);
test = new TestPapers();
test.setTestId("2");
undoList.add(test);
test = new TestPapers();
test.setTestId("3");
undoList.add(test);
test = new TestPapers();
test.setTestId("4");
undoList.add(test);
test = new TestPapers();
test.setTestId("5");
undoList.add(test);
List<Score> doneList = new ArrayList<>();
Score score = new Score();
score.setTestId("1");
doneList.add(score);
Mockito.doReturn(undoList).when(testPaperDao).queryUndoTestByUserId(null);
Mockito.doReturn(doneList).when(scoreDao).queryDoneTestByUserId(null);
TestPapers testPaper = new TestPapers();
testPaper.setTestId("6");
Mockito.doReturn(testPaper).when(testPaperDao).queryTestByTestId("1");
List<TestPapers> myList = testPaperService.queryMyAllTest();
Assertions.assertEquals(6, myList.size());
Assertions.assertTrue(myList.get(5).getDone());
}
@Test
void queryTestDetails() {
TestPapers test = new TestPapers();
test.setTestId("1");
Mockito.doReturn(test).when(testPaperDao).queryTestByTestIdAndBatchAndUserId(null, null, null);
Mockito.doReturn(new ArrayList<>()).when(questionDao).queryAnswerByTestIdAndBatchAndUserId(null, null, null);
test = new TestPapers();
test.setTestId("2");
Mockito.doReturn(test).when(testPaperDao).queryTestByTestId(null);
Mockito.doReturn(new ArrayList<>()).when(questionDao).queryQuestionByTestId(null);
QueryTestVO queryTestVO = new QueryTestVO();
queryTestVO.setDone(true);
test = testPaperService.queryTestDetails(queryTestVO);
Assertions.assertEquals("1", test.getTestId());
queryTestVO = new QueryTestVO();
queryTestVO.setDone(false);
test = testPaperService.queryTestDetails(queryTestVO);
Assertions.assertEquals("2", test.getTestId());
}
@Test
void deleteTestPapers() {
int result = testPaperService.deleteTestPapers("1,2,3");
Assertions.assertEquals(0, result);
}
@Test
void queryTestPapers() throws BasException {
// Mockito.doReturn(new ArrayList<>()).when(testPaperDao).selectTestPapers(any(Example.class));
Config config = new Config();
EntityHelper.initEntityNameMap(TestPapers.class, config);
Mockito.when(testPaperDao.selectTestPapers(any(Example.class))).thenReturn(new ArrayList<>());
PageCriteria<TestPapers> result = testPaperService.queryTestPapers(new QueryDTO());
}
@Test
void getTestPapersDetailsInfo() {
}
@Test
void editTest() {
}
@SpringBootApplication(scanBasePackages = {"com.ekingwin.bas.cloud"})
@MapperScan({"com.ekingwin.bas.cloud.**.dao"})
static class InnerConfig {
/*
* 目前tkmapper扫描加载的dao接口,会覆盖mockBean导致mockBean无法生效(无论如何都会调用原始方法);
* 所以如果要使dao的mock生效,需要在这里手工初始化测试过程中涉及到的dao接口;
* 当然,如果你想要在测试业务方法时,同时测试数据库层的接口,可以不加这些配置,并“去掉”测试方法中的打桩逻辑
*/
@Bean(name = "testPaperDao")
public TestPaperDao getTestPaperDao() {
return testPaperDao;
}
@Bean(name = "questionDao")
public QuestionDao getQuestionDao() {
return questionDao;
}
@Bean(name = "scoreDao")
public ScoreDao getScoreDao() {
return scoreDao;
}
@MockBean
private TestPaperDao testPaperDao;
@MockBean
private QuestionDao questionDao;
@MockBean
private ScoreDao scoreDao;
}
@Resource
private TestPaperService testPaperService;
/*
对于在configuration中预先初始化的mockbean对象, 这需要通过@Resource或者@Autowired注入
*/
@Resource
private TestPaperDao testPaperDao;
@Resource
private QuestionDao questionDao;
@Resource
private ScoreDao scoreDao;
@MockBean
private SubjectDao subjectDao;
@MockBean
private IOrganizationManager organizationManager;
// @MockBean
// private TestPaperDao testPaperDao;
}
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.QueryTestVO;
import com.ekingwin.bas.cloud.exam.dto.QuestionVO;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.exam.service.AnswerService;
import com.ekingwin.bas.cloud.exam.service.QuestionsService;
import com.ekingwin.bas.cloud.exam.service.TestPaperService;
import com.ekingwin.bas.cloud.infra.utils.common.JsonUtil;
import com.ekingwin.bas.cloud.test.BaseWebTestService;
import com.ekingwin.bas.cloud.test.util.HttpTestUtils;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
/**
* @author chenjb
* @version 1.0.0
* @ClassName AnswerControllerTest.java
* @Description TODO
* @createTime 2021/6/10 18:56
*/
@WebMvcTest(controllers = AnswerController.class)
class AnswerControllerTest extends BaseWebTestService {
@Test
void checkAndSaveAnswer() throws Exception {
HttpTestUtils http = super.build();
TestPapers question = new TestPapers();
question.setQuestions(new ArrayList<>());
String content = JsonUtil.objectToJsonString(question);
ResultActions resultActions = http.post("/answerTest", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Test
void queryMyAllTest() throws Exception {
HttpTestUtils http = super.build();
ResultActions resultActions = http.get("/queryMyAllTest", null, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Test
void queryTestDetails() throws Exception {
HttpTestUtils http = super.build();
QueryTestVO query = new QueryTestVO();
String content = JsonUtil.objectToJsonString(query);
ResultActions resultActions = http.post("/queryTestDetails", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Override
protected String getBaseUrl() {
return "/exam/answer";
}
@SpringBootApplication
static class InnerConfig {
}
@MockBean
private AnswerService answerService;
@MockBean
private TestPaperService testPaperService;
}
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.QuestionVO;
import com.ekingwin.bas.cloud.exam.service.QuestionsService;
import com.ekingwin.bas.cloud.infra.utils.common.JsonUtil;
import com.ekingwin.bas.cloud.test.BaseWebTestService;
import com.ekingwin.bas.cloud.test.util.HttpTestUtils;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
/**
* @author chenjb
* @version 1.0.0
* @ClassName QuestionControllerTest.java
* @Description TODO
* @createTime 2021/6/10 18:42
*/
@WebMvcTest(controllers = QuestionController.class)
class QuestionControllerTest extends BaseWebTestService {
@Test
void addQuestions() throws Exception {
HttpTestUtils http = super.build();
QuestionVO question = new QuestionVO();
question.setQuestions(new ArrayList<>());
String content = JsonUtil.objectToJsonString(question);
Mockito.doReturn(1).when(questionsService).addQuestions(any(List.class));
ResultActions resultActions = http.post("/addQuestions", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Test
void queryQuestionsBySubjectId() throws Exception {
HttpTestUtils http = super.build();
ResultActions resultActions = http.get("/queryQuestions/1/2/3", null, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Test
void editQuestions() throws Exception {
HttpTestUtils http = super.build();
QuestionVO question = new QuestionVO();
String content = JsonUtil.objectToJsonString(question);
Mockito.doReturn(1).when(questionsService).addQuestions(any(List.class));
ResultActions resultActions = http.post("/editQuestions", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Override
protected String getBaseUrl() {
return "/exam/question";
}
@SpringBootApplication
static class InnerConfig {
}
@MockBean
private QuestionsService questionsService;
}
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.QuerySubjectVO;
import com.ekingwin.bas.cloud.exam.dto.SubjectVerifyVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Subject;
import com.ekingwin.bas.cloud.exam.service.SubjectService;
import com.ekingwin.bas.cloud.infra.utils.common.JsonUtil;
import com.ekingwin.bas.cloud.test.BaseWebTestService;
import com.ekingwin.bas.cloud.test.util.HttpTestUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
/**
* @author chenjb
* @version 1.0.0
* @ClassName SubjectControllerTest.java
* @Description TODO
* @createTime 2021/6/10 15:13
*/
@WebMvcTest(controllers = SubjectController.class)
class SubjectControllerTest extends BaseWebTestService {
//@ParameterizedTest注解表示参数化测试,可以通过@ValueSource注解自定义测试时需要用到的参数值
//@ValueSource只支持同时传入一个参数,虽然定义的类型是数组,那也只是根据数组中的元素个数作为入参进行多次测试
//动态的参数支持java的8中基本类型的数组外,也支持class对象数组(不是对象实例)
@ParameterizedTest
@ValueSource(strings = {"s", "e"})
@DisplayName("添加科目")
void addSubject(String param) throws Exception {
//测试web层时,先构建一个http测试工具
HttpTestUtils http = super.build();
//构建请求参数(测试的目标函数逻辑中,对与参数的属性并没有要求,所以这里定义一个空的实例就行)
Subject subject = new Subject();
//函数逻辑中,调用了底层业务类中的两个方法;这两个方法不需要再这里进行测试(会有单独的单元测试类),因此通过stub进行模拟返回
SubjectVerifyVO subjectVerify = new SubjectVerifyVO();
int result = 0;
int code = 200;
//根据动态参数,设置不同的模拟返回值
if ("s".equals(param)) {
subjectVerify.setMsg("success");
subjectVerify.setSuccess(true);
result = 1;
} else {
subjectVerify.setMsg("error");
subjectVerify.setSuccess(false);
code = 400;
}
//开始打桩(stub)
Mockito.doReturn(subjectVerify).when(subjectService).verify(any(Subject.class));
Mockito.doReturn(result).when(subjectService).addSubject(any(Subject.class));
//将请求参数转为string字符串(一般为json字符串)
String content = JsonUtil.objectToJsonString(subject);
//除了requestBody的传参方式,也支持requestParam的方式
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
//通过http测试工具发送请求
//参数也支持通过url传递,如/addSubject/{id}
ResultActions resultActions = http.post("/addSubject", content, params, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(code));
//也可以获取最终响应值,在来进行断言
MvcResult mvcResult = resultActions.andReturn();
//通过断言工具,对获取到的响应信息进行校验
//如果不需要对返回结果的业务数据进行校验,也可以省略这一步
// Assertions.assertEquals(code, mvcResult.getResponse().getStatus());
}
//这个测试的目标方法中的逻辑比较简单,其实是可以不用测试的,不过对于controller,目前都需要做定义一个单元测试,主要目的是保证接口路径的准确性;
//另外,controller中的逻辑基本都十分简单,所以一般不需要对其中的逻辑进行测试
@Test
@DisplayName("删除科目")
void dleSubjectById() throws Exception {
HttpTestUtils http = super.build();
//我们只测试目标方法的逻辑,它所引用的底层方法我们这里并不关注,模拟一个假的返回值即可
//实际上,mock的对象调用的方法默认返回的是null,如果在逻辑中不会造成空指针,同时也不需要使用该返回值进行逻辑判断,这里打打桩操作也可以省略
Mockito.doReturn(1).when(subjectService).delSubjectById(anyString());
//定义controller的web参数
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
List<String> idList = new ArrayList<>();
idList.add("1");
params.put("ids", idList);
//发送模拟请求
ResultActions resultActions = http.get("/delSubjectById", null, params, null);
//验证是否是想要得到的记过
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Test
@DisplayName("查询科目")
void querySubjectById() throws Exception {
HttpTestUtils http = super.build();
QuerySubjectVO query = new QuerySubjectVO();
String content = JsonUtil.objectToJsonString(query);
ResultActions resultActions = http.post("/querySubject", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
//也可以获取最终响应值,在来进行断言
MvcResult mvcResult = resultActions.andReturn();
}
@Test
@DisplayName("修改科目信息")
void changeSubjectInfo() throws Exception {
HttpTestUtils http = super.build();
Subject subject = new Subject();
String content = JsonUtil.objectToJsonString(subject);
Mockito.doReturn(new SubjectVerifyVO()).when(subjectService).verify(any(Subject.class));
Mockito.doReturn(1).when(subjectService).addSubject(any(Subject.class));
ResultActions resultActions = http.post("/changeSubjectInfo", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(400));
//也可以获取最终响应值,在来进行断言
MvcResult mvcResult = resultActions.andReturn();
}
@Override
protected String getBaseUrl() {
return "/exam/subject";
}
@SpringBootApplication
// @SpringBootApplication(scanBasePackages = {"com.ekingwin.bas.cloud.**.web"})
static class InnerConfig {
}
@MockBean
private SubjectService subjectService;
}
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.web;
import com.ekingwin.bas.cloud.exam.dto.SubjectVerifyVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Subject;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.exam.service.ScoreService;
import com.ekingwin.bas.cloud.exam.service.SubjectService;
import com.ekingwin.bas.cloud.exam.service.TestPaperService;
import com.ekingwin.bas.cloud.infra.utils.common.JsonUtil;
import com.ekingwin.bas.cloud.test.BaseWebTestService;
import com.ekingwin.bas.cloud.test.util.HttpTestUtils;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
/**
* @author chenjb
* @version 1.0.0
* @ClassName TestPaperControllerTest.java
* @Description TODO
* @createTime 2021/6/10 18:21
*/
@WebMvcTest(controllers = TestPaperController.class)
class TestPaperControllerTest extends BaseWebTestService {
@Test
void createTest() throws Exception {
HttpTestUtils http = super.build();
TestPapers test = new TestPapers();
test.setQuestions(new ArrayList<>());
String content = JsonUtil.objectToJsonString(test);
Mockito.doReturn(1).when(testPaperService).createTest(any(TestPapers.class));
ResultActions resultActions = http.post("/createTest", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
//也可以获取最终响应值,在来进行断言
MvcResult mvcResult = resultActions.andReturn();
}
@Test
void queryScoreInfo() throws Exception {
HttpTestUtils http = super.build();
ResultActions resultActions = http.post("/queryScoreInfo", null, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
//也可以获取最终响应值,在来进行断言
MvcResult mvcResult = resultActions.andReturn();
}
@Test
void deleteTestPapers() throws Exception {
HttpTestUtils http = super.build();
Mockito.doReturn(1).when(testPaperService).deleteTestPapers(anyString());
ResultActions resultActions = http.get("/deleteTestPapers/1,2,3", null, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
//也可以获取最终响应值,在来进行断言
MvcResult mvcResult = resultActions.andReturn();
}
@Test
void queryTestPapers() throws Exception {
HttpTestUtils http = super.build();
ResultActions resultActions = http.post("/queryTestPapers", null, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
//也可以获取最终响应值,在来进行断言
// MvcResult mvcResult = resultActions.andReturn();
}
@Test
void getTestPapersDetailsInfo() throws Exception {
HttpTestUtils http = super.build();
Mockito.doReturn(new TestPapers()).when(testPaperService).getTestPapersDetailsInfo(anyString());
ResultActions resultActions = http.get("/getTestPapersDetailsInfo/1", null, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Test
void editTest() throws Exception {
HttpTestUtils http = super.build();
TestPapers test = new TestPapers();
test.setQuestions(new ArrayList<>());
String content = JsonUtil.objectToJsonString(test);
Mockito.doReturn(1).when(testPaperService).editTest(any(TestPapers.class));
ResultActions resultActions = http.post("/editTest", content, null, null);
//可以为虚拟结果添加预期值(这里支持jsonpath,可以根据json路径获取值来进行判断)
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200));
}
@Override
protected String getBaseUrl() {
return "/exam/test";
}
@SpringBootApplication
static class InnerConfig {
}
@MockBean
private TestPaperService testPaperService;
@MockBean
private ScoreService scoreService;
}
\ No newline at end of file
spring.profiles.active=dev
spring.datasource.schema=classpath:**/**.sql
spring.datasource.dynamic.datasource.master.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL
mybatis.type-aliases-package=com.ekingwin.bas.cloud
mybatis.mapper-locations=classpath*:/mapper/**/*Mapper.xml
mapper.mappers=com.ekingwin.bas.mapper.BasMapper,com.ekingwin.bas.mapper.BasTreeMapper
mapper.not-empty=false
mapper.before=true
pagehelper.helperDialect=mysql
#\u5206\u9875\u5408\u7406\u5316\uFF0C\u9488\u5BF9\u4E0D\u5408\u7406\u7684\u4EE3\u7801\u81EA\u52A8\u5904\u7406
pagehelper.reasonable=true
#\u5206\u9875\u63D2\u4EF6\u4F1A\u4ECE\u67E5\u8BE2\u65B9\u6CD5\u7684\u53C2\u6570\u503C\u4E2D\uFF0C\u81EA\u52A8\u6839\u636E\u4E0A\u9762 params \u914D\u7F6E\u7684\u5B57\u6BB5\u4E2D\u53D6\u503C\uFF0C\u67E5\u627E\u5230\u5408\u9002\u7684\u503C\u65F6\u5C31\u4F1A\u81EA\u52A8\u5206\u9875\u3002
pagehelper.supportMethodsArguments=true
spring.datasource.dynamic.p6spy=true
#\u65E5\u5FD7
logging.level.root=INFO
#\u8BBE\u4E3ADEBUG\uFF0C\u53EF\u6253\u5370mybatis\u7684sql\u8BED\u53E5
logging.level.com.ekingwin.bas=INFO
logging.level.jdbc.sqlonly=INFO
logging.level.org.quartz=WARN
ScoreToBpm=http://bpapr.lj028.cn:8092/bpm/common/parameter/saveKsInfo
\ No newline at end of file
/*
Navicat Premium Data Transfer
Source Server : huawei_bpa_bpm
Source Server Type : MySQL
Source Server Version : 50729
Source Host : huaweimysql1.jiucaiyun.cn:3306
Source Schema : jiucaiyunbpm
Target Server Type : MySQL
Target Server Version : 50729
File Encoding : 65001
Date: 11/06/2021 11:30:14
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for bas_exam_answer
-- ----------------------------
DROP TABLE IF EXISTS `bas_exam_answer`;
CREATE TABLE `bas_exam_answer` (
`id` varchar(50) NOT NULL COMMENT '答题id',
`test_id` varchar(50) NOT NULL COMMENT '所属试卷',
`stuff_id` varchar(50) NOT NULL COMMENT '答题人id',
`answer_batch` varchar(255) NOT NULL COMMENT '答题批次',
`question_id` varchar(50) NOT NULL COMMENT '问题id',
`question_title` varchar(2000) NULL DEFAULT NULL COMMENT '问题题目',
`question_content` varchar(4000) NULL DEFAULT NULL COMMENT '问题内容',
`my_answer` varchar(4000) NULL DEFAULT NULL COMMENT '我的答案',
`my_score` int(3) NULL DEFAULT NULL COMMENT '我的得分',
`type` int(1) NULL DEFAULT NULL COMMENT '问题类型',
`correct` int(1) NULL DEFAULT NULL COMMENT '是否正确'
) ;
-- ----------------------------
-- Table structure for bas_exam_question
-- ----------------------------
DROP TABLE IF EXISTS `bas_exam_question`;
CREATE TABLE `bas_exam_question` (
`id` varchar(50) NOT NULL COMMENT '试题id',
`question_title` varchar(2000) NOT NULL COMMENT '问题题目',
`question_content` varchar(4000) NOT NULL COMMENT '问题内容',
`answer` varchar(4000) NULL DEFAULT NULL COMMENT '正确答案',
`single_score` int(2) NULL DEFAULT NULL COMMENT '该题分数',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`create_by` varchar(50) NULL DEFAULT NULL COMMENT '创建人',
`isdelete` int(2) NULL DEFAULT NULL,
`subject_id` varchar(50) NULL DEFAULT NULL,
`type` int(1) NULL DEFAULT NULL
) ;
-- ----------------------------
-- Table structure for bas_exam_question_test
-- ----------------------------
DROP TABLE IF EXISTS `bas_exam_question_test`;
CREATE TABLE `bas_exam_question_test` (
`test_id` varchar(50) NOT NULL COMMENT '所属试卷',
`question_title` varchar(2000) NULL DEFAULT NULL COMMENT '问题题目',
`question_content` varchar(4000) NULL DEFAULT NULL COMMENT '问题内容',
`answer` varchar(4000) NULL DEFAULT NULL COMMENT '答案',
`singlescore` int(2) NULL DEFAULT NULL COMMENT '该题分数',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`create_by` varchar(20) NULL DEFAULT NULL COMMENT '创建人',
`isdelete` int(1) NULL DEFAULT NULL COMMENT '是否删除',
`subject_id` varchar(50) NULL DEFAULT NULL COMMENT '所属科目',
`type` int(1) NULL DEFAULT NULL COMMENT '类型',
`id` varchar(50) NOT NULL,
`question_id` varchar(50) NULL DEFAULT NULL COMMENT '试题id'
) ;
-- ----------------------------
-- Table structure for bas_exam_score
-- ----------------------------
DROP TABLE IF EXISTS `bas_exam_score`;
CREATE TABLE `bas_exam_score` (
`id` varchar(50) NOT NULL COMMENT '成绩ID',
`stuff_id` varchar(50) NULL DEFAULT NULL COMMENT '员工id',
`stuff_name` varchar(30) NULL DEFAULT NULL COMMENT '员工姓名',
`test_id` varchar(50) NULL DEFAULT NULL COMMENT '试卷id',
`test_name` varchar(1000) NULL DEFAULT NULL COMMENT '试卷名字',
`answer_batch` varchar(50) NULL DEFAULT NULL COMMENT '答题批次',
`score` int(3) NULL DEFAULT NULL COMMENT '得分',
`qualified` int(1) NULL DEFAULT NULL COMMENT '是否合格 1:合格 0:不合格',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`department` varchar(50) NULL DEFAULT NULL COMMENT '所属部门'
) ;
-- ----------------------------
-- Table structure for bas_exam_subject
-- ----------------------------
DROP TABLE IF EXISTS `bas_exam_subject`;
CREATE TABLE `bas_exam_subject` (
`id` varchar(50) NOT NULL COMMENT '科目id',
`subject_name` varchar(30) NULL DEFAULT NULL COMMENT '科目名称',
`create_by` varchar(30) NULL DEFAULT NULL COMMENT '创建人',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更改时间',
`isdelete` int(1) NULL DEFAULT NULL COMMENT '是否删除',
`subject_no` varchar(50) NULL DEFAULT NULL COMMENT '科目编号'
) ;
-- ----------------------------
-- Table structure for bas_exam_test
-- ----------------------------
DROP TABLE IF EXISTS `bas_exam_test`;
CREATE TABLE `bas_exam_test` (
`test_id` varchar(255) NOT NULL COMMENT '试卷id',
`subject_id` varchar(50) NOT NULL COMMENT '所属科目',
`test_name` varchar(255) NOT NULL COMMENT '试卷名字',
`total_score` int(4) NOT NULL COMMENT '试卷总分',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`isdelete` int(1) NOT NULL COMMENT '是否删除',
`create_by` varchar(30) NULL COMMENT '创建人',
`pass_score` varchar(10) NULL DEFAULT NULL COMMENT '合格分数',
`code_name` varchar(255) NULL DEFAULT NULL COMMENT '编码及名称',
`bpm_id` varchar(32) NULL DEFAULT NULL
) ;
SET FOREIGN_KEY_CHECKS = 1;
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
`empuid` varchar(20) NOT NULL,
`empid` varchar(100) NULL DEFAULT NULL,
`cnname` varchar(100) NULL DEFAULT NULL,
`enname` varchar(100) NULL DEFAULT NULL,
`email` varchar(100) NULL DEFAULT NULL,
`phone` varchar(50) NULL DEFAULT NULL,
`division_code` varchar(20) NULL DEFAULT NULL,
`syn_index` varchar(20) NULL DEFAULT NULL,
`is_deleted` varchar(1) NOT NULL DEFAULT 'N',
`displayname` varchar(300) NULL DEFAULT NULL,
`defaultpos` int(11) NULL DEFAULT NULL,
`password` varchar(70) NULL DEFAULT NULL,
`officephone` varchar(50) NULL DEFAULT NULL,
`mobilephone` varchar(30) NULL DEFAULT NULL,
`emailpassword` varchar(100) NULL DEFAULT NULL,
`status` varchar(10) NULL DEFAULT NULL,
`personaldesc` varchar(1500) NULL DEFAULT NULL,
`faxnumber` varchar(50) NULL DEFAULT NULL,
`extension` varchar(50) NULL DEFAULT NULL,
`homeaddress` varchar(800) NULL DEFAULT NULL,
`homefax` varchar(50) NULL DEFAULT NULL,
`homeemail` varchar(100) NULL DEFAULT NULL,
`headportrait` varchar(800) NULL DEFAULT NULL,
`homemobile` varchar(30) NULL DEFAULT NULL,
`remark` varchar(2000) NULL DEFAULT NULL,
`postid` int(11) NULL DEFAULT NULL,
`superior` varchar(50) NULL DEFAULT NULL,
`outauthority` varchar(20) NULL DEFAULT NULL,
`passloseefficacy` date NULL DEFAULT NULL,
`lv` varchar(50) NULL DEFAULT NULL,
`areaid` int(11) NULL DEFAULT NULL,
`maindept` int(11) NULL DEFAULT NULL,
`area` varchar(30) NULL DEFAULT NULL,
`hukoaddress` varchar(100) NULL DEFAULT NULL,
`billaddress` varchar(100) NULL DEFAULT NULL,
`bussaddress` varchar(100) NULL DEFAULT NULL,
`chkaddress` varchar(100) NULL DEFAULT NULL,
`mailaddress` varchar(100) NULL DEFAULT NULL,
`oth2address` varchar(100) NULL DEFAULT NULL,
`permaddress` varchar(100) NULL DEFAULT NULL,
`busnphone` varchar(100) NULL DEFAULT NULL,
`cellphone` varchar(100) NULL DEFAULT NULL,
`emerphone` varchar(100) NULL DEFAULT NULL,
`homephone` varchar(100) NULL DEFAULT NULL,
`mainphone` varchar(100) NULL DEFAULT NULL,
`otrphone` varchar(100) NULL DEFAULT NULL,
`busnmail` varchar(100) NULL DEFAULT NULL,
`campmail` varchar(100) NULL DEFAULT NULL,
`dormmail` varchar(100) NULL DEFAULT NULL,
`homemail` varchar(100) NULL DEFAULT NULL,
`othrmail` varchar(100) NULL DEFAULT NULL,
`deptid` varchar(100) NULL DEFAULT NULL,
`sex` varchar(10) NULL DEFAULT NULL,
`operatingtime` date NULL DEFAULT NULL,
`gender` varchar(100) NULL DEFAULT NULL,
`factory` varchar(100) NULL DEFAULT NULL,
`elecsignature` varchar(800) NULL DEFAULT NULL,
`updatetime` date NULL DEFAULT NULL,
`phone1_s` varchar(10) NULL DEFAULT NULL,
`phone2` varchar(30) NULL DEFAULT NULL,
`phone2_s` varchar(10) NULL DEFAULT NULL,
`zzip2` varchar(10) NULL DEFAULT NULL,
`tel2` varchar(30) NULL DEFAULT NULL,
`payrollcardnumber` varchar(30) NULL DEFAULT NULL,
`bank` varchar(100) NULL DEFAULT NULL,
`icnum` varchar(100) NULL DEFAULT NULL,
`province_birth` varchar(100) NULL DEFAULT NULL,
`origin` varchar(100) NULL DEFAULT NULL,
`zzip` varchar(10) NULL DEFAULT NULL,
`mobile_touxiang` blob NULL,
`entrydate` date NULL DEFAULT NULL,
`birthdate` date NULL DEFAULT NULL,
`professional` varchar(100) NULL DEFAULT NULL,
`education` varchar(100) NULL DEFAULT NULL,
`code` varchar(50) NULL DEFAULT NULL,
`logo_id` bigint(20) NULL DEFAULT NULL,
PRIMARY KEY (`empuid`)
) ;
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>bas-cloud-exam</artifactId>
<groupId>com.ekingwin</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bas-cloud-exam-model</artifactId>
<dependencies>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-infrastructure</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.dto;
import com.ekingwin.bas.cloud.infra.dto.BaseResult;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel("固定返回参数")
public class BackResult<T> extends BaseResult {
public BackResult() {
super();
}
@ApiModelProperty("响应状态码,200成功")
private Integer code;
@ApiModelProperty("响应提示信息")
private String msg;
public static BackResult successResponse() {
return new BackResult(0);
}
public static BackResult successResponse(Object data) {
return new BackResult(0, data);
}
public static BackResult successResponse(Integer code, Object o) {
return new BackResult(code, o);
}
public static BackResult successResponse(Integer code, String msg, Object o) {
return new BackResult(code, msg, o);
}
public static BackResult successResponse(Integer code, String msg) {
return new BackResult(code, msg);
}
public static BackResult successResponse(String msg, Object o) {
return new BackResult(msg, o);
}
public static BackResult failResponse(Integer code, String msg) {
return new BackResult(code, msg);
}
public static BackResult failResponse(Integer code) {
return new BackResult(code);
}
public static BackResult failResponse(String msg) {
return new BackResult(1, msg);
}
public BackResult(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public BackResult(Integer code, T data) {
this.code = code;
super.setData(data);
}
public BackResult(Integer code) {
this.code = code;
}
public BackResult(Integer code, String msg, T data) {
this.code = code;
this.msg = msg;
super.setData(data);
}
public BackResult(T data) {
this.code = 0;
this.msg = "SUCCESS";
super.setData(data);
}
public BackResult(String msg) {
this.code = 0;
this.msg = msg;
super.setData(null);
}
public BackResult(String msg, T data) {
this.code = 0;
this.msg = msg;
super.setData(data);
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public String toString() {
return "ResponseData{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + this.getData() + '}';
}
}
package com.ekingwin.bas.cloud.exam.dto;
import java.io.Serializable;
public class QuerySubjectVO implements Serializable {
private static final long serialVersionUID = -1016532981058680632L;
private String subjectId;
private String subjectName;
private String subjectNo;
private Integer startPage;
private Integer pageSize;
public QuerySubjectVO(String subjectId, String subjectName, String subjectNo, Integer startPage, Integer pageSize) {
this.subjectId = subjectId;
this.subjectName = subjectName;
this.subjectNo = subjectNo;
this.startPage = startPage;
this.pageSize = pageSize;
}
public QuerySubjectVO() {
}
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 getSubjectNo() {
return subjectNo;
}
public void setSubjectNo(String subjectNo) {
this.subjectNo = subjectNo;
}
public Integer getStartPage() {
return startPage;
}
public void setStartPage(Integer startPage) {
this.startPage = startPage;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.ekingwin.bas.cloud.exam.dto;
import java.io.Serializable;
public class QueryTestVO implements Serializable {
private static final long serialVersionUID = 8222032172103602633L;
private String stuffId;
private String stuffName;
private String testName;
private String bpmid;
private String codeName;
private String testId;
private String answerBatch;
private Boolean done;
private Integer startPage;
private Integer pageSize;
public QueryTestVO() {
}
public QueryTestVO(String stuffId, String stuffName, String testName, String bpmid, String codeName,
String testId, String answerBatch, Boolean done, Integer startPage, Integer pageSize) {
this.stuffId = stuffId;
this.stuffName = stuffName;
this.testName = testName;
this.bpmid = bpmid;
this.codeName = codeName;
this.testId = testId;
this.answerBatch = answerBatch;
this.done = done;
this.startPage = startPage;
this.pageSize = pageSize;
}
public Boolean getDone() {
return done;
}
public void setDone(Boolean done) {
this.done = done;
}
public String getBpmid() {
return bpmid;
}
public void setBpmid(String bpmid) {
this.bpmid = bpmid;
}
public String getCodeName() {
return codeName;
}
public void setCodeName(String codeName) {
this.codeName = codeName;
}
public String getStuffName() {
return stuffName;
}
public void setStuffName(String stuffName) {
this.stuffName = stuffName;
}
public String getTestName() {
return testName;
}
public void setTestName(String testName) {
this.testName = testName;
}
public Integer getStartPage() {
return startPage;
}
public void setStartPage(Integer startPage) {
this.startPage = startPage;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getStuffId() {
return stuffId;
}
public void setStuffId(String stuffId) {
this.stuffId = stuffId;
}
public String getTestId() {
return testId;
}
public void setTestId(String testId) {
this.testId = testId;
}
public String getAnswerBatch() {
return answerBatch;
}
public void setAnswerBatch(String answerBatch) {
this.answerBatch = answerBatch;
}
}
package com.ekingwin.bas.cloud.exam.dto;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import java.io.Serializable;
import java.util.List;
public class QuestionVO implements Serializable {
private static final long serialVersionUID = -8461193042019596906L;
List<Question> questions;
public QuestionVO() {
}
public QuestionVO(List<Question> questions) {
this.questions = questions;
}
public List<Question> getQuestions() {
return questions;
}
public void setQuestions(List<Question> questions) {
this.questions = questions;
}
}
package com.ekingwin.bas.cloud.exam.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class ScoreToBpm implements Serializable {
private static final long serialVersionUID = 4133478013987877768L;
private String bm;
private String bpaid;
private String cj;
private String kssj;
private String xm;
private String zh;
public String getBm() {
return bm;
}
public void setBm(String bm) {
this.bm = bm;
}
public String getBpaid() {
return bpaid;
}
public void setBpaid(String bpaid) {
this.bpaid = bpaid;
}
public String getCj() {
return cj;
}
public void setCj(String cj) {
this.cj = cj;
}
public String getKssj() {
return kssj;
}
public void setKssj(String kssj) {
this.kssj = kssj;
}
public String getXm() {
return xm;
}
public void setXm(String xm) {
this.xm = xm;
}
public String getZh() {
return zh;
}
public void setZh(String zh) {
this.zh = zh;
}
}
package com.ekingwin.bas.cloud.exam.dto;
import lombok.Data;
@Data
public class SubjectVerifyVO {
//成功状态
private boolean success;
//错误信息
private String msg;
}
package com.ekingwin.bas.cloud.exam.dto;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import java.io.Serializable;
import java.util.List;
public class TestVO implements Serializable {
private static final long serialVersionUID = 7852329728179189965L;
private List<TestPapers> tests;
public TestVO() {
}
public TestVO(List<TestPapers> tests) {
this.tests = tests;
}
public List<TestPapers> getTests() {
return tests;
}
public void setTests(List<TestPapers> tests) {
this.tests = tests;
}
}
package com.ekingwin.bas.cloud.exam.dto.entity;
import com.ekingwin.bas.cloud.infra.dao.entity.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
* 问题
*/
@Table(name = "BAS_EXAM_QUESTION_TEST")
public class Question extends BaseEntity {
private static final long serialVersionUID = -7469321517627819733L;
@Id
private String id;
// 所属试卷
private String testId;
// 考试人id
@Transient
private String stuffId;
// 问题题目
private String questionTitle;
// 问题内容
private String questionContent;
// 问题答案 或者 我的答案
private String answer;
// 该题分数
@Column(name = "SINGLESCORE")
private long singleScore;
// 创建时间
private Date createTime;
// 创建人
private String createBy;
// 是否删除
@Column(name = "ISDELETE")
private long isDelete;
// 所属科目
private String subjectId;
// 类型 1单选题 2多选题 3问答题
private long type;
// 答题批次
@Transient
private String answerBatch;
// 是否正确
@Transient
private long correct;
// 所属科目名字
@Transient
private String belongSubject;
public Question(String id, String testId, String stuffId, String questionTitle, String questionContent, String answer, long singleScore, Date createTime, String createBy, long isDelete, String subjectId, long type, String answerBatch, long correct, String belongSubject) {
this.id = id;
this.testId = testId;
this.stuffId = stuffId;
this.questionTitle = questionTitle;
this.questionContent = questionContent;
this.answer = answer;
this.singleScore = singleScore;
this.createTime = createTime;
this.createBy = createBy;
this.isDelete = isDelete;
this.subjectId = subjectId;
this.type = type;
this.answerBatch = answerBatch;
this.correct = correct;
this.belongSubject = belongSubject;
}
public String getBelongSubject() {
return belongSubject;
}
public void setBelongSubject(String belongSubject) {
this.belongSubject = belongSubject;
}
public String getAnswerBatch() {
return answerBatch;
}
public void setAnswerBatch(String answerBatch) {
this.answerBatch = answerBatch;
}
public long getIsDelete() {
return isDelete;
}
public void setIsDelete(long isDelete) {
this.isDelete = isDelete;
}
public long getCorrect() {
return correct;
}
public void setCorrect(long correct) {
this.correct = correct;
}
public Question() {
}
public String getStuffId() {
return stuffId;
}
public void setStuffId(String stuffId) {
this.stuffId = stuffId;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTestId() {
return testId;
}
public void setTestId(String testId) {
this.testId = testId;
}
public String getQuestionTitle() {
return questionTitle;
}
public void setQuestionTitle(String questionTitle) {
this.questionTitle = questionTitle;
}
public String getQuestionContent() {
return questionContent;
}
public void setQuestionContent(String questionContent) {
this.questionContent = questionContent;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public long getSingleScore() {
return singleScore;
}
public void setSingleScore(long singleScore) {
this.singleScore = singleScore;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public long getDelete() {
return isDelete;
}
public void setDelete(long delete) {
this.isDelete = delete;
}
public String getSubjectId() {
return subjectId;
}
public void setSubjectId(String subjectId) {
this.subjectId = subjectId;
}
public long getType() {
return type;
}
public void setType(long type) {
this.type = type;
}
}
package com.ekingwin.bas.cloud.exam.dto.entity;
import com.ekingwin.bas.cloud.infra.dao.entity.BaseEntity;
import java.util.Date;
/**
* 分数信息
*/
public class Score extends BaseEntity {
private static final long serialVersionUID = -107506585031782603L;
private String id;
private String bpmId;
// 考试人id
private String stuffId;
// 考试人名字
private String stuffName;
// 试卷id
private String testId;
// 试卷名字
private String testName;
// 答题批次
private String answerBatch;
// 试卷得分
private long score;
// 是否合格 0不合格 1合格
private long qualified;
// 创建时间
private Date createTime;
// 合格分数
private Integer passScore;
// 答题人所属部门
private String department;
// 编码及名称
private String codeName;
public String getBpmId() {
return bpmId;
}
public void setBpmId(String bpmId) {
this.bpmId = bpmId;
}
public String getStuffId() {
return stuffId;
}
public void setStuffId(String stuffId) {
this.stuffId = stuffId;
}
public String getStuffName() {
return stuffName;
}
public void setStuffName(String stuffName) {
this.stuffName = stuffName;
}
public String getTestId() {
return testId;
}
public void setTestId(String testId) {
this.testId = testId;
}
public String getTestName() {
return testName;
}
public void setTestName(String testName) {
this.testName = testName;
}
public String getAnswerBatch() {
return answerBatch;
}
public void setAnswerBatch(String answerBatch) {
this.answerBatch = answerBatch;
}
public long getScore() {
return score;
}
public void setScore(long score) {
this.score = score;
}
public long getQualified() {
return qualified;
}
public void setQualified(long qualified) {
this.qualified = qualified;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getPassScore() {
return passScore;
}
public void setPassScore(Integer passScore) {
this.passScore = passScore;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getCodeName() {
return codeName;
}
public void setCodeName(String codeName) {
this.codeName = codeName;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
package com.ekingwin.bas.cloud.exam.dto.entity;
/**
* 科目
*/
import com.ekingwin.bas.cloud.infra.dao.entity.BaseEntity;
import java.util.Date;
public class Subject extends BaseEntity {
private static final long serialVersionUID = 1995977049110069449L;
// 科目id
private String id;
// 科目名字
private String subjectName;
// 创建人
private String createBy;
// 创建时间
private Date createTime;
// 更新时间
private Date updateTime;
// 是否删除 0不删除 1删除
private Boolean isDelete;
// 科目编号
private String subjectNo;
public Subject(String id, String subjectName, String createBy, Date createTime, Date updateTime, Boolean isDelete, String subjectNo) {
this.id = id;
this.subjectName = subjectName;
this.createBy = createBy;
this.createTime = createTime;
this.updateTime = updateTime;
this.isDelete = isDelete;
this.subjectNo = subjectNo;
}
public Subject() {
}
public Date getCreateTime() {
return createTime;
}
public String getSubjectNo() {
return subjectNo;
}
public void setSubjectNo(String subjectNo) {
this.subjectNo = subjectNo;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSubjectName() {
return subjectName;
}
public void setSubjectName(String subjectName) {
this.subjectName = subjectName;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime(Date date) {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Boolean getDelete() {
return isDelete;
}
public void setDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
}
package com.ekingwin.bas.cloud.exam.dto.entity;
import com.ekingwin.bas.cloud.infra.dao.entity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 试卷
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "BAS_EXAM_TEST")
public class TestPapers extends BaseEntity {
private static final long serialVersionUID = -4396960034746549794L;
@Transient
private String id;
//编号及名称
private String codeName;
// 试卷id
@Id
@Column(name = "TEST_ID")
private String testId;
//bpm流程id
private String bpmId;
// 所属科目
private String subjectId;
// 试卷名字
private String testName;
// 该试卷总分
@Column(name ="total_score")
private long totalScore;
// 创建时间
private Date createTime;
// 更新时间
@Transient
private Date updateTime;
// 是否删除 0不删除 1删除
private Boolean isDelete;
// 创建人empuid
private String createBy;
// 中文名称
@Transient
private String cnname;
// 是否已做
@Transient
private Boolean done;
// 是否自定义
@Transient
private Boolean DIY;
// 所属科目名字
@Transient
private String belongSubject;
//合格分数
private Integer passScore;
// 答题人所属部门
@Transient
private String department;
// 试题
@Transient
private List<Question> questions;
public Boolean getDelete() {
return isDelete;
}
public void setDelete(Boolean delete) {
isDelete = delete;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCodeName() {
return codeName;
}
public void setCodeName(String codeName) {
this.codeName = codeName;
}
public String getTestId() {
return testId;
}
public void setTestId(String testId) {
this.testId = testId;
}
public String getSubjectId() {
return subjectId;
}
public void setSubjectId(String subjectId) {
this.subjectId = subjectId;
}
public String getTestName() {
return testName;
}
public void setTestName(String testName) {
this.testName = testName;
}
public long getTotalScore() {
return totalScore;
}
public void setTotalScore(long totalScore) {
this.totalScore = totalScore;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Boolean getDone() {
return done;
}
public void setDone(Boolean done) {
this.done = done;
}
public Boolean getDIY() {
return DIY;
}
public void setDIY(Boolean dIY) {
DIY = dIY;
}
public String getBelongSubject() {
return belongSubject;
}
public void setBelongSubject(String belongSubject) {
this.belongSubject = belongSubject;
}
public Integer getPassScore() {
return passScore;
}
public void setPassScore(Integer passScore) {
this.passScore = passScore;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public List<Question> getQuestions() {
return questions;
}
public void setQuestions(List<Question> questions) {
this.questions = questions;
}
public String getBpmId() {
return bpmId;
}
public void setBpmId(String bpmId) {
this.bpmId = bpmId;
}
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestPapers that = (TestPapers) o;
return Objects.equals(testName, that.testName);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), testName);
}
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import java.util.Map;
public interface AnswerService {
Map<String,Object> checkAndSaveAnswer(TestPapers test);
String scoreToBpm(Score score);
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dto.entity.Question;
import com.github.pagehelper.PageInfo;
import java.util.List;
public interface QuestionsService {
/**
* 批量添加试题
* @param questions
* @return
*/
int addQuestions(List<Question> questions);
int addQuestion(Question question, Boolean diy);
/**
* 根据科目编号获取试题
* @param subjectId
* @return
*/
PageInfo<Question> queryQuestionsBySubjectId(String subjectId, Integer startPage, Integer pageSize);
/**
* 批量修改试题
* @param questions
* @return
*/
int editQuestions(List<Question> questions);
int editQuestion(Question question);
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dto.entity.Score;
import com.ekingwin.bas.cloud.infra.dto.QueryDTO;
import com.ekingwin.bas.cloud.infra.exception.BasException;
import com.ekingwin.bas.cloud.infra.service.IBaseEntityService;
import com.ekingwin.bas.cloud.infra.utils.db.PageCriteria;
/**
*
*/
public interface ScoreService extends IBaseEntityService<Score> {
/**
*
* @param queryTestVO
* @return
* @throws BasException
*/
PageCriteria<Score> queryScoreInfo(QueryDTO queryTestVO) throws BasException;
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dto.QuerySubjectVO;
import com.ekingwin.bas.cloud.exam.dto.SubjectVerifyVO;
import com.ekingwin.bas.cloud.exam.dto.entity.Subject;
import com.github.pagehelper.PageInfo;
public interface SubjectService {
/**
* 添加科目
*
* @param subject
* @return
*/
int addSubject(Subject subject);
/**
* 根据id删除科目
*
* @param id
* @return
*/
int delSubjectById(String id);
/**
* 查询科目
*
* @return
*/
PageInfo<Subject> querySubject(QuerySubjectVO querySubjectVO);
/**
* 修改科目信息
*
* @param subject
* @return
*/
int changeSubjectInfo(Subject subject);
/**
* 验证是否存在
* @param subject
* @return
*/
SubjectVerifyVO verify(Subject subject);
}
package com.ekingwin.bas.cloud.exam.service;
import com.ekingwin.bas.cloud.exam.dto.QueryTestVO;
import com.ekingwin.bas.cloud.exam.dto.entity.TestPapers;
import com.ekingwin.bas.cloud.infra.dto.QueryDTO;
import com.ekingwin.bas.cloud.infra.exception.BasException;
import com.ekingwin.bas.cloud.infra.service.IBaseEntityService;
import com.ekingwin.bas.cloud.infra.utils.db.PageCriteria;
import java.util.List;
public interface TestPaperService extends IBaseEntityService<TestPapers> {
/**
* 创建试卷
*
* @param test
* @return
*/
int createTest(TestPapers test);
/**
* 查询我的所有试卷
*
* @return
*/
List<TestPapers> queryMyAllTest();
/**
* 查询试卷详情
*
* @param queryTestVO
* @return
*/
TestPapers queryTestDetails(QueryTestVO queryTestVO);
int deleteTestPapers(String ids);
PageCriteria<TestPapers> queryTestPapers(QueryDTO query) throws BasException;
TestPapers getTestPapersDetailsInfo(String id);
/**
* 修改
*
* @param test
* @return
*/
int editTest(TestPapers test);
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>bas-cloud-exam</artifactId>
<groupId>com.ekingwin</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bas-cloud-exam-runner</artifactId>
<dependencies>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-exam-impl</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>persistence-api</artifactId>
<groupId>javax.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-exam-api</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-cache-redis</artifactId>
</dependency>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-oam-org-impl</artifactId>
<version>${bas-oam.version}</version>
<exclusions>
<exclusion>
<artifactId>persistence-api</artifactId>
<groupId>javax.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.ekingwin.bas.cloud.exam;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.ekingwin.bas.cloud.infra.dto.BaseResult;
import com.ekingwin.bas.cloud.infra.utils.common.ResultUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.spring.annotation.MapperScan;
/**
* demo项目,作为演示使用,各个项目可以参照改demo来构建启动项目,
* 不要直接使用该项目进行开发,需要参考该项目的配置,重新创建一个新的项目进行开发
*
* @author chenjb
*/
@EnableDiscoveryClient
@RefreshScope
@RestController
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@ComponentScan({"com.ekingwin.bas.cloud"})
@MapperScan({"com.ekingwin.bas.cloud.**.dao"})
@EnableTransactionManagement
@EnableCaching
@ServletComponentScan(basePackages = "com.ekingwin.bas.cloud")
public class DemoServiceApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoServiceApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(DemoServiceApplication.class, args);
}
@GetMapping(value = "/get/{id}")
public BaseResult<String> get(@PathVariable String id) {
String result = id + ":" + prop;
return ResultUtils.build(result);
}
@Value("${test}")
private String prop;
}
package com.ekingwin.bas.cloud.exam.config;
import com.alibaba.druid.support.http.WebStatFilter;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*",
initParams={
@WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源
})
public class DruidFilter extends WebStatFilter {
}
\ No newline at end of file
package com.ekingwin.bas.cloud.exam.config;
import com.alibaba.druid.support.http.StatViewServlet;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
@WebServlet(urlPatterns = "/druid/*",
initParams={
// @WebInitParam(name="allow",value="192.168.16.110,127.0.0.1"),// IP白名单 (没有配置或者为空,则允许所有访问)
// @WebInitParam(name="deny",value="192.168.16.111"),// IP黑名单 (存在共同时,deny优先于allow)
@WebInitParam(name="loginUsername",value="admin"),// 用户名
@WebInitParam(name="loginPassword",value="admin"),// 密码
@WebInitParam(name="resetEnable",value="false")// 禁用HTML页面上的“Reset All”功能
})
public class DruidServlet extends StatViewServlet {
/**
*
*/
private static final long serialVersionUID = 3027129555878842910L;
}
\ No newline at end of file
server.port=8000
server.servlet.context-path=/test
#database
spring.datasource.dynamic.p6spy=true
spring.datasource.dynamic.datasource.master.username=demo
spring.datasource.dynamic.datasource.master.password=Ekingwin123
spring.datasource.dynamic.datasource.master.url=jdbc:mysql://test1.jiucaiyun.cn:3306/demo?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
#\u6253\u5370mybatis\u7684sql\u8BED\u53E5\uFF08\u4E0E\u4E0B\u9762\u7684\u65E5\u5FD7\u914D\u7F6E\u4E8C\u9009\u4E00\u5373\u53EF\uFF09
spring.datasource.dynamic.druid.stat.log-slow-sql=true
spring.datasource.dynamic.druid.stat.slow-sql-millis=10000
#\u65E5\u5FD7
logging.level.root=DEBUG
#\u8BBE\u4E3ADEBUG\uFF0C\u53EF\u6253\u5370mybatis\u7684sql\u8BED\u53E5
logging.level.com.ekingwin.bas=DEBUG
logging.level.jdbc.sqlonly=INFO
logging.level.org.quartz=WARN
#redis
spring.redis.host=test3.jiucaiyun.cn
spring.redis.port=6379
spring.redis.password=Password1
bas.cloud.core.id.generator.mark=2-5
bas.security.permitAllUrl=/actuator/**
ScoreToBpm=http://bpapr.lj028.cn:8092/bpm/common/parameter/saveKsInfo
feign.hystrix.enabled=false
#\u66FF\u6362\u6389JDK\u9ED8\u8BA4HttpURLConnection\u5B9E\u73B0\u7684 Http Client
feign.httpclient.enabled=true
feign.client.config.remote-service.connectTimeout=5000
feign.client.config.remote-service.readTimeout=12000
ribbon.eager-load.enabled=true
#\u8BF4\u660E\uFF1A\u540C\u4E00\u53F0\u5B9E\u4F8B\u7684\u6700\u5927\u81EA\u52A8\u91CD\u8BD5\u6B21\u6570\uFF0C\u9ED8\u8BA4\u4E3A1\u6B21\uFF0C\u4E0D\u5305\u62EC\u9996\u6B21
ribbon.MaxAutoRetries=1
#\u8BF4\u660E\uFF1A\u8981\u91CD\u8BD5\u7684\u4E0B\u4E00\u4E2A\u5B9E\u4F8B\u7684\u6700\u5927\u6570\u91CF\uFF0C\u9ED8\u8BA4\u4E3A1\uFF0C\u4E0D\u5305\u62EC\u7B2C\u4E00\u6B21\u88AB\u8C03\u7528\u7684\u5B9E\u4F8B
ribbon.MaxAutoRetriesNextServer=1
#\u8BF4\u660E\uFF1A\u662F\u5426\u6240\u6709\u7684\u64CD\u4F5C\u90FD\u91CD\u8BD5\uFF0C\u9ED8\u8BA4\u4E3Atrue
ribbon.OkToRetryOnAllOperations=true
#\u8BF4\u660E\uFF1A\u4ECE\u6CE8\u518C\u4E2D\u5FC3\u5237\u65B0\u670D\u52A1\u5668\u5217\u8868\u4FE1\u606F\u7684\u65F6\u95F4\u95F4\u9694\uFF0C\u9ED8\u8BA4\u4E3A2000\u6BEB\u79D2\uFF0C\u53732\u79D2
ribbon.ServerListRefreshInterval=2000
#\u8BF4\u660E\uFF1A\u4F7F\u7528Apache HttpClient\u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2
ribbon.ConnectTimeout=5000
#\u8BF4\u660E\uFF1A\u4F7F\u7528Apache HttpClient\u8BFB\u53D6\u7684\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2
ribbon.ReadTimeout=5000
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
\ No newline at end of file
############################################BASIC START############################################
spring.profiles.active=dev
spring.application.name=bas-exam
server.servlet.context-path=/bas-exam
#management.security.enabled=false
############################################BASIC END############################################
############################################MYBATIS START############################################
#mybatis
mybatis.type-aliases-package=com.ekingwin.bas.cloud
mybatis.mapper-locations=classpath*:/mapper/**/*Mapper.xml
mapper.mappers=com.ekingwin.bas.mapper.BasMapper,com.ekingwin.bas.mapper.BasTreeMapper,com.ekingwin.bas.mapper.ObjectTemplateRecodeJoinMapper
mapper.not-empty=false
mapper.before=true
pagehelper.helperDialect=mysql
#\u5206\u9875\u5408\u7406\u5316\uFF0C\u9488\u5BF9\u4E0D\u5408\u7406\u7684\u4EE3\u7801\u81EA\u52A8\u5904\u7406
pagehelper.reasonable=true
#\u5206\u9875\u63D2\u4EF6\u4F1A\u4ECE\u67E5\u8BE2\u65B9\u6CD5\u7684\u53C2\u6570\u503C\u4E2D\uFF0C\u81EA\u52A8\u6839\u636E\u4E0A\u9762 params \u914D\u7F6E\u7684\u5B57\u6BB5\u4E2D\u53D6\u503C\uFF0C\u67E5\u627E\u5230\u5408\u9002\u7684\u503C\u65F6\u5C31\u4F1A\u81EA\u52A8\u5206\u9875\u3002
pagehelper.supportMethodsArguments=true
############################################MYBATIS END############################################
############################################MAIL START############################################
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=false
bas.cloud.mail.mq.listener=false
############################################MAIL END############################################
############################################DATASOURCE START############################################
#\u6307\u5B9A\u521D\u59CB\u5316\u6570\u636E\u6E90\uFF0C\u662F\u5426\u7528data.sql\u6765\u521D\u59CB\u5316\uFF0C\u9ED8\u8BA4: true
#\u5982\u679C\u4F60\u7684\u5E94\u7528\u4E0D\u4F9D\u8D56\u4E8E\u6570\u636E\u5E93\uFF0C\u5219\u4E00\u5B9A\u8981\u662Ffalse\uFF0C\u5426\u5219\u4F1A\u62A5\u9519
spring.datasource.initialization-mode=never
#spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.dynamic.datasource.master.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.dynamic.datasource.master.druid.validation-query=select 1
spring.datasource.dynamic.datasource.master.druid.test-on-borrow=true
spring.datasource.dynamic.datasource.master.druid.wall.comment-allow=true
############################################DATASOURCE END############################################
############################################FREEMARKER START############################################
spring.freemarker.cache=true
spring.freemarker.suffix=.ftl
############################################FREEMARKER END############################################
############################################REDIS START############################################
#\u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.lettuce.pool.max-active=100
#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.lettuce.pool.max-idle=100
#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.lettuce.pool.min-idle=50
#\u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.lettuce.pool.max-wait=6000
spring.redis.timeout=5000
spring.redis.database=15
bas.cloud.cache.redis.ttl=300
############################################REDIS END############################################
#strict\u4E25\u683C\u6A21\u5F0F loose\u5BBD\u677E\u6A21\u5F0F
bas.security.login.authorityMode=loose
############################################SWAGGER OAUTH2 START############################################
bas.cloud.base.app.desc=bas-exam
bas.cloud.base.app.version=1.0.0
bas.cloud.base.app.name=Organization Authority Manage API
############################################SWAGGER OAUTH2 END############################################
############################################i18N START############################################
spring.messages.basename=i18n/messages
#spring.messages.cacheDuration
spring.messages.useCodeAsDefaultMessage=true
############################################i18N END############################################
bas.authority.admin=test04
bas.authority.role.adminRole=test04
spring.main.allow-bean-definition-overriding=true
88888888ba, 88888888888 88b d88 ,ad8888ba,
88 `"8b 88 888b d888 d8"' `"8b
88 `8b 88 88`8b d8'88 d8' `8b
88 88 88aaaaa 88 `8b d8' 88 88 88
88 88 88""""" 88 `8b d8' 88 88 88
88 8P 88 88 `8b d8' 88 Y8, ,8P
88 .a8P 88 88 `888' 88 Y8a. .a8P
88888888Y"' 88888888888 88 `8' 88 `"Y8888Y"'
\ No newline at end of file
#spring:
# cloud:
# consul:
# config:
# enabled: false
# discovery:
# register: false
# application:
# name: bas-cloud-demo
spring:
profiles:
include:
aaa
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
\ No newline at end of file
bas.security.resetpwd.original.invalid=\u539F\u59CB\u5BC6\u7801\u4E0D\u6B63\u786E
\ No newline at end of file
bas.security.resetpwd.original.invalid=\u539F\u59CB\u5BC6\u7801\u4E0D\u6B63\u786E
AbstractUserDetailsAuthenticationProvider.badCredentials=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
AbstractAccessDecisionManager.accessDenied=\u6B64\u7528\u6237\u672A\u6388\u6743
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- 配置日志文件输出目录 -->
<property name="APP_NAME" value="demo" />
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${user.home}/logs/${APP_NAME}/debug.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %X{type} - %X{requestId} %logger{50} - %m%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${user.home}/logs/${APP_NAME}/${date:yyyy-MM}/debug-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${user.home}/logs/${APP_NAME}/info.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %X{type} - %X{requestId} %logger{50} - %m%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${user.home}/logs/${APP_NAME}/${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${user.home}/logs/${APP_NAME}/warn.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %X{type} - %X{requestId} %logger{50} - %m%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${user.home}/logs/${APP_NAME}/${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${user.home}/logs/${APP_NAME}/error.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %X{type} - %X{requestId} %logger{50} - %m%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${user.home}/logs/${APP_NAME}/${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、
以及指定<appender>。<logger>仅有一个name属性,
一个可选的level和一个可选的addtivity属性。
name:用来指定受此logger约束的某一个包或者具体的某一个类。
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
如果未设置此属性,那么当前logger将会继承上级的级别。
addtivity:是否向上级logger传递打印信息。默认是true。
-->
<!--<logger name="org.springframework.web" level="info"/>-->
<!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
<!--
使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
-->
<!--
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
不能设置为INHERITED或者同义词NULL。默认是DEBUG
可以包含零个或多个元素,标识这个appender将会添加到这个logger。
-->
<!--开发环境:打印控制台-->
<springProfile name="dev">
<logger name="com.ekingwin.bas" level="debug"/>
</springProfile>
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
<!--生产环境:输出到文件-->
<!--<springProfile name="pro">-->
<!--<root level="info">-->
<!--<appender-ref ref="CONSOLE" />-->
<!--<appender-ref ref="DEBUG_FILE" />-->
<!--<appender-ref ref="INFO_FILE" />-->
<!--<appender-ref ref="ERROR_FILE" />-->
<!--<appender-ref ref="WARN_FILE" />-->
<!--</root>-->
<!--</springProfile>-->
</configuration>
\ No newline at end of file
ExceptionTranslationFilter.insufficientAuthentication=\u7528\u6237\u672A\u767B\u5F55
AbstractAccessDecisionManager.accessDenied=\u6B64\u7528\u6237\u672A\u6388\u6743
AbstractLdapAuthenticationProvider.emptyPassword=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
AbstractSecurityInterceptor.authenticationNotFound=\u672A\u5728SecurityContext\u4E2D\u67E5\u627E\u5230\u8BA4\u8BC1\u5BF9\u8C61
AbstractUserDetailsAuthenticationProvider.badCredentials=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F
AbstractUserDetailsAuthenticationProvider.disabled=\u7528\u6237\u5DF2\u5931\u6548
AbstractUserDetailsAuthenticationProvider.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F
AbstractUserDetailsAuthenticationProvider.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A
AbstractUserDetailsAuthenticationProvider.onlySupports=\u4EC5\u4EC5\u652F\u6301UsernamePasswordAuthenticationToken
AccountStatusUserDetailsChecker.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F
AccountStatusUserDetailsChecker.disabled=\u7528\u6237\u5DF2\u5931\u6548
AccountStatusUserDetailsChecker.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F
AccountStatusUserDetailsChecker.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A
AclEntryAfterInvocationProvider.noPermission=\u7ED9\u5B9A\u7684Authentication\u5BF9\u8C61({0})\u6839\u672C\u65E0\u6743\u64CD\u63A7\u9886\u57DF\u5BF9\u8C61({1})
AnonymousAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684AnonymousAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
BindAuthenticator.badCredentials=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
BindAuthenticator.emptyPassword=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
CasAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684CasAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
CasAuthenticationProvider.noServiceTicket=\u672A\u80FD\u591F\u6B63\u786E\u63D0\u4F9B\u5F85\u9A8C\u8BC1\u7684CAS\u670D\u52A1\u7968\u6839
ConcurrentSessionControlAuthenticationStrategy.exceededAllowed=\u5DF2\u7ECF\u8D85\u8FC7\u4E86\u5F53\u524D\u4E3B\u4F53({0})\u88AB\u5141\u8BB8\u7684\u6700\u5927\u4F1A\u8BDD\u6570\u91CF
DigestAuthenticationFilter.incorrectRealm=\u54CD\u5E94\u7ED3\u679C\u4E2D\u7684Realm\u540D\u5B57({0})\u540C\u7CFB\u7EDF\u6307\u5B9A\u7684Realm\u540D\u5B57({1})\u4E0D\u543B\u5408
DigestAuthenticationFilter.incorrectResponse=\u9519\u8BEF\u7684\u54CD\u5E94\u7ED3\u679C
DigestAuthenticationFilter.missingAuth=\u9057\u6F0F\u4E86\u9488\u5BF9'auth' QOP\u7684\u3001\u5FC5\u987B\u7ED9\u5B9A\u7684\u6458\u8981\u53D6\u503C; \u63A5\u6536\u5230\u7684\u5934\u4FE1\u606F\u4E3A{0}
DigestAuthenticationFilter.missingMandatory=\u9057\u6F0F\u4E86\u5FC5\u987B\u7ED9\u5B9A\u7684\u6458\u8981\u53D6\u503C; \u63A5\u6536\u5230\u7684\u5934\u4FE1\u606F\u4E3A{0}
DigestAuthenticationFilter.nonceCompromised=Nonce\u4EE4\u724C\u5DF2\u7ECF\u5B58\u5728\u95EE\u9898\u4E86\uFF0C{0}
DigestAuthenticationFilter.nonceEncoding=Nonce\u672A\u7ECF\u8FC7Base64\u7F16\u7801; \u76F8\u5E94\u7684nonce\u53D6\u503C\u4E3A {0}
DigestAuthenticationFilter.nonceExpired=Nonce\u5DF2\u7ECF\u8FC7\u671F/\u8D85\u65F6
DigestAuthenticationFilter.nonceNotNumeric=Nonce\u4EE4\u724C\u7684\u7B2C1\u90E8\u5206\u5E94\u8BE5\u662F\u6570\u5B57\uFF0C\u4F46\u7ED3\u679C\u5374\u662F{0}
DigestAuthenticationFilter.nonceNotTwoTokens=Nonce\u5E94\u8BE5\u7531\u4E24\u90E8\u5206\u53D6\u503C\u6784\u6210\uFF0C\u4F46\u7ED3\u679C\u5374\u662F{0}
DigestAuthenticationFilter.usernameNotFound=\u7528\u6237\u540D{0}\u672A\u627E\u5230
JdbcDaoImpl.noAuthority=\u6CA1\u6709\u4E3A\u7528\u6237{0}\u6307\u5B9A\u89D2\u8272
JdbcDaoImpl.notFound=\u672A\u627E\u5230\u7528\u6237{0}
LdapAuthenticationProvider.badCredentials=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
LdapAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F
LdapAuthenticationProvider.disabled=\u7528\u6237\u5DF2\u5931\u6548
LdapAuthenticationProvider.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F
LdapAuthenticationProvider.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A
LdapAuthenticationProvider.emptyUsername=\u7528\u6237\u540D\u4E0D\u5141\u8BB8\u4E3A\u7A7A
LdapAuthenticationProvider.onlySupports=\u4EC5\u4EC5\u652F\u6301UsernamePasswordAuthenticationToken
PasswordComparisonAuthenticator.badCredentials=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
#PersistentTokenBasedRememberMeServices.cookieStolen=Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack.
ProviderManager.providerNotFound=\u672A\u67E5\u627E\u5230\u9488\u5BF9{0}\u7684AuthenticationProvider
RememberMeAuthenticationProvider.incorrectKey=\u5C55\u793ARememberMeAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
RunAsImplAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684RunAsUserToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
SubjectDnX509PrincipalExtractor.noMatching=\u672A\u5728subjectDN\: {0}\u4E2D\u627E\u5230\u5339\u914D\u7684\u6A21\u5F0F
SwitchUserFilter.noCurrentUser=\u4E0D\u5B58\u5728\u5F53\u524D\u7528\u6237
SwitchUserFilter.noOriginalAuthentication=\u4E0D\u80FD\u591F\u67E5\u627E\u5230\u539F\u5148\u7684\u5DF2\u8BA4\u8BC1\u5BF9\u8C61
appender=com.p6spy.engine.spy.appender.Slf4JLogger
customLogMessageFormat=%(executionTime)|%(category)|%(sqlSingleLine)
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTb5LusXlzft4n9zg7bmeB39QD
fKlBTZQdwiG+4w9EKxTKYpbP4hPgZrK9/lYYPTtYjb9FYVUTRKWBMCiL16dEtB6N
0hpbYuT2UCiiIYqxGrBTdVbBGEY7L20bvGu8nur3Zqs1A/710icS18ZdvZINyNa3
o3oiQruIGm0lokrrxQIDAQAB
-----END PUBLIC KEY-----
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-exam</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>bas-cloud-exam-model</module>
<module>bas-cloud-exam-impl</module>
<module>bas-cloud-exam-api</module>
<module>bas-cloud-exam-runner</module>
</modules>
<properties>
<java.version>1.8</java.version>
<bas.version>3.2.2-SNAPSHOT</bas.version>
<bas-oam.version>3.2.1-SNAPSHOT</bas-oam.version>
<springcloud.version>Hoxton.SR9</springcloud.version>
<springcloud-alibaba.version>2.2.5.RELEASE</springcloud-alibaba.version>
<springboot.version>2.3.3.RELEASE</springboot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.ekingwin</groupId>
<artifactId>bas-cloud-dependencies</artifactId>
<version>${bas.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${springcloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${springcloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment