feat: 🎸 讨论表代码+接口、作业接口、消息接口、课程章节接口

This commit is contained in:
GoCo 2025-09-19 10:06:17 +08:00
parent 93a5b7e3b2
commit e0aa844162
28 changed files with 1899 additions and 10 deletions

View File

@ -39,6 +39,8 @@ public final class EntityLinkConst {
public static final String REPO = "repo"; public static final String REPO = "repo";
// 班级 // 班级
public static final String CLASS = "class"; public static final String CLASS = "class";
// 讨论
public static final String DISCUSSION = "discussion";
} }
/** 资源类型 0:视频,1:图片,2:文档 */ /** 资源类型 0:视频,1:图片,2:文档 */

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.aiol.controller; package org.jeecg.modules.aiol.controller;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -93,7 +94,19 @@ public class AiolCommentController extends JeecgController<AiolComment, IAiolCom
@Operation(summary = "评论-添加") @Operation(summary = "评论-添加")
@RequiresPermissions("aiol:aiol_comment:add") @RequiresPermissions("aiol:aiol_comment:add")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<String> add(@RequestBody AiolComment aiolComment) { public Result<String> add(@RequestBody AiolComment aiolComment, HttpServletRequest request) {
// 1. 获取当前登录用户信息
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
String username = JwtUtil.getUsername(token);
LoginUser sysUser = sysBaseApi.getUserByName(username);
if (sysUser == null) {
return Result.error("用户未登录或登录已过期");
}
aiolComment.setUserId(sysUser.getId()); // 用户ID
aiolComment.setLikeCount(0);
aiolCommentService.save(aiolComment); aiolCommentService.save(aiolComment);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
@ -153,6 +166,7 @@ public class AiolCommentController extends JeecgController<AiolComment, IAiolCom
// @AutoLog(value = "评论-通过id查询") // @AutoLog(value = "评论-通过id查询")
@Operation(summary = "评论-通过id查询") @Operation(summary = "评论-通过id查询")
@GetMapping(value = "/queryById") @GetMapping(value = "/queryById")
@IgnoreAuth
public Result<AiolComment> queryById(@RequestParam(name = "id", required = true) String id) { public Result<AiolComment> queryById(@RequestParam(name = "id", required = true) String id) {
AiolComment aiolComment = aiolCommentService.getById(id); AiolComment aiolComment = aiolCommentService.getById(id);
if (aiolComment == null) { if (aiolComment == null) {
@ -187,11 +201,49 @@ public class AiolCommentController extends JeecgController<AiolComment, IAiolCom
} }
@GetMapping("/course/{courseId}/list") @GetMapping("/course/{courseId}/list")
@Operation(summary = "查询课程评论列表", description = "根据课程ID查询课程评论列表包含用户信息") @Operation(summary = "查询课程评论列表", description = "根据课程ID查询课程评论列表包含用户信息和所有子评论支持多层嵌套所有子评论都放在顶级评论的replies中")
@IgnoreAuth @IgnoreAuth
public Result<List<CommentWithUserInfo>> queryCourseCommentList(@PathVariable("courseId") String courseId) { public Result<List<CommentWithUserInfo>> queryCourseCommentList(@PathVariable("courseId") String courseId) {
List<CommentWithUserInfo> list = aiolCommentService.getCommentList("course", courseId); try {
return Result.OK(list); // 1. 查询课程的一级评论target_type=course, target_id=courseId
List<CommentWithUserInfo> parentComments = aiolCommentService.getCommentList("course", courseId);
// 2. 为每个一级评论查询其所有子评论递归查询所有层级
for (CommentWithUserInfo parentComment : parentComments) {
List<CommentWithUserInfo> allReplies = getAllRepliesRecursively(parentComment.getId());
parentComment.setReplies(allReplies);
}
log.info("查询课程评论列表成功: courseId={}, 一级评论数量={}", courseId, parentComments.size());
return Result.OK(parentComments);
} catch (Exception e) {
log.error("查询课程评论列表失败: courseId={}, error={}", courseId, e.getMessage(), e);
return Result.error("查询课程评论列表失败: " + e.getMessage());
}
}
/**
* 递归查询评论的所有子评论
* @param commentId 评论ID
* @return 所有子评论列表
*/
private List<CommentWithUserInfo> getAllRepliesRecursively(String commentId) {
List<CommentWithUserInfo> allReplies = new ArrayList<>();
// 查询直接子评论target_type=comment, target_id=commentId
List<CommentWithUserInfo> directReplies = aiolCommentService.getCommentList("comment", commentId);
for (CommentWithUserInfo reply : directReplies) {
// 将当前回复添加到总列表中
allReplies.add(reply);
// 递归查询当前回复的子评论
List<CommentWithUserInfo> subReplies = getAllRepliesRecursively(reply.getId());
allReplies.addAll(subReplies);
}
return allReplies;
} }
// @GetMapping("/activity/{activityId}/list") // @GetMapping("/activity/{activityId}/list")
@ -243,11 +295,9 @@ public class AiolCommentController extends JeecgController<AiolComment, IAiolCom
} }
// 2. 设置评论基本信息 // 2. 设置评论基本信息
aiolComment.setTargetType("course"); // 默认设置为course aiolComment.setTargetType("course");
aiolComment.setTargetId(courseId); // 设置课程ID aiolComment.setTargetId(courseId); // 课程ID
aiolComment.setUserId(sysUser.getId()); // 设置用户ID aiolComment.setUserId(sysUser.getId()); // 用户ID
aiolComment.setCreateBy(sysUser.getId()); // 设置创建人
aiolComment.setCreateTime(new Date()); // 设置创建时间
// 3. 保存评论 // 3. 保存评论
aiolCommentService.save(aiolComment); aiolCommentService.save(aiolComment);
@ -262,4 +312,34 @@ public class AiolCommentController extends JeecgController<AiolComment, IAiolCom
return Result.error("评论添加失败: " + e.getMessage()); return Result.error("评论添加失败: " + e.getMessage());
} }
} }
@AutoLog(value = "评论-点赞")
@Operation(summary = "点赞评论", description = "为指定评论点赞增加like_count字段值")
@GetMapping(value = "/like/{commentId}")
@IgnoreAuth
public Result<String> likeComment(@PathVariable("commentId") String commentId) {
try {
// 1. 查询评论是否存在
AiolComment comment = aiolCommentService.getById(commentId);
if (comment == null) {
return Result.error("评论不存在");
}
// 2. 更新点赞数
Integer currentLikeCount = comment.getLikeCount() != null ? comment.getLikeCount() : 0;
comment.setLikeCount(currentLikeCount + 1);
boolean updated = aiolCommentService.updateById(comment);
if (!updated) {
return Result.error("点赞失败");
}
log.info("评论点赞成功: commentId={}, 当前点赞数={}", commentId, comment.getLikeCount());
return Result.OK("点赞成功!");
} catch (Exception e) {
log.error("评论点赞失败: commentId={}, error={}", commentId, e.getMessage(), e);
return Result.error("点赞失败: " + e.getMessage());
}
}
} }

