From ece34fba9ffa60ce83582af8007b56cb7205446f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=B9=8F?= <1154799293@qq.com> Date: Tue, 2 Aug 2022 14:58:10 +0800 Subject: [PATCH] =?UTF-8?q?2022.8.2=E6=8C=81=E4=B9=85=E5=B1=82users?= =?UTF-8?q?=E8=A1=A8=E5=85=A8=E6=95=B0=E6=8D=AE=E5=A2=9E=E5=88=A0=E6=94=B9?= =?UTF-8?q?=E6=9F=A5=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - .../course/mapper/database/UsersMapper.java | 19 ++++++++++- .../resources/mybatis/mapper/UsersMapper.xml | 12 ++++++- .../com/snhanyue/mapper/UserMapperTests.java | 32 ++++++++++++++++++- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index ce4b726..90e15af 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ target # Log file *.log - # BlueJ files *.ctxt diff --git a/src/main/java/com/snhanyue/course/mapper/database/UsersMapper.java b/src/main/java/com/snhanyue/course/mapper/database/UsersMapper.java index 2702d50..5997afa 100644 --- a/src/main/java/com/snhanyue/course/mapper/database/UsersMapper.java +++ b/src/main/java/com/snhanyue/course/mapper/database/UsersMapper.java @@ -2,6 +2,7 @@ package com.snhanyue.course.mapper.database; import com.snhanyue.course.entity.Users; import com.snhanyue.course.vo.UsersVo; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -18,8 +19,24 @@ public interface UsersMapper { */ int insert(Users users); - //查询方法 + /** + * 查询数据 + * @param username用户名 + * @return 查询的数据 + */ UsersVo getByName(String username); + /** + * + * @param id 主键编号 + * @return 受影响行数 + */ + int Update(@Param("id") int id, @Param("username")String username); + /** + * 删除数据 + * @param id 主键id + * @return受影响行数 + */ + int deleteUsers(int id); } diff --git a/src/main/resources/mybatis/mapper/UsersMapper.xml b/src/main/resources/mybatis/mapper/UsersMapper.xml index 4f65982..a515532 100644 --- a/src/main/resources/mybatis/mapper/UsersMapper.xml +++ b/src/main/resources/mybatis/mapper/UsersMapper.xml @@ -13,6 +13,17 @@ ) + + delete from users where id=#{id} + + + + update users + set username=#{username} + where id = #{id} + + +