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 * 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/>. * 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.io.Serial;
@ -48,7 +48,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Table(name = "app_permission_action") @Table(name = "app_permission_action")
@SQLDelete(sql = "update app_permission_action set " + SOFT_DELETE_SET + " where id_ = ?") @SQLDelete(sql = "update app_permission_action set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE) @Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionActionEntity extends LogicDeleteEntity<Long> { public class PermissionActionEntity extends LogicDeleteEntity<Long> {
@Serial @Serial
private static final long serialVersionUID = -3954680915360748087L; private static final long serialVersionUID = -3954680915360748087L;
@ -75,5 +75,5 @@ public class AppPermissionActionEntity extends LogicDeleteEntity<Long> {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "resource_id") @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 * 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/>. * 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.SQLDelete;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
@ -50,7 +50,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Table(name = "app_permission_policy") @Table(name = "app_permission_policy")
@SQLDelete(sql = "update app_permission_policy set " + SOFT_DELETE_SET + " where id_ = ?") @SQLDelete(sql = "update app_permission_policy set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE) @Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionPolicyEntity extends LogicDeleteEntity<Long> { public class PermissionPolicyEntity extends LogicDeleteEntity<Long> {
/** /**
* id * id

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.io.Serial;
import java.util.List; import java.util.List;
@ -52,7 +52,7 @@ import static jakarta.persistence.FetchType.LAZY;
@Table(name = "app_permission_resource") @Table(name = "app_permission_resource")
@SQLDelete(sql = "update app_permission_resource set " + SOFT_DELETE_SET + " where id_ = ?") @SQLDelete(sql = "update app_permission_resource set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE) @Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionResourceEntity extends LogicDeleteEntity<Long> { public class PermissionResourceEntity extends LogicDeleteEntity<Long> {
@Serial @Serial
private static final long serialVersionUID = 7342074686605139968L; private static final long serialVersionUID = 7342074686605139968L;
@ -93,5 +93,5 @@ public class AppPermissionResourceEntity extends LogicDeleteEntity<Long> {
@ToString.Exclude @ToString.Exclude
@OneToMany(mappedBy = "resource", fetch = LAZY, cascade = { CascadeType.PERSIST, @OneToMany(mappedBy = "resource", fetch = LAZY, cascade = { CascadeType.PERSIST,
CascadeType.REMOVE }) 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 * 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/>. * 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.io.Serial;
@ -51,7 +51,7 @@ import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOF
@Table(name = "app_permission_role") @Table(name = "app_permission_role")
@SQLDelete(sql = "update app_permission_role set " + SOFT_DELETE_SET + " where id_ = ?") @SQLDelete(sql = "update app_permission_role set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE) @Where(clause = SOFT_DELETE_WHERE)
public class AppPermissionRoleEntity extends LogicDeleteEntity<Long> { public class PermissionRoleEntity extends LogicDeleteEntity<Long> {
@Serial @Serial
private static final long serialVersionUID = -7761332532995424593L; 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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -38,7 +38,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Schema(description = "分页查询策略响应") @Schema(description = "分页查询策略响应")
public class AppPermissionPolicyPO implements Serializable { public class PermissionPolicyPO implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 3320953184046791392L; 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 java.util.List;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -28,10 +29,9 @@ import org.springframework.util.ObjectUtils;
import com.google.common.collect.Lists; 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.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.app.impl.mapper.AppPermissionPolicyPoMapper;
import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepositoryCustomized;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -49,7 +49,7 @@ public class AppPermissionPolicyRepositoryCustomizedImpl implements
} }
@Override @Override
public Page<AppPermissionPolicyPO> findPage(AppPolicyQuery query, Pageable pageable) { public Page<PermissionPolicyPO> findPage(AppPolicyQuery query, Pageable pageable) {
//查询条件 //查询条件
//@formatter:off //@formatter:off
// 所属应用 // 所属应用
@ -111,7 +111,7 @@ public class AppPermissionPolicyRepositoryCustomizedImpl implements
.append(" FROM app_permission_policy policy ").append(subjectJoin).append(objectJoin); .append(" FROM app_permission_policy policy ").append(subjectJoin).append(objectJoin);
// @formatter:off // @formatter:off
List<AppPermissionPolicyPO> list = jdbcTemplate List<PermissionPolicyPO> list = jdbcTemplate
.query( .query(
selectSql.append(" LIMIT ").append(pageable.getPageNumber() * pageable.getPageSize()) selectSql.append(" LIMIT ").append(pageable.getPageNumber() * pageable.getPageSize())
.append(",").append(pageable.getPageSize()).toString(), .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.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import cn.topiam.employee.common.entity.permission.po.PermissionPolicyPO;
import org.springframework.jdbc.core.RowMapper; 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.AppPolicyEffect;
import cn.topiam.employee.common.enums.app.AppPolicyObjectType; import cn.topiam.employee.common.enums.app.AppPolicyObjectType;
import cn.topiam.employee.common.enums.app.AppPolicySubjectType; import cn.topiam.employee.common.enums.app.AppPolicySubjectType;
@ -31,7 +31,7 @@ import cn.topiam.employee.common.enums.app.AppPolicySubjectType;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2022/2/13 23:25 * 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 * Implementations must implement this method to map each row of data
@ -46,18 +46,18 @@ public class AppPermissionPolicyPoMapper implements RowMapper<AppPermissionPolic
*/ */
@SuppressWarnings("DuplicatedCode") @SuppressWarnings("DuplicatedCode")
@Override @Override
public AppPermissionPolicyPO mapRow(ResultSet rs, int rowNum) throws SQLException { public PermissionPolicyPO mapRow(ResultSet rs, int rowNum) throws SQLException {
AppPermissionPolicyPO appPermissionPolicyPo = new AppPermissionPolicyPO(); PermissionPolicyPO permissionPolicyPo = new PermissionPolicyPO();
appPermissionPolicyPo.setId(rs.getLong("id_")); permissionPolicyPo.setId(rs.getLong("id_"));
appPermissionPolicyPo.setEffect(AppPolicyEffect.getType(rs.getString("effect"))); permissionPolicyPo.setEffect(AppPolicyEffect.getType(rs.getString("effect")));
appPermissionPolicyPo.setSubjectId(rs.getString("subject_id")); permissionPolicyPo.setSubjectId(rs.getString("subject_id"));
appPermissionPolicyPo permissionPolicyPo
.setSubjectType(AppPolicySubjectType.getType(rs.getString("subject_type"))); .setSubjectType(AppPolicySubjectType.getType(rs.getString("subject_type")));
appPermissionPolicyPo.setSubjectName(rs.getString("subject_name")); permissionPolicyPo.setSubjectName(rs.getString("subject_name"));
appPermissionPolicyPo.setObjectId(rs.getLong("object_id")); permissionPolicyPo.setObjectId(rs.getLong("object_id"));
appPermissionPolicyPo permissionPolicyPo
.setObjectType(AppPolicyObjectType.getType(rs.getString("object_type"))); .setObjectType(AppPolicyObjectType.getType(rs.getString("object_type")));
appPermissionPolicyPo.setObjectName(rs.getString("object_name")); permissionPolicyPo.setObjectName(rs.getString("object_name"));
return appPermissionPolicyPo; return permissionPolicyPo;
} }
} }

View File

