Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
10c9ab50
Y
youlai-mall
项目概览
有来技术
/
youlai-mall
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
youlai-mall
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
10c9ab50
编写于
1月 05, 2022
作者:
郝
郝先瑞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 商品分页参数调整
上级
0f9ffc89
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
40 deletion
+41
-40
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/GoodsController.java
...com/youlai/mall/pms/controller/admin/GoodsController.java
+19
-14
youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java
.../src/main/java/com/youlai/admin/mapper/SysUserMapper.java
+1
-1
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java
...lai/common/mybatis/handler/DataPermissionHandlerImpl.java
+20
-23
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java
.../com/youlai/common/mybatis/handler/InterceptorIgnore.java
+1
-2
未找到文件。
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/GoodsController.java
浏览文件 @
10c9ab50
...
...
@@ -32,8 +32,8 @@ public class GoodsController {
@ApiOperation
(
value
=
"商品分页列表"
)
@GetMapping
(
"/page"
)
public
Result
list
(
@ApiParam
(
"页码
"
)
long
pageNum
,
@ApiParam
(
"每页数量
"
)
long
pageSize
,
@ApiParam
(
value
=
"页码"
,
example
=
"1
"
)
long
pageNum
,
@ApiParam
(
value
=
"每页数量"
,
example
=
"10
"
)
long
pageSize
,
@ApiParam
(
"商品分类ID"
)
Long
categoryId
,
@ApiParam
(
"商品名称"
)
String
name
)
{
...
...
@@ -44,42 +44,47 @@ public class GoodsController {
@ApiOperation
(
value
=
"商品详情"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}"
)
public
Result
detail
(
@PathVariable
Long
id
)
{
public
Result
detail
(
@ApiParam
(
"商品ID"
)
@PathVariable
Long
id
)
{
GoodsDetailVO
goodsDetail
=
iPmsSpuService
.
getGoodsById
(
id
);
return
Result
.
success
(
goodsDetail
);
}
@ApiOperation
(
value
=
"新增商品"
)
@ApiImplicitParam
(
name
=
"goodsForm"
,
value
=
"实体JSON对象"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"GoodsFormDTO"
)
@PostMapping
public
Result
add
(
@RequestBody
GoodsFormDTO
goodsForm
)
{
public
Result
addGoods
(
@RequestBody
GoodsFormDTO
goodsForm
)
{
boolean
result
=
iPmsSpuService
.
addGoods
(
goodsForm
);
return
Result
.
judge
(
result
);
}
@ApiOperation
(
value
=
"修改商品"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@PutMapping
(
value
=
"/{id}"
)
public
Result
update
(
@PathVariable
Long
id
,
@RequestBody
GoodsFormDTO
goods
)
{
public
Result
update
(
@ApiParam
(
"商品ID"
)
@PathVariable
Long
id
,
@RequestBody
GoodsFormDTO
goods
)
{
boolean
result
=
iPmsSpuService
.
updateGoods
(
goods
);
return
Result
.
judge
(
result
);
}
@ApiOperation
(
value
=
"删除商品"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"id集合,以英文逗号','分隔"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"String"
)
@DeleteMapping
(
"/{ids}"
)
public
Result
delete
(
@PathVariable
String
ids
)
{
public
Result
delete
(
@ApiParam
(
"id集合,以英文逗号(,)分隔"
)
@PathVariable
String
ids
)
{
boolean
result
=
iPmsSpuService
.
removeByGoodsIds
(
Arrays
.
asList
(
ids
.
split
(
","
)).
stream
().
map
(
id
->
Long
.
parseLong
(
id
)).
collect
(
Collectors
.
toList
()));
return
Result
.
judge
(
result
);
}
@ApiOperation
(
value
=
"选择性修改商品"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品ID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"spu"
,
value
=
"实体JSON对象"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"PmsSpu"
)
})
@PatchMapping
(
value
=
"/{id}"
)
public
Result
patch
(
@PathVariable
Integer
id
,
@RequestBody
PmsSpu
spu
)
{
public
Result
patch
(
@ApiParam
(
"商品ID"
)
@PathVariable
Long
id
,
@RequestBody
PmsSpu
spu
)
{
LambdaUpdateWrapper
<
PmsSpu
>
updateWrapper
=
new
LambdaUpdateWrapper
<
PmsSpu
>().
eq
(
PmsSpu:
:
getId
,
id
);
updateWrapper
.
set
(
spu
.
getStatus
()
!=
null
,
PmsSpu:
:
getStatus
,
spu
.
getStatus
());
boolean
update
=
iPmsSpuService
.
update
(
updateWrapper
);
...
...
youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java
浏览文件 @
10c9ab50
...
...
@@ -12,7 +12,7 @@ import java.util.List;
@Mapper
public
interface
SysUserMapper
extends
BaseMapper
<
SysUser
>
{
@InterceptorIgnore
(
store
Alias
=
"d"
)
@InterceptorIgnore
(
dept
Alias
=
"d"
)
List
<
SysUser
>
list
(
Page
<
SysUser
>
page
,
SysUser
user
);
UserAuthDTO
getByUsername
(
String
username
);
...
...
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java
浏览文件 @
10c9ab50
...
...
@@ -38,11 +38,11 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
if
(
ObjectUtils
.
isNotEmpty
(
annotation
)
&&
(
method
.
getName
().
equals
(
methodName
)
||
(
method
.
getName
()
+
"_COUNT"
).
equals
(
methodName
)))
{
// 获取当前的用户角色
List
<
String
>
roles
=
JwtUtils
.
getRoles
();
if
(
!
roles
.
isEmpty
()
&&
roles
.
contains
(
GlobalConstants
.
ROOT_ROLE_CODE
))
{
if
(
!
roles
.
isEmpty
()
&&
roles
.
contains
(
GlobalConstants
.
ROOT_ROLE_CODE
))
{
// 如果是超级管理员则放行
return
where
;
}
else
{
return
dataScopeFilter
(
annotation
.
d
ataPermission
(),
annotation
.
store
Alias
(),
where
);
}
else
{
return
dataScopeFilter
(
annotation
.
d
ept
Alias
(),
where
);
}
}
}
...
...
@@ -58,33 +58,30 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
* @param where 当前查询条件
* @return 构建后查询条件
*/
public
static
Expression
dataScopeFilter
(
String
dataPermission
,
String
storeAlias
,
Expression
where
)
{
Expression
expression
=
null
;
if
(
dataPermission
.
equals
(
"1"
)){
return
where
;
}
else
{
EqualsTo
equalsTo
=
new
EqualsTo
(
new
Column
(
StrUtil
.
isEmpty
(
storeAlias
)?
"id"
:
storeAlias
+
".id"
),
getDeptId
());
expression
=
ObjectUtils
.
isNotEmpty
(
expression
)
?
new
AndExpression
(
expression
,
equalsTo
)
:
equalsTo
;
LikeExpression
likeExpression
=
new
LikeExpression
();
Function
left
=
new
Function
();
left
.
setName
(
"concat"
);
left
.
setParameters
(
new
ExpressionList
().
addExpressions
(
new
StringValue
(
","
),
new
Column
(
"tree_path"
),
new
StringValue
(
","
)));
likeExpression
.
setLeftExpression
(
left
);
Function
right
=
new
Function
();
right
.
setName
(
"concat"
);
right
.
setParameters
(
new
ExpressionList
().
addExpressions
(
new
StringValue
(
"%,"
),
getDeptId
(),
new
StringValue
(
"%,"
)));
likeExpression
.
setRightExpression
(
right
);
expression
=
ObjectUtils
.
isNotEmpty
(
expression
)
?
new
OrExpression
(
expression
,
likeExpression
)
:
expression
;
}
public
static
Expression
dataScopeFilter
(
String
deptAlias
,
Expression
where
)
{
Expression
expression
=
new
EqualsTo
(
new
Column
(
StrUtil
.
isEmpty
(
deptAlias
)
?
"id"
:
deptAlias
+
".id"
),
getDeptId
());
LikeExpression
likeExpression
=
new
LikeExpression
();
Function
left
=
new
Function
();
left
.
setName
(
"concat"
);
left
.
setParameters
(
new
ExpressionList
().
addExpressions
(
new
StringValue
(
","
),
new
Column
(
"tree_path"
),
new
StringValue
(
","
)));
likeExpression
.
setLeftExpression
(
left
);
Function
right
=
new
Function
();
right
.
setName
(
"concat"
);
right
.
setParameters
(
new
ExpressionList
().
addExpressions
(
new
StringValue
(
"%,"
),
getDeptId
(),
new
StringValue
(
"%,"
)));
likeExpression
.
setRightExpression
(
right
);
expression
=
ObjectUtils
.
isNotEmpty
(
expression
)
?
new
OrExpression
(
expression
,
likeExpression
)
:
expression
;
return
ObjectUtils
.
isNotEmpty
(
where
)
?
new
AndExpression
(
where
,
new
Parenthesis
(
expression
))
:
expression
;
}
/**
* 当前用户的部门id
*
* @return
*/
private
static
Expression
getDeptId
(){
return
new
LongValue
(
JwtUtils
.
getJwtPayload
().
getLong
(
"deptId"
));
private
static
Expression
getDeptId
()
{
LongValue
deptId
=
new
LongValue
(
JwtUtils
.
getJwtPayload
().
getLong
(
"deptId"
));
return
deptId
;
}
...
...
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java
浏览文件 @
10c9ab50
...
...
@@ -18,8 +18,7 @@ public @interface InterceptorIgnore {
* <p>
* 默认打开,需要注解关闭
*/
String
dataPermission
()
default
"0"
;
String
store
Alias
()
default
""
;
String
dept
Alias
()
default
""
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录