Commit 29523757 authored by YangZhaoJun1's avatar YangZhaoJun1

新增练习

parent 25aa79ad
*.idea
*.iml
target/
.settings/
.classpath
.project
.gitignore
application-dev.yml.bak
logback-spring.xml.bak
\ No newline at end of file
......@@ -171,9 +171,10 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value="分数列表", notes="根据章节id获取分数列表")
@ApiImplicitParams({@ApiImplicitParam(name = "stuInfo", value = "学生学号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "classInfo", value = "班级编号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "chapterId", value = "章节主键", required = true, dataType = "varchar")})
@GetMapping(value = "/queryScoreListByChapterId")
public GridModel queryScoreListByChapterId(QueryScoreListDTO dto) {
@GetMapping(value = "/queryScoreListByChapterIdByPagination")
public GridModel queryScoreListByChapterIdByPagination(QueryScoreListDTO dto) {
bChapterService.queryScoreListByChapterIdByPagination(getPaginationUtility(), dto);
GridModel gridModel = getGridModelResponse();
return gridModel;
......
......@@ -67,7 +67,7 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* @return
*/
@Select("<script>SELECT\n" +
"\tt1.chapter_name,t5.class_name,t3.`code`,t6.`name`,t2.score,t3.business_id as sId,t2.business_id as scoreId\n" +
"\tt1.chapter_name,t2.automatic,t5.class_name,t3.`code`,t6.`name`,t2.score,t3.business_id as sId,t2.business_id as scoreId\n" +
"FROM\n" +
"\tb_chapter t1\n" +
"\tLEFT JOIN b_r_student_chapter t2 ON t2.chapter_id = t1.`business_id`\n" +
......@@ -76,15 +76,14 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"\tLEFT JOIN b_class t5 ON t5.`code` = t4.class_code\n" +
"\tLEFT JOIN s_user t6 ON t6.login_name = t3.`code`\n" +
"WHERE t1.del_flag='0' and t1.flag='1' and t2.is_complete='1' " +
"\nand t2.`score` <if test=\"hasMark\">!=</if> <if test=\"!hasMark\">=</if> -1" +
"\nand t2.`score` != -1" +
"\tand t1.business_id = #{dto.chapterId}\n" +
"\tand (" +
"(t3.code like #{dto.stuInfo} or t6.name like #{dto.stuInfo})\n" +
"\tor " +
"(t5.code like #{dto.stuInfo} or t5.class_name like #{dto.stuInfo})" +
")</script>")
"<if test=\"dto.stuInfo !=null and dto.stuInfo !=''\">AND (t3.code like CONCAT('%',#{dto.stuInfo}.'%') or t6.name like CONCAT('%',#{dto.stuInfo}.'%')) </if> \n" +
"<if test=\"dto.automatic !=null and dto.automatic !=''\">AND t2.automatic = #{dto.stuInfo} </if> \n" +
"<if test=\"dto.classInfo !=null and dto.classInfo !=''\">AND t5.code like like CONCAT('%',#{dto.classInfo}.'%') </if> \n" +
"</script>")
@ResultMap("QueryScoreListByChapterIdResultMap")
List<StudentChapterScoreVO> queryScoreListByChapterId(@Param("dto") QueryScoreListDTO dto, @Param("hasMark") boolean hasMark);
List<StudentChapterScoreVO> queryScoreListByChapterId(@Param("dto") QueryScoreListDTO dto);
/**
* 根据课程id和学生id查找该学生所学课程分数列表
......@@ -133,7 +132,7 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* @param scoreInfoDTO
* @return
*/
@Update("<script>update b_r_student_chapter set chapter_id=#{chapterId},student_id=#{studentId},score=#{score} where business_id = #{businessId}</script>")
@Update("<script>update b_r_student_chapter set chapter_id=#{chapterId},automatic=#{automatic},student_id=#{studentId},score=#{score} where business_id = #{businessId}</script>")
int updateScoreInfo(ScoreInfoDTO scoreInfoDTO);
/**
......@@ -283,9 +282,9 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
int remark(@Param("chapterId") String chapterId, @Param("studentId") String studentId, @Param("score") String score);
@Insert("<script>insert into b_r_student_chapter(" +
"business_id,student_id,chapter_id,is_complete,sl_id,score) " +
"business_id,student_id,chapter_id,is_complete,sl_id,score,automatic) " +
"values (" +
"#{businessId},#{studentId},#{chapterId},'1',#{slId},#{score})</script>")
"#{businessId},#{studentId},#{chapterId},'1',#{slId},#{score},'0')</script>")
int insertStudentScore(String businessId, String chapterId, String slId, String studentId, String score);
......
......@@ -9,6 +9,7 @@ import lombok.Data;
public class QueryScoreListDTO {
private String classInfo;
private String stuInfo;
private String automatic;
private String chapterId;
private Integer hasMark;
}
......@@ -13,6 +13,7 @@ public class ScoreInfoDTO extends IdEntity<ScoreInfoDTO> {
String studentId;
String studentCode;
String isComplete;
String automatic;
String slId;
String filePath;
String examType;
......
......@@ -77,10 +77,7 @@ public class BChapterServiceImpl implements BChapterService {
@Override
public List<StudentChapterScoreVO> queryScoreListByChapterIdByPagination(PageUtil pageUtil, QueryScoreListDTO dto){
boolean result = dto.getHasMark() == HasMarkEnum.HAS_MARK.getCode();
dto.setClassInfo(dto.getClassInfo()==null?"%%":"%"+dto.getClassInfo()+"%");
dto.setStuInfo(dto.getStuInfo()==null?"%%":"%"+dto.getStuInfo()+"%");
return bChapterRepository.queryScoreListByChapterId(dto,result);
return bChapterRepository.queryScoreListByChapterId(dto);
}
@Override
......@@ -173,6 +170,7 @@ public class BChapterServiceImpl implements BChapterService {
throw new ServiceException(ResultServiceEnums.UN_COMPLETE);
}else{ //已经学习则修改
scoreInfoDTO.setBusinessId(id);
scoreInfoDTO.setAutomatic("0");
UserUtil.setCurrentMergeOperation(scoreInfoDTO);
bChapterRepository.updateScoreInfo(scoreInfoDTO);
}
......@@ -488,6 +486,7 @@ public class BChapterServiceImpl implements BChapterService {
int line;
ScoreInfoDTO scoreInfoDTO = bChapterRepository.queryScoreByChapterId(chapterId,studentCode);
if(scoreInfoDTO!=null){//重新打分
scoreInfoDTO.setAutomatic("0");
line=bChapterRepository.remark(chapterId,scoreInfoDTO.getStudentId(),score);
}else {//打分
BStudent student = bStudentRepository.selectOne(new BStudent(studentCode));
......
......@@ -22,4 +22,6 @@ public class StudentChapterScoreVO {
private String sId;
/**分数id**/
private String scoreId;
/*是否智评*/
private String automatic;
}
......@@ -51,7 +51,7 @@ public class TPaperController extends PaginationController<TPaper> {
@ApiOperation(value="逻辑删除", notes="逻辑删除")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")})
@DeleteMapping("/{id:\\d+}")
public Result delete(@PathVariable String id) {
public Result delete(@PathVariable Integer id) {
TPaper tPaper = new TPaper();
tPaper.setBusinessId(id);
tPaper.setToken(getToken());
......@@ -86,7 +86,6 @@ public class TPaperController extends PaginationController<TPaper> {
@ApiOperation(value="查看 集合", notes="查看单 集合")
@GetMapping(value = "/queryTPaperByPagination")
public GridModel listByPagination(TPaper tPaper) {
tPaper.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
tPaperServiceImpl.findAllByPagination(getPaginationUtility(), tPaper);
return getGridModelResponse();
}
......
package org.rcisoft.business.tpaper.dao;
import org.apache.ibatis.annotations.Insert;
import org.rcisoft.business.tpaper.entity.TPaperDetail;
import org.rcisoft.core.base.BaseMapper;
import org.apache.ibatis.annotations.ResultMap;
......@@ -25,5 +26,12 @@ public interface TPaperDetailRepository extends BaseMapper<TPaperDetail> {
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<TPaperDetail> queryTPaperDetails(TPaperDetail tPaperDetail);
@Insert("<script>INSERT INTO t_paper_detail " +
"(p_id,ps_id,q_id,p_score,sorder)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.pId},#{item.psId},#{item.qId},#{item.pScore},#{item.sorder})" +
"</foreach></script>")
int insertList(List<TPaperDetail> tPaperDetails);
}
package org.rcisoft.business.tpaper.dao;
import org.apache.ibatis.annotations.Insert;
import org.rcisoft.business.tpaper.entity.TPaperSection;
import org.rcisoft.business.tpaperchapter.dto.SectionIdDto;
import org.rcisoft.core.base.BaseMapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
......@@ -25,5 +27,20 @@ public interface TPaperSectionRepository extends BaseMapper<TPaperSection> {
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<TPaperSection> queryTPaperSections(TPaperSection tPaperSection);
@Insert("<script>INSERT INTO t_paper_section " +
"(p_id,sdesc,sorder,q_type)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.pId},#{item.sdesc},#{item.sorder},#{item.qType})" +
"</foreach></script>")
int insertList(List<TPaperSection> tPaperSections);
@Select("<script>SELECT \n" +
"(SELECT business_id from t_paper_section where p_id = #{pid} AND q_type = '1')AS choiceId,\n" +
"(SELECT business_id from t_paper_section where p_id = #{pid} AND q_type = '3')AS judgmentId,\n" +
"(SELECT business_id from t_paper_section where p_id = #{pid} AND q_type = '2')AS multiSelectId\n" +
" from t_paper_section </script>")
List<SectionIdDto> querySectionIdByPid(String pid);
}
......@@ -2,6 +2,7 @@ package org.rcisoft.business.tpaper.entity;
import lombok.*;
import org.rcisoft.core.entity.AutoIncrementEntity;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*;
import java.math.BigDecimal;
......@@ -18,9 +19,10 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_paper")
public class TPaper extends IdEntity<TPaper> {
public class TPaper extends AutoIncrementEntity<TPaper> {
private static final long serialVersionUID = 8239396163023570214L;
private String pcId;
......
......@@ -2,6 +2,7 @@ package org.rcisoft.business.tpaper.entity;
import lombok.*;
import org.rcisoft.core.entity.AutoIncrementEntity;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*;
import java.math.BigDecimal;
......@@ -18,9 +19,10 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_paper_detail")
public class TPaperDetail extends IdEntity<TPaperDetail> {
public class TPaperDetail extends AutoIncrementEntity<TPaperDetail> {
private static final long serialVersionUID = -7387975301231354793L;
private String pId;
......
......@@ -2,6 +2,7 @@ package org.rcisoft.business.tpaper.entity;
import lombok.*;
import org.rcisoft.core.entity.AutoIncrementEntity;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*;
import java.math.BigDecimal;
......@@ -18,9 +19,10 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_paper_section")
public class TPaperSection extends IdEntity<TPaperSection> {
public class TPaperSection extends AutoIncrementEntity<TPaperSection> {
private static final long serialVersionUID = -2596263315203973219L;
private String pId;
......@@ -28,6 +30,8 @@ public class TPaperSection extends IdEntity<TPaperSection> {
private Integer sorder;
private String qType;
}
......@@ -38,9 +38,7 @@ public class TPaperServiceImpl implements TPaperService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(TPaper tPaper){
tPaper.setCommonBusinessId();
//增加操作
UserUtil.setCurrentPersistOperation(tPaper);
int line = tPaperRepository.insertSelective(tPaper);
log.info(UserUtil.getUserInfoProp(tPaper.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
tPaper.getBusinessId()+"的信息");
......@@ -55,7 +53,6 @@ public class TPaperServiceImpl implements TPaperService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(TPaper tPaper){
UserUtil.setCurrentMergeOperation(tPaper);
int line = tPaperRepository.logicalDelete(tPaper);
log.info(UserUtil.getUserInfoProp(tPaper.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
tPaper.getBusinessId()+"的信息");
......@@ -70,7 +67,6 @@ public class TPaperServiceImpl implements TPaperService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel merge(TPaper tPaper){
UserUtil.setCurrentMergeOperation(tPaper);
int line = tPaperRepository.updateByPrimaryKeySelective(tPaper);
log.info(UserUtil.getUserInfoProp(tPaper.getToken(),UserUtil.USER_USERNAME)+"修改了ID为"+
tPaper.getBusinessId()+"的信息");
......
......@@ -43,8 +43,10 @@ public class TPaperChapterController extends PaginationController<TPaperChapter>
@ApiImplicitParam(name = "poption", value = "1 随机 2 自主", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "pscope", value = "1 全部 2 本节", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "pcompose", value = "{'1':3,'2':0} 3道选择,2道判断", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "questionsId", value = "题目ID", required = false, dataType = "varchar")})
@PostMapping
@ApiImplicitParam(name = "choiceIds", value = "选择题ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "judgmentIds", value = "判断题ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "multiSelectIds", value = "多选题ID", required = false, dataType = "varchar")})
@PostMapping("/add")
public Result add(TPaperChapter tPaperChapter) {
tPaperChapter.setToken(getToken());
PersistModel data = tPaperChapterServiceImpl.save(tPaperChapter);
......
package org.rcisoft.business.tpaperchapter.dao;
import org.apache.ibatis.annotations.Insert;
import org.rcisoft.business.tpaperchapter.entity.TPaperChapterSection;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by yangzhaojun on 2018/1/26.
*/
@Repository
public interface TPaperChapterSectionRepository extends BaseMapper<TPaperChapterSection> {
@Insert("<script>INSERT INTO t_paper_chapter_section " +
"(pc_id,sdesc,q_num,q_type)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.pcId},#{item.sdesc},#{item.qNum},#{item.qType})" +
"</foreach></script>")
int insertList(List<TPaperChapterSection> tPaperChapterSections);
}
package org.rcisoft.business.tpaperchapter.dto;
import lombok.Data;
/**
* Created by yangzhaojun on 2018/1/26.
*/
@Data
public class SectionIdDto {
private String choiceId;
private String judgmentId;
private String multiSelectId;
}
......@@ -20,7 +20,7 @@ import java.util.List;
@Table(name = "t_paper_chapter")
public class TPaperChapter extends IdEntity<TPaperChapter> {
private static final long serialVersionUID = 5201491638420229438L;
private String pdesc;
......@@ -37,7 +37,13 @@ public class TPaperChapter extends IdEntity<TPaperChapter> {
private String pcompose;
@Transient
private String questionsId;
private String choiceIds;
@Transient
private String judgmentIds;
@Transient
private String multiSelectIds;
}
......
package org.rcisoft.business.tpaperchapter.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.rcisoft.core.entity.AutoIncrementEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* Created by Administrator on 2018/1/26.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_paper_chapter_section")
public class TPaperChapterSection extends AutoIncrementEntity{
private static final long serialVersionUID = -821006305968482843L;
private String pcId;
private String sdesc;
private String qType;
private Integer qNum;
}
package org.rcisoft.business.tpaperchapter.service.impl;
import com.google.gson.Gson;
import org.rcisoft.business.tpaper.dao.TPaperDetailRepository;
import org.rcisoft.business.tpaper.dao.TPaperRepository;
import org.rcisoft.business.tpaper.dao.TPaperSectionRepository;
import org.rcisoft.business.tpaper.entity.TPaper;
import org.rcisoft.business.tpaper.entity.TPaperDetail;
import org.rcisoft.business.tpaper.entity.TPaperSection;
import org.rcisoft.business.tpaperchapter.dao.TPaperChapterSectionRepository;
import org.rcisoft.business.tpaperchapter.dto.SectionIdDto;
import org.rcisoft.business.tpaperchapter.entity.TPaperChapterSection;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
......@@ -15,7 +25,11 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
......@@ -29,6 +43,18 @@ public class TPaperChapterServiceImpl implements TPaperChapterService {
@Autowired
private TPaperChapterRepository tPaperChapterRepository;
@Autowired
private TPaperRepository tPaperRepository;
@Autowired
private TPaperSectionRepository tPaperSectionRepository;
@Autowired
private TPaperChapterSectionRepository tPaperChapterSectionRepository;
@Autowired
private TPaperDetailRepository tPaperDetailRepository;
/**
* 保存 tPaperChapter
......@@ -38,12 +64,85 @@ public class TPaperChapterServiceImpl implements TPaperChapterService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(TPaperChapter tPaperChapter){
tPaperChapter.setCommonBusinessId();
//增加操作
UserUtil.setCurrentPersistOperation(tPaperChapter);
int line = tPaperChapterRepository.insertSelective(tPaperChapter);
log.info(UserUtil.getUserInfoProp(tPaperChapter.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
tPaperChapter.getBusinessId()+"的信息");
if(tPaperChapter.getPoption().equals("2")){
//自主选题
//1.添加试卷表信息
TPaper tPaper = new TPaper();
tPaper.setChapId(tPaperChapter.getChapId());
tPaper.setPcId(tPaperChapter.getBusinessId());
tPaper.setStatus("1");
tPaperRepository.insertSelective(tPaper);
//2.添加大题表信息 记录题型及数量
List<TPaperSection> tPaperSections = new ArrayList<>();
List<TPaperChapterSection> tPaperChapterSections = new ArrayList<>();
//得到试卷ID
TPaper pid = tPaperRepository.selectOne(tPaper);
//数据转为map
Gson gson = new Gson();
Map<String, Object> map = new HashMap<String, Object>();
map = gson.fromJson(tPaperChapter.getPcompose(), map.getClass());
for(int i=0; i<map.size();i++){
String key = String.valueOf(i+1);
TPaperSection tPaperSection = new TPaperSection();
tPaperSection.setPId(String.valueOf(pid.getBusinessId()));
tPaperSection.setQType(key);
tPaperSection.setSorder(i+1);
tPaperSections.add(tPaperSection);
//记录题型及数量
TPaperChapterSection tPaperChapterSection = new TPaperChapterSection();
tPaperChapterSection.setPcId(tPaperChapter.getBusinessId());
tPaperChapterSection.setQType(key);
tPaperChapterSection.setQNum(Double.valueOf(String.valueOf(map.get(key))).intValue());
tPaperChapterSections.add(tPaperChapterSection);
}
//插入数据库
tPaperSectionRepository.insertList(tPaperSections);
tPaperChapterSectionRepository.insertList(tPaperChapterSections);
//3.添加小题表信息
List<TPaperDetail> tPaperDetails = new ArrayList<>();
List<SectionIdDto> sectionIdDto = tPaperSectionRepository.querySectionIdByPid(String.valueOf(pid.getBusinessId()));
int i = 0;
for(String questionId : tPaperChapter.getChoiceIds().split(",")){
TPaperDetail tPaperDetail = new TPaperDetail();
tPaperDetail.setPId(String.valueOf(pid.getBusinessId()));
tPaperDetail.setPsId(sectionIdDto.get(0).getChoiceId());
tPaperDetail.setQId(questionId);
tPaperDetail.setSorder(i);
tPaperDetails.add(tPaperDetail);
i++;
}
int j = 0;
for(String questionId : tPaperChapter.getJudgmentIds().split(",")){
TPaperDetail tPaperDetail = new TPaperDetail();
tPaperDetail.setPId(String.valueOf(pid.getBusinessId()));
tPaperDetail.setPsId(sectionIdDto.get(0).getJudgmentId());
tPaperDetail.setQId(questionId);
tPaperDetail.setSorder(j);
tPaperDetails.add(tPaperDetail);
j++;
}
int k = 0;
for(String questionId : tPaperChapter.getMultiSelectIds().split(",")){
TPaperDetail tPaperDetail = new TPaperDetail();
tPaperDetail.setPId(String.valueOf(pid.getBusinessId()));
tPaperDetail.setPsId(sectionIdDto.get(0).getMultiSelectId());
tPaperDetail.setQId(questionId);
tPaperDetail.setSorder(k);
tPaperDetails.add(tPaperDetail);
k++;
}
tPaperDetailRepository.insertList(tPaperDetails);
}else{
//随机生成
}
return new PersistModel(line);
}
......
package org.rcisoft.business.tquestion.dao;
import org.apache.ibatis.annotations.Param;
import org.rcisoft.business.tquestion.entity.TQuestionOptions;
import org.rcisoft.core.base.BaseMapper;
import org.apache.ibatis.annotations.ResultMap;
......@@ -20,9 +21,10 @@ public interface TQuestionOptionsRepository extends BaseMapper<TQuestionOptions>
*
*/
@Select("<script>select * from t_question_options where 1=1 "
+ "<if test=\"qid !=null and qid != '' \">and qid = #{qid} </if>' "
+ "<if test=\"qid !=null and qid != '' \">and qid = #{qid} </if> " +
"order by alias"
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<TQuestionOptions> queryTQuestionOptions(String qid);
List<TQuestionOptions> queryTQuestionOptions(@Param("qid") String qid);
}
......@@ -43,9 +43,9 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
int deleteByIds(String idInfoList);
@Insert("<script>INSERT INTO t_question_options " +
"(business_id,qid,describe,alias)VALUES " +
"(business_id,qid,represent,alias)VALUES " +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.businessId},#{item.qid},#{item.describe},#{item.alias})" +
"( #{item.businessId},#{item.qid},#{item.represent},#{item.alias})" +
"</foreach></script>")
int insertOptionsList(List<TQuestionOptions> optionList);
}
......
......@@ -45,6 +45,10 @@ public class TQuestion extends IdEntity<TQuestion> {
@Transient
List<TQuestionOptions> options;
@Transient
private String questionOptions;
public TQuestion(String businessId) {
this.businessId = businessId;
}
......
......@@ -26,7 +26,7 @@ public class TQuestionOptions extends IdEntity<TQuestionOptions> {
private String alias;
private String describe;
private String represent;
}
......
package org.rcisoft.business.tquestion.service.impl;
import com.google.gson.Gson;
import org.apache.commons.collections.MapUtils;
import org.json.JSONArray;
import org.rcisoft.business.tquestion.dao.TQuestionOptionsRepository;
......@@ -50,12 +51,20 @@ public class TQuestionServiceImpl implements TQuestionService {
UserUtil.setCurrentPersistOperation(tQuestion);
int line = tQuestionRepository.insertSelective(tQuestion);
//增加选项信息
for(TQuestionOptions option : tQuestion.getOptions()){
option.setCommonBusinessId();
option.setQid(tQuestion.getBusinessId());
List<TQuestionOptions> options = new ArrayList<>();
if(!tQuestion.getQtype().equals("3")){
int i = 0;
for (String option : tQuestion.getQuestionOptions().split(",")){
TQuestionOptions TOptions = new TQuestionOptions();
TOptions.setCommonBusinessId();
TOptions.setQid(tQuestion.getBusinessId());
TOptions.setAlias(String.valueOf(i));
TOptions.setRepresent(option);
options.add(TOptions);
i++;
}
tQuestionRepository.insertOptionsList(options);
}
tQuestionRepository.insertOptionsList(tQuestion.getOptions());
return new PersistModel(line);
}
......@@ -115,7 +124,18 @@ public class TQuestionServiceImpl implements TQuestionService {
@Override
public List<TQuestion> queryTQuestions(TQuestion tQuestion) {
return tQuestionRepository.queryTQuestions(tQuestion);
List<TQuestion> questions = tQuestionRepository.queryTQuestions(tQuestion);
if(questions.size()>0){
for(TQuestion question : questions) {
if(!question.getQtype().equals("3")){
//不是判断题 获取选项
List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(question.getBusinessId());
question.setOptions(options);
}
}
}
return questions;
}
@Override
......@@ -126,7 +146,7 @@ public class TQuestionServiceImpl implements TQuestionService {
@Override
public TQuestion queryTQestionById(String businessId) {
TQuestion tQuestion = tQuestionRepository.selectOne(new TQuestion(businessId));
if(!tQuestion.getQtype().equals("2")){
if(!tQuestion.getQtype().equals("3")){
//选择题 获取选项
List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(tQuestion.getBusinessId());
tQuestion.setOptions(options);
......
package org.rcisoft.core.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
/**
* Created by Administrator on 2018/1/25.
* 自增长
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
public abstract class AutoIncrementEntity<T> implements Serializable {
private static final long serialVersionUID = 4698384920887817032L;
@Id
protected Integer businessId; // 编号
@Transient
protected String token;
}
......@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.tpaper.dao.TPaperDetailRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.tpaper.entity.TPaperDetail">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<id column="business_id" jdbcType="INTEGER" property="businessId"/>
<result column="p_id" jdbcType="VARCHAR" property="pId"/>
<result column="ps_id" jdbcType="VARCHAR" property="psId"/>
<result column="q_id" jdbcType="VARCHAR" property="qId"/>
......
......@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.tpaper.dao.TPaperRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.tpaper.entity.TPaper">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<id column="business_id" jdbcType="INTEGER" property="businessId"/>
<result column="pc_id" jdbcType="VARCHAR" property="pcId"/>
<result column="chap_id" jdbcType="VARCHAR" property="chapId"/>
<result column="p_score" jdbcType="FLOAT" property="pScore"/>
......
......@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.tpaper.dao.TPaperSectionRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.tpaper.entity.TPaperSection">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<id column="business_id" jdbcType="INTEGER" property="businessId"/>
<result column="p_id" jdbcType="VARCHAR" property="pId"/>
<result column="sdesc" jdbcType="VARCHAR" property="sdesc"/>
<result column="sorder" jdbcType="INTEGER" property="sorder"/>
......
<?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="org.rcisoft.business.tpaperchapter.dao.TPaperChapterSectionRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.tpaperchapter.entity.TPaperChapterSection">
<id column="business_id" jdbcType="INTEGER" property="businessId"/>
<result column="sdesc" jdbcType="VARCHAR" property="sdesc"/>
<result column="pc_id" jdbcType="VARCHAR" property="pcId"/>
<result column="q_num" jdbcType="INTEGER" property="qNum"/>
<result column="q_type" jdbcType="VARCHAR" property="qType"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="qid" jdbcType="VARCHAR" property="qid"/>
<result column="alias" jdbcType="VARCHAR" property="alias"/>
<result column="desc" jdbcType="VARCHAR" property="desc"/>
<result column="represent" jdbcType="VARCHAR" property="represent"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
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