2023.12.1版本
This commit is contained in:
parent
c33896f298
commit
ea2b9c7256
|
@ -1,4 +1,4 @@
|
|||
package com.example.chat.service.websocket;
|
||||
package com.example.chat.controller.websocket;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.example.chat.dao.chat.ChatMapper;
|
|
@ -45,4 +45,12 @@ public class Login implements UserMapper {
|
|||
sqlSession.close();
|
||||
return returnUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyHead(String pic, String account) throws IOException {
|
||||
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
|
||||
sqlSession.update("dao.Login.updateHead",new User("","",account,pic,""));
|
||||
sqlSession.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class Test01 implements CommandLineRunner {
|
|||
public void run(String... args) throws Exception {
|
||||
while (true) {
|
||||
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
||||
User user = sqlSession.selectOne("dao.Login.getUser", "123");
|
||||
User user = sqlSession.selectOne("dao.Login.getUser", "img/123/123");
|
||||
if (user != null) {
|
||||
System.out.println(user);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,6 @@ public interface UserMapper {
|
|||
|
||||
public abstract User getUser(User user) throws IOException;
|
||||
public abstract User emailCheck(User user) throws IOException;
|
||||
|
||||
public abstract void modifyHead(String Pic,String username) throws IOException;
|
||||
}
|
||||
|
|
|
@ -14,5 +14,5 @@ public interface ChatMapper {
|
|||
|
||||
public abstract List<Message> getMessage() throws IOException;
|
||||
|
||||
public abstract void updateMessage(UpdateMessage updateMessage) throws IOException;
|
||||
public abstract void updateMessage(Message message) throws IOException;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ public class ChatMessage implements ChatMapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateMessage(UpdateMessage updateMessage) throws IOException {
|
||||
public void updateMessage(Message message) throws IOException {
|
||||
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
||||
sqlSession.update("dao.chat.Message.updateMessage", updateMessage);
|
||||
sqlSession.update("dao.chat.Message.updateHead", message);
|
||||
sqlSession.commit();
|
||||
sqlSession.close();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ public class User {
|
|||
private String username;
|
||||
private String password;
|
||||
private String account;
|
||||
|
||||
private String pic;
|
||||
private String email;
|
||||
|
||||
|
||||
|
@ -18,6 +18,14 @@ public class User {
|
|||
this.email = email;
|
||||
}
|
||||
|
||||
public User(String username, String password, String account, String pic, String email) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.account = account;
|
||||
this.pic = pic;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取
|
||||
*
|
||||
|
@ -93,4 +101,20 @@ public class User {
|
|||
public String toString() {
|
||||
return "User{username = " + username + ", password = " + password + ", account = " + account + ", email = " + email + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取
|
||||
* @return pic
|
||||
*/
|
||||
public String getPic() {
|
||||
return pic;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置
|
||||
* @param pic
|
||||
*/
|
||||
public void setPic(String pic) {
|
||||
this.pic = pic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class LoginService {
|
|||
returnInt = 1002;
|
||||
}
|
||||
} else {
|
||||
requestUser.setUsername("用户");
|
||||
requestUser.setUsername(requestUser.getAccount());
|
||||
userTable.addUser(requestUser);
|
||||
returnInt = 200;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
</select>
|
||||
|
||||
<insert id="addUser">
|
||||
insert into user(account, password, username, email)
|
||||
values (#{account}, #{password}, #{username}, #{email});
|
||||
insert into user(account, password, username, email, pic)
|
||||
values (#{account}, #{password}, #{username}, #{email}, #{pic});
|
||||
</insert>
|
||||
<delete id="delUser">
|
||||
delete
|
||||
|
@ -26,4 +26,9 @@
|
|||
set password=#{password} and username = #{username} and email = #{email}
|
||||
where account = #{account};
|
||||
</update>
|
||||
<update id="updateHead" parameterType="com.example.chat.entity.User">
|
||||
update user
|
||||
set pic=#{pic}
|
||||
where account = #{account}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
values (#{nickname}, #{pic}, #{sendTime}, #{message})
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="com.example.chat.entity.chat.UpdateMessage">
|
||||
<update id="updateHead" parameterType="com.example.chat.entity.chat.Message">
|
||||
update message
|
||||
set nickname=#{newName} and pic = #{newPic}
|
||||
set and pic = #{pic}
|
||||
where nickname = #{nickname}
|
||||
and pic = #{pic}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue