功能迭代
This commit is contained in:
1 parent
5fc7d4564c
commit
84184a2dd1
41 files changed
+1054
-8
No files matched your search
@@ -14,7 +14,7 @@ public enum BusinessCodePrefixEnum {
|
||||
INQUIRY_LOG("ILG"), INQUIRY_RECEIVER("IRC"), MAIL_TASK("MLT"), CUSTOMER("CUS"),
|
||||
CONTACT("CON"), LEAD("LED"), FOLLOW_UP("FLW"), MEDIA("MED"), SEO("SEO"), SEO_HEADING("SEH"),
|
||||
PUBLISH("PUB"), JOB("JOB"), USER("USR"), USER_SITE("UST"), ROLE("ROL"), FLOW_LOG("FLO"), SOCIAL_CHANNEL("SOC"),
|
||||
CRM_TAG("CTG"), CRM_TAG_RELATION("CTR");
|
||||
CRM_TAG("CTG"), CRM_TAG_RELATION("CTR"), GSC_CONNECTION("GSC");
|
||||
|
||||
/** 三位业务前缀。 */
|
||||
private final String prefix;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.shoplix.modules.gsc.enums;
|
||||
|
||||
/** Google Search Console连接允许操作。 */
|
||||
public enum GscConnectionOperationEnum {
|
||||
/** 发起Google授权。 */ AUTHORIZE,
|
||||
/** 解除Google授权。 */ DISCONNECT,
|
||||
/** 重新发起Google授权。 */ REAUTHORIZE,
|
||||
/** 查询Search Console统计。 */ QUERY_STATISTICS
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.shoplix.modules.gsc.enums;
|
||||
|
||||
/** Google Search Console连接状态。 */
|
||||
public enum GscConnectionStatusEnum {
|
||||
/** 已成功授权并可查询数据。 */ CONNECTED("已连接", GscConnectionOperationEnum.DISCONNECT, GscConnectionOperationEnum.QUERY_STATISTICS),
|
||||
/** 已主动解除授权。 */ DISCONNECTED("未连接", GscConnectionOperationEnum.AUTHORIZE),
|
||||
/** Google授权已失效。 */ EXPIRED("授权已失效", GscConnectionOperationEnum.REAUTHORIZE);
|
||||
|
||||
private final String label;
|
||||
private final java.util.List<GscConnectionOperationEnum> operations;
|
||||
/** 创建连接状态。 */ GscConnectionStatusEnum(String label, GscConnectionOperationEnum... operations) {
|
||||
this.label = label;
|
||||
this.operations = java.util.List.of(operations);
|
||||
}
|
||||
/** 获取状态文案。 */ public String getLabel() { return label; }
|
||||
/** 获取当前状态允许操作。 */ public java.util.List<GscConnectionOperationEnum> getOperations() { return operations; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.shoplix.modules.gsc.enums;
|
||||
|
||||
/** Google OAuth临时状态使用状态。 */
|
||||
public enum GscOauthStateStatusEnum {
|
||||
/** 尚未使用。 */ UNUSED(0),
|
||||
/** 已使用。 */ USED(1);
|
||||
|
||||
private final int value;
|
||||
/** 创建OAuth状态枚举。 */ GscOauthStateStatusEnum(int value) { this.value = value; }
|
||||
/** 获取数据库状态值。 */ public int getValue() { return value; }
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.shoplix.modules.gsc.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/** Google Search Console站点授权连接持久化实体。 */
|
||||
@Data
|
||||
@TableName("gsc_connection")
|
||||
public class GscConnectionEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** GSC连接业务编号。 */ private String connectionCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** Google Search Console站点资源地址。 */ private String propertyUri;
|
||||
/** 授权Google账户邮箱。 */ private String accountEmail;
|
||||
/** 加密后的OAuth刷新令牌。 */ private String refreshTokenCiphertext;
|
||||
/** 连接状态:CONNECTED已连接,DISCONNECTED已解绑,EXPIRED授权失效。 */ private String status;
|
||||
/** 创建时间毫秒时间戳。 */ private Long createTime;
|
||||
/** 更新时间毫秒时间戳。 */ private Long updateTime;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.shoplix.modules.gsc.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/** Google Search Console OAuth临时状态持久化实体。 */
|
||||
@Data
|
||||
@TableName("gsc_oauth_state")
|
||||
public class GscOauthStateEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** OAuth防重放随机状态码。 */ private String stateCode;
|
||||
/** 发起授权的站点业务编号。 */ private String siteCode;
|
||||
/** 授权完成后的后台跳转地址。 */ private String redirectUri;
|
||||
/** 状态码失效时间毫秒时间戳。 */ private Long expireTime;
|
||||
/** 使用状态:0未使用,1已使用。 */ private Integer used;
|
||||
/** 创建时间毫秒时间戳。 */ private Long createTime;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.gsc.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.gsc.repository.entity.GscConnectionEntity;
|
||||
|
||||
/** Google Search Console连接Mapper。 */
|
||||
public interface GscConnectionMapper extends BaseMapper<GscConnectionEntity> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.gsc.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.gsc.repository.entity.GscOauthStateEntity;
|
||||
|
||||
/** Google Search Console OAuth状态Mapper。 */
|
||||
public interface GscOauthStateMapper extends BaseMapper<GscOauthStateEntity> {
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.shoplix.modules.gsc.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.gsc.repository.entity.GscConnectionEntity;
|
||||
import com.shoplix.modules.gsc.repository.mapper.GscConnectionMapper;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/** Google Search Console连接单表数据源服务。 */
|
||||
@Service
|
||||
public class GscConnectionRepositoryService {
|
||||
private final GscConnectionMapper mapper;
|
||||
|
||||
/** 注入GSC连接Mapper。 */
|
||||
public GscConnectionRepositoryService(GscConnectionMapper mapper) { this.mapper = mapper; }
|
||||
|
||||
/** 按站点查询GSC连接。 */
|
||||
public Optional<GscConnectionEntity> findBySiteCode(String siteCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<GscConnectionEntity>lambdaQuery()
|
||||
.eq(GscConnectionEntity::getSiteCode, siteCode)));
|
||||
}
|
||||
|
||||
/** 新增GSC连接。 */ public int insert(GscConnectionEntity entity) { return mapper.insert(entity); }
|
||||
/** 更新GSC连接。 */ public int update(GscConnectionEntity entity) { return mapper.updateById(entity); }
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.shoplix.modules.gsc.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.gsc.repository.entity.GscOauthStateEntity;
|
||||
import com.shoplix.modules.gsc.repository.mapper.GscOauthStateMapper;
|
||||
import com.shoplix.modules.gsc.enums.GscOauthStateStatusEnum;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/** Google Search Console OAuth状态单表数据源服务。 */
|
||||
@Service
|
||||
public class GscOauthStateRepositoryService {
|
||||
private final GscOauthStateMapper mapper;
|
||||
|
||||
/** 注入OAuth状态Mapper。 */
|
||||
public GscOauthStateRepositoryService(GscOauthStateMapper mapper) { this.mapper = mapper; }
|
||||
|
||||
/** 新增OAuth状态。 */ public int insert(GscOauthStateEntity entity) { return mapper.insert(entity); }
|
||||
|
||||
/** 查询尚未使用的OAuth状态。 */
|
||||
public Optional<GscOauthStateEntity> findUsable(String stateCode, long currentTime) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<GscOauthStateEntity>lambdaQuery()
|
||||
.eq(GscOauthStateEntity::getStateCode, stateCode).eq(GscOauthStateEntity::getUsed, GscOauthStateStatusEnum.UNUSED.getValue())
|
||||
.gt(GscOauthStateEntity::getExpireTime, currentTime)));
|
||||
}
|
||||
|
||||
/** 将OAuth状态原子标记为已使用。 */
|
||||
public int markUsed(String stateCode) {
|
||||
GscOauthStateEntity update = new GscOauthStateEntity();
|
||||
update.setUsed(GscOauthStateStatusEnum.USED.getValue());
|
||||
return mapper.update(update, Wrappers.<GscOauthStateEntity>lambdaUpdate()
|
||||
.eq(GscOauthStateEntity::getStateCode, stateCode).eq(GscOauthStateEntity::getUsed, GscOauthStateStatusEnum.UNUSED.getValue()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user