refactor(接口测试): 优化截止时间字段
--bug=1047828 --user=宋昌昌 【接口测试】定义-分享-分享列表-截止时间-点击排序报错 https://www.tapd.cn/55049933/s/1595933
This commit is contained in:
parent
a91fc070ca
commit
bb5bb53322
|
@ -28,28 +28,26 @@ public class ApiDocShare implements Serializable {
|
|||
@NotNull(message = "{api_doc_share.is_private.not_blank}", groups = {Created.class})
|
||||
private Boolean isPrivate;
|
||||
|
||||
@Schema(title = "访问密码;私有时需要访问密码")
|
||||
@Schema(title = "访问密码; 私有时需要访问密码")
|
||||
private String password;
|
||||
|
||||
@Schema(title = "允许导出;0: 不允许、1: 允许")
|
||||
@Schema(title = "允许导出; 0: 不允许、1: 允许", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "{api_doc_share.allow_export.not_blank}", groups = {Created.class})
|
||||
private Boolean allowExport;
|
||||
|
||||
@Schema(title = "接口范围;全部接口(ALL)、模块(MODULE)、路径(PATH)、标签(TAG)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(title = "接口范围; 全部接口(ALL)、模块(MODULE)、路径(PATH)、标签(TAG)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_doc_share.api_range.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 10, message = "{api_doc_share.api_range.length_range}", groups = {Created.class, Updated.class})
|
||||
private String apiRange;
|
||||
|
||||
@Schema(title = "范围匹配符;包含(CONTAINS)、等于(EQUALS)")
|
||||
@Schema(title = "范围匹配符; 包含(CONTAINS)、等于(EQUALS)")
|
||||
private String rangeMatchSymbol;
|
||||
|
||||
@Schema(title = "范围匹配值;eg: 选中路径范围时, 该值作为路径匹配")
|
||||
@Schema(title = "范围匹配值; eg: 选中路径范围时, 该值作为路径匹配")
|
||||
private String rangeMatchVal;
|
||||
|
||||
@Schema(title = "失效时间值")
|
||||
private Integer invalidTime;
|
||||
|
||||
@Schema(title = "失效时间单位;小时(HOUR)、天(DAY)、月(MONTH)、年(YEAR)")
|
||||
private String invalidUnit;
|
||||
@Schema(title = "截止时间")
|
||||
private Long invalidTime;
|
||||
|
||||
@Schema(title = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_doc_share.project_id.not_blank}", groups = {Created.class})
|
||||
|
@ -73,8 +71,7 @@ public class ApiDocShare implements Serializable {
|
|||
apiRange("api_range", "apiRange", "VARCHAR", false),
|
||||
rangeMatchSymbol("range_match_symbol", "rangeMatchSymbol", "VARCHAR", false),
|
||||
rangeMatchVal("range_match_val", "rangeMatchVal", "VARCHAR", false),
|
||||
invalidTime("invalid_time", "invalidTime", "INTEGER", false),
|
||||
invalidUnit("invalid_unit", "invalidUnit", "VARCHAR", false),
|
||||
invalidTime("invalid_time", "invalidTime", "BIGINT", false),
|
||||
projectId("project_id", "projectId", "VARCHAR", false),
|
||||
createTime("create_time", "createTime", "BIGINT", false),
|
||||
createUser("create_user", "createUser", "VARCHAR", false);
|
||||
|
|
|
@ -654,126 +654,56 @@ public class ApiDocShareExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeEqualTo(Integer value) {
|
||||
public Criteria andInvalidTimeEqualTo(Long value) {
|
||||
addCriterion("invalid_time =", value, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeNotEqualTo(Integer value) {
|
||||
public Criteria andInvalidTimeNotEqualTo(Long value) {
|
||||
addCriterion("invalid_time <>", value, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeGreaterThan(Integer value) {
|
||||
public Criteria andInvalidTimeGreaterThan(Long value) {
|
||||
addCriterion("invalid_time >", value, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeGreaterThanOrEqualTo(Integer value) {
|
||||
public Criteria andInvalidTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("invalid_time >=", value, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeLessThan(Integer value) {
|
||||
public Criteria andInvalidTimeLessThan(Long value) {
|
||||
addCriterion("invalid_time <", value, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeLessThanOrEqualTo(Integer value) {
|
||||
public Criteria andInvalidTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("invalid_time <=", value, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeIn(List<Integer> values) {
|
||||
public Criteria andInvalidTimeIn(List<Long> values) {
|
||||
addCriterion("invalid_time in", values, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeNotIn(List<Integer> values) {
|
||||
public Criteria andInvalidTimeNotIn(List<Long> values) {
|
||||
addCriterion("invalid_time not in", values, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeBetween(Integer value1, Integer value2) {
|
||||
public Criteria andInvalidTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("invalid_time between", value1, value2, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidTimeNotBetween(Integer value1, Integer value2) {
|
||||
public Criteria andInvalidTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("invalid_time not between", value1, value2, "invalidTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitIsNull() {
|
||||
addCriterion("invalid_unit is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitIsNotNull() {
|
||||
addCriterion("invalid_unit is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitEqualTo(String value) {
|
||||
addCriterion("invalid_unit =", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitNotEqualTo(String value) {
|
||||
addCriterion("invalid_unit <>", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitGreaterThan(String value) {
|
||||
addCriterion("invalid_unit >", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("invalid_unit >=", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitLessThan(String value) {
|
||||
addCriterion("invalid_unit <", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitLessThanOrEqualTo(String value) {
|
||||
addCriterion("invalid_unit <=", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitLike(String value) {
|
||||
addCriterion("invalid_unit like", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitNotLike(String value) {
|
||||
addCriterion("invalid_unit not like", value, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitIn(List<String> values) {
|
||||
addCriterion("invalid_unit in", values, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitNotIn(List<String> values) {
|
||||
addCriterion("invalid_unit not in", values, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitBetween(String value1, String value2) {
|
||||
addCriterion("invalid_unit between", value1, value2, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andInvalidUnitNotBetween(String value1, String value2) {
|
||||
addCriterion("invalid_unit not between", value1, value2, "invalidUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNull() {
|
||||
addCriterion("project_id is null");
|
||||
return (Criteria) this;
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
<result column="api_range" jdbcType="VARCHAR" property="apiRange" />
|
||||
<result column="range_match_symbol" jdbcType="VARCHAR" property="rangeMatchSymbol" />
|
||||
<result column="range_match_val" jdbcType="VARCHAR" property="rangeMatchVal" />
|
||||
<result column="invalid_time" jdbcType="INTEGER" property="invalidTime" />
|
||||
<result column="invalid_unit" jdbcType="VARCHAR" property="invalidUnit" />
|
||||
<result column="invalid_time" jdbcType="BIGINT" property="invalidTime" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||
|
@ -76,7 +75,7 @@
|
|||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `name`, is_private, `password`, allow_export, api_range, range_match_symbol,
|
||||
range_match_val, invalid_time, invalid_unit, project_id, create_time, create_user
|
||||
range_match_val, invalid_time, project_id, create_time, create_user
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiDocShareExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -112,13 +111,13 @@
|
|||
insert into api_doc_share (id, `name`, is_private,
|
||||
`password`, allow_export, api_range,
|
||||
range_match_symbol, range_match_val, invalid_time,
|
||||
invalid_unit, project_id, create_time,
|
||||
create_user)
|
||||
project_id, create_time, create_user
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{isPrivate,jdbcType=BIT},
|
||||
#{password,jdbcType=VARCHAR}, #{allowExport,jdbcType=BIT}, #{apiRange,jdbcType=VARCHAR},
|
||||
#{rangeMatchSymbol,jdbcType=VARCHAR}, #{rangeMatchVal,jdbcType=VARCHAR}, #{invalidTime,jdbcType=INTEGER},
|
||||
#{invalidUnit,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||
#{createUser,jdbcType=VARCHAR})
|
||||
#{rangeMatchSymbol,jdbcType=VARCHAR}, #{rangeMatchVal,jdbcType=VARCHAR}, #{invalidTime,jdbcType=BIGINT},
|
||||
#{projectId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiDocShare">
|
||||
insert into api_doc_share
|
||||
|
@ -150,9 +149,6 @@
|
|||
<if test="invalidTime != null">
|
||||
invalid_time,
|
||||
</if>
|
||||
<if test="invalidUnit != null">
|
||||
invalid_unit,
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
|
@ -189,10 +185,7 @@
|
|||
#{rangeMatchVal,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="invalidTime != null">
|
||||
#{invalidTime,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="invalidUnit != null">
|
||||
#{invalidUnit,jdbcType=VARCHAR},
|
||||
#{invalidTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
|
@ -239,10 +232,7 @@
|
|||
range_match_val = #{record.rangeMatchVal,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.invalidTime != null">
|
||||
invalid_time = #{record.invalidTime,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.invalidUnit != null">
|
||||
invalid_unit = #{record.invalidUnit,jdbcType=VARCHAR},
|
||||
invalid_time = #{record.invalidTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
|
@ -268,8 +258,7 @@
|
|||
api_range = #{record.apiRange,jdbcType=VARCHAR},
|
||||
range_match_symbol = #{record.rangeMatchSymbol,jdbcType=VARCHAR},
|
||||
range_match_val = #{record.rangeMatchVal,jdbcType=VARCHAR},
|
||||
invalid_time = #{record.invalidTime,jdbcType=INTEGER},
|
||||
invalid_unit = #{record.invalidUnit,jdbcType=VARCHAR},
|
||||
invalid_time = #{record.invalidTime,jdbcType=BIGINT},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR}
|
||||
|
@ -302,10 +291,7 @@
|
|||
range_match_val = #{rangeMatchVal,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="invalidTime != null">
|
||||
invalid_time = #{invalidTime,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="invalidUnit != null">
|
||||
invalid_unit = #{invalidUnit,jdbcType=VARCHAR},
|
||||
invalid_time = #{invalidTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
|
@ -328,8 +314,7 @@
|
|||
api_range = #{apiRange,jdbcType=VARCHAR},
|
||||
range_match_symbol = #{rangeMatchSymbol,jdbcType=VARCHAR},
|
||||
range_match_val = #{rangeMatchVal,jdbcType=VARCHAR},
|
||||
invalid_time = #{invalidTime,jdbcType=INTEGER},
|
||||
invalid_unit = #{invalidUnit,jdbcType=VARCHAR},
|
||||
invalid_time = #{invalidTime,jdbcType=BIGINT},
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
create_user = #{createUser,jdbcType=VARCHAR}
|
||||
|
@ -338,15 +323,14 @@
|
|||
<insert id="batchInsert" parameterType="map">
|
||||
insert into api_doc_share
|
||||
(id, `name`, is_private, `password`, allow_export, api_range, range_match_symbol,
|
||||
range_match_val, invalid_time, invalid_unit, project_id, create_time, create_user
|
||||
)
|
||||
range_match_val, invalid_time, project_id, create_time, create_user)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.isPrivate,jdbcType=BIT},
|
||||
#{item.password,jdbcType=VARCHAR}, #{item.allowExport,jdbcType=BIT}, #{item.apiRange,jdbcType=VARCHAR},
|
||||
#{item.rangeMatchSymbol,jdbcType=VARCHAR}, #{item.rangeMatchVal,jdbcType=VARCHAR},
|
||||
#{item.invalidTime,jdbcType=INTEGER}, #{item.invalidUnit,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR},
|
||||
#{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR})
|
||||
#{item.invalidTime,jdbcType=BIGINT}, #{item.projectId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT},
|
||||
#{item.createUser,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
|
@ -384,10 +368,7 @@
|
|||
#{item.rangeMatchVal,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'invalid_time'.toString() == column.value">
|
||||
#{item.invalidTime,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="'invalid_unit'.toString() == column.value">
|
||||
#{item.invalidUnit,jdbcType=VARCHAR}
|
||||
#{item.invalidTime,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="'project_id'.toString() == column.value">
|
||||
#{item.projectId,jdbcType=VARCHAR}
|
||||
|
|
|
@ -89,8 +89,7 @@ CREATE TABLE api_doc_share (
|
|||
`api_range` VARCHAR(10) NOT NULL DEFAULT 'ALL' COMMENT '接口范围; 全部接口(ALL)、模块(MODULE)、路径(PATH)、标签(TAG)' ,
|
||||
`range_match_symbol` VARCHAR(10) COMMENT '范围匹配符; 包含(CONTAINS)、等于(EQUALS)' ,
|
||||
`range_match_val` VARCHAR(1000) COMMENT '范围匹配值; eg: 选中路径范围时, 该值作为路径匹配' ,
|
||||
`invalid_time` INT COMMENT '失效时间值' ,
|
||||
`invalid_unit` VARCHAR(10) COMMENT '失效时间单位; 小时(HOUR)、天(DAY)、月(MONTH)、年(YEAR)' ,
|
||||
`invalid_time` BIGINT COMMENT '截止时间' ,
|
||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' ,
|
||||
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
|
||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
|
||||
|
|
|
@ -18,9 +18,6 @@ public class ApiDocShareDTO extends ApiDocShare {
|
|||
@Schema(title = "分享接口数量")
|
||||
private Integer apiShareNum;
|
||||
|
||||
@Schema(title = "截止日期")
|
||||
private Long deadline;
|
||||
|
||||
@Schema(title = "创建人")
|
||||
private String createUserName;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ public class ApiDocShareEditRequest implements Serializable {
|
|||
@Schema(title = "范围匹配值;eg: 选中路径范围时, 该值作为路径匹配")
|
||||
private String rangeMatchVal;
|
||||
|
||||
@Schema(title = "失效时间值")
|
||||
private Integer invalidTime;
|
||||
@Schema(title = "截止时间值")
|
||||
private Long invalidTime;
|
||||
|
||||
@Schema(title = "失效时间单位;小时(HOUR)、天(DAY)、月(MONTH)、年(YEAR)")
|
||||
private String invalidUnit;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<select id="list" resultType="io.metersphere.api.dto.definition.ApiDocShareDTO">
|
||||
select id, name, is_private isPrivate, create_user createUser, create_time createTime, allow_export allowExport,
|
||||
api_range apiRange, range_match_symbol rangeMatchSymbol, range_match_val rangeMatchVal,
|
||||
invalid_time invalidTime, invalid_unit invalidUnit, project_id projectId, password
|
||||
invalid_time invalidTime, project_id projectId, password
|
||||
from api_doc_share
|
||||
<include refid="queryWhereCondition"/>
|
||||
</select>
|
||||
|
|
|
@ -125,11 +125,10 @@ public class ApiDocShareService {
|
|||
public ApiDocShareDetail detail(String id) {
|
||||
ApiDocShare docShare = checkExit(id);
|
||||
ApiDocShareDetail detail = ApiDocShareDetail.builder().allowExport(docShare.getAllowExport()).isPrivate(docShare.getIsPrivate()).build();
|
||||
if (docShare.getInvalidTime() == null || StringUtils.isBlank(docShare.getInvalidUnit())) {
|
||||
if (docShare.getInvalidTime() == null || docShare.getInvalidTime() == 0) {
|
||||
detail.setInvalid(false);
|
||||
} else {
|
||||
Long deadline = calculateDeadline(docShare.getInvalidTime(), docShare.getInvalidUnit(), docShare.getCreateTime());
|
||||
detail.setInvalid(deadline < System.currentTimeMillis());
|
||||
detail.setInvalid(docShare.getInvalidTime() < System.currentTimeMillis());
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
@ -180,8 +179,7 @@ public class ApiDocShareService {
|
|||
List<String> distinctUserIds = docShares.stream().map(ApiDocShareDTO::getCreateUser).distinct().toList();
|
||||
Map<String, String> userMap = userToolService.getUserMapByIds(distinctUserIds);
|
||||
docShares.forEach(docShare -> {
|
||||
docShare.setDeadline(calculateDeadline(docShare.getInvalidTime(), docShare.getInvalidUnit(), docShare.getCreateTime()));
|
||||
docShare.setInvalid(docShare.getDeadline() != null && docShare.getDeadline() < System.currentTimeMillis());
|
||||
docShare.setInvalid(docShare.getInvalidTime() != null && docShare.getInvalidTime() != 0 && docShare.getInvalidTime() < System.currentTimeMillis());
|
||||
docShare.setApiShareNum(countApiShare(docShare));
|
||||
docShare.setCreateUserName(userMap.get(docShare.getCreateUser()));
|
||||
});
|
||||
|
@ -276,26 +274,6 @@ public class ApiDocShareService {
|
|||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算截止时间
|
||||
* @param val 时间值
|
||||
* @param unit 时间单位
|
||||
* @param stareTime 起始时间
|
||||
* @return 截止时间
|
||||
*/
|
||||
private Long calculateDeadline(Integer val, String unit, Long stareTime) {
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
return switch (unit) {
|
||||
case "HOUR" -> stareTime + val * 60 * 60 * 1000L;
|
||||
case "DAY" -> stareTime + val * 24 * 60 * 60 * 1000L;
|
||||
case "MONTH" -> stareTime + val * 30 * 24 * 60 * 60 * 1000L;
|
||||
case "YEAR" -> stareTime + val * 365 * 24 * 60 * 60 * 1000L;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在
|
||||
* @param id 分享ID
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ApiDocShareControllerTests extends BaseTest {
|
|||
request.setPassword(StringUtils.EMPTY);
|
||||
request.setApiRange("MODULE");
|
||||
request.setRangeMatchVal("module-1");
|
||||
request.setInvalidTime(1);
|
||||
request.setInvalidTime(System.currentTimeMillis());
|
||||
request.setInvalidUnit("HOUR");
|
||||
this.requestPostWithOk(UPDATE, request);
|
||||
this.requestPostWithOk(CHECK, checkRequest);
|
||||
|
@ -99,7 +99,7 @@ public class ApiDocShareControllerTests extends BaseTest {
|
|||
request.setAllowExport(false);
|
||||
this.requestPost(ADD, request);
|
||||
request.setName("share-3");
|
||||
request.setInvalidTime(1);
|
||||
request.setInvalidTime(System.currentTimeMillis());
|
||||
request.setInvalidUnit("HOUR");
|
||||
request.setApiRange("MODULE");
|
||||
request.setRangeMatchVal("module-1");
|
||||
|
|
|
@ -453,8 +453,7 @@ export interface ShareDetail {
|
|||
password: string; // 访问密码
|
||||
allowExport: boolean; // 允许导出
|
||||
projectId: string;
|
||||
invalidTime?: string; // 失效时间值
|
||||
invalidUnit?: string; // 失效时间单位;小时(HOUR)、天(DAY)、月(MONTH)、年(YEAR)
|
||||
invalidTime?: number; // 失效时间值
|
||||
}
|
||||
// 分享列表
|
||||
export interface shareItem extends ShareDetail {
|
||||
|
|
|
@ -58,8 +58,8 @@
|
|||
/>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item field="effectiveTime" :label="t('apiTestManagement.effectiveTime')" asterisk-position="end">
|
||||
<MsTimeSelectorVue v-model="invalidTimeValue" allow-empty @change="handleTimeChange" />
|
||||
<a-form-item field="invalidTime" :label="t('apiTestManagement.invalidTime')" asterisk-position="end">
|
||||
<a-date-picker v-model:model-value="form.invalidTime" show-time value-format="timestamp" class="w-[400px]" />
|
||||
</a-form-item>
|
||||
<div class="mb-[16px] flex items-center">
|
||||
<a-switch v-model:model-value="form.isPrivate" class="mr-[8px]" size="small" @change="changePrivate" />
|
||||
|
@ -107,10 +107,10 @@
|
|||
import { ref } from 'vue';
|
||||
import { FormInstance, Message, SelectOptionData } from '@arco-design/web-vue';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { CONTAINS, EQUAL } from '@/components/pure/ms-advance-filter/index';
|
||||
import MsTagsInput from '@/components/pure/ms-tags-input/index.vue';
|
||||
import MsTimeSelectorVue from '@/components/pure/ms-time-selector/MsTimeSelector.vue';
|
||||
import MsTreeSelect from '@/components/pure/ms-tree-select/index.vue';
|
||||
|
||||
import { addShare, getEnvModules, updateShare } from '@/api/modules/api-test/management';
|
||||
|
@ -148,8 +148,7 @@
|
|||
apiRange: 'ALL',
|
||||
rangeMatchSymbol: OperatorEnum.CONTAINS,
|
||||
rangeMatchVal: '',
|
||||
invalidTime: '',
|
||||
invalidUnit: '',
|
||||
invalidTime: 0,
|
||||
isPrivate: false,
|
||||
password: '',
|
||||
allowExport: false,
|
||||
|
@ -158,7 +157,6 @@
|
|||
|
||||
const tags = ref<string[]>([]);
|
||||
const moduleIds = ref<string[]>([]);
|
||||
const invalidTimeValue = ref('');
|
||||
|
||||
const form = ref<ShareDetail>({ ...initForm });
|
||||
|
||||
|
@ -185,10 +183,6 @@
|
|||
return form.value.apiRange === 'PATH' ? [CONTAINS, EQUAL] : [CONTAINS];
|
||||
});
|
||||
|
||||
function handleTimeChange(value: string) {
|
||||
invalidTimeValue.value = value;
|
||||
}
|
||||
|
||||
const okText = computed(() => {
|
||||
return props?.record?.id ? t('common.update') : t('common.newCreate');
|
||||
});
|
||||
|
@ -214,46 +208,6 @@
|
|||
emit('close');
|
||||
}
|
||||
|
||||
const timeValueUnit = computed(() => {
|
||||
let time: string | undefined;
|
||||
let unit: string | undefined;
|
||||
|
||||
if (invalidTimeValue.value) {
|
||||
// 匹配时间部分和单位部分,时间部分为数字,单位部分为H, D, M, Y
|
||||
const match = invalidTimeValue.value.match(/^(\d+)([HDMY])$/);
|
||||
|
||||
if (match) {
|
||||
const [_, timeValue, symbol] = match;
|
||||
|
||||
time = timeValue; // 时间部分
|
||||
const unitSymbol = symbol; // 单位部分 (H, D, M, Y)
|
||||
|
||||
// 根据符号转换为全称
|
||||
switch (unitSymbol) {
|
||||
case 'H':
|
||||
unit = 'HOUR';
|
||||
break;
|
||||
case 'D':
|
||||
unit = 'DAY';
|
||||
break;
|
||||
case 'M':
|
||||
unit = 'MONTH';
|
||||
break;
|
||||
case 'Y':
|
||||
unit = 'YEAR';
|
||||
break;
|
||||
default:
|
||||
unit = undefined; // 如果有其他单位,默认不处理
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
time,
|
||||
unit,
|
||||
};
|
||||
});
|
||||
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
const originPassword = ref<string>('');
|
||||
function handleConfirm() {
|
||||
|
@ -263,8 +217,7 @@
|
|||
try {
|
||||
const params: ShareDetail = {
|
||||
...form.value,
|
||||
invalidTime: timeValueUnit.value.time,
|
||||
invalidUnit: timeValueUnit.value.unit,
|
||||
invalidTime: dayjs(form.value.invalidTime).valueOf(),
|
||||
projectId: appStore.currentProjectId,
|
||||
};
|
||||
if (form.value.apiRange === 'TAG') {
|
||||
|
@ -311,35 +264,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
function getOriginalUnit() {
|
||||
switch (props.record?.invalidUnit) {
|
||||
case 'HOUR':
|
||||
return 'H';
|
||||
case 'DAY':
|
||||
return 'D';
|
||||
case 'MONTH':
|
||||
return 'M';
|
||||
case 'YEAR':
|
||||
return 'Y';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function initDetail() {
|
||||
if (props.record?.id) {
|
||||
originPassword.value = form.value.password;
|
||||
form.value = {
|
||||
...props.record,
|
||||
};
|
||||
const { rangeMatchVal, invalidTime } = form.value;
|
||||
const { rangeMatchVal } = form.value;
|
||||
if (form.value.apiRange === 'TAG') {
|
||||
tags.value = rangeMatchVal.split(',');
|
||||
}
|
||||
if (form.value.apiRange === 'MODULE') {
|
||||
moduleIds.value = rangeMatchVal.split(',');
|
||||
}
|
||||
invalidTimeValue.value = `${invalidTime}${getOriginalUnit()}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
<div class="one-line-text">{{ record.createUserName || '-' }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template #invalidTime="{ record }">
|
||||
{{ record.invalidTime === 0 ? t('apiTestManagement.permanent') : record.invalidTime }}
|
||||
</template>
|
||||
<template #operation="{ record }">
|
||||
<div v-permission="['PROJECT_API_DEFINITION:READ+SHARE']" class="flex items-center">
|
||||
<a-tooltip :disabled="!!record.apiShareNum" :content="t('apiTestManagement.apiShareNumberTip')">
|
||||
|
@ -135,8 +138,8 @@
|
|||
},
|
||||
{
|
||||
title: 'apiTestManagement.deadline',
|
||||
dataIndex: 'deadline',
|
||||
slotName: 'deadline',
|
||||
dataIndex: 'invalidTime',
|
||||
slotName: 'invalidTime',
|
||||
showInTable: true,
|
||||
sortable: {
|
||||
sortDirections: ['ascend', 'descend'],
|
||||
|
@ -184,7 +187,7 @@
|
|||
},
|
||||
(item) => ({
|
||||
...item,
|
||||
deadline: item.deadline ? dayjs(item.deadline).format('YYYY-MM-DD HH:mm:ss') : t('apiTestManagement.permanent'),
|
||||
invalidTime: item.invalidTime ? dayjs(item.invalidTime).format('YYYY-MM-DD HH:mm:ss') : 0,
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -179,6 +179,7 @@ export default {
|
|||
'apiTestManagement.newCreatedList': 'New list',
|
||||
'apiTestManagement.interfaceRange': 'Interface range',
|
||||
'apiTestManagement.effectiveTime': 'Effective time',
|
||||
'apiTestManagement.invalidTime': 'Deadline',
|
||||
'apiTestManagement.passwordAccess': 'Password access',
|
||||
'apiTestManagement.sharePasswordPlaceholder': 'Please enter the share password',
|
||||
'apiTestManagement.apiShareNum': 'Api number',
|
||||
|
|
|
@ -172,6 +172,7 @@ export default {
|
|||
'apiTestManagement.newCreatedList': '新建列表',
|
||||
'apiTestManagement.interfaceRange': '接口范围',
|
||||
'apiTestManagement.effectiveTime': '有效时间',
|
||||
'apiTestManagement.invalidTime': '截止时间',
|
||||
'apiTestManagement.passwordAccess': '密码访问',
|
||||
'apiTestManagement.sharePasswordPlaceholder': '请输入分享密码',
|
||||
'apiTestManagement.apiShareNum': '接口数量',
|
||||
|
|
Loading…
Reference in New Issue