Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
govdna
Project
Project
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
开发共享交流平台
govdna
Commits
8bd28814
Commit
8bd28814
authored
6 years ago
by
Fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http://115.233.227.46:8066/root/govdna.git
parents
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
1799 additions
and
0 deletions
+1799
-0
.classpath
.classpath
+36
-0
.gitignore
.gitignore
+1
-0
.project
.project
+23
-0
org.eclipse.core.resources.prefs
.settings/org.eclipse.core.resources.prefs
+6
-0
org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+5
-0
org.eclipse.m2e.core.prefs
.settings/org.eclipse.m2e.core.prefs
+4
-0
pom.xml
pom.xml
+200
-0
RenrenApplication.java
src/main/java/com/govmade/RenrenApplication.java
+25
-0
OAuth2Filter.java
src/main/java/com/govmade/common/oauth2/OAuth2Filter.java
+0
-0
OAuth2Realm.java
src/main/java/com/govmade/common/oauth2/OAuth2Realm.java
+0
-0
OAuth2Token.java
src/main/java/com/govmade/common/oauth2/OAuth2Token.java
+0
-0
TokenGenerator.java
src/main/java/com/govmade/common/oauth2/TokenGenerator.java
+0
-0
Constant.java
src/main/java/com/govmade/common/utils/Constant.java
+46
-0
MyMetaObjectHandler.java
...in/java/com/govmade/common/utils/MyMetaObjectHandler.java
+42
-0
PageUtils.java
src/main/java/com/govmade/common/utils/PageUtils.java
+99
-0
Query.java
src/main/java/com/govmade/common/utils/Query.java
+91
-0
R.java
src/main/java/com/govmade/common/utils/R.java
+58
-0
HTMLFilter.java
src/main/java/com/govmade/common/xss/HTMLFilter.java
+0
-0
SQLFilter.java
src/main/java/com/govmade/common/xss/SQLFilter.java
+42
-0
XssFilter.java
src/main/java/com/govmade/common/xss/XssFilter.java
+31
-0
XssHttpServletRequestWrapper.java
.../com/govmade/common/xss/XssHttpServletRequestWrapper.java
+140
-0
CorsConfig.java
src/main/java/com/govmade/config/CorsConfig.java
+19
-0
MybatisPlusConfig.java
src/main/java/com/govmade/config/MybatisPlusConfig.java
+25
-0
ShiroConfig.java
src/main/java/com/govmade/config/ShiroConfig.java
+90
-0
SwaggerConfig.java
src/main/java/com/govmade/config/SwaggerConfig.java
+47
-0
DataSourceNames.java
src/main/java/com/govmade/datasources/DataSourceNames.java
+12
-0
DynamicDataSource.java
src/main/java/com/govmade/datasources/DynamicDataSource.java
+40
-0
DynamicDataSourceConfig.java
...java/com/govmade/datasources/DynamicDataSourceConfig.java
+35
-0
AbstractController.java
.../govmade/modules/basic/controller/AbstractController.java
+29
-0
BaseEntity.java
...ain/java/com/govmade/modules/basic/entity/BaseEntity.java
+71
-0
UserController.java
...com/govmade/modules/system/controller/UserController.java
+80
-0
UserDao.java
src/main/java/com/govmade/modules/system/dao/UserDao.java
+36
-0
UserEntity.java
...in/java/com/govmade/modules/system/entity/UserEntity.java
+109
-0
UserService.java
.../java/com/govmade/modules/system/service/UserService.java
+42
-0
UserServiceImpl.java
.../govmade/modules/system/service/impl/UserServiceImpl.java
+65
-0
application-dev.yml
src/main/resources/application-dev.yml
+34
-0
application-prod.yml
src/main/resources/application-prod.yml
+38
-0
application-test.yml
src/main/resources/application-test.yml
+38
-0
application.yml
src/main/resources/application.yml
+76
-0
logback-spring.xml
src/main/resources/logback-spring.xml
+22
-0
index.html
src/main/resources/static/index.html
+2
-0
UserTest.java
src/test/java/test/UserTest.java
+29
-0
SysUserDao.xml
src/test/resources/mapper/system/SysUserDao.xml
+11
-0
No files found.
.classpath
0 → 100644
View file @
8bd28814
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"src"
output=
"target/classes"
path=
"src/main/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/classes"
path=
"src/main/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"src/test/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/test-classes"
path=
"src/test/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
This diff is collapsed.
Click to expand it.
.gitignore
0 → 100644
View file @
8bd28814
/target/
This diff is collapsed.
Click to expand it.
.project
0 → 100644
View file @
8bd28814
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
govdna
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.m2e.core.maven2Nature
</nature>
</natures>
</projectDescription>
This diff is collapsed.
Click to expand it.
.settings/org.eclipse.core.resources.prefs
0 → 100644
View file @
8bd28814
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
This diff is collapsed.
Click to expand it.
.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
8bd28814
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
This diff is collapsed.
Click to expand it.
.settings/org.eclipse.m2e.core.prefs
0 → 100644
View file @
8bd28814
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
This diff is collapsed.
Click to expand it.
pom.xml
0 → 100644
View file @
8bd28814
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.govmade
</groupId>
<artifactId>
govdna
</artifactId>
<version>
0.0.1
</version>
<packaging>
jar
</packaging>
<description>
govdna
</description>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
1.5.10.RELEASE
</version>
</parent>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<mybatisplus.spring.boot.version>
1.0.5
</mybatisplus.spring.boot.version>
<mybatisplus.version>
2.1.9
</mybatisplus.version>
<mysql.version>
5.1.38
</mysql.version>
<druid.version>
1.1.3
</druid.version>
<quartz.version>
2.3.0
</quartz.version>
<commons.lang.version>
2.6
</commons.lang.version>
<commons.fileupload.version>
1.3.1
</commons.fileupload.version>
<commons.io.version>
2.5
</commons.io.version>
<commons.codec.version>
1.10
</commons.codec.version>
<commons.configuration.version>
1.10
</commons.configuration.version>
<shiro.version>
1.3.2
</shiro.version>
<jwt.version>
0.7.0
</jwt.version>
<kaptcha.version>
0.0.9
</kaptcha.version>
<aliyun.oss.version>
2.5.0
</aliyun.oss.version>
<swagger.version>
2.2.2
</swagger.version>
<hutool.version>
4.1.0
</hutool.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatisplus-spring-boot-starter
</artifactId>
<version>
${mybatisplus.spring.boot.version}
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus
</artifactId>
<version>
${mybatisplus.version}
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
${druid.version}
</version>
</dependency>
<dependency>
<groupId>
org.quartz-scheduler
</groupId>
<artifactId>
quartz
</artifactId>
<version>
${quartz.version}
</version>
<exclusions>
<exclusion>
<groupId>
com.mchange
</groupId>
<artifactId>
c3p0
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
${commons.lang.version}
</version>
</dependency>
<dependency>
<groupId>
commons-fileupload
</groupId>
<artifactId>
commons-fileupload
</artifactId>
<version>
${commons.fileupload.version}
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
${commons.io.version}
</version>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
</dependency>
<dependency>
<groupId>
commons-configuration
</groupId>
<artifactId>
commons-configuration
</artifactId>
<version>
${commons.configuration.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-core
</artifactId>
<version>
${shiro.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-spring
</artifactId>
<version>
${shiro.version}
</version>
</dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
${jwt.version}
</version>
</dependency>
<dependency>
<groupId>
com.github.axet
</groupId>
<artifactId>
kaptcha
</artifactId>
<version>
${kaptcha.version}
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
${aliyun.oss.version}
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
${hutool.version}
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<fork>
true
</fork>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>
public
</id>
<name>
aliyun nexus
</name>
<url>
http://maven.aliyun.com/nexus/content/groups/public/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
public
</id>
<name>
aliyun nexus
</name>
<url>
http://maven.aliyun.com/nexus/content/groups/public/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/RenrenApplication.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.web.support.SpringBootServletInitializer
;
import
org.springframework.context.annotation.Import
;
import
com.govmade.datasources.DynamicDataSourceConfig
;
@SpringBootApplication
(
exclude
={
DataSourceAutoConfiguration
.
class
})
@Import
({
DynamicDataSourceConfig
.
class
})
public
class
RenrenApplication
extends
SpringBootServletInitializer
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
RenrenApplication
.
class
,
args
);
}
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
RenrenApplication
.
class
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/oauth2/OAuth2Filter.java
0 → 100644
View file @
8bd28814
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/oauth2/OAuth2Realm.java
0 → 100644
View file @
8bd28814
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/oauth2/OAuth2Token.java
0 → 100644
View file @
8bd28814
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/oauth2/TokenGenerator.java
0 → 100644
View file @
8bd28814
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/utils/Constant.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
utils
;
/**
* 常量类
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
class
Constant
{
/** 超级管理员ID */
public
static
final
int
SUPER_ADMIN
=
1
;
/**
* 菜单类型
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
enum
MenuType
{
/**
* 目录
*/
CATALOG
(
0
),
/**
* 菜单
*/
MENU
(
1
),
/**
* 按钮
*/
BUTTON
(
2
);
private
int
value
;
MenuType
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/utils/MyMetaObjectHandler.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
utils
;
import
java.util.Date
;
import
org.apache.ibatis.reflection.MetaObject
;
import
com.baomidou.mybatisplus.mapper.MetaObjectHandler
;
import
com.govmade.modules.system.entity.UserEntity
;
import
cn.hutool.core.date.DateUtil
;
public
class
MyMetaObjectHandler
extends
MetaObjectHandler
{
@Override
public
void
insertFill
(
MetaObject
metaObject
)
{
//获取当前登录用户
UserEntity
ue
=
new
UserEntity
();
ue
.
setId
(
1L
);
// 获取当前时间
Date
date
=
DateUtil
.
date
();
metaObject
.
setValue
(
"createBy"
,
ue
.
getId
());
metaObject
.
setValue
(
"modifyBy"
,
ue
.
getId
());
metaObject
.
setValue
(
"createTime"
,
date
);
metaObject
.
setValue
(
"modifyTime"
,
date
);
setFieldValByName
(
"state"
,
1
,
metaObject
);
}
@Override
public
void
updateFill
(
MetaObject
metaObject
)
{
//获取当前登录用户
UserEntity
ue
=
new
UserEntity
();
ue
.
setId
(
1L
);
// 获取当前时间
Date
date
=
DateUtil
.
date
();
metaObject
.
setValue
(
"modifyBy"
,
ue
.
getId
());
metaObject
.
setValue
(
"modifyTime"
,
date
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/utils/PageUtils.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
utils
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 分页工具类
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
class
PageUtils
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
int
totalCount
;
// 总记录数
private
int
pageSize
;
// 每页记录数
private
int
totalPage
;
// 总页数
private
int
currPage
;
// 当前页数
private
List
<?>
list
;
// 列表数据
/**
* 分页
*
* @param list
* 列表数据
* @param totalCount
* 总记录数
* @param pageSize
* 每页记录数
* @param currPage
* 当前页数
*/
public
PageUtils
(
List
<?>
list
,
int
totalCount
,
int
pageSize
,
int
currPage
)
{
this
.
list
=
list
;
this
.
totalCount
=
totalCount
;
this
.
pageSize
=
pageSize
;
this
.
currPage
=
currPage
;
this
.
totalPage
=
(
int
)
Math
.
ceil
((
double
)
totalCount
/
pageSize
);
}
/**
* 分页
*/
public
PageUtils
(
Page
<?>
page
)
{
this
.
list
=
page
.
getRecords
();
this
.
totalCount
=
page
.
getTotal
();
this
.
pageSize
=
page
.
getSize
();
this
.
currPage
=
page
.
getCurrent
();
this
.
totalPage
=
page
.
getPages
();
}
public
int
getTotalCount
()
{
return
totalCount
;
}
public
void
setTotalCount
(
int
totalCount
)
{
this
.
totalCount
=
totalCount
;
}
public
int
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
int
getTotalPage
()
{
return
totalPage
;
}
public
void
setTotalPage
(
int
totalPage
)
{
this
.
totalPage
=
totalPage
;
}
public
int
getCurrPage
()
{
return
currPage
;
}
public
void
setCurrPage
(
int
currPage
)
{
this
.
currPage
=
currPage
;
}
public
List
<?>
getList
()
{
return
list
;
}
public
void
setList
(
List
<?>
list
)
{
this
.
list
=
list
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/utils/Query.java
0 → 100644
View file @
8bd28814
/**
* Copyright 2018 人人开源 http://www.renren.io
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package
com
.
govmade
.
common
.
utils
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.apache.commons.lang.StringUtils
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.govmade.common.xss.SQLFilter
;
/**
* 查询参数
*
* @author Mark sunlightcs@gmail.com
* @since 2.0.0 2017-03-14
*/
public
class
Query
<
T
>
extends
LinkedHashMap
<
String
,
Object
>
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* mybatis-plus分页参数
*/
private
Page
<
T
>
page
;
/**
* 当前页码
*/
private
int
currPage
=
1
;
/**
* 每页条数
*/
private
int
limit
=
10
;
public
Query
(
Map
<
String
,
Object
>
params
){
this
.
putAll
(
params
);
//分页参数
if
(
params
.
get
(
"page"
)
!=
null
){
currPage
=
Integer
.
parseInt
((
String
)
params
.
get
(
"page"
));
}
if
(
params
.
get
(
"limit"
)
!=
null
){
limit
=
Integer
.
parseInt
((
String
)
params
.
get
(
"limit"
));
}
this
.
put
(
"offset"
,
(
currPage
-
1
)
*
limit
);
this
.
put
(
"page"
,
currPage
);
this
.
put
(
"limit"
,
limit
);
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
String
sidx
=
SQLFilter
.
sqlInject
((
String
)
params
.
get
(
"sidx"
));
String
order
=
SQLFilter
.
sqlInject
((
String
)
params
.
get
(
"order"
));
this
.
put
(
"sidx"
,
sidx
);
this
.
put
(
"order"
,
order
);
//mybatis-plus分页
this
.
page
=
new
Page
<>(
currPage
,
limit
);
//排序
if
(
StringUtils
.
isNotBlank
(
sidx
)
&&
StringUtils
.
isNotBlank
(
order
)){
this
.
page
.
setOrderByField
(
sidx
);
this
.
page
.
setAsc
(
"ASC"
.
equalsIgnoreCase
(
order
));
}
}
public
Page
<
T
>
getPage
()
{
return
page
;
}
public
int
getCurrPage
()
{
return
currPage
;
}
public
int
getLimit
()
{
return
limit
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/utils/R.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
utils
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.http.HttpStatus
;
/**
* 返回数据
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
class
R
extends
HashMap
<
String
,
Object
>
{
private
static
final
long
serialVersionUID
=
1L
;
public
R
()
{
put
(
"code"
,
0
);
put
(
"msg"
,
"success"
);
}
public
static
R
error
()
{
return
error
(
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
,
"未知异常,请联系管理员"
);
}
public
static
R
error
(
String
msg
)
{
return
error
(
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
,
msg
);
}
public
static
R
error
(
int
code
,
String
msg
)
{
R
r
=
new
R
();
r
.
put
(
"code"
,
code
);
r
.
put
(
"msg"
,
msg
);
return
r
;
}
public
static
R
ok
(
String
msg
)
{
R
r
=
new
R
();
r
.
put
(
"msg"
,
msg
);
return
r
;
}
public
static
R
ok
(
Map
<
String
,
Object
>
map
)
{
R
r
=
new
R
();
r
.
putAll
(
map
);
return
r
;
}
public
static
R
ok
()
{
return
new
R
();
}
public
R
put
(
String
key
,
Object
value
)
{
super
.
put
(
key
,
value
);
return
this
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/xss/HTMLFilter.java
0 → 100644
View file @
8bd28814
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/xss/SQLFilter.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
xss
;
import
org.apache.commons.lang.StringUtils
;
/**
* SQL过滤
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017-04-01 16:16
*/
public
class
SQLFilter
{
/**
* SQL注入过滤
* @param str 待验证的字符串
*/
public
static
String
sqlInject
(
String
str
){
if
(
StringUtils
.
isBlank
(
str
)){
return
null
;
}
//去掉'|"|;|\字符
str
=
StringUtils
.
replace
(
str
,
"'"
,
""
);
str
=
StringUtils
.
replace
(
str
,
"\""
,
""
);
str
=
StringUtils
.
replace
(
str
,
";"
,
""
);
str
=
StringUtils
.
replace
(
str
,
"\\"
,
""
);
//转换成小写
str
=
str
.
toLowerCase
();
//非法字符
String
[]
keywords
=
{
"master"
,
"truncate"
,
"insert"
,
"select"
,
"delete"
,
"update"
,
"declare"
,
"alert"
,
"drop"
};
//判断是否包含非法字符
for
(
String
keyword
:
keywords
){
if
(
str
.
indexOf
(
keyword
)
!=
-
1
){
// throw new RRException("包含非法字符");
}
}
return
str
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/xss/XssFilter.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
xss
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
/**
* XSS过滤
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017-04-01 10:20
*/
public
class
XssFilter
implements
Filter
{
@Override
public
void
init
(
FilterConfig
config
)
throws
ServletException
{
}
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
XssHttpServletRequestWrapper
xssRequest
=
new
XssHttpServletRequestWrapper
((
HttpServletRequest
)
request
);
chain
.
doFilter
(
xssRequest
,
response
);
}
@Override
public
void
destroy
()
{
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/common/xss/XssHttpServletRequestWrapper.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
common
.
xss
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
javax.servlet.ReadListener
;
import
javax.servlet.ServletInputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequestWrapper
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* XSS过滤处理
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017-04-01 11:29
*/
public
class
XssHttpServletRequestWrapper
extends
HttpServletRequestWrapper
{
//没被包装过的HttpServletRequest(特殊场景,需要自己过滤)
HttpServletRequest
orgRequest
;
//html过滤
private
final
static
HTMLFilter
htmlFilter
=
new
HTMLFilter
();
public
XssHttpServletRequestWrapper
(
HttpServletRequest
request
)
{
super
(
request
);
orgRequest
=
request
;
}
@Override
public
ServletInputStream
getInputStream
()
throws
IOException
{
//非json类型,直接返回
if
(!
MediaType
.
APPLICATION_JSON_VALUE
.
equalsIgnoreCase
(
super
.
getHeader
(
HttpHeaders
.
CONTENT_TYPE
))){
return
super
.
getInputStream
();
}
//为空,直接返回
String
json
=
IOUtils
.
toString
(
super
.
getInputStream
(),
"utf-8"
);
if
(
StringUtils
.
isBlank
(
json
))
{
return
super
.
getInputStream
();
}
//xss过滤
json
=
xssEncode
(
json
);
final
ByteArrayInputStream
bis
=
new
ByteArrayInputStream
(
json
.
getBytes
(
"utf-8"
));
return
new
ServletInputStream
()
{
@Override
public
boolean
isFinished
()
{
return
true
;
}
@Override
public
boolean
isReady
()
{
return
true
;
}
@Override
public
void
setReadListener
(
ReadListener
readListener
)
{
}
@Override
public
int
read
()
throws
IOException
{
return
bis
.
read
();
}
};
}
@Override
public
String
getParameter
(
String
name
)
{
String
value
=
super
.
getParameter
(
xssEncode
(
name
));
if
(
StringUtils
.
isNotBlank
(
value
))
{
value
=
xssEncode
(
value
);
}
return
value
;
}
@Override
public
String
[]
getParameterValues
(
String
name
)
{
String
[]
parameters
=
super
.
getParameterValues
(
name
);
if
(
parameters
==
null
||
parameters
.
length
==
0
)
{
return
null
;
}
for
(
int
i
=
0
;
i
<
parameters
.
length
;
i
++)
{
parameters
[
i
]
=
xssEncode
(
parameters
[
i
]);
}
return
parameters
;
}
@Override
public
Map
<
String
,
String
[]>
getParameterMap
()
{
Map
<
String
,
String
[]>
map
=
new
LinkedHashMap
<>();
Map
<
String
,
String
[]>
parameters
=
super
.
getParameterMap
();
for
(
String
key
:
parameters
.
keySet
())
{
String
[]
values
=
parameters
.
get
(
key
);
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
values
[
i
]
=
xssEncode
(
values
[
i
]);
}
map
.
put
(
key
,
values
);
}
return
map
;
}
@Override
public
String
getHeader
(
String
name
)
{
String
value
=
super
.
getHeader
(
xssEncode
(
name
));
if
(
StringUtils
.
isNotBlank
(
value
))
{
value
=
xssEncode
(
value
);
}
return
value
;
}
private
String
xssEncode
(
String
input
)
{
return
htmlFilter
.
filter
(
input
);
}
/**
* 获取最原始的request
*/
public
HttpServletRequest
getOrgRequest
()
{
return
orgRequest
;
}
/**
* 获取最原始的request
*/
public
static
HttpServletRequest
getOrgRequest
(
HttpServletRequest
request
)
{
if
(
request
instanceof
XssHttpServletRequestWrapper
)
{
return
((
XssHttpServletRequestWrapper
)
request
).
getOrgRequest
();
}
return
request
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/config/CorsConfig.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Configuration
public
class
CorsConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedOrigins
(
"*"
)
.
allowCredentials
(
true
)
.
allowedMethods
(
"GET"
,
"POST"
,
"PUT"
,
"DELETE"
,
"OPTIONS"
)
.
maxAge
(
3600
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/config/MybatisPlusConfig.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.baomidou.mybatisplus.plugins.PaginationInterceptor
;
/**
* mybatis-plus配置
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
@Configuration
public
class
MybatisPlusConfig
{
/**
* 分页插件
*/
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
return
new
PaginationInterceptor
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/config/ShiroConfig.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
config
;
import
org.apache.shiro.mgt.SecurityManager
;
import
org.apache.shiro.session.mgt.SessionManager
;
import
org.apache.shiro.spring.LifecycleBeanPostProcessor
;
import
org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor
;
import
org.apache.shiro.spring.web.ShiroFilterFactoryBean
;
import
org.apache.shiro.web.session.mgt.DefaultWebSessionManager
;
import
org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.servlet.Filter
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* Shiro配置
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017-04-20 18:33
*/
@Configuration
public
class
ShiroConfig
{
@Bean
(
"sessionManager"
)
public
SessionManager
sessionManager
(){
DefaultWebSessionManager
sessionManager
=
new
DefaultWebSessionManager
();
sessionManager
.
setSessionValidationSchedulerEnabled
(
true
);
sessionManager
.
setSessionIdCookieEnabled
(
true
);
return
sessionManager
;
}
// @Bean("securityManager")
// public SecurityManager securityManager(OAuth2Realm oAuth2Realm, SessionManager sessionManager) {
// DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// securityManager.setRealm(oAuth2Realm);
// securityManager.setSessionManager(sessionManager);
//
// return securityManager;
// }
@Bean
(
"shiroFilter"
)
public
ShiroFilterFactoryBean
shirFilter
(
SecurityManager
securityManager
)
{
ShiroFilterFactoryBean
shiroFilter
=
new
ShiroFilterFactoryBean
();
shiroFilter
.
setSecurityManager
(
securityManager
);
//oauth过滤
Map
<
String
,
Filter
>
filters
=
new
HashMap
<>();
// filters.put("oauth2", new OAuth2Filter());
shiroFilter
.
setFilters
(
filters
);
Map
<
String
,
String
>
filterMap
=
new
LinkedHashMap
<>();
filterMap
.
put
(
"/webjars/**"
,
"anon"
);
filterMap
.
put
(
"/druid/**"
,
"anon"
);
filterMap
.
put
(
"/app/**"
,
"anon"
);
filterMap
.
put
(
"/sys/login"
,
"anon"
);
filterMap
.
put
(
"/swagger/**"
,
"anon"
);
filterMap
.
put
(
"/v2/api-docs"
,
"anon"
);
filterMap
.
put
(
"/swagger-ui.html"
,
"anon"
);
filterMap
.
put
(
"/swagger-resources/**"
,
"anon"
);
filterMap
.
put
(
"/captcha.jpg"
,
"anon"
);
filterMap
.
put
(
"/**"
,
"anon"
);
shiroFilter
.
setFilterChainDefinitionMap
(
filterMap
);
return
shiroFilter
;
}
@Bean
(
"lifecycleBeanPostProcessor"
)
public
LifecycleBeanPostProcessor
lifecycleBeanPostProcessor
()
{
return
new
LifecycleBeanPostProcessor
();
}
@Bean
public
DefaultAdvisorAutoProxyCreator
defaultAdvisorAutoProxyCreator
()
{
DefaultAdvisorAutoProxyCreator
proxyCreator
=
new
DefaultAdvisorAutoProxyCreator
();
proxyCreator
.
setProxyTargetClass
(
true
);
return
proxyCreator
;
}
@Bean
public
AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor
(
SecurityManager
securityManager
)
{
AuthorizationAttributeSourceAdvisor
advisor
=
new
AuthorizationAttributeSourceAdvisor
();
advisor
.
setSecurityManager
(
securityManager
);
return
advisor
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/config/SwaggerConfig.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
config
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@Configuration
@EnableSwagger2
public
class
SwaggerConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"swagger-ui.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
withMethodAnnotation
(
ApiOperation
.
class
))
//加了ApiOperation注解的方法,生成接口文档
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.govmade.modules.system.controller"
))
//包下的类,生成接口文档
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"数据基因"
)
.
description
(
"govdata接口文档"
)
.
termsOfServiceUrl
(
"http://www.govmade.cn"
)
.
version
(
"1.0"
)
.
build
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/datasources/DataSourceNames.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
datasources
;
/**
* 增加多数据源,在此配置
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017/8/18 23:46
*/
public
interface
DataSourceNames
{
String
GOVMADE
=
"govmade"
;
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/datasources/DynamicDataSource.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
datasources
;
import
org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
;
import
javax.sql.DataSource
;
import
java.util.Map
;
/**
* 动态数据源
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017/8/19 1:03
*/
public
class
DynamicDataSource
extends
AbstractRoutingDataSource
{
private
static
final
ThreadLocal
<
String
>
contextHolder
=
new
ThreadLocal
<>();
public
DynamicDataSource
(
DataSource
defaultTargetDataSource
,
Map
<
Object
,
Object
>
targetDataSources
)
{
super
.
setDefaultTargetDataSource
(
defaultTargetDataSource
);
super
.
setTargetDataSources
(
targetDataSources
);
super
.
afterPropertiesSet
();
}
@Override
protected
Object
determineCurrentLookupKey
()
{
return
getDataSource
();
}
public
static
void
setDataSource
(
String
dataSource
)
{
contextHolder
.
set
(
dataSource
);
}
public
static
String
getDataSource
()
{
return
contextHolder
.
get
();
}
public
static
void
clearDataSource
()
{
contextHolder
.
remove
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/datasources/DynamicDataSourceConfig.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
datasources
;
import
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
javax.sql.DataSource
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 配置多数据源
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017/8/19 0:41
*/
@Configuration
public
class
DynamicDataSourceConfig
{
@Bean
@ConfigurationProperties
(
"spring.datasource.druid.govmade"
)
public
DataSource
firstDataSource
(){
return
DruidDataSourceBuilder
.
create
().
build
();
}
@Bean
@Primary
public
DynamicDataSource
dataSource
(
DataSource
firstDataSource
)
{
Map
<
Object
,
Object
>
targetDataSources
=
new
HashMap
<>();
targetDataSources
.
put
(
DataSourceNames
.
GOVMADE
,
firstDataSource
);
return
new
DynamicDataSource
(
firstDataSource
,
targetDataSources
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/basic/controller/AbstractController.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
basic
.
controller
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.govmade.modules.system.entity.UserEntity
;
/**
* Controller公共组件
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
abstract
class
AbstractController
{
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
protected
UserEntity
getUser
()
{
//return (UserEntity) SecurityUtils.getSubject().getPrincipal();
UserEntity
ue
=
new
UserEntity
();
ue
.
setDeptId
(
1L
);
return
null
;
}
protected
Long
getUserId
()
{
//return getUser().getId();
return
2L
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/basic/entity/BaseEntity.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
basic
.
entity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.enums.FieldFill
;
public
abstract
class
BaseEntity
<
ID
extends
Serializable
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
private
ID
id
;
// 主键ID
@TableField
(
value
=
"create_by"
,
fill
=
FieldFill
.
INSERT
)
private
Long
createBy
;
// 创建者
@TableField
(
value
=
"modify_by"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Long
modifyBy
;
// 更新者
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
// 创建时间
@TableField
(
value
=
"modify_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
modifyTime
;
// 更新时间
@TableField
(
value
=
"state"
,
fill
=
FieldFill
.
INSERT
)
private
Integer
state
;
// 更新时间
public
ID
getId
()
{
return
id
;
}
public
void
setId
(
ID
id
)
{
this
.
id
=
id
;
}
public
Long
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
Long
createBy
)
{
this
.
createBy
=
createBy
;
}
public
Long
getModifyBy
()
{
return
modifyBy
;
}
public
void
setModifyBy
(
Long
modifyBy
)
{
this
.
modifyBy
=
modifyBy
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getModifyTime
()
{
return
modifyTime
;
}
public
void
setModifyTime
(
Date
modifyTime
)
{
this
.
modifyTime
=
modifyTime
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/controller/UserController.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.govmade.common.utils.Constant
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.R
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
import
cn.hutool.crypto.SecureUtil
;
/**
* 系统管理 - 用户设置
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
@RestController
@RequestMapping
(
"/system/user"
)
public
class
UserController
extends
AbstractController
{
@Autowired
private
UserService
userService
;
/**
* 保存或更新用户
*/
@PostMapping
(
"/save"
)
public
R
save
(
UserEntity
ue
)
{
if
(
null
==
ue
.
getId
())
{
if
(
this
.
userService
.
checkUser
(
ue
.
getUsername
())
>
0
)
{
return
R
.
error
(
ue
.
getUsername
()
+
" 已存在!"
);
}
String
password
=
SecureUtil
.
md5
(
"123456"
);
ue
.
setPassword
(
password
);
}
userService
.
save
(
ue
);
return
R
.
ok
();
}
/**
* 用户列表
*/
@GetMapping
(
"/list"
)
public
R
list
(
Map
<
String
,
Object
>
params
)
{
// 只有超级管理员,才能查看所有用户列表
if
(
getUserId
()
!=
Constant
.
SUPER_ADMIN
)
{
params
.
put
(
"createBy"
,
getUserId
());
}
else
{
params
.
put
(
"deptId"
,
getUser
().
getDeptId
());
// 部门管理员,查看本部门用户列表
}
PageUtils
page
=
userService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 根据ID查询用户
*
* @param id
* @return
*/
@GetMapping
(
"info/{id}"
)
public
R
info
(
@PathVariable
(
"id"
)
Long
id
)
{
return
R
.
ok
().
put
(
"user"
,
userService
.
queryById
(
id
));
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/dao/UserDao.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
system
.
dao
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.govmade.modules.system.entity.UserEntity
;
/**
* 系统管理 - 用户设置
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
@Mapper
public
interface
UserDao
extends
BaseMapper
<
UserEntity
>
{
/**
* 查询用户的所有权限
* @param userId 用户ID
*/
List
<
String
>
queryAllPerms
(
Long
userId
);
/**
* 查询用户的所有菜单ID
*/
List
<
Long
>
queryAllMenuId
(
Long
userId
);
/**
* 根据用户名,查询系统用户
*/
UserEntity
queryByUserName
(
String
username
);
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/entity/UserEntity.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
system
.
entity
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.govmade.modules.basic.entity.BaseEntity
;
/**
* 系统管理 - 用户设置
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
@TableName
(
"system_users"
)
public
class
UserEntity
extends
BaseEntity
<
Long
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
deptId
;
// 部门ID
private
Long
roleId
;
// 角色ID
private
String
username
;
// 用户名
private
String
password
;
// 密码
private
String
realname
;
// 真实姓名
private
String
email
;
// 邮箱
private
String
telephone
;
// 电话号码
private
String
lastLoginIp
;
// 最后一次登录IP
private
Date
lastLoginTime
;
// 最后一次登录时间
public
Long
getDeptId
()
{
return
deptId
;
}
public
void
setDeptId
(
Long
deptId
)
{
this
.
deptId
=
deptId
;
}
public
Long
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
Long
roleId
)
{
this
.
roleId
=
roleId
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getRealname
()
{
return
realname
;
}
public
void
setRealname
(
String
realname
)
{
this
.
realname
=
realname
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getTelephone
()
{
return
telephone
;
}
public
void
setTelephone
(
String
telephone
)
{
this
.
telephone
=
telephone
;
}
public
String
getLastLoginIp
()
{
return
lastLoginIp
;
}
public
void
setLastLoginIp
(
String
lastLoginIp
)
{
this
.
lastLoginIp
=
lastLoginIp
;
}
public
Date
getLastLoginTime
()
{
return
lastLoginTime
;
}
public
void
setLastLoginTime
(
Date
lastLoginTime
)
{
this
.
lastLoginTime
=
lastLoginTime
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/service/UserService.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
system
.
service
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.modules.system.entity.UserEntity
;
/**
* 系统管理 - 用户设置
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
interface
UserService
extends
IService
<
UserEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
UserEntity
queryById
(
Long
id
);
/**
* 保存或修改用户
*/
void
save
(
UserEntity
user
);
/**
* 删除用户
*/
void
deleteBatch
(
Long
[]
userIds
);
/**
* 修改密码
* @param userId 用户ID
* @param password 原密码
* @param newPassword 新密码
*/
boolean
updatePassword
(
Long
userId
,
String
password
,
String
newPassword
);
Integer
checkUser
(
String
username
);
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/service/impl/UserServiceImpl.java
0 → 100644
View file @
8bd28814
package
com
.
govmade
.
modules
.
system
.
service
.
impl
;
import
java.util.Map
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.Query
;
import
com.govmade.modules.system.dao.UserDao
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
import
cn.hutool.core.util.StrUtil
;
/**
* 系统用户
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2016年9月18日 上午9:46:09
*/
@Service
(
"UserService"
)
public
class
UserServiceImpl
extends
ServiceImpl
<
UserDao
,
UserEntity
>
implements
UserService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
// TODO Auto-generated method stub
String
username
=
(
String
)
params
.
get
(
"username"
);
Long
createBy
=
(
Long
)
params
.
get
(
"createBy"
);
Page
<
UserEntity
>
page
=
this
.
selectPage
(
new
Query
<
UserEntity
>(
params
).
getPage
(),
new
EntityWrapper
<
UserEntity
>()
.
eq
(
StrUtil
.
isNotBlank
(
username
),
"username"
,
username
).
eq
(
createBy
!=
null
,
"create_by"
,
createBy
));
return
new
PageUtils
(
page
);
}
@Override
public
UserEntity
queryById
(
Long
id
)
{
return
super
.
selectById
(
id
);
}
@Override
public
void
save
(
UserEntity
user
)
{
super
.
insertOrUpdate
(
user
);
}
@Override
public
void
deleteBatch
(
Long
[]
userIds
)
{
// TODO Auto-generated method stub
}
@Override
public
boolean
updatePassword
(
Long
userId
,
String
password
,
String
newPassword
)
{
// TODO Auto-generated method stub
return
false
;
}
@Override
public
Integer
checkUser
(
String
username
)
{
return
super
.
selectCount
(
new
EntityWrapper
<
UserEntity
>().
eq
(
"username"
,
username
));
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/application-dev.yml
0 → 100644
View file @
8bd28814
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
com.mysql.jdbc.Driver
druid
:
govmade
:
#数据源(多源)
url
:
jdbc:mysql://115.233.227.46:13308/govmade?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
gov567
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
validation-query
:
SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
true
wall
:
config
:
multi-statement-allow
:
true
This diff is collapsed.
Click to expand it.
src/main/resources/application-prod.yml
0 → 100644
View file @
8bd28814
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
com.mysql.jdbc.Driver
druid
:
first
:
url
:
jdbc:mysql://localhost:3306/renren_fast?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username
:
renren
password
:
123456
second
:
url
:
jdbc:mysql://localhost:3306/renren_fast?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username
:
renren
password
:
123456
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
validation-query
:
SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
true
wall
:
config
:
multi-statement-allow
:
true
This diff is collapsed.
Click to expand it.
src/main/resources/application-test.yml
0 → 100644
View file @
8bd28814
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
com.mysql.jdbc.Driver
druid
:
first
:
url
:
jdbc:mysql://localhost:3306/renren_fast?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username
:
renren
password
:
123456
second
:
url
:
jdbc:mysql://localhost:3306/renren_fast?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username
:
renren
password
:
123456
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
validation-query
:
SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
true
wall
:
config
:
multi-statement-allow
:
true
This diff is collapsed.
Click to expand it.
src/main/resources/application.yml
0 → 100644
View file @
8bd28814
# Tomcat
server
:
tomcat
:
uri-encoding
:
UTF-8
max-threads
:
1000
min-spare-threads
:
30
port
:
18080
connection-timeout
:
5000
context-path
:
/govdna
spring
:
# 环境 dev|test|prod
profiles
:
active
:
dev
# jackson时间格式化
jackson
:
time-zone
:
GMT+8
date-format
:
yyyy-MM-dd HH:mm:ss
http
:
multipart
:
max-file-size
:
100MB
max-request-size
:
100MB
enabled
:
true
redis
:
open
:
false
# 是否开启redis缓存 true开启 false关闭
database
:
0
host
:
localhost
port
:
6379
password
:
# 密码(默认为空)
timeout
:
6000
# 连接超时时长(毫秒)
pool
:
max-active
:
1000
# 连接池最大连接数(使用负值表示没有限制)
max-wait
:
-1
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle
:
10
# 连接池中的最大空闲连接
min-idle
:
5
# 连接池中的最小空闲连接
#mybatis
mybatis-plus
:
mapper-locations
:
classpath:mapper/**/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage
:
com.govmade.modules.*.entity
global-config
:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type
:
0
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy
:
2
#驼峰下划线转换
db-column-underline
:
true
#刷新mapper 调试神器
refresh-mapper
:
true
#数据库大写下划线转换
#capital-mode: true
#序列接口实现类配置
#key-generator: com.baomidou.springboot.xxx
#逻辑删除配置
logic-delete-value
:
-1
logic-not-delete-value
:
0
#自定义填充策略接口实现
meta-object-handler
:
com.govmade.common.utils.MyMetaObjectHandler
#自定义SQL注入器
sql-injector
:
com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration
:
map-underscore-to-camel-case
:
true
cache-enabled
:
false
call-setters-on-nulls
:
true
renren
:
# APP模块,是通过jwt认证的,如果要使用APP模块,则需要修改【加密秘钥】
jwt
:
# 加密秘钥
secret
:
f4e2e52034348f86b67cde581c0f9eb5[www.renren.io]
# token有效时长,7天,单位秒
expire
:
604800
header
:
token
This diff is collapsed.
Click to expand it.
src/main/resources/logback-spring.xml
0 → 100644
View file @
8bd28814
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<logger
name=
"org.springframework.web"
level=
"INFO"
/>
<logger
name=
"org.springboot.sample"
level=
"TRACE"
/>
<!-- 开发、测试环境 -->
<springProfile
name=
"dev,test"
>
<logger
name=
"org.springframework.web"
level=
"INFO"
/>
<logger
name=
"org.springboot.sample"
level=
"INFO"
/>
<logger
name=
"com.govmade"
level=
"DEBUG"
/>
</springProfile>
<!-- 生产环境 -->
<springProfile
name=
"prod"
>
<logger
name=
"org.springframework.web"
level=
"ERROR"
/>
<logger
name=
"org.springboot.sample"
level=
"ERROR"
/>
<logger
name=
"com.govmade"
level=
"ERROR"
/>
</springProfile>
</configuration>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/resources/static/index.html
0 → 100644
View file @
8bd28814
这是首页吗
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/test/java/test/UserTest.java
0 → 100644
View file @
8bd28814
package
test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
UserTest
{
@Autowired
private
UserService
userService
;
@Test
public
void
contextLoads
()
{
UserEntity
user
=
new
UserEntity
();
user
.
setEmail
(
"qqq@qq.com"
);
user
.
setDeptId
(
1L
);
user
.
setRoleId
(
1L
);
System
.
out
.
println
(
user
);
//userService.save(user);
}
}
This diff is collapsed.
Click to expand it.
src/test/resources/mapper/system/SysUserDao.xml
0 → 100644
View file @
8bd28814
<?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=
"io.renren.modules.sys.dao.SysUserDao"
>
<select
id=
"queryByUserName"
resultType=
"io.renren.modules.sys.entity.SysUserEntity"
>
select * from sys_user where username = #{username}
</select>
</mapper>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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