fix(项目报告): 修复创建项目报告选择用户组时查询出了所有系统用户的问题

--bug=1014134 --user=宋天阳
【项目报告】在创建项目报告时,收件人选择“项目管理员”角色时,人员为非指定项目的管理员也包含进来了。
https://www.tapd.cn/55049933/s/1186568
This commit is contained in:
song-tianyang 2022-06-20 15:34:40 +08:00 committed by TIanyang
parent 66a5ada1b6
commit 053a1229e0
7 changed files with 92 additions and 64 deletions

View File

@ -13,7 +13,7 @@ import java.util.List;
public interface ExtUserGroupMapper {
List<UserGroupDTO> getUserGroup(@Param("userId") String userId , @Param("projectId") String projectId);
List<UserGroupDTO> getUserGroup(@Param("userId") String userId, @Param("projectId") String projectId);
List<Group> getWorkspaceMemberGroups(@Param("workspaceId") String workspaceId, @Param("userId") String userId);
@ -21,15 +21,15 @@ public interface ExtUserGroupMapper {
List<User> getProjectMemberList(@Param("request") QueryMemberRequest request);
List<Group> getProjectMemberGroups(@Param("projectId") String projectId,@Param("userId") String userId);
List<Group> getProjectMemberGroups(@Param("projectId") String projectId, @Param("userId") String userId);
List<RelatedSource> getRelatedSource(@Param("userId") String userId);
List<User> getGroupUser(@Param("request")EditGroupRequest request);
List<User> getGroupUser(@Param("request") EditGroupRequest request);
int checkSourceRole(@Param("sourceId") String sourceId, @Param("userId") String userId, @Param("groupId") String groupId);
List<UserGroupInfoDTO> getUserGroupInfo();
List<UserGroupInfoDTO> getUserGroupInfoByProjectId(String projectId);
List<User> getProjectMemberOption(@Param("projectId") String projectId);
List<User> getProjectMemberOption(@Param("projectId") String projectId);
}

View File

@ -17,7 +17,8 @@
from workspace w
join user_group ur on w.id = ur.source_id
join `group` r on r.id = ur.group_id
where w.id = #{workspaceId} and ur.user_id = #{userId}
where w.id = #{workspaceId}
and ur.user_id = #{userId}
</select>
<select id="getMemberList" resultType="io.metersphere.base.domain.User">
SELECT DISTINCT * FROM (
@ -29,17 +30,21 @@
order by user_group.update_time desc) temp
</select>
<select id="getProjectMemberList" resultType="io.metersphere.base.domain.User">
SELECT DISTINCT * FROM (
SELECT `user`.* FROM user_group JOIN `user` ON user_group.user_id = `user`.id
WHERE user_group.source_id = #{request.projectId}
order by `user`.update_time desc) temp
SELECT DISTINCT *
FROM (
SELECT `user`.*
FROM user_group
JOIN `user` ON user_group.user_id = `user`.id
WHERE user_group.source_id = #{request.projectId}
order by `user`.update_time desc) temp
</select>
<select id="getProjectMemberGroups" resultType="io.metersphere.base.domain.Group">
select r.id, r.name
from project p
join user_group ur on p.id = ur.source_id
join `group` r on r.id = ur.group_id
where p.id = #{projectId} and ur.user_id = #{userId}
where p.id = #{projectId}
and ur.user_id = #{userId}
</select>
<select id="getRelatedSource" resultType="io.metersphere.dto.RelatedSource">
SELECT workspace_id, project.id
@ -48,15 +53,15 @@
JOIN workspace w ON project.workspace_id = w.id
WHERE user_id = #{userId} -- project_admin project_member read_only bb
UNION
SELECT w.id, ''
SELECT w.id, ''
FROM user_group
JOIN workspace w ON user_group.source_id = w.id
WHERE user_id = #{userId} -- workspace_admin workspace_member ccc
</select>
<select id="getGroupUser" resultType="io.metersphere.base.domain.User">
select distinct user.id, user.name, user.email, user.phone, user.create_time
from user join user_group ug on user.id = ug.user_id
where ug.group_id = #{request.userGroupId}
from user join user_group ug on user.id = ug.user_id
where ug.group_id = #{request.userGroupId}
<if test="request.name != null and request.name !=''">
and user.name like concat('%', #{request.name},'%')
</if>
@ -70,21 +75,32 @@
SELECT COUNT(id)
FROM user_group ug
WHERE ug.user_id = #{userId}
AND ug.source_id = #{sourceId}
AND ug.group_id = #{groupId}
AND ug.source_id = #{sourceId}
AND ug.group_id = #{groupId}
</select>
<select id="getUserGroupInfo" resultType="io.metersphere.dto.UserGroupInfoDTO">
select distinct user.id AS userId, user.name AS userName, user.email AS userEmail, g.`name` AS groupName, g.id AS groupId
from user INNER JOIN user_group ug on user.id = ug.user_id
INNER JOIN `group` g ON ug.group_id = g.id
order by ug.create_time ASC;
<select id="getUserGroupInfoByProjectId" resultType="io.metersphere.dto.UserGroupInfoDTO">
select distinct user.id AS userId,
user.name AS userName,
user.email AS userEmail,
ug.source_id AS sourceId,
g.`name` AS groupName,
g.id AS groupId
from user
INNER JOIN user_group ug on user.id = ug.user_id
INNER JOIN `group` g ON ug.group_id = g.id
WHERE g.type = 'PROJECT'
AND ug.source_id = #{0}
order by g.create_time ASC;
</select>
<select id="getProjectMemberOption" resultType="io.metersphere.base.domain.User">
SELECT DISTINCT * FROM (
SELECT u.id, u.name, u.email FROM user_group JOIN `user` u ON user_group.user_id = u.id
WHERE user_group.source_id = #{projectId}
order by user_group.update_time desc
) temp
SELECT DISTINCT *
FROM (
SELECT u.id, u.name, u.email
FROM user_group
JOIN `user` u ON user_group.user_id = u.id
WHERE user_group.source_id = #{projectId}
order by user_group.update_time desc
) temp
</select>
</mapper>

View File

@ -11,4 +11,5 @@ public class UserGroupInfoDTO {
private String userEmail;
private String groupId;
private String groupName;
private String sourceId;
}

View File

@ -1,30 +1,30 @@
<template>
<div
class="el-input-tag input-tag-wrapper"
:class="[size ? 'el-input-tag--' + size : '']"
style="height: auto"
@click="foucusTagInput">
class="el-input-tag input-tag-wrapper"
:class="[size ? 'el-input-tag--' + size : '']"
style="height: auto"
@click="foucusTagInput">
<el-tag
class="ms-top"
v-for="(tag, idx) in innerTags"
v-bind="$attrs"
type="info"
:key="tag"
:size="size"
:closable="!readOnly"
:disable-transitions="false"
@close="remove(idx)">
class="ms-top"
v-for="(tag, idx) in innerTags"
v-bind="$attrs"
type="info"
:key="tag"
:size="size"
:closable="!readOnly"
:disable-transitions="false"
@close="remove(idx)">
{{ tag && tag.length > 10 ? tag.substring(0, 10) + "..." : tag }}
</el-tag>
<input
:disabled="readOnly"
class="tag-input el-input"
v-model="newTag"
:placeholder=defaultPlaceHolder
@keydown.delete.stop="removeLastTag"
@keydown="addNew"
@blur="addNew"/>
:disabled="readOnly"
class="tag-input el-input"
v-model="newTag"
:placeholder=defaultPlaceHolder
@keydown.delete.stop="removeLastTag"
@keydown="addNew"
@blur="addNew"/>
</div>
</template>
@ -71,10 +71,10 @@ export default {
this.currentScenario[this.prop] = this.innerTags;
},
'currentScenario.tags'() {
if(this.prop==='tags'){
if(!this.currentScenario[this.prop]||this.currentScenario[this.prop]===''||this.currentScenario[this.prop].length===0){
if(this.innerTags.length!==0){
this.innerTags=[];
if (this.prop === 'tags') {
if (!this.currentScenario[this.prop] || this.currentScenario[this.prop] === '' || this.currentScenario[this.prop].length === 0) {
if (this.innerTags.length !== 0) {
this.innerTags = [];
}
}
}
@ -88,6 +88,7 @@ export default {
}
},
addNew(e) {
this.$emit("onblur");
if (e && (!this.addTagOnKeys.includes(e.keyCode)) && (e.type !== 'blur')) {
return
}
@ -125,8 +126,12 @@ export default {
return false
},
remove(index) {
this.innerTags.splice(index, 1)
this.tagChange()
this.innerTags.splice(index, 1);
this.tagChange();
this.$nextTick(() => {
//tagonblur
this.$emit("onblur");
});
},
removeLastTag() {
if (this.newTag) {

View File

@ -2797,6 +2797,8 @@ export default {
mail_subject: "Subject ",
mail_addressee: "To ",
mail_duplicate: "Cc ",
enter_mail_addressee: "Enter to add email",
enter_mail_duplicate: "Enter to add email",
},
notice: {
operation: {
@ -3189,7 +3191,7 @@ export default {
error_report_library: {
name: "Error report",
assertion: "Error code assertion",
tips:"Tips: Use error report in \"Project Settings - Project environment-Assertions\"",
tips: "Tips: Use error report in \"Project Settings - Project environment-Assertions\"",
use_error_report: "Use error code",
use_desc: "In case of conflict between error code and error assertions, it is treated as error code",
conflict_with_success: "If request has error report and success assertion",

View File

@ -2806,6 +2806,8 @@ export default {
mail_subject: "邮件主题",
mail_addressee: "收件人",
mail_duplicate: "抄送人",
enter_mail_addressee: "输入回车添加邮箱",
enter_mail_duplicate: "输入回车添加邮箱",
},
notice: {
operation: {

View File

@ -1,7 +1,7 @@
export default {
commons: {
project_permission: '請先添加該項目權限',
no_permission:'暫無權限',
no_permission: '暫無權限',
failure_continues: "失敗繼續",
full_screen_editing: "全屏編輯",
trash: "回收站",
@ -51,7 +51,7 @@ export default {
project: '項目',
about_us: '關於',
current_project: '當前項目',
not_exist:"不存在",
not_exist: "不存在",
name: '名稱',
description: '描述',
annotation: '註釋',
@ -252,8 +252,8 @@ export default {
cancel_follow_success: "取消關註成功",
type: "類型",
type_of_integer: "請輸入整數類型",
type_of_num:"請輸入數字類型",
validity_period:'有效期',
type_of_num: "請輸入數字類型",
validity_period: '有效期',
please_select_a_deadline: "請選擇截止時間",
relationship: {
name: '依賴關系',
@ -1193,14 +1193,14 @@ export default {
rule: {
input_code: "請輸入 HTTP Code"
},
range_type:{
range_type: {
value_eq: "值-等於[value=]",
value_not_eq: "值-不等於[value!=]",
value_contain:"值-包含[include=]",
value_contain: "值-包含[include=]",
length_eq: "長度-等于[length=]",
length_not_eq: "長度-不等於[length!=]",
length_large_than:"長度-大於[length>]",
length_shot_than:"長度-小於[length<]",
length_large_than: "長度-大於[length>]",
length_shot_than: "長度-小於[length<]",
regular_match: "正則匹配",
}
},
@ -2800,6 +2800,8 @@ export default {
mail_subject: "郵件主題",
mail_addressee: "收件人",
mail_duplicate: "抄送人",
enter_mail_addressee: "輸入回車添加郵箱",
enter_mail_duplicate: "輸入回車添加郵箱",
},
notice: {
operation: {
@ -3170,8 +3172,8 @@ export default {
delete: "刪除",
read: "查看腳本",
},
personal_information:{
name:'設置',
personal_information: {
name: '設置',
personal_setting: '個人設置',
api_keys: 'API Keys',
edit_password: "修改密碼",
@ -3193,7 +3195,7 @@ export default {
error_report_library: {
name: "誤報庫",
assertion: "誤報斷言",
tips:"注:在\"項目設置-設置環境-全局斷言\"中啟用誤報將進行以下規則匹配",
tips: "注:在\"項目設置-設置環境-全局斷言\"中啟用誤報將進行以下規則匹配",
use_error_report: "啟用誤報",
use_desc: "失敗斷言與誤報規則衝突時統一處理為誤報",
conflict_with_success: "請求同時包含誤報和成功斷言,請求結果處理為:",