2023.12.1版本

This commit is contained in:
Cool 2023-12-01 20:57:59 +08:00
parent c3fb605ab6
commit a43dd75246
7 changed files with 46 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.example.chat.controller;
import com.example.chat.ChatApplication;
import com.example.chat.dao.UserMapper;
import com.example.chat.dao.chat.ChatMapper;
import com.example.chat.entity.Email;
import com.example.chat.entity.Result;
@ -25,7 +26,8 @@ public class LoginController {
CodeCheck codeCheck;
@Resource
MailUtil mailUtil;
@Resource
UserMapper userMapper;
@PostMapping("/login")
@ -63,4 +65,9 @@ public class LoginController {
System.out.println(email.getEmail());
mailUtil.sendMail(email.getEmail());
}
@PostMapping("/getHead")
public User getHead(@RequestBody User user) throws IOException {
return userMapper.getHead(user.getAccount());
}
}

View File

@ -0,0 +1,19 @@
package com.example.chat.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@Slf4j
@RestController
public class WebSocketInterceptorController {
@GetMapping("/interceptor")
public void interceptor() {
log.info("ws进来咯");
}
}

View File

@ -50,7 +50,17 @@ public class Login implements UserMapper {
public void modifyHead(String pic, String account) throws IOException {
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
sqlSession.update("dao.Login.updateHead",new User("","",account,pic,""));
sqlSession.commit();
sqlSession.close();
}
@Override
public User getHead(String account) throws IOException {
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
User user=sqlSession.selectOne("dao.Login.getHead",account);
sqlSession.close();
return user;
}
}

View File

@ -16,4 +16,6 @@ public interface UserMapper {
public abstract User emailCheck(User user) throws IOException;
public abstract void modifyHead(String Pic,String username) throws IOException;
public abstract User getHead(String account)throws IOException;
}

View File

@ -24,7 +24,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
excludePath.add("/sendCode");
excludePath.add("/register");//注册
excludePath.add("/register");
excludePath.add("/chat/get");
registry.addInterceptor(tokenInterceptor)//注册拦截器
.addPathPatterns("/**")//拦截所有请求
.excludePathPatterns(excludePath);//添加拦截白名单

View File

@ -43,7 +43,7 @@ public class HeadOss {
}
file.transferTo(targetFile);
log.info("成功添加");
String head=username+"/"+fileName;
String head="https://www.oss.coollh.cn/"+username+"/"+fileName;
userMapper.modifyHead(head,username);
Message message=new Message(username,head,"","");
chatMapper.updateMessage(message);

View File

@ -31,4 +31,9 @@
set pic=#{pic}
where account = #{account}
</update>
<select id="getHead" resultType="com.example.chat.entity.User">
select *
from user
where account = #{account}
</select>
</mapper>