Commit cd112ea9 authored by wujipeng's avatar wujipeng
Browse files

init

parents
Pipeline #346 canceled with stages
package com.platform.business.controller;
import com.platform.business.model.entity.SysMenuEntity;
import com.platform.business.service.SysMenuService;
import com.platform.model.resp.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author : wujipeng
* @date : 2025/9/8 16:59
* @Version: 1.0
* @Desc : 描述信息
*/
@RestController
@RequestMapping("/sys/menu")
public class SysMenuController {
@Resource
private SysMenuService sysMenuService;
@GetMapping("/list")
public Result<List<SysMenuEntity>> queryList() {
return Result.data(sysMenuService.queryList());
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.SysRoleDTO;
import com.platform.business.model.vo.SysRoleVO;
import com.platform.business.service.SysRoleService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("/role")
public class SysRoleController extends BaseController {
@Resource
private SysRoleService sysRoleService;
@PostMapping("/page")
public TableDataInfo page(@RequestBody SysRoleDTO sysRoleDTO) {
startPage(sysRoleDTO.getPageNum(), sysRoleDTO.getPageSize());
return getDataTable(sysRoleService.queryList(sysRoleDTO));
}
@PostMapping("/saveOrUpdate")
public Result saveOrUpdate(@RequestBody SysRoleDTO sysRoleDTO) {
return toAjax(sysRoleService.saveRole(sysRoleDTO));
}
@GetMapping("/detail/{id}")
public Result<SysRoleVO> detail(@PathVariable int id) {
return Result.data(sysRoleService.detail(id));
}
@DeleteMapping("/delete/{id}")
public Result<Object> delete(@PathVariable int id) {
return sysRoleService.delete(id);
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.TheoreticalLibraryDTO;
import com.platform.business.service.TheoreticalLibraryService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author : wujipeng
* @date : 2025/10/29 15:17
* @Version: 1.0
* @Desc : 理论题库管理
*/
@Api(tags = "理论题库管理")
@RestController
@RequestMapping("/theoretical/library")
public class TheoreticalLibraryController extends BaseController {
@Resource
private TheoreticalLibraryService theoreticalLibraryService;
@ApiOperation("上传")
@PostMapping("/import")
public Result<Boolean> importTheoreticalLibrary(@RequestParam(name = "file") MultipartFile file) throws IOException {
return theoreticalLibraryService.importTheoreticalLibrary(file);
}
@ApiOperation("分页")
@PostMapping("/page")
public TableDataInfo page(@RequestBody TheoreticalLibraryDTO theoreticalLibraryDTO) {
startPage(theoreticalLibraryDTO.getPageNum(), theoreticalLibraryDTO.getPageSize());
return getDataTable(theoreticalLibraryService.pageData(theoreticalLibraryDTO));
}
@ApiOperation("编辑")
@PutMapping("/update")
public Result<Boolean> updateData(@RequestBody TheoreticalLibraryDTO theoreticalLibraryDTO) {
return Result.data(theoreticalLibraryService.updateData(theoreticalLibraryDTO));
}
@ApiOperation("删除")
@DeleteMapping("/{id}")
public Result<Boolean> delete(@PathVariable String id) {
return Result.data(theoreticalLibraryService.removeById(id));
}
@ApiOperation("导出")
@PostMapping("/export")
public void export(@RequestBody TheoreticalLibraryDTO theoreticalLibraryDTO, HttpServletResponse response) {
theoreticalLibraryService.export(theoreticalLibraryDTO, response);
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.CombinationDTO;
import com.platform.business.model.dto.TheoreticalPaperDTO;
import com.platform.business.model.vo.CombinationVO;
import com.platform.business.model.vo.TheoreticalPaperVO;
import com.platform.business.service.TheoreticalPaperService;
import com.platform.business.utils.JwtTokenUtil;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author : wujipeng
* @date : 2025/11/3 14:01
* @Version: 1.0
* @Desc : 理论试卷管理
*/
@Api(tags = "理论试卷管理")
@RestController
@RequestMapping("/theoretical/paper")
public class TheoreticalPaperController extends BaseController {
@Resource
private JwtTokenUtil jwtTokenUtil;
@Resource
private TheoreticalPaperService theoreticalPaperService;
@PostMapping("/page")
public TableDataInfo pageData(@RequestBody TheoreticalPaperDTO theoreticalPaperDTO) {
startPage(theoreticalPaperDTO.getPageNum(), theoreticalPaperDTO.getPageSize());
return getDataTable(theoreticalPaperService.pageData(theoreticalPaperDTO));
}
@GetMapping("/auto")
@ApiOperation("自动组卷")
public Result<CombinationVO> auto(@RequestParam(name = "lev") String lev) {
return Result.data(theoreticalPaperService.auto(lev));
}
@PostMapping("/create")
@ApiOperation("创建试卷")
public Result<Boolean> create(@RequestBody CombinationDTO combinationDTO, HttpServletRequest httpServletRequest) {
String token = httpServletRequest.getHeader("Authorization");
String userName = jwtTokenUtil.getUsernameFromToken(token);
combinationDTO.setCreateUser(userName);
return Result.data(theoreticalPaperService.create(combinationDTO));
}
@ApiOperation("详情")
@GetMapping("/detail/{id}")
public Result<TheoreticalPaperVO> detail(@PathVariable(name = "id") String id) {
return Result.data(theoreticalPaperService.detail(id));
}
@ApiOperation("导出")
@GetMapping("/export/{id}")
public void export(@PathVariable String id, HttpServletResponse response) {
theoreticalPaperService.export(id, response);
}
@ApiOperation("导出带答案的版本")
@GetMapping("/export/answer/{id}")
public void exportWithAnswer(@PathVariable String id, HttpServletResponse response) {
theoreticalPaperService.exportWithAnswer(id, response);
}
@ApiOperation("删除")
@DeleteMapping("/{id}")
public Result<Boolean> delete(@PathVariable String id) {
return Result.data(theoreticalPaperService.delete(id));
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.TheoreticalPracticeDTO;
import com.platform.business.model.vo.TheoreticalPracticeVO;
import com.platform.business.service.TheoreticalPracticeService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author : wujipeng
* @date : 2026/4/21 10:14
* @Version: 1.0
* @Desc : 描述信息
*/
@RestController
@RequestMapping("/theoretical/practice")
public class TheoreticalPracticeController extends BaseController {
@Resource
private TheoreticalPracticeService theoreticalPracticeService;
@PostMapping("/page")
public TableDataInfo page(@RequestBody TheoreticalPracticeDTO theoreticalPracticeDTO) {
startPage(theoreticalPracticeDTO.getPageNum(), theoreticalPracticeDTO.getPageSize());
return getDataTable(theoreticalPracticeService.page(theoreticalPracticeDTO));
}
@GetMapping("/{id}")
public Result<TheoreticalPracticeVO> detail(@PathVariable String id) {
return Result.data(theoreticalPracticeService.detail(id));
}
@PostMapping("/saveOrUpdate")
public Result<Boolean> saveOrUpdateData(@RequestBody TheoreticalPracticeDTO theoreticalPracticeDTO) {
return theoreticalPracticeService.saveOrUpdateData(theoreticalPracticeDTO);
}
@PostMapping("/close")
public Result<Boolean> close(@RequestBody TheoreticalPracticeDTO theoreticalPracticeDTO) {
return Result.data(theoreticalPracticeService.close(theoreticalPracticeDTO));
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.TheoreticalPracticeStudentQuestionBankDTO;
import com.platform.business.model.vo.TheoreticalPracticeStudentQuestionBankVO;
import com.platform.business.service.TheoreticalPracticeStudentQuestionBankService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/theoretical/practice/student/question/bank")
public class TheoreticalPracticeStudentQuestionBankController extends BaseController {
@Resource
private TheoreticalPracticeStudentQuestionBankService theoreticalPracticeStudentQuestionBankService;
@ApiOperation(value = "一级分页")
@PostMapping("/one/page")
public TableDataInfo onePage(@RequestBody TheoreticalPracticeStudentQuestionBankDTO theoreticalPracticeStudentQuestionBankDTO) {
return getDataTable(theoreticalPracticeStudentQuestionBankService.onePage(theoreticalPracticeStudentQuestionBankDTO));
}
@ApiOperation(value = "二级分页")
@PostMapping("/two/page")
public TableDataInfo twoPage(@RequestBody TheoreticalPracticeStudentQuestionBankDTO theoreticalPracticeStudentQuestionBankDTO) {
return getDataTable(theoreticalPracticeStudentQuestionBankService.twoPage(theoreticalPracticeStudentQuestionBankDTO));
}
@ApiOperation(value = "编辑")
@PostMapping("/update")
public Result<Boolean> edit(@RequestBody TheoreticalPracticeStudentQuestionBankDTO theoreticalPracticeStudentQuestionBankDTO) {
return Result.data(theoreticalPracticeStudentQuestionBankService.edit(theoreticalPracticeStudentQuestionBankDTO));
}
@ApiOperation(value = "题库总览")
@PostMapping("/overview")
public Result<List<TheoreticalPracticeStudentQuestionBankVO>> overview(@RequestBody TheoreticalPracticeStudentQuestionBankDTO theoreticalPracticeStudentQuestionBankDTO) {
return Result.data(theoreticalPracticeStudentQuestionBankService.overview(theoreticalPracticeStudentQuestionBankDTO));
}
@ApiOperation(value = "详情")
@GetMapping("/{id}")
public Result<TheoreticalPracticeStudentQuestionBankVO> detail(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentQuestionBankService.detail(id));
}
@ApiOperation(value = "重新作答")
@PostMapping("/reAnswer")
public Result<Boolean> reAnswer(@RequestBody TheoreticalPracticeStudentQuestionBankDTO theoreticalPracticeStudentQuestionBankDTO) {
return Result.data(theoreticalPracticeStudentQuestionBankService.reAnswer(theoreticalPracticeStudentQuestionBankDTO));
}
@ApiOperation(value = "理论练习-结束倒计时")
@GetMapping("/countdown")
public Result<Long> countdown() {
return Result.data(theoreticalPracticeStudentQuestionBankService.countdown());
}
}
package com.platform.business.controller;
import cn.hutool.core.bean.BeanUtil;
import com.platform.business.model.dto.CombinationDTO;
import com.platform.business.model.dto.TheoreticalPracticeStudentSimulationDTO;
import com.platform.business.model.dto.TheoreticalPracticeStudentSimulationDetailDTO;
import com.platform.business.model.vo.TheoreticalPracticeStudentSimulationDetailVO;
import com.platform.business.model.vo.TheoreticalPracticeStudentSimulationVO;
import com.platform.business.service.TheoreticalPracticeStudentSimulationService;
import com.platform.business.utils.JwtTokenUtil;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/theoretical/practice/student/simulation")
public class TheoreticalPracticeStudentSimulationController extends BaseController {
@Resource
private TheoreticalPracticeStudentSimulationService theoreticalPracticeStudentSimulationService;
@Resource
private JwtTokenUtil jwtTokenUtil;
@PostMapping("/page")
public TableDataInfo pageData(@RequestBody TheoreticalPracticeStudentSimulationDTO theoreticalPracticeStudentSimulationDTO) {
startPage(theoreticalPracticeStudentSimulationDTO.getPageNum(), theoreticalPracticeStudentSimulationDTO.getPageSize());
return getDataTable(theoreticalPracticeStudentSimulationService.pageData(theoreticalPracticeStudentSimulationDTO));
}
@GetMapping("/{id}")
public Result<TheoreticalPracticeStudentSimulationVO> detail(@PathVariable String id) {
return Result.data(BeanUtil.copyProperties(theoreticalPracticeStudentSimulationService.getById(id), TheoreticalPracticeStudentSimulationVO.class));
}
@PostMapping("/create")
public Result<Boolean> create(@RequestBody CombinationDTO combinationDTO, HttpServletRequest httpServletRequest) {
String token = httpServletRequest.getHeader("Authorization");
String userName = jwtTokenUtil.getUsernameFromToken(token);
combinationDTO.setCreateUser(userName);
return Result.data(theoreticalPracticeStudentSimulationService.create(combinationDTO));
}
@GetMapping("/start/{id}")
public Result<Boolean> start(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentSimulationService.start(id));
}
@PutMapping("/update")
public Result<Boolean> updateDetail(@RequestBody TheoreticalPracticeStudentSimulationDetailDTO theoreticalPracticeStudentSimulationDetailDTO) {
return Result.data(theoreticalPracticeStudentSimulationService.updateDetail(theoreticalPracticeStudentSimulationDetailDTO));
}
@GetMapping("/overview/{id}")
public Result<List<TheoreticalPracticeStudentSimulationDetailVO>> overview(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentSimulationService.overview(id));
}
@ApiOperation("重新作答")
@GetMapping("/reAnswer/{id}")
public Result<Boolean> reAnswer(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentSimulationService.reAnswer(id));
}
@ApiOperation(value = "交卷校验")
@GetMapping("/submit/check/{id}")
public Result<Map<String, String>> submitCheck(@PathVariable(name = "id") String id) {
return Result.data(theoreticalPracticeStudentSimulationService.submitCheck(id));
}
@ApiOperation("交卷")
@GetMapping("/submit/{id}")
public Result<Boolean> submit(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentSimulationService.submit(id));
}
@ApiOperation("考试中-考题详情")
@GetMapping("/proceed/title/{id}")
public Result<TheoreticalPracticeStudentSimulationDetailVO> proceedTitleDetail(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentSimulationService.proceedTitleDetail(id));
}
@ApiOperation("查看解析-考题详情")
@GetMapping("/analysis/title/{id}")
public Result<TheoreticalPracticeStudentSimulationDetailVO> analysisTitleDetail(@PathVariable String id) {
return Result.data(theoreticalPracticeStudentSimulationService.analysisTitleDetail(id));
}
@ApiOperation("获取创建试卷等级与名称")
@GetMapping("/paper/information")
public Result<Map<String, String>> getPaperInformation(HttpServletRequest httpServletRequest) {
String token = httpServletRequest.getHeader("Authorization");
String userName = jwtTokenUtil.getUsernameFromToken(token);
return Result.data(theoreticalPracticeStudentSimulationService.getPaperInformation(userName));
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.UserDTO;
import com.platform.business.model.vo.UserVO;
import com.platform.business.service.UserService;
import com.platform.business.utils.JwtTokenUtil;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
@Resource
private UserService userService;
@Resource
private JwtTokenUtil jwtTokenUtil;
@PostMapping("/page")
public TableDataInfo page(@RequestBody UserDTO userDTO) {
startPage(userDTO.getPageNum(), userDTO.getPageSize());
return getDataTable(userService.queryList(userDTO));
}
@PostMapping("/saveOrUpdate")
public Result saveOrUpdate(@RequestBody UserDTO userDTO) {
return Result.data(userService.saveOrUpdateUser(userDTO));
}
@GetMapping("/detail/{id}")
public Result<UserVO> detail(@PathVariable String id) {
return Result.data(userService.detail(id));
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable int id) {
return Result.data(userService.removeById(id));
}
@ApiOperation("重置密码")
@GetMapping("/reset/{id}")
public Result resetPassword(@PathVariable String id) {
return Result.data(userService.resetPassword(id));
}
@ApiOperation("修改密码")
@PostMapping("/updatePassword")
public Result updatePassword(@RequestBody UserDTO userDTO) {
return userService.updatePassword(userDTO);
}
@ApiOperation("学员列表导入")
@PostMapping("/student/import")
public Result studentImport(@RequestParam("file") MultipartFile file) {
return userService.studentImport(file);
}
@ApiOperation("教师导入")
@PostMapping("/teacher/import")
public Result teacherImport(@RequestParam("file") MultipartFile file) {
return Result.data(userService.teacherImport(file));
}
@ApiOperation("获取用户信息")
@GetMapping("/getUserMessage")
public Result<UserVO> getUserMessage(HttpServletRequest httpServletRequest) {
String token = httpServletRequest.getHeader("Authorization");
String userName = jwtTokenUtil.getUsernameFromToken(token);
return Result.data(userService.getUserMessage(userName));
}
}
package com.platform.business.controller;
import com.alibaba.fastjson.JSON;
import com.platform.business.duplex.WebSocketServer;
import com.platform.business.model.dto.WebSocketDTO;
import com.platform.business.model.req.ExamReq;
import com.platform.business.service.ExamDetailService;
import com.platform.model.resp.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
/**
* @author : wujipeng
* @date : 2025/7/21 17:51
* @Version: 1.0
* @Desc : 描述信息
*/
@Api(tags = "WebSocket控制层")
@RestController
@RequestMapping("/web/socket")
@Slf4j
public class WebSocketController {
@Resource
private WebSocketServer webSocketServer;
@Resource
private ExamDetailService examDetailService;
@ApiModelProperty("发送消息")
@PostMapping("/send")
public Result<Object> send(@RequestBody WebSocketDTO webSocketDTO) {
try {
webSocketServer.sendInfo(JSON.toJSONString(webSocketDTO), webSocketDTO.getUserId());
return Result.data("发送成功");
} catch (IOException e) {
return Result.fail("发送失败");
}
}
@ApiModelProperty("获取数字仿真在线人员id列表")
@GetMapping("/online")
public Result<List<String>> online() {
return Result.data(webSocketServer.online());
}
@PostMapping("/test")
public void test(@RequestBody ExamReq examReq) {
webSocketServer.onMessage(JSON.toJSONString(examReq), null);
}
@ApiOperation("主观题")
@PostMapping("/subjective")
public Result<String> subjective(@RequestParam(name = "content") String content, @RequestParam(name = "files", required = false) List<MultipartFile> files) {
try {
examDetailService.subjective(content, files);
return Result.data("上传成功");
} catch (Exception e) {
log.error("上传失败:{}", e.getMessage());
return Result.fail("上传失败");
}
}
}
package com.platform.business.controller;
import com.platform.business.model.entity.TeacherWorkRecordEntity;
import com.platform.business.service.TeacherWorkRecordService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("/work/record")
public class WorkRecordController extends BaseController {
@Resource
private TeacherWorkRecordService teacherWorkRecordService;
@PostMapping("/saveOrUpdate")
public Result save(@RequestBody TeacherWorkRecordEntity teacherWorkRecordEntity) {
return toAjax(teacherWorkRecordService.saveOrUpdate(teacherWorkRecordEntity));
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable int id) {
return toAjax(teacherWorkRecordService.removeById(id));
}
}
package com.platform.business.duplex;
import com.alibaba.fastjson2.JSON;
import com.platform.business.model.req.ExamReq;
import com.platform.business.service.ExamDetailService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint("/websocket/{userId}")
@Component
@Slf4j
public class WebSocketServer {
private static ExamDetailService examDetailService;
@Resource
public void setExamDetailService(ExamDetailService examDetailService) {
WebSocketServer.examDetailService = examDetailService;
}
/**
* 在线人数
*/
private static int onlineCount = 0;
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
*/
private static final ConcurrentHashMap<String, WebSocketServer> webSocketMap = new ConcurrentHashMap<>();
/**
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
*/
private Session session;
/**
* 接收用户ID
*/
private String userId = "";
@OnOpen
public void onOpen(Session session, @PathParam("userId") String userId) {
this.session = session;
this.userId = userId;
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
webSocketMap.put(userId, this);
} else {
webSocketMap.put(userId, this);
addOnlineCount();
}
log.info(userId + "上线,当前在线人数为:" + getOnlineCount());
try {
sendMessage("连接成功");
} catch (IOException e) {
log.error("用户:" + userId + ",网络异常!!!!!!");
}
}
@OnClose
public void onClose() {
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
subOnlineCount();
}
log.info(userId + "退出登录,当前在线人数为:" + getOnlineCount());
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息
*/
@OnMessage
public void onMessage(String message, Session session) {
log.info(userId + ":" + message);
ExamReq examReq = JSON.parseObject(message, ExamReq.class);
//判断题型
// String type = examReq.getType();
// if ("客观题".equals(type)) {
examDetailService.objective(examReq);
// } else if ("线下题".equals(type)) {
// examDetailService.offline(examReq);
// }
// WebSocketTypeFactory.getBean(examReq);
}
@OnError
public void onError(Session session, Throwable error) {
log.error("用户错误:" + this.userId + ",原因:" + error.getMessage());
}
public void sendMessage(String message) throws IOException {
this.session.getBasicRemote().sendText(message);
}
/**
* 群发消息
*
* @param message 消息
* @throws IOException IOException
*/
public void sendAllMessage(String message) throws IOException {
ConcurrentHashMap.KeySetView<String, WebSocketServer> userIds = webSocketMap.keySet();
for (String userId : userIds) {
WebSocketServer webSocketServer = webSocketMap.get(userId);
webSocketServer.session.getBasicRemote().sendText(message);
}
}
/**
* 发送信息给指定用户
*
* @param message 消息
* @param userId 用户ID
* @throws IOException IOException
*/
public void sendInfo(String message, @PathParam("userId") String userId) throws IOException {
log.info("发送消息到:" + userId + ",报文:" + message);
if (StringUtils.isNotBlank(userId) && webSocketMap.containsKey(userId)) {
webSocketMap.get(userId).sendMessage(message);
} else {
log.error("用户" + userId + ",不在线!");
}
}
public List<String> online() {
ConcurrentHashMap.KeySetView<String, WebSocketServer> userIds = webSocketMap.keySet();
return new ArrayList<>(userIds);
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
WebSocketServer.onlineCount++;
}
public static synchronized void subOnlineCount() {
WebSocketServer.onlineCount--;
}
}
\ No newline at end of file
//package com.platform.business.factory;
//
//import com.platform.business.model.req.ExamReq;
//import com.platform.business.model.resp.ExamResp;
//import com.platform.business.strategy.WebSocketMsgStrategy;
//import com.platform.business.strategy.impl.ExamSubmitStrategyImpl;
//
//import java.util.HashMap;
//import java.util.Map;
//
//public class WebSocketTypeFactory {
//
// private static final Map<String, WebSocketMsgStrategy> STRATEGY_MAP = new HashMap<>();
//
// static {
// STRATEGY_MAP.put("EXAM_SUBMIT", new ExamSubmitStrategyImpl());
// }
//
// public static ExamResp getBean(ExamReq examReq) {
// WebSocketMsgStrategy strategy = STRATEGY_MAP.get(examReq.getType());
// if (strategy != null) {
// return strategy.execute(examReq);
// }
// return null;
// }
//}
package com.platform.business.handle;
import com.platform.business.model.entity.ApprovalFlowEntity;
/**
* @author : wujipeng
* @date : 2025/7/17 15:00
* @Version: 1.0
* @Desc : 描述信息
*/
public interface Handler {
/**
* 设置下一个处理者
* @param nextHandler 下一个处理者
* @return Handler
*/
Handler setNextHandler(Handler nextHandler);
/**
* 处理请求
* @param approvalFlowEntity approvalFlowEntity
*/
void handleRequest(ApprovalFlowEntity approvalFlowEntity);
}
package com.platform.business.handle;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* @author : wujipeng
* @date : 2025/7/23 9:53
* @Version: 1.0
* @Desc : 描述信息
*/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
}
@Override
public void updateFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
}
}
package com.platform.business.handle.impl;
import com.platform.business.handle.Handler;
import lombok.*;
/**
* @author : wujipeng
* @date : 2025/7/17 15:01
* @Version: 1.0
* @Desc : 描述信息
*/
@Data
public abstract class AbstractHandler implements Handler {
private Handler nextHandler;
public Handler setNextHandler(Handler nextHandler) {
this.nextHandler = nextHandler;
return this.nextHandler;
}
}
package com.platform.business.handle.inheritance;
import com.platform.business.handle.impl.AbstractHandler;
import com.platform.business.model.entity.ApprovalFlowEntity;
/**
* @author : wujipeng
* @date : 2025/7/17 15:03
* @Version: 1.0
* @Desc : 超管处理
*/
public class SuperTube extends AbstractHandler {
public void handleRequest(ApprovalFlowEntity approvalFlowEntity) {
//TODO 处理逻辑
}
}
package com.platform.business.handle.inheritance;
import com.platform.business.handle.impl.AbstractHandler;
import com.platform.business.model.entity.ApprovalFlowEntity;
/**
* @author : wujipeng
* @date : 2025/7/17 15:03
* @Version: 1.0
* @Desc : 主管处理
*/
public class Supervisor extends AbstractHandler {
public void handleRequest(ApprovalFlowEntity approvalFlowEntity) {
//TODO 处理逻辑
}
}
package com.platform.business.handle.inheritance;
import com.platform.business.handle.impl.AbstractHandler;
import com.platform.business.model.entity.ApprovalFlowEntity;
/**
* @author : wujipeng
* @date : 2025/7/17 15:02
* @Version: 1.0
* @Desc : 组长处理
*/
public class TeamLeader extends AbstractHandler {
public void handleRequest(ApprovalFlowEntity approvalFlowEntity) {
//TODO 处理逻辑
}
}
package com.platform.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.business.model.entity.BsFileEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author : wujipeng
* @date : 2025/9/3 9:42
* @Version: 1.0
* @Desc : 描述信息
*/
@Mapper
public interface BsFileMapper extends BaseMapper<BsFileEntity> {
}
package com.platform.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.business.model.entity.CandidateEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author : wujipeng
* @date : 2025/7/7 17:40
* @Version: 1.0
* @Desc : 描述信息
*/
@Mapper
public interface CandidateMapper extends BaseMapper<CandidateEntity> {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment