Commit adce717d by 阳浪

题库管理优化

parent 5424fb97
......@@ -54,6 +54,12 @@ public class ContextAndPageSizeVO {
@ApiModelProperty("题库id")
private Long libraryId;
@ApiModelProperty(value = "题库no")
private String libraryNo;
@ApiModelProperty("题库类型")
private Integer libraryType;
@ApiModelProperty("出题策略")
private Integer makeStrategy;
......
......@@ -44,6 +44,9 @@ public class ListLibraryVO {
@ApiModelProperty(value = "操作人姓名")
String accountName;
@ApiModelProperty("题库标签")
private String libraryLabel;
@ApiModelProperty("题库类型:1-测试,2-问卷,3-投票")
private Integer libraryType;
......
......@@ -142,12 +142,9 @@ public class QuestionLibraryController {
if(!requestContext.isAdmin() && !CollectionUtils.isEmpty(requestContext.getManagerIds())){
managerIds = requestContext.getManagerIds();
}
list=iQuestionLibraryService.getList(contextAndPageSizeVO.getState(),contextAndPageSizeVO.getName(),
contextAndPageSizeVO.getPageNo(),contextAndPageSizeVO.getPageSize(),contextAndPageSizeVO.getSiteId(),
contextAndPageSizeVO.getCompanyId(),managerIds);
list=iQuestionLibraryService.getList(contextAndPageSizeVO,managerIds);
int count = iQuestionLibraryService.selectLibraryCount(contextAndPageSizeVO.getState(),
contextAndPageSizeVO.getName(), contextAndPageSizeVO.getSiteId(), contextAndPageSizeVO.getCompanyId(), managerIds);
int count = iQuestionLibraryService.selectLibraryCount(contextAndPageSizeVO, managerIds);
Map<String, Integer> page = new HashMap<String, Integer>();
page.put("pageNo", contextAndPageSizeVO.getPageNo());
page.put("pageSize", contextAndPageSizeVO.getPageSize());
......
......@@ -2,6 +2,7 @@ package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.QuestionLibrary;
import com.yizhi.exam.application.vo.ContextAndPageSizeVO;
import com.yizhi.exam.application.vo.ListLibraryVO;
import com.yizhi.exam.application.vo.TypeAndCountVo;
import org.apache.ibatis.annotations.Param;
......@@ -31,11 +32,9 @@ public interface QuestionLibraryMapper extends BaseMapper<QuestionLibrary> {
int questionState(@Param("questionId") Long questionId, @Param("companyId") Long companyId, @Param("orgId") Long orgId,
@Param("siteId") Long siteId);
List<ListLibraryVO> listLibrary(@Param("state") Integer state,@Param("name") String name,
@Param("pageNo")Integer pageNo,@Param("pageSize")Integer pageSize,
@Param("siteId")Long siteId,@Param("companyId") Long companyId, @Param("managerIds")List<Long> managerIds);
List<ListLibraryVO> listLibrary(@Param("contextAndPageSizeVO") ContextAndPageSizeVO contextAndPageSizeVO, @Param("managerIds")List<Long> managerIds);
Integer listLibraryVOCount(@Param("name")String name,@Param("state") Integer state,@Param("siteId")Long siteId,@Param("companyId") Long companyId,@Param("managerIds")List<Long> managerIds);
Integer listLibraryVOCount(@Param("contextAndPageSizeVO") ContextAndPageSizeVO contextAndPageSizeVO,@Param("managerIds")List<Long> managerIds);
/**
* 查询试题是否被考试使用
......
......@@ -2,6 +2,7 @@ package com.yizhi.application.service;
import java.util.List;
import com.yizhi.exam.application.vo.ContextAndPageSizeVO;
import com.yizhi.exam.application.vo.TypeAndCountVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
......@@ -80,14 +81,14 @@ public interface IQuestionLibraryService extends IService<QuestionLibrary> {
* @param id
* @return
*/
List<ListLibraryVO> getList(Integer state, String name, Integer pageNo, Integer pageSize, Long siteId, Long companyId, List<Long> managerIds);
List<ListLibraryVO> getList(ContextAndPageSizeVO contextAndPageSizeVO, List<Long> managerIds);
Boolean importQuestionLibrary(String file, String fileName, Long id);
/*
* 查询题库数量
* **/
public int selectLibraryCount(Integer state, String name, Long siteId, Long companyId, List<Long> managerIds);
public int selectLibraryCount(ContextAndPageSizeVO contextAndPageSizeVO, List<Long> managerIds);
/**
* 删除
......
......@@ -7,10 +7,7 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.QuestionLibrary;
import com.yizhi.application.domain.TrQuestionLibrarySubject;
import com.yizhi.application.domain.TrQuestionSubjectOption;
import com.yizhi.exam.application.vo.ExamImportVO;
import com.yizhi.exam.application.vo.ListLibraryVO;
import com.yizhi.exam.application.vo.QuestionLibraryVO;
import com.yizhi.exam.application.vo.TypeAndCountVo;
import com.yizhi.exam.application.vo.*;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.mapper.QuestionLibraryMapper;
......@@ -81,8 +78,8 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
}
@Override
public int selectLibraryCount(Integer state, String name, Long siteId, Long companyId, List<Long> managerIds) {
return questionLibraryMapper.listLibraryVOCount(name, state, siteId, companyId, managerIds);
public int selectLibraryCount(ContextAndPageSizeVO contextAndPageSizeVO, List<Long> managerIds) {
return questionLibraryMapper.listLibraryVOCount(contextAndPageSizeVO, managerIds);
}
public void insertDb(List<ExamImportVO> listExam) throws Exception {
......@@ -451,12 +448,12 @@ public class QuestionLibraryServiceImpl extends ServiceImpl<QuestionLibraryMappe
}
@Override
public List<ListLibraryVO> getList(Integer state, String name, Integer pageNo, Integer pageSize, Long siteId, Long companyId, List<Long> managerIds) {
public List<ListLibraryVO> getList(ContextAndPageSizeVO contextAndPageSizeVO, List<Long> managerIds) {
// TODO Auto-generated method stub
int start = (pageNo - 1) * pageSize;
int start = (contextAndPageSizeVO.getPageNo() - 1) * contextAndPageSizeVO.getPageSize();
RequestContext res = ContextHolder.get();
List<ListLibraryVO> listLibraryVOS = questionLibraryMapper.listLibrary(state, name, start, pageSize, siteId, companyId, managerIds);
contextAndPageSizeVO.setPageNo(start);
List<ListLibraryVO> listLibraryVOS = questionLibraryMapper.listLibrary(contextAndPageSizeVO, managerIds);
if (!CollectionUtils.isEmpty(listLibraryVOS)){
List<Long> ids = listLibraryVOS.stream().map(ListLibraryVO::getId).collect(Collectors.toList());
List<TypeAndCountVo> typeAndCountVos = questionLibraryMapper.selectTypeAndCount(ids);
......
......@@ -61,14 +61,20 @@
when ((exists(select library_id from tr_exam_question where state =1 and library_id = a.id)
or
exists(SELECT library_id from tr_exam_answer_question where library_id = a.id ))) then 1 else 2 end) des,
a.library_label AS libraryType,a.create_by_name AS accountName,a.library_no AS libraryNo
a.library_label AS libraryLabel,a.library_type AS libraryType,a.create_by_name AS accountName,a.library_no AS libraryNo
FROM question_library a
WHERE a.state = 1
<if test="name!=null">
AND (a.name LIKE CONCAT("%",#{name},"%") or a.library_label LIKE CONCAT("%",#{name},"%"))
<if test="contextAndPageSizeVO.name!=null and contextAndPageSizeVO.name !=''">
AND (a.name LIKE CONCAT("%",#{contextAndPageSizeVO.name},"%") or a.library_label LIKE CONCAT("%",#{contextAndPageSizeVO.name},"%"))
</if>
AND a.site_id = #{siteId}
AND a.company_id = #{companyId}
<if test="contextAndPageSizeVO.libraryType!=null">
AND a.library_type = #{contextAndPageSizeVO.libraryType}
</if>
<if test="contextAndPageSizeVO.libraryNo!=null and contextAndPageSizeVO.libraryNo !=''">
AND a.library_no LIKE CONCAT("%",#{contextAndPageSizeVO.libraryNo},"%")
</if>
AND a.site_id = #{contextAndPageSizeVO.siteId}
AND a.company_id = #{contextAndPageSizeVO.companyId}
<if test="managerIds != null">
AND a.create_by_id IN
<foreach item="item" collection="managerIds" index="index" open="(" separator="," close=")">
......@@ -78,14 +84,14 @@
ORDER BY updateTime DESC
) aaa
<where>
<if test="state == 1">
<if test="contextAndPageSizeVO.state == 1">
aaa.des=1
</if>
<if test="state == 2">
<if test="contextAndPageSizeVO.state == 2">
aaa.des=2
</if>
</where>
LIMIT #{pageNo},#{pageSize}
LIMIT #{contextAndPageSizeVO.pageNo},#{contextAndPageSizeVO.pageSize}
</select>
<select id="listLibraryVOCount" resultType="int">
......@@ -95,11 +101,14 @@
create_time AS createTime,update_time AS updateTime
FROM question_library a
WHERE a.state = 1
<if test="name!=null">
AND (a.name LIKE CONCAT("%",#{name},"%") or a.library_label LIKE CONCAT("%",#{name},"%"))
<if test="contextAndPageSizeVO.name!=null and contextAndPageSizeVO.name !=''">
AND (a.name LIKE CONCAT("%",#{contextAndPageSizeVO.name},"%") or a.library_label LIKE CONCAT("%",#{contextAndPageSizeVO.name},"%"))
</if>
<if test="contextAndPageSizeVO.libraryNo!=null and contextAndPageSizeVO.libraryNo !=''">
AND a.library_no LIKE CONCAT("%",#{contextAndPageSizeVO.libraryNo},"%")
</if>
AND a.site_id = #{siteId}
AND a.company_id = #{companyId}
AND a.site_id = #{contextAndPageSizeVO.siteId}
AND a.company_id = #{contextAndPageSizeVO.companyId}
<if test="managerIds != null">
AND a.create_by_id IN
<foreach item="item" collection="managerIds" index="index" open="(" separator="," close=")">
......@@ -109,13 +118,13 @@
ORDER BY updateTime DESC
) aaa
<where>1=1
<if test="state == 1">
<if test="contextAndPageSizeVO.state == 1">
AND
(exists(select library_id from tr_exam_question where state =1 and library_id = aaa.id)
or
exists(SELECT library_id from tr_exam_answer_question where library_id = aaa.id ))
</if>
<if test="state == 2">
<if test="contextAndPageSizeVO.state == 2">
AND
(not exists(select library_id from tr_exam_question where state =1 and library_id = aaa.id)
and
......
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