Merge remote-tracking branch 'origin/在线访问lhj' into 在线访问lhj

在线访问lhj
李宏杰 8 months ago
commit 46c38e66d3

@ -2,45 +2,40 @@ package com.tamguo.modules.tiku.model;
import java.io.Serializable; import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField; // 用于 JSON 序列化时的注解
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature; // JSON 序列化特性
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField; // 与数据库表字段相关的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName; // 表名注解
import com.tamguo.config.dao.SuperEntity; import com.tamguo.config.dao.SuperEntity; // 父类实体
import com.tamguo.modules.tiku.model.enums.ChapterStatusEnum; import com.tamguo.modules.tiku.model.enums.ChapterStatusEnum; // 章节状态枚举
import lombok.Data; import lombok.Data; // Lombok 的数据注解
import java.util.List;
/** /**
* The persistent class for the t_chapter database table. * t_chapter
*
*/ */
@TableName(value="t_chapter") @TableName(value = "t_chapter") // 指定表名为 t_chapter
@Data @Data // Lombok 的数据注解,自动生成 getter 和 setter 等方法
public class ChapterEntity extends SuperEntity<ChapterEntity> implements Serializable { public class ChapterEntity extends SuperEntity<ChapterEntity> implements Serializable { // 继承父类实体,实现序列化接口
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L; // 序列化版本号
private String courseId; private String courseId; // 课程 ID
private String bookId; private String bookId; // 书籍 ID
private String name; private String name; // 章节名称
private String parentCode; private String parentCode; // 父章节代码
private String parentCodes; private String parentCodes; // 父章节代码列表
private Integer questionNum; private Integer questionNum; // 问题数量
private Integer pointNum; private Integer pointNum; // 知识点数量
private Integer orders; private Integer orders; // 排序序号
private Boolean treeLeaf; private Boolean treeLeaf; // 是否为叶子节点
private Integer treeLevel; private Integer treeLevel; // 树的层级
private String seoTitle; private String seoTitle; // SEO 标题
private String seoKeywords; private String seoKeywords; // SEO 关键字
private String seoDescription; private String seoDescription; // SEO 描述
@TableField(exist=false) @TableField(exist = false) // 表示该字段在数据库中不存在
private List<ChapterEntity> childChapterList; private List<ChapterEntity> childChapterList; // 子章节列表
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString) @JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString) // 指定 JSON 序列化枚举时的特性
private ChapterStatusEnum status; private ChapterStatusEnum status; // 章节状态枚举
} }

@ -1,43 +1,42 @@
package com.tamguo.modules.tiku.model; package com.tamguo.modules.tiku.model;
import java.util.Date; import java.util.Date; // 日期类
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.tamguo.modules.tiku.model.enums.CourseStatusEnum;
import lombok.Data;
@Data import com.alibaba.fastjson.annotation.JSONField; // 用于 JSON 序列化时的注解
@TableName(value="t_course") import com.alibaba.fastjson.serializer.SerializerFeature; // JSON 序列化特性
public class CourseEntity { import com.baomidou.mybatisplus.annotations.TableField; // 与数据库表字段相关的注解
import com.baomidou.mybatisplus.annotations.TableId; // 表主键注解
@TableId import com.baomidou.mybatisplus.annotations.TableName; // 表名注解
private String id; import com.baomidou.mybatisplus.enums.FieldFill; // 字段填充策略枚举
private String subjectId; import com.tamguo.modules.tiku.model.enums.CourseStatusEnum; // 课程状态枚举
private String name; import lombok.Data; // Lombok 的数据注解
private Integer sort;
private Integer questionNum;
private Integer pointNum;
private String remarks;
private String icon;
private String seoTitle; @Data // Lombok 的数据注解,自动生成 getter 和 setter 等方法
private String seoKeywords; @TableName(value = "t_course") // 指定表名为 t_course
private String seoDescription; public class CourseEntity {
@TableId // 标识为主键
private String id; // 课程 ID
private String subjectId; // 科目 ID
private String name; // 课程名称
private Integer sort; // 排序号
private Integer questionNum; // 问题数量
private Integer pointNum; // 知识点数量
private String remarks; // 备注
private String icon; // 图标
@TableField(fill = FieldFill.INSERT_UPDATE) private String seoTitle; // SEO 标题
private String createBy; private String seoKeywords; // SEO 关键字
@TableField(fill = FieldFill.INSERT_UPDATE) private String seoDescription; // SEO 描述
private String updateBy;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date createDate;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
@JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString) @TableField(fill = FieldFill.INSERT_UPDATE) // 字段填充策略,在插入和更新时填充
private CourseStatusEnum status; private String createBy; // 创建人
@TableField(fill = FieldFill.INSERT_UPDATE) // 字段填充策略,在插入和更新时填充
private String updateBy; // 更新人
@TableField(fill = FieldFill.INSERT_UPDATE) // 字段填充策略,在插入和更新时填充
private Date createDate; // 创建日期
@TableField(fill = FieldFill.INSERT_UPDATE) // 字段填充策略,在插入和更新时填充
private Date updateDate; // 更新日期
@JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString) // 指定 JSON 序列化枚举时的特性
private CourseStatusEnum status; // 课程状态枚举
} }

