feat(iap): 新增 Google Play 内购与 AI 评论举报支持
完成 Google Play 内购集成所需的全链路实现,包括: - 数据库表结构(google-play-iap.sql) - 实体、Mapper、Service 及 XML 配置 - AI 评论举报实体与业务层 - 集成文档(google-play-iap-integration.md)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.yolo.keyborad.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yolo.keyborad.model.entity.KeyboardAiCommentReport;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/3/20 15:07
|
||||
*/
|
||||
|
||||
public interface KeyboardAiCommentReportMapper extends BaseMapper<KeyboardAiCommentReport> {
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.yolo.keyborad.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/3/20 15:07
|
||||
*/
|
||||
|
||||
/**
|
||||
* AI角色评论举报记录表
|
||||
*/
|
||||
@Schema(description="AI角色评论举报记录表")
|
||||
@Data
|
||||
@TableName(value = "keyboard_ai_comment_report")
|
||||
public class KeyboardAiCommentReport {
|
||||
/**
|
||||
* 举报记录唯一ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@Schema(description="举报记录唯一ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 被举报的评论Id
|
||||
*/
|
||||
@TableField(value = "comment_id")
|
||||
@Schema(description="被举报的评论Id")
|
||||
private Long commentId;
|
||||
|
||||
/**
|
||||
* 发起举报的用户ID(逻辑关联用户表)
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
@Schema(description="发起举报的用户ID(逻辑关联用户表)")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 举报类型:1=色情低俗, 2=政治敏感, 3=暴力恐怖, 4=侵权/冒充, 5=价值观问题, 99=其他
|
||||
*/
|
||||
@TableField(value = "report_type")
|
||||
@Schema(description="举报类型:1=色情低俗, 2=政治敏感, 3=暴力恐怖, 4=侵权/冒充, 5=价值观问题, 99=其他")
|
||||
private String reportType;
|
||||
|
||||
/**
|
||||
* 用户填写的详细举报描述
|
||||
*/
|
||||
@TableField(value = "report_desc")
|
||||
@Schema(description="用户填写的详细举报描述")
|
||||
private String reportDesc;
|
||||
|
||||
/**
|
||||
* 违规现场:举报时的评论的内容,用于审核取证
|
||||
*/
|
||||
@TableField(value = "comment_context")
|
||||
@Schema(description="违规现场:举报时的评论的内容,用于审核取证")
|
||||
private String commentContext;
|
||||
|
||||
/**
|
||||
* 图片证据:用户上传的截图URL
|
||||
*/
|
||||
@TableField(value = "evidence_image_url")
|
||||
@Schema(description="图片证据:用户上传的截图URL")
|
||||
private String evidenceImageUrl;
|
||||
|
||||
/**
|
||||
* 处理状态:0=待处理, 1=违规确立(已处罚), 2=无效举报/已驳回, 3=已忽略
|
||||
*/
|
||||
@TableField(value = "\"status\"")
|
||||
@Schema(description="处理状态:0=待处理, 1=违规确立(已处罚), 2=无效举报/已驳回, 3=已忽略")
|
||||
private Short status;
|
||||
|
||||
/**
|
||||
* 管理员处理备注(记录处理理由或处罚措施)
|
||||
*/
|
||||
@TableField(value = "admin_remark")
|
||||
@Schema(description="管理员处理备注(记录处理理由或处罚措施)")
|
||||
private String adminRemark;
|
||||
|
||||
/**
|
||||
* 举报提交时间
|
||||
*/
|
||||
@TableField(value = "created_at")
|
||||
@Schema(description="举报提交时间")
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
@TableField(value = "updated_at")
|
||||
@Schema(description="最后更新时间")
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yolo.keyborad.service;
|
||||
|
||||
import com.yolo.keyborad.model.entity.KeyboardAiCommentReport;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/3/20 15:07
|
||||
*/
|
||||
|
||||
public interface KeyboardAiCommentReportService extends IService<KeyboardAiCommentReport>{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yolo.keyborad.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yolo.keyborad.model.entity.KeyboardAiCommentReport;
|
||||
import com.yolo.keyborad.mapper.KeyboardAiCommentReportMapper;
|
||||
import com.yolo.keyborad.service.KeyboardAiCommentReportService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2026/3/20 15:07
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class KeyboardAiCommentReportServiceImpl extends ServiceImpl<KeyboardAiCommentReportMapper, KeyboardAiCommentReport> implements KeyboardAiCommentReportService{
|
||||
|
||||
}
|
||||
24
src/main/resources/mapper/KeyboardAiCommentReportMapper.xml
Normal file
24
src/main/resources/mapper/KeyboardAiCommentReportMapper.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yolo.keyborad.mapper.KeyboardAiCommentReportMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yolo.keyborad.model.entity.KeyboardAiCommentReport">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table keyboard_ai_comment_report-->
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="comment_id" jdbcType="BIGINT" property="commentId" />
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||
<result column="report_type" jdbcType="VARCHAR" property="reportType" />
|
||||
<result column="report_desc" jdbcType="VARCHAR" property="reportDesc" />
|
||||
<result column="comment_context" jdbcType="VARCHAR" property="commentContext" />
|
||||
<result column="evidence_image_url" jdbcType="VARCHAR" property="evidenceImageUrl" />
|
||||
<result column="status" jdbcType="SMALLINT" property="status" />
|
||||
<result column="admin_remark" jdbcType="VARCHAR" property="adminRemark" />
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
||||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, comment_id, user_id, report_type, report_desc, comment_context, evidence_image_url,
|
||||
"status", admin_remark, created_at, updated_at
|
||||
</sql>
|
||||
</mapper>
|
||||
113
src/main/resources/sql/google-play-iap.sql
Normal file
113
src/main/resources/sql/google-play-iap.sql
Normal file
@@ -0,0 +1,113 @@
|
||||
CREATE TABLE IF NOT EXISTS google_play_order (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
user_id BIGINT,
|
||||
package_name VARCHAR(128) NOT NULL,
|
||||
product_id VARCHAR(255) NOT NULL,
|
||||
product_type VARCHAR(32) NOT NULL,
|
||||
purchase_token VARCHAR(512) NOT NULL,
|
||||
order_key VARCHAR(128) NOT NULL UNIQUE,
|
||||
google_order_id VARCHAR(128),
|
||||
linked_purchase_token VARCHAR(512),
|
||||
order_state VARCHAR(64) NOT NULL,
|
||||
acknowledgement_state VARCHAR(32) NOT NULL,
|
||||
consumption_state VARCHAR(32) NOT NULL,
|
||||
quantity INTEGER,
|
||||
refundable_quantity INTEGER,
|
||||
delivery_status VARCHAR(64) NOT NULL,
|
||||
granted_quantity NUMERIC(18,2) NOT NULL DEFAULT 0,
|
||||
entitlement_start_time TIMESTAMP,
|
||||
entitlement_end_time TIMESTAMP,
|
||||
last_event_time TIMESTAMP,
|
||||
last_synced_at TIMESTAMP NOT NULL,
|
||||
raw_response TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_google_play_order_purchase_token
|
||||
ON google_play_order (purchase_token);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_google_play_order_user_product
|
||||
ON google_play_order (user_id, product_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS google_play_purchase_token (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
purchase_token VARCHAR(512) NOT NULL UNIQUE,
|
||||
linked_purchase_token VARCHAR(512),
|
||||
user_id BIGINT,
|
||||
package_name VARCHAR(128) NOT NULL,
|
||||
product_id VARCHAR(255) NOT NULL,
|
||||
product_type VARCHAR(32) NOT NULL,
|
||||
latest_order_key VARCHAR(128) NOT NULL,
|
||||
latest_order_id VARCHAR(128),
|
||||
token_state VARCHAR(64) NOT NULL,
|
||||
acknowledgement_state VARCHAR(32) NOT NULL,
|
||||
consumption_state VARCHAR(32) NOT NULL,
|
||||
auto_renew_enabled BOOLEAN,
|
||||
external_account_id VARCHAR(255),
|
||||
external_profile_id VARCHAR(255),
|
||||
region_code VARCHAR(16),
|
||||
start_time TIMESTAMP,
|
||||
expiry_time TIMESTAMP,
|
||||
auto_resume_time TIMESTAMP,
|
||||
canceled_state_reason VARCHAR(64),
|
||||
last_event_type VARCHAR(128),
|
||||
last_event_time TIMESTAMP,
|
||||
last_synced_at TIMESTAMP NOT NULL,
|
||||
raw_response TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_google_play_purchase_token_user
|
||||
ON google_play_purchase_token (user_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS google_play_user_entitlement (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
entitlement_key VARCHAR(128) NOT NULL,
|
||||
product_id VARCHAR(255) NOT NULL,
|
||||
product_type VARCHAR(32) NOT NULL,
|
||||
source_purchase_token VARCHAR(512) NOT NULL,
|
||||
current_order_key VARCHAR(128) NOT NULL,
|
||||
benefit_type VARCHAR(64) NOT NULL,
|
||||
state VARCHAR(64) NOT NULL,
|
||||
active BOOLEAN NOT NULL,
|
||||
quantity NUMERIC(18,2) NOT NULL DEFAULT 0,
|
||||
start_time TIMESTAMP,
|
||||
end_time TIMESTAMP,
|
||||
last_granted_at TIMESTAMP,
|
||||
last_revoked_at TIMESTAMP,
|
||||
metadata TEXT,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT uk_google_play_user_entitlement UNIQUE (source_purchase_token, entitlement_key)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_google_play_user_entitlement_user
|
||||
ON google_play_user_entitlement (user_id, active);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS google_play_rtdn_event (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
message_id VARCHAR(128) NOT NULL UNIQUE,
|
||||
subscription_name VARCHAR(255),
|
||||
package_name VARCHAR(128),
|
||||
event_type VARCHAR(32) NOT NULL,
|
||||
notification_type INTEGER,
|
||||
notification_name VARCHAR(128),
|
||||
purchase_token VARCHAR(512),
|
||||
product_id VARCHAR(255),
|
||||
order_id VARCHAR(128),
|
||||
event_time TIMESTAMP,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
retry_count INTEGER NOT NULL DEFAULT 0,
|
||||
raw_envelope TEXT NOT NULL,
|
||||
raw_payload TEXT NOT NULL,
|
||||
error_message TEXT,
|
||||
processed_at TIMESTAMP,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_google_play_rtdn_event_purchase_token
|
||||
ON google_play_rtdn_event (purchase_token);
|
||||
Reference in New Issue
Block a user