Initial commit
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_fingerprint_config")
|
||||
public class BrowserFingerprint extends BaseEntity {
|
||||
|
||||
@TableId(value = "fingerprint_id")
|
||||
private Long fingerprintId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long profileId;
|
||||
|
||||
private String browserFamily;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String userAgent;
|
||||
|
||||
private String geoMode;
|
||||
|
||||
private String locale;
|
||||
|
||||
private String timezone;
|
||||
|
||||
private String geoCountry;
|
||||
|
||||
private Integer screenWidth;
|
||||
|
||||
private Integer screenHeight;
|
||||
|
||||
private String webRtcPolicy;
|
||||
|
||||
private String canvasPolicy;
|
||||
|
||||
private String webglPolicy;
|
||||
|
||||
private String audioPolicy;
|
||||
|
||||
private String fontPolicy;
|
||||
|
||||
private String cookieConfig;
|
||||
|
||||
private String encryptedPayload;
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_browser_kernel_package")
|
||||
public class BrowserKernelPackage extends BaseEntity {
|
||||
|
||||
@TableId(value = "kernel_id")
|
||||
private Long kernelId;
|
||||
|
||||
private String browserEngine;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String fullVersion;
|
||||
|
||||
private String osType;
|
||||
|
||||
private String archType;
|
||||
|
||||
private String packageUrl;
|
||||
|
||||
private String packageSha256;
|
||||
|
||||
private String archiveRootDir;
|
||||
|
||||
private String executablePath;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String isDefault;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_member_user")
|
||||
public class BrowserMemberUser extends BaseEntity {
|
||||
|
||||
@TableId(value = "member_id")
|
||||
private Long memberId;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String phonenumber;
|
||||
|
||||
private String status;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireTime;
|
||||
|
||||
private String lastLoginIp;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastLoginTime;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_platform")
|
||||
public class BrowserPlatform extends BaseEntity {
|
||||
|
||||
@TableId(value = "platform_id")
|
||||
private Long platformId;
|
||||
|
||||
private String platformName;
|
||||
|
||||
private String websiteUrl;
|
||||
|
||||
private String iconFileName;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_profile")
|
||||
public class BrowserProfile extends BaseEntity {
|
||||
|
||||
@TableId(value = "profile_id")
|
||||
private Long profileId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String profileName;
|
||||
|
||||
private Long groupId;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String tags;
|
||||
|
||||
private Long platformId;
|
||||
|
||||
private String platform;
|
||||
|
||||
private String customWebsiteUrl;
|
||||
|
||||
private String browserEngine;
|
||||
|
||||
private String browserChannel;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String browserOsType;
|
||||
|
||||
private String browserArchType;
|
||||
|
||||
private String proxyName;
|
||||
|
||||
private Long proxyId;
|
||||
|
||||
private String launchDiagnostics;
|
||||
|
||||
private Long fingerprintId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String proxyType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String proxyHost;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer proxyPort;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String fingerprintPayload;
|
||||
|
||||
private String localProfileKey;
|
||||
|
||||
private String syncStatus;
|
||||
|
||||
private String purityStatus;
|
||||
|
||||
private Date lastLaunchTime;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_profile_group")
|
||||
public class BrowserProfileGroup extends BaseEntity {
|
||||
|
||||
@TableId(value = "group_id")
|
||||
private Long groupId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String isDefault;
|
||||
|
||||
private String groupColor;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_proxy")
|
||||
public class BrowserProxy extends BaseEntity {
|
||||
|
||||
@TableId(value = "proxy_id")
|
||||
private Long proxyId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String proxyName;
|
||||
|
||||
private String proxyType;
|
||||
|
||||
private String host;
|
||||
|
||||
private Integer port;
|
||||
|
||||
private String geoCountry;
|
||||
|
||||
private String geoRegion;
|
||||
|
||||
private String geoCity;
|
||||
|
||||
private String username;
|
||||
|
||||
private String passwordEncrypted;
|
||||
|
||||
private String status;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.browser.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fp_runtime_record")
|
||||
public class BrowserRuntimeRecord extends BaseEntity {
|
||||
|
||||
@TableId(value = "runtime_id")
|
||||
private Long runtimeId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long profileId;
|
||||
|
||||
private Integer pid;
|
||||
|
||||
private Integer port;
|
||||
|
||||
private String status;
|
||||
|
||||
private Date startedAt;
|
||||
|
||||
private Date stoppedAt;
|
||||
|
||||
private String runtimePath;
|
||||
|
||||
private String profileDir;
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserFingerprintBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long fingerprintId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long profileId;
|
||||
|
||||
@NotBlank(message = "浏览器家族不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String browserFamily;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String userAgent;
|
||||
|
||||
private String geoMode;
|
||||
|
||||
private String locale;
|
||||
private String timezone;
|
||||
private String geoCountry;
|
||||
private Integer screenWidth;
|
||||
private Integer screenHeight;
|
||||
private String webRtcPolicy;
|
||||
private String canvasPolicy;
|
||||
private String webglPolicy;
|
||||
private String audioPolicy;
|
||||
private String fontPolicy;
|
||||
private String cookieConfig;
|
||||
private String encryptedPayload;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserKernelPackageBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long kernelId;
|
||||
|
||||
@NotBlank(message = "浏览器内核不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String browserEngine;
|
||||
|
||||
@NotBlank(message = "浏览器版本不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String browserVersion;
|
||||
|
||||
@NotBlank(message = "完整版本号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String fullVersion;
|
||||
|
||||
@NotBlank(message = "系统类型不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String osType;
|
||||
|
||||
@NotBlank(message = "架构类型不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String archType;
|
||||
|
||||
@NotBlank(message = "压缩包地址不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String packageUrl;
|
||||
|
||||
private String packageSha256;
|
||||
|
||||
private String archiveRootDir;
|
||||
|
||||
@NotBlank(message = "可执行文件路径不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String executablePath;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String isDefault;
|
||||
|
||||
private String status;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class BrowserMemberRegisterBo {
|
||||
|
||||
@NotBlank(message = "会员账号不能为空")
|
||||
@Length(min = 2, max = 20, message = "会员账号长度必须介于 2 和 20 之间")
|
||||
private String username;
|
||||
|
||||
@NotBlank(message = "会员密码不能为空")
|
||||
@Length(min = 5, max = 20, message = "会员密码长度必须介于 5 和 20 之间")
|
||||
private String password;
|
||||
|
||||
private String confirmPassword;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String phonenumber;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserMemberUserBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "会员ID不能为空", groups = {EditGroup.class})
|
||||
private Long memberId;
|
||||
|
||||
@NotBlank(message = "会员账号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
@Length(min = 2, max = 20, message = "会员账号长度必须介于 2 和 20 之间", groups = {AddGroup.class, EditGroup.class, QueryGroup.class})
|
||||
private String username;
|
||||
|
||||
@NotBlank(message = "会员密码不能为空", groups = {AddGroup.class})
|
||||
@Length(min = 5, max = 20, message = "会员密码长度必须介于 5 和 20 之间", groups = {AddGroup.class})
|
||||
private String password;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String phonenumber;
|
||||
|
||||
private String status;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireTime;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserPlatformBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long platformId;
|
||||
|
||||
@NotBlank(message = "平台名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String platformName;
|
||||
|
||||
@NotBlank(message = "网站地址不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String websiteUrl;
|
||||
|
||||
private String iconFileName;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserProfileBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long profileId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String memberUsername;
|
||||
|
||||
@NotBlank(message = "环境名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
@Size(min = 2, max = 64, message = "环境名称长度必须介于{min}和{max}之间")
|
||||
private String profileName;
|
||||
|
||||
private Long groupId;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String tags;
|
||||
|
||||
private Long platformId;
|
||||
|
||||
private String platform;
|
||||
|
||||
private String customWebsiteUrl;
|
||||
|
||||
@NotBlank(message = "浏览器内核不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String browserEngine;
|
||||
|
||||
private String browserChannel;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String browserOsType;
|
||||
|
||||
private String browserArchType;
|
||||
|
||||
private String proxyName;
|
||||
|
||||
private Long proxyId;
|
||||
|
||||
private String launchDiagnostics;
|
||||
|
||||
private Long fingerprintId;
|
||||
|
||||
private String proxyType;
|
||||
|
||||
private String proxyHost;
|
||||
|
||||
private Integer proxyPort;
|
||||
|
||||
private String fingerprintPayload;
|
||||
|
||||
private String localProfileKey;
|
||||
|
||||
private String syncStatus;
|
||||
|
||||
private String purityStatus;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserProfileGroupBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "分组主键不能为空", groups = {EditGroup.class})
|
||||
private Long groupId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
@NotBlank(message = "分组名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
@Size(min = 1, max = 64, message = "分组名称长度必须介于{min}和{max}之间", groups = {AddGroup.class, EditGroup.class, QueryGroup.class})
|
||||
private String groupName;
|
||||
|
||||
private String isDefault;
|
||||
|
||||
private String groupColor;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BrowserProfileGroupMoveBo {
|
||||
|
||||
@NotNull(message = "目标分组不能为空")
|
||||
private Long targetGroupId;
|
||||
|
||||
@NotEmpty(message = "环境列表不能为空")
|
||||
private List<Long> profileIds;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class BrowserProfileQuickSaveBo {
|
||||
|
||||
@Valid
|
||||
@NotNull(message = "环境信息不能为空")
|
||||
private BrowserProfileBo profile;
|
||||
|
||||
@Valid
|
||||
@NotNull(message = "指纹信息不能为空")
|
||||
private BrowserFingerprintBo fingerprint;
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.browser.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BrowserProxyBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long proxyId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
@NotBlank(message = "代理名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String proxyName;
|
||||
|
||||
@NotBlank(message = "代理类型不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String proxyType;
|
||||
|
||||
private String host;
|
||||
|
||||
private Integer port;
|
||||
|
||||
private String geoCountry;
|
||||
|
||||
private String geoRegion;
|
||||
|
||||
private String geoCity;
|
||||
|
||||
private String username;
|
||||
|
||||
private String passwordEncrypted;
|
||||
|
||||
private String status;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserFingerprintVo {
|
||||
private Long fingerprintId;
|
||||
private Long userId;
|
||||
private Long profileId;
|
||||
private String browserFamily;
|
||||
private String browserVersion;
|
||||
private String userAgent;
|
||||
private String geoMode;
|
||||
private String locale;
|
||||
private String timezone;
|
||||
private String geoCountry;
|
||||
private Integer screenWidth;
|
||||
private Integer screenHeight;
|
||||
private String webRtcPolicy;
|
||||
private String canvasPolicy;
|
||||
private String webglPolicy;
|
||||
private String audioPolicy;
|
||||
private String fontPolicy;
|
||||
private String cookieConfig;
|
||||
private String encryptedPayload;
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserKernelPackageVo {
|
||||
|
||||
private Long kernelId;
|
||||
|
||||
private String browserEngine;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String fullVersion;
|
||||
|
||||
private String osType;
|
||||
|
||||
private String archType;
|
||||
|
||||
private String packageUrl;
|
||||
|
||||
private String packageSha256;
|
||||
|
||||
private String archiveRootDir;
|
||||
|
||||
private String executablePath;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String isDefault;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private Date createTime;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserMemberUserVo {
|
||||
|
||||
private Long memberId;
|
||||
|
||||
private String username;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String phonenumber;
|
||||
|
||||
private String status;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireTime;
|
||||
|
||||
private String lastLoginIp;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastLoginTime;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserPlatformVo {
|
||||
|
||||
private Long platformId;
|
||||
|
||||
private String platformName;
|
||||
|
||||
private String websiteUrl;
|
||||
|
||||
private String iconFileName;
|
||||
|
||||
private String iconUrl;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private Date createTime;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserProfileGroupVo {
|
||||
|
||||
private Long groupId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String isDefault;
|
||||
|
||||
private String groupColor;
|
||||
|
||||
private Integer sortOrder;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Long profileCount;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private Date createTime;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class BrowserProfileQuickSaveVo {
|
||||
|
||||
private Long profileId;
|
||||
|
||||
private Long fingerprintId;
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserProfileVo {
|
||||
|
||||
private Long profileId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String memberUsername;
|
||||
|
||||
private String memberNickName;
|
||||
|
||||
private String profileName;
|
||||
|
||||
private Long groupId;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String tags;
|
||||
|
||||
private Long platformId;
|
||||
|
||||
private String platform;
|
||||
|
||||
private String customWebsiteUrl;
|
||||
|
||||
private String platformWebsiteUrl;
|
||||
|
||||
private String platformIconFileName;
|
||||
|
||||
private String platformIconUrl;
|
||||
|
||||
private String resolvedWebsiteUrl;
|
||||
|
||||
private String browserEngine;
|
||||
|
||||
private String browserChannel;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String browserOsType;
|
||||
|
||||
private String browserArchType;
|
||||
|
||||
private String proxyName;
|
||||
|
||||
private Long proxyId;
|
||||
|
||||
private String launchDiagnostics;
|
||||
|
||||
private Long fingerprintId;
|
||||
|
||||
private String proxyType;
|
||||
|
||||
private String proxyHost;
|
||||
|
||||
private Integer proxyPort;
|
||||
|
||||
private String fingerprintPayload;
|
||||
|
||||
private String localProfileKey;
|
||||
|
||||
private String syncStatus;
|
||||
|
||||
private String purityStatus;
|
||||
|
||||
private Date lastLaunchTime;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private Date createTime;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BrowserProxyVo {
|
||||
private Long proxyId;
|
||||
private Long userId;
|
||||
private String proxyName;
|
||||
private String proxyType;
|
||||
private String host;
|
||||
private Integer port;
|
||||
private String geoCountry;
|
||||
private String geoRegion;
|
||||
private String geoCity;
|
||||
private String username;
|
||||
private String status;
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.browser.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class BrowserRuntimeVo {
|
||||
|
||||
private String profileId;
|
||||
private String browserEngine;
|
||||
private String runtimePath;
|
||||
private String profileDir;
|
||||
private String startUrl;
|
||||
private Boolean headless;
|
||||
private List<String> browserArgs;
|
||||
private Map<String, Object> proxy;
|
||||
private Map<String, Object> fingerprint;
|
||||
private Map<String, Object> kernelPackage;
|
||||
private String proxyType;
|
||||
private String proxyHost;
|
||||
private Integer proxyPort;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserFingerprint;
|
||||
import com.ruoyi.browser.domain.vo.BrowserFingerprintVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserFingerprintMapper extends BaseMapperPlus<BrowserFingerprintMapper, BrowserFingerprint, BrowserFingerprintVo> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserKernelPackage;
|
||||
import com.ruoyi.browser.domain.vo.BrowserKernelPackageVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserKernelPackageMapper extends BaseMapperPlus<BrowserKernelPackageMapper, BrowserKernelPackage, BrowserKernelPackageVo> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserMemberUser;
|
||||
import com.ruoyi.browser.domain.vo.BrowserMemberUserVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserMemberUserMapper extends BaseMapperPlus<BrowserMemberUserMapper, BrowserMemberUser, BrowserMemberUserVo> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserPlatform;
|
||||
import com.ruoyi.browser.domain.vo.BrowserPlatformVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserPlatformMapper extends BaseMapperPlus<BrowserPlatformMapper, BrowserPlatform, BrowserPlatformVo> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserProfileGroup;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileGroupVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserProfileGroupMapper extends BaseMapperPlus<BrowserProfileGroupMapper, BrowserProfileGroup, BrowserProfileGroupVo> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserProfile;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserProfileMapper extends BaseMapperPlus<BrowserProfileMapper, BrowserProfile, BrowserProfileVo> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserProxy;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProxyVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserProxyMapper extends BaseMapperPlus<BrowserProxyMapper, BrowserProxy, BrowserProxyVo> {
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.ruoyi.browser.mapper;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserRuntimeRecord;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
public interface BrowserRuntimeRecordMapper extends BaseMapperPlus<BrowserRuntimeRecordMapper, BrowserRuntimeRecord, BrowserRuntimeRecord> {
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.bo.BrowserFingerprintBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserFingerprintVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IBrowserFingerprintService {
|
||||
TableDataInfo<BrowserFingerprintVo> queryPageList(BrowserFingerprintBo bo, PageQuery pageQuery);
|
||||
BrowserFingerprintVo queryById(Long fingerprintId);
|
||||
Boolean insertByBo(BrowserFingerprintBo bo);
|
||||
Boolean updateByBo(BrowserFingerprintBo bo);
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.bo.BrowserKernelPackageBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserKernelPackageVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface IBrowserKernelPackageService {
|
||||
|
||||
TableDataInfo<BrowserKernelPackageVo> queryPageList(BrowserKernelPackageBo bo, PageQuery pageQuery);
|
||||
|
||||
List<BrowserKernelPackageVo> queryEnabledOptions(BrowserKernelPackageBo bo);
|
||||
|
||||
BrowserKernelPackageVo queryById(Long kernelId);
|
||||
|
||||
Boolean insertByBo(BrowserKernelPackageBo bo);
|
||||
|
||||
Boolean updateByBo(BrowserKernelPackageBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
BrowserKernelPackageVo resolvePackage(String browserEngine, String browserVersion, String osType, String archType);
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.bo.BrowserMemberRegisterBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserMemberUserBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserMemberUserVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IBrowserMemberUserService {
|
||||
|
||||
TableDataInfo<BrowserMemberUserVo> queryPageList(BrowserMemberUserBo bo, PageQuery pageQuery);
|
||||
|
||||
BrowserMemberUserVo queryById(Long memberId);
|
||||
|
||||
Boolean insertByBo(BrowserMemberUserBo bo);
|
||||
|
||||
Boolean updateByBo(BrowserMemberUserBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
Boolean changeStatus(BrowserMemberUserBo bo);
|
||||
|
||||
String login(LoginBody loginBody);
|
||||
|
||||
void register(BrowserMemberRegisterBo bo);
|
||||
|
||||
BrowserMemberUserVo currentMember();
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.bo.BrowserPlatformBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserPlatformVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface IBrowserPlatformService {
|
||||
|
||||
TableDataInfo<BrowserPlatformVo> queryPageList(BrowserPlatformBo bo, PageQuery pageQuery);
|
||||
|
||||
List<BrowserPlatformVo> queryEnabledOptions();
|
||||
|
||||
BrowserPlatformVo queryById(Long platformId);
|
||||
|
||||
Boolean insertByBo(BrowserPlatformBo bo);
|
||||
|
||||
Boolean updateByBo(BrowserPlatformBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.BrowserProfileGroup;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileGroupBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileGroupMoveBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileGroupVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBrowserProfileGroupService {
|
||||
|
||||
List<BrowserProfileGroupVo> queryList(BrowserProfileGroupBo bo);
|
||||
|
||||
Boolean insertByBo(BrowserProfileGroupBo bo);
|
||||
|
||||
Boolean updateByBo(BrowserProfileGroupBo bo);
|
||||
|
||||
Boolean deleteById(Long groupId);
|
||||
|
||||
Boolean moveProfiles(BrowserProfileGroupMoveBo bo);
|
||||
|
||||
BrowserProfileGroup ensureDefaultGroup(Long userId);
|
||||
|
||||
void prepareGroupsForUser(Long userId);
|
||||
|
||||
BrowserProfileGroup resolveGroupForProfile(Long userId, Long groupId, String groupName);
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileQuickSaveBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileQuickSaveVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IBrowserProfileService {
|
||||
|
||||
TableDataInfo<BrowserProfileVo> queryPageList(BrowserProfileBo bo, PageQuery pageQuery);
|
||||
|
||||
BrowserProfileVo queryById(Long profileId);
|
||||
|
||||
Boolean insertByBo(BrowserProfileBo bo);
|
||||
|
||||
Boolean updateByBo(BrowserProfileBo bo);
|
||||
|
||||
BrowserProfileQuickSaveVo quickCreate(BrowserProfileQuickSaveBo bo);
|
||||
|
||||
BrowserProfileQuickSaveVo quickUpdate(BrowserProfileQuickSaveBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
void launch(Long profileId);
|
||||
|
||||
boolean close(Long profileId);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.bo.BrowserProxyBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProxyVo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IBrowserProxyService {
|
||||
TableDataInfo<BrowserProxyVo> queryPageList(BrowserProxyBo bo, PageQuery pageQuery);
|
||||
BrowserProxyVo queryById(Long proxyId);
|
||||
Boolean insertByBo(BrowserProxyBo bo);
|
||||
Boolean updateByBo(BrowserProxyBo bo);
|
||||
Boolean refreshGeoById(Long proxyId);
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
public interface IBrowserRuntimeRecordService {
|
||||
void recordLaunch(Long userId, Long profileId, Integer pid, Integer port, String runtimePath, String profileDir);
|
||||
void recordClose(Long userId, Long profileId);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.browser.service;
|
||||
|
||||
import com.ruoyi.browser.domain.vo.BrowserRuntimeVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBrowserRuntimeService {
|
||||
|
||||
BrowserProfileVo launch(Long profileId);
|
||||
|
||||
boolean close(Long profileId);
|
||||
|
||||
List<Object> running();
|
||||
|
||||
BrowserRuntimeVo buildLaunchPayload(BrowserProfileVo profileVo);
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.browser.domain.BrowserFingerprint;
|
||||
import com.ruoyi.browser.domain.bo.BrowserFingerprintBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserFingerprintVo;
|
||||
import com.ruoyi.browser.mapper.BrowserFingerprintMapper;
|
||||
import com.ruoyi.browser.service.IBrowserFingerprintService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserFingerprintServiceImpl implements IBrowserFingerprintService {
|
||||
|
||||
private final BrowserFingerprintMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BrowserFingerprintVo> queryPageList(BrowserFingerprintBo bo, PageQuery pageQuery) {
|
||||
Page<BrowserFingerprintVo> result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo));
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserFingerprintVo queryById(Long fingerprintId) {
|
||||
BrowserFingerprintVo vo = baseMapper.selectVoById(fingerprintId);
|
||||
checkAccess(vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserFingerprintBo bo) {
|
||||
BrowserFingerprint entity = BeanUtil.toBean(bo, BrowserFingerprint.class);
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if (ObjectUtil.isNull(userId)) {
|
||||
throw new ServiceException("未获取到当前登录会员信息");
|
||||
}
|
||||
entity.setUserId(userId);
|
||||
if (!checkUnique(entity)) {
|
||||
throw new ServiceException("指纹配置已存在");
|
||||
}
|
||||
return baseMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserFingerprintBo bo) {
|
||||
BrowserFingerprint entity = BeanUtil.toBean(bo, BrowserFingerprint.class);
|
||||
BrowserFingerprint old = baseMapper.selectById(entity.getFingerprintId());
|
||||
checkAccess(old);
|
||||
entity.setUserId(old.getUserId());
|
||||
if (!checkUnique(entity)) {
|
||||
throw new ServiceException("指纹配置已存在");
|
||||
}
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
for (Long id : ids) {
|
||||
checkAccess(baseMapper.selectById(id));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BrowserFingerprint> buildQueryWrapper(BrowserFingerprintBo bo) {
|
||||
LambdaQueryWrapper<BrowserFingerprint> lqw = new LambdaQueryWrapper<>();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if (isSystemAdmin()) {
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getUserId()), BrowserFingerprint::getUserId, bo.getUserId());
|
||||
} else {
|
||||
if (ObjectUtil.isNull(userId)) {
|
||||
throw new ServiceException("未获取到当前登录会员信息");
|
||||
}
|
||||
lqw.eq(BrowserFingerprint::getUserId, userId);
|
||||
}
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getProfileId()), BrowserFingerprint::getProfileId, bo.getProfileId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBrowserFamily()), BrowserFingerprint::getBrowserFamily, bo.getBrowserFamily());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserFingerprintVo vo) {
|
||||
if (ObjectUtil.isNull(vo)) {
|
||||
throw new ServiceException("指纹数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), vo.getUserId())) {
|
||||
throw new ServiceException("无权限访问该指纹数据");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserFingerprint entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
throw new ServiceException("指纹数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), entity.getUserId())) {
|
||||
throw new ServiceException("无权限操作该指纹数据");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSystemAdmin() {
|
||||
return LoginHelper.isAdmin() && LoginHelper.getUserType() == UserType.SYS_USER;
|
||||
}
|
||||
|
||||
private boolean checkUnique(BrowserFingerprint entity) {
|
||||
long fingerprintId = ObjectUtil.isNull(entity.getFingerprintId()) ? -1L : entity.getFingerprintId();
|
||||
return !baseMapper.exists(new LambdaQueryWrapper<BrowserFingerprint>()
|
||||
.eq(BrowserFingerprint::getUserId, entity.getUserId())
|
||||
.eq(BrowserFingerprint::getProfileId, entity.getProfileId())
|
||||
.ne(ObjectUtil.isNotNull(entity.getFingerprintId()), BrowserFingerprint::getFingerprintId, fingerprintId));
|
||||
}
|
||||
}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.browser.domain.BrowserKernelPackage;
|
||||
import com.ruoyi.browser.domain.bo.BrowserKernelPackageBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserKernelPackageVo;
|
||||
import com.ruoyi.browser.mapper.BrowserKernelPackageMapper;
|
||||
import com.ruoyi.browser.service.IBrowserKernelPackageService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserKernelPackageServiceImpl implements IBrowserKernelPackageService {
|
||||
|
||||
private final BrowserKernelPackageMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BrowserKernelPackageVo> queryPageList(BrowserKernelPackageBo bo, PageQuery pageQuery) {
|
||||
Page<BrowserKernelPackageVo> result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo, false));
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrowserKernelPackageVo> queryEnabledOptions(BrowserKernelPackageBo bo) {
|
||||
return baseMapper.selectVoList(buildQueryWrapper(bo, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserKernelPackageVo queryById(Long kernelId) {
|
||||
BrowserKernelPackageVo vo = baseMapper.selectVoById(kernelId);
|
||||
if (ObjectUtil.isNull(vo)) {
|
||||
throw new ServiceException("内核包配置不存在");
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserKernelPackageBo bo) {
|
||||
BrowserKernelPackage entity = normalizeEntity(BeanUtil.toBean(bo, BrowserKernelPackage.class));
|
||||
entity.setKernelId(null);
|
||||
ensureUnique(entity);
|
||||
resetDefaultIfNeeded(entity);
|
||||
return baseMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserKernelPackageBo bo) {
|
||||
BrowserKernelPackage old = baseMapper.selectById(bo.getKernelId());
|
||||
if (ObjectUtil.isNull(old)) {
|
||||
throw new ServiceException("内核包配置不存在");
|
||||
}
|
||||
BrowserKernelPackage entity = normalizeEntity(BeanUtil.toBean(bo, BrowserKernelPackage.class));
|
||||
ensureUnique(entity);
|
||||
resetDefaultIfNeeded(entity);
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserKernelPackageVo resolvePackage(String browserEngine, String browserVersion, String osType, String archType) {
|
||||
String normalizedEngine = StringUtils.trimToEmpty(browserEngine);
|
||||
String normalizedVersion = StringUtils.trimToEmpty(browserVersion);
|
||||
String normalizedOs = StringUtils.trimToEmpty(osType);
|
||||
String normalizedArch = StringUtils.trimToEmpty(archType);
|
||||
if (StringUtils.isAnyBlank(normalizedEngine, normalizedOs, normalizedArch)) {
|
||||
return null;
|
||||
}
|
||||
BrowserKernelPackage kernelPackage = null;
|
||||
if (StringUtils.isNotBlank(normalizedVersion)) {
|
||||
kernelPackage = baseMapper.selectOne(new LambdaQueryWrapper<BrowserKernelPackage>()
|
||||
.eq(BrowserKernelPackage::getBrowserEngine, normalizedEngine)
|
||||
.eq(BrowserKernelPackage::getBrowserVersion, normalizedVersion)
|
||||
.eq(BrowserKernelPackage::getOsType, normalizedOs)
|
||||
.eq(BrowserKernelPackage::getArchType, normalizedArch)
|
||||
.eq(BrowserKernelPackage::getStatus, "0")
|
||||
.last("limit 1"));
|
||||
}
|
||||
if (ObjectUtil.isNull(kernelPackage)) {
|
||||
kernelPackage = baseMapper.selectOne(new LambdaQueryWrapper<BrowserKernelPackage>()
|
||||
.eq(BrowserKernelPackage::getBrowserEngine, normalizedEngine)
|
||||
.eq(BrowserKernelPackage::getOsType, normalizedOs)
|
||||
.eq(BrowserKernelPackage::getArchType, normalizedArch)
|
||||
.eq(BrowserKernelPackage::getIsDefault, "1")
|
||||
.eq(BrowserKernelPackage::getStatus, "0")
|
||||
.last("limit 1"));
|
||||
}
|
||||
return ObjectUtil.isNull(kernelPackage) ? null : BeanUtil.toBean(kernelPackage, BrowserKernelPackageVo.class);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BrowserKernelPackage> buildQueryWrapper(BrowserKernelPackageBo bo, boolean enabledOnly) {
|
||||
LambdaQueryWrapper<BrowserKernelPackage> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBrowserEngine()), BrowserKernelPackage::getBrowserEngine, bo.getBrowserEngine());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBrowserVersion()), BrowserKernelPackage::getBrowserVersion, bo.getBrowserVersion());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOsType()), BrowserKernelPackage::getOsType, bo.getOsType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getArchType()), BrowserKernelPackage::getArchType, bo.getArchType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), BrowserKernelPackage::getStatus, bo.getStatus());
|
||||
if (enabledOnly) {
|
||||
lqw.eq(BrowserKernelPackage::getStatus, "0");
|
||||
}
|
||||
lqw.orderByAsc(BrowserKernelPackage::getBrowserEngine)
|
||||
.orderByAsc(BrowserKernelPackage::getOsType)
|
||||
.orderByAsc(BrowserKernelPackage::getArchType)
|
||||
.orderByDesc(BrowserKernelPackage::getIsDefault)
|
||||
.orderByAsc(BrowserKernelPackage::getSortOrder)
|
||||
.orderByAsc(BrowserKernelPackage::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private BrowserKernelPackage normalizeEntity(BrowserKernelPackage entity) {
|
||||
entity.setBrowserEngine(StringUtils.trim(entity.getBrowserEngine()));
|
||||
entity.setBrowserVersion(StringUtils.trim(entity.getBrowserVersion()));
|
||||
entity.setFullVersion(StringUtils.trim(entity.getFullVersion()));
|
||||
entity.setOsType(StringUtils.lowerCase(StringUtils.trim(entity.getOsType())));
|
||||
entity.setArchType(StringUtils.lowerCase(StringUtils.trim(entity.getArchType())));
|
||||
entity.setPackageUrl(normalizeUrl(entity.getPackageUrl(), "压缩包地址"));
|
||||
entity.setPackageSha256(StringUtils.trim(entity.getPackageSha256()));
|
||||
entity.setArchiveRootDir(StringUtils.trim(entity.getArchiveRootDir()));
|
||||
entity.setExecutablePath(StringUtils.trim(entity.getExecutablePath()));
|
||||
entity.setSortOrder(ObjectUtil.defaultIfNull(entity.getSortOrder(), 0));
|
||||
entity.setIsDefault(StringUtils.equals(entity.getIsDefault(), "1") ? "1" : "0");
|
||||
entity.setStatus(StringUtils.isBlank(entity.getStatus()) ? "0" : entity.getStatus());
|
||||
return entity;
|
||||
}
|
||||
|
||||
private void ensureUnique(BrowserKernelPackage entity) {
|
||||
long kernelId = ObjectUtil.defaultIfNull(entity.getKernelId(), -1L);
|
||||
boolean exists = baseMapper.exists(new LambdaQueryWrapper<BrowserKernelPackage>()
|
||||
.eq(BrowserKernelPackage::getBrowserEngine, entity.getBrowserEngine())
|
||||
.eq(BrowserKernelPackage::getBrowserVersion, entity.getBrowserVersion())
|
||||
.eq(BrowserKernelPackage::getOsType, entity.getOsType())
|
||||
.eq(BrowserKernelPackage::getArchType, entity.getArchType())
|
||||
.ne(ObjectUtil.isNotNull(entity.getKernelId()), BrowserKernelPackage::getKernelId, kernelId));
|
||||
if (exists) {
|
||||
throw new ServiceException("同系统架构下该内核版本已存在");
|
||||
}
|
||||
}
|
||||
|
||||
private void resetDefaultIfNeeded(BrowserKernelPackage entity) {
|
||||
if (!StringUtils.equals(entity.getIsDefault(), "1")) {
|
||||
return;
|
||||
}
|
||||
baseMapper.update(
|
||||
null,
|
||||
new LambdaUpdateWrapper<BrowserKernelPackage>()
|
||||
.eq(BrowserKernelPackage::getBrowserEngine, entity.getBrowserEngine())
|
||||
.eq(BrowserKernelPackage::getOsType, entity.getOsType())
|
||||
.eq(BrowserKernelPackage::getArchType, entity.getArchType())
|
||||
.set(BrowserKernelPackage::getIsDefault, "0")
|
||||
.ne(ObjectUtil.isNotNull(entity.getKernelId()), BrowserKernelPackage::getKernelId, entity.getKernelId())
|
||||
);
|
||||
}
|
||||
|
||||
private String normalizeUrl(String value, String fieldName) {
|
||||
String normalized = StringUtils.trim(value);
|
||||
if (StringUtils.isBlank(normalized)) {
|
||||
throw new ServiceException(fieldName + "不能为空");
|
||||
}
|
||||
if (!(StringUtils.startsWithIgnoreCase(normalized, "http://")
|
||||
|| StringUtils.startsWithIgnoreCase(normalized, "https://"))) {
|
||||
throw new ServiceException(fieldName + "必须以 http:// 或 https:// 开头");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.browser.domain.BrowserMemberUser;
|
||||
import com.ruoyi.browser.domain.bo.BrowserMemberRegisterBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserMemberUserBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserMemberUserVo;
|
||||
import com.ruoyi.browser.mapper.BrowserMemberUserMapper;
|
||||
import com.ruoyi.browser.service.IBrowserProfileGroupService;
|
||||
import com.ruoyi.browser.service.IBrowserMemberUserService;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.DeviceType;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserMemberUserServiceImpl implements IBrowserMemberUserService {
|
||||
|
||||
private static final Set<String> MEMBER_MENU_PERMISSION = new HashSet<>(Arrays.asList(
|
||||
"browser:profile:list",
|
||||
"browser:profile:query",
|
||||
"browser:profile:add",
|
||||
"browser:profile:edit",
|
||||
"browser:profile:remove",
|
||||
"browser:profile:launch",
|
||||
"browser:profile:close",
|
||||
"browser:platform:list",
|
||||
"browser:platform:query",
|
||||
"browser:profile-group:list",
|
||||
"browser:profile-group:add",
|
||||
"browser:profile-group:edit",
|
||||
"browser:profile-group:remove",
|
||||
"browser:proxy:list",
|
||||
"browser:proxy:query",
|
||||
"browser:proxy:add",
|
||||
"browser:proxy:edit",
|
||||
"browser:proxy:remove",
|
||||
"browser:proxy:refresh-geo",
|
||||
"browser:fingerprint:list",
|
||||
"browser:fingerprint:query",
|
||||
"browser:fingerprint:add",
|
||||
"browser:fingerprint:edit",
|
||||
"browser:fingerprint:remove"
|
||||
));
|
||||
|
||||
private final BrowserMemberUserMapper baseMapper;
|
||||
private final IBrowserProfileGroupService profileGroupService;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BrowserMemberUserVo> queryPageList(BrowserMemberUserBo bo, PageQuery pageQuery) {
|
||||
Page<BrowserMemberUserVo> result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo));
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserMemberUserVo queryById(Long memberId) {
|
||||
BrowserMemberUserVo vo = baseMapper.selectVoById(memberId);
|
||||
if (ObjectUtil.isNull(vo)) {
|
||||
throw new ServiceException("会员数据不存在");
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserMemberUserBo bo) {
|
||||
BrowserMemberUser entity = BeanUtil.toBean(bo, BrowserMemberUser.class);
|
||||
entity.setMemberId(null);
|
||||
entity.setPassword(BCrypt.hashpw(bo.getPassword()));
|
||||
if (StringUtils.isBlank(entity.getNickName())) {
|
||||
entity.setNickName(entity.getUsername());
|
||||
}
|
||||
if (!checkUsernameUnique(entity)) {
|
||||
throw new ServiceException("会员账号已存在");
|
||||
}
|
||||
if (StringUtils.isBlank(entity.getStatus())) {
|
||||
entity.setStatus(UserConstants.USER_NORMAL);
|
||||
}
|
||||
boolean inserted = baseMapper.insert(entity) > 0;
|
||||
if (inserted) {
|
||||
profileGroupService.ensureDefaultGroup(entity.getMemberId());
|
||||
}
|
||||
return inserted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserMemberUserBo bo) {
|
||||
BrowserMemberUser entity = BeanUtil.toBean(bo, BrowserMemberUser.class);
|
||||
BrowserMemberUser old = baseMapper.selectById(entity.getMemberId());
|
||||
if (ObjectUtil.isNull(old)) {
|
||||
throw new ServiceException("会员数据不存在");
|
||||
}
|
||||
if (!checkUsernameUnique(entity)) {
|
||||
throw new ServiceException("会员账号已存在");
|
||||
}
|
||||
if (StringUtils.isBlank(entity.getPassword())) {
|
||||
entity.setPassword(null);
|
||||
} else {
|
||||
entity.setPassword(BCrypt.hashpw(entity.getPassword()));
|
||||
}
|
||||
if (StringUtils.isBlank(entity.getNickName())) {
|
||||
entity.setNickName(entity.getUsername());
|
||||
}
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean changeStatus(BrowserMemberUserBo bo) {
|
||||
BrowserMemberUser entity = new BrowserMemberUser();
|
||||
entity.setMemberId(bo.getMemberId());
|
||||
entity.setStatus(bo.getStatus());
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String login(LoginBody loginBody) {
|
||||
BrowserMemberUser user = baseMapper.selectOne(new LambdaQueryWrapper<BrowserMemberUser>()
|
||||
.eq(BrowserMemberUser::getUsername, loginBody.getUsername()));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
throw new ServiceException("会员账号不存在");
|
||||
}
|
||||
if (UserConstants.USER_DISABLE.equals(user.getStatus())) {
|
||||
throw new ServiceException("会员账号已被停用");
|
||||
}
|
||||
if (ObjectUtil.isNotNull(user.getExpireTime()) && user.getExpireTime().before(DateUtils.getNowDate())) {
|
||||
throw new ServiceException("会员账号已过期");
|
||||
}
|
||||
if (!BCrypt.checkpw(loginBody.getPassword(), user.getPassword())) {
|
||||
throw new ServiceException("会员账号或密码错误");
|
||||
}
|
||||
profileGroupService.ensureDefaultGroup(user.getMemberId());
|
||||
LoginUser loginUser = buildLoginUser(user);
|
||||
LoginHelper.loginByDevice(loginUser, DeviceType.PC);
|
||||
BrowserMemberUser update = new BrowserMemberUser();
|
||||
update.setMemberId(user.getMemberId());
|
||||
update.setLastLoginIp(ServletUtils.getClientIP());
|
||||
update.setLastLoginTime(new Date());
|
||||
baseMapper.updateById(update);
|
||||
return StpUtil.getTokenValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void register(BrowserMemberRegisterBo bo) {
|
||||
if (StringUtils.isNotBlank(bo.getConfirmPassword()) && !StringUtils.equals(bo.getPassword(), bo.getConfirmPassword())) {
|
||||
throw new ServiceException("两次输入的密码不一致");
|
||||
}
|
||||
BrowserMemberUser entity = new BrowserMemberUser();
|
||||
entity.setUsername(bo.getUsername());
|
||||
entity.setPassword(BCrypt.hashpw(bo.getPassword()));
|
||||
entity.setNickName(StringUtils.isBlank(bo.getNickName()) ? bo.getUsername() : bo.getNickName());
|
||||
entity.setEmail(bo.getEmail());
|
||||
entity.setPhonenumber(bo.getPhonenumber());
|
||||
entity.setStatus(UserConstants.USER_NORMAL);
|
||||
if (!checkUsernameUnique(entity)) {
|
||||
throw new ServiceException("会员账号已存在");
|
||||
}
|
||||
if (baseMapper.insert(entity) <= 0) {
|
||||
throw new ServiceException("会员注册失败");
|
||||
}
|
||||
profileGroupService.ensureDefaultGroup(entity.getMemberId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserMemberUserVo currentMember() {
|
||||
if (LoginHelper.getUserType() != UserType.MEMBER_USER) {
|
||||
throw new ServiceException("当前登录身份不是会员用户");
|
||||
}
|
||||
Long memberId = LoginHelper.getUserId();
|
||||
if (ObjectUtil.isNull(memberId)) {
|
||||
throw new ServiceException("未获取到会员登录信息");
|
||||
}
|
||||
return queryById(memberId);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BrowserMemberUser> buildQueryWrapper(BrowserMemberUserBo bo) {
|
||||
LambdaQueryWrapper<BrowserMemberUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getUsername()), BrowserMemberUser::getUsername, bo.getUsername());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getNickName()), BrowserMemberUser::getNickName, bo.getNickName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), BrowserMemberUser::getStatus, bo.getStatus());
|
||||
lqw.orderByDesc(BrowserMemberUser::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private boolean checkUsernameUnique(BrowserMemberUser entity) {
|
||||
long memberId = ObjectUtil.isNull(entity.getMemberId()) ? -1L : entity.getMemberId();
|
||||
return !baseMapper.exists(new LambdaQueryWrapper<BrowserMemberUser>()
|
||||
.eq(BrowserMemberUser::getUsername, entity.getUsername())
|
||||
.ne(ObjectUtil.isNotNull(entity.getMemberId()), BrowserMemberUser::getMemberId, memberId));
|
||||
}
|
||||
|
||||
private LoginUser buildLoginUser(BrowserMemberUser user) {
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setUserId(user.getMemberId());
|
||||
loginUser.setUsername(user.getUsername());
|
||||
loginUser.setUserType(UserType.MEMBER_USER.getUserType());
|
||||
loginUser.setMenuPermission(new HashSet<>(MEMBER_MENU_PERMISSION));
|
||||
loginUser.setRolePermission(new HashSet<>(CollUtil.newArrayList("member")));
|
||||
return loginUser;
|
||||
}
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.browser.domain.BrowserPlatform;
|
||||
import com.ruoyi.browser.domain.BrowserProfile;
|
||||
import com.ruoyi.browser.domain.bo.BrowserPlatformBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserPlatformVo;
|
||||
import com.ruoyi.browser.mapper.BrowserPlatformMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserProfileMapper;
|
||||
import com.ruoyi.browser.service.IBrowserPlatformService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserPlatformServiceImpl implements IBrowserPlatformService {
|
||||
|
||||
public static final String ICON_BASE_URL_KEY = "browser.platform.iconBaseUrl";
|
||||
|
||||
private final BrowserPlatformMapper baseMapper;
|
||||
private final BrowserProfileMapper profileMapper;
|
||||
private final ISysConfigService configService;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BrowserPlatformVo> queryPageList(BrowserPlatformBo bo, PageQuery pageQuery) {
|
||||
Page<BrowserPlatformVo> result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo));
|
||||
enrichIconUrl(result.getRecords());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrowserPlatformVo> queryEnabledOptions() {
|
||||
List<BrowserPlatformVo> rows = baseMapper.selectVoList(new LambdaQueryWrapper<BrowserPlatform>()
|
||||
.eq(BrowserPlatform::getStatus, "0")
|
||||
.orderByAsc(BrowserPlatform::getSortOrder)
|
||||
.orderByAsc(BrowserPlatform::getCreateTime));
|
||||
enrichIconUrl(rows);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserPlatformVo queryById(Long platformId) {
|
||||
BrowserPlatformVo vo = baseMapper.selectVoById(platformId);
|
||||
if (ObjectUtil.isNull(vo)) {
|
||||
throw new ServiceException("平台数据不存在");
|
||||
}
|
||||
enrichIconUrl(CollUtil.newArrayList(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserPlatformBo bo) {
|
||||
BrowserPlatform entity = normalizeEntity(BeanUtil.toBean(bo, BrowserPlatform.class));
|
||||
entity.setPlatformId(null);
|
||||
if (!checkNameUnique(entity)) {
|
||||
throw new ServiceException("平台名称已存在");
|
||||
}
|
||||
return baseMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserPlatformBo bo) {
|
||||
BrowserPlatform old = baseMapper.selectById(bo.getPlatformId());
|
||||
if (ObjectUtil.isNull(old)) {
|
||||
throw new ServiceException("平台数据不存在");
|
||||
}
|
||||
BrowserPlatform entity = normalizeEntity(BeanUtil.toBean(bo, BrowserPlatform.class));
|
||||
if (!checkNameUnique(entity)) {
|
||||
throw new ServiceException("平台名称已存在");
|
||||
}
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
for (Long id : ids) {
|
||||
long count = profileMapper.selectCount(new LambdaQueryWrapper<BrowserProfile>()
|
||||
.eq(BrowserProfile::getPlatformId, id));
|
||||
if (count > 0) {
|
||||
throw new ServiceException("平台已被环境使用,不能删除");
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BrowserPlatform> buildQueryWrapper(BrowserPlatformBo bo) {
|
||||
LambdaQueryWrapper<BrowserPlatform> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPlatformName()), BrowserPlatform::getPlatformName, bo.getPlatformName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getWebsiteUrl()), BrowserPlatform::getWebsiteUrl, bo.getWebsiteUrl());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), BrowserPlatform::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(BrowserPlatform::getSortOrder);
|
||||
lqw.orderByAsc(BrowserPlatform::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private BrowserPlatform normalizeEntity(BrowserPlatform entity) {
|
||||
entity.setPlatformName(StringUtils.trim(entity.getPlatformName()));
|
||||
entity.setWebsiteUrl(normalizeWebsiteUrl(entity.getWebsiteUrl(), "平台网站地址"));
|
||||
entity.setIconFileName(normalizeIconFileName(entity.getIconFileName()));
|
||||
entity.setSortOrder(ObjectUtil.defaultIfNull(entity.getSortOrder(), 0));
|
||||
entity.setStatus(StringUtils.isBlank(entity.getStatus()) ? "0" : entity.getStatus());
|
||||
return entity;
|
||||
}
|
||||
|
||||
private boolean checkNameUnique(BrowserPlatform entity) {
|
||||
long platformId = ObjectUtil.isNull(entity.getPlatformId()) ? -1L : entity.getPlatformId();
|
||||
return !baseMapper.exists(new LambdaQueryWrapper<BrowserPlatform>()
|
||||
.eq(BrowserPlatform::getPlatformName, entity.getPlatformName())
|
||||
.ne(ObjectUtil.isNotNull(entity.getPlatformId()), BrowserPlatform::getPlatformId, platformId));
|
||||
}
|
||||
|
||||
private void enrichIconUrl(List<BrowserPlatformVo> rows) {
|
||||
if (CollUtil.isEmpty(rows)) {
|
||||
return;
|
||||
}
|
||||
String baseUrl = normalizeBaseUrl(configService.selectConfigByKey(ICON_BASE_URL_KEY));
|
||||
rows.forEach(item -> item.setIconUrl(buildIconUrl(baseUrl, item.getIconFileName())));
|
||||
}
|
||||
|
||||
public static String normalizeWebsiteUrl(String value, String fieldName) {
|
||||
String normalized = StringUtils.trim(value);
|
||||
if (StringUtils.isBlank(normalized)) {
|
||||
throw new ServiceException(fieldName + "不能为空");
|
||||
}
|
||||
if (!(StringUtils.startsWithIgnoreCase(normalized, "http://")
|
||||
|| StringUtils.startsWithIgnoreCase(normalized, "https://"))) {
|
||||
throw new ServiceException(fieldName + "必须以 http:// 或 https:// 开头");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
public static String normalizeBaseUrl(String value) {
|
||||
String normalized = StringUtils.trim(value);
|
||||
if (StringUtils.isBlank(normalized)) {
|
||||
return null;
|
||||
}
|
||||
return StringUtils.stripEnd(normalized, "/");
|
||||
}
|
||||
|
||||
public static String normalizeIconFileName(String value) {
|
||||
String normalized = StringUtils.trim(value);
|
||||
return StringUtils.isBlank(normalized) ? null : normalized;
|
||||
}
|
||||
|
||||
public static String buildIconUrl(String baseUrl, String iconFileName) {
|
||||
if (StringUtils.isAnyBlank(baseUrl, iconFileName)) {
|
||||
return null;
|
||||
}
|
||||
return baseUrl + "/" + iconFileName;
|
||||
}
|
||||
}
|
||||
+336
@@ -0,0 +1,336 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ruoyi.browser.domain.BrowserProfile;
|
||||
import com.ruoyi.browser.domain.BrowserProfileGroup;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileGroupBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileGroupMoveBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileGroupVo;
|
||||
import com.ruoyi.browser.mapper.BrowserProfileGroupMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserProfileMapper;
|
||||
import com.ruoyi.browser.service.IBrowserProfileGroupService;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserProfileGroupServiceImpl implements IBrowserProfileGroupService {
|
||||
|
||||
private static final String DEFAULT_GROUP_FLAG = "1";
|
||||
private static final String NORMAL_GROUP_FLAG = "0";
|
||||
private static final String DEFAULT_GROUP_NAME = "默认分组";
|
||||
private static final String DEFAULT_GROUP_COLOR = "#2563eb";
|
||||
|
||||
private final BrowserProfileGroupMapper baseMapper;
|
||||
private final BrowserProfileMapper profileMapper;
|
||||
|
||||
@Override
|
||||
public List<BrowserProfileGroupVo> queryList(BrowserProfileGroupBo bo) {
|
||||
Long userId = resolveQueryUserId(bo.getUserId());
|
||||
prepareGroupsForUser(userId);
|
||||
List<BrowserProfileGroupVo> groups = baseMapper.selectVoList(new LambdaQueryWrapper<BrowserProfileGroup>()
|
||||
.eq(BrowserProfileGroup::getUserId, userId)
|
||||
.like(StringUtils.isNotBlank(bo.getGroupName()), BrowserProfileGroup::getGroupName, bo.getGroupName())
|
||||
.orderByDesc(BrowserProfileGroup::getIsDefault)
|
||||
.orderByAsc(BrowserProfileGroup::getSortOrder)
|
||||
.orderByAsc(BrowserProfileGroup::getCreateTime));
|
||||
Map<Long, Long> countMap = queryProfileCountMap(userId);
|
||||
groups.forEach(group -> group.setProfileCount(countMap.getOrDefault(group.getGroupId(), 0L)));
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserProfileGroupBo bo) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
prepareGroupsForUser(userId);
|
||||
BrowserProfileGroup entity = BeanUtil.toBean(bo, BrowserProfileGroup.class);
|
||||
entity.setGroupId(null);
|
||||
entity.setUserId(userId);
|
||||
entity.setIsDefault(NORMAL_GROUP_FLAG);
|
||||
entity.setGroupName(normalizeGroupName(bo.getGroupName()));
|
||||
entity.setGroupColor(normalizeGroupColor(bo.getGroupColor(), DEFAULT_GROUP_COLOR));
|
||||
entity.setSortOrder(ObjectUtil.defaultIfNull(bo.getSortOrder(), nextSortOrder(userId)));
|
||||
if (!checkNameUnique(entity)) {
|
||||
throw new ServiceException("分组名称已存在");
|
||||
}
|
||||
return baseMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserProfileGroupBo bo) {
|
||||
BrowserProfileGroup old = baseMapper.selectById(bo.getGroupId());
|
||||
checkAccess(old);
|
||||
BrowserProfileGroup entity = BeanUtil.toBean(bo, BrowserProfileGroup.class);
|
||||
entity.setUserId(old.getUserId());
|
||||
entity.setIsDefault(old.getIsDefault());
|
||||
entity.setGroupName(normalizeGroupName(StringUtils.blankToDefault(bo.getGroupName(), old.getGroupName())));
|
||||
entity.setGroupColor(normalizeGroupColor(StringUtils.blankToDefault(bo.getGroupColor(), old.getGroupColor()), DEFAULT_GROUP_COLOR));
|
||||
entity.setSortOrder(ObjectUtil.defaultIfNull(bo.getSortOrder(), old.getSortOrder()));
|
||||
if (!checkNameUnique(entity)) {
|
||||
throw new ServiceException("分组名称已存在");
|
||||
}
|
||||
boolean updated = baseMapper.updateById(entity) > 0;
|
||||
if (updated && !StringUtils.equals(old.getGroupName(), entity.getGroupName())) {
|
||||
syncProfilesToGroupName(entity.getGroupId(), entity.getGroupName());
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Boolean deleteById(Long groupId) {
|
||||
BrowserProfileGroup entity = baseMapper.selectById(groupId);
|
||||
checkAccess(entity);
|
||||
if (DEFAULT_GROUP_FLAG.equals(entity.getIsDefault())) {
|
||||
throw new ServiceException("默认分组不允许删除");
|
||||
}
|
||||
BrowserProfileGroup defaultGroup = ensureDefaultGroup(entity.getUserId());
|
||||
moveProfilesToGroup(fetchProfilesByGroup(entity.getGroupId()), defaultGroup);
|
||||
return baseMapper.deleteById(groupId) > 0;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Boolean moveProfiles(BrowserProfileGroupMoveBo bo) {
|
||||
BrowserProfileGroup targetGroup = baseMapper.selectById(bo.getTargetGroupId());
|
||||
checkAccess(targetGroup);
|
||||
List<BrowserProfile> profiles = profileMapper.selectBatchIds(bo.getProfileIds());
|
||||
if (CollUtil.isEmpty(profiles) || profiles.size() != bo.getProfileIds().size()) {
|
||||
throw new ServiceException("存在环境数据不存在");
|
||||
}
|
||||
for (BrowserProfile profile : profiles) {
|
||||
checkProfileAccess(profile);
|
||||
if (!ObjectUtil.equal(profile.getUserId(), targetGroup.getUserId())) {
|
||||
throw new ServiceException("不能移动到其他用户的分组");
|
||||
}
|
||||
}
|
||||
moveProfilesToGroup(profiles, targetGroup);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserProfileGroup ensureDefaultGroup(Long userId) {
|
||||
BrowserProfileGroup group = baseMapper.selectOne(new LambdaQueryWrapper<BrowserProfileGroup>()
|
||||
.eq(BrowserProfileGroup::getUserId, userId)
|
||||
.eq(BrowserProfileGroup::getIsDefault, DEFAULT_GROUP_FLAG)
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isNotNull(group)) {
|
||||
return group;
|
||||
}
|
||||
BrowserProfileGroup existing = findByUserAndName(userId, DEFAULT_GROUP_NAME);
|
||||
if (ObjectUtil.isNotNull(existing)) {
|
||||
BrowserProfileGroup update = new BrowserProfileGroup();
|
||||
update.setGroupId(existing.getGroupId());
|
||||
update.setIsDefault(DEFAULT_GROUP_FLAG);
|
||||
update.setSortOrder(ObjectUtil.defaultIfNull(existing.getSortOrder(), 0));
|
||||
update.setGroupColor(normalizeGroupColor(existing.getGroupColor(), DEFAULT_GROUP_COLOR));
|
||||
baseMapper.updateById(update);
|
||||
existing.setIsDefault(DEFAULT_GROUP_FLAG);
|
||||
existing.setSortOrder(ObjectUtil.defaultIfNull(existing.getSortOrder(), 0));
|
||||
existing.setGroupColor(normalizeGroupColor(existing.getGroupColor(), DEFAULT_GROUP_COLOR));
|
||||
return existing;
|
||||
}
|
||||
BrowserProfileGroup entity = new BrowserProfileGroup();
|
||||
entity.setUserId(userId);
|
||||
entity.setGroupName(DEFAULT_GROUP_NAME);
|
||||
entity.setIsDefault(DEFAULT_GROUP_FLAG);
|
||||
entity.setGroupColor(DEFAULT_GROUP_COLOR);
|
||||
entity.setSortOrder(0);
|
||||
baseMapper.insert(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void prepareGroupsForUser(Long userId) {
|
||||
if (ObjectUtil.isNull(userId)) {
|
||||
return;
|
||||
}
|
||||
BrowserProfileGroup defaultGroup = ensureDefaultGroup(userId);
|
||||
syncLegacyProfiles(userId, defaultGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserProfileGroup resolveGroupForProfile(Long userId, Long groupId, String groupName) {
|
||||
prepareGroupsForUser(userId);
|
||||
if (ObjectUtil.isNotNull(groupId)) {
|
||||
BrowserProfileGroup group = baseMapper.selectById(groupId);
|
||||
if (ObjectUtil.isNull(group) || !ObjectUtil.equal(group.getUserId(), userId)) {
|
||||
throw new ServiceException("分组数据不存在或无权限访问");
|
||||
}
|
||||
return group;
|
||||
}
|
||||
if (StringUtils.isNotBlank(groupName)) {
|
||||
String normalizedName = normalizeGroupName(groupName);
|
||||
BrowserProfileGroup exists = findByUserAndName(userId, normalizedName);
|
||||
return ObjectUtil.isNotNull(exists) ? exists : createGroup(userId, normalizedName, NORMAL_GROUP_FLAG);
|
||||
}
|
||||
return ensureDefaultGroup(userId);
|
||||
}
|
||||
|
||||
private void syncLegacyProfiles(Long userId, BrowserProfileGroup defaultGroup) {
|
||||
List<BrowserProfile> legacyProfiles = profileMapper.selectList(new LambdaQueryWrapper<BrowserProfile>()
|
||||
.eq(BrowserProfile::getUserId, userId)
|
||||
.isNull(BrowserProfile::getGroupId));
|
||||
if (CollUtil.isEmpty(legacyProfiles)) {
|
||||
return;
|
||||
}
|
||||
for (BrowserProfile profile : legacyProfiles) {
|
||||
BrowserProfileGroup targetGroup = StringUtils.isNotBlank(profile.getGroupName())
|
||||
? findOrCreateNamedGroup(userId, profile.getGroupName())
|
||||
: defaultGroup;
|
||||
BrowserProfile update = new BrowserProfile();
|
||||
update.setProfileId(profile.getProfileId());
|
||||
update.setGroupId(targetGroup.getGroupId());
|
||||
update.setGroupName(targetGroup.getGroupName());
|
||||
profileMapper.updateById(update);
|
||||
}
|
||||
}
|
||||
|
||||
private BrowserProfileGroup findOrCreateNamedGroup(Long userId, String groupName) {
|
||||
String normalizedName = normalizeGroupName(groupName);
|
||||
BrowserProfileGroup exists = findByUserAndName(userId, normalizedName);
|
||||
return ObjectUtil.isNotNull(exists) ? exists : createGroup(userId, normalizedName, NORMAL_GROUP_FLAG);
|
||||
}
|
||||
|
||||
private BrowserProfileGroup createGroup(Long userId, String groupName, String isDefault) {
|
||||
BrowserProfileGroup entity = new BrowserProfileGroup();
|
||||
entity.setUserId(userId);
|
||||
entity.setGroupName(groupName);
|
||||
entity.setIsDefault(isDefault);
|
||||
entity.setGroupColor(DEFAULT_GROUP_COLOR);
|
||||
entity.setSortOrder(DEFAULT_GROUP_FLAG.equals(isDefault) ? 0 : nextSortOrder(userId));
|
||||
baseMapper.insert(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
private BrowserProfileGroup findByUserAndName(Long userId, String groupName) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<BrowserProfileGroup>()
|
||||
.eq(BrowserProfileGroup::getUserId, userId)
|
||||
.eq(BrowserProfileGroup::getGroupName, groupName)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
private int nextSortOrder(Long userId) {
|
||||
BrowserProfileGroup lastGroup = baseMapper.selectOne(new LambdaQueryWrapper<BrowserProfileGroup>()
|
||||
.eq(BrowserProfileGroup::getUserId, userId)
|
||||
.orderByDesc(BrowserProfileGroup::getSortOrder)
|
||||
.last("limit 1"));
|
||||
return ObjectUtil.isNull(lastGroup) || ObjectUtil.isNull(lastGroup.getSortOrder())
|
||||
? 10
|
||||
: lastGroup.getSortOrder() + 10;
|
||||
}
|
||||
|
||||
private Map<Long, Long> queryProfileCountMap(Long userId) {
|
||||
List<Map<String, Object>> rows = profileMapper.selectMaps(new QueryWrapper<BrowserProfile>()
|
||||
.select("group_id", "count(*) as total")
|
||||
.eq("user_id", userId)
|
||||
.isNotNull("group_id")
|
||||
.groupBy("group_id"));
|
||||
Map<Long, Long> result = new HashMap<>();
|
||||
for (Map<String, Object> row : rows) {
|
||||
Object groupIdValue = row.get("group_id");
|
||||
Object totalValue = row.get("total");
|
||||
if (groupIdValue instanceof Number && totalValue instanceof Number) {
|
||||
result.put(((Number) groupIdValue).longValue(), ((Number) totalValue).longValue());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<BrowserProfile> fetchProfilesByGroup(Long groupId) {
|
||||
return profileMapper.selectList(new LambdaQueryWrapper<BrowserProfile>()
|
||||
.eq(BrowserProfile::getGroupId, groupId));
|
||||
}
|
||||
|
||||
private void moveProfilesToGroup(Collection<BrowserProfile> profiles, BrowserProfileGroup targetGroup) {
|
||||
if (CollUtil.isEmpty(profiles)) {
|
||||
return;
|
||||
}
|
||||
for (BrowserProfile profile : profiles) {
|
||||
BrowserProfile update = new BrowserProfile();
|
||||
update.setProfileId(profile.getProfileId());
|
||||
update.setGroupId(targetGroup.getGroupId());
|
||||
update.setGroupName(targetGroup.getGroupName());
|
||||
profileMapper.updateById(update);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncProfilesToGroupName(Long groupId, String groupName) {
|
||||
List<BrowserProfile> profiles = fetchProfilesByGroup(groupId);
|
||||
for (BrowserProfile profile : profiles) {
|
||||
BrowserProfile update = new BrowserProfile();
|
||||
update.setProfileId(profile.getProfileId());
|
||||
update.setGroupName(groupName);
|
||||
profileMapper.updateById(update);
|
||||
}
|
||||
}
|
||||
|
||||
private Long resolveQueryUserId(Long requestedUserId) {
|
||||
if (isSystemAdmin() && ObjectUtil.isNotNull(requestedUserId)) {
|
||||
return requestedUserId;
|
||||
}
|
||||
return LoginHelper.getUserId();
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserProfileGroup entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
throw new ServiceException("分组数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), entity.getUserId())) {
|
||||
throw new ServiceException("无权限操作该分组");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkProfileAccess(BrowserProfile entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
throw new ServiceException("环境数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), entity.getUserId())) {
|
||||
throw new ServiceException("无权限操作该环境数据");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkNameUnique(BrowserProfileGroup entity) {
|
||||
long groupId = ObjectUtil.isNull(entity.getGroupId()) ? -1L : entity.getGroupId();
|
||||
return !baseMapper.exists(new LambdaQueryWrapper<BrowserProfileGroup>()
|
||||
.eq(BrowserProfileGroup::getUserId, entity.getUserId())
|
||||
.eq(BrowserProfileGroup::getGroupName, entity.getGroupName())
|
||||
.ne(ObjectUtil.isNotNull(entity.getGroupId()), BrowserProfileGroup::getGroupId, groupId));
|
||||
}
|
||||
|
||||
private String normalizeGroupName(String groupName) {
|
||||
String normalized = StringUtils.trim(groupName);
|
||||
if (StringUtils.isBlank(normalized)) {
|
||||
throw new ServiceException("分组名称不能为空");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
private String normalizeGroupColor(String groupColor, String fallback) {
|
||||
String normalized = StringUtils.trim(groupColor);
|
||||
if (StringUtils.isBlank(normalized)) {
|
||||
return fallback;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
private boolean isSystemAdmin() {
|
||||
return LoginHelper.isAdmin() && LoginHelper.getUserType() == UserType.SYS_USER;
|
||||
}
|
||||
}
|
||||
+457
@@ -0,0 +1,457 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.browser.domain.BrowserFingerprint;
|
||||
import com.ruoyi.browser.domain.BrowserKernelPackage;
|
||||
import com.ruoyi.browser.domain.BrowserMemberUser;
|
||||
import com.ruoyi.browser.domain.BrowserPlatform;
|
||||
import com.ruoyi.browser.domain.BrowserProfile;
|
||||
import com.ruoyi.browser.domain.BrowserProfileGroup;
|
||||
import com.ruoyi.browser.domain.BrowserProxy;
|
||||
import com.ruoyi.browser.domain.bo.BrowserFingerprintBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileQuickSaveBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileQuickSaveVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileVo;
|
||||
import com.ruoyi.browser.mapper.BrowserFingerprintMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserKernelPackageMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserMemberUserMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserPlatformMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserProfileMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserProxyMapper;
|
||||
import com.ruoyi.browser.service.IBrowserProfileGroupService;
|
||||
import com.ruoyi.browser.service.IBrowserProfileService;
|
||||
import com.ruoyi.browser.service.IBrowserRuntimeService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StreamUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserProfileServiceImpl implements IBrowserProfileService {
|
||||
|
||||
private final BrowserProfileMapper baseMapper;
|
||||
private final BrowserFingerprintMapper fingerprintMapper;
|
||||
private final BrowserKernelPackageMapper kernelPackageMapper;
|
||||
private final BrowserProxyMapper proxyMapper;
|
||||
private final BrowserPlatformMapper platformMapper;
|
||||
private final BrowserMemberUserMapper memberUserMapper;
|
||||
private final IBrowserProfileGroupService profileGroupService;
|
||||
private final IBrowserRuntimeService runtimeService;
|
||||
private final ISysConfigService configService;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BrowserProfileVo> queryPageList(BrowserProfileBo bo, PageQuery pageQuery) {
|
||||
prepareGroupsForQuery(bo);
|
||||
LambdaQueryWrapper<BrowserProfile> lqw = buildQueryWrapper(bo);
|
||||
Page<BrowserProfileVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
List<BrowserProfileVo> records = result.getRecords();
|
||||
enrichMemberInfo(records);
|
||||
enrichPlatformInfo(records);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserProfileVo queryById(Long profileId) {
|
||||
BrowserProfileVo vo = baseMapper.selectVoById(profileId);
|
||||
checkAccess(vo);
|
||||
if (ObjectUtil.isNotNull(vo) && ObjectUtil.isNotNull(vo.getUserId()) && ObjectUtil.isNull(vo.getGroupId())) {
|
||||
profileGroupService.prepareGroupsForUser(vo.getUserId());
|
||||
vo = baseMapper.selectVoById(profileId);
|
||||
}
|
||||
enrichMemberInfo(CollUtil.newArrayList(vo));
|
||||
enrichPlatformInfo(CollUtil.newArrayList(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserProfileBo bo) {
|
||||
BrowserProfile entity = buildProfileEntity(bo, null);
|
||||
entity.setProfileId(null);
|
||||
entity.setUserId(LoginHelper.getUserId());
|
||||
if (!checkNameUnique(entity)) {
|
||||
throw new ServiceException("环境名称已存在");
|
||||
}
|
||||
return baseMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserProfileBo bo) {
|
||||
BrowserProfile old = baseMapper.selectById(bo.getProfileId());
|
||||
checkAccess(old);
|
||||
BrowserProfile entity = buildProfileEntity(bo, old);
|
||||
entity.setUserId(old.getUserId());
|
||||
if (!checkNameUnique(entity)) {
|
||||
throw new ServiceException("环境名称已存在");
|
||||
}
|
||||
return persistProfileUpdate(entity) > 0;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public BrowserProfileQuickSaveVo quickCreate(BrowserProfileQuickSaveBo bo) {
|
||||
BrowserProfile profile = buildProfileEntity(bo.getProfile(), null);
|
||||
profile.setUserId(LoginHelper.getUserId());
|
||||
if (!checkNameUnique(profile)) {
|
||||
throw new ServiceException("环境名称已存在");
|
||||
}
|
||||
baseMapper.insert(profile);
|
||||
|
||||
BrowserFingerprint fingerprint = buildFingerprintEntity(bo.getFingerprint(), profile, null);
|
||||
fingerprintMapper.insert(fingerprint);
|
||||
|
||||
profile.setFingerprintId(fingerprint.getFingerprintId());
|
||||
baseMapper.updateById(profile);
|
||||
return new BrowserProfileQuickSaveVo(profile.getProfileId(), fingerprint.getFingerprintId());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public BrowserProfileQuickSaveVo quickUpdate(BrowserProfileQuickSaveBo bo) {
|
||||
BrowserProfileBo profileBo = bo.getProfile();
|
||||
if (ObjectUtil.isNull(profileBo.getProfileId())) {
|
||||
throw new ServiceException("环境主键不能为空");
|
||||
}
|
||||
|
||||
BrowserProfile oldProfile = baseMapper.selectById(profileBo.getProfileId());
|
||||
checkAccess(oldProfile);
|
||||
|
||||
BrowserProfile profile = buildProfileEntity(profileBo, oldProfile);
|
||||
profile.setUserId(oldProfile.getUserId());
|
||||
if (!checkNameUnique(profile)) {
|
||||
throw new ServiceException("环境名称已存在");
|
||||
}
|
||||
persistProfileUpdate(profile);
|
||||
|
||||
BrowserFingerprint currentFingerprint = resolveFingerprint(oldProfile);
|
||||
BrowserFingerprint fingerprint = buildFingerprintEntity(
|
||||
bo.getFingerprint(),
|
||||
profile,
|
||||
currentFingerprint
|
||||
);
|
||||
|
||||
if (ObjectUtil.isNull(currentFingerprint)) {
|
||||
fingerprintMapper.insert(fingerprint);
|
||||
profile.setFingerprintId(fingerprint.getFingerprintId());
|
||||
baseMapper.updateById(profile);
|
||||
} else {
|
||||
fingerprintMapper.updateById(fingerprint);
|
||||
profile.setFingerprintId(fingerprint.getFingerprintId());
|
||||
if (ObjectUtil.isNull(oldProfile.getFingerprintId())) {
|
||||
baseMapper.updateById(profile);
|
||||
}
|
||||
}
|
||||
return new BrowserProfileQuickSaveVo(
|
||||
oldProfile.getProfileId(),
|
||||
ObjectUtil.defaultIfNull(profile.getFingerprintId(), fingerprint.getFingerprintId())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
for (Long id : ids) {
|
||||
checkAccess(baseMapper.selectById(id));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(Long profileId) {
|
||||
runtimeService.launch(profileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close(Long profileId) {
|
||||
return runtimeService.close(profileId);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BrowserProfile> buildQueryWrapper(BrowserProfileBo bo) {
|
||||
LambdaQueryWrapper<BrowserProfile> lqw = new LambdaQueryWrapper<>();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if (isSystemAdmin()) {
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getUserId()), BrowserProfile::getUserId, bo.getUserId());
|
||||
if (StringUtils.isNotBlank(bo.getMemberUsername())) {
|
||||
BrowserMemberUser memberUser = memberUserMapper.selectOne(new LambdaQueryWrapper<BrowserMemberUser>()
|
||||
.select(BrowserMemberUser::getMemberId)
|
||||
.eq(BrowserMemberUser::getUsername, bo.getMemberUsername()));
|
||||
lqw.eq(BrowserProfile::getUserId, ObjectUtil.isNull(memberUser) ? -1L : memberUser.getMemberId());
|
||||
}
|
||||
} else {
|
||||
lqw.eq(BrowserProfile::getUserId, userId);
|
||||
}
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProfileName()), BrowserProfile::getProfileName, bo.getProfileName());
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getGroupId()), BrowserProfile::getGroupId, bo.getGroupId());
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getPlatformId()), BrowserProfile::getPlatformId, bo.getPlatformId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBrowserEngine()), BrowserProfile::getBrowserEngine, bo.getBrowserEngine());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), BrowserProfile::getStatus, bo.getStatus());
|
||||
lqw.orderByDesc(BrowserProfile::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserProfileVo vo) {
|
||||
if (ObjectUtil.isNull(vo)) {
|
||||
throw new ServiceException("环境数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), vo.getUserId())) {
|
||||
throw new ServiceException("无权限访问该环境数据");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserProfile entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
throw new ServiceException("环境数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), entity.getUserId())) {
|
||||
throw new ServiceException("无权限操作该环境数据");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserFingerprint entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
throw new ServiceException("指纹数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), entity.getUserId())) {
|
||||
throw new ServiceException("无权限操作该指纹数据");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSystemAdmin() {
|
||||
return LoginHelper.isAdmin() && LoginHelper.getUserType() == UserType.SYS_USER;
|
||||
}
|
||||
|
||||
private void enrichMemberInfo(List<BrowserProfileVo> rows) {
|
||||
if (CollUtil.isEmpty(rows)) {
|
||||
return;
|
||||
}
|
||||
List<Long> memberIds = StreamUtils.toList(rows, BrowserProfileVo::getUserId);
|
||||
Map<Long, BrowserMemberUser> memberMap = StreamUtils.toMap(
|
||||
memberUserMapper.selectBatchIds(memberIds),
|
||||
BrowserMemberUser::getMemberId,
|
||||
member -> member
|
||||
);
|
||||
rows.forEach(item -> {
|
||||
BrowserMemberUser member = memberMap.get(item.getUserId());
|
||||
if (ObjectUtil.isNotNull(member)) {
|
||||
item.setMemberUsername(member.getUsername());
|
||||
item.setMemberNickName(member.getNickName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enrichPlatformInfo(List<BrowserProfileVo> rows) {
|
||||
if (CollUtil.isEmpty(rows)) {
|
||||
return;
|
||||
}
|
||||
Set<Long> platformIds = StreamUtils.toSet(rows, BrowserProfileVo::getPlatformId);
|
||||
platformIds.remove(null);
|
||||
Map<Long, BrowserPlatform> platformMap = StreamUtils.toMap(
|
||||
platformIds.isEmpty() ? CollUtil.newArrayList() : platformMapper.selectBatchIds(platformIds),
|
||||
BrowserPlatform::getPlatformId,
|
||||
item -> item
|
||||
);
|
||||
String iconBaseUrl = BrowserPlatformServiceImpl.normalizeBaseUrl(
|
||||
configService.selectConfigByKey(BrowserPlatformServiceImpl.ICON_BASE_URL_KEY)
|
||||
);
|
||||
rows.forEach(item -> {
|
||||
BrowserPlatform platform = platformMap.get(item.getPlatformId());
|
||||
if (ObjectUtil.isNotNull(platform)) {
|
||||
item.setPlatform(platform.getPlatformName());
|
||||
item.setPlatformWebsiteUrl(platform.getWebsiteUrl());
|
||||
item.setPlatformIconFileName(platform.getIconFileName());
|
||||
item.setPlatformIconUrl(BrowserPlatformServiceImpl.buildIconUrl(iconBaseUrl, platform.getIconFileName()));
|
||||
}
|
||||
item.setResolvedWebsiteUrl(resolveWebsiteUrl(item.getCustomWebsiteUrl(), item.getPlatformWebsiteUrl()));
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkNameUnique(BrowserProfile entity) {
|
||||
long profileId = ObjectUtil.isNull(entity.getProfileId()) ? -1L : entity.getProfileId();
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<BrowserProfile>()
|
||||
.eq(BrowserProfile::getUserId, entity.getUserId())
|
||||
.eq(BrowserProfile::getProfileName, entity.getProfileName())
|
||||
.ne(ObjectUtil.isNotNull(entity.getProfileId()), BrowserProfile::getProfileId, profileId));
|
||||
return !exist;
|
||||
}
|
||||
|
||||
private BrowserProfile buildProfileEntity(BrowserProfileBo bo, BrowserProfile oldProfile) {
|
||||
BrowserProfile entity = BeanUtil.toBean(bo, BrowserProfile.class);
|
||||
BrowserProfileGroup group = resolveProfileGroup(bo, oldProfile);
|
||||
entity.setGroupId(group.getGroupId());
|
||||
entity.setGroupName(group.getGroupName());
|
||||
if (ObjectUtil.isNotNull(oldProfile)) {
|
||||
entity.setProfileId(oldProfile.getProfileId());
|
||||
entity.setFingerprintId(oldProfile.getFingerprintId());
|
||||
entity.setLastLaunchTime(oldProfile.getLastLaunchTime());
|
||||
}
|
||||
BrowserPlatform platform = resolvePlatform(bo.getPlatformId());
|
||||
if (ObjectUtil.isNotNull(platform)) {
|
||||
entity.setPlatformId(platform.getPlatformId());
|
||||
entity.setPlatform(platform.getPlatformName());
|
||||
entity.setCustomWebsiteUrl(null);
|
||||
} else {
|
||||
String customWebsiteUrl = normalizeOptionalWebsiteUrl(bo.getCustomWebsiteUrl());
|
||||
entity.setPlatformId(null);
|
||||
entity.setPlatform(StringUtils.isBlank(bo.getPlatform()) ? "其它" : StringUtils.trim(bo.getPlatform()));
|
||||
entity.setCustomWebsiteUrl(customWebsiteUrl);
|
||||
}
|
||||
entity.setBrowserOsType(StringUtils.lowerCase(StringUtils.trim(entity.getBrowserOsType())));
|
||||
entity.setBrowserArchType(StringUtils.lowerCase(StringUtils.trim(entity.getBrowserArchType())));
|
||||
entity.setBrowserVersion(resolveBrowserVersion(entity));
|
||||
BrowserProxy proxy = resolveProxy(bo.getProxyId());
|
||||
if (ObjectUtil.isNull(proxy)) {
|
||||
entity.setProxyId(null);
|
||||
entity.setProxyName(null);
|
||||
entity.setProxyType(null);
|
||||
entity.setProxyHost(null);
|
||||
entity.setProxyPort(null);
|
||||
} else {
|
||||
entity.setProxyId(proxy.getProxyId());
|
||||
entity.setProxyName(proxy.getProxyName());
|
||||
entity.setProxyType(proxy.getProxyType());
|
||||
entity.setProxyHost(proxy.getHost());
|
||||
entity.setProxyPort(proxy.getPort());
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
private int persistProfileUpdate(BrowserProfile profile) {
|
||||
int rows = baseMapper.updateById(profile);
|
||||
if (ObjectUtil.isNull(profile.getProxyId())) {
|
||||
rows += baseMapper.update(
|
||||
null,
|
||||
new LambdaUpdateWrapper<BrowserProfile>()
|
||||
.eq(BrowserProfile::getProfileId, profile.getProfileId())
|
||||
.set(BrowserProfile::getProxyId, null)
|
||||
.set(BrowserProfile::getProxyName, null)
|
||||
);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private BrowserProfileGroup resolveProfileGroup(BrowserProfileBo bo, BrowserProfile oldProfile) {
|
||||
Long userId = ObjectUtil.isNotNull(oldProfile) ? oldProfile.getUserId() : LoginHelper.getUserId();
|
||||
Long groupId = bo.getGroupId();
|
||||
String groupName = bo.getGroupName();
|
||||
if (ObjectUtil.isNull(groupId) && StringUtils.isBlank(groupName) && ObjectUtil.isNotNull(oldProfile)) {
|
||||
groupId = oldProfile.getGroupId();
|
||||
groupName = oldProfile.getGroupName();
|
||||
}
|
||||
return profileGroupService.resolveGroupForProfile(userId, groupId, groupName);
|
||||
}
|
||||
|
||||
private void prepareGroupsForQuery(BrowserProfileBo bo) {
|
||||
if (!isSystemAdmin()) {
|
||||
profileGroupService.prepareGroupsForUser(LoginHelper.getUserId());
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(bo.getUserId())) {
|
||||
profileGroupService.prepareGroupsForUser(bo.getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
private BrowserFingerprint buildFingerprintEntity(BrowserFingerprintBo bo, BrowserProfile profile, BrowserFingerprint oldFingerprint) {
|
||||
BrowserFingerprint entity = BeanUtil.toBean(bo, BrowserFingerprint.class);
|
||||
entity.setBrowserFamily(StringUtils.blankToDefault(profile.getBrowserEngine(), "chromium"));
|
||||
entity.setBrowserVersion(profile.getBrowserVersion());
|
||||
entity.setGeoMode(StringUtils.defaultIfBlank(entity.getGeoMode(), "auto"));
|
||||
entity.setProfileId(profile.getProfileId());
|
||||
entity.setUserId(LoginHelper.getUserId());
|
||||
if (ObjectUtil.isNotNull(oldFingerprint)) {
|
||||
checkAccess(oldFingerprint);
|
||||
entity.setFingerprintId(oldFingerprint.getFingerprintId());
|
||||
} else {
|
||||
entity.setFingerprintId(null);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
private String resolveBrowserVersion(BrowserProfile profile) {
|
||||
String version = StringUtils.trim(profile.getBrowserVersion());
|
||||
if (StringUtils.isNotBlank(version)) {
|
||||
return version;
|
||||
}
|
||||
if (StringUtils.isAnyBlank(profile.getBrowserEngine(), profile.getBrowserOsType(), profile.getBrowserArchType())) {
|
||||
return version;
|
||||
}
|
||||
BrowserKernelPackage kernelPackage = kernelPackageMapper.selectOne(new LambdaQueryWrapper<BrowserKernelPackage>()
|
||||
.eq(BrowserKernelPackage::getBrowserEngine, profile.getBrowserEngine())
|
||||
.eq(BrowserKernelPackage::getOsType, profile.getBrowserOsType())
|
||||
.eq(BrowserKernelPackage::getArchType, profile.getBrowserArchType())
|
||||
.eq(BrowserKernelPackage::getIsDefault, "1")
|
||||
.eq(BrowserKernelPackage::getStatus, "0")
|
||||
.last("limit 1"));
|
||||
return ObjectUtil.isNull(kernelPackage) ? version : kernelPackage.getBrowserVersion();
|
||||
}
|
||||
|
||||
private BrowserProxy resolveProxy(Long proxyId) {
|
||||
if (ObjectUtil.isNull(proxyId)) {
|
||||
return null;
|
||||
}
|
||||
BrowserProxy proxy = proxyMapper.selectById(proxyId);
|
||||
if (ObjectUtil.isNull(proxy)) {
|
||||
throw new ServiceException("代理数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), proxy.getUserId())) {
|
||||
throw new ServiceException("无权限使用该代理");
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private BrowserFingerprint resolveFingerprint(BrowserProfile profile) {
|
||||
if (ObjectUtil.isNull(profile.getFingerprintId())) {
|
||||
return fingerprintMapper.selectOne(new LambdaQueryWrapper<BrowserFingerprint>()
|
||||
.eq(BrowserFingerprint::getUserId, profile.getUserId())
|
||||
.eq(BrowserFingerprint::getProfileId, profile.getProfileId())
|
||||
.last("limit 1"));
|
||||
}
|
||||
return fingerprintMapper.selectById(profile.getFingerprintId());
|
||||
}
|
||||
|
||||
private BrowserPlatform resolvePlatform(Long platformId) {
|
||||
if (ObjectUtil.isNull(platformId)) {
|
||||
return null;
|
||||
}
|
||||
BrowserPlatform platform = platformMapper.selectById(platformId);
|
||||
if (ObjectUtil.isNull(platform)) {
|
||||
throw new ServiceException("平台数据不存在");
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
private String normalizeOptionalWebsiteUrl(String value) {
|
||||
String normalized = StringUtils.trim(value);
|
||||
if (StringUtils.isBlank(normalized)) {
|
||||
return null;
|
||||
}
|
||||
return BrowserPlatformServiceImpl.normalizeWebsiteUrl(normalized, "自定义网站地址");
|
||||
}
|
||||
|
||||
private String resolveWebsiteUrl(String customWebsiteUrl, String platformWebsiteUrl) {
|
||||
if (StringUtils.isNotBlank(customWebsiteUrl)) {
|
||||
return customWebsiteUrl;
|
||||
}
|
||||
String normalized = StringUtils.trim(platformWebsiteUrl);
|
||||
return StringUtils.isBlank(normalized) ? null : normalized;
|
||||
}
|
||||
}
|
||||
+390
@@ -0,0 +1,390 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.maxmind.db.CHMCache;
|
||||
import com.maxmind.geoip2.DatabaseReader;
|
||||
import com.maxmind.geoip2.exception.AddressNotFoundException;
|
||||
import com.maxmind.geoip2.model.CountryResponse;
|
||||
import com.maxmind.geoip2.record.City;
|
||||
import com.maxmind.geoip2.record.Country;
|
||||
import com.maxmind.geoip2.record.Subdivision;
|
||||
import com.maxmind.geoip2.model.CityResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.browser.domain.BrowserProxy;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProxyBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProxyVo;
|
||||
import com.ruoyi.browser.mapper.BrowserProxyMapper;
|
||||
import com.ruoyi.browser.service.IBrowserProxyService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserProxyServiceImpl implements IBrowserProxyService {
|
||||
|
||||
private final BrowserProxyMapper baseMapper;
|
||||
|
||||
@Value("${browser.geoip-db-path:}")
|
||||
private String geoIpDbPath;
|
||||
|
||||
private volatile DatabaseReader geoIpReader;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<BrowserProxyVo> queryPageList(BrowserProxyBo bo, PageQuery pageQuery) {
|
||||
Page<BrowserProxyVo> result = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo));
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserProxyVo queryById(Long proxyId) {
|
||||
BrowserProxyVo vo = baseMapper.selectVoById(proxyId);
|
||||
checkAccess(vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(BrowserProxyBo bo) {
|
||||
BrowserProxy entity = BeanUtil.toBean(bo, BrowserProxy.class);
|
||||
entity.setUserId(LoginHelper.getUserId());
|
||||
normalizeProxy(entity);
|
||||
if (!checkUnique(entity)) {
|
||||
throw new ServiceException("代理名称已存在");
|
||||
}
|
||||
return baseMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(BrowserProxyBo bo) {
|
||||
BrowserProxy entity = BeanUtil.toBean(bo, BrowserProxy.class);
|
||||
BrowserProxy old = baseMapper.selectById(entity.getProxyId());
|
||||
checkAccess(old);
|
||||
entity.setUserId(old.getUserId());
|
||||
normalizeProxy(entity, old);
|
||||
if (!checkUnique(entity)) {
|
||||
throw new ServiceException("代理名称已存在");
|
||||
}
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean refreshGeoById(Long proxyId) {
|
||||
BrowserProxy entity = baseMapper.selectById(proxyId);
|
||||
checkAccess(entity);
|
||||
normalizeProxyGeo(entity, null);
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
for (Long id : ids) {
|
||||
checkAccess(baseMapper.selectById(id));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BrowserProxy> buildQueryWrapper(BrowserProxyBo bo) {
|
||||
LambdaQueryWrapper<BrowserProxy> lqw = new LambdaQueryWrapper<>();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if (isSystemAdmin()) {
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getUserId()), BrowserProxy::getUserId, bo.getUserId());
|
||||
} else {
|
||||
lqw.eq(BrowserProxy::getUserId, userId);
|
||||
}
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProxyName()), BrowserProxy::getProxyName, bo.getProxyName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProxyType()), BrowserProxy::getProxyType, bo.getProxyType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getGeoCountry()), BrowserProxy::getGeoCountry, bo.getGeoCountry());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getGeoRegion()), BrowserProxy::getGeoRegion, bo.getGeoRegion());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getGeoCity()), BrowserProxy::getGeoCity, bo.getGeoCity());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), BrowserProxy::getStatus, bo.getStatus());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserProxyVo vo) {
|
||||
if (ObjectUtil.isNull(vo)) {
|
||||
throw new ServiceException("代理数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), vo.getUserId())) {
|
||||
throw new ServiceException("无权限访问该代理数据");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAccess(BrowserProxy entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
throw new ServiceException("代理数据不存在");
|
||||
}
|
||||
if (!isSystemAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), entity.getUserId())) {
|
||||
throw new ServiceException("无权限操作该代理数据");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSystemAdmin() {
|
||||
return LoginHelper.isAdmin() && LoginHelper.getUserType() == UserType.SYS_USER;
|
||||
}
|
||||
|
||||
private void normalizeProxy(BrowserProxy entity) {
|
||||
normalizeProxy(entity, null);
|
||||
}
|
||||
|
||||
private void normalizeProxy(BrowserProxy entity, BrowserProxy old) {
|
||||
String proxyType = StringUtils.blankToDefault(entity.getProxyType(), "").trim().toLowerCase();
|
||||
entity.setProxyType(proxyType);
|
||||
entity.setProxyName(StringUtils.trim(entity.getProxyName()));
|
||||
entity.setHost(StringUtils.trim(entity.getHost()));
|
||||
entity.setUsername(StringUtils.trim(entity.getUsername()));
|
||||
if ("direct".equals(proxyType)) {
|
||||
entity.setHost(null);
|
||||
entity.setPort(null);
|
||||
entity.setGeoCountry(null);
|
||||
entity.setGeoRegion(null);
|
||||
entity.setGeoCity(null);
|
||||
entity.setUsername(null);
|
||||
entity.setPasswordEncrypted(null);
|
||||
return;
|
||||
}
|
||||
if (!("http".equals(proxyType) || "https".equals(proxyType) || "socks5".equals(proxyType))) {
|
||||
throw new ServiceException("代理类型仅支持 direct/http/https/socks5");
|
||||
}
|
||||
if (StringUtils.isBlank(entity.getHost())) {
|
||||
throw new ServiceException("IP代理模式下代理主机不能为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(entity.getPort())) {
|
||||
throw new ServiceException("IP代理模式下代理端口不能为空");
|
||||
}
|
||||
normalizeProxyGeo(entity, old);
|
||||
}
|
||||
|
||||
private boolean checkUnique(BrowserProxy entity) {
|
||||
long proxyId = ObjectUtil.isNull(entity.getProxyId()) ? -1L : entity.getProxyId();
|
||||
return !baseMapper.exists(new LambdaQueryWrapper<BrowserProxy>()
|
||||
.eq(BrowserProxy::getUserId, entity.getUserId())
|
||||
.eq(BrowserProxy::getProxyName, entity.getProxyName())
|
||||
.ne(ObjectUtil.isNotNull(entity.getProxyId()), BrowserProxy::getProxyId, proxyId));
|
||||
}
|
||||
|
||||
private void normalizeProxyGeo(BrowserProxy entity, BrowserProxy old) {
|
||||
GeoInfo fallback = GeoInfo.fromEntity(old != null ? old : entity);
|
||||
GeoInfo resolved = resolveGeoInfo(entity.getHost(), fallback);
|
||||
entity.setGeoCountry(resolved.geoCountry);
|
||||
entity.setGeoRegion(resolved.geoRegion);
|
||||
entity.setGeoCity(resolved.geoCity);
|
||||
}
|
||||
|
||||
private GeoInfo resolveGeoInfo(String host, GeoInfo fallback) {
|
||||
GeoInfo normalizedFallback = GeoInfo.normalized(fallback);
|
||||
if (StringUtils.isBlank(host)) {
|
||||
return normalizedFallback;
|
||||
}
|
||||
try {
|
||||
DatabaseReader reader = getGeoIpReader();
|
||||
if (ObjectUtil.isNull(reader)) {
|
||||
return normalizedFallback;
|
||||
}
|
||||
InetAddress address = resolveHostAddress(host);
|
||||
if (ObjectUtil.isNull(address)) {
|
||||
return normalizedFallback;
|
||||
}
|
||||
try {
|
||||
CityResponse response = reader.city(address);
|
||||
return GeoInfo.fromResponse(response, normalizedFallback);
|
||||
} catch (UnsupportedOperationException ignored) {
|
||||
CountryResponse response = reader.country(address);
|
||||
return GeoInfo.fromCountryResponse(response, normalizedFallback);
|
||||
}
|
||||
} catch (AddressNotFoundException ignored) {
|
||||
return normalizedFallback;
|
||||
} catch (Exception ignored) {
|
||||
return normalizedFallback;
|
||||
}
|
||||
}
|
||||
|
||||
private InetAddress resolveHostAddress(String host) {
|
||||
try {
|
||||
InetAddress[] addresses = InetAddress.getAllByName(host);
|
||||
if (addresses == null || addresses.length == 0) {
|
||||
return null;
|
||||
}
|
||||
for (InetAddress address : addresses) {
|
||||
if (address instanceof Inet6Address) {
|
||||
return address;
|
||||
}
|
||||
if (StringUtils.equals(host, address.getHostAddress())) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
return addresses[0];
|
||||
} catch (UnknownHostException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private DatabaseReader getGeoIpReader() {
|
||||
if (ObjectUtil.isNotNull(geoIpReader)) {
|
||||
return geoIpReader;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (ObjectUtil.isNotNull(geoIpReader)) {
|
||||
return geoIpReader;
|
||||
}
|
||||
try {
|
||||
File dbFile = resolveGeoIpDbFile();
|
||||
if (ObjectUtil.isNotNull(dbFile) && dbFile.exists() && dbFile.isFile()) {
|
||||
geoIpReader = new DatabaseReader.Builder(dbFile)
|
||||
.withCache(new CHMCache())
|
||||
.build();
|
||||
return geoIpReader;
|
||||
}
|
||||
|
||||
InputStream inputStream = resolveGeoIpDbStream();
|
||||
if (ObjectUtil.isNull(inputStream)) {
|
||||
return null;
|
||||
}
|
||||
geoIpReader = new DatabaseReader.Builder(inputStream)
|
||||
.withCache(new CHMCache())
|
||||
.build();
|
||||
return geoIpReader;
|
||||
} catch (IOException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File resolveGeoIpDbFile() {
|
||||
if (StringUtils.isNotBlank(geoIpDbPath)) {
|
||||
return new File(geoIpDbPath.trim());
|
||||
}
|
||||
String[] candidates = {
|
||||
"GeoLite2-City.mmdb",
|
||||
"data/GeoLite2-City.mmdb",
|
||||
"geoip/GeoLite2-City.mmdb",
|
||||
"resources/GeoLite2-City.mmdb",
|
||||
"GeoLite2-Country.mmdb",
|
||||
"data/GeoLite2-Country.mmdb",
|
||||
"geoip/GeoLite2-Country.mmdb",
|
||||
"resources/GeoLite2-Country.mmdb"
|
||||
};
|
||||
for (String candidate : candidates) {
|
||||
File file = new File(candidate);
|
||||
if (file.exists() && file.isFile()) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private InputStream resolveGeoIpDbStream() throws IOException {
|
||||
String[] candidates = {
|
||||
"GeoLite2-City.mmdb",
|
||||
"GeoLite2-Country.mmdb"
|
||||
};
|
||||
for (String candidate : candidates) {
|
||||
ClassPathResource resource = new ClassPathResource(candidate);
|
||||
if (resource.exists()) {
|
||||
return resource.getInputStream();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
if (ObjectUtil.isNull(geoIpReader)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
geoIpReader.close();
|
||||
} catch (IOException ignored) {
|
||||
// ignore close failure
|
||||
}
|
||||
}
|
||||
|
||||
private static final class GeoInfo {
|
||||
private final String geoCountry;
|
||||
private final String geoRegion;
|
||||
private final String geoCity;
|
||||
|
||||
private GeoInfo(String geoCountry, String geoRegion, String geoCity) {
|
||||
this.geoCountry = geoCountry;
|
||||
this.geoRegion = geoRegion;
|
||||
this.geoCity = geoCity;
|
||||
}
|
||||
|
||||
private static GeoInfo fromEntity(BrowserProxy entity) {
|
||||
if (ObjectUtil.isNull(entity)) {
|
||||
return empty();
|
||||
}
|
||||
return new GeoInfo(entity.getGeoCountry(), entity.getGeoRegion(), entity.getGeoCity());
|
||||
}
|
||||
|
||||
private static GeoInfo fromResponse(CityResponse response, GeoInfo fallback) {
|
||||
if (ObjectUtil.isNull(response)) {
|
||||
return fallback;
|
||||
}
|
||||
Country country = response.getCountry();
|
||||
List<Subdivision> subdivisions = response.getSubdivisions();
|
||||
City city = response.getCity();
|
||||
String geoCountry = ObjectUtil.isNull(country) ? fallback.geoCountry : fallback.normalizeCountryCode(country.getIsoCode());
|
||||
String geoRegion = CollUtil.isEmpty(subdivisions)
|
||||
? fallback.geoRegion
|
||||
: fallback.normalizeGeoText(subdivisions.get(0).getName());
|
||||
String geoCity = ObjectUtil.isNull(city) ? fallback.geoCity : fallback.normalizeGeoText(city.getName());
|
||||
return new GeoInfo(geoCountry, geoRegion, geoCity);
|
||||
}
|
||||
|
||||
private static GeoInfo fromCountryResponse(CountryResponse response, GeoInfo fallback) {
|
||||
if (ObjectUtil.isNull(response)) {
|
||||
return fallback;
|
||||
}
|
||||
Country country = response.getCountry();
|
||||
String geoCountry = ObjectUtil.isNull(country) ? fallback.geoCountry : fallback.normalizeCountryCode(country.getIsoCode());
|
||||
return new GeoInfo(geoCountry, fallback.geoRegion, fallback.geoCity);
|
||||
}
|
||||
|
||||
private static GeoInfo normalized(GeoInfo info) {
|
||||
GeoInfo source = ObjectUtil.defaultIfNull(info, empty());
|
||||
return new GeoInfo(
|
||||
source.normalizeCountryCode(source.geoCountry),
|
||||
source.normalizeGeoText(source.geoRegion),
|
||||
source.normalizeGeoText(source.geoCity)
|
||||
);
|
||||
}
|
||||
|
||||
private static GeoInfo empty() {
|
||||
return new GeoInfo(null, null, null);
|
||||
}
|
||||
|
||||
private String normalizeCountryCode(String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
return value.trim().toUpperCase();
|
||||
}
|
||||
|
||||
private String normalizeGeoText(String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.browser.domain.BrowserRuntimeRecord;
|
||||
import com.ruoyi.browser.mapper.BrowserRuntimeRecordMapper;
|
||||
import com.ruoyi.browser.service.IBrowserRuntimeRecordService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserRuntimeRecordServiceImpl implements IBrowserRuntimeRecordService {
|
||||
|
||||
private final BrowserRuntimeRecordMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public void recordLaunch(Long userId, Long profileId, Integer pid, Integer port, String runtimePath, String profileDir) {
|
||||
BrowserRuntimeRecord record = new BrowserRuntimeRecord();
|
||||
record.setUserId(userId);
|
||||
record.setProfileId(profileId);
|
||||
record.setPid(pid);
|
||||
record.setPort(port);
|
||||
record.setStatus("0");
|
||||
record.setStartedAt(new Date());
|
||||
record.setRuntimePath(runtimePath);
|
||||
record.setProfileDir(profileDir);
|
||||
baseMapper.insert(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordClose(Long userId, Long profileId) {
|
||||
BrowserRuntimeRecord record = baseMapper.selectOne(new LambdaQueryWrapper<BrowserRuntimeRecord>()
|
||||
.eq(BrowserRuntimeRecord::getUserId, userId)
|
||||
.eq(BrowserRuntimeRecord::getProfileId, profileId)
|
||||
.eq(BrowserRuntimeRecord::getStatus, "0")
|
||||
.orderByDesc(BrowserRuntimeRecord::getCreateTime)
|
||||
.last("limit 1"));
|
||||
if (record == null) {
|
||||
return;
|
||||
}
|
||||
record.setStatus("1");
|
||||
record.setStoppedAt(new Date());
|
||||
baseMapper.updateById(record);
|
||||
}
|
||||
}
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
package com.ruoyi.browser.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.browser.domain.BrowserPlatform;
|
||||
import com.ruoyi.browser.domain.vo.BrowserKernelPackageVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserFingerprintVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProxyVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserRuntimeVo;
|
||||
import com.ruoyi.browser.mapper.BrowserFingerprintMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserPlatformMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserProfileMapper;
|
||||
import com.ruoyi.browser.mapper.BrowserProxyMapper;
|
||||
import com.ruoyi.browser.service.IBrowserKernelPackageService;
|
||||
import com.ruoyi.browser.service.IBrowserRuntimeService;
|
||||
import com.ruoyi.browser.service.IBrowserRuntimeRecordService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BrowserRuntimeServiceImpl implements IBrowserRuntimeService {
|
||||
|
||||
private final BrowserProfileMapper profileMapper;
|
||||
private final BrowserProxyMapper proxyMapper;
|
||||
private final BrowserFingerprintMapper fingerprintMapper;
|
||||
private final BrowserPlatformMapper platformMapper;
|
||||
private final IBrowserKernelPackageService kernelPackageService;
|
||||
private final IBrowserRuntimeRecordService runtimeRecordService;
|
||||
|
||||
@Value("${browser.local-controller-url:http://127.0.0.1:8001}")
|
||||
private String localControllerUrl;
|
||||
|
||||
@Value("${browser.chromium-runtime-path:}")
|
||||
private String chromiumRuntimePath;
|
||||
|
||||
@Value("${browser.camoufox-runtime-path:}")
|
||||
private String camoufoxRuntimePath;
|
||||
|
||||
@Override
|
||||
public BrowserProfileVo launch(Long profileId) {
|
||||
BrowserProfileVo profileVo = queryProfile(profileId);
|
||||
BrowserRuntimeVo payload = buildLaunchPayload(profileVo);
|
||||
HttpResponse response = HttpRequest.post(localControllerUrl + "/profiles/" + profileId + "/launch")
|
||||
.body(JSONUtil.toJsonStr(toLocalControllerPayload(payload)))
|
||||
.contentType("application/json")
|
||||
.timeout(15000)
|
||||
.execute();
|
||||
if (!response.isOk()) {
|
||||
throw new ServiceException("启动本地浏览器失败: " + response.body());
|
||||
}
|
||||
cn.hutool.json.JSONObject body = JSONUtil.parseObj(response.body());
|
||||
cn.hutool.json.JSONObject data = body.getJSONObject("data");
|
||||
if (data == null) {
|
||||
throw new ServiceException("本地浏览器启动返回数据为空");
|
||||
}
|
||||
String runtimePath = data.getStr("runtime_path");
|
||||
String profileDir = data.getStr("profile_dir");
|
||||
runtimeRecordService.recordLaunch(
|
||||
profileVo.getUserId(),
|
||||
profileId,
|
||||
data.getInt("pid"),
|
||||
data.getInt("port"),
|
||||
ObjectUtil.isNotEmpty(runtimePath) ? runtimePath : payload.getRuntimePath(),
|
||||
ObjectUtil.isNotEmpty(profileDir) ? profileDir : payload.getProfileDir()
|
||||
);
|
||||
return profileVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close(Long profileId) {
|
||||
HttpResponse response = HttpRequest.post(localControllerUrl + "/profiles/" + profileId + "/close")
|
||||
.timeout(15000)
|
||||
.execute();
|
||||
if (!response.isOk()) {
|
||||
return false;
|
||||
}
|
||||
cn.hutool.json.JSONObject body = JSONUtil.parseObj(response.body());
|
||||
boolean closed = body.getBool("ok", false);
|
||||
if (closed) {
|
||||
BrowserProfileVo profileVo = queryProfile(profileId);
|
||||
runtimeRecordService.recordClose(profileVo.getUserId(), profileId);
|
||||
}
|
||||
return closed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> running() {
|
||||
HttpResponse response = HttpRequest.get(localControllerUrl + "/profiles/running")
|
||||
.timeout(15000)
|
||||
.execute();
|
||||
if (!response.isOk()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return JSONUtil.parseObj(response.body()).getJSONArray("items").toList(Object.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserRuntimeVo buildLaunchPayload(BrowserProfileVo profileVo) {
|
||||
BrowserRuntimeVo vo = new BrowserRuntimeVo();
|
||||
vo.setProfileId(String.valueOf(profileVo.getProfileId()));
|
||||
vo.setBrowserEngine(profileVo.getBrowserEngine());
|
||||
vo.setProfileDir(buildProfileDir(profileVo));
|
||||
vo.setStartUrl(resolveStartUrl(profileVo));
|
||||
vo.setHeadless(false);
|
||||
vo.setBrowserArgs(new ArrayList<>());
|
||||
vo.setRuntimePath(resolveRuntimePath(profileVo.getBrowserEngine()));
|
||||
vo.setKernelPackage(buildKernelPackage(profileVo));
|
||||
BrowserProxyVo proxy = resolveProxy(profileVo);
|
||||
BrowserFingerprintVo fingerprint = resolveFingerprint(profileVo);
|
||||
vo.setProxy(buildProxy(proxy));
|
||||
vo.setFingerprint(buildFingerprint(profileVo, fingerprint));
|
||||
vo.setProxyType(proxy == null ? null : proxy.getProxyType());
|
||||
vo.setProxyHost(proxy == null ? null : proxy.getHost());
|
||||
vo.setProxyPort(proxy == null ? null : proxy.getPort());
|
||||
return vo;
|
||||
}
|
||||
|
||||
private BrowserProxyVo resolveProxy(BrowserProfileVo profileVo) {
|
||||
if (ObjectUtil.isNull(profileVo.getProxyId())) {
|
||||
return null;
|
||||
}
|
||||
BrowserProxyVo proxy = proxyMapper.selectVoById(profileVo.getProxyId());
|
||||
if (ObjectUtil.isNull(proxy)) {
|
||||
throw new ServiceException("代理配置不存在");
|
||||
}
|
||||
if (!LoginHelper.isAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), proxy.getUserId())) {
|
||||
throw new ServiceException("无权限使用该代理配置");
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private BrowserProfileVo queryProfile(Long profileId) {
|
||||
BrowserProfileVo profileVo = profileMapper.selectVoById(profileId);
|
||||
if (ObjectUtil.isNull(profileVo)) {
|
||||
throw new ServiceException("环境数据不存在");
|
||||
}
|
||||
if (!LoginHelper.isAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), profileVo.getUserId())) {
|
||||
throw new ServiceException("无权限访问该环境数据");
|
||||
}
|
||||
if (ObjectUtil.isNotNull(profileVo.getPlatformId())) {
|
||||
BrowserPlatform platform = platformMapper.selectById(profileVo.getPlatformId());
|
||||
if (ObjectUtil.isNotNull(platform)) {
|
||||
profileVo.setPlatform(platform.getPlatformName());
|
||||
profileVo.setPlatformWebsiteUrl(platform.getWebsiteUrl());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(profileVo.getCustomWebsiteUrl())) {
|
||||
profileVo.setResolvedWebsiteUrl(profileVo.getCustomWebsiteUrl());
|
||||
} else {
|
||||
profileVo.setResolvedWebsiteUrl(profileVo.getPlatformWebsiteUrl());
|
||||
}
|
||||
return profileVo;
|
||||
}
|
||||
|
||||
private BrowserFingerprintVo resolveFingerprint(BrowserProfileVo profileVo) {
|
||||
if (ObjectUtil.isNull(profileVo.getFingerprintId())) {
|
||||
return null;
|
||||
}
|
||||
BrowserFingerprintVo fingerprint = fingerprintMapper.selectVoById(profileVo.getFingerprintId());
|
||||
if (ObjectUtil.isNull(fingerprint)) {
|
||||
throw new ServiceException("指纹配置不存在");
|
||||
}
|
||||
if (!LoginHelper.isAdmin() && !ObjectUtil.equal(LoginHelper.getUserId(), fingerprint.getUserId())) {
|
||||
throw new ServiceException("无权限使用该指纹配置");
|
||||
}
|
||||
return fingerprint;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildProxy(BrowserProxyVo proxy) {
|
||||
if (ObjectUtil.isNull(proxy)) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("proxyId", proxy.getProxyId());
|
||||
result.put("proxyName", proxy.getProxyName());
|
||||
result.put("proxyType", proxy.getProxyType());
|
||||
result.put("host", proxy.getHost());
|
||||
result.put("port", proxy.getPort());
|
||||
result.put("geoCountry", proxy.getGeoCountry());
|
||||
result.put("username", proxy.getUsername());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildFingerprint(BrowserProfileVo profileVo, BrowserFingerprintVo fingerprint) {
|
||||
if (ObjectUtil.isNull(fingerprint)) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("fingerprintId", fingerprint.getFingerprintId());
|
||||
result.put("browserFamily", fingerprint.getBrowserFamily());
|
||||
result.put("browserVersion", fingerprint.getBrowserVersion());
|
||||
result.put("userAgent", fingerprint.getUserAgent());
|
||||
result.put("geoMode", fingerprint.getGeoMode());
|
||||
result.put("locale", fingerprint.getLocale());
|
||||
result.put("timezone", fingerprint.getTimezone());
|
||||
result.put("geoCountry", fingerprint.getGeoCountry());
|
||||
result.put("screenWidth", fingerprint.getScreenWidth());
|
||||
result.put("screenHeight", fingerprint.getScreenHeight());
|
||||
result.put("webRtcPolicy", fingerprint.getWebRtcPolicy());
|
||||
result.put("canvasPolicy", fingerprint.getCanvasPolicy());
|
||||
result.put("webglPolicy", fingerprint.getWebglPolicy());
|
||||
result.put("audioPolicy", fingerprint.getAudioPolicy());
|
||||
result.put("fontPolicy", fingerprint.getFontPolicy());
|
||||
result.put("cookieConfig", fingerprint.getCookieConfig());
|
||||
result.put("payload", fingerprint.getEncryptedPayload());
|
||||
result.put("profileId", profileVo.getProfileId());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildKernelPackage(BrowserProfileVo profileVo) {
|
||||
BrowserKernelPackageVo kernelPackage = kernelPackageService.resolvePackage(
|
||||
profileVo.getBrowserEngine(),
|
||||
profileVo.getBrowserVersion(),
|
||||
profileVo.getBrowserOsType(),
|
||||
profileVo.getBrowserArchType()
|
||||
);
|
||||
if (ObjectUtil.isNull(kernelPackage)) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("kernelId", kernelPackage.getKernelId());
|
||||
result.put("browserEngine", kernelPackage.getBrowserEngine());
|
||||
result.put("browserVersion", kernelPackage.getBrowserVersion());
|
||||
result.put("fullVersion", kernelPackage.getFullVersion());
|
||||
result.put("osType", kernelPackage.getOsType());
|
||||
result.put("archType", kernelPackage.getArchType());
|
||||
result.put("packageUrl", kernelPackage.getPackageUrl());
|
||||
result.put("packageSha256", kernelPackage.getPackageSha256());
|
||||
result.put("archiveRootDir", kernelPackage.getArchiveRootDir());
|
||||
result.put("executablePath", kernelPackage.getExecutablePath());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildProfileDir(BrowserProfileVo profileVo) {
|
||||
return "data/profiles/" + profileVo.getUserId() + "/" + profileVo.getProfileId() + "/" + profileVo.getBrowserEngine();
|
||||
}
|
||||
|
||||
private String resolveRuntimePath(String engine) {
|
||||
if ("firefox".equalsIgnoreCase(engine)) {
|
||||
return ObjectUtil.isNotEmpty(camoufoxRuntimePath) ? camoufoxRuntimePath : null;
|
||||
}
|
||||
return ObjectUtil.isNotEmpty(chromiumRuntimePath) ? chromiumRuntimePath : null;
|
||||
}
|
||||
|
||||
private String resolveStartUrl(BrowserProfileVo profileVo) {
|
||||
if ("1".equals(profileVo.getLaunchDiagnostics())) {
|
||||
return localControllerUrl + "/diagnostics/fingerprint";
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(profileVo.getResolvedWebsiteUrl())) {
|
||||
return profileVo.getResolvedWebsiteUrl();
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(profileVo.getCustomWebsiteUrl())) {
|
||||
return profileVo.getCustomWebsiteUrl();
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(profileVo.getPlatformWebsiteUrl())) {
|
||||
return profileVo.getPlatformWebsiteUrl();
|
||||
}
|
||||
return "about:blank";
|
||||
}
|
||||
|
||||
private Map<String, Object> toLocalControllerPayload(BrowserRuntimeVo payload) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("profile_id", payload.getProfileId());
|
||||
result.put("browser_engine", payload.getBrowserEngine());
|
||||
result.put("runtime_path", payload.getRuntimePath());
|
||||
result.put("profile_dir", payload.getProfileDir());
|
||||
result.put("start_url", payload.getStartUrl());
|
||||
result.put("headless", payload.getHeadless());
|
||||
result.put("browser_args", payload.getBrowserArgs());
|
||||
result.put("proxy", payload.getProxy());
|
||||
result.put("fingerprint", payload.getFingerprint());
|
||||
result.put("kernel_package", payload.getKernelPackage());
|
||||
result.put("proxy_type", payload.getProxyType());
|
||||
result.put("proxy_host", payload.getProxyHost());
|
||||
result.put("proxy_port", payload.getProxyPort());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserFingerprintBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserFingerprintVo;
|
||||
import com.ruoyi.browser.service.IBrowserFingerprintService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/fingerprint")
|
||||
public class BrowserFingerprintController extends BaseController {
|
||||
|
||||
private final IBrowserFingerprintService service;
|
||||
|
||||
@SaCheckPermission("browser:fingerprint:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BrowserFingerprintVo> list(@Validated(QueryGroup.class) BrowserFingerprintBo bo, PageQuery pageQuery) {
|
||||
return service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:fingerprint:query")
|
||||
@GetMapping("/{fingerprintId}")
|
||||
public R<BrowserFingerprintVo> getInfo(@PathVariable Long fingerprintId) {
|
||||
return R.ok(service.queryById(fingerprintId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:fingerprint:add")
|
||||
@Log(title = "指纹管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserFingerprintBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:fingerprint:edit")
|
||||
@Log(title = "指纹管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserFingerprintBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:fingerprint:remove")
|
||||
@Log(title = "指纹管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{fingerprintIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] fingerprintIds) {
|
||||
return toAjax(service.deleteWithValidByIds(Arrays.asList(fingerprintIds), true));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserKernelPackageBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserKernelPackageVo;
|
||||
import com.ruoyi.browser.service.IBrowserKernelPackageService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/kernel-package")
|
||||
public class BrowserKernelPackageController extends BaseController {
|
||||
|
||||
private final IBrowserKernelPackageService service;
|
||||
|
||||
@SaCheckPermission("browser:kernel-package:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BrowserKernelPackageVo> list(@Validated(QueryGroup.class) BrowserKernelPackageBo bo, PageQuery pageQuery) {
|
||||
return service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@GetMapping("/options")
|
||||
public R<List<BrowserKernelPackageVo>> options(BrowserKernelPackageBo bo) {
|
||||
return R.ok(service.queryEnabledOptions(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:kernel-package:query")
|
||||
@GetMapping("/{kernelId}")
|
||||
public R<BrowserKernelPackageVo> getInfo(@PathVariable Long kernelId) {
|
||||
return R.ok(service.queryById(kernelId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:kernel-package:add")
|
||||
@Log(title = "浏览器内核包", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserKernelPackageBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:kernel-package:edit")
|
||||
@Log(title = "浏览器内核包", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserKernelPackageBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:kernel-package:remove")
|
||||
@Log(title = "浏览器内核包", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{kernelIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] kernelIds) {
|
||||
return toAjax(service.deleteWithValidByIds(Arrays.asList(kernelIds), true));
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.ruoyi.browser.domain.bo.BrowserMemberRegisterBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserMemberUserVo;
|
||||
import com.ruoyi.browser.service.IBrowserMemberUserService;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/member/auth")
|
||||
public class BrowserMemberAuthController {
|
||||
|
||||
private final IBrowserMemberUserService service;
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/login")
|
||||
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put(Constants.TOKEN, service.login(loginBody));
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/register")
|
||||
public R<Void> register(@Validated @RequestBody BrowserMemberRegisterBo bo) {
|
||||
service.register(bo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/info")
|
||||
public R<BrowserMemberUserVo> info() {
|
||||
return R.ok(service.currentMember());
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserMemberUserBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserMemberUserVo;
|
||||
import com.ruoyi.browser.service.IBrowserMemberUserService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/member")
|
||||
public class BrowserMemberController extends BaseController {
|
||||
|
||||
private final IBrowserMemberUserService service;
|
||||
|
||||
@SaCheckPermission("browser:member:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BrowserMemberUserVo> list(@Validated(QueryGroup.class) BrowserMemberUserBo bo, PageQuery pageQuery) {
|
||||
return service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:member:query")
|
||||
@GetMapping("/{memberId}")
|
||||
public R<BrowserMemberUserVo> getInfo(@PathVariable Long memberId) {
|
||||
return R.ok(service.queryById(memberId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:member:add")
|
||||
@Log(title = "会员管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserMemberUserBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:member:edit")
|
||||
@Log(title = "会员管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserMemberUserBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:member:remove")
|
||||
@Log(title = "会员管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{memberIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] memberIds) {
|
||||
return toAjax(service.deleteWithValidByIds(Arrays.asList(memberIds), true));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:member:edit")
|
||||
@Log(title = "会员管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody BrowserMemberUserBo bo) {
|
||||
return toAjax(service.changeStatus(bo));
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserPlatformBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserPlatformVo;
|
||||
import com.ruoyi.browser.service.IBrowserPlatformService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/platform")
|
||||
public class BrowserPlatformController extends BaseController {
|
||||
|
||||
private final IBrowserPlatformService service;
|
||||
|
||||
@SaCheckPermission("browser:platform:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BrowserPlatformVo> list(@Validated(QueryGroup.class) BrowserPlatformBo bo, PageQuery pageQuery) {
|
||||
return service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:platform:list")
|
||||
@GetMapping("/options")
|
||||
public R<List<BrowserPlatformVo>> options() {
|
||||
return R.ok(service.queryEnabledOptions());
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:platform:query")
|
||||
@GetMapping("/{platformId}")
|
||||
public R<BrowserPlatformVo> getInfo(@PathVariable Long platformId) {
|
||||
return R.ok(service.queryById(platformId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:platform:add")
|
||||
@Log(title = "平台配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserPlatformBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:platform:edit")
|
||||
@Log(title = "平台配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserPlatformBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:platform:remove")
|
||||
@Log(title = "平台配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{platformIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] platformIds) {
|
||||
return toAjax(service.deleteWithValidByIds(Arrays.asList(platformIds), true));
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileQuickSaveBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileQuickSaveVo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileVo;
|
||||
import com.ruoyi.browser.service.IBrowserProfileService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/profile")
|
||||
public class BrowserProfileController extends BaseController {
|
||||
|
||||
private final IBrowserProfileService browserProfileService;
|
||||
|
||||
@SaCheckPermission("browser:profile:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BrowserProfileVo> list(@Validated(QueryGroup.class) BrowserProfileBo bo, PageQuery pageQuery) {
|
||||
return browserProfileService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:query")
|
||||
@GetMapping("/{profileId}")
|
||||
public R<BrowserProfileVo> getInfo(@PathVariable Long profileId) {
|
||||
return R.ok(browserProfileService.queryById(profileId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:add")
|
||||
@Log(title = "浏览器Profile", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserProfileBo bo) {
|
||||
return toAjax(browserProfileService.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:add")
|
||||
@Log(title = "浏览器Profile", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/quick-create")
|
||||
public R<BrowserProfileQuickSaveVo> quickCreate(@Validated(AddGroup.class) @RequestBody BrowserProfileQuickSaveBo bo) {
|
||||
return R.ok(browserProfileService.quickCreate(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:edit")
|
||||
@Log(title = "浏览器Profile", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserProfileBo bo) {
|
||||
return toAjax(browserProfileService.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:edit")
|
||||
@Log(title = "浏览器Profile", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/quick-update")
|
||||
public R<BrowserProfileQuickSaveVo> quickUpdate(@Validated(EditGroup.class) @RequestBody BrowserProfileQuickSaveBo bo) {
|
||||
return R.ok(browserProfileService.quickUpdate(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:remove")
|
||||
@Log(title = "浏览器Profile", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{profileIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] profileIds) {
|
||||
return toAjax(browserProfileService.deleteWithValidByIds(Arrays.asList(profileIds), true));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:launch")
|
||||
@PostMapping("/{profileId}/launch")
|
||||
public R<Void> launch(@PathVariable Long profileId) {
|
||||
browserProfileService.launch(profileId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile:close")
|
||||
@PostMapping("/{profileId}/close")
|
||||
public R<Void> close(@PathVariable Long profileId) {
|
||||
return toAjax(browserProfileService.close(profileId));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileGroupBo;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProfileGroupMoveBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProfileGroupVo;
|
||||
import com.ruoyi.browser.service.IBrowserProfileGroupService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/profile-group")
|
||||
public class BrowserProfileGroupController extends BaseController {
|
||||
|
||||
private final IBrowserProfileGroupService service;
|
||||
|
||||
@SaCheckPermission("browser:profile-group:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<BrowserProfileGroupVo>> list(@Validated(QueryGroup.class) BrowserProfileGroupBo bo) {
|
||||
return R.ok(service.queryList(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile-group:add")
|
||||
@Log(title = "环境分组", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserProfileGroupBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile-group:edit")
|
||||
@Log(title = "环境分组", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserProfileGroupBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile-group:edit")
|
||||
@Log(title = "环境分组", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/move-profiles")
|
||||
public R<Void> moveProfiles(@Validated @RequestBody BrowserProfileGroupMoveBo bo) {
|
||||
return toAjax(service.moveProfiles(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:profile-group:remove")
|
||||
@Log(title = "环境分组", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{groupId}")
|
||||
public R<Void> remove(@PathVariable Long groupId) {
|
||||
return toAjax(service.deleteById(groupId));
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.web.controller.browser;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.browser.domain.bo.BrowserProxyBo;
|
||||
import com.ruoyi.browser.domain.vo.BrowserProxyVo;
|
||||
import com.ruoyi.browser.service.IBrowserProxyService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/browser/proxy")
|
||||
public class BrowserProxyController extends BaseController {
|
||||
|
||||
private final IBrowserProxyService service;
|
||||
|
||||
@SaCheckPermission("browser:proxy:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BrowserProxyVo> list(@Validated(QueryGroup.class) BrowserProxyBo bo, PageQuery pageQuery) {
|
||||
return service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:proxy:query")
|
||||
@GetMapping("/{proxyId}")
|
||||
public R<BrowserProxyVo> getInfo(@PathVariable Long proxyId) {
|
||||
return R.ok(service.queryById(proxyId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:proxy:add")
|
||||
@Log(title = "代理管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BrowserProxyBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:proxy:edit")
|
||||
@Log(title = "代理管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BrowserProxyBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:proxy:refresh-geo")
|
||||
@Log(title = "代理管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{proxyId}/refresh-geo")
|
||||
public R<Void> refreshGeo(@PathVariable Long proxyId) {
|
||||
return toAjax(service.refreshGeoById(proxyId));
|
||||
}
|
||||
|
||||
@SaCheckPermission("browser:proxy:remove")
|
||||
@Log(title = "代理管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{proxyIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] proxyIds) {
|
||||
return toAjax(service.deleteWithValidByIds(Arrays.asList(proxyIds), true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user