keys = redisUtil.keys(key1);
+ keys.addAll(redisUtil.keys(key2));
+ keys.addAll(redisUtil.keys(key3));
+ if (null == keys || 0 == keys.size()) {
+ return new ResultVO(ResultCode.SUCCESS,"未查询到数据");
+ } else {
+ List list = redisUtil.multiGet(keys);
+ ResultVO success = new ResultVO(ResultCode.SUCCESS, "获取成功");
+ success.setData(JSON.toJSON(list));
+ return success;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResultVO(ResultCode.ERROR,"发生错误");
+ }
+ }
+
+ @ApiOperation(value = "更新消息(暂时用于更改已读状态)")
+ @PutMapping("/messagecommunication")
+ public ResultVO redisMessagePut(@RequestBody MessageCommunication messageCommunication) {
+ try {
+ String sendto = messageCommunication.getSendto();
+ if (null != sendto && !sendto.equals("")) {
+ String key1 = messageCommunication.getId() + ":" + messageCommunication.getUUID() + ":" + sendto;
+ if (redisUtil.setIfPresent(key1, messageCommunication)) {
+ return new ResultVO(ResultCode.SUCCESS,"更新成功");
+ } else {
+ return new ResultVO(ResultCode.FAILED,"不存在该数据");
+ }
+ } else {
+ String key1 = messageCommunication.getId() + ":" + messageCommunication.getUUID() + ":all";
+ if (redisUtil.setIfPresent(key1, messageCommunication)) {
+ return new ResultVO(ResultCode.SUCCESS,"更新成功");
+ } else {
+ return new ResultVO(ResultCode.FAILED,"不存在该数据");
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResultVO(ResultCode.ERROR,"请检查参数");
+ }
+ }
+
+ @ApiOperation(value = "删除消息(存疑 单方面删除后该消息会从数据库中删除)")
+ @DeleteMapping("/messagecommunication")
+ public ResultVO redisMessageDel(@RequestBody MessageCommunication messageCommunication) {
+ try {
+ String newKey = "";
+ if ("" != messageCommunication.getSendto() && null != messageCommunication.getSendto()) {
+ newKey = messageCommunication.getId() + ":" + messageCommunication.getUUID() + ":" + messageCommunication.getSendto();
+ } else {
+ newKey = messageCommunication.getId() + ":" + messageCommunication.getUUID() + ":all";
+ }
+ if (redisUtil.hasKey(newKey)) {
+ if (redisUtil.deleteKey(newKey)) {
+ return new ResultVO(ResultCode.SUCCESS,"删除成功");
+ } else {
+ return new ResultVO(ResultCode.FAILED,"请检查参数");
+ }
+ } else {
+ return new ResultVO(ResultCode.FAILED,"删除的数据不存在");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ResultVO(ResultCode.ERROR,"请检查参数");
+ }
+ }
+}
diff --git a/src/main/java/com/example/controller/MessageController.java b/src/main/java/com/example/controller/MessageController.java
index 00d3f79a2e86e25db94e1665340564e130f30cb2..ba71145c3e4d9954b2d9f5f030eecc4f57963ddd 100644
--- a/src/main/java/com/example/controller/MessageController.java
+++ b/src/main/java/com/example/controller/MessageController.java
@@ -15,9 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* @author: 谢佳辉
@@ -39,7 +37,6 @@ public class MessageController {
Result result = new Result();
Login currentlogin;
try{
-
Subject subject = SecurityUtils.getSubject();
currentlogin =(Login)subject.getPrincipal();
}catch (RuntimeException e){
diff --git a/src/main/java/com/example/controller/StaffController.java b/src/main/java/com/example/controller/StaffController.java
index d1b521220d5e7267ffc656416cec0f55f70663c8..1ad3169640cefe71b161214b1b5753e876c2994b 100644
--- a/src/main/java/com/example/controller/StaffController.java
+++ b/src/main/java/com/example/controller/StaffController.java
@@ -1,34 +1,14 @@
package com.example.controller;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.example.model.Login;
-import com.example.model.Staff;
-import com.example.model.form.EvidenceForm;
-import com.example.model.form.PostEvidence;
-import com.example.model.form.StaffForm;
import com.example.rmso.ResultVO;
-import com.example.service.IEvidenceService;
-import com.example.service.IStaffService;
-import com.example.service.TokenService;
-import com.example.util.UploadUtils;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.subject.Subject;
+import com.example.service.impl.testimpl;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
-import javax.servlet.http.HttpSession;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Wrapper;
-import java.util.HashMap;
-import java.util.Map;
+import org.springframework.web.bind.annotation.RestController;
/**
*
@@ -39,25 +19,14 @@ import java.util.Map;
* @since 2021-01-12
*/
@CrossOrigin
-@Controller
+@RestController
@RequestMapping("/staff")
-@Api(value = "用户")
public class StaffController {
-
@Autowired
- IStaffService staffService;
- @PostMapping("UploadHeadImg")
- @ApiOperation("头像上传")
- @ResponseBody
- public Map uploadHeadImg(@RequestPart("headImg") MultipartFile headerImg) throws IOException {
- HashMap map = new HashMap<>();
- Subject subject = SecurityUtils.getSubject();
- if( staffService.UploadHeadImg(headerImg,subject)){
- //返回信息
- map.put("msg","修改头像成功");
- }else {
- map.put("msg","头像修改失败");
- }
- return map;
+ testimpl testimpl;
+ @GetMapping("gets")
+ public ResultVO get(){
+ return testimpl.get();
}
-}
\ No newline at end of file
+
+}
diff --git a/src/main/java/com/example/controller/TestController.java b/src/main/java/com/example/controller/TestController.java
deleted file mode 100644
index 5d10bc8f1559c694790508088e46243a756e91de..0000000000000000000000000000000000000000
--- a/src/main/java/com/example/controller/TestController.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.example.controller;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-@Controller
-@RequestMapping("/cyy")
-public class TestController {
-
- @RequestMapping("/test1")
- public String loginToTest(){
- return "/cyy.html";
- }
-
-}
diff --git a/src/main/java/com/example/controller/WebSocket.java b/src/main/java/com/example/controller/WebSocket.java
new file mode 100644
index 0000000000000000000000000000000000000000..df47b53e5ce898dd06b5e70607a81a6a1207487b
--- /dev/null
+++ b/src/main/java/com/example/controller/WebSocket.java
@@ -0,0 +1,227 @@
+//package com.example.controller;
+//
+//import com.alibaba.fastjson.JSON;
+//import com.example.config.WebSocketConfig;
+//import com.example.model.form.MessageCommunication;
+//import com.example.util.RedisUtil;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+//import org.springframework.stereotype.Component;
+//
+//import javax.websocket.*;
+//import javax.websocket.server.PathParam;
+//import javax.websocket.server.ServerEndpoint;
+//import java.io.IOException;
+//import java.text.SimpleDateFormat;
+//import java.util.Date;
+//import java.util.List;
+//import java.util.Map;
+//import java.util.Set;
+//import java.util.concurrent.ConcurrentHashMap;
+//import java.util.concurrent.atomic.AtomicInteger;
+//
+///**
+// * @author: HoweverXz
+// * @Date: 2021/9/22
+// * 纸上得来终觉浅 绝知此事要躬行
+// */
+//@ConditionalOnClass(value = {WebSocketConfig.class})
+//@ServerEndpoint("/websocket/{userID}")
+//@Component
+//public class WebSocket {
+// //连接数
+// private static AtomicInteger count;
+// //uid-session 连接池
+// private static Map clints;
+// private static Set sessions;
+//
+// static {
+// ConcurrentHashMap stringSessionConcurrentHashMap = new ConcurrentHashMap<>();
+// clints = stringSessionConcurrentHashMap;
+// AtomicInteger atomicInteger = new AtomicInteger(0);
+// count = atomicInteger;
+// }
+//
+// // 这里使用静态,让 Util的Bean 属于本类
+// private static RedisUtil redisUtil;
+//
+// // 注入的时候,给本类的 属性 注入
+// @Autowired
+// public void setChatService(RedisUtil redisUtil) {
+// WebSocket.redisUtil = redisUtil;
+// }
+//
+//
+// /**
+// * 访问路径传入id参数
+// * 多个相同用户访问会顶掉前一个
+// *
+// * @param session
+// * @param uid
+// * @throws IOException
+// */
+// @OnOpen
+// public void onOpen(Session session, @PathParam("userID") String uid) throws IOException {
+// if (clints.containsKey(uid)) {
+// clints.get(uid).close();
+// clints.remove(uid);
+// onOpen(session, uid);
+// } else {
+// clints.put(uid, session);
+// String s = redisMessageGet(uid);
+// sentTo(s, uid);
+// countInc();
+// System.out.println(uid + "已上线,目前在线数" + count);
+// }
+// }
+//
+// @OnClose
+// public void onClose(Session session, @PathParam("userID") String uid) {
+// if (clints.containsKey(uid)) {
+// clints.remove(uid);
+// countDec();
+// System.out.println(uid + "断开连接,目前在线数" + count);
+// } else {
+// System.out.println("关闭失败 对应链接不存在");
+// }
+//
+// }
+//
+// @OnError
+// public void onError(Throwable throwable) {
+// throwable.printStackTrace();
+// System.out.println("参数错误");
+// }
+//
+// @OnMessage
+// public void onMessage(String messageJson) {
+// MessageCommunication message = JSON.parseObject(messageJson, MessageCommunication.class);
+// String sendto = message.getSendto();
+// //判断是否带del参数 携带则为删除模式
+// if (null != message.getDel() && message.getDel()) {
+// if (contain(message)) {
+// redisMessageDel(message);
+// } else {
+// System.out.println("不存在条信息");
+// }
+// } else {
+// if (null == sendto || "" == sendto) {
+// sentToAll(messageJson);
+// } else {
+// sentTo(messageJson, sendto);
+// }
+// //发完消息判断数据库是否存在数据 选择更新和添加
+// if (!contain(message)) {
+// redisMessagePost(messageJson);
+// } else {
+// redisMessagePost(messageJson, new Date());
+// }
+// }
+// }
+//
+// public void sentToAll(String messageJson) {
+// for (Map.Entry stringSessionEntry : clints.entrySet()) {
+// stringSessionEntry.getValue().getAsyncRemote().sendText(messageJson);
+// }
+// }
+//
+// public void sentTo(String messageJson, String uid) {
+// Session session = clints.get(uid);
+// session.getAsyncRemote().sendText(messageJson);
+// }
+//
+// private void countInc() {
+// count.incrementAndGet();
+// }
+//
+// private void countDec() {
+// count.decrementAndGet();
+// }
+//
+// private String redisMessagePost(String messageJson, Date... date) {
+// MessageCommunication message = JSON.parseObject(messageJson, MessageCommunication.class);
+// String sendto = message.getSendto();
+// //判断是否有 日期值传入 传入日期则为更新模式 不传入日期则为添加模式
+// //添加模式
+// if (0 == date.length || null == date) {
+// //判断是否传入sendto值 确定发送消息到哪里 若无sendto值则默认发送给所有链接socket的人
+// if (null != sendto && !sendto.equals("")) {
+// String key1 = message.getId() + ":" + message.getSendtime() + ":" + sendto;
+// if (redisUtil.setIfAbsent(key1, message)) {
+// return "添加成功";
+// } else {
+// return "不存在";
+// }
+// } else {
+// String key2 = message.getId() + ":" + message.getSendtime() + ":all";
+// if (redisUtil.setIfAbsent(key2, message)) {
+// return "添加成功";
+// } else {
+// return "不存在";
+// }
+// }
+// } else { //更新模式
+// if (null != sendto && !sendto.equals("")) {
+// String key1 = message.getId() + ":" + message.getSendtime() + ":" + sendto;
+// redisUtil.deleteKey(key1);
+// String key2 = message.getId() + ":" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date[0]) + ":" + sendto;
+// if (redisUtil.setIfAbsent(key2, message)) {
+// return "添加成功";
+// } else {
+// return "不存在";
+// }
+// } else {
+// String key1 = message.getId() + ":" + message.getSendtime() + ":all";
+// redisUtil.deleteKey(key1);
+// String key2 = message.getId() + ":" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date[0]) + ":" + ":all";
+// if (redisUtil.setIfAbsent(key2, message)) {
+// return "添加成功";
+// } else {
+// return "不存在";
+// }
+// }
+// }
+// }
+//
+// /*
+// 获取信息
+// id:* 自己发送出去
+// *:id 接收到来自别人的信息
+// *:all 接收到的全体信息
+// */
+// private String redisMessageGet(String id) {
+// String key1 = id + ":*";
+// String key2 = "*:" + id;
+// String key3 = "*:all";
+// Set keys = redisUtil.keys(key1);
+// keys.addAll(redisUtil.keys(key2));
+// keys.addAll(redisUtil.keys(key3));
+// if (null == keys || 0 == keys.size()) {
+// return "未查询到数据";
+// } else {
+// List list = redisUtil.multiGet(keys);
+// return JSON.toJSONString(list);
+//
+// }
+// }
+//
+// private void redisMessageDel(MessageCommunication message) {
+// String key = parseKey(message);
+// redisUtil.deleteKey(key);
+// }
+//
+// private Boolean contain(MessageCommunication message) {
+// String key = parseKey(message);
+// return redisUtil.hasKey(key);
+// }
+//
+// private String parseKey(MessageCommunication message) {
+// String newKey = "";
+// if ("" != message.getSendto() && null != message.getSendto()) {
+// newKey = message.getId() + ":" + message.getSendtime() + ":" + message.getSendto();
+// } else {
+// newKey = message.getId() + ":" + message.getSendtime() + ":all";
+// }
+// return newKey;
+// }
+//}
diff --git a/src/main/java/com/example/mapper/CaseTypeMapper.java b/src/main/java/com/example/mapper/CaseTypeMapper.java
index 274c89f35ab7e39df7f0533b9d72bb37ecc269e8..7068a1d708ac44c3f409788388c0cab9d3c14c79 100644
--- a/src/main/java/com/example/mapper/CaseTypeMapper.java
+++ b/src/main/java/com/example/mapper/CaseTypeMapper.java
@@ -1,7 +1,5 @@
package com.example.mapper;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.example.model.Cases;
import com.example.model.vo.ReturnCase;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@@ -14,7 +12,7 @@ import java.util.List;
* @date 2021/5/3 10:24 下午
*/
@Mapper
-public interface CaseTypeMapper extends BaseMapper {
+public interface CaseTypeMapper {
@Select({"