页面上的部分查询
This commit is contained in:
parent
026a03c21d
commit
9120825caa
|
@ -1,15 +0,0 @@
|
|||
package io.metersphere.commons.annotations;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Inherited
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FuzzyQuery {
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import io.metersphere.commons.annotations.FuzzyQuery;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BeanUtils {
|
||||
|
||||
|
@ -69,38 +65,4 @@ public class BeanUtils {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> objectToMap(Object obj) {
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
if (obj != null) {
|
||||
ReflectionUtils.doWithFields(obj.getClass(), field -> {
|
||||
boolean accessFlag = field.isAccessible();
|
||||
try {
|
||||
String varName = field.getName();
|
||||
field.setAccessible(true);
|
||||
Object o = field.get(obj);
|
||||
if (o != null) {
|
||||
if (field.isAnnotationPresent(FuzzyQuery.class) && o instanceof String) {
|
||||
String value = "%" + o + "%";
|
||||
map.put(varName, value);
|
||||
} else {
|
||||
map.put(varName, field.get(obj));
|
||||
}
|
||||
}
|
||||
field.setAccessible(accessFlag);
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
field.setAccessible(accessFlag);
|
||||
}
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,13 @@ import io.metersphere.base.domain.Organization;
|
|||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.controller.request.OrganizationRequest;
|
||||
import io.metersphere.dto.OrganizationMemberDTO;
|
||||
import io.metersphere.service.OrganizationService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -23,26 +25,34 @@ public class OrganizationController {
|
|||
|
||||
@PostMapping("/add")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public Organization addOrganization(@RequestBody Organization organization) { return organizationService.addOrganization(organization); }
|
||||
public Organization addOrganization(@RequestBody Organization organization) {
|
||||
return organizationService.addOrganization(organization);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN,RoleConstants.ORG_ADMIN,RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public List<Organization> getOrganizationList() { return organizationService.getOrganizationList(); }
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public List<Organization> getOrganizationList() {
|
||||
return organizationService.getOrganizationList(new OrganizationRequest());
|
||||
}
|
||||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN,RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public Pager<List<Organization>> getOrganizationList(@PathVariable int goPage, @PathVariable int pageSize) {
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public Pager<List<Organization>> getOrganizationList(@RequestBody OrganizationRequest request, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, organizationService.getOrganizationList());
|
||||
return PageUtils.setPageInfo(page, organizationService.getOrganizationList(request));
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{organizationId}")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public void deleteOrganization(@PathVariable(value = "organizationId") String organizationId) { organizationService.deleteOrganization(organizationId); }
|
||||
public void deleteOrganization(@PathVariable(value = "organizationId") String organizationId) {
|
||||
organizationService.deleteOrganization(organizationId);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN,RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public void updateOrganization(@RequestBody Organization organization) { organizationService.updateOrganization(organization); }
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public void updateOrganization(@RequestBody Organization organization) {
|
||||
organizationService.updateOrganization(organization);
|
||||
}
|
||||
|
||||
@GetMapping("/list/userorg/{userId}")
|
||||
public List<Organization> getOrganizationListByUserId(@PathVariable String userId) {
|
||||
|
@ -50,7 +60,7 @@ public class OrganizationController {
|
|||
}
|
||||
|
||||
@PostMapping("/member/update")
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN,RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public void updateOrgMember(@RequestBody OrganizationMemberDTO memberDTO) {
|
||||
organizationService.updateOrgMember(memberDTO);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.controller.request;
|
||||
|
||||
public class OrganizationRequest {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
package io.metersphere.controller.request;
|
||||
|
||||
import io.metersphere.commons.annotations.FuzzyQuery;
|
||||
|
||||
public class WorkspaceRequest {
|
||||
private String organizationId;
|
||||
@FuzzyQuery
|
||||
private String name;
|
||||
|
||||
public String getOrganizationId() {
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ext.ExtOrganizationMapper;
|
|||
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.controller.request.OrganizationRequest;
|
||||
import io.metersphere.dto.OrganizationMemberDTO;
|
||||
import io.metersphere.dto.UserRoleHelpDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
@ -48,8 +49,13 @@ public class OrganizationService {
|
|||
return organization;
|
||||
}
|
||||
|
||||
public List<Organization> getOrganizationList() {
|
||||
return organizationMapper.selectByExample(null);
|
||||
public List<Organization> getOrganizationList(OrganizationRequest request) {
|
||||
OrganizationExample example = new OrganizationExample();
|
||||
OrganizationExample.Criteria criteria = example.createCriteria();
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%"));
|
||||
}
|
||||
return organizationMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void deleteOrganization(String organizationId) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.metersphere.i18n.Translator;
|
|||
import io.metersphere.user.SessionUser;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -77,13 +78,16 @@ public class WorkspaceService {
|
|||
criteria.andOrganizationIdEqualTo(request.getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
criteria.andNameLike(request.getName());
|
||||
criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%"));
|
||||
}
|
||||
return workspaceMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<WorkspaceDTO> getAllWorkspaceList() {
|
||||
return extWorkspaceMapper.getWorkspaceWithOrg();
|
||||
public List<WorkspaceDTO> getAllWorkspaceList(WorkspaceRequest request) {
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
request.setName(StringUtils.wrapIfMissing(request.getName(), "%"));
|
||||
}
|
||||
return extWorkspaceMapper.getWorkspaceWithOrg(request);
|
||||
}
|
||||
|
||||
public void deleteWorkspace(String workspaceId) {
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
<ms-create-box :tips="btnTips" :exec="create"/>
|
||||
</span>
|
||||
<span class="search">
|
||||
<el-input type="text" size="small" :placeholder="$t('organization.search_by_name')" prefix-icon="el-icon-search"
|
||||
<el-input type="text" size="small" :placeholder="$t('organization.search_by_name')"
|
||||
prefix-icon="el-icon-search" @change="search"
|
||||
maxlength="60" v-model="condition" clearable/>
|
||||
</span>
|
||||
</el-row>
|
||||
|
@ -22,7 +23,8 @@
|
|||
<el-table-column prop="description" :label="$t('commons.description')"/>
|
||||
<el-table-column :label="$t('commons.member')">
|
||||
<template v-slot:default="scope">
|
||||
<el-button type="text" class="member-size" @click="cellClick(scope.row)">{{scope.row.memberSize}}</el-button>
|
||||
<el-button type="text" class="member-size" @click="cellClick(scope.row)">{{scope.row.memberSize}}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.operating')">
|
||||
|
@ -102,8 +104,10 @@
|
|||
</el-dialog>
|
||||
|
||||
<!-- add organization form -->
|
||||
<el-dialog :title="$t('organization.create')" :visible.sync="createVisible" width="30%" @closed="closeFunc" :destroy-on-close="true">
|
||||
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule" ref="createOrganization">
|
||||
<el-dialog :title="$t('organization.create')" :visible.sync="createVisible" width="30%" @closed="closeFunc"
|
||||
:destroy-on-close="true">
|
||||
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule"
|
||||
ref="createOrganization">
|
||||
<el-form-item :label="$t('commons.name')" prop="name">
|
||||
<el-input v-model="form.name" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
|
@ -119,8 +123,10 @@
|
|||
</el-dialog>
|
||||
|
||||
<!-- update organization form -->
|
||||
<el-dialog :title="$t('organization.modify')" :visible.sync="updateVisible" width="30%" :destroy-on-close="true" @close="closeFunc">
|
||||
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule" ref="updateOrganizationForm">
|
||||
<el-dialog :title="$t('organization.modify')" :visible.sync="updateVisible" width="30%" :destroy-on-close="true"
|
||||
@close="closeFunc">
|
||||
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule"
|
||||
ref="updateOrganizationForm">
|
||||
<el-form-item :label="$t('commons.name')" prop="name">
|
||||
<el-input v-model="form.name" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
|
@ -136,10 +142,13 @@
|
|||
</el-dialog>
|
||||
|
||||
<!-- add organization member form -->
|
||||
<el-dialog :title="$t('member.create')" :visible.sync="addMemberVisible" width="30%" :destroy-on-close="true" @close="closeFunc">
|
||||
<el-form :model="memberForm" ref="form" :rules="orgMemberRule" label-position="right" label-width="100px" size="small">
|
||||
<el-dialog :title="$t('member.create')" :visible.sync="addMemberVisible" width="30%" :destroy-on-close="true"
|
||||
@close="closeFunc">
|
||||
<el-form :model="memberForm" ref="form" :rules="orgMemberRule" label-position="right" label-width="100px"
|
||||
size="small">
|
||||
<el-form-item :label="$t('commons.member')" prop="userIds">
|
||||
<el-select v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')" class="select-width">
|
||||
<el-select v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')"
|
||||
class="select-width">
|
||||
<el-option
|
||||
v-for="item in memberForm.userList"
|
||||
:key="item.id"
|
||||
|
@ -151,7 +160,8 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
||||
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')" class="select-width">
|
||||
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
|
||||
class="select-width">
|
||||
<el-option
|
||||
v-for="item in memberForm.roles"
|
||||
:key="item.id"
|
||||
|
@ -162,14 +172,15 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<span class="dialog-footer">
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm('form')" size="medium">{{$t('commons.save')}}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- update organization member form -->
|
||||
<el-dialog :title="$t('member.modify')" :visible.sync="updateMemberVisible" width="30%" :destroy-on-close="true" @close="closeFunc">
|
||||
<el-dialog :title="$t('member.modify')" :visible.sync="updateMemberVisible" width="30%" :destroy-on-close="true"
|
||||
@close="closeFunc">
|
||||
<el-form :model="memberForm" label-position="right" label-width="100px" size="small" ref="updateUserForm">
|
||||
<el-form-item label="ID" prop="id">
|
||||
<el-input v-model="memberForm.id" autocomplete="off" :disabled="true"/>
|
||||
|
@ -184,7 +195,8 @@
|
|||
<el-input v-model="memberForm.phone" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
||||
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')" class="select-width">
|
||||
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
|
||||
class="select-width">
|
||||
<el-option
|
||||
v-for="item in memberForm.allroles"
|
||||
:key="item.id"
|
||||
|
@ -196,7 +208,8 @@
|
|||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" @click="updateOrgMember('updateUserForm')" size="medium">{{$t('commons.save')}}</el-button>
|
||||
<el-button type="primary" @click="updateOrgMember('updateUserForm')"
|
||||
size="medium">{{$t('commons.save')}}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
@ -239,7 +252,7 @@
|
|||
rule: {
|
||||
name: [
|
||||
{required: true, message: this.$t('organization.input_name'), trigger: 'blur'},
|
||||
{ min: 2, max: 10, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur' },
|
||||
{min: 2, max: 10, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
|
||||
|
@ -248,7 +261,7 @@
|
|||
}
|
||||
],
|
||||
description: [
|
||||
{ max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur'}
|
||||
{max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur'}
|
||||
]
|
||||
},
|
||||
orgMemberRule: {
|
||||
|
@ -292,7 +305,7 @@
|
|||
// 编辑时填充角色信息
|
||||
this.$set(this.memberForm, 'roleIds', roleIds);
|
||||
},
|
||||
cellClick(row){
|
||||
cellClick(row) {
|
||||
// 保存当前点击的组织信息到currentRow
|
||||
this.currentRow = row;
|
||||
this.memberVisible = true;
|
||||
|
@ -320,7 +333,7 @@
|
|||
cancelButtonText: this.$t('commons.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get(this.deletePath + row.id,() => {
|
||||
this.result = this.$get(this.deletePath + row.id, () => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('commons.delete_success')
|
||||
|
@ -355,16 +368,16 @@
|
|||
});
|
||||
},
|
||||
createOrganization(createOrganizationForm) {
|
||||
this.$refs[createOrganizationForm].validate( valide => {
|
||||
this.$refs[createOrganizationForm].validate(valide => {
|
||||
if (valide) {
|
||||
this.result = this.$post(this.createPath, this.form,() => {
|
||||
this.result = this.$post(this.createPath, this.form, () => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('commons.save_success')
|
||||
});
|
||||
this.initTableData();
|
||||
this.createVisible = false;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -373,21 +386,27 @@
|
|||
updateOrganization(udpateOrganizationForm) {
|
||||
this.$refs[udpateOrganizationForm].validate(valide => {
|
||||
if (valide) {
|
||||
this.result = this.$post(this.updatePath, this.form,() => {
|
||||
this.result = this.$post(this.updatePath, this.form, () => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('commons.modify_success')
|
||||
});
|
||||
this.updateVisible = false;
|
||||
this.initTableData();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
},
|
||||
search() {
|
||||
this.initTableData();
|
||||
},
|
||||
initTableData() {
|
||||
this.result = this.$post(this.buildPagePath(this.queryPath),{},response => {
|
||||
let param = {
|
||||
name: this.condition
|
||||
};
|
||||
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
|
||||
let data = response.data;
|
||||
this.tableData = data.listObject;
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
|
@ -441,7 +460,7 @@
|
|||
roleIds: this.memberForm.roleIds,
|
||||
organizationId: this.currentRow.id
|
||||
};
|
||||
this.result = this.$post("user/special/org/member/add", param,() => {
|
||||
this.result = this.$post("user/special/org/member/add", param, () => {
|
||||
this.cellClick(this.currentRow);
|
||||
this.addMemberVisible = false;
|
||||
})
|
||||
|
@ -459,7 +478,7 @@
|
|||
roleIds: this.memberForm.roleIds,
|
||||
organizationId: this.currentRow.id
|
||||
}
|
||||
this.result = this.$post("/organization/member/update", param,() => {
|
||||
this.result = this.$post("/organization/member/update", param, () => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('commons.modify_success')
|
||||
|
@ -485,8 +504,8 @@
|
|||
}
|
||||
|
||||
.member-size {
|
||||
text-decoration:underline;
|
||||
cursor:pointer;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.org-member-name {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<span class="search">
|
||||
<el-input type="text" size="small"
|
||||
:placeholder="$t('workspace.search_by_name')"
|
||||
prefix-icon="el-icon-search"
|
||||
prefix-icon="el-icon-search" @change="search"
|
||||
maxlength="60" v-model="condition" clearable/>
|
||||
</span>
|
||||
</el-row>
|
||||
|
@ -353,6 +353,9 @@
|
|||
this.memberLineData = [];
|
||||
this.list();
|
||||
},
|
||||
search() {
|
||||
this.list();
|
||||
},
|
||||
list() {
|
||||
let url = '/workspace/list/all/' + this.currentPage + '/' + this.pageSize;
|
||||
this.result = this.$post(url, {name: this.condition}, response => {
|
||||
|
|
|
@ -284,7 +284,6 @@
|
|||
},
|
||||
methods: {
|
||||
initTableData() {
|
||||
this.loading = true;
|
||||
let param = {
|
||||
name: this.condition
|
||||
};
|
||||
|
@ -293,7 +292,6 @@
|
|||
let data = response.data;
|
||||
this.items = data.listObject;
|
||||
this.total = data.itemCount;
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
changeResourceType() {
|
||||
|
|
Loading…
Reference in New Issue