View File

@ -0,0 +1,205 @@
package org.jeecg.modules.aiol.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.aiol.entity.AiolDiscussion;
import org.jeecg.modules.aiol.service.IAiolDiscussionService;
import org.jeecg.modules.aiol.service.IAiolEntityLinkService;
import org.jeecg.modules.aiol.constant.EntityLinkConst;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 讨论
* @Author: jeecg-boot
* @Date: 2025-09-19
* @Version: V1.0
*/
@Tag(name="讨论")
@RestController
@RequestMapping("/aiol/aiolDiscussion")
@Slf4j
public class AiolDiscussionController extends JeecgController<AiolDiscussion, IAiolDiscussionService> {
@Autowired
private IAiolDiscussionService aiolDiscussionService;
@Autowired
private IAiolEntityLinkService aiolEntityLinkService;
/**
* 分页列表查询
*
* @param aiolDiscussion
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "讨论-分页列表查询")
@Operation(summary="讨论-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<AiolDiscussion>> queryPageList(AiolDiscussion aiolDiscussion,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<AiolDiscussion> queryWrapper = QueryGenerator.initQueryWrapper(aiolDiscussion, req.getParameterMap());
Page<AiolDiscussion> page = new Page<AiolDiscussion>(pageNo, pageSize);
IPage<AiolDiscussion> pageList = aiolDiscussionService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param aiolDiscussion
* @param sectionId 可选的章节ID如果传入则创建与章节的关联关系
* @return
*/
@AutoLog(value = "讨论-添加")
@Operation(summary="讨论-添加", description="添加讨论,可选择关联到指定章节")
@RequiresPermissions("aiol:aiol_discussion:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody AiolDiscussion aiolDiscussion,
@RequestParam(value = "sectionId", required = false) String sectionId) {
try {
// 保存讨论记录
aiolDiscussionService.save(aiolDiscussion);
// 如果传入了sectionId创建与章节的关联关系
if (sectionId != null && !sectionId.trim().isEmpty()) {
aiolEntityLinkService.save(
EntityLinkConst.SourceType.COURSE_SECTION,
sectionId.trim(),
EntityLinkConst.TargetType.DISCUSSION,
aiolDiscussion.getId()
);
log.info("讨论 {} 成功关联到章节 {}", aiolDiscussion.getId(), sectionId);
}
return Result.OK("添加成功!");
} catch (Exception e) {
log.error("添加讨论失败: {}", e.getMessage(), e);
return Result.error("添加讨论失败: " + e.getMessage());
}
}
/**
* 编辑
*
* @param aiolDiscussion
* @return
*/
@AutoLog(value = "讨论-编辑")
@Operation(summary="讨论-编辑")
@RequiresPermissions("aiol:aiol_discussion:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody AiolDiscussion aiolDiscussion) {
aiolDiscussionService.updateById(aiolDiscussion);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "讨论-通过id删除")
@Operation(summary="讨论-通过id删除")
@RequiresPermissions("aiol:aiol_discussion:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
aiolDiscussionService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "讨论-批量删除")
@Operation(summary="讨论-批量删除")
@RequiresPermissions("aiol:aiol_discussion:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.aiolDiscussionService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "讨论-通过id查询")
@Operation(summary="讨论-通过id查询")
@GetMapping(value = "/queryById")
public Result<AiolDiscussion> queryById(@RequestParam(name="id",required=true) String id) {
AiolDiscussion aiolDiscussion = aiolDiscussionService.getById(id);
if(aiolDiscussion==null) {
return Result.error("未找到对应数据");
}
return Result.OK(aiolDiscussion);
}
/**
* 导出excel
*
* @param request
* @param aiolDiscussion
*/
@RequiresPermissions("aiol:aiol_discussion:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, AiolDiscussion aiolDiscussion) {
return super.exportXls(request, aiolDiscussion, AiolDiscussion.class, "讨论");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("aiol:aiol_discussion:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, AiolDiscussion.class);
}
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.aiol.controller; package org.jeecg.modules.aiol.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -15,10 +16,17 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum; import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.aiol.dto.AiolHomeworkSaveDTO;
import org.jeecg.modules.aiol.dto.StudentSubmitHomework; import org.jeecg.modules.aiol.dto.StudentSubmitHomework;
import org.jeecg.modules.aiol.entity.AiolHomework; import org.jeecg.modules.aiol.entity.AiolHomework;
import org.jeecg.modules.aiol.entity.AiolHomeworkSubmit; import org.jeecg.modules.aiol.entity.AiolHomeworkSubmit;
import org.jeecg.modules.aiol.service.IAiolHomeworkService; import org.jeecg.modules.aiol.service.IAiolHomeworkService;
import org.jeecg.modules.aiol.service.IAiolEntityLinkService;
import org.jeecg.modules.aiol.constant.EntityLinkConst;
import org.jeecg.modules.aiol.mapper.AiolClassStudentMapper;
import org.jeecg.modules.aiol.mapper.AiolCourseSignupMapper;
import org.jeecg.modules.aiol.entity.AiolClassStudent;
import org.jeecg.modules.aiol.entity.AiolCourseSignup;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -32,6 +40,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -187,6 +196,15 @@ public class AiolHomeworkController extends JeecgController<AiolHomework, IAiolH
@Autowired @Autowired
private IAiolHomeworkSubmitService homeworkSubmitService; private IAiolHomeworkSubmitService homeworkSubmitService;
@Autowired
private IAiolEntityLinkService entityLinkBizService;
@Autowired
private AiolClassStudentMapper aiolClassStudentMapper;
@Autowired
private AiolCourseSignupMapper aiolCourseSignupMapper;
@GetMapping("/course/{courseId}") @GetMapping("/course/{courseId}")
@Operation(summary = "查询课程作业") @Operation(summary = "查询课程作业")
public Result<List<AiolHomework>> list(@PathVariable String courseId) { public Result<List<AiolHomework>> list(@PathVariable String courseId) {
@ -211,4 +229,117 @@ public class AiolHomeworkController extends JeecgController<AiolHomework, IAiolH
@RequestParam String comment, @RequestParam String teacherId) { @RequestParam String comment, @RequestParam String teacherId) {
return Result.OK(homeworkSubmitService.correct(homeworkSubmitId, score, comment, teacherId)); return Result.OK(homeworkSubmitService.correct(homeworkSubmitId, score, comment, teacherId));
} }
@AutoLog(value = "作业-教师删除")
@Operation(summary = "作业-教师删除", description = "教师删除作业,同时删除相关的作业提交记录")
@RequiresPermissions("aiol:aiol_homework:delete")
@DeleteMapping(value = "/teacher_delete")
public Result<String> teacherDelete(@RequestParam(name = "id", required = true) String homeworkId) {
try {
// 1. 删除作业提交记录
QueryWrapper<AiolHomeworkSubmit> submitWrapper = new QueryWrapper<>();
submitWrapper.eq("homework_id", homeworkId);
List<AiolHomeworkSubmit> submitList = homeworkSubmitService.list(submitWrapper);
if (!submitList.isEmpty()) {
List<String> submitIds = submitList.stream()
.map(AiolHomeworkSubmit::getId)
.collect(Collectors.toList());
homeworkSubmitService.removeByIds(submitIds);
log.info("删除作业提交记录成功: homeworkId={}, 删除数量={}", homeworkId, submitIds.size());
}
// 2. 删除作业记录
boolean deleted = aiolHomeworkService.removeById(homeworkId);
if (!deleted) {
return Result.error("删除作业失败,作业不存在");
}
log.info("教师删除作业成功: homeworkId={}", homeworkId);
return Result.OK("删除成功!");
} catch (Exception e) {
log.error("教师删除作业失败: homeworkId={}, error={}", homeworkId, e.getMessage(), e);
return Result.error("删除作业失败: " + e.getMessage());
}
}
@AutoLog(value = "作业-教师添加")
@Operation(summary = "作业-教师添加", description = "教师添加作业,支持指定班级、课程和章节,自动为学生创建作业提交记录")
@RequiresPermissions("aiol:aiol_homework:add")
@PostMapping(value = "/teacher_add")
public Result<String> teacherAdd(@RequestBody AiolHomeworkSaveDTO homeworkSaveDTO) {
try {
// 1. 保存作业记录
AiolHomework aiolHomework = new AiolHomework();
// 复制DTO中的作业字段到实体
BeanUtils.copyProperties(homeworkSaveDTO, aiolHomework);
aiolHomeworkService.save(aiolHomework);
String homeworkId = aiolHomework.getId();
String classId = homeworkSaveDTO.getClassId();
String courseId = homeworkSaveDTO.getCourseId();
String sectionId = homeworkSaveDTO.getSectionId();
// 2. 为学生创建作业提交记录
List<String> studentIds = new ArrayList<>();
if (classId != null && !classId.trim().isEmpty()) {
// 如果传递了班级ID查询指定班级的学生
String[] classIds = classId.split(",");
for (String singleClassId : classIds) {
if (singleClassId != null && !singleClassId.trim().isEmpty()) {
singleClassId = singleClassId.trim();
QueryWrapper<AiolClassStudent> classStudentWrapper = new QueryWrapper<>();
classStudentWrapper.eq("class_id", singleClassId);
List<AiolClassStudent> classStudents = aiolClassStudentMapper.selectList(classStudentWrapper);
for (AiolClassStudent classStudent : classStudents) {
String studentId = classStudent.getStudentId();
if (!studentIds.contains(studentId)) {
studentIds.add(studentId);
}
}
}
}
} else if (courseId != null && !courseId.trim().isEmpty()) {
// 如果没有传递班级ID查询课程下的所有学生
QueryWrapper<AiolCourseSignup> courseSignupWrapper = new QueryWrapper<>();
courseSignupWrapper.eq("course_id", courseId);
List<AiolCourseSignup> courseSignups = aiolCourseSignupMapper.selectList(courseSignupWrapper);
for (AiolCourseSignup courseSignup : courseSignups) {
String studentId = courseSignup.getUserId();
if (!studentIds.contains(studentId)) {
studentIds.add(studentId);
}
}
}
// 为每个学生创建空的作业提交记录
for (String studentId : studentIds) {
homeworkSubmitService.createEmptySubmit(homeworkId, studentId);
}
// 3. 如果传递了章节ID创建章节与作业的关联关系
if (sectionId != null && !sectionId.trim().isEmpty()) {
entityLinkBizService.save(
EntityLinkConst.SourceType.COURSE_SECTION,
sectionId.trim(),
EntityLinkConst.TargetType.HOMEWORK,
homeworkId
);
log.info("作业 {} 成功关联到章节 {}", homeworkId, sectionId);
}
log.info("教师添加作业成功: homeworkId={}, courseId={}, classId={}, sectionId={}, 学生数量={}",
homeworkId, courseId, classId, sectionId, studentIds.size());
return Result.OK("添加成功!");
} catch (Exception e) {
log.error("教师添加作业失败: homeworkSaveDTO={}, error={}", homeworkSaveDTO, e.getMessage(), e);
return Result.error("添加作业失败: " + e.getMessage());
}
}
} }

View File

@ -14,10 +14,17 @@ import org.jeecg.common.system.vo.LoginUser;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.system.model.AnnouncementSendModel; import org.jeecg.modules.system.model.AnnouncementSendModel;
import org.jeecg.modules.system.service.ISysAnnouncementSendService; import org.jeecg.modules.system.service.ISysAnnouncementSendService;
import org.jeecg.modules.system.entity.SysAnnouncementSend;
import org.jeecg.modules.system.entity.SysAnnouncement;
import org.jeecg.modules.system.service.ISysAnnouncementService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/aiol/message") @RequestMapping("/aiol/message")
@ -28,6 +35,9 @@ public class AiolMessageController {
@Autowired @Autowired
private ISysAnnouncementSendService sysAnnouncementSendService; private ISysAnnouncementSendService sysAnnouncementSendService;
@Autowired
private ISysAnnouncementService sysAnnouncementService;
@GetMapping("/test") @GetMapping("/test")
public void test() { public void test() {
// //推送消息 // //推送消息
@ -113,4 +123,96 @@ public class AiolMessageController {
return Result.error("查询点赞消息失败: " + e.getMessage()); return Result.error("查询点赞消息失败: " + e.getMessage());
} }
} }
@GetMapping("/system")
public Result<IPage<AnnouncementSendModel>> querySystemMessages(
AnnouncementSendModel model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
try {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
model.setUserId(userId);
model.setPageNo((pageNo - 1) * pageSize);
model.setPageSize(pageSize);
// 处理时间范围与SysAnnouncementSendController一致
if (StringUtils.isNotEmpty(model.getSendTimeBegin())) {
model.setSendTimeBegin(model.getSendTimeBegin() + " 00:00:00");
}
if (StringUtils.isNotEmpty(model.getSendTimeEnd())) {
model.setSendTimeEnd(model.getSendTimeEnd() + " 23:59:59");
}
// 系统消息 消息类别 = 2
model.setMsgCategory("2");
Page<AnnouncementSendModel> page = new Page<>(pageNo, pageSize);
IPage<AnnouncementSendModel> pageList = sysAnnouncementSendService.getMyAnnouncementSendPage(page, model);
return Result.OK(pageList);
} catch (Exception e) {
return Result.error("查询系统消息失败: " + e.getMessage());
}
}
@GetMapping("/unread_count")
public Result<Map<String, Object>> queryUnreadMessageCount() {
try {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
Map<String, Object> result = new HashMap<>();
// 1. 先查询用户所有未读消息的annt_id
QueryWrapper<SysAnnouncementSend> unreadWrapper = new QueryWrapper<>();
unreadWrapper.eq("user_id", userId)
.eq("read_flag", 0);
List<SysAnnouncementSend> unreadMessages = sysAnnouncementSendService.list(unreadWrapper);
if (unreadMessages.isEmpty()) {
// 如果没有未读消息返回0
result.put("commentsUnreadCount", 0);
result.put("likesUnreadCount", 0);
result.put("systemUnreadCount", 0);
result.put("totalUnreadCount", 0);
return Result.OK(result);
}
// 2. 提取所有annt_id
List<String> anntIds = unreadMessages.stream()
.map(SysAnnouncementSend::getAnntId)
.collect(java.util.stream.Collectors.toList());
// 3. 根据annt_id查询对应的消息详情获取msg_category
QueryWrapper<SysAnnouncement> announcementWrapper = new QueryWrapper<>();
announcementWrapper.in("id", anntIds);
List<SysAnnouncement> announcements = sysAnnouncementService.list(announcementWrapper);
// 4. 按msg_category分类统计
long commentsUnreadCount = 0; // msg_category=3
long likesUnreadCount = 0; // msg_category=4
long systemUnreadCount = 0; // msg_category=2
for (SysAnnouncement announcement : announcements) {
String msgCategory = announcement.getMsgCategory();
if ("3".equals(msgCategory)) {
commentsUnreadCount++;
} else if ("4".equals(msgCategory)) {
likesUnreadCount++;
} else if ("2".equals(msgCategory)) {
systemUnreadCount++;
}
}
// 5. 计算总未读数量
long totalUnreadCount = commentsUnreadCount + likesUnreadCount + systemUnreadCount;
result.put("commentsUnreadCount", commentsUnreadCount);
result.put("likesUnreadCount", likesUnreadCount);
result.put("systemUnreadCount", systemUnreadCount);
result.put("totalUnreadCount", totalUnreadCount);
return Result.OK(result);
} catch (Exception e) {
return Result.error("查询未读消息数量失败: " + e.getMessage());
}
}
} }

