Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
V
vms
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
LJJ
vms
Commits
34e46d3b
提交
34e46d3b
authored
9月 24, 2021
作者:
xyy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
4d6bead1
隐藏空白字符变更
内嵌
并排
正在显示
90 个修改的文件
包含
2092 行增加
和
1957 行删除
+2092
-1957
pom.xml
pom.xml
+1
-8
pom.xml
vms-inspection/pom.xml
+1
-1
InspectionApp.java
.../src/main/java/com/zjty/vms/inspection/InspectionApp.java
+0
-16
HandleProcessType.java
...ava/com/zjty/vms/inspection/config/HandleProcessType.java
+27
-0
ReportController.java
.../com/zjty/vms/inspection/controller/ReportController.java
+43
-0
ReportRepository.java
...in/java/com/zjty/vms/inspection/dao/ReportRepository.java
+12
-0
ReportDto.java
...in/java/com/zjty/vms/inspection/entity/dto/ReportDto.java
+49
-0
ReportSearchDto.java
...a/com/zjty/vms/inspection/entity/dto/ReportSearchDto.java
+16
-0
Report.java
...c/main/java/com/zjty/vms/inspection/entity/po/Report.java
+86
-0
ReportService.java
...n/java/com/zjty/vms/inspection/service/ReportService.java
+34
-0
ReportConverter.java
...jty/vms/inspection/service/converter/ReportConverter.java
+23
-0
ReportServiceImpl.java
...m/zjty/vms/inspection/service/impl/ReportServiceImpl.java
+74
-0
EventController.java
...ty/vms/inspection/subject/controller/EventController.java
+0
-80
FileController.java
...jty/vms/inspection/subject/controller/FileController.java
+0
-81
EventDao.java
...in/java/com/zjty/vms/inspection/subject/dao/EventDao.java
+0
-17
EventImageDao.java
...va/com/zjty/vms/inspection/subject/dao/EventImageDao.java
+0
-11
Event.java
.../com/zjty/vms/inspection/subject/entity/domain/Event.java
+0
-93
EventImage.java
...zjty/vms/inspection/subject/entity/domain/EventImage.java
+0
-45
EventCreateVo.java
.../zjty/vms/inspection/subject/entity/vo/EventCreateVo.java
+0
-42
FindVo.java
...ava/com/zjty/vms/inspection/subject/entity/vo/FindVo.java
+0
-35
EventImageService.java
...jty/vms/inspection/subject/service/EventImageService.java
+0
-8
EventService.java
...com/zjty/vms/inspection/subject/service/EventService.java
+0
-59
EventImageServiceImpl.java
...nspection/subject/service/impl/EventImageServiceImpl.java
+0
-14
EventServiceImpl.java
...vms/inspection/subject/service/impl/EventServiceImpl.java
+0
-122
application.properties
vms-inspection/src/main/resources/application.properties
+0
-0
pom.xml
vms-maintain/pom.xml
+11
-19
CommonMaintainController.java
...jty/vms/maintain/controller/CommonMaintainController.java
+17
-0
CommonMaintain.java
.../java/com/zjty/vms/maintain/entity/po/CommonMaintain.java
+45
-0
pom.xml
vms-misc/pom.xml
+25
-1
BaseSearchDto.java
...main/java/com/zjty/vms/misc/baseEntity/BaseSearchDto.java
+10
-11
Swagger2Config.java
...rc/main/java/com/zjty/vms/misc/config/Swagger2Config.java
+76
-37
PageResult.java
...sc/src/main/java/com/zjty/vms/misc/entity/PageResult.java
+95
-0
ResponseCode.java
.../src/main/java/com/zjty/vms/misc/entity/ResponseCode.java
+116
-0
VmsFile.java
...c/main/java/com/zjty/vms/misc/subject/entity/VmsFile.java
+13
-16
JsonUtil.java
vms-misc/src/main/java/com/zjty/vms/misc/util/JsonUtil.java
+84
-0
StringUtil.java
...misc/src/main/java/com/zjty/vms/misc/util/StringUtil.java
+9
-0
pom.xml
vms-union/pom.xml
+21
-10
UnionApp.java
vms-union/src/main/java/com/zjty/vms/union/UnionApp.java
+9
-7
application.properties
vms-union/src/main/resources/application.properties
+0
-15
application.yml
vms-union/src/main/resources/application.yml
+27
-0
pom.xml
vms-user/pom.xml
+12
-6
UserApp.java
vms-user/src/main/java/com/zjty/vms/user/UserApp.java
+0
-22
UserException.java
...ava/com/zjty/vms/user/config/exception/UserException.java
+16
-0
UserExceptionConsts.java
...m/zjty/vms/user/config/exception/UserExceptionConsts.java
+23
-0
UseridAuditorBean.java
.../java/com/zjty/vms/user/config/jpa/UseridAuditorBean.java
+31
-0
BCryptConfig.java
.../java/com/zjty/vms/user/config/security/BCryptConfig.java
+19
-0
GrantedAuthorityImpl.java
...m/zjty/vms/user/config/security/GrantedAuthorityImpl.java
+28
-0
JwtAuthenticationFilter.java
...jty/vms/user/config/security/JwtAuthenticationFilter.java
+35
-0
JwtLoginFilter.java
...ava/com/zjty/vms/user/config/security/JwtLoginFilter.java
+107
-0
JwtTokenUtils.java
...java/com/zjty/vms/user/config/security/JwtTokenUtils.java
+221
-0
SecurityConfig.java
...ava/com/zjty/vms/user/config/security/SecurityConfig.java
+101
-0
SecurityUtils.java
...java/com/zjty/vms/user/config/security/SecurityUtils.java
+88
-0
WxConfiguration.java
...ain/java/com/zjty/vms/user/config/wx/WxConfiguration.java
+161
-0
WxProperties.java
...c/main/java/com/zjty/vms/user/config/wx/WxProperties.java
+46
-0
BusinessOwnerController.java
.../vms/user/subject/controller/BusinessOwnerController.java
+0
-34
CarController.java
...a/com/zjty/vms/user/subject/controller/CarController.java
+0
-61
RoleController.java
.../com/zjty/vms/user/subject/controller/RoleController.java
+0
-48
UserController.java
.../com/zjty/vms/user/subject/controller/UserController.java
+43
-40
AppUserDao.java
...c/main/java/com/zjty/vms/user/subject/dao/AppUserDao.java
+0
-18
BusinessOwnerDao.java
.../java/com/zjty/vms/user/subject/dao/BusinessOwnerDao.java
+0
-16
CarDao.java
...r/src/main/java/com/zjty/vms/user/subject/dao/CarDao.java
+0
-21
RoleDao.java
.../src/main/java/com/zjty/vms/user/subject/dao/RoleDao.java
+0
-12
UserRepository.java
...in/java/com/zjty/vms/user/subject/dao/UserRepository.java
+26
-0
AppUser.java
...c/main/java/com/zjty/vms/user/subject/entity/AppUser.java
+0
-56
BusinessOwner.java
.../java/com/zjty/vms/user/subject/entity/BusinessOwner.java
+0
-55
Car.java
...r/src/main/java/com/zjty/vms/user/subject/entity/Car.java
+0
-62
ParkingSpace.java
...n/java/com/zjty/vms/user/subject/entity/ParkingSpace.java
+0
-41
Role.java
.../src/main/java/com/zjty/vms/user/subject/entity/Role.java
+0
-38
Room.java
.../src/main/java/com/zjty/vms/user/subject/entity/Room.java
+0
-40
User.java
.../src/main/java/com/zjty/vms/user/subject/entity/User.java
+19
-10
UserVo.java
...rc/main/java/com/zjty/vms/user/subject/entity/UserVo.java
+7
-0
AppUserService.java
...ava/com/zjty/vms/user/subject/service/AppUserService.java
+0
-32
BusinessOwnerService.java
...m/zjty/vms/user/subject/service/BusinessOwnerService.java
+0
-29
CarService.java
...in/java/com/zjty/vms/user/subject/service/CarService.java
+0
-53
RoleService.java
...n/java/com/zjty/vms/user/subject/service/RoleService.java
+0
-33
UserService.java
...n/java/com/zjty/vms/user/subject/service/UserService.java
+61
-0
AppUserServiceImpl.java
...jty/vms/user/subject/service/impl/AppUserServiceImpl.java
+0
-47
BusinessOwnerServiceImpl.java
...s/user/subject/service/impl/BusinessOwnerServiceImpl.java
+0
-51
CarServiceImpl.java
...om/zjty/vms/user/subject/service/impl/CarServiceImpl.java
+0
-55
RoleServiceImpl.java
...m/zjty/vms/user/subject/service/impl/RoleServiceImpl.java
+0
-39
UserServiceImpl.java
...m/zjty/vms/user/subject/service/impl/UserServiceImpl.java
+124
-0
application.properties
vms-user/src/main/resources/application.properties
+0
-15
WeChatApp.java
vms-wechat/src/main/java/com/zjty/vms/wechat/WeChatApp.java
+0
-20
WeChatRestTemplateConfig.java
.../com/zjty/vms/wechat/config/WeChatRestTemplateConfig.java
+0
-47
WxMappingJackson2HttpMessageConverter.java
.../wechat/config/WxMappingJackson2HttpMessageConverter.java
+0
-21
WeChatController.java
.../zjty/vms/wechat/subject/controller/WeChatController.java
+0
-35
AuthCodeSession.java
...a/com/zjty/vms/wechat/subject/entity/AuthCodeSession.java
+0
-45
WeChatApiUrl.java
...java/com/zjty/vms/wechat/subject/entity/WeChatApiUrl.java
+0
-14
WeChatApiService.java
...com/zjty/vms/wechat/subject/service/WeChatApiService.java
+0
-23
WeChatApiServiceImpl.java
...vms/wechat/subject/service/impl/WeChatApiServiceImpl.java
+0
-70
没有找到文件。
pom.xml
浏览文件 @
34e46d3b
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
<module>
vms-union
</module>
<module>
vms-union
</module>
<module>
vms-user
</module>
<module>
vms-user
</module>
<module>
vms-inspection
</module>
<module>
vms-inspection
</module>
<module>
vms-wechat
</module>
</modules>
</modules>
<name>
vms
</name>
<name>
vms
</name>
...
@@ -23,7 +22,7 @@
...
@@ -23,7 +22,7 @@
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.
1.4.RELEASE
</version>
<version>
2.
4.0
</version>
<relativePath/>
<!-- lookup parent from repository -->
<relativePath/>
<!-- lookup parent from repository -->
</parent>
</parent>
...
@@ -37,12 +36,6 @@
...
@@ -37,12 +36,6 @@
<dependencies>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.19
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
...
...
vms-inspection/pom.xml
浏览文件 @
34e46d3b
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.zjty
</groupId>
<groupId>
com.zjty
</groupId>
<artifactId>
vms-
misc
</artifactId>
<artifactId>
vms-
user
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
vms-inspection/src/main/java/com/zjty/vms/inspection/InspectionApp.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@SpringBootApplication
public
class
InspectionApp
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
InspectionApp
.
class
,
args
);
}
}
vms-inspection/src/main/java/com/zjty/vms/inspection/config/HandleProcessType.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
config
;
/**
* @author xyy
*/
public
enum
HandleProcessType
{
/**
* 未处理
*/
UNTREATED
(
0
),
/**
* 处理中
*/
TREATING
(
1
),
/**
* 已处理
*/
TREATED
(
2
),;
private
Integer
num
;
HandleProcessType
(
Integer
num
)
{
this
.
num
=
num
;
}
}
vms-inspection/src/main/java/com/zjty/vms/inspection/controller/ReportController.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
controller
;
import
com.zjty.vms.inspection.entity.dto.ReportSearchDto
;
import
com.zjty.vms.inspection.service.ReportService
;
import
com.zjty.vms.inspection.entity.po.Report
;
import
com.zjty.vms.inspection.entity.dto.ReportDto
;
import
com.zjty.vms.misc.entity.PageResult
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
/**
* @author xyy
*/
@Api
(
tags
=
"违停举报"
)
@RestController
@RequestMapping
(
"report"
)
public
class
ReportController
{
@Resource
private
ReportService
reportService
;
@PostMapping
(
"save"
)
@ApiModelProperty
(
"新增或修改"
)
public
Report
save
(
@RequestBody
ReportDto
reportDto
)
{
return
reportService
.
save
(
reportDto
);
}
@PostMapping
(
"search"
)
@ApiModelProperty
(
"查询"
)
public
PageResult
<
Report
>
search
(
@RequestBody
ReportSearchDto
reportSearchDto
)
{
return
reportService
.
search
(
reportSearchDto
);
}
@DeleteMapping
@ApiModelProperty
(
"删除"
)
public
void
delete
(
String
id
)
{
reportService
.
delete
(
id
);
}
}
vms-inspection/src/main/java/com/zjty/vms/inspection/dao/ReportRepository.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
dao
;
import
com.zjty.vms.inspection.entity.po.Report
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
/**
* @author xyy
*/
public
interface
ReportRepository
extends
JpaRepository
<
Report
,
String
>,
JpaSpecificationExecutor
{
}
vms-inspection/src/main/java/com/zjty/vms/inspection/entity/dto/ReportDto.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
entity
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
/**
* @author xyy
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ReportDto
{
@Id
@GenericGenerator
(
name
=
"idGenerator"
,
strategy
=
"uuid"
)
@GeneratedValue
(
generator
=
"idGenerator"
)
private
String
id
;
@ApiModelProperty
(
"举报类型"
)
private
String
type
;
@ApiModelProperty
(
"车牌号"
)
private
String
licensePlateNum
;
@ApiModelProperty
(
"事发地址"
)
private
String
address
;
@ApiModelProperty
(
"匿名标识"
)
private
boolean
anonymous
;
@ApiModelProperty
(
"描述内容"
)
private
String
content
;
@ApiModelProperty
(
"近景照片"
)
private
String
nearlyPhoto
;
@ApiModelProperty
(
"远景照片"
)
private
String
farPhoto
;
@ApiModelProperty
(
"其他照片"
)
private
String
otherPhoto
;
}
vms-inspection/src/main/java/com/zjty/vms/inspection/entity/dto/ReportSearchDto.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
entity
.
dto
;
import
com.zjty.vms.misc.baseEntity.BaseSearchDto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author xyy
*/
@Data
public
class
ReportSearchDto
extends
BaseSearchDto
{
@ApiModelProperty
(
value
=
"处理进度 0: 未处理, 1: 处理中, 2: 已处理"
)
private
Integer
handleProcessType
;
}
vms-inspection/src/main/java/com/zjty/vms/inspection/entity/po/Report.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
entity
.
po
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.SQLDeleteAll
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.annotation.CreatedBy
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
javax.persistence.*
;
import
java.time.LocalDate
;
/**
* @author xyy
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@EntityListeners
(
AuditingEntityListener
.
class
)
@SQLDelete
(
sql
=
"update report set del_flag = 1 where id = ?"
)
@SQLDeleteAll
(
sql
=
"update report set del_flag = 1 where id = ?"
)
@Where
(
clause
=
"del_flag = 0"
)
public
class
Report
{
@Id
@GenericGenerator
(
name
=
"idGenerator"
,
strategy
=
"uuid"
)
@GeneratedValue
(
generator
=
"idGenerator"
)
private
String
id
;
@ApiModelProperty
(
"用户id"
)
@CreatedBy
private
String
userId
;
@ApiModelProperty
(
"举报类型"
)
private
String
type
;
@ApiModelProperty
(
"车牌号"
)
private
String
licensePlateNum
;
@ApiModelProperty
(
"事发地址"
)
private
String
address
;
@ApiModelProperty
(
"匿名标识"
)
@Column
(
columnDefinition
=
"boolean default false"
)
private
Boolean
anonymous
;
@ApiModelProperty
(
"描述内容"
)
private
String
content
;
@ApiModelProperty
(
"上报日期"
)
@CreatedDate
private
LocalDate
reportDate
;
@ApiModelProperty
(
value
=
"处理进度"
,
notes
=
"0:未处理, 1:处理中, 2: 已处理"
)
private
Integer
handleProcess
;
@ApiModelProperty
(
"近景照片"
)
private
String
nearlyPhoto
;
@ApiModelProperty
(
"远景照片"
)
private
String
farPhoto
;
@ApiModelProperty
(
"其他照片"
)
private
String
otherPhoto
;
@ApiModelProperty
(
"评价"
)
private
String
evaluation
;
@ApiModelProperty
(
"反馈"
)
private
String
feedback
;
@ApiModelProperty
(
value
=
"删除标识"
,
notes
=
"true: 已删除, false: 未删除"
)
@Column
(
columnDefinition
=
"boolean default false"
)
@JsonIgnore
private
Boolean
delFlag
;
}
\ No newline at end of file
vms-inspection/src/main/java/com/zjty/vms/inspection/service/ReportService.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
service
;
import
com.zjty.vms.inspection.entity.dto.ReportSearchDto
;
import
com.zjty.vms.inspection.entity.po.Report
;
import
com.zjty.vms.inspection.entity.dto.ReportDto
;
import
com.zjty.vms.misc.entity.PageResult
;
/**
* @author xyy
*/
public
interface
ReportService
{
/**
* 添加违停举报
* @param reportDto report
* @return report
*/
Report
save
(
ReportDto
reportDto
);
/**
* 根据条件查询违停举报记录
* @param reportSearchDto reportSearchDto
* @return PageResult
*/
PageResult
<
Report
>
search
(
ReportSearchDto
reportSearchDto
);
/**
* 删除指定Id
* @param id id
*/
void
delete
(
String
id
);
}
vms-inspection/src/main/java/com/zjty/vms/inspection/service/converter/ReportConverter.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
service
.
converter
;
import
com.zjty.vms.inspection.entity.dto.ReportDto
;
import
com.zjty.vms.inspection.entity.po.Report
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
/**
* @author xyy
*/
@Mapper
(
componentModel
=
"spring"
)
public
interface
ReportConverter
{
ReportConverter
INSTANCE
=
Mappers
.
getMapper
(
ReportConverter
.
class
);
/**
* to Report
* @param reportDto ReportDto
* @return Report
*/
Report
toReport
(
ReportDto
reportDto
);
}
vms-inspection/src/main/java/com/zjty/vms/inspection/service/impl/ReportServiceImpl.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
inspection
.
service
.
impl
;
import
com.github.wenhao.jpa.Specifications
;
import
com.zjty.vms.inspection.dao.ReportRepository
;
import
com.zjty.vms.inspection.entity.dto.ReportDto
;
import
com.zjty.vms.inspection.entity.dto.ReportSearchDto
;
import
com.zjty.vms.inspection.entity.po.Report
;
import
com.zjty.vms.inspection.service.ReportService
;
import
com.zjty.vms.inspection.service.converter.ReportConverter
;
import
com.zjty.vms.misc.entity.PageResult
;
import
com.zjty.vms.misc.util.StringUtil
;
import
com.zjty.vms.user.subject.entity.User
;
import
com.zjty.vms.user.subject.service.UserService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Objects
;
import
java.util.Optional
;
/**
* @author xyy
*/
@Service
public
class
ReportServiceImpl
implements
ReportService
{
@Resource
private
ReportConverter
reportConverter
;
@Resource
private
ReportRepository
reportRepository
;
@Resource
private
UserService
userService
;
@Override
public
Report
save
(
ReportDto
reportDto
)
{
Report
report
=
reportConverter
.
toReport
(
reportDto
);
//存在Id
if
(
StringUtil
.
isNotBlank
(
reportDto
.
getId
()))
{
Optional
<
Report
>
reportOptional
=
reportRepository
.
findById
(
reportDto
.
getId
());
if
(
reportOptional
.
isPresent
())
{
BeanUtils
.
copyProperties
(
report
,
reportOptional
.
get
());
report
=
reportOptional
.
get
();
}
}
return
reportRepository
.
save
(
report
);
}
@Override
public
PageResult
<
Report
>
search
(
ReportSearchDto
reportSearchDto
)
{
Optional
<
User
>
user
=
userService
.
currentUser
();
Specification
<
Report
>
specifications
=
Specifications
.<
Report
>
and
()
.
eq
(
user
.
isPresent
(),
"userId"
,
user
.
get
().
getId
())
.
eq
(!
Objects
.
isNull
(
reportSearchDto
.
getHandleProcessType
()),
"handleProcess"
,
reportSearchDto
.
getHandleProcessType
())
.
build
();
Pageable
pageable
=
PageRequest
.
of
(
reportSearchDto
.
getPageNum
()
-
1
,
reportSearchDto
.
getPageSize
(),
Sort
.
Direction
.
DESC
,
"reportDate"
);
Page
<
Report
>
userAll
=
reportRepository
.
findAll
(
specifications
,
pageable
);
return
PageResult
.
pageToPageResult
(
userAll
);
}
@Override
public
void
delete
(
String
id
)
{
reportRepository
.
deleteById
(
id
);
}
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/controller/EventController.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
controller
;
import
com.sun.javafx.image.PixelUtils
;
import
com.zjty.vms.inspection.subject.entity.domain.Event
;
import
com.zjty.vms.inspection.subject.entity.vo.EventCreateVo
;
import
com.zjty.vms.inspection.subject.entity.vo.FindVo
;
import
com.zjty.vms.inspection.subject.service.EventService
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.security.PublicKey
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@RestController
@RequestMapping
(
"/vms"
)
@AutoDocument
@Api
(
tags
=
"举报模块"
)
public
class
EventController
{
@Autowired
private
EventService
eventService
;
@ApiOperation
(
value
=
"创建举报事件"
)
@PostMapping
(
"/event"
)
public
ResponseEntity
<
Event
>
addEvent
(
@RequestBody
@ApiParam
(
name
=
"创建事件对象"
)
EventCreateVo
eventCreateVo
)
{
Event
event
=
eventService
.
startEvent
(
eventCreateVo
);
return
ResponseEntity
.
ok
(
event
);
}
@PutMapping
(
"sgCheck"
)
@ApiOperation
(
value
=
"安保人员确认已联系"
)
public
ResponseEntity
<
Event
>
sgCheck
(
@RequestParam
@ApiParam
(
name
=
"事件uuid"
)
String
uuid
,
@RequestParam
@ApiParam
(
name
=
"安保人员id"
)
String
sgId
)
{
return
ResponseEntity
.
ok
(
eventService
.
sgCheck
(
uuid
,
sgId
));
}
@PutMapping
(
"ownerCt"
)
@ApiOperation
(
value
=
"业主继续举报"
)
public
ResponseEntity
<
Event
>
ownerCon
(
@RequestParam
@ApiParam
(
name
=
"事件uuid"
)
String
uuid
)
{
return
ResponseEntity
.
ok
(
eventService
.
ownerChangeStatus
(
uuid
));
}
@PutMapping
(
"delEvent"
)
@ApiOperation
(
value
=
"业主或安保人员完结事件"
)
public
ResponseEntity
<
Event
>
changeStatus
(
@RequestParam
@ApiParam
(
name
=
"事件uuid"
)
String
uuid
,
@RequestParam
@ApiParam
(
name
=
"对象,0_业主,1_安保"
)
Integer
obj
)
{
return
ResponseEntity
.
ok
(
eventService
.
finishEvent
(
uuid
,
obj
));
}
@GetMapping
(
"tsFind"
)
@ApiOperation
(
value
=
"业主查询事件接口"
)
public
ResponseEntity
<
FindVo
<
List
<
Event
>>>
ownerFind
(
@RequestParam
(
value
=
"tsId"
)
@ApiParam
(
name
=
"tsId"
)
String
tsId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
@ApiParam
(
name
=
"page"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
@ApiParam
(
name
=
"size"
)
Integer
size
)
{
page
=
page
-
1
;
return
ResponseEntity
.
ok
(
eventService
.
findAllByOwner
(
tsId
,
page
,
size
));
}
@GetMapping
(
"sgFind"
)
@ApiOperation
(
value
=
"安保人员查询事件接口"
)
public
ResponseEntity
<
FindVo
<
List
<
Event
>>>
ownerFind
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
@ApiParam
(
name
=
"page"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
@ApiParam
(
name
=
"size"
)
Integer
size
)
{
page
=
page
-
1
;
return
ResponseEntity
.
ok
(
eventService
.
findAllBySg
(
page
,
size
));
}
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/controller/FileController.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
controller
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.util.UUID
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-03
*/
@RestController
@RequestMapping
(
"/file"
)
@AutoDocument
@Api
(
tags
=
"上传下载模块"
)
public
class
FileController
{
@PostMapping
(
"/upload"
)
@ApiOperation
(
value
=
"上传文件"
)
public
String
fileUpload
(
MultipartFile
file
)
throws
IllegalStateException
,
IOException
{
if
(
file
.
getSize
()
==
0
)
{
return
""
;
}
System
.
err
.
println
(
"文件是否为空 : "
+
file
.
isEmpty
());
System
.
err
.
println
(
"文件的大小为 :"
+
file
.
getSize
());
System
.
err
.
println
(
"文件的媒体类型为 : "
+
file
.
getContentType
());
System
.
err
.
println
(
"文件的名字: "
+
file
.
getName
());
System
.
err
.
println
(
"文件的originName为: "
+
file
.
getOriginalFilename
());
final
UUID
uuid
=
UUID
.
randomUUID
();
File
newFile
=
new
File
(
"/Users/ljj/data/file/"
+
uuid
);
file
.
transferTo
(
newFile
);
return
uuid
.
toString
();
}
@PostMapping
(
"/download"
)
@ApiOperation
(
value
=
"下载文件"
)
public
boolean
download
(
HttpServletResponse
res
,
@RequestParam
(
value
=
"fileId"
)
@ApiParam
(
name
=
"文件id"
)
String
fileId
)
throws
IOException
{
File
file
=
new
File
(
"/Users/ljj/data/file/"
+
fileId
);
String
fileName
=
"bg1.png"
;
res
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
);
byte
[]
buff
=
new
byte
[
1024
];
BufferedInputStream
bis
=
null
;
OutputStream
os
=
null
;
try
{
os
=
res
.
getOutputStream
();
bis
=
new
BufferedInputStream
(
new
FileInputStream
(
file
));
int
i
=
bis
.
read
(
buff
);
while
(
i
!=
-
1
)
{
os
.
write
(
buff
,
0
,
buff
.
length
);
os
.
flush
();
i
=
bis
.
read
(
buff
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
bis
!=
null
)
{
try
{
bis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
System
.
out
.
println
(
"success"
);
return
false
;
}
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/dao/EventDao.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
dao
;
import
com.zjty.vms.inspection.subject.entity.domain.Event
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.awt.print.Pageable
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
EventDao
extends
JpaRepository
<
Event
,
String
>,
JpaSpecificationExecutor
<
Event
>
{
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/dao/EventImageDao.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
dao
;
import
com.zjty.vms.inspection.subject.entity.domain.EventImage
;
import
org.springframework.data.jpa.repository.JpaRepository
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
EventImageDao
extends
JpaRepository
<
EventImage
,
String
>
{
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/entity/domain/Event.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
entity
.
domain
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@AutoDocument
@ApiModel
(
value
=
"举报事件"
,
description
=
"一个举报事件"
)
@Table
(
name
=
"vms_event"
)
public
class
Event
{
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
uuid
;
@ApiModelProperty
(
value
=
"举报事件名称"
,
example
=
"事件名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"图片id,以英文,分割"
,
example
=
"1,2,3,4"
)
private
String
image
;
@ApiModelProperty
(
value
=
"投诉人Id"
,
example
=
"asdads"
)
private
String
tsId
;
@ApiModelProperty
(
value
=
"被举报人Id"
,
example
=
"asdads"
)
private
String
reportedId
;
@ApiModelProperty
(
value
=
"被举报车牌号"
,
example
=
"浙A88888"
)
private
String
numberPlate
;
@ApiModelProperty
(
value
=
"车位号"
,
example
=
"A101"
)
private
String
parkingSpace
;
@ApiModelProperty
(
value
=
"处理保安id"
,
example
=
"asdasd"
)
private
String
sgId
;
@ApiModelProperty
(
value
=
"是否电话,通知0_未通知,1_已通知"
,
example
=
"0"
)
private
Integer
isPhoneNotification
;
@ApiModelProperty
(
value
=
"电话通知时间"
,
example
=
"2001-01-01 00:00:00"
)
private
Date
phoneNotificationTime
;
@ApiModelProperty
(
value
=
"是否推送了公众号0_未通知,1_已通知"
,
example
=
"0"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Integer
isForwardNews
;
@ApiModelProperty
(
value
=
"公众号推送通知时间"
,
example
=
"2001-01-01 00:00:00"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
forwardNewsTime
;
@ApiModelProperty
(
value
=
"继续举报时间,若无继续举报,则为空(即将事件状态变为1时需传入这个字段)"
,
example
=
"2001-01-01 00:00:00"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
continueToReportTime
;
@ApiModelProperty
(
value
=
"事件状态,0_未处理,1_需人工处理,2_完结"
,
example
=
"0"
)
private
Integer
status
=
0
;
@ApiModelProperty
(
value
=
"事件完结时间"
,
example
=
"2001-01-01 00:00:00"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
finishEventTime
;
@ApiModelProperty
(
value
=
"0_业主完结,1_保安完结"
,
example
=
"0"
)
private
Integer
finishEventObj
;
@ApiModelProperty
(
value
=
"事件生成时间"
,
example
=
"2001-01-01 00:00:00"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/entity/domain/EventImage.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
entity
.
domain
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@AutoDocument
@ApiModel
(
value
=
"图片库"
,
description
=
"用于存储图片"
)
@Table
(
name
=
"vms_image"
)
public
class
EventImage
{
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
uuid
;
@ApiModelProperty
(
value
=
"图片路径"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
path
;
@ApiModelProperty
(
value
=
"图片创建时间"
,
example
=
"2001-01-01 00:00:00"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/entity/vo/EventCreateVo.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
entity
.
vo
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@AutoDocument
@ApiModel
(
value
=
"生成事件"
,
description
=
"生成事件时需要传入的对象"
)
@Table
(
name
=
"vms_event"
)
public
class
EventCreateVo
{
@ApiModelProperty
(
value
=
"举报事件名称"
,
example
=
"事件名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"图片id,以英文,分割"
,
example
=
"1,2,3,4"
)
private
String
image
;
@ApiModelProperty
(
value
=
"投诉人Id"
,
example
=
"asdads"
)
private
String
tsId
;
@ApiModelProperty
(
value
=
"被举报车牌号"
,
example
=
"浙A88888"
)
private
String
numberPlate
;
@ApiModelProperty
(
value
=
"车位号"
,
example
=
"A101"
)
private
String
parkingSpace
;
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/entity/vo/FindVo.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
entity
.
vo
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
sun.jvm.hotspot.debugger.Page
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@AutoDocument
@ApiModel
(
value
=
"生成事件"
,
description
=
"生成事件时需要传入的对象"
)
public
class
FindVo
<
T
>
{
@ApiModelProperty
(
value
=
"总数"
,
example
=
"100"
)
private
Long
total
;
@ApiModelProperty
(
value
=
"页数"
,
example
=
"1"
)
private
Integer
page
;
@ApiModelProperty
(
value
=
"每页"
,
example
=
"10"
)
private
Integer
size
;
@ApiModelProperty
(
value
=
"数据内容"
,
example
=
"数据内容"
)
private
T
data
;
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/service/EventImageService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
service
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
EventImageService
{
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/service/EventService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
service
;
import
com.zjty.vms.inspection.subject.entity.domain.Event
;
import
com.zjty.vms.inspection.subject.entity.vo.EventCreateVo
;
import
com.zjty.vms.inspection.subject.entity.vo.FindVo
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
EventService
{
/**
* 生成一个举报事件
*
* @param eventCreateVo ecvo
* @return obj
*/
Event
startEvent
(
EventCreateVo
eventCreateVo
);
/**
* 安保人员确认,电话通知后确认
*
* @param uuid 事件uuid
* @param sgId 安保人员ID
* @return obj
*/
Event
sgCheck
(
String
uuid
,
String
sgId
);
/**
* 业主继续反馈,举报
*
* @param uuid 事件主键id
* @return
*/
Event
ownerChangeStatus
(
String
uuid
);
/**
* 完结事件
*
* @param uuid 事件id
* @param obj 0_业主,1_安保
* @return obj
*/
Event
finishEvent
(
String
uuid
,
Integer
obj
);
/**
*业主查询事件接口
* @param tsId 业主id
* @param page page
* @param size size
* @return obj
*/
FindVo
<
List
<
Event
>>
findAllByOwner
(
String
tsId
,
Integer
page
,
Integer
size
);
FindVo
<
List
<
Event
>>
findAllBySg
(
Integer
page
,
Integer
size
);
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/service/impl/EventImageServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
service
.
impl
;
import
com.zjty.vms.inspection.subject.service.EventImageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Service
@Slf4j
public
class
EventImageServiceImpl
implements
EventImageService
{
}
vms-inspection/src/main/java/com/zjty/vms/inspection/subject/service/impl/EventServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
inspection
.
subject
.
service
.
impl
;
import
com.zjty.vms.inspection.subject.dao.EventDao
;
import
com.zjty.vms.inspection.subject.entity.domain.Event
;
import
com.zjty.vms.inspection.subject.entity.vo.EventCreateVo
;
import
com.zjty.vms.inspection.subject.entity.vo.FindVo
;
import
com.zjty.vms.inspection.subject.service.EventService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Service
@Slf4j
public
class
EventServiceImpl
implements
EventService
{
@Autowired
private
EventDao
eventDao
;
@Override
public
Event
startEvent
(
EventCreateVo
eventCreateVo
)
{
String
reportedId
=
""
;
//todo 1.根据车牌查找是否有这个人 2.推送订阅消息
Event
build
=
Event
.
builder
()
.
image
(
eventCreateVo
.
getImage
())
.
name
(
eventCreateVo
.
getName
())
.
tsId
(
eventCreateVo
.
getTsId
())
.
numberPlate
(
eventCreateVo
.
getNumberPlate
())
.
parkingSpace
(
eventCreateVo
.
getParkingSpace
())
.
createTime
(
new
Date
())
//被举报人id
.
reportedId
(
reportedId
)
.
isPhoneNotification
(
0
)
.
isForwardNews
(
0
)
.
status
(
0
)
.
build
();
return
eventDao
.
save
(
build
);
}
@Override
public
Event
sgCheck
(
String
uuid
,
String
sgId
)
{
Optional
<
Event
>
one
=
eventDao
.
findById
(
uuid
);
if
(
one
.
isPresent
())
{
Event
event
=
one
.
get
();
event
.
setIsPhoneNotification
(
1
);
event
.
setPhoneNotificationTime
(
new
Date
());
return
eventDao
.
save
(
event
);
}
else
{
return
new
Event
();
}
}
@Override
public
Event
ownerChangeStatus
(
String
uuid
)
{
final
Optional
<
Event
>
one
=
eventDao
.
findById
(
uuid
);
if
(
one
.
isPresent
())
{
Event
event
=
one
.
get
();
event
.
setStatus
(
1
);
event
.
setContinueToReportTime
(
new
Date
());
return
eventDao
.
save
(
event
);
}
else
{
return
new
Event
();
}
}
@Override
public
Event
finishEvent
(
String
uuid
,
Integer
obj
)
{
final
Optional
<
Event
>
one
=
eventDao
.
findById
(
uuid
);
if
(!
one
.
isPresent
())
{
return
new
Event
();
}
Event
event
=
one
.
get
();
event
.
setStatus
(
2
);
event
.
setFinishEventTime
(
new
Date
());
event
.
setFinishEventObj
(
obj
);
return
eventDao
.
save
(
event
);
}
@Override
public
FindVo
<
List
<
Event
>>
findAllByOwner
(
String
tsId
,
Integer
page
,
Integer
size
)
{
Specification
<
Event
>
contactSpecification
=
new
Specification
<
Event
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
Event
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
criteriaBuilder
)
{
Predicate
predicate
=
criteriaBuilder
.
equal
(
root
.
get
(
"tsId"
),
tsId
);
return
criteriaBuilder
.
and
(
predicate
);
}
};
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
,
Sort
.
Direction
.
DESC
,
"createTime"
);
final
Page
<
Event
>
all
=
eventDao
.
findAll
(
contactSpecification
,
pageable
);
return
new
FindVo
<>(
all
.
getTotalElements
(),
page
,
size
,
all
.
getContent
());
}
@Override
public
FindVo
<
List
<
Event
>>
findAllBySg
(
Integer
page
,
Integer
size
)
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
,
Sort
.
Direction
.
DESC
,
"createTime"
);
final
Page
<
Event
>
all
=
eventDao
.
findAll
(
pageable
);
return
new
FindVo
<
List
<
Event
>>(
all
.
getTotalElements
(),
page
,
size
,
all
.
getContent
());
}
}
vms-inspection/src/main/resources/application.properties
deleted
100644 → 0
浏览文件 @
4d6bead1
vms-
wechat
/pom.xml
→
vms-
maintain
/pom.xml
浏览文件 @
34e46d3b
...
@@ -2,32 +2,23 @@
...
@@ -2,32 +2,23 @@
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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"
>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
vms
</artifactId>
<groupId>
com.zjty
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
vms-wechat
</artifactId>
<groupId>
groupId
</groupId>
<artifactId>
vms-maintain
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.zjty
</groupId>
<groupId>
com.zjty
</groupId>
<artifactId>
vms-
misc
</artifactId>
<artifactId>
vms-
user
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
RELEASE
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
vms-maintain/src/main/java/com/zjty/vms/maintain/controller/CommonMaintainController.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
maintain
.
controller
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author xyy
*/
@Api
(
tags
=
"公共保修"
)
@RestController
@RequestMapping
(
"/commonMaintain"
)
public
class
CommonMaintainController
{
}
vms-maintain/src/main/java/com/zjty/vms/maintain/entity/po/CommonMaintain.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
maintain
.
entity
.
po
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.SQLDeleteAll
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.annotation.CreatedBy
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
javax.persistence.*
;
/**
* @author xyy
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@EntityListeners
(
AuditingEntityListener
.
class
)
@SQLDelete
(
sql
=
"update common_maintain set del_flag = 1 where id = ?"
)
@SQLDeleteAll
(
sql
=
"update common_maintain set del_flag = 1 where id = ?"
)
@Where
(
clause
=
"del_flag = 0"
)
public
class
CommonMaintain
{
@Id
@GenericGenerator
(
name
=
"idGenerator"
,
strategy
=
"uuid"
)
@GeneratedValue
(
generator
=
"idGenerator"
)
private
String
id
;
@ApiModelProperty
(
"用户id"
)
@CreatedBy
private
String
userId
;
@ApiModelProperty
(
value
=
"删除标识"
,
notes
=
"true: 已删除, false: 未删除"
)
@Column
(
columnDefinition
=
"boolean default false"
)
@JsonIgnore
private
Boolean
delFlag
;
}
vms-misc/pom.xml
浏览文件 @
34e46d3b
...
@@ -46,7 +46,30 @@
...
@@ -46,7 +46,30 @@
<artifactId>
springfox-bean-validators
</artifactId>
<artifactId>
springfox-bean-validators
</artifactId>
<version>
${swagger.version}
</version>
<version>
${swagger.version}
</version>
</dependency>
</dependency>
</dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.19
</version>
</dependency>
<dependency>
<groupId>
com.github.wenhao
</groupId>
<artifactId>
jpa-spec
</artifactId>
<version>
3.2.1
</version>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-jdk8
</artifactId>
<version>
1.3.1.Final
</version>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
1.3.1.Final
</version>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
vms-
wechat/src/main/java/com/zjty/vms/wechat/subject/entity/AccessToken
.java
→
vms-
misc/src/main/java/com/zjty/vms/misc/baseEntity/BaseSearchDto
.java
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
wechat
.
subject
.
e
ntity
;
package
com
.
zjty
.
vms
.
misc
.
baseE
ntity
;
import
com.fasterxml.jackson.annotation.Json
Property
;
import
io.swagger.annotations.ApiModel
Property
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
/**
/**
* @author
LJJ cnljj1995@gmail.com
* @author
xyy
*
on 2020-05-29
*
@date 2021/7/26
*/
*/
@Data
@Data
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Builder
public
class
BaseSearchDto
{
public
class
AccessToken
{
@JsonProperty
(
"access_token"
)
@ApiModelProperty
(
example
=
"1"
)
private
String
accessToken
;
private
Integer
pageNum
;
@ApiModelProperty
(
example
=
"10"
)
private
Integer
pageSize
;
@JsonProperty
(
"expires_in"
)
private
String
expiresIn
;
}
}
vms-misc/src/main/java/com/zjty/vms/misc/config/Swagger2Config.java
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
misc
.
config
;
package
com
.
zjty
.
vms
.
misc
.
config
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.OAuthBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.*
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
/**
/**
* @author LJJ cnljj1995@gmail.com
* @author LJJ cnljj1995@gmail.com
* on 2020-04-26
* on 2020-04-26
...
@@ -20,56 +27,88 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
...
@@ -20,56 +27,88 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@EnableSwagger2
public
class
Swagger2Config
{
public
class
Swagger2Config
{
public
static
final
String
AUTHORIZATION_HEADER
=
"Authorization"
;
@Value
(
"${vms.swagger.enable}"
)
private
Boolean
enableFlag
;
@Value
(
"${vms.swagger.loginUrl}"
)
private
String
loginUrl
;
@Bean
@Bean
public
Docket
createRestApi
()
{
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
produces
(
Sets
.
newHashSet
(
"application/json"
))
.
produces
(
Sets
.
newHashSet
(
"application/json"
))
.
consumes
(
Sets
.
newHashSet
(
"application/json"
))
.
consumes
(
Sets
.
newHashSet
(
"application/json"
))
.
protocols
(
Sets
.
newHashSet
(
"http"
,
"https"
))
.
protocols
(
Sets
.
newHashSet
(
"http"
,
"https"
))
.
apiInfo
(
apiInfo
())
.
apiInfo
(
apiInfo
())
.
forCodeGeneration
(
true
)
.
forCodeGeneration
(
true
)
.
useDefaultResponseMessages
(
true
)
.
useDefaultResponseMessages
(
true
)
// .globalResponseMessage(RequestMethod.GET, getResMsg())
.
select
()
.
select
()
// 指定controller存放的目录路径
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.zjty.vms"
))
.
apis
(
RequestHandlerSelectors
.
withClassAnnotation
(
AutoDocument
.
class
))
.
paths
(
PathSelectors
.
any
())
.
paths
(
PathSelectors
.
any
())
.
build
()
.
enable
(
enableFlag
)
// 配置token
.
securitySchemes
(
Collections
.
singletonList
(
apiKey
()))
// 配置用户名,密码
// .securitySchemes(Collections.singletonList(securityScheme()))
.
securityContexts
(
securityContexts
());
}
private
ApiKey
apiKey
()
{
return
new
ApiKey
(
AUTHORIZATION_HEADER
,
AUTHORIZATION_HEADER
,
"header"
);
}
private
List
<
SecurityContext
>
securityContexts
()
{
List
<
SecurityContext
>
securityContexts
=
new
ArrayList
<>();
securityContexts
.
add
(
SecurityContext
.
builder
().
securityReferences
(
defaultAuth
())
//过滤要验证的路径
.
forPaths
(
PathSelectors
.
regex
(
"^(?!auth).*$"
))
.
build
());
securityContexts
.
add
(
securityContext
());
return
securityContexts
;
}
// 增加全局认证
List
<
SecurityReference
>
defaultAuth
()
{
AuthorizationScope
authorizationScope
=
new
AuthorizationScope
(
"global"
,
"accessEverything"
);
AuthorizationScope
[]
authorizationScopes
=
new
AuthorizationScope
[
1
];
authorizationScopes
[
0
]
=
authorizationScope
;
List
<
SecurityReference
>
securityReferences
=
new
ArrayList
<>();
securityReferences
.
add
(
new
SecurityReference
(
AUTHORIZATION_HEADER
,
authorizationScopes
));
return
securityReferences
;
}
private
SecurityContext
securityContext
()
{
return
SecurityContext
.
builder
()
.
securityReferences
(
Collections
.
singletonList
(
new
SecurityReference
(
"spring_oauth"
,
scopes
())))
.
forPaths
(
PathSelectors
.
any
())
.
build
();
.
build
();
}
}
private
ApiInfo
apiInfo
()
{
private
SecurityScheme
securityScheme
()
{
return
new
ApiInfoBuilder
()
GrantType
grantType
=
new
ResourceOwnerPasswordCredentialsGrant
(
loginUrl
);
// 文档标题
.
title
(
"机动车管理系统接口文档"
)
return
new
OAuthBuilder
()
// 文档描述
.
name
(
"spring_oauth"
)
.
description
(
"机动车管理系统的接口文档与测试页面"
)
.
grantTypes
(
Collections
.
singletonList
(
grantType
))
.
termsOfServiceUrl
(
"git地址待更新"
)
.
scopes
(
Arrays
.
asList
(
scopes
()))
.
version
(
"v1"
)
.
contact
(
new
Contact
(
"efs"
,
"git"
,
"ty@example.com"
))
.
build
();
.
build
();
}
}
// private ArrayList<ResponseMessage> getResMsg() {
private
AuthorizationScope
[]
scopes
()
{
// return newArrayList(new ResponseMessageBuilder()
return
new
AuthorizationScope
[]{
// .code(500)
new
AuthorizationScope
(
"all"
,
"All scope is trusted!"
)
// .message("服务器内部发生了某种错误")
};
// .responseModel(new ModelRef("Error"))
}
// .build(),
// new ResponseMessageBuilder()
public
ApiInfo
apiInfo
()
{
// .code(404)
return
new
ApiInfoBuilder
()
// .message("用户发出的请求针对的是不存在的记录,服务器没有进行操作")
.
title
(
"未来社区后台API文档"
)
// .responseModel(new ModelRef("Exception"))
.
description
(
""
)
// .build(),
.
termsOfServiceUrl
(
""
)
// new ResponseMessageBuilder()
.
version
(
"1.0"
)
// .code(406)
.
build
();
// .message("用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)")
}
// .responseModel(new ModelRef("Exception"))
// .build(),
// new ResponseMessageBuilder()
// .code(501)
// .message("不支持的HTTP请求,请检查HTTP TYPE与资源路径是否正确")
// .responseModel(new ModelRef("Exception"))
// .build());
// }
}
}
vms-misc/src/main/java/com/zjty/vms/misc/entity/PageResult.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
misc
.
entity
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.data.domain.Page
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author fatpanda
* @date 2020/10/19
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Api
(
"分页数据"
)
public
class
PageResult
<
T
>
{
@ApiModelProperty
(
value
=
"每页条数"
)
private
Integer
pageSize
;
@ApiModelProperty
(
value
=
"页码"
)
private
Integer
pageNum
;
@ApiModelProperty
(
value
=
"分页数据"
)
private
List
<
T
>
content
;
@ApiModelProperty
(
value
=
"总条数"
)
private
Long
total
;
@ApiModelProperty
(
value
=
"总页数"
)
private
Integer
totalPage
;
public
PageResult
listToPageResult
(
List
<
T
>
listAll
,
Integer
pageNum
,
Integer
pageSize
)
{
//对返回list做分页
List
<
T
>
returnList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
listAll
.
size
();
i
++)
{
//分页处理
if
(
i
<
(
pageNum
*
pageSize
)
||
i
>=
((
pageNum
+
1
)
*
pageSize
))
{
continue
;
}
returnList
.
add
(
listAll
.
get
(
i
));
}
this
.
setTotal
(
Long
.
parseLong
(
listAll
.
size
()
+
""
));
this
.
setPageSize
(
pageSize
);
this
.
setPageNum
(
pageNum
);
this
.
setContent
(
returnList
);
int
totalPage
=
(
int
)
(
this
.
getTotal
()
/
pageSize
);
this
.
setTotalPage
(
this
.
getTotal
()
%
pageSize
==
0
?
totalPage
:
totalPage
+
1
);
return
this
;
}
/**
* @param page jpa page
* @return custom pageResult
*/
public
static
PageResult
pageToPageResult
(
Page
page
)
{
PageResult
pageResult
=
new
PageResult
();
pageResult
.
setContent
(
page
.
getContent
());
pageResult
.
setPageNum
(
page
.
getNumber
()
+
1
);
pageResult
.
setPageSize
(
page
.
getSize
());
pageResult
.
setTotal
(
page
.
getTotalElements
());
pageResult
.
setTotalPage
(
page
.
getTotalPages
());
return
pageResult
;
}
/**
* @param page jpa page
* @return custom pageResult
*/
public
static
PageResult
pageToPageResult
(
Page
page
,
List
handleList
)
{
PageResult
pageResult
=
new
PageResult
();
pageResult
.
setContent
(
handleList
);
pageResult
.
setPageNum
(
page
.
getNumber
()
+
1
);
pageResult
.
setPageSize
(
page
.
getSize
());
pageResult
.
setTotal
(
page
.
getTotalElements
());
pageResult
.
setTotalPage
(
page
.
getTotalPages
());
return
pageResult
;
}
public
PageResult
fixPageNum
(
Integer
pageNum
)
{
setPageNum
(
pageNum
);
return
this
;
}
}
vms-misc/src/main/java/com/zjty/vms/misc/entity/ResponseCode.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
misc
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* <p>Description : 异常结果枚举类,用于统一异常状态码与相关描述信息
*
* @author : M@tr!x [xhyrzldf@foxmail.com]
* @Date : 2017/12/13 0:51
*/
@AllArgsConstructor
@Getter
public
enum
ResponseCode
{
/**
* 服务器成功返回用户请求的数据
*/
OK
(
200
,
"[GET]:服务器成功返回用户请求的数据,返回资源对象"
),
/**
* 用户新建或修改数据成功
*/
CREATED
(
201
,
"[POST/PUT/PATCH]:用户新建或修改数据成功,返回新生成或修改的资源对象"
),
/**
* 表示一个请求已经进入后台排队(异步任务)
*/
ACCEPTED
(
202
,
"[*]:表示一个请求已经进入后台排队(异步任务)"
),
/**
* 用户上传文件成功
*/
UPLOADED
(
203
,
"[POST]文件上传成功"
),
/**
* 用户删除数据成功
*/
NO_CONTENT
(
204
,
" [DELETE]:用户删除数据成功"
),
/**
* 用户发出的请求有错误,服务器没有进行新建或修改数据的操作
*/
INVALID_REQUEST
(
400
,
"[POST/PUT/PATCH]:用户发出的请求有错误,服务器没有进行新建或修改数据的操作"
),
/**
* 表示用户没有权限(令牌、用户名、密码错误)
*/
UNAUTHORIZED
(
401
,
" [*]:表示用户没有权限(令牌、用户名、密码错误)"
),
/**
* 表示用户登录超时
*/
LOGINOUTTIME
(
402
,
" [*]:表示用户登录超时"
),
/**
* 表示用户得到授权(与401错误相对),但是访问是被禁止的
*/
FORBIDDEN
(
403
,
" [*] 表示用户得到授权(与401错误相对),但是访问是被禁止的"
),
/**
* 用户发出的请求针对的是不存在的记录,服务器没有进行操作,该操作是幂等的
*/
NOT_FOUND
(
404
,
" [*]:用户发出的请求针对的是不存在的记录,服务器没有进行操作"
),
/**
* 非法参数,请求中附带的参数不符合要求规范
*/
ILLEGAL_PARAMETER
(
405
,
"[*]:非法参数,请求中附带的参数不符合要求规范"
),
/**
* 用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)
*/
NOT_ACCEPTABLE
(
406
,
" [GET]:用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)"
),
/**
* 用户的参数不得为空
*/
NOT_NULL_PARAMETER
(
408
,
"传递的参数不能为空"
),
/**
* 用户请求的资源被永久删除,且不会再得到的
*/
GONE
(
413
,
"[GET]:用户请求的资源被永久删除,且不会再得到的"
),
/**
* [PUT,PATCH,POST,DELETE]:操作没有成功,并没有数据发生变化
*/
NO_CHANGED
(
414
,
"[PUT,PATCH,POST,DELETE]:操作没有成功,并没有数据发生变化"
),
/**
* 创建一个对象时,发生一个验证错误
*/
UNPROCESSABLE_ENTITY
(
422
,
"[POST/PUT/PATCH] 当创建一个对象时,发生一个验证错误"
),
/**
* 服务器发生错误
*/
INTERNAL_SERVER_ERROR
(
500
,
"服务器发生错误"
),
/**
* 服务器发生错误
*/
FILE_ALREADY_EXISTS
(
501
,
"服务器发生错误"
);
/**
* 结果代码编号
*/
private
Integer
code
;
/**
* 结果信息
*/
private
String
msg
;
}
vms-
user/src/main/java/com/zjty/vms/user/subject/entity/SecurityGuard
.java
→
vms-
misc/src/main/java/com/zjty/vms/misc/subject/entity/VmsFile
.java
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
package
com
.
zjty
.
vms
.
misc
.
subject
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
/**
* @author LJJ cnljj1995@gmail.com
* @author xyy
* on 2020-06-01
*/
*/
@Data
@Data
@Entity
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Builder
public
class
VmsFile
{
@Table
(
name
=
"vms_security_guard"
)
public
class
SecurityGuard
{
@Id
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"idGenerator"
,
strategy
=
"uuid"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@GeneratedValue
(
generator
=
"idGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
id
;
private
String
uuid
;
@ApiModelProperty
(
"文件名"
)
private
String
name
;
@ApiModelProperty
(
"文件地址"
)
private
String
path
;
@ApiModelProperty
(
value
=
"openId"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
openId
;
}
}
vms-misc/src/main/java/com/zjty/vms/misc/util/JsonUtil.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
misc
.
util
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @author xyy
*/
@Slf4j
public
class
JsonUtil
{
private
static
ObjectMapper
objectMapper
;
private
static
ObjectMapper
initObjectMapper
(
ObjectMapper
objectMapper
)
{
if
(
null
==
objectMapper
)
{
objectMapper
=
new
ObjectMapper
();
objectMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
JavaTimeModule
javaTimeModule
=
new
JavaTimeModule
();
//日期序列化
// javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
//日期反序列化
// javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
objectMapper
.
registerModule
(
javaTimeModule
);
}
return
objectMapper
;
}
/**
* 对象转Json
*
* @param obj
* @return
* @throws JsonProcessingException
*/
public
static
String
toJson
(
Object
obj
)
throws
JsonProcessingException
{
objectMapper
=
initObjectMapper
(
objectMapper
);
String
jsonStr
=
objectMapper
.
writeValueAsString
(
obj
);
return
jsonStr
;
}
/**
* 对象转Json
*
* @param obj
* @return
* @throws JsonProcessingException
*/
public
static
String
toJsonWithNoException
(
Object
obj
)
{
objectMapper
=
initObjectMapper
(
objectMapper
);
String
jsonStr
=
null
;
try
{
jsonStr
=
objectMapper
.
writeValueAsString
(
obj
);
}
catch
(
JsonProcessingException
e
)
{
log
.
error
(
"转JSON异常"
);
}
return
jsonStr
;
}
/**
* 解析json
*
* @param content json字符串
* @param valueType 字符串的类型
* @return 对象
*/
public
static
<
T
>
T
fromJson
(
String
content
,
Class
<
T
>
valueType
)
{
objectMapper
=
initObjectMapper
(
objectMapper
);
try
{
return
objectMapper
.
readValue
(
content
,
valueType
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
vms-misc/src/main/java/com/zjty/vms/misc/util/StringUtil.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
misc
.
util
;
import
org.apache.commons.lang3.StringUtils
;
/**
* @author xyy
*/
public
class
StringUtil
extends
StringUtils
{
}
vms-union/pom.xml
浏览文件 @
34e46d3b
...
@@ -12,26 +12,36 @@
...
@@ -12,26 +12,36 @@
<artifactId>
vms-union
</artifactId>
<artifactId>
vms-union
</artifactId>
<dependencies>
<dependencies>
<dependency>
<groupId>
com.zjty
</groupId>
<artifactId>
vms-wechat
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.zjty
</groupId>
<groupId>
com.zjty
</groupId>
<artifactId>
vms-user
</artifactId>
<artifactId>
vms-user
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.19
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.zjty
</groupId>
<groupId>
com.zjty
</groupId>
<artifactId>
vms-inspection
</artifactId>
<artifactId>
vms-inspection
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<annotationProcessorPaths>
<!-- MapStruct 在编译时会通过这个插件生成代码 -->
<path>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
1.3.0.Final
</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
\ No newline at end of file
vms-union/src/main/java/com/zjty/vms/union/UnionApp.java
浏览文件 @
34e46d3b
...
@@ -2,22 +2,24 @@ package com.zjty.vms.union;
...
@@ -2,22 +2,24 @@ package com.zjty.vms.union;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.data.jpa.repository.config.EnableJpaAuditing
;
import
org.springframework.data.jpa.repository.config.EnableJpaRepositories
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
/**
* @author LJJ cnljj1995@gmail.com
* @author LJJ cnljj1995@gmail.com
* on 2020-05-28
* on 2020-05-28
*/
*/
@SpringBootApplication
(
scanBasePackages
=
{
@SpringBootApplication
(
scanBasePackages
=
{
"com.zjty.vms"
})
"com.zjty.vms.union"
,
@EnableJpaAuditing
"com.zjty.vms.user"
,
@EntityScan
(
basePackages
=
"com.zjty.vms"
)
"com.zjty.vms.wechat"
,
@EnableJpaRepositories
(
basePackages
=
"com.zjty.vms"
)
"com.zjty.vms.inspection"
})
@EnableSwagger2
@EnableSwagger2
public
class
UnionApp
{
public
class
UnionApp
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
UnionApp
.
class
,
args
);
SpringApplication
.
run
(
UnionApp
.
class
,
args
);
}
}
}
}
vms-union/src/main/resources/application.properties
deleted
100644 → 0
浏览文件 @
4d6bead1
# server port
server.port
=
8082
##连接中心数据库数据库mysql
spring.datasource.url
=
jdbc:mysql://localhost:3306/vms?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.username
=
root
spring.datasource.password
=
ljj123456
# spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto
=
update
spring.jpa.show-sql
=
false
spring.jpa.properties.hibernate.dialect
=
org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.open-in-view
=
true
vms-union/src/main/resources/application.yml
0 → 100644
浏览文件 @
34e46d3b
server
:
port
:
8082
spring
:
datasource
:
url
:
jdbc:mysql://localhost:3306/vms?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8
driver-class-name
:
com.mysql.cj.jdbc.Driver
username
:
root
password
:
qwer1234
jpa
:
database
:
mysql
hibernate
:
ddl-auto
:
update
show-sql
:
true
open-in-view
:
true
wx
:
miniapp
:
configs
:
-
appid
:
wx5c27dd9dc48f4d17
#微信小程序的appid
secret
:
7c0527063486b8017b724a7a7f2db9ff
#微信小程序的Secret
token
:
#微信小程序消息服务器配置的token
aesKey
:
#微信小程序消息服务器配置的EncodingAESKey
msgDataFormat
:
JSON
vms
:
swagger
:
enable
:
true
loginUrl
:
/user/login
\ No newline at end of file
vms-user/pom.xml
浏览文件 @
34e46d3b
...
@@ -18,14 +18,20 @@
...
@@ -18,14 +18,20 @@
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.
zjty
</groupId>
<groupId>
com.
github.binarywang
</groupId>
<artifactId>
vms-wechat
</artifactId>
<artifactId>
weixin-java-miniapp
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
4.1.0
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
mysql
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<artifactId>
spring-boot-starter-security
</artifactId>
<version>
8.0.19
</version>
</dependency>
<!-- jwt -->
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
0.9.1
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
vms-user/src/main/java/com/zjty/vms/user/UserApp.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-28
*/
@SpringBootApplication
(
scanBasePackages
=
{
"com.zjty.vms.user"
,
"com.zjty.vms.misc"
,
"com.zjty.vms.wechat"
})
@EnableSwagger2
public
class
UserApp
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
UserApp
.
class
,
args
);
}
}
vms-user/src/main/java/com/zjty/vms/user/config/exception/UserException.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
exception
;
/**
* @author xyy
*/
public
class
UserException
extends
RuntimeException
{
public
UserException
(
String
msg
)
{
super
(
msg
);
}
public
UserException
(
UserExceptionConsts
userExceptionConsts
)
{
super
(
userExceptionConsts
.
getMsg
());
}
}
vms-user/src/main/java/com/zjty/vms/user/config/exception/UserExceptionConsts.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
exception
;
/**
* @author xyy
*/
public
enum
UserExceptionConsts
{
NO_CURRENT_USER
(
"当前无登录用户"
);
private
String
msg
;
UserExceptionConsts
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
vms-user/src/main/java/com/zjty/vms/user/config/jpa/UseridAuditorBean.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
jpa
;
import
com.zjty.vms.user.config.exception.UserException
;
import
com.zjty.vms.user.config.exception.UserExceptionConsts
;
import
com.zjty.vms.user.subject.entity.User
;
import
com.zjty.vms.user.subject.service.UserService
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.domain.AuditorAware
;
import
javax.annotation.Resource
;
import
java.util.Optional
;
/**
* @author xyy
*/
@Configuration
public
class
UseridAuditorBean
implements
AuditorAware
<
String
>
{
@Resource
private
UserService
userService
;
@Override
public
Optional
<
String
>
getCurrentAuditor
()
{
Optional
<
User
>
user
=
userService
.
currentUser
();
if
(
user
.
isPresent
())
{
return
Optional
.
of
(
user
.
get
().
getId
());
}
throw
new
UserException
(
UserExceptionConsts
.
NO_CURRENT_USER
);
}
}
vms-user/src/main/java/com/zjty/vms/user/config/security/BCryptConfig.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
/**
* @author xyy
* @date 2021/7/26
*/
@Configuration
public
class
BCryptConfig
{
@Bean
public
BCryptPasswordEncoder
getBCryptPasswordEncoder
()
{
return
new
BCryptPasswordEncoder
();
}
}
vms-user/src/main/java/com/zjty/vms/user/config/security/GrantedAuthorityImpl.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
lombok.Builder
;
import
org.springframework.security.core.GrantedAuthority
;
/**
* @author xyy
*/
@Builder
public
class
GrantedAuthorityImpl
implements
GrantedAuthority
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
authority
;
public
GrantedAuthorityImpl
(
String
authority
)
{
this
.
authority
=
authority
;
}
public
void
setAuthority
(
String
authority
)
{
this
.
authority
=
authority
;
}
@Override
public
String
getAuthority
()
{
return
this
.
authority
;
}
}
vms-user/src/main/java/com/zjty/vms/user/config/security/JwtAuthenticationFilter.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
com.zjty.vms.misc.util.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.web.authentication.www.BasicAuthenticationFilter
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* @author xyy
*/
public
class
JwtAuthenticationFilter
extends
BasicAuthenticationFilter
{
@Autowired
public
JwtAuthenticationFilter
(
AuthenticationManager
authenticationManager
)
{
super
(
authenticationManager
);
}
@Override
protected
void
doFilterInternal
(
HttpServletRequest
request
,
HttpServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
String
token
=
JwtTokenUtils
.
getToken
(
request
);
if
(
StringUtil
.
isNotBlank
(
token
))
{
// 获取token, 并检查登录状态
SecurityUtils
.
checkAuthentication
(
request
);
}
chain
.
doFilter
(
request
,
response
);
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/config/security/JwtLoginFilter.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
com.zjty.vms.misc.util.JsonUtil
;
import
com.zjty.vms.user.subject.service.UserService
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
;
import
javax.annotation.Resource
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
/**
* @author xyy
*/
public
class
JwtLoginFilter
extends
UsernamePasswordAuthenticationFilter
{
@Resource
private
UserService
userService
;
public
JwtLoginFilter
(
AuthenticationManager
authManager
)
{
setAuthenticationManager
(
authManager
);
}
@Override
public
void
doFilter
(
ServletRequest
req
,
ServletResponse
res
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
// POST 请求 /login 登录时拦截, 由此方法触发执行登录认证流程,可以在此覆写整个登录认证逻辑
super
.
doFilter
(
req
,
res
,
chain
);
}
@Override
public
Authentication
attemptAuthentication
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
AuthenticationException
{
SecurityUtils
.
checkAuthentication
(
request
);
return
SecurityUtils
.
getAuthentication
();
}
@Override
protected
void
successfulAuthentication
(
HttpServletRequest
request
,
HttpServletResponse
response
,
FilterChain
chain
,
Authentication
authResult
)
throws
IOException
,
ServletException
{
// 存储登录认证信息到上下文
SecurityContextHolder
.
getContext
().
setAuthentication
(
authResult
);
// 记住我服务
getRememberMeServices
().
loginSuccess
(
request
,
response
,
authResult
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
String
json
=
JsonUtil
.
toJson
(
"resultMap"
);
response
.
getWriter
().
print
(
json
);
response
.
getWriter
().
flush
();
response
.
getWriter
().
close
();
}
@Override
protected
void
unsuccessfulAuthentication
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AuthenticationException
failed
)
throws
IOException
,
ServletException
{
super
.
unsuccessfulAuthentication
(
request
,
response
,
failed
);
}
/**
* 获取请求Body
*
* @param request
* @return
*/
public
String
getBody
(
HttpServletRequest
request
)
{
StringBuilder
sb
=
new
StringBuilder
();
InputStream
inputStream
=
null
;
BufferedReader
reader
=
null
;
try
{
inputStream
=
request
.
getInputStream
();
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
Charset
.
forName
(
"UTF-8"
)));
String
line
=
""
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
sb
.
append
(
line
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
inputStream
!=
null
)
{
try
{
inputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
reader
!=
null
)
{
try
{
reader
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
return
sb
.
toString
();
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/config/security/JwtTokenUtils.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.Serializable
;
import
java.util.*
;
/**
* @author xyy
*/
@Component
public
class
JwtTokenUtils
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 用户名称
*/
private
static
final
String
USERNAME
=
Claims
.
SUBJECT
;
/**
* 创建时间
*/
private
static
final
String
CREATED
=
"created"
;
/**
* 权限列表
*/
private
static
final
String
AUTHORITIES
=
"authorities"
;
/**
* 密钥
*/
private
static
final
String
SECRET
=
"4BE5T@v*isPbr32x"
;
/**
* 有效期12小时
*/
private
static
final
long
EXPIRE_TIME
=
12
*
60
*
60
*
1000
;
private
static
UserDetailsService
userDetailsService
;
/**
* 生成令牌
*
* @param authentication 用户
* @return 令牌
*/
public
static
String
generateToken
(
Authentication
authentication
)
{
Map
<
String
,
Object
>
claims
=
new
HashMap
<>(
3
);
claims
.
put
(
USERNAME
,
SecurityUtils
.
getUsername
(
authentication
));
claims
.
put
(
CREATED
,
new
Date
());
claims
.
put
(
AUTHORITIES
,
authentication
.
getAuthorities
());
return
generateToken
(
claims
);
}
/**
* 从数据声明生成令牌
*
* @param claims 数据声明
* @return 令牌
*/
private
static
String
generateToken
(
Map
<
String
,
Object
>
claims
)
{
Date
expirationDate
=
new
Date
(
System
.
currentTimeMillis
()
+
EXPIRE_TIME
);
return
Jwts
.
builder
().
setClaims
(
claims
).
setExpiration
(
expirationDate
).
signWith
(
SignatureAlgorithm
.
HS512
,
SECRET
).
compact
();
}
/**
* 从令牌中获取用户名
*
* @param token 令牌
* @return 用户名
*/
public
static
String
getUsernameFromToken
(
String
token
)
{
String
username
;
try
{
Claims
claims
=
getClaimsFromToken
(
token
);
username
=
claims
.
getSubject
();
}
catch
(
Exception
e
)
{
username
=
null
;
}
return
username
;
}
/**
* 根据请求令牌获取登录认证信息
*
* @param request 令牌
* @return 用户名
*/
public
static
Authentication
getAuthenticationFromToken
(
HttpServletRequest
request
)
{
Authentication
authentication
=
null
;
// 获取请求携带的令牌
String
token
=
JwtTokenUtils
.
getToken
(
request
);
if
(
token
!=
null
)
{
// 请求令牌不能为空
if
(
SecurityUtils
.
getAuthentication
()
==
null
)
{
// 上下文中Authentication为空
Claims
claims
=
getClaimsFromToken
(
token
);
if
(
claims
==
null
)
{
return
null
;
}
String
username
=
claims
.
getSubject
();
if
(
username
==
null
)
{
return
null
;
}
if
(
isTokenExpired
(
token
))
{
return
null
;
}
Object
authors
=
claims
.
get
(
AUTHORITIES
);
List
<
GrantedAuthority
>
authorities
=
new
ArrayList
<>();
if
(
authors
instanceof
List
)
{
for
(
Object
object
:
(
List
)
authors
)
{
authorities
.
add
(
new
GrantedAuthorityImpl
((
String
)
((
Map
)
object
).
get
(
"authority"
)));
}
}
authentication
=
new
UsernamePasswordAuthenticationToken
(
username
,
null
,
null
);
}
else
{
if
(
validateToken
(
token
,
SecurityUtils
.
getUsername
()))
{
// 如果上下文中Authentication非空,且请求令牌合法,直接返回当前登录认证信息
authentication
=
SecurityUtils
.
getAuthentication
();
}
}
}
return
authentication
;
}
/**
* 从令牌中获取数据声明
*
* @param token 令牌
* @return 数据声明
*/
private
static
Claims
getClaimsFromToken
(
String
token
)
{
Claims
claims
;
try
{
claims
=
Jwts
.
parser
().
setSigningKey
(
SECRET
).
parseClaimsJws
(
token
).
getBody
();
}
catch
(
Exception
e
)
{
claims
=
null
;
}
return
claims
;
}
/**
* 验证令牌
*
* @param token token
* @param username 用户名
* @return 验证是否通过
*/
public
static
Boolean
validateToken
(
String
token
,
String
username
)
{
String
userName
=
getUsernameFromToken
(
token
);
return
(
userName
.
equals
(
username
)
&&
!
isTokenExpired
(
token
));
}
/**
* 刷新令牌
*
* @param token token
* @return 新的token
*/
public
static
String
refreshToken
(
String
token
)
{
String
refreshedToken
;
try
{
Claims
claims
=
getClaimsFromToken
(
token
);
claims
.
put
(
CREATED
,
new
Date
());
refreshedToken
=
generateToken
(
claims
);
}
catch
(
Exception
e
)
{
refreshedToken
=
null
;
}
return
refreshedToken
;
}
/**
* 判断令牌是否过期
*
* @param token 令牌
* @return 是否过期
*/
public
static
Boolean
isTokenExpired
(
String
token
)
{
try
{
Claims
claims
=
getClaimsFromToken
(
token
);
Date
expiration
=
claims
.
getExpiration
();
return
expiration
.
before
(
new
Date
());
}
catch
(
Exception
e
)
{
return
false
;
}
}
/**
* 获取请求token
*
* @param request request
* @return token
*/
public
static
String
getToken
(
HttpServletRequest
request
)
{
String
token
=
request
.
getHeader
(
"Authorization"
);
String
tokenHead
=
"Bearer "
;
if
(
token
==
null
)
{
token
=
request
.
getHeader
(
"token"
);
}
else
if
(
token
.
contains
(
tokenHead
))
{
token
=
token
.
substring
(
tokenHead
.
length
());
}
if
(
""
.
equals
(
token
))
{
token
=
null
;
}
return
token
;
}
@Resource
private
void
setUserDetailsService
(
UserDetailsService
userDetailsService
)
{
JwtTokenUtils
.
userDetailsService
=
userDetailsService
;
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/config/security/SecurityConfig.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
com.zjty.vms.misc.util.JsonUtil
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.builders.WebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfigurationSource
;
import
org.springframework.web.cors.CorsUtils
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
java.io.PrintWriter
;
/**
* @author xyy
*/
@Configuration
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
//前后端分离前端不会302重定向,所以要重写AuthenticationEntryPoint
http
.
cors
().
and
()
.
csrf
().
disable
()
.
authorizeRequests
()
//开启登录配置
//处理跨域请求中的Preflight请求
.
requestMatchers
(
CorsUtils:
:
isPreFlightRequest
).
permitAll
()
.
antMatchers
(
"/"
).
permitAll
()
.
anyRequest
().
authenticated
()
//表示剩余的其他接口,登录之后就能访问
.
and
()
.
formLogin
()
//登录处理接口
.
loginProcessingUrl
(
"/login"
)
.
permitAll
()
//和表单登录相关的接口统统都直接通过
.
and
()
.
logout
()
.
logoutUrl
(
"/logout"
)
.
logoutSuccessHandler
((
req
,
resp
,
authentication
)
->
{
resp
.
setContentType
(
"application/json;charset=utf-8"
);
resp
.
setCharacterEncoding
(
"utf-8"
);
resp
.
setContentType
(
"text/html; charset=utf-8"
);
PrintWriter
out
=
resp
.
getWriter
();
out
.
write
(
"logout success"
);
out
.
flush
();
})
.
permitAll
()
.
and
()
.
exceptionHandling
()
.
accessDeniedHandler
((
req
,
resp
,
e
)
->
{
// Ser result = Result.ERROR(ResultCode.NO_PERMISSION);
resp
.
setCharacterEncoding
(
"utf-8"
);
resp
.
setContentType
(
"text/html; charset=utf-8"
);
PrintWriter
out
=
resp
.
getWriter
();
out
.
write
(
JsonUtil
.
toJson
(
"认证失败"
));
out
.
flush
();
out
.
close
();
})
.
authenticationEntryPoint
((
req
,
resp
,
e
)
->
{
// Result result = Result.ERROR(ResultCode.USER_NOT_LOGIN);
resp
.
setCharacterEncoding
(
"utf-8"
);
resp
.
setContentType
(
"text/html; charset=utf-8"
);
PrintWriter
out
=
resp
.
getWriter
();
out
.
write
(
JsonUtil
.
toJson
(
"认证失败"
));
out
.
flush
();
out
.
close
();
})
.
and
()
.
httpBasic
();
// 开启登录认证流程过滤器
http
.
addFilterBefore
(
new
JwtLoginFilter
(
authenticationManager
()),
UsernamePasswordAuthenticationFilter
.
class
);
// 访问控制时登录状态检查过滤器
http
.
addFilterBefore
(
new
JwtAuthenticationFilter
(
authenticationManager
()),
UsernamePasswordAuthenticationFilter
.
class
);
}
@Override
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
ignoring
().
antMatchers
(
"/v2/api-docs"
,
"/swagger-resources/configuration/ui"
,
"/swagger-resources"
,
"/swagger-resources/configuration/security"
,
"/swagger-ui.html"
,
"/webjars/**"
,
"/csrf"
,
"/js/**"
,
"/css/**"
,
"/favicon.ico"
,
"/index.html"
,
"/fonts/**"
,
"/static/**"
).
and
().
ignoring
().
antMatchers
(
HttpMethod
.
GET
,
"/user/login"
);
}
@Bean
CorsConfigurationSource
corsConfigurationSource
()
{
CorsConfiguration
configuration
=
new
CorsConfiguration
();
configuration
.
addAllowedOriginPattern
(
"*"
);
configuration
.
addAllowedMethod
(
"*"
);
configuration
.
addAllowedHeader
(
"*"
);
configuration
.
setAllowCredentials
(
true
);
UrlBasedCorsConfigurationSource
source
=
new
UrlBasedCorsConfigurationSource
();
source
.
registerCorsConfiguration
(
"/**"
,
configuration
);
return
source
;
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/config/security/SecurityUtils.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
security
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.web.authentication.WebAuthenticationDetailsSource
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @author xyy
*/
public
class
SecurityUtils
{
/**
* 系统登录认证
*
* @param request
* @param username
* @param password
* @param authenticationManager
* @return token
*/
public
static
String
login
(
HttpServletRequest
request
,
String
username
,
String
password
,
AuthenticationManager
authenticationManager
)
{
UsernamePasswordAuthenticationToken
token
=
new
UsernamePasswordAuthenticationToken
(
username
,
password
);
token
.
setDetails
(
new
WebAuthenticationDetailsSource
().
buildDetails
(
request
));
// 执行登录认证过程
Authentication
authentication
=
authenticationManager
.
authenticate
(
token
);
// 认证成功存储认证信息到上下文
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
// 生成令牌并返回给客户端
return
JwtTokenUtils
.
generateToken
(
authentication
);
}
/**
* 获取令牌进行认证
* @param request
*/
public
static
void
checkAuthentication
(
HttpServletRequest
request
)
{
// 获取令牌并根据令牌获取登录认证信息
Authentication
authentication
=
JwtTokenUtils
.
getAuthenticationFromToken
(
request
);
// 设置登录认证信息到上下文
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
}
/**
* 获取当前用户名
* @return
*/
public
static
String
getUsername
()
{
Authentication
authentication
=
getAuthentication
();
return
getUsername
(
authentication
);
}
/**
* 获取用户名
* @return
*/
public
static
String
getUsername
(
Authentication
authentication
)
{
String
username
=
null
;
if
(
authentication
!=
null
)
{
Object
principal
=
authentication
.
getPrincipal
();
if
(
principal
!=
null
&&
principal
instanceof
UserDetails
)
{
username
=
((
UserDetails
)
principal
).
getUsername
();
}
if
(
principal
!=
null
&&
principal
instanceof
String
)
{
username
=
((
String
)
principal
);
}
}
return
username
;
}
/**
* 获取当前登录信息
* @return
*/
public
static
Authentication
getAuthentication
()
{
if
(
SecurityContextHolder
.
getContext
()
==
null
)
{
return
null
;
}
Authentication
authentication
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
return
authentication
;
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/config/wx/WxConfiguration.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
wx
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl
;
import
cn.binarywang.wx.miniapp.bean.WxMaKefuMessage
;
import
cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage
;
import
cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl
;
import
cn.binarywang.wx.miniapp.message.WxMaMessageHandler
;
import
cn.binarywang.wx.miniapp.message.WxMaMessageRouter
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.zjty.vms.misc.util.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.bean.result.WxMediaUploadResult
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.common.error.WxRuntimeException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
import
java.io.File
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author xyy
*/
@Slf4j
@Configuration
@EnableConfigurationProperties
(
WxProperties
.
class
)
public
class
WxConfiguration
{
private
static
final
Map
<
String
,
WxMaMessageRouter
>
routers
=
Maps
.
newHashMap
();
private
static
Map
<
String
,
WxMaService
>
maServices
;
private
final
WxProperties
properties
;
private
final
WxMaMessageHandler
subscribeMsgHandler
=
(
wxMessage
,
context
,
service
,
sessionManager
)
->
{
service
.
getMsgService
().
sendSubscribeMsg
(
WxMaSubscribeMessage
.
builder
()
.
templateId
(
"此处更换为自己的模板id"
)
.
data
(
Lists
.
newArrayList
(
new
WxMaSubscribeMessage
.
MsgData
(
"keyword1"
,
"339208499"
)))
.
toUser
(
wxMessage
.
getFromUser
())
.
build
());
return
null
;
};
private
final
WxMaMessageHandler
logHandler
=
(
wxMessage
,
context
,
service
,
sessionManager
)
->
{
log
.
info
(
"收到消息:"
+
wxMessage
.
toString
());
service
.
getMsgService
().
sendKefuMsg
(
WxMaKefuMessage
.
newTextBuilder
().
content
(
"收到信息为:"
+
wxMessage
.
toJson
())
.
toUser
(
wxMessage
.
getFromUser
()).
build
());
return
null
;
};
private
final
WxMaMessageHandler
textHandler
=
(
wxMessage
,
context
,
service
,
sessionManager
)
->
{
service
.
getMsgService
().
sendKefuMsg
(
WxMaKefuMessage
.
newTextBuilder
().
content
(
"回复文本消息"
)
.
toUser
(
wxMessage
.
getFromUser
()).
build
());
return
null
;
};
private
final
WxMaMessageHandler
picHandler
=
(
wxMessage
,
context
,
service
,
sessionManager
)
->
{
try
{
WxMediaUploadResult
uploadResult
=
service
.
getMediaService
()
.
uploadMedia
(
"image"
,
"png"
,
ClassLoader
.
getSystemResourceAsStream
(
"tmp.png"
));
service
.
getMsgService
().
sendKefuMsg
(
WxMaKefuMessage
.
newImageBuilder
()
.
mediaId
(
uploadResult
.
getMediaId
())
.
toUser
(
wxMessage
.
getFromUser
())
.
build
());
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
}
return
null
;
};
private
final
WxMaMessageHandler
qrcodeHandler
=
(
wxMessage
,
context
,
service
,
sessionManager
)
->
{
try
{
final
File
file
=
service
.
getQrcodeService
().
createQrcode
(
"123"
,
430
);
WxMediaUploadResult
uploadResult
=
service
.
getMediaService
().
uploadMedia
(
"image"
,
file
);
service
.
getMsgService
().
sendKefuMsg
(
WxMaKefuMessage
.
newImageBuilder
()
.
mediaId
(
uploadResult
.
getMediaId
())
.
toUser
(
wxMessage
.
getFromUser
())
.
build
());
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
}
return
null
;
};
@Autowired
public
WxConfiguration
(
WxProperties
properties
)
{
this
.
properties
=
properties
;
}
public
static
WxMaService
getMaService
(
String
appid
)
{
WxMaService
wxService
=
maServices
.
get
(
appid
);
if
(
wxService
==
null
)
{
throw
new
IllegalArgumentException
(
String
.
format
(
"未找到对应appid=[%s]的配置,请核实!"
,
appid
));
}
return
wxService
;
}
public
static
WxMaMessageRouter
getRouter
(
String
appid
)
{
return
routers
.
get
(
appid
);
}
@Bean
(
"wxMaService"
)
public
WxMaService
getMaService
()
{
WxProperties
.
Config
config
=
properties
.
getConfigs
().
get
(
0
);
if
(
config
==
null
||
StringUtil
.
isBlank
(
config
.
getAppid
()))
{
throw
new
IllegalArgumentException
(
"未找到appid的配置,请核实!"
);
}
WxMaService
wxService
=
maServices
.
get
(
config
.
getAppid
());
if
(
wxService
==
null
)
{
throw
new
IllegalArgumentException
(
String
.
format
(
"未找到对应appid=[%s]的配置,请核实!"
,
config
.
getAppid
()));
}
return
wxService
;
}
@PostConstruct
public
void
init
()
{
List
<
WxProperties
.
Config
>
configs
=
this
.
properties
.
getConfigs
();
if
(
configs
==
null
)
{
throw
new
WxRuntimeException
(
"大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!"
);
}
maServices
=
configs
.
stream
()
.
map
(
a
->
{
WxMaDefaultConfigImpl
config
=
new
WxMaDefaultConfigImpl
();
// WxMaDefaultConfigImpl config = new WxMaRedisConfigImpl(new JedisPool());
// 使用上面的配置时,需要同时引入jedis-lock的依赖,否则会报类无法找到的异常
config
.
setAppid
(
a
.
getAppid
());
config
.
setSecret
(
a
.
getSecret
());
config
.
setToken
(
a
.
getToken
());
config
.
setAesKey
(
a
.
getAesKey
());
config
.
setMsgDataFormat
(
a
.
getMsgDataFormat
());
WxMaService
service
=
new
WxMaServiceImpl
();
service
.
setWxMaConfig
(
config
);
routers
.
put
(
a
.
getAppid
(),
this
.
newRouter
(
service
));
return
service
;
}).
collect
(
Collectors
.
toMap
(
s
->
s
.
getWxMaConfig
().
getAppid
(),
a
->
a
));
}
private
WxMaMessageRouter
newRouter
(
WxMaService
service
)
{
final
WxMaMessageRouter
router
=
new
WxMaMessageRouter
(
service
);
router
.
rule
().
handler
(
logHandler
).
next
()
.
rule
().
async
(
false
).
content
(
"订阅消息"
).
handler
(
subscribeMsgHandler
).
end
()
.
rule
().
async
(
false
).
content
(
"文本"
).
handler
(
textHandler
).
end
()
.
rule
().
async
(
false
).
content
(
"图片"
).
handler
(
picHandler
).
end
()
.
rule
().
async
(
false
).
content
(
"二维码"
).
handler
(
qrcodeHandler
).
end
();
return
router
;
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/config/wx/WxProperties.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
config
.
wx
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
java.util.List
;
/**
* @author xyy
*/
@Data
@ConfigurationProperties
(
prefix
=
"wx.miniapp"
)
public
class
WxProperties
{
private
List
<
Config
>
configs
;
@Data
public
static
class
Config
{
/**
* 设置微信小程序的appid
*/
private
String
appid
;
/**
* 设置微信小程序的Secret
*/
private
String
secret
;
/**
* 设置微信小程序消息服务器配置的token
*/
private
String
token
;
/**
* 设置微信小程序消息服务器配置的EncodingAESKey
*/
private
String
aesKey
;
/**
* 消息格式,XML或者JSON
*/
private
String
msgDataFormat
;
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/subject/controller/BusinessOwnerController.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
controller
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
com.zjty.vms.user.subject.entity.BusinessOwner
;
import
com.zjty.vms.user.subject.service.BusinessOwnerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@RestController
@RequestMapping
(
"/vms"
)
@AutoDocument
@Api
(
tags
=
"业主信息模块"
)
public
class
BusinessOwnerController
{
@Autowired
private
BusinessOwnerService
businessOwnerService
;
@GetMapping
(
"/bo"
)
public
ResponseEntity
getByOpenId
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
return
ResponseEntity
.
ok
(
businessOwnerService
.
findByOpenId
(
openId
));
}
@PostMapping
(
"/bo"
)
private
ResponseEntity
<
BusinessOwner
>
saveOne
(
@RequestBody
@ApiParam
(
name
=
"业主对象"
)
BusinessOwner
businessOwner
)
{
return
ResponseEntity
.
ok
(
businessOwnerService
.
save
(
businessOwner
));
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/controller/CarController.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
controller
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
com.zjty.vms.user.subject.dao.CarDao
;
import
com.zjty.vms.user.subject.entity.Car
;
import
com.zjty.vms.user.subject.service.CarService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
@RequestMapping
(
"/vms"
)
@RestController
@AutoDocument
@Api
(
tags
=
"车辆车位模块"
)
public
class
CarController
{
@Autowired
private
CarService
carService
;
@GetMapping
(
"car/num"
)
@ApiOperation
(
value
=
"根据车牌查"
)
public
ResponseEntity
<
Car
>
findByCarNum
(
@RequestParam
(
name
=
"numberPlate"
)
String
numberPlate
)
{
return
ResponseEntity
.
ok
(
carService
.
findByCarNum
(
numberPlate
));
}
@GetMapping
(
"car/tel"
)
@ApiOperation
(
value
=
"根据电话查"
)
public
ResponseEntity
<
List
<
Car
>>
findByTel
(
@RequestParam
(
name
=
"tel"
)
String
tel
)
{
return
ResponseEntity
.
ok
(
carService
.
findByPhone
(
tel
));
}
@ApiOperation
(
value
=
"保存一个车辆信息"
)
@PostMapping
(
"car"
)
public
ResponseEntity
<
Car
>
saveOne
(
@RequestBody@ApiParam
(
name
=
"车辆"
)
Car
car
)
{
return
ResponseEntity
.
ok
(
carService
.
saveOne
(
car
));
}
@ApiOperation
(
value
=
"根据停车位查车"
)
@GetMapping
(
"car/space"
)
public
ResponseEntity
<
List
<
Car
>>
findByParkingSpace
(
@RequestParam
(
name
=
"parkingSpace"
)
String
parkingSpace
)
{
return
ResponseEntity
.
ok
(
carService
.
findByParkingSpace
(
parkingSpace
));
}
@ApiOperation
(
value
=
"根据id删除车辆信息"
)
@DeleteMapping
(
"car"
)
public
ResponseEntity
deleteCar
(
@RequestParam
(
name
=
"uuid"
)
String
uuid
)
{
carService
.
deleteCar
(
uuid
);
return
ResponseEntity
.
ok
(
"ok"
);
}
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/subject/controller/RoleController.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
controller
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
com.zjty.vms.user.subject.entity.Role
;
import
com.zjty.vms.user.subject.service.RoleService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.persistence.Id
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@RestController
@RequestMapping
(
"/vms"
)
@AutoDocument
@Api
(
tags
=
"人员权限模块"
)
public
class
RoleController
{
@Autowired
private
RoleService
roleService
;
@GetMapping
(
"/role"
)
public
ResponseEntity
<
Role
>
getOne
(
@RequestParam
(
value
=
"roleId"
)
Integer
roleId
)
{
return
ResponseEntity
.
status
(
200
).
body
(
roleService
.
getById
(
roleId
));
}
@GetMapping
(
"/allRoles"
)
public
ResponseEntity
<
List
<
Role
>>
getRoles
(
@RequestParam
(
value
=
"ids"
)
@ApiParam
(
name
=
"ids,,分割"
,
example
=
"1,2,3"
)
String
ids
)
{
final
String
[]
str
=
ids
.
split
(
","
);
List
<
Integer
>
list
=
new
ArrayList
<>();
for
(
String
s
:
str
)
{
list
.
add
(
Integer
.
parseInt
(
s
));
}
return
ResponseEntity
.
status
(
200
).
body
(
roleService
.
findByIds
(
list
));
}
@PostMapping
public
ResponseEntity
<
Role
>
saveOne
(
@RequestBody@ApiParam
(
name
=
"权限"
)
Role
role
)
{
return
ResponseEntity
.
status
(
200
).
body
(
roleService
.
save
(
role
));
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/controller/UserController.java
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
controller
;
package
com
.
zjty
.
vms
.
user
.
subject
.
controller
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
com.zjty.vms.user.subject.entity.User
;
import
com.zjty.vms.user.subject.entity.AppUser
;
import
com.zjty.vms.user.subject.service.UserService
;
import
com.zjty.vms.user.subject.service.AppUserService
;
import
com.zjty.vms.wechat.subject.service.WeChatApiService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
import
javax.annotation.Resource
;
import
java.util.Map
;
/**
/**
* @author LJJ cnljj1995@gmail.com
* @author xyy
* on 2020-06-01
*/
*/
@Api
(
tags
=
"用户管理"
)
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/vms"
)
@RequestMapping
(
"user"
)
@AutoDocument
@Api
(
tags
=
"人员基础信息模块"
)
public
class
UserController
{
public
class
UserController
{
@Autowired
@Resource
private
AppUserService
appUserService
;
private
UserService
userService
;
@Autowired
private
WeChatApiService
apiService
;
@ApiOperation
(
value
=
"登陆接口"
)
/**
@GetMapping
(
"login2"
)
* 登陆接口
public
ResponseEntity
<
AppUser
>
login
(
@ApiParam
(
name
=
"openId"
)
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
*/
return
ResponseEntity
.
status
(
200
).
body
(
appUserService
.
findByOpenId
(
openId
));
@GetMapping
(
"/login"
)
@ApiModelProperty
(
"用户登录"
)
public
Map
<
String
,
String
>
login
(
String
jsCode
)
{
return
userService
.
login
(
jsCode
);
}
}
@ApiOperation
(
value
=
"获取人员基础信息"
)
/**
@GetMapping
(
"userInfo"
)
* <pre>
public
ResponseEntity
<
AppUser
>
getOne
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
* 获取用户信息接口
return
ResponseEntity
.
status
(
200
).
body
(
appUserService
.
findByOpenId
(
openId
));
* </pre>
*/
@GetMapping
(
"/info"
)
@ApiModelProperty
(
"获取用户信息接口"
)
public
User
info
(
@PathVariable
String
appid
,
String
sessionKey
,
String
signature
,
String
rawData
,
String
encryptedData
,
String
iv
)
{
return
userService
.
getInfo
(
sessionKey
,
signature
,
rawData
,
encryptedData
,
iv
);
}
}
@ApiOperation
(
value
=
"保存个人基本信息"
)
/**
@PostMapping
(
"/appUser"
)
* <pre>
public
ResponseEntity
<
AppUser
>
saveOne
(
@RequestBody@ApiParam
(
name
=
"人员基础信息"
)
AppUser
appUser
)
{
* 获取用户绑定手机号信息
appUser
.
setUpdateTime
(
new
Date
());
* </pre>
AppUser
user
=
appUserService
.
saveOne
(
appUser
);
*/
return
ResponseEntity
.
status
(
200
).
body
(
user
);
@GetMapping
(
"/phone"
)
@ApiModelProperty
(
"获取用户绑定手机号信息"
)
public
String
phone
(
@PathVariable
String
appid
,
String
sessionKey
,
String
signature
,
String
rawData
,
String
encryptedData
,
String
iv
)
{
return
userService
.
getPhone
(
sessionKey
,
signature
,
rawData
,
encryptedData
,
iv
);
}
}
@ApiOperation
(
value
=
"根据手机号码查询人员"
)
@GetMapping
(
"/user/tel"
)
public
ResponseEntity
<
AppUser
>
findByTel
(
@RequestParam
(
value
=
"tel"
)
@ApiParam
(
name
=
"手机号码"
)
String
tel
)
{
return
ResponseEntity
.
ok
(
appUserService
.
findByPhone
(
tel
));
}
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/dao/AppUserDao.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
dao
;
import
com.zjty.vms.user.subject.entity.AppUser
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-28
*/
public
interface
AppUserDao
extends
JpaRepository
<
AppUser
,
String
>
{
Optional
<
List
<
AppUser
>>
findByTel
(
String
tel
);
}
\ No newline at end of file
vms-user/src/main/java/com/zjty/vms/user/subject/dao/BusinessOwnerDao.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
dao
;
import
com.zjty.vms.user.subject.entity.BusinessOwner
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
BusinessOwnerDao
extends
JpaRepository
<
BusinessOwner
,
String
>
{
Optional
<
List
<
BusinessOwner
>>
findByOpenId
(
String
openId
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/dao/CarDao.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
dao
;
import
com.zjty.vms.user.subject.entity.Car
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
public
interface
CarDao
extends
JpaRepository
<
Car
,
String
>,
JpaSpecificationExecutor
<
Car
>
{
Optional
<
Car
>
findTopByNumberPlate
(
String
numberPlate
);
Optional
<
List
<
Car
>>
findByParkingSpace
(
String
parkingSpace
);
Optional
<
List
<
Car
>>
findByPhone
(
String
tel
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/dao/RoleDao.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
dao
;
import
com.zjty.vms.user.subject.entity.Role
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
RoleDao
extends
JpaRepository
<
Role
,
Integer
>
{
}
vms-user/src/main/java/com/zjty/vms/user/subject/dao/UserRepository.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
dao
;
import
com.zjty.vms.user.subject.entity.User
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.Optional
;
/**
* @author xyy
*/
public
interface
UserRepository
extends
JpaRepository
<
User
,
String
>
{
/**
* 通过电话号查询用户
* @param phoneNum 电话号
* @return 用户
*/
Optional
<
User
>
findByPhoneNum
(
String
phoneNum
);
/**
* 通过微信小程序唯一id查找用户
* @param openId openId
* @return 用户
*/
Optional
<
User
>
findByOpenId
(
String
openId
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/AppUser.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
/**
* 业主对象
*
* @author LJJ cnljj1995@gmail.com
* on 2020-05-28
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@AutoDocument
@ApiModel
(
value
=
"人员基本信息"
,
description
=
"人员基本信息实体类"
)
@Table
(
name
=
"vms_user"
)
public
class
AppUser
{
@Id
@ApiModelProperty
(
value
=
"小程序用户唯一标识,人员主键id"
,
example
=
"asdasd"
)
private
String
openId
;
@ApiModelProperty
(
value
=
"用户在开放平台的唯一标识符"
,
example
=
"asdasd"
)
private
String
unionId
;
@ApiModelProperty
(
value
=
"联系人"
,
example
=
"张三"
)
private
String
name
;
@ApiModelProperty
(
value
=
"联系电话"
,
example
=
"15912331111"
)
private
String
tel
;
@ApiModelProperty
(
value
=
"角色"
,
example
=
"1,2,3,4"
)
private
String
role
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
value
=
"创建时间"
,
example
=
"2001-01-01 00:00:00"
)
private
Date
createTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2001-01-01 00:00:00"
)
private
Date
updateTime
;
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/BusinessOwner.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table
(
name
=
"vms_business_owner"
)
@AutoDocument
@ApiModel
(
value
=
"小区业主对象"
,
description
=
"小区业主实体类"
)
public
class
BusinessOwner
{
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
uuid
;
@ApiModelProperty
(
value
=
"关联人员id"
,
example
=
"asdasd"
)
private
String
openId
;
@ApiModelProperty
(
value
=
"车牌号"
,
example
=
"浙A888888"
)
private
String
numberPlate
;
@ApiModelProperty
(
value
=
"门号"
,
example
=
"23-1-2002"
)
private
String
room
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2001-01-01 00:00:00"
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"创建时间"
,
example
=
"2001-01-01 00:00:00"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/Car.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Builder
@Table
(
name
=
"vms_car"
)
@AutoDocument
@ApiModel
(
value
=
"车辆对象"
,
description
=
"车辆实体类"
)
public
class
Car
{
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
uuid
;
@ApiModelProperty
(
value
=
"车牌号"
,
example
=
"浙A888888"
)
private
String
numberPlate
;
@ApiModelProperty
(
value
=
"车位号"
,
example
=
"A101"
)
private
String
parkingSpace
;
@ApiModelProperty
(
value
=
"房号"
,
example
=
"1-01-1001"
)
private
String
room
;
@ApiModelProperty
(
value
=
"车主姓名"
,
example
=
"张三"
)
private
String
carOwner
;
@ApiModelProperty
(
value
=
"车主手机号"
,
example
=
"15123123123"
)
private
String
phone
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
value
=
"创建"
,
example
=
"2001-01-01 00:00:00"
)
private
Date
createTime
=
new
Date
();
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2001-01-01 00:00:00"
)
private
Date
updateTime
=
new
Date
();
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/ParkingSpace.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table
(
name
=
"vms_parking"
)
@AutoDocument
@ApiModel
(
value
=
"车位"
,
description
=
"车位信息实体类"
)
public
class
ParkingSpace
{
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
uuid
;
@ApiModelProperty
(
value
=
"所属房子Id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
roomId
;
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/Role.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table
(
name
=
"vms_role"
)
@AutoDocument
@ApiModel
(
value
=
"权限表"
,
description
=
"权限实体类"
)
public
class
Role
{
@Id
@ApiModelProperty
(
value
=
"id"
,
example
=
"1"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"权限名称"
,
example
=
"业主"
)
private
String
roleName
=
""
;
@ApiModelProperty
(
value
=
"权限描述"
,
example
=
"描述信息"
)
private
String
description
=
""
;
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/Room.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table
(
name
=
"vms_room"
)
@AutoDocument
@ApiModel
(
value
=
"房子"
,
description
=
"房子实体类"
)
public
class
Room
{
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
uuid
;
private
String
ownerId
;
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/
Committee
.java
→
vms-user/src/main/java/com/zjty/vms/user/subject/entity/
User
.java
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Builder
;
...
@@ -10,23 +11,31 @@ import org.hibernate.annotations.GenericGenerator;
...
@@ -10,23 +11,31 @@ import org.hibernate.annotations.GenericGenerator;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
/**
* @author LJJ cnljj1995@gmail.com
* @author xyy
* on 2020-06-01
*/
*/
@Data
@Data
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Entity
@
Table
(
name
=
"vms_committee"
)
@
Builder
public
class
Committee
{
public
class
User
{
@Id
@Id
@GeneratedValue
(
generator
=
"uuid2"
)
@GenericGenerator
(
name
=
"idGenerator"
,
strategy
=
"uuid"
)
@GenericGenerator
(
name
=
"uuid2"
,
strategy
=
"org.hibernate.id.UUIDGenerator"
)
@GeneratedValue
(
generator
=
"idGenerator"
)
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"3eee-eqwe-qwe-123"
)
private
String
Id
;
private
String
uuid
;
@ApiModelProperty
(
"openId"
)
private
String
openId
;
@ApiModelProperty
(
"用户名"
)
private
String
username
;
@ApiModelProperty
(
"手机号"
)
private
String
phoneNum
;
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/entity/UserVo.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
entity
;
/**
* @author xyy
*/
public
class
UserVo
{
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/AppUserService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
;
import
com.zjty.vms.user.subject.entity.AppUser
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
public
interface
AppUserService
{
/**
* 根据open ID 查找用户
* @param openId openid
* @return obj
*/
AppUser
findByOpenId
(
String
openId
);
/**
* 保存用户
* @param appUser app user
* @return obj
*/
AppUser
saveOne
(
AppUser
appUser
);
/**
* 根据手机号码查询
* @param tel 手机号码
* @return obj
*/
AppUser
findByPhone
(
String
tel
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/BusinessOwnerService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
;
import
com.zjty.vms.user.subject.entity.BusinessOwner
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
BusinessOwnerService
{
BusinessOwner
save
(
BusinessOwner
businessOwner
);
BusinessOwner
findById
(
String
uuid
);
/**
* 根据openid 查询业主
* @param openId
* @return
*/
BusinessOwner
findByOpenId
(
String
openId
);
/**
* 根据车牌号码查询业务
* @param numberPlate 车牌号码
* @return 业主
*/
BusinessOwner
findByCar
(
String
numberPlate
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/CarService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
;
import
com.zjty.vms.user.subject.entity.Car
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
public
interface
CarService
{
/**
* 根据车牌号码查询
* @param numberPlate 车牌号码
* @return car
*/
Car
findByCarNum
(
String
numberPlate
);
/**
* 根据停车位查询车辆
* @param parkingSpace parking space
* @return objs
*/
List
<
Car
>
findByParkingSpace
(
String
parkingSpace
);
/**
* 根据手机查找车子
* @param tel tel
* @return objs
*/
List
<
Car
>
findByPhone
(
String
tel
);
/**
* 保存车辆信息
* @param car car
* @return car
*/
Car
saveOne
(
Car
car
);
/**
* save cars
* @param cars cars
* @return cars
*/
List
<
Car
>
saveAll
(
List
<
Car
>
cars
);
/**
* delete car
* @param id car's uuid
*/
void
deleteCar
(
String
id
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/RoleService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
;
import
com.zjty.vms.user.subject.entity.Role
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
public
interface
RoleService
{
/**
* 保存Role
* @param role role
* @return obj
*/
Role
save
(
Role
role
);
/**
* 根据ID查找
* @param roleId roleId
* @return obj
*/
Role
getById
(
Integer
roleId
);
/**
* 根据id查找
* @param ids id集合
* @return list
*/
List
<
Role
>
findByIds
(
List
<
Integer
>
ids
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/UserService.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
service
;
import
com.zjty.vms.user.subject.entity.User
;
import
java.util.Map
;
import
java.util.Optional
;
/**
* @author xyy
*/
public
interface
UserService
{
/**
* 新增用户
* @param user 用户
* @return 用户
*/
User
save
(
User
user
);
/**
* 通过手机号查询用户
* @param phoneNum 手机号
* @return 用户
*/
Optional
<
User
>
findByPhoneNum
(
String
phoneNum
);
/**
* 用户登录
* @param code 小程序登录code
* @return 返回token
*/
Map
<
String
,
String
>
login
(
String
code
);
/**
* 当前用户
* @return user
*/
Optional
<
User
>
currentUser
();
/**
* 获取用户手机号
* @param sessionKey sessionKey
* @param signature signature
* @param rawData rawData
* @param encryptedData encryptedData
* @param iv iv
* @return 手机号
*/
String
getPhone
(
String
sessionKey
,
String
signature
,
String
rawData
,
String
encryptedData
,
String
iv
);
/**
* 获取用户信息
* @param sessionKey sessionKey
* @param signature signature
* @param rawData rawData
* @param encryptedData encryptedData
* @param iv iv
* @return user
*/
User
getInfo
(
String
sessionKey
,
String
signature
,
String
rawData
,
String
encryptedData
,
String
iv
);
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/impl/AppUserServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
.
impl
;
import
com.zjty.vms.user.subject.dao.AppUserDao
;
import
com.zjty.vms.user.subject.entity.AppUser
;
import
com.zjty.vms.user.subject.service.AppUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
@Service
@Slf4j
public
class
AppUserServiceImpl
implements
AppUserService
{
@Autowired
private
AppUserDao
appUserDao
;
@Override
public
AppUser
findByOpenId
(
String
openId
)
{
Optional
<
AppUser
>
appUser
=
appUserDao
.
findById
(
openId
);
return
appUser
.
orElseGet
(
AppUser:
:
new
);
}
@Override
public
AppUser
saveOne
(
AppUser
appUser
)
{
appUser
.
setUpdateTime
(
new
Date
());
return
appUserDao
.
save
(
appUser
);
}
@Override
public
AppUser
findByPhone
(
String
tel
)
{
final
Optional
<
List
<
AppUser
>>
find
=
appUserDao
.
findByTel
(
tel
);
if
(
find
.
isPresent
()
&&
find
.
get
().
size
()
==
1
)
{
return
find
.
get
().
get
(
0
);
}
else
{
return
new
AppUser
();
}
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/impl/BusinessOwnerServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
.
impl
;
import
com.zjty.vms.user.subject.dao.BusinessOwnerDao
;
import
com.zjty.vms.user.subject.entity.BusinessOwner
;
import
com.zjty.vms.user.subject.service.BusinessOwnerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Service
@Slf4j
public
class
BusinessOwnerServiceImpl
implements
BusinessOwnerService
{
@Autowired
private
BusinessOwnerDao
businessOwnerDao
;
@Override
public
BusinessOwner
save
(
BusinessOwner
businessOwner
)
{
businessOwner
.
setUpdateTime
(
new
Date
());
return
businessOwnerDao
.
save
(
businessOwner
);
}
@Override
public
BusinessOwner
findById
(
String
uuid
)
{
final
Optional
<
BusinessOwner
>
rs
=
businessOwnerDao
.
findById
(
uuid
);
return
rs
.
orElseGet
(
BusinessOwner:
:
new
);
}
@Override
public
BusinessOwner
findByOpenId
(
String
openId
)
{
final
Optional
<
List
<
BusinessOwner
>>
rs
=
businessOwnerDao
.
findByOpenId
(
openId
);
final
boolean
tag
=
rs
.
isPresent
();
if
(
tag
&&
rs
.
get
().
size
()==
1
)
{
return
rs
.
get
().
get
(
0
);
}
else
{
return
new
BusinessOwner
();
}
}
@Override
public
BusinessOwner
findByCar
(
String
numberPlate
)
{
return
null
;
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/impl/CarServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
.
impl
;
import
com.zjty.vms.user.subject.dao.CarDao
;
import
com.zjty.vms.user.subject.entity.Car
;
import
com.zjty.vms.user.subject.service.CarService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-02
*/
@Service
@Slf4j
public
class
CarServiceImpl
implements
CarService
{
@Autowired
private
CarDao
carDao
;
@Override
public
Car
findByCarNum
(
String
numberPlate
)
{
final
Optional
<
Car
>
topByNumberPlate
=
carDao
.
findTopByNumberPlate
(
numberPlate
);
return
topByNumberPlate
.
orElseGet
(
Car:
:
new
);
}
@Override
public
List
<
Car
>
findByParkingSpace
(
String
parkingSpace
)
{
final
Optional
<
List
<
Car
>>
cars
=
carDao
.
findByParkingSpace
(
parkingSpace
);
return
cars
.
orElse
(
Collections
.
emptyList
());
}
@Override
public
List
<
Car
>
findByPhone
(
String
tel
)
{
final
Optional
<
List
<
Car
>>
rs
=
carDao
.
findByPhone
(
tel
);
return
rs
.
orElse
(
Collections
.
emptyList
());
}
@Override
public
Car
saveOne
(
Car
car
)
{
return
carDao
.
save
(
car
);
}
@Override
public
List
<
Car
>
saveAll
(
List
<
Car
>
cars
)
{
return
carDao
.
saveAll
(
cars
);
}
@Override
public
void
deleteCar
(
String
id
)
{
carDao
.
deleteById
(
id
);
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/impl/RoleServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
user
.
subject
.
service
.
impl
;
import
com.zjty.vms.user.subject.dao.RoleDao
;
import
com.zjty.vms.user.subject.entity.Role
;
import
com.zjty.vms.user.subject.service.RoleService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@Service
@Slf4j
public
class
RoleServiceImpl
implements
RoleService
{
@Autowired
private
RoleDao
roleDao
;
@Override
public
Role
save
(
Role
role
)
{
return
roleDao
.
save
(
role
);
}
@Override
public
Role
getById
(
Integer
roleId
)
{
Optional
<
Role
>
rs
=
roleDao
.
findById
(
roleId
);
return
rs
.
orElseGet
(
Role:
:
new
);
}
@Override
public
List
<
Role
>
findByIds
(
List
<
Integer
>
ids
)
{
return
roleDao
.
findAllById
(
ids
);
}
}
vms-user/src/main/java/com/zjty/vms/user/subject/service/impl/UserServiceImpl.java
0 → 100644
浏览文件 @
34e46d3b
package
com
.
zjty
.
vms
.
user
.
subject
.
service
.
impl
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo
;
import
cn.binarywang.wx.miniapp.bean.WxMaUserInfo
;
import
com.zjty.vms.user.config.security.JwtTokenUtils
;
import
com.zjty.vms.user.subject.dao.UserRepository
;
import
com.zjty.vms.user.subject.entity.User
;
import
com.zjty.vms.user.subject.service.UserService
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.springframework.security.authentication.AnonymousAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
/**
* @author xyy
*/
@Slf4j
@Service
public
class
UserServiceImpl
implements
UserService
{
@Resource
private
UserRepository
userRepository
;
@Resource
private
WxMaService
wxMaService
;
@Override
public
User
save
(
User
user
)
{
return
userRepository
.
save
(
user
);
}
@Override
public
Optional
<
User
>
findByPhoneNum
(
String
phoneNum
)
{
return
userRepository
.
findByPhoneNum
(
phoneNum
);
}
@Override
public
Map
<
String
,
String
>
login
(
String
code
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>(
4
);
try
{
WxMaJscode2SessionResult
session
=
wxMaService
.
getUserService
().
getSessionInfo
(
code
);
map
.
put
(
"sessionKey"
,
session
.
getSessionKey
());
UsernamePasswordAuthenticationToken
authenticationToken
=
new
UsernamePasswordAuthenticationToken
(
session
.
getOpenid
(),
null
,
null
);
//判断是否为新用户
Optional
<
User
>
userOptional
=
userRepository
.
findByOpenId
(
session
.
getOpenid
());
if
(!
userOptional
.
isPresent
())
{
User
user
=
User
.
builder
()
.
openId
(
session
.
getOpenid
())
.
build
();
save
(
user
);
}
String
token
=
JwtTokenUtils
.
generateToken
(
authenticationToken
);
map
.
put
(
"token"
,
token
);
}
catch
(
WxErrorException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
return
map
;
}
@Override
public
Optional
<
User
>
currentUser
()
{
// return findByOpenId("oOO7F5J7RLT7Tp78WEqV3MLN3f7k");
Authentication
authentication
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
//有登陆用户就返回登录用户,没有就返回null
if
(
authentication
!=
null
)
{
if
(
authentication
instanceof
AnonymousAuthenticationToken
)
{
return
Optional
.
empty
();
}
if
(
authentication
instanceof
UsernamePasswordAuthenticationToken
)
{
String
openId
=
authentication
.
getPrincipal
().
toString
();
return
findByOpenId
(
openId
);
}
}
return
Optional
.
empty
();
}
@Override
public
String
getPhone
(
String
sessionKey
,
String
signature
,
String
rawData
,
String
encryptedData
,
String
iv
)
{
// 用户信息校验
if
(!
wxMaService
.
getUserService
().
checkUserInfo
(
sessionKey
,
rawData
,
signature
))
{
throw
new
IllegalArgumentException
(
"参数异常"
);
}
// 解密
WxMaPhoneNumberInfo
phoneNoInfo
=
wxMaService
.
getUserService
().
getPhoneNoInfo
(
sessionKey
,
encryptedData
,
iv
);
return
phoneNoInfo
.
getPhoneNumber
();
}
@Override
public
User
getInfo
(
String
sessionKey
,
String
signature
,
String
rawData
,
String
encryptedData
,
String
iv
)
{
// 用户信息校验
if
(!
wxMaService
.
getUserService
().
checkUserInfo
(
sessionKey
,
rawData
,
signature
))
{
throw
new
IllegalArgumentException
(
"参数异常"
);
}
// 解密用户信息
WxMaUserInfo
userInfo
=
wxMaService
.
getUserService
().
getUserInfo
(
sessionKey
,
encryptedData
,
iv
);
User
user
=
User
.
builder
()
.
username
(
userInfo
.
getNickName
())
.
build
();
return
user
;
}
private
Optional
<
User
>
findByOpenId
(
String
openId
)
{
Optional
<
User
>
userOptional
=
userRepository
.
findByOpenId
(
openId
);
return
userOptional
;
}
}
vms-user/src/main/resources/application.properties
deleted
100644 → 0
浏览文件 @
4d6bead1
# server port
server.port
=
8082
##连接中心数据库数据库mysql
spring.datasource.url
=
jdbc:mysql://localhost:3306/vms?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.username
=
root
spring.datasource.password
=
ljj123456
# spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto
=
update
spring.jpa.show-sql
=
false
spring.jpa.properties.hibernate.dialect
=
org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.open-in-view
=
true
vms-wechat/src/main/java/com/zjty/vms/wechat/WeChatApp.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
@SpringBootApplication
(
scanBasePackages
=
{
"com.zjty.vms.misc"
,
"com.zjty.vms.wechat"
})
@EnableSwagger2
public
class
WeChatApp
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
WeChatApp
.
class
,
args
);
}
}
vms-wechat/src/main/java/com/zjty/vms/wechat/config/WeChatRestTemplateConfig.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
config
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.conn.ssl.TrustStrategy
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.web.client.RestTemplate
;
import
javax.net.ssl.SSLContext
;
import
java.security.KeyManagementException
;
import
java.security.KeyStoreException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.cert.X509Certificate
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
@Configuration
public
class
WeChatRestTemplateConfig
{
@Bean
public
RestTemplate
restTemplate
()
throws
KeyStoreException
,
NoSuchAlgorithmException
,
KeyManagementException
{
TrustStrategy
acceptingTrustStrategy
=
(
X509Certificate
[]
chain
,
String
authType
)
->
true
;
SSLContext
sslContext
=
org
.
apache
.
http
.
ssl
.
SSLContexts
.
custom
()
.
loadTrustMaterial
(
null
,
acceptingTrustStrategy
)
.
build
();
SSLConnectionSocketFactory
csf
=
new
SSLConnectionSocketFactory
(
sslContext
);
CloseableHttpClient
httpClient
=
HttpClients
.
custom
()
.
setSSLSocketFactory
(
csf
)
.
build
();
HttpComponentsClientHttpRequestFactory
requestFactory
=
new
HttpComponentsClientHttpRequestFactory
();
requestFactory
.
setHttpClient
(
httpClient
);
RestTemplate
restTemplate
=
new
RestTemplate
(
requestFactory
);
return
restTemplate
;
}
}
vms-wechat/src/main/java/com/zjty/vms/wechat/config/WxMappingJackson2HttpMessageConverter.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
config
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
public
class
WxMappingJackson2HttpMessageConverter
extends
MappingJackson2HttpMessageConverter
{
public
WxMappingJackson2HttpMessageConverter
()
{
List
<
MediaType
>
mediaTypes
=
new
ArrayList
<>();
mediaTypes
.
add
(
MediaType
.
TEXT_PLAIN
);
// mediaTypes.add(MediaType.TEXT_HTML);
setSupportedMediaTypes
(
mediaTypes
);
}
}
\ No newline at end of file
vms-wechat/src/main/java/com/zjty/vms/wechat/subject/controller/WeChatController.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
subject
.
controller
;
import
com.sun.xml.internal.bind.v2.model.core.ReferencePropertyInfo
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
com.zjty.vms.wechat.subject.entity.AuthCodeSession
;
import
com.zjty.vms.wechat.subject.service.WeChatApiService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-06-01
*/
@RestController
@RequestMapping
(
"/vms"
)
@AutoDocument
@Api
(
tags
=
"微信登陆模块"
)
public
class
WeChatController
{
@Autowired
private
WeChatApiService
weChatApiService
;
@GetMapping
(
"login"
)
@ApiOperation
(
value
=
"登陆接口"
)
public
ResponseEntity
login
(
@RequestParam
(
value
=
"jsCode"
)
String
jsCode
)
{
final
AuthCodeSession
authCodeSession
=
weChatApiService
.
getAuthSession
(
"wx44b039ae19434b36"
,
"1030a6aef6cfe8b5543e5e5ba043dca3"
,
jsCode
);
return
ResponseEntity
.
ok
(
authCodeSession
);
}
}
vms-wechat/src/main/java/com/zjty/vms/wechat/subject/entity/AuthCodeSession.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
subject
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.zjty.vms.misc.config.AutoDocument
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@AutoDocument
@ApiModel
(
value
=
"登陆返回对象"
,
description
=
"登陆返回对象"
)
public
class
AuthCodeSession
{
@JsonIgnoreProperties
(
"openid"
)
@ApiModelProperty
(
value
=
"小程序用户唯一标识,人员主键id"
,
example
=
"asdasd"
)
private
String
openId
;
@JsonIgnoreProperties
(
"session_key"
)
private
String
sessionKey
;
@JsonIgnoreProperties
(
"unionid"
)
private
String
unionId
;
@JsonIgnoreProperties
(
"errcode"
)
private
Integer
errCode
;
@JsonIgnoreProperties
(
"errmsg"
)
private
String
errMsg
;
}
vms-wechat/src/main/java/com/zjty/vms/wechat/subject/entity/WeChatApiUrl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
subject
.
entity
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
public
interface
WeChatApiUrl
{
String
AUTH_CODE_SESSION
=
"https://api.weixin.qq.com/sns/jscode2session?"
+
"appid={appid}&secret={secret}&js_code={js_code}&grant_type={grant_type}"
;
String
GET_ACCESS_TOKEN
=
"https://api.weixin.qq.com/cgi-bin/token"
+
"?grant_type={grant_type}&appid={appid}&secret={secret}"
;
}
vms-wechat/src/main/java/com/zjty/vms/wechat/subject/service/WeChatApiService.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
subject
.
service
;
import
com.zjty.vms.wechat.subject.entity.AccessToken
;
import
com.zjty.vms.wechat.subject.entity.AuthCodeSession
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
public
interface
WeChatApiService
{
/**
* 登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。
*
* @param appId 小程序 appId
* @param secret 小程序 appSecret
* @param jsCode 登录时获取的 code
* @return obj
*/
AuthCodeSession
getAuthSession
(
String
appId
,
String
secret
,
String
jsCode
);
AccessToken
getAccessToken
(
String
appId
,
String
secret
);
}
vms-wechat/src/main/java/com/zjty/vms/wechat/subject/service/impl/WeChatApiServiceImpl.java
deleted
100644 → 0
浏览文件 @
4d6bead1
package
com
.
zjty
.
vms
.
wechat
.
subject
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.zjty.vms.wechat.subject.entity.AccessToken
;
import
com.zjty.vms.wechat.subject.entity.AuthCodeSession
;
import
com.zjty.vms.wechat.subject.entity.WeChatApiUrl
;
import
com.zjty.vms.wechat.subject.service.WeChatApiService
;
import
com.zjty.vms.wechat.config.WxMappingJackson2HttpMessageConverter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author LJJ cnljj1995@gmail.com
* on 2020-05-29
*/
@Service
@Slf4j
public
class
WeChatApiServiceImpl
implements
WeChatApiService
{
@Override
public
AuthCodeSession
getAuthSession
(
String
appId
,
String
secret
,
String
jsCode
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
restTemplate
.
getMessageConverters
().
add
(
new
WxMappingJackson2HttpMessageConverter
());
Map
<
String
,
String
>
pram
=
new
HashMap
();
pram
.
put
(
"appid"
,
appId
);
pram
.
put
(
"secret"
,
secret
);
pram
.
put
(
"js_code"
,
jsCode
);
pram
.
put
(
"grant_type"
,
"authorization_code"
);
String
entity
=
restTemplate
.
getForObject
(
WeChatApiUrl
.
AUTH_CODE_SESSION
,
String
.
class
,
pram
);
AuthCodeSession
authCodeSession
=
JSONObject
.
parseObject
(
entity
,
new
TypeReference
<
AuthCodeSession
>()
{
});
System
.
out
.
println
(
authCodeSession
.
toString
());
return
authCodeSession
;
}
@Override
public
AccessToken
getAccessToken
(
String
appId
,
String
secret
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
restTemplate
.
getMessageConverters
().
add
(
new
WxMappingJackson2HttpMessageConverter
());
Map
<
String
,
String
>
pram
=
new
HashMap
();
pram
.
put
(
"grant_type"
,
"client_credential"
);
pram
.
put
(
"appid"
,
appId
);
pram
.
put
(
"secret"
,
secret
);
AccessToken
entity
=
restTemplate
.
getForObject
(
WeChatApiUrl
.
GET_ACCESS_TOKEN
,
AccessToken
.
class
,
pram
);
System
.
out
.
println
(
entity
.
toString
());
return
entity
;
}
public
static
void
main
(
String
[]
args
)
{
WeChatApiServiceImpl
weChatApiService
=
new
WeChatApiServiceImpl
();
// weChatApiService.getAuthSession("wx44b039ae19434b36",
// "1030a6aef6cfe8b5543e5e5ba043dca3", "033qqa8b2PzIuL0Rf77b2lly8b2qqa8c");
weChatApiService
.
getAccessToken
(
"wx44b039ae19434b36"
,
"1030a6aef6cfe8b5543e5e5ba043dca3"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论