Commit adce717d by 阳浪

题库管理优化

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