feat(REQ-2298): 单测示例commit
This commit is contained in:
parent
9a76dc3171
commit
84b0298d70
@ -2,9 +2,13 @@ package cn.axzo.tyr.server.permission;
|
||||
|
||||
import cn.axzo.tyr.base.BaseTest;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureDao;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasRoleUserRelationDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@ -15,6 +19,8 @@ public class DemoTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
private SaasFeatureDao saasFeatureDao;
|
||||
@Autowired
|
||||
private SaasRoleUserRelationDao saasRoleUserRelationDao;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
@ -23,4 +29,18 @@ public class DemoTest extends BaseTest {
|
||||
List<SaasFeature> saasFeatures = saasFeatureDao.list();
|
||||
Assert.assertEquals(saasFeatures.size(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteUserRole() {
|
||||
Long personId = 1L;
|
||||
Long workspaceId = 1L;
|
||||
Long ouId = 1L;
|
||||
List<SaasRoleUserRelation> roleUserRelations = saasRoleUserRelationDao.queryByPersonId(personId, workspaceId, ouId);
|
||||
Assertions.assertEquals(roleUserRelations.size(), 1);
|
||||
|
||||
saasRoleUserRelationDao.removeWorkspaceOuAllUserRole(workspaceId, ouId);
|
||||
|
||||
List<SaasRoleUserRelation> roleUserRelations2 = saasRoleUserRelationDao.queryByPersonId(personId, workspaceId, ouId);
|
||||
Assertions.assertTrue(CollectionUtils.isEmpty(roleUserRelations2));
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,17 @@ flush:
|
||||
role1052:
|
||||
saasPreTempalteIdOfProject: 5
|
||||
saasPreTempalteIdOfOu: 43
|
||||
|
||||
axzo:
|
||||
cache:
|
||||
auth:
|
||||
enable: false
|
||||
expire: 30
|
||||
# 菜单同步基准环境 不配默认为PRE
|
||||
# service.base.tyr: https://test-api.axzo.cn/tyr
|
||||
# 超管编码
|
||||
role.superAdmin: '{1:"entSuperAdmin",2:"projSuperAdmin",6:"omsSuperAdmin"}'
|
||||
|
||||
axzo:
|
||||
role:
|
||||
superAdmin: '{1:"entSuperAdmin",2:"projSuperAdmin",6:"omsSuperAdmin"}'
|
||||
@ -1 +1,7 @@
|
||||
select 1;
|
||||
select 1;
|
||||
|
||||
-- saas_role_user_relation 表初始化数据
|
||||
-- DemoTest.testDeleteUserRole 使用
|
||||
INSERT INTO `saas_role_user_relation` (`id`, `identity_id`, `role_id`, `identity_type`, `natural_person_id`, `workspace_id`, `ou_id`, `resource_type`, `resource_id`, `is_delete`, `create_at`, `update_at`, `create_by`, `update_by`, `job_type`) VALUES (1, 2008231, 100001, 2, 1, 1, 1, 1, 9592, 0, '2024-05-22 18:23:40', '2024-05-22 18:23:39', 0, 0, 2);
|
||||
|
||||
|
||||
|
||||
@ -55,6 +55,28 @@ CREATE TABLE `saas_feature` (
|
||||
KEY `IDX_CODE` (`feature_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4618 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='saas-菜单页面表';
|
||||
|
||||
CREATE TABLE `saas_role_user_relation` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`identity_id` bigint NOT NULL DEFAULT '0' COMMENT '身份Id',
|
||||
`role_id` bigint NOT NULL DEFAULT '0' COMMENT '角色Id',
|
||||
`identity_type` tinyint NOT NULL DEFAULT '0' COMMENT '身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员',
|
||||
`natural_person_id` bigint NOT NULL DEFAULT '0' COMMENT '自然人Id',
|
||||
`workspace_id` bigint NOT NULL DEFAULT '0' COMMENT '工作台Id',
|
||||
`ou_id` bigint NOT NULL DEFAULT '0' COMMENT '所属单位Id',
|
||||
`resource_type` tinyint NOT NULL DEFAULT '0' COMMENT '资源类型',
|
||||
`resource_id` bigint NOT NULL DEFAULT '0' COMMENT '资源Id',
|
||||
`is_delete` bigint NOT NULL DEFAULT '0' COMMENT '是否删除:0否,other是',
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` bigint NOT NULL DEFAULT '0' COMMENT '创建者',
|
||||
`update_by` bigint NOT NULL DEFAULT '0' COMMENT '更新者',
|
||||
`job_type` int NOT NULL DEFAULT '2' COMMENT '岗位类型 1:主岗 2:兼岗',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_ouId_spaceId_identityId` (`ou_id`,`workspace_id`,`identity_id`),
|
||||
KEY `idx_role_id` (`role_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=214132 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='saas-角色用户关联表';
|
||||
|
||||
|
||||
|
||||
CREATE TABLE `saas_role` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user