Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
07b6d961
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,发现更多精彩内容 >>
提交
07b6d961
编写于
12月 18, 2021
作者:
有
有来技术
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of gitee.com:youlaitech/youlai-mall into develop
上级
03bcb5a9
7bd16a9d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
87 addition
and
35 deletion
+87
-35
youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/UserController.java
...main/java/com/youlai/admin/controller/UserController.java
+2
-1
youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/V2UserController.java
...java/com/youlai/admin/controller/v2/V2UserController.java
+52
-0
youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java
.../src/main/java/com/youlai/admin/mapper/SysUserMapper.java
+2
-0
youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/entity/SysUser.java
...t/src/main/java/com/youlai/admin/pojo/entity/SysUser.java
+4
-0
youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysDeptServiceImpl.java
...ava/com/youlai/admin/service/impl/SysDeptServiceImpl.java
+3
-4
youlai-admin/admin-boot/src/main/resources/mapper/SysUserMapper.xml
...in/admin-boot/src/main/resources/mapper/SysUserMapper.xml
+17
-12
youlai-common/common-mybatis/pom.xml
youlai-common/common-mybatis/pom.xml
+1
-0
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java
...lai/common/mybatis/handler/DataPermissionHandlerImpl.java
+4
-18
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java
.../com/youlai/common/mybatis/handler/InterceptorIgnore.java
+2
-0
未找到文件。
youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/UserController.java
浏览文件 @
07b6d961
...
...
@@ -104,9 +104,10 @@ public class UserController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"用户ID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@PatchMapping
(
value
=
"/{id}"
)
public
Result
patch
(
@PathVariable
Long
id
,
@RequestBody
SysUser
user
)
{
System
.
out
.
println
(
user
.
getPassword
()
!=
null
);
LambdaUpdateWrapper
<
SysUser
>
updateWrapper
=
new
LambdaUpdateWrapper
<
SysUser
>().
eq
(
SysUser:
:
getId
,
id
);
updateWrapper
.
set
(
user
.
getStatus
()
!=
null
,
SysUser:
:
getStatus
,
user
.
getStatus
());
updateWrapper
.
set
(
user
.
getPassword
()
!=
null
,
SysUser:
:
getPassword
,
passwordEncoder
.
encode
(
user
.
getPassword
())
);
updateWrapper
.
set
(
user
.
getPassword
()
!=
null
,
SysUser:
:
getPassword
,
user
.
getPassword
()
!=
null
?
passwordEncoder
.
encode
(
user
.
getPassword
()):
null
);
boolean
status
=
iSysUserService
.
update
(
updateWrapper
);
return
Result
.
judge
(
status
);
}
...
...
youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/V2UserController.java
0 → 100644
浏览文件 @
07b6d961
package
com.youlai.admin.controller.v2
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.youlai.admin.pojo.entity.SysUser
;
import
com.youlai.admin.service.ISysPermissionService
;
import
com.youlai.admin.service.ISysUserRoleService
;
import
com.youlai.admin.service.ISysUserService
;
import
com.youlai.common.result.Result
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@Api
(
tags
=
"用户接口"
)
@RestController
@RequestMapping
(
"/api/v2/users"
)
@Slf4j
@RequiredArgsConstructor
public
class
V2UserController
{
private
final
ISysUserService
iSysUserService
;
@ApiOperation
(
value
=
"列表分页"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
paramType
=
"query"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"limit"
,
value
=
"每页数量"
,
paramType
=
"query"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"keywords"
,
value
=
"关键字"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"mobile"
,
value
=
"手机号码"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态"
,
paramType
=
"query"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"deptId"
,
value
=
"部门ID"
,
paramType
=
"query"
,
dataType
=
"Long"
),
})
@GetMapping
public
Result
list
(
Integer
page
,
Integer
limit
,
String
keywords
,
String
mobile
,
Integer
status
,
Long
deptId
)
{
SysUser
user
=
new
SysUser
();
user
.
setKeywords
(
keywords
);
user
.
setMobile
(
mobile
);
user
.
setStatus
(
status
);
user
.
setDeptId
(
deptId
);
IPage
<
SysUser
>
result
=
iSysUserService
.
list
(
new
Page
<>(
page
,
limit
),
user
);
return
Result
.
success
(
result
.
getRecords
(),
result
.
getTotal
());
}
}
youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java
浏览文件 @
07b6d961
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.youlai.admin.dto.UserAuthDTO
;
import
com.youlai.admin.pojo.entity.SysUser
;
import
com.youlai.common.mybatis.handler.InterceptorIgnore
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
...
...
@@ -11,6 +12,7 @@ import java.util.List;
@Mapper
public
interface
SysUserMapper
extends
BaseMapper
<
SysUser
>
{
@InterceptorIgnore
(
storeAlias
=
"d"
)
List
<
SysUser
>
list
(
Page
<
SysUser
>
page
,
SysUser
user
);
UserAuthDTO
getByUsername
(
String
username
);
...
...
youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/entity/SysUser.java
浏览文件 @
07b6d961
...
...
@@ -52,4 +52,8 @@ public class SysUser extends BaseEntity {
private
List
<
String
>
roles
;
@TableField
(
exist
=
false
)
private
String
keywords
;
}
youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysDeptServiceImpl.java
浏览文件 @
07b6d961
...
...
@@ -9,17 +9,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.youlai.admin.common.constant.SystemConstants
;
import
com.youlai.admin.mapper.SysDeptMapper
;
import
com.youlai.admin.pojo.entity.SysDept
;
import
com.youlai.admin.pojo.entity.SysUser
;
import
com.youlai.admin.pojo.vo.DeptVO
;
import
com.youlai.admin.pojo.vo.TreeSelectVO
;
import
com.youlai.admin.service.ISysDeptService
;
import
com.youlai.admin.service.ISysRolePermissionService
;
import
com.youlai.admin.service.ISysUserService
;
import
com.youlai.common.constant.GlobalConstants
;
import
com.youlai.common.web.util.JwtUtils
;
import
lombok.AllArgsConstructor
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.stream.Collectors
;
...
...
@@ -120,8 +119,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
.
eq
(
SysDept:
:
getStatus
,
GlobalConstants
.
STATUS_YES
)
.
orderByAsc
(
SysDept:
:
getSort
)
);
List
<
TreeSelectVO
>
deptSelectList
=
recursionTreeSelectList
(
JwtUtils
.
getJwtPayload
().
getLong
(
"deptId"
),
deptList
);
SysDept
sysDept
=
this
.
getById
(
JwtUtils
.
getJwtPayload
().
getLong
(
"deptId"
));
List
<
TreeSelectVO
>
deptSelectList
=
recursionTreeSelectList
(
sysDept
.
getParentId
(
),
deptList
);
return
deptSelectList
;
}
...
...
youlai-admin/admin-boot/src/main/resources/mapper/SysUserMapper.xml
浏览文件 @
07b6d961
...
...
@@ -25,7 +25,7 @@
<sql
id=
"Base_Column_List"
>
id
,username,nickname,
,username,nickname,
gender,password,dept_id,
avatar,mobile,status,
email,gmt_create,gmt_modified,
...
...
@@ -44,23 +44,23 @@
</resultMap>
<select
id=
"getByUsername"
resultMap=
"UserAuthMap"
>
select t1.id userId, t1.username, t1.nickname, t1.password, t1.status, t1.dept_id deptId,t3.code roleCode
from sys_user t1,
sys_user_role t2,
sys_role t3
where t1.username = #{username}
and t1.deleted = 0
and t1.id = t2.user_id
and t2.role_id = t3.id
select t1.id userId, t1.username, t1.nickname, t1.password, t1.status, t1.dept_id deptId,
t3.code roleCode
from sys_user t1,
sys_user_role t2,
sys_role t3
where t1.username = #{username}
and t1.deleted = 0
and t1.id = t2.user_id
and t2.role_id = t3.id
</select>
<select
id=
"list"
resultType=
"com.youlai.admin.pojo.entity.SysUser"
>
select u.*,d.name as dept_name , GROUP_CONCAT(r.name) as roleNames
from sys_user u
left join sys_dept d on u.dept_id= d.id
left join sys_user_role ur on u.id=ur.user_id
left join sys_role r on ur.role_id=r.id
left join sys_dept d on u.dept_id= d.id
left join sys_user_role ur on u.id=ur.user_id
left join sys_role r on ur.role_id=r.id
where 1=1
<if
test=
'user.username!=null and user.username.trim() neq ""'
>
and u.username like concat('%',#{user.username},'%')
...
...
@@ -74,6 +74,11 @@
<if
test=
'user.deptId!=null'
>
and concat(',',concat(d.tree_path,',',d.id),',') like concat('%,',#{user.deptId},',%')
</if>
<if
test=
'user.keywords!=null'
>
and(u.username like concat('%',#{user.keywords},'%')
OR u.nickname like concat('%',#{user.keywords},'%')
OR u.mobile like concat('%',#{user.keywords},'%'))
</if>
GROUP BY u.id
</select>
</mapper>
youlai-common/common-mybatis/pom.xml
浏览文件 @
07b6d961
...
...
@@ -39,6 +39,7 @@
<dependency>
<groupId>
com.youlai
</groupId>
<artifactId>
common-web
</artifactId>
<optional>
true
</optional>
</dependency>
</dependencies>
</project>
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java
浏览文件 @
07b6d961
package
com.youlai.common.mybatis.handler
;
import
cn.hutool.json.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.toolkit.ObjectUtils
;
import
com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler
;
import
com.youlai.common.constant.GlobalConstants
;
import
com.youlai.common.web.util.JwtUtils
;
import
jdk.nashorn.internal.ir.JoinPredecessor
;
import
jdk.nashorn.internal.ir.LexicalContext
;
import
jdk.nashorn.internal.ir.LocalVariableConversion
;
import
lombok.extern.slf4j.Slf4j
;
import
net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils
;
import
net.sf.jsqlparser.JSQLParserException
;
import
net.sf.jsqlparser.expression.*
;
import
net.sf.jsqlparser.expression.operators.arithmetic.Concat
;
import
net.sf.jsqlparser.expression.operators.conditional.AndExpression
;
import
net.sf.jsqlparser.expression.operators.conditional.OrExpression
;
import
net.sf.jsqlparser.expression.operators.relational.EqualsTo
;
import
net.sf.jsqlparser.expression.operators.relational.ExpressionList
;
import
net.sf.jsqlparser.expression.operators.relational.LikeExpression
;
import
net.sf.jsqlparser.expression.operators.relational.OldOracleJoinBinaryExpression
;
import
net.sf.jsqlparser.parser.CCJSqlParserUtil
;
import
net.sf.jsqlparser.schema.Column
;
import
net.sf.jsqlparser.schema.Table
;
import
net.sf.jsqlparser.statement.select.*
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
...
...
@@ -56,7 +42,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
// 如果是超级管理员则放行
return
where
;
}
else
{
return
dataScopeFilter
(
annotation
.
dataPermission
(),
where
);
return
dataScopeFilter
(
annotation
.
dataPermission
(),
annotation
.
storeAlias
(),
where
);
}
}
}
...
...
@@ -72,12 +58,12 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
* @param where 当前查询条件
* @return 构建后查询条件
*/
public
static
Expression
dataScopeFilter
(
String
dataPermission
,
Expression
where
)
{
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
(
"
id"
),
getDeptId
());
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
();
...
...
youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java
浏览文件 @
07b6d961
...
...
@@ -19,5 +19,7 @@ public @interface InterceptorIgnore {
* 默认打开,需要注解关闭
*/
String
dataPermission
()
default
"0"
;
String
storeAlias
()
default
""
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录