2023.12.1版本
This commit is contained in:
parent
c3fb605ab6
commit
a43dd75246
|
@ -1,6 +1,7 @@
|
||||||
package com.example.chat.controller;
|
package com.example.chat.controller;
|
||||||
|
|
||||||
import com.example.chat.ChatApplication;
|
import com.example.chat.ChatApplication;
|
||||||
|
import com.example.chat.dao.UserMapper;
|
||||||
import com.example.chat.dao.chat.ChatMapper;
|
import com.example.chat.dao.chat.ChatMapper;
|
||||||
import com.example.chat.entity.Email;
|
import com.example.chat.entity.Email;
|
||||||
import com.example.chat.entity.Result;
|
import com.example.chat.entity.Result;
|
||||||
|
@ -25,7 +26,8 @@ public class LoginController {
|
||||||
CodeCheck codeCheck;
|
CodeCheck codeCheck;
|
||||||
@Resource
|
@Resource
|
||||||
MailUtil mailUtil;
|
MailUtil mailUtil;
|
||||||
|
@Resource
|
||||||
|
UserMapper userMapper;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
|
@ -63,4 +65,9 @@ public class LoginController {
|
||||||
System.out.println(email.getEmail());
|
System.out.println(email.getEmail());
|
||||||
mailUtil.sendMail(email.getEmail());
|
mailUtil.sendMail(email.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getHead")
|
||||||
|
public User getHead(@RequestBody User user) throws IOException {
|
||||||
|
return userMapper.getHead(user.getAccount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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进来咯");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -50,7 +50,17 @@ public class Login implements UserMapper {
|
||||||
public void modifyHead(String pic, String account) throws IOException {
|
public void modifyHead(String pic, String account) throws IOException {
|
||||||
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
|
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
sqlSession.update("dao.Login.updateHead",new User("","",account,pic,""));
|
sqlSession.update("dao.Login.updateHead",new User("","",account,pic,""));
|
||||||
|
sqlSession.commit();
|
||||||
sqlSession.close();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,6 @@ public interface UserMapper {
|
||||||
public abstract User emailCheck(User user) throws IOException;
|
public abstract User emailCheck(User user) throws IOException;
|
||||||
|
|
||||||
public abstract void modifyHead(String Pic,String username) throws IOException;
|
public abstract void modifyHead(String Pic,String username) throws IOException;
|
||||||
|
public abstract User getHead(String account)throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
|
||||||
excludePath.add("/sendCode");
|
excludePath.add("/sendCode");
|
||||||
excludePath.add("/register");//注册
|
excludePath.add("/register");//注册
|
||||||
excludePath.add("/register");
|
excludePath.add("/register");
|
||||||
excludePath.add("/chat/get");
|
|
||||||
registry.addInterceptor(tokenInterceptor)//注册拦截器
|
registry.addInterceptor(tokenInterceptor)//注册拦截器
|
||||||
.addPathPatterns("/**")//拦截所有请求
|
.addPathPatterns("/**")//拦截所有请求
|
||||||
.excludePathPatterns(excludePath);//添加拦截白名单
|
.excludePathPatterns(excludePath);//添加拦截白名单
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class HeadOss {
|
||||||
}
|
}
|
||||||
file.transferTo(targetFile);
|
file.transferTo(targetFile);
|
||||||
log.info("成功添加");
|
log.info("成功添加");
|
||||||
String head=username+"/"+fileName;
|
String head="https://www.oss.coollh.cn/"+username+"/"+fileName;
|
||||||
userMapper.modifyHead(head,username);
|
userMapper.modifyHead(head,username);
|
||||||
Message message=new Message(username,head,"","");
|
Message message=new Message(username,head,"","");
|
||||||
chatMapper.updateMessage(message);
|
chatMapper.updateMessage(message);
|
||||||
|
|
|
@ -31,4 +31,9 @@
|
||||||
set pic=#{pic}
|
set pic=#{pic}
|
||||||
where account = #{account}
|
where account = #{account}
|
||||||
</update>
|
</update>
|
||||||
|
<select id="getHead" resultType="com.example.chat.entity.User">
|
||||||
|
select *
|
||||||
|
from user
|
||||||
|
where account = #{account}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue