This commit is contained in:
shiziyuan9527 2020-11-16 16:11:42 +08:00
commit 0ecb9870a1
11 changed files with 66 additions and 10 deletions

3
.gitignore vendored
View File

@ -30,4 +30,5 @@ target
.settings
.project
.classpath
.jython_cache
.jython_cache
qywx.json

View File

@ -49,8 +49,16 @@
<select id="getOrgMemberList" resultType="io.metersphere.base.domain.User">
SELECT DISTINCT * FROM (
SELECT `user`.* FROM user_role JOIN `user` ON user_role.user_id = `user`.id
WHERE user_role.source_id = #{orgMember.organizationId}
SELECT `user`.*
FROM user_role JOIN `user`
ON user_role.user_id = `user`.id
WHERE user_role.source_id in
(
SELECT id FROM workspace w
WHERE w.organization_id = #{orgMember.organizationId}
UNION
SELECT #{orgMember.organizationId} AS id FROM dual
)
<if test="orgMember.name != null">
AND `user`.name like CONCAT('%', #{orgMember.name},'%')
</if>

View File

@ -3,6 +3,7 @@ package io.metersphere.commons.constants;
public class RoleConstants {
public final static String ADMIN = "admin";
public final static String ORG_ADMIN = "org_admin";
public final static String ORG_MEMBER = "org_member";
public final static String TEST_VIEWER = "test_viewer";
public final static String TEST_MANAGER = "test_manager";
public final static String TEST_USER = "test_user";

View File

@ -171,12 +171,11 @@ public class OrganizationService {
SessionUser sessionUser = SessionUtils.getUser();
UserDTO user = userService.getUserDTO(sessionUser.getId());
List<String> collect = user.getUserRoles().stream()
.filter(ur -> RoleConstants.ORG_ADMIN.equals(ur.getRoleId()))
.filter(ur -> RoleConstants.ORG_ADMIN.equals(ur.getRoleId()) || RoleConstants.ORG_MEMBER.equals(ur.getRoleId()))
.map(UserRole::getSourceId)
.collect(Collectors.toList());
if (!collect.contains(organizationId)) {
MSException.throwException(Translator.get("organization_does_not_belong_to_user"));
}
}
}

View File

@ -457,12 +457,19 @@ public class TestCaseService {
if (t.getMethod().equals("manual")) {
String steps = t.getSteps();
String setp = "";
if (steps.contains("null") && !steps.contains("\"null\"")) {
setp = steps.replace("null", "\"\"");
} else {
setp = steps;
setp = steps;
JSONArray jsonArray = null;
//解决旧版本保存用例导出报错
try {
jsonArray = JSON.parseArray(setp);
} catch (Exception e) {
if (steps.contains("null") && !steps.contains("\"null\"")) {
setp = steps.replace("null", "\"\"");
jsonArray = JSON.parseArray(setp);
}
}
JSONArray jsonArray = JSON.parseArray(setp);
for (int j = 0; j < jsonArray.size(); j++) {
int num = j + 1;
step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\n");

View File

@ -0,0 +1,2 @@
INSERT INTO role (id, name, description, type, create_time, update_time)
VALUES ('org_member', '组织成员', NULL, NULL, unix_timestamp() * 1000, unix_timestamp() * 1000);

View File

@ -165,6 +165,11 @@
for (let i = 0; i < this.tableData.length; i++) {
this.$get(url + "/" + encodeURIComponent(this.tableData[i].id), response => {
let roles = response.data;
if (roles.length < 1) {
roles.push({
id : "org_member",
});
}
this.$set(this.tableData[i], "roles", roles);
})
}

View File

@ -103,6 +103,21 @@
</el-select>
</el-form-item>
</div>
<div v-if="role.id === 'org_member'">
<el-form-item :label="$t('organization.select_organization')"
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('organization.select_organization'), trigger: 'change'}"
>
<el-select filterable v-model="role.ids" :placeholder="$t('organization.select_organization')" multiple>
<el-option
v-for="item in form.orgList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id === 'test_manager'">
<el-form-item :label="$t('workspace.select')"
:prop="'roles.' + index + '.ids'"
@ -214,6 +229,21 @@
</el-select>
</el-form-item>
</div>
<div v-if="role.id === 'org_member'">
<el-form-item :label="$t('organization.select_organization')"
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('organization.select_organization'), trigger: 'change'}"
>
<el-select filterable v-model="role.ids" :placeholder="$t('organization.select_organization')" multiple>
<el-option
v-for="item in form.orgList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div v-if="role.id === 'test_manager'">
<el-form-item :label="$t('workspace.select')"
:prop="'roles.' + index + '.ids'"

View File

@ -339,6 +339,7 @@ export default {
please_choose_role: 'Please Choose Role',
admin: 'Admin',
org_admin: 'Org_Admin',
org_member: 'Org Member',
test_manager: 'Test Manager',
test_user: 'Test User',
test_viewer: 'Read-only User',

View File

@ -338,6 +338,7 @@ export default {
please_choose_role: '请选择角色',
admin: '系统管理员',
org_admin: '组织管理员',
org_member: '组织成员',
test_manager: '测试经理',
test_user: '测试人员',
test_viewer: '只读用户',

View File

@ -340,6 +340,7 @@ export default {
please_choose_role: '請選擇角色',
admin: '系統管理員',
org_admin: '組織管理員',
org_member: '組織成員',
test_manager: '測試經理',
test_user: '測試人員',
test_viewer: '只讀用戶',