View File

@ -368,6 +368,74 @@ public class AiolResourceController extends JeecgController<AiolResource, IAiolR
} }
} }
@PostMapping("/image_upload")
@Operation(summary = "课程图片文件上传", description = "上传图片文件并关联到课程支持jpg、jpeg、png、gif、bmp、webp等格式")
public Result<String> uploadImage(
@RequestParam("file") MultipartFile file,
@RequestParam("courseId") String courseId,
@RequestParam("name") String name,
@RequestParam(value = "description", required = false) String description,
HttpServletRequest request) throws Exception {
if (file == null || file.isEmpty()) {
return Result.error("没有找到上传的文件");
}
if (courseId == null || courseId.trim().isEmpty()) {
return Result.error("课程ID不能为空");
}
if (name == null || name.trim().isEmpty()) {
return Result.error("图片名称不能为空");
}
// 检查文件类型
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || !isValidImageType(originalFilename)) {
return Result.error("不支持的文件类型仅支持jpg、jpeg、png、gif、bmp、webp等格式");
}
try {
// 1. 上传图片文件
String fileUrl = uploadImageFile(file, request);
// 2. 获取文件大小
Integer fileSize = (int) file.getSize();
// 3. 创建资源记录
AiolResource resource = new AiolResource();
resource.setName(name.trim());
resource.setDescription(description != null ? description.trim() : "");
resource.setType(ResourceTypeConst.IMAGE); // 1:图片
resource.setFileUrl(fileUrl);
resource.setFileSize(fileSize);
// 4. 保存资源记录
boolean saved = aiolResourceService.save(resource);
if (!saved) {
return Result.error("保存资源记录失败");
}
// 5. 创建课程与资源的关联关系
entityLinkBizService.save(
EntityLinkConst.SourceType.COURSE,
courseId,
EntityLinkConst.TargetType.RESOURCE,
resource.getId()
);
log.info("图片上传成功: resourceId={}, courseId={}, name={}",
resource.getId(), courseId, name);
return Result.OK(resource.getId());
} catch (Exception e) {
log.error("图片上传失败: courseId={}, name={}, error={}",
courseId, name, e.getMessage(), e);
return Result.error("图片上传失败: " + e.getMessage());
}
}
@GetMapping("/course_materials") @GetMapping("/course_materials")
@Operation(summary = "查询课程课件", description = "根据课程ID、资源分类和资源名关键词查询课程相关资源") @Operation(summary = "查询课程课件", description = "根据课程ID、资源分类和资源名关键词查询课程相关资源")
@IgnoreAuth @IgnoreAuth
@ -430,6 +498,20 @@ public class AiolResourceController extends JeecgController<AiolResource, IAiolR
lowerFilename.endsWith(".md") || lowerFilename.endsWith(".markdown"); // Markdown lowerFilename.endsWith(".md") || lowerFilename.endsWith(".markdown"); // Markdown
} }
/**
* 检查是否为有效的图片类型
*/
private boolean isValidImageType(String filename) {
if (filename == null) return false;
String lowerFilename = filename.toLowerCase();
return lowerFilename.endsWith(".jpg") || lowerFilename.endsWith(".jpeg") || // JPEG
lowerFilename.endsWith(".png") || // PNG
lowerFilename.endsWith(".gif") || // GIF
lowerFilename.endsWith(".bmp") || // BMP
lowerFilename.endsWith(".webp"); // WebP
}
/** /**
* 上传文档文件 * 上传文档文件
*/ */
@ -465,4 +547,40 @@ public class AiolResourceController extends JeecgController<AiolResource, IAiolR
return fileUrl; return fileUrl;
} }
} }
/**
* 上传图片文件
*/
private String uploadImageFile(MultipartFile file, HttpServletRequest request) throws Exception {
// 读取上传类型
String configUploadType = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("jeecg.uploadType", "minio");
String uploadType = configUploadType;
// 生成文件路径
String uuid = UUID.randomUUID().toString();
String originalFilename = file.getOriginalFilename();
String fileExtension = originalFilename.substring(originalFilename.lastIndexOf("."));
String fileName = uuid + fileExtension;
String relativePath = "image/" + fileName;
try (InputStream inputStream = file.getInputStream()) {
String fileUrl = "";
if ("minio".equals(uploadType)) {
fileUrl = MinioUtil.upload(inputStream, relativePath);
} else if ("alioss".equals(uploadType)) {
OssBootUtil.upload(inputStream, relativePath);
fileUrl = relativePath; // 可在网关拼域名
} else {
// 本地存储
String uploadpath = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("jeecg.path.upload");
Path target = Path.of(uploadpath, relativePath);
Files.createDirectories(target.getParent());
Files.copy(inputStream, target, StandardCopyOption.REPLACE_EXISTING);
fileUrl = relativePath;
}
log.info("图片文件上传成功: originalFilename={}, fileUrl={}", originalFilename, fileUrl);
return fileUrl;
}
}
} }

