• 第3章业务功能开发(创建mybatis的逆向工程)


    1.mybatis逆向工程:
      1)简介:根据表生成mapper层三部分代码:实体类,mapper接口,映射文件。
      2)使用mybatis逆向工程:
        a)创建工程:crm-mybatis-generator


        b)添加插件:

    pom.xml文件

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    5. <modelVersion>4.0.0</modelVersion>
    6. <groupId>com.it.crm</groupId>
    7. <artifactId>crm-mybatis-generator</artifactId>
    8. <version>1.0-SNAPSHOT</version>
    9. <build>
    10. <plugins>
    11. <!--myBatis逆向工程插件-->
    12. <plugin>
    13. <groupId>org.mybatis.generator</groupId>
    14. <artifactId>mybatis-generator-maven-plugin</artifactId>
    15. <version>1.3.2</version>
    16. <configuration>
    17. <verbose>true</verbose>
    18. <overwrite>true</overwrite>
    19. </configuration>
    20. </plugin>
    21. </plugins>
    22. </build>
    23. </project>


       c)添加配置文件:
         数据库连接信息

    generator.properties配置文件

    jdbc.driverLocation:代表Maven仓库中mql的驱动文件的位置

    1. jdbc.driverLocation=D:/jsp/Maven/MavenTest/repository/mysql/mysql-connector-java/5.1.43/mysql-connector-java-5.1.43.jar
    2. jdbc.driverClass=com.mysql.jdbc.Driver
    3. jdbc.connectionURL=jdbc:mysql://127.0.0.1:3306/db_crm_ssm
    4. jdbc.userId=root
    5. jdbc.password=123456

        generatorConfig.xml配置文件

    当前把需要逆向生成的表全部已经写好了,需要逆向生成那些表就放出来那些表,已经生成过的需要再关进去。现在只需要逆向生成tbl_user表

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE generatorConfiguration
    3. PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
    4. "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
    5. <generatorConfiguration>
    6. <!--指定mysql数据库驱动-->
    7. <!--<classPathEntry location="E://repository-p2p//mysql//mysql-connector-java//5.1.43//mysql-connector-java-5.1.43.jar"/>-->
    8. <!--导入属性配置-->
    9. <properties resource="generator.properties"></properties>
    10. <!--指定特定数据库的jdbc驱动jar包的位置-->
    11. <classPathEntry location="${jdbc.driverLocation}"/>
    12. <context id="default" targetRuntime="MyBatis3">
    13. <!-- optional,旨在创建class时,对注释进行控制,false生成注释,true无注释 -->
    14. <commentGenerator>
    15. <property name="suppressDate" value="false"/>
    16. <property name="suppressAllComments" value="false"/>
    17. </commentGenerator>
    18. <!--jdbc的数据库连接 -->
    19. <jdbcConnection
    20. driverClass="${jdbc.driverClass}"
    21. connectionURL="${jdbc.connectionURL}"
    22. userId="${jdbc.userId}"
    23. password="${jdbc.password}">
    24. </jdbcConnection>
    25. <!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制-->
    26. <javaTypeResolver>
    27. <property name="forceBigDecimals" value="false"/>
    28. </javaTypeResolver>
    29. <!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
    30. targetPackage 指定生成的model生成所在的包名
    31. targetProject 指定在该项目下所在的路径|指定生成到的工程名称
    32. -->
    33. <javaModelGenerator targetPackage="com.it.crm.settings.entity"
    34. targetProject="D:/SSM框架/SSM版CRMTest/crm/src/main/java">
    35. <!-- 是否允许子包,即targetPackage.schemaName.tableName -->
    36. <property name="enableSubPackages" value="false"/>
    37. <!-- 是否对model添加 构造函数 true添加,false不添加-->
    38. <property name="constructorBased" value="false"/>
    39. <!-- 是否对类CHAR类型的列的数据进行trim操作 -->
    40. <property name="trimStrings" value="true"/>
    41. <!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 -->
    42. <property name="immutable" value="false"/>
    43. </javaModelGenerator>
    44. <!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
    45. <sqlMapGenerator targetPackage="com.it.crm.settings.mapper"
    46. targetProject="D:/SSM框架/SSM版CRMTest/crm/src/main/java">
    47. <property name="enableSubPackages" value="false"/>
    48. </sqlMapGenerator>
    49. <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
    50. type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
    51. type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
    52. type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口
    53. -->
    54. <javaClientGenerator targetPackage="com.it.crm.settings.mapper"
    55. targetProject="D:/SSM框架/SSM版CRMTest/crm/src/main/java" type="XMLMAPPER">
    56. <property name="enableSubPackages" value="true"/>
    57. </javaClientGenerator>
    58. <table tableName="tbl_user" domainObjectName="User"
    59. enableCountByExample="false" enableUpdateByExample="false"
    60. enableDeleteByExample="false" enableSelectByExample="false"
    61. selectByExampleQueryId="false">
    62. </table>
    63. <!--
    64. <table tableName="tbl_clue" domainObjectName="Clue"
    65. enableCountByExample="false" enableUpdateByExample="false"
    66. enableDeleteByExample="false" enableSelectByExample="false"
    67. selectByExampleQueryId="false">
    68. </table>
    69. <table tableName="tbl_clue_activity_relation" domainObjectName="ClueActivityRelation"
    70. enableCountByExample="false" enableUpdateByExample="false"
    71. enableDeleteByExample="false" enableSelectByExample="false"
    72. selectByExampleQueryId="false">
    73. </table>
    74. <table tableName="tbl_clue_remark" domainObjectName="ClueRemark"
    75. enableCountByExample="false" enableUpdateByExample="false"
    76. enableDeleteByExample="false" enableSelectByExample="false"
    77. selectByExampleQueryId="false">
    78. </table>
    79. -->
    80. <!--
    81. <table tableName="tbl_contacts" domainObjectName="Contacts"
    82. enableCountByExample="false" enableUpdateByExample="false"
    83. enableDeleteByExample="false" enableSelectByExample="false"
    84. selectByExampleQueryId="false">
    85. </table>
    86. <table tableName="tbl_contacts_activity_relation" domainObjectName="ContactsActivityRelation"
    87. enableCountByExample="false" enableUpdateByExample="false"
    88. enableDeleteByExample="false" enableSelectByExample="false"
    89. selectByExampleQueryId="false">
    90. </table>
    91. <table tableName="tbl_contacts_remark" domainObjectName="ContactsRemark"
    92. enableCountByExample="false" enableUpdateByExample="false"
    93. enableDeleteByExample="false" enableSelectByExample="false"
    94. selectByExampleQueryId="false">
    95. </table>
    96. -->
    97. <!--
    98. <table tableName="tbl_customer" domainObjectName="Customer"
    99. enableCountByExample="false" enableUpdateByExample="false"
    100. enableDeleteByExample="false" enableSelectByExample="false"
    101. selectByExampleQueryId="false">
    102. </table>
    103. <table tableName="tbl_customer_remark" domainObjectName="CustomerRemark"
    104. enableCountByExample="false" enableUpdateByExample="false"
    105. enableDeleteByExample="false" enableSelectByExample="false"
    106. selectByExampleQueryId="false">
    107. </table>
    108. -->
    109. <!--
    110. <table tableName="tbl_dictionary_type" domainObjectName="DictionaryType"
    111. enableCountByExample="false" enableUpdateByExample="false"
    112. enableDeleteByExample="false" enableSelectByExample="false"
    113. selectByExampleQueryId="false">
    114. </table>
    115. <table tableName="tbl_dictionary_value" domainObjectName="DictionaryValue"
    116. enableCountByExample="false" enableUpdateByExample="false"
    117. enableDeleteByExample="false" enableSelectByExample="false"
    118. selectByExampleQueryId="false">
    119. </table>
    120. <table tableName="tbl_marketing_activities" domainObjectName="MarketingActivities"
    121. enableCountByExample="false" enableUpdateByExample="false"
    122. enableDeleteByExample="false" enableSelectByExample="false"
    123. selectByExampleQueryId="false">
    124. </table>
    125. <table tableName="tbl_marketing_activities_remark" domainObjectName="MarketingActivitiesRemark"
    126. enableCountByExample="false" enableUpdateByExample="false"
    127. enableDeleteByExample="false" enableSelectByExample="false"
    128. selectByExampleQueryId="false">
    129. </table>
    130. <table tableName="tbl_transaction" domainObjectName="Transaction"
    131. enableCountByExample="false" enableUpdateByExample="false"
    132. enableDeleteByExample="false" enableSelectByExample="false"
    133. selectByExampleQueryId="false">
    134. </table>
    135. <table tableName="tbl_transaction_history" domainObjectName="TransactionHistory"
    136. enableCountByExample="false" enableUpdateByExample="false"
    137. enableDeleteByExample="false" enableSelectByExample="false"
    138. selectByExampleQueryId="false">
    139. </table>
    140. <table tableName="tbl_transaction_remark" domainObjectName="TransactionRemark"
    141. enableCountByExample="false" enableUpdateByExample="false"
    142. enableDeleteByExample="false" enableSelectByExample="false"
    143. selectByExampleQueryId="false">
    144. </table>
    145. -->
    146. </context>
    147. </generatorConfiguration>


       d)运行mybatis的逆向工程,根据指定表生成java代码,保存到指定的目录中。

    双击蓝色阴影的插件

     

    自动在crm项目中生成了这三个文件,实体类,用户接口,用户接口的映射文件。

    User实体类

    1. package com.it.crm.settings.entity;
    2. public class User {
    3. /**
    4. * This field was generated by MyBatis Generator.
    5. * This field corresponds to the database column tbl_user.id
    6. *
    7. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    8. */
    9. private String id;
    10. /**
    11. * This field was generated by MyBatis Generator.
    12. * This field corresponds to the database column tbl_user.login_act
    13. *
    14. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    15. */
    16. private String loginAct;
    17. /**
    18. * This field was generated by MyBatis Generator.
    19. * This field corresponds to the database column tbl_user.name
    20. *
    21. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    22. */
    23. private String name;
    24. /**
    25. * This field was generated by MyBatis Generator.
    26. * This field corresponds to the database column tbl_user.login_pwd
    27. *
    28. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    29. */
    30. private String loginPwd;
    31. /**
    32. * This field was generated by MyBatis Generator.
    33. * This field corresponds to the database column tbl_user.email
    34. *
    35. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    36. */
    37. private String email;
    38. /**
    39. * This field was generated by MyBatis Generator.
    40. * This field corresponds to the database column tbl_user.expire_time
    41. *
    42. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    43. */
    44. private String expireTime;
    45. /**
    46. * This field was generated by MyBatis Generator.
    47. * This field corresponds to the database column tbl_user.lock_state
    48. *
    49. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    50. */
    51. private String lockState;
    52. /**
    53. * This field was generated by MyBatis Generator.
    54. * This field corresponds to the database column tbl_user.deptno
    55. *
    56. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    57. */
    58. private String deptno;
    59. /**
    60. * This field was generated by MyBatis Generator.
    61. * This field corresponds to the database column tbl_user.allow_ips
    62. *
    63. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    64. */
    65. private String allowIps;
    66. /**
    67. * This field was generated by MyBatis Generator.
    68. * This field corresponds to the database column tbl_user.createTime
    69. *
    70. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    71. */
    72. private String createtime;
    73. /**
    74. * This field was generated by MyBatis Generator.
    75. * This field corresponds to the database column tbl_user.create_by
    76. *
    77. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    78. */
    79. private String createBy;
    80. /**
    81. * This field was generated by MyBatis Generator.
    82. * This field corresponds to the database column tbl_user.edit_time
    83. *
    84. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    85. */
    86. private String editTime;
    87. /**
    88. * This field was generated by MyBatis Generator.
    89. * This field corresponds to the database column tbl_user.edit_by
    90. *
    91. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    92. */
    93. private String editBy;
    94. /**
    95. * This method was generated by MyBatis Generator.
    96. * This method returns the value of the database column tbl_user.id
    97. *
    98. * @return the value of tbl_user.id
    99. *
    100. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    101. */
    102. public String getId() {
    103. return id;
    104. }
    105. /**
    106. * This method was generated by MyBatis Generator.
    107. * This method sets the value of the database column tbl_user.id
    108. *
    109. * @param id the value for tbl_user.id
    110. *
    111. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    112. */
    113. public void setId(String id) {
    114. this.id = id == null ? null : id.trim();
    115. }
    116. /**
    117. * This method was generated by MyBatis Generator.
    118. * This method returns the value of the database column tbl_user.login_act
    119. *
    120. * @return the value of tbl_user.login_act
    121. *
    122. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    123. */
    124. public String getLoginAct() {
    125. return loginAct;
    126. }
    127. /**
    128. * This method was generated by MyBatis Generator.
    129. * This method sets the value of the database column tbl_user.login_act
    130. *
    131. * @param loginAct the value for tbl_user.login_act
    132. *
    133. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    134. */
    135. public void setLoginAct(String loginAct) {
    136. this.loginAct = loginAct == null ? null : loginAct.trim();
    137. }
    138. /**
    139. * This method was generated by MyBatis Generator.
    140. * This method returns the value of the database column tbl_user.name
    141. *
    142. * @return the value of tbl_user.name
    143. *
    144. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    145. */
    146. public String getName() {
    147. return name;
    148. }
    149. /**
    150. * This method was generated by MyBatis Generator.
    151. * This method sets the value of the database column tbl_user.name
    152. *
    153. * @param name the value for tbl_user.name
    154. *
    155. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    156. */
    157. public void setName(String name) {
    158. this.name = name == null ? null : name.trim();
    159. }
    160. /**
    161. * This method was generated by MyBatis Generator.
    162. * This method returns the value of the database column tbl_user.login_pwd
    163. *
    164. * @return the value of tbl_user.login_pwd
    165. *
    166. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    167. */
    168. public String getLoginPwd() {
    169. return loginPwd;
    170. }
    171. /**
    172. * This method was generated by MyBatis Generator.
    173. * This method sets the value of the database column tbl_user.login_pwd
    174. *
    175. * @param loginPwd the value for tbl_user.login_pwd
    176. *
    177. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    178. */
    179. public void setLoginPwd(String loginPwd) {
    180. this.loginPwd = loginPwd == null ? null : loginPwd.trim();
    181. }
    182. /**
    183. * This method was generated by MyBatis Generator.
    184. * This method returns the value of the database column tbl_user.email
    185. *
    186. * @return the value of tbl_user.email
    187. *
    188. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    189. */
    190. public String getEmail() {
    191. return email;
    192. }
    193. /**
    194. * This method was generated by MyBatis Generator.
    195. * This method sets the value of the database column tbl_user.email
    196. *
    197. * @param email the value for tbl_user.email
    198. *
    199. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    200. */
    201. public void setEmail(String email) {
    202. this.email = email == null ? null : email.trim();
    203. }
    204. /**
    205. * This method was generated by MyBatis Generator.
    206. * This method returns the value of the database column tbl_user.expire_time
    207. *
    208. * @return the value of tbl_user.expire_time
    209. *
    210. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    211. */
    212. public String getExpireTime() {
    213. return expireTime;
    214. }
    215. /**
    216. * This method was generated by MyBatis Generator.
    217. * This method sets the value of the database column tbl_user.expire_time
    218. *
    219. * @param expireTime the value for tbl_user.expire_time
    220. *
    221. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    222. */
    223. public void setExpireTime(String expireTime) {
    224. this.expireTime = expireTime == null ? null : expireTime.trim();
    225. }
    226. /**
    227. * This method was generated by MyBatis Generator.
    228. * This method returns the value of the database column tbl_user.lock_state
    229. *
    230. * @return the value of tbl_user.lock_state
    231. *
    232. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    233. */
    234. public String getLockState() {
    235. return lockState;
    236. }
    237. /**
    238. * This method was generated by MyBatis Generator.
    239. * This method sets the value of the database column tbl_user.lock_state
    240. *
    241. * @param lockState the value for tbl_user.lock_state
    242. *
    243. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    244. */
    245. public void setLockState(String lockState) {
    246. this.lockState = lockState == null ? null : lockState.trim();
    247. }
    248. /**
    249. * This method was generated by MyBatis Generator.
    250. * This method returns the value of the database column tbl_user.deptno
    251. *
    252. * @return the value of tbl_user.deptno
    253. *
    254. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    255. */
    256. public String getDeptno() {
    257. return deptno;
    258. }
    259. /**
    260. * This method was generated by MyBatis Generator.
    261. * This method sets the value of the database column tbl_user.deptno
    262. *
    263. * @param deptno the value for tbl_user.deptno
    264. *
    265. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    266. */
    267. public void setDeptno(String deptno) {
    268. this.deptno = deptno == null ? null : deptno.trim();
    269. }
    270. /**
    271. * This method was generated by MyBatis Generator.
    272. * This method returns the value of the database column tbl_user.allow_ips
    273. *
    274. * @return the value of tbl_user.allow_ips
    275. *
    276. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    277. */
    278. public String getAllowIps() {
    279. return allowIps;
    280. }
    281. /**
    282. * This method was generated by MyBatis Generator.
    283. * This method sets the value of the database column tbl_user.allow_ips
    284. *
    285. * @param allowIps the value for tbl_user.allow_ips
    286. *
    287. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    288. */
    289. public void setAllowIps(String allowIps) {
    290. this.allowIps = allowIps == null ? null : allowIps.trim();
    291. }
    292. /**
    293. * This method was generated by MyBatis Generator.
    294. * This method returns the value of the database column tbl_user.createTime
    295. *
    296. * @return the value of tbl_user.createTime
    297. *
    298. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    299. */
    300. public String getCreatetime() {
    301. return createtime;
    302. }
    303. /**
    304. * This method was generated by MyBatis Generator.
    305. * This method sets the value of the database column tbl_user.createTime
    306. *
    307. * @param createtime the value for tbl_user.createTime
    308. *
    309. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    310. */
    311. public void setCreatetime(String createtime) {
    312. this.createtime = createtime == null ? null : createtime.trim();
    313. }
    314. /**
    315. * This method was generated by MyBatis Generator.
    316. * This method returns the value of the database column tbl_user.create_by
    317. *
    318. * @return the value of tbl_user.create_by
    319. *
    320. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    321. */
    322. public String getCreateBy() {
    323. return createBy;
    324. }
    325. /**
    326. * This method was generated by MyBatis Generator.
    327. * This method sets the value of the database column tbl_user.create_by
    328. *
    329. * @param createBy the value for tbl_user.create_by
    330. *
    331. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    332. */
    333. public void setCreateBy(String createBy) {
    334. this.createBy = createBy == null ? null : createBy.trim();
    335. }
    336. /**
    337. * This method was generated by MyBatis Generator.
    338. * This method returns the value of the database column tbl_user.edit_time
    339. *
    340. * @return the value of tbl_user.edit_time
    341. *
    342. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    343. */
    344. public String getEditTime() {
    345. return editTime;
    346. }
    347. /**
    348. * This method was generated by MyBatis Generator.
    349. * This method sets the value of the database column tbl_user.edit_time
    350. *
    351. * @param editTime the value for tbl_user.edit_time
    352. *
    353. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    354. */
    355. public void setEditTime(String editTime) {
    356. this.editTime = editTime == null ? null : editTime.trim();
    357. }
    358. /**
    359. * This method was generated by MyBatis Generator.
    360. * This method returns the value of the database column tbl_user.edit_by
    361. *
    362. * @return the value of tbl_user.edit_by
    363. *
    364. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    365. */
    366. public String getEditBy() {
    367. return editBy;
    368. }
    369. /**
    370. * This method was generated by MyBatis Generator.
    371. * This method sets the value of the database column tbl_user.edit_by
    372. *
    373. * @param editBy the value for tbl_user.edit_by
    374. *
    375. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    376. */
    377. public void setEditBy(String editBy) {
    378. this.editBy = editBy == null ? null : editBy.trim();
    379. }
    380. }

    UserMapper接口

    1. package com.it.crm.settings.mapper;
    2. import com.it.crm.settings.entity.User;
    3. public interface UserMapper {
    4. /**
    5. * This method was generated by MyBatis Generator.
    6. * This method corresponds to the database table tbl_user
    7. *
    8. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    9. */
    10. int deleteByPrimaryKey(String id);
    11. /**
    12. * This method was generated by MyBatis Generator.
    13. * This method corresponds to the database table tbl_user
    14. *
    15. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    16. */
    17. int insert(User record);
    18. /**
    19. * This method was generated by MyBatis Generator.
    20. * This method corresponds to the database table tbl_user
    21. *
    22. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    23. */
    24. int insertSelective(User record);
    25. /**
    26. * This method was generated by MyBatis Generator.
    27. * This method corresponds to the database table tbl_user
    28. *
    29. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    30. */
    31. User selectByPrimaryKey(String id);
    32. /**
    33. * This method was generated by MyBatis Generator.
    34. * This method corresponds to the database table tbl_user
    35. *
    36. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    37. */
    38. int updateByPrimaryKeySelective(User record);
    39. /**
    40. * This method was generated by MyBatis Generator.
    41. * This method corresponds to the database table tbl_user
    42. *
    43. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    44. */
    45. int updateByPrimaryKey(User record);
    46. }

    UserMapper.xml映射文件

     

    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
    3. <mapper namespace="com.it.crm.settings.mapper.UserMapper" >
    4. <resultMap id="BaseResultMap" type="com.it.crm.settings.entity.User" >
    5. <!--
    6. WARNING - @mbggenerated
    7. This element is automatically generated by MyBatis Generator, do not modify.
    8. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    9. -->
    10. <id column="id" property="id" jdbcType="CHAR" />
    11. <result column="login_act" property="loginAct" jdbcType="VARCHAR" />
    12. <result column="name" property="name" jdbcType="VARCHAR" />
    13. <result column="login_pwd" property="loginPwd" jdbcType="VARCHAR" />
    14. <result column="email" property="email" jdbcType="VARCHAR" />
    15. <result column="expire_time" property="expireTime" jdbcType="CHAR" />
    16. <result column="lock_state" property="lockState" jdbcType="CHAR" />
    17. <result column="deptno" property="deptno" jdbcType="CHAR" />
    18. <result column="allow_ips" property="allowIps" jdbcType="VARCHAR" />
    19. <result column="createTime" property="createtime" jdbcType="CHAR" />
    20. <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    21. <result column="edit_time" property="editTime" jdbcType="CHAR" />
    22. <result column="edit_by" property="editBy" jdbcType="VARCHAR" />
    23. </resultMap>
    24. <sql id="Base_Column_List" >
    25. <!--
    26. WARNING - @mbggenerated
    27. This element is automatically generated by MyBatis Generator, do not modify.
    28. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    29. -->
    30. id, login_act, name, login_pwd, email, expire_time, lock_state, deptno, allow_ips,
    31. createTime, create_by, edit_time, edit_by
    32. </sql>
    33. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    34. <!--
    35. WARNING - @mbggenerated
    36. This element is automatically generated by MyBatis Generator, do not modify.
    37. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    38. -->
    39. select
    40. <include refid="Base_Column_List" />
    41. from tbl_user
    42. where id = #{id,jdbcType=CHAR}
    43. </select>
    44. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    45. <!--
    46. WARNING - @mbggenerated
    47. This element is automatically generated by MyBatis Generator, do not modify.
    48. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    49. -->
    50. delete from tbl_user
    51. where id = #{id,jdbcType=CHAR}
    52. </delete>
    53. <insert id="insert" parameterType="com.it.crm.settings.entity.User" >
    54. <!--
    55. WARNING - @mbggenerated
    56. This element is automatically generated by MyBatis Generator, do not modify.
    57. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    58. -->
    59. insert into tbl_user (id, login_act, name,
    60. login_pwd, email, expire_time,
    61. lock_state, deptno, allow_ips,
    62. createTime, create_by, edit_time,
    63. edit_by)
    64. values (#{id,jdbcType=CHAR}, #{loginAct,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
    65. #{loginPwd,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{expireTime,jdbcType=CHAR},
    66. #{lockState,jdbcType=CHAR}, #{deptno,jdbcType=CHAR}, #{allowIps,jdbcType=VARCHAR},
    67. #{createtime,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{editTime,jdbcType=CHAR},
    68. #{editBy,jdbcType=VARCHAR})
    69. </insert>
    70. <insert id="insertSelective" parameterType="com.it.crm.settings.entity.User" >
    71. <!--
    72. WARNING - @mbggenerated
    73. This element is automatically generated by MyBatis Generator, do not modify.
    74. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    75. -->
    76. insert into tbl_user
    77. <trim prefix="(" suffix=")" suffixOverrides="," >
    78. <if test="id != null" >
    79. id,
    80. </if>
    81. <if test="loginAct != null" >
    82. login_act,
    83. </if>
    84. <if test="name != null" >
    85. name,
    86. </if>
    87. <if test="loginPwd != null" >
    88. login_pwd,
    89. </if>
    90. <if test="email != null" >
    91. email,
    92. </if>
    93. <if test="expireTime != null" >
    94. expire_time,
    95. </if>
    96. <if test="lockState != null" >
    97. lock_state,
    98. </if>
    99. <if test="deptno != null" >
    100. deptno,
    101. </if>
    102. <if test="allowIps != null" >
    103. allow_ips,
    104. </if>
    105. <if test="createtime != null" >
    106. createTime,
    107. </if>
    108. <if test="createBy != null" >
    109. create_by,
    110. </if>
    111. <if test="editTime != null" >
    112. edit_time,
    113. </if>
    114. <if test="editBy != null" >
    115. edit_by,
    116. </if>
    117. </trim>
    118. <trim prefix="values (" suffix=")" suffixOverrides="," >
    119. <if test="id != null" >
    120. #{id,jdbcType=CHAR},
    121. </if>
    122. <if test="loginAct != null" >
    123. #{loginAct,jdbcType=VARCHAR},
    124. </if>
    125. <if test="name != null" >
    126. #{name,jdbcType=VARCHAR},
    127. </if>
    128. <if test="loginPwd != null" >
    129. #{loginPwd,jdbcType=VARCHAR},
    130. </if>
    131. <if test="email != null" >
    132. #{email,jdbcType=VARCHAR},
    133. </if>
    134. <if test="expireTime != null" >
    135. #{expireTime,jdbcType=CHAR},
    136. </if>
    137. <if test="lockState != null" >
    138. #{lockState,jdbcType=CHAR},
    139. </if>
    140. <if test="deptno != null" >
    141. #{deptno,jdbcType=CHAR},
    142. </if>
    143. <if test="allowIps != null" >
    144. #{allowIps,jdbcType=VARCHAR},
    145. </if>
    146. <if test="createtime != null" >
    147. #{createtime,jdbcType=CHAR},
    148. </if>
    149. <if test="createBy != null" >
    150. #{createBy,jdbcType=VARCHAR},
    151. </if>
    152. <if test="editTime != null" >
    153. #{editTime,jdbcType=CHAR},
    154. </if>
    155. <if test="editBy != null" >
    156. #{editBy,jdbcType=VARCHAR},
    157. </if>
    158. </trim>
    159. </insert>
    160. <update id="updateByPrimaryKeySelective" parameterType="com.it.crm.settings.entity.User" >
    161. <!--
    162. WARNING - @mbggenerated
    163. This element is automatically generated by MyBatis Generator, do not modify.
    164. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    165. -->
    166. update tbl_user
    167. <set >
    168. <if test="loginAct != null" >
    169. login_act = #{loginAct,jdbcType=VARCHAR},
    170. </if>
    171. <if test="name != null" >
    172. name = #{name,jdbcType=VARCHAR},
    173. </if>
    174. <if test="loginPwd != null" >
    175. login_pwd = #{loginPwd,jdbcType=VARCHAR},
    176. </if>
    177. <if test="email != null" >
    178. email = #{email,jdbcType=VARCHAR},
    179. </if>
    180. <if test="expireTime != null" >
    181. expire_time = #{expireTime,jdbcType=CHAR},
    182. </if>
    183. <if test="lockState != null" >
    184. lock_state = #{lockState,jdbcType=CHAR},
    185. </if>
    186. <if test="deptno != null" >
    187. deptno = #{deptno,jdbcType=CHAR},
    188. </if>
    189. <if test="allowIps != null" >
    190. allow_ips = #{allowIps,jdbcType=VARCHAR},
    191. </if>
    192. <if test="createtime != null" >
    193. createTime = #{createtime,jdbcType=CHAR},
    194. </if>
    195. <if test="createBy != null" >
    196. create_by = #{createBy,jdbcType=VARCHAR},
    197. </if>
    198. <if test="editTime != null" >
    199. edit_time = #{editTime,jdbcType=CHAR},
    200. </if>
    201. <if test="editBy != null" >
    202. edit_by = #{editBy,jdbcType=VARCHAR},
    203. </if>
    204. </set>
    205. where id = #{id,jdbcType=CHAR}
    206. </update>
    207. <update id="updateByPrimaryKey" parameterType="com.it.crm.settings.entity.User" >
    208. <!--
    209. WARNING - @mbggenerated
    210. This element is automatically generated by MyBatis Generator, do not modify.
    211. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    212. -->
    213. update tbl_user
    214. set login_act = #{loginAct,jdbcType=VARCHAR},
    215. name = #{name,jdbcType=VARCHAR},
    216. login_pwd = #{loginPwd,jdbcType=VARCHAR},
    217. email = #{email,jdbcType=VARCHAR},
    218. expire_time = #{expireTime,jdbcType=CHAR},
    219. lock_state = #{lockState,jdbcType=CHAR},
    220. deptno = #{deptno,jdbcType=CHAR},
    221. allow_ips = #{allowIps,jdbcType=VARCHAR},
    222. createTime = #{createtime,jdbcType=CHAR},
    223. create_by = #{createBy,jdbcType=VARCHAR},
    224. edit_time = #{editTime,jdbcType=CHAR},
    225. edit_by = #{editBy,jdbcType=VARCHAR}
    226. where id = #{id,jdbcType=CHAR}
    227. </update>
    228. </mapper>

  • 相关阅读:
    RabbitMQ学习整理————基于RabbitMQ实现RPC
    使用键盘控制Franka机械臂运动
    不允许还有Java程序员不了解BlockingQueue阻塞队列的实现原理
    使用 sqlc 生成类型安全的Go代码与SQL数据库交互
    多线程调用外部接口
    uniapp tabBar app页面滚动闪屏的问题
    实时输出Java8 HashMap数据结构
    DataX DorisWriter 插件DorisStreamLoadObserver类详细解读
    我的NAS方案及使用的功能
    手把手教你Nginx常用模块详解之ngx_http_access_module(一)
  • 原文地址:https://blog.csdn.net/weixin_59334478/article/details/125518545