diff --git a/.idea/.gitignore b/.idea/.gitignore index 26d33521af10bcc7fd8cea344038eaaeb78d0ef5..73f69e0958611ac6e00bde95641f6699030ad235 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,8 @@ # Default ignored files /shelf/ /workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index efd261bf79519c997d1c2ac4154798d551f022dd..0000000000000000000000000000000000000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -demo \ No newline at end of file diff --git a/.idea/artifacts/demo1_jar.xml b/.idea/artifacts/demo1_jar.xml deleted file mode 100644 index 913fdc94fe2dacc2064428649894e388b14cfbde..0000000000000000000000000000000000000000 --- a/.idea/artifacts/demo1_jar.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/demo1_jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/artifacts/demo_war.xml b/.idea/artifacts/demo_war.xml deleted file mode 100644 index d49390ca49cda6cb4f918f73e04ba8b27a36af96..0000000000000000000000000000000000000000 --- a/.idea/artifacts/demo_war.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - $PROJECT_DIR$/target - - - demo - war - - - - - - - \ No newline at end of file diff --git a/.idea/artifacts/demo_war_exploded.xml b/.idea/artifacts/demo_war_exploded.xml deleted file mode 100644 index a01eec8382974993a97aac3b90471a90da0c9076..0000000000000000000000000000000000000000 --- a/.idea/artifacts/demo_war_exploded.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - $PROJECT_DIR$/target/demo-0.0.1-SNAPSHOT - - - true - demo - war - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 919ce1f1f77253454105acb2aad9997c1047a0e6..0000000000000000000000000000000000000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a179bde3e4e772c29c0c85e53354aa54618..0000000000000000000000000000000000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 3856761c44dc43e8d2f7aac8365806ee1b99a551..cb923d125b4f9158812faf8569f6f8acadd3788e 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,17 +7,16 @@ - + - - + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 63e900193296f8ed911a1b9f5b051cf908099431..aa00ffab7828f4818589659c804ec2cfd99baed3 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 6560a98983ec708cf9d8b5c5c3776d7bd39c475b..0000000000000000000000000000000000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index 78d55c91a536dbda6338ab2171343a1791da97b3..712ab9d985c20018a0c97b93d2148ac1ffe588a5 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -16,15 +16,5 @@ \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0bb498eec10c0e30ddeb5626af3b6b0d000a2c30..9ca532690637596a771395ce0a62dbb2c06c4253 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ 1.8 + 1.6.0-M1 @@ -23,10 +24,7 @@ aliyun-sdk-oss 3.10.2 - - org.springframework.boot - spring-boot-starter-web - + org.springframework.boot @@ -37,17 +35,15 @@ org.springframework.boot spring-boot-starter-data-redis + + org.springframework.boot + spring-boot-starter-websocket + org.springframework.boot spring-boot-starter-test test - - - asm - org.ow2.asm - - mysql @@ -67,10 +63,6 @@ swagger-models io.swagger - - guava - com.google.guava - @@ -98,49 +90,17 @@ org.fisco-bcos web3sdk - 2.3.0 - - - fastjson - com.alibaba - - - commons-lang3 - org.apache.commons - - - jnr-ffi - com.github.jnr - - - org.ethereum - solcJ-all - - + 2.6.4 com.baomidou mybatis-plus-boot-starter 3.2.0 - - org.springframework - spring-web - com.baomidou mybatis-plus-generator 3.2.0 - - - mybatis - org.mybatis - - - mybatis-spring - org.mybatis - - org.springframework.boot @@ -150,8 +110,6 @@ org.springframework.boot spring-boot-starter-web - - org.thymeleaf thymeleaf-spring5 @@ -169,18 +127,24 @@ io.springfox springfox-swagger2 2.9.2 - - - guava - com.google.guava - - io.springfox springfox-swagger-ui 2.9.2 + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + @@ -191,17 +155,49 @@ 2.3.4.RELEASE - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + - - - com.example.DemoApplication - - + 1.8 + + org.apache.maven.plugins + maven-compiler-plugin + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + @@ -228,4 +224,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/Result.java b/src/main/java/com/Result.java index d3931c6d9cad28ac27e2add3d613bf207f39b0c5..8ad3acd666db866b9ce0466a5ee88ff28287a802 100644 --- a/src/main/java/com/Result.java +++ b/src/main/java/com/Result.java @@ -46,7 +46,6 @@ public class Result extends HashMap { return new Result(); } - @Override public Result put(String key, Object value) { super.put(key, value); return this; diff --git a/src/main/java/com/Startapplication.java b/src/main/java/com/Startapplication.java index 15755f985481f33e7762b45746db1e12ae8e1069..9567e8248bec48251a3115f52fdca26d0ff41c42 100644 --- a/src/main/java/com/Startapplication.java +++ b/src/main/java/com/Startapplication.java @@ -14,7 +14,7 @@ //@EnableAutoConfiguration //@MapperScan("com.example.mapper") //public class Startapplication { -// public templates void main(String[] args) { +// public static void main(String[] args) { // SpringApplication.run(Startapplication.class,args); // // } diff --git a/src/main/java/com/bcos/asset/client/EDVclient.java b/src/main/java/com/bcos/asset/client/EDVclient.java index 4644bf9cbbaa9e5a1eb7b7589868323fcfe54709..ed44bcd9cc72d52f8dcb029c3ac136d082d8e6ad 100644 --- a/src/main/java/com/bcos/asset/client/EDVclient.java +++ b/src/main/java/com/bcos/asset/client/EDVclient.java @@ -118,6 +118,7 @@ public class EDVclient { list.add(result.getValue2()); list.add(result.getValue3()); list.add(result.getValue4()); + list.add(result.getValue5()); System.out.println(list); @@ -153,14 +154,8 @@ public class EDVclient { public static void main(String[] args) throws Exception { EDVclient edVclient = new EDVclient(); edVclient.initialize(); - //edVclient.deployAssetAndRecordAddr(); - Evidence evidence = new Evidence(); - evidence.setEvidenceId(5); - evidence.setDepartmentIds("4"); - evidence.setNote("3"); - evidence.setCaseId("12"); - edVclient.put(evidence,"12"); - edVclient.queryEDV("5"); + edVclient.deployAssetAndRecordAddr(); + edVclient.queryEDV("1782"); } } diff --git a/src/main/java/com/example/aop/LogAspect.java b/src/main/java/com/example/aop/LogAspect.java index b96c1cf2649721d2f7b2fc0109358886abbd8adc..51c127041d059046805038cf2478fd5f1ca0f54d 100644 --- a/src/main/java/com/example/aop/LogAspect.java +++ b/src/main/java/com/example/aop/LogAspect.java @@ -17,12 +17,13 @@ import java.util.Arrays; @Aspect @Component public class LogAspect { - @Pointcut("execution(public * com.example.controller.*.*(..))") + //如果想启用websocket服务 需要 && !execution(public * com.example.controller.WebSocket.*(..)) + @Pointcut("execution(public * com.example.controller.*.*(..)) ") public void webLog() { } @Before("webLog()") - public void deBefore(JoinPoint joinPoint) throws Throwable { + public void doBefore(JoinPoint joinPoint) throws Throwable { // 接收到请求,记录请求内容 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); @@ -66,4 +67,4 @@ public class LogAspect { return null; } } -} \ No newline at end of file +} diff --git a/src/main/java/com/example/config/BcosConfig.java b/src/main/java/com/example/config/BcosConfig.java index d86644a6775c6142389bdd3bce83a27d069fd602..46457598b2af9d6c04435f877435418c37d38ad2 100644 --- a/src/main/java/com/example/config/BcosConfig.java +++ b/src/main/java/com/example/config/BcosConfig.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; * @author: 谢佳辉 * @date 2021/5/9 4:16 下午 */ -@Component +//@Component public class BcosConfig { public static EDVclient edVclient; @Bean @@ -17,8 +17,9 @@ public class BcosConfig { if(edVclient==null){ edVclient = new EDVclient(); edVclient.initialize(); + edVclient.deployAssetAndRecordAddr(); } - return edVclient; + return edVclient; } } diff --git a/src/main/java/com/example/config/RedisConfig.java b/src/main/java/com/example/config/RedisConfig.java index fd4fa6611cc52369c06074a407dad38ebbea1aa8..5f1675ccb2db2c13187377f632ef0f0aac403070 100644 --- a/src/main/java/com/example/config/RedisConfig.java +++ b/src/main/java/com/example/config/RedisConfig.java @@ -1,5 +1,9 @@ package com.example.config; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.DateSerializer; +import net.sf.jsqlparser.expression.DateTimeLiteralExpression; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.cache.CacheManager; @@ -10,10 +14,9 @@ import org.springframework.data.redis.cache.RedisCacheConfiguration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.RedisSerializationContext; -import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.data.redis.serializer.*; + +import java.text.DateFormatSymbols; /** * redis客户端配置 @@ -30,6 +33,7 @@ public class RedisConfig { private final Jackson2JsonRedisSerializer jsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); + /** * 配置key,value的序列化方式 */ diff --git a/src/main/java/com/example/config/ShiroConfig.java b/src/main/java/com/example/config/ShiroConfig.java index 824bc78b5250d68311b91b7380a70972b03885ec..2946de21e09b1c7a22c87ec3d89e2011f7ab3e18 100644 --- a/src/main/java/com/example/config/ShiroConfig.java +++ b/src/main/java/com/example/config/ShiroConfig.java @@ -33,8 +33,6 @@ public class ShiroConfig { //filterMap.put("/cases/*","authc"); //filterMap.put("/evidence/postevidence","perms[user:add]"); //filterMap.put("/user/update","perms[user:update]"); - filterMap.put("/cyy/test1","anon"); - filterMap.put("/login.html","anon"); bean.setFilterChainDefinitionMap(filterMap); bean.setFilterChainDefinitionMap(filterMap); bean.setLoginUrl("/login/ulogins"); diff --git a/src/main/java/com/example/config/WebSocketConfig.java b/src/main/java/com/example/config/WebSocketConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..e6c5160c8c988eb9f4025e0a12de782ce11ea6fc --- /dev/null +++ b/src/main/java/com/example/config/WebSocketConfig.java @@ -0,0 +1,23 @@ +package com.example.config; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +import javax.websocket.server.ServerEndpoint; + +/** + * @author: HoweverXz + * @Date: 2021/9/22 + */ + +//@EnableWebSocket +//@Configuration +//public class WebSocketConfig { +// @Bean +// public ServerEndpointExporter serverEndpointExporter(ApplicationContext context){ +// return new ServerEndpointExporter(); +// } +//} diff --git a/src/main/java/com/example/controller/CasesController.java b/src/main/java/com/example/controller/CasesController.java index 23f01db32e2ef59602e56ae2fe6c6c437eb7b38c..3dbf307d5f397f956a3c3389bda2cf04e28aaec9 100644 --- a/src/main/java/com/example/controller/CasesController.java +++ b/src/main/java/com/example/controller/CasesController.java @@ -1,6 +1,7 @@ package com.example.controller; +import com.example.model.Cases; import com.example.model.Login; import com.example.model.form.AddCreateForm; import com.example.model.form.CaseForm; @@ -58,19 +59,7 @@ public class CasesController { return ResultVO.error("未登录"); } return new ResultVO(iCaseService.findCaseByType(caseForm,currentlogin)); - } - @ApiOperation(value = "按ID获取案件") - @PostMapping("getCaseById") - public ResultVO getCaseById(@RequestBody CaseForm caseForm){ - Login currentlogin; - try{ - Subject subject = SecurityUtils.getSubject(); - }catch (RuntimeException e){ - e.printStackTrace(); - return ResultVO.error("未登录"); - } - return new ResultVO(iCaseService.findCaseById(caseForm.getCaseId())); } @ApiOperation(value = "创建案件") @PostMapping("addCase") @@ -84,4 +73,11 @@ public class CasesController { return iCaseService.updateCase(updateCase.getCaseId()); } + + @ApiOperation(value = "根据id") + @GetMapping("get/{caseId}") + public ResultVO getById(@PathVariable("caseId") String caseId){ + Cases c = iCaseService.getByCaseId(caseId); + return new ResultVO(c); + } } diff --git a/src/main/java/com/example/controller/EvidenceController.java b/src/main/java/com/example/controller/EvidenceController.java index f6d753c5f2a54a29faa8f1967b6285f4a4c118f0..c7b7756e730783f4bac53e9e6c60bd6f95a07f76 100644 --- a/src/main/java/com/example/controller/EvidenceController.java +++ b/src/main/java/com/example/controller/EvidenceController.java @@ -25,9 +25,9 @@ import java.io.InputStream; * @author astupidcoder * @since 2021-01-12 */ -@CrossOrigin -@RestController -@RequestMapping("/evidence") +//@CrossOrigin +//@RestController +//@RequestMapping("/evidence") public class EvidenceController { @Autowired @@ -47,6 +47,10 @@ public class EvidenceController { public ResultVO addEvidence( PostEvidence postEvidence) throws Exception { + InputStream inputStream = postEvidence.getEvidenceUrl().getInputStream(); + BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); + bufferedInputStream.read(); + System.out.println(bufferedInputStream); Subject subject = SecurityUtils.getSubject(); Login currentlogin =(Login)subject.getPrincipal(); System.out.println("==="+postEvidence.getEvidenceUrl()); diff --git a/src/main/java/com/example/controller/MessageCommunicationController.java b/src/main/java/com/example/controller/MessageCommunicationController.java new file mode 100644 index 0000000000000000000000000000000000000000..44507c4f72f23ef89db850d0984af2e368581992 --- /dev/null +++ b/src/main/java/com/example/controller/MessageCommunicationController.java @@ -0,0 +1,137 @@ +package com.example.controller; + +import com.alibaba.fastjson.JSON; +import com.example.model.form.MessageCommunication; +import com.example.rmso.ResultCode; +import com.example.rmso.ResultVO; +import com.example.util.RedisUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +/** + * @author: HoweverXz + * @Date: 2021/9/19 + * 纸上得来终觉浅 绝知此事要躬行 + */ +//初步实现 关闭了EvidenceController、BcosConfig、EvidenceServiceImpl(有关区块链部分) +@CrossOrigin +@RestController +@Api("消息系统-用户间互发消息") +public class MessageCommunicationController { + //redis模式 + @Autowired + public RedisUtil redisUtil; + + //redis实现 + @ApiOperation(value = "发送出一条消息") + @PostMapping("/messagecommunication") + public ResultVO redisMessagePost(@RequestBody MessageCommunication messageCommunication) { + try { + messageCommunication.setUUID(UUID.randomUUID().toString()); + String sendto = messageCommunication.getSendto(); + if (null != sendto && !sendto.equals("")) { + String key1 = messageCommunication.getId() + ":" + messageCommunication.getUUID() + ":" + sendto; + if (redisUtil.setIfAbsent(key1, messageCommunication)) { + return new ResultVO(ResultCode.SUCCESS); + } else { + return new ResultVO(ResultCode.FAILED,"已存在该消息"); + } + } else { + String key2 = messageCommunication.getId() + ":" + messageCommunication.getUUID() + ":all"; + if (redisUtil.setIfAbsent(key2, messageCommunication)) { + return new ResultVO(ResultCode.SUCCESS); + } else { + return new ResultVO(ResultCode.FAILED,"已存在该消息"); + } + } + } catch (Exception e) { + e.printStackTrace(); + return new ResultVO(ResultCode.ERROR,"请检查传入参数"); + } + } + + /* + 获取信息 + id:* 自己发送出去 + *:id 接收到来自别人的信息 + *:all 接收到的全体信息 + */ + @ApiOperation(value = "获取消息") + @GetMapping(value = "/messagecommunication/{id}") + public ResultVO redisMessageGet(@PathVariable("id") String id) { + try { + 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 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({"