@ -1,28 +1,66 @@
package com.tamguo.modules.tiku.model.enums; package com.tamguo.modules.tiku.model.enums;
import java.io.Serializable;
/** /**
* (1.2.; 3.) *
* (1. 2. 3. 4. 5. )
* *
* @author tamguo * @author tamguo
*
*/ */
public enum QuestionTypeEnum { public enum QuestionTypeEnum {
/**
*
* @param value
* @param desc
*/
DANXUANTI("1", "单选题"), DANXUANTI("1", "单选题"),
/**
*
* @param value
* @param desc
*/
DUOXUANTI("2", "多选题"), DUOXUANTI("2", "多选题"),
/**
*
* @param value
* @param desc
*/
TIANKONGTI("3", "填空题"), TIANKONGTI("3", "填空题"),
/**
*
* @param value
* @param desc
*/
PANDUANTI("4", "判断题"), PANDUANTI("4", "判断题"),
/**
*
* @param value
* @param desc
*/
WENDATI("5", "问答题"); WENDATI("5", "问答题");
private String value; private String value; // 枚举值
private String desc; private String desc; // 描述
/**
*
* @param value
* @param desc
*/
QuestionTypeEnum(final String value, final String desc) { QuestionTypeEnum(final String value, final String desc) {
this.value = value; this.value = value;
this.desc = desc; this.desc = desc;
} }
/**
* value
* @param value value
* @return WENDATI
*/
public static QuestionTypeEnum getQuestionType(String value) { public static QuestionTypeEnum getQuestionType(String value) {
if ("1".equals(value)) { if ("1".equals(value)) {
return DANXUANTI; return DANXUANTI;
@ -38,17 +76,28 @@ public enum QuestionTypeEnum {
return WENDATI; return WENDATI;
} }
/**
*
* @return
*/
public Serializable getValue() { public Serializable getValue() {
return this.value; return this.value;
} }
/**
*
* @return
*/
public String getDesc() { public String getDesc() {
return this.desc; return this.desc;
} }
/**
*
* @return
*/
@Override @Override
public String toString() { public String toString() {
return this.value; return this.value;
} }
} }

@ -1,45 +1,54 @@
package com.tamguo.modules.tiku.service.impl; package com.tamguo.modules.tiku.service.impl;
import java.util.ArrayList; import java.util.ArrayList; // 导入 ArrayList 类,用于存储章节列表
import java.util.List; import java.util.List; // 导入 List 接口,用于存储章节实体列表
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils; // 导入StringUtils 类,用于字符串操作
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired; // 导入 Autowired 注解,用于依赖注入
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service; // 导入 Service 注解,标识为服务层实现类
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional; // 导入 Transactional 注解,用于事务管理
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray; // 导入 JSONArray 类,用于处理 JSON 数组
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject; // 导入 JSONObject 类,用于处理 JSON 对象
import com.baomidou.mybatisplus.mapper.Condition; import com.baomidou.mybatisplus.mapper.Condition; // 导入 Condition 类,用于构建查询条件
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page; // 导入 Page 类,用于分页查询
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl; // 导入 ServiceImpl 类,作为服务层实现类的父类
import com.tamguo.common.utils.SystemConstant; import com.tamguo.common.utils.SystemConstant; // 导入 SystemConstant 类,用于定义系统常量
import com.tamguo.modules.tiku.dao.KnowPointMapper; import com.tamguo.modules.tiku.dao.KnowPointMapper; // 导入 KnowPointMapper 接口,用于知识关键点的数据访问
import com.tamguo.modules.tiku.dao.ChapterMapper; import com.tamguo.modules.tiku.dao.ChapterMapper; // 导入 ChapterMapper 接口,用于章节的数据访问
import com.tamguo.modules.tiku.dao.CourseMapper; import com.tamguo.modules.tiku.dao.CourseMapper; // 导入 CourseMapper 接口,用于课程的数据访问
import com.tamguo.modules.tiku.model.KnowPointEntity; import com.tamguo.modules.tiku.model.KnowPointEntity; // 导入 KnowPointEntity 类,代表知识关键点实体
import com.tamguo.modules.tiku.model.ChapterEntity; import com.tamguo.modules.tiku.model.ChapterEntity; // 导入 ChapterEntity 类,代表章节实体
import com.tamguo.modules.tiku.model.condition.ChapterCondition; import com.tamguo.modules.tiku.model.condition.ChapterCondition; // 导入 ChapterCondition 类,代表章节查询条件
import com.tamguo.modules.tiku.model.enums.ChapterStatusEnum; import com.tamguo.modules.tiku.model.enums.ChapterStatusEnum; // 导入 ChapterStatusEnum 枚举,代表章节状态
import com.tamguo.modules.tiku.service.IChapterService; import com.tamguo.modules.tiku.service.IChapterService; // 导入 IChapterService 接口,定义章节服务的接口
@Service @Service // 标识为服务层实现类
public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity> implements IChapterService { public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity> implements IChapterService {
@Autowired @Autowired // 自动注入 ChapterMapper 实例
ChapterMapper chapterMapper; private ChapterMapper chapterMapper;
@Autowired
CourseMapper courseMapper; @Autowired // 自动注入 CourseMapper 实例
@Autowired private CourseMapper courseMapper;
KnowPointMapper bookMapper;
@Autowired // 自动注入 KnowPointMapper 实例
private KnowPointMapper bookMapper;
@Transactional(readOnly=false) /**
@SuppressWarnings("unchecked") *
*
* @param bookId ID
* @return
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@SuppressWarnings("unchecked") // 抑制unchecked 警告
@Override @Override
public List<ChapterEntity> findChapterTree(String bookId) { public List<ChapterEntity> findChapterTree(String bookId) {
// 根据书籍 ID 查询章节列表
List<ChapterEntity> chapterList = baseMapper.selectList(Condition.create().eq("book_id", bookId)); List<ChapterEntity> chapterList = baseMapper.selectList(Condition.create().eq("book_id", bookId));
// 获取根chapter UID // 获取根章节 UID
String rootUid = StringUtils.EMPTY; String rootUid = StringUtils.EMPTY;
for (int i = 0; i < chapterList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
ChapterEntity chapter = chapterList.get(i); ChapterEntity chapter = chapterList.get(i);
@ -47,6 +56,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
rootUid = chapter.getId(); rootUid = chapter.getId();
} }
} }
// 获取第一层结构 // 获取第一层结构
List<ChapterEntity> entitys = new ArrayList<>(); List<ChapterEntity> entitys = new ArrayList<>();
for (int i = 0; i < chapterList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
@ -55,8 +65,10 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
entitys.add(chapter); entitys.add(chapter);
} }
} }
for (int i = 0; i < entitys.size(); i++) { for (int i = 0; i < entitys.size(); i++) {
ChapterEntity entity = entitys.get(i); ChapterEntity entity = entitys.get(i);
// 获取子章节列表
List<ChapterEntity> childs = new ArrayList<>(); List<ChapterEntity> childs = new ArrayList<>();
for (int k = 0; k < chapterList.size(); k++) { for (int k = 0; k < chapterList.size(); k++) {
ChapterEntity chapter = chapterList.get(k); ChapterEntity chapter = chapterList.get(k);
@ -66,10 +78,12 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
} }
entity.setChildChapterList(childs); entity.setChildChapterList(childs);
} }
for (int i = 0; i < entitys.size(); i++) { for (int i = 0; i < entitys.size(); i++) {
List<ChapterEntity> childs = entitys.get(i).getChildChapterList(); List<ChapterEntity> childs = entitys.get(i).getChildChapterList();
for (int k = 0; k < childs.size(); k++) { for (int k = 0; k < childs.size(); k++) {
ChapterEntity child = childs.get(k); ChapterEntity child = childs.get(k);
// 获取子子章节列表
List<ChapterEntity> tmpChilds = new ArrayList<>(); List<ChapterEntity> tmpChilds = new ArrayList<>();
for (int n = 0; n < chapterList.size(); n++) { for (int n = 0; n < chapterList.size(); n++) {
ChapterEntity chapter = chapterList.get(n); ChapterEntity chapter = chapterList.get(n);
@ -83,83 +97,98 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
return entitys; return entitys;
} }
@SuppressWarnings("unchecked") /**
*
*
* @param condition
* @return
*/
@SuppressWarnings("unchecked") // 抑制 unchecked 警告
@Override @Override
public List<ChapterEntity> listData(ChapterCondition condition) { public List<ChapterEntity> listData(ChapterCondition condition) {
Condition query = Condition.create(); Condition query = Condition.create(); // 创建查询条件对象
if (!StringUtils.isEmpty(condition.getParentCode())) { if (!StringUtils.isEmpty(condition.getParentCode())) {
query.eq("parent_code", condition.getParentCode()); query.eq("parent_code", condition.getParentCode()); // 添加父章节代码条件
} else { } else {
query.eq("tree_level", "0"); query.eq("tree_level", "0"); // 添加树级别为 0 的条件(即根章节)
} }
if (!StringUtils.isEmpty(condition.getId())) { if (!StringUtils.isEmpty(condition.getId())) {
query.eq("id", condition.getId()); query.eq("id", condition.getId()); // 添加章节 ID 条件
} }
if (!StringUtils.isEmpty(condition.getName())) { if (!StringUtils.isEmpty(condition.getName())) {
query.like("name", condition.getName()); query.like("name", condition.getName()); // 添加章节名称模糊匹配条件
} }
if (!StringUtils.isEmpty(condition.getBookId())) { if (!StringUtils.isEmpty(condition.getBookId())) {
query.andNew().eq("course_id", condition.getBookId()).or().eq("book_id", condition.getBookId()).or().eq("subject_id", condition.getBookId());; query.andNew().eq("course_id", condition.getBookId()).or().eq("book_id", condition.getBookId()).or().eq("subject_id", condition.getBookId()); // 添加课程 ID、书籍 ID 或科目 ID 条件
} }
return chapterMapper.selectList(query); return chapterMapper.selectList(query); // 执行查询并返回结果
}
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData(String courseId, String excludeId) {
List<ChapterEntity> chapterList = null;
if(StringUtils.isEmpty(excludeId)) {
chapterList = chapterMapper.selectList(Condition.EMPTY);
} else {
chapterList = chapterMapper.selectList(Condition.create().notLike("parent_codes", excludeId).eq("id", excludeId));
}
return turnZTreeData(chapterList);
} }
/**
* ZTree JSON
*
* @param chapterList
* @return ZTree JSON
*/
private JSONArray turnZTreeData(List<ChapterEntity> chapterList) { private JSONArray turnZTreeData(List<ChapterEntity> chapterList) {
if (chapterList!= null) { if (chapterList!= null) {
JSONArray nodes = new JSONArray(); JSONArray nodes = new JSONArray(); // 创建 JSON 数组对象
for (int i = 0; i < chapterList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
JSONObject node = new JSONObject(); JSONObject node = new JSONObject(); // 创建 JSON 对象
ChapterEntity office = chapterList.get(i); ChapterEntity office = chapterList.get(i); // 获取章节实体
node.put("name", office.getName()); node.put("name", office.getName()); // 设置节点名称
node.put("id", office.getId()); node.put("id", office.getId()); // 设置节点 ID
node.put("pId", office.getParentCode()); node.put("pId", office.getParentCode()); // 设置父节点 ID
node.put("title", office.getName()); node.put("title", office.getName()); // 设置节点标题
nodes.add(node);
nodes.add(node); // 将节点添加到 JSON 数组中
} }
return nodes; return nodes; // 返回 JSON 数组
} }
return null; return null; // 如果章节列表为空,则返回 null
} }
@Transactional(readOnly=false) /**
*
*
* @param chapter
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void save(ChapterEntity chapter) { public void save(ChapterEntity chapter) {
// 更新父章节的叶子节点状态为 false
ChapterEntity parentChapter = chapterMapper.selectById(chapter.getParentCode()); ChapterEntity parentChapter = chapterMapper.selectById(chapter.getParentCode());
parentChapter.setTreeLeaf(false); parentChapter.setTreeLeaf(false);
chapterMapper.updateById(parentChapter); chapterMapper.updateById(parentChapter);
chapter.setStatus(ChapterStatusEnum.NORMAL); chapter.setStatus(ChapterStatusEnum.NORMAL); // 设置章节状态为正常
chapter.setTreeLeaf(true); chapter.setTreeLeaf(true); // 设置章节为叶子节点
chapter.setTreeLevel(parentChapter.getTreeLevel() + 1); chapter.setTreeLevel(parentChapter.getTreeLevel() + 1); // 设置章节树级别
chapter.setBookId(parentChapter.getBookId()); chapter.setBookId(parentChapter.getBookId()); // 设置章节所属书籍 ID
chapterMapper.insert(chapter); chapterMapper.insert(chapter); // 插入章节记录
// 更新章节的父章节代码列表
chapter.setParentCodes(parentChapter.getParentCodes() + chapter.getId() + ","); chapter.setParentCodes(parentChapter.getParentCodes() + chapter.getId() + ",");
chapterMapper.updateById(chapter); chapterMapper.updateById(chapter);
} }
@SuppressWarnings("unchecked") /**
@Transactional(readOnly=false) *
*
* @param chapter
*/
@SuppressWarnings("unchecked") // 抑制 unchecked 警告
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void update(ChapterEntity chapter) { public void update(ChapterEntity chapter) {
ChapterEntity entity = chapterMapper.selectById(chapter.getId()); // 更新父章节的叶子节点状态为 false
ChapterEntity parentChapter = chapterMapper.selectById(chapter.getParentCode()); ChapterEntity parentChapter = chapterMapper.selectById(chapter.getParentCode());
parentChapter.setTreeLeaf(false); parentChapter.setTreeLeaf(false);
chapterMapper.updateById(parentChapter); chapterMapper.updateById(parentChapter);
// 更新章节信息
ChapterEntity entity = chapterMapper.selectById(chapter.getId());
entity.setName(chapter.getName()); entity.setName(chapter.getName());
entity.setParentCode(chapter.getParentCode()); entity.setParentCode(chapter.getParentCode());
entity.setParentCodes(parentChapter.getParentCodes() + entity.getId() + ","); entity.setParentCodes(parentChapter.getParentCodes() + entity.getId() + ",");
@ -168,7 +197,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
entity.setOrders(chapter.getOrders()); entity.setOrders(chapter.getOrders());
entity.setTreeLevel(entity.getParentCodes().split(",").length - 1); entity.setTreeLevel(entity.getParentCodes().split(",").length - 1);
// 更新子集章节 // 更新子集章节的父章节代码列表和树级别
List<ChapterEntity> chapterList = chapterMapper.selectList(Condition.create().like("parent_codes", entity.getId())); List<ChapterEntity> chapterList = chapterMapper.selectList(Condition.create().like("parent_codes", entity.getId()));
for (int i = 0; i < chapterList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
ChapterEntity child = chapterList.get(i); ChapterEntity child = chapterList.get(i);
@ -181,13 +210,20 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
chapterMapper.updateById(entity); chapterMapper.updateById(entity);
} }
@Transactional(readOnly=false) /**
@SuppressWarnings("unchecked") *
*
* @param id ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@SuppressWarnings("unchecked") // 抑制 unchecked 警告
@Override @Override
public void delete(String id) { public void delete(String id) {
// 更新章节状态为已删除
ChapterEntity chapter = chapterMapper.selectById(id); ChapterEntity chapter = chapterMapper.selectById(id);
chapter.setStatus(ChapterStatusEnum.DELETE); chapter.setStatus(ChapterStatusEnum.DELETE);
chapterMapper.updateById(chapter); chapterMapper.updateById(chapter);
// 删除子章节 // 删除子章节
List<ChapterEntity> childs = chapterMapper.selectList(Condition.create().like("parent_codes", id)); List<ChapterEntity> childs = chapterMapper.selectList(Condition.create().like("parent_codes", id));
for (int i = 0; i < childs.size(); i++) { for (int i = 0; i < childs.size(); i++) {
@ -197,24 +233,41 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
} }
} }
@Transactional(readOnly=true) /**
@SuppressWarnings("unchecked") * ID
*
* @param courseId ID
* @return
*/
@Transactional(readOnly = true) // 开启事务,设置只读为 true
@SuppressWarnings("unchecked") // 抑制 unchecked 警告
@Override @Override
public List<ChapterEntity> findCourseChapter(String courseId) { public List<ChapterEntity> findCourseChapter(String courseId) {
// 根据课程 ID 查询知识关键点列表
List<KnowPointEntity> bookList = bookMapper.selectList(Condition.create().eq("course_id", courseId)); List<KnowPointEntity> bookList = bookMapper.selectList(Condition.create().eq("course_id", courseId));
if (bookList.size() == 0) { if (bookList.size() == 0) {
return null; return null; // 如果没有找到知识关键点,则返回 null
} }
Condition condition = Condition.create();
condition.eq("tree_level", 1); Condition condition = Condition.create(); // 创建查询条件对象
condition.eq("book_id", bookList.get(0).getId()); condition.eq("tree_level", 1); // 设置树级别为 1
condition.eq("book_id", bookList.get(0).getId()); // 设置书籍 ID
// 根据条件查询章节列表
List<ChapterEntity> list = chapterMapper.selectPage(new Page<>(1, 5), condition); List<ChapterEntity> list = chapterMapper.selectPage(new Page<>(1, 5), condition);
return list; return list; // 返回章节列表
} }
@Transactional(readOnly=true) /**
* ID
*
* @param parentCode
* @param id ID
* @return
*/
@Transactional(readOnly = true) // 开启事务,设置只读为 true
@Override @Override
public ChapterEntity selectNextChapter(String parentCode, String id) { public ChapterEntity selectNextChapter(String parentCode, String id) {
return chapterMapper.selectNextChapter(parentCode , id); return chapterMapper.selectNextChapter(parentCode, id); // 查询下一个章节
} }
} }

@ -1,125 +1,185 @@
package com.tamguo.modules.tiku.service.impl; package com.tamguo.modules.tiku.service.impl;
import java.util.Arrays; import java.util.Arrays; // 导入 Arrays 类,用于操作数组
import java.util.List; import java.util.List; // 导入 List 接口,用于存储科目和课程实体列表
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired; // 导入 Autowired 注解,用于依赖注入
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service; // 导入 Service 注解,标识为服务层实现类
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional; // 导入 Transactional 注解,用于事务管理
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils; // 导入 StringUtils 类,用于字符串操作
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray; // 导入 JSONArray 类,用于处理 JSON 数组
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject; // 导入 JSONObject 类,用于处理 JSON 对象
import com.baomidou.mybatisplus.mapper.Condition; import com.baomidou.mybatisplus.mapper.Condition; // 导入 Condition 类,用于构建查询条件
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page; // 导入 Page 类,用于分页查询
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl; // 导入 ServiceImpl 类,作为服务层实现类的父类
import com.tamguo.modules.tiku.dao.CourseMapper; import com.tamguo.modules.tiku.dao.CourseMapper; // 导入 CourseMapper 接口,用于课程的数据访问
import com.tamguo.modules.tiku.dao.SubjectMapper; import com.tamguo.modules.tiku.dao.SubjectMapper; // 导入 SubjectMapper 接口,用于科目的数据访问
import com.tamguo.modules.tiku.model.CourseEntity; import com.tamguo.modules.tiku.model.CourseEntity; // 导入 CourseEntity 类,代表课程实体
import com.tamguo.modules.tiku.model.SubjectEntity; import com.tamguo.modules.tiku.model.SubjectEntity; // 导入 SubjectEntity 类,代表科目实体
import com.tamguo.modules.tiku.model.condition.CourseCondition; import com.tamguo.modules.tiku.model.condition.CourseCondition; // 导入 CourseCondition 类,代表课程查询条件
import com.tamguo.modules.tiku.model.enums.CourseStatusEnum; import com.tamguo.modules.tiku.model.enums.CourseStatusEnum; // 导入 CourseStatusEnum 枚举,代表课程状态
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum; import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum; // 导入 SubjectStatusEnum 枚举,代表科目状态
import com.tamguo.modules.tiku.service.ICourseService; import com.tamguo.modules.tiku.service.ICourseService; // 导入 ICourseService 接口,定义课程服务的接口
@Service @Service // 标识为服务层实现类
public class CourseServiceImpl extends ServiceImpl<CourseMapper, CourseEntity> implements ICourseService { public class CourseServiceImpl extends ServiceImpl<CourseMapper, CourseEntity> implements ICourseService {
@Autowired @Autowired // 自动注入 CourseMapper 实例
public CourseMapper courseMapper; private CourseMapper courseMapper;
@Autowired
public SubjectMapper subjectMapper;
@SuppressWarnings("unchecked") @Autowired // 自动注入 SubjectMapper 实例
@Transactional(readOnly=true) private SubjectMapper subjectMapper;
/**
*
*
* @param condition
* @return
*/
@SuppressWarnings("unchecked") // 抑制unchecked 警告
@Transactional(readOnly = true) // 开启事务,设置只读为 true
@Override @Override
public Page<CourseEntity> listData(CourseCondition condition) { public Page<CourseEntity> listData(CourseCondition condition) {
Page<CourseEntity> page = new Page<>(condition.getPageNo() , condition.getPageSize()); Page<CourseEntity> page = new Page<>(condition.getPageNo(), condition.getPageSize()); // 创建分页对象
Condition query = Condition.create();
Condition query = Condition.create(); // 创建查询条件对象
if (!StringUtils.isEmpty(condition.getId())) { if (!StringUtils.isEmpty(condition.getId())) {
query.eq("id", condition.getId()); query.eq("id", condition.getId()); // 添加课程 ID 条件
} }
if (!StringUtils.isEmpty(condition.getName())) { if (!StringUtils.isEmpty(condition.getName())) {
query.like("name", condition.getName()); query.like("name", condition.getName()); // 添加课程名称模糊匹配条件
} }
if (!StringUtils.isEmpty(condition.getSubjectId())) { if (!StringUtils.isEmpty(condition.getSubjectId())) {
query.eq("subject_id", condition.getSubjectId()); query.eq("subject_id", condition.getSubjectId()); // 添加科目 ID 条件
} }
if (!StringUtils.isEmpty(condition.getStatus())) { if (!StringUtils.isEmpty(condition.getStatus())) {
query.eq("status", condition.getStatus()); query.eq("status", condition.getStatus()); // 添加课程状态条件
} }
query.orderAsc(Arrays.asList("sort")); query.orderAsc(Arrays.asList("sort")); // 根据排序字段升序排序
return page.setRecords(courseMapper.selectPage(page , query));
return page.setRecords(courseMapper.selectPage(page, query)); // 执行查询并设置分页结果
} }
@Transactional(readOnly=false) /**
*
*
* @param course
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void save(CourseEntity course) { public void save(CourseEntity course) {
course.setStatus(CourseStatusEnum.NORMAL); course.setStatus(CourseStatusEnum.NORMAL); // 设置课程状态为正常
courseMapper.insert(course); courseMapper.insert(course); // 插入课程记录
} }
@Transactional(readOnly=false) /**
*
*
* @param course
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void update(CourseEntity course) { public void update(CourseEntity course) {
CourseEntity entity = courseMapper.selectById(course.getId()); CourseEntity entity = courseMapper.selectById(course.getId()); // 获取要更新的课程实体
entity.setName(course.getName());
entity.setSubjectId(course.getSubjectId()); entity.setName(course.getName()); // 更新课程名称
entity.setSort(course.getSort()); entity.setSubjectId(course.getSubjectId()); // 更新科目 ID
entity.setRemarks(course.getRemarks()); entity.setSort(course.getSort()); // 更新排序号
courseMapper.updateById(entity); entity.setRemarks(course.getRemarks()); // 更新备注
courseMapper.updateById(entity); // 更新课程记录
} }
@Transactional(readOnly=false) /**
*
*
* @param uid ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void delete(String uid) { public void delete(String uid) {
CourseEntity entity = courseMapper.selectById(uid); CourseEntity entity = courseMapper.selectById(uid); // 获取要删除的课程实体
entity.setStatus(CourseStatusEnum.DELETE);
courseMapper.updateById(entity); entity.setStatus(CourseStatusEnum.DELETE); // 设置课程状态为已删除
courseMapper.updateById(entity); // 更新课程记录
} }
@Transactional(readOnly=false) /**
*
*
* @param uid ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void enable(String uid) { public void enable(String uid) {
CourseEntity entity = courseMapper.selectById(uid); CourseEntity entity = courseMapper.selectById(uid); // 获取要启用的课程实体
entity.setStatus(CourseStatusEnum.NORMAL);
courseMapper.updateById(entity); entity.setStatus(CourseStatusEnum.NORMAL); // 设置课程状态为正常
courseMapper.updateById(entity); // 更新课程记录
} }
@Transactional(readOnly=false) /**
*
*
* @param uid ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void disabled(String uid) { public void disabled(String uid) {
CourseEntity entity = courseMapper.selectById(uid); CourseEntity entity = courseMapper.selectById(uid); // 获取要禁用的课程实体
entity.setStatus(CourseStatusEnum.DISABLED);
courseMapper.updateById(entity); entity.setStatus(CourseStatusEnum.DISABLED); // 设置课程状态为禁用
courseMapper.updateById(entity); // 更新课程记录
} }
@SuppressWarnings("unchecked") /**
* ZTree JSON
*
* @return ZTree JSON
*/
@SuppressWarnings("unchecked") // 抑制 unchecked 警告
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public JSONArray treeData() { public JSONArray treeData() {
List<SubjectEntity> subjectList = subjectMapper.selectList(Condition.create().eq("status", SubjectStatusEnum.NORMAL.getValue())); List<SubjectEntity> subjectList = subjectMapper.selectList(Condition.create().eq("status", SubjectStatusEnum.NORMAL.getValue())); // 查询正常状态的科目列表
List<CourseEntity> courseList = courseMapper.selectList(Condition.create().eq("status", CourseStatusEnum.NORMAL.getValue())); List<CourseEntity> courseList = courseMapper.selectList(Condition.create().eq("status", CourseStatusEnum.NORMAL.getValue())); // 查询正常状态的课程列表
return transform(subjectList, courseList);
return transform(subjectList, courseList); // 转换科目和课程数据为 JSON 数组
} }
/**
* ZTree JSON
*
* @param subjectList
* @param courseList
* @return ZTree JSON
*/
private JSONArray transform(List<SubjectEntity> subjectList, List<CourseEntity> courseList) { private JSONArray transform(List<SubjectEntity> subjectList, List<CourseEntity> courseList) {
JSONArray entitys = new JSONArray(); JSONArray entitys = new JSONArray(); // 创建 JSON 数组对象
for (int i = 0; i < subjectList.size(); i++) { for (int i = 0; i < subjectList.size(); i++) {
JSONObject entity = new JSONObject(); JSONObject entity = new JSONObject(); // 创建 JSON 对象
entity.put("id", subjectList.get(i).getId());
entity.put("name", subjectList.get(i).getName()); SubjectEntity subject = subjectList.get(i); // 获取科目实体
entity.put("pId", "0"); entity.put("id", subject.getId()); // 设置科目 ID
entitys.add(entity); entity.put("name", subject.getName()); // 设置科目名称
entity.put("pId", "0"); // 设置父节点 ID 为 0
entitys.add(entity); // 将科目对象添加到 JSON 数组中
} }
for (int i = 0; i < courseList.size(); i++) { for (int i = 0; i < courseList.size(); i++) {
JSONObject entity = new JSONObject(); JSONObject entity = new JSONObject(); // 创建 JSON 对象
entity.put("id", courseList.get(i).getId());
entity.put("name", courseList.get(i).getName());
entity.put("pId", courseList.get(i).getSubjectId());
entitys.add(entity);
}
return entitys;
}
CourseEntity course = courseList.get(i); // 获取课程实体
entity.put("id", course.getId()); // 设置课程 ID
entity.put("name", course.getName()); // 设置课程名称
entity.put("pId", course.getSubjectId()); // 设置父节点 ID 为课程所属科目 ID
entitys.add(entity); // 将课程对象添加到 JSON 数组中
}
return entitys; // 返回转换后的 JSON 数组
}
} }

@ -1,129 +1,192 @@
package com.tamguo.modules.tiku.service.impl; package com.tamguo.modules.tiku.service.impl;
import java.util.List; import java.util.List; // 导入 List 接口,用于存储科目、课程和知识点实体列表
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired; // 导入 Autowired 注解,用于依赖注入
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service; // 导入 Service 注解,标识为服务层实现类
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional; // 导入 Transactional 注解,用于事务管理
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray; // 导入 JSONArray 类,用于处理 JSON 数组
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject; // 导入 JSONObject 类,用于处理 JSON 对象
import com.baomidou.mybatisplus.mapper.Condition; import com.baomidou.mybatisplus.mapper.Condition; // 导入 Condition 类,用于构建查询条件
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page; // 导入 Page 类,用于分页查询
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl; // 导入 ServiceImpl 类,作为服务层实现类的父类
import com.tamguo.modules.tiku.dao.KnowPointMapper; import com.tamguo.modules.tiku.dao.KnowPointMapper; // 导入 KnowPointMapper 接口,用于知识点的数据访问
import com.tamguo.modules.tiku.dao.CourseMapper; import com.tamguo.modules.tiku.dao.CourseMapper; // 导入 CourseMapper 接口,用于课程的数据访问
import com.tamguo.modules.tiku.dao.SubjectMapper; import com.tamguo.modules.tiku.dao.SubjectMapper; // 导入 SubjectMapper 接口,用于科目的数据访问
import com.tamguo.modules.tiku.model.KnowPointEntity; import com.tamguo.modules.tiku.model.KnowPointEntity; // 导入 KnowPointEntity 类,代表知识点实体
import com.tamguo.modules.tiku.model.CourseEntity; import com.tamguo.modules.tiku.model.CourseEntity; // 导入 CourseEntity 类,代表课程实体
import com.tamguo.modules.tiku.model.SubjectEntity; import com.tamguo.modules.tiku.model.SubjectEntity; // 导入 SubjectEntity 类,代表科目实体
import com.tamguo.modules.tiku.model.condition.BookCondition; import com.tamguo.modules.tiku.model.condition.BookCondition; // 导入 BookCondition 类,代表知识点查询条件
import com.tamguo.modules.tiku.model.enums.BookStatusEnum; import com.tamguo.modules.tiku.model.enums.BookStatusEnum; // 导入 BookStatusEnum 枚举,代表知识点状态
import com.tamguo.modules.tiku.model.enums.CourseStatusEnum; import com.tamguo.modules.tiku.model.enums.CourseStatusEnum; // 导入 CourseStatusEnum 枚举,代表课程状态
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum; import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum; // 导入 SubjectStatusEnum 枚举,代表科目状态
import com.tamguo.modules.tiku.service.IKnowPointService; import com.tamguo.modules.tiku.service.IKnowPointService; // 导入 IKnowPointService 接口,定义知识点服务的接口
@Service @Service // 标识为服务层实现类
public class KnowPointServiceImpl extends ServiceImpl<KnowPointMapper, KnowPointEntity> implements IKnowPointService { public class KnowPointServiceImpl extends ServiceImpl<KnowPointMapper, KnowPointEntity> implements IKnowPointService {
@Autowired @Autowired // 自动注入 KnowPointMapper 实例
KnowPointMapper knowPointMapper; private KnowPointMapper knowPointMapper;
@Autowired
CourseMapper courseMapper;
@Autowired
SubjectMapper subjectMapper;
@Transactional(readOnly=false) @Autowired // 自动注入 CourseMapper 实例
private CourseMapper courseMapper;
@Autowired // 自动注入 SubjectMapper 实例
private SubjectMapper subjectMapper;
/**
*
*
* @param condition
* @return
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public Page<KnowPointEntity> listData(BookCondition condition) { public Page<KnowPointEntity> listData(BookCondition condition) {
Page<KnowPointEntity> page = new Page<>(condition.getPageNo() , condition.getPageSize()); Page<KnowPointEntity> page = new Page<>(condition.getPageNo(), condition.getPageSize()); // 创建分页对象
return page.setRecords(knowPointMapper.listData(page, condition)); return page.setRecords(knowPointMapper.listData(page, condition)); // 执行查询并设置分页结果
} }
@Transactional(readOnly=false) /**
*
*
* @param book
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void save(KnowPointEntity book) { public void save(KnowPointEntity book) {
CourseEntity course = courseMapper.selectById(book.getCourseId()); CourseEntity course = courseMapper.selectById(book.getCourseId()); // 获取课程实体
book.setStatus(BookStatusEnum.NORMAL); book.setStatus(BookStatusEnum.NORMAL); // 设置知识点状态为正常
book.setSubjectId(course.getSubjectId()); book.setSubjectId(course.getSubjectId()); // 设置知识点所属科目 ID
knowPointMapper.insert(book); knowPointMapper.insert(book); // 插入知识点记录
} }
@Transactional(readOnly=false) /**
*
*
* @param book
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void update(KnowPointEntity book) { public void update(KnowPointEntity book) {
CourseEntity course = courseMapper.selectById(book.getCourseId()); CourseEntity course = courseMapper.selectById(book.getCourseId()); // 获取课程实体
KnowPointEntity entity = knowPointMapper.selectById(book.getId()); KnowPointEntity entity = knowPointMapper.selectById(book.getId()); // 获取要更新的知识点实体
entity.setName(book.getName()); entity.setName(book.getName()); // 更新知识点名称
entity.setPointNum(book.getPointNum()); entity.setPointNum(book.getPointNum()); // 更新知识点数量
entity.setQuestionNum(book.getQuestionNum()); entity.setQuestionNum(book.getQuestionNum()); // 更新问题数量
entity.setRemarks(book.getRemarks()); entity.setRemarks(book.getRemarks()); // 更新备注
entity.setPublishingHouse(book.getPublishingHouse()); entity.setPublishingHouse(book.getPublishingHouse()); // 更新出版社
entity.setSort(book.getSort()); entity.setSort(book.getSort()); // 更新排序号
entity.setCourseId(course.getId()); entity.setCourseId(course.getId()); // 更新课程 ID
knowPointMapper.updateById(entity); knowPointMapper.updateById(entity); // 更新知识点记录
} }
@Transactional(readOnly=false) /**
*
*
* @param id ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void delete(String id) { public void delete(String id) {
KnowPointEntity book = knowPointMapper.selectById(id); KnowPointEntity book = knowPointMapper.selectById(id); // 获取要删除的知识点实体
book.setStatus(BookStatusEnum.DELETE);
knowPointMapper.updateById(book); book.setStatus(BookStatusEnum.DELETE); // 设置知识点状态为已删除
knowPointMapper.updateById(book); // 更新知识点记录
} }
@Transactional(readOnly=false) /**
*
*
* @param id ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void enable(String id) { public void enable(String id) {
KnowPointEntity book = knowPointMapper.selectById(id); KnowPointEntity book = knowPointMapper.selectById(id); // 获取要启用的知识点实体
book.setStatus(BookStatusEnum.NORMAL);
knowPointMapper.updateById(book); book.setStatus(BookStatusEnum.NORMAL); // 设置知识点状态为正常
knowPointMapper.updateById(book); // 更新知识点记录
} }
@Transactional(readOnly=false) /**
*
*
* @param id ID
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@Override @Override
public void disabled(String id) { public void disabled(String id) {
KnowPointEntity book = knowPointMapper.selectById(id); KnowPointEntity book = knowPointMapper.selectById(id); // 获取要禁用的知识点实体
book.setStatus(BookStatusEnum.DISABLED);
knowPointMapper.updateById(book); book.setStatus(BookStatusEnum.DISABLED); // 设置知识点状态为禁用
knowPointMapper.updateById(book); // 更新知识点记录
} }
@Transactional(readOnly=false) /**
@SuppressWarnings("unchecked") * ZTree JSON
*
* @return ZTree JSON
*/
@Transactional(readOnly = false) // 开启事务,设置只读为 false
@SuppressWarnings("unchecked") // 抑制 unchecked 警告
@Override @Override
public JSONArray treeData() { public JSONArray treeData() {
List<SubjectEntity> subjectList = subjectMapper.selectList(Condition.create().eq("status", SubjectStatusEnum.NORMAL.getValue())); List<SubjectEntity> subjectList = subjectMapper.selectList(Condition.create().eq("status", SubjectStatusEnum.NORMAL.getValue())); // 查询正常状态的科目列表
List<CourseEntity> courseList = courseMapper.selectList(Condition.create().eq("status", CourseStatusEnum.NORMAL.getValue())); List<CourseEntity> courseList = courseMapper.selectList(Condition.create().eq("status", CourseStatusEnum.NORMAL.getValue())); // 查询正常状态的课程列表
List<KnowPointEntity> bookList = knowPointMapper.selectList(Condition.create().eq("status", BookStatusEnum.NORMAL.getValue())); List<KnowPointEntity> bookList = knowPointMapper.selectList(Condition.create().eq("status", BookStatusEnum.NORMAL.getValue())); // 查询正常状态的知识点列表
return transform(subjectList, courseList , bookList);
return transform(subjectList, courseList, bookList); // 转换科目、课程和知识点数据为 JSON 数组
} }
/**
* ZTree JSON
*
* @param subjectList
* @param courseList
* @param bookList
* @return ZTree JSON
*/
private JSONArray transform(List<SubjectEntity> subjectList, List<CourseEntity> courseList, List<KnowPointEntity> bookList) { private JSONArray transform(List<SubjectEntity> subjectList, List<CourseEntity> courseList, List<KnowPointEntity> bookList) {
JSONArray entitys = new JSONArray(); JSONArray entitys = new JSONArray(); // 创建 JSON 数组对象
for (int i = 0; i < subjectList.size(); i++) { for (int i = 0; i < subjectList.size(); i++) {
JSONObject entity = new JSONObject(); JSONObject entity = new JSONObject(); // 创建 JSON 对象
entity.put("id", subjectList.get(i).getId());
entity.put("name", subjectList.get(i).getName()); SubjectEntity subject = subjectList.get(i); // 获取科目实体
entity.put("pId", "0"); entity.put("id", subject.getId()); // 设置科目 ID
entitys.add(entity); entity.put("name", subject.getName()); // 设置科目名称
entity.put("pId", "0"); // 设置父节点 ID 为 0
entitys.add(entity); // 将科目对象添加到 JSON 数组中
} }
for (int i = 0; i < courseList.size(); i++) { for (int i = 0; i < courseList.size(); i++) {
JSONObject entity = new JSONObject(); JSONObject entity = new JSONObject(); // 创建 JSON 对象
entity.put("id", courseList.get(i).getId());
entity.put("name", courseList.get(i).getName()); CourseEntity course = courseList.get(i); // 获取课程实体
entity.put("pId", courseList.get(i).getSubjectId()); entity.put("id", course.getId()); // 设置课程 ID
entitys.add(entity); entity.put("name", course.getName()); // 设置课程名称
entity.put("pId", course.getSubjectId()); // 设置父节点 ID 为课程所属科目 ID
entitys.add(entity); // 将课程对象添加到 JSON 数组中
} }
for (int i = 0; i < bookList.size(); i++) { for (int i = 0; i < bookList.size(); i++) {
JSONObject entity = new JSONObject(); JSONObject entity = new JSONObject(); // 创建 JSON 对象
entity.put("id", bookList.get(i).getId());
entity.put("name", bookList.get(i).getName()); KnowPointEntity book = bookList.get(i); // 获取知识点实体
entity.put("pId", bookList.get(i).getCourseId()); entity.put("id", book.getId()); // 设置知识点 ID
entitys.add(entity); entity.put("name", book.getName()); // 设置知识点名称
entity.put("pId", book.getCourseId()); // 设置父节点 ID 为知识点所属课程 ID
entitys.add(entity); // 将知识点对象添加到 JSON 数组中
} }
return entitys;
return entitys; // 返回转换后的 JSON 数组
} }
} }

@ -2,6 +2,7 @@ package com.tamguo.modules.tiku.service.impl;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,14 +14,28 @@ import com.tamguo.modules.tiku.dao.MenuMapper;
import com.tamguo.modules.tiku.model.MenuEntity; import com.tamguo.modules.tiku.model.MenuEntity;
import com.tamguo.modules.tiku.service.IMenuService; import com.tamguo.modules.tiku.service.IMenuService;
/**
* MenuServiceImpl IMenuService
*/
@Service @Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> implements IMenuService { public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> implements IMenuService {
/**
* MenuMapper
*/
@Autowired @Autowired
private MenuMapper menuMapper; private MenuMapper menuMapper;
/**
*
*/
@Autowired @Autowired
private CacheService cacheService; private CacheService cacheService;
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<MenuEntity> findMenus() { public List<MenuEntity> findMenus() {
@ -36,6 +51,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
return menuList; return menuList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<MenuEntity> findAllMenus() { public List<MenuEntity> findAllMenus() {
@ -51,6 +70,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
return allMenuList; return allMenuList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<MenuEntity> findLeftMenus() { public List<MenuEntity> findLeftMenus() {
@ -66,7 +89,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
return leftMenuList; return leftMenuList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<MenuEntity> findChapterMenus() { public List<MenuEntity> findChapterMenus() {
@ -82,7 +108,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
return chapterMenuList; return chapterMenuList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<MenuEntity> findFooterMenus() { public List<MenuEntity> findFooterMenus() {
@ -98,15 +127,23 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
return footerMenuList; return footerMenuList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<MenuEntity> getMenuTree() { public List<MenuEntity> getMenuTree() {
return menuMapper.selectList(Condition.EMPTY); return menuMapper.selectList(Condition.EMPTY);
} }
/**
* ID
* @param uid ID
* @return
*/
@Override @Override
public MenuEntity findById(String uid) { public MenuEntity findById(String uid) {
return menuMapper.selectById(uid); return menuMapper.selectById(uid);
} }
} }

@ -27,24 +27,58 @@ import com.tamguo.modules.tiku.service.ICourseService;
import com.tamguo.modules.tiku.service.IPaperService; import com.tamguo.modules.tiku.service.IPaperService;
import com.tamguo.modules.tiku.service.ISubjectService; import com.tamguo.modules.tiku.service.ISubjectService;
/**
* PaperServiceImpl IPaperService
*/
@Service @Service
public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> implements IPaperService { public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> implements IPaperService {
/**
* ISubjectService
*/
@Autowired @Autowired
private ISubjectService iSubjectService; private ISubjectService iSubjectService;
/**
* ICourseService
*/
@Autowired @Autowired
private ICourseService iCourseService; private ICourseService iCourseService;
/**
* ISysAreaService
*/
@Autowired @Autowired
private ISysAreaService iSysAreaService; private ISysAreaService iSysAreaService;
/**
* PaperMapper
*/
@Autowired @Autowired
private PaperMapper paperMapper; private PaperMapper paperMapper;
/**
* CacheService
*/
@Autowired @Autowired
private CacheService cacheService; private CacheService cacheService;
/**
* QuestionMapper
*/
@Autowired @Autowired
private QuestionMapper questionMapper; private QuestionMapper questionMapper;
/**
* QuestionOptionsMapper
*/
@Autowired @Autowired
private QuestionOptionsMapper questionOptionsMapper; private QuestionOptionsMapper questionOptionsMapper;
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<PaperEntity> findHistoryPaper() { public List<PaperEntity> findHistoryPaper() {
@ -63,6 +97,10 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return paperList; return paperList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<PaperEntity> findSimulationPaper() { public List<PaperEntity> findSimulationPaper() {
@ -81,6 +119,11 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return paperList; return paperList;
} }
/**
*
* @param areaId ID
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<PaperEntity> findHotPaper(String areaId) { public List<PaperEntity> findHotPaper(String areaId) {
@ -99,6 +142,13 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return paperList; return paperList;
} }
/**
*
* @param paperId ID
* @param title
* @param name
* @param type
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void addPaperQuestionInfo(String paperId, String title, String name, String type) { public void addPaperQuestionInfo(String paperId, String title, String name, String type) {
@ -117,6 +167,14 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
paperMapper.updateById(paper); paperMapper.updateById(paper);
} }
/**
*
* @param paperId ID
* @param title
* @param name
* @param type
* @param uid ID
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void updatePaperQuestionInfo(String paperId, String title, String name, String type, String uid) { public void updatePaperQuestionInfo(String paperId, String title, String name, String type, String uid) {
@ -135,9 +193,15 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
paperMapper.updateById(paper); paperMapper.updateById(paper);
} }
/**
*
* @param currMemberId ID
* @param paperId ID
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Result deletePaper(String currMemberId , String paperId) { public Result deletePaper(String CurrMemberId, String paperId) {
PaperEntity paper = paperMapper.selectById(paperId); PaperEntity paper = paperMapper.selectById(paperId);
if (!currMemberId.equals(paper.getCreaterId())) { if (!currMemberId.equals(paper.getCreaterId())) {
return Result.result(501, null, "不能删除其他人的试卷!"); return Result.result(501, null, "不能删除其他人的试卷!");
@ -148,9 +212,16 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return Result.result(Result.SUCCESS_CODE, null, "删除成功!"); return Result.result(Result.SUCCESS_CODE, null, "删除成功!");
} }
/**
*
* @param CurrMemberId ID
* @param paperId ID
* @param cuid ID
* @return
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public Result deletePaperQuestionInfoBtn(String currMemberId , String paperId, String cuid) { public Result deletePaperQuestionInfoBtn(String CurrMemberId, String paperId, String cuid) {
PaperEntity paper = paperMapper.selectById(paperId); PaperEntity paper = paperMapper.selectById(paperId);
if (!paper.getCreaterId().equals(currMemberId)) { if (!paper.getCreaterId().equals(currMemberId)) {
return Result.failResult("试卷属于当前用户,不能修改!"); return Result.failResult("试卷属于当前用户,不能修改!");
@ -167,6 +238,10 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return Result.result(Result.SUCCESS_CODE, null, "删除子卷成功"); return Result.result(Result.SUCCESS_CODE, null, "删除子卷成功");
} }
/**
*
* @param paper
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void addPaper(PaperEntity paper) { public void addPaper(PaperEntity paper) {
@ -181,8 +256,14 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
paperMapper.insert(paper); paperMapper.insert(paper);
} }
/**
*
* @param paper
* @param currMemberId ID
* @return
*/
@Override @Override
public Result updatePaper(PaperEntity paper ,String currMemberId) { public Result updatePaper(PaperEntity paper, String CurrMemberId) {
PaperEntity entity = paperMapper.selectById(paper.getId()); PaperEntity entity = paperMapper.selectById(paper.getId());
if (!entity.getCreaterId().equals(currMemberId)) { if (!entity.getCreaterId().equals(currMemberId)) {
return Result.failResult("试卷属于当前用户,不能修改!"); return Result.failResult("试卷属于当前用户,不能修改!");
@ -192,6 +273,11 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
return Result.result(Result.SUCCESS_CODE, paper, "修改成功"); return Result.result(Result.SUCCESS_CODE, paper, "修改成功");
} }
/**
*
* @param paperId ID
* @return
*/
@Override @Override
public List<QuestionEntity> findQuestionList(String paperId) { public List<QuestionEntity> findQuestionList(String paperId) {
// 查询选项信息 // 查询选项信息
@ -202,5 +288,4 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperEntity> impl
}); });
return questionList; return questionList;
} }
} }

@ -15,66 +15,135 @@ import com.tamguo.modules.tiku.model.PaperEntity;
import com.tamguo.modules.tiku.model.QuestionEntity; import com.tamguo.modules.tiku.model.QuestionEntity;
import com.tamguo.modules.tiku.service.IQuestionService; import com.tamguo.modules.tiku.service.IQuestionService;
// 标识这是一个Spring的服务层组件类用于实现IQuestionService接口中定义的与题目Question相关的业务逻辑方法
// 它继承自ServicePlus框架提供的ServiceImpl类借助其提供的通用数据库操作能力结合自身的业务逻辑实现对题目数据的添加、查询、更新和删除等操作并且通过依赖注入获取相关的Mapper对象来与数据库进行交互。
@Service @Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, QuestionEntity> implements IQuestionService { public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, QuestionEntity> implements IQuestionService {
// 自动注入PaperMapper用于操作试卷Paper相关的数据比如通过试卷ID查询试卷信息等操作在题目相关业务逻辑中可能需要获取试卷的创建者等信息来进行权限判断等操作依赖该Mapper与数据库的试卷表进行交互。
@Autowired @Autowired
private PaperMapper paperMapper; private PaperMapper paperMapper;
// 自动注入QuestionMapper用于操作题目Question相关的数据比如插入题目、根据条件查询题目、更新题目以及删除题目等数据库操作是实现题目业务逻辑中与数据库进行交互的核心依赖对象直接对应数据库中的题目表。
@Autowired @Autowired
private QuestionMapper questionMapper; private QuestionMapper questionMapper;
/**
*
* ID
* ID
*
* @param question ID
* @param currMemberId IDID
* @return Result0501
*/
@Override @Override
public Result addQuestion(QuestionEntity question, String currMemberId) { public Result addQuestion(QuestionEntity question, String currMemberId) {
// 根据题目实体对象中携带的试卷ID通过PaperMapper从数据库中查询对应的试卷实体信息用于后续判断当前用户对该试卷是否有操作权限即是否为试卷创建者
PaperEntity paper = paperMapper.selectById(question.getPaperId().toString()); PaperEntity paper = paperMapper.selectById(question.getPaperId().toString());
// 判断当前登录会员的ID与查询到的试卷创建者的ID是否相等如果不相等表示当前用户无权操作该试卷下的题目返回包含相应错误提示信息和状态码501的Result对象给调用者。
if (!currMemberId.equals(paper.getCreaterId())) { if (!currMemberId.equals(paper.getCreaterId())) {
return Result.result(501, null, "改试卷不属于您!"); return Result.result(501, null, "改试卷不属于您!");
} }
// 如果当前用户有权限添加题目将从试卷实体对象中获取的课程ID设置到题目实体对象中保证题目与试卷在课程维度上的关联关系正确便于后续按课程等维度进行题目相关的查询、统计等业务操作。
question.setCourseId(paper.getCourseId()); question.setCourseId(paper.getCourseId());
// 通过QuestionMapper将题目实体对象插入到数据库的题目表中完成题目添加的数据库操作若插入成功则数据库中会新增一条对应的题目记录。
questionMapper.insert(question); questionMapper.insert(question);
// 返回包含添加成功提示信息和状态码0表示成功的Result对象给调用者告知题目添加操作已成功完成。
return Result.result(0, null, "添加成功!"); return Result.result(0, null, "添加成功!");
} }
/**
*
* IDIDID
* IDID
* MyBatis Plus
*
* @param questionType
* @param id IDIDID便ID
* @param content LIKE
* @param paperId IDIDIDID
* @param currMemberId IDID访
* @param p 便
* @return Page<QuestionEntity>p.setRecords(null)
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Page<QuestionEntity> queryQuestionList(String questionType, String id, String content, String paperId, String currMemberId, public Page<QuestionEntity> queryQuestionList(String questionType, String id, String content, String paperId, String currMemberId,
Page<QuestionEntity> p) { Page<QuestionEntity> p) {
// 根据传入的试卷ID从数据库中查询对应的试卷实体信息然后判断当前登录会员的ID与查询到的试卷创建者的ID是否相等如果不相等表示当前用户无权查询该试卷下的题目直接返回传入的分页对象并将其记录列表设置为空表示无权获取题目数据。
if (!currMemberId.equals(paperMapper.selectById(paperId).getCreaterId())) { if (!currMemberId.equals(paperMapper.selectById(paperId).getCreaterId())) {
return p.setRecords(null); return p.setRecords(null);
} }
// 创建一个MyBatis Plus的查询条件对象用于构建后续查询题目时的各种条件通过该对象可以方便地添加等于、大于、小于、模糊匹配等各种条件来精确筛选题目数据符合MyBatis Plus的条件查询规范。
Condition condition = new Condition(); Condition condition = new Condition();
// 判断题目类型是否不为空字符串如果不为空则添加一个等于eq条件到查询条件对象中使得查询时只会获取指定题目类型的题目与数据库题目表中的题目类型字段进行精确匹配查询。
if (!StringUtils.isEmpty(questionType)) { if (!StringUtils.isEmpty(questionType)) {
condition.eq("question_type", questionType); condition.eq("question_type", questionType);
} }
// 判断题目ID是否不为空字符串如果不为空则添加一个等于eq条件到查询条件对象中使得查询时只会获取指定ID的题目与数据库题目表中的题目ID字段进行精确匹配查询用于精确查找特定题目。
if (!StringUtils.isEmpty(id)) { if (!StringUtils.isEmpty(id)) {
condition.eq("id", id); condition.eq("id", id);
} }
// 判断题目内容是否不为空字符串如果不为空则添加一个模糊匹配like条件到查询条件对象中使得查询时会获取题目内容包含指定关键字的题目通过数据库的模糊查询LIKE操作符与题目表中的题目内容字段进行匹配查询用于根据部分内容查找相关题目。
if (!StringUtils.isEmpty(content)) { if (!StringUtils.isEmpty(content)) {
condition.like("content", content); condition.like("content", content);
} }
// 添加一个等于eq条件到查询条件对象中指定要查询的题目所属的试卷ID与数据库题目表中的所属试卷ID字段进行精确匹配查询确保获取的题目都是属于指定试卷的。
condition.eq("paper_id", paperId); condition.eq("paper_id", paperId);
// 通过QuestionMapper结合分页对象和构建好的查询条件对象进行分页查询从数据库中获取符合条件的题目列表数据并将查询结果设置到传入的分页对象的记录列表中最后返回该分页对象供前端进行分页展示等操作。
return p.setRecords(questionMapper.selectPage(p, condition)); return p.setRecords(questionMapper.selectPage(p, condition));
} }
/**
*
* ID
* QuestionMapperID
* 使
*
* @param question ID
* @param currMemberId IDID
* @return Result0501
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public Result updateQuestion(QuestionEntity question, String currMemberId) { public Result updateQuestion(QuestionEntity question, String currMemberId) {
// 根据题目实体对象中携带的试卷ID通过PaperMapper从数据库中查询对应的试卷实体信息用于后续判断当前用户对该试卷是否有操作权限即是否为试卷创建者
PaperEntity paper = paperMapper.selectById(question.getPaperId().toString()); PaperEntity paper = paperMapper.selectById(question.getPaperId().toString());
// 判断当前登录会员的ID与查询到的试卷创建者的ID是否相等如果不相等表示当前用户无权操作该试卷下的题目返回包含相应错误提示信息和状态码501的Result对象给调用者。
if (!currMemberId.equals(paper.getCreaterId())) { if (!currMemberId.equals(paper.getCreaterId())) {
return Result.result(501, null, "改试卷不属于您!"); return Result.result(501, null, "改试卷不属于您!");
} }
// 如果当前用户有权限更新题目通过QuestionMapper根据题目实体对象的ID更新数据库中对应的题目记录将传入的题目实体对象中的属性值覆盖原有记录中的相应属性值完成题目信息的更新操作。
questionMapper.updateById(question); questionMapper.updateById(question);
// 返回包含更新成功提示信息和状态码0表示成功的Result对象给调用者告知题目更新操作已成功完成。
return Result.result(0, null, "修改成功!"); return Result.result(0, null, "修改成功!");
} }
/**
*
* IDID
* QuestionMapperID
* 使
*
* @param uid IDID
* @param currMemberId IDID
* @return Result0501
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public Result delete(String uid, String currMemberId) { public Result delete(String uid, String currMemberId) {
// 根据传入的题目ID通过QuestionMapper从数据库中查询对应的题目实体信息用于获取该题目所属试卷的ID以便后续判断当前用户对该试卷是否有操作权限即是否为试卷创建者
QuestionEntity question = questionMapper.selectById(uid); QuestionEntity question = questionMapper.selectById(uid);
// 根据题目所属试卷的ID通过PaperMapper从数据库中查询对应的试卷实体信息用于后续判断当前用户对该试卷是否有操作权限即是否为试卷创建者
PaperEntity paper = paperMapper.selectById(question.getPaperId().toString()); PaperEntity paper = paperMapper.selectById(question.getPaperId().toString());
// 判断当前登录会员的ID与查询到的试卷创建者的ID是否相等如果不相等表示当前用户无权操作该试卷下的题目返回包含相应错误提示信息和状态码501的Result对象给调用者。
if (!currMemberId.equals(paper.getCreaterId())) { if (!currMemberId.equals(paper.getCreaterId())) {
return Result.result(501, null, "改试卷不属于您!"); return Result.result(501, null, "改试卷不属于您!");
} }
// 如果当前用户有权限删除题目通过QuestionMapper根据题目ID删除数据库中对应的题目记录完成题目删除的数据库操作从数据库表中移除该题目对应的行数据。
questionMapper.deleteById(uid); questionMapper.deleteById(uid);
// 返回包含删除成功提示信息和状态码0表示成功的Result对象给调用者告知题目删除操作已成功完成。
return Result.result(0, null, "删除成功!"); return Result.result(0, null, "删除成功!");
} }

@ -19,16 +19,35 @@ import com.tamguo.modules.tiku.model.PaperEntity;
import com.tamguo.modules.tiku.model.SchoolEntity; import com.tamguo.modules.tiku.model.SchoolEntity;
import com.tamguo.modules.tiku.service.ISchoolService; import com.tamguo.modules.tiku.service.ISchoolService;
/**
* SchoolServiceImpl ISchoolService
*/
@Service @Service
public class SchoolService extends ServiceImpl<SchoolMapper, SchoolEntity> implements ISchoolService { public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, SchoolEntity> implements ISchoolService {
/**
* SchoolMapper
*/
@Autowired @Autowired
private SchoolMapper schoolMapper; private SchoolMapper schoolMapper;
/**
* PaperMapper
*/
@Autowired @Autowired
private PaperMapper paperMapper; private PaperMapper paperMapper;
/**
* CacheService
*/
@Autowired @Autowired
private CacheService cacheService; private CacheService cacheService;
/**
*
* @param shcoolId ID
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<SchoolEntity> findEliteSchoolPaper(String shcoolId) { public List<SchoolEntity> findEliteSchoolPaper(String shcoolId) {
@ -47,6 +66,10 @@ public class SchoolService extends ServiceImpl<SchoolMapper, SchoolEntity> imple
return schoolList; return schoolList;
} }
/**
*
* @return
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<SchoolEntity> findEliteSchool() { public List<SchoolEntity> findEliteSchool() {
@ -59,11 +82,15 @@ public class SchoolService extends ServiceImpl<SchoolMapper, SchoolEntity> imple
return schoolList; return schoolList;
} }
/**
* ID
* @param areaId ID
* @return
*/
@Transactional(readOnly = true) @Transactional(readOnly = true)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<SchoolEntity> findSchoolByAreaId(String areaId) { public List<SchoolEntity> findSchoolByAreaId(String areaId) {
return schoolMapper.selectList(Condition.create().in("area_id", Arrays.asList(areaId.split(",")))); return schoolMapper.selectList(Condition.create().in("area_id", Arrays.asList(areaId.split(","))));
} }
} }

@ -19,14 +19,29 @@ import com.tamguo.modules.tiku.model.condition.SubjectCondition;
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum; import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum;
import com.tamguo.modules.tiku.service.ISubjectService; import com.tamguo.modules.tiku.service.ISubjectService;
/**
* SubjectServiceImpl ISubjectService
*/
@Service @Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity> implements ISubjectService { public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity> implements ISubjectService {
/**
* SubjectMapper
*/
@Autowired @Autowired
private SubjectMapper subjectMapper; private SubjectMapper subjectMapper;
/**
* CourseMapper
*/
@Autowired @Autowired
private CourseMapper courseMapper; private CourseMapper courseMapper;
/**
*
* @param condition
* @return
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@ -44,6 +59,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
return page.setRecords(subjectMapper.selectPage(page, query)); return page.setRecords(subjectMapper.selectPage(page, query));
} }
/**
*
* @param subject
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void save(SubjectEntity subject) { public void save(SubjectEntity subject) {
@ -51,6 +70,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
subjectMapper.insert(subject); subjectMapper.insert(subject);
} }
/**
*
* @param subject
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void update(SubjectEntity subject) { public void update(SubjectEntity subject) {
@ -64,6 +87,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
subjectMapper.updateById(entity); subjectMapper.updateById(entity);
} }
/**
*
* @param uid
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void enable(String uid) { public void enable(String uid) {
@ -72,6 +99,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
subjectMapper.updateById(entity); subjectMapper.updateById(entity);
} }
/**
*
* @param uid
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void disabled(String uid) { public void disabled(String uid) {
@ -80,6 +111,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
subjectMapper.updateById(entity); subjectMapper.updateById(entity);
} }
/**
*
* @param uid
*/
@Transactional(readOnly = false) @Transactional(readOnly = false)
@Override @Override
public void delete(String uid) { public void delete(String uid) {
@ -88,6 +123,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
subjectMapper.updateById(entity); subjectMapper.updateById(entity);
} }
/**
*
* @return JSON
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public JSONArray getCourseCascaderTree() { public JSONArray getCourseCascaderTree() {
@ -115,6 +154,10 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
return courseTree; return courseTree;
} }
/**
*
* @return JSON
*/
@Transactional(readOnly = true) @Transactional(readOnly = true)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@ -130,5 +173,4 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity
} }
return courseTree; return courseTree;
} }
} }
Loading…
Cancel
Save