【新增】专业-课程-题型功能迁移,知识点半迁移没有调试

This commit is contained in:
任维炳
2025-04-21 15:33:19 +08:00
parent e58a23079c
commit 09afc46c92
21 changed files with 1272 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
package pc.exam.pp.module.exam.controller.admin;
package pc.exam.pp.module.exam.controller.admin.authorize;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;

View File

@@ -0,0 +1,180 @@
//package pc.exam.pp.module.exam.controller.admin.knowledge;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//import pc.exam.pp.module.exam.service.knowledge.ExamKnowledgePointsService;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Objects;
//
///**
// * 知识点Controller
// *
// * @author pengchen
// * @date 2025-04-02
// */
//@RestController
//@RequestMapping("/exam/points")
//public class ExamKnowledgePointsController{
//
// @Autowired
// private ExamKnowledgePointsService knowledgePointsService;
//
// /**
// * 查询知识点列表
// */
// @GetMapping("/list")
// public AjaxResult list(ExamKnowledgePoints knowledgePoints) {
// List<ExamKnowledgePoints> list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId()));
// return success(list);
// }
//
// /**
// * 导出知识点列表
// */
// @ApiOperation("导出知识点列表")
// @Log(title = "知识点", businessType = BusinessType.EXPORT)
// @PostMapping("/export")
// public void export(HttpServletResponse response, ExamKnowledgePoints knowledgePoints) {
// List<ExamKnowledgePoints> list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId()));
// ExcelUtil<ExamKnowledgePoints> util = new ExcelUtil<ExamKnowledgePoints>(ExamKnowledgePoints.class);
// util.exportExcel(response, list, "知识点数据");
// }
//
// /**
// * 获取知识点详细信息
// */
// @ApiOperation("获取知识点详细信息")
// @GetMapping(value = "/{spId}")
// public AjaxResult getInfo(@PathVariable("spId") Long spId) {
// return success(knowledgePointsService.selectKnowledgePointsBySpId(spId));
// }
//
// /**
// * 新增知识点
// */
// @ApiOperation("新增知识点")
// @Log(title = "知识点", businessType = BusinessType.INSERT)
// @PostMapping
// public AjaxResult add(@RequestBody ExamKnowledgePoints knowledgePoints) {
// //获取登录用户id
// knowledgePoints.setDeptId(String.valueOf(getDeptId()));
// //获取登录部门id
// knowledgePoints.setUserId(String.valueOf(getUserId()));
// //获取登录用户名
// knowledgePoints.setCreateBy(getUsername());
// //获取新增名称信息
// String SpName = knowledgePoints.getSpName();
// //修改祖籍列表
// Long ParentId = knowledgePoints.getParentId();
// if (SpName != null) {
// if (String.valueOf(ParentId).equals("0")) {
// return error("不可增加根节点!");
//
// } else {
// //获取父节点的信息
// ExamKnowledgePoints knowledgePointF = knowledgePointsService.selectKnowledgePointsBySpId(ParentId);
// //获取父节点的id
// String ancestors = knowledgePointF.getAncestors();
// //父节点子树+1
// knowledgePointF.setTreeNum(knowledgePointF.getTreeNum() + 1);
// knowledgePointsService.updateKnowledgePoints(knowledgePointF);
//
// //修改祖籍列表
// knowledgePoints.setAncestors(ancestors + "," + ParentId);
// return toAjax(knowledgePointsService.insertKnowledgePoints(knowledgePoints));
// }
//
// } else
// return error("输入名称不能为空!");
//
// }
//
// /**
// * 修改知识点
// */
// @ApiOperation("修改知识点")
// @Log(title = "知识点", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@RequestBody ExamKnowledgePoints knowledgePoints) {
// //判断是否修改的根节点
// if (Objects.equals(knowledgePoints.getAncestors(), "0")) {
// return error("不可直接修改根节点,请在专业表中修改!");
// } else {
// if (Objects.equals(knowledgePoints.getSpName(), "")) {
// return error("修改名称不得为空!");
// } else {
// //获取修改人
// knowledgePoints.setUpdateBy(getUsername());
// //修改时间
// knowledgePoints.setUpdateTime(DateUtils.getNowDate());
// return toAjax(knowledgePointsService.updateKnowledgePoints(knowledgePoints));
// }
// }
// }
//
// /**
// * 删除知识点
// */
// @ApiOperation("删除知识点")
// @Log(title = "知识点", businessType = BusinessType.DELETE)
// @DeleteMapping("/{spIds}")
// public AjaxResult remove(@PathVariable Long[] spIds) {
// //用于判断是否符合删除条件
// for (Long spId : spIds) {
// //实例化节点
// ExamKnowledgePoints knowledgePoint = knowledgePointsService.selectKnowledgePointsBySpId(spId);
// Long ParentId = knowledgePoint.getParentId();
// // 根据父节点id查找是否为根节点根节点为专业不可在此删除
// if (ParentId == 0) {
// return error("删除失败,删除目录中含有专业,请在专业表中删除!");
// } else {
// // 判断是否有子树
// if (knowledgePoint.getTreeNum() != 0) {
// return error("删除失败,删除目录下还存在知识点!");
// }
// }
// }
// // 用于操作节点数
// for (Long spId : spIds) {
// //根据主键id查询实例化节点
// ExamKnowledgePoints knowledgePoint = knowledgePointsService.selectKnowledgePointsBySpId(spId);
// Long ParentId = knowledgePoint.getParentId();
// //实例化父节点
// ExamKnowledgePoints knowledgePointF = knowledgePointsService.selectKnowledgePointsBySpId(ParentId);
// //父节点子树-1
// knowledgePointF.setTreeNum(knowledgePointF.getTreeNum() - 1);
// knowledgePointsService.updateKnowledgePoints(knowledgePointF);
// //获取删除人
// knowledgePoint.setUpdateBy(getUsername());
// //获取删除时间
// knowledgePoint.setUpdateTime(DateUtils.getNowDate());
// knowledgePointsService.updateKnowledgePoints(knowledgePoint);
// }
//
// return toAjax(knowledgePointsService.deleteKnowledgePointsBySpIds(spIds));
// }
//
//
// /**
// * 构建知识点树状结构
// */
// @ApiOperation("构建知识点树状结构")
// @GetMapping("/tree")
// public AjaxResult listTree(ExamKnowledgePoints knowledgePoints) {
// //定义List
// List<Tree> tree = new ArrayList<>();
// //查询数据库表中全部数据
// List<ExamKnowledgePoints> list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId()));
// //将SpId、ParentId、SpName添加至数组
// for (ExamKnowledgePoints L : list) {
// tree.add(new Tree(String.valueOf(L.getSpId()), String.valueOf(L.getParentId()), L.getSpName()));
// }
// // 构建树状结构
// BuildTree T = new BuildTree();
// tree = T.builTree(tree);
// // 转为json
// return AjaxResult.success(tree);
// }
//}

