Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
01cfceda
提交
01cfceda
authored
4月 24, 2022
作者:
17607474349
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:
1、部门相关api 2、用户相关api
上级
d2e161e4
显示空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
300 行增加
和
67 行删除
+300
-67
LocationTag.java
...main/java/com/yiring/app/domain/location/LocationTag.java
+0
-10
LocationTagExportExcel.java
...com/yiring/app/excel/location/LocationTagExportExcel.java
+2
-0
LocationTagImportExcel.java
...com/yiring/app/excel/location/LocationTagImportExcel.java
+2
-0
UserExportExcel.java
.../main/java/com/yiring/app/excel/user/UserExportExcel.java
+49
-0
DepartmentAddParam.java
...in/java/com/yiring/app/param/dept/DepartmentAddParam.java
+2
-2
LocationTagAddParam.java
...va/com/yiring/app/param/location/LocationTagAddParam.java
+3
-0
LocationTagModifyParam.java
...com/yiring/app/param/location/LocationTagModifyParam.java
+3
-0
ZyLocationTagAddParam.java
...m/yiring/app/param/location/zy/ZyLocationTagAddParam.java
+2
-0
PostParam.java
app/src/main/java/com/yiring/app/param/post/PostParam.java
+2
-0
DepartmentService.java
...n/java/com/yiring/app/service/dept/DepartmentService.java
+14
-0
DepartmentServiceImpl.java
...m/yiring/app/service/dept/impl/DepartmentServiceImpl.java
+29
-1
LocationTagService.java
...a/com/yiring/app/service/location/LocationTagService.java
+3
-1
LocationTagServiceImpl.java
...ing/app/service/location/impl/LocationTagServiceImpl.java
+20
-1
PostService.java
...rc/main/java/com/yiring/app/service/post/PostService.java
+6
-0
PostServiceImpl.java
...ava/com/yiring/app/service/post/impl/PostServiceImpl.java
+8
-0
UserService.java
...rc/main/java/com/yiring/app/service/user/UserService.java
+16
-2
UserServiceImpl.java
...ava/com/yiring/app/service/user/impl/UserServiceImpl.java
+101
-42
DepartmentController.java
...in/java/com/yiring/app/web/dept/DepartmentController.java
+13
-4
LocationTagController.java
...om/yiring/app/web/location/tag/LocationTagController.java
+6
-4
PostController.java
...src/main/java/com/yiring/app/web/post/PostController.java
+6
-0
UserAppController.java
.../main/java/com/yiring/app/web/user/UserAppController.java
+13
-0
没有找到文件。
app/src/main/java/com/yiring/app/domain/location/LocationTag.java
浏览文件 @
01cfceda
...
...
@@ -6,12 +6,10 @@ import com.yiring.common.annotation.FieldMapping;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.Objects
;
import
javax.persistence.*
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
org.hibernate.Hibernate
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.snowflake.SnowflakeId
;
...
...
@@ -129,14 +127,6 @@ public class LocationTag implements Serializable {
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
Hibernate
.
getClass
(
this
)
!=
Hibernate
.
getClass
(
o
))
return
false
;
LocationTag
that
=
(
LocationTag
)
o
;
return
id
!=
null
&&
Objects
.
equals
(
id
,
that
.
id
);
}
@Override
public
int
hashCode
()
{
return
getClass
().
hashCode
();
}
...
...
app/src/main/java/com/yiring/app/excel/location/LocationTagExportExcel.java
浏览文件 @
01cfceda
...
...
@@ -5,6 +5,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import
com.github.liaochong.myexcel.core.annotation.ExcelColumn
;
import
com.github.liaochong.myexcel.core.annotation.ExcelModel
;
import
com.yiring.app.domain.location.LocationTag
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -25,6 +26,7 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
LocationTagExportExcel
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
4549580878785078998L
;
/* @ExcelColumn(title = "主键")
...
...
app/src/main/java/com/yiring/app/excel/location/LocationTagImportExcel.java
浏览文件 @
01cfceda
...
...
@@ -3,6 +3,7 @@ package com.yiring.app.excel.location;
import
com.github.liaochong.myexcel.core.annotation.ExcelColumn
;
import
com.yiring.app.domain.location.LocationTag
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
lombok.*
;
...
...
@@ -20,6 +21,7 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
LocationTagImportExcel
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
8817732062049005201L
;
// 编号
...
...
app/src/main/java/com/yiring/app/excel/user/UserExportExcel.java
0 → 100644
浏览文件 @
01cfceda
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
excel
.
user
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.github.liaochong.myexcel.core.annotation.ExcelColumn
;
import
com.yiring.app.vo.user.UserVo
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* 部门信息控制器
*
* @author LJ-2204
* @date 2022/4/24
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
UserExportExcel
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
7104402721241163991L
;
@ExcelColumn
(
title
=
"真实姓名"
)
String
realName
;
@ExcelColumn
(
title
=
"创建时间"
)
String
createTime
;
public
static
List
<
UserExportExcel
>
transforms
(
List
<
UserVo
>
userVos
)
{
return
userVos
.
stream
()
.
map
(
userVo
->
UserExportExcel
.
builder
()
.
realName
(
userVo
.
getRealName
())
.
createTime
(
LocalDateTimeUtil
.
format
(
userVo
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
))
.
build
()
)
.
collect
(
Collectors
.
toList
());
}
}
app/src/main/java/com/yiring/app/param/dept/DepartmentAddParam.java
浏览文件 @
01cfceda
...
...
@@ -29,11 +29,11 @@ public class DepartmentAddParam implements Serializable {
@Serial
private
static
final
long
serialVersionUID
=
-
9143398676976586072L
;
@ApiModelProperty
(
value
=
"上级部门"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"上级部门"
,
example
=
"1"
,
required
=
true
)
@NotNull
Long
pid
;
@ApiModelProperty
(
value
=
"名称"
,
example
=
"Java"
)
@ApiModelProperty
(
value
=
"名称"
,
example
=
"Java"
,
required
=
true
)
@NotNull
String
name
;
...
...
app/src/main/java/com/yiring/app/param/location/LocationTagAddParam.java
浏览文件 @
01cfceda
...
...
@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
javax.validation.constraints.NotNull
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
...
...
@@ -28,9 +29,11 @@ public class LocationTagAddParam implements Serializable {
private
static
final
long
serialVersionUID
=
-
2942040230386389302L
;
@ApiModelProperty
(
value
=
"编号"
,
example
=
"BTT88888888"
,
required
=
true
)
@NotNull
String
code
;
@ApiModelProperty
(
value
=
"标签类型"
,
example
=
"蓝牙人员定位卡"
,
required
=
true
)
@NotNull
LocationTag
.
Type
type
;
@ApiModelProperty
(
value
=
"imei 设备编码标识"
,
example
=
"88888888"
)
...
...
app/src/main/java/com/yiring/app/param/location/LocationTagModifyParam.java
浏览文件 @
01cfceda
...
...
@@ -26,6 +26,9 @@ public class LocationTagModifyParam implements Serializable {
@Serial
private
static
final
long
serialVersionUID
=
7711908393372149723L
;
@ApiModelProperty
(
value
=
"id"
,
example
=
"7777777"
,
required
=
true
)
Long
id
;
@ApiModelProperty
(
value
=
"编号"
,
example
=
"BTT88888888"
,
required
=
true
)
String
code
;
...
...
app/src/main/java/com/yiring/app/param/location/zy/ZyLocationTagAddParam.java
浏览文件 @
01cfceda
...
...
@@ -6,6 +6,7 @@ import com.yiring.app.domain.location.LocationTag;
import
com.yiring.app.excel.location.LocationTagImportExcel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -26,6 +27,7 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
ZyLocationTagAddParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
8828137320896062620L
;
@ApiModelProperty
(
value
=
"工厂"
,
example
=
"100"
)
...
...
app/src/main/java/com/yiring/app/param/post/PostParam.java
浏览文件 @
01cfceda
...
...
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
javax.validation.constraints.NotNull
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
...
...
@@ -27,6 +28,7 @@ public class PostParam implements Serializable {
private
static
final
long
serialVersionUID
=
5247408856592333466L
;
@ApiModelProperty
(
value
=
"名称"
,
example
=
"Java"
,
required
=
true
)
@NotNull
String
name
;
@ApiModelProperty
(
value
=
"描述"
,
example
=
"描述"
,
required
=
true
)
...
...
app/src/main/java/com/yiring/app/service/dept/DepartmentService.java
浏览文件 @
01cfceda
...
...
@@ -43,4 +43,18 @@ public interface DepartmentService {
* @param response HttpServletResponse
*/
void
exportDepartment
(
DepartmentFindParam
param
,
HttpServletResponse
response
);
/**
* 逻辑删除部门
* @param idParam IdParam
* @return Result<String>
*/
Result
<
String
>
deleteDepartment
(
IdParam
idParam
);
/**
* 启用/停用
* @param idParam IdParam
* @return Result<String>
*/
Result
<
String
>
stateDepartment
(
IdParam
idParam
);
}
app/src/main/java/com/yiring/app/service/dept/impl/DepartmentServiceImpl.java
浏览文件 @
01cfceda
...
...
@@ -48,9 +48,17 @@ public class DepartmentServiceImpl implements DepartmentService {
@Resource
ZyHttpService
zyHttpService
;
// todo
@Override
public
Result
<
String
>
addDepartment
(
DepartmentAddParam
param
)
{
// todo
long
pidExist
=
departmentRepository
.
count
(
Example
.
of
(
Department
.
builder
().
id
(
param
.
getPid
()).
build
()));
if
(
pidExist
==
0
)
return
Result
.
no
(
Status
.
BAD_REQUEST
,
"上级部门不存在"
);
long
exist
=
departmentRepository
.
count
(
Example
.
of
(
Department
.
builder
().
name
(
param
.
getName
()).
pid
(
param
.
getPid
()).
build
())
);
if
(
exist
>
0
)
return
Result
.
no
(
Status
.
BAD_REQUEST
,
"同级目录下,已存在该部门"
);
Department
department
=
param
.
transform
();
departmentRepository
.
save
(
department
);
return
Result
.
ok
();
...
...
@@ -122,6 +130,26 @@ public class DepartmentServiceImpl implements DepartmentService {
}
}
@Override
public
Result
<
String
>
deleteDepartment
(
IdParam
idParam
)
{
departmentRepository
.
deleteById
(
idParam
.
getId
());
return
Result
.
ok
();
}
@Override
public
Result
<
String
>
stateDepartment
(
IdParam
idParam
)
{
Optional
<
Department
>
departmentOptional
=
departmentRepository
.
findOne
(
Example
.
of
(
Department
.
builder
().
id
(
idParam
.
getId
()).
build
())
);
if
(
departmentOptional
.
isEmpty
())
return
Result
.
no
(
Status
.
BAD_REQUEST
);
Department
department
=
departmentOptional
.
get
();
department
.
setEnable
(!
department
.
getEnable
());
departmentRepository
.
save
(
department
);
return
Result
.
ok
();
}
public
List
<
DepartmentVo
>
getChildrenList
(
Long
pid
,
String
pName
,
List
<
DepartmentVo
>
departmentVos
)
{
return
departmentVos
.
stream
()
...
...
app/src/main/java/com/yiring/app/service/location/LocationTagService.java
浏览文件 @
01cfceda
...
...
@@ -4,6 +4,7 @@ package com.yiring.app.service.location;
import
com.yiring.app.param.location.LocationTagAddParam
;
import
com.yiring.app.param.location.LocationTagDeleteParam
;
import
com.yiring.app.param.location.LocationTagFindParam
;
import
com.yiring.app.param.location.LocationTagModifyParam
;
import
com.yiring.app.vo.location.LocationTagVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.PageParam
;
...
...
@@ -51,10 +52,11 @@ public interface LocationTagService {
* @return Result<String>
*/
Result
<
String
>
importLocationTagInfo
(
MultipartFile
file
);
/**
* 修改定位标签
* @param param 入参
* @return Result<String>
*/
// Result<String> modifyLocationTag(LocationTagModifyParam param, IdParam idP
aram);
Result
<
String
>
modifyLocationTag
(
LocationTagModifyParam
p
aram
);
}
app/src/main/java/com/yiring/app/service/location/impl/LocationTagServiceImpl.java
浏览文件 @
01cfceda
...
...
@@ -14,6 +14,7 @@ import com.yiring.app.excel.location.LocationTagImportExcel;
import
com.yiring.app.param.location.LocationTagAddParam
;
import
com.yiring.app.param.location.LocationTagDeleteParam
;
import
com.yiring.app.param.location.LocationTagFindParam
;
import
com.yiring.app.param.location.LocationTagModifyParam
;
import
com.yiring.app.param.location.zy.ZyLocationTagAddParam
;
import
com.yiring.app.service.location.LocationTagService
;
import
com.yiring.app.service.zy.ZyHttpService
;
...
...
@@ -84,7 +85,7 @@ public class LocationTagServiceImpl implements LocationTagService {
Pageable
pageable
=
PageRequest
.
of
(
pageParam
.
getPageNo
()
-
1
,
pageParam
.
getPageSize
());
Page
<
LocationTag
>
locationTags
=
locationTagRepository
.
findAll
(
specification
,
pageable
);
List
<
LocationTagVo
>
locationTagVos
=
LocationTagVo
.
transforms
(
locationTags
.
getContent
());
PageVo
<
LocationTagVo
>
page
=
PageVo
.
build
(
locationTagVos
,
locationTag
Vos
.
size
());
PageVo
<
LocationTagVo
>
page
=
PageVo
.
build
(
locationTagVos
,
locationTag
s
.
getTotalElements
());
return
Result
.
ok
(
page
);
}
else
{
List
<
LocationTag
>
locationTags
=
locationTagRepository
.
findAll
(
specification
,
sort
);
...
...
@@ -174,6 +175,24 @@ public class LocationTagServiceImpl implements LocationTagService {
return
Result
.
ok
();
}
@Override
public
Result
<
String
>
modifyLocationTag
(
LocationTagModifyParam
param
)
{
Optional
<
LocationTag
>
locationTagOptional
=
locationTagRepository
.
findById
(
param
.
getId
());
if
(
locationTagOptional
.
isEmpty
())
return
Result
.
no
(
Status
.
BAD_REQUEST
,
"被修改的数据不存在"
);
LocationTag
locationTag
=
locationTagOptional
.
get
();
if
(!
StrUtil
.
equals
(
locationTag
.
getCode
(),
param
.
getCode
()))
{
if
(
hasLocationTagInfoByCode
(
param
.
getCode
()))
return
Result
.
no
(
Status
.
BAD_REQUEST
,
"编号已存在"
);
}
locationTag
=
param
.
transform
();
locationTag
.
setId
(
param
.
getId
());
locationTagRepository
.
save
(
locationTag
);
return
Result
.
ok
();
}
private
boolean
hasLocationTagInfoByCode
(
String
code
)
{
LocationTag
locationTag
=
LocationTag
.
builder
().
code
(
code
).
build
();
return
locationTagRepository
.
count
(
Example
.
of
(
locationTag
))
>
0
;
...
...
app/src/main/java/com/yiring/app/service/post/PostService.java
浏览文件 @
01cfceda
...
...
@@ -65,4 +65,10 @@ public interface PostService {
* @param response 响应信息
*/
void
exportPostInfo
(
PostFindParam
param
,
HttpServletResponse
response
);
/**
* 下拉菜单
* @return Result<PageVo<PostVo>>
*/
Result
<
PageVo
<
PostVo
>>
selectPost
();
}
app/src/main/java/com/yiring/app/service/post/impl/PostServiceImpl.java
浏览文件 @
01cfceda
...
...
@@ -153,6 +153,14 @@ public class PostServiceImpl implements PostService {
}
}
@Override
public
Result
<
PageVo
<
PostVo
>>
selectPost
()
{
List
<
Post
>
posts
=
postRepository
.
findAll
();
List
<
PostVo
>
postVos
=
PostVo
.
transforms
(
posts
);
PageVo
<
PostVo
>
pageVo
=
PageVo
.
build
(
postVos
,
postVos
.
size
());
return
Result
.
ok
(
pageVo
);
}
private
Specification
<
Post
>
getPostPageSpecification
(
PostFindParam
param
)
{
return
(
root
,
cq
,
cb
)
->
{
List
<
Predicate
>
predicates
=
ListUtil
.
toList
();
...
...
app/src/main/java/com/yiring/app/service/user/UserService.java
浏览文件 @
01cfceda
...
...
@@ -8,6 +8,7 @@ import com.yiring.common.core.Result;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
javax.servlet.http.HttpServletResponse
;
/**
* 用户
...
...
@@ -46,8 +47,21 @@ public interface UserService {
/**
* 删除用户
* @param idParam
* @return
* @param idParam
IdParam
* @return
Result<String>
*/
Result
<
String
>
deleteUser
(
IdParam
idParam
);
/**
* 下拉菜单
* @return Result<PageVo<UserVo>>
*/
Result
<
PageVo
<
UserVo
>>
selectUser
();
/**
* 导出用户
* @param param UserFindParam
* @param response HttpServletResponse
*/
void
exportUser
(
UserFindParam
param
,
HttpServletResponse
response
);
}
app/src/main/java/com/yiring/app/service/user/impl/UserServiceImpl.java
浏览文件 @
01cfceda
...
...
@@ -4,8 +4,10 @@ package com.yiring.app.service.user.impl;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder
;
import
com.yiring.app.domain.location.LocationTag
;
import
com.yiring.app.domain.location.LocationTagRepository
;
import
com.yiring.app.excel.user.UserExportExcel
;
import
com.yiring.app.param.user.UserBingTagParam
;
import
com.yiring.app.param.user.UserFindParam
;
import
com.yiring.app.service.user.UserService
;
...
...
@@ -21,12 +23,19 @@ import com.yiring.common.domain.BasicEntity;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.Executors
;
import
javax.annotation.Resource
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.*
;
import
javax.servlet.http.HttpServletResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.jetbrains.annotations.NotNull
;
import
org.springframework.data.domain.Example
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -56,48 +65,7 @@ public class UserServiceImpl implements UserService {
@Override
public
Result
<
PageVo
<
UserVo
>>
findUserPage
(
UserFindParam
param
,
PageParam
pageParam
)
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
UserVo
>
cq
=
cb
.
createQuery
(
UserVo
.
class
);
Root
<
User
>
root
=
cq
.
from
(
User
.
class
);
Expression
<
String
>
realName
=
root
.
get
(
User
.
Fields
.
realName
);
Expression
<
String
>
uuid
=
root
.
get
(
User
.
Fields
.
uuid
);
Expression
<
User
.
Type
>
type
=
root
.
get
(
User
.
Fields
.
type
);
Expression
<
Department
>
department
=
root
.
get
(
User
.
Fields
.
department
).
get
(
"name"
);
Expression
<
String
>
mobile
=
root
.
get
(
User
.
Fields
.
mobile
);
Expression
<
Post
>
post
=
root
.
get
(
User
.
Fields
.
post
).
get
(
"name"
);
Subquery
<
String
>
query
=
cq
.
subquery
(
String
.
class
);
Root
<
LocationTag
>
tagRoot
=
query
.
from
(
LocationTag
.
class
);
query
.
select
(
tagRoot
.
get
(
LocationTag
.
Fields
.
code
));
query
.
where
(
cb
.
equal
(
tagRoot
.
get
(
LocationTag
.
Fields
.
user
),
root
));
cq
.
multiselect
(
realName
,
uuid
,
type
,
department
,
mobile
,
post
,
query
);
List
<
Predicate
>
predicates
=
ListUtil
.
toList
();
if
(
StrUtil
.
isNotEmpty
(
param
.
getRealName
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
User
.
Fields
.
realName
),
"%"
+
param
.
getRealName
()
+
"%"
));
}
if
(
StrUtil
.
isNotEmpty
(
param
.
getCode
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
LocationTag
.
Fields
.
code
),
"%"
+
param
.
getCode
()
+
"%"
));
}
if
(
StrUtil
.
isNotEmpty
(
param
.
getUuid
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
User
.
Fields
.
uuid
),
"%"
+
param
.
getUuid
()
+
"%"
));
}
if
(
StrUtil
.
isNotEmpty
(
param
.
getMobile
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
User
.
Fields
.
mobile
),
"%"
+
param
.
getMobile
()
+
"%"
));
}
if
(
ObjectUtil
.
isNotEmpty
(
param
.
getDeptId
()))
{
predicates
.
add
(
cb
.
equal
(
root
.
get
(
User
.
Fields
.
department
).
get
(
"id"
),
param
.
getDeptId
()));
}
Order
order
=
cb
.
desc
(
root
.
get
(
BasicEntity
.
Fields
.
createTime
));
cq
.
orderBy
(
order
).
where
(
predicates
.
toArray
(
new
Predicate
[
0
])).
getRestriction
();
CriteriaQuery
<
UserVo
>
cq
=
getUserVoCriteriaQuery
(
param
);
if
(
ObjectUtil
.
isNotEmpty
(
pageParam
.
getPageNo
())
||
ObjectUtil
.
isNotEmpty
(
pageParam
.
getPageSize
()))
{
List
<
UserVo
>
userVos
=
em
...
...
@@ -168,4 +136,95 @@ public class UserServiceImpl implements UserService {
userRepository
.
deleteById
(
idParam
.
getId
());
return
Result
.
ok
();
}
@Override
public
Result
<
PageVo
<
UserVo
>>
selectUser
()
{
List
<
User
>
users
=
userRepository
.
findAll
();
List
<
UserVo
>
userVos
=
UserVo
.
transforms
(
users
);
PageVo
<
UserVo
>
pageVo
=
PageVo
.
build
(
userVos
,
userVos
.
size
());
return
Result
.
ok
(
pageVo
);
}
@Override
public
void
exportUser
(
UserFindParam
param
,
HttpServletResponse
response
)
{
CriteriaQuery
<
UserVo
>
cq
=
getUserVoCriteriaQuery
(
param
);
List
<
UserVo
>
userVos
=
em
.
createQuery
(
cq
).
getResultList
();
List
<
UserExportExcel
>
userExportExcels
=
UserExportExcel
.
transforms
(
userVos
);
try
(
DefaultStreamExcelBuilder
<
UserExportExcel
>
streamExcelBuilder
=
DefaultStreamExcelBuilder
.
of
(
UserExportExcel
.
class
)
.
threadPool
(
Executors
.
newFixedThreadPool
(
2
))
.
rowHeight
(
14
)
.
titleRowHeight
(
14
)
.
style
(
"cell->vertical-align:center;text-align:center"
,
"title->vertical-align:center;text-align:center;font-weight:bold;font-family:等线"
)
.
start
()
)
{
streamExcelBuilder
.
append
(
userExportExcels
);
String
fileName
=
URLEncoder
.
encode
(
"用户信息.xlsx"
,
StandardCharsets
.
UTF_8
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
);
OutputStream
out
=
response
.
getOutputStream
();
Workbook
workbook
=
streamExcelBuilder
.
fixedTitles
().
build
();
workbook
.
write
(
out
);
workbook
.
close
();
out
.
flush
();
out
.
close
();
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
"用户信息导出失败: "
+
e
.
getMessage
());
}
}
@NotNull
private
CriteriaQuery
<
UserVo
>
getUserVoCriteriaQuery
(
UserFindParam
param
)
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
UserVo
>
cq
=
cb
.
createQuery
(
UserVo
.
class
);
Root
<
User
>
root
=
cq
.
from
(
User
.
class
);
Expression
<
String
>
realName
=
root
.
get
(
User
.
Fields
.
realName
);
Expression
<
String
>
uuid
=
root
.
get
(
User
.
Fields
.
uuid
);
Expression
<
User
.
Type
>
type
=
root
.
get
(
User
.
Fields
.
type
);
Expression
<
Department
>
department
=
root
.
get
(
User
.
Fields
.
department
).
get
(
"name"
);
Expression
<
String
>
mobile
=
root
.
get
(
User
.
Fields
.
mobile
);
Expression
<
Post
>
post
=
root
.
get
(
User
.
Fields
.
post
).
get
(
"name"
);
Subquery
<
String
>
query
=
cq
.
subquery
(
String
.
class
);
Root
<
LocationTag
>
tagRoot
=
query
.
from
(
LocationTag
.
class
);
query
.
select
(
tagRoot
.
get
(
LocationTag
.
Fields
.
code
));
query
.
where
(
cb
.
equal
(
tagRoot
.
get
(
LocationTag
.
Fields
.
user
),
root
));
cq
.
multiselect
(
realName
,
uuid
,
type
,
department
,
mobile
,
post
,
query
);
List
<
Predicate
>
predicates
=
ListUtil
.
toList
();
if
(
StrUtil
.
isNotEmpty
(
param
.
getRealName
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
User
.
Fields
.
realName
),
"%"
+
param
.
getRealName
()
+
"%"
));
}
if
(
StrUtil
.
isNotEmpty
(
param
.
getCode
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
LocationTag
.
Fields
.
code
),
"%"
+
param
.
getCode
()
+
"%"
));
}
if
(
StrUtil
.
isNotEmpty
(
param
.
getUuid
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
User
.
Fields
.
uuid
),
"%"
+
param
.
getUuid
()
+
"%"
));
}
if
(
StrUtil
.
isNotEmpty
(
param
.
getMobile
()))
{
predicates
.
add
(
cb
.
like
(
root
.
get
(
User
.
Fields
.
mobile
),
"%"
+
param
.
getMobile
()
+
"%"
));
}
if
(
ObjectUtil
.
isNotEmpty
(
param
.
getDeptId
()))
{
predicates
.
add
(
cb
.
equal
(
root
.
get
(
User
.
Fields
.
department
).
get
(
"id"
),
param
.
getDeptId
()));
}
Order
order
=
cb
.
desc
(
root
.
get
(
BasicEntity
.
Fields
.
createTime
));
cq
.
orderBy
(
order
).
where
(
predicates
.
toArray
(
new
Predicate
[
0
])).
getRestriction
();
return
cq
;
}
}
app/src/main/java/com/yiring/app/web/dept/DepartmentController.java
浏览文件 @
01cfceda
...
...
@@ -16,10 +16,7 @@ import javax.servlet.http.HttpServletResponse;
import
javax.validation.Valid
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
/**
* 部门信息控制器
...
...
@@ -60,4 +57,16 @@ public class DepartmentController {
public
void
exportDepartment
(
@Valid
DepartmentFindParam
param
,
HttpServletResponse
response
)
{
departmentService
.
exportDepartment
(
param
,
response
);
}
@ApiOperation
(
"逻辑删除部门"
)
@DeleteMapping
(
"deleteDepartment"
)
public
Result
<
String
>
deleteDepartment
(
@Valid
IdParam
idParam
)
{
return
departmentService
.
deleteDepartment
(
idParam
);
}
@ApiOperation
(
"启用/停用"
)
@PutMapping
(
"stateDepartment"
)
public
Result
<
String
>
stateDepartment
(
@Valid
IdParam
idParam
)
{
return
departmentService
.
stateDepartment
(
idParam
);
}
}
app/src/main/java/com/yiring/app/web/location/tag/LocationTagController.java
浏览文件 @
01cfceda
...
...
@@ -4,6 +4,7 @@ package com.yiring.app.web.location.tag;
import
com.yiring.app.param.location.LocationTagAddParam
;
import
com.yiring.app.param.location.LocationTagDeleteParam
;
import
com.yiring.app.param.location.LocationTagFindParam
;
import
com.yiring.app.param.location.LocationTagModifyParam
;
import
com.yiring.app.service.location.LocationTagService
;
import
com.yiring.app.vo.location.LocationTagVo
;
import
com.yiring.common.core.Result
;
...
...
@@ -64,9 +65,10 @@ public class LocationTagController {
public
Result
<
String
>
importLocationTagInfo
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
return
locationTagService
.
importLocationTagInfo
(
file
);
}
/* @ApiOperation("修改定位标签")
@ApiOperation
(
"修改定位标签"
)
@PutMapping
(
"modifyLocationTag"
)
public Result<String> modifyLocationTag(@Valid LocationTagModifyParam param
, IdParam idParam
) {
return locationTagService.modifyLocationTag(param
, idParam
);
}
*/
public
Result
<
String
>
modifyLocationTag
(
@Valid
LocationTagModifyParam
param
)
{
return
locationTagService
.
modifyLocationTag
(
param
);
}
}
app/src/main/java/com/yiring/app/web/post/PostController.java
浏览文件 @
01cfceda
...
...
@@ -69,4 +69,10 @@ public class PostController {
public
void
exportPostInfo
(
@Valid
PostFindParam
param
,
HttpServletResponse
response
)
{
postService
.
exportPostInfo
(
param
,
response
);
}
@ApiOperation
(
value
=
"下拉菜单"
)
@GetMapping
(
"selectPost"
)
public
Result
<
PageVo
<
PostVo
>>
selectPost
()
{
return
postService
.
selectPost
();
}
}
app/src/main/java/com/yiring/app/web/user/UserAppController.java
浏览文件 @
01cfceda
...
...
@@ -12,6 +12,7 @@ import com.yiring.common.vo.PageVo;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -64,4 +65,16 @@ public class UserAppController {
public
Result
<
String
>
deleteUser
(
@Valid
IdParam
idParam
)
{
return
userService
.
deleteUser
(
idParam
);
}
@ApiOperation
(
"下拉菜单"
)
@GetMapping
(
"selectUser"
)
public
Result
<
PageVo
<
UserVo
>>
selectUser
()
{
return
userService
.
selectUser
();
}
@ApiOperation
(
"用户导出"
)
@GetMapping
(
"exportUser"
)
public
void
exportUser
(
@Valid
UserFindParam
param
,
HttpServletResponse
response
)
{
userService
.
exportUser
(
param
,
response
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论