浏览代码

金聪提交

jc 1 周之前
父节点
当前提交
42b47e0dcf

+ 0 - 0
images/fuben/1.txt


+ 39 - 4
pom.xml

@@ -12,6 +12,8 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <spring-boot.version>2.6.13</spring-boot.version>
+        <kafka.version>2.6.6</kafka.version>
+        <kafka.client.version>2.5.1</kafka.client.version>
     </properties>
     <dependencies>
         <dependency>
@@ -94,10 +96,10 @@
             <optional>true</optional>
         </dependency>
 
-<!--        <dependency>-->
-<!--            <groupId>org.springframework.boot</groupId>-->
-<!--            <artifactId>spring-boot-starter-websocket</artifactId>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
 
 <!--        引入虹软jar包-->
         <dependency>
@@ -114,6 +116,39 @@
             <version>7.1.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.kafka</groupId>
+            <artifactId>spring-kafka</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.kafka</groupId>
+                    <artifactId>kafka-clients</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.kafka</groupId>
+            <artifactId>kafka-clients</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+            <version>2.5.1</version>
+        </dependency>
+
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-devtools</artifactId>-->
+<!--            <scope>runtime</scope>-->
+<!--            <optional>true</optional>-->
+<!--        </dependency>-->
+
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
+<!--        </dependency>-->
+
     </dependencies>
     <dependencyManagement>
         <dependencies>

+ 131 - 0
src/main/java/com/neko/chat/WebSocketServer.java

