Commit 5f3805ad authored by YangZhaoJun1's avatar YangZhaoJun1

试题

parent 438f8539
...@@ -8,6 +8,7 @@ import org.rcisoft.common.component.Global; ...@@ -8,6 +8,7 @@ import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.DelStatus; import org.rcisoft.core.constant.DelStatus;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.util.FileUtil;
import org.rcisoft.core.util.IdGen; import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.OfficeToPdf; import org.rcisoft.core.util.OfficeToPdf;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -237,7 +238,8 @@ public class BFileServiceImpl implements BFileService { ...@@ -237,7 +238,8 @@ public class BFileServiceImpl implements BFileService {
String name = uploadFile.substring(uploadFile.lastIndexOf(File.separator) + 1,uploadFile.lastIndexOf('.')); String name = uploadFile.substring(uploadFile.lastIndexOf(File.separator) + 1,uploadFile.lastIndexOf('.'));
// 截取上传文件的后缀 // 截取上传文件的后缀
String uploadFileSuffix = uploadFile.substring(uploadFile.lastIndexOf('.') + 1, uploadFile.length()); String uploadFileSuffix = FileUtil.getFilePostfix(uploadFile);
//uploadFile.substring(uploadFile.lastIndexOf('.') + 1, uploadFile.length());
// 设置文件名为乱码 // 设置文件名为乱码
String uploadFileName = IdGen.uuid(); String uploadFileName = IdGen.uuid();
......
...@@ -43,12 +43,13 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -43,12 +43,13 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="新增试题", notes="新增试题") @ApiOperation(value="新增试题", notes="新增试题")
@ApiImplicitParams({@ApiImplicitParam(name = "sl_id", value = "课程ID", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "slId", value = "课程ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chap_id", value = "章ID", required = false, dataType = "varchar"), @ApiImplicitParam(name = "chapId", value = "章ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "qtype", value = "1 选择题 2 多选题 3 判断题", required = true, dataType = "varchar"), @ApiImplicitParam(name = "qtype", value = "1 选择题 2 多选题 3 判断题", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "qtitle", value = "题干", required = true, dataType = "varchar"), @ApiImplicitParam(name = "qtitle", value = "题干", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "qdesc", value = "解析", required = false, dataType = "varchar"), @ApiImplicitParam(name = "qdesc", value = "解析", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "qanswer", value = "单选从0开始;判断:0错误 1正确;多选 0,1,2", required = true, dataType = "varchar")}) @ApiImplicitParam(name = "qanswer", value = "单选从0开始;判断:0错误 1正确;多选 0,1,2", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "questionOptions", value = "选项", required = true, dataType = "varchar")})
@PostMapping("/add") @PostMapping("/add")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
public Result add(TQuestion tQuestion) { public Result add(TQuestion tQuestion) {
...@@ -59,32 +60,6 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -59,32 +60,6 @@ public class TQuestionController extends PaginationController<TQuestion> {
tQuestion); tQuestion);
} }
@ApiOperation(value = "新增选项",notes = "新增加一个选项")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "qid", value = "题目id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "alias", value = "列别名", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "desc", value = "列描述", required = true, dataType = "varchar")})
@PostMapping("/addOption")
@PreAuthorize("hasRole('ROLE_1002')")
public Result addoption(@PathVariable TQuestionOptions tQuestionOptions){
PersistModel data = tQuestionServiceImpl.saveoption(tQuestionOptions);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
tQuestionOptions);
}
@ApiOperation(value="删除选项", notes="根据ID删除一个选项")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")})
@PostMapping("/removeOption")
@PreAuthorize("hasRole('ROLE_1002')")
public Result deleteOption(@PathVariable String id) {
return Result.builder(new PersistModel(tQuestionServiceImpl.removeOption(id,getToken())),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
id);
}
@ApiOperation(value="删除题目", notes="根据ID删除一个题") @ApiOperation(value="删除题目", notes="根据ID删除一个题")
@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar") @ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")
...@@ -110,10 +85,17 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -110,10 +85,17 @@ public class TQuestionController extends PaginationController<TQuestion> {
} }
@ApiOperation(value="修改", notes="修改") @ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "章ID", required = true, dataType = "varchar"),
@PutMapping("/{id:\\d+}") @ApiImplicitParam(name = "slId", value = "课程ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "chapId", value = "章ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "qtype", value = "1 选择题 2 多选题 3 判断题", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "qtitle", value = "题干", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "qdesc", value = "解析", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "qanswer", value = "单选从0开始;判断:0错误 1正确;多选 0,1,2", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "questionOptions", value = "选项", required = false, dataType = "varchar")})
@PostMapping("/update")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
public Result update(@Valid TQuestion tQuestion, BindingResult bindingResult) { public Result update(TQuestion tQuestion) {
tQuestion.setToken(getToken()); tQuestion.setToken(getToken());
PersistModel data = tQuestionServiceImpl.merge(tQuestion); PersistModel data = tQuestionServiceImpl.merge(tQuestion);
return Result.builder(data, return Result.builder(data,
...@@ -134,16 +116,17 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -134,16 +116,17 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="根据条件分页查询", notes="根据URL中的参数分页查询") @ApiOperation(value="根据条件分页查询", notes="根据URL中的参数分页查询")
@ApiImplicitParams({@ApiImplicitParam(name = "qtype" , value = "题目类型" , required = false , dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "qtype" , value = "题目类型" , required = false , dataType = "varchar"),
@ApiImplicitParam(name = "qtitle" , value = "关键字" , required = false , dataType = "varchar")}) @ApiImplicitParam(name = "qtitle" , value = "关键字" , required = false , dataType = "varchar"),
@ApiImplicitParam(name = "slId" , value = "课程ID" , required = true , dataType = "varchar")})
@GetMapping(value = "/queryTQuestionByPagination") @GetMapping(value = "/queryTQuestionByPagination")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
public GridModel listByPagination(TQuestion tQuestion) { public GridModel listByPagination(TQuestion tQuestion) {
tQuestion.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID)); //tQuestion.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
tQuestionServiceImpl.findAllByPagination(getPaginationUtility(), tQuestion); tQuestionServiceImpl.findAllByPagination(getPaginationUtility(), tQuestion);
return getGridModelResponse(); return getGridModelResponse();
} }
@ApiOperation(value="根据条件查询", notes="根据URL中的参数查询全部") @ApiOperation(value="根据条件查询(不分页)", notes="根据URL中的参数查询全部")
@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar") @ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")
@GetMapping(value = "/queryTQestions") @GetMapping(value = "/queryTQestions")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
...@@ -154,4 +137,16 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -154,4 +137,16 @@ public class TQuestionController extends PaginationController<TQuestion> {
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
tQuestionServiceImpl.queryTQuestions(tQuestion)); tQuestionServiceImpl.queryTQuestions(tQuestion));
} }
@ApiOperation(value="题目详情", notes="根据题目ID获取题目详情")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
@GetMapping(value = "/queryTQestionById")
@PreAuthorize("hasRole('ROLE_1002')")
public Result queryTQestionById(String BusinessId) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
tQuestionServiceImpl.queryTQestionById(BusinessId));
}
} }
...@@ -20,25 +20,24 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> { ...@@ -20,25 +20,24 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
* 分页查询 tQuestion * 分页查询 tQuestion
* *
*/ */
@Select("<script>select * from t_question where 1=1 " @Select("<script>select * from t_question where sl_id = #{slId} "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> " + "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> " + "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "<if test=\"qtype != null and qtype != '' \">and qtype = #{qtype} </if>" + "<if test=\"qtype != null and qtype != '' \">and qtype = #{qtype} </if>"
+ "<if test=\"qtitle != null and qtitle != '' \">and qtitle LIKE CONCAT ('%',#{qtitle},'%')</if>" + "<if test=\"qtitle != null and qtitle != '' \">and qtitle LIKE CONCAT ('%',#{qtitle},'%')</if>"
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<TQuestion> queryTQuestionsByPagination(TQuestion tQuestion); List<TQuestion> queryTQuestions(TQuestion tQuestion);
@Select("<script>select * " /*@Select("<script>select * "
+"from t_question tq" +"from t_question tq"
+"left join t_question_options tqo on tqo.qid = tq.business_id" +"left join t_question_options tqo on tqo.qid = tq.business_id"
+"where 1=1" +"where 1=1"
+"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> " +"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+"<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> " +"<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+"<if test=\"business_id != null and business_id != ''\">and business_id = #{business_id}</if></script>") +"<if test=\"business_id != null and business_id != ''\">and business_id = #{business_id}</if></script>")
List<TQuestion> queryTQuestions(TQuestion tQuestion); List<TQuestion> queryTQuestions(TQuestion tQuestion);*/
@Update("<script> update t_question set del_flag = 1 , flag = 0 where FIND_IN_SET(business_id,#{idInfoList})</script>") @Update("<script> update t_question set del_flag = 1 , flag = 0 where FIND_IN_SET(business_id,#{idInfoList})</script>")
int deleteByIds(String idInfoList); int deleteByIds(String idInfoList);
......
...@@ -44,6 +44,10 @@ public class TQuestion extends IdEntity<TQuestion> { ...@@ -44,6 +44,10 @@ public class TQuestion extends IdEntity<TQuestion> {
@Transient @Transient
List<Map<String,Object>> questionOptions; List<Map<String,Object>> questionOptions;
List<TQuestionOptions> options;
public TQuestion(String businessId) {
this.businessId = businessId;
}
} }
...@@ -46,15 +46,12 @@ public interface TQuestionService { ...@@ -46,15 +46,12 @@ public interface TQuestionService {
* @param tQuestion * @param tQuestion
* @return * @return
*/ */
List<TQuestion> findAllByPagination(PageUtil<TQuestion> paginationUtility, List<TQuestion> findAllByPagination(PageUtil<TQuestion> paginationUtility,TQuestion tQuestion);
TQuestion tQuestion);
List<TQuestion> queryTQuestions(TQuestion tQuestion); List<TQuestion> queryTQuestions(TQuestion tQuestion);
int removeByIds(String idInfoList); int removeByIds(String idInfoList);
PersistModel saveoption(TQuestionOptions tQuestionOptions); TQuestion queryTQestionById(String businessId);
int removeOption(String id, String token);
} }
...@@ -46,54 +46,19 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -46,54 +46,19 @@ public class TQuestionServiceImpl implements TQuestionService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(TQuestion tQuestion){ public PersistModel save(TQuestion tQuestion){
List<TQuestionOptions> optionList = new ArrayList();
//增加主表题干信息 //增加主表题干信息
UserUtil.setCurrentPersistOperation(tQuestion); UserUtil.setCurrentPersistOperation(tQuestion);
int line = tQuestionRepository.insertSelective(tQuestion); int line = tQuestionRepository.insertSelective(tQuestion);
//增加选项信息 //增加选项信息
for(Map<String,Object> map : tQuestion.getQuestionOptions()){ for(TQuestionOptions option : tQuestion.getOptions()){
TQuestionOptions tQuestionOptions = new TQuestionOptions(); option.setCommonBusinessId();
tQuestionOptions.setCommonBusinessId(); option.setQid(tQuestion.getBusinessId());
tQuestionOptions.setQid(tQuestion.getBusinessId());
tQuestionOptions.setAlias(String.valueOf(map.keySet()));
tQuestionOptions.setDescribe(String.valueOf(map.get(map.keySet())));
optionList.add(tQuestionOptions);
} }
tQuestionRepository.insertOptionsList(optionList); tQuestionRepository.insertOptionsList(tQuestion.getOptions());
return new PersistModel(line); return new PersistModel(line);
} }
/**
* 增加选项
* @param tQuestionOptions
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel saveoption(TQuestionOptions tQuestionOptions) {
tQuestionOptions.setCommonBusinessId();
int line = tQuestionOptionsRepository.insertSelective(tQuestionOptions);
return new PersistModel(line);
}
/**
* 删除选项
* @param id
* @param token
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public int removeOption(String id, String token){
TQuestionOptions tQuestionOptions = new TQuestionOptions();
tQuestionOptions.setBusinessId(id);
// UserUtil.setCurrentMergeOperation(tQuestion);
int line = tQuestionOptionsRepository.deleteByPrimaryKey(id);
log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
tQuestionOptions.getBusinessId()+"的信息");
return line;
}
/** /**
* 逻辑删除 * 逻辑删除
...@@ -106,9 +71,10 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -106,9 +71,10 @@ public class TQuestionServiceImpl implements TQuestionService {
TQuestion tQuestion = new TQuestion(); TQuestion tQuestion = new TQuestion();
tQuestion.setBusinessId(id); tQuestion.setBusinessId(id);
UserUtil.setCurrentMergeOperation(tQuestion); UserUtil.setCurrentMergeOperation(tQuestion);
tQuestion.setDeleted();
int line = tQuestionRepository.logicalDelete(tQuestion); int line = tQuestionRepository.logicalDelete(tQuestion);
log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"逻辑删除了ID为"+ /*log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
tQuestion.getBusinessId()+"的信息"); tQuestion.getBusinessId()+"的信息");*/
return line; return line;
} }
...@@ -141,11 +107,10 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -141,11 +107,10 @@ public class TQuestionServiceImpl implements TQuestionService {
* @param tQuestion * @param tQuestion
* @return * @return
*/ */
public List<TQuestion> findAllByPagination(PageUtil<TQuestion> paginationUtility, public List<TQuestion> findAllByPagination(PageUtil<TQuestion> paginationUtility,TQuestion tQuestion){
TQuestion tQuestion){
tQuestion.setStart(); tQuestion.setStart();
tQuestion.setNotDeleted(); tQuestion.setNotDeleted();
return tQuestionRepository.queryTQuestionsByPagination(tQuestion); return tQuestionRepository.queryTQuestions(tQuestion);
} }
@Override @Override
...@@ -158,5 +123,10 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -158,5 +123,10 @@ public class TQuestionServiceImpl implements TQuestionService {
return tQuestionRepository.deleteByIds(idInfoList); return tQuestionRepository.deleteByIds(idInfoList);
} }
@Override
public TQuestion queryTQestionById(String businessId) {
return tQuestionRepository.selectOne(new TQuestion(businessId));
}
} }
...@@ -16,7 +16,16 @@ public class FileUtil { ...@@ -16,7 +16,16 @@ public class FileUtil {
public static String getFilePostfix(String fileName){ public static String getFilePostfix(String fileName){
if(StringUtils.isEmpty(fileName)) if(StringUtils.isEmpty(fileName))
return ""; return "";
return fileName.substring(fileName.lastIndexOf(".")+1); String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1);
if(fileSuffix.equals("docx")){
return "doc";
}else if(fileSuffix.equals("pptx")){
return "ppt";
}else if(fileSuffix.equals("xlsx")){
return "xls";
}else {
return "";
}
} }
} }
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