Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-control
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
常超
xzxt-control
Commits
e76123ab
Commit
e76123ab
authored
Mar 08, 2019
by
chang_chao@founder.com.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加fmq多数据源配置
parent
52602246
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
231 additions
and
7 deletions
+231
-7
src/main/java/com/cc/config/DataSourceFmqConfig.java
+41
-0
src/main/java/com/cc/controller/HelloController.java
+9
-0
src/main/java/com/cc/mapper/fmq/UserFmqDemoMapper.java
+19
-0
src/main/java/com/cc/service/UserFmqDmeoService.java
+21
-0
src/main/java/com/cc/service/serviceimpl/UserServiceFmqDemoImpl.java
+34
-0
src/main/resources/application-dev.yml
+9
-2
src/main/resources/application-pro.yml
+11
-5
src/main/resources/mybatis/mapper/fmq/UserFmqDemoMapper.xml
+87
-0
No files found.
src/main/java/com/cc/config/DataSourceFmqConfig.java
0 → 100644
View file @
e76123ab
package
com
.
cc
.
config
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
javax.sql.DataSource
;
/**
* Created by summer on 2016/11/25.
*/
@Configuration
@MapperScan
(
basePackages
=
"com.cc.mapper.fmq"
,
sqlSessionTemplateRef
=
"fmqSqlSessionTemplate"
)
public
class
DataSourceFmqConfig
{
@Bean
(
name
=
"fmqDataSource"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource.fmq"
)
public
DataSource
xzxtDataSource
()
{
return
DataSourceBuilder
.
create
().
build
();
}
@Bean
(
name
=
"fmqSqlSessionFactory"
)
public
SqlSessionFactory
xzxtSqlSessionFactory
(
@Qualifier
(
"fmqDataSource"
)
DataSource
dataSource
)
throws
Exception
{
SqlSessionFactoryBean
bean
=
new
SqlSessionFactoryBean
();
bean
.
setDataSource
(
dataSource
);
bean
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:mybatis/mapper/fmq/*.xml"
));
return
bean
.
getObject
();
}
@Bean
(
name
=
"fmqSqlSessionTemplate"
)
public
SqlSessionTemplate
xzxtSqlSessionTemplate
(
@Qualifier
(
"fmqSqlSessionFactory"
)
SqlSessionFactory
sqlSessionFactory
)
throws
Exception
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
}
src/main/java/com/cc/controller/HelloController.java
View file @
e76123ab
...
@@ -2,6 +2,7 @@ package com.cc.controller;
...
@@ -2,6 +2,7 @@ package com.cc.controller;
import
com.cc.bean.AutoSysUser
;
import
com.cc.bean.AutoSysUser
;
import
com.cc.common.ResultMap
;
import
com.cc.common.ResultMap
;
import
com.cc.service.UserFmqDmeoService
;
import
com.cc.service.UserXzxtDmeoService
;
import
com.cc.service.UserXzxtDmeoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
...
@@ -15,6 +16,8 @@ import java.util.List;
...
@@ -15,6 +16,8 @@ import java.util.List;
public
class
HelloController
{
public
class
HelloController
{
@Autowired
@Autowired
UserXzxtDmeoService
userXzxtDmeoService
;
UserXzxtDmeoService
userXzxtDmeoService
;
@Autowired
UserFmqDmeoService
userFmqDmeoService
;
@GetMapping
(
"/abc"
)
@GetMapping
(
"/abc"
)
public
String
hello
(
Model
model
){
public
String
hello
(
Model
model
){
model
.
addAttribute
(
"msg"
,
"你好"
);
model
.
addAttribute
(
"msg"
,
"你好"
);
...
@@ -26,4 +29,10 @@ public class HelloController {
...
@@ -26,4 +29,10 @@ public class HelloController {
return
userXzxtDmeoService
.
userAll
();
return
userXzxtDmeoService
.
userAll
();
}
}
@ResponseBody
@GetMapping
(
"/fmqdemo"
)
public
ResultMap
fmqdemo
(
Model
model
){
return
userFmqDmeoService
.
userAll
();
}
}
}
src/main/java/com/cc/mapper/fmq/UserFmqDemoMapper.java
0 → 100644
View file @
e76123ab
package
com
.
cc
.
mapper
.
fmq
;
import
com.cc.bean.User
;
import
java.util.List
;
public
interface
UserFmqDemoMapper
{
/**
* 获取所有用户
*
*
* @return
*/
List
<
User
>
userAll
();
}
src/main/java/com/cc/service/UserFmqDmeoService.java
0 → 100644
View file @
e76123ab
package
com
.
cc
.
service
;
import
com.cc.common.ResultMap
;
/**
* @author yutons
*/
public
interface
UserFmqDmeoService
{
/**
* 登录逻辑
* 1、先根据用户名查询用户对象
* 2、如果有用户对象,则继续匹配密码
* 如果没有用户对象,则抛出异常
*
* @return
*/
ResultMap
userAll
();
}
src/main/java/com/cc/service/serviceimpl/UserServiceFmqDemoImpl.java
0 → 100644
View file @
e76123ab
package
com
.
cc
.
service
.
serviceimpl
;
import
com.cc.bean.User
;
import
com.cc.common.ResultMap
;
import
com.cc.mapper.fmq.UserFmqDemoMapper
;
import
com.cc.mapper.xzxt.UserXzxtDemoMapper
;
import
com.cc.service.UserFmqDmeoService
;
import
com.cc.service.UserXzxtDmeoService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
UserServiceFmqDemoImpl
implements
UserFmqDmeoService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserServiceFmqDemoImpl
.
class
);
@Resource
private
UserFmqDemoMapper
userFmqDemoMapper
;
@Override
public
ResultMap
userAll
()
{
List
<
User
>
userlist
=
userFmqDemoMapper
.
userAll
();
ResultMap
resultMap
=
new
ResultMap
();
if
(!
StringUtils
.
isEmpty
(
userlist
))
{
resultMap
.
setData
(
userlist
);
return
resultMap
;
}
return
resultMap
;
}
}
src/main/resources/application-dev.yml
View file @
e76123ab
...
@@ -5,14 +5,21 @@ spring:
...
@@ -5,14 +5,21 @@ spring:
driverClassName
:
com.mysql.jdbc.Driver
driverClassName
:
com.mysql.jdbc.Driver
username
:
root
username
:
root
password
:
123
password
:
123
#
spring2.0此处为jdbc-ur
l
#
mysq
l
jdbc-url
:
jdbc:mysql://127.0.0.1:3306/mybatis
jdbc-url
:
jdbc:mysql://127.0.0.1:3306/mybatis
type
:
com.alibaba.druid.pool.DruidDataSource
type
:
com.alibaba.druid.pool.DruidDataSource
xzxt
:
xzxt
:
driverClassName
:
oracle.jdbc.driver.OracleDriver
driverClassName
:
oracle.jdbc.driver.OracleDriver
username
:
XZXT
username
:
XZXT
password
:
XZXT
password
:
XZXT
# spring2.0此处为jdbc-url
# oracle
jdbc-url
:
jdbc:oracle:thin:@127.0.0.1:1521:XZXT
type
:
com.alibaba.druid.pool.DruidDataSource
fmq
:
driverClassName
:
oracle.jdbc.driver.OracleDriver
username
:
XZXT
password
:
XZXT
# oracle
jdbc-url
:
jdbc:oracle:thin:@127.0.0.1:1521:XZXT
jdbc-url
:
jdbc:oracle:thin:@127.0.0.1:1521:XZXT
type
:
com.alibaba.druid.pool.DruidDataSource
type
:
com.alibaba.druid.pool.DruidDataSource
...
...
src/main/resources/application-pro.yml
View file @
e76123ab
spring
:
spring
:
datasource
:
datasource
:
#
数据源基本配置
#
数据源基本配置
mysql
:
mysql
:
driverClassName
:
com.mysql.jdbc.Driver
driverClassName
:
com.mysql.jdbc.Driver
username
:
root
username
:
root
password
:
123
password
:
123
#
spring2.0此处为jdbc-ur
l
#
mysq
l
jdbc-url
:
jdbc:mysql://127.0.0.1:3306/mybatis
jdbc-url
:
jdbc:mysql://127.0.0.1:3306/mybatis
type
:
com.alibaba.druid.pool.DruidDataSource
type
:
com.alibaba.druid.pool.DruidDataSource
xzxt
:
xzxt
:
driverClassName
:
oracle.jdbc.driver.OracleDriver
driverClassName
:
oracle.jdbc.driver.OracleDriver
username
:
XZXT
username
:
XZXT
password
:
XZXT
password
:
XZXT
# spring2.0此处为jdbc-url
# oracle
jdbc-url
:
jdbc:oracle:thin:@192.168.1.109:1521:XZXT
jdbc-url
:
jdbc:oracle:thin:@127.0.0.1:1521:XZXT
type
:
com.alibaba.druid.pool.DruidDataSource
fmq
:
driverClassName
:
oracle.jdbc.driver.OracleDriver
username
:
XZXT
password
:
XZXT
# oracle
jdbc-url
:
jdbc:oracle:thin:@127.0.0.1:1521:XZXT
type
:
com.alibaba.druid.pool.DruidDataSource
type
:
com.alibaba.druid.pool.DruidDataSource
#schema:
#schema:
# - classpath:sql/department.sql
# - classpath:sql/department.sql
# - classpath:sql/employee.sql
# - classpath:sql/employee.sql
...
...
src/main/resources/mybatis/mapper/fmq/UserFmqDemoMapper.xml
0 → 100644
View file @
e76123ab
<?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.cc.mapper.fmq.UserFmqDemoMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.cc.bean.AutoSysUser"
>
<id
column=
"id"
property=
"id"
jdbcType=
"VARCHAR"
/>
<result
column=
"birthday"
property=
"birthday"
jdbcType=
"VARCHAR"
/>
<result
column=
"gzzm_zcy"
property=
"gzzmZcy"
jdbcType=
"VARCHAR"
/>
<result
column=
"glybz"
property=
"glybz"
jdbcType=
"VARCHAR"
/>
<result
column=
"lrdwmc"
property=
"lrdwmc"
jdbcType=
"VARCHAR"
/>
<result
column=
"lrdwdm"
property=
"lrdwdm"
jdbcType=
"VARCHAR"
/>
<result
column=
"policemanid"
property=
"policemanid"
jdbcType=
"VARCHAR"
/>
<result
column=
"gzzm_play"
property=
"gzzmPlay"
jdbcType=
"VARCHAR"
/>
<result
column=
"grade"
property=
"grade"
jdbcType=
"VARCHAR"
/>
<result
column=
"sex"
property=
"sex"
jdbcType=
"VARCHAR"
/>
<result
column=
"username"
property=
"username"
jdbcType=
"VARCHAR"
/>
<result
column=
"password"
property=
"password"
jdbcType=
"VARCHAR"
/>
<result
column=
"true_name"
property=
"trueName"
jdbcType=
"VARCHAR"
/>
<result
column=
"unitcode"
property=
"unitcode"
jdbcType=
"VARCHAR"
/>
<result
column=
"gxsj"
property=
"gxsj"
jdbcType=
"VARCHAR"
/>
<result
column=
"lrsj"
property=
"lrsj"
jdbcType=
"VARCHAR"
/>
<result
column=
"scbz"
property=
"scbz"
jdbcType=
"VARCHAR"
/>
<result
column=
"unitname"
property=
"unitname"
jdbcType=
"VARCHAR"
/>
<result
column=
"tqyhbz"
property=
"tqyhbz"
jdbcType=
"VARCHAR"
/>
<result
column=
"gxr"
property=
"gxr"
jdbcType=
"VARCHAR"
/>
<result
column=
"lrr"
property=
"lrr"
jdbcType=
"VARCHAR"
/>
<result
column=
"ip"
property=
"ip"
jdbcType=
"VARCHAR"
/>
<result
column=
"default_model"
property=
"defaultModel"
jdbcType=
"VARCHAR"
/>
<result
column=
"remark"
property=
"remark"
jdbcType=
"VARCHAR"
/>
<result
column=
"default_desktop"
property=
"defaultDesktop"
jdbcType=
"VARCHAR"
/>
<result
column=
"lastlogintime"
property=
"lastlogintime"
jdbcType=
"VARCHAR"
/>
<result
column=
"lastchecktime"
property=
"lastchecktime"
jdbcType=
"VARCHAR"
/>
<result
column=
"theme"
property=
"theme"
jdbcType=
"VARCHAR"
/>
<result
column=
"gzzm_zhy"
property=
"gzzmZhy"
jdbcType=
"VARCHAR"
/>
<result
column=
"open_flag"
property=
"openFlag"
jdbcType=
"VARCHAR"
/>
<result
column=
"gzzm_ypy"
property=
"gzzmYpy"
jdbcType=
"VARCHAR"
/>
<result
column=
"identitycard"
property=
"identitycard"
jdbcType=
"VARCHAR"
/>
<result
column=
"telephone"
property=
"telephone"
jdbcType=
"VARCHAR"
/>
<result
column=
"xxzyurl"
property=
"xxzyurl"
jdbcType=
"VARCHAR"
/>
</resultMap>
<!-- public Employee getEmpById(Integer id);
public void insertEmp(Employee employee);-->
<sql
id=
"Base_Column_List"
>
birthday
,gzzm_zcy
,glybz
,lrdwmc
,lrdwdm
,policemanid
,gzzm_play
,grade
,sex
,username
,password
,true_name
,unitcode
,gxsj
,lrsj
,scbz
,unitname
,tqyhbz
,gxr
,lrr
,id
,ip
,default_model
,remark
,default_desktop
,lastlogintime
,lastchecktime
,theme
,gzzm_zhy
,open_flag
,gzzm_ypy
,identitycard
,telephone
,xxzyurl
</sql>
<select
id=
"userAll"
resultType=
"com.cc.bean.AutoSysUser"
>
SELECT * FROM sys_user
</select>
</mapper>
\ No newline at end of file
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