Merge remote-tracking branch 'origin/master'

# Conflicts:
#	eiam-console/src/main/console-fe/src/pages/permission/Role/index.tsx
pull/54/head
shao1121353141 2023-09-20 08:43:35 +08:00
commit 91814d8e0a
67 changed files with 651 additions and 598 deletions

View File

@ -0,0 +1,27 @@
package cn.topiam.employee.common.constant;
import static cn.topiam.employee.support.constant.EiamConstants.COLON;
import static cn.topiam.employee.support.constant.EiamConstants.V1_API_PATH;
/**
*
* @author SanLi
* Created by qinggang.zuo@gmail.com / 2689170096@qq.com on 2023/9/18 14:35
*/
public class PermissionConstants {
/**
* API
*/
public final static String PERMISSION_PATH = V1_API_PATH + "/permission";
/**
*
*/
public static final String PERMISSION_GROUP_NAME = "应用管理";
/**
*
*/
public static final String PERMISSION_CACHE_NAME_PREFIX = "permission" + COLON;
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.entity.app;
package cn.topiam.employee.common.entity.permission;
import java.io.Serial;
@ -48,7 +48,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Table(name = "app_permission_action")
@SQLDelete(sql = "update app_permission_action set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionActionEntity extends LogicDeleteEntity<Long> {
public class PermissionActionEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = -3954680915360748087L;
@ -75,5 +75,5 @@ public class AppPermissionActionEntity extends LogicDeleteEntity<Long> {
*/
@ManyToOne
@JoinColumn(name = "resource_id")
private AppPermissionResourceEntity resource;
private PermissionResourceEntity resource;
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.entity.app;
package cn.topiam.employee.common.entity.permission;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
@ -50,7 +50,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Table(name = "app_permission_policy")
@SQLDelete(sql = "update app_permission_policy set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionPolicyEntity extends LogicDeleteEntity<Long> {
public class PermissionPolicyEntity extends LogicDeleteEntity<Long> {
/**
* id

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.entity.app;
package cn.topiam.employee.common.entity.permission;
import java.io.Serial;
import java.util.List;
@ -52,7 +52,7 @@ import static jakarta.persistence.FetchType.LAZY;
@Table(name = "app_permission_resource")
@SQLDelete(sql = "update app_permission_resource set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionResourceEntity extends LogicDeleteEntity<Long> {
public class PermissionResourceEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = 7342074686605139968L;
@ -93,5 +93,5 @@ public class AppPermissionResourceEntity extends LogicDeleteEntity<Long> {
@ToString.Exclude
@OneToMany(mappedBy = "resource", fetch = LAZY, cascade = { CascadeType.PERSIST,
CascadeType.REMOVE })
private List<AppPermissionActionEntity> actions;
private List<PermissionActionEntity> actions;
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.entity.app;
package cn.topiam.employee.common.entity.permission;
import java.io.Serial;
@ -51,7 +51,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Table(name = "app_permission_role")
@SQLDelete(sql = "update app_permission_role set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionRoleEntity extends LogicDeleteEntity<Long> {
public class PermissionRoleEntity extends LogicDeleteEntity<Long> {
@Serial
private static final long serialVersionUID = -7761332532995424593L;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.entity.app.po;
package cn.topiam.employee.common.entity.permission.po;
import java.io.Serial;
import java.io.Serializable;
@ -38,7 +38,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data
@Accessors(chain = true)
@Schema(description = "分页查询策略响应")
public class AppPermissionPolicyPO implements Serializable {
public class PermissionPolicyPO implements Serializable {
@Serial
private static final long serialVersionUID = 3320953184046791392L;

View File

@ -19,6 +19,7 @@ package cn.topiam.employee.common.repository.app.impl;
import java.util.List;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
@ -28,10 +29,9 @@ import org.springframework.util.ObjectUtils;
import com.google.common.collect.Lists;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepositoryCustomized;
import cn.topiam.employee.common.repository.app.impl.mapper.AppPermissionPolicyPoMapper;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepositoryCustomized;
import lombok.RequiredArgsConstructor;
@ -49,7 +49,7 @@ public class AppPermissionPolicyRepositoryCustomizedImpl implements
}
@Override
public Page<AppPermissionPolicyPO> findPage(AppPolicyQuery query, Pageable pageable) {
public Page<PermissionPolicyPO> findPage(AppPolicyQuery query, Pageable pageable) {
//查询条件
//@formatter:off
// 所属应用
@ -111,7 +111,7 @@ public class AppPermissionPolicyRepositoryCustomizedImpl implements
.append(" FROM app_permission_policy policy ").append(subjectJoin).append(objectJoin);
// @formatter:off
List<AppPermissionPolicyPO> list = jdbcTemplate
List<PermissionPolicyPO> list = jdbcTemplate
.query(
selectSql.append(" LIMIT ").append(pageable.getPageNumber() * pageable.getPageSize())
.append(",").append(pageable.getPageSize()).toString(),

View File

@ -20,9 +20,9 @@ package cn.topiam.employee.common.repository.app.impl.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.jdbc.core.RowMapper;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.enums.app.AppPolicyEffect;
import cn.topiam.employee.common.enums.app.AppPolicyObjectType;
import cn.topiam.employee.common.enums.app.AppPolicySubjectType;
@ -31,7 +31,7 @@ import cn.topiam.employee.common.enums.app.AppPolicySubjectType;
* @author TopIAM
* Created by support@topiam.cn on 2022/2/13 23:25
*/
public class AppPermissionPolicyPoMapper implements RowMapper<AppPermissionPolicyPO> {
public class AppPermissionPolicyPoMapper implements RowMapper<PermissionPolicyPO> {
/**
* Implementations must implement this method to map each row of data
@ -46,18 +46,18 @@ public class AppPermissionPolicyPoMapper implements RowMapper<AppPermissionPolic
*/
@SuppressWarnings("DuplicatedCode")
@Override
public AppPermissionPolicyPO mapRow(ResultSet rs, int rowNum) throws SQLException {
AppPermissionPolicyPO appPermissionPolicyPo = new AppPermissionPolicyPO();
appPermissionPolicyPo.setId(rs.getLong("id_"));
appPermissionPolicyPo.setEffect(AppPolicyEffect.getType(rs.getString("effect")));
appPermissionPolicyPo.setSubjectId(rs.getString("subject_id"));
appPermissionPolicyPo
public PermissionPolicyPO mapRow(ResultSet rs, int rowNum) throws SQLException {
PermissionPolicyPO permissionPolicyPo = new PermissionPolicyPO();
permissionPolicyPo.setId(rs.getLong("id_"));
permissionPolicyPo.setEffect(AppPolicyEffect.getType(rs.getString("effect")));
permissionPolicyPo.setSubjectId(rs.getString("subject_id"));
permissionPolicyPo
.setSubjectType(AppPolicySubjectType.getType(rs.getString("subject_type")));
appPermissionPolicyPo.setSubjectName(rs.getString("subject_name"));
appPermissionPolicyPo.setObjectId(rs.getLong("object_id"));
appPermissionPolicyPo
permissionPolicyPo.setSubjectName(rs.getString("subject_name"));
permissionPolicyPo.setObjectId(rs.getLong("object_id"));
permissionPolicyPo
.setObjectType(AppPolicyObjectType.getType(rs.getString("object_type")));
appPermissionPolicyPo.setObjectName(rs.getString("object_name"));
return appPermissionPolicyPo;
permissionPolicyPo.setObjectName(rs.getString("object_name"));
return permissionPolicyPo;
}
}

View File

@ -15,15 +15,15 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.repository.app;
package cn.topiam.employee.common.repository.permission;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionActionEntity;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.app.AppPermissionActionEntity;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
/**
@ -32,13 +32,13 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/
@Repository
public interface AppPermissionActionRepository extends
LogicDeleteRepository<AppPermissionActionEntity, Long>,
QuerydslPredicateExecutor<AppPermissionActionEntity> {
LogicDeleteRepository<PermissionActionEntity, Long>,
QuerydslPredicateExecutor<PermissionActionEntity> {
/**
* findAllByResource
*
* @param resource {@link AppPermissionResourceEntity}
* @param resource {@link PermissionResourceEntity}
* @return {@link List}
*/
List<AppPermissionActionEntity> findAllByResource(AppPermissionResourceEntity resource);
List<PermissionActionEntity> findAllByResource(PermissionResourceEntity resource);
}

View File

@ -15,11 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.repository.app;
package cn.topiam.employee.common.repository.permission;
import java.io.Serializable;
import java.util.Collection;
import cn.topiam.employee.common.entity.permission.PermissionPolicyEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
@ -27,7 +28,6 @@ import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
@ -37,8 +37,8 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
*/
@Repository
public interface AppPermissionPolicyRepository extends AppPermissionPolicyRepositoryCustomized,
LogicDeleteRepository<AppPermissionPolicyEntity, Long>,
QuerydslPredicateExecutor<AppPermissionPolicyEntity> {
LogicDeleteRepository<PermissionPolicyEntity, Long>,
QuerydslPredicateExecutor<PermissionPolicyEntity> {
/**
* ID
*
@ -81,6 +81,6 @@ public interface AppPermissionPolicyRepository extends AppPermissionPolicyReposi
*/
@Transactional(rollbackFor = Exception.class)
@Modifying
@Query(value = "UPDATE AppPermissionResourceEntity set enabled =:status WHERE id =:id")
@Query(value = "UPDATE PermissionResourceEntity set enabled =:status WHERE id =:id")
Integer updateStatus(@Param(value = "id") Long id, @Param(value = "status") Boolean status);
}

View File

@ -15,12 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.repository.app;
package cn.topiam.employee.common.repository.permission;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
/**
@ -33,7 +33,7 @@ public interface AppPermissionPolicyRepositoryCustomized {
*
* @param query {@link AppPolicyQuery}
* @param request {@link Pageable}
* @return {@link AppPermissionPolicyPO}
* @return {@link PermissionPolicyPO}
*/
Page<AppPermissionPolicyPO> findPage(AppPolicyQuery query, Pageable request);
Page<PermissionPolicyPO> findPage(AppPolicyQuery query, Pageable request);
}

View File

@ -15,17 +15,17 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.repository.app;
package cn.topiam.employee.common.repository.permission;
import java.util.Optional;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
/**
@ -38,16 +38,16 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/
@Repository
public interface AppPermissionResourceRepository extends
LogicDeleteRepository<AppPermissionResourceEntity, Long>,
QuerydslPredicateExecutor<AppPermissionResourceEntity> {
LogicDeleteRepository<PermissionResourceEntity, Long>,
QuerydslPredicateExecutor<PermissionResourceEntity> {
/**
* findByIdContainsDeleted
*
* @param id must not be {@literal null}.
* @return {@link AppPermissionResourceEntity}
* @return {@link PermissionResourceEntity}
*/
@NotNull
@Query(value = "SELECT * FROM app_permission_resource WHERE id_ = :id", nativeQuery = true)
Optional<AppPermissionResourceEntity> findByIdContainsDeleted(@NotNull @Param(value = "id") Long id);
Optional<PermissionResourceEntity> findByIdContainsDeleted(@NotNull @Param(value = "id") Long id);
}

View File

@ -15,10 +15,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.common.repository.app;
package cn.topiam.employee.common.repository.permission;
import java.util.Optional;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import org.jetbrains.annotations.NotNull;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying;
@ -28,7 +29,6 @@ import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppPermissionRoleEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository;
/**
@ -41,8 +41,8 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/
@Repository
public interface AppPermissionRoleRepository extends
LogicDeleteRepository<AppPermissionRoleEntity, Long>,
QuerydslPredicateExecutor<AppPermissionRoleEntity> {
LogicDeleteRepository<PermissionRoleEntity, Long>,
QuerydslPredicateExecutor<PermissionRoleEntity> {
/**
*
*
@ -58,10 +58,10 @@ public interface AppPermissionRoleRepository extends
* findByIdContainsDeleted
*
* @param id must not be {@literal null}.
* @return {@link AppPermissionRoleEntity}
* @return {@link PermissionRoleEntity}
*/
@NotNull
@Cacheable
@Query(value = "SELECT * FROM app_permission_role WHERE id_ = :id", nativeQuery = true)
Optional<AppPermissionRoleEntity> findByIdContainsDeleted(@NotNull @Param(value = "id") Long id);
Optional<PermissionRoleEntity> findByIdContainsDeleted(@NotNull @Param(value = "id") Long id);
}

View File

@ -0,0 +1,22 @@
/*
* eiam-console - Employee Identity and Access Management
* Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Role from './Role';
export default () => {
return <Role />;
};

View File

@ -15,10 +15,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.controller.app;
package cn.topiam.employee.console.controller.permission;
import java.util.List;
import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
@ -28,16 +29,16 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
import cn.topiam.employee.console.service.app.AppPermissionActionService;
import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.service.permission.PermissionActionService;
import cn.topiam.employee.support.result.ApiRestResult;
import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
import static cn.topiam.employee.common.constant.PermissionConstants.PERMISSION_PATH;
/**
* -
@ -48,29 +49,29 @@ import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
@RequiredArgsConstructor
@Validated
@Tag(name = "应用权限-权限项")
@RequestMapping(value = APP_PATH
+ "/permission/action", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = PERMISSION_PATH
+ "/action", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
public class AppPermissionActionController {
public class PermissionActionController {
/**
* logger
*/
private final Logger logger = LoggerFactory.getLogger(AppPermissionActionController.class);
private final Logger logger = LoggerFactory.getLogger(PermissionActionController.class);
/**
*
*
* @return {@link AppPermissionActionListResult}
* @return {@link PermissionActionListResult}
*/
@Operation(summary = "获取权限项列表")
@GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<List<AppPermissionActionListResult>> getPermissionActionList(@Validated AppPermissionActionListQuery query) {
List<AppPermissionActionListResult> list = appPermissionActionService
public ApiRestResult<List<PermissionActionListResult>> getPermissionActionList(@Validated PermissionActionListQuery query) {
List<PermissionActionListResult> list = permissionActionService
.getPermissionActionList(query);
return ApiRestResult.<List<AppPermissionActionListResult>> builder().result(list).build();
return ApiRestResult.<List<PermissionActionListResult>> builder().result(list).build();
}
private final AppPermissionActionService appPermissionActionService;
private final PermissionActionService permissionActionService;
}

View File

@ -15,22 +15,22 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.controller.app;
package cn.topiam.employee.console.controller.permission;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyListResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.update.permission.PermissionPolicyUpdateParam;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionPolicyService;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.permission.PermissionPolicyService;
import cn.topiam.employee.support.lock.Lock;
import cn.topiam.employee.support.preview.Preview;
import cn.topiam.employee.support.repository.page.domain.Page;
@ -41,7 +41,8 @@ import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
import static cn.topiam.employee.common.constant.PermissionConstants.PERMISSION_PATH;
/**
*
@ -51,32 +52,32 @@ import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
*/
@Validated
@Tag(name = "应用权限-授权策略")
@RequestMapping(value = APP_PATH
+ "/permission/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = PERMISSION_PATH
+ "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequiredArgsConstructor
public class AppPermissionPolicyController {
public class PermissionPolicyController {
/**
*
*
* @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult}
* @return {@link PermissionRoleListResult}
*/
@Operation(summary = "获取策略列表")
@GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Page<AppPermissionPolicyListResult>> getPermissionPolicyList(PageModel page,
@Validated AppPolicyQuery query) {
Page<AppPermissionPolicyListResult> result = permissionPolicyService
public ApiRestResult<Page<PermissionPolicyListResult>> getPermissionPolicyList(PageModel page,
@Validated AppPolicyQuery query) {
Page<PermissionPolicyListResult> result = permissionPolicyService
.getPermissionPolicyList(page, query);
return ApiRestResult.<Page<AppPermissionPolicyListResult>> builder().result(result).build();
return ApiRestResult.<Page<PermissionPolicyListResult>> builder().result(result).build();
}
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean}
*/
@Lock
@ -84,7 +85,7 @@ public class AppPermissionPolicyController {
@Operation(summary = "创建资源")
@PostMapping(value = "/create")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> createPolicy(@Validated @RequestBody AppPermissionPolicyCreateParam param) {
public ApiRestResult<Boolean> createPolicy(@Validated @RequestBody PermissionPolicyCreateParam param) {
return ApiRestResult.<Boolean> builder()
.result(permissionPolicyService.createPermissionPolicy(param)).build();
}
@ -100,7 +101,7 @@ public class AppPermissionPolicyController {
@Operation(summary = "修改资源")
@PutMapping(value = "/update/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> updatePolicy(@Validated AppPermissionPolicyUpdateParam param) {
public ApiRestResult<Boolean> updatePolicy(@Validated PermissionPolicyUpdateParam param) {
return ApiRestResult.<Boolean> builder()
.result(permissionPolicyService.updatePermissionPolicy(param)).build();
}
@ -132,11 +133,11 @@ public class AppPermissionPolicyController {
@Operation(summary = "获取资源信息")
@GetMapping(value = "/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<AppPermissionPolicyGetResult> getPermissionPolicy(@PathVariable(value = "id") String id) {
public ApiRestResult<PermissionPolicyGetResult> getPermissionPolicy(@PathVariable(value = "id") String id) {
//返回
return ApiRestResult.<AppPermissionPolicyGetResult> builder()
return ApiRestResult.<PermissionPolicyGetResult> builder()
.result(permissionPolicyService.getPermissionPolicy(id)).build();
}
private final AppPermissionPolicyService permissionPolicyService;
private final PermissionPolicyService permissionPolicyService;
}

View File

@ -15,8 +15,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.controller.app;
package cn.topiam.employee.console.controller.permission;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -25,15 +28,12 @@ import org.springframework.web.bind.annotation.*;
import cn.topiam.employee.audit.annotation.Audit;
import cn.topiam.employee.audit.event.type.EventType;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionResourceUpdateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionResourceService;
import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionResourceUpdateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.permission.PermissionResourceService;
import cn.topiam.employee.support.lock.Lock;
import cn.topiam.employee.support.preview.Preview;
import cn.topiam.employee.support.repository.page.domain.Page;
@ -47,7 +47,8 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
import static cn.topiam.employee.common.constant.PermissionConstants.PERMISSION_PATH;
/**
*
@ -57,33 +58,33 @@ import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
*/
@Validated
@Tag(name = "应用权限-资源")
@RequestMapping(value = APP_PATH
+ "/permission/resource", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = PERMISSION_PATH
+ "/resource", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequiredArgsConstructor
public class AppPermissionResourceController {
public class PermissionResourceController {
/**
*
*
* @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult}
* @return {@link PermissionRoleListResult}
*/
@Operation(summary = "获取资源列表")
@GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Page<AppPermissionResourceListResult>> getPermissionResourceList(PageModel page,
@Validated AppResourceListQuery query) {
Page<AppPermissionResourceListResult> result = appPermissionResourceService
public ApiRestResult<Page<PermissionResourceListResult>> getPermissionResourceList(PageModel page,
@Validated PermissionResourceListQuery query) {
Page<PermissionResourceListResult> result = permissionResourceService
.getPermissionResourceList(page, query);
return ApiRestResult.<Page<AppPermissionResourceListResult>> builder().result(result)
return ApiRestResult.<Page<PermissionResourceListResult>> builder().result(result)
.build();
}
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean}
*/
@Lock
@ -92,9 +93,9 @@ public class AppPermissionResourceController {
@Audit(type = EventType.SAVE_APP_PERMISSION_RESOURCE)
@PostMapping(value = "/create")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> createResource(@Validated @RequestBody AppPermissionResourceCreateParam param) {
public ApiRestResult<Boolean> createResource(@Validated @RequestBody PermissionResourceCreateParam param) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionResourceService.createPermissionResource(param)).build();
.result(permissionResourceService.createPermissionResource(param)).build();
}
/**
@ -109,9 +110,9 @@ public class AppPermissionResourceController {
@Audit(type = EventType.UPDATE_APP_PERMISSION_RESOURCE)
@PutMapping(value = "/update")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> updateResource(@RequestBody @Validated AppPermissionResourceUpdateParam param) {
public ApiRestResult<Boolean> updateResource(@RequestBody @Validated PermissionResourceUpdateParam param) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionResourceService.updatePermissionResource(param)).build();
.result(permissionResourceService.updatePermissionResource(param)).build();
}
/**
@ -128,7 +129,7 @@ public class AppPermissionResourceController {
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> deletePermissionResource(@PathVariable(value = "id") String id) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionResourceService.deletePermissionResource(id)).build();
.result(permissionResourceService.deletePermissionResource(id)).build();
}
/**
@ -140,10 +141,10 @@ public class AppPermissionResourceController {
@Operation(summary = "获取资源信息")
@GetMapping(value = "/get/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<AppPermissionResourceGetResult> getPermissionResource(@PathVariable(value = "id") String id) {
public ApiRestResult<PermissionResourceGetResult> getPermissionResource(@PathVariable(value = "id") String id) {
//返回
return ApiRestResult.<AppPermissionResourceGetResult> builder()
.result(appPermissionResourceService.getPermissionResource(id)).build();
return ApiRestResult.<PermissionResourceGetResult> builder()
.result(permissionResourceService.getPermissionResource(id)).build();
}
/**
@ -160,7 +161,7 @@ public class AppPermissionResourceController {
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> enableOrganization(@PathVariable(value = "id") Long id) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionResourceService.updateStatus(id, Boolean.TRUE)).build();
.result(permissionResourceService.updateStatus(id, Boolean.TRUE)).build();
}
/**
@ -177,7 +178,7 @@ public class AppPermissionResourceController {
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> disableOrganization(@PathVariable(value = "id") Long id) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionResourceService.updateStatus(id, Boolean.FALSE)).build();
.result(permissionResourceService.updateStatus(id, Boolean.FALSE)).build();
}
/**
@ -192,7 +193,7 @@ public class AppPermissionResourceController {
@Parameter(description = "值") @NotEmpty(message = "验证值不能为空") String value,
@Parameter(description = "应用ID") @NotNull(message = "应用ID不能为空") Long appId,
@Parameter(description = "ID") Long id) {
Boolean result = appPermissionResourceService.permissionResourceParamCheck(type, value,
Boolean result = permissionResourceService.permissionResourceParamCheck(type, value,
appId, id);
//返回
return ApiRestResult.<Boolean> builder().result(result).build();
@ -201,5 +202,5 @@ public class AppPermissionResourceController {
/**
*
*/
private final AppPermissionResourceService appPermissionResourceService;
private final PermissionResourceService permissionResourceService;
}

View File

@ -15,8 +15,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.controller.app;
package cn.topiam.employee.console.controller.permission;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -25,12 +28,9 @@ import org.springframework.web.bind.annotation.*;
import cn.topiam.employee.audit.annotation.Audit;
import cn.topiam.employee.audit.event.type.EventType;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionRoleService;
import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.permission.PermissionRoleService;
import cn.topiam.employee.support.lock.Lock;
import cn.topiam.employee.support.preview.Preview;
import cn.topiam.employee.support.repository.page.domain.Page;
@ -44,7 +44,8 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
import static cn.topiam.employee.common.constant.PermissionConstants.PERMISSION_PATH;
/**
*
@ -55,30 +56,30 @@ import static cn.topiam.employee.common.constant.AppConstants.APP_PATH;
@RequiredArgsConstructor
@Validated
@Tag(name = "应用权限-角色")
@RequestMapping(value = APP_PATH + "/permission/role", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = PERMISSION_PATH + "/role", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
public class AppPermissionRoleController {
public class PermissionRoleController {
/**
*
*
* @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult}
* @return {@link PermissionRoleListResult}
*/
@Operation(summary = "获取角色列表")
@GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Page<AppPermissionRoleListResult>> getPermissionRoleList(PageModel page,
@Validated AppPermissionRoleListQuery query) {
Page<AppPermissionRoleListResult> result = appPermissionRoleService
public ApiRestResult<Page<PermissionRoleListResult>> getPermissionRoleList(PageModel page,
@Validated PermissionRoleListQuery query) {
Page<PermissionRoleListResult> result = permissionRoleService
.getPermissionRoleList(page, query);
return ApiRestResult.<Page<AppPermissionRoleListResult>> builder().result(result).build();
return ApiRestResult.<Page<PermissionRoleListResult>> builder().result(result).build();
}
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean}
*/
@Lock
@ -87,9 +88,9 @@ public class AppPermissionRoleController {
@Audit(type = EventType.SAVE_APP_PERMISSION_ROLE)
@PostMapping(value = "/create")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> createPermissionRole(@Validated @RequestBody AppPermissionRoleCreateParam param) {
public ApiRestResult<Boolean> createPermissionRole(@Validated @RequestBody PermissionRoleCreateParam param) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionRoleService.createPermissionRole(param)).build();
.result(permissionRoleService.createPermissionRole(param)).build();
}
/**
@ -106,7 +107,7 @@ public class AppPermissionRoleController {
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> updatePermissionRole(@RequestBody @Validated PermissionRoleUpdateParam param) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionRoleService.updatePermissionRole(param)).build();
.result(permissionRoleService.updatePermissionRole(param)).build();
}
/**
@ -123,7 +124,7 @@ public class AppPermissionRoleController {
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> deletePermissionRole(@PathVariable(value = "ids") String ids) {
return ApiRestResult.<Boolean> builder()
.result(appPermissionRoleService.deletePermissionRole(ids)).build();
.result(permissionRoleService.deletePermissionRole(ids)).build();
}
/**
@ -135,10 +136,10 @@ public class AppPermissionRoleController {
@Operation(summary = "获取角色信息")
@GetMapping(value = "/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<AppPermissionRoleResult> getPermissionRole(@PathVariable(value = "id") Long id) {
AppPermissionRoleResult details = appPermissionRoleService.getPermissionRole(id);
public ApiRestResult<PermissionRoleResult> getPermissionRole(@PathVariable(value = "id") Long id) {
PermissionRoleResult details = permissionRoleService.getPermissionRole(id);
//返回
return ApiRestResult.<AppPermissionRoleResult> builder().result(details).build();
return ApiRestResult.<PermissionRoleResult> builder().result(details).build();
}
/**
@ -153,7 +154,7 @@ public class AppPermissionRoleController {
@PutMapping(value = "/enable/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> enablePermissionRole(@PathVariable(value = "id") String id) {
Boolean result = appPermissionRoleService.updatePermissionRoleStatus(id, Boolean.TRUE);
Boolean result = permissionRoleService.updatePermissionRoleStatus(id, Boolean.TRUE);
return ApiRestResult.<Boolean> builder().result(result).build();
}
@ -169,7 +170,7 @@ public class AppPermissionRoleController {
@PutMapping(value = "/disable/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> disablePermissionRole(@PathVariable(value = "id") String id) {
Boolean result = appPermissionRoleService.updatePermissionRoleStatus(id, Boolean.FALSE);
Boolean result = permissionRoleService.updatePermissionRoleStatus(id, Boolean.FALSE);
return ApiRestResult.<Boolean> builder().result(result).build();
}
@ -185,7 +186,7 @@ public class AppPermissionRoleController {
@Parameter(description = "值") @NotEmpty(message = "验证值不能为空") String value,
@Parameter(description = "应用ID") @NotNull(message = "应用ID不能为空") Long appId,
@Parameter(description = "ID") Long id) {
Boolean result = appPermissionRoleService.permissionRoleParamCheck(type, value, appId, id);
Boolean result = permissionRoleService.permissionRoleParamCheck(type, value, appId, id);
//返回
return ApiRestResult.<Boolean> builder().result(result).build();
}
@ -193,5 +194,5 @@ public class AppPermissionRoleController {
/**
*
*/
private final AppPermissionRoleService appPermissionRoleService;
private final PermissionRoleService permissionRoleService;
}

View File

@ -29,7 +29,7 @@ import cn.topiam.employee.common.enums.MailType;
import cn.topiam.employee.common.enums.MessageCategory;
import cn.topiam.employee.common.enums.SmsType;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam;
import cn.topiam.employee.console.pojo.setting.SmsProviderConfigResult;
import cn.topiam.employee.console.pojo.result.setting.SmsProviderConfigResult;
import cn.topiam.employee.console.service.setting.MessageSettingService;
import cn.topiam.employee.core.message.MsgVariable;
import cn.topiam.employee.core.message.sms.SmsMsgEventPublish;

View File

@ -15,11 +15,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.converter.app;
package cn.topiam.employee.console.converter.permission;
import java.util.ArrayList;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionActionEntity;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -28,12 +30,10 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionActionEntity;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.common.enums.PermissionActionType;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
/**
*
@ -42,14 +42,14 @@ import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring")
public interface AppPermissionActionConverter {
public interface PermissionActionConverter {
/**
*
*
* @param query {@link AppPermissionActionListQuery}
* @param query {@link PermissionActionListQuery}
* @return {@link Predicate}
*/
default Predicate appPermissionActionListQueryConvertToPredicate(AppPermissionActionListQuery query) {
default Predicate appPermissionActionListQueryConvertToPredicate(PermissionActionListQuery query) {
QAppPermissionResourceEntity resource = QAppPermissionResourceEntity.appPermissionResourceEntity;
Predicate predicate = ExpressionUtils.and(resource.isNotNull(),
resource.deleted.eq(Boolean.FALSE));
@ -68,18 +68,18 @@ public interface AppPermissionActionConverter {
/**
*
*
* @param list {@link AppPermissionResourceEntity}
* @return {@link AppPermissionActionListResult}
* @param list {@link PermissionResourceEntity}
* @return {@link PermissionActionListResult}
*/
default List<AppPermissionActionListResult> entityConvertToResourceActionListResult(List<AppPermissionResourceEntity> list) {
List<AppPermissionActionListResult> results = new ArrayList<>();
List<AppPermissionActionListResult.Action> menus = new ArrayList<>();
List<AppPermissionActionListResult.Action> apis = new ArrayList<>();
List<AppPermissionActionListResult.Action> buttons = new ArrayList<>();
List<AppPermissionActionListResult.Action> others = new ArrayList<>();
List<AppPermissionActionListResult.Action> datas = new ArrayList<>();
for (AppPermissionResourceEntity resource : list) {
for (AppPermissionActionEntity action : resource.getActions()) {
default List<PermissionActionListResult> entityConvertToResourceActionListResult(List<PermissionResourceEntity> list) {
List<PermissionActionListResult> results = new ArrayList<>();
List<PermissionActionListResult.Action> menus = new ArrayList<>();
List<PermissionActionListResult.Action> apis = new ArrayList<>();
List<PermissionActionListResult.Action> buttons = new ArrayList<>();
List<PermissionActionListResult.Action> others = new ArrayList<>();
List<PermissionActionListResult.Action> datas = new ArrayList<>();
for (PermissionResourceEntity resource : list) {
for (PermissionActionEntity action : resource.getActions()) {
if (PermissionActionType.MENU.equals(action.getType())) {
menus.add(actionConvertToResourceActionResult(action));
}
@ -96,7 +96,7 @@ public interface AppPermissionActionConverter {
others.add(actionConvertToResourceActionResult(action));
}
}
AppPermissionActionListResult result = new AppPermissionActionListResult();
PermissionActionListResult result = new PermissionActionListResult();
//基本信息
result.setAppId(resource.getAppId().toString());
result.setId(resource.getId().toString());
@ -117,10 +117,10 @@ public interface AppPermissionActionConverter {
/**
* actionConvertToResourceActionResult
*
* @param action {@link AppPermissionActionEntity}
* @return {@link AppPermissionActionListResult.Action}
* @param action {@link PermissionActionEntity}
* @return {@link PermissionActionListResult.Action}
*/
@Mapping(target = "access", source = "value")
AppPermissionActionListResult.Action actionConvertToResourceActionResult(AppPermissionActionEntity action);
PermissionActionListResult.Action actionConvertToResourceActionResult(PermissionActionEntity action);
}

View File

@ -15,20 +15,20 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.converter.app;
package cn.topiam.employee.console.converter.permission;
import java.util.ArrayList;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionPolicyEntity;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionPolicyCreateParam;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.util.CollectionUtils;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionPolicyUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
/**
@ -37,14 +37,14 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class)
public interface AppPermissionPolicyConverter {
@Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface PermissionPolicyConverter {
/**
*
*
* @param param {@link AppPermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity}
* @param param {@link PermissionPolicyCreateParam}
* @return {@link PermissionPolicyEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true)
@ -53,13 +53,13 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionPolicyEntity policyCreateParamConvertToEntity(AppPermissionPolicyCreateParam param);
PermissionPolicyEntity policyCreateParamConvertToEntity(PermissionPolicyCreateParam param);
/**
*
*
* @param param {@link AppPermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity}
* @param param {@link PermissionPolicyCreateParam}
* @return {@link PermissionPolicyEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "updateTime", ignore = true)
@ -67,7 +67,7 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionPolicyEntity policyUpdateParamConvertToEntity(AppPermissionPolicyUpdateParam param);
PermissionPolicyEntity policyUpdateParamConvertToEntity(PermissionPolicyUpdateParam param);
/**
*
@ -75,9 +75,9 @@ public interface AppPermissionPolicyConverter {
* @param page {@link Page}
* @return {@link Page}
*/
default Page<AppPermissionPolicyListResult> entityConvertToPolicyListResult(org.springframework.data.domain.Page<AppPermissionPolicyPO> page) {
Page<AppPermissionPolicyListResult> result = new Page<>();
List<AppPermissionPolicyPO> pageList = page.getContent();
default Page<PermissionPolicyListResult> entityConvertToPolicyListResult(org.springframework.data.domain.Page<PermissionPolicyPO> page) {
Page<PermissionPolicyListResult> result = new Page<>();
List<PermissionPolicyPO> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) {
//@formatter:off
result.setPagination(Page.Pagination.builder()
@ -86,8 +86,8 @@ public interface AppPermissionPolicyConverter {
.current(page.getPageable().getPageNumber() + 1)
.build());
//@formatter:on
List<AppPermissionPolicyListResult> list = new ArrayList<>();
for (AppPermissionPolicyPO po : pageList) {
List<PermissionPolicyListResult> list = new ArrayList<>();
for (PermissionPolicyPO po : pageList) {
list.add(entityConvertToPolicyListResult(po));
}
result.setList(list);
@ -98,8 +98,8 @@ public interface AppPermissionPolicyConverter {
/**
* entityConvertToPolicyListResult
*
* @param entity {@link AppPermissionPolicyListResult}
* @return {@link AppPermissionPolicyPO}
* @param entity {@link PermissionPolicyListResult}
* @return {@link PermissionPolicyPO}
*/
AppPermissionPolicyListResult entityConvertToPolicyListResult(AppPermissionPolicyPO entity);
PermissionPolicyListResult entityConvertToPolicyListResult(PermissionPolicyPO entity);
}

View File

@ -15,11 +15,15 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.converter.app;
package cn.topiam.employee.console.converter.permission;
import java.util.ArrayList;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceListResult;
import cn.topiam.employee.console.pojo.update.permission.PermissionResourceUpdateParam;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -29,13 +33,9 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionResourceUpdateParam;
import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
/**
@ -44,16 +44,16 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class)
public interface AppPermissionResourceConverter {
@Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface PermissionResourceConverter {
/**
*
*
* @param query {@link AppResourceListQuery}
* @param query {@link PermissionResourceListQuery}
* @return {@link Predicate}
*/
default Predicate resourcePaginationParamConvertToPredicate(AppResourceListQuery query) {
default Predicate resourcePaginationParamConvertToPredicate(PermissionResourceListQuery query) {
QAppPermissionResourceEntity resource = QAppPermissionResourceEntity.appPermissionResourceEntity;
Predicate predicate = ExpressionUtils.and(resource.isNotNull(),
resource.deleted.eq(Boolean.FALSE));
@ -70,8 +70,8 @@ public interface AppPermissionResourceConverter {
/**
*
*
* @param param {@link AppPermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity}
* @param param {@link PermissionResourceCreateParam}
* @return {@link PermissionResourceEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "actions", ignore = true)
@ -81,13 +81,13 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionResourceEntity resourceCreateParamConvertToEntity(AppPermissionResourceCreateParam param);
PermissionResourceEntity resourceCreateParamConvertToEntity(PermissionResourceCreateParam param);
/**
*
*
* @param param {@link AppPermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity}
* @param param {@link PermissionResourceCreateParam}
* @return {@link PermissionResourceEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "actions", ignore = true)
@ -96,7 +96,7 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionResourceEntity resourceUpdateParamConvertToEntity(AppPermissionResourceUpdateParam param);
PermissionResourceEntity resourceUpdateParamConvertToEntity(PermissionResourceUpdateParam param);
/**
*
@ -104,12 +104,12 @@ public interface AppPermissionResourceConverter {
* @param page {@link Page}
* @return {@link Page}
*/
default Page<AppPermissionResourceListResult> entityConvertToResourceListResult(org.springframework.data.domain.Page<AppPermissionResourceEntity> page) {
Page<AppPermissionResourceListResult> result = new Page<>();
List<AppPermissionResourceEntity> pageList = page.getContent();
default Page<PermissionResourceListResult> entityConvertToResourceListResult(org.springframework.data.domain.Page<PermissionResourceEntity> page) {
Page<PermissionResourceListResult> result = new Page<>();
List<PermissionResourceEntity> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) {
List<AppPermissionResourceListResult> list = new ArrayList<>();
for (AppPermissionResourceEntity resource : pageList) {
List<PermissionResourceListResult> list = new ArrayList<>();
for (PermissionResourceEntity resource : pageList) {
list.add(entityConvertToResourceListResult(resource));
}
//@formatter:off
@ -127,17 +127,17 @@ public interface AppPermissionResourceConverter {
/**
*
*
* @param data {@link AppPermissionResourceEntity}
* @return {@link AppPermissionResourceListResult}
* @param data {@link PermissionResourceEntity}
* @return {@link PermissionResourceListResult}
*/
AppPermissionResourceListResult entityConvertToResourceListResult(AppPermissionResourceEntity data);
PermissionResourceListResult entityConvertToResourceListResult(PermissionResourceEntity data);
/**
*
*
* @param resource {@link AppPermissionResourceEntity}
* @return {@link AppPermissionResourceGetResult}
* @param resource {@link PermissionResourceEntity}
* @return {@link PermissionResourceGetResult}
*/
@Mapping(target = "actions", source = "actions")
AppPermissionResourceGetResult entityConvertToResourceGetResult(AppPermissionResourceEntity resource);
PermissionResourceGetResult entityConvertToResourceGetResult(PermissionResourceEntity resource);
}

View File

@ -15,11 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.converter.app;
package cn.topiam.employee.console.converter.permission;
import java.util.ArrayList;
import java.util.List;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -29,13 +30,12 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionRoleEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionRoleEntity;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleResult;
import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
/**
@ -45,7 +45,7 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring")
public interface AppPermissionRoleConverter {
public interface PermissionRoleConverter {
/**
*
@ -53,11 +53,11 @@ public interface AppPermissionRoleConverter {
* @param page {@link Page}
* @return {@link Page}
*/
default Page<AppPermissionRoleListResult> entityConvertToRolePaginationResult(org.springframework.data.domain.Page<AppPermissionRoleEntity> page) {
Page<AppPermissionRoleListResult> result = new Page<>();
default Page<PermissionRoleListResult> entityConvertToRolePaginationResult(org.springframework.data.domain.Page<PermissionRoleEntity> page) {
Page<PermissionRoleListResult> result = new Page<>();
if (!CollectionUtils.isEmpty(page.getContent())) {
List<AppPermissionRoleListResult> list = new ArrayList<>();
for (AppPermissionRoleEntity user : page.getContent()) {
List<PermissionRoleListResult> list = new ArrayList<>();
for (PermissionRoleEntity user : page.getContent()) {
list.add(entityConvertToRolePaginationResult(user));
}
//@formatter:off
@ -75,16 +75,16 @@ public interface AppPermissionRoleConverter {
/**
*
*
* @param page {@link AppPermissionRoleEntity}
* @return {@link AppPermissionRoleListResult}
* @param page {@link PermissionRoleEntity}
* @return {@link PermissionRoleListResult}
*/
AppPermissionRoleListResult entityConvertToRolePaginationResult(AppPermissionRoleEntity page);
PermissionRoleListResult entityConvertToRolePaginationResult(PermissionRoleEntity page);
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @return {@link AppPermissionRoleEntity}
* @param param {@link PermissionRoleCreateParam}
* @return {@link PermissionRoleEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true)
@ -93,13 +93,13 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionRoleEntity roleCreateParamConvertToEntity(AppPermissionRoleCreateParam param);
PermissionRoleEntity roleCreateParamConvertToEntity(PermissionRoleCreateParam param);
/**
*
*
* @param param {@link PermissionRoleUpdateParam}
* @return {@link AppPermissionRoleEntity}
* @return {@link PermissionRoleEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "appId", ignore = true)
@ -108,23 +108,23 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionRoleEntity roleUpdateParamConvertToEntity(PermissionRoleUpdateParam param);
PermissionRoleEntity roleUpdateParamConvertToEntity(PermissionRoleUpdateParam param);
/**
*
*
* @param role {@link AppPermissionRoleEntity}
* @return {@link AppPermissionRoleResult}
* @param role {@link PermissionRoleEntity}
* @return {@link PermissionRoleResult}
*/
AppPermissionRoleResult entityConvertToRoleDetailResult(AppPermissionRoleEntity role);
PermissionRoleResult entityConvertToRoleDetailResult(PermissionRoleEntity role);
/**
*
*
* @param query {@link AppPermissionRoleListQuery}
* @return {@link AppPermissionRoleEntity}
* @param query {@link PermissionRoleListQuery}
* @return {@link PermissionRoleEntity}
*/
default Predicate rolePaginationParamConvertToPredicate(AppPermissionRoleListQuery query) {
default Predicate rolePaginationParamConvertToPredicate(PermissionRoleListQuery query) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;
Predicate predicate = ExpressionUtils.and(role.isNotNull(), role.deleted.eq(Boolean.FALSE));
//查询条件

View File

@ -42,7 +42,7 @@ import cn.topiam.employee.common.message.sms.tencent.TencentSmsProviderConfig;
import cn.topiam.employee.console.pojo.result.setting.EmailProviderConfigResult;
import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam;
import cn.topiam.employee.console.pojo.setting.SmsProviderConfigResult;
import cn.topiam.employee.console.pojo.result.setting.SmsProviderConfigResult;
import cn.topiam.employee.support.exception.TopIamException;
import cn.topiam.employee.support.validation.ValidationUtils;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.query.app;
package cn.topiam.employee.console.pojo.query.permission;
import java.io.Serial;
import java.io.Serializable;
@ -37,7 +37,7 @@ import jakarta.validation.constraints.NotEmpty;
@Data
@Schema(description = "查询权限列表入参")
@ParameterObject
public class AppPermissionActionListQuery implements Serializable {
public class PermissionActionListQuery implements Serializable {
@Serial
private static final long serialVersionUID = 4307939244290315206L;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.query.app;
package cn.topiam.employee.console.pojo.query.permission;
import java.io.Serializable;
@ -36,7 +36,7 @@ import jakarta.validation.constraints.NotNull;
@Data
@Schema(description = "查询权限资源列表入参")
@ParameterObject
public class AppResourceListQuery implements Serializable {
public class PermissionResourceListQuery implements Serializable {
/**
*

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.query.app;
package cn.topiam.employee.console.pojo.query.permission;
import java.io.Serializable;
@ -36,7 +36,7 @@ import jakarta.validation.constraints.NotNull;
@Data
@Schema(description = "查询角色列表入参")
@ParameterObject
public class AppPermissionRoleListQuery implements Serializable {
public class PermissionRoleListQuery implements Serializable {
/**
*

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import java.io.Serial;
import java.io.Serializable;
@ -36,7 +36,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data
@Accessors(chain = true)
@Schema(description = "获取应用资源权限列表")
public class AppPermissionActionListResult implements Serializable {
public class PermissionActionListResult implements Serializable {
@Serial
private static final long serialVersionUID = 3320953184046791392L;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import java.io.Serializable;
@ -36,7 +36,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/
@Schema(description = "获取资源结果")
@Data
public class AppPermissionPolicyGetResult implements Serializable {
public class PermissionPolicyGetResult implements Serializable {
/**
* ID
*/

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import cn.topiam.employee.common.enums.app.AppPolicyEffect;
import cn.topiam.employee.common.enums.app.AppPolicyObjectType;
@ -33,7 +33,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/
@Schema(description = "获取授权列表")
@Data
public class AppPermissionPolicyListResult {
public class PermissionPolicyListResult {
/**
* ID
*/

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import java.io.Serial;
import java.io.Serializable;
@ -36,7 +36,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/
@Schema(description = "获取资源结果")
@Data
public class AppPermissionResourceGetResult implements Serializable {
public class PermissionResourceGetResult implements Serializable {
/**
*
*/

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import java.io.Serial;
import java.io.Serializable;
@ -35,7 +35,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data
@Accessors(chain = true)
@Schema(description = "分页查询资源结果")
public class AppPermissionResourceListResult implements Serializable {
public class PermissionResourceListResult implements Serializable {
@Serial
private static final long serialVersionUID = 3320953184046791392L;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import java.io.Serial;
import java.io.Serializable;
@ -35,7 +35,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data
@Accessors(chain = true)
@Schema(description = "分页查询角色结果")
public class AppPermissionRoleListResult implements Serializable {
public class PermissionRoleListResult implements Serializable {
@Serial
private static final long serialVersionUID = 3320953184046791392L;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.result.app;
package cn.topiam.employee.console.pojo.result.permission;
import java.io.Serializable;
@ -32,7 +32,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/
@Schema(description = "获取角色")
@Data
public class AppPermissionRoleResult implements Serializable {
public class PermissionRoleResult implements Serializable {
/**
* id
*/

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.setting;
package cn.topiam.employee.console.pojo.result.setting;
import java.io.Serial;
import java.io.Serializable;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.save.app;
package cn.topiam.employee.console.pojo.save.permission;
import java.io.Serializable;
@ -37,7 +37,7 @@ import jakarta.validation.constraints.NotNull;
*/
@Data
@Schema(description = "创建策略入参")
public class AppPermissionPolicyCreateParam implements Serializable {
public class PermissionPolicyCreateParam implements Serializable {
/**
*

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.save.app;
package cn.topiam.employee.console.pojo.save.permission;
import java.io.Serializable;
import java.util.List;
@ -34,7 +34,7 @@ import jakarta.validation.constraints.NotNull;
*/
@Data
@Schema(description = "创建资源入参")
public class AppPermissionResourceCreateParam implements Serializable {
public class PermissionResourceCreateParam implements Serializable {
/**
*
*/
@ -70,6 +70,6 @@ public class AppPermissionResourceCreateParam implements Serializable {
*
*/
@Schema(description = "资源权限")
@NotNull(message = "资源权限不能为空")
private List<AppPermissionsActionParam> actions;
// @NotNull(message = "资源权限不能为空")
private List<PermissionsActionParam> actions;
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.save.app;
package cn.topiam.employee.console.pojo.save.permission;
import java.io.Serializable;
@ -33,7 +33,7 @@ import jakarta.validation.constraints.NotNull;
*/
@Data
@Schema(description = "创建角色入参")
public class AppPermissionRoleCreateParam implements Serializable {
public class PermissionRoleCreateParam implements Serializable {
/**
*
*/

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.save.app;
package cn.topiam.employee.console.pojo.save.permission;
import java.io.Serial;
import java.io.Serializable;
@ -36,7 +36,7 @@ import jakarta.validation.constraints.NotNull;
*/
@Data
@Valid
public class AppPermissionsActionParam implements Serializable {
public class PermissionsActionParam implements Serializable {
@Serial
private static final long serialVersionUID = -6391182747252245592L;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.update.app;
package cn.topiam.employee.console.pojo.update.permission;
import java.io.Serializable;
@ -37,7 +37,7 @@ import jakarta.validation.constraints.NotNull;
*/
@Data
@Schema(description = "修改策略入参")
public class AppPermissionPolicyUpdateParam implements Serializable {
public class PermissionPolicyUpdateParam implements Serializable {
/**
*
*/

View File

@ -15,13 +15,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.update.app;
package cn.topiam.employee.console.pojo.update.permission;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import cn.topiam.employee.console.pojo.save.app.AppPermissionsActionParam;
import cn.topiam.employee.console.pojo.save.permission.PermissionsActionParam;
import lombok.Data;
@ -38,7 +38,7 @@ import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY;
*/
@Data
@Schema(description = "修改资源入参")
public class AppPermissionResourceUpdateParam implements Serializable {
public class PermissionResourceUpdateParam implements Serializable {
@Serial
private static final long serialVersionUID = 6021548372386059064L;
/**
@ -87,5 +87,5 @@ public class AppPermissionResourceUpdateParam implements Serializable {
*/
@Schema(description = "资源权限")
@NotNull(message = "资源权限不能为空")
private List<AppPermissionsActionParam> actions;
private List<PermissionsActionParam> actions;
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.pojo.update.app;
package cn.topiam.employee.console.pojo.update.permission;
import java.io.Serial;
import java.io.Serializable;

View File

@ -15,12 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app;
package cn.topiam.employee.console.service.permission;
import java.util.List;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
/**
* <p>
@ -30,14 +30,14 @@ import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionActionService {
public interface PermissionActionService {
/**
*
*
* @param query {@link AppPermissionActionListQuery}
* @return {@link AppPermissionActionListResult}
* @param query {@link PermissionActionListQuery}
* @return {@link PermissionActionListResult}
*/
List<AppPermissionActionListResult> getPermissionActionList(AppPermissionActionListQuery query);
List<PermissionActionListResult> getPermissionActionList(PermissionActionListQuery query);
}

View File

@ -15,13 +15,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app;
package cn.topiam.employee.console.service.permission;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionPolicyUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -33,24 +33,24 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionPolicyService {
public interface PermissionPolicyService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link AppPolicyQuery}
* @return {@link AppPermissionPolicyListResult}
* @return {@link PermissionPolicyListResult}
*/
Page<AppPermissionPolicyListResult> getPermissionPolicyList(PageModel page,
AppPolicyQuery query);
Page<PermissionPolicyListResult> getPermissionPolicyList(PageModel page,
AppPolicyQuery query);
/**
*
*
* @param id {@link String}
* @return {@link AppPermissionPolicyGetResult}
* @return {@link PermissionPolicyGetResult}
*/
AppPermissionPolicyGetResult getPermissionPolicy(String id);
PermissionPolicyGetResult getPermissionPolicy(String id);
/**
*
@ -63,16 +63,16 @@ public interface AppPermissionPolicyService {
/**
*
*
* @param param {@link AppPermissionPolicyCreateParam}
* @param param {@link PermissionPolicyCreateParam}
* @return {@link Boolean}
*/
Boolean createPermissionPolicy(AppPermissionPolicyCreateParam param);
Boolean createPermissionPolicy(PermissionPolicyCreateParam param);
/**
*
*
* @param param {@link AppPermissionPolicyUpdateParam}
* @param param {@link PermissionPolicyUpdateParam}
* @return {@link Boolean}
*/
Boolean updatePermissionPolicy(AppPermissionPolicyUpdateParam param);
Boolean updatePermissionPolicy(PermissionPolicyUpdateParam param);
}

View File

@ -15,14 +15,14 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app;
package cn.topiam.employee.console.service.permission;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionResourceUpdateParam;
import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionResourceUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -34,24 +34,24 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionResourceService {
public interface PermissionResourceService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link AppResourceListQuery}
* @return {@link AppPermissionResourceListResult}
* @param query {@link PermissionResourceListQuery}
* @return {@link PermissionResourceListResult}
*/
Page<AppPermissionResourceListResult> getPermissionResourceList(PageModel page,
AppResourceListQuery query);
Page<PermissionResourceListResult> getPermissionResourceList(PageModel page,
PermissionResourceListQuery query);
/**
*
*
* @param id {@link String}
* @return {@link AppPermissionResourceGetResult}
* @return {@link PermissionResourceGetResult}
*/
AppPermissionResourceGetResult getPermissionResource(String id);
PermissionResourceGetResult getPermissionResource(String id);
/**
*
@ -73,18 +73,18 @@ public interface AppPermissionResourceService {
/**
*
*
* @param param {@link AppPermissionResourceCreateParam}
* @param param {@link PermissionResourceCreateParam}
* @return {@link Boolean}
*/
Boolean createPermissionResource(AppPermissionResourceCreateParam param);
Boolean createPermissionResource(PermissionResourceCreateParam param);
/**
*
*
* @param param {@link AppPermissionResourceUpdateParam}
* @param param {@link PermissionResourceUpdateParam}
* @return {@link Boolean}
*/
Boolean updatePermissionResource(AppPermissionResourceUpdateParam param);
Boolean updatePermissionResource(PermissionResourceUpdateParam param);
/**
*

View File

@ -15,14 +15,14 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app;
package cn.topiam.employee.console.service.permission;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam;
import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -34,25 +34,25 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionRoleService {
public interface PermissionRoleService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link AppPermissionRoleListQuery}
* @return {@link AppPermissionRoleListResult}
* @param query {@link PermissionRoleListQuery}
* @return {@link PermissionRoleListResult}
*/
Page<AppPermissionRoleListResult> getPermissionRoleList(PageModel page,
AppPermissionRoleListQuery query);
Page<PermissionRoleListResult> getPermissionRoleList(PageModel page,
PermissionRoleListQuery query);
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean}
*/
boolean createPermissionRole(AppPermissionRoleCreateParam param);
boolean createPermissionRole(PermissionRoleCreateParam param);
/**
*
@ -74,9 +74,9 @@ public interface AppPermissionRoleService {
*
*
* @param id {@link Long}
* @return {@link AppPermissionRoleResult}
* @return {@link PermissionRoleResult}
*/
AppPermissionRoleResult getPermissionRole(Long id);
PermissionRoleResult getPermissionRole(Long id);
/**
*

View File

@ -15,20 +15,20 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app.impl;
package cn.topiam.employee.console.service.permission.impl;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import cn.topiam.employee.console.converter.permission.PermissionActionConverter;
import org.springframework.stereotype.Service;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.common.repository.app.AppPermissionResourceRepository;
import cn.topiam.employee.console.converter.app.AppPermissionActionConverter;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
import cn.topiam.employee.console.service.app.AppPermissionActionService;
import cn.topiam.employee.common.repository.permission.AppPermissionResourceRepository;
import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
import cn.topiam.employee.console.service.permission.PermissionActionService;
import lombok.RequiredArgsConstructor;
@ -42,24 +42,24 @@ import lombok.RequiredArgsConstructor;
*/
@Service
@RequiredArgsConstructor
public class AppPermissionActionServiceImpl implements AppPermissionActionService {
public class PermissionActionServiceImpl implements PermissionActionService {
/**
*
*
* @param query {@link AppPermissionActionListQuery}
* @return {@link AppPermissionActionListResult}
* @param query {@link PermissionActionListQuery}
* @return {@link PermissionActionListResult}
*/
@Override
public List<AppPermissionActionListResult> getPermissionActionList(AppPermissionActionListQuery query) {
Predicate predicate = appPermissionActionConverter
public List<PermissionActionListResult> getPermissionActionList(PermissionActionListQuery query) {
Predicate predicate = permissionActionConverter
.appPermissionActionListQueryConvertToPredicate(query);
List<AppPermissionResourceEntity> list = (List<AppPermissionResourceEntity>) appPermissionResourceRepository
List<PermissionResourceEntity> list = (List<PermissionResourceEntity>) appPermissionResourceRepository
.findAll(predicate);
return appPermissionActionConverter.entityConvertToResourceActionListResult(list);
return permissionActionConverter.entityConvertToResourceActionListResult(list);
}
private final AppPermissionResourceRepository appPermissionResourceRepository;
private final AppPermissionActionConverter appPermissionActionConverter;
private final PermissionActionConverter permissionActionConverter;
}

View File

@ -15,23 +15,23 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app.impl;
package cn.topiam.employee.console.service.permission.impl;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionPolicyCreateParam;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
import cn.topiam.employee.common.entity.permission.PermissionPolicyEntity;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import cn.topiam.employee.common.exception.app.AppPolicyNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository;
import cn.topiam.employee.console.converter.app.AppPermissionPolicyConverter;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionPolicyService;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.console.converter.permission.PermissionPolicyConverter;
import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.update.permission.PermissionPolicyUpdateParam;
import cn.topiam.employee.console.service.permission.PermissionPolicyService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -47,32 +47,32 @@ import lombok.RequiredArgsConstructor;
*/
@Service
@RequiredArgsConstructor
public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyService {
public class PermissionPolicyServiceImpl implements PermissionPolicyService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link AppPolicyQuery}
* @return {@link AppPermissionPolicyListResult}
* @return {@link PermissionPolicyListResult}
*/
@Override
public Page<AppPermissionPolicyListResult> getPermissionPolicyList(PageModel page,
AppPolicyQuery query) {
org.springframework.data.domain.Page<AppPermissionPolicyPO> data;
public Page<PermissionPolicyListResult> getPermissionPolicyList(PageModel page,
AppPolicyQuery query) {
org.springframework.data.domain.Page<PermissionPolicyPO> data;
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appPermissionPolicyRepository.findPage(query, request);
return appPermissionPolicyConverter.entityConvertToPolicyListResult(data);
return permissionPolicyConverter.entityConvertToPolicyListResult(data);
}
/**
*
*
* @param id {@link String}
* @return {@link AppPermissionPolicyGetResult}
* @return {@link PermissionPolicyGetResult}
*/
@Override
public AppPermissionPolicyGetResult getPermissionPolicy(String id) {
public PermissionPolicyGetResult getPermissionPolicy(String id) {
return null;
}
@ -94,13 +94,13 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
/**
*
*
* @param param {@link AppPermissionPolicyCreateParam}
* @param param {@link PermissionPolicyCreateParam}
* @return {@link Boolean}
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean createPermissionPolicy(AppPermissionPolicyCreateParam param) {
AppPermissionPolicyEntity resource = appPermissionPolicyConverter
public Boolean createPermissionPolicy(PermissionPolicyCreateParam param) {
PermissionPolicyEntity resource = permissionPolicyConverter
.policyCreateParamConvertToEntity(param);
// 新增策略
appPermissionPolicyRepository.save(resource);
@ -110,19 +110,19 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
/**
*
*
* @param param {@link AppPermissionPolicyUpdateParam}
* @param param {@link PermissionPolicyUpdateParam}
* @return {@link Boolean}
*/
@Override
public Boolean updatePermissionPolicy(AppPermissionPolicyUpdateParam param) {
AppPermissionPolicyEntity resource = appPermissionPolicyConverter
public Boolean updatePermissionPolicy(PermissionPolicyUpdateParam param) {
PermissionPolicyEntity resource = permissionPolicyConverter
.policyUpdateParamConvertToEntity(param);
// 更新策略
appPermissionPolicyRepository.save(resource);
return null;
}
private final AppPermissionPolicyConverter appPermissionPolicyConverter;
private final PermissionPolicyConverter permissionPolicyConverter;
private final AppPermissionPolicyRepository appPermissionPolicyRepository;
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app.impl;
package cn.topiam.employee.console.service.permission.impl;
import java.util.ArrayList;
import java.util.List;
@ -23,6 +23,12 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import cn.topiam.employee.common.entity.permission.PermissionActionEntity;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.update.permission.PermissionResourceUpdateParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;
@ -34,22 +40,16 @@ import com.querydsl.core.types.dsl.BooleanExpression;
import cn.topiam.employee.audit.context.AuditContext;
import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType;
import cn.topiam.employee.common.entity.app.AppPermissionActionEntity;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.common.exception.app.AppResourceNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionActionRepository;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.app.AppPermissionResourceRepository;
import cn.topiam.employee.console.converter.app.AppPermissionResourceConverter;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionsActionParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionResourceUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionResourceService;
import cn.topiam.employee.common.repository.permission.AppPermissionActionRepository;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.permission.AppPermissionResourceRepository;
import cn.topiam.employee.console.converter.permission.PermissionResourceConverter;
import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.save.permission.PermissionsActionParam;
import cn.topiam.employee.console.service.permission.PermissionResourceService;
import cn.topiam.employee.support.exception.BadParamsException;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -69,37 +69,37 @@ import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIF
*/
@Service
@RequiredArgsConstructor
public class AppPermissionResourceServiceImpl implements AppPermissionResourceService {
public class PermissionResourceServiceImpl implements PermissionResourceService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link AppResourceListQuery}
* @return {@link AppPermissionResourceListResult}
* @param query {@link PermissionResourceListQuery}
* @return {@link PermissionResourceListResult}
*/
@Override
public Page<AppPermissionResourceListResult> getPermissionResourceList(PageModel page,
AppResourceListQuery query) {
org.springframework.data.domain.Page<AppPermissionResourceEntity> data;
Predicate predicate = appPermissionResourceConverter
public Page<PermissionResourceListResult> getPermissionResourceList(PageModel page,
PermissionResourceListQuery query) {
org.springframework.data.domain.Page<PermissionResourceEntity> data;
Predicate predicate = permissionResourceConverter
.resourcePaginationParamConvertToPredicate(query);
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appResourceRepository.findAll(predicate, request);
return appPermissionResourceConverter.entityConvertToResourceListResult(data);
return permissionResourceConverter.entityConvertToResourceListResult(data);
}
/**
*
*
* @param id {@link String}
* @return {@link AppPermissionResourceGetResult}
* @return {@link PermissionResourceGetResult}
*/
@Override
public AppPermissionResourceGetResult getPermissionResource(String id) {
AppPermissionResourceEntity resource = appResourceRepository.findById(Long.valueOf(id))
public PermissionResourceGetResult getPermissionResource(String id) {
PermissionResourceEntity resource = appResourceRepository.findById(Long.valueOf(id))
.orElseThrow(AppResourceNotExistException::new);
return appPermissionResourceConverter.entityConvertToResourceGetResult(resource);
return permissionResourceConverter.entityConvertToResourceGetResult(resource);
}
/**
@ -112,12 +112,12 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
@Transactional(rollbackFor = Exception.class)
public Boolean deletePermissionResource(String id) {
Long resourceId = Long.valueOf(id);
AppPermissionResourceEntity resource = appResourceRepository.findById(resourceId)
PermissionResourceEntity resource = appResourceRepository.findById(resourceId)
.orElseThrow(AppResourceNotExistException::new);
List<AppPermissionActionEntity> actionList = appPermissionActionRepository
List<PermissionActionEntity> actionList = appPermissionActionRepository
.findAllByResource(resource);
List<Long> objectIdList = new ArrayList<>(
actionList.stream().map(AppPermissionActionEntity::getId).toList());
actionList.stream().map(PermissionActionEntity::getId).toList());
objectIdList.add(resourceId);
appPermissionPolicyRepository.deleteAllByObjectIdIn(objectIdList);
appResourceRepository.deleteById(resourceId);
@ -135,7 +135,7 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
*/
@Override
public Boolean updateStatus(Long id, boolean enabled) {
AppPermissionResourceEntity resource = appResourceRepository.findById(Long.valueOf(id))
PermissionResourceEntity resource = appResourceRepository.findById(Long.valueOf(id))
.orElseThrow(AppResourceNotExistException::new);
AuditContext.setTarget(
Target.builder().id(id.toString()).type(TargetType.APP_PERMISSION_RESOURCE).build());
@ -145,13 +145,13 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
/**
*
*
* @param param {@link AppPermissionResourceCreateParam}
* @param param {@link PermissionResourceCreateParam}
* @return {@link Boolean}
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean createPermissionResource(AppPermissionResourceCreateParam param) {
AppPermissionResourceEntity resource = appPermissionResourceConverter
public Boolean createPermissionResource(PermissionResourceCreateParam param) {
PermissionResourceEntity resource = permissionResourceConverter
.resourceCreateParamConvertToEntity(param);
buildActions(param.getActions(), resource);
// 新增资源
@ -164,28 +164,28 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
/**
*
*
* @param param {@link AppPermissionResourceUpdateParam}
* @param param {@link PermissionResourceUpdateParam}
* @return {@link Boolean}
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updatePermissionResource(AppPermissionResourceUpdateParam param) {
AppPermissionResourceEntity resource = appPermissionResourceConverter
public Boolean updatePermissionResource(PermissionResourceUpdateParam param) {
PermissionResourceEntity resource = permissionResourceConverter
.resourceUpdateParamConvertToEntity(param);
AppPermissionResourceEntity entity = getAppPermissionResourceEntity(
PermissionResourceEntity entity = getAppPermissionResourceEntity(
Long.valueOf(param.getId()));
buildActions(param.getActions(), resource);
BeanUtils.merge(resource, entity, LAST_MODIFIED_BY, LAST_MODIFIED_TIME);
// 查询资源下所有权限
List<AppPermissionActionEntity> actionList = appPermissionActionRepository
List<PermissionActionEntity> actionList = appPermissionActionRepository
.findAllByResource(resource);
// 取出未删除的权限id
Set<Long> reservedSet = resource.getActions().stream().map(AppPermissionActionEntity::getId)
Set<Long> reservedSet = resource.getActions().stream().map(PermissionActionEntity::getId)
.collect(Collectors.toSet());
// 过滤要删除的权限id
List<Long> removeActions = actionList.stream()
.filter(item -> !reservedSet.contains(item.getId()))
.map(AppPermissionActionEntity::getId).toList();
.map(PermissionActionEntity::getId).toList();
appPermissionActionRepository.deleteAllById(removeActions);
// 更新资源
appResourceRepository.save(entity);
@ -198,9 +198,9 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
*
*
* @param id {@link Long}
* @return {@link AppPermissionResourceEntity}
* @return {@link PermissionResourceEntity}
*/
private AppPermissionResourceEntity getAppPermissionResourceEntity(Long id) {
private PermissionResourceEntity getAppPermissionResourceEntity(Long id) {
return appResourceRepository.findById(id)
.orElseThrow(() -> new BadParamsException("应用权限资源不存在"));
}
@ -219,7 +219,7 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
public Boolean permissionResourceParamCheck(CheckValidityType type, String value, Long appId,
Long id) {
QAppPermissionResourceEntity role = QAppPermissionResourceEntity.appPermissionResourceEntity;
AppPermissionResourceEntity entity = new AppPermissionResourceEntity();
PermissionResourceEntity entity = new PermissionResourceEntity();
boolean result = false;
// ID存在说明是修改操作查询一下当前数据
if (Objects.nonNull(id)) {
@ -248,15 +248,15 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
/**
* actions
*
* @param permissions {@link List<AppPermissionsActionParam>}
* @param resource {@link AppPermissionResourceEntity>}
* @param permissions {@link List< PermissionsActionParam >}
* @param resource {@link PermissionResourceEntity >}
*/
private void buildActions(List<AppPermissionsActionParam> permissions,
AppPermissionResourceEntity resource) {
private void buildActions(List<PermissionsActionParam> permissions,
PermissionResourceEntity resource) {
// 权限
List<AppPermissionActionEntity> list = new ArrayList<>();
for (AppPermissionsActionParam p : permissions) {
AppPermissionActionEntity entity = new AppPermissionActionEntity();
List<PermissionActionEntity> list = new ArrayList<>();
for (PermissionsActionParam p : permissions) {
PermissionActionEntity entity = new PermissionActionEntity();
entity.setResource(resource);
entity.setType(p.getType());
entity.setName(p.getName());
@ -267,7 +267,7 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
resource.setActions(list);
}
private final AppPermissionResourceConverter appPermissionResourceConverter;
private final PermissionResourceConverter permissionResourceConverter;
private final AppPermissionResourceRepository appResourceRepository;
/**

View File

@ -15,13 +15,17 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.console.service.app.impl;
package cn.topiam.employee.console.service.permission.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import cn.topiam.employee.console.converter.permission.PermissionRoleConverter;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.permission.PermissionRoleResult;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;
@ -33,19 +37,15 @@ import com.querydsl.core.types.dsl.BooleanExpression;
import cn.topiam.employee.audit.context.AuditContext;
import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType;
import cn.topiam.employee.common.entity.app.AppPermissionRoleEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionRoleEntity;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.common.exception.app.AppRoleNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.app.AppPermissionRoleRepository;
import cn.topiam.employee.console.converter.app.AppPermissionRoleConverter;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionRoleService;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.permission.AppPermissionRoleRepository;
import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.service.permission.PermissionRoleService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.util.BeanUtils;
@ -64,34 +64,34 @@ import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIF
*/
@Service
@RequiredArgsConstructor
public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
public class PermissionRoleServiceImpl implements PermissionRoleService {
/**
*
*
* @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult}
* @return {@link PermissionRoleListResult}
*/
@Override
public Page<AppPermissionRoleListResult> getPermissionRoleList(PageModel page,
AppPermissionRoleListQuery query) {
org.springframework.data.domain.Page<AppPermissionRoleEntity> data;
Predicate predicate = appPermissionRoleConverter
public Page<PermissionRoleListResult> getPermissionRoleList(PageModel page,
PermissionRoleListQuery query) {
org.springframework.data.domain.Page<PermissionRoleEntity> data;
Predicate predicate = permissionRoleConverter
.rolePaginationParamConvertToPredicate(query);
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appPermissionRoleRepository.findAll(predicate, request);
return appPermissionRoleConverter.entityConvertToRolePaginationResult(data);
return permissionRoleConverter.entityConvertToRolePaginationResult(data);
}
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean}
*/
@Override
public boolean createPermissionRole(AppPermissionRoleCreateParam param) {
AppPermissionRoleEntity entity = appPermissionRoleConverter
public boolean createPermissionRole(PermissionRoleCreateParam param) {
PermissionRoleEntity entity = permissionRoleConverter
.roleCreateParamConvertToEntity(param);
appPermissionRoleRepository.save(entity);
AuditContext.setTarget(Target.builder().id(entity.getId().toString())
@ -105,9 +105,9 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
*/
@Override
public boolean updatePermissionRole(PermissionRoleUpdateParam param) {
AppPermissionRoleEntity source = appPermissionRoleConverter
PermissionRoleEntity source = permissionRoleConverter
.roleUpdateParamConvertToEntity(param);
AppPermissionRoleEntity target = appPermissionRoleRepository
PermissionRoleEntity target = appPermissionRoleRepository
.findById(Long.valueOf(param.getId())).orElseThrow(AppRoleNotExistException::new);
BeanUtils.merge(source, target, LAST_MODIFIED_TIME, LAST_MODIFIED_BY);
appPermissionRoleRepository.save(target);
@ -140,14 +140,14 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
*
*
* @param id {@link Long}
* @return {@link AppPermissionRoleResult}
* @return {@link PermissionRoleResult}
*/
@Override
public AppPermissionRoleResult getPermissionRole(Long id) {
public PermissionRoleResult getPermissionRole(Long id) {
//查询
Optional<AppPermissionRoleEntity> entity = appPermissionRoleRepository.findById(id);
Optional<PermissionRoleEntity> entity = appPermissionRoleRepository.findById(id);
//映射
return appPermissionRoleConverter.entityConvertToRoleDetailResult(entity.orElse(null));
return permissionRoleConverter.entityConvertToRoleDetailResult(entity.orElse(null));
}
/**
@ -164,7 +164,7 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
public Boolean permissionRoleParamCheck(CheckValidityType type, String value, Long appId,
Long id) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;
AppPermissionRoleEntity entity = new AppPermissionRoleEntity();
PermissionRoleEntity entity = new PermissionRoleEntity();
boolean result = false;
// ID存在说明是修改操作查询一下当前数据
if (Objects.nonNull(id)) {
@ -208,7 +208,7 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
/**
*
*/
private final AppPermissionRoleConverter appPermissionRoleConverter;
private final PermissionRoleConverter permissionRoleConverter;
/**
* RoleRepository
*/

View File

@ -20,7 +20,7 @@ package cn.topiam.employee.console.service.setting;
import cn.topiam.employee.console.pojo.result.setting.EmailProviderConfigResult;
import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam;
import cn.topiam.employee.console.pojo.setting.SmsProviderConfigResult;
import cn.topiam.employee.console.pojo.result.setting.SmsProviderConfigResult;
/**
*

View File

@ -25,7 +25,7 @@ import cn.topiam.employee.console.converter.setting.MessageSettingConverter;
import cn.topiam.employee.console.pojo.result.setting.EmailProviderConfigResult;
import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam;
import cn.topiam.employee.console.pojo.setting.SmsProviderConfigResult;
import cn.topiam.employee.console.pojo.result.setting.SmsProviderConfigResult;
import cn.topiam.employee.console.service.setting.MessageSettingService;
import cn.topiam.employee.support.context.ApplicationContextHelp;
import static cn.topiam.employee.common.constant.ConfigBeanNameConstants.MAIL_PROVIDER_SEND;

View File

@ -15,12 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.openapi.converter.app;
package cn.topiam.employee.openapi.converter.permission;
import cn.topiam.employee.common.entity.permission.PermissionActionEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import cn.topiam.employee.common.entity.app.AppPermissionActionEntity;
import cn.topiam.employee.openapi.pojo.request.app.AppPermissionsActionParam;
/**
@ -31,7 +31,7 @@ import cn.topiam.employee.openapi.pojo.request.app.AppPermissionsActionParam;
*/
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
@Mapper(componentModel = "spring")
public interface AppPermissionActionConverter {
public interface PermissionActionConverter {
@Mapping(target = "updateTime", ignore = true)
@Mapping(target = "updateBy", ignore = true)
@Mapping(target = "resource", ignore = true)
@ -40,7 +40,7 @@ public interface AppPermissionActionConverter {
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionActionEntity toEntity(AppPermissionsActionParam dto);
PermissionActionEntity toEntity(AppPermissionsActionParam dto);
AppPermissionsActionParam toDTO(AppPermissionActionEntity entities);
AppPermissionsActionParam toDTO(PermissionActionEntity entities);
}

View File

@ -15,16 +15,16 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.openapi.converter.app;
package cn.topiam.employee.openapi.converter.permission;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionPolicyEntity;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.util.CollectionUtils;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionPolicyCreateParam;
import cn.topiam.employee.openapi.pojo.request.app.update.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page;
@ -35,14 +35,14 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class)
public interface AppPermissionPolicyConverter {
@Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface PermissionPolicyConverter {
/**
*
*
* @param param {@link AppPermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity}
* @return {@link PermissionPolicyEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true)
@ -51,13 +51,13 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionPolicyEntity policyCreateParamConvertToEntity(AppPermissionPolicyCreateParam param);
PermissionPolicyEntity policyCreateParamConvertToEntity(AppPermissionPolicyCreateParam param);
/**
*
*
* @param param {@link AppPermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity}
* @return {@link PermissionPolicyEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "updateTime", ignore = true)
@ -65,7 +65,7 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionPolicyEntity policyUpdateParamConvertToEntity(AppPermissionPolicyUpdateParam param);
PermissionPolicyEntity policyUpdateParamConvertToEntity(AppPermissionPolicyUpdateParam param);
/**
*
@ -73,9 +73,9 @@ public interface AppPermissionPolicyConverter {
* @param page {@link Page}
* @return {@link Page}
*/
default Page<AppPermissionPolicyPO> entityConvertToPolicyListResult(org.springframework.data.domain.Page<AppPermissionPolicyPO> page) {
Page<AppPermissionPolicyPO> result = new Page<>();
List<AppPermissionPolicyPO> pageList = page.getContent();
default Page<PermissionPolicyPO> entityConvertToPolicyListResult(org.springframework.data.domain.Page<PermissionPolicyPO> page) {
Page<PermissionPolicyPO> result = new Page<>();
List<PermissionPolicyPO> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) {
//@formatter:off
result.setPagination(Page.Pagination.builder()

View File

@ -15,11 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.openapi.converter.app;
package cn.topiam.employee.openapi.converter.permission;
import java.util.ArrayList;
import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -28,7 +29,6 @@ import org.springframework.util.CollectionUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.openapi.pojo.request.app.query.AppResourceListQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionResourceCreateParam;
@ -43,8 +43,8 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class)
public interface AppPermissionResourceConverter {
@Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface PermissionResourceConverter {
/**
*
@ -70,7 +70,7 @@ public interface AppPermissionResourceConverter {
*
*
* @param param {@link AppPermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity}
* @return {@link PermissionResourceEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "actions", ignore = true)
@ -80,13 +80,13 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionResourceEntity resourceCreateParamConvertToEntity(AppPermissionResourceCreateParam param);
PermissionResourceEntity resourceCreateParamConvertToEntity(AppPermissionResourceCreateParam param);
/**
*
*
* @param param {@link AppPermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity}
* @return {@link PermissionResourceEntity}
*/
@Mapping(target = "enabled", expression = "java(Boolean.TRUE)")
@Mapping(target = "deleted", ignore = true)
@ -98,7 +98,7 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionResourceEntity resourceUpdateParamConvertToEntity(AppPermissionResourceUpdateParam param);
PermissionResourceEntity resourceUpdateParamConvertToEntity(AppPermissionResourceUpdateParam param);
/**
*
@ -106,12 +106,12 @@ public interface AppPermissionResourceConverter {
* @param page {@link Page}
* @return {@link Page}
*/
default Page<AppPermissionResourceListResult> entityConvertToResourceListResult(org.springframework.data.domain.Page<AppPermissionResourceEntity> page) {
default Page<AppPermissionResourceListResult> entityConvertToResourceListResult(org.springframework.data.domain.Page<PermissionResourceEntity> page) {
Page<AppPermissionResourceListResult> result = new Page<>();
List<AppPermissionResourceEntity> pageList = page.getContent();
List<PermissionResourceEntity> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) {
List<AppPermissionResourceListResult> list = new ArrayList<>();
for (AppPermissionResourceEntity resource : pageList) {
for (PermissionResourceEntity resource : pageList) {
list.add(entityConvertToResourceListResult(resource));
}
//@formatter:off
@ -129,17 +129,17 @@ public interface AppPermissionResourceConverter {
/**
*
*
* @param data {@link AppPermissionResourceEntity}
* @param data {@link PermissionResourceEntity}
* @return {@link AppPermissionResourceListResult}
*/
AppPermissionResourceListResult entityConvertToResourceListResult(AppPermissionResourceEntity data);
AppPermissionResourceListResult entityConvertToResourceListResult(PermissionResourceEntity data);
/**
*
*
* @param resource {@link AppPermissionResourceEntity}
* @param resource {@link PermissionResourceEntity}
* @return {@link AppPermissionResourceGetResult}
*/
@Mapping(target = "actions", source = "actions")
AppPermissionResourceGetResult entityConvertToResourceGetResult(AppPermissionResourceEntity resource);
AppPermissionResourceGetResult entityConvertToResourceGetResult(PermissionResourceEntity resource);
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.openapi.converter.app;
package cn.topiam.employee.openapi.converter.permission;
import java.util.ArrayList;
import java.util.List;
@ -29,8 +29,8 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionRoleEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionRoleEntity;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import cn.topiam.employee.openapi.pojo.request.app.query.AppPermissionRoleListQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionRoleCreateParam;
import cn.topiam.employee.openapi.pojo.request.app.update.PermissionRoleUpdateParam;
@ -45,7 +45,7 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* Created by support@topiam.cn on 2020/8/14 22:45
*/
@Mapper(componentModel = "spring")
public interface AppPermissionRoleConverter {
public interface PermissionRoleConverter {
/**
*
@ -53,11 +53,11 @@ public interface AppPermissionRoleConverter {
* @param page {@link Page}
* @return {@link Page}
*/
default Page<AppPermissionRoleListResult> entityConvertToRolePaginationResult(org.springframework.data.domain.Page<AppPermissionRoleEntity> page) {
default Page<AppPermissionRoleListResult> entityConvertToRolePaginationResult(org.springframework.data.domain.Page<PermissionRoleEntity> page) {
Page<AppPermissionRoleListResult> result = new Page<>();
if (!CollectionUtils.isEmpty(page.getContent())) {
List<AppPermissionRoleListResult> list = new ArrayList<>();
for (AppPermissionRoleEntity user : page.getContent()) {
for (PermissionRoleEntity user : page.getContent()) {
list.add(entityConvertToRolePaginationResult(user));
}
//@formatter:off
@ -75,16 +75,16 @@ public interface AppPermissionRoleConverter {
/**
*
*
* @param page {@link AppPermissionRoleEntity}
* @param page {@link PermissionRoleEntity}
* @return {@link AppPermissionRoleListResult}
*/
AppPermissionRoleListResult entityConvertToRolePaginationResult(AppPermissionRoleEntity page);
AppPermissionRoleListResult entityConvertToRolePaginationResult(PermissionRoleEntity page);
/**
*
*
* @param param {@link AppPermissionRoleCreateParam}
* @return {@link AppPermissionRoleEntity}
* @return {@link PermissionRoleEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true)
@ -93,13 +93,13 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionRoleEntity roleCreateParamConvertToEntity(AppPermissionRoleCreateParam param);
PermissionRoleEntity roleCreateParamConvertToEntity(AppPermissionRoleCreateParam param);
/**
*
*
* @param param {@link PermissionRoleUpdateParam}
* @return {@link AppPermissionRoleEntity}
* @return {@link PermissionRoleEntity}
*/
@Mapping(target = "deleted", ignore = true)
@Mapping(target = "appId", ignore = true)
@ -108,21 +108,21 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true)
AppPermissionRoleEntity roleUpdateParamConvertToEntity(PermissionRoleUpdateParam param);
PermissionRoleEntity roleUpdateParamConvertToEntity(PermissionRoleUpdateParam param);
/**
*
*
* @param role {@link AppPermissionRoleEntity}
* @param role {@link PermissionRoleEntity}
* @return {@link AppPermissionRoleResult}
*/
AppPermissionRoleResult entityConvertToRoleDetailResult(AppPermissionRoleEntity role);
AppPermissionRoleResult entityConvertToRoleDetailResult(PermissionRoleEntity role);
/**
*
*
* @param query {@link AppPermissionRoleListQuery}
* @return {@link AppPermissionRoleEntity}
* @return {@link PermissionRoleEntity}
*/
default Predicate rolePaginationParamConvertToPredicate(AppPermissionRoleListQuery query) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;

View File

@ -17,14 +17,14 @@
*/
package cn.topiam.employee.openapi.endpoint.permission;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.openapi.pojo.request.app.query.OpenApiPolicyQuery;
import cn.topiam.employee.openapi.service.AppPermissionPolicyService;
import cn.topiam.employee.openapi.service.PermissionPolicyService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.result.ApiRestResult;
@ -43,21 +43,21 @@ import static cn.topiam.employee.openapi.constants.OpenApiV1Constants.OPEN_API_P
@RestController
@RequestMapping(value = OPEN_API_PERMISSION_PATH + "/policy")
@RequiredArgsConstructor
public class AppPermissionPolicyEndpoint {
public class PermissionPolicyEndpoint {
/**
*
*
* @param page {@link PageModel}
* @return {@link AppPermissionPolicyPO}
* @return {@link PermissionPolicyPO}
*/
@Operation(summary = "获取策略列表")
@GetMapping(value = "/list")
public ApiRestResult<Page<AppPermissionPolicyPO>> getPermissionPolicyList(PageModel page,
@Validated OpenApiPolicyQuery query) {
Page<AppPermissionPolicyPO> result = permissionPolicyService.getPermissionPolicyList(page,
public ApiRestResult<Page<PermissionPolicyPO>> getPermissionPolicyList(PageModel page,
@Validated OpenApiPolicyQuery query) {
Page<PermissionPolicyPO> result = permissionPolicyService.getPermissionPolicyList(page,
query);
return ApiRestResult.<Page<AppPermissionPolicyPO>> builder().result(result).build();
return ApiRestResult.<Page<PermissionPolicyPO>> builder().result(result).build();
}
private final AppPermissionPolicyService permissionPolicyService;
private final PermissionPolicyService permissionPolicyService;
}

View File

@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
import cn.topiam.employee.openapi.pojo.request.app.query.AppResourceListQuery;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionResourceListResult;
import cn.topiam.employee.openapi.service.AppPermissionResourceService;
import cn.topiam.employee.openapi.service.PermissionResourceService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.result.ApiRestResult;
@ -43,7 +43,7 @@ import static cn.topiam.employee.openapi.constants.OpenApiV1Constants.OPEN_API_P
@RestController
@RequestMapping(value = OPEN_API_PERMISSION_PATH + "/resource")
@RequiredArgsConstructor
public class AppPermissionResourceEndpoint {
public class PermissionResourceEndpoint {
/**
*
*
@ -54,7 +54,7 @@ public class AppPermissionResourceEndpoint {
@GetMapping(value = "/list")
public ApiRestResult<Page<AppPermissionResourceListResult>> getPermissionResourceList(PageModel page,
@Validated AppResourceListQuery query) {
Page<AppPermissionResourceListResult> result = appPermissionResourceService
Page<AppPermissionResourceListResult> result = permissionResourceService
.getPermissionResourceList(page, query);
return ApiRestResult.<Page<AppPermissionResourceListResult>> builder().result(result)
.build();
@ -68,5 +68,5 @@ public class AppPermissionResourceEndpoint {
/**
*
*/
private final AppPermissionResourceService appPermissionResourceService;
private final PermissionResourceService permissionResourceService;
}

View File

@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
import cn.topiam.employee.openapi.pojo.request.app.query.AppPermissionRoleListQuery;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionRoleListResult;
import cn.topiam.employee.openapi.service.AppPermissionRoleService;
import cn.topiam.employee.openapi.service.PermissionRoleService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.result.ApiRestResult;
@ -43,7 +43,7 @@ import static cn.topiam.employee.openapi.constants.OpenApiV1Constants.OPEN_API_P
@RestController
@RequestMapping(value = OPEN_API_PERMISSION_PATH + "/role")
@RequiredArgsConstructor
public class AppPermissionRoleEndpoint {
public class PermissionRoleEndpoint {
//1、获取应用的所有角色分页
/**
*
@ -55,7 +55,7 @@ public class AppPermissionRoleEndpoint {
@GetMapping(value = "/list")
public ApiRestResult<Page<AppPermissionRoleListResult>> getPermissionRoleList(PageModel page,
@Validated AppPermissionRoleListQuery query) {
Page<AppPermissionRoleListResult> result = appPermissionRoleService
Page<AppPermissionRoleListResult> result = permissionRoleService
.getPermissionRoleList(page, query);
return ApiRestResult.<Page<AppPermissionRoleListResult>> builder().result(result).build();
}
@ -68,5 +68,5 @@ public class AppPermissionRoleEndpoint {
/**
*
*/
private final AppPermissionRoleService appPermissionRoleService;
private final PermissionRoleService permissionRoleService;
}

View File

@ -33,7 +33,7 @@ import cn.topiam.employee.openapi.pojo.response.app.AppPermissionActionListResul
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionActionService {
public interface PermissionActionService {
/**
*
*

View File

@ -17,7 +17,7 @@
*/
package cn.topiam.employee.openapi.service;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import cn.topiam.employee.openapi.pojo.request.app.query.OpenApiPolicyQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionPolicyCreateParam;
import cn.topiam.employee.openapi.pojo.request.app.update.AppPermissionPolicyUpdateParam;
@ -33,15 +33,15 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionPolicyService {
public interface PermissionPolicyService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link OpenApiPolicyQuery}
* @return {@link AppPermissionPolicyPO}
* @return {@link PermissionPolicyPO}
*/
Page<AppPermissionPolicyPO> getPermissionPolicyList(PageModel page, OpenApiPolicyQuery query);
Page<PermissionPolicyPO> getPermissionPolicyList(PageModel page, OpenApiPolicyQuery query);
/**
*

View File

@ -34,7 +34,7 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionResourceService {
public interface PermissionResourceService {
/**
*
*

View File

@ -34,7 +34,7 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM
* Created by support@topiam.cn on 2020-08-10
*/
public interface AppPermissionRoleService {
public interface PermissionRoleService {
/**
*

View File

@ -26,7 +26,7 @@ import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionActionCreat
import cn.topiam.employee.openapi.pojo.request.app.update.ResourceActionUpdateParam;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionActionGetResult;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionActionListResult;
import cn.topiam.employee.openapi.service.AppPermissionActionService;
import cn.topiam.employee.openapi.service.PermissionActionService;
import lombok.RequiredArgsConstructor;
@ -40,7 +40,7 @@ import lombok.RequiredArgsConstructor;
*/
@Service
@RequiredArgsConstructor
public class AppPermissionActionServiceImpl implements AppPermissionActionService {
public class PermissionActionServiceImpl implements PermissionActionService {
/**
*

View File

@ -17,21 +17,21 @@
*/
package cn.topiam.employee.openapi.service.impl;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
import cn.topiam.employee.common.entity.permission.PermissionPolicyEntity;
import cn.topiam.employee.common.exception.app.AppPolicyNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository;
import cn.topiam.employee.openapi.converter.app.AppPermissionPolicyConverter;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.openapi.converter.permission.PermissionPolicyConverter;
import cn.topiam.employee.openapi.pojo.request.app.query.OpenApiPolicyQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionPolicyCreateParam;
import cn.topiam.employee.openapi.pojo.request.app.update.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionPolicyGetResult;
import cn.topiam.employee.openapi.service.AppPermissionPolicyService;
import cn.topiam.employee.openapi.service.PermissionPolicyService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -47,18 +47,18 @@ import lombok.RequiredArgsConstructor;
*/
@Service
@RequiredArgsConstructor
public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyService {
public class PermissionPolicyServiceImpl implements PermissionPolicyService {
/**
*
*
* @param page {@link PageModel}
* @param query {@link OpenApiPolicyQuery}
* @return {@link AppPermissionPolicyPO}
* @return {@link PermissionPolicyPO}
*/
@Override
public Page<AppPermissionPolicyPO> getPermissionPolicyList(PageModel page,
OpenApiPolicyQuery query) {
public Page<PermissionPolicyPO> getPermissionPolicyList(PageModel page,
OpenApiPolicyQuery query) {
AppPolicyQuery appPolicyQuery = new AppPolicyQuery();
// TODO token获取所属应用
// appPolicyQuery.setAppId(0L);
@ -68,9 +68,9 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
appPolicyQuery.setSubjectType(query.getSubjectType());
appPolicyQuery.setObjectType(query.getObjectType());
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
org.springframework.data.domain.Page<AppPermissionPolicyPO> data = appPermissionPolicyRepository
org.springframework.data.domain.Page<PermissionPolicyPO> data = appPermissionPolicyRepository
.findPage(appPolicyQuery, request);
return appPermissionPolicyConverter.entityConvertToPolicyListResult(data);
return permissionPolicyConverter.entityConvertToPolicyListResult(data);
}
/**
@ -108,7 +108,7 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean createPermissionPolicy(AppPermissionPolicyCreateParam param) {
AppPermissionPolicyEntity resource = appPermissionPolicyConverter
PermissionPolicyEntity resource = permissionPolicyConverter
.policyCreateParamConvertToEntity(param);
// 新增策略
appPermissionPolicyRepository.save(resource);
@ -123,14 +123,14 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
*/
@Override
public Boolean updatePermissionPolicy(AppPermissionPolicyUpdateParam param) {
AppPermissionPolicyEntity resource = appPermissionPolicyConverter
PermissionPolicyEntity resource = permissionPolicyConverter
.policyUpdateParamConvertToEntity(param);
// 更新策略
appPermissionPolicyRepository.save(resource);
return null;
}
private final AppPermissionPolicyConverter appPermissionPolicyConverter;
private final PermissionPolicyConverter permissionPolicyConverter;
private final AppPermissionPolicyRepository appPermissionPolicyRepository;
}

View File

@ -23,6 +23,9 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import cn.topiam.employee.common.entity.permission.PermissionActionEntity;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import cn.topiam.employee.openapi.converter.permission.PermissionResourceConverter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;
@ -31,15 +34,12 @@ import org.springframework.transaction.annotation.Transactional;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import cn.topiam.employee.common.entity.app.AppPermissionActionEntity;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.common.exception.app.AppResourceNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionActionRepository;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.app.AppPermissionResourceRepository;
import cn.topiam.employee.openapi.converter.app.AppPermissionResourceConverter;
import cn.topiam.employee.common.repository.permission.AppPermissionActionRepository;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.permission.AppPermissionResourceRepository;
import cn.topiam.employee.openapi.pojo.request.app.AppPermissionsActionParam;
import cn.topiam.employee.openapi.pojo.request.app.query.AppResourceListQuery;
import cn.topiam.employee.openapi.pojo.request.app.query.OpenApiPolicyQuery;
@ -47,7 +47,7 @@ import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionResourceCre
import cn.topiam.employee.openapi.pojo.request.app.update.AppPermissionResourceUpdateParam;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionResourceGetResult;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionResourceListResult;
import cn.topiam.employee.openapi.service.AppPermissionResourceService;
import cn.topiam.employee.openapi.service.PermissionResourceService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -63,7 +63,7 @@ import lombok.RequiredArgsConstructor;
*/
@Service
@RequiredArgsConstructor
public class AppPermissionResourceServiceImpl implements AppPermissionResourceService {
public class PermissionResourceServiceImpl implements PermissionResourceService {
/**
*
@ -75,12 +75,12 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
@Override
public Page<AppPermissionResourceListResult> getPermissionResourceList(PageModel page,
AppResourceListQuery query) {
org.springframework.data.domain.Page<AppPermissionResourceEntity> data;
Predicate predicate = appPermissionResourceConverter
org.springframework.data.domain.Page<PermissionResourceEntity> data;
Predicate predicate = permissionResourceConverter
.resourcePaginationParamConvertToPredicate(query);
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appResourceRepository.findAll(predicate, request);
return appPermissionResourceConverter.entityConvertToResourceListResult(data);
return permissionResourceConverter.entityConvertToResourceListResult(data);
}
/**
@ -91,9 +91,9 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
*/
@Override
public AppPermissionResourceGetResult getPermissionResource(String id) {
AppPermissionResourceEntity resource = appResourceRepository.findById(Long.valueOf(id))
PermissionResourceEntity resource = appResourceRepository.findById(Long.valueOf(id))
.orElseThrow(AppResourceNotExistException::new);
return appPermissionResourceConverter.entityConvertToResourceGetResult(resource);
return permissionResourceConverter.entityConvertToResourceGetResult(resource);
}
/**
@ -106,12 +106,12 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
@Transactional(rollbackFor = Exception.class)
public Boolean deletePermissionResource(String id) {
Long resourceId = Long.valueOf(id);
AppPermissionResourceEntity resource = appResourceRepository.findById(resourceId)
PermissionResourceEntity resource = appResourceRepository.findById(resourceId)
.orElseThrow(AppResourceNotExistException::new);
List<AppPermissionActionEntity> actionList = appPermissionActionRepository
List<PermissionActionEntity> actionList = appPermissionActionRepository
.findAllByResource(resource);
List<Long> objectIdList = new ArrayList<>(
actionList.stream().map(AppPermissionActionEntity::getId).toList());
actionList.stream().map(PermissionActionEntity::getId).toList());
objectIdList.add(resourceId);
appPermissionPolicyRepository.deleteAllByObjectIdIn(objectIdList);
appResourceRepository.deleteById(resourceId);
@ -127,7 +127,7 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean createPermissionResource(AppPermissionResourceCreateParam param) {
AppPermissionResourceEntity resource = appPermissionResourceConverter
PermissionResourceEntity resource = permissionResourceConverter
.resourceCreateParamConvertToEntity(param);
buildActions(param.getActions(), resource);
// 新增资源
@ -144,19 +144,19 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updatePermissionResource(AppPermissionResourceUpdateParam param) {
AppPermissionResourceEntity resource = appPermissionResourceConverter
PermissionResourceEntity resource = permissionResourceConverter
.resourceUpdateParamConvertToEntity(param);
buildActions(param.getActions(), resource);
// 查询资源下所有权限
List<AppPermissionActionEntity> actionList = appPermissionActionRepository
List<PermissionActionEntity> actionList = appPermissionActionRepository
.findAllByResource(resource);
// 取出未删除的权限id
Set<Long> reservedSet = resource.getActions().stream().map(AppPermissionActionEntity::getId)
Set<Long> reservedSet = resource.getActions().stream().map(PermissionActionEntity::getId)
.collect(Collectors.toSet());
// 过滤要删除的权限id
List<Long> removeActions = actionList.stream()
.filter(item -> reservedSet.contains(item.getId()))
.map(AppPermissionActionEntity::getId).toList();
.map(PermissionActionEntity::getId).toList();
appPermissionPolicyRepository.deleteAllByObjectIdIn(removeActions);
// 更新资源
appResourceRepository.save(resource);
@ -177,7 +177,7 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
public Boolean permissionResourceParamCheck(CheckValidityType type, String value, Long appId,
Long id) {
QAppPermissionResourceEntity role = QAppPermissionResourceEntity.appPermissionResourceEntity;
AppPermissionResourceEntity entity = new AppPermissionResourceEntity();
PermissionResourceEntity entity = new PermissionResourceEntity();
boolean result = false;
// ID存在说明是修改操作查询一下当前数据
if (Objects.nonNull(id)) {
@ -209,14 +209,14 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
* actions
*
* @param permissions {@link List<AppPermissionsActionParam>}
* @param resource {@link AppPermissionResourceEntity>}
* @param resource {@link PermissionResourceEntity >}
*/
private void buildActions(List<AppPermissionsActionParam> permissions,
AppPermissionResourceEntity resource) {
PermissionResourceEntity resource) {
// 权限
List<AppPermissionActionEntity> list = new ArrayList<>();
List<PermissionActionEntity> list = new ArrayList<>();
for (AppPermissionsActionParam p : permissions) {
AppPermissionActionEntity entity = new AppPermissionActionEntity();
PermissionActionEntity entity = new PermissionActionEntity();
entity.setResource(resource);
entity.setType(p.getType());
entity.setName(p.getName());
@ -227,7 +227,7 @@ public class AppPermissionResourceServiceImpl implements AppPermissionResourceSe
resource.setActions(list);
}
private final AppPermissionResourceConverter appPermissionResourceConverter;
private final PermissionResourceConverter permissionResourceConverter;
private final AppPermissionResourceRepository appResourceRepository;
/**

View File

@ -22,6 +22,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;
@ -30,19 +31,18 @@ import org.springframework.transaction.annotation.Transactional;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import cn.topiam.employee.common.entity.app.AppPermissionRoleEntity;
import cn.topiam.employee.common.entity.app.QAppPermissionRoleEntity;
import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.common.exception.app.AppRoleNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.app.AppPermissionRoleRepository;
import cn.topiam.employee.openapi.converter.app.AppPermissionRoleConverter;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.permission.AppPermissionRoleRepository;
import cn.topiam.employee.openapi.converter.permission.PermissionRoleConverter;
import cn.topiam.employee.openapi.pojo.request.app.query.AppPermissionRoleListQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionRoleCreateParam;
import cn.topiam.employee.openapi.pojo.request.app.update.PermissionRoleUpdateParam;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionRoleListResult;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionRoleResult;
import cn.topiam.employee.openapi.service.AppPermissionRoleService;
import cn.topiam.employee.openapi.service.PermissionRoleService;
import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.util.BeanUtils;
@ -61,7 +61,7 @@ import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIF
*/
@Service
@RequiredArgsConstructor
public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
public class PermissionRoleServiceImpl implements PermissionRoleService {
/**
*
@ -72,12 +72,12 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
@Override
public Page<AppPermissionRoleListResult> getPermissionRoleList(PageModel page,
AppPermissionRoleListQuery query) {
org.springframework.data.domain.Page<AppPermissionRoleEntity> data;
Predicate predicate = appPermissionRoleConverter
org.springframework.data.domain.Page<PermissionRoleEntity> data;
Predicate predicate = permissionRoleConverter
.rolePaginationParamConvertToPredicate(query);
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appPermissionRoleRepository.findAll(predicate, request);
return appPermissionRoleConverter.entityConvertToRolePaginationResult(data);
return permissionRoleConverter.entityConvertToRolePaginationResult(data);
}
/**
@ -88,7 +88,7 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
*/
@Override
public boolean createPermissionRole(AppPermissionRoleCreateParam param) {
AppPermissionRoleEntity entity = appPermissionRoleConverter
PermissionRoleEntity entity = permissionRoleConverter
.roleCreateParamConvertToEntity(param);
appPermissionRoleRepository.save(entity);
return true;
@ -100,9 +100,9 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
*/
@Override
public boolean updatePermissionRole(PermissionRoleUpdateParam param) {
AppPermissionRoleEntity source = appPermissionRoleConverter
PermissionRoleEntity source = permissionRoleConverter
.roleUpdateParamConvertToEntity(param);
AppPermissionRoleEntity target = appPermissionRoleRepository
PermissionRoleEntity target = appPermissionRoleRepository
.findById(Long.valueOf(param.getId())).orElseThrow(AppRoleNotExistException::new);
BeanUtils.merge(source, target, LAST_MODIFIED_TIME, LAST_MODIFIED_BY);
appPermissionRoleRepository.save(target);
@ -136,9 +136,9 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
@Override
public AppPermissionRoleResult getPermissionRole(Long id) {
//查询
Optional<AppPermissionRoleEntity> entity = appPermissionRoleRepository.findById(id);
Optional<PermissionRoleEntity> entity = appPermissionRoleRepository.findById(id);
//映射
return appPermissionRoleConverter.entityConvertToRoleDetailResult(entity.orElse(null));
return permissionRoleConverter.entityConvertToRoleDetailResult(entity.orElse(null));
}
/**
@ -155,7 +155,7 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
public Boolean permissionRoleParamCheck(CheckValidityType type, String value, Long appId,
Long id) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;
AppPermissionRoleEntity entity = new AppPermissionRoleEntity();
PermissionRoleEntity entity = new PermissionRoleEntity();
boolean result = false;
// ID存在说明是修改操作查询一下当前数据
if (Objects.nonNull(id)) {
@ -199,7 +199,7 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
/**
*
*/
private final AppPermissionRoleConverter appPermissionRoleConverter;
private final PermissionRoleConverter permissionRoleConverter;
/**
* RoleRepository
*/