refactor(系统设置): 修改用户管理查询接口,去掉无用的表字段,优化文件转存接口
This commit is contained in:
parent
74f1958eff
commit
25b374a286
|
@ -15,12 +15,6 @@ public class UserExtend implements Serializable {
|
||||||
@Size(min = 1, max = 50, message = "{user_extend.id.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 50, message = "{user_extend.id.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "UI本地调试地址")
|
|
||||||
private String seleniumServer;
|
|
||||||
|
|
||||||
@Schema(description = "api本地调试地址")
|
|
||||||
private String apiServer;
|
|
||||||
|
|
||||||
@Schema(description = "头像")
|
@Schema(description = "头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
|
@ -31,8 +25,6 @@ public class UserExtend implements Serializable {
|
||||||
|
|
||||||
public enum Column {
|
public enum Column {
|
||||||
id("id", "id", "VARCHAR", false),
|
id("id", "id", "VARCHAR", false),
|
||||||
seleniumServer("selenium_server", "seleniumServer", "VARCHAR", false),
|
|
||||||
apiServer("api_server", "apiServer", "VARCHAR", false),
|
|
||||||
avatar("avatar", "avatar", "VARCHAR", false),
|
avatar("avatar", "avatar", "VARCHAR", false),
|
||||||
platformInfo("platform_info", "platformInfo", "LONGVARBINARY", false);
|
platformInfo("platform_info", "platformInfo", "LONGVARBINARY", false);
|
||||||
|
|
||||||
|
|
|
@ -174,146 +174,6 @@ public class UserExtendExample {
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andSeleniumServerIsNull() {
|
|
||||||
addCriterion("selenium_server is null");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerIsNotNull() {
|
|
||||||
addCriterion("selenium_server is not null");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerEqualTo(String value) {
|
|
||||||
addCriterion("selenium_server =", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerNotEqualTo(String value) {
|
|
||||||
addCriterion("selenium_server <>", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerGreaterThan(String value) {
|
|
||||||
addCriterion("selenium_server >", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerGreaterThanOrEqualTo(String value) {
|
|
||||||
addCriterion("selenium_server >=", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerLessThan(String value) {
|
|
||||||
addCriterion("selenium_server <", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerLessThanOrEqualTo(String value) {
|
|
||||||
addCriterion("selenium_server <=", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerLike(String value) {
|
|
||||||
addCriterion("selenium_server like", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerNotLike(String value) {
|
|
||||||
addCriterion("selenium_server not like", value, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerIn(List<String> values) {
|
|
||||||
addCriterion("selenium_server in", values, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerNotIn(List<String> values) {
|
|
||||||
addCriterion("selenium_server not in", values, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerBetween(String value1, String value2) {
|
|
||||||
addCriterion("selenium_server between", value1, value2, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andSeleniumServerNotBetween(String value1, String value2) {
|
|
||||||
addCriterion("selenium_server not between", value1, value2, "seleniumServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerIsNull() {
|
|
||||||
addCriterion("api_server is null");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerIsNotNull() {
|
|
||||||
addCriterion("api_server is not null");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerEqualTo(String value) {
|
|
||||||
addCriterion("api_server =", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerNotEqualTo(String value) {
|
|
||||||
addCriterion("api_server <>", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerGreaterThan(String value) {
|
|
||||||
addCriterion("api_server >", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerGreaterThanOrEqualTo(String value) {
|
|
||||||
addCriterion("api_server >=", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerLessThan(String value) {
|
|
||||||
addCriterion("api_server <", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerLessThanOrEqualTo(String value) {
|
|
||||||
addCriterion("api_server <=", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerLike(String value) {
|
|
||||||
addCriterion("api_server like", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerNotLike(String value) {
|
|
||||||
addCriterion("api_server not like", value, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerIn(List<String> values) {
|
|
||||||
addCriterion("api_server in", values, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerNotIn(List<String> values) {
|
|
||||||
addCriterion("api_server not in", values, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerBetween(String value1, String value2) {
|
|
||||||
addCriterion("api_server between", value1, value2, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andApiServerNotBetween(String value1, String value2) {
|
|
||||||
addCriterion("api_server not between", value1, value2, "apiServer");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andAvatarIsNull() {
|
public Criteria andAvatarIsNull() {
|
||||||
addCriterion("avatar is null");
|
addCriterion("avatar is null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
<mapper namespace="io.metersphere.system.mapper.UserExtendMapper">
|
<mapper namespace="io.metersphere.system.mapper.UserExtendMapper">
|
||||||
<resultMap id="BaseResultMap" type="io.metersphere.system.domain.UserExtend">
|
<resultMap id="BaseResultMap" type="io.metersphere.system.domain.UserExtend">
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
<result column="selenium_server" jdbcType="VARCHAR" property="seleniumServer" />
|
|
||||||
<result column="api_server" jdbcType="VARCHAR" property="apiServer" />
|
|
||||||
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
|
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.system.domain.UserExtend">
|
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.system.domain.UserExtend">
|
||||||
|
@ -69,7 +67,7 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, selenium_server, api_server, avatar
|
id, avatar
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
platform_info
|
platform_info
|
||||||
|
@ -123,10 +121,10 @@
|
||||||
</if>
|
</if>
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="io.metersphere.system.domain.UserExtend">
|
<insert id="insert" parameterType="io.metersphere.system.domain.UserExtend">
|
||||||
insert into user_extend (id, selenium_server, api_server,
|
insert into user_extend (id, avatar, platform_info
|
||||||
avatar, platform_info)
|
)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{seleniumServer,jdbcType=VARCHAR}, #{apiServer,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, #{platformInfo,jdbcType=LONGVARBINARY}
|
||||||
#{avatar,jdbcType=VARCHAR}, #{platformInfo,jdbcType=LONGVARBINARY})
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.system.domain.UserExtend">
|
<insert id="insertSelective" parameterType="io.metersphere.system.domain.UserExtend">
|
||||||
insert into user_extend
|
insert into user_extend
|
||||||
|
@ -134,12 +132,6 @@
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
id,
|
id,
|
||||||
</if>
|
</if>
|
||||||
<if test="seleniumServer != null">
|
|
||||||
selenium_server,
|
|
||||||
</if>
|
|
||||||
<if test="apiServer != null">
|
|
||||||
api_server,
|
|
||||||
</if>
|
|
||||||
<if test="avatar != null">
|
<if test="avatar != null">
|
||||||
avatar,
|
avatar,
|
||||||
</if>
|
</if>
|
||||||
|
@ -151,12 +143,6 @@
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
#{id,jdbcType=VARCHAR},
|
#{id,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="seleniumServer != null">
|
|
||||||
#{seleniumServer,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="apiServer != null">
|
|
||||||
#{apiServer,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="avatar != null">
|
<if test="avatar != null">
|
||||||
#{avatar,jdbcType=VARCHAR},
|
#{avatar,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -177,12 +163,6 @@
|
||||||
<if test="record.id != null">
|
<if test="record.id != null">
|
||||||
id = #{record.id,jdbcType=VARCHAR},
|
id = #{record.id,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.seleniumServer != null">
|
|
||||||
selenium_server = #{record.seleniumServer,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="record.apiServer != null">
|
|
||||||
api_server = #{record.apiServer,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="record.avatar != null">
|
<if test="record.avatar != null">
|
||||||
avatar = #{record.avatar,jdbcType=VARCHAR},
|
avatar = #{record.avatar,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -197,8 +177,6 @@
|
||||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||||
update user_extend
|
update user_extend
|
||||||
set id = #{record.id,jdbcType=VARCHAR},
|
set id = #{record.id,jdbcType=VARCHAR},
|
||||||
selenium_server = #{record.seleniumServer,jdbcType=VARCHAR},
|
|
||||||
api_server = #{record.apiServer,jdbcType=VARCHAR},
|
|
||||||
avatar = #{record.avatar,jdbcType=VARCHAR},
|
avatar = #{record.avatar,jdbcType=VARCHAR},
|
||||||
platform_info = #{record.platformInfo,jdbcType=LONGVARBINARY}
|
platform_info = #{record.platformInfo,jdbcType=LONGVARBINARY}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
|
@ -208,8 +186,6 @@
|
||||||
<update id="updateByExample" parameterType="map">
|
<update id="updateByExample" parameterType="map">
|
||||||
update user_extend
|
update user_extend
|
||||||
set id = #{record.id,jdbcType=VARCHAR},
|
set id = #{record.id,jdbcType=VARCHAR},
|
||||||
selenium_server = #{record.seleniumServer,jdbcType=VARCHAR},
|
|
||||||
api_server = #{record.apiServer,jdbcType=VARCHAR},
|
|
||||||
avatar = #{record.avatar,jdbcType=VARCHAR}
|
avatar = #{record.avatar,jdbcType=VARCHAR}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
@ -218,12 +194,6 @@
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.system.domain.UserExtend">
|
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.system.domain.UserExtend">
|
||||||
update user_extend
|
update user_extend
|
||||||
<set>
|
<set>
|
||||||
<if test="seleniumServer != null">
|
|
||||||
selenium_server = #{seleniumServer,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="apiServer != null">
|
|
||||||
api_server = #{apiServer,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="avatar != null">
|
<if test="avatar != null">
|
||||||
avatar = #{avatar,jdbcType=VARCHAR},
|
avatar = #{avatar,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -235,26 +205,22 @@
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.system.domain.UserExtend">
|
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.system.domain.UserExtend">
|
||||||
update user_extend
|
update user_extend
|
||||||
set selenium_server = #{seleniumServer,jdbcType=VARCHAR},
|
set avatar = #{avatar,jdbcType=VARCHAR},
|
||||||
api_server = #{apiServer,jdbcType=VARCHAR},
|
|
||||||
avatar = #{avatar,jdbcType=VARCHAR},
|
|
||||||
platform_info = #{platformInfo,jdbcType=LONGVARBINARY}
|
platform_info = #{platformInfo,jdbcType=LONGVARBINARY}
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.system.domain.UserExtend">
|
<update id="updateByPrimaryKey" parameterType="io.metersphere.system.domain.UserExtend">
|
||||||
update user_extend
|
update user_extend
|
||||||
set selenium_server = #{seleniumServer,jdbcType=VARCHAR},
|
set avatar = #{avatar,jdbcType=VARCHAR}
|
||||||
api_server = #{apiServer,jdbcType=VARCHAR},
|
|
||||||
avatar = #{avatar,jdbcType=VARCHAR}
|
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
<insert id="batchInsert" parameterType="map">
|
<insert id="batchInsert" parameterType="map">
|
||||||
insert into user_extend
|
insert into user_extend
|
||||||
(id, selenium_server, api_server, avatar, platform_info)
|
(id, avatar, platform_info)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id,jdbcType=VARCHAR}, #{item.seleniumServer,jdbcType=VARCHAR}, #{item.apiServer,jdbcType=VARCHAR},
|
(#{item.id,jdbcType=VARCHAR}, #{item.avatar,jdbcType=VARCHAR}, #{item.platformInfo,jdbcType=LONGVARBINARY}
|
||||||
#{item.avatar,jdbcType=VARCHAR}, #{item.platformInfo,jdbcType=LONGVARBINARY})
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="batchInsertSelective" parameterType="map">
|
<insert id="batchInsertSelective" parameterType="map">
|
||||||
|
@ -270,12 +236,6 @@
|
||||||
<if test="'id'.toString() == column.value">
|
<if test="'id'.toString() == column.value">
|
||||||
#{item.id,jdbcType=VARCHAR}
|
#{item.id,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="'selenium_server'.toString() == column.value">
|
|
||||||
#{item.seleniumServer,jdbcType=VARCHAR}
|
|
||||||
</if>
|
|
||||||
<if test="'api_server'.toString() == column.value">
|
|
||||||
#{item.apiServer,jdbcType=VARCHAR}
|
|
||||||
</if>
|
|
||||||
<if test="'avatar'.toString() == column.value">
|
<if test="'avatar'.toString() == column.value">
|
||||||
#{item.avatar,jdbcType=VARCHAR}
|
#{item.avatar,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -321,11 +321,9 @@ CREATE INDEX idx_update_user ON organization(`update_user`);
|
||||||
DROP TABLE IF EXISTS user_extend;
|
DROP TABLE IF EXISTS user_extend;
|
||||||
CREATE TABLE user_extend
|
CREATE TABLE user_extend
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '用户ID',
|
`id` VARCHAR(50) NOT NULL COMMENT '用户ID',
|
||||||
`platform_info` BLOB COMMENT '其他平台对接信息',
|
`platform_info` BLOB COMMENT '其他平台对接信息',
|
||||||
`selenium_server` VARCHAR(255) COMMENT 'UI本地调试地址',
|
`avatar` VARCHAR(255) COMMENT '头像',
|
||||||
`api_server` VARCHAR(255) COMMENT 'api本地调试地址',
|
|
||||||
`avatar` VARCHAR(255) COMMENT '头像',
|
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) ENGINE = InnoDB
|
) ENGINE = InnoDB
|
||||||
DEFAULT CHARSET = utf8mb4
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.functional.request.FunctionalCaseAssociationFileRequest;
|
||||||
import io.metersphere.functional.request.FunctionalCaseDeleteFileRequest;
|
import io.metersphere.functional.request.FunctionalCaseDeleteFileRequest;
|
||||||
import io.metersphere.functional.request.FunctionalCaseFileRequest;
|
import io.metersphere.functional.request.FunctionalCaseFileRequest;
|
||||||
import io.metersphere.functional.service.FunctionalCaseAttachmentService;
|
import io.metersphere.functional.service.FunctionalCaseAttachmentService;
|
||||||
|
import io.metersphere.project.dto.filemanagement.FileAssociationDTO;
|
||||||
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
||||||
import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest;
|
import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest;
|
||||||
import io.metersphere.project.dto.filemanagement.response.FileInformationResponse;
|
import io.metersphere.project.dto.filemanagement.response.FileInformationResponse;
|
||||||
|
@ -118,7 +119,8 @@ public class FunctionalCaseAttachmentController {
|
||||||
|
|
||||||
String fileId = null;
|
String fileId = null;
|
||||||
try {
|
try {
|
||||||
fileId = fileAssociationService.transferAndAssociation(attachment.getFileName(), fileByte, attachment.getCaseId(), FileAssociationSourceUtil.SOURCE_TYPE_FUNCTIONAL_CASE, fileLogRecord);
|
FileAssociationDTO fileAssociationDTO = new FileAssociationDTO(attachment.getFileName(), fileByte, attachment.getCaseId(), FileAssociationSourceUtil.SOURCE_TYPE_FUNCTIONAL_CASE, fileLogRecord);
|
||||||
|
fileId = fileAssociationService.transferAndAssociation(fileAssociationDTO);
|
||||||
functionalCaseAttachmentService.deleteCaseAttachment(Arrays.asList(request.getFileId()), request.getCaseId(), request.getProjectId());
|
functionalCaseAttachmentService.deleteCaseAttachment(Arrays.asList(request.getFileId()), request.getCaseId(), request.getProjectId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new MSException(Translator.get("file.transfer.error"));
|
throw new MSException(Translator.get("file.transfer.error"));
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package io.metersphere.project.dto.filemanagement;
|
||||||
|
|
||||||
|
import io.metersphere.sdk.constants.ModuleConstants;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件转存
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FileAssociationDTO {
|
||||||
|
@NotBlank
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String sourceId;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String sourceType;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String moduleId = ModuleConstants.NODE_TYPE_DEFAULT;
|
||||||
|
|
||||||
|
private byte[] fileBytes;
|
||||||
|
|
||||||
|
private FileLogRecord fileLogRecord;
|
||||||
|
|
||||||
|
public FileAssociationDTO(String fileName, byte[] fileBytes, String sourceId, String sourceType, FileLogRecord fileLogRecord) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.sourceId = sourceId;
|
||||||
|
this.sourceType = sourceType;
|
||||||
|
this.fileBytes = fileBytes;
|
||||||
|
this.fileLogRecord = fileLogRecord;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package io.metersphere.project.service;
|
||||||
import io.metersphere.project.domain.FileAssociation;
|
import io.metersphere.project.domain.FileAssociation;
|
||||||
import io.metersphere.project.domain.FileAssociationExample;
|
import io.metersphere.project.domain.FileAssociationExample;
|
||||||
import io.metersphere.project.domain.FileMetadata;
|
import io.metersphere.project.domain.FileMetadata;
|
||||||
|
import io.metersphere.project.dto.filemanagement.FileAssociationDTO;
|
||||||
import io.metersphere.project.dto.filemanagement.FileAssociationSource;
|
import io.metersphere.project.dto.filemanagement.FileAssociationSource;
|
||||||
import io.metersphere.project.dto.filemanagement.FileInfo;
|
import io.metersphere.project.dto.filemanagement.FileInfo;
|
||||||
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
||||||
|
@ -307,22 +308,22 @@ public class FileAssociationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转存并关联文件
|
* 转存并关联文件
|
||||||
* @param fileName 文件名称(含后缀)
|
|
||||||
* @param fileBytes 文件字节流
|
|
||||||
* @param sourceId 要关联的资源ID
|
|
||||||
* @param sourceType 要关联的资源名称
|
|
||||||
* @param fileLogRecord 日志记录相关
|
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String transferAndAssociation(String fileName,byte[] fileBytes,String sourceId,String sourceType, @Validated FileLogRecord fileLogRecord) throws Exception {
|
public String transferAndAssociation(@Validated FileAssociationDTO fileAssociationDTO) throws Exception {
|
||||||
FileAssociationSource source = extFileAssociationMapper.selectNameBySourceTableAndId(FileAssociationSourceUtil.getQuerySql(sourceType),sourceId);
|
FileAssociationSource source = extFileAssociationMapper.selectNameBySourceTableAndId(FileAssociationSourceUtil.getQuerySql(fileAssociationDTO.getSourceType()), fileAssociationDTO.getSourceId());
|
||||||
this.validateSourceName(source);
|
this.validateSourceName(source);
|
||||||
String fileId = fileMetadataService.transferFile(fileName, fileLogRecord.getProjectId(), fileLogRecord.getOperator(),fileBytes);
|
String fileId = fileMetadataService.transferFile(
|
||||||
|
fileAssociationDTO.getFileName(),
|
||||||
|
fileAssociationDTO.getFileLogRecord().getProjectId(),
|
||||||
|
fileAssociationDTO.getModuleId(),
|
||||||
|
fileAssociationDTO.getFileLogRecord().getOperator(),
|
||||||
|
fileAssociationDTO.getFileBytes());
|
||||||
List<String> accociationList = new ArrayList<>();
|
List<String> accociationList = new ArrayList<>();
|
||||||
accociationList.add(fileId);
|
accociationList.add(fileId);
|
||||||
this.association(sourceId, sourceType, accociationList, fileLogRecord);
|
this.association(fileAssociationDTO.getSourceId(), fileAssociationDTO.getSourceType(), accociationList, fileAssociationDTO.getFileLogRecord());
|
||||||
fileAssociationLogService.saveTransferAssociationLog(sourceId,fileName,source.getSourceName(),fileLogRecord);
|
fileAssociationLogService.saveTransferAssociationLog(fileAssociationDTO.getSourceId(), fileAssociationDTO.getFileName(), source.getSourceName(), fileAssociationDTO.getFileLogRecord());
|
||||||
return fileId;
|
return fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +333,6 @@ public class FileAssociationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件列表接口
|
* 获取文件列表接口
|
||||||
*
|
*
|
||||||
|
|
|
@ -214,12 +214,11 @@ public class FileMetadataService {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String transferFile(String fileName, String projectId, String operator, byte[] fileBytes) throws Exception {
|
public String transferFile(String fileName, String projectId, String moduleId, String operator, byte[] fileBytes) throws Exception {
|
||||||
if (StringUtils.isBlank(fileName)) {
|
if (StringUtils.isBlank(fileName)) {
|
||||||
throw new MSException(Translator.get("file.name.cannot.be.empty"));
|
throw new MSException(Translator.get("file.name.cannot.be.empty"));
|
||||||
}
|
}
|
||||||
fileName = this.genTransferFileName(StringUtils.trim(fileName), projectId);
|
fileName = this.genTransferFileName(StringUtils.trim(fileName), projectId);
|
||||||
String moduleId = ModuleConstants.NODE_TYPE_DEFAULT;
|
|
||||||
|
|
||||||
FileMetadata fileMetadata = this.genFileMetadata(fileName, StorageType.MINIO.name(), fileBytes.length, false, projectId, moduleId, operator);
|
FileMetadata fileMetadata = this.genFileMetadata(fileName, StorageType.MINIO.name(), fileBytes.length, false, projectId, moduleId, operator);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.project.controller.filemanagement;
|
package io.metersphere.project.controller.filemanagement;
|
||||||
|
|
||||||
import io.metersphere.project.domain.*;
|
import io.metersphere.project.domain.*;
|
||||||
|
import io.metersphere.project.dto.filemanagement.FileAssociationDTO;
|
||||||
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
||||||
import io.metersphere.project.dto.filemanagement.request.*;
|
import io.metersphere.project.dto.filemanagement.request.*;
|
||||||
import io.metersphere.project.dto.filemanagement.response.FileAssociationResponse;
|
import io.metersphere.project.dto.filemanagement.response.FileAssociationResponse;
|
||||||
|
@ -15,7 +16,10 @@ import io.metersphere.project.service.FileService;
|
||||||
import io.metersphere.project.utils.FileManagementBaseUtils;
|
import io.metersphere.project.utils.FileManagementBaseUtils;
|
||||||
import io.metersphere.project.utils.FileManagementRequestUtils;
|
import io.metersphere.project.utils.FileManagementRequestUtils;
|
||||||
import io.metersphere.project.utils.FileMetadataUtils;
|
import io.metersphere.project.utils.FileMetadataUtils;
|
||||||
import io.metersphere.sdk.constants.*;
|
import io.metersphere.sdk.constants.ModuleConstants;
|
||||||
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
|
import io.metersphere.sdk.constants.StorageType;
|
||||||
import io.metersphere.sdk.util.FileAssociationSourceUtil;
|
import io.metersphere.sdk.util.FileAssociationSourceUtil;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.TempFileUtils;
|
import io.metersphere.sdk.util.TempFileUtils;
|
||||||
|
@ -1591,31 +1595,31 @@ public class FileManagementControllerTests extends BaseTest {
|
||||||
.build();
|
.build();
|
||||||
//关联正常文件
|
//关联正常文件
|
||||||
String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/file_upload.JPG")).getPath();
|
String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/file_upload.JPG")).getPath();
|
||||||
String fileID = fileAssociationService.transferAndAssociation("testTransferFile.jpg", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord);
|
String fileID = fileAssociationService.transferAndAssociation(new FileAssociationDTO("testTransferFile.jpg", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord));
|
||||||
FileMetadataExample example = new FileMetadataExample();
|
FileMetadataExample example = new FileMetadataExample();
|
||||||
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransferFile").andTypeEqualTo("JPG");
|
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransferFile").andTypeEqualTo("JPG");
|
||||||
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
||||||
//重复转存检查文件名是否加1
|
//重复转存检查文件名是否加1
|
||||||
fileID = fileAssociationService.transferAndAssociation("testTransferFile.jpg", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord);
|
fileID = fileAssociationService.transferAndAssociation(new FileAssociationDTO("testTransferFile.jpg", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord));
|
||||||
example.clear();
|
example.clear();
|
||||||
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransferFile(1)").andTypeEqualTo("JPG");
|
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransferFile(1)").andTypeEqualTo("JPG");
|
||||||
|
|
||||||
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
||||||
//重复转存检查文件名是否加1
|
//重复转存检查文件名是否加1
|
||||||
fileID = fileAssociationService.transferAndAssociation("testTransferFile.jpg", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord);
|
fileID = fileAssociationService.transferAndAssociation(new FileAssociationDTO("testTransferFile.jpg", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord));
|
||||||
example.clear();
|
example.clear();
|
||||||
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransferFile(2)").andTypeEqualTo("JPG");
|
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransferFile(2)").andTypeEqualTo("JPG");
|
||||||
|
|
||||||
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
||||||
//测试没有后缀的文件名
|
//测试没有后缀的文件名
|
||||||
fileID = fileAssociationService.transferAndAssociation("testTransfer", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord);
|
fileID = fileAssociationService.transferAndAssociation(new FileAssociationDTO("testTransfer", TempFileUtils.getFile(filePath), "sty-file-association-bug-id-4", FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord));
|
||||||
example.clear();
|
example.clear();
|
||||||
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransfer");
|
example.createCriteria().andIdEqualTo(fileID).andNameEqualTo("testTransfer");
|
||||||
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
Assertions.assertEquals(fileMetadataMapper.countByExample(example), 1);
|
||||||
//资源不存在
|
//资源不存在
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
try {
|
try {
|
||||||
fileAssociationService.transferAndAssociation("testTransferFile.jpg", TempFileUtils.getFile(filePath), IDGenerator.nextStr(), FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord);
|
fileAssociationService.transferAndAssociation(new FileAssociationDTO("testTransferFile.jpg", TempFileUtils.getFile(filePath), IDGenerator.nextStr(), FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
@ -1623,7 +1627,7 @@ public class FileManagementControllerTests extends BaseTest {
|
||||||
//文件名称不合法
|
//文件名称不合法
|
||||||
error = false;
|
error = false;
|
||||||
try {
|
try {
|
||||||
fileAssociationService.transferAndAssociation("testTransfer/File.jpg", TempFileUtils.getFile(filePath), IDGenerator.nextStr(), FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord);
|
fileAssociationService.transferAndAssociation(new FileAssociationDTO("testTransfer/File.jpg", TempFileUtils.getFile(filePath), IDGenerator.nextStr(), FileAssociationSourceUtil.SOURCE_TYPE_BUG, fileLogRecord));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.system.dto.request.user.PersonalUpdatePasswordRequest;
|
import io.metersphere.system.dto.request.user.PersonalUpdatePasswordRequest;
|
||||||
import io.metersphere.system.dto.request.user.PersonalUpdateRequest;
|
import io.metersphere.system.dto.request.user.PersonalUpdateRequest;
|
||||||
import io.metersphere.system.dto.user.UserDTO;
|
import io.metersphere.system.dto.user.PersonalDTO;
|
||||||
import io.metersphere.system.log.annotation.Log;
|
import io.metersphere.system.log.annotation.Log;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.service.UserLogService;
|
import io.metersphere.system.service.UserLogService;
|
||||||
|
@ -29,9 +29,9 @@ public class PersonalCenterController {
|
||||||
@GetMapping("/get/{id}")
|
@GetMapping("/get/{id}")
|
||||||
@Operation(summary = "个人中心-获取信息")
|
@Operation(summary = "个人中心-获取信息")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_PERSONAL_READ)
|
@RequiresPermissions(PermissionConstants.SYSTEM_PERSONAL_READ)
|
||||||
public UserDTO getInformation(@PathVariable String id) {
|
public PersonalDTO getInformation(@PathVariable String id) {
|
||||||
this.checkPermission(id);
|
this.checkPermission(id);
|
||||||
return userService.getUserDTOByKeyword(id);
|
return userService.getPersonalById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update-info")
|
@PostMapping("/update-info")
|
||||||
|
|
|
@ -13,6 +13,9 @@ public class PersonalUpdateRequest {
|
||||||
@NotBlank(message = "{user.id.not_blank}")
|
@NotBlank(message = "{user.id.not_blank}")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{user.id.not_blank}")
|
@NotBlank(message = "{user.id.not_blank}")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package io.metersphere.system.dto.user;
|
||||||
|
|
||||||
|
import io.metersphere.project.domain.Project;
|
||||||
|
import io.metersphere.system.domain.Organization;
|
||||||
|
import io.metersphere.system.domain.User;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PersonalDTO extends User {
|
||||||
|
|
||||||
|
@Schema(description = "头像")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
@Schema(description = "用户所属组织和项目")
|
||||||
|
private Map<Organization, List<Project>> organizationProjectMap = new LinkedHashMap<>();
|
||||||
|
}
|
|
@ -21,12 +21,6 @@ public class UserDTO extends User {
|
||||||
@Schema(description = "其他平台对接信息", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
@Schema(description = "其他平台对接信息", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||||
private byte[] platformInfo;
|
private byte[] platformInfo;
|
||||||
|
|
||||||
@Schema(description = "UI本地调试地址")
|
|
||||||
private String seleniumServer;
|
|
||||||
|
|
||||||
@Schema(description = "API本地调试地址")
|
|
||||||
private String apiServer;
|
|
||||||
|
|
||||||
@Schema(description = "头像")
|
@Schema(description = "头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,13 @@
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
user_role_relation
|
user_role_relation
|
||||||
WHERE
|
WHERE
|
||||||
<foreach collection="userIds" item="userId" open="(" close=")" separator="OR">
|
user_id IN
|
||||||
user_id = #{userId}
|
<foreach collection="userIds" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
<!-- <foreach collection="userIds" item="userId" open="(" close=")" separator="OR">-->
|
||||||
|
<!-- user_id = #{userId}-->
|
||||||
|
<!-- </foreach>-->
|
||||||
AND role_id IN (
|
AND role_id IN (
|
||||||
SELECT id FROM user_role WHERE scope_id = 'global'
|
SELECT id FROM user_role WHERE scope_id = 'global'
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
package io.metersphere.system.service;
|
package io.metersphere.system.service;
|
||||||
|
|
||||||
|
import io.metersphere.project.domain.Project;
|
||||||
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||||
import io.metersphere.sdk.constants.UserRoleEnum;
|
import io.metersphere.sdk.constants.UserRoleEnum;
|
||||||
import io.metersphere.sdk.constants.UserRoleScope;
|
import io.metersphere.sdk.constants.UserRoleScope;
|
||||||
import io.metersphere.system.log.dto.LogDTO;
|
|
||||||
import io.metersphere.system.log.constants.OperationLogModule;
|
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
|
||||||
import io.metersphere.system.log.service.OperationLogService;
|
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.domain.*;
|
import io.metersphere.system.domain.*;
|
||||||
|
import io.metersphere.system.dto.response.UserTableResponse;
|
||||||
|
import io.metersphere.system.log.constants.OperationLogModule;
|
||||||
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.mapper.ExtUserRoleRelationMapper;
|
import io.metersphere.system.mapper.ExtUserRoleRelationMapper;
|
||||||
import io.metersphere.system.mapper.OrganizationMapper;
|
import io.metersphere.system.mapper.OrganizationMapper;
|
||||||
import io.metersphere.system.mapper.UserRoleMapper;
|
import io.metersphere.system.mapper.UserRoleMapper;
|
||||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||||
import io.metersphere.system.dto.response.UserTableResponse;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
@ -27,10 +29,7 @@ import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -48,6 +47,8 @@ public class UserRoleRelationService {
|
||||||
private OrganizationMapper organizationMapper;
|
private OrganizationMapper organizationMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private OperationLogService operationLogService;
|
private OperationLogService operationLogService;
|
||||||
|
@Resource
|
||||||
|
private ProjectMapper projectMapper;
|
||||||
|
|
||||||
//批量添加用户记录日志
|
//批量添加用户记录日志
|
||||||
public List<LogDTO> getBatchLogs(@Valid @NotEmpty List<String> userRoleId,
|
public List<LogDTO> getBatchLogs(@Valid @NotEmpty List<String> userRoleId,
|
||||||
|
@ -129,6 +130,29 @@ public class UserRoleRelationService {
|
||||||
userRoleRelationMapper.batchInsert(userRoleRelationSaveList);
|
userRoleRelationMapper.batchInsert(userRoleRelationSaveList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Organization, List<Project>> selectOrganizationProjectByUserId(String userId) {
|
||||||
|
Map<Organization, List<Project>> returnMap = new LinkedHashMap<>();
|
||||||
|
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||||
|
example.createCriteria().andUserIdEqualTo(userId);
|
||||||
|
List<UserRoleRelation> userRoleRelationList = userRoleRelationMapper.selectByExample(example);
|
||||||
|
for (UserRoleRelation userRoleRelation : userRoleRelationList) {
|
||||||
|
Organization organization = organizationMapper.selectByPrimaryKey(userRoleRelation.getOrganizationId());
|
||||||
|
if (organization != null) {
|
||||||
|
Project project = projectMapper.selectByPrimaryKey(userRoleRelation.getSourceId());
|
||||||
|
if (project != null) {
|
||||||
|
if (returnMap.containsKey(organization)) {
|
||||||
|
if (!returnMap.get(organization).contains(project)) {
|
||||||
|
returnMap.get(organization).add(project);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
returnMap.put(organization, new ArrayList<>(Arrays.asList(project)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, UserTableResponse> selectGlobalUserRoleAndOrganization(@Valid @NotEmpty List<String> userIdList) {
|
public Map<String, UserTableResponse> selectGlobalUserRoleAndOrganization(@Valid @NotEmpty List<String> userIdList) {
|
||||||
List<UserRoleRelation> userRoleRelationList = extUserRoleRelationMapper.selectGlobalRoleByUserIdList(userIdList);
|
List<UserRoleRelation> userRoleRelationList = extUserRoleRelationMapper.selectGlobalRoleByUserIdList(userIdList);
|
||||||
List<String> userRoleIdList = userRoleRelationList.stream().map(UserRoleRelation::getRoleId).distinct().collect(Collectors.toList());
|
List<String> userRoleIdList = userRoleRelationList.stream().map(UserRoleRelation::getRoleId).distinct().collect(Collectors.toList());
|
||||||
|
|
|
@ -24,13 +24,11 @@ import io.metersphere.system.dto.sdk.ExcelParseDTO;
|
||||||
import io.metersphere.system.dto.sdk.SessionUser;
|
import io.metersphere.system.dto.sdk.SessionUser;
|
||||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||||
import io.metersphere.system.dto.table.TableBatchProcessResponse;
|
import io.metersphere.system.dto.table.TableBatchProcessResponse;
|
||||||
|
import io.metersphere.system.dto.user.PersonalDTO;
|
||||||
import io.metersphere.system.dto.user.UserDTO;
|
import io.metersphere.system.dto.user.UserDTO;
|
||||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||||
import io.metersphere.system.log.service.OperationLogService;
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.mapper.BaseUserMapper;
|
import io.metersphere.system.mapper.*;
|
||||||
import io.metersphere.system.mapper.ExtUserMapper;
|
|
||||||
import io.metersphere.system.mapper.SystemParameterMapper;
|
|
||||||
import io.metersphere.system.mapper.UserMapper;
|
|
||||||
import io.metersphere.system.notice.sender.impl.MailNoticeSender;
|
import io.metersphere.system.notice.sender.impl.MailNoticeSender;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import io.metersphere.system.utils.UserImportEventListener;
|
import io.metersphere.system.utils.UserImportEventListener;
|
||||||
|
@ -67,6 +65,8 @@ public class UserService {
|
||||||
@Resource
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
private UserExtendMapper userExtendMapper;
|
||||||
|
@Resource
|
||||||
private ExtUserMapper extUserMapper;
|
private ExtUserMapper extUserMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserInviteService userInviteService;
|
private UserInviteService userInviteService;
|
||||||
|
@ -140,7 +140,6 @@ public class UserService {
|
||||||
return userCreateDTO;
|
return userCreateDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UserDTO getUserDTOByKeyword(String email) {
|
public UserDTO getUserDTOByKeyword(String email) {
|
||||||
UserDTO userDTO = baseUserMapper.selectDTOByKeyword(email);
|
UserDTO userDTO = baseUserMapper.selectDTOByKeyword(email);
|
||||||
if (userDTO != null) {
|
if (userDTO != null) {
|
||||||
|
@ -154,6 +153,16 @@ public class UserService {
|
||||||
return userDTO;
|
return userDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PersonalDTO getPersonalById(String id) {
|
||||||
|
UserDTO userDTO = baseUserMapper.selectDTOByKeyword(id);
|
||||||
|
PersonalDTO personalDTO = new PersonalDTO();
|
||||||
|
if (userDTO != null) {
|
||||||
|
BeanUtils.copyBean(personalDTO, userDTO);
|
||||||
|
personalDTO.setOrganizationProjectMap(userRoleRelationService.selectOrganizationProjectByUserId(userDTO.getId()));
|
||||||
|
}
|
||||||
|
return personalDTO;
|
||||||
|
}
|
||||||
|
|
||||||
public List<UserTableResponse> list(BasePageRequest request) {
|
public List<UserTableResponse> list(BasePageRequest request) {
|
||||||
List<UserTableResponse> returnList = new ArrayList<>();
|
List<UserTableResponse> returnList = new ArrayList<>();
|
||||||
List<User> userList = baseUserMapper.selectByKeyword(request.getKeyword(), false);
|
List<User> userList = baseUserMapper.selectByKeyword(request.getKeyword(), false);
|
||||||
|
@ -524,6 +533,20 @@ public class UserService {
|
||||||
editUser.setEmail(request.getEmail());
|
editUser.setEmail(request.getEmail());
|
||||||
editUser.setUpdateUser(operator);
|
editUser.setUpdateUser(operator);
|
||||||
editUser.setUpdateTime(System.currentTimeMillis());
|
editUser.setUpdateTime(System.currentTimeMillis());
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(request.getAvatar())) {
|
||||||
|
UserExtend userExtend = userExtendMapper.selectByPrimaryKey(request.getId());
|
||||||
|
if (userExtend == null) {
|
||||||
|
userExtend = new UserExtend();
|
||||||
|
userExtend.setId(request.getId());
|
||||||
|
userExtend.setAvatar(request.getAvatar());
|
||||||
|
userExtendMapper.insert(userExtend);
|
||||||
|
} else {
|
||||||
|
userExtend.setAvatar(request.getAvatar());
|
||||||
|
userExtendMapper.updateByPrimaryKey(userExtend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return userMapper.updateByPrimaryKeySelective(editUser) > 0;
|
return userMapper.updateByPrimaryKeySelective(editUser) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,40 +69,40 @@
|
||||||
</javaClientGenerator>
|
</javaClientGenerator>
|
||||||
|
|
||||||
<!--要生成的数据库表 -->
|
<!--要生成的数据库表 -->
|
||||||
<table tableName="user_invite"/>
|
<!-- <table tableName="user_invite"/>-->
|
||||||
<table tableName="auth_source"/>
|
<!-- <table tableName="auth_source"/>-->
|
||||||
<table tableName="license"/>
|
<!-- <table tableName="license"/>-->
|
||||||
<table tableName="message_task"/>
|
<!-- <table tableName="message_task"/>-->
|
||||||
<table tableName="message_task_blob"/>
|
<!-- <table tableName="message_task_blob"/>-->
|
||||||
<table tableName="notification"/>
|
<!-- <table tableName="notification"/>-->
|
||||||
<table tableName="novice_statistics"/>
|
<!-- <table tableName="novice_statistics"/>-->
|
||||||
<table tableName="operating_log"/>
|
<!-- <table tableName="operating_log"/>-->
|
||||||
<table tableName="operating_log_resource"/>
|
<!-- <table tableName="operating_log_resource"/>-->
|
||||||
<table tableName="plugin"/>
|
<!-- <table tableName="plugin"/>-->
|
||||||
<table tableName="plugin_script"/>
|
<!-- <table tableName="plugin_script"/>-->
|
||||||
<table tableName="plugin_organization"/>
|
<!-- <table tableName="plugin_organization"/>-->
|
||||||
<table tableName="schedule"/>
|
<!-- <table tableName="schedule"/>-->
|
||||||
<table tableName="service_integration"/>
|
<!-- <table tableName="service_integration"/>-->
|
||||||
<table tableName="system_parameter"/>
|
<!-- <table tableName="system_parameter"/>-->
|
||||||
<table tableName="test_resource"/>
|
<!-- <table tableName="test_resource"/>-->
|
||||||
<table tableName="test_resource_pool"/>
|
<!-- <table tableName="test_resource_pool"/>-->
|
||||||
<table tableName="user"/>
|
<!-- <table tableName="user"/>-->
|
||||||
<table tableName="user_extend"/>
|
<!-- <table tableName="user_extend"/>-->
|
||||||
<table tableName="user_key"/>
|
<!-- <table tableName="user_key"/>-->
|
||||||
<table tableName="user_role"/>
|
<!-- <table tableName="user_role"/>-->
|
||||||
<table tableName="user_role_permission"/>
|
<!-- <table tableName="user_role_permission"/>-->
|
||||||
<table tableName="user_role_relation"/>
|
<!-- <table tableName="user_role_relation"/>-->
|
||||||
<table tableName="organization"/>
|
<!-- <table tableName="organization"/>-->
|
||||||
|
|
||||||
<table tableName="custom_field"/>
|
<!-- <table tableName="custom_field"/>-->
|
||||||
<table tableName="custom_field_option"/>
|
<!-- <table tableName="custom_field_option"/>-->
|
||||||
<table tableName="template"/>
|
<!-- <table tableName="template"/>-->
|
||||||
<table tableName="template_custom_field"/>
|
<!-- <table tableName="template_custom_field"/>-->
|
||||||
<table tableName="status_item"/>
|
<!-- <table tableName="status_item"/>-->
|
||||||
<table tableName="status_definition"/>
|
<!-- <table tableName="status_definition"/>-->
|
||||||
<table tableName="status_flow"/>
|
<!-- <table tableName="status_flow"/>-->
|
||||||
<table tableName="organization_parameter"/>
|
<!-- <table tableName="organization_parameter"/>-->
|
||||||
<table tableName="user_local_config"/>
|
<table tableName="user_extend"/>
|
||||||
|
|
||||||
<!-- 要忽略的字段-->
|
<!-- 要忽略的字段-->
|
||||||
<!-- <table tableName="test_case">
|
<!-- <table tableName="test_case">
|
||||||
|
|
|
@ -6,9 +6,11 @@ import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.domain.UserExample;
|
import io.metersphere.system.domain.UserExample;
|
||||||
|
import io.metersphere.system.domain.UserExtendExample;
|
||||||
import io.metersphere.system.dto.request.user.PersonalUpdatePasswordRequest;
|
import io.metersphere.system.dto.request.user.PersonalUpdatePasswordRequest;
|
||||||
import io.metersphere.system.dto.request.user.PersonalUpdateRequest;
|
import io.metersphere.system.dto.request.user.PersonalUpdateRequest;
|
||||||
import io.metersphere.system.dto.user.UserDTO;
|
import io.metersphere.system.dto.user.UserDTO;
|
||||||
|
import io.metersphere.system.mapper.UserExtendMapper;
|
||||||
import io.metersphere.system.mapper.UserMapper;
|
import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import io.metersphere.system.utils.user.PersonalRequestUtils;
|
import io.metersphere.system.utils.user.PersonalRequestUtils;
|
||||||
|
@ -49,6 +51,8 @@ public class PersonalControllerTests extends BaseTest {
|
||||||
return JSON.parseObject(JSON.toJSONString(resultHolder.getData()), UserDTO.class);
|
return JSON.parseObject(JSON.toJSONString(resultHolder.getData()), UserDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserExtendMapper userExtendMapper;
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
void testPersonalUpdateInfo() throws Exception {
|
void testPersonalUpdateInfo() throws Exception {
|
||||||
|
@ -61,6 +65,27 @@ public class PersonalControllerTests extends BaseTest {
|
||||||
UserDTO userDTO = this.selectUserDTO(loginUser);
|
UserDTO userDTO = this.selectUserDTO(loginUser);
|
||||||
this.checkUserInformation(userDTO, request);
|
this.checkUserInformation(userDTO, request);
|
||||||
|
|
||||||
|
//修改头像
|
||||||
|
UserExtendExample example = new UserExtendExample();
|
||||||
|
example.createCriteria().andIdEqualTo(loginUser);
|
||||||
|
Assertions.assertEquals(userExtendMapper.countByExample(example), 0);
|
||||||
|
|
||||||
|
request = new PersonalUpdateRequest();
|
||||||
|
request.setId(loginUser);
|
||||||
|
request.setEmail("admin_update@metersphere.io");
|
||||||
|
request.setUsername("admin_update");
|
||||||
|
request.setPhone("1111111111");
|
||||||
|
request.setAvatar(IDGenerator.nextStr());
|
||||||
|
this.requestPostWithOk(PersonalRequestUtils.URL_PERSONAL_UPDATE_INFO, request);
|
||||||
|
userDTO = this.selectUserDTO(loginUser);
|
||||||
|
Assertions.assertEquals(userDTO.getAvatar(), request.getAvatar());
|
||||||
|
//多次修改头像
|
||||||
|
Assertions.assertEquals(userExtendMapper.countByExample(example), 1L);
|
||||||
|
request.setAvatar(IDGenerator.nextStr());
|
||||||
|
this.requestPostWithOk(PersonalRequestUtils.URL_PERSONAL_UPDATE_INFO, request);
|
||||||
|
userDTO = this.selectUserDTO(loginUser);
|
||||||
|
Assertions.assertEquals(userDTO.getAvatar(), request.getAvatar());
|
||||||
|
|
||||||
//修改回去
|
//修改回去
|
||||||
request = new PersonalUpdateRequest();
|
request = new PersonalUpdateRequest();
|
||||||
request.setId(loginUser);
|
request.setId(loginUser);
|
||||||
|
|
|
@ -892,6 +892,11 @@ public class UserControllerTests extends BaseTest {
|
||||||
for (String userID : request.getSelectIds()) {
|
for (String userID : request.getSelectIds()) {
|
||||||
this.checkLog(userID, OperationLogType.UPDATE, UserRequestUtils.URL_ADD_PROJECT_MEMBER);
|
this.checkLog(userID, OperationLogType.UPDATE, UserRequestUtils.URL_ADD_PROJECT_MEMBER);
|
||||||
}
|
}
|
||||||
|
//获取用户信息
|
||||||
|
for (String userID : request.getSelectIds()) {
|
||||||
|
userService.getPersonalById(userID);
|
||||||
|
}
|
||||||
|
|
||||||
//检查用户表格不会加载出来非全局用户组
|
//检查用户表格不会加载出来非全局用户组
|
||||||
this.testPageSuccess();
|
this.testPageSuccess();
|
||||||
}
|
}
|
||||||
|
@ -929,6 +934,11 @@ public class UserControllerTests extends BaseTest {
|
||||||
for (String userID : request.getSelectIds()) {
|
for (String userID : request.getSelectIds()) {
|
||||||
this.checkLog(userID, OperationLogType.UPDATE, UserRequestUtils.URL_ADD_ORGANIZATION_MEMBER);
|
this.checkLog(userID, OperationLogType.UPDATE, UserRequestUtils.URL_ADD_ORGANIZATION_MEMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取用户信息
|
||||||
|
for (String userID : request.getSelectIds()) {
|
||||||
|
userService.getPersonalById(userID);
|
||||||
|
}
|
||||||
//检查用户表格加载组织
|
//检查用户表格加载组织
|
||||||
this.testPageSuccess();
|
this.testPageSuccess();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,4 +44,13 @@ INSERT INTO project (id, num, organization_id, name, description, create_user, u
|
||||||
('tianyang-projectId-50', 12151, 'tianyang-organization-5', 'tianyang-projectId-50', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
('tianyang-projectId-50', 12151, 'tianyang-organization-5', 'tianyang-projectId-50', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||||
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES
|
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES
|
||||||
('tianyang-projectId-60', 12152, 'tianyang-organization-6', 'tianyang-projectId-60', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
('tianyang-projectId-60', 12152, 'tianyang-organization-6', 'tianyang-projectId-60', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||||
|
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time)
|
||||||
|
VALUES ('tianyang-projectId-61', 12153, 'tianyang-organization-6', 'tianyang-projectId-60', '系统默认创建的项目',
|
||||||
|
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||||
|
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time)
|
||||||
|
VALUES ('tianyang-projectId-62', 12154, 'tianyang-organization-6', 'tianyang-projectId-60', '系统默认创建的项目',
|
||||||
|
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||||
|
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time)
|
||||||
|
VALUES ('tianyang-projectId-63', 12155, 'tianyang-organization-6', 'tianyang-projectId-60', '系统默认创建的项目',
|
||||||
|
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue