Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
springboot-cli
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
springboot-cli
Commits
73cadb12
Commit
73cadb12
authored
Oct 24, 2023
by
gechengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交Mps/Mpi/Mpe/Lck等相关类和配置
parent
248d9dc8
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
478 additions
and
61 deletions
+478
-61
pom.xml
pom.xml
+10
-0
MpsController.java
src/main/java/com/brilliance/controller/MpsController.java
+0
-33
XxxtskController.java
...main/java/com/brilliance/controller/XxxtskController.java
+79
-0
Lck.java
src/main/java/com/brilliance/entity/Lck.java
+36
-0
LckMapper.java
src/main/java/com/brilliance/mapper/LckMapper.java
+13
-0
MpsMapper.java
src/main/java/com/brilliance/mapper/MpsMapper.java
+7
-1
LckService.java
src/main/java/com/brilliance/service/LckService.java
+23
-0
MpsService.java
src/main/java/com/brilliance/service/MpsService.java
+8
-1
LckServiceImpl.java
...main/java/com/brilliance/service/impl/LckServiceImpl.java
+87
-0
MpsServiceServiceImpl.java
...va/com/brilliance/service/impl/MpsServiceServiceImpl.java
+28
-2
DbCommonUtil.java
src/main/java/com/brilliance/util/DbCommonUtil.java
+29
-0
LckMapper.xml
src/main/resources/com/brilliance/mapper/LckMapper.xml
+46
-0
MpsMapper.xml
src/main/resources/com/brilliance/mapper/MpsMapper.xml
+17
-1
dbConfig.properties
src/main/resources/dbConfig.properties
+0
-0
generatorConfig.xml
src/main/resources/generatorConfig.xml
+21
-23
mybatis-config.xml
src/main/resources/mybatis-config.xml
+28
-0
MybatisTest.java
src/test/java/com/brilliance/test/MybatisTest.java
+46
-0
No files found.
pom.xml
View file @
73cadb12
...
...
@@ -25,6 +25,13 @@
</properties>
<dependencies>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
...
...
@@ -79,6 +86,9 @@
<version>
11.2.0.3
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/brilliance/controller/MpsController.java
deleted
100644 → 0
View file @
248d9dc8
package
com
.
brilliance
.
controller
;
import
com.brilliance.entity.Mps
;
import
com.brilliance.service.MpsService
;
import
com.brilliance.vo.Result
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@RestController
@RequestMapping
(
"mps"
)
public
class
MpsController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Autowired
private
MpsService
mpsService
;
@PostMapping
(
"getMps"
)
/* public Result userList(@RequestParam("pageNum") Integer pageNum,
@RequestParam("pageSize") Integer pageSize) {*/
public
Result
userList
()
{
List
<
Mps
>
mpsList
=
mpsService
.
getMpsList
(
">"
,
"D"
,
new
Date
());
return
new
Result
(
"success"
);
}
}
src/main/java/com/brilliance/controller/XxxtskController.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
controller
;
import
com.brilliance.entity.Mps
;
import
com.brilliance.service.LckService
;
import
com.brilliance.service.MpsService
;
import
com.brilliance.vo.Result
;
import
org.apache.commons.lang.reflect.MethodUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@RestController
@RequestMapping
(
"mps"
)
public
class
XxxtskController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Autowired
private
MpsService
mpsService
;
@Autowired
private
LckService
lckService
;
@PostMapping
(
"xxxtsk"
)
public
Result
userList
()
{
List
<
Mps
>
mpsList
=
mpsService
.
getMpsList
(
"XXX"
,
">"
,
"A"
,
new
Date
(),
"sttdattim ASC"
);
for
(
Mps
mps
:
mpsList
){
}
Mps
mps
=
new
Mps
();
String
inr
=
"CTEST001"
;
mps
.
setInr
(
inr
);
mps
.
setChncod
(
"SWT"
);
mps
.
setDir
(
">"
);
mps
.
setLstdattim
(
new
Date
());
mps
.
setRcvdattim
(
new
Date
());
mps
.
setSrcchncod
(
"CTS"
);
mps
.
setSta
(
"W"
);
mps
.
setSttdattim
(
new
Date
());
mps
.
setIsmx
(
0L
);
//mpsService.test();
// mpsService.insert(mps);
// mpsService.delete(inr);
return
new
Result
(
mpsList
);
}
public
static
void
main
(
String
[]
args
)
{
Mps
mps
=
new
Mps
();
mps
.
setInr
(
"TEST0001"
);
System
.
out
.
println
(
mps
.
getClass
().
getSimpleName
().
toLowerCase
());
try
{
Object
inrObj
=
MethodUtils
.
invokeMethod
(
mps
,
"getInr"
,
null
);
System
.
out
.
println
(
inrObj
);
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/com/brilliance/entity/Lck.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
entity
;
import
java.util.Date
;
public
class
Lck
{
private
String
nam
;
private
String
txt
;
private
Date
dattim
;
public
String
getNam
()
{
return
nam
;
}
public
void
setNam
(
String
nam
)
{
this
.
nam
=
nam
==
null
?
null
:
nam
.
trim
();
}
public
String
getTxt
()
{
return
txt
;
}
public
void
setTxt
(
String
txt
)
{
this
.
txt
=
txt
==
null
?
null
:
txt
.
trim
();
}
public
Date
getDattim
()
{
return
dattim
;
}
public
void
setDattim
(
Date
dattim
)
{
this
.
dattim
=
dattim
;
}
}
\ No newline at end of file
src/main/java/com/brilliance/mapper/LckMapper.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
mapper
;
import
com.brilliance.entity.Lck
;
import
org.apache.ibatis.annotations.Param
;
public
interface
LckMapper
{
int
insert
(
Lck
record
);
int
insertSelective
(
Lck
record
);
int
deleteByPrimaryKey
(
@Param
(
"txt"
)
String
txt
,
@Param
(
"nam"
)
String
nam
);
}
\ No newline at end of file
src/main/java/com/brilliance/mapper/MpsMapper.java
View file @
73cadb12
...
...
@@ -18,8 +18,13 @@ public interface MpsMapper {
int
updateByPrimaryKeySelective
(
Mps
record
);
int
updateByPrimaryKey
(
Mps
record
);
//Platform.mdbReadset($mpslst,new Argument("nxtchncod",channel).and("sta",state).and("dir",dir).and("sttdattim",LE,new Date()),new Argument("sttdattim",ASC));
List
<
Mps
>
getMpsList
(
@Param
(
"nxtchncod"
)
String
nxtchncod
,
@Param
(
"dir"
)
String
dir
,
@Param
(
"sta"
)
String
sta
,
@Param
(
"sttdattim"
)
Date
sttdattim
,
@Param
(
"orderBy"
)
String
orderBy
)
;
List
<
Mps
>
getMpsList
(
@Param
(
"dir"
)
String
dir
,
@Param
(
"sta"
)
String
sta
,
@Param
(
"sttdattim"
)
Date
sttdattim
)
;
int
counterMps
(
@Param
(
"dir"
)
String
dir
);
String
getSrcchncod
(
@Param
(
"inr"
)
String
inr
);
}
\ No newline at end of file
src/main/java/com/brilliance/service/LckService.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
service
;
import
com.brilliance.entity.Mps
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
public
interface
LckService
{
boolean
dbLock
(
Object
obj
,
String
userName
);
boolean
dbUnlock
(
Object
obj
,
String
userName
);
boolean
dbLock
(
String
modeType
,
String
inr
,
String
userName
);
boolean
dbUnlock
(
String
modeType
,
String
inr
,
String
name
);
}
src/main/java/com/brilliance/service/MpsService.java
View file @
73cadb12
...
...
@@ -13,5 +13,12 @@ import java.util.List;
*/
public
interface
MpsService
{
List
<
Mps
>
getMpsList
(
@Param
(
"dir"
)
String
dir
,
@Param
(
"sta"
)
String
sta
,
@Param
(
"sttdattim"
)
Date
sttdattim
);
List
<
Mps
>
getMpsList
(
String
nxtchncod
,
String
dir
,
String
sta
,
Date
sttdattim
,
String
orderBy
)
;
boolean
insert
(
Mps
mps
);
boolean
delete
(
String
inr
);
void
test
();
}
src/main/java/com/brilliance/service/impl/LckServiceImpl.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
service
.
impl
;
import
com.brilliance.entity.Lck
;
import
com.brilliance.mapper.LckMapper
;
import
com.brilliance.service.LckService
;
import
org.apache.commons.lang.reflect.MethodUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Date
;
/**
* @Description
* @Author gechengyang
* @Date 2023/10/23
*/
@Service
public
class
LckServiceImpl
implements
LckService
{
@Autowired
private
LckMapper
lckMapper
;
@Override
public
boolean
dbLock
(
Object
obj
,
String
userName
)
{
Lck
lck
=
new
Lck
();
Object
inrObj
=
null
;
if
(
obj
==
null
)
return
false
;
String
modeType
=
obj
.
getClass
().
getSimpleName
().
toLowerCase
();
try
{
inrObj
=
MethodUtils
.
invokeMethod
(
obj
,
"getInr"
,
null
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
if
(
inrObj
==
null
)
{
return
false
;
}
String
inr
=
(
String
)
inrObj
;
lck
.
setTxt
(
modeType
+
inr
);
lck
.
setNam
(
userName
);
lck
.
setDattim
(
new
Date
());
int
insert
=
lckMapper
.
insert
(
lck
);
if
(
insert
>
0
)
return
true
;
return
false
;
}
@Override
public
boolean
dbUnlock
(
Object
obj
,
String
userName
)
{
String
modeType
=
obj
.
getClass
().
getSimpleName
().
toLowerCase
();
String
inr
=
""
;
try
{
Object
inrObj
=
MethodUtils
.
invokeMethod
(
obj
,
"getInr"
,
null
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
String
txt
=
modeType
+
inr
;
int
delete
=
lckMapper
.
deleteByPrimaryKey
(
txt
,
userName
);
if
(
delete
>
0
)
return
true
;
return
false
;
}
@Override
public
boolean
dbLock
(
String
modeType
,
String
inr
,
String
userName
)
{
Lck
lck
=
new
Lck
();
lck
.
setTxt
(
modeType
+
inr
);
lck
.
setNam
(
userName
);
int
insert
=
lckMapper
.
insert
(
lck
);
if
(
insert
>
0
)
return
true
;
return
false
;
}
@Override
public
boolean
dbUnlock
(
String
modeType
,
String
inr
,
String
name
)
{
String
txt
=
modeType
+
inr
;
int
delete
=
lckMapper
.
deleteByPrimaryKey
(
txt
,
name
);
if
(
delete
>
0
)
return
true
;
return
false
;
}
}
src/main/java/com/brilliance/service/impl/MpsServiceServiceImpl.java
View file @
73cadb12
...
...
@@ -3,6 +3,7 @@ package com.brilliance.service.impl;
import
com.brilliance.entity.Mps
;
import
com.brilliance.mapper.MpsMapper
;
import
com.brilliance.service.MpsService
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -22,7 +23,32 @@ public class MpsServiceServiceImpl implements MpsService {
@Override
public
List
<
Mps
>
getMpsList
(
String
dir
,
String
sta
,
Date
sttdattim
)
{
return
mpsMapper
.
getMpsList
(
dir
,
sta
,
sttdattim
);
public
List
<
Mps
>
getMpsList
(
String
nxtchncod
,
String
dir
,
String
sta
,
Date
sttdattim
,
String
orderBy
)
{
return
mpsMapper
.
getMpsList
(
nxtchncod
,
dir
,
sta
,
sttdattim
,
orderBy
);
}
@Override
public
boolean
insert
(
Mps
mps
)
{
int
insert
=
mpsMapper
.
insert
(
mps
);
if
(
insert
>
0
)
return
true
;
else
return
false
;
}
@Override
public
boolean
delete
(
String
inr
)
{
int
deleteByPrimaryKey
=
mpsMapper
.
deleteByPrimaryKey
(
inr
);
if
(
deleteByPrimaryKey
>
0
)
return
true
;
else
return
false
;
}
@Override
public
void
test
()
{
int
i
=
mpsMapper
.
counterMps
(
">"
);
String
srcchncod
=
mpsMapper
.
getSrcchncod
(
"00000972"
);
}
}
src/main/java/com/brilliance/util/DbCommonUtil.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
util
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
DbCommonUtil
{
private
static
String
resource
=
"mybatis-config.xml"
;
public
static
SqlSession
getSqlSession
()
throws
IOException
{
InputStream
inputStream
=
Resources
.
getResourceAsStream
(
resource
);
SqlSessionFactory
sqlSessionFactory
=
new
SqlSessionFactoryBuilder
().
build
(
inputStream
);
// sqlSessionFactory.getConfiguration().addMapper(MpsMapper.class);
//2. 获取SqlSession对象,用它来执行sql
SqlSession
openSession
=
sqlSessionFactory
.
openSession
();
return
openSession
;
}
public
static
void
close
(
SqlSession
sqlSession
){
if
(
sqlSession
==
null
)
return
;
sqlSession
.
close
();
}
}
src/main/resources/com/brilliance/mapper/LckMapper.xml
0 → 100644
View file @
73cadb12
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.brilliance.mapper.LckMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.brilliance.entity.Lck"
>
<result
column=
"NAM"
property=
"nam"
jdbcType=
"VARCHAR"
/>
<result
column=
"TXT"
property=
"txt"
jdbcType=
"VARCHAR"
/>
<result
column=
"DATTIM"
property=
"dattim"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<insert
id=
"insert"
parameterType=
"com.brilliance.entity.Lck"
>
insert into TEST.LCK (NAM, TXT, DATTIM
)
values (#{nam,jdbcType=VARCHAR}, #{txt,jdbcType=VARCHAR}, #{dattim,jdbcType=TIMESTAMP}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.brilliance.entity.Lck"
>
insert into TEST.LCK
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"nam != null"
>
NAM,
</if>
<if
test=
"txt != null"
>
TXT,
</if>
<if
test=
"dattim != null"
>
DATTIM,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"nam != null"
>
#{nam,jdbcType=VARCHAR},
</if>
<if
test=
"txt != null"
>
#{txt,jdbcType=VARCHAR},
</if>
<if
test=
"dattim != null"
>
#{dattim,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.String"
>
delete from TEST.LCK
where TXT = #{txt,jdbcType=CHAR} and NAM=#{nam}
</delete>
</mapper>
\ No newline at end of file
src/main/resources/com/brilliance/mapper/MpsMapper.xml
View file @
73cadb12
...
...
@@ -50,6 +50,9 @@
<select
id=
"getMpsList"
resultType=
"com.brilliance.entity.Mps"
>
select * from mps
where 1=1
<if
test=
"nxtchncod != null"
>
and nxtchncod = #{nxtchncod}
</if>
<if
test=
"dir != null"
>
and dir = #{dir}
</if>
...
...
@@ -59,8 +62,21 @@
<if
test=
"sttdattim != null"
>
and sttdattim
<
= #{sttdattim}
</if>
<if
test=
"orderBy != null"
>
order by #{orderBy}
</if>
</select>
<select
id=
"counterMps"
resultType=
"java.lang.Integer"
>
select count(*) cnt from mps where dir=#{dir}
</select>
<select
id=
"getSrcchncod"
resultType=
"java.lang.String"
>
select srcchncod from mps where inr=#{inr}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.String"
>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.String"
>
delete from TEST.MPS
where INR = #{inr,jdbcType=CHAR}
</delete>
...
...
src/main/resources/
generator
.properties
→
src/main/resources/
dbConfig
.properties
View file @
73cadb12
File moved
src/main/resources/generatorConfig.xml
View file @
73cadb12
...
...
@@ -4,11 +4,12 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry
location=
"E:\programFile\work\MavenRepository\com\oracle\ojdbc6\11.2.0.3\ojdbc6-11.2.0.3.jar"
/>
<!--导入属性配置-->
<!--
<properties resource="generator.properties"></properties>
-->
<properties
resource=
"dbConfig.properties"
></properties>
<classPathEntry
location=
"E:\programFile\work\MavenRepository\com\oracle\ojdbc6\11.2.0.3\ojdbc6-11.2.0.3.jar"
/>
<!--指定特定数据库的jdbc驱动jar包的位置-->
...
...
@@ -21,9 +22,9 @@
</commentGenerator>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"
oracle.jdbc.driver.OracleDriver
"
connectionURL=
"
jdbc:oracle:thin:@114.115.138.98:9400:XE
"
userId=
"
test"
password=
"test
"
>
<jdbcConnection
driverClass=
"
${jdbc.driverClass}
"
connectionURL=
"
${jdbc.connectionURL}
"
userId=
"
${jdbc.userId}"
password=
"${jdbc.password}
"
>
<property
name=
"nullCatalogMeansCurrent"
value=
"true"
/>
</jdbcConnection>
...
...
@@ -59,26 +60,22 @@
<!-- <property name="enableSubPackages" value="true"/>-->
</javaClientGenerator>
<
table
schema=
"test"
tableName=
"MPI"
domainObjectName=
"Mpi
"
enableCountByExample=
"false"
<
!--<table schema="test" tableName="LCK" domainObjectName="Lck
" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId=
"false"
/>
selectByExampleQueryId="false"/>
-->
<table
schema=
"test"
tableName=
"MPS"
domainObjectName=
"Mps"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
<table
schema=
"test"
tableName=
"MPE"
domainObjectName=
"Mpe"
enableCountByExample=
"false"
<table
schema=
"test"
tableName=
"MPI"
domainObjectName=
"Mpi"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
<!--
<table schema="test" tableName="MPS" domainObjectName="Mps" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<table schema="test" tableName="MPE" domainObjectName="Mpe" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>-->
</context>
<!-- <table tableName="usr" domainObjectName="Usr" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"/>-->
<!-- <table tableName="rol" domainObjectName="Rol" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"/>-->
<!-- <table tableName="usr_rol" domainObjectName="UsrRol" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"/>-->
</generatorConfiguration>
\ No newline at end of file
src/main/resources/mybatis-config.xml
0 → 100644
View file @
73cadb12
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties
resource=
"dbConfig.properties"
/>
<environments
default=
"development"
>
<environment
id=
"development"
>
<transactionManager
type=
"JDBC"
/>
<dataSource
type=
"POOLED"
>
<property
name=
"driver"
value=
"${jdbc.driverClass}"
/>
<property
name=
"url"
value=
"${jdbc.connectionURL}"
/>
<property
name=
"username"
value=
"${jdbc.userId}"
/>
<property
name=
"password"
value=
"${jdbc.password}"
/>
</dataSource>
</environment>
</environments>
<mappers>
<!-- <package name="mappers"/>-->
<!--<mapper resource="com/brilliance/mappers/MpsMapper.xml"/>-->
<mapper
resource=
"com/brilliance/mapper/MpsMapper.xml"
/>
<mapper
resource=
"com/brilliance/mapper/MpiMapper.xml"
/>
<mapper
resource=
"com/brilliance/mapper/MpeMapper.xml"
/>
<mapper
resource=
"com/brilliance/mapper/LckMapper.xml"
/>
</mappers>
</configuration>
src/test/java/com/brilliance/test/MybatisTest.java
0 → 100644
View file @
73cadb12
package
com
.
brilliance
.
test
;
import
com.brilliance.entity.Mpi
;
import
com.brilliance.mapper.MpiMapper
;
import
com.brilliance.mapper.MpsMapper
;
import
com.brilliance.util.DbCommonUtil
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
MybatisTest
{
@Test
public
void
test
()
throws
Exception
{
String
resource
=
"mybatis-config.xml"
;
InputStream
inputStream
=
Resources
.
getResourceAsStream
(
resource
);
SqlSessionFactory
sqlSessionFactory
=
new
SqlSessionFactoryBuilder
().
build
(
inputStream
);
// sqlSessionFactory.getConfiguration().addMapper(MpsMapper.class);
//2. 获取SqlSession对象,用它来执行sql
SqlSession
openSession
=
sqlSessionFactory
.
openSession
();
MpsMapper
mpsMapper
=
openSession
.
getMapper
(
MpsMapper
.
class
);
int
cnt
=
mpsMapper
.
counterMps
(
">"
);
System
.
out
.
println
(
"cnt="
+
cnt
);
openSession
.
close
();
}
@Test
public
void
test2
()
throws
Exception
{
SqlSession
openSession
=
DbCommonUtil
.
getSqlSession
();
MpsMapper
mpsMapper
=
openSession
.
getMapper
(
MpsMapper
.
class
);
int
cnt
=
mpsMapper
.
counterMps
(
">"
);
System
.
out
.
println
(
"cnt="
+
cnt
);
MpiMapper
mpiMapper
=
openSession
.
getMapper
(
MpiMapper
.
class
);
Mpi
mpi
=
mpiMapper
.
getMpi
(
"CFIX2022080100000901"
,
"<"
);
System
.
out
.
println
(
mpi
.
getInr
());
DbCommonUtil
.
close
(
openSession
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment