mybatis xml 写法解析

This commit is contained in:
qiurunze 2018-09-27 22:23:19 +08:00
parent d053fbcf6c
commit 55fbc8d08d
7 changed files with 86 additions and 75 deletions

View File

@ -2,46 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="59bd24de-7908-4982-927f-6d236db7e416" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/common/ResponseCode.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/common/ServerResponse.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/UserController.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/UserMapper.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/service/IUserService.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/mybatis/config.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/mybatis/mapper/UserMapper.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/common/ResponseCode.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/common/ServerResponse.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/controller/UserController.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/service/IUserService.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/miaosha.iml" beforeDir="false" afterPath="$PROJECT_DIR$/miaosha.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/Test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/Test.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/LoginController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/LoginController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/MiaoShaUserDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/MiaoShaUserDao.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/MiaoshaUserDao.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/domain/MiaoshaUser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/domain/MiaoshaUser.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/result/CodeMsg.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/result/CodeMsg.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/result/Result.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/result/Result.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/service/MiaoShaUserService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/service/MiaoShaUserService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/eekQMainApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/eekQMainApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/templates/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/login.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/Test.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/Test.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/controller/LoginController.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/dao/MiaoShaUserDao.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/dao/MiaoShaUserDao.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/dao/MiaoshaUserDao.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/domain/MiaoshaUser.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/domain/MiaoshaUser.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/result/CodeMsg.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/result/CodeMsg.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/result/Result.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/result/Result.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/service/MiaoShaUserService.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/service/MiaoShaUserService.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/eekQMainApplication.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/geekq/miaosha/eekQMainApplication.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/templates/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/templates/login.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/UserMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/UserMapper.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/mybatis/mapper/UserMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mybatis/mapper/UserMapper.xml" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/target/" />
<ignored path="$PROJECT_DIR$/springcloud-server/target/" />
@ -134,25 +97,25 @@
<entry key="gitignore" value="2" />
<entry key="htm" value="1" />
<entry key="html" value="24" />
<entry key="java" value="10231" />
<entry key="java" value="10313" />
<entry key="md" value="667" />
<entry key="properties" value="95" />
<entry key="regexp" value="11" />
<entry key="txt" value="615" />
<entry key="xml" value="980" />
<entry key="xml" value="1004" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="CLASS" value="1" />
<entry key="HTML" value="25" />
<entry key="JAVA" value="10231" />
<entry key="JAVA" value="10313" />
<entry key="Markdown" value="667" />
<entry key="PLAIN_TEXT" value="653" />
<entry key="Properties" value="95" />
<entry key="RegExp" value="11" />
<entry key="SQL" value="12" />
<entry key="XML" value="968" />
<entry key="SQL" value="13" />
<entry key="XML" value="991" />
</counts>
</usages-collector>
</session>
@ -162,8 +125,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/resources/mybatis/mapper/UserMapper.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="276">
<caret line="36" column="33" selection-start-line="36" selection-start-column="16" selection-end-line="36" selection-end-column="33" />
<state relative-caret-position="408">
<caret line="28" column="39" selection-start-line="28" selection-start-column="16" selection-end-line="28" selection-end-column="39" />
</state>
</provider>
</entry>
@ -180,8 +143,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/UserMapper.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="386">
<caret line="28" column="35" selection-start-line="28" selection-start-column="35" selection-end-line="28" selection-end-column="35" />
<state relative-caret-position="414">
<caret line="23" column="32" selection-start-line="23" selection-start-column="9" selection-end-line="23" selection-end-column="32" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -192,11 +155,12 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/LoginController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="320">
<caret line="70" column="63" selection-start-line="70" selection-start-column="63" selection-end-line="70" selection-end-column="63" />
<state relative-caret-position="414">
<caret line="79" column="53" selection-start-line="79" selection-start-column="53" selection-end-line="79" selection-end-column="53" />
<folding>
<element signature="e#1495#1496#0" expanded="true" />
<element signature="e#1553#1554#0" expanded="true" />
<element signature="e#2479#2492#0" expanded="true" />
</folding>
</state>
</provider>
@ -214,8 +178,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/MiaoShaUserDao.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="13" column="47" selection-start-line="13" selection-start-column="47" selection-end-line="13" selection-end-column="47" />
<state relative-caret-position="352">
<caret line="17" column="59" lean-forward="true" selection-start-line="17" selection-start-column="59" selection-end-line="17" selection-end-column="59" />
</state>
</provider>
</entry>
@ -446,7 +410,7 @@
<property name="RequestMappingsPanelWidth2" value="75" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1538057366147" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1538058142261" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../project/we-p2p" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
@ -616,12 +580,12 @@
<workItem from="1537947897813" duration="3356000" />
<workItem from="1537969313502" duration="4411000" />
<workItem from="1538041783822" duration="770000" />
<workItem from="1538052217986" duration="5104000" />
<workItem from="1538052217986" duration="5794000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="164965000" />
<option name="totallyTimeSpent" value="165655000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -647,7 +611,7 @@
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" sideWeight="0.6996805" weight="0.26815644" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.8945687" weight="0.42234638" />
<window_info active="true" anchor="bottom" id="Debug" order="3" sideWeight="0.78541" visible="true" weight="0.46368715" />
<window_info active="true" anchor="bottom" id="Debug" order="3" sideWeight="0.78541" visible="true" weight="0.16201118" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32960895" />
@ -775,10 +739,16 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/LoginController.java</url>
<line>65</line>
<line>67</line>
<properties />
<option name="timeStamp" value="29" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/LoginController.java</url>
<line>74</line>
<properties />
<option name="timeStamp" value="30" />
</line-breakpoint>
</breakpoints>
<breakpoints-dialog>
<breakpoints-dialog />
@ -1098,16 +1068,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/UserMapper.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="386">
<caret line="28" column="35" selection-start-line="28" selection-start-column="35" selection-end-line="28" selection-end-column="35" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/domain/MiaoshaUser.java">
<provider selected="true" editor-type-id="text-editor">
<state>
@ -1117,25 +1077,36 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/mybatis/mapper/UserMapper.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="276">
<caret line="36" column="33" selection-start-line="36" selection-start-column="16" selection-end-line="36" selection-end-column="33" />
<state relative-caret-position="408">
<caret line="28" column="39" selection-start-line="28" selection-start-column="16" selection-end-line="28" selection-end-column="39" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/MiaoShaUserDao.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="13" column="47" selection-start-line="13" selection-start-column="47" selection-end-line="13" selection-end-column="47" />
<state relative-caret-position="352">
<caret line="17" column="59" lean-forward="true" selection-start-line="17" selection-start-column="59" selection-end-line="17" selection-end-column="59" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/dao/UserMapper.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414">
<caret line="23" column="32" selection-start-line="23" selection-start-column="9" selection-end-line="23" selection-end-column="32" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/geekq/miaosha/controller/LoginController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="320">
<caret line="70" column="63" selection-start-line="70" selection-start-column="63" selection-end-line="70" selection-end-column="63" />
<state relative-caret-position="414">
<caret line="79" column="53" selection-start-line="79" selection-start-column="53" selection-end-line="79" selection-end-column="53" />
<folding>
<element signature="e#1495#1496#0" expanded="true" />
<element signature="e#1553#1554#0" expanded="true" />
<element signature="e#2479#2492#0" expanded="true" />
</folding>
</state>
</provider>

