fix(XPack): license 验证缺陷修复

This commit is contained in:
fit2-zhao 2020-09-22 19:48:44 +08:00
parent d370a5bb7b
commit 8f807044ad
5 changed files with 38 additions and 38 deletions

View File

@ -127,10 +127,4 @@ public class APITestController {
public List<ScheduleDao> listSchedule(@RequestBody QueryScheduleRequest request) { public List<ScheduleDao> listSchedule(@RequestBody QueryScheduleRequest request) {
return apiTestService.listSchedule(request); return apiTestService.listSchedule(request);
} }
@GetMapping("/license/valid")
public LicenseDTO valid() {
return apiTestService.validateLicense();
}
} }

View File

@ -437,13 +437,4 @@ public class APITestService {
quotaService.checkAPITestQuota(); quotaService.checkAPITestQuota();
} }
} }
public LicenseDTO validateLicense() {
LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class);
if (licenseService != null) {
return licenseService.valid();
}
return null;
}
} }

View File

@ -5,6 +5,7 @@ import io.metersphere.commons.constants.UserSource;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.LoginRequest; import io.metersphere.controller.request.LoginRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.service.UserService; import io.metersphere.service.UserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
@ -67,4 +68,9 @@ public class LoginController {
return userService.getDefaultLanguage(); return userService.getDefaultLanguage();
} }
@GetMapping("/api/license/valid")
public LicenseDTO valid() {
return userService.validateLicense();
}
} }

View File

@ -10,6 +10,7 @@ import io.metersphere.commons.constants.UserStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.CodingUtil; import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.ResultHolder; import io.metersphere.controller.ResultHolder;
import io.metersphere.controller.request.LoginRequest; import io.metersphere.controller.request.LoginRequest;
@ -19,6 +20,7 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.member.UserRequest; import io.metersphere.controller.request.member.UserRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest; import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest; import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO; import io.metersphere.dto.UserRoleDTO;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
@ -589,4 +591,12 @@ public class UserService {
public List<User> searchUser(String condition) { public List<User> searchUser(String condition) {
return extUserMapper.searchUser(condition); return extUserMapper.searchUser(condition);
} }
public LicenseDTO validateLicense() {
LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class);
if (licenseService != null) {
return licenseService.valid();
}
return null;
}
} }

View File

@ -1,15 +1,11 @@
<template> <template>
<el-col v-if="auth"> <el-col v-if="auth">
<el-row id="header-top1" type="flex" justify="space-between" align="middle"> <el-row v-if="licenseHeader != null">
<el-col> <el-col>
<div class="license-head" v-if="validData.status == 'expired'">License has expired since <component :is="licenseHeader"></component>
{{(validData!= undefined && validData.license!= undefined) ? validData.license.expired:''}},please
update license.
</div>
</el-col> </el-col>
</el-row> </el-row>
<el-row id="header-top" type="flex" justify="space-between" align="middle"> <el-row id="header-top" type="flex" justify="space-between" align="middle">
<el-col :span="12"> <el-col :span="12">
<a class="logo"/> <a class="logo"/>
<ms-top-menus/> <ms-top-menus/>
@ -34,15 +30,18 @@
import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs"; import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs";
import MsLanguageSwitch from "./components/common/head/LanguageSwitch"; import MsLanguageSwitch from "./components/common/head/LanguageSwitch";
import {saveLocalStorage} from "../common/js/utils"; import {saveLocalStorage} from "../common/js/utils";
import {saveLicense} from "../common/js/utils";
import Setting from "@/business/components/settings/router"; const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const header = requireComponent("./license/LicenseMessage.vue");
export default { export default {
name: 'app', name: 'app',
props: {},
data() { data() {
return { return {
validData: {}, licenseHeader: null,
auth: false auth: false,
header: {},
} }
}, },
beforeCreate() { beforeCreate() {
@ -51,6 +50,10 @@
this.$setLang(response.data.data.language); this.$setLang(response.data.data.language);
saveLocalStorage(response.data); saveLocalStorage(response.data);
this.auth = true; this.auth = true;
//
if (header.default !== undefined) {
this.licenseHeader = "MsLicenseHeader";
}
} else { } else {
window.location.href = "/login" window.location.href = "/login"
} }
@ -58,21 +61,18 @@
window.location.href = "/login" window.location.href = "/login"
}); });
}, },
beforeMount() { components: {
// license MsLanguageSwitch,
this.result = this.$get("/api/license/valid", response => { MsUser,
let data = response.data; MsView,
if (data != undefined && data != null) { MsTopMenus,
this.validData = response.data; MsHeaderOrgWs,
saveLicense(response.data); "MsLicenseHeader": header.default
} }
});
},
components: {MsLanguageSwitch, MsUser, MsView, MsTopMenus, MsHeaderOrgWs},
methods: {}
} }
</script> </script>
<style scoped> <style scoped>
#header-top { #header-top {
width: 100%; width: 100%;
@ -128,4 +128,3 @@
color: white; color: white;
} }
</style> </style>