View File

@ -0,0 +1,23 @@
package org.jeecg.modules.aiol.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.jeecg.modules.aiol.entity.AiolHomework;
/**
* 作业保存DTO
* 继承AiolHomework实体增加班级ID课程ID章节ID字段
*/
@Data
@Schema(description = "作业保存DTO")
public class AiolHomeworkSaveDTO extends AiolHomework {
@Schema(description = "班级ID多个用逗号分割")
private String classId;
@Schema(description = "课程ID")
private String courseId;
@Schema(description = "章节ID")
private String sectionId;
}

View File

@ -5,6 +5,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.jeecg.modules.aiol.entity.AiolComment; import org.jeecg.modules.aiol.entity.AiolComment;
import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Schema(description = "评论信息(包含用户信息)") @Schema(description = "评论信息(包含用户信息)")
@ -17,4 +19,7 @@ public class CommentWithUserInfo extends AiolComment {
@Schema(description = "用户标签") @Schema(description = "用户标签")
private String userTag; private String userTag;
@Schema(description = "子评论列表")
private List<CommentWithUserInfo> replies;
} }

View File

@ -0,0 +1,64 @@
package org.jeecg.modules.aiol.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 讨论
* @Author: jeecg-boot
* @Date: 2025-09-19
* @Version: V1.0
*/
@Data
@TableName("aiol_discussion")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description="讨论")
public class AiolDiscussion implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private java.lang.String id;
/**讨论标题*/
@Excel(name = "讨论标题", width = 15)
@Schema(description = "讨论标题")
private java.lang.String title;
/**讨论描述*/
@Excel(name = "讨论描述", width = 15)
@Schema(description = "讨论描述")
private java.lang.String description;
/**创建人*/
@Schema(description = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private java.util.Date createTime;
/**更新人*/
@Schema(description = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private java.util.Date updateTime;
}

View File

@ -22,7 +22,7 @@ import lombok.experimental.Accessors;
/** /**
* @Description: 作业 * @Description: 作业
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2025-08-31 * @Date: 2025-09-19
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@ -74,6 +74,20 @@ public class AiolHomework implements Serializable {
@Dict(dicCode = "course_status") @Dict(dicCode = "course_status")
@Schema(description = "状态") @Schema(description = "状态")
private java.lang.Integer status; private java.lang.Integer status;
/**是否允许补交*/
@Excel(name = "是否允许补交", width = 15)
@Schema(description = "是否允许补交")
private java.lang.Integer allowMakeup;
/**补交截止时间*/
@Excel(name = "补交截止时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "补交截止时间")
private java.util.Date makeupTime;
/**作业通知时间*/
@Excel(name = "作业通知时间", width = 15)
@Schema(description = "作业通知时间")
private java.lang.Integer notifyTime;
/**创建人*/ /**创建人*/
@Schema(description = "创建人") @Schema(description = "创建人")
private java.lang.String createBy; private java.lang.String createBy;

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.aiol.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.aiol.entity.AiolDiscussion;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 讨论
* @Author: jeecg-boot
* @Date: 2025-09-19
* @Version: V1.0
*/
public interface AiolDiscussionMapper extends BaseMapper<AiolDiscussion> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.aiol.mapper.AiolDiscussionMapper">
</mapper>

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.aiol.service;
import org.jeecg.modules.aiol.entity.AiolDiscussion;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 讨论
* @Author: jeecg-boot
* @Date: 2025-09-19
* @Version: V1.0
*/
public interface IAiolDiscussionService extends IService<AiolDiscussion> {
}

View File

@ -19,4 +19,9 @@ public interface IAiolHomeworkSubmitService extends IService<AiolHomeworkSubmit>
List<AiolHomeworkSubmit> submitted(String studentId); List<AiolHomeworkSubmit> submitted(String studentId);
Integer correct(String homeworkSubmitId, Integer score, String comment, String teacherId); Integer correct(String homeworkSubmitId, Integer score, String comment, String teacherId);
/**
* 新增作业时创建预留空记录用于查询作业列表
*/
boolean createEmptySubmit(String homeworkId, String studentId);
} }

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.aiol.service.impl;
import org.jeecg.modules.aiol.entity.AiolDiscussion;
import org.jeecg.modules.aiol.mapper.AiolDiscussionMapper;
import org.jeecg.modules.aiol.service.IAiolDiscussionService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 讨论
* @Author: jeecg-boot
* @Date: 2025-09-19
* @Version: V1.0
*/
@Service
public class AiolDiscussionServiceImpl extends ServiceImpl<AiolDiscussionMapper, AiolDiscussion> implements IAiolDiscussionService {
}