View File

@@ -0,0 +1,154 @@
package pc.exam.pp.module.exam.controller.admin.specialty;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.common.util.object.BeanUtils;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo;
import pc.exam.pp.module.exam.dal.dataobject.ExamKnowledgePoints;
import pc.exam.pp.module.exam.dal.dataobject.ExamSpecialty;
import pc.exam.pp.module.exam.service.knowledge.ExamKnowledgePointsService;
import pc.exam.pp.module.exam.service.specialty.ExamSpecialtyService;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static pc.exam.pp.framework.common.pojo.CommonResult.error;
import static pc.exam.pp.framework.common.pojo.CommonResult.success;
/**
* 专业-课程-题型Controller
*
* @author pengchen
* @date 2025-03-24
*/
@RestController
@RequestMapping("/exam/specialty")
public class ExamSpecialtyController{
@Autowired
private ExamSpecialtyService examSpecialtyService;
@Autowired
private ExamKnowledgePointsService knowledgePointsService;
@GetMapping("/list")
@Operation(summary = "获取专业列表")
public CommonResult<List<SpecialtyQueryVo>> getDeptList(SpecialtListReqVo reqVO) {
List<SpecialtyQueryVo> list = examSpecialtyService.selectExamSpecialtyList(reqVO);
return success(BeanUtils.toBean(list, SpecialtyQueryVo.class));
}
/**
* 获取全部数据详细信息
*/
@GetMapping(value = "/{spId}")
@Operation(summary = "获取专业-课程-题型ID对应数据", description = "获取专业-课程-题型ID对应数据")
@Parameter(name = "spId", description = "专业ID", required = true, example = "1024")
public CommonResult<ExamSpecialty> getInfo(@PathVariable("spId") Long spId) {
return success(examSpecialtyService.selectExamSpecialtyBySpId(spId));
}
/**
* 新增数据信息(一级:专业,二级:课程,三级:题型)
*/
@Operation(summary = "新增数据信息(一级:专业,二级:课程,三级:题型)", description = "新增数据信息(一级:专业,二级:课程,三级:题型)")
@Parameter(name = "examSpecialty", description = "专业数据", required = true, example = "1024")
@PostMapping
public CommonResult<Integer> add(@RequestBody ExamSpecialty examSpecialty) {
//定义层的数量LimitNodes>=3(专业、课程、题型)
int LimitNodes = 3;
//获取新增名称信息
String SpName = examSpecialty.getSpName();
//修改祖籍列表
Long ParentId = examSpecialty.getParentId();
if (SpName != null) {
if (String.valueOf(ParentId).equals("0")) {
examSpecialty.setAncestors("0");
return success(examSpecialtyService.insertExamSpecialty(examSpecialty));
} else {
//获取父亲节点的父ID
String ancestors = examSpecialtyService.selectExamSpecialtyBySpId(ParentId).getAncestors();
//获取节点数量并判断是否可在添加
int nodeNum = ancestors.split(",").length;
if (nodeNum == LimitNodes) {
return error(25530, "不可在添加更深节点!");
} else {
//获取父节点的信息
ExamSpecialty examSpecialtyF = examSpecialtyService.selectExamSpecialtyBySpId(ParentId);
//父节点子树+1
examSpecialtyF.setTreeNum(examSpecialtyF.getTreeNum() + 1);
examSpecialtyService.updateExamSpecialty(examSpecialtyF);
//修改祖籍列表
examSpecialty.setAncestors(ancestors + "," + ParentId);
return success(examSpecialtyService.insertExamSpecialty(examSpecialty));
}
}
} else
return error(255301, "输入名称不能为空!");
}
/**
* 修改数据信息
*/
@Operation(summary = "修改数据信息", description = "修改数据信息(一级:专业,二级:课程,三级:题型)")
@Parameter(name = "examSpecialty", description = "专业数据", required = true, example = "1024")
@PutMapping
public CommonResult<Integer> edit(@RequestBody ExamSpecialty examSpecialty) {
//判断修改名称是否为空
if (Objects.equals(examSpecialty.getSpName(), "")) {
return error(25532, "修改名称不能为空!");
} else {
return success(examSpecialtyService.updateExamSpecialty(examSpecialty));
}
}
/**
* 删除数据信息
*/
@Operation(summary = "删除数据信息", description = "删除数据信息(一级:专业,二级:课程,三级:题型)")
@Parameter(name = "examSpecialty", description = "专业数据", required = true, example = "1024")
@DeleteMapping("/{spIds}")
public CommonResult<Integer> remove(@PathVariable Long[] spIds) {
//用于判断是否符合删除条件
for (Long spId : spIds) {
//实例化节点
ExamSpecialty examSpecialty = examSpecialtyService.selectExamSpecialtyBySpId(spId);
Long ParentId = examSpecialty.getParentId();
// 判断是否有子树
if (examSpecialty.getTreeNum() != 0) {
return error(25533, "删除失败,删除目录下还存在课程或题型!");
}
ExamKnowledgePoints knowledgePoints = knowledgePointsService.selectKnowledgePointsBySpId(spId);
if (knowledgePoints != null) {
Long treeNum = knowledgePoints.getTreeNum();
if (treeNum != 0) {
return error(255334, "删除失败,删除目录下还存在知识点!");
}
}
}
// 用于操作节点数
for (Long spId : spIds) {
//根据主键id查询实例化节点
ExamSpecialty examSpecialty = examSpecialtyService.selectExamSpecialtyBySpId(spId);
Long ParentId = examSpecialty.getParentId();
//判断是不是根节点
if (examSpecialty.getParentId() != 0) {
//实例化父节点
ExamSpecialty examSpecialtyF = examSpecialtyService.selectExamSpecialtyBySpId(ParentId);
//父节点子树-1
examSpecialtyF.setTreeNum(examSpecialtyF.getTreeNum() - 1);
// examSpecialtyService.updateExamSpecialty(examSpecialtyF);
} else {
knowledgePointsService.deleteKnowledgePointsBySpId(spId);
}
// examSpecialtyService.updateExamSpecialty(examSpecialty);
}
return success(examSpecialtyService.deleteExamSpecialtyBySpIds(spIds));
}
}

