commit
14026544d1
7 changed files with 396 additions and 0 deletions
@ -0,0 +1,51 @@ |
|||||||
|
package com.ccic.safeliab.dao; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ccic.safeliab.entity.ExamPapers; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper 接口 |
||||||
|
* |
||||||
|
* @author Chill |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface ExamPaperMapper extends BaseMapper<ExamPapers> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询当前页数据 |
||||||
|
* |
||||||
|
* @param industryId 监管行业 |
||||||
|
* @param paperName 试卷名称 |
||||||
|
* @param offset 偏移量 |
||||||
|
* @param num 每页显示的记录数 |
||||||
|
* @return 当前页数据 |
||||||
|
*/ |
||||||
|
List<ExamPapers> getList( |
||||||
|
@Param("industryId") Long industryId, |
||||||
|
@Param("paperName") String paperName, |
||||||
|
@Param("offset") int offset, |
||||||
|
@Param("num") int num); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询总数量 |
||||||
|
* |
||||||
|
* @param industryId 监管行业 |
||||||
|
* @param paperName 试卷名称 |
||||||
|
* @return 总数量 |
||||||
|
*/ |
||||||
|
int getListSize( |
||||||
|
@Param("industryId") Long industryId, |
||||||
|
@Param("paperName") String paperName); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询当题目详情 |
||||||
|
* |
||||||
|
* @param id 监管行业 |
||||||
|
* @return 题目详情 |
||||||
|
*/ |
||||||
|
ExamPapers getDetail(@Param("id") Long id); |
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
package com.ccic.safeliab.service; |
||||||
|
|
||||||
|
import com.ccic.safeliab.entity.ExamPapers; |
||||||
|
import com.ccic.safeliab.support.BaseService; |
||||||
|
import com.ccic.safeliab.vo.InsExamPaperVO; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Service |
||||||
|
public interface ExamPaperService extends BaseService<ExamPapers> { |
||||||
|
/** |
||||||
|
* 获取试卷列表 |
||||||
|
* @param page 页码 |
||||||
|
* @param num 每页数量 |
||||||
|
* @param entity 试卷表 |
||||||
|
* @return 试卷列表 |
||||||
|
*/ |
||||||
|
Map<String, Object> getList(int page, int num, ExamPapers entity); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 根据主键删除试卷记录 |
||||||
|
* @param id 试卷记录的主键 |
||||||
|
* @return 删除操作是否成功 |
||||||
|
*/ |
||||||
|
boolean deleteExamPaperById(Long id); |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据主键批量删除试卷记录 |
||||||
|
* @param ids 试卷记录的主键列表 |
||||||
|
* @return 删除操作是否成功 |
||||||
|
*/ |
||||||
|
boolean deleteExamPaperListByIds(List<Long> ids); |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新试卷状态 |
||||||
|
* @param vo 试题 VO 列表 |
||||||
|
* @return 添加是否成功 |
||||||
|
*/ |
||||||
|
boolean updatePaperStatus(InsExamPaperVO vo); |
||||||
|
|
||||||
|
/** |
||||||
|
* 批量更新试卷状态 |
||||||
|
* @param vos 试卷记录的主键列表 |
||||||
|
* @return 删除操作是否成功 |
||||||
|
*/ |
||||||
|
boolean batchUpdatePaperStatus(List<InsExamPaperVO> vos); |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加试题 |
||||||
|
* @param vo 试题 VO 列表 |
||||||
|
* @return 添加是否成功 |
||||||
|
*/ |
||||||
|
int add(List<InsExamPaperVO> vo); |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改试题 |
||||||
|
* @param vo 试题 VO 列表 |
||||||
|
* @return 添加是否成功 |
||||||
|
*/ |
||||||
|
boolean update(InsExamPaperVO vo); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取试卷列表 |
||||||
|
* @param id 题目ID |
||||||
|
* @return 题目详情 |
||||||
|
*/ |
||||||
|
ExamPapers getDetail(String id); |
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
package com.ccic.safeliab.service; |
||||||
|
|
||||||
|
import com.ccic.safeliab.dao.ExamPaperMapper; |
||||||
|
import com.ccic.safeliab.entity.*; |
||||||
|
import com.ccic.safeliab.support.BaseServiceImpl; |
||||||
|
import com.ccic.safeliab.vo.InsExamPaperVO; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamPapers> implements ExamPaperService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Map<String, Object> getList(int page,int num, ExamPapers entity) { |
||||||
|
int offset = (page - 1) * num; |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
List<ExamPapers> data = baseMapper.getList( |
||||||
|
entity.getIndustryId(), |
||||||
|
entity.getPaperName(), |
||||||
|
offset, |
||||||
|
num); |
||||||
|
|
||||||
|
int total = baseMapper.getListSize( |
||||||
|
entity.getIndustryId(), |
||||||
|
entity.getPaperName()); |
||||||
|
map.put("data", data); |
||||||
|
map.put("total", total); |
||||||
|
return map; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean deleteExamPaperById(Long id) { |
||||||
|
List<Long> ids = new ArrayList<>(); |
||||||
|
ids.add(id); |
||||||
|
return deleteLogic(ids); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean deleteExamPaperListByIds(List<Long> ids) { |
||||||
|
return deleteLogic(ids); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Transactional |
||||||
|
public boolean updatePaperStatus(InsExamPaperVO vo) { |
||||||
|
ExamPapers entity = baseMapper.getDetail(vo.getId()); |
||||||
|
if(vo.getPaperStatus()==0){ |
||||||
|
entity.setPaperStatus(1); |
||||||
|
}else if(vo.getPaperStatus()==1){ |
||||||
|
entity.setPaperStatus(0); |
||||||
|
} |
||||||
|
return updateById(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Transactional |
||||||
|
public boolean batchUpdatePaperStatus(List<InsExamPaperVO> vos) { |
||||||
|
boolean flag = false; |
||||||
|
for(InsExamPaperVO vo : vos){ |
||||||
|
flag = updatePaperStatus(vo); |
||||||
|
} |
||||||
|
return flag; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int add(List<InsExamPaperVO> vo) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean update(InsExamPaperVO vo) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ExamPapers getDetail(String id){ |
||||||
|
return baseMapper.getDetail(Long.valueOf(id)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package com.ccic.safeliab.vo; |
||||||
|
|
||||||
|
import com.ccic.safeliab.entity.ExamPapers; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
/** |
||||||
|
* 值对象(VO),用于在不同层之间传递题目相关数据。 |
||||||
|
* 该类的属性与数据库中题目表的字段相对应,以满足数据传输需求。 |
||||||
|
*/ |
||||||
|
@Getter |
||||||
|
@Setter |
||||||
|
public class InsExamPaperVO extends ExamPapers { |
||||||
|
// 每页数量
|
||||||
|
private int num; |
||||||
|
// 页码
|
||||||
|
private int page; |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,94 @@ |
|||||||
|
package com.ccic.safeliab.web; |
||||||
|
|
||||||
|
import com.ccic.safeliab.entity.ExamPapers; |
||||||
|
import com.ccic.safeliab.service.ExamPaperService; |
||||||
|
import com.ccic.safeliab.util.R; |
||||||
|
import com.ccic.safeliab.vo.InsExamPaperVO; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/ex/examPaper") |
||||||
|
public class ExamPaperController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private ExamPaperService examPaperService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取试题 |
||||||
|
* @param vo 题库对象(VO) |
||||||
|
* @return 查询结果 |
||||||
|
*/ |
||||||
|
@PostMapping("/list") |
||||||
|
public R list(@RequestBody InsExamPaperVO vo) { |
||||||
|
ExamPapers entity = new ExamPapers(); |
||||||
|
entity.setIndustryId(vo.getIndustryId()); |
||||||
|
entity.setPaperName(vo.getPaperName()); |
||||||
|
Map<String, Object> map = examPaperService.getList(vo.getPage(), vo.getNum(), entity); |
||||||
|
return R.ok().data(map); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除单个试卷 |
||||||
|
*/ |
||||||
|
@GetMapping("/delete") |
||||||
|
public R delete(String id) { |
||||||
|
boolean resultFlg = examPaperService.deleteExamPaperById(Long.valueOf((id))); |
||||||
|
return R.ok().data(resultFlg); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除多个试卷 |
||||||
|
*/ |
||||||
|
@PostMapping("/deleteList") |
||||||
|
public R deleteList(@RequestBody List<Long> ids) { |
||||||
|
boolean resultFlg = examPaperService.deleteExamPaperListByIds(ids); |
||||||
|
return R.ok().data(resultFlg); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新试卷状态 |
||||||
|
*/ |
||||||
|
@PostMapping("/updatePaperStatus") |
||||||
|
public R updatePaperStatus(@RequestBody InsExamPaperVO vo) { |
||||||
|
return R.ok().data(examPaperService.updatePaperStatus(vo) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 批量更新试卷状态 |
||||||
|
*/ |
||||||
|
@PostMapping("/batchUpdatePaperStatus") |
||||||
|
public R batchUpdatePaperStatus(@RequestBody List<InsExamPaperVO> vos) { |
||||||
|
boolean resultFlg = examPaperService.batchUpdatePaperStatus(vos); |
||||||
|
return R.ok().data(resultFlg); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加试卷 |
||||||
|
*/ |
||||||
|
@PostMapping("/add") |
||||||
|
public R add(@RequestBody List<InsExamPaperVO> vo) { |
||||||
|
return R.ok().data(examPaperService.add(vo)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改试卷 |
||||||
|
*/ |
||||||
|
@PostMapping("/update") |
||||||
|
public R add(@RequestBody InsExamPaperVO vo) { |
||||||
|
return R.ok().data(examPaperService.update(vo)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 题目详情 |
||||||
|
*/ |
||||||
|
@GetMapping("/getDetail") |
||||||
|
public R getDetail(String id) { |
||||||
|
ExamPapers data = examPaperService.getDetail(id); |
||||||
|
return R.ok().data(data); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
<?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.ccic.safeliab.dao.ExamPaperMapper"> |
||||||
|
<!-- 通用查询映射结果 --> |
||||||
|
<resultMap id="ExamPapersResultMap" type="com.ccic.safeliab.entity.ExamPapers"> |
||||||
|
<id column="id" property="id"/> |
||||||
|
<result column="paper_name" property="paperName"/> |
||||||
|
<result column="industry_id" property="industryId"/> |
||||||
|
<result column="question_count" property="questionCount"/> |
||||||
|
<result column="total_score" property="totalScore"/> |
||||||
|
<result column="exam_duration" property="examDuration"/> |
||||||
|
<result column="duration_type" property="durationType"/> |
||||||
|
<result column="paper_content" property="paperContent"/> |
||||||
|
<result column="paper_status" property="paperStatus"/> |
||||||
|
</resultMap> |
||||||
|
<select id="getList" resultMap="ExamPapersResultMap"> |
||||||
|
SELECT |
||||||
|
id |
||||||
|
, paper_name |
||||||
|
, industry_id |
||||||
|
, question_count |
||||||
|
, total_score |
||||||
|
, exam_duration |
||||||
|
, duration_type |
||||||
|
, paper_content |
||||||
|
, paper_status |
||||||
|
FROM ex_exam_papers |
||||||
|
<where> |
||||||
|
is_deleted = '0' |
||||||
|
<if test="industryId!= null and industryId!= ''"> |
||||||
|
AND industry_id = #{industryId} |
||||||
|
</if> |
||||||
|
<if test="paperName!= null and paperName!= ''"> |
||||||
|
AND paper_name LIKE '%' || #{paperName} || '%' |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
ORDER BY id DESC |
||||||
|
LIMIT #{offset}, #{num}; |
||||||
|
</select> |
||||||
|
<select id="getListSize" resultType="int"> |
||||||
|
SELECT |
||||||
|
COUNT(id) |
||||||
|
FROM ex_exam_papers |
||||||
|
<where> |
||||||
|
is_deleted = '0' |
||||||
|
<if test="industryId!= null and industryId!= ''"> |
||||||
|
AND industry_id = #{industryId} |
||||||
|
</if> |
||||||
|
<if test="paperName!= null and paperName!= ''"> |
||||||
|
AND paper_name LIKE '%' || #{paperName} || '%' |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
<select id="getDetail" resultMap="ExamPapersResultMap"> |
||||||
|
SELECT |
||||||
|
id |
||||||
|
, paper_name |
||||||
|
, industry_id |
||||||
|
, question_count |
||||||
|
, total_score |
||||||
|
, exam_duration |
||||||
|
, duration_type |
||||||
|
, paper_content |
||||||
|
, paper_status |
||||||
|
FROM ex_exam_papers |
||||||
|
<where> |
||||||
|
is_deleted = '0' |
||||||
|
<if test="id!= null and id!= ''"> |
||||||
|
AND id = #{id} |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
</mapper> |
Loading…
Reference in new issue