Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
b1248d7e
提交
b1248d7e
authored
2月 28, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
资源添加开发完成
上级
f5b10597
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
382 行增加
和
47 行删除
+382
-47
PassportController.java
...mall/admin/application/controller/PassportController.java
+1
-1
ResourceController.java
...mall/admin/application/controller/ResourceController.java
+24
-15
ResourceService.java
.../main/java/cn/iocoder/mall/admin/api/ResourceService.java
+24
-2
AdminErrorCodeEnum.java
...n/iocoder/mall/admin/api/constant/AdminErrorCodeEnum.java
+9
-2
ResourceConstants.java
...cn/iocoder/mall/admin/api/constant/ResourceConstants.java
+11
-5
ResourceAddDTO.java
...in/java/cn/iocoder/mall/admin/api/dto/ResourceAddDTO.java
+1
-1
ResourceUpdateDTO.java
...java/cn/iocoder/mall/admin/api/dto/ResourceUpdateDTO.java
+95
-0
ResourceConvert.java
...n/java/cn/iocoder/mall/admin/convert/ResourceConvert.java
+9
-0
ResourceMapper.java
...c/main/java/cn/iocoder/mall/admin/dao/ResourceMapper.java
+10
-0
ResourceServiceImpl.java
...va/cn/iocoder/mall/admin/service/ResourceServiceImpl.java
+103
-3
ResourceMapper.xml
...service-impl/src/main/resources/mapper/ResourceMapper.xml
+80
-15
BaseDO.java
...n/java/cn/iocoder/common/framework/dataobject/BaseDO.java
+15
-3
没有找到文件。
admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/PassportController.java
浏览文件 @
b1248d7e
...
...
@@ -24,7 +24,7 @@ public class PassportController {
private
OAuth2Service
oauth2Service
;
@PostMapping
(
"/login"
)
@ApiOperation
(
value
=
"手机号 +
验证码登陆(注册)"
,
notes
=
"如果手机对应的账号不存在,则会自动创建
"
)
@ApiOperation
(
value
=
"手机号 +
密码登陆
"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"username"
,
value
=
"账号"
,
required
=
true
,
example
=
"15601691300"
),
@ApiImplicitParam
(
name
=
"password"
,
value
=
"密码"
,
required
=
true
,
example
=
"future"
)
...
...
admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/controller/ResourceController.java
浏览文件 @
b1248d7e
...
...
@@ -3,8 +3,9 @@ package cn.iocoder.mall.admin.application.controller;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.admin.api.ResourceService
;
import
cn.iocoder.mall.admin.api.bo.ResourceBO
;
import
cn.iocoder.mall.admin.api.constant.Resource
Type
;
import
cn.iocoder.mall.admin.api.constant.Resource
Constants
;
import
cn.iocoder.mall.admin.api.dto.ResourceAddDTO
;
import
cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO
;
import
cn.iocoder.mall.admin.application.convert.ResourceConvert
;
import
cn.iocoder.mall.admin.application.vo.AdminMenuTreeNodeVO
;
import
cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder
;
...
...
@@ -32,7 +33,7 @@ public class ResourceController {
@GetMapping
(
"/admin_menu_tree"
)
@ApiOperation
(
value
=
"获得当前登陆的管理员拥有的菜单权限"
,
notes
=
"以树结构返回"
)
public
CommonResult
<
List
<
AdminMenuTreeNodeVO
>>
adminMenuTree
()
{
List
<
ResourceBO
>
resources
=
resourceService
.
getResource
ByTypeAndRoleIds
(
ResourceType
.
MENU
,
AdminSecurityContextHolder
.
getContext
().
getRoleIds
());
List
<
ResourceBO
>
resources
=
resourceService
.
getResource
sByTypeAndRoleIds
(
ResourceConstants
.
TYPE_
MENU
,
AdminSecurityContextHolder
.
getContext
().
getRoleIds
());
// 创建 AdminMenuTreeNodeVO Map
Map
<
Integer
,
AdminMenuTreeNodeVO
>
treeNodeMap
=
resources
.
stream
().
collect
(
Collectors
.
toMap
(
ResourceBO:
:
getId
,
ResourceConvert
.
INSTANCE
::
convert
));
// 处理父子关系
...
...
@@ -58,33 +59,40 @@ public class ResourceController {
@ApiOperation
(
value
=
"获得当前登陆的管理员拥有的 URL 权限列表"
)
// @ApiModelProperty(value = "data", example = "['/admin/role/add', '/admin/role/update']") 没效果
public
CommonResult
<
Set
<
String
>>
adminUrlList
()
{
List
<
ResourceBO
>
resources
=
resourceService
.
getResource
ByTypeAndRoleIds
(
ResourceType
.
URL
,
AdminSecurityContextHolder
.
getContext
().
getRoleIds
());
List
<
ResourceBO
>
resources
=
resourceService
.
getResource
sByTypeAndRoleIds
(
ResourceConstants
.
TYPE_
URL
,
AdminSecurityContextHolder
.
getContext
().
getRoleIds
());
return
CommonResult
.
success
(
resources
.
stream
().
map
(
ResourceBO:
:
getHandler
).
collect
(
Collectors
.
toSet
()));
}
// =========== 资源管理 API ===========
// TODO 芋艿,注释
@PostMapping
(
"/add"
)
@ApiOperation
(
value
=
"创建资源"
,
notes
=
"例如说,菜单资源,Url 资源"
)
public
void
add
(
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"type"
)
Integer
type
,
@RequestParam
(
"sort"
)
Integer
sort
,
@RequestParam
(
"displayName"
)
String
displayName
,
@RequestParam
(
"pid"
)
Integer
pid
,
@RequestParam
(
"handler"
)
String
handler
)
{
public
CommonResult
<
ResourceBO
>
add
(
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"type"
)
Integer
type
,
@RequestParam
(
"sort"
)
Integer
sort
,
@RequestParam
(
"displayName"
)
String
displayName
,
@RequestParam
(
"pid"
)
Integer
pid
,
@RequestParam
(
"handler"
)
String
handler
)
{
ResourceAddDTO
resourceAddDTO
=
new
ResourceAddDTO
().
setName
(
name
).
setType
(
type
).
setSort
(
sort
)
.
setDisplayName
(
displayName
).
setPid
(
pid
).
setHandler
(
handler
);
CommonResult
<
ResourceBO
>
result
=
resourceService
.
addResource
(
resourceAddDTO
);
return
resourceService
.
addResource
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
resourceAddDTO
);
}
public
void
update
()
{
@PostMapping
(
"/update"
)
public
CommonResult
<
Boolean
>
update
(
@RequestParam
(
"id"
)
Integer
id
,
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"sort"
)
Integer
sort
,
@RequestParam
(
"displayName"
)
String
displayName
,
@RequestParam
(
"pid"
)
Integer
pid
,
@RequestParam
(
"handler"
)
String
handler
)
{
ResourceUpdateDTO
resourceUpdateDTO
=
new
ResourceUpdateDTO
().
setId
(
id
).
setName
(
name
).
setSort
(
sort
).
setDisplayName
(
displayName
).
setPid
(
pid
).
setHandler
(
handler
);
return
resourceService
.
updateResource
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
resourceUpdateDTO
);
}
public
void
delete
()
{
@PostMapping
(
"/delete"
)
public
CommonResult
<
Boolean
>
delete
(
@RequestParam
(
"id"
)
Integer
id
)
{
return
resourceService
.
deleteResource
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
id
);
}
}
\ No newline at end of file
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/ResourceService.java
浏览文件 @
b1248d7e
...
...
@@ -3,14 +3,35 @@ package cn.iocoder.mall.admin.api;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.admin.api.bo.ResourceBO
;
import
cn.iocoder.mall.admin.api.dto.ResourceAddDTO
;
import
cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO
;
import
org.springframework.lang.Nullable
;
import
java.util.List
;
import
java.util.Set
;
public
interface
ResourceService
{
List
<
ResourceBO
>
getResourceByTypeAndRoleIds
(
Integer
type
,
Set
<
Integer
>
roleIds
);
/**
* 查询指定类型 + 指定角色的资源列表
*
* @param type 指定类型。
* @param roleIds 指定角色的数组。
* @return 资源列表
*/
List
<
ResourceBO
>
getResourcesByTypeAndRoleIds
(
Integer
type
,
Set
<
Integer
>
roleIds
);
CommonResult
<
ResourceBO
>
addResource
(
ResourceAddDTO
resourceAddDTO
);
/**
* 查询指定类型的资源列表
*
* @param type 指定类型。可以为空,此时不做为过滤条件
* @return 资源列表
*/
List
<
ResourceBO
>
getResourcesByType
(
@Nullable
Integer
type
);
CommonResult
<
ResourceBO
>
addResource
(
Integer
adminId
,
ResourceAddDTO
resourceAddDTO
);
CommonResult
<
Boolean
>
updateResource
(
Integer
adminId
,
ResourceUpdateDTO
resourceUpdateDTO
);
CommonResult
<
Boolean
>
deleteResource
(
Integer
adminId
,
Integer
resourceId
);
}
\ No newline at end of file
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminErrorCodeEnum.java
浏览文件 @
b1248d7e
...
...
@@ -20,10 +20,17 @@ public enum AdminErrorCodeEnum {
OAUTH_INVALID_TOKEN
(
1002001020
,
""
),
// 预留
// ========== 管理员模块 ==========
// ========== 管理员模块
1002002000
==========
ADMIN_USERNAME_NOT_REGISTERED
(
1002002000
,
"账号不存在"
),
ADMIN_PASSWORD_ERROR
(
1002002001
,
"密码不正确"
),
ADMIN_IS_DISABLE
(
1002002002
,
"账号被禁用"
);
ADMIN_IS_DISABLE
(
1002002002
,
"账号被禁用"
),
// ========== 资源模块 1002003000 ==========
RESOURCE_NAME_DUPLICATE
(
1002003000
,
"已经存在该名字的资源"
),
RESOURCE_PARENT_NOT_EXISTS
(
1002003001
,
"父资源不存在"
),
RESOURCE_PARENT_ERROR
(
1002003002
,
"不能设置自己为父资源"
),
RESOURCE_NOT_EXISTS
(
1002003002
,
"资源不存在"
),
;
private
final
int
code
;
private
final
String
message
;
...
...
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/Resource
Type
.java
→
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/Resource
Constants
.java
浏览文件 @
b1248d7e
...
...
@@ -3,15 +3,20 @@ package cn.iocoder.mall.admin.api.constant;
/**
* 资源类型
*/
public
interface
Resource
Type
{
public
interface
Resource
Constants
{
/**
*
彩蛋
*
类型 - 菜单
*/
Integer
MENU
=
1
;
Integer
TYPE_
MENU
=
1
;
/**
* URL
*
类型 -
URL
*/
Integer
URL
=
2
;
Integer
TYPE_URL
=
2
;
/**
* 父资源编号 - 根节点
*/
Integer
PID_ROOT
=
0
;
}
\ No newline at end of file
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/ResourceAddDTO.java
浏览文件 @
b1248d7e
...
...
@@ -29,7 +29,7 @@ public class ResourceAddDTO {
@NotEmpty
(
message
=
"资源名字不能为空"
)
private
String
displayName
;
/**
* 父资源
比那好
* 父资源
编号
*/
private
Integer
pid
;
/**
...
...
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/ResourceUpdateDTO.java
0 → 100644
浏览文件 @
b1248d7e
package
cn
.
iocoder
.
mall
.
admin
.
api
.
dto
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
/**
* 资源更新 DTO
*/
public
class
ResourceUpdateDTO
{
/**
* 资源编号
*/
@NotNull
(
message
=
"资源编号不能为空"
)
private
Integer
id
;
/**
* 资源名字(标识)
*/
@NotEmpty
(
message
=
"资源名字不能为空"
)
private
String
name
;
/**
* 排序值
*/
@NotNull
(
message
=
"类型不能为空"
)
private
Integer
sort
;
/**
* 展示名
*/
@NotEmpty
(
message
=
"资源名字不能为空"
)
private
String
displayName
;
/**
* 父资源编号
*/
private
Integer
pid
;
/**
* 操作
*/
private
String
handler
;
public
Integer
getId
()
{
return
id
;
}
public
ResourceUpdateDTO
setId
(
Integer
id
)
{
this
.
id
=
id
;
return
this
;
}
public
String
getName
()
{
return
name
;
}
public
ResourceUpdateDTO
setName
(
String
name
)
{
this
.
name
=
name
;
return
this
;
}
public
Integer
getSort
()
{
return
sort
;
}
public
ResourceUpdateDTO
setSort
(
Integer
sort
)
{
this
.
sort
=
sort
;
return
this
;
}
public
String
getDisplayName
()
{
return
displayName
;
}
public
ResourceUpdateDTO
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
return
this
;
}
public
Integer
getPid
()
{
return
pid
;
}
public
ResourceUpdateDTO
setPid
(
Integer
pid
)
{
this
.
pid
=
pid
;
return
this
;
}
public
String
getHandler
()
{
return
handler
;
}
public
ResourceUpdateDTO
setHandler
(
String
handler
)
{
this
.
handler
=
handler
;
return
this
;
}
}
\ No newline at end of file
admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/convert/ResourceConvert.java
浏览文件 @
b1248d7e
package
cn
.
iocoder
.
mall
.
admin
.
convert
;
import
cn.iocoder.mall.admin.api.bo.ResourceBO
;
import
cn.iocoder.mall.admin.api.dto.ResourceAddDTO
;
import
cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO
;
import
cn.iocoder.mall.admin.dataobject.ResourceDO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mappings
;
...
...
@@ -19,4 +21,10 @@ public interface ResourceConvert {
@Mappings
({})
List
<
ResourceBO
>
convert
(
List
<
ResourceDO
>
resourceDOs
);
@Mappings
({})
ResourceDO
convert
(
ResourceAddDTO
resourceAddDTO
);
@Mappings
({})
ResourceDO
convert
(
ResourceUpdateDTO
resourceUpdateDTO
);
}
\ No newline at end of file
admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/dao/ResourceMapper.java
浏览文件 @
b1248d7e
...
...
@@ -16,4 +16,13 @@ public interface ResourceMapper {
List
<
ResourceDO
>
selectListByTypeAndRoleIds
(
@Param
(
"type"
)
Integer
type
,
@Param
(
"roleIds"
)
Set
<
Integer
>
roleIds
);
List
<
ResourceDO
>
selectListByType
(
@Param
(
"type"
)
Integer
type
);
ResourceDO
selectByName
(
@Param
(
"name"
)
String
name
);
ResourceDO
selectById
(
@Param
(
"id"
)
Integer
id
);
void
insert
(
ResourceDO
resource
);
int
update
(
ResourceDO
resource
);
}
\ No newline at end of file
admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/ResourceServiceImpl.java
浏览文件 @
b1248d7e
package
cn
.
iocoder
.
mall
.
admin
.
service
;
import
cn.iocoder.common.framework.constant.SysErrorCodeEnum
;
import
cn.iocoder.common.framework.dataobject.BaseDO
;
import
cn.iocoder.common.framework.util.ServiceExceptionUtil
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.admin.api.ResourceService
;
import
cn.iocoder.mall.admin.api.bo.ResourceBO
;
import
cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum
;
import
cn.iocoder.mall.admin.api.constant.ResourceConstants
;
import
cn.iocoder.mall.admin.api.dto.ResourceAddDTO
;
import
cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO
;
import
cn.iocoder.mall.admin.convert.ResourceConvert
;
import
cn.iocoder.mall.admin.dao.ResourceMapper
;
import
cn.iocoder.mall.admin.dataobject.ResourceDO
;
...
...
@@ -11,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -26,7 +33,7 @@ public class ResourceServiceImpl implements ResourceService {
}
@Override
public
List
<
ResourceBO
>
getResourceByTypeAndRoleIds
(
Integer
type
,
Set
<
Integer
>
roleIds
)
{
public
List
<
ResourceBO
>
getResource
s
ByTypeAndRoleIds
(
Integer
type
,
Set
<
Integer
>
roleIds
)
{
if
(
roleIds
==
null
||
roleIds
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
...
...
@@ -34,8 +41,100 @@ public class ResourceServiceImpl implements ResourceService {
}
@Override
public
CommonResult
<
ResourceBO
>
addResource
(
ResourceAddDTO
resourceAddDTO
)
{
return
null
;
public
List
<
ResourceBO
>
getResourcesByType
(
Integer
type
)
{
return
ResourceConvert
.
INSTANCE
.
convert
(
resourceMapper
.
selectListByType
(
type
));
}
@Override
@SuppressWarnings
(
"Duplicates"
)
public
CommonResult
<
ResourceBO
>
addResource
(
Integer
adminId
,
ResourceAddDTO
resourceAddDTO
)
{
// 补充未在 Validation 中校验的参数校验
if
(!
isValidResourceType
(
resourceAddDTO
.
getType
()))
{
return
CommonResult
.
error
(
SysErrorCodeEnum
.
VALIDATION_REQUEST_PARAM_ERROR
.
getCode
(),
"资源类型必须是菜单或 Url"
);
// TODO 有点搓
}
// 校验资源唯一性
if
(
resourceMapper
.
selectByName
(
resourceAddDTO
.
getName
())
!=
null
)
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_NAME_DUPLICATE
.
getCode
());
}
// 校验父资源存在
if
(
resourceAddDTO
.
getPid
()
==
null
)
{
resourceAddDTO
.
setPid
(
ResourceConstants
.
PID_ROOT
);
}
if
(
checkParentExists
(
resourceAddDTO
.
getPid
()))
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_PARENT_NOT_EXISTS
.
getCode
());
}
// 存储到数据库
ResourceDO
resource
=
ResourceConvert
.
INSTANCE
.
convert
(
resourceAddDTO
);
if
(
ResourceConstants
.
PID_ROOT
.
equals
(
resourceAddDTO
.
getPid
()))
{
// 根节点,必须没有操作
resource
.
setHandler
(
null
);
}
resource
.
setCreateTime
(
new
Date
());
resource
.
setDeleted
(
BaseDO
.
DELETED_NO
);
resourceMapper
.
insert
(
resource
);
// TODO 操作日志
// 返回成功
return
CommonResult
.
success
(
ResourceConvert
.
INSTANCE
.
convert
(
resource
));
}
@Override
@SuppressWarnings
(
"Duplicates"
)
public
CommonResult
<
Boolean
>
updateResource
(
Integer
adminId
,
ResourceUpdateDTO
resourceUpdateDTO
)
{
// 校验更新的资源是否存在
if
(
resourceMapper
.
selectById
(
resourceUpdateDTO
.
getId
())
==
null
)
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_NOT_EXISTS
.
getCode
());
}
// 校验资源唯一性
ResourceDO
existNameResource
=
resourceMapper
.
selectByName
(
resourceUpdateDTO
.
getName
());
if
(
existNameResource
!=
null
&&
existNameResource
.
getId
().
equals
(
resourceUpdateDTO
.
getId
()))
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_NAME_DUPLICATE
.
getCode
());
}
// 不能设置自己为父资源
if
(
resourceUpdateDTO
.
getId
().
equals
(
resourceUpdateDTO
.
getPid
()))
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_PARENT_ERROR
.
getCode
());
}
// 校验父资源存在
if
(
resourceUpdateDTO
.
getPid
()
==
null
)
{
resourceUpdateDTO
.
setPid
(
ResourceConstants
.
PID_ROOT
);
}
if
(
checkParentExists
(
resourceUpdateDTO
.
getPid
()))
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_PARENT_NOT_EXISTS
.
getCode
());
}
// 更新到数据库
ResourceDO
resource
=
ResourceConvert
.
INSTANCE
.
convert
(
resourceUpdateDTO
);
if
(
ResourceConstants
.
PID_ROOT
.
equals
(
resourceUpdateDTO
.
getPid
()))
{
// 根节点,必须没有操作
resource
.
setHandler
(
null
);
}
resourceMapper
.
update
(
resource
);
// TODO 操作日志
// 返回成功
return
CommonResult
.
success
(
true
);
}
@Override
public
CommonResult
<
Boolean
>
deleteResource
(
Integer
adminId
,
Integer
resourceId
)
{
// 校验更新的资源是否存在
if
(
resourceMapper
.
selectById
(
resourceId
)
==
null
)
{
return
ServiceExceptionUtil
.
error
(
AdminErrorCodeEnum
.
RESOURCE_NOT_EXISTS
.
getCode
());
}
// TODO 还有校验
// 更新到数据库
ResourceDO
resource
=
new
ResourceDO
().
setId
(
resourceId
);
resource
.
setDeleted
(
BaseDO
.
DELETED_YES
);
resourceMapper
.
update
(
resource
);
// 返回成功
return
CommonResult
.
success
(
true
);
}
private
boolean
isValidResourceType
(
Integer
type
)
{
return
ResourceConstants
.
TYPE_MENU
.
equals
(
type
)
||
ResourceConstants
.
TYPE_URL
.
equals
(
type
);
}
private
boolean
checkParentExists
(
Integer
pid
)
{
if
(!
ResourceConstants
.
PID_ROOT
.
equals
(
pid
))
{
return
resourceMapper
.
selectById
(
pid
)
==
null
;
}
return
false
;
}
}
\ No newline at end of file
admin/admin-service-impl/src/main/resources/mapper/ResourceMapper.xml
浏览文件 @
b1248d7e
...
...
@@ -10,28 +10,92 @@
<!--)-->
<!--</insert>-->
<select
id=
"selectByTypeAndHandler"
resultType=
"ResourceDO"
>
SELECT
<sql
id=
"FIELDS"
>
id, name, type, sort, display_name,
create_time, pid, handler
FROM resource
WHERE type = #{type}
AND handler = #{handler}
AND deleted = 0
</sql>
<select
id=
"selectByTypeAndHandler"
resultType=
"ResourceDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM resource
WHERE type = #{type}
AND handler = #{handler}
AND deleted = 0
LIMIT 1
</select>
<select
id=
"selectListByType"
parameterType=
"Integer"
resultType=
"ResourceDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM resource
WHERE type = #{type}
AND deleted = 0
</select>
<select
id=
"selectListByTypeAndRoleIds"
resultType=
"ResourceDO"
>
SELECT
r.id, r.name, r.type, r.sort, r.display_name,
r.create_time, r.pid, r.handler
FROM resource r, role_resource rr
WHERE r.type = #{type}
AND deleted = 0
AND rr.role_id IN
SELECT
r.id, r.name, r.type, r.sort, r.display_name,
r.create_time, r.pid, r.handler
FROM resource r, role_resource rr
WHERE r.type = #{type}
AND deleted = 0
AND rr.role_id IN
<foreach
item=
"roleId"
collection=
"roleIds"
separator=
","
open=
"("
close=
")"
index=
""
>
#{roleId}
#{roleId}
</foreach>
AND r.id = rr.resource_id
AND r.id = rr.resource_id
</select>
<select
id=
"selectByName"
parameterType=
"String"
resultType=
"ResourceDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM resource
WHERE name = #{name}
AND deleted = 0
LIMIT 1
</select>
<select
id=
"selectById"
resultType=
"ResourceDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM resource
WHERE id = #{id}
AND deleted = 0
</select>
<insert
id=
"insert"
parameterType=
"ResourceDO"
useGeneratedKeys=
"true"
keyColumn=
"id"
keyProperty=
"id"
>
INSERT INTO resource (
name, type, sort, display_name, handler,
pid, create_time, deleted
) VALUES (
#{name}, #{type}, #{sort}, #{displayName}, #{handler},
#{pid}, #{createTime}, #{deleted}
)
</insert>
<update
id=
"update"
parameterType=
"ResourceDO"
>
UPDATE resource
<set>
<if
test=
"name != null"
>
name = #{name},
</if>
<if
test=
"sort != null"
>
sort = #{sort},
</if>
<if
test=
"displayName != null"
>
display_name = #{displayName},
</if>
<if
test=
"pid != null"
>
pid = #{pid},
</if>
<if
test=
"handler != null"
>
handler = #{handler},
</if>
<if
test=
"deleted != null"
>
deleted = #{deleted}
</if>
</set>
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
common/common-framework/src/main/java/cn/iocoder/common/framework/dataobject/BaseDO.java
浏览文件 @
b1248d7e
...
...
@@ -7,6 +7,15 @@ import java.util.Date;
*/
public
class
BaseDO
{
/**
* 是否删除 - 是
*/
public
static
final
Integer
DELETED_YES
=
1
;
/**
* 是否删除 - 否
*/
public
static
final
Integer
DELETED_NO
=
0
;
/**
* 创建时间
*/
...
...
@@ -15,7 +24,10 @@ public class BaseDO {
* 最后更新时间
*/
private
Date
updateTime
;
private
Boolean
deleted
;
/**
* 是否删除
*/
private
Integer
deleted
;
public
Date
getCreateTime
()
{
return
createTime
;
...
...
@@ -35,11 +47,11 @@ public class BaseDO {
return
this
;
}
public
Boolean
getDeleted
()
{
public
Integer
getDeleted
()
{
return
deleted
;
}
public
BaseDO
setDeleted
(
Boolean
deleted
)
{
public
BaseDO
setDeleted
(
Integer
deleted
)
{
this
.
deleted
=
deleted
;
return
this
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论