View File

@@ -0,0 +1,20 @@
package pc.exam.pp.module.exam.controller.admin.specialty.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 专业列表 Request VO")
@Data
public class SpecialtListReqVo {
@Schema(description = "专业名称,模糊匹配", example = "计算机专业")
private String name;
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
private Integer status;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,25 @@
package pc.exam.pp.module.exam.controller.admin.specialty.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 专业列表 QueryResult VO")
@Data
public class SpecialtyQueryVo {
private Long id;
private Long parentId;
private String name;
private Integer status;
private String ancestors;
private Integer orderNum;
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,43 @@
package pc.exam.pp.module.exam.dal.dataobject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import pc.exam.pp.framework.tenant.core.db.TenantBaseDO;
/**
* 知识点对象 exam_knowledge_points
*
* @author pengchen
* @date 2025-04-02
*/
@TableName("exam_knowledge_points")
@Data
@EqualsAndHashCode(callSuper = true)
public class ExamKnowledgePoints extends TenantBaseDO
{
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "sp_id", type = IdType.AUTO)
private Long spId;
private Long parentId;
private String ancestors;
private int orderNum;
/** 名称 */
private String spName;
/** 状态0正常 1停用 */
private int status;
/** 子树数量 */
private Long treeNum;
}

View File

@@ -0,0 +1,37 @@
package pc.exam.pp.module.exam.dal.dataobject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import pc.exam.pp.framework.tenant.core.db.TenantBaseDO;
@TableName("exam_specialty")
@Data
@EqualsAndHashCode(callSuper = true)
public class ExamSpecialty extends TenantBaseDO {
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "sp_id", type = IdType.AUTO)
private Long spId;
private Long parentId;
private String ancestors;
private int orderNum;
/** 名称 */
private String spName;
/** 状态0正常 1停用 */
private int status;
private String unite;
/** 子树数量 */
private Long treeNum;
}