View File

@ -83,4 +83,14 @@ public class AiolHomeworkSubmitServiceImpl extends ServiceImpl<AiolHomeworkSubmi
} }
return homeworkSubmitMapper.updateById(homeworkSubmit); return homeworkSubmitMapper.updateById(homeworkSubmit);
} }
@Override
public boolean createEmptySubmit(String homeworkId, String studentId) {
AiolHomeworkSubmit homeworkSubmit = new AiolHomeworkSubmit();
homeworkSubmit.setHomeworkId(homeworkId);
homeworkSubmit.setStudentId(studentId);
homeworkSubmit.setScore(0);
homeworkSubmit.setStatus(0);
return homeworkSubmitMapper.insert(homeworkSubmit) > 0;
}
} }

View File

@ -0,0 +1,89 @@
<template>
<view>
<!--标题和返回-->
<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
<block slot="backText">返回</block>
<block slot="content">讨论</block>
</cu-custom>
<!--表单区域-->
<view>
<form>
<view class="cu-form-group">
<view class="flex align-center">
<view class="title"><text space="ensp">讨论标题</text></view>
<input placeholder="请输入讨论标题" v-model="model.title"/>
</view>
</view>
<view class="cu-form-group">
<view class="flex align-center">
<view class="title"><text space="ensp">讨论描述</text></view>
<input placeholder="请输入讨论描述" v-model="model.description"/>
</view>
</view>
<view class="padding">
<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
</button>
</view>
</form>
</view>
</view>
</template>
<script>
import myDate from '@/components/my-componets/my-date.vue'
export default {
name: "AiolDiscussionForm",
components:{ myDate },
props:{
formData:{
type:Object,
default:()=>{},
required:false
}
},
data(){
return {
CustomBar: this.CustomBar,
NavBarColor: this.NavBarColor,
loading:false,
model: {},
backRouteName:'index',
url: {
queryById: "/aiol/aiolDiscussion/queryById",
add: "/aiol/aiolDiscussion/add",
edit: "/aiol/aiolDiscussion/edit",
},
}
},
created(){
this.initFormData();
},
methods:{
initFormData(){
if(this.formData){
let dataId = this.formData.dataId;
this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
if(res.data.success){
console.log("表单数据",res);
this.model = res.data.result;
}
})
}
},
onSubmit() {
let myForm = {...this.model};
this.loading = true;
let url = myForm.id?this.url.edit:this.url.add;
this.$http.post(url,myForm).then(res=>{
console.log("res",res)
this.loading = false
this.$Router.push({name:this.backRouteName})
}).catch(()=>{
this.loading = false
});
}
}
}
</script>

