commit
8375311bc4
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="17 (2)" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,28 +1,27 @@
|
|||||||
package com.tamguo.web;
|
package com.tamguo.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest; // 导入 HttpServletRequest 类
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse; // 导入 HttpServletResponse 类
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession; // 导入 HttpSession 类
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller; // 表示这是一个控制器类
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping; // 用于处理请求映射
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod; // 用于指定请求方法
|
||||||
|
|
||||||
import com.tamguo.utils.ShiroUtils;
|
import com.tamguo.utils.ShiroUtils; // 导入 ShiroUtils 类
|
||||||
|
|
||||||
@Controller
|
@Controller // 声明这是一个控制器
|
||||||
public class LogoutController {
|
public class LogoutController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注销
|
* 注销方法
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "logout.html", method = RequestMethod.GET)
|
@RequestMapping(value = "logout.html", method = RequestMethod.GET) // 映射到 "logout.html" 且使用 GET 方法的请求
|
||||||
public String logout(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
public String logout(HttpServletRequest request, HttpServletResponse response, HttpSession session) { // 接收请求、响应和会话对象
|
||||||
if (session.getAttribute("currMember") != null) {
|
if (session.getAttribute("currMember")!= null) { // 如果会话中当前成员不为空
|
||||||
session.removeAttribute("currMember");
|
session.removeAttribute("currMember"); // 从会话中移除当前成员属性
|
||||||
ShiroUtils.logout();
|
ShiroUtils.logout(); // 执行 ShiroUtils 的注销操作
|
||||||
}
|
}
|
||||||
return "redirect:/";
|
return "redirect:/"; // 重定向到根路径
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,81 +1,95 @@
|
|||||||
package com.tamguo.web;
|
package com.tamguo.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession; // 导入 HttpSession 类
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired; // 表示自动注入
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller; // 声明这是一个控制器类
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping; // 处理请求映射
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod; // 指定请求方法
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody; // 用于返回响应体
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView; // 模型和视图类
|
||||||
|
|
||||||
import com.tamguo.common.utils.Result;
|
import com.tamguo.common.utils.Result; // 通用结果类
|
||||||
import com.tamguo.common.utils.SystemConstant;
|
import com.tamguo.common.utils.SystemConstant; // 系统常量类
|
||||||
import com.tamguo.modules.member.service.IMemberService;
|
import com.tamguo.modules.member.service.IMemberService; // 会员服务接口
|
||||||
|
|
||||||
@Controller
|
@Controller // 控制器注解
|
||||||
public class PasswordController {
|
public class PasswordController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired // 自动注入会员服务
|
||||||
private IMemberService iMemberService;
|
private IMemberService iMemberService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认账号页面的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/find.html", method = RequestMethod.GET)
|
@RequestMapping(value = "password/find.html", method = RequestMethod.GET)
|
||||||
public ModelAndView confirmAccount(ModelAndView model){
|
public ModelAndView confirmAccount(ModelAndView model) { // 处理方法,接收模型和视图对象
|
||||||
model.setViewName("password/confirmAccount");
|
model.setViewName("password/confirmAccount"); // 设置视图名称
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交确认账号的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST)
|
@RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST)
|
||||||
public ModelAndView submitConfirmAccount(String username , String veritycode , ModelAndView model , HttpSession session){
|
public ModelAndView submitConfirmAccount(String username, String veritycode, ModelAndView model, HttpSession session) { // 处理方法,接收参数、模型和视图对象、会话对象
|
||||||
Result result = iMemberService.confirmAccount(username, veritycode);
|
Result result = iMemberService.confirmAccount(username, veritycode); // 调用会员服务的确认账号方法
|
||||||
String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString();
|
String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString(); // 获取验证码
|
||||||
if (!veritycode.equalsIgnoreCase(kaptcha)) {
|
if (!veritycode.equalsIgnoreCase(kaptcha)) { // 比较验证码是否正确
|
||||||
result = Result.result(202, null, "验证码错误");
|
result = Result.result(202, null, "验证码错误"); // 设置错误结果
|
||||||
}
|
}
|
||||||
if(result.getCode() == 200){
|
if (result.getCode() == 200) { // 如果结果码为 200
|
||||||
model.setViewName("password/securityCheck");
|
model.setViewName("password/securityCheck"); // 设置视图名称
|
||||||
model.addObject("result", result);
|
model.addObject("result", result); // 添加结果到模型
|
||||||
model.addObject("isEmail", username.contains("@") ? "1" : "0");
|
model.addObject("isEmail", username.contains("@")? "1" : "0"); // 添加是否为邮箱的标识到模型
|
||||||
} else {
|
} else {
|
||||||
model.setViewName("password/confirmAccount");
|
model.setViewName("password/confirmAccount"); // 设置视图名称
|
||||||
model.addObject("account", username);
|
model.addObject("account", username); // 添加账号到模型
|
||||||
model.addObject("username",username);
|
model.addObject("username", username); // 添加用户名到模型
|
||||||
model.addObject("veritycode", veritycode);
|
model.addObject("veritycode", veritycode); // 添加验证码到模型
|
||||||
model.addObject("code", result.getCode());
|
model.addObject("code", result.getCode()); // 添加结果码到模型
|
||||||
}
|
}
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全检查页面的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/securityCheck.html", method = RequestMethod.POST)
|
@RequestMapping(value = "password/securityCheck.html", method = RequestMethod.POST)
|
||||||
public ModelAndView securityCheck(String username , String isEmail , String mobileVcode , ModelAndView model){
|
public ModelAndView securityCheck(String username, String isEmail, String mobileVcode, ModelAndView model) { // 处理方法,接收参数、模型和视图对象
|
||||||
Result result = iMemberService.securityCheck(username , isEmail , mobileVcode);
|
Result result = iMemberService.securityCheck(username, isEmail, mobileVcode); // 调用会员服务的安全检查方法
|
||||||
if(result.getCode() == 200){
|
if (result.getCode() == 200) { // 如果结果码为 200
|
||||||
model.addObject("username", username);
|
model.addObject("username", username); // 添加用户名到模型
|
||||||
model.addObject("resetPasswordKey" , result.getResult());
|
model.addObject("resetPasswordKey", result.getResult()); // 添加重置密码键到模型
|
||||||
model.setViewName("password/resetPassword");
|
model.setViewName("password/resetPassword"); // 设置视图名称
|
||||||
} else {
|
} else {
|
||||||
model.addObject("result", result);
|
model.addObject("result", result); // 添加结果到模型
|
||||||
model.addObject("isEmail", isEmail);
|
model.addObject("isEmail", isEmail); // 添加是否为邮箱的标识到模型
|
||||||
model.addObject("codeError", "1");
|
model.addObject("codeError", "1"); // 添加错误标识到模型
|
||||||
model.setViewName("password/securityCheck");
|
model.setViewName("password/securityCheck"); // 设置视图名称
|
||||||
}
|
}
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码页面的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/resetPassword.html", method = RequestMethod.POST)
|
@RequestMapping(value = "password/resetPassword.html", method = RequestMethod.POST)
|
||||||
public ModelAndView resetPassword(String resetPasswordKey , String username , String password , String verifypwd , ModelAndView model){
|
public ModelAndView resetPassword(String resetPasswordKey, String username, String password, String verifypwd, ModelAndView model) { // 处理方法,接收参数、模型和视图对象
|
||||||
Result result = iMemberService.resetPassword(resetPasswordKey , username , password , verifypwd);
|
Result result = iMemberService.resetPassword(resetPasswordKey, username, password, verifypwd); // 调用会员服务的重置密码方法
|
||||||
if(result.getCode() == 200){
|
if (result.getCode() == 200) { // 如果结果码为 200
|
||||||
model.setViewName("password/resetPwSuccess");
|
model.setViewName("password/resetPwSuccess"); // 设置视图名称
|
||||||
} else {
|
} else {
|
||||||
model.setViewName("password/resetPassword");
|
model.setViewName("password/resetPassword"); // 设置视图名称
|
||||||
}
|
}
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查账号的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/checkAccount.html", method = RequestMethod.GET)
|
@RequestMapping(value = "password/checkAccount.html", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody // 返回响应体
|
||||||
public Result checkAccount(String account){
|
public Result checkAccount(String account) { // 处理方法,接收账号参数
|
||||||
return iMemberService.checkAccount(account);
|
return iMemberService.checkAccount(account); // 调用会员服务的检查账号方法并返回结果
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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,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 数组
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue