refactor(系统设置): 模块管理已经开源

--task=1010909 --user=刘瑞斌 【开源计划】功能模块... https://www.tapd.cn/55049933/s/1323488
This commit is contained in:
CaptainB 2023-01-06 10:50:06 +08:00 committed by lyh
parent 246322faad
commit 9629e92884
8 changed files with 104 additions and 21 deletions

View File

@ -1,7 +1,8 @@
package io.metersphere.xpack.module.controller; package io.metersphere.controller;
import io.metersphere.xpack.module.dto.Module;
import io.metersphere.xpack.module.service.ListModuleService; import io.metersphere.dto.Module;
import io.metersphere.service.ListModuleService;
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;

View File

@ -1,4 +1,4 @@
package io.metersphere.xpack.module.dto; package io.metersphere.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -1,9 +1,9 @@
package io.metersphere.xpack.module.service; package io.metersphere.service;
import io.metersphere.base.domain.SystemParameter; import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.SystemParameterExample; import io.metersphere.base.domain.SystemParameterExample;
import io.metersphere.base.mapper.SystemParameterMapper; import io.metersphere.base.mapper.SystemParameterMapper;
import io.metersphere.xpack.module.dto.Module; import io.metersphere.dto.Module;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,9 +0,0 @@
package io.metersphere.xpack.module.service;
public interface ModuleService {
void updateModuleStatus(String key, String status);
String getLogDetails(String key, String status);
}

View File

@ -0,0 +1,26 @@
package io.metersphere.controller;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.ModuleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("module")
public class ModuleController {
@Resource
private ModuleService moduleService;
@GetMapping("update/{key}/status/{status}")
@MsAuditLog(module = OperLogModule.SYSTEM_PARAMETER_SETTING, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#key,#status)", msClass = ModuleService.class)
public void updateModuleStatus(@PathVariable("key") String key, @PathVariable("status") String status) {
moduleService.updateModuleStatus(key, status);
}
}

View File

@ -0,0 +1,65 @@
package io.metersphere.service;
import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.mapper.SystemParameterMapper;
import io.metersphere.commons.utils.JSON;
import io.metersphere.log.vo.OperatingLogDetails;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.LinkedList;
@Service
@Transactional(rollbackFor = Exception.class)
public class ModuleService {
private static final String PREFIX = "metersphere.module.";
@Resource
private SystemParameterMapper systemParameterMapper;
public void updateModuleStatus(String key, String status) {
SystemParameter record = new SystemParameter();
record.setParamKey(PREFIX + key);
record.setParamValue(status);
record.setType("text");
record.setSort(1);
if (systemParameterMapper.updateByPrimaryKey(record) == 0) {
systemParameterMapper.insert(record);
}
}
public String getLogDetails(String key, String status) {
if (StringUtils.isNotEmpty(key)) {
switch (key) {
case "performance":
key = "性能测试";
break;
case "report":
key = "报表统计";
break;
case "api":
key = "接口测试";
break;
case "track":
key = "测试跟踪";
break;
case "project":
key = "项目设置";
break;
case "setting":
key = "系统设置";
break;
}
}
if (status.equals("ENABLE")) {
status = "开启";
} else {
status = "禁用";
}
OperatingLogDetails details = new OperatingLogDetails(null, null, "修改:" + key + " 状态为:" + status, null, new LinkedList<>());
return JSON.toJSONString(details);
}
}

View File

@ -56,7 +56,7 @@ import {getModuleList, updateStatus} from "@/api/module";
import {hasLicense} from "metersphere-frontend/src/utils/permission"; import {hasLicense} from "metersphere-frontend/src/utils/permission";
export default { export default {
name: "MxModule", name: "MsModule",
props: { props: {
isShow: { isShow: {
type: Boolean, type: Boolean,

View File

@ -11,15 +11,15 @@
<el-tab-pane :label="$t('system_parameter_setting.ldap_setting')" name="ldap"> <el-tab-pane :label="$t('system_parameter_setting.ldap_setting')" name="ldap">
<ldap-setting/> <ldap-setting/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('module.title')" name="module">
<ms-module/>
</el-tab-pane>
<el-tab-pane v-if="hasLicense()" :label="$t('display.title')" name="display"> <el-tab-pane v-if="hasLicense()" :label="$t('display.title')" name="display">
<mx-display/> <mx-display/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane v-if="hasLicense()" :label="$t('auth_source.title')" name="auth"> <el-tab-pane v-if="hasLicense()" :label="$t('auth_source.title')" name="auth">
<mx-auth/> <mx-auth/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane v-if="hasLicense()" :label="$t('module.title')" name="module">
<mx-module/>
</el-tab-pane>
</el-tabs> </el-tabs>
</el-card> </el-card>
</template> </template>
@ -30,7 +30,7 @@ import LdapSetting from "./LdapSetting";
import BaseSetting from "./BaseSetting"; import BaseSetting from "./BaseSetting";
import MxAuth from "./MxAuth"; import MxAuth from "./MxAuth";
import MxDisplay from "./MxDisplay"; import MxDisplay from "./MxDisplay";
import MxModule from "./MxModule"; import MsModule from "./MsModule";
import {hasLicense} from 'metersphere-frontend/src/utils/permission'; import {hasLicense} from 'metersphere-frontend/src/utils/permission';
export default { export default {
@ -41,7 +41,7 @@ export default {
LdapSetting, LdapSetting,
MxAuth, MxAuth,
MxDisplay, MxDisplay,
MxModule MsModule
}, },
data() { data() {
return { return {