View File

@ -0,0 +1,44 @@
<template>
<view>
<!--标题和返回-->
<cu-custom :bgColor="NavBarColor" isBack>
<block slot="backText">返回</block>
<block slot="content">讨论</block>
</cu-custom>
<!--滚动加载列表-->
<mescroll-body ref="mescrollRef" bottom="88" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback">
<view class="cu-list menu">
<view class="cu-item" v-for="(item,index) in list" :key="index" @click="goHome">
<view class="flex" style="width:100%">
<text class="text-lg" style="color: #000;">
{{ item.createBy}}
</text>
</view>
</view>
</view>
</mescroll-body>
</view>
</template>
<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import Mixin from "@/common/mixin/Mixin.js";
export default {
name: '讨论',
mixins: [MescrollMixin,Mixin],
data() {
return {
CustomBar:this.CustomBar,
NavBarColor:this.NavBarColor,
url: "/aiol/aiolDiscussion/list",
};
},
methods: {
goHome(){
this.$Router.push({name: "index"})
}
}
}
</script>

View File

@ -0,0 +1,14 @@
import { render } from '@/common/renderUtils';
//
export const columns = [
{
title: '讨论标题',
align:"center",
dataIndex: 'title'
},
{
title: '讨论描述',
align:"center",
dataIndex: 'description'
},
];

View File

@ -0,0 +1,222 @@
<route lang="json5" type="page">
{
layout: 'default',
style: {
navigationStyle: 'custom',
navigationBarTitleText: '讨论',
},
}
</route>
<template>
<PageLayout :navTitle="navTitle" :backRouteName="backRouteName">
<scroll-view class="scrollArea" scroll-y>
<view class="form-container">
<wd-form ref="form" :model="myFormData">
<wd-cell-group border>
<view class="{ 'mt-14px': 0 == 0 }">
<wd-input
label-width="100px"
v-model="myFormData['title']"
:label="get4Label('讨论标题')"
name='title'
prop='title'
placeholder="请选择讨论标题"
:rules="[
]"
clearable
/>
</view>
<view class="{ 'mt-14px': 1 == 0 }">
<wd-input
label-width="100px"
v-model="myFormData['description']"
:label="get4Label('讨论描述')"
name='description'
prop='description'
placeholder="请选择讨论描述"
:rules="[
]"
clearable
/>
</view>
</wd-cell-group>
</wd-form>
</view>
</scroll-view>
<view class="footer">
<wd-button :disabled="loading" block :loading="loading" @click="handleSubmit">提交</wd-button>
</view>
</PageLayout>
</template>
<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { http } from '@/utils/http'
import { useToast } from 'wot-design-uni'
import { useRouter } from '@/plugin/uni-mini-router'
import { ref, onMounted, computed,reactive } from 'vue'
import OnlineImage from '@/components/online/view/online-image.vue'
import OnlineFile from '@/components/online/view/online-file.vue'
import OnlineFileCustom from '@/components/online/view/online-file-custom.vue'
import OnlineSelect from '@/components/online/view/online-select.vue'
import OnlineTime from '@/components/online/view/online-time.vue'
import OnlineDate from '@/components/online/view/online-date.vue'
import OnlineRadio from '@/components/online/view/online-radio.vue'
import OnlineCheckbox from '@/components/online/view/online-checkbox.vue'
import OnlineMulti from '@/components/online/view/online-multi.vue'
import OnlinePopupLinkRecord from '@/components/online/view/online-popup-link-record.vue'
import OnlinePca from '@/components/online/view/online-pca.vue'
import SelectDept from '@/components/SelectDept/SelectDept.vue'
import SelectUser from '@/components/SelectUser/SelectUser.vue'
import {duplicateCheck} from "@/service/api";
defineOptions({
name: 'AiolDiscussionForm',
options: {
styleIsolation: 'shared',
},
})
const toast = useToast()
const router = useRouter()
const form = ref(null)
//
const myFormData = reactive({})
const loading = ref(false)
const navTitle = ref('新增')
const dataId = ref('')
const backRouteName = ref('AiolDiscussionList')
// initForm
const initForm = (item) => {
console.log('initForm item', item)
if(item?.dataId){
dataId.value = item.dataId;
navTitle.value = item.dataId?'编辑':'新增';
initData();
}
}
//
const initData = () => {
http.get("/aiol/aiolDiscussion/queryById",{id:dataId.value}).then((res) => {
if (res.success) {
let obj = res.result
Object.assign(myFormData, { ...obj })
}else{
toast.error(res?.message || '表单加载失败!')
}
})
}
const handleSuccess = () => {
uni.$emit('refreshList');
router.back()
}
/**
* 校验唯一
* @param values
* @returns {boolean}
*/
async function fieldCheck(values: any) {
const onlyField = [
];
for (const field of onlyField) {
if (values[field]) {
//
const res: any = await duplicateCheck({
tableName: 'aiol_discussion',
fieldName: field, // 使
fieldVal: values[field],
dataId: values.id,
});
if (!res.success) {
toast.warning(res.message);
return true; //
}
}
}
return false; //
}
//
const handleSubmit = async () => {
//
if (await fieldCheck(myFormData)) {
return
}
let url = dataId.value?'/aiol/aiolDiscussion/edit':'/aiol/aiolDiscussion/add';
form.value
.validate()
.then(({ valid, errors }) => {
if (valid) {
loading.value = true;
http.post(url,myFormData).then((res) => {
loading.value = false;
if (res.success) {
toast.success('保存成功');
handleSuccess()
}else{
toast.error(res?.message || '表单保存失败!')
}
})
}
})
.catch((error) => {
console.log(error, 'error')
loading.value = false;
})
}
//
const get4Label = computed(() => {
return (label) => {
return label && label.length > 4 ? label.substring(0, 4) : label;
}
})
//
const getFormSchema = computed(() => {
return (dictTable,dictCode,dictText) => {
return {
dictCode,
dictTable,
dictText
};
}
})
/**
* 获取日期控件的扩展类型
* @param picker
* @returns {string}
*/
const getDateExtendType = (picker: string) => {
let mapField = {
month: 'year-month',
year: 'year',
quarter: 'quarter',
week: 'week',
day: 'date',
}
return picker && mapField[picker]
? mapField[picker]
: 'date'
}
//pop
const setFieldsValue = (data) => {
Object.assign(myFormData, {...data })
}
// onLoad
onLoad((option) => {
initForm(option)
})
</script>
<style lang="scss" scoped>
.footer {
width: 100%;
padding: 10px 20px;
padding-bottom: calc(constant(safe-area-inset-bottom) + 10px);
padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
}
:deep(.wd-cell__label) {
font-size: 14px;
color: #444;
}
:deep(.wd-cell__value) {
text-align: left;
}
</style>