@ -15,15 +15,15 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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 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.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository; 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; import cn.topiam.employee.support.repository.LogicDeleteRepository;
/** /**
@ -32,13 +32,13 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/ */
@Repository @Repository
public interface AppPermissionActionRepository extends public interface AppPermissionActionRepository extends
LogicDeleteRepository<AppPermissionActionEntity, Long>, LogicDeleteRepository<PermissionActionEntity, Long>,
QuerydslPredicateExecutor<AppPermissionActionEntity> { QuerydslPredicateExecutor<PermissionActionEntity> {
/** /**
* findAllByResource * findAllByResource
* *
* @param resource {@link AppPermissionResourceEntity} * @param resource {@link PermissionResourceEntity}
* @return {@link List} * @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 * 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/>. * 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.io.Serializable;
import java.util.Collection; 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.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor; 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.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository; import cn.topiam.employee.support.repository.LogicDeleteRepository;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET; 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 @Repository
public interface AppPermissionPolicyRepository extends AppPermissionPolicyRepositoryCustomized, public interface AppPermissionPolicyRepository extends AppPermissionPolicyRepositoryCustomized,
LogicDeleteRepository<AppPermissionPolicyEntity, Long>, LogicDeleteRepository<PermissionPolicyEntity, Long>,
QuerydslPredicateExecutor<AppPermissionPolicyEntity> { QuerydslPredicateExecutor<PermissionPolicyEntity> {
/** /**
* ID * ID
* *
@ -81,6 +81,6 @@ public interface AppPermissionPolicyRepository extends AppPermissionPolicyReposi
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Modifying @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); 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 * 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/>. * 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.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import cn.topiam.employee.common.entity.app.po.AppPermissionPolicyPO;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery; import cn.topiam.employee.common.entity.app.query.AppPolicyQuery;
/** /**
@ -33,7 +33,7 @@ public interface AppPermissionPolicyRepositoryCustomized {
* *
* @param query {@link AppPolicyQuery} * @param query {@link AppPolicyQuery}
* @param request {@link Pageable} * @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 * 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/>. * 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 java.util.Optional;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository; import cn.topiam.employee.support.repository.LogicDeleteRepository;
/** /**
@ -38,16 +38,16 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/ */
@Repository @Repository
public interface AppPermissionResourceRepository extends public interface AppPermissionResourceRepository extends
LogicDeleteRepository<AppPermissionResourceEntity, Long>, LogicDeleteRepository<PermissionResourceEntity, Long>,
QuerydslPredicateExecutor<AppPermissionResourceEntity> { QuerydslPredicateExecutor<PermissionResourceEntity> {
/** /**
* findByIdContainsDeleted * findByIdContainsDeleted
* *
* @param id must not be {@literal null}. * @param id must not be {@literal null}.
* @return {@link AppPermissionResourceEntity} * @return {@link PermissionResourceEntity}
*/ */
@NotNull @NotNull
@Query(value = "SELECT * FROM app_permission_resource WHERE id_ = :id", nativeQuery = true) @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 * 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/>. * 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 java.util.Optional;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying; 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.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import cn.topiam.employee.common.entity.app.AppPermissionRoleEntity;
import cn.topiam.employee.support.repository.LogicDeleteRepository; import cn.topiam.employee.support.repository.LogicDeleteRepository;
/** /**
@ -41,8 +41,8 @@ import cn.topiam.employee.support.repository.LogicDeleteRepository;
*/ */
@Repository @Repository
public interface AppPermissionRoleRepository extends public interface AppPermissionRoleRepository extends
LogicDeleteRepository<AppPermissionRoleEntity, Long>, LogicDeleteRepository<PermissionRoleEntity, Long>,
QuerydslPredicateExecutor<AppPermissionRoleEntity> { QuerydslPredicateExecutor<PermissionRoleEntity> {
/** /**
* *
* *
@ -58,10 +58,10 @@ public interface AppPermissionRoleRepository extends
* findByIdContainsDeleted * findByIdContainsDeleted
* *
* @param id must not be {@literal null}. * @param id must not be {@literal null}.
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
@NotNull @NotNull
@Cacheable @Cacheable
@Query(value = "SELECT * FROM app_permission_role WHERE id_ = :id", nativeQuery = true) @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 * 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/>. * 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 java.util.List;
import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult; import cn.topiam.employee.console.service.permission.PermissionActionService;
import cn.topiam.employee.console.service.app.AppPermissionActionService;
import cn.topiam.employee.support.result.ApiRestResult; import cn.topiam.employee.support.result.ApiRestResult;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; 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 @RequiredArgsConstructor
@Validated @Validated
@Tag(name = "应用权限-权限项") @Tag(name = "应用权限-权限项")
@RequestMapping(value = APP_PATH @RequestMapping(value = PERMISSION_PATH
+ "/permission/action", produces = MediaType.APPLICATION_JSON_VALUE) + "/action", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController @RestController
public class AppPermissionActionController { public class PermissionActionController {
/** /**
* logger * 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 = "获取权限项列表") @Operation(summary = "获取权限项列表")
@GetMapping(value = "/list") @GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<List<AppPermissionActionListResult>> getPermissionActionList(@Validated AppPermissionActionListQuery query) { public ApiRestResult<List<PermissionActionListResult>> getPermissionActionList(@Validated PermissionActionListQuery query) {
List<AppPermissionActionListResult> list = appPermissionActionService List<PermissionActionListResult> list = permissionActionService
.getPermissionActionList(query); .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 * 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/>. * 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.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import cn.topiam.employee.common.entity.app.query.AppPolicyQuery; 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.permission.PermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult; import cn.topiam.employee.console.pojo.save.permission.PermissionPolicyCreateParam;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult; import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam; import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam; import cn.topiam.employee.console.service.permission.PermissionPolicyService;
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.support.lock.Lock; import cn.topiam.employee.support.lock.Lock;
import cn.topiam.employee.support.preview.Preview; import cn.topiam.employee.support.preview.Preview;
import cn.topiam.employee.support.repository.page.domain.Page; 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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; 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 @Validated
@Tag(name = "应用权限-授权策略") @Tag(name = "应用权限-授权策略")
@RequestMapping(value = APP_PATH @RequestMapping(value = PERMISSION_PATH
+ "/permission/policy", produces = MediaType.APPLICATION_JSON_VALUE) + "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionPolicyController { public class PermissionPolicyController {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult} * @return {@link PermissionRoleListResult}
*/ */
@Operation(summary = "获取策略列表") @Operation(summary = "获取策略列表")
@GetMapping(value = "/list") @GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Page<AppPermissionPolicyListResult>> getPermissionPolicyList(PageModel page, public ApiRestResult<Page<PermissionPolicyListResult>> getPermissionPolicyList(PageModel page,
@Validated AppPolicyQuery query) { @Validated AppPolicyQuery query) {
Page<AppPermissionPolicyListResult> result = permissionPolicyService Page<PermissionPolicyListResult> result = permissionPolicyService
.getPermissionPolicyList(page, query); .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} * @return {@link Boolean}
*/ */
@Lock @Lock
@ -84,7 +85,7 @@ public class AppPermissionPolicyController {
@Operation(summary = "创建资源") @Operation(summary = "创建资源")
@PostMapping(value = "/create") @PostMapping(value = "/create")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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() return ApiRestResult.<Boolean> builder()
.result(permissionPolicyService.createPermissionPolicy(param)).build(); .result(permissionPolicyService.createPermissionPolicy(param)).build();
} }
@ -100,7 +101,7 @@ public class AppPermissionPolicyController {
@Operation(summary = "修改资源") @Operation(summary = "修改资源")
@PutMapping(value = "/update/{id}") @PutMapping(value = "/update/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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() return ApiRestResult.<Boolean> builder()
.result(permissionPolicyService.updatePermissionPolicy(param)).build(); .result(permissionPolicyService.updatePermissionPolicy(param)).build();
} }
@ -132,11 +133,11 @@ public class AppPermissionPolicyController {
@Operation(summary = "获取资源信息") @Operation(summary = "获取资源信息")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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(); .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 * 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/>. * 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.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; 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.annotation.Audit;
import cn.topiam.employee.audit.event.type.EventType; import cn.topiam.employee.audit.event.type.EventType;
import cn.topiam.employee.common.enums.CheckValidityType; import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult; import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceListResult; import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult; import cn.topiam.employee.console.pojo.update.permission.PermissionResourceUpdateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionResourceCreateParam; import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam; import cn.topiam.employee.console.service.permission.PermissionResourceService;
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.support.lock.Lock; import cn.topiam.employee.support.lock.Lock;
import cn.topiam.employee.support.preview.Preview; import cn.topiam.employee.support.preview.Preview;
import cn.topiam.employee.support.repository.page.domain.Page; 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 io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; 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 @Validated
@Tag(name = "应用权限-资源") @Tag(name = "应用权限-资源")
@RequestMapping(value = APP_PATH @RequestMapping(value = PERMISSION_PATH
+ "/permission/resource", produces = MediaType.APPLICATION_JSON_VALUE) + "/resource", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionResourceController { public class PermissionResourceController {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult} * @return {@link PermissionRoleListResult}
*/ */
@Operation(summary = "获取资源列表") @Operation(summary = "获取资源列表")
@GetMapping(value = "/list") @GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Page<AppPermissionResourceListResult>> getPermissionResourceList(PageModel page, public ApiRestResult<Page<PermissionResourceListResult>> getPermissionResourceList(PageModel page,
@Validated AppResourceListQuery query) { @Validated PermissionResourceListQuery query) {
Page<AppPermissionResourceListResult> result = appPermissionResourceService Page<PermissionResourceListResult> result = permissionResourceService
.getPermissionResourceList(page, query); .getPermissionResourceList(page, query);
return ApiRestResult.<Page<AppPermissionResourceListResult>> builder().result(result) return ApiRestResult.<Page<PermissionResourceListResult>> builder().result(result)
.build(); .build();
} }
/** /**
* *
* *
* @param param {@link AppPermissionRoleCreateParam} * @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean} * @return {@link Boolean}
*/ */
@Lock @Lock
@ -92,9 +93,9 @@ public class AppPermissionResourceController {
@Audit(type = EventType.SAVE_APP_PERMISSION_RESOURCE) @Audit(type = EventType.SAVE_APP_PERMISSION_RESOURCE)
@PostMapping(value = "/create") @PostMapping(value = "/create")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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() 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) @Audit(type = EventType.UPDATE_APP_PERMISSION_RESOURCE)
@PutMapping(value = "/update") @PutMapping(value = "/update")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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() 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)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> deletePermissionResource(@PathVariable(value = "id") String id) { public ApiRestResult<Boolean> deletePermissionResource(@PathVariable(value = "id") String id) {
return ApiRestResult.<Boolean> builder() return ApiRestResult.<Boolean> builder()
.result(appPermissionResourceService.deletePermissionResource(id)).build(); .result(permissionResourceService.deletePermissionResource(id)).build();
} }
/** /**
@ -140,10 +141,10 @@ public class AppPermissionResourceController {
@Operation(summary = "获取资源信息") @Operation(summary = "获取资源信息")
@GetMapping(value = "/get/{id}") @GetMapping(value = "/get/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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() return ApiRestResult.<PermissionResourceGetResult> builder()
.result(appPermissionResourceService.getPermissionResource(id)).build(); .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)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> enableOrganization(@PathVariable(value = "id") Long id) { public ApiRestResult<Boolean> enableOrganization(@PathVariable(value = "id") Long id) {
return ApiRestResult.<Boolean> builder() 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)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> disableOrganization(@PathVariable(value = "id") Long id) { public ApiRestResult<Boolean> disableOrganization(@PathVariable(value = "id") Long id) {
return ApiRestResult.<Boolean> builder() 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 = "值") @NotEmpty(message = "验证值不能为空") String value,
@Parameter(description = "应用ID") @NotNull(message = "应用ID不能为空") Long appId, @Parameter(description = "应用ID") @NotNull(message = "应用ID不能为空") Long appId,
@Parameter(description = "ID") Long id) { @Parameter(description = "ID") Long id) {
Boolean result = appPermissionResourceService.permissionResourceParamCheck(type, value, Boolean result = permissionResourceService.permissionResourceParamCheck(type, value,
appId, id); appId, id);
//返回 //返回
return ApiRestResult.<Boolean> builder().result(result).build(); 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 * 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/>. * 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.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; 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.annotation.Audit;
import cn.topiam.employee.audit.event.type.EventType; import cn.topiam.employee.audit.event.type.EventType;
import cn.topiam.employee.common.enums.CheckValidityType; import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult; import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult; import cn.topiam.employee.console.service.permission.PermissionRoleService;
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.support.lock.Lock; import cn.topiam.employee.support.lock.Lock;
import cn.topiam.employee.support.preview.Preview; import cn.topiam.employee.support.preview.Preview;
import cn.topiam.employee.support.repository.page.domain.Page; 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 io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; 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 @RequiredArgsConstructor
@Validated @Validated
@Tag(name = "应用权限-角色") @Tag(name = "应用权限-角色")
@RequestMapping(value = APP_PATH + "/permission/role", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = PERMISSION_PATH + "/role", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController @RestController
public class AppPermissionRoleController { public class PermissionRoleController {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult} * @return {@link PermissionRoleListResult}
*/ */
@Operation(summary = "获取角色列表") @Operation(summary = "获取角色列表")
@GetMapping(value = "/list") @GetMapping(value = "/list")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Page<AppPermissionRoleListResult>> getPermissionRoleList(PageModel page, public ApiRestResult<Page<PermissionRoleListResult>> getPermissionRoleList(PageModel page,
@Validated AppPermissionRoleListQuery query) { @Validated PermissionRoleListQuery query) {
Page<AppPermissionRoleListResult> result = appPermissionRoleService Page<PermissionRoleListResult> result = permissionRoleService
.getPermissionRoleList(page, query); .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} * @return {@link Boolean}
*/ */
@Lock @Lock
@ -87,9 +88,9 @@ public class AppPermissionRoleController {
@Audit(type = EventType.SAVE_APP_PERMISSION_ROLE) @Audit(type = EventType.SAVE_APP_PERMISSION_ROLE)
@PostMapping(value = "/create") @PostMapping(value = "/create")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @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() 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)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> updatePermissionRole(@RequestBody @Validated PermissionRoleUpdateParam param) { public ApiRestResult<Boolean> updatePermissionRole(@RequestBody @Validated PermissionRoleUpdateParam param) {
return ApiRestResult.<Boolean> builder() 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)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> deletePermissionRole(@PathVariable(value = "ids") String ids) { public ApiRestResult<Boolean> deletePermissionRole(@PathVariable(value = "ids") String ids) {
return ApiRestResult.<Boolean> builder() return ApiRestResult.<Boolean> builder()
.result(appPermissionRoleService.deletePermissionRole(ids)).build(); .result(permissionRoleService.deletePermissionRole(ids)).build();
} }
/** /**
@ -135,10 +136,10 @@ public class AppPermissionRoleController {
@Operation(summary = "获取角色信息") @Operation(summary = "获取角色信息")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<AppPermissionRoleResult> getPermissionRole(@PathVariable(value = "id") Long id) { public ApiRestResult<PermissionRoleResult> getPermissionRole(@PathVariable(value = "id") Long id) {
AppPermissionRoleResult details = appPermissionRoleService.getPermissionRole(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}") @PutMapping(value = "/enable/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> enablePermissionRole(@PathVariable(value = "id") String id) { 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(); return ApiRestResult.<Boolean> builder().result(result).build();
} }
@ -169,7 +170,7 @@ public class AppPermissionRoleController {
@PutMapping(value = "/disable/{id}") @PutMapping(value = "/disable/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)") @PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> disablePermissionRole(@PathVariable(value = "id") String id) { 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(); return ApiRestResult.<Boolean> builder().result(result).build();
} }
@ -185,7 +186,7 @@ public class AppPermissionRoleController {
@Parameter(description = "值") @NotEmpty(message = "验证值不能为空") String value, @Parameter(description = "值") @NotEmpty(message = "验证值不能为空") String value,
@Parameter(description = "应用ID") @NotNull(message = "应用ID不能为空") Long appId, @Parameter(description = "应用ID") @NotNull(message = "应用ID不能为空") Long appId,
@Parameter(description = "ID") Long id) { @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(); 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.MessageCategory;
import cn.topiam.employee.common.enums.SmsType; import cn.topiam.employee.common.enums.SmsType;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam; 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.console.service.setting.MessageSettingService;
import cn.topiam.employee.core.message.MsgVariable; import cn.topiam.employee.core.message.MsgVariable;
import cn.topiam.employee.core.message.sms.SmsMsgEventPublish; 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 * 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/>. * 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.ArrayList;
import java.util.List; 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.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
@ -28,12 +30,10 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate; 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.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.common.enums.PermissionActionType; import cn.topiam.employee.common.enums.PermissionActionType;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult; 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 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface AppPermissionActionConverter { public interface PermissionActionConverter {
/** /**
* *
* *
* @param query {@link AppPermissionActionListQuery} * @param query {@link PermissionActionListQuery}
* @return {@link Predicate} * @return {@link Predicate}
*/ */
default Predicate appPermissionActionListQueryConvertToPredicate(AppPermissionActionListQuery query) { default Predicate appPermissionActionListQueryConvertToPredicate(PermissionActionListQuery query) {
QAppPermissionResourceEntity resource = QAppPermissionResourceEntity.appPermissionResourceEntity; QAppPermissionResourceEntity resource = QAppPermissionResourceEntity.appPermissionResourceEntity;
Predicate predicate = ExpressionUtils.and(resource.isNotNull(), Predicate predicate = ExpressionUtils.and(resource.isNotNull(),
resource.deleted.eq(Boolean.FALSE)); resource.deleted.eq(Boolean.FALSE));
@ -68,18 +68,18 @@ public interface AppPermissionActionConverter {
/** /**
* *
* *
* @param list {@link AppPermissionResourceEntity} * @param list {@link PermissionResourceEntity}
* @return {@link AppPermissionActionListResult} * @return {@link PermissionActionListResult}
*/ */
default List<AppPermissionActionListResult> entityConvertToResourceActionListResult(List<AppPermissionResourceEntity> list) { default List<PermissionActionListResult> entityConvertToResourceActionListResult(List<PermissionResourceEntity> list) {
List<AppPermissionActionListResult> results = new ArrayList<>(); List<PermissionActionListResult> results = new ArrayList<>();
List<AppPermissionActionListResult.Action> menus = new ArrayList<>(); List<PermissionActionListResult.Action> menus = new ArrayList<>();
List<AppPermissionActionListResult.Action> apis = new ArrayList<>(); List<PermissionActionListResult.Action> apis = new ArrayList<>();
List<AppPermissionActionListResult.Action> buttons = new ArrayList<>(); List<PermissionActionListResult.Action> buttons = new ArrayList<>();
List<AppPermissionActionListResult.Action> others = new ArrayList<>(); List<PermissionActionListResult.Action> others = new ArrayList<>();
List<AppPermissionActionListResult.Action> datas = new ArrayList<>(); List<PermissionActionListResult.Action> datas = new ArrayList<>();
for (AppPermissionResourceEntity resource : list) { for (PermissionResourceEntity resource : list) {
for (AppPermissionActionEntity action : resource.getActions()) { for (PermissionActionEntity action : resource.getActions()) {
if (PermissionActionType.MENU.equals(action.getType())) { if (PermissionActionType.MENU.equals(action.getType())) {
menus.add(actionConvertToResourceActionResult(action)); menus.add(actionConvertToResourceActionResult(action));
} }
@ -96,7 +96,7 @@ public interface AppPermissionActionConverter {
others.add(actionConvertToResourceActionResult(action)); others.add(actionConvertToResourceActionResult(action));
} }
} }
AppPermissionActionListResult result = new AppPermissionActionListResult(); PermissionActionListResult result = new PermissionActionListResult();
//基本信息 //基本信息
result.setAppId(resource.getAppId().toString()); result.setAppId(resource.getAppId().toString());
result.setId(resource.getId().toString()); result.setId(resource.getId().toString());
@ -117,10 +117,10 @@ public interface AppPermissionActionConverter {
/** /**
* actionConvertToResourceActionResult * actionConvertToResourceActionResult
* *
* @param action {@link AppPermissionActionEntity} * @param action {@link PermissionActionEntity}
* @return {@link AppPermissionActionListResult.Action} * @return {@link PermissionActionListResult.Action}
*/ */
@Mapping(target = "access", source = "value") @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 * 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/>. * 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.ArrayList;
import java.util.List; 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.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import cn.topiam.employee.common.entity.app.AppPermissionPolicyEntity; import cn.topiam.employee.console.pojo.update.permission.PermissionPolicyUpdateParam;
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.support.repository.page.domain.Page; import cn.topiam.employee.support.repository.page.domain.Page;
/** /**
@ -37,14 +37,14 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class) @Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface AppPermissionPolicyConverter { public interface PermissionPolicyConverter {
/** /**
* *
* *
* @param param {@link AppPermissionPolicyCreateParam} * @param param {@link PermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity} * @return {@link PermissionPolicyEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true) @Mapping(target = "id", ignore = true)
@ -53,13 +53,13 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true) @Mapping(target = "createBy", ignore = true)
AppPermissionPolicyEntity policyCreateParamConvertToEntity(AppPermissionPolicyCreateParam param); PermissionPolicyEntity policyCreateParamConvertToEntity(PermissionPolicyCreateParam param);
/** /**
* *
* *
* @param param {@link AppPermissionPolicyCreateParam} * @param param {@link PermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity} * @return {@link PermissionPolicyEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "updateTime", ignore = true) @Mapping(target = "updateTime", ignore = true)
@ -67,7 +67,7 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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} * @param page {@link Page}
* @return {@link Page} * @return {@link Page}
*/ */
default Page<AppPermissionPolicyListResult> entityConvertToPolicyListResult(org.springframework.data.domain.Page<AppPermissionPolicyPO> page) { default Page<PermissionPolicyListResult> entityConvertToPolicyListResult(org.springframework.data.domain.Page<PermissionPolicyPO> page) {
Page<AppPermissionPolicyListResult> result = new Page<>(); Page<PermissionPolicyListResult> result = new Page<>();
List<AppPermissionPolicyPO> pageList = page.getContent(); List<PermissionPolicyPO> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) { if (!CollectionUtils.isEmpty(pageList)) {
//@formatter:off //@formatter:off
result.setPagination(Page.Pagination.builder() result.setPagination(Page.Pagination.builder()
@ -86,8 +86,8 @@ public interface AppPermissionPolicyConverter {
.current(page.getPageable().getPageNumber() + 1) .current(page.getPageable().getPageNumber() + 1)
.build()); .build());
//@formatter:on //@formatter:on
List<AppPermissionPolicyListResult> list = new ArrayList<>(); List<PermissionPolicyListResult> list = new ArrayList<>();
for (AppPermissionPolicyPO po : pageList) { for (PermissionPolicyPO po : pageList) {
list.add(entityConvertToPolicyListResult(po)); list.add(entityConvertToPolicyListResult(po));
} }
result.setList(list); result.setList(list);
@ -98,8 +98,8 @@ public interface AppPermissionPolicyConverter {
/** /**
* entityConvertToPolicyListResult * entityConvertToPolicyListResult
* *
* @param entity {@link AppPermissionPolicyListResult} * @param entity {@link PermissionPolicyListResult}
* @return {@link AppPermissionPolicyPO} * @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 * 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/>. * 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.ArrayList;
import java.util.List; 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.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
@ -29,13 +33,9 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate; 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.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult; import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
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.support.repository.page.domain.Page; import cn.topiam.employee.support.repository.page.domain.Page;
/** /**
@ -44,16 +44,16 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class) @Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface AppPermissionResourceConverter { public interface PermissionResourceConverter {
/** /**
* *
* *
* @param query {@link AppResourceListQuery} * @param query {@link PermissionResourceListQuery}
* @return {@link Predicate} * @return {@link Predicate}
*/ */
default Predicate resourcePaginationParamConvertToPredicate(AppResourceListQuery query) { default Predicate resourcePaginationParamConvertToPredicate(PermissionResourceListQuery query) {
QAppPermissionResourceEntity resource = QAppPermissionResourceEntity.appPermissionResourceEntity; QAppPermissionResourceEntity resource = QAppPermissionResourceEntity.appPermissionResourceEntity;
Predicate predicate = ExpressionUtils.and(resource.isNotNull(), Predicate predicate = ExpressionUtils.and(resource.isNotNull(),
resource.deleted.eq(Boolean.FALSE)); resource.deleted.eq(Boolean.FALSE));
@ -70,8 +70,8 @@ public interface AppPermissionResourceConverter {
/** /**
* *
* *
* @param param {@link AppPermissionResourceCreateParam} * @param param {@link PermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity} * @return {@link PermissionResourceEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "actions", ignore = true) @Mapping(target = "actions", ignore = true)
@ -81,13 +81,13 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true) @Mapping(target = "createBy", ignore = true)
AppPermissionResourceEntity resourceCreateParamConvertToEntity(AppPermissionResourceCreateParam param); PermissionResourceEntity resourceCreateParamConvertToEntity(PermissionResourceCreateParam param);
/** /**
* *
* *
* @param param {@link AppPermissionResourceCreateParam} * @param param {@link PermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity} * @return {@link PermissionResourceEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "actions", ignore = true) @Mapping(target = "actions", ignore = true)
@ -96,7 +96,7 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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} * @param page {@link Page}
* @return {@link Page} * @return {@link Page}
*/ */
default Page<AppPermissionResourceListResult> entityConvertToResourceListResult(org.springframework.data.domain.Page<AppPermissionResourceEntity> page) { default Page<PermissionResourceListResult> entityConvertToResourceListResult(org.springframework.data.domain.Page<PermissionResourceEntity> page) {
Page<AppPermissionResourceListResult> result = new Page<>(); Page<PermissionResourceListResult> result = new Page<>();
List<AppPermissionResourceEntity> pageList = page.getContent(); List<PermissionResourceEntity> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) { if (!CollectionUtils.isEmpty(pageList)) {
List<AppPermissionResourceListResult> list = new ArrayList<>(); List<PermissionResourceListResult> list = new ArrayList<>();
for (AppPermissionResourceEntity resource : pageList) { for (PermissionResourceEntity resource : pageList) {
list.add(entityConvertToResourceListResult(resource)); list.add(entityConvertToResourceListResult(resource));
} }
//@formatter:off //@formatter:off
@ -127,17 +127,17 @@ public interface AppPermissionResourceConverter {
/** /**
* *
* *
* @param data {@link AppPermissionResourceEntity} * @param data {@link PermissionResourceEntity}
* @return {@link AppPermissionResourceListResult} * @return {@link PermissionResourceListResult}
*/ */
AppPermissionResourceListResult entityConvertToResourceListResult(AppPermissionResourceEntity data); PermissionResourceListResult entityConvertToResourceListResult(PermissionResourceEntity data);
/** /**
* *
* *
* @param resource {@link AppPermissionResourceEntity} * @param resource {@link PermissionResourceEntity}
* @return {@link AppPermissionResourceGetResult} * @return {@link PermissionResourceGetResult}
*/ */
@Mapping(target = "actions", source = "actions") @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 * 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/>. * 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.ArrayList;
import java.util.List; import java.util.List;
import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
@ -29,13 +30,12 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate; 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.app.QAppPermissionRoleEntity;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery; import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult; import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult; import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam; import cn.topiam.employee.console.pojo.result.permission.PermissionRoleResult;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam; 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.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 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface AppPermissionRoleConverter { public interface PermissionRoleConverter {
/** /**
* *
@ -53,11 +53,11 @@ public interface AppPermissionRoleConverter {
* @param page {@link Page} * @param page {@link Page}
* @return {@link Page} * @return {@link Page}
*/ */
default Page<AppPermissionRoleListResult> entityConvertToRolePaginationResult(org.springframework.data.domain.Page<AppPermissionRoleEntity> page) { default Page<PermissionRoleListResult> entityConvertToRolePaginationResult(org.springframework.data.domain.Page<PermissionRoleEntity> page) {
Page<AppPermissionRoleListResult> result = new Page<>(); Page<PermissionRoleListResult> result = new Page<>();
if (!CollectionUtils.isEmpty(page.getContent())) { if (!CollectionUtils.isEmpty(page.getContent())) {
List<AppPermissionRoleListResult> list = new ArrayList<>(); List<PermissionRoleListResult> list = new ArrayList<>();
for (AppPermissionRoleEntity user : page.getContent()) { for (PermissionRoleEntity user : page.getContent()) {
list.add(entityConvertToRolePaginationResult(user)); list.add(entityConvertToRolePaginationResult(user));
} }
//@formatter:off //@formatter:off
@ -75,16 +75,16 @@ public interface AppPermissionRoleConverter {
/** /**
* *
* *
* @param page {@link AppPermissionRoleEntity} * @param page {@link PermissionRoleEntity}
* @return {@link AppPermissionRoleListResult} * @return {@link PermissionRoleListResult}
*/ */
AppPermissionRoleListResult entityConvertToRolePaginationResult(AppPermissionRoleEntity page); PermissionRoleListResult entityConvertToRolePaginationResult(PermissionRoleEntity page);
/** /**
* *
* *
* @param param {@link AppPermissionRoleCreateParam} * @param param {@link PermissionRoleCreateParam}
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true) @Mapping(target = "id", ignore = true)
@ -93,13 +93,13 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true) @Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true) @Mapping(target = "createBy", ignore = true)
AppPermissionRoleEntity roleCreateParamConvertToEntity(AppPermissionRoleCreateParam param); PermissionRoleEntity roleCreateParamConvertToEntity(PermissionRoleCreateParam param);
/** /**
* *
* *
* @param param {@link PermissionRoleUpdateParam} * @param param {@link PermissionRoleUpdateParam}
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "appId", ignore = true) @Mapping(target = "appId", ignore = true)
@ -108,23 +108,23 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true) @Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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} * @return {@link PermissionRoleResult}
*/ */
AppPermissionRoleResult entityConvertToRoleDetailResult(AppPermissionRoleEntity role); PermissionRoleResult entityConvertToRoleDetailResult(PermissionRoleEntity role);
/** /**
* *
* *
* @param query {@link AppPermissionRoleListQuery} * @param query {@link PermissionRoleListQuery}
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
default Predicate rolePaginationParamConvertToPredicate(AppPermissionRoleListQuery query) { default Predicate rolePaginationParamConvertToPredicate(PermissionRoleListQuery query) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity; QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;
Predicate predicate = ExpressionUtils.and(role.isNotNull(), role.deleted.eq(Boolean.FALSE)); 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.result.setting.EmailProviderConfigResult;
import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam; import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam; 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.exception.TopIamException;
import cn.topiam.employee.support.validation.ValidationUtils; 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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -37,7 +37,7 @@ import jakarta.validation.constraints.NotEmpty;
@Data @Data
@Schema(description = "查询权限列表入参") @Schema(description = "查询权限列表入参")
@ParameterObject @ParameterObject
public class AppPermissionActionListQuery implements Serializable { public class PermissionActionListQuery implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 4307939244290315206L; 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 * 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/>. * 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; import java.io.Serializable;
@ -36,7 +36,7 @@ import jakarta.validation.constraints.NotNull;
@Data @Data
@Schema(description = "查询权限资源列表入参") @Schema(description = "查询权限资源列表入参")
@ParameterObject @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 * 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/>. * 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; import java.io.Serializable;
@ -36,7 +36,7 @@ import jakarta.validation.constraints.NotNull;
@Data @Data
@Schema(description = "查询角色列表入参") @Schema(description = "查询角色列表入参")
@ParameterObject @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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -36,7 +36,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Schema(description = "获取应用资源权限列表") @Schema(description = "获取应用资源权限列表")
public class AppPermissionActionListResult implements Serializable { public class PermissionActionListResult implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 3320953184046791392L; 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 * 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/>. * 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; import java.io.Serializable;
@ -36,7 +36,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/ */
@Schema(description = "获取资源结果") @Schema(description = "获取资源结果")
@Data @Data
public class AppPermissionPolicyGetResult implements Serializable { public class PermissionPolicyGetResult implements Serializable {
/** /**
* ID * ID
*/ */

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.AppPolicyEffect;
import cn.topiam.employee.common.enums.app.AppPolicyObjectType; import cn.topiam.employee.common.enums.app.AppPolicyObjectType;
@ -33,7 +33,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/ */
@Schema(description = "获取授权列表") @Schema(description = "获取授权列表")
@Data @Data
public class AppPermissionPolicyListResult { public class PermissionPolicyListResult {
/** /**
* ID * ID
*/ */

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -36,7 +36,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/ */
@Schema(description = "获取资源结果") @Schema(description = "获取资源结果")
@Data @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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -35,7 +35,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Schema(description = "分页查询资源结果") @Schema(description = "分页查询资源结果")
public class AppPermissionResourceListResult implements Serializable { public class PermissionResourceListResult implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 3320953184046791392L; 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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -35,7 +35,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Schema(description = "分页查询角色结果") @Schema(description = "分页查询角色结果")
public class AppPermissionRoleListResult implements Serializable { public class PermissionRoleListResult implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 3320953184046791392L; 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 * 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/>. * 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; import java.io.Serializable;
@ -32,7 +32,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
*/ */
@Schema(description = "获取角色") @Schema(description = "获取角色")
@Data @Data
public class AppPermissionRoleResult implements Serializable { public class PermissionRoleResult implements Serializable {
/** /**
* id * id
*/ */

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.io.Serializable;
@ -37,7 +37,7 @@ import jakarta.validation.constraints.NotNull;
*/ */
@Data @Data
@Schema(description = "创建策略入参") @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 * 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/>. * 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.io.Serializable;
import java.util.List; import java.util.List;
@ -34,7 +34,7 @@ import jakarta.validation.constraints.NotNull;
*/ */
@Data @Data
@Schema(description = "创建资源入参") @Schema(description = "创建资源入参")
public class AppPermissionResourceCreateParam implements Serializable { public class PermissionResourceCreateParam implements Serializable {
/** /**
* *
*/ */
@ -70,6 +70,6 @@ public class AppPermissionResourceCreateParam implements Serializable {
* *
*/ */
@Schema(description = "资源权限") @Schema(description = "资源权限")
@NotNull(message = "资源权限不能为空") // @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 * 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/>. * 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.io.Serializable;
@ -33,7 +33,7 @@ import jakarta.validation.constraints.NotNull;
*/ */
@Data @Data
@Schema(description = "创建角色入参") @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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
@ -36,7 +36,7 @@ import jakarta.validation.constraints.NotNull;
*/ */
@Data @Data
@Valid @Valid
public class AppPermissionsActionParam implements Serializable { public class PermissionsActionParam implements Serializable {
@Serial @Serial
private static final long serialVersionUID = -6391182747252245592L; 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 * 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/>. * 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; import java.io.Serializable;
@ -37,7 +37,7 @@ import jakarta.validation.constraints.NotNull;
*/ */
@Data @Data
@Schema(description = "修改策略入参") @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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; 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; import lombok.Data;
@ -38,7 +38,7 @@ import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY;
*/ */
@Data @Data
@Schema(description = "修改资源入参") @Schema(description = "修改资源入参")
public class AppPermissionResourceUpdateParam implements Serializable { public class PermissionResourceUpdateParam implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 6021548372386059064L; private static final long serialVersionUID = 6021548372386059064L;
/** /**
@ -87,5 +87,5 @@ public class AppPermissionResourceUpdateParam implements Serializable {
*/ */
@Schema(description = "资源权限") @Schema(description = "资源权限")
@NotNull(message = "资源权限不能为空") @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 * 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/>. * 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.Serial;
import java.io.Serializable; import java.io.Serializable;

View File

@ -15,12 +15,12 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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 java.util.List;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult; import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
/** /**
* <p> * <p>
@ -30,14 +30,14 @@ import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * Created by support@topiam.cn on 2020-08-10
*/ */
public interface AppPermissionActionService { public interface PermissionActionService {
/** /**
* *
* *
* @param query {@link AppPermissionActionListQuery} * @param query {@link PermissionActionListQuery}
* @return {@link AppPermissionActionListResult} * @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 * 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/>. * 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.common.entity.app.query.AppPolicyQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyGetResult; import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult; import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam; import cn.topiam.employee.console.pojo.save.permission.PermissionPolicyCreateParam;
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; import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -33,24 +33,24 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * Created by support@topiam.cn on 2020-08-10
*/ */
public interface AppPermissionPolicyService { public interface PermissionPolicyService {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @param query {@link AppPolicyQuery} * @param query {@link AppPolicyQuery}
* @return {@link AppPermissionPolicyListResult} * @return {@link PermissionPolicyListResult}
*/ */
Page<AppPermissionPolicyListResult> getPermissionPolicyList(PageModel page, Page<PermissionPolicyListResult> getPermissionPolicyList(PageModel page,
AppPolicyQuery query); AppPolicyQuery query);
/** /**
* *
* *
* @param id {@link String} * @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} * @return {@link Boolean}
*/ */
Boolean createPermissionPolicy(AppPermissionPolicyCreateParam param); Boolean createPermissionPolicy(PermissionPolicyCreateParam param);
/** /**
* *
* *
* @param param {@link AppPermissionPolicyUpdateParam} * @param param {@link PermissionPolicyUpdateParam}
* @return {@link Boolean} * @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 * 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/>. * 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.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppResourceListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionResourceListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceGetResult; import cn.topiam.employee.console.pojo.result.permission.PermissionResourceGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionResourceListResult; import cn.topiam.employee.console.pojo.result.permission.PermissionResourceListResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionResourceCreateParam; import cn.topiam.employee.console.pojo.save.permission.PermissionResourceCreateParam;
import cn.topiam.employee.console.pojo.update.app.AppPermissionResourceUpdateParam; 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.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -34,24 +34,24 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * Created by support@topiam.cn on 2020-08-10
*/ */
public interface AppPermissionResourceService { public interface PermissionResourceService {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @param query {@link AppResourceListQuery} * @param query {@link PermissionResourceListQuery}
* @return {@link AppPermissionResourceListResult} * @return {@link PermissionResourceListResult}
*/ */
Page<AppPermissionResourceListResult> getPermissionResourceList(PageModel page, Page<PermissionResourceListResult> getPermissionResourceList(PageModel page,
AppResourceListQuery query); PermissionResourceListQuery query);
/** /**
* *
* *
* @param id {@link String} * @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} * @return {@link Boolean}
*/ */
Boolean createPermissionResource(AppPermissionResourceCreateParam param); Boolean createPermissionResource(PermissionResourceCreateParam param);
/** /**
* *
* *
* @param param {@link AppPermissionResourceUpdateParam} * @param param {@link PermissionResourceUpdateParam}
* @return {@link Boolean} * @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 * 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/>. * 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.common.enums.CheckValidityType;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery; import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult; import cn.topiam.employee.console.pojo.result.permission.PermissionRoleListResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleResult; import cn.topiam.employee.console.pojo.result.permission.PermissionRoleResult;
import cn.topiam.employee.console.pojo.save.app.AppPermissionRoleCreateParam; import cn.topiam.employee.console.pojo.save.permission.PermissionRoleCreateParam;
import cn.topiam.employee.console.pojo.update.app.PermissionRoleUpdateParam; 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.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -34,25 +34,25 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * Created by support@topiam.cn on 2020-08-10
*/ */
public interface AppPermissionRoleService { public interface PermissionRoleService {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @param query {@link AppPermissionRoleListQuery} * @param query {@link PermissionRoleListQuery}
* @return {@link AppPermissionRoleListResult} * @return {@link PermissionRoleListResult}
*/ */
Page<AppPermissionRoleListResult> getPermissionRoleList(PageModel page, Page<PermissionRoleListResult> getPermissionRoleList(PageModel page,
AppPermissionRoleListQuery query); PermissionRoleListQuery query);
/** /**
* *
* *
* @param param {@link AppPermissionRoleCreateParam} * @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean} * @return {@link Boolean}
*/ */
boolean createPermissionRole(AppPermissionRoleCreateParam param); boolean createPermissionRole(PermissionRoleCreateParam param);
/** /**
* *
@ -74,9 +74,9 @@ public interface AppPermissionRoleService {
* *
* *
* @param id {@link Long} * @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 * 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/>. * 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 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 org.springframework.stereotype.Service;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
import cn.topiam.employee.common.entity.app.AppPermissionResourceEntity; import cn.topiam.employee.common.repository.permission.AppPermissionResourceRepository;
import cn.topiam.employee.common.repository.app.AppPermissionResourceRepository; import cn.topiam.employee.console.pojo.query.permission.PermissionActionListQuery;
import cn.topiam.employee.console.converter.app.AppPermissionActionConverter; import cn.topiam.employee.console.pojo.result.permission.PermissionActionListResult;
import cn.topiam.employee.console.pojo.query.app.AppPermissionActionListQuery; import cn.topiam.employee.console.service.permission.PermissionActionService;
import cn.topiam.employee.console.pojo.result.app.AppPermissionActionListResult;
import cn.topiam.employee.console.service.app.AppPermissionActionService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -42,24 +42,24 @@ import lombok.RequiredArgsConstructor;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionActionServiceImpl implements AppPermissionActionService { public class PermissionActionServiceImpl implements PermissionActionService {
/** /**
* *
* *
* @param query {@link AppPermissionActionListQuery} * @param query {@link PermissionActionListQuery}
* @return {@link AppPermissionActionListResult} * @return {@link PermissionActionListResult}
*/ */
@Override @Override
public List<AppPermissionActionListResult> getPermissionActionList(AppPermissionActionListQuery query) { public List<PermissionActionListResult> getPermissionActionList(PermissionActionListQuery query) {
Predicate predicate = appPermissionActionConverter Predicate predicate = permissionActionConverter
.appPermissionActionListQueryConvertToPredicate(query); .appPermissionActionListQueryConvertToPredicate(query);
List<AppPermissionResourceEntity> list = (List<AppPermissionResourceEntity>) appPermissionResourceRepository List<PermissionResourceEntity> list = (List<PermissionResourceEntity>) appPermissionResourceRepository
.findAll(predicate); .findAll(predicate);
return appPermissionActionConverter.entityConvertToResourceActionListResult(list); return permissionActionConverter.entityConvertToResourceActionListResult(list);
} }
private final AppPermissionResourceRepository appPermissionResourceRepository; 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 * 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/>. * 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.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; 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.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.exception.app.AppPolicyNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository; import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.console.converter.app.AppPermissionPolicyConverter; import cn.topiam.employee.console.converter.permission.PermissionPolicyConverter;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyGetResult; import cn.topiam.employee.console.pojo.result.permission.PermissionPolicyGetResult;
import cn.topiam.employee.console.pojo.result.app.AppPermissionPolicyListResult; import cn.topiam.employee.console.pojo.update.permission.PermissionPolicyUpdateParam;
import cn.topiam.employee.console.pojo.save.app.AppPermissionPolicyCreateParam; import cn.topiam.employee.console.service.permission.PermissionPolicyService;
import cn.topiam.employee.console.pojo.update.app.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.console.service.app.AppPermissionPolicyService;
import cn.topiam.employee.support.repository.page.domain.Page; import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
@ -47,32 +47,32 @@ import lombok.RequiredArgsConstructor;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyService { public class PermissionPolicyServiceImpl implements PermissionPolicyService {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @param query {@link AppPolicyQuery} * @param query {@link AppPolicyQuery}
* @return {@link AppPermissionPolicyListResult} * @return {@link PermissionPolicyListResult}
*/ */
@Override @Override
public Page<AppPermissionPolicyListResult> getPermissionPolicyList(PageModel page, public Page<PermissionPolicyListResult> getPermissionPolicyList(PageModel page,
AppPolicyQuery query) { AppPolicyQuery query) {
org.springframework.data.domain.Page<AppPermissionPolicyPO> data; org.springframework.data.domain.Page<PermissionPolicyPO> data;
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize()); QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appPermissionPolicyRepository.findPage(query, request); data = appPermissionPolicyRepository.findPage(query, request);
return appPermissionPolicyConverter.entityConvertToPolicyListResult(data); return permissionPolicyConverter.entityConvertToPolicyListResult(data);
} }
/** /**
* *
* *
* @param id {@link String} * @param id {@link String}
* @return {@link AppPermissionPolicyGetResult} * @return {@link PermissionPolicyGetResult}
*/ */
@Override @Override
public AppPermissionPolicyGetResult getPermissionPolicy(String id) { public PermissionPolicyGetResult getPermissionPolicy(String id) {
return null; return null;
} }
@ -94,13 +94,13 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
/** /**
* *
* *
* @param param {@link AppPermissionPolicyCreateParam} * @param param {@link PermissionPolicyCreateParam}
* @return {@link Boolean} * @return {@link Boolean}
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean createPermissionPolicy(AppPermissionPolicyCreateParam param) { public Boolean createPermissionPolicy(PermissionPolicyCreateParam param) {
AppPermissionPolicyEntity resource = appPermissionPolicyConverter PermissionPolicyEntity resource = permissionPolicyConverter
.policyCreateParamConvertToEntity(param); .policyCreateParamConvertToEntity(param);
// 新增策略 // 新增策略
appPermissionPolicyRepository.save(resource); appPermissionPolicyRepository.save(resource);
@ -110,19 +110,19 @@ public class AppPermissionPolicyServiceImpl implements AppPermissionPolicyServic
/** /**
* *
* *
* @param param {@link AppPermissionPolicyUpdateParam} * @param param {@link PermissionPolicyUpdateParam}
* @return {@link Boolean} * @return {@link Boolean}
*/ */
@Override @Override
public Boolean updatePermissionPolicy(AppPermissionPolicyUpdateParam param) { public Boolean updatePermissionPolicy(PermissionPolicyUpdateParam param) {
AppPermissionPolicyEntity resource = appPermissionPolicyConverter PermissionPolicyEntity resource = permissionPolicyConverter
.policyUpdateParamConvertToEntity(param); .policyUpdateParamConvertToEntity(param);
// 更新策略 // 更新策略
appPermissionPolicyRepository.save(resource); appPermissionPolicyRepository.save(resource);
return null; return null;
} }
private final AppPermissionPolicyConverter appPermissionPolicyConverter; private final PermissionPolicyConverter permissionPolicyConverter;
private final AppPermissionPolicyRepository appPermissionPolicyRepository; private final AppPermissionPolicyRepository appPermissionPolicyRepository;
} }

View File

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

View File

@ -15,13 +15,17 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; 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.apache.commons.lang3.StringUtils;
import org.springframework.data.querydsl.QPageRequest; import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service; 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.context.AuditContext;
import cn.topiam.employee.audit.entity.Target; import cn.topiam.employee.audit.entity.Target;
import cn.topiam.employee.audit.enums.TargetType; 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.app.QAppPermissionRoleEntity;
import cn.topiam.employee.common.entity.permission.PermissionRoleEntity;
import cn.topiam.employee.common.enums.CheckValidityType; import cn.topiam.employee.common.enums.CheckValidityType;
import cn.topiam.employee.common.exception.app.AppRoleNotExistException; import cn.topiam.employee.common.exception.app.AppRoleNotExistException;
import cn.topiam.employee.common.repository.app.AppPermissionPolicyRepository; import cn.topiam.employee.common.repository.permission.AppPermissionPolicyRepository;
import cn.topiam.employee.common.repository.app.AppPermissionRoleRepository; import cn.topiam.employee.common.repository.permission.AppPermissionRoleRepository;
import cn.topiam.employee.console.converter.app.AppPermissionRoleConverter; import cn.topiam.employee.console.pojo.query.permission.PermissionRoleListQuery;
import cn.topiam.employee.console.pojo.query.app.AppPermissionRoleListQuery; import cn.topiam.employee.console.pojo.update.permission.PermissionRoleUpdateParam;
import cn.topiam.employee.console.pojo.result.app.AppPermissionRoleListResult; import cn.topiam.employee.console.service.permission.PermissionRoleService;
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.support.repository.page.domain.Page; import cn.topiam.employee.support.repository.page.domain.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.util.BeanUtils; import cn.topiam.employee.support.util.BeanUtils;
@ -64,34 +64,34 @@ import static cn.topiam.employee.support.repository.domain.BaseEntity.LAST_MODIF
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionRoleServiceImpl implements AppPermissionRoleService { public class PermissionRoleServiceImpl implements PermissionRoleService {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @return {@link AppPermissionRoleListResult} * @return {@link PermissionRoleListResult}
*/ */
@Override @Override
public Page<AppPermissionRoleListResult> getPermissionRoleList(PageModel page, public Page<PermissionRoleListResult> getPermissionRoleList(PageModel page,
AppPermissionRoleListQuery query) { PermissionRoleListQuery query) {
org.springframework.data.domain.Page<AppPermissionRoleEntity> data; org.springframework.data.domain.Page<PermissionRoleEntity> data;
Predicate predicate = appPermissionRoleConverter Predicate predicate = permissionRoleConverter
.rolePaginationParamConvertToPredicate(query); .rolePaginationParamConvertToPredicate(query);
QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize()); QPageRequest request = QPageRequest.of(page.getCurrent(), page.getPageSize());
data = appPermissionRoleRepository.findAll(predicate, request); data = appPermissionRoleRepository.findAll(predicate, request);
return appPermissionRoleConverter.entityConvertToRolePaginationResult(data); return permissionRoleConverter.entityConvertToRolePaginationResult(data);
} }
/** /**
* *
* *
* @param param {@link AppPermissionRoleCreateParam} * @param param {@link PermissionRoleCreateParam}
* @return {@link Boolean} * @return {@link Boolean}
*/ */
@Override @Override
public boolean createPermissionRole(AppPermissionRoleCreateParam param) { public boolean createPermissionRole(PermissionRoleCreateParam param) {
AppPermissionRoleEntity entity = appPermissionRoleConverter PermissionRoleEntity entity = permissionRoleConverter
.roleCreateParamConvertToEntity(param); .roleCreateParamConvertToEntity(param);
appPermissionRoleRepository.save(entity); appPermissionRoleRepository.save(entity);
AuditContext.setTarget(Target.builder().id(entity.getId().toString()) AuditContext.setTarget(Target.builder().id(entity.getId().toString())
@ -105,9 +105,9 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
*/ */
@Override @Override
public boolean updatePermissionRole(PermissionRoleUpdateParam param) { public boolean updatePermissionRole(PermissionRoleUpdateParam param) {
AppPermissionRoleEntity source = appPermissionRoleConverter PermissionRoleEntity source = permissionRoleConverter
.roleUpdateParamConvertToEntity(param); .roleUpdateParamConvertToEntity(param);
AppPermissionRoleEntity target = appPermissionRoleRepository PermissionRoleEntity target = appPermissionRoleRepository
.findById(Long.valueOf(param.getId())).orElseThrow(AppRoleNotExistException::new); .findById(Long.valueOf(param.getId())).orElseThrow(AppRoleNotExistException::new);
BeanUtils.merge(source, target, LAST_MODIFIED_TIME, LAST_MODIFIED_BY); BeanUtils.merge(source, target, LAST_MODIFIED_TIME, LAST_MODIFIED_BY);
appPermissionRoleRepository.save(target); appPermissionRoleRepository.save(target);
@ -140,14 +140,14 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
* *
* *
* @param id {@link Long} * @param id {@link Long}
* @return {@link AppPermissionRoleResult} * @return {@link PermissionRoleResult}
*/ */
@Override @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, public Boolean permissionRoleParamCheck(CheckValidityType type, String value, Long appId,
Long id) { Long id) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity; QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;
AppPermissionRoleEntity entity = new AppPermissionRoleEntity(); PermissionRoleEntity entity = new PermissionRoleEntity();
boolean result = false; boolean result = false;
// ID存在说明是修改操作查询一下当前数据 // ID存在说明是修改操作查询一下当前数据
if (Objects.nonNull(id)) { if (Objects.nonNull(id)) {
@ -208,7 +208,7 @@ public class AppPermissionRoleServiceImpl implements AppPermissionRoleService {
/** /**
* *
*/ */
private final AppPermissionRoleConverter appPermissionRoleConverter; private final PermissionRoleConverter permissionRoleConverter;
/** /**
* RoleRepository * 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.result.setting.EmailProviderConfigResult;
import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam; import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam; 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.result.setting.EmailProviderConfigResult;
import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam; import cn.topiam.employee.console.pojo.save.setting.MailProviderSaveParam;
import cn.topiam.employee.console.pojo.save.setting.SmsProviderSaveParam; 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.console.service.setting.MessageSettingService;
import cn.topiam.employee.support.context.ApplicationContextHelp; import cn.topiam.employee.support.context.ApplicationContextHelp;
import static cn.topiam.employee.common.constant.ConfigBeanNameConstants.MAIL_PROVIDER_SEND; 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 * 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/>. * 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.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import cn.topiam.employee.common.entity.app.AppPermissionActionEntity;
import cn.topiam.employee.openapi.pojo.request.app.AppPermissionsActionParam; import cn.topiam.employee.openapi.pojo.request.app.AppPermissionsActionParam;
/** /**
@ -31,7 +31,7 @@ import cn.topiam.employee.openapi.pojo.request.app.AppPermissionsActionParam;
*/ */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc") @SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface AppPermissionActionConverter { public interface PermissionActionConverter {
@Mapping(target = "updateTime", ignore = true) @Mapping(target = "updateTime", ignore = true)
@Mapping(target = "updateBy", ignore = true) @Mapping(target = "updateBy", ignore = true)
@Mapping(target = "resource", ignore = true) @Mapping(target = "resource", ignore = true)
@ -40,7 +40,7 @@ public interface AppPermissionActionConverter {
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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 * 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/>. * 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 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.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.springframework.util.CollectionUtils; 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.save.AppPermissionPolicyCreateParam;
import cn.topiam.employee.openapi.pojo.request.app.update.AppPermissionPolicyUpdateParam; import cn.topiam.employee.openapi.pojo.request.app.update.AppPermissionPolicyUpdateParam;
import cn.topiam.employee.support.repository.page.domain.Page; import cn.topiam.employee.support.repository.page.domain.Page;
@ -35,14 +35,14 @@ import cn.topiam.employee.support.repository.page.domain.Page;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class) @Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface AppPermissionPolicyConverter { public interface PermissionPolicyConverter {
/** /**
* *
* *
* @param param {@link AppPermissionPolicyCreateParam} * @param param {@link AppPermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity} * @return {@link PermissionPolicyEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true) @Mapping(target = "id", ignore = true)
@ -51,13 +51,13 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true) @Mapping(target = "createBy", ignore = true)
AppPermissionPolicyEntity policyCreateParamConvertToEntity(AppPermissionPolicyCreateParam param); PermissionPolicyEntity policyCreateParamConvertToEntity(AppPermissionPolicyCreateParam param);
/** /**
* *
* *
* @param param {@link AppPermissionPolicyCreateParam} * @param param {@link AppPermissionPolicyCreateParam}
* @return {@link AppPermissionPolicyEntity} * @return {@link PermissionPolicyEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "updateTime", ignore = true) @Mapping(target = "updateTime", ignore = true)
@ -65,7 +65,7 @@ public interface AppPermissionPolicyConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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} * @param page {@link Page}
* @return {@link Page} * @return {@link Page}
*/ */
default Page<AppPermissionPolicyPO> entityConvertToPolicyListResult(org.springframework.data.domain.Page<AppPermissionPolicyPO> page) { default Page<PermissionPolicyPO> entityConvertToPolicyListResult(org.springframework.data.domain.Page<PermissionPolicyPO> page) {
Page<AppPermissionPolicyPO> result = new Page<>(); Page<PermissionPolicyPO> result = new Page<>();
List<AppPermissionPolicyPO> pageList = page.getContent(); List<PermissionPolicyPO> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) { if (!CollectionUtils.isEmpty(pageList)) {
//@formatter:off //@formatter:off
result.setPagination(Page.Pagination.builder() result.setPagination(Page.Pagination.builder()

View File

@ -15,11 +15,12 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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.ArrayList;
import java.util.List; import java.util.List;
import cn.topiam.employee.common.entity.permission.PermissionResourceEntity;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
@ -28,7 +29,6 @@ import org.springframework.util.CollectionUtils;
import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate; 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.common.entity.app.QAppPermissionResourceEntity;
import cn.topiam.employee.openapi.pojo.request.app.query.AppResourceListQuery; import cn.topiam.employee.openapi.pojo.request.app.query.AppResourceListQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionResourceCreateParam; 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 * @author TopIAM
* Created by support@topiam.cn on 2020/8/14 22:45 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring", uses = AppPermissionActionConverter.class) @Mapper(componentModel = "spring", uses = PermissionActionConverter.class)
public interface AppPermissionResourceConverter { public interface PermissionResourceConverter {
/** /**
* *
@ -70,7 +70,7 @@ public interface AppPermissionResourceConverter {
* *
* *
* @param param {@link AppPermissionResourceCreateParam} * @param param {@link AppPermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity} * @return {@link PermissionResourceEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "actions", ignore = true) @Mapping(target = "actions", ignore = true)
@ -80,13 +80,13 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true) @Mapping(target = "createBy", ignore = true)
AppPermissionResourceEntity resourceCreateParamConvertToEntity(AppPermissionResourceCreateParam param); PermissionResourceEntity resourceCreateParamConvertToEntity(AppPermissionResourceCreateParam param);
/** /**
* *
* *
* @param param {@link AppPermissionResourceCreateParam} * @param param {@link AppPermissionResourceCreateParam}
* @return {@link AppPermissionResourceEntity} * @return {@link PermissionResourceEntity}
*/ */
@Mapping(target = "enabled", expression = "java(Boolean.TRUE)") @Mapping(target = "enabled", expression = "java(Boolean.TRUE)")
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@ -98,7 +98,7 @@ public interface AppPermissionResourceConverter {
@Mapping(target = "remark", ignore = true) @Mapping(target = "remark", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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} * @param page {@link Page}
* @return {@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<>(); Page<AppPermissionResourceListResult> result = new Page<>();
List<AppPermissionResourceEntity> pageList = page.getContent(); List<PermissionResourceEntity> pageList = page.getContent();
if (!CollectionUtils.isEmpty(pageList)) { if (!CollectionUtils.isEmpty(pageList)) {
List<AppPermissionResourceListResult> list = new ArrayList<>(); List<AppPermissionResourceListResult> list = new ArrayList<>();
for (AppPermissionResourceEntity resource : pageList) { for (PermissionResourceEntity resource : pageList) {
list.add(entityConvertToResourceListResult(resource)); list.add(entityConvertToResourceListResult(resource));
} }
//@formatter:off //@formatter:off
@ -129,17 +129,17 @@ public interface AppPermissionResourceConverter {
/** /**
* *
* *
* @param data {@link AppPermissionResourceEntity} * @param data {@link PermissionResourceEntity}
* @return {@link AppPermissionResourceListResult} * @return {@link AppPermissionResourceListResult}
*/ */
AppPermissionResourceListResult entityConvertToResourceListResult(AppPermissionResourceEntity data); AppPermissionResourceListResult entityConvertToResourceListResult(PermissionResourceEntity data);
/** /**
* *
* *
* @param resource {@link AppPermissionResourceEntity} * @param resource {@link PermissionResourceEntity}
* @return {@link AppPermissionResourceGetResult} * @return {@link AppPermissionResourceGetResult}
*/ */
@Mapping(target = "actions", source = "actions") @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 * 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/>. * 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.ArrayList;
import java.util.List; import java.util.List;
@ -29,8 +29,8 @@ import org.springframework.util.ObjectUtils;
import com.querydsl.core.types.ExpressionUtils; import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Predicate; 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.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.query.AppPermissionRoleListQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionRoleCreateParam; 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.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 * Created by support@topiam.cn on 2020/8/14 22:45
*/ */
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface AppPermissionRoleConverter { public interface PermissionRoleConverter {
/** /**
* *
@ -53,11 +53,11 @@ public interface AppPermissionRoleConverter {
* @param page {@link Page} * @param page {@link Page}
* @return {@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<>(); Page<AppPermissionRoleListResult> result = new Page<>();
if (!CollectionUtils.isEmpty(page.getContent())) { if (!CollectionUtils.isEmpty(page.getContent())) {
List<AppPermissionRoleListResult> list = new ArrayList<>(); List<AppPermissionRoleListResult> list = new ArrayList<>();
for (AppPermissionRoleEntity user : page.getContent()) { for (PermissionRoleEntity user : page.getContent()) {
list.add(entityConvertToRolePaginationResult(user)); list.add(entityConvertToRolePaginationResult(user));
} }
//@formatter:off //@formatter:off
@ -75,16 +75,16 @@ public interface AppPermissionRoleConverter {
/** /**
* *
* *
* @param page {@link AppPermissionRoleEntity} * @param page {@link PermissionRoleEntity}
* @return {@link AppPermissionRoleListResult} * @return {@link AppPermissionRoleListResult}
*/ */
AppPermissionRoleListResult entityConvertToRolePaginationResult(AppPermissionRoleEntity page); AppPermissionRoleListResult entityConvertToRolePaginationResult(PermissionRoleEntity page);
/** /**
* *
* *
* @param param {@link AppPermissionRoleCreateParam} * @param param {@link AppPermissionRoleCreateParam}
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "id", ignore = true) @Mapping(target = "id", ignore = true)
@ -93,13 +93,13 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true) @Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", ignore = true) @Mapping(target = "createBy", ignore = true)
AppPermissionRoleEntity roleCreateParamConvertToEntity(AppPermissionRoleCreateParam param); PermissionRoleEntity roleCreateParamConvertToEntity(AppPermissionRoleCreateParam param);
/** /**
* *
* *
* @param param {@link PermissionRoleUpdateParam} * @param param {@link PermissionRoleUpdateParam}
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
@Mapping(target = "deleted", ignore = true) @Mapping(target = "deleted", ignore = true)
@Mapping(target = "appId", ignore = true) @Mapping(target = "appId", ignore = true)
@ -108,21 +108,21 @@ public interface AppPermissionRoleConverter {
@Mapping(target = "updateBy", ignore = true) @Mapping(target = "updateBy", ignore = true)
@Mapping(target = "createTime", ignore = true) @Mapping(target = "createTime", ignore = true)
@Mapping(target = "createBy", 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} * @return {@link AppPermissionRoleResult}
*/ */
AppPermissionRoleResult entityConvertToRoleDetailResult(AppPermissionRoleEntity role); AppPermissionRoleResult entityConvertToRoleDetailResult(PermissionRoleEntity role);
/** /**
* *
* *
* @param query {@link AppPermissionRoleListQuery} * @param query {@link AppPermissionRoleListQuery}
* @return {@link AppPermissionRoleEntity} * @return {@link PermissionRoleEntity}
*/ */
default Predicate rolePaginationParamConvertToPredicate(AppPermissionRoleListQuery query) { default Predicate rolePaginationParamConvertToPredicate(AppPermissionRoleListQuery query) {
QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity; QAppPermissionRoleEntity role = QAppPermissionRoleEntity.appPermissionRoleEntity;

View File

@ -17,14 +17,14 @@
*/ */
package cn.topiam.employee.openapi.endpoint.permission; 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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; 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.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.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.result.ApiRestResult; import cn.topiam.employee.support.result.ApiRestResult;
@ -43,21 +43,21 @@ import static cn.topiam.employee.openapi.constants.OpenApiV1Constants.OPEN_API_P
@RestController @RestController
@RequestMapping(value = OPEN_API_PERMISSION_PATH + "/policy") @RequestMapping(value = OPEN_API_PERMISSION_PATH + "/policy")
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionPolicyEndpoint { public class PermissionPolicyEndpoint {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @return {@link AppPermissionPolicyPO} * @return {@link PermissionPolicyPO}
*/ */
@Operation(summary = "获取策略列表") @Operation(summary = "获取策略列表")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ApiRestResult<Page<AppPermissionPolicyPO>> getPermissionPolicyList(PageModel page, public ApiRestResult<Page<PermissionPolicyPO>> getPermissionPolicyList(PageModel page,
@Validated OpenApiPolicyQuery query) { @Validated OpenApiPolicyQuery query) {
Page<AppPermissionPolicyPO> result = permissionPolicyService.getPermissionPolicyList(page, Page<PermissionPolicyPO> result = permissionPolicyService.getPermissionPolicyList(page,
query); 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.request.app.query.AppResourceListQuery;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionResourceListResult; 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.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.result.ApiRestResult; import cn.topiam.employee.support.result.ApiRestResult;
@ -43,7 +43,7 @@ import static cn.topiam.employee.openapi.constants.OpenApiV1Constants.OPEN_API_P
@RestController @RestController
@RequestMapping(value = OPEN_API_PERMISSION_PATH + "/resource") @RequestMapping(value = OPEN_API_PERMISSION_PATH + "/resource")
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionResourceEndpoint { public class PermissionResourceEndpoint {
/** /**
* *
* *
@ -54,7 +54,7 @@ public class AppPermissionResourceEndpoint {
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ApiRestResult<Page<AppPermissionResourceListResult>> getPermissionResourceList(PageModel page, public ApiRestResult<Page<AppPermissionResourceListResult>> getPermissionResourceList(PageModel page,
@Validated AppResourceListQuery query) { @Validated AppResourceListQuery query) {
Page<AppPermissionResourceListResult> result = appPermissionResourceService Page<AppPermissionResourceListResult> result = permissionResourceService
.getPermissionResourceList(page, query); .getPermissionResourceList(page, query);
return ApiRestResult.<Page<AppPermissionResourceListResult>> builder().result(result) return ApiRestResult.<Page<AppPermissionResourceListResult>> builder().result(result)
.build(); .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.request.app.query.AppPermissionRoleListQuery;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionRoleListResult; 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.Page;
import cn.topiam.employee.support.repository.page.domain.PageModel; import cn.topiam.employee.support.repository.page.domain.PageModel;
import cn.topiam.employee.support.result.ApiRestResult; import cn.topiam.employee.support.result.ApiRestResult;
@ -43,7 +43,7 @@ import static cn.topiam.employee.openapi.constants.OpenApiV1Constants.OPEN_API_P
@RestController @RestController
@RequestMapping(value = OPEN_API_PERMISSION_PATH + "/role") @RequestMapping(value = OPEN_API_PERMISSION_PATH + "/role")
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionRoleEndpoint { public class PermissionRoleEndpoint {
//1、获取应用的所有角色分页 //1、获取应用的所有角色分页
/** /**
* *
@ -55,7 +55,7 @@ public class AppPermissionRoleEndpoint {
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ApiRestResult<Page<AppPermissionRoleListResult>> getPermissionRoleList(PageModel page, public ApiRestResult<Page<AppPermissionRoleListResult>> getPermissionRoleList(PageModel page,
@Validated AppPermissionRoleListQuery query) { @Validated AppPermissionRoleListQuery query) {
Page<AppPermissionRoleListResult> result = appPermissionRoleService Page<AppPermissionRoleListResult> result = permissionRoleService
.getPermissionRoleList(page, query); .getPermissionRoleList(page, query);
return ApiRestResult.<Page<AppPermissionRoleListResult>> builder().result(result).build(); 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 * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * 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; 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.query.OpenApiPolicyQuery;
import cn.topiam.employee.openapi.pojo.request.app.save.AppPermissionPolicyCreateParam; 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.request.app.update.AppPermissionPolicyUpdateParam;
@ -33,15 +33,15 @@ import cn.topiam.employee.support.repository.page.domain.PageModel;
* @author TopIAM * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * Created by support@topiam.cn on 2020-08-10
*/ */
public interface AppPermissionPolicyService { public interface PermissionPolicyService {
/** /**
* *
* *
* @param page {@link PageModel} * @param page {@link PageModel}
* @param query {@link OpenApiPolicyQuery} * @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 * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * 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 * @author TopIAM
* Created by support@topiam.cn on 2020-08-10 * 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.request.app.update.ResourceActionUpdateParam;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionActionGetResult; import cn.topiam.employee.openapi.pojo.response.app.AppPermissionActionGetResult;
import cn.topiam.employee.openapi.pojo.response.app.AppPermissionActionListResult; 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; import lombok.RequiredArgsConstructor;
@ -40,7 +40,7 @@ import lombok.RequiredArgsConstructor;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppPermissionActionServiceImpl implements AppPermissionActionService { public class PermissionActionServiceImpl implements PermissionActionService {
/** /**
* *

View File

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

View File

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

View File

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