Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zcq
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
zcq
Commits
3e3dc861
提交
3e3dc861
authored
3月 07, 2019
作者:
lizhuo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
b671bc0b
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
38 个修改的文件
包含
0 行增加
和
2071 行删除
+0
-2071
.classpath
com.zrqx.content/.classpath
+0
-36
.project
com.zrqx.content/.project
+0
-35
org.eclipse.core.resources.prefs
com.zrqx.content/.settings/org.eclipse.core.resources.prefs
+0
-6
org.eclipse.jdt.core.prefs
com.zrqx.content/.settings/org.eclipse.jdt.core.prefs
+0
-8
org.eclipse.m2e.core.prefs
com.zrqx.content/.settings/org.eclipse.m2e.core.prefs
+0
-4
org.eclipse.wst.common.project.facet.core.prefs.xml
...tings/org.eclipse.wst.common.project.facet.core.prefs.xml
+0
-7
org.eclipse.wst.common.project.facet.core.xml
...t/.settings/org.eclipse.wst.common.project.facet.core.xml
+0
-5
pom.xml
com.zrqx.content/pom.xml
+0
-104
ContentStart.java
....content/src/main/java/com/zrqx/content/ContentStart.java
+0
-55
SysuserClient.java
...ava/com/zrqx/content/bg/client/sysuser/SysuserClient.java
+0
-33
SysuserClientHystric.java
.../zrqx/content/bg/client/sysuser/SysuserClientHystric.java
+0
-37
ContentController.java
...zrqx/content/bg/controller/content/ContentController.java
+0
-0
ContentColumnController.java
.../bg/controller/contentColumn/ContentColumnController.java
+0
-199
ContentSourceController.java
.../bg/controller/contentSource/ContentSourceController.java
+0
-111
ContentImgMapper.java
.../com/zrqx/content/bg/mapper/content/ContentImgMapper.java
+0
-11
ContentMapper.java
...ava/com/zrqx/content/bg/mapper/content/ContentMapper.java
+0
-80
ContentColumnMapper.java
.../content/bg/mapper/contentColumn/ContentColumnMapper.java
+0
-79
ContentSourceMapper.java
.../content/bg/mapper/contentSource/ContentSourceMapper.java
+0
-46
ContentImgService.java
...om/zrqx/content/bg/service/content/ContentImgService.java
+0
-8
ContentImgServiceImpl.java
...rqx/content/bg/service/content/ContentImgServiceImpl.java
+0
-22
ContentService.java
...a/com/zrqx/content/bg/service/content/ContentService.java
+0
-37
ContentServiceImpl.java
...m/zrqx/content/bg/service/content/ContentServiceImpl.java
+0
-79
ContentColumnService.java
...ontent/bg/service/contentColumn/ContentColumnService.java
+0
-49
ContentColumnServiceImpl.java
...nt/bg/service/contentColumn/ContentColumnServiceImpl.java
+0
-163
ContentSourceService.java
...ontent/bg/service/contentSource/ContentSourceService.java
+0
-26
ContentSourceServiceImpl.java
...nt/bg/service/contentSource/ContentSourceServiceImpl.java
+0
-78
Redis.java
...content/src/main/java/com/zrqx/content/commons/Redis.java
+0
-138
Swagger2Config.java
.../java/com/zrqx/content/commons/config/Swagger2Config.java
+0
-70
WebAppConfig.java
...in/java/com/zrqx/content/commons/config/WebAppConfig.java
+0
-27
CustomExceptionHandler.java
...x/content/commons/interceptor/CustomExceptionHandler.java
+0
-87
InterceptorConfig.java
...m/zrqx/content/commons/interceptor/InterceptorConfig.java
+0
-51
LogAspect.java
.../java/com/zrqx/content/commons/interceptor/LogAspect.java
+0
-36
TxAdviceInterceptor.java
...zrqx/content/commons/interceptor/TxAdviceInterceptor.java
+0
-77
Copy.java
...ent/src/main/java/com/zrqx/content/commons/util/Copy.java
+0
-59
SysuserUtil.java
.../main/java/com/zrqx/content/commons/util/SysuserUtil.java
+0
-16
application.yml
com.zrqx.content/src/main/resources/application.yml
+0
-47
bootstrap.yml
com.zrqx.content/src/main/resources/bootstrap.yml
+0
-10
logback-custom.xml
com.zrqx.content/src/main/resources/logback-custom.xml
+0
-135
没有找到文件。
com.zrqx.content/.classpath
deleted
100644 → 0
浏览文件 @
b671bc0b
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
including=
"**/*.java"
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>
com.zrqx.content/.project
deleted
100644 → 0
浏览文件 @
b671bc0b
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
com.zrqx.content
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.wst.common.project.facet.core.builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.genuitec.eclipse.springframework.springbuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
com.genuitec.eclipse.springframework.springnature
</nature>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.m2e.core.maven2Nature
</nature>
<nature>
org.eclipse.wst.common.project.facet.core.nature
</nature>
</natures>
</projectDescription>
com.zrqx.content/.settings/org.eclipse.core.resources.prefs
deleted
100644 → 0
浏览文件 @
b671bc0b
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
com.zrqx.content/.settings/org.eclipse.jdt.core.prefs
deleted
100644 → 0
浏览文件 @
b671bc0b
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
com.zrqx.content/.settings/org.eclipse.m2e.core.prefs
deleted
100644 → 0
浏览文件 @
b671bc0b
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
com.zrqx.content/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
deleted
100644 → 0
浏览文件 @
b671bc0b
<root>
<facet
id=
"me.spring"
>
<node
name=
"libprov"
>
<attribute
name=
"provider-id"
value=
"spring-no-op-library-provider"
/>
</node>
</facet>
</root>
com.zrqx.content/.settings/org.eclipse.wst.common.project.facet.core.xml
deleted
100644 → 0
浏览文件 @
b671bc0b
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed
facet=
"java"
version=
"1.8"
/>
<installed
facet=
"me.spring"
version=
"4.1"
/>
</faceted-project>
com.zrqx.content/pom.xml
deleted
100644 → 0
浏览文件 @
b671bc0b
<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>
<parent>
<groupId>
com.zrqx
</groupId>
<artifactId>
com.zrqx.pom
</artifactId>
<version>
1.0.0
</version>
<relativePath>
../com.zrqx.pom
</relativePath>
</parent>
<groupId>
com.zrqx
</groupId>
<artifactId>
com.zrqx.content
</artifactId>
<dependencies>
<dependency>
<groupId>
com.zrqx
</groupId>
<artifactId>
com.zrqx.core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-zipkin
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-eureka
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<!--表示为web工程 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<!-- 用于健康监控 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-feign
</artifactId>
</dependency>
<!--熔断器 -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-hystrix
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-hystrix-dashboard
</artifactId>
</dependency>
<!-- <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId>
</dependency> -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<!--分布式事务 -->
<!-- <dependency> <groupId>com.codingapi</groupId> <artifactId>transaction-springcloud</artifactId>
<exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>*</artifactId>
</exclusion> </exclusions> </dependency> <dependency> <groupId>com.codingapi</groupId>
<artifactId>tx-plugins-db</artifactId> <exclusions> <exclusion> <groupId>org.slf4j</groupId>
<artifactId>*</artifactId> </exclusion> </exclusions> </dependency> -->
<!--swagger2 -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
</dependency>
<!-- Springsecurity给服务端提供安全访问 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-security
</artifactId>
</dependency>
<!--用于测试的 -->
<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-devtools</artifactId>
</dependency> -->
</dependencies>
</project>
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/ContentStart.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.feign.EnableFeignClients
;
import
org.springframework.context.annotation.Bean
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
tk.mybatis.spring.annotation.MapperScan
;
@EnableFeignClients
@EnableEurekaClient
@SpringBootApplication
// 系统会去入口类的同级包以及下级包中去扫描实体类,因此我们建议入口类的位置在groupId+arctifactID组合的包名下。
@MapperScan
(
basePackages
=
{
"com.zrqx.content.bg.mapper.*"
})
public
class
ContentStart
{
@Value
(
"${spring.datasource.url}"
)
private
String
url
;
@Value
(
"${spring.datasource.username}"
)
private
String
username
;
@Value
(
"${spring.datasource.password}"
)
private
String
password
;
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ContentStart
.
class
);
public
static
void
main
(
String
[]
args
)
{
// 下面两行代码都可以用来启动
SpringApplication
.
run
(
ContentStart
.
class
,
args
);
// new SpringApplicationBuilder(AppStart.class).web(true).run(args);
logger
.
info
(
"content服务已启动....."
);
// test serversion
}
@Bean
public
DruidDataSource
dataSource
()
{
DruidDataSource
dataSource
=
new
DruidDataSource
();
dataSource
.
setUrl
(
url
);
dataSource
.
setUsername
(
username
);
// 用户名
dataSource
.
setPassword
(
password
);
// 密码
dataSource
.
setInitialSize
(
2
);
dataSource
.
setMaxActive
(
20
);
dataSource
.
setMinIdle
(
0
);
dataSource
.
setMaxWait
(
60000
);
dataSource
.
setValidationQuery
(
"SELECT 1"
);
dataSource
.
setTestOnBorrow
(
false
);
dataSource
.
setTestWhileIdle
(
true
);
dataSource
.
setPoolPreparedStatements
(
false
);
return
dataSource
;
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/client/sysuser/SysuserClient.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
bg
.
client
.
sysuser
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
com.zrqx.core.constant.sysuser.SysUserRequestPath
;
import
com.zrqx.core.model.sysuser.log.Log
;
import
com.zrqx.core.util.CallBack
;
import
com.zrqx.core.vo.sysuser.bg.user.BasicsUserVo
;
@FeignClient
(
name
=
"sysuser"
,
fallback
=
SysuserClientHystric
.
class
)
public
interface
SysuserClient
{
/**
* 保存日志
* @param log
* @return
* @author yzg
* @date: 2018年8月16日 下午2:37:59
*/
@PostMapping
(
SysUserRequestPath
.
BG
+
SysUserRequestPath
.
LOG
+
SysUserRequestPath
.
SAVE
)
CallBack
<
Boolean
>
saveLog
(
@RequestBody
Log
log
);
/**
* 获得当前用户信息
* @return
*/
@GetMapping
(
SysUserRequestPath
.
BG
+
SysUserRequestPath
.
USER
+
SysUserRequestPath
.
GET_DEFAULT
)
CallBack
<
BasicsUserVo
>
selectOp
();
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/bg/client/sysuser/SysuserClientHystric.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
bg
.
client
.
sysuser
;
import
org.apache.log4j.Logger
;
import
org.springframework.stereotype.Component
;
import
com.zrqx.core.model.sysuser.log.Log
;
import
com.zrqx.core.util.CallBack
;
import
com.zrqx.core.vo.sysuser.bg.user.BasicsUserVo
;
/**
* @author Tujide.lv
*
*/
@Component
public
class
SysuserClientHystric
implements
SysuserClient
{
private
static
final
Logger
log
=
Logger
.
getLogger
(
SysuserClientHystric
.
class
);
/**
* @see com.zrqx.order.client.SysuserClient#saveLog(com.zrqx.core.model.sysuser.log.Log)
* @param log
* @return
* @author ray
* @date: 2018年7月27日 上午10:59:35
*/
@Override
public
CallBack
<
Boolean
>
saveLog
(
Log
log
)
{
SysuserClientHystric
.
log
.
info
(
"保存操作日志失败"
);
return
CallBack
.
fail
();
}
@Override
public
CallBack
<
BasicsUserVo
>
selectOp
()
{
// TODO Auto-generated method stub
return
null
;
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/controller/content/ContentController.java
deleted
100644 → 0
浏览文件 @
b671bc0b
差异被折叠。
点击展开。
com.zrqx.content/src/main/java/com/zrqx/content/bg/controller/contentColumn/ContentColumnController.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午12:00:29
*/
package
com
.
zrqx
.
content
.
bg
.
controller
.
contentColumn
;
import
java.util.List
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang.StringUtils
;
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.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
tk.mybatis.mapper.entity.Example.Criteria
;
import
com.zrqx.content.bg.service.content.ContentService
;
import
com.zrqx.content.bg.service.contentColumn.ContentColumnService
;
import
com.zrqx.core.constant.content.ContentRequestPath
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.model.content.contentColumn.ContentColumn
;
import
com.zrqx.core.util.CallBack
;
import
com.zrqx.core.util.Copy
;
import
com.zrqx.core.util.PageParam
;
import
com.zrqx.core.vo.content.contentColumn.ContentColumnVo
;
/**
* 内容栏目
*
* @author niguanghui
* @date 2018年12月24日下午12:00:29
*/
@RestController
@RequestMapping
(
ContentRequestPath
.
BG
+
ContentRequestPath
.
CONTENTCOLUMN
)
@Api
(
description
=
"内容管理-栏目库"
)
public
class
ContentColumnController
{
@Autowired
private
ContentColumnService
service
;
@Autowired
private
ContentService
contentService
;
@ApiOperation
(
value
=
"新增"
,
notes
=
"新增一个"
)
@PostMapping
(
value
=
ContentRequestPath
.
SAVE
)
public
CallBack
<
Boolean
>
save
(
@RequestBody
ContentColumn
contentColumn
)
{
contentColumn
.
setCode
(
null
);
int
sort
=
contentColumn
.
getSort
();
// sort最小值为0
int
minSort
=
0
;
if
(
sort
<
minSort
)
{
throw
new
BaseException
(
7
,
"请输入自然数"
);
}
if
(!
service
.
updateBySort
(
sort
,
null
,
contentColumn
.
getUpperId
()))
{
throw
new
BaseException
(
7
,
"修改排序号失败"
);
}
if
(!
service
.
insert
(
contentColumn
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
// 修改code
if
(!
service
.
updateByCode
(
contentColumn
.
getUpperId
(),
null
,
sort
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"单条删除"
,
notes
=
"根据id删除"
)
@PostMapping
(
value
=
ContentRequestPath
.
DELETE
)
public
CallBack
<
Boolean
>
delete
(
@RequestBody
Integer
oid
)
{
ContentColumn
cc
=
service
.
selectByPrimaryKey
(
oid
);
Integer
upperId
=
cc
.
getUpperId
();
Integer
sort
=
cc
.
getSort
();
String
code
=
cc
.
getCode
();
Criteria
cr
=
service
.
createCriteria
();
if
(
StringUtils
.
isBlank
(
code
))
{
throw
new
BaseException
(
7
,
"code不能为空"
);
}
cr
.
andLike
(
"code"
,
code
+
"%"
);
if
(!
service
.
deleteByCriteria
())
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
if
(!
service
.
updateByCode
(
upperId
,
sort
,
null
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"单条更新"
,
notes
=
"更新内容栏目"
)
@PostMapping
(
value
=
ContentRequestPath
.
UPDATE_OID
)
public
CallBack
<
Boolean
>
update
(
@RequestBody
ContentColumn
contentColumn
)
{
int
sort
=
contentColumn
.
getSort
();
contentColumn
.
setCode
(
null
);
// sort最小值为0
int
minSort
=
0
;
if
(
sort
<
minSort
)
{
throw
new
BaseException
(
7
,
"请输入自然数"
);
}
Integer
sortBefore
=
service
.
selectByPrimaryKey
(
contentColumn
).
getSort
();
// 修改排序号后的数据
if
(!
service
.
updateBySort
(
sort
,
contentColumn
.
getId
(),
contentColumn
.
getUpperId
()))
{
throw
new
BaseException
(
7
,
"修改排序号失败"
);
}
// 保存
if
(!
service
.
updateByPrimaryKeySelective
(
contentColumn
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
// 修改code
if
(!
service
.
updateByCode
(
contentColumn
.
getUpperId
(),
sortBefore
,
sort
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"根据ID查看内容栏目详情"
,
notes
=
"根据ID查看内容栏目详情"
)
@GetMapping
(
value
=
ContentRequestPath
.
OID
)
public
CallBack
<
ContentColumn
>
selectById
(
@PathVariable
Integer
oid
)
{
return
CallBack
.
success
(
service
.
selectByPrimaryKey
(
oid
));
}
@ApiOperation
(
value
=
"查看所有栏目"
,
notes
=
"查看所有栏目"
)
@GetMapping
(
value
=
ContentRequestPath
.
ALL
)
public
CallBack
<
List
<
ContentColumnVo
>>
selectAll
()
{
PageParam
pageParam
=
new
PageParam
();
pageParam
.
setPageSize
(
99999
);
pageParam
.
setOrderBy
(
"code"
);
List
<
ContentColumn
>
list
=
service
.
queryCriteria
(
pageParam
).
getList
();
List
<
ContentColumnVo
>
voList
=
Copy
.
copyList
(
list
,
ContentColumnVo
.
class
,
obj
->
obj
.
getUpperId
().
equals
(
0
));
tree
(
list
,
voList
);
return
CallBack
.
success
(
voList
);
}
@ApiOperation
(
value
=
"上/下移一位"
,
notes
=
"与上/下一条数据的sort和code互换"
)
@PostMapping
(
value
=
ContentRequestPath
.
UPDATE
)
public
CallBack
<
Boolean
>
exchangeSort
(
Integer
operationId
,
Integer
exchangeId
)
{
ContentColumn
operation
=
service
.
selectByPrimaryKey
(
operationId
);
ContentColumn
exchange
=
service
.
selectByPrimaryKey
(
exchangeId
);
if
(
operation
.
getUpperId
()
==
exchange
.
getUpperId
())
{
int
sortBefore
=
operation
.
getSort
();
int
sortAfter
=
exchange
.
getSort
();
operation
.
setSort
(
sortAfter
);
exchange
.
setSort
(
sortBefore
);
service
.
updateByPrimaryKeySelective
(
operation
);
service
.
updateByPrimaryKeySelective
(
exchange
);
// 修改code
service
.
updateByCode
(
operation
.
getUpperId
(),
sortBefore
,
sortAfter
);
return
CallBack
.
success
();
}
// 不在同级分类里:
// 向上移动,遇到上级分类
if
(
operation
.
getUpperId
().
equals
(
exchange
.
getId
()))
{
throw
new
BaseException
(
7
,
"到顶了"
);
}
// 向下移动,遇到上级分类同级的下一个分类
if
(
operation
.
getSort
()
<
exchange
.
getSort
())
{
throw
new
BaseException
(
7
,
"到底了"
);
}
throw
new
BaseException
(
7
,
"传入数据有问题"
);
}
@ApiOperation
(
value
=
"最大排序号"
,
notes
=
"最大排序号"
)
@GetMapping
(
ContentRequestPath
.
GET
+
ContentRequestPath
.
MAXORDERNUM
)
public
CallBack
<
Integer
>
getMaxSort
(
Integer
upperId
){
Integer
MaxSort
=
service
.
getMaxSort
(
upperId
);
if
(
MaxSort
==
null
){
MaxSort
=
0
;
}
return
CallBack
.
success
(
MaxSort
);
}
public
List
<
ContentColumnVo
>
tree
(
List
<
ContentColumn
>
list
,
List
<
ContentColumnVo
>
voList
){
voList
.
forEach
(
entity
->{
//第一次设置 一级分类的子类 后续递归设置 子类的子类
entity
.
setList
(
Copy
.
copyList
(
list
,
ContentColumnVo
.
class
,
obj
->
obj
.
getUpperId
().
equals
(
entity
.
getId
())));
//当前分类存在子类 开始递归子类
if
(
entity
.
getList
().
size
()
>
0
){
tree
(
list
,
entity
.
getList
());
}
});
return
voList
;
}
@ApiOperation
(
value
=
"标识名是否已存在"
,
notes
=
"true为已存在 新增时,oid为null"
)
@GetMapping
(
ContentRequestPath
.
NAME
+
ContentRequestPath
.
ISEXIST
)
public
CallBack
<
Boolean
>
isExistIdeName
(
String
identifierName
,
Integer
oid
){
return
CallBack
.
success
(
service
.
isExistIdeName
(
identifierName
,
oid
));
}
@ApiOperation
(
value
=
"显示名是否已存在"
,
notes
=
"true为已存在 新增时,oid为null"
)
@GetMapping
(
ContentRequestPath
.
CHECK_NAME
)
public
CallBack
<
Boolean
>
isExistDisName
(
String
displayName
,
Integer
oid
){
return
CallBack
.
success
(
service
.
isExistDisName
(
displayName
,
oid
));
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/controller/contentSource/ContentSourceController.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午4:58:44
*/
package
com
.
zrqx
.
content
.
bg
.
controller
.
contentSource
;
import
java.util.Date
;
import
java.util.List
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang.StringUtils
;
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.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
tk.mybatis.mapper.entity.Example.Criteria
;
import
com.zrqx.content.bg.service.contentSource.ContentSourceService
;
import
com.zrqx.core.constant.content.ContentRequestPath
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.model.content.contentSource.ContentSource
;
import
com.zrqx.core.util.CallBack
;
import
com.zrqx.core.util.PageInfo
;
import
com.zrqx.core.util.PageParam
;
/**
* 内容来源管理
*
* @author niguanghui
* @date 2018年12月24日下午4:58:45
*/
@RestController
@RequestMapping
(
ContentRequestPath
.
BG
+
ContentRequestPath
.
CONTENTSOURCE
)
@Api
(
description
=
"内容管理-来源库"
)
public
class
ContentSourceController
{
@Autowired
private
ContentSourceService
service
;
@ApiOperation
(
value
=
"新增"
,
notes
=
"新增一个"
)
@PostMapping
(
value
=
ContentRequestPath
.
SAVE
)
public
CallBack
<
Boolean
>
save
(
@RequestBody
ContentSource
contentSource
)
{
int
sort
=
contentSource
.
getSort
();
if
(
service
.
updateBySort
(
sort
,
null
))
{
contentSource
.
setCreateTime
(
new
Date
());
if
(!
service
.
insert
(
contentSource
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
}
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"批量删除"
,
notes
=
"批量删除"
)
@PostMapping
(
value
=
ContentRequestPath
.
BATCH_DELETE
)
public
CallBack
<
Boolean
>
delete
(
@RequestBody
List
<
Integer
>
ids
)
{
if
(
ids
.
size
()
==
0
)
{
throw
new
BaseException
(
7
,
"没有选中任何数据,请重新选择"
);
}
Criteria
cr
=
service
.
createCriteria
();
cr
.
andIn
(
"id"
,
ids
);
if
(!
service
.
deleteByCriteria
())
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"根据ID查看内容来源详情"
,
notes
=
"根据ID查看内容详情"
)
@GetMapping
(
value
=
ContentRequestPath
.
OID
)
public
CallBack
<
ContentSource
>
selectById
(
@PathVariable
Integer
oid
)
{
return
CallBack
.
success
(
service
.
selectByPrimaryKey
(
oid
));
}
@ApiOperation
(
value
=
"单条更新"
,
notes
=
"更新内容来源"
)
@PostMapping
(
value
=
ContentRequestPath
.
UPDATE
)
public
CallBack
<
Boolean
>
update
(
@RequestBody
ContentSource
contentSource
)
{
// 先修改新的排序号后面的排序号,再保存新的更新后的contentSource
if
(
service
.
updateBySort
(
contentSource
.
getSort
(),
contentSource
.
getId
()))
{
if
(!
service
.
updateByPrimaryKey
(
contentSource
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
FAIL
);
}
}
return
CallBack
.
success
(
true
);
}
@ApiOperation
(
value
=
"按来源名称模糊查找"
,
notes
=
"按来源名称模糊查找"
)
@GetMapping
(
ContentRequestPath
.
PAGE
+
ContentRequestPath
.
NAME
)
public
CallBack
<
PageInfo
<
ContentSource
>>
selectByCondition
(
String
sourceName
,
PageParam
pageParam
)
{
if
(
null
!=
pageParam
&&
StringUtils
.
isBlank
(
pageParam
.
getOrderBy
()))
{
pageParam
.
setOrderBy
(
"createTime desc"
);
}
Criteria
cr
=
service
.
createCriteria
();
if
(
StringUtils
.
isNotBlank
(
sourceName
))
{
cr
.
orLike
(
"sourceName"
,
sourceName
+
"%"
);
}
return
CallBack
.
success
(
service
.
queryCriteria
(
pageParam
));
}
@ApiOperation
(
value
=
"来源名称是否已存在"
,
notes
=
"true 已存在 "
)
@GetMapping
(
ContentRequestPath
.
ISEXIST
)
public
CallBack
<
Boolean
>
isexist
(
String
sourceName
,
Integer
oid
){
return
CallBack
.
success
(
service
.
isExistIdeName
(
sourceName
,
oid
));
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/mapper/content/ContentImgMapper.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
bg
.
mapper
.
content
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.content.ContentImg
;
@Mapper
public
interface
ContentImgMapper
extends
BaseMapper
<
ContentImg
>{
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/mapper/content/ContentMapper.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月25日 下午2:49:37
*/
package
com
.
zrqx
.
content
.
bg
.
mapper
.
content
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Delete
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
com.zrqx.core.form.content.bg.content.ContentSelectForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.content.Content
;
import
com.zrqx.core.vo.content.content.ContentVo
;
/**
* @author niguanghui
* @date 2018年12月25日下午2:49:37
*/
@Mapper
public
interface
ContentMapper
extends
BaseMapper
<
Content
>
{
/** 清空回收站 */
@Delete
(
"<script>"
+
"DELETE FROM con_content WHERE isDelete = 1 "
+
"</script>"
)
Integer
deleteAll
();
/** 统计回收站有多少条数据 */
@Select
(
"<script>"
+
"SELECT COUNT(*) FROM con_content WHERE isDelete = 1 "
+
"</script>"
)
Integer
count
();
/** 统计未删除数据数量 */
@Select
(
"<script>"
+
"SELECT COUNT(*) FROM con_content WHERE isDelete = 0 "
+
"</script>"
)
int
content
();
/** 分页查询*/
@Select
(
"<script>"
+
"SELECT cc.id,cc.title,cc.property,cc.source,cc.author,DATE_FORMAT(cc.uploadTime,'%Y-%m-%d %H:%i:%s') uploadTime,"
+
"cc.text,cc.video,cc.status,cc.userName "
+
"FROM con_content cc "
+
"<if test='"
+
NOTBLANK
+
"(form.range)'>"
+
"<if test='form.range == imgs'>"
+
"INNER JOIN con_content_img ci ON cc.id = ci.contentId "
+
"</if>"
+
"</if>"
+
"WHERE cc.isDelete = '${form.isDelete}' "
+
"<if test='form.status != null'>"
+
"and cc.status = '${form.status}' "
+
"</if>"
+
"<if test='"
+
NOTBLANK
+
"(form.range)'>"
+
"<if test='form.range != imgs'>"
+
"and cc.${form.range} IS NOT NULL "
+
"</if>"
+
"</if>"
+
"<if test='"
+
NOTBLANK
+
"(form.classify)'>"
+
"and cc.classify like concat ('${form.classify}','%') "
+
"</if>"
+
"<if test='"
+
NOTBLANK
+
"(form.search)'>"
+
"<if test='"
+
NOTBLANK
+
"(form.text)'>"
+
"and cc.${form.search} like concat('%','${form.text}','%') "
+
"</if>"
+
"</if>"
+
" and cc.uploadTime Between '${form.beginTime}' and '${form.endTime}' "
+
"</script>"
)
List
<
ContentVo
>
page
(
@Param
(
"form"
)
ContentSelectForm
form
,
@Param
(
"imgs"
)
String
imgs
);
/** 查询回收站所有数据的id*/
@Select
(
"<script>"
+
"SELECT id FROM con_content WHERE isDelete = 1 "
+
"</script>"
)
List
<
Integer
>
selectAllId
();
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/mapper/contentColumn/ContentColumnMapper.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午12:06:37
*/
package
com
.
zrqx
.
content
.
bg
.
mapper
.
contentColumn
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
com.zrqx.core.form.content.bg.contentColumn.ContentColumnForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.contentColumn.ContentColumn
;
import
com.zrqx.core.vo.content.contentColumn.ContentColumnVo
;
/**
* 内容栏目
*
* @author niguanghui
* @date 2018年12月24日下午12:06:37
*/
@Mapper
public
interface
ContentColumnMapper
extends
BaseMapper
<
ContentColumn
>
{
@Select
(
"<script>"
+
"SELECT MAX(sort) FROM con_content_column WHERE upperId = #{upperId}"
+
"</script>"
)
Integer
getMaxSort
(
Integer
upperId
);
/** 修改同级中,某排序号后的排序号 */
@Select
(
"<script>"
+
"SELECT id,upperId,sort FROM con_content_column "
+
" WHERE upperId = #{upperId} AND sort = #{sort} "
+
"<if test = 'id != null'>"
+
" AND id != #{id} "
+
"</if>"
+
"</script>"
)
List
<
ContentColumnForm
>
selecrBySort
(
ContentColumnForm
form
);
/** 排序全查询*/
@Select
(
"<script>"
+
"SELECT * FROM con_content_column ORDER BY code "
+
"</script>"
)
List
<
ContentColumnVo
>
selectOrderByAll
();
/** 按sort从小到大查找同级数据*/
@Select
(
"<script>"
+
" SELECT id,sort,code FROM con_content_column WHERE upperId = #{upperId} ORDER BY sort"
+
"</script>"
)
List
<
ContentColumn
>
selectOrderBy
(
int
upperId
);
/** 查找所有子级数据*/
@Select
(
"<script>"
+
" SELECT id,code FROM con_content_column WHERE code like concat(#{code},'%') ORDER BY code"
+
"</script>"
)
List
<
ContentColumn
>
selectByCode
(
String
code
);
/** 查询其他标识名相同的数量*/
@Select
(
"<script>"
+
" SELECT COUNT(*) FROM con_content_column WHERE "
+
" identifierName = #{identifierName} "
+
"<if test = 'oid != null'>"
+
" AND id != #{oid} "
+
"</if>"
+
"</script>"
)
int
isExistIdeName
(
@Param
(
"identifierName"
)
String
identifierName
,
@Param
(
"oid"
)
Integer
oid
);
/** 查询其他显示名相同的数量*/
@Select
(
"<script>"
+
" SELECT COUNT(*) FROM con_content_column WHERE "
+
" displayName = #{displayName} "
+
"<if test = 'oid != null'>"
+
" AND id != #{oid} "
+
"</if>"
+
"</script>"
)
int
isExistDisName
(
@Param
(
"displayName"
)
String
displayName
,
@Param
(
"oid"
)
Integer
oid
);
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/mapper/contentSource/ContentSourceMapper.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午4:59:01
*/
package
com
.
zrqx
.
content
.
bg
.
mapper
.
contentSource
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Select
;
import
com.zrqx.core.form.content.bg.contentSource.ContentSourceForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.contentSource.ContentSource
;
/**
* 内容来源管理
* @author niguanghui
* @date 2018年12月24日下午4:59:01
*/
@Mapper
public
interface
ContentSourceMapper
extends
BaseMapper
<
ContentSource
>{
@Select
(
"<script>"
+
"SELECT id,sort FROM con_content_source WHERE sort = #{sort} "
+
"<if test = 'id != null'>"
+
" AND id != #{id} "
+
"</if>"
+
"</script>"
)
List
<
ContentSourceForm
>
selecrBySort
(
ContentSourceForm
form
);
/** 最大排序号*/
@Select
(
"<script>"
+
"SELECT MAX(sort) FROM con_content_source "
+
"</script>"
)
Integer
getMaxSort
();
/** 其他同名的来源数量*/
@Select
(
"<script>"
+
"SELECT COUNT(*) FROM con_content_source WHERE sourceName = #{sourceName}"
+
"<if test = 'oid != null'>"
+
" AND id != #{oid} "
+
"</if>"
+
"</script>"
)
int
isExistIdeName
(
String
sourceName
,
Integer
oid
);
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/content/ContentImgService.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
bg
.
service
.
content
;
import
com.zrqx.core.model.content.content.ContentImg
;
import
com.zrqx.core.service.BaseService
;
public
interface
ContentImgService
extends
BaseService
<
ContentImg
,
Integer
>{
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/content/ContentImgServiceImpl.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
bg
.
service
.
content
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zrqx.content.bg.mapper.content.ContentImgMapper
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.content.ContentImg
;
import
com.zrqx.core.service.BaseServiceImpl
;
@Service
public
class
ContentImgServiceImpl
extends
BaseServiceImpl
<
ContentImg
,
Integer
>
implements
ContentImgService
{
@Autowired
ContentImgMapper
mapper
;
@Override
public
BaseMapper
<
ContentImg
>
getMapper
()
{
return
mapper
;
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/content/ContentService.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月25日 下午2:49:53
*/
package
com
.
zrqx
.
content
.
bg
.
service
.
content
;
import
java.util.List
;
import
com.zrqx.core.form.content.bg.content.ContentSelectForm
;
import
com.zrqx.core.model.content.content.Content
;
import
com.zrqx.core.service.BaseService
;
import
com.zrqx.core.util.PageInfo
;
import
com.zrqx.core.util.PageParam
;
import
com.zrqx.core.vo.content.content.ContentVo
;
/**
* @author niguanghui
* @date 2018年12月25日下午2:49:53
*/
public
interface
ContentService
extends
BaseService
<
Content
,
Integer
>
{
/** 清空回收站 */
Integer
deleteAll
();
/** 统计回收站有多少条数据 */
Integer
count
();
/** 资讯总数*/
int
content
();
/** 分页查询*/
PageInfo
<
ContentVo
>
page
(
ContentSelectForm
form
,
PageParam
pageParam
);
/** 查询回收站所有数据的id*/
List
<
Integer
>
selectAllId
();
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/content/ContentServiceImpl.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月25日 下午2:50:06
*/
package
com
.
zrqx
.
content
.
bg
.
service
.
content
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zrqx.content.bg.mapper.content.ContentMapper
;
import
com.zrqx.core.form.content.bg.content.ContentSelectForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.content.Content
;
import
com.zrqx.core.service.BaseServiceImpl
;
import
com.zrqx.core.util.PageInfo
;
import
com.zrqx.core.util.PageParam
;
import
com.zrqx.core.vo.content.content.ContentVo
;
/**
* @author niguanghui
* @date 2018年12月25日下午2:50:06
*/
@Service
public
class
ContentServiceImpl
extends
BaseServiceImpl
<
Content
,
Integer
>
implements
ContentService
{
@Autowired
ContentMapper
mapper
;
@Override
public
BaseMapper
<
Content
>
getMapper
()
{
return
mapper
;
}
/** 清空回收站 */
@Override
public
Integer
deleteAll
()
{
return
mapper
.
deleteAll
();
}
/** 统计回收站有多少条数据 */
@Override
public
Integer
count
()
{
return
mapper
.
count
();
}
/** 统计未删除数据数量 */
@Override
public
int
content
()
{
return
mapper
.
content
();
}
/** 分页查询*/
@Override
public
PageInfo
<
ContentVo
>
page
(
ContentSelectForm
form
,
PageParam
pageParam
)
{
startPage
(
pageParam
);
String
beginTime
=
form
.
getBeginTime
();
if
(
beginTime
==
null
)
{
beginTime
=
"0001-01-01"
;
form
.
setBeginTime
(
beginTime
);
}
String
endTime
=
form
.
getEndTime
();
if
(
endTime
==
null
)
{
endTime
=
"9999-12-31"
;
}
form
.
setEndTime
(
endTime
+
" 23:59:59"
);
List
<
ContentVo
>
list
=
mapper
.
page
(
form
,
"imgs"
);
return
new
PageInfo
<
ContentVo
>(
list
);
}
/** 查询回收站所有数据的id*/
@Override
public
List
<
Integer
>
selectAllId
()
{
return
mapper
.
selectAllId
();
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/contentColumn/ContentColumnService.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午12:02:14
*/
package
com
.
zrqx
.
content
.
bg
.
service
.
contentColumn
;
import
java.util.List
;
import
com.zrqx.core.model.content.contentColumn.ContentColumn
;
import
com.zrqx.core.service.BaseService
;
import
com.zrqx.core.vo.content.contentColumn.ContentColumnVo
;
/**
* 内容栏目
*
* @author niguanghui
* @date 2018年12月24日下午12:02:14
*/
public
interface
ContentColumnService
extends
BaseService
<
ContentColumn
,
Integer
>
{
/** 根据上级排序号,查询同级最大排序号 */
Integer
getMaxSort
(
Integer
upperId
);
/** 修改某排序号后面的数据的排序号 */
boolean
updateBySort
(
Integer
sort
,
Integer
oid
,
Integer
upperId
);
/** 排序全查询 */
List
<
ContentColumnVo
>
selectOrderByAll
();
/**
*
* @param upperId
* 上级id
* @param sotrBefore
* 修改前sort
* @param sotrAfter
* 修改后sort
* @return
* @author niguanghui
* @date: 2019年1月18日 上午9:11:04
*/
boolean
updateByCode
(
int
upperId
,
Integer
sortBefore
,
Integer
sortAfter
);
/** 标识名是否已存在*/
boolean
isExistIdeName
(
String
identifierName
,
Integer
oid
);
/** 显示名是否已存在*/
boolean
isExistDisName
(
String
displayName
,
Integer
oid
);
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/contentColumn/ContentColumnServiceImpl.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午12:02:35
*/
package
com
.
zrqx
.
content
.
bg
.
service
.
contentColumn
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zrqx.content.bg.mapper.contentColumn.ContentColumnMapper
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.content.bg.contentColumn.ContentColumnForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.contentColumn.ContentColumn
;
import
com.zrqx.core.service.BaseServiceImpl
;
import
com.zrqx.core.vo.content.contentColumn.ContentColumnVo
;
/**
* 内容栏目
*
* @author niguanghui
* @date 2018年12月24日下午12:02:35
*/
@Service
public
class
ContentColumnServiceImpl
extends
BaseServiceImpl
<
ContentColumn
,
Integer
>
implements
ContentColumnService
{
@Autowired
private
ContentColumnMapper
mapper
;
@Override
public
BaseMapper
<
ContentColumn
>
getMapper
()
{
return
mapper
;
}
/** 根据上级排序号,查询同级最大排序号 */
@Override
public
Integer
getMaxSort
(
Integer
upperId
)
{
return
mapper
.
getMaxSort
(
upperId
);
}
/** 修改某排序号后面的数据的排序号 */
public
boolean
updateBySort
(
Integer
sort
,
Integer
oid
,
Integer
upperId
)
{
ContentColumnForm
form
=
new
ContentColumnForm
();
int
size
=
0
;
form
.
setId
(
oid
);
form
.
setSort
(
sort
);
form
.
setUpperId
(
upperId
);
do
{
List
<
ContentColumnForm
>
list
=
mapper
.
selecrBySort
(
form
);
size
=
list
.
size
();
// 没有数据
if
(
size
==
0
)
{
return
true
;
}
// 有且只有一个数据
if
(
size
==
1
)
{
sort
++;
form
=
list
.
get
(
0
);
ContentColumn
cc
=
new
ContentColumn
();
form
.
setSort
(
sort
);
cc
.
setId
(
form
.
getId
());
cc
.
setSort
(
sort
);
mapper
.
updateByPrimaryKeySelective
(
cc
);
}
// 有多个数据
if
(
size
>
1
)
{
throw
new
BaseException
(
7
,
"数据库数据有异常!"
);
}
}
while
(
true
);
}
/** 排序全查询 */
@Override
public
List
<
ContentColumnVo
>
selectOrderByAll
()
{
return
mapper
.
selectOrderByAll
();
}
/** 设置code */
@Override
public
boolean
updateByCode
(
int
upperId
,
Integer
sortBefore
,
Integer
sortAfter
)
{
if
(
sortBefore
==
sortAfter
)
{
return
true
;
}
// sortBefore sortAfter中的较大值larger 较小值smaller
int
larger
,
smaller
;
if
(
sortBefore
==
null
)
{
// 新增
larger
=
mapper
.
getMaxSort
(
upperId
);
smaller
=
sortAfter
;
}
else
if
(
sortAfter
==
null
)
{
// 删除
larger
=
mapper
.
getMaxSort
(
upperId
);
smaller
=
sortBefore
;
}
else
if
(
sortBefore
<
sortAfter
)
{
larger
=
sortAfter
;
smaller
=
sortBefore
;
}
else
{
larger
=
sortBefore
;
smaller
=
sortAfter
;
}
String
upCode
=
""
;
ContentColumn
obj
=
mapper
.
selectByPrimaryKey
(
upperId
);
if
(
obj
!=
null
)
{
upCode
=
obj
.
getCode
();
}
List
<
ContentColumn
>
list
=
mapper
.
selectOrderBy
(
upperId
);
// code从大到小赋值
List
<
ContentColumn
>
updateList
=
new
ArrayList
<
ContentColumn
>();
for
(
int
i
=
list
.
size
();
i
>
0
;
i
--)
{
ContentColumn
cc
=
list
.
get
(
i
-
1
);
int
sort
=
cc
.
getSort
();
// 不需要修改
if
(
sort
>
larger
)
{
continue
;
}
if
(
sort
<
smaller
)
{
break
;
}
// 需要修改code的数据
String
code
=
upCode
;
if
(
sort
<
10
)
{
code
+=
0
;
}
code
+=
sort
;
String
codeBefore
=
cc
.
getCode
();
cc
.
setCode
(
code
);
updateList
.
add
(
cc
);
// 修改子级code
List
<
ContentColumn
>
ccList
=
mapper
.
selectByCode
(
codeBefore
);
if
(
ccList
!=
null
)
{
for
(
ContentColumn
contentColumn
:
ccList
)
{
String
cs
=
contentColumn
.
getCode
();
StringBuffer
sb
=
new
StringBuffer
(
cs
);
sb
.
replace
(
0
,
code
.
length
(),
code
);
contentColumn
.
setCode
(
sb
+
""
);
updateList
.
add
(
contentColumn
);
}
}
}
if
(
updateList
!=
null
)
{
for
(
ContentColumn
contentColumn
:
updateList
)
{
if
(
mapper
.
updateByPrimaryKeySelective
(
contentColumn
)
!=
1
)
{
throw
new
BaseException
(
7
,
"修改子级code时出错"
);
}
}
}
return
true
;
}
@Override
public
boolean
isExistIdeName
(
String
identifierName
,
Integer
oid
)
{
return
mapper
.
isExistIdeName
(
identifierName
,
oid
)
>
0
;
}
@Override
public
boolean
isExistDisName
(
String
displayName
,
Integer
oid
)
{
return
mapper
.
isExistDisName
(
displayName
,
oid
)
>
0
;
}
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/contentSource/ContentSourceService.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午4:59:43
*/
package
com
.
zrqx
.
content
.
bg
.
service
.
contentSource
;
import
com.zrqx.core.model.content.contentSource.ContentSource
;
import
com.zrqx.core.service.BaseService
;
/**
* 内容来源管理
*
* @author niguanghui
* @date 2018年12月24日下午4:59:43
*/
public
interface
ContentSourceService
extends
BaseService
<
ContentSource
,
Integer
>
{
/** 修改某排序号后面的数据的排序号 */
Boolean
updateBySort
(
Integer
sort
,
Integer
oid
);
/** 获取最大排序号 */
Integer
getMaxSort
();
/** 来源名称是否已存在*/
boolean
isExistIdeName
(
String
sourceName
,
Integer
oid
);
}
com.zrqx.content/src/main/java/com/zrqx/content/bg/service/contentSource/ContentSourceServiceImpl.java
deleted
100644 → 0
浏览文件 @
b671bc0b
/**
* @author niguanghui
* @date 2018年12月24日 下午5:00:19
*/
package
com
.
zrqx
.
content
.
bg
.
service
.
contentSource
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zrqx.content.bg.mapper.contentSource.ContentSourceMapper
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.content.bg.contentSource.ContentSourceForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.content.contentSource.ContentSource
;
import
com.zrqx.core.service.BaseServiceImpl
;
/**
* 内容来源管理
*
* @author niguanghui
* @date 2018年12月24日下午5:00:19
*/
@Service
public
class
ContentSourceServiceImpl
extends
BaseServiceImpl
<
ContentSource
,
Integer
>
implements
ContentSourceService
{
@Autowired
ContentSourceMapper
mapper
;
@Override
public
BaseMapper
<
ContentSource
>
getMapper
()
{
// TODO Auto-generated method stub
return
mapper
;
}
/** 修改某排序号后面的数据的排序号 */
public
Boolean
updateBySort
(
Integer
sort
,
Integer
oid
)
{
ContentSourceForm
form
=
new
ContentSourceForm
();
int
size
=
0
;
form
.
setId
(
oid
);
form
.
setSort
(
sort
);
do
{
List
<
ContentSourceForm
>
list
=
mapper
.
selecrBySort
(
form
);
size
=
list
.
size
();
// 没有数据
if
(
size
==
0
)
{
return
true
;
}
System
.
err
.
println
(
sort
);
// 有且只有一个数据
if
(
size
==
1
)
{
sort
++;
form
=
list
.
get
(
0
);
ContentSource
cs
=
new
ContentSource
();
form
.
setSort
(
sort
);
cs
.
setId
(
form
.
getId
());
cs
.
setSort
(
sort
);
mapper
.
updateByPrimaryKeySelective
(
cs
);
}
// 有多个数据
if
(
size
>
1
)
{
throw
new
BaseException
(
7
,
"数据库数据有异常!"
);
}
}
while
(
true
);
}
@Override
public
Integer
getMaxSort
()
{
return
mapper
.
getMaxSort
();
}
@Override
public
boolean
isExistIdeName
(
String
sourceName
,
Integer
oid
)
{
return
mapper
.
isExistIdeName
(
sourceName
,
oid
)
>
0
;
}
}
com.zrqx.content/src/main/java/com/zrqx/content/commons/Redis.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
;
import
java.io.IOException
;
import
java.util.Enumeration
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.jedis.JedisConnectionFactory
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.model.sysuser.user.User
;
import
com.zrqx.core.util.JsonUtil.JsonUtil
;
/**
* Redis消息管理 ,调用时不能用多线程调用
* @author lpf
* @date 2018年6月5日上午10:03:01
*/
@Component
public
class
Redis
{
private
static
final
String
FG_TOKEN
=
"y-token"
;
private
static
final
String
BG_TOKEN
=
"x-token"
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
public
void
updateDatebase
(
int
num
)
{
JedisConnectionFactory
jedisConnectionFactory
=
(
JedisConnectionFactory
)
stringRedisTemplate
.
getConnectionFactory
();
jedisConnectionFactory
.
setDatabase
(
num
);
stringRedisTemplate
.
setConnectionFactory
(
jedisConnectionFactory
);
}
/**
* 获取后台登录用户信息
*
* @return
*/
public
User
getUser
()
{
return
getInfoObjectRedis
(
getToken
(
BG_TOKEN
),
User
.
class
);
}
public
String
fmtObj
(
Object
obj
)
throws
IOException
{
return
obj
instanceof
String
?
obj
.
toString
():
JsonUtil
.
bean2Json
(
obj
);
}
/**
* 添加到redis
* @param token
* Key
* @param obj
* Value
* @param timeout
* 过期时间
* @param unit
* TimeUnitEnum 时间格式
* @throws IOException
*/
public
void
set
(
String
token
,
Object
obj
,
long
timeout
,
TimeUnit
unit
)
throws
IOException
{
stringRedisTemplate
.
opsForValue
().
set
(
token
,
fmtObj
(
obj
),
timeout
,
unit
);
}
public
void
set
(
String
token
,
Object
obj
,
long
timeout
)
throws
IOException
{
stringRedisTemplate
.
opsForValue
().
set
(
token
,
fmtObj
(
obj
),
timeout
,
TimeUnit
.
SECONDS
);
}
/**
* 添加到redis
* @param token Key
* @param obj Value
* @throws IOException
*/
public
void
set
(
String
token
,
Object
obj
)
throws
IOException
{
stringRedisTemplate
.
opsForValue
().
set
(
token
,
fmtObj
(
obj
));
}
/**
* 根据key删除redis中的数据
* @param key
* @throws IOException
*/
public
void
delete
(
String
key
)
throws
IOException
{
stringRedisTemplate
.
delete
(
key
);
}
/**
* 根据key查询redis中的数据
*
* @param token
* @return
*/
public
String
get
(
String
token
)
{
return
stringRedisTemplate
.
opsForValue
().
get
(
token
);
}
public
<
T
>
T
getInfoObjectRedis
(
String
key
,
Class
<
T
>
objClass
){
try
{
String
userInfo
=
get
(
key
);
if
(
StringUtils
.
isEmpty
(
userInfo
))
{
throw
new
BaseException
(
ResponseCodeEnum
.
NO_LOGIN
);
}
return
JsonUtil
.
json2Bean
(
userInfo
,
objClass
);
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"获取用户信息错误!"
+
e
.
getMessage
());
}
}
public
static
String
getToken
(
String
tokenName
){
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
String
token
=
null
;
while
(
headerNames
.
hasMoreElements
())
{
String
key
=
(
String
)
headerNames
.
nextElement
();
//TODO--前台获取token
if
(
key
.
toLowerCase
().
equals
(
tokenName
)){
token
=
request
.
getHeader
(
key
);
}
}
if
(
token
==
null
)
{
throw
new
BaseException
(
ResponseCodeEnum
.
NO_LOGIN
);
}
return
token
;
}
public
static
String
getBgToken
(){
return
getToken
(
BG_TOKEN
);
}
public
static
String
getFgToken
(){
return
getToken
(
FG_TOKEN
);
}
}
com.zrqx.content/src/main/java/com/zrqx/content/commons/config/Swagger2Config.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* 访问地址
* http://ip:port/swagger-ui.html
最常用的5个注解
@Api:修饰整个类,描述Controller的作用
@ApiOperation:描述一个类的一个方法,或者说一个接口
@ApiParam:单个参数描述
@ApiModel:用对象来接收参数
@ApiModelProperty:用对象接收参数时,描述对象的一个字段
其它若干
@ApiResponse:HTTP响应其中1个描述
@ApiResponses:HTTP响应整体描述
@ApiIgnore:使用该注解忽略这个API
@ApiClass
@ApiError
@ApiErrors
@ApiParamImplicit
@ApiParamsImplicit
*/
@EnableSwagger2
@Configuration
public
class
Swagger2Config
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
//为当前包路径
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.zrqx"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
//构建 api文档的详细信息函数
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
//页面标题
.
title
(
"sysUser 测试使用 Swagger2 构建RESTful API"
)
//描述
.
description
(
"sysUser服务 API 描述"
)
//创建人
.
contact
(
new
Contact
(
"陈新昌"
,
"www.baidu.com"
,
"cxinchang@126.com"
))
//版本号
.
version
(
"3.0"
)
.
build
();
}
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/commons/config/WebAppConfig.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.zrqx.content.commons.interceptor.InterceptorConfig
;
import
com.zrqx.core.constant.sysuser.SysUserRequestPath
;
@Configuration
public
class
WebAppConfig
extends
WebMvcConfigurerAdapter
{
/**
* 跨域支持
*/
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
).
allowedOrigins
(
"*"
).
allowedMethods
(
"*"
).
allowCredentials
(
false
).
maxAge
(
3600
);
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
//注册自定义拦截器,添加拦截路径和排除拦截路径
registry
.
addInterceptor
(
new
InterceptorConfig
()).
addPathPatterns
(
SysUserRequestPath
.
BG
+
"/**"
)
.
excludePathPatterns
(
SysUserRequestPath
.
BG
+
SysUserRequestPath
.
PERMISSIONS
+
SysUserRequestPath
.
LOGIN
);
}
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/commons/interceptor/CustomExceptionHandler.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
interceptor
;
import
java.util.Date
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.log4j.Logger
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.ObjectError
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.CallBack
;
/**
*controller 异常处理
* @ClassName: CustomExceptionHandler
* @Description: TODO(这里用一句话描述这个类的作用)
* @author 杨振广
* @date 2016-7-14 上午9:45:40
*
*/
@ControllerAdvice
public
class
CustomExceptionHandler
{
private
static
Logger
logger
=
Logger
.
getLogger
(
CustomExceptionHandler
.
class
);
@ExceptionHandler
(
Exception
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseBody
public
Object
handlerException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Exception
e
){
e
.
printStackTrace
();
StackTraceElement
[]
s
=
e
.
getStackTrace
();
StringBuffer
stes
=
new
StringBuffer
(
s
.
length
*
2
);
for
(
StackTraceElement
stackTraceElement
:
s
)
{
stes
.
append
(
stackTraceElement
.
toString
());
stes
.
append
(
"<br/>"
);
}
String
info
=
"异常时间:"
+
new
Date
().
toLocaleString
()+
"\n请求地址:"
+
request
.
getRequestURI
()+
"\n参数:"
+
request
.
getQueryString
()+
"\n"
+
e
.
getMessage
();
logger
.
error
(
info
+
"\n"
+
stes
.
toString
());
request
.
setAttribute
(
"error"
,
info
);
request
.
setAttribute
(
"errorInfo"
,
e
.
getStackTrace
());
return
CallBack
.
exception
(
e
.
getMessage
());
}
/**
* 参数验证异常处理
* @Title: handlerException
* @Description:
* @param request
* @param response
* @param e BindException
* @return
* @author lpf
* @date: 2018年5月9日 下午5:01:58
*/
@ExceptionHandler
(
BindException
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseBody
public
Object
handlerException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
BindException
e
)
{
List
<
ObjectError
>
errors
=
e
.
getAllErrors
();
StringBuffer
msg
=
new
StringBuffer
();
for
(
ObjectError
objectError
:
errors
)
{
msg
.
append
(
objectError
.
getDefaultMessage
());
msg
.
append
(
","
);
}
msg
.
deleteCharAt
(
msg
.
length
()-
1
);
return
CallBack
.
validate
(
msg
.
toString
());
}
/**
* 执行异常处理
* @Description:
* @param e BaseException
* @return
* @date: 2018年5月9日 下午5:01:58
*
*/
@ExceptionHandler
(
BaseException
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseBody
public
Object
myException
(
BaseException
e
)
{
return
CallBack
.
exception
(
e
.
getCode
(),
null
,
e
.
getMessage
());
}
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/commons/interceptor/InterceptorConfig.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
interceptor
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
public
class
InterceptorConfig
implements
HandlerInterceptor
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
InterceptorConfig
.
class
);
/**
* 进入controller层之前拦截请求
* @param httpServletRequest
* @param httpServletResponse
* @param o
* @return
* @throws Exception
*/
@Override
public
boolean
preHandle
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
Object
o
)
throws
Exception
{
HttpSession
session
=
httpServletRequest
.
getSession
();
if
(
session
.
getAttribute
(
"user"
)
!=
null
){
return
true
;
}
else
{
// PrintWriter printWriter = httpServletResponse.getWriter();
// printWriter.write(JsonUtil.bean2Json(CallBack.create(ResponseCodeEnum.NO_LOGIN)));
// return false;
return
true
;
}
}
@Override
public
void
postHandle
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
Object
o
,
ModelAndView
modelAndView
)
throws
Exception
{
log
.
info
(
"--------------处理请求完成后视图渲染之前的处理操作---------------"
);
}
@Override
public
void
afterCompletion
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
Object
o
,
Exception
e
)
throws
Exception
{
log
.
info
(
"---------------视图渲染之后的操作--------------------------"
);
}
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/commons/interceptor/LogAspect.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
interceptor
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.zrqx.content.bg.client.sysuser.SysuserClient
;
import
com.zrqx.content.commons.Redis
;
import
com.zrqx.core.model.sysuser.log.Log
;
import
com.zrqx.core.model.sysuser.user.User
;
import
com.zrqx.core.util.LogUtils
;
import
io.swagger.annotations.ApiOperation
;
@Aspect
@Component
public
class
LogAspect
{
@Autowired
private
SysuserClient
logService
;
@Autowired
private
Redis
redis
;
// 环绕通知,环绕增强,相当于MethodInterceptor
@Around
(
value
=
"execution(* com.zrqx.content.bg.controller..*(..)) and @annotation(annotation) and @annotation(org.springframework.web.bind.annotation.PostMapping)"
,
argNames
=
"annotation"
)
public
Object
arround
(
ProceedingJoinPoint
pjp
,
ApiOperation
annotation
)
throws
Throwable
{
// User user = redis.getInfoObjectRedis("661fb581c7144400a4ab09b4977c1f54", User.class);
User
user
=
redis
.
getUser
();
Log
log
=
LogUtils
.
getLog
(
pjp
,
annotation
,
this
.
getClass
(),
user
.
getUserName
(),
user
.
getIp
());
logService
.
saveLog
(
log
);
return
log
.
getResult
();
}
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/commons/interceptor/TxAdviceInterceptor.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
interceptor
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.sql.DataSource
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.aop.Advisor
;
import
org.springframework.aop.aspectj.AspectJExpressionPointcut
;
import
org.springframework.aop.support.DefaultPointcutAdvisor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource
;
import
org.springframework.transaction.interceptor.RollbackRuleAttribute
;
import
org.springframework.transaction.interceptor.RuleBasedTransactionAttribute
;
import
org.springframework.transaction.interceptor.TransactionAttribute
;
import
org.springframework.transaction.interceptor.TransactionInterceptor
;
/**
* Created by guozp on 2017/8/28.
*/
@Aspect
//@Component 事务依然生效
@Configuration
public
class
TxAdviceInterceptor
{
private
static
final
int
TX_METHOD_TIMEOUT
=
5
;
private
static
final
String
AOP_POINTCUT_EXPRESSION
=
"execution(* com.zrqx..service..*Impl.*(..))"
;
@Autowired
private
PlatformTransactionManager
transactionManager
;
// 其中 dataSource 框架会自动为我们注入
@Bean
(
name
=
"transactionManager"
)
public
PlatformTransactionManager
transactionManager
(
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
public
TransactionInterceptor
txAdvice
()
{
NameMatchTransactionAttributeSource
source
=
new
NameMatchTransactionAttributeSource
();
/*只读事务,不做更新操作*/
RuleBasedTransactionAttribute
readOnlyTx
=
new
RuleBasedTransactionAttribute
();
readOnlyTx
.
setReadOnly
(
true
);
readOnlyTx
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
/*当前存在事务就使用当前事务,当前不存在事务就创建一个新的事务*/
RuleBasedTransactionAttribute
requiredTx
=
new
RuleBasedTransactionAttribute
();
requiredTx
.
setRollbackRules
(
Collections
.
singletonList
(
new
RollbackRuleAttribute
(
Exception
.
class
)));
requiredTx
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
requiredTx
.
setTimeout
(
TX_METHOD_TIMEOUT
);
Map
<
String
,
TransactionAttribute
>
txMap
=
new
HashMap
<>();
txMap
.
put
(
"add*"
,
requiredTx
);
txMap
.
put
(
"save*"
,
requiredTx
);
txMap
.
put
(
"insert*"
,
requiredTx
);
txMap
.
put
(
"update*"
,
requiredTx
);
txMap
.
put
(
"delete*"
,
requiredTx
);
txMap
.
put
(
"get*"
,
readOnlyTx
);
txMap
.
put
(
"query*"
,
readOnlyTx
);
source
.
setNameMap
(
txMap
);
TransactionInterceptor
txAdvice
=
new
TransactionInterceptor
(
transactionManager
,
source
);
return
txAdvice
;
}
@Bean
public
Advisor
txAdviceAdvisor
()
{
AspectJExpressionPointcut
pointcut
=
new
AspectJExpressionPointcut
();
pointcut
.
setExpression
(
AOP_POINTCUT_EXPRESSION
);
return
new
DefaultPointcutAdvisor
(
pointcut
,
txAdvice
());
//return new DefaultPointcutAdvisor(pointcut, txAdvice);
}
}
\ No newline at end of file
com.zrqx.content/src/main/java/com/zrqx/content/commons/util/Copy.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
util
;
import
java.util.List
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.BeanUtils
;
import
com.zrqx.core.exception.BaseException
;
public
class
Copy
{
/**
* 批量复制对象
*
* @param list
* @param clazz
* @return
*/
public
static
<
VO
,
R
>
List
<
VO
>
copyList
(
List
<
R
>
list
,
Class
<
VO
>
clazz
)
{
return
list
.
stream
().
map
(
obj
->
{
VO
vo
=
null
;
try
{
vo
=
clazz
.
newInstance
();
BeanUtils
.
copyProperties
(
obj
,
vo
);
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
throw
new
BaseException
(
"批量复制对象时创建对象失败。"
);
}
return
vo
;
}).
collect
(
Collectors
.
toList
());
}
/**
* 过滤批量复制对象
*
* @param list
* @param clazz
* @param filter
* @return
*/
public
static
<
VO
,
R
>
List
<
VO
>
copyList
(
List
<
R
>
list
,
Class
<
VO
>
clazz
,
Predicate
<
R
>
filter
)
{
return
list
.
stream
().
filter
(
filter
).
map
(
obj
->
{
VO
vo
=
null
;
try
{
vo
=
clazz
.
newInstance
();
BeanUtils
.
copyProperties
(
obj
,
vo
);
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
throw
new
BaseException
(
"批量复制对象时创建对象失败。"
);
}
return
vo
;
}).
collect
(
Collectors
.
toList
());
}
}
com.zrqx.content/src/main/java/com/zrqx/content/commons/util/SysuserUtil.java
deleted
100644 → 0
浏览文件 @
b671bc0b
package
com
.
zrqx
.
content
.
commons
.
util
;
public
class
SysuserUtil
{
/**
* 获取当前登录的系统管理员账号
*/
public
static
String
getSysuserAccount
(){
return
"test"
;
}
/**
* 获取当前登录的系统管理员的ip
*/
public
static
String
getSysuserIP
(){
return
"127.0.0.1"
;
}
}
com.zrqx.content/src/main/resources/application.yml
deleted
100644 → 0
浏览文件 @
b671bc0b
security
:
sessions
:
always
#always设置保存用户状态(内存可能会被占满) stateless设置不保存用户状态
basic
:
enabled
:
false
#开启认证
user
:
name
:
user
password
:
123456
feign
:
hystrix
:
enabled
:
true
logging
:
level
:
com.zrqx.content.bg.mapper
:
DEBUG
mybatis
:
type-aliases-package
:
com.zrqx.core.model
mapper
:
mappers
:
-
com.zrqx.core.mapper.BaseMapper
not-empty
:
false
i-d-e-n-t-i-t-y
:
MYSQL
style
:
normal
b-e-f-o-r-e
:
true
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
supportMethodsArguments
:
true
params
:
count=countSql
spring
:
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
time-zone
:
GMT+8
http
:
multipart
:
maxFileSize
:
20Mb
maxRequestSize
:
20Mb
ribbon
:
ConnectTimeout
:
60000
ReadTimeout
:
60000
hystrix
:
command
:
default
:
execution
:
isolation
:
strategy
:
SEMAPHORE
thread
:
timeoutInMilliseconds
:
120000
\ No newline at end of file
com.zrqx.content/src/main/resources/bootstrap.yml
deleted
100644 → 0
浏览文件 @
b671bc0b
server
:
port
:
8213
spring
:
cloud
:
config
:
uri
:
http://localhost:8218
#配置中心地址
name
:
content
profile
:
prod
label
:
master
\ No newline at end of file
com.zrqx.content/src/main/resources/logback-custom.xml
deleted
100644 → 0
浏览文件 @
b671bc0b
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://www.padual.com/java/logback.xsd"
debug=
"false"
scan=
"true"
scanPeriod=
"30 second"
>
<!--读取配置中心的属性-->
<springProperty
scope=
"context"
name=
"name"
source=
"spring.application.name"
/>
<property
name=
"ROOT"
value=
"/opt/logs/nrgl/${name}/"
/>
<property
name=
"FILESIZE"
value=
"50MB"
/>
<property
name=
"MAXHISTORY"
value=
"100"
/>
<property
name=
"DATETIME"
value=
"yyyy-MM-dd HH:mm:ss"
/>
<!-- 控制台打印 -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
</appender>
<!-- ERROR 输入到文件,按日期和文件大小 -->
<appender
name=
"ERROR"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/error.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- WARN 输入到文件,按日期和文件大小 -->
<appender
name=
"WARN"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/warn.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- INFO 输入到文件,按日期和文件大小 -->
<appender
name=
"INFO"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/info.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- DEBUG 输入到文件,按日期和文件大小 -->
<appender
name=
"DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
DEBUG
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/debug.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- TRACE 输入到文件,按日期和文件大小 -->
<appender
name=
"TRACE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
TRACE
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/trace.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- SQL相关日志输出-->
<logger
name=
"org.mybatis.spring"
level=
"DEBUG"
additivity=
"true"
/>
<logger
name=
"com.zrqx.content"
level=
"DEBUG"
additivity=
"true"
/>
<!-- Logger 根目录 -->
<root
level=
"INFO"
>
<appender-ref
ref=
"STDOUT"
/>
<appender-ref
ref=
"DEBUG"
/>
<appender-ref
ref=
"ERROR"
/>
<appender-ref
ref=
"WARN"
/>
<appender-ref
ref=
"INFO"
/>
<appender-ref
ref=
"TRACE"
/>
</root>
</configuration>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论