@@ -0,0 +1,131 @@
+package com.neko.chat;
+
+import com.alibaba.fastjson2.JSON;
+import com.neko.config.SpringConfigurator;
+import com.neko.domain.dto.messageDto.SendMessageContentDto;
+import com.neko.service.MessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+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.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+@Component
+@ServerEndpoint(value = "/ws/{receiverId}/{userId}",configurator = SpringConfigurator.class)
+public class WebSocketServer {
+    private String receiverId;
+    private String token;
+    @Autowired
+    MessageService chatService;
+    //存放会话对象
+    public static ConcurrentMap<String, Session> sessionMap = new ConcurrentHashMap<>();
+
+
+
+    /**
+     * 连接建立成功调用的方法
+     */
+    @OnOpen
+    public void onOpen(Session session, @PathParam("userId") String userId) {
+        System.out.println("客户端:" + userId + "建立连接");
+        sessionMap.put(userId, session);
+        System.out.println("当前在线人数:" + sessionMap.size());
+    }
+
+    /**
+     * 收到客户端消息后调用的方法
+     *
+     * @param message 客户端发送过来的消息
+     */
+    @OnMessage
+    public void onMessage(String message, @PathParam("userId") String userId,@PathParam("receiverId") String receiverId) {
+//        sendToClient(userId,friendId,message);
+        System.out.println("客服端接受到用户:" + userId + "向好友:"+receiverId+"发送的消息:" + message);
+        Map<String, String> map = JSON.parseObject(message, Map.class);
+        SendMessageContentDto sendMessageContent =  new SendMessageContentDto(userId, receiverId, map.get("content"));
+
+        boolean success = chatService.sendMessage(sendMessageContent);
+        if (success){
+            System.out.println("发送消息成功");
+        }else {
+            System.out.println("发送消息失败");
+        }
+    }
+
+    /**
+     * 连接关闭调用的方法
+     *
+     * @param userId
+     */
+    @OnClose
+    public void onClose(@PathParam("userId") Integer userId) {
+        System.out.println("客户端:" + userId + "关闭连接");
+        sessionMap.remove(userId);
+    }
+
+    /**
+     * 群发
+     *
+     * @param message
+     */
+    public void sendToAllClient(String message) {
+        Collection<Session> sessions = sessionMap.values();
+        for (Session session : sessions) {
+            try {
+                System.out.println("服务端向所有客户端发送消息:" + message);
+                session.getBasicRemote().sendText(message);
+            } catch (Exception e) {}
+        }
+    }
+
+    /**
+     * 私发
+     *
+     * @param message
+     */
+    public static void sendToClient(Integer userId,Integer friendId,String message) {
+        Session session = sessionMap.get(friendId);
+        if (session != null){
+            try {
+                System.out.println("用户:" + userId + "向好友:"+friendId+"发送了消息:" + message);
+                Map<String, Object> map = new HashMap<>();
+                map.put("message",message);
+                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
+                map.put("time",sdf.format(new Date()));
+                String jsonString = JSON.toJSONString(map);
+                session.getBasicRemote().sendText(jsonString);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * AI发送的信息
+     */
+    public static void aiSendToClient(Integer userId,String message) {
+        Session session = sessionMap.get(userId);
+        if (session != null){
+            try {
+                System.out.println("AI向:" + userId +"发送了消息:" + message);
+                Map<String, Object> map = new HashMap<>();
+                map.put("message",message);
+                map.put("type","waring");
+                String jsonString = JSON.toJSONString(map);
+                session.getBasicRemote().sendText(jsonString);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 24 - 0
src/main/java/com/neko/config/SpringConfigurator.java

@@ -0,0 +1,24 @@
+package com.neko.config;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.server.ServerEndpointConfig;
+
+@Component
+public class SpringConfigurator extends ServerEndpointConfig.Configurator implements ApplicationContextAware {
+
+    private static ApplicationContext applicationContext;
+
+    @Override
+    public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
+        return applicationContext.getBean(endpointClass);
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        SpringConfigurator.applicationContext = applicationContext;
+    }
+}

+ 46 - 0
src/main/java/com/neko/config/WebSocketConfig.java

@@ -0,0 +1,46 @@
+package com.neko.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
+
+/**
+ * @Title: WebSocketConfig
+ * @Package: com.jiayuan.common.config
+ * @Description: websocket配置
+ * @Author: xmc
+ * @Date: 创建时间 2024-04-24
+ */
+@Configuration
+public class WebSocketConfig {
+
+    /**
+     * 自动注册使用了@ServerEndpoint注解声明的Websocket endpoint
+     *
+     * @return
+     */
+
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+        return new ServerEndpointExporter();
+    }
+
+    /**
+     * 通信文本消息和二进制缓存区大小
+     * 避免对接 第三方 报文过大时,Websocket 1009 错误
+     *
+     * @return
+     */
+
+    @Bean
+    public ServletServerContainerFactoryBean createWebSocketContainer() {
+        ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
+        // 在此处设置bufferSize
+        container.setMaxTextMessageBufferSize(10240000);
+        container.setMaxBinaryMessageBufferSize(10240000);
+        container.setMaxSessionIdleTimeout(15 * 60000L);
+        return container;
+    }
+}
+

+ 16 - 0
src/main/java/com/neko/consumer/Consumer.java

@@ -0,0 +1,16 @@
+package com.neko.consumer;
+
+import com.alibaba.fastjson2.JSON;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class Consumer {
+    @KafkaListener(topics = "offending_user_topic")
+    public void job1(String msg){
+        System.out.println("消费了:"+msg);
+        Map map = JSON.parseObject(msg, Map.class);
+    }
+}

+ 11 - 0
src/main/java/com/neko/controller/FriendController.java

@@ -7,6 +7,7 @@ import com.neko.mapper.FriendRequestMapper;
 import com.neko.service.FriendRelationService;
 import com.neko.service.FriendRequestService;
 import com.neko.utils.ResultVo;
+import org.apache.kafka.common.protocol.types.Field;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -57,4 +58,14 @@ public class FriendController {
         return friendRelationService.findFriendList(requestFriend);
     }
 
+    /**
+     * 通过手机号查找要添加的好友
+     * @param phone
+     * @return
+     */
+    @RequestMapping("find_phone_user")
+    public ResultVo findPhoneUser(String phone){
+        return friendRelationService.findPhoneUser(phone);
+    }
+
 }

+ 7 - 10
src/main/java/com/neko/controller/MessageController.java

@@ -8,6 +8,7 @@ import com.neko.utils.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -20,16 +21,6 @@ public class MessageController {
     @Autowired
     MessageService messageService;
 
-    /**
-     * 消息发送(文本消息)
-     * @param dto
-     * @return
-     **/
-    @RequestMapping("sendMessageWen")
-    public ResultVo sendMessage(@RequestBody SendMessageContentDto dto){
-        return messageService.sendMessage(dto);
-    }
-
     @RequestMapping("sendMessageFile")
     public ResultVo sendMessageFile(SendMessageVoidDto dto){
         try {
@@ -39,4 +30,10 @@ public class MessageController {
             return ResultVo.error(ApiServiceExceptionEnum.CAN_SHU_YICHANG);
         }
     }
+
+    @RequestMapping("chatHistory")
+    public ResultVo chatHistory(@RequestParam("userId") String userId, @RequestParam("receiverId") String receiverId){
+        System.err.println("userId:"+userId+"receiverId:"+receiverId);
+        return messageService.findAll(userId,  receiverId);
+    }
 }

+ 5 - 0
src/main/java/com/neko/controller/UserController.java

@@ -162,4 +162,9 @@ public class UserController {
     public ResultVo rlsb(@RequestParam("image") MultipartFile filePath){
         return userService.rlsb(filePath);
     }
+
+    @RequestMapping("friendAll")
+    public ResultVo friendAll(String token){
+        return userService.friendAll(token);
+    }
 }

+ 4 - 0
src/main/java/com/neko/domain/dto/messageDto/SendMessageContentDto.java

@@ -1,6 +1,8 @@
 package com.neko.domain.dto.messageDto;
 
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import org.springframework.web.multipart.MultipartFile;
 
 /**
@@ -8,6 +10,8 @@ import org.springframework.web.multipart.MultipartFile;
  * @Author neko
  **/
 @Data
+@AllArgsConstructor
+@NoArgsConstructor
 public class SendMessageContentDto {
     private String senderId;//发送者
     private String receiverId;//接受者

+ 3 - 0
src/main/java/com/neko/domain/pojo/FriendRelation.java

@@ -69,4 +69,7 @@ public class FriendRelation implements Serializable {
 
     @TableField(exist = false)
     private UserProfile userProfiles;
+
+    @TableField(exist = false)
+    private String letter;
 }

+ 8 - 0
src/main/java/com/neko/domain/pojo/Message.java

@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.util.Date;
+
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 /**
  * 消息主表
@@ -14,6 +17,8 @@ import lombok.Data;
  */
 @TableName(value ="message")
 @Data
+@AllArgsConstructor
+@NoArgsConstructor
 public class Message implements Serializable {
     /**
      * 消息id
@@ -73,4 +78,7 @@ public class Message implements Serializable {
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
+
+    @TableField(exist = false)
+    private MessageContentText MessageContentText;
 }

+ 2 - 0
src/main/java/com/neko/service/FriendRelationService.java

@@ -19,4 +19,6 @@ public interface FriendRelationService extends IService<FriendRelation> {
     ResultVo handleFriendHttp(FriendTongDto dto);
 
     ResultVo findFriendList(RequestFriendVo requestFriend);
+
+    ResultVo findPhoneUser(String phone);
 }

+ 4 - 1
src/main/java/com/neko/service/MessageService.java

@@ -5,6 +5,7 @@ import com.neko.domain.dto.messageDto.SendMessageContentDto;
 import com.neko.domain.dto.messageDto.SendMessageVoidDto;
 import com.neko.domain.pojo.Message;
 import com.neko.utils.ResultVo;
+import org.apache.ibatis.annotations.Param;
 
 /**
 * @author 金聪
@@ -13,7 +14,9 @@ import com.neko.utils.ResultVo;
 */
 public interface MessageService extends IService<Message> {
 
-    ResultVo sendMessage(SendMessageContentDto dto);
+    Boolean sendMessage(SendMessageContentDto dto);
 
     ResultVo sendMessageFile(SendMessageVoidDto dto);
+
+    ResultVo findAll(@Param("userId") String userId, @Param("receiverId") String receiverId);
 }

+ 2 - 0
src/main/java/com/neko/service/UserService.java

@@ -56,4 +56,6 @@ public interface UserService extends IService<User> {
     ResultVo wxLogin(WxLoginDto dto);
 
     ResultVo rlsb(MultipartFile filePath);
+
+    ResultVo friendAll(String token);
 }

+ 16 - 0
src/main/java/com/neko/service/impl/FriendRelationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.neko.service.impl;
 
+import cn.hutool.setting.profile.Profile;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.neko.domain.dto.friendDto.FriendDto;
@@ -151,6 +152,21 @@ public class FriendRelationServiceImpl extends ServiceImpl<FriendRelationMapper,
 
         return ResultVo.success(ApiServiceExceptionEnum.RESULT_SUCCES,list);
     }
+
+    @Override
+    public ResultVo findPhoneUser(String phone) {
+        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(User::getPhone,phone);
+        User user = userMapper.selectOne(queryWrapper);
+        if(user==null){
+            return ResultVo.error(ApiServiceExceptionEnum.RESULT_ERROR);
+        }
+        QueryWrapper<UserProfile> wrapper = new QueryWrapper<>();
+        wrapper.lambda().eq(UserProfile::getUserId,user.getId());
+        UserProfile profile = userProfileMapper.selectOne(wrapper);
+        user.setProfiles(profile);
+        return ResultVo.success(ApiServiceExceptionEnum.RESULT_SUCCES,user);
+    }
 }
 
 

+ 24 - 2
src/main/java/com/neko/service/impl/MessageServiceImpl.java

@@ -1,6 +1,8 @@
 package com.neko.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.annotation.JsonSubTypes;
 import com.neko.domain.dto.messageDto.SendMessageContentDto;
@@ -24,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
+import java.util.List;
 import java.util.UUID;
 
 /**
@@ -46,7 +49,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message>
     MessageContentMediaMapper messageContentMediaMapper;
 
     @Override
-    public ResultVo sendMessage(SendMessageContentDto dto) {
+    public Boolean sendMessage(SendMessageContentDto dto) {
         //消息主表
         Message message = new Message();
         message.setId(String.valueOf(SnowflakeUtil.nextId()));
@@ -76,7 +79,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message>
         messageMapper.insert(message);
         messageContentTextMapper.insert(messageContentText);
 
-        return ResultVo.success("发送成功");
+        return true;
     }
 
     @Override
@@ -151,6 +154,25 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message>
         }
 
     }
+
+    @Override
+    public ResultVo findAll(String userId, String receiverId) {
+
+        List<Message> messages = messageMapper.selectList(new LambdaQueryWrapper<Message>()
+                .eq(Message::getSenderId, userId)
+                .eq(Message::getReceiverId, receiverId));
+        List<Message> messages1 = messageMapper.selectList(new LambdaQueryWrapper<Message>()
+                .eq(Message::getSenderId, receiverId)
+                .eq(Message::getReceiverId, userId));
+        for (Message msg : messages1){
+            messages.add(msg);
+        }
+        for (Message message : messages) {
+            message.setMessageContentText(messageContentTextMapper.selectById(message.getContentId()));
+        }
+        System.err.println("messages"+messages);
+        return ResultVo.success(messages);
+    }
 }
 
 

+ 32 - 0
src/main/java/com/neko/service/impl/UserServiceImpl.java

@@ -10,10 +10,12 @@ import com.neko.domain.dto.userDto.WxLoginDto;
 import com.neko.domain.dto.friendDto.UserPwdDto;
 import com.neko.domain.dto.userDto.PhoneLoginDto;
 import com.neko.domain.dto.userDto.YanDto;
+import com.neko.domain.pojo.FriendRelation;
 import com.neko.domain.pojo.User;
 import com.neko.domain.pojo.UserLog;
 import com.neko.domain.pojo.UserProfile;
 import com.neko.face.FaceUtil;
+import com.neko.mapper.FriendRelationMapper;
 import com.neko.mapper.UserLogMapper;
 import com.neko.mapper.UserProfileMapper;
 import com.neko.miniofile.service.FileService;
@@ -22,7 +24,10 @@ import com.neko.mapper.UserMapper;
 import com.neko.utils.*;
 import io.jsonwebtoken.Claims;
 import lombok.extern.slf4j.Slf4j;
+import net.sourceforge.pinyin4j.PinyinHelper;
 import org.apache.http.HttpResponse;
+import org.apache.kafka.common.protocol.types.Field;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -37,6 +42,7 @@ import java.net.InetAddress;
 import java.nio.charset.StandardCharsets;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 /**
 * @author 金聪
@@ -59,6 +65,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
     UserLogMapper userLogMapper;
     @Autowired
     FileService fileService;
+    @Autowired
+    FriendRelationMapper friendRelationMapper;
 
     @Override
     public ResultVo phoenLogin(PhoneLoginDto dto) throws Exception {
@@ -535,6 +543,30 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
             return ResultVo.error(ApiServiceExceptionEnum.LOGIN_ERROR);
         }
     }
+
+    @Override
+    public ResultVo friendAll(String token) {
+        Claims claims = AppJwtUtil.getClaimsBody(token);
+        String id = claims.get("id").toString();
+        QueryWrapper<FriendRelation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(FriendRelation::getUserId,id);
+        List<FriendRelation> list = friendRelationMapper.selectList(queryWrapper);
+        for(FriendRelation f : list){
+            if(f.getRemark()==null || f.getRemark().isEmpty()) return ResultVo.success("#");
+            char firstChar = f.getRemark().charAt(0);
+            if(Character.toString(firstChar).matches("[\\u4E08-\\u9FA5]")){
+                String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(firstChar);
+                if(pinyinArray != null && pinyinArray.length>0){
+                    f.setLetter(pinyinArray[0].substring(0,1).toUpperCase());
+                }
+            }
+        }
+        List<FriendRelation> fList = list.stream()
+                .sorted(Comparator.comparing(FriendRelation::getLetter))
+                .collect(Collectors.toList());
+
+        return ResultVo.success(ApiServiceExceptionEnum.RESULT_SUCCES,fList);
+    }
 }
 
 

+ 10 - 1
src/main/resources/application.yml

@@ -16,6 +16,15 @@ spring:
   redis:
     host: 127.0.0.1
     port: 6379
+  kafka:
+    bootstrap-servers: 47.95.170.81:9092
+    producer:
+      key-serializer: org.apache.kafka.common.serialization.StringSerializer
+      value-serializer: org.apache.kafka.common.serialization.StringSerializer
+    consumer:
+      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+      group-id: nekomimi
 mybatis-plus:
   mapper-locations: classpath:/mapper/*.xml
   type-aliases-package: com.neko.domain.pojo
@@ -26,7 +35,7 @@ gitee:
 arcsoft:
   appid: 7QqJ1iFejXvwgt2UqVGM7aSMknu5SpXJEoixwVjUMJNn
   sdkkey: Bs5JhkCG7NDRSakHoQkmk2Ys7LbpvJ7X9VvMLEVSrMgi
-  libpath: D:\kee\renlianshibie\ArcSoft_ArcFace_Java_Windows_x64_V3.0\libs\WIN64
+  libpath: D:\javatext\Zg5\week1\nekomimi\libs\WIN64
 minio:
   endpoint: http://47.95.170.81:19000
   accesskey: minioadmin

+ 5 - 15
src/test/java/com/neko/NekomimiApplicationTests.java

@@ -2,28 +2,18 @@ package com.neko;
 
 import com.neko.domain.pojo.Testdd;
 import com.neko.domain.pojo.User;
+import com.neko.utils.ResultVo;
+import net.sourceforge.pinyin4j.PinyinHelper;
+import org.apache.kafka.common.protocol.types.Field;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
+import java.util.*;
 
 @SpringBootTest
 class NekomimiApplicationTests {
 
     public static void main(String[] args) {
-        String s = "fghjhsdjkgh.png";
-        int lastDotIndex = s.lastIndexOf('.');
-        String extension = s.substring(lastDotIndex + 1);
-        System.out.println(extension);
-//        String v = s.substring(s.lastIndexOf("."));
-//        if(extension.contains("jpg") || extension.contains("png")){
-//            System.out.println(111);
-//        }else{
-//            System.out.println(222);
-//        }
+
     }
 
 }