2023.12.1版本

This commit is contained in:
Cool 2023-12-01 13:44:14 +08:00
parent c33896f298
commit ea2b9c7256
10 changed files with 50 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package com.example.chat.service.websocket; package com.example.chat.controller.websocket;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.example.chat.dao.chat.ChatMapper; import com.example.chat.dao.chat.ChatMapper;

View File

@ -45,4 +45,12 @@ public class Login implements UserMapper {
sqlSession.close(); sqlSession.close();
return returnUser; 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();
}
} }

View File

@ -16,7 +16,7 @@ public class Test01 implements CommandLineRunner {
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
while (true) { while (true) {
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession(); 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) { if (user != null) {
System.out.println(user); System.out.println(user);
} }

View File

@ -14,4 +14,6 @@ public interface UserMapper {
public abstract User getUser(User user) throws IOException; public abstract User getUser(User user) throws IOException;
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;
} }

View File

@ -14,5 +14,5 @@ public interface ChatMapper {
public abstract List<Message> getMessage() throws IOException; public abstract List<Message> getMessage() throws IOException;
public abstract void updateMessage(UpdateMessage updateMessage) throws IOException; public abstract void updateMessage(Message message) throws IOException;
} }

View File

@ -20,9 +20,9 @@ public class ChatMessage implements ChatMapper {
} }
@Override @Override
public void updateMessage(UpdateMessage updateMessage) throws IOException { public void updateMessage(Message message) throws IOException {
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession(); SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
sqlSession.update("dao.chat.Message.updateMessage", updateMessage); sqlSession.update("dao.chat.Message.updateHead", message);
sqlSession.commit(); sqlSession.commit();
sqlSession.close(); sqlSession.close();
} }

View File

@ -4,7 +4,7 @@ public class User {
private String username; private String username;
private String password; private String password;
private String account; private String account;
private String pic;
private String email; private String email;
@ -18,6 +18,14 @@ public class User {
this.email = email; 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() { public String toString() {
return "User{username = " + username + ", password = " + password + ", account = " + account + ", email = " + email + "}"; 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;
}
} }

View File

@ -57,7 +57,7 @@ public class LoginService {
returnInt = 1002; returnInt = 1002;
} }
} else { } else {
requestUser.setUsername("用户"); requestUser.setUsername(requestUser.getAccount());
userTable.addUser(requestUser); userTable.addUser(requestUser);
returnInt = 200; returnInt = 200;
} }

View File

@ -13,8 +13,8 @@
</select> </select>
<insert id="addUser"> <insert id="addUser">
insert into user(account, password, username, email) insert into user(account, password, username, email, pic)
values (#{account}, #{password}, #{username}, #{email}); values (#{account}, #{password}, #{username}, #{email}, #{pic});
</insert> </insert>
<delete id="delUser"> <delete id="delUser">
delete delete
@ -26,4 +26,9 @@
set password=#{password} and username = #{username} and email = #{email} set password=#{password} and username = #{username} and email = #{email}
where account = #{account}; where account = #{account};
</update> </update>
<update id="updateHead" parameterType="com.example.chat.entity.User">
update user
set pic=#{pic}
where account = #{account}
</update>
</mapper> </mapper>

View File

@ -11,11 +11,10 @@
values (#{nickname}, #{pic}, #{sendTime}, #{message}) values (#{nickname}, #{pic}, #{sendTime}, #{message})
</insert> </insert>
<update id="updateUser" parameterType="com.example.chat.entity.chat.UpdateMessage"> <update id="updateHead" parameterType="com.example.chat.entity.chat.Message">
update message update message
set nickname=#{newName} and pic = #{newPic} set and pic = #{pic}
where nickname = #{nickname} where nickname = #{nickname}
and pic = #{pic}
</update> </update>
</mapper> </mapper>