View File

@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("/login")
@ -63,12 +65,24 @@ public class LoginController {
// miaoshaUser.setNickname("test");
// Long num = userMapper.insertMiaoShaUser(miaoshaUser);
// MiaoshaUser upmiaoshaUser =new MiaoshaUser();
// upmiaoshaUser.setId(Long.valueOf("1234569879"));
// upmiaoshaUser.setNickname("test1");
// userMapper.updateMiaoShaUser(upmiaoshaUser);
//
// userMapper.deleteMiaoShaUser(Long.valueOf("1234569879"));
List<MiaoshaUser> lists = new ArrayList<MiaoshaUser>();
MiaoshaUser upmiaoshaUser =new MiaoshaUser();
upmiaoshaUser.setId(Long.valueOf("1234569879"));
upmiaoshaUser.setNickname("test1");
userMapper.updateMiaoShaUser(upmiaoshaUser);
MiaoshaUser upmiaoshaUser1 =new MiaoshaUser();
upmiaoshaUser1.setId(Long.valueOf("1234569872"));
upmiaoshaUser1.setNickname("test1");
lists.add(upmiaoshaUser);
lists.add(upmiaoshaUser1);
userMapper.deleteMiaoShaUser(Long.valueOf("1234569879"));
userMapper.insertMiaoShaUserValues(lists);
}
}

View File

@ -21,6 +21,8 @@ public interface UserMapper {
public Long insertMiaoShaUser(MiaoshaUser user);
void insertMiaoShaUserValues(List<MiaoshaUser> miaoshaUsers);
//更改表数据
void updateMiaoShaUser(MiaoshaUser user) ;

View File

@ -24,6 +24,18 @@
#{loginCount,jdbcType=INTEGER}
)
</insert>
<!--批量插入-->
<insert id="insertMiaoShaUserValues" useGeneratedKeys="true"
keyProperty="id">
insert into miaosha_user (id, nickname, salt, register_date,last_login_date,login_Count ) values
<foreach item="item" collection="list" separator=",">
(#{item.id,jdbcType=BIGINT},#{item.nickname,jdbcType=VARCHAR},
#{item.salt,jdbcType=VARCHAR},#{item.registerDate,jdbcType=DATE},#{item.lastLoginDate,jdbcType=DATE},
#{item.loginCount,jdbcType=INTEGER}
)
</foreach>
</insert>
<!--更新一条数据-->

View File

@ -24,6 +24,18 @@
#{loginCount,jdbcType=INTEGER}
)
</insert>
<!--批量插入-->
<insert id="insertMiaoShaUserValues" useGeneratedKeys="true"
keyProperty="id">
insert into miaosha_user (id, nickname, salt, register_date,last_login_date,login_Count ) values
<foreach item="item" collection="list" separator=",">
(#{item.id,jdbcType=BIGINT},#{item.nickname,jdbcType=VARCHAR},
#{item.salt,jdbcType=VARCHAR},#{item.registerDate,jdbcType=DATE},#{item.lastLoginDate,jdbcType=DATE},
#{item.loginCount,jdbcType=INTEGER}
)
</foreach>
</insert>
<!--更新一条数据-->