View File

@ -0,0 +1,148 @@
<route lang="json5" type="page">
{
layout: 'default',
style: {
navigationBarTitleText: '讨论',
navigationStyle: 'custom',
},
}
</route>
<template>
<PageLayout navTitle="讨论" backRouteName="index" routeMethod="pushTab">
<view class="wrap">
<z-paging
ref="paging"
:fixed="false"
v-model="dataList"
@query="queryList"
:default-page-size="15"
>
<template v-for="item in dataList" :key="item.id">
<wd-swipe-action>
<view class="list" @click="handleEdit(item)">
<template v-for="(cItem, cIndex) in columns" :key="cIndex">
<view v-if="cIndex < 3" class="box" :style="getBoxStyle">
<view class="field ellipsis">{{ cItem.title }}</view>
<view class="value cu-text-grey">{{ item[cItem.dataIndex] }}</view>
</view>
</template>
</view>
<template #right>
<view class="action">
<view class="button" @click="handleAction('del', item)">删除</view>
</view>
</template>
</wd-swipe-action>
</template>
</z-paging>
<view class="add u-iconfont u-icon-add" @click="handleAdd"></view>
</view>
</PageLayout>
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { http } from '@/utils/http'
import usePageList from '@/hooks/usePageList'
import {columns} from './AiolDiscussionData';
defineOptions({
name: 'AiolDiscussionList',
options: {
styleIsolation: 'shared',
}
})
//
let { toast, router, paging, dataList, queryList } = usePageList('/aiol/aiolDiscussion/list');
//
const getBoxStyle = computed(() => {
return { width: "calc(33% - 5px)" }
})
//
const handleAction = (val, item) => {
if (val == 'del') {
http.delete("/aiol/aiolDiscussion/delete?id="+item.id,{id:item.id}).then((res) => {
toast.success('删除成功~')
paging.value.reload()
})
}
}
// go
const handleAdd = () => {
router.push({
name: 'AiolDiscussionForm'
})
}
//go
const handleEdit = (record) => {
router.push({
name: 'AiolDiscussionForm',
params: {dataId: record.id},
})
}
onMounted(() => {
//
uni.$on('refreshList', () => {
queryList(1,10)
})
})
</script>
<style lang="scss" scoped>
.wrap {
height: 100%;
}
:deep(.wd-swipe-action) {
margin-top: 10px;
background-color: #fff;
}
.list {
padding: 10px 10px;
width: 100%;
text-align: left;
display: flex;
justify-content: space-between;
.box {
width: 33%;
.field {
margin-bottom: 10px;
line-height: 20px;
}
}
}
.action {
width: 60px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.button {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: 100%;
color: #fff;
&:first-child {
background-color: #fa4350;
}
}
}
.add {
height: 70upx;
width: 70upx;
text-align: center;
line-height: 70upx;
background-color: #fff;
border-radius: 50%;
position: fixed;
bottom: 80upx;
right: 30upx;
box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1);
color: #666;
}
</style>

View File

@ -0,0 +1,64 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/aiol/aiolDiscussion/list',
save='/aiol/aiolDiscussion/add',
edit='/aiol/aiolDiscussion/edit',
deleteOne = '/aiol/aiolDiscussion/delete',
deleteBatch = '/aiol/aiolDiscussion/deleteBatch',
importExcel = '/aiol/aiolDiscussion/importExcel',
exportXls = '/aiol/aiolDiscussion/exportXls',
}
/**
* 导出api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* 导入api
*/
export const getImportUrl = Api.importExcel;
/**
* 列表接口
* @param params
*/
export const list = (params) =>
defHttp.get({url: Api.list, params});
/**
* 删除单个
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
* 批量删除
* @param params
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
* 保存或者更新
* @param params
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}

View File

@ -0,0 +1,56 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//
export const columns: BasicColumn[] = [
{
title: '讨论标题',
align:"center",
dataIndex: 'title'
},
{
title: '讨论描述',
align:"center",
dataIndex: 'description'
},
];
//
export const searchFormSchema: FormSchema[] = [
];
//
export const formSchema: FormSchema[] = [
{
label: '讨论标题',
field: 'title',
component: 'Input',
},
{
label: '讨论描述',
field: 'description',
component: 'Input',
},
// TODO ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
];
//
export const superQuerySchema = {
title: {title: '讨论标题',order: 0,view: 'text', type: 'string',},
description: {title: '讨论描述',order: 1,view: 'text', type: 'string',},
};
/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// formSchema
return formSchema;
}

View File

@ -0,0 +1,206 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'aiol:aiol_discussion:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" v-auth="'aiol:aiol_discussion:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" v-auth="'aiol:aiol_discussion:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'aiol:aiol_discussion:deleteBatch'">批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
<!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }">
</template>
</BasicTable>
<!-- 表单区域 -->
<AiolDiscussionModal @register="registerModal" @success="handleSuccess"></AiolDiscussionModal>
</div>
</template>
<script lang="ts" name="aiol-aiolDiscussion" setup>
import {ref, reactive, computed, unref} from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table';
import {useModal} from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'
import AiolDiscussionModal from './components/AiolDiscussionModal.vue'
import {columns, searchFormSchema, superQuerySchema} from './AiolDiscussion.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './AiolDiscussion.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
//
const fieldPickers = reactive({
});
const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore();
const { createMessage } = useMessage();
//model
const [registerModal, {openModal}] = useModal();
//table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
title: '讨论',
api: list,
columns,
canResize:true,
formConfig: {
//labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter:true,
showAdvancedButton:true,
fieldMapToNumber: [
],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
if (params && fieldPickers) {
for (let key in fieldPickers) {
if (params[key]) {
params[key] = getDateByPicker(params[key], fieldPickers[key]);
}
}
}
return Object.assign(params, queryParam);
},
},
exportConfig: {
name:"讨论",
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
//
const superQueryConfig = reactive(superQuerySchema);
/**
* 高级查询事件
*/
function handleSuperQuery(params) {
Object.keys(params).map((k) => {
queryParam[k] = params[k];
});
reload();
}
/**
* 新增事件
*/
function handleAdd() {
openModal(true, {
isUpdate: false,
showFooter: true,
});
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
showFooter: true,
});
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
showFooter: false,
});
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record){
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'aiol:aiol_discussion:edit'
}
]
}
/**
* 下拉操作栏
*/
function getDropDownAction(record){
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
placement: 'topLeft',
},
auth: 'aiol:aiol_discussion:delete'
}
]
}
</script>
<style lang="less" scoped>
:deep(.ant-picker),:deep(.ant-input-number){
width: 100%;
}
</style>

