Merge branch 'v1.3' of https://github.com/metersphere/metersphere into v1.3
This commit is contained in:
commit
cb8fb36297
|
@ -7,9 +7,11 @@ import io.metersphere.api.dto.scenario.request.HttpRequest;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -19,7 +21,7 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
|||
|
||||
protected String getApiTestStr(InputStream source) {
|
||||
StringBuilder testStr = null;
|
||||
try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source, StandardCharsets.UTF_8))) {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source, StandardCharsets.UTF_8))) {
|
||||
testStr = new StringBuilder();
|
||||
String inputStr;
|
||||
while ((inputStr = bufferedReader.readLine()) != null) {
|
||||
|
@ -46,21 +48,21 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
|||
}
|
||||
|
||||
protected void addContentType(HttpRequest request, String contentType) {
|
||||
addHeader(request, HttpHeader.CONTENT_TYPE.toString(), contentType);
|
||||
addHeader(request, "Content-Type", contentType);
|
||||
}
|
||||
|
||||
protected void addCookie(HttpRequest request, String key, String value) {
|
||||
List<KeyValue> headers = Optional.ofNullable(request.getHeaders()).orElse(new ArrayList<>());
|
||||
boolean hasCookie = false;
|
||||
for (KeyValue header : headers) {
|
||||
if (StringUtils.equalsIgnoreCase(HttpHeader.COOKIE.name(), header.getName())) {
|
||||
if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) {
|
||||
hasCookie = true;
|
||||
String cookies = Optional.ofNullable(header.getValue()).orElse("");
|
||||
header.setValue(cookies + key + "=" + value + ";");
|
||||
}
|
||||
}
|
||||
if (!hasCookie) {
|
||||
addHeader(request, HttpHeader.COOKIE.name(), key + "=" + value + ";");
|
||||
addHeader(request, "Cookie", key + "=" + value + ";");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import io.metersphere.api.dto.parse.ApiImport;
|
|||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.commons.constants.MsRequestBodyType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class MsParser extends ApiImportAbstractParser {
|
|||
Object body = requestObject.get("body");
|
||||
if (body instanceof JSONArray) {
|
||||
JSONArray bodies = requestObject.getJSONArray("body");
|
||||
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodies != null) {
|
||||
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), "POST") && bodies != null) {
|
||||
StringBuilder bodyStr = new StringBuilder();
|
||||
for (int i = 0; i < bodies.size(); i++) {
|
||||
String tmp = bodies.getString(i);
|
||||
|
@ -75,7 +74,7 @@ public class MsParser extends ApiImportAbstractParser {
|
|||
}
|
||||
} else if (body instanceof JSONObject) {
|
||||
JSONObject bodyObj = requestObject.getJSONObject("body");
|
||||
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodyObj != null) {
|
||||
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), "POST") && bodyObj != null) {
|
||||
JSONArray kvs = new JSONArray();
|
||||
bodyObj.keySet().forEach(key -> {
|
||||
JSONObject kv = new JSONObject();
|
||||
|
|
|
@ -12,11 +12,11 @@ public class Notice implements Serializable {
|
|||
|
||||
private String testId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String enable;
|
||||
|
||||
private String type;
|
||||
|
||||
private String userId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -314,76 +314,6 @@ public class NoticeExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("`NAME` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("`NAME` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("`NAME` =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("`NAME` <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("`NAME` >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`NAME` >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("`NAME` <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("`NAME` <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("`NAME` like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("`NAME` not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("`NAME` in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("`NAME` not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("`NAME` between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("`NAME` not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableIsNull() {
|
||||
addCriterion("`ENABLE` is null");
|
||||
return (Criteria) this;
|
||||
|
@ -523,6 +453,76 @@ public class NoticeExample {
|
|||
addCriterion("`type` not between", value1, value2, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIsNull() {
|
||||
addCriterion("user_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIsNotNull() {
|
||||
addCriterion("user_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdEqualTo(String value) {
|
||||
addCriterion("user_id =", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotEqualTo(String value) {
|
||||
addCriterion("user_id <>", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdGreaterThan(String value) {
|
||||
addCriterion("user_id >", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("user_id >=", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLessThan(String value) {
|
||||
addCriterion("user_id <", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("user_id <=", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdLike(String value) {
|
||||
addCriterion("user_id like", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotLike(String value) {
|
||||
addCriterion("user_id not like", value, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdIn(List<String> values) {
|
||||
addCriterion("user_id in", values, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotIn(List<String> values) {
|
||||
addCriterion("user_id not in", values, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdBetween(String value1, String value2) {
|
||||
addCriterion("user_id between", value1, value2, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUserIdNotBetween(String value1, String value2) {
|
||||
addCriterion("user_id not between", value1, value2, "userId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="EVENT" jdbcType="VARCHAR" property="event" />
|
||||
<result column="TEST_ID" jdbcType="VARCHAR" property="testId" />
|
||||
<result column="NAME" jdbcType="VARCHAR" property="name" />
|
||||
<result column="ENABLE" jdbcType="VARCHAR" property="enable" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -68,7 +68,7 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, EVENT, TEST_ID, `NAME`, `ENABLE`, `type`
|
||||
id, EVENT, TEST_ID, `ENABLE`, `type`, user_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.NoticeExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -102,9 +102,11 @@
|
|||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.Notice">
|
||||
INSERT INTO notice (id, EVENT, TEST_ID,
|
||||
`NAME`, `ENABLE`, `type`)
|
||||
`ENABLE`, `type`, user_id
|
||||
)
|
||||
VALUES (#{id,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
|
||||
#{name,jdbcType=VARCHAR}, #{enable,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR})
|
||||
#{enable,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Notice">
|
||||
insert into notice
|
||||
|
@ -118,15 +120,15 @@
|
|||
<if test="testId != null">
|
||||
TEST_ID,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`NAME`,
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
`ENABLE`,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
`type`,
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
|
@ -138,15 +140,15 @@
|
|||
<if test="testId != null">
|
||||
#{testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
#{enable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
#{userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.NoticeExample" resultType="java.lang.Long">
|
||||
|
@ -167,15 +169,15 @@
|
|||
<if test="record.testId != null">
|
||||
TEST_ID = #{record.testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`NAME` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.enable != null">
|
||||
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
|
@ -186,9 +188,9 @@
|
|||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
EVENT = #{record.event,jdbcType=VARCHAR},
|
||||
TEST_ID = #{record.testId,jdbcType=VARCHAR},
|
||||
`NAME` = #{record.name,jdbcType=VARCHAR},
|
||||
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
|
||||
`type` = #{record.type,jdbcType=VARCHAR}
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
user_id = #{record.userId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -202,15 +204,15 @@
|
|||
<if test="testId != null">
|
||||
TEST_ID = #{testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`NAME` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
`ENABLE` = #{enable,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id = #{userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
@ -218,9 +220,9 @@
|
|||
UPDATE notice
|
||||
SET EVENT = #{event,jdbcType=VARCHAR},
|
||||
TEST_ID = #{testId,jdbcType=VARCHAR},
|
||||
`NAME` = #{name,jdbcType=VARCHAR},
|
||||
`ENABLE` = #{enable,jdbcType=VARCHAR},
|
||||
`type` = #{type,jdbcType=VARCHAR}
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
user_id = #{userId,jdbcType=VARCHAR}
|
||||
WHERE id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -16,8 +16,6 @@ public interface ExtUserMapper {
|
|||
|
||||
List<User> searchUser(String condition);
|
||||
|
||||
List<String> queryEmails(String[] names);
|
||||
|
||||
List<String> queryEmailByIds(List<String> userIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -33,18 +33,6 @@
|
|||
</where>
|
||||
order by u.update_time desc
|
||||
</select>
|
||||
<!--查询邮箱-->
|
||||
<select id="queryEmails" parameterType="java.lang.String" resultType="java.lang.String">
|
||||
SELECT
|
||||
email
|
||||
from user
|
||||
WHERE name IN
|
||||
<foreach collection="array" item="id" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
<select id="queryEmailByIds" parameterType="java.lang.String" resultType="java.lang.String">
|
||||
SELECT
|
||||
email
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.mgt.DefaultSessionManager;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -26,6 +30,30 @@ public class SessionUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static Session getSessionByUsername(String username) {
|
||||
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
|
||||
Collection<Session> sessions = sessionManager.getSessionDAO().getActiveSessions();
|
||||
for (Session session : sessions) {
|
||||
if (null != session && StringUtils.equals(String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)), username)) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢除用户
|
||||
*
|
||||
* @param username
|
||||
*/
|
||||
public static void kickOutUser(String username) {
|
||||
Session session = getSessionByUsername(username);
|
||||
if (session != null) {
|
||||
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
|
||||
sessionManager.getSessionDAO().delete(session);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
public static void putUser(SessionUser sessionUser) {
|
||||
SecurityUtils.getSubject().getSession().setAttribute(ATTR_USER, sessionUser);
|
||||
|
|
|
@ -2,7 +2,6 @@ package io.metersphere.config;
|
|||
|
||||
import io.metersphere.commons.utils.ShiroUtils;
|
||||
import io.metersphere.security.ApiKeyFilter;
|
||||
import io.metersphere.security.LoginFilter;
|
||||
import io.metersphere.security.ShiroDBRealm;
|
||||
import org.apache.shiro.cache.MemoryConstrainedCacheManager;
|
||||
import org.apache.shiro.session.mgt.SessionManager;
|
||||
|
@ -36,7 +35,7 @@ public class ShiroConfig implements EnvironmentAware {
|
|||
@Bean
|
||||
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager sessionManager) {
|
||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
||||
shiroFilterFactoryBean.getFilters().put("authc", new LoginFilter());
|
||||
// shiroFilterFactoryBean.getFilters().put("authc", new LoginFilter());
|
||||
shiroFilterFactoryBean.setLoginUrl("/login");
|
||||
shiroFilterFactoryBean.setSecurityManager(sessionManager);
|
||||
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
|
||||
|
@ -45,7 +44,8 @@ public class ShiroConfig implements EnvironmentAware {
|
|||
shiroFilterFactoryBean.getFilters().put("apikey", new ApiKeyFilter());
|
||||
Map<String, String> filterChainDefinitionMap = shiroFilterFactoryBean.getFilterChainDefinitionMap();
|
||||
ShiroUtils.loadBaseFilterChain(filterChainDefinitionMap);
|
||||
filterChainDefinitionMap.put("/**", "apikey, authc");
|
||||
// filterChainDefinitionMap.put("/**", "apikey, authc");
|
||||
filterChainDefinitionMap.put("/**", "apikey");
|
||||
return shiroFilterFactoryBean;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ public class UserController {
|
|||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public void deleteUser(@PathVariable(value = "userId") String userId) {
|
||||
userService.deleteUser(userId);
|
||||
// 踢掉在线用户
|
||||
SessionUtils.kickOutUser(userId);
|
||||
}
|
||||
|
||||
@PostMapping("/special/update")
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
public interface ExcelDataFactory {
|
||||
Object getExcelDataByLocal();
|
||||
}
|
|
@ -1,65 +1,31 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
@Getter
|
||||
@Setter
|
||||
public class TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("{test_case_name}")
|
||||
@ExcelIgnore
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("{test_case_module}")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
@ExcelIgnore
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_type}")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
@ExcelIgnore
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_maintainer}")
|
||||
@ExcelIgnore
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_priority}")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
@ExcelIgnore
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_method}")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
@ExcelIgnore
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_prerequisite}")
|
||||
@Length(min = 0, max = 1000)
|
||||
@ExcelIgnore
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_remark}")
|
||||
@Length(max = 1000)
|
||||
@ExcelIgnore
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_step_desc}")
|
||||
@Length(max = 1000)
|
||||
@ExcelIgnore
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_step_result}")
|
||||
@Length(max = 1000)
|
||||
@ExcelIgnore
|
||||
private String stepResult;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
public class TestCaseExcelDataCn extends TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("用例名称")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("所属模块")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例类型")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("维护人")
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例等级")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("测试方式")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("前置条件")
|
||||
@Length(min = 0, max = 1000)
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("备注")
|
||||
@Length(max = 1000)
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("步骤描述")
|
||||
@Length(max = 1000)
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("预期结果")
|
||||
@Length(max = 1000)
|
||||
private String stepResult;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TestCaseExcelDataFactory implements ExcelDataFactory {
|
||||
@Override
|
||||
public Class getExcelDataByLocal() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (Locale.US.toString().equalsIgnoreCase(locale.toString())) {
|
||||
return TestCaseExcelDataUs.class;
|
||||
} else if (Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())) {
|
||||
return TestCaseExcelDataTw.class;
|
||||
}
|
||||
return TestCaseExcelDataCn.class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
public class TestCaseExcelDataTw extends TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("用例名稱")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("所屬模塊")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例類型")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("維護人")
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例等級")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("測試方式")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("前置條件")
|
||||
@Length(min = 0, max = 1000)
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("備註")
|
||||
@Length(max = 1000)
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("步驟描述")
|
||||
@Length(max = 1000)
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("預期結果")
|
||||
@Length(max = 1000)
|
||||
private String stepResult;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
public class TestCaseExcelDataUs extends TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("Name")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("Module")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Type")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Maintainer")
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Priority")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Method")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Prerequisite")
|
||||
@Length(min = 0, max = 1000)
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Remark")
|
||||
@Length(max = 1000)
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Step description")
|
||||
@Length(max = 1000)
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Step result")
|
||||
@Length(max = 1000)
|
||||
private String stepResult;
|
||||
}
|
|
@ -8,7 +8,6 @@ import com.alibaba.excel.util.StringUtils;
|
|||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.excel.domain.ExcelErrData;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.excel.utils.EasyExcelI18nTranslator;
|
||||
import io.metersphere.excel.utils.ExcelValidateHelper;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
||||
|
@ -17,14 +16,12 @@ import java.lang.reflect.ParameterizedType;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> implements AutoCloseable {
|
||||
public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
|
||||
|
||||
protected List<ExcelErrData<T>> errList = new ArrayList<>();
|
||||
|
||||
protected List<T> list = new ArrayList<>();
|
||||
|
||||
protected EasyExcelI18nTranslator easyExcelI18nTranslator;
|
||||
|
||||
protected List<TestCaseExcelData> excelDataList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
@ -37,11 +34,6 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> impl
|
|||
public EasyExcelListener() {
|
||||
Type type = getClass().getGenericSuperclass();
|
||||
this.clazz = (Class<T>) ((ParameterizedType) type).getActualTypeArguments()[0];
|
||||
//防止多线程修改运行时类注解后,saveOriginalExcelProperty保存的是修改后的值
|
||||
synchronized (EasyExcelI18nTranslator.class) {
|
||||
this.easyExcelI18nTranslator = new EasyExcelI18nTranslator(this.clazz);
|
||||
this.easyExcelI18nTranslator.translateExcelProperty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,9 +145,4 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> impl
|
|||
return errList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.easyExcelI18nTranslator.resetExcelProperty();
|
||||
}
|
||||
}
|
|
@ -12,20 +12,12 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
public class EasyExcelExporter implements AutoCloseable {
|
||||
|
||||
EasyExcelI18nTranslator easyExcelI18nTranslator;
|
||||
public class EasyExcelExporter {
|
||||
|
||||
private Class clazz;
|
||||
|
||||
public EasyExcelExporter(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
//防止多线程修改运行时类注解后,saveOriginalExcelProperty保存的是修改后的值
|
||||
synchronized (EasyExcelI18nTranslator.class) {
|
||||
easyExcelI18nTranslator = new EasyExcelI18nTranslator(clazz);
|
||||
easyExcelI18nTranslator.translateExcelProperty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void export(HttpServletResponse response, List data, String fileName, String sheetName) {
|
||||
|
@ -46,9 +38,4 @@ public class EasyExcelExporter implements AutoCloseable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
easyExcelI18nTranslator.resetExcelProperty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package io.metersphere.excel.utils;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.exception.ExcelException;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 表头国际化
|
||||
* 先调用 saveOriginalExcelProperty 存储原表头注解值
|
||||
* 再调用 translateExcelProperty 获取国际化的值
|
||||
* 最后调用 resetExcelProperty 重置为原来值,防止切换语言后无法国际化
|
||||
*/
|
||||
public class EasyExcelI18nTranslator {
|
||||
|
||||
private Map<String, List<String>> excelPropertyMap = new HashMap<>();
|
||||
|
||||
private Class clazz;
|
||||
|
||||
public EasyExcelI18nTranslator(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
saveOriginalExcelProperty();
|
||||
}
|
||||
|
||||
private void readExcelProperty(Class clazz, BiConsumer<String, Map<String, Object>> operate) {
|
||||
Field field;
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
try {
|
||||
field = clazz.getDeclaredField(fields[i].getName());
|
||||
field.setAccessible(true);
|
||||
ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
|
||||
if (excelProperty != null) {
|
||||
InvocationHandler invocationHandler = Proxy.getInvocationHandler(excelProperty);
|
||||
Field fieldValue = invocationHandler.getClass().getDeclaredField("memberValues");
|
||||
fieldValue.setAccessible(true);
|
||||
Map<String, Object> memberValues = null;
|
||||
try {
|
||||
memberValues = (Map<String, Object>) fieldValue.get(invocationHandler);
|
||||
} catch (IllegalAccessException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new ExcelException(e.getMessage());
|
||||
}
|
||||
|
||||
operate.accept(field.getName(), memberValues);
|
||||
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void saveOriginalExcelProperty() {
|
||||
readExcelProperty(clazz, (fieldName, memberValues) -> {
|
||||
List<String> values = Arrays.asList((String[]) memberValues.get("value"));
|
||||
List<String> copyValues = new ArrayList<>();
|
||||
values.forEach(value -> {
|
||||
copyValues.add(value);
|
||||
});
|
||||
excelPropertyMap.put(fieldName, copyValues);
|
||||
});
|
||||
}
|
||||
|
||||
public void translateExcelProperty() {
|
||||
readExcelProperty(TestCaseExcelData.class, (fieldName, memberValues) -> {
|
||||
String[] values = (String[]) memberValues.get("value");
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
if (Pattern.matches("^\\{.+\\}$", values[j])) {
|
||||
values[j] = Translator.get(values[j].substring(1, values[j].length() - 1));
|
||||
}
|
||||
}
|
||||
memberValues.put("value", values);
|
||||
});
|
||||
}
|
||||
|
||||
public void resetExcelProperty() {
|
||||
readExcelProperty(clazz, (fieldName, memberValues) -> {
|
||||
String[] values = (String[]) memberValues.get("value");
|
||||
List<String> list = excelPropertyMap.get(fieldName);
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
values[j] = list.get(j);
|
||||
}
|
||||
memberValues.put("value", values);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -3,7 +3,10 @@ package io.metersphere.notice.domain;
|
|||
import io.metersphere.base.domain.Notice;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NoticeDetail extends Notice {
|
||||
private String[] names;
|
||||
private List<String> userIds = new ArrayList<>();
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import io.metersphere.base.domain.ApiTestReport;
|
|||
import io.metersphere.base.domain.LoadTestWithBLOBs;
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||
import io.metersphere.commons.utils.EncryptUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
|
@ -40,19 +42,19 @@ public class MailService {
|
|||
@Resource
|
||||
private SystemParameterService systemParameterService;
|
||||
|
||||
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest) {
|
||||
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest, String id) {
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
Map<String, String> context = new HashMap<>();
|
||||
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
|
||||
context.put("testName", loadTest.getName());
|
||||
context.put("id", loadTest.getId());
|
||||
context.put("id", id);
|
||||
context.put("type", "performance");
|
||||
context.put("url", baseSystemConfigDTO.getUrl());
|
||||
String performanceTemplate = "";
|
||||
try {
|
||||
if (status.equals("Completed")) {
|
||||
if (StringUtils.equals(status, PerformanceTestStatus.Completed.name())) {
|
||||
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/successPerformance.html"), StandardCharsets.UTF_8);
|
||||
} else if (status.equals("Error")) {
|
||||
} else if (StringUtils.equals(status, PerformanceTestStatus.Error.name())) {
|
||||
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/failPerformance.html"), StandardCharsets.UTF_8);
|
||||
}
|
||||
sendHtmlTimeTasks(noticeList, status, context, performanceTemplate);
|
||||
|
@ -71,9 +73,9 @@ public class MailService {
|
|||
context.put("id", apiTestReport.getId());
|
||||
String apiTemplate = "";
|
||||
try {
|
||||
if (apiTestReport.getStatus().equals("Success")) {
|
||||
if (StringUtils.equals(APITestStatus.Success.name(), apiTestReport.getStatus())) {
|
||||
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/success.html"), StandardCharsets.UTF_8);
|
||||
} else if (apiTestReport.getStatus().equals("Error")) {
|
||||
} else if (StringUtils.equals(APITestStatus.Error.name(), apiTestReport.getStatus())) {
|
||||
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/fail.html"), StandardCharsets.UTF_8);
|
||||
}
|
||||
sendHtmlTimeTasks(noticeList, apiTestReport.getStatus(), context, apiTemplate);
|
||||
|
@ -184,17 +186,21 @@ public class MailService {
|
|||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
javaMailSender.setProtocol("smtps");
|
||||
for (SystemParameter p : paramList) {
|
||||
if (p.getParamKey().equals("smtp.host")) {
|
||||
javaMailSender.setHost(p.getParamValue());
|
||||
}
|
||||
if (p.getParamKey().equals("smtp.port")) {
|
||||
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
|
||||
}
|
||||
if (p.getParamKey().equals("smtp.account")) {
|
||||
javaMailSender.setUsername(p.getParamValue());
|
||||
}
|
||||
if (p.getParamKey().equals("smtp.password")) {
|
||||
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
|
||||
switch (p.getParamKey()) {
|
||||
case "smtp.host":
|
||||
javaMailSender.setHost(p.getParamValue());
|
||||
break;
|
||||
case "smtp.port":
|
||||
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
|
||||
break;
|
||||
case "smtp.account":
|
||||
javaMailSender.setUsername(p.getParamValue());
|
||||
break;
|
||||
case "smtp.password":
|
||||
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Properties props = new Properties();
|
||||
|
@ -224,18 +230,18 @@ public class MailService {
|
|||
List<String> failEmailList = new ArrayList<>();
|
||||
if (noticeList.size() > 0) {
|
||||
for (NoticeDetail n : noticeList) {
|
||||
if (n.getEnable().equals("true") && n.getEvent().equals(NoticeConstants.EXECUTE_SUCCESSFUL)) {
|
||||
successEmailList = userService.queryEmail(n.getNames());
|
||||
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_SUCCESSFUL)) {
|
||||
successEmailList = userService.queryEmail(n.getUserIds());
|
||||
}
|
||||
if (n.getEnable().equals("true") && n.getEvent().equals(NoticeConstants.EXECUTE_FAILED)) {
|
||||
failEmailList = userService.queryEmail(n.getNames());
|
||||
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_FAILED)) {
|
||||
failEmailList = userService.queryEmail(n.getUserIds());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LogUtil.error("Recipient information is empty");
|
||||
}
|
||||
|
||||
if (status.equals("Success") || status.equals("Completed")) {
|
||||
if (StringUtils.equalsAny(status, PerformanceTestStatus.Completed.name(), APITestStatus.Success.name())) {
|
||||
recipientEmails = successEmailList.toArray(new String[0]);
|
||||
} else {
|
||||
recipientEmails = failEmailList.toArray(new String[0]);
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.base.domain.NoticeExample;
|
|||
import io.metersphere.base.mapper.NoticeMapper;
|
||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -28,14 +29,14 @@ public class NoticeService {
|
|||
noticeMapper.deleteByExample(example);
|
||||
}
|
||||
noticeRequest.getNotices().forEach(n -> {
|
||||
if (n.getNames().length > 0) {
|
||||
for (String x : n.getNames()) {
|
||||
if (CollectionUtils.isNotEmpty(n.getUserIds())) {
|
||||
for (String x : n.getUserIds()) {
|
||||
Notice notice = new Notice();
|
||||
notice.setId(UUID.randomUUID().toString());
|
||||
notice.setEvent(n.getEvent());
|
||||
notice.setEnable(n.getEnable());
|
||||
notice.setTestId(noticeRequest.getTestId());
|
||||
notice.setName(x);
|
||||
notice.setUserId(x);
|
||||
notice.setType(n.getType());
|
||||
noticeMapper.insert(notice);
|
||||
}
|
||||
|
@ -48,33 +49,29 @@ public class NoticeService {
|
|||
example.createCriteria().andTestIdEqualTo(id);
|
||||
List<Notice> notices = noticeMapper.selectByExample(example);
|
||||
List<NoticeDetail> result = new ArrayList<>();
|
||||
List<String> success = new ArrayList<>();
|
||||
List<String> fail = new ArrayList<>();
|
||||
String[] successArray;
|
||||
String[] failArray;
|
||||
List<String> successList = new ArrayList<>();
|
||||
List<String> failList = new ArrayList<>();
|
||||
NoticeDetail notice1 = new NoticeDetail();
|
||||
NoticeDetail notice2 = new NoticeDetail();
|
||||
if (notices.size() > 0) {
|
||||
for (Notice n : notices) {
|
||||
if (n.getEvent().equals(EXECUTE_SUCCESSFUL)) {
|
||||
success.add(n.getName());
|
||||
successList.add(n.getUserId());
|
||||
notice1.setEnable(n.getEnable());
|
||||
notice1.setTestId(id);
|
||||
notice1.setType(n.getType());
|
||||
notice1.setEvent(n.getEvent());
|
||||
}
|
||||
if (n.getEvent().equals(EXECUTE_FAILED)) {
|
||||
fail.add(n.getName());
|
||||
failList.add(n.getUserId());
|
||||
notice2.setEnable(n.getEnable());
|
||||
notice2.setTestId(id);
|
||||
notice2.setType(n.getType());
|
||||
notice2.setEvent(n.getEvent());
|
||||
}
|
||||
}
|
||||
successArray = success.toArray(new String[0]);
|
||||
failArray = fail.toArray(new String[0]);
|
||||
notice1.setNames(successArray);
|
||||
notice2.setNames(failArray);
|
||||
notice1.setUserIds(successList);
|
||||
notice2.setUserIds(failList);
|
||||
result.add(notice1);
|
||||
result.add(notice2);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public class PerformanceTestService {
|
|||
if (request.getTriggerMode().equals("SCHEDULE")) {
|
||||
try {
|
||||
noticeList = noticeService.queryNotice(loadTest.getId());
|
||||
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest);
|
||||
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest, engine.getReportId());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class PerformanceTestService {
|
|||
loadTestMapper.updateByPrimaryKeySelective(loadTest);
|
||||
if (triggerMode.equals("SCHEDULE")) {
|
||||
noticeList = noticeService.queryNotice(loadTest.getId());
|
||||
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest);
|
||||
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest, loadTest.getId());
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ public class PerformanceTestService {
|
|||
if (loadTestReport.getTriggerMode().equals("SCHEDULE")) {
|
||||
try {
|
||||
noticeList = noticeService.queryNotice(loadTest.getId());
|
||||
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest);
|
||||
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest, loadTestReport.getId());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -62,8 +61,8 @@ public class UserService {
|
|||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
public List<String> queryEmail(String[] names) {
|
||||
return extUserMapper.queryEmails(names);
|
||||
public List<String> queryEmail(List<String> userIds) {
|
||||
return extUserMapper.queryEmailByIds(userIds);
|
||||
}
|
||||
|
||||
public List<String> queryEmailByIds(List<String> userIds) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.metersphere.controller.request.OrderRequest;
|
|||
import io.metersphere.excel.domain.ExcelErrData;
|
||||
import io.metersphere.excel.domain.ExcelResponse;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.excel.domain.TestCaseExcelDataFactory;
|
||||
import io.metersphere.excel.listener.EasyExcelListener;
|
||||
import io.metersphere.excel.listener.TestCaseDataListener;
|
||||
import io.metersphere.excel.utils.EasyExcelExporter;
|
||||
|
@ -305,8 +306,9 @@ public class TestCaseService {
|
|||
|
||||
Set<String> userIds = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getUserId).collect(Collectors.toSet());
|
||||
|
||||
try (EasyExcelListener easyExcelListener = new TestCaseDataListener(this, projectId, testCaseNames, userIds)) {
|
||||
EasyExcelFactory.read(multipartFile.getInputStream(), TestCaseExcelData.class, easyExcelListener).sheet().doRead();
|
||||
try {
|
||||
EasyExcelListener easyExcelListener = new TestCaseDataListener(this, projectId, testCaseNames, userIds);
|
||||
EasyExcelFactory.read(multipartFile.getInputStream(), new TestCaseExcelDataFactory().getExcelDataByLocal(), easyExcelListener).sheet().doRead();
|
||||
errList = easyExcelListener.getErrList();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
|
@ -344,7 +346,8 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
public void testCaseTemplateExport(HttpServletResponse response) {
|
||||
try (EasyExcelExporter easyExcelExporter = new EasyExcelExporter(TestCaseExcelData.class)) {
|
||||
try {
|
||||
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(new TestCaseExcelDataFactory().getExcelDataByLocal());
|
||||
easyExcelExporter.export(response, generateExportTemplate(),
|
||||
Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
||||
} catch (Exception e) {
|
||||
|
@ -422,10 +425,12 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
public void testCaseExport(HttpServletResponse response, TestCaseBatchRequest request) {
|
||||
try (EasyExcelExporter easyExcelExporter = new EasyExcelExporter(TestCaseExcelData.class)) {
|
||||
try {
|
||||
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(new TestCaseExcelDataFactory().getExcelDataByLocal());
|
||||
easyExcelExporter.export(response, generateTestCaseExcel(request),
|
||||
Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +478,7 @@ public class TestCaseService {
|
|||
} else if (t.getMethod().equals("auto") && t.getType().equals("api")) {
|
||||
data.setStepDesc("");
|
||||
data.setStepResult("");
|
||||
if (t.getTestId().equals("other")) {
|
||||
if (t.getTestId() != null && t.getTestId().equals("other")) {
|
||||
data.setRemark(t.getOtherTestName());
|
||||
} else {
|
||||
data.setRemark(t.getApiName());
|
||||
|
@ -482,7 +487,7 @@ public class TestCaseService {
|
|||
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) {
|
||||
data.setStepDesc("");
|
||||
data.setStepResult("");
|
||||
if (t.getTestId().equals("other")) {
|
||||
if (t.getTestId() != null && t.getTestId().equals("other")) {
|
||||
data.setRemark(t.getOtherTestName());
|
||||
} else {
|
||||
data.setRemark(t.getPerformName());
|
||||
|
|
|
@ -95,10 +95,6 @@ public class TestPlanService {
|
|||
|
||||
testPlan.setId(testPlanId);
|
||||
testPlan.setStatus(TestPlanStatus.Prepare.name());
|
||||
testPlan.setPlannedStartTime(System.currentTimeMillis());
|
||||
testPlan.setPlannedEndTime(System.currentTimeMillis());
|
||||
testPlan.setActualStartTime(System.currentTimeMillis());
|
||||
testPlan.setActualEndTime(System.currentTimeMillis());
|
||||
testPlan.setCreateTime(System.currentTimeMillis());
|
||||
testPlan.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanMapper.insert(testPlan);
|
||||
|
@ -120,16 +116,14 @@ public class TestPlanService {
|
|||
testPlan.setUpdateTime(System.currentTimeMillis());
|
||||
checkTestPlanExist(testPlan);
|
||||
//进行中状态,写入实际开始时间
|
||||
if ("Underway".equals(testPlan.getStatus())) {
|
||||
if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) {
|
||||
testPlan.setActualStartTime(System.currentTimeMillis());
|
||||
return testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||
} else if("Completed".equals(testPlan.getStatus())){
|
||||
|
||||
} else if(TestPlanStatus.Completed.name().equals(testPlan.getStatus())){
|
||||
//已完成,写入实际完成时间
|
||||
testPlan.setActualEndTime(System.currentTimeMillis());
|
||||
return testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||
}
|
||||
|
||||
private void editTestPlanProject(TestPlanDTO testPlan) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE notice
|
||||
ADD user_id VARCHAR(50) NULL;
|
||||
UPDATE notice
|
||||
SET notice.user_id = (
|
||||
SELECT id
|
||||
FROM user
|
||||
WHERE notice.NAME = user.name
|
||||
);
|
||||
ALTER TABLE notice
|
||||
DROP COLUMN name;
|
|
@ -7,7 +7,7 @@
|
|||
<body>
|
||||
<div>
|
||||
<p style="text-align: left">${creator} 发起的:<br>
|
||||
${reviewName}<br>
|
||||
${reviewName}已完成<br>
|
||||
计划开始时间是:${start}<br>
|
||||
计划结束时间为:${end}<br>
|
||||
已完成<br>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<body>
|
||||
<div>
|
||||
<p style="text-align: left">${creator} 发起的:<br>
|
||||
${reviewName}<br>
|
||||
${reviewName}待开始<br>
|
||||
计划开始时间是:${start}<br>
|
||||
计划结束时间为:${end}<br>
|
||||
请跟进<br>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="text-container">
|
||||
<div @click="active" class="collapse">
|
||||
<i class="icon el-icon-arrow-right" :class="{'is-active': isActive}"/>
|
||||
{{$t('api_report.response')}}
|
||||
{{ $t('api_report.response') }}
|
||||
</div>
|
||||
<el-collapse-transition>
|
||||
<el-tabs v-model="activeName" v-show="isActive">
|
||||
|
@ -10,7 +10,7 @@
|
|||
<ms-code-edit :mode="mode" :read-only="true" :data="response.body" :modes="modes" ref="codeEdit"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="Headers" name="headers" class="pane">
|
||||
<pre>{{response.headers}}</pre>
|
||||
<pre>{{ response.headers }}</pre>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_report.assertions')" name="assertions" class="pane assertions">
|
||||
<ms-assertion-results :assertions="response.assertions"/>
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
<el-tab-pane v-if="activeName == 'body'" :disabled="true" name="mode" class="pane assertions">
|
||||
<template v-slot:label>
|
||||
<ms-dropdown :commands="modes" @command="modeChange"/>
|
||||
<ms-dropdown :commands="modes" :default-command="mode" @command="modeChange"/>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
|
||||
|
@ -28,73 +28,83 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsAssertionResults from "./AssertionResults";
|
||||
import MsCodeEdit from "../../../common/components/MsCodeEdit";
|
||||
import MsDropdown from "../../../common/components/MsDropdown";
|
||||
import {BODY_FORMAT} from "../../test/model/ScenarioModel";
|
||||
import MsAssertionResults from "./AssertionResults";
|
||||
import MsCodeEdit from "../../../common/components/MsCodeEdit";
|
||||
import MsDropdown from "../../../common/components/MsDropdown";
|
||||
import {BODY_FORMAT} from "../../test/model/ScenarioModel";
|
||||
|
||||
export default {
|
||||
name: "MsResponseText",
|
||||
export default {
|
||||
name: "MsResponseText",
|
||||
|
||||
components: {
|
||||
MsDropdown,
|
||||
MsCodeEdit,
|
||||
MsAssertionResults,
|
||||
components: {
|
||||
MsDropdown,
|
||||
MsCodeEdit,
|
||||
MsAssertionResults,
|
||||
},
|
||||
|
||||
props: {
|
||||
response: Object
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
isActive: true,
|
||||
activeName: "body",
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
mode: BODY_FORMAT.TEXT
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
active() {
|
||||
this.isActive = !this.isActive;
|
||||
},
|
||||
modeChange(mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
},
|
||||
|
||||
props: {
|
||||
response: Object
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
isActive: true,
|
||||
activeName: "body",
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
mode: BODY_FORMAT.TEXT
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
active() {
|
||||
this.isActive = !this.isActive;
|
||||
},
|
||||
modeChange(mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log(this.response.headers);
|
||||
if (!this.response.headers) {
|
||||
return;
|
||||
}
|
||||
if (this.response.headers.indexOf("Content-Type: application/json") > 0) {
|
||||
this.mode = BODY_FORMAT.JSON;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.text-container .icon {
|
||||
padding: 5px;
|
||||
}
|
||||
.text-container .icon {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.text-container .collapse {
|
||||
cursor: pointer;
|
||||
}
|
||||
.text-container .collapse {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.text-container .collapse:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
.text-container .collapse:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.text-container .icon.is-active {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
.text-container .icon.is-active {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.text-container .pane {
|
||||
background-color: #F5F5F5;
|
||||
padding: 0 10px;
|
||||
height: 250px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.text-container .pane {
|
||||
background-color: #F5F5F5;
|
||||
padding: 0 10px;
|
||||
height: 250px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.text-container .pane.assertions {
|
||||
padding: 0;
|
||||
}
|
||||
.text-container .pane.assertions {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -115,6 +115,9 @@ export default {
|
|||
watch: {
|
||||
test() {
|
||||
this.initScenarioEnvironment();
|
||||
},
|
||||
projectId() {
|
||||
this.initScenarioEnvironment();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -208,9 +211,13 @@ export default {
|
|||
let env = environmentMap.get(scenario.environmentId);
|
||||
if (!env) {
|
||||
scenario.environmentId = undefined;
|
||||
scenario.environment = undefined;
|
||||
} else {
|
||||
scenario.environment = env;
|
||||
}
|
||||
} else {
|
||||
scenario.environmentId = undefined;
|
||||
scenario.environment = undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,7 +38,15 @@
|
|||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_set_variable'),
|
||||
value: 'vars.put("variable_name", "variable_value");',
|
||||
value: 'vars.put("variable_name", "variable_value")',
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_get_global_variable'),
|
||||
value: '${__P("variable_name")}',
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_set_global_variable'),
|
||||
value: '${__setProperty("variable_name","variable_value",)}',
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_get_response_header'),
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<el-form-item v-if="request.useEnvironment" :label="$t('api_test.request.address')" class="adjust-margin-bottom">
|
||||
<el-tag class="environment-display">
|
||||
<span class="environment-name">{{ request.environment ? request.environment.name + ': ' : '' }}</span>
|
||||
<span class="environment-name">{{ scenario.environment ? scenario.environment.name + ': ' : '' }}</span>
|
||||
<span class="environment-url">{{ displayUrl }}</span>
|
||||
<span v-if="!displayUrl"
|
||||
class="environment-url-tip">{{ $t('api_test.request.please_configure_socket_in_environment') }}</span>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<el-tab-pane :label="$t('api_test.request.parameters')" name="parameters">
|
||||
<ms-api-variable :is-read-only="isReadOnly"
|
||||
:parameters="request.parameters"
|
||||
:environment="request.environment"
|
||||
:environment="scenario.environment"
|
||||
:scenario="scenario"
|
||||
:extract="request.extract"
|
||||
:description="$t('api_test.request.parameters_desc')"/>
|
||||
|
@ -62,7 +62,7 @@
|
|||
:body="request.body"
|
||||
:scenario="scenario"
|
||||
:extract="request.extract"
|
||||
:environment="request.environment"/>
|
||||
:environment="scenario.environment"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_test.request.assertions.label')" name="assertions">
|
||||
<ms-api-assertions :is-read-only="isReadOnly" :assertions="request.assertions"/>
|
||||
|
@ -148,7 +148,7 @@ export default {
|
|||
if (!this.request.path) return;
|
||||
let url = this.getURL(this.displayUrl);
|
||||
let urlStr = url.origin + url.pathname;
|
||||
let envUrl = this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket;
|
||||
let envUrl = this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket;
|
||||
this.request.path = decodeURIComponent(urlStr.substring(envUrl.length, urlStr.length));
|
||||
},
|
||||
getURL(urlStr) {
|
||||
|
@ -156,7 +156,7 @@ export default {
|
|||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.request.parameters.splice(0, 0, new KeyValue({name: name, value: value}));
|
||||
this.request.parameters.splice(0, 0, new KeyValue({name: key, value: value}));
|
||||
}
|
||||
});
|
||||
return url;
|
||||
|
@ -170,7 +170,7 @@ export default {
|
|||
}
|
||||
},
|
||||
useEnvironmentChange(value) {
|
||||
if (value && !this.request.environment) {
|
||||
if (value && !this.scenario.environment) {
|
||||
this.$error(this.$t('api_test.request.please_add_environment_to_scenario'), 2000);
|
||||
this.request.useEnvironment = false;
|
||||
}
|
||||
|
@ -191,8 +191,8 @@ export default {
|
|||
|
||||
computed: {
|
||||
displayUrl() {
|
||||
return (this.request.environment && this.request.environment.config.httpConfig.socket) ?
|
||||
this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
|
||||
return (this.scenario.environment && this.scenario.environment.config.httpConfig.socket) ?
|
||||
this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
|
||||
: '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
|
||||
:placeholder="$t('schedule.please_input_cron_expression')"/>
|
||||
<!-- <el-button type="primary" @click="showCronDialog">{{$t('schedule.generate_expression')}}</el-button>-->
|
||||
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{ $t('commons.save') }}</el-button>
|
||||
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{
|
||||
$t('commons.save')
|
||||
}}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-link :disabled="isReadOnly" type="primary" @click="showCronDialog">
|
||||
|
@ -21,8 +24,10 @@
|
|||
</el-form-item>
|
||||
<crontab-result :ex="form.cronValue" ref="crontabResult"/>
|
||||
</el-form>
|
||||
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron" :modal="false">
|
||||
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value" ref="crontab"/>
|
||||
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron"
|
||||
:modal="false">
|
||||
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value"
|
||||
ref="crontab"/>
|
||||
</el-dialog>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('schedule.task_notification')" name="second">
|
||||
|
@ -42,16 +47,17 @@
|
|||
<el-table-column
|
||||
prop="name"
|
||||
:label="$t('schedule.receiver')"
|
||||
width="200"
|
||||
width="240"
|
||||
>
|
||||
<template v-slot:default="{row}">
|
||||
<el-select v-model="row.names" filterable multiple :placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()">
|
||||
<el-select v-model="row.userIds" filterable multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.name">
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
@ -148,13 +154,13 @@ export default {
|
|||
{
|
||||
event: "EXECUTE_SUCCESSFUL",
|
||||
type: "EMAIL",
|
||||
names: [],
|
||||
userIds: [],
|
||||
enable: false
|
||||
},
|
||||
{
|
||||
event: "EXECUTE_FAILED",
|
||||
type: "EMAIL",
|
||||
names: [],
|
||||
userIds: [],
|
||||
enable: false
|
||||
}
|
||||
],
|
||||
|
@ -184,8 +190,8 @@ export default {
|
|||
this.tableData[1].event = "EXECUTE_FAILED"
|
||||
this.tableData[1].type = "EMAIL"
|
||||
} else {
|
||||
this.tableData[0].names = []
|
||||
this.tableData[1].names = []
|
||||
this.tableData[0].userIds = []
|
||||
this.tableData[1].userIds = []
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -269,4 +275,10 @@ export default {
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/deep/ .el-select__tags {
|
||||
flex-wrap: unset;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
this.$refs[form].validate(valid => {
|
||||
if (valid) {
|
||||
|
||||
let formatUrl = this.form.url;
|
||||
let formatUrl = this.form.url.trim();
|
||||
if (!formatUrl.endsWith('/')) {
|
||||
formatUrl = formatUrl + '/';
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<el-col>
|
||||
<el-form-item :label="$t('system_config.base.url')" prop="url">
|
||||
<el-input v-model="formInline.url" :placeholder="$t('system_config.base.url_tip')"/>
|
||||
<i>({{$t('commons.examples')}}:https://rdmetersphere.fit2cloud.com)</i>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<template>
|
||||
<home-base-component title="我的评审" v-loading>
|
||||
<home-base-component :title="$t('test_track.review.my_review')" v-loading>
|
||||
<template slot="header-area">
|
||||
<div style="float: right">
|
||||
<ms-table-button :is-tester-permission="true" v-if="!showMyCreator" icon="el-icon-view"
|
||||
content="我创建的评审" @click="searchMyCreator"/>
|
||||
:content="$t('test_track.review.my_create')" @click="searchMyCreator"/>
|
||||
<ms-table-button :is-tester-permission="true" v-if="showMyCreator" icon="el-icon-view"
|
||||
content="待我评审" @click="searchMyCreator"/>
|
||||
:content="$t('test_track.review.reviewed_by_me')" @click="searchMyCreator"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
@ -24,13 +24,13 @@
|
|||
<el-table-column
|
||||
prop="creator"
|
||||
fixed
|
||||
label="创建人"
|
||||
:label="$t('test_track.review.creator')"
|
||||
show-overflow-tooltip>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="reviewerName"
|
||||
fixed
|
||||
label="评审人"
|
||||
:label="$t('test_track.review.reviewer')"
|
||||
show-overflow-tooltip>
|
||||
</el-table-column>
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
<el-table-column
|
||||
prop="projectName"
|
||||
label="已评用例"
|
||||
:label="$t('test_track.review.done')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
{{scope.row.reviewed}}/{{scope.row.total}}
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
<el-table-column
|
||||
prop="projectName"
|
||||
:label="$t('test_track.home.test_rate')"
|
||||
:label="$t('test_track.home.review_progress')"
|
||||
min-width="100"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
|
|
|
@ -271,6 +271,8 @@ export default {
|
|||
this.form.stage = '';
|
||||
this.form.description = '';
|
||||
this.form.status = null;
|
||||
this.form.plannedStartTime = null;
|
||||
this.form.plannedEndTime = null;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
:placeholder="$t('test_track.review.input_review_project')"
|
||||
multiple
|
||||
style="width: 100%"
|
||||
collapse-tags
|
||||
filterable>
|
||||
<el-option
|
||||
v-for="item in projects"
|
||||
|
@ -49,7 +48,6 @@
|
|||
v-model="form.userIds"
|
||||
:placeholder="$t('test_track.review.input_reviewer')"
|
||||
filterable multiple
|
||||
collapse-tags
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reviewerOptions"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export default {
|
||||
commons: {
|
||||
examples: 'examples',
|
||||
help_documentation: 'Help documentation',
|
||||
delete_cancelled: 'Delete cancelled',
|
||||
workspace: 'Workspace',
|
||||
|
@ -537,11 +538,13 @@ export default {
|
|||
post_exec_script: "PostProcessor",
|
||||
code_template: "Code template",
|
||||
bean_shell_processor_tip: "Currently only BeanShell scripts are supported",
|
||||
code_template_get_variable: "Get variable",
|
||||
code_template_set_variable: "Set variable",
|
||||
code_template_get_response_header: "Get response header",
|
||||
code_template_get_response_code: "Get response code",
|
||||
code_template_get_response_result: "Get response result"
|
||||
code_template_get_variable: "Get Variable",
|
||||
code_template_set_variable: "Set Variable",
|
||||
code_template_get_global_variable: "Get Global Variable",
|
||||
code_template_set_global_variable: "Set Global variable",
|
||||
code_template_get_response_header: "Get Response Header",
|
||||
code_template_get_response_code: "Get Response Code",
|
||||
code_template_get_response_result: "Get Response Result"
|
||||
},
|
||||
dubbo: {
|
||||
protocol: "protocol",
|
||||
|
@ -758,6 +761,11 @@ export default {
|
|||
pass: "pass",
|
||||
un_pass: "UnPass",
|
||||
comment: "Comment",
|
||||
my_review: "My Review",
|
||||
my_create: "My Create",
|
||||
reviewed_by_me: "Review By Me",
|
||||
creator: "Creator",
|
||||
done: "Commented use cases"
|
||||
},
|
||||
comment: {
|
||||
no_comment: "No Comment",
|
||||
|
@ -794,6 +802,7 @@ export default {
|
|||
my_plan: "My plan",
|
||||
test_rate: "Test rate",
|
||||
tested_case: "Tested case",
|
||||
review_progress: "Review progress"
|
||||
},
|
||||
plan_view: {
|
||||
plan: "Plan",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export default {
|
||||
commons: {
|
||||
examples: '示例',
|
||||
help_documentation: '帮助文档',
|
||||
delete_cancelled: '已取消删除',
|
||||
workspace: '工作空间',
|
||||
|
@ -540,6 +541,8 @@ export default {
|
|||
bean_shell_processor_tip: "仅支持 BeanShell 脚本",
|
||||
code_template_get_variable: "获取变量",
|
||||
code_template_set_variable: "设置变量",
|
||||
code_template_get_global_variable: "获取全局变量",
|
||||
code_template_set_global_variable: "设置全局变量",
|
||||
code_template_get_response_header: "获取响应头",
|
||||
code_template_get_response_code: "获取响应码",
|
||||
code_template_get_response_result: "获取响应结果"
|
||||
|
@ -764,6 +767,11 @@ export default {
|
|||
pass: "通过",
|
||||
un_pass: "未通过",
|
||||
comment: "评论",
|
||||
my_review: "我的评审",
|
||||
my_create: "我创建的评审",
|
||||
reviewed_by_me: "待我评审",
|
||||
creator: "创建人",
|
||||
done: "已评用例"
|
||||
},
|
||||
comment: {
|
||||
no_comment: "暂无评论",
|
||||
|
@ -800,6 +808,7 @@ export default {
|
|||
my_plan: "我的计划",
|
||||
test_rate: "测试进度",
|
||||
tested_case: "已测用例",
|
||||
review_progress: "评审进度"
|
||||
},
|
||||
plan_view: {
|
||||
plan: "计划",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export default {
|
||||
commons: {
|
||||
examples: '示例',
|
||||
help_documentation: '幫助文檔',
|
||||
delete_cancelled: '已取消刪除',
|
||||
workspace: '工作空間',
|
||||
|
@ -540,6 +541,8 @@ export default {
|
|||
bean_shell_processor_tip: "僅支持 BeanShell 腳本",
|
||||
code_template_get_variable: "獲取變量",
|
||||
code_template_set_variable: "設置變量",
|
||||
code_template_get_global_variable: "獲取全局變量",
|
||||
code_template_set_global_variable: "設置全局變量",
|
||||
code_template_get_response_header: "獲取響應頭",
|
||||
code_template_get_response_code: "獲取響應碼",
|
||||
code_template_get_response_result: "獲取響應結果"
|
||||
|
@ -760,6 +763,11 @@ export default {
|
|||
pass: "通過",
|
||||
un_pass: "未通過",
|
||||
comment: "評論",
|
||||
my_review: "我的評審",
|
||||
my_create: "我創建的評審",
|
||||
reviewed_by_me: "待我評審",
|
||||
creator: "創建人",
|
||||
done: "已評用例"
|
||||
},
|
||||
comment: {
|
||||
no_comment: "暫無評論",
|
||||
|
@ -796,6 +804,7 @@ export default {
|
|||
my_plan: "我的計劃",
|
||||
test_rate: "測試進度",
|
||||
tested_case: "已測用例",
|
||||
review_progress: "評審進度"
|
||||
},
|
||||
plan_view: {
|
||||
plan: "計劃",
|
||||
|
|
Loading…
Reference in New Issue