View File

@@ -0,0 +1,50 @@
package pc.exam.pp.module.exam.dal.mysql;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
import pc.exam.pp.module.exam.dal.dataobject.ExamKnowledgePoints;
import java.util.List;
/**
* 知识点Mapper接口
*
* @author pengchen
* @date 2025-04-02
*/
@Mapper
public interface ExamKnowledgePointsMapper extends BaseMapperX<ExamKnowledgePoints>
{
/**
* 查询知识点
*
* @param spId 知识点主键
* @return 知识点
*/
public ExamKnowledgePoints selectKnowledgePointsBySpId(Long spId);
/**
* 查询知识点列表
*
* @param knowledgePoints 知识点
* @return 知识点集合
*/
public List<ExamKnowledgePoints> selectKnowledgePointsList(@Param("knowledgePoints") ExamKnowledgePoints knowledgePoints);
/**
* 删除知识点
*
* @param spId 知识点主键
* @return 结果
*/
public int deleteKnowledgePointsBySpId(Long spId);
/**
* 批量删除知识点
*
* @param spIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteKnowledgePointsBySpIds(Long[] spIds);
}

View File

@@ -0,0 +1,75 @@
package pc.exam.pp.module.exam.dal.mysql;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo;
import pc.exam.pp.module.exam.dal.dataobject.ExamSpecialty;
import java.util.List;
/**
* 客户端Mapper接口
*
* @author pengchen
* @date 2025-03-24
*/
@Mapper
public interface ExamSpecialtyMapper extends BaseMapperX<ExamSpecialty>
{
/**
* 查询数据
*
* @param spId 数据主键
* @return 数据信息
*/
public ExamSpecialty selectExamSpecialtyBySpId(Long spId);
/**
* 修改数据信息
*
* @param examSpecialty 修改数据
* @return 结果
*/
public int updateExamSpecialty(ExamSpecialty examSpecialty);
/**
* 查询数据信息列表
*
* @param reqVo 查询数据信息
* @return 数据集合
*/
public List<SpecialtyQueryVo> selectExamSpecialtyListVo(SpecialtListReqVo reqVo);
/**
* 查询数据信息列表
*
* @param reqVo 查询数据信息
* @return 数据集合
*/
public List<ExamSpecialty> selectExamSpecialtyList(SpecialtListReqVo reqVo);
/**
* 根据主键列表查询
*
* @param spIds 主键列表
* @return 数据集合
*/
public List<ExamSpecialty> selectSpIds(Long[] spIds);
/**
* 删除数据
*
* @param spId 数据主键
* @return 结果
*/
public int deleteExamSpecialtyBySpId(Long spId);
/**
* 批量删除数据
*
* @param spIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteExamSpecialtyBySpIds(Long[] spIds);
}

View File

@@ -0,0 +1,62 @@
package pc.exam.pp.module.exam.service.knowledge;
import pc.exam.pp.module.exam.dal.dataobject.ExamKnowledgePoints;
import java.util.List;
/**
* 知识点Service接口
*
* @author pengchen
* @date 2025-04-02
*/
public interface ExamKnowledgePointsService
{
/**
* 查询知识点
*
* @param spId 知识点主键
* @return 知识点
*/
public ExamKnowledgePoints selectKnowledgePointsBySpId(Long spId);
/**
* 查询知识点列表
*
* @param knowledgePoints 知识点
* @return 知识点集合
*/
public List<ExamKnowledgePoints> selectKnowledgePointsList(ExamKnowledgePoints knowledgePoints);
/**
* 新增知识点
*
* @param knowledgePoints 知识点
* @return 结果
*/
public int insertKnowledgePoints(ExamKnowledgePoints knowledgePoints);
/**
* 修改知识点
*
* @param knowledgePoints 知识点
* @return 结果
*/
public int updateKnowledgePoints(ExamKnowledgePoints knowledgePoints);
/**
* 批量删除知识点
*
* @param spIds 需要删除的知识点主键集合
* @return 结果
*/
public int deleteKnowledgePointsBySpIds(Long[] spIds);
/**
* 删除知识点信息
*
* @param spId 知识点主键
* @return 结果
*/
public int deleteKnowledgePointsBySpId(Long spId);
}

View File

@@ -0,0 +1,120 @@
package pc.exam.pp.module.exam.service.knowledge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
import pc.exam.pp.module.exam.dal.dataobject.ExamKnowledgePoints;
import pc.exam.pp.module.exam.dal.dataobject.ExamSpecialty;
import pc.exam.pp.module.exam.dal.mysql.ExamKnowledgePointsMapper;
import pc.exam.pp.module.exam.dal.mysql.ExamSpecialtyMapper;
import java.util.List;
import java.util.Objects;
/**
* 知识点Service业务层处理
*
* @author pengchen
* @date 2025-04-02
*/
@Service
public class ExamKnowledgePointsServiceImpl implements ExamKnowledgePointsService
{
@Autowired
private ExamKnowledgePointsMapper knowledgePointsMapper;
@Autowired
private ExamSpecialtyMapper examSpecialtyMapper;
/**
* 查询知识点
*
* @param spId 知识点主键
* @return 知识点
*/
@Override
public ExamKnowledgePoints selectKnowledgePointsBySpId(Long spId)
{
return knowledgePointsMapper.selectKnowledgePointsBySpId(spId);
}
/**
* 查询知识点列表
*
* @param knowledgePoints 知识点
* @return 知识点
*/
@Override
public List<ExamKnowledgePoints> selectKnowledgePointsList(ExamKnowledgePoints knowledgePoints)
{
SpecialtListReqVo reqVo = new SpecialtListReqVo();
List<ExamSpecialty> examSpecialtyList = examSpecialtyMapper.selectExamSpecialtyList(reqVo);
for (ExamSpecialty Specialty:examSpecialtyList){
// 根据ParentId是否为0判断是否为专业
if (Objects.equals(String.valueOf(Specialty.getParentId()), "0") && Objects.equals(Specialty.getUnite(), "0")){
// 实例化已经存在的专业
ExamKnowledgePoints knowledgePoint = new ExamKnowledgePoints();
knowledgePoint.setSpId(Specialty.getSpId());
knowledgePoint.setParentId(Specialty.getParentId());
knowledgePoint.setAncestors(Specialty.getAncestors());
knowledgePoint.setSpName(Specialty.getSpName());
knowledgePoint.setOrderNum(Specialty.getOrderNum());
knowledgePoint.setStatus(Specialty.getStatus());
// 新增专业
knowledgePointsMapper.insert(knowledgePoint);
// 将合并标志改为1
Specialty.setUnite("1");
examSpecialtyMapper.updateById(Specialty);
}
}
return knowledgePointsMapper.selectKnowledgePointsList(knowledgePoints);
}
/**
* 新增知识点
*
* @param knowledgePoints 知识点
* @return 结果
*/
@Override
public int insertKnowledgePoints(ExamKnowledgePoints knowledgePoints)
{
return knowledgePointsMapper.insert(knowledgePoints);
}
/**
* 修改知识点
*
* @param knowledgePoints 知识点
* @return 结果
*/
@Override
public int updateKnowledgePoints(ExamKnowledgePoints knowledgePoints)
{
return knowledgePointsMapper.updateById(knowledgePoints);
}
/**
* 批量删除知识点
*
* @param spIds 需要删除的知识点主键
* @return 结果
*/
@Override
public int deleteKnowledgePointsBySpIds(Long[] spIds)
{
return knowledgePointsMapper.deleteKnowledgePointsBySpIds(spIds);
}
/**
* 删除知识点信息
*
* @param spId 知识点主键
* @return 结果
*/
@Override
public int deleteKnowledgePointsBySpId(Long spId)
{
return knowledgePointsMapper.deleteKnowledgePointsBySpId(spId);
}
}

View File

@@ -0,0 +1,73 @@
package pc.exam.pp.module.exam.service.specialty;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo;
import pc.exam.pp.module.exam.dal.dataobject.ExamSpecialty;
import java.util.List;
/**
* 专业——课程——题型Service接口
*
* @author pengchen
* @date 2025-03-24
*/
public interface ExamSpecialtyService
{
/**
* 查询信息
*
* @param spId 主键
* @return 所有信息
*/
public ExamSpecialty selectExamSpecialtyBySpId(Long spId);
/**
* 查询全部信息列表
*
* @param reqVO 信息数据
* @return 全部信息集合
*/
public List<SpecialtyQueryVo> selectExamSpecialtyList(SpecialtListReqVo reqVO);
/**
* 根据主键查询
*
* @param spIds 主键id列表
* @return 该主键id列表下的全部数据
*/
public List<ExamSpecialty> selectSpIds(Long[] spIds);
/**
* 新增数据信息
*
* @param examSpecialty 数据信息
* @return 结果
*/
public int insertExamSpecialty(ExamSpecialty examSpecialty);
/**
* 修改数据
*
* @param examSpecialty 数据信息
* @return 结果
*/
public int updateExamSpecialty(ExamSpecialty examSpecialty);
/**
* 批量删除客户端
*
* @param spIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteExamSpecialtyBySpIds(Long[] spIds);
/**
* 删除客户端信息
*
* @param spId 主键id
* @return 结果
*/
public int deleteExamSpecialtyBySpId(Long spId);
}

View File

@@ -0,0 +1,118 @@
package pc.exam.pp.module.exam.service.specialty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pc.exam.pp.framework.common.util.object.BeanUtils;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo;
import pc.exam.pp.module.exam.dal.dataobject.ExamKnowledgePoints;
import pc.exam.pp.module.exam.dal.dataobject.ExamSpecialty;
import pc.exam.pp.module.exam.dal.mysql.ExamKnowledgePointsMapper;
import pc.exam.pp.module.exam.dal.mysql.ExamSpecialtyMapper;
import java.util.List;
import java.util.Objects;
@Service
public class ExamSpecialtyServiceImpl implements ExamSpecialtyService {
@Autowired
private ExamSpecialtyMapper examSpecialtyMapper;
@Autowired
private ExamKnowledgePointsMapper knowledgePointsMapper;
/**
* 查询数据信息
*
* @param spId 数据主键id
* @return 数据信息
*/
@Override
public ExamSpecialty selectExamSpecialtyBySpId(Long spId)
{
return examSpecialtyMapper.selectExamSpecialtyBySpId(spId);
}
/**
* 查询数据信息列表
*
* @param reqVo 查询数据信息
* @return 数据信息
*/
@Override
public List<SpecialtyQueryVo> selectExamSpecialtyList(SpecialtListReqVo reqVo)
{
return examSpecialtyMapper.selectExamSpecialtyListVo(reqVo);
}
/**
* 根据主键列表查询
*
* @param spIds 主键id列表
* @return 数据信息
*/
@Override
public List<ExamSpecialty> selectSpIds(Long[] spIds){
return examSpecialtyMapper.selectSpIds(spIds);
}
/**
* 新增数据信息
*
* @param examSpecialty 新增数据
* @return 结果
*/
@Override
public int insertExamSpecialty(ExamSpecialty examSpecialty)
{
// 插入部门
ExamSpecialty specialty = BeanUtils.toBean(examSpecialty, ExamSpecialty.class);
return examSpecialtyMapper.insert(specialty);
}
/**
* 修改数据信息
*
* @param examSpecialty 修改数据
* @return 结果
*/
@Override
public int updateExamSpecialty(ExamSpecialty examSpecialty)
{
// 对专业修改需判断是否已经互联
// 已互联的情况需要对知识点表也进行修改
ExamSpecialty Specialty = examSpecialtyMapper.selectExamSpecialtyBySpId(examSpecialty.getSpId());
if (Objects.equals(Specialty.getUnite(), "1")){
// 实例化需要修改的专业
ExamKnowledgePoints knowledgePoint = new ExamKnowledgePoints();
knowledgePoint.setSpId(examSpecialty.getSpId());
knowledgePoint.setSpName(examSpecialty.getSpName());
knowledgePointsMapper.updateById(knowledgePoint);
}
return examSpecialtyMapper.updateById(examSpecialty);
}
/**
* 批量删除数据
*
* @param spIds 需要删除的数据主键
* @return 结果
*/
@Override
public int deleteExamSpecialtyBySpIds(Long[] spIds)
{
return examSpecialtyMapper.deleteExamSpecialtyBySpIds(spIds);
}
/**
* 删除数据信息
*
* @param spId 数据主键
* @return 结果
*/
@Override
public int deleteExamSpecialtyBySpId(Long spId)
{
return examSpecialtyMapper.deleteExamSpecialtyBySpId(spId);
}
}

View File

@@ -0,0 +1,58 @@
<?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="pc.exam.pp.module.exam.dal.mysql.ExamKnowledgePointsMapper">
<resultMap type="ExamKnowledgePoints" id="KnowledgePointsResult">
<result property="spId" column="sp_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="spName" column="sp_name" />
<result property="orderNum" column="order_num" />
<result property="status" column="status" />
<result property="treeNum" column="tree_num" />
</resultMap>
<sql id="selectKnowledgePointsVo">
select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, tree_num, tenant_id from exam_knowledge_points
</sql>
<select id="selectKnowledgePointsList" parameterType="ExamKnowledgePoints" resultMap="KnowledgePointsResult">
<include refid="selectKnowledgePointsVo"/>
<where>
<if test="knowledgePoints.parentId != null "> and parent_id = #{knowledgePoints.parentId}</if>
<if test="knowledgePoints.ancestors != null and knowledgePoints.ancestors != ''"> and ancestors = #{knowledgePoints.ancestors}</if>
<if test="knowledgePoints.spName != null and knowledgePoints.spName != ''"> and sp_name like concat('%', #{knowledgePoints.spName}, '%')</if>
<if test="knowledgePoints.orderNum != null "> and order_num = #{knowledgePoints.orderNum}</if>
<if test="knowledgePoints.status != null and knowledgePoints.status != ''"> and status = #{knowledgePoints.status}</if>
and deleted = 0
</where>
</select>
<select id="selectKnowledgePointsBySpId" parameterType="Long" resultMap="KnowledgePointsResult">
<include refid="selectKnowledgePointsVo"/>
where sp_id = #{spId}
</select>
<update id="deleteKnowledgePointsBySpId" parameterType="Long">
update exam_knowledge_points
<trim prefix="SET" suffixOverrides=",">
deleted = 1
</trim>
where sp_id = #{spId}
</update>
<update id="deleteKnowledgePointsBySpIds" parameterType="String">
-- delete from knowledge_points
update exam_knowledge_points
<trim prefix="SET" suffixOverrides=",">
deleted = 1
</trim>
where sp_id in
<foreach item="spId" collection="array" open="(" separator="," close=")">
#{spId}
</foreach>
</update>
</mapper>

View File

@@ -0,0 +1,90 @@
<?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="pc.exam.pp.module.exam.dal.mysql.ExamSpecialtyMapper">
<resultMap type="ExamSpecialty" id="ExamSpecialtyResult">
<result property="spId" column="sp_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="spName" column="sp_name" />
<result property="orderNum" column="order_num" />
<result property="status" column="status" />
<result property="unite" column="unite" />
<result property="treeNum" column="tree_num" />
</resultMap>
<sql id="selectExamSpecialtyVo">
select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, unite, tree_num, tenant_id from exam_specialty
</sql>
<select id="selectExamSpecialtyListVo" resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
select sp_id as id, sp_name as name, parent_id, status, create_time from exam_specialty
<where>
<if test="name != null and name != ''"> and sp_name like concat('%', #{name}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
and deleted = 0
</where>
</select>
<select id="selectExamSpecialtyList" resultType="ExamSpecialty">
<include refid="selectExamSpecialtyVo"/>
<where>
<if test="name != null and name != ''"> and sp_name like concat('%', #{name}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
and deleted = 0
</where>
</select>
<select id="selectSpIds" parameterType="ExamSpecialty" resultMap="ExamSpecialtyResult">
<include refid="selectExamSpecialtyVo"/>
<!-- <where>-->
<!-- <if test="spId != null "> and sp_id = #{spId}</if>-->
<!-- </where>-->
where sp_id in
<foreach item="spId" collection="array" open="(" separator="," close=")">
#{spId}
</foreach>
</select>
<update id="updateExamSpecialty" parameterType="ExamSpecialty">
update exam_specialty
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="spName != null">sp_name = #{spName},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="status != null">status = #{status},</if>
<if test="unite != null">unite = #{unite},</if>
<if test="treeNum != null">tree_num = #{treeNum},</if>
</trim>
where sp_id = #{spId}
</update>
<select id="selectExamSpecialtyBySpId" parameterType="Long" resultMap="ExamSpecialtyResult">
<include refid="selectExamSpecialtyVo"/>
where sp_id = #{spId}
</select>
<update id="deleteExamSpecialtyBySpId" parameterType="Long">
update exam_specialty
<trim prefix="SET" suffixOverrides=",">
deleted = 1
</trim>
where sp_id = #{spId}
</update>
<update id="deleteExamSpecialtyBySpIds" parameterType="String">
update exam_specialty
<trim prefix="SET" suffixOverrides=",">
deleted = 1
</trim>
where sp_id in
<foreach item="spId" collection="array" open="(" separator="," close=")">
#{spId}
</foreach>
</update>
</mapper>