View File

@ -0,0 +1,26 @@
-- 注意该页面对应的前台目录为views/aiol文件夹下
-- 如果你想更改到其他目录请修改sql中component字段对应的值
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external)
VALUES ('2025091908381460460', NULL, '讨论', '/aiol/aiolDiscussionList', 'aiol/AiolDiscussionList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0);
-- 权限控制sql
-- 新增
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025091908381460461', '2025091908381460460', '添加讨论', NULL, NULL, 0, NULL, NULL, 2, 'aiol:aiol_discussion:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0, 0, '1', 0);
-- 编辑
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025091908381460462', '2025091908381460460', '编辑讨论', NULL, NULL, 0, NULL, NULL, 2, 'aiol:aiol_discussion:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0, 0, '1', 0);
-- 删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025091908381460463', '2025091908381460460', '删除讨论', NULL, NULL, 0, NULL, NULL, 2, 'aiol:aiol_discussion:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0, 0, '1', 0);
-- 批量删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025091908381460464', '2025091908381460460', '批量删除讨论', NULL, NULL, 0, NULL, NULL, 2, 'aiol:aiol_discussion:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0, 0, '1', 0);
-- 导出excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025091908381460465', '2025091908381460460', '导出excel_讨论', NULL, NULL, 0, NULL, NULL, 2, 'aiol:aiol_discussion:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0, 0, '1', 0);
-- 导入excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025091908381460466', '2025091908381460460', '导入excel_讨论', NULL, NULL, 0, NULL, NULL, 2, 'aiol:aiol_discussion:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-09-19 08:38:46', NULL, NULL, 0, 0, '1', 0);

View File

@ -0,0 +1,70 @@
<template>
<div style="min-height: 400px">
<BasicForm @register="registerForm"></BasicForm>
<div style="width: 100%;text-align: center" v-if="!formDisabled">
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary"> </a-button>
</div>
</div>
</template>
<script lang="ts">
import {BasicForm, useForm} from '/@/components/Form/index';
import {computed, defineComponent} from 'vue';
import {defHttp} from '/@/utils/http/axios';
import { propTypes } from '/@/utils/propTypes';
import {getBpmFormSchema} from '../AiolDiscussion.data';
import {saveOrUpdate} from '../AiolDiscussion.api';
export default defineComponent({
name: "AiolDiscussionForm",
components:{
BasicForm
},
props:{
formData: propTypes.object.def({}),
formBpm: propTypes.bool.def(true),
},
setup(props){
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 150,
schemas: getBpmFormSchema(props.formData),
showActionButtonGroup: false,
baseColProps: {span: 24}
});
const formDisabled = computed(()=>{
if(props.formData.disabled === false){
return false;
}
return true;
});
let formData = {};
const queryByIdUrl = '/aiol/aiolDiscussion/queryById';
async function initFormData(){
let params = {id: props.formData.dataId};
const data = await defHttp.get({url: queryByIdUrl, params});
formData = {...data}
//
await setFieldsValue(formData);
//
await setProps({disabled: formDisabled.value})
}
async function submitForm() {
let data = getFieldsValue();
let params = Object.assign({}, formData, data);
console.log('表单数据', params)
await saveOrUpdate(params, true)
}
initFormData();
return {
registerForm,
formDisabled,
submitForm,
}
}
});
</script>

View File

@ -0,0 +1,99 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm" name="AiolDiscussionForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref, reactive} from 'vue';
import {BasicModal, useModalInner} from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form/index';
import {formSchema} from '../AiolDiscussion.data';
import {saveOrUpdate} from '../AiolDiscussion.api';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
const { createMessage } = useMessage();
// Emits
const emit = defineEmits(['register','success']);
const isUpdate = ref(true);
const isDetail = ref(false);
//
const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({
labelWidth: 150,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: {span: 24}
});
//
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
//
await resetFields();
setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
isUpdate.value = !!data?.isUpdate;
isDetail.value = !!data?.showFooter;
if (unref(isUpdate)) {
//
await setFieldsValue({
...data.record,
});
}
//
setProps({ disabled: !data?.showFooter })
});
//
const fieldPickers = reactive({
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
//
changeDateValue(values);
setModalProps({confirmLoading: true});
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
} finally {
setModalProps({confirmLoading: false});
}
}
/**
* 处理日期值
* @param formData 表单数据
*/
const changeDateValue = (formData) => {
if (formData && fieldPickers) {
for (let key in fieldPickers) {
if (formData[key]) {
formData[key] = getDateByPicker(formData[key], fieldPickers[key]);
}
}
}
};
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-calendar-picker) {
width: 100%;
}
</style>

View File

@ -45,6 +45,21 @@ export const columns: BasicColumn[] = [
align:"center", align:"center",
dataIndex: 'status_dictText' dataIndex: 'status_dictText'
}, },
{
title: '是否允许补交',
align:"center",
dataIndex: 'allowMakeup'
},
{
title: '补交截止时间',
align:"center",
dataIndex: 'makeupTime'
},
{
title: '作业通知时间',
align:"center",
dataIndex: 'notifyTime'
},
]; ];
// //
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
@ -104,6 +119,25 @@ export const formSchema: FormSchema[] = [
dictCode:"course_status", dictCode:"course_status",
type: "radio" type: "radio"
}, },
},
{
label: '是否允许补交',
field: 'allowMakeup',
component: 'InputNumber',
},
{
label: '补交截止时间',
field: 'makeupTime',
component: 'DatePicker',
componentProps: {
showTime: true,
valueFormat: 'YYYY-MM-DD HH:mm:ss'
},
},
{
label: '作业通知时间',
field: 'notifyTime',
component: 'InputNumber',
}, },
// TODO ID // TODO ID
{ {
@ -124,6 +158,9 @@ export const superQuerySchema = {
startTime: {title: '开始时间',order: 5,view: 'datetime', type: 'string',}, startTime: {title: '开始时间',order: 5,view: 'datetime', type: 'string',},
endTime: {title: '结束时间',order: 6,view: 'datetime', type: 'string',}, endTime: {title: '结束时间',order: 6,view: 'datetime', type: 'string',},
status: {title: '状态',order: 7,view: 'number', type: 'number',dictCode: 'course_status',}, status: {title: '状态',order: 7,view: 'number', type: 'number',dictCode: 'course_status',},
allowMakeup: {title: '是否允许补交',order: 8,view: 'number', type: 'number',},
makeupTime: {title: '补交截止时间',order: 9,view: 'datetime', type: 'string',},
notifyTime: {title: '作业通知时间',order: 10,view: 'number', type: 'number',},
}; };
/** /**