新增修改昵称以及修改密码功能,对Message表增加了一个account字段,将account作为主码
This commit is contained in:
parent
a9472696b5
commit
f1fba63e8c
|
@ -1,5 +1,6 @@
|
||||||
package com.example.chat.controller;
|
package com.example.chat.controller;
|
||||||
|
|
||||||
|
import com.example.chat.entity.User;
|
||||||
import com.example.chat.service.ChatIndex;
|
import com.example.chat.service.ChatIndex;
|
||||||
import com.example.chat.service.HeadOss;
|
import com.example.chat.service.HeadOss;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -7,23 +8,44 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping("/index")
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
HeadOss headOss;
|
HeadOss headOss;
|
||||||
@Resource
|
@Resource
|
||||||
ChatIndex chatIndex;
|
ChatIndex chatIndex;
|
||||||
@RequestMapping("/index/modifyHead")
|
|
||||||
public void modifyHead(@RequestParam("file")MultipartFile file, @RequestParam("username") String username) {
|
@RequestMapping("/modifyHead")
|
||||||
headOss.ModifyHead(username,file);
|
public void modifyHead( @RequestParam("file") MultipartFile file) {
|
||||||
|
System.out.println(file.getOriginalFilename());
|
||||||
|
headOss.modifyHead(file);
|
||||||
}
|
}
|
||||||
@GetMapping("/index/deleteUser")
|
|
||||||
|
@GetMapping("/deleteUser")
|
||||||
public void deleteUser(@RequestParam("account") String account) {
|
public void deleteUser(@RequestParam("account") String account) {
|
||||||
chatIndex.deleteUser(account);
|
chatIndex.deleteUser(account);
|
||||||
}
|
}
|
||||||
|
@PostMapping("/modifyPassword")
|
||||||
|
public String updatePassword(@RequestBody Map<String,String> requestData) throws IOException {
|
||||||
|
System.out.println(requestData);
|
||||||
|
User user=new User();
|
||||||
|
user.setAccount(requestData.get("account"));
|
||||||
|
user.setPassword(requestData.get("password"));
|
||||||
|
String oldPassword=requestData.get("oldPassword");
|
||||||
|
System.out.println(user);
|
||||||
|
System.out.println(oldPassword);
|
||||||
|
return chatIndex.modifyPassword(user,oldPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/modifyUsername")
|
||||||
|
public void modifyUser(@RequestBody User user) throws IOException {
|
||||||
|
chatIndex.modifyUsername(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,14 @@ import com.example.chat.entity.User;
|
||||||
import com.example.chat.service.CodeCheck;
|
import com.example.chat.service.CodeCheck;
|
||||||
import com.example.chat.service.LoginService;
|
import com.example.chat.service.LoginService;
|
||||||
import com.example.chat.service.mail.MailUtil;
|
import com.example.chat.service.mail.MailUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RestController
|
@RestController
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
@ -64,6 +66,7 @@ public class LoginController {
|
||||||
|
|
||||||
@PostMapping("/getHead")
|
@PostMapping("/getHead")
|
||||||
public User getHead(@RequestBody User user) throws IOException {
|
public User getHead(@RequestBody User user) throws IOException {
|
||||||
|
log.info(user.getAccount());
|
||||||
return userMapper.getUserByAccount(user.getAccount());
|
return userMapper.getUserByAccount(user.getAccount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,14 @@ public class UserDao implements UserMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUser(User oldUser, User newUser) {
|
public void updateUser(User user) throws IOException {
|
||||||
|
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
|
sqlSession.update("dao.Login.updateUsername",user);
|
||||||
|
sqlSession.commit();
|
||||||
|
sqlSession.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User getUser(User user) throws IOException {
|
public User getUser(User user) throws IOException {
|
||||||
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
|
@ -60,11 +64,20 @@ public class UserDao implements UserMapper {
|
||||||
public User getUserByAccount(String account) throws IOException {
|
public User getUserByAccount(String account) throws IOException {
|
||||||
|
|
||||||
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
User user=sqlSession.selectOne("dao.Login.getUserByAccount",account);
|
User user=new User();
|
||||||
|
user.setAccount(account);
|
||||||
|
User user1 = sqlSession.selectOne("dao.Login.getUserByAccount", user);
|
||||||
|
sqlSession.close();
|
||||||
|
return user1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePassword(User user) throws IOException {
|
||||||
|
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
|
sqlSession.update("dao.Login.updatePassword",user);
|
||||||
|
sqlSession.commit();
|
||||||
sqlSession.close();
|
sqlSession.close();
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,19 +4,22 @@ import com.example.chat.entity.User;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface UserMapper {
|
public interface UserMapper {
|
||||||
public abstract void addUser(User user) throws IOException;
|
public abstract void addUser(User user) throws IOException;
|
||||||
|
|
||||||
public abstract void delUser(User user) throws IOException;
|
public abstract void delUser(User user) throws IOException;
|
||||||
|
|
||||||
public abstract void updateUser(User oldUser,User newUser);
|
public abstract void updateUser(User user) throws IOException;
|
||||||
|
|
||||||
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;
|
public abstract void modifyHead(String Pic, String username) throws IOException;
|
||||||
|
|
||||||
public abstract User getUserByAccount(String account) throws IOException;
|
public abstract User getUserByAccount(String account) throws IOException;
|
||||||
|
|
||||||
|
public abstract void updatePassword(User user)throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package com.example.chat.dao.chat;
|
package com.example.chat.dao.chat;
|
||||||
|
|
||||||
|
import com.example.chat.entity.User;
|
||||||
import com.example.chat.entity.chat.Message;
|
import com.example.chat.entity.chat.Message;
|
||||||
import com.example.chat.entity.chat.UpdateMessage;
|
|
||||||
import io.netty.handler.codec.MessageAggregator;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ChatMapper {
|
public interface ChatMapper {
|
||||||
public abstract void addMessage(Message message) throws IOException;
|
public abstract void addMessage(Message message) throws IOException;
|
||||||
|
|
||||||
public abstract void deleteMessage(String str) throws IOException;
|
public abstract void logOffUser(String str) throws IOException;
|
||||||
|
|
||||||
public abstract List<Message> getMessage() throws IOException;
|
public abstract List<Message> getMessage() throws IOException;
|
||||||
|
|
||||||
public abstract void updateMessage(Message message) throws IOException;
|
public abstract void updateMessage(Message message) throws IOException;
|
||||||
|
public abstract void updateUser(User user) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package com.example.chat.dao.chat;
|
package com.example.chat.dao.chat;
|
||||||
|
|
||||||
import com.example.chat.dao.mybatis.MybatisSingleton;
|
import com.example.chat.dao.mybatis.MybatisSingleton;
|
||||||
|
import com.example.chat.entity.User;
|
||||||
import com.example.chat.entity.chat.Message;
|
import com.example.chat.entity.chat.Message;
|
||||||
import com.example.chat.entity.chat.UpdateMessage;
|
import com.example.chat.entity.chat.UpdateMessage;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -27,6 +29,23 @@ public class ChatMessage implements ChatMapper {
|
||||||
sqlSession.close();
|
sqlSession.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateUser(User user) throws IOException {
|
||||||
|
SqlSession sqlSession=MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
|
if(user.getPassword()==null){
|
||||||
|
sqlSession.update("dao.chat.Message.updateUsername",user);
|
||||||
|
sqlSession.commit();
|
||||||
|
sqlSession.close();
|
||||||
|
}else {
|
||||||
|
sqlSession.update("dao.chat.Message.updatePassword",user);
|
||||||
|
sqlSession.commit();
|
||||||
|
sqlSession.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Message> getMessage() throws IOException {
|
public List<Message> getMessage() throws IOException {
|
||||||
List<Message> messageList;
|
List<Message> messageList;
|
||||||
|
@ -37,11 +56,12 @@ public class ChatMessage implements ChatMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMessage(String nickname) throws IOException {
|
public void logOffUser(String account) throws IOException {
|
||||||
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
|
||||||
sqlSession.update("dao.chat.Message.updateUser",nickname);
|
sqlSession.update("dao.chat.Message.logOffUser", account);
|
||||||
sqlSession.commit();
|
sqlSession.commit();
|
||||||
sqlSession.close();
|
sqlSession.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = ChatApplication.class)
|
@SpringBootTest(classes = ChatApplication.class)
|
||||||
public class MapperTest {
|
public class MapperTest {
|
||||||
|
|
|
@ -9,16 +9,28 @@ public class Message {
|
||||||
private String sendTime;
|
private String sendTime;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
private String account;
|
||||||
|
|
||||||
|
public Message(String nickname, String pic, String sendTime, String message, String account) {
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.pic = pic;
|
||||||
|
this.sendTime = sendTime;
|
||||||
|
this.message = message;
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
@JSONCreator
|
@JSONCreator
|
||||||
public static Message create(@JSONField(name= "nickname")String nickname,
|
public static Message create(@JSONField(name= "nickname")String nickname,
|
||||||
@JSONField(name= "pic")String pic,
|
@JSONField(name= "pic")String pic,
|
||||||
@JSONField(name= "sendTime")String sendTime,
|
@JSONField(name= "sendTime")String sendTime,
|
||||||
@JSONField(name= "message")String message){
|
@JSONField(name= "message")String message,
|
||||||
|
@JSONField(name="account")String account){
|
||||||
Message message1=new Message();
|
Message message1=new Message();
|
||||||
message1.setNickname(nickname);
|
message1.setNickname(nickname);
|
||||||
message1.setMessage(message);
|
message1.setMessage(message);
|
||||||
message1.setPic(pic);
|
message1.setPic(pic);
|
||||||
message1.setSendTime(sendTime);
|
message1.setSendTime(sendTime);
|
||||||
|
message1.setAccount(account);
|
||||||
return message1;
|
return message1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +111,20 @@ public class Message {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Message{nickName = " + nickname + ", pic = " + pic + ", time = " + sendTime + ", message = " + message + "}";
|
return "Message{nickName = " + nickname + ", pic = " + pic + ", time = " + sendTime + ", message = " + message + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取
|
||||||
|
* @return account
|
||||||
|
*/
|
||||||
|
public String getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置
|
||||||
|
* @param account
|
||||||
|
*/
|
||||||
|
public void setAccount(String account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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("/index/modifyHead");
|
||||||
registry.addInterceptor(tokenInterceptor)//注册拦截器
|
registry.addInterceptor(tokenInterceptor)//注册拦截器
|
||||||
.addPathPatterns("/**")//拦截所有请求
|
.addPathPatterns("/**")//拦截所有请求
|
||||||
.excludePathPatterns(excludePath);//添加拦截白名单
|
.excludePathPatterns(excludePath);//添加拦截白名单
|
||||||
|
|
|
@ -23,10 +23,31 @@ public class ChatIndex {
|
||||||
user.setAccount(account);
|
user.setAccount(account);
|
||||||
try {
|
try {
|
||||||
userMapper.delUser(user);
|
userMapper.delUser(user);
|
||||||
user = userMapper.getUserByAccount(account);
|
|
||||||
chatMapper.deleteMessage(user.getUsername());//修改用户的聊天记录的头像与昵称
|
chatMapper.logOffUser(user.getAccount());//修改用户的聊天记录的头像与昵称
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//修改用户User属性以及聊天记录中的User属性
|
||||||
|
public void modifyUsername(User user) throws IOException {
|
||||||
|
chatMapper.updateUser(user);
|
||||||
|
userMapper.updateUser(user);
|
||||||
|
}
|
||||||
|
public String modifyPassword(User user,String oldPassword){
|
||||||
|
String returnStr=null;
|
||||||
|
try {
|
||||||
|
User dbUser=userMapper.getUserByAccount(user.getAccount());
|
||||||
|
System.out.println("dbUser"+dbUser);
|
||||||
|
if (dbUser.getPassword().equals(oldPassword)){
|
||||||
|
userMapper.updatePassword(user);
|
||||||
|
returnStr= "success";
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
|
||||||
|
}
|
||||||
|
return returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.example.chat.service;
|
||||||
import com.example.chat.dao.UserMapper;
|
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.chat.Message;
|
import com.example.chat.entity.chat.Message;
|
||||||
import com.example.chat.entity.chat.UpdateMessage;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -11,6 +10,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@ -21,10 +21,14 @@ public class HeadOss {
|
||||||
ChatMapper chatMapper;
|
ChatMapper chatMapper;
|
||||||
|
|
||||||
|
|
||||||
public void ModifyHead(String username, MultipartFile file){
|
public void modifyHead(MultipartFile file) {
|
||||||
String folderPath = "/www/wwwroot/oss";
|
String folderPath = "/www/wwwroot/oss";
|
||||||
String newFoldPath = folderPath + "/"+ username;
|
String username;
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
|
username= fileName.split("\\.")[0];
|
||||||
|
|
||||||
|
String newFoldPath = folderPath + "/" + username;
|
||||||
|
|
||||||
File targetFile = new File(newFoldPath + "/" + fileName);
|
File targetFile = new File(newFoldPath + "/" + fileName);
|
||||||
File newFile = new File(newFoldPath);
|
File newFile = new File(newFoldPath);
|
||||||
if (!newFile.exists()) {
|
if (!newFile.exists()) {
|
||||||
|
@ -43,7 +47,7 @@ public class HeadOss {
|
||||||
}
|
}
|
||||||
file.transferTo(targetFile);
|
file.transferTo(targetFile);
|
||||||
log.info("成功添加");
|
log.info("成功添加");
|
||||||
String head="https://www.oss.coollh.cn/"+username+"/"+fileName;
|
String head = "http://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);
|
||||||
|
|
|
@ -19,7 +19,6 @@ public class LoginService {
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String LoginCheck(User requestUser) throws IOException {
|
public String LoginCheck(User requestUser) throws IOException {
|
||||||
User user;
|
User user;
|
||||||
user = userTable.getUser(requestUser);
|
user = userTable.getUser(requestUser);
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="addMessage" parameterType="com.example.chat.entity.chat.Message">
|
<insert id="addMessage" parameterType="com.example.chat.entity.chat.Message">
|
||||||
insert into message (nickname, pic, sendTime, message)
|
insert into message (nickname, pic, sendTime, message,account)
|
||||||
values (#{nickname}, #{pic}, #{sendTime}, #{message})
|
values (#{nickname}, #{pic}, #{sendTime}, #{message},#{account})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateHead" parameterType="com.example.chat.entity.chat.Message">
|
<update id="updateHead" parameterType="com.example.chat.entity.chat.Message">
|
||||||
|
@ -17,10 +17,13 @@
|
||||||
where nickname = #{nickname}
|
where nickname = #{nickname}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateUser" parameterType="com.example.chat.entity.chat.Message">
|
<update id="logOffUser" parameterType="com.example.chat.entity.chat.Message">
|
||||||
update message
|
update message
|
||||||
set nickname='用户已注销' and pic = 'http://www.oss.coollh.cn/delete.jpg'
|
set nickname='用户已注销' and account='用户已注销' and pic = 'http://www.oss.coollh.cn/delete.jpg'
|
||||||
where nickname = #{nickname}
|
where account = #{account}
|
||||||
|
</update>
|
||||||
|
<update id="updateUsername" parameterType="com.example.chat.entity.User">
|
||||||
|
update message set nickname=#{username} where account=#{account}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -11,7 +11,11 @@
|
||||||
from user
|
from user
|
||||||
where email = #{email};
|
where email = #{email};
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getUserByAccount" resultType="com.example.chat.entity.User">
|
||||||
|
select *
|
||||||
|
from user
|
||||||
|
where account = #{account}
|
||||||
|
</select>
|
||||||
<insert id="addUser">
|
<insert id="addUser">
|
||||||
insert into user(account, password, username, email, pic)
|
insert into user(account, password, username, email, pic)
|
||||||
values (#{account}, #{password}, #{username}, #{email}, #{pic});
|
values (#{account}, #{password}, #{username}, #{email}, #{pic});
|
||||||
|
@ -31,12 +35,13 @@
|
||||||
set pic=#{pic}
|
set pic=#{pic}
|
||||||
where account = #{account}
|
where account = #{account}
|
||||||
</update>
|
</update>
|
||||||
<select id="getUserByAccount" resultType="com.example.chat.entity.User">
|
<update id="updateUsername">
|
||||||
select *
|
update user set username=#{username} where account=#{account}
|
||||||
from user
|
</update>
|
||||||
|
<update id="updatePassword">
|
||||||
|
update user
|
||||||
|
set password=#{password}
|
||||||
where account = #{account}
|
where account = #{account}
|
||||||
</select>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
-->
|
-->
|
||||||
<mappers>
|
<mappers>
|
||||||
<!--下面编写mapper映射文件↓↓↓↓↓ 参考格式:<VueLoginMapper.xml resource="dao/VueLoginMapper.xml"/> -->
|
<!--下面编写mapper映射文件↓↓↓↓↓ 参考格式:<VueLoginMapper.xml resource="dao/VueLoginMapper.xml"/> -->
|
||||||
<mapper resource="mapper/LoginMapper.xml"></mapper>
|
<mapper resource="mapper/UserMapper.xml"></mapper>
|
||||||
<mapper resource="mapper/MessageMapper.xml"></mapper>
|
<mapper resource="mapper/MessageMapper.xml"></mapper>
|
||||||
</mappers>
|
</mappers>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in New Issue