mirror of https://gitee.com/stylefeng/roses
【7.6.0】【stat】更新点击次数统计模块
parent
fee8db5aec
commit
a76ce9d7db
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.stat.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.stat.api.callback.ClickCountCallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 计算业务的点击次数
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:07
|
||||
*/
|
||||
public interface ClickCountCalcApi {
|
||||
|
||||
/**
|
||||
* 计算一组数据的点击数量
|
||||
*
|
||||
* @param clickCountCallbackList 原始数据,需要实现callback接口
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:03
|
||||
*/
|
||||
<T extends ClickCountCallback> void calcClickCount(List<T> clickCountCallbackList);
|
||||
|
||||
/**
|
||||
* 将某个业务数据的点击数量统计+1
|
||||
*
|
||||
* @param clickCountCallback 原始数据
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:39
|
||||
*/
|
||||
Long addOneClickCount(ClickCountCallback clickCountCallback);
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.stat.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.stat.api.callback.ClickStatusCallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 计算点击状态
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:08
|
||||
*/
|
||||
public interface ClickStatusCalcApi {
|
||||
|
||||
/**
|
||||
* 计算一组数据的点击状态
|
||||
*
|
||||
* @param clickStatusCallbackList 原始数据,需要实现callback接口
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:03
|
||||
*/
|
||||
<T extends ClickStatusCallback> void calcClickStatus(List<T> clickStatusCallbackList);
|
||||
|
||||
/**
|
||||
* 更新某条记录的点击状态为已点击
|
||||
*
|
||||
* @param clickStatusCallback 原始数据
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:39
|
||||
*/
|
||||
void addClickStatus(ClickStatusCallback clickStatusCallback);
|
||||
|
||||
}
|
|
@ -22,15 +22,39 @@
|
|||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.stat.api;
|
||||
package cn.stylefeng.roses.kernel.stat.api.callback;
|
||||
|
||||
/**
|
||||
* 点击统计Api
|
||||
* 回调事件:计算点击次数
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023-05-10 10:10:15
|
||||
* @since 2023/3/28 15:02
|
||||
*/
|
||||
public interface StatApi {
|
||||
public interface ClickCountCallback {
|
||||
|
||||
/**
|
||||
* 给元素增加点击次数的获取
|
||||
*
|
||||
* @param count 设定点击次数
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 14:43
|
||||
*/
|
||||
void addClickCount(Long count);
|
||||
|
||||
/**
|
||||
* 获取业务主键id
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:05
|
||||
*/
|
||||
Long getBusinessId();
|
||||
|
||||
/**
|
||||
* 获取业务的类别编码
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:05
|
||||
*/
|
||||
String getBusinessTypeCode();
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.stat.api.callback;
|
||||
|
||||
/**
|
||||
* 回调事件:计算点击状态
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 14:42
|
||||
*/
|
||||
public interface ClickStatusCallback {
|
||||
|
||||
/**
|
||||
* 给元素增加点击状态标识
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 14:43
|
||||
*/
|
||||
void addClickStatus();
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:06
|
||||
*/
|
||||
Long getUserId();
|
||||
|
||||
/**
|
||||
* 获取业务主键id
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:05
|
||||
*/
|
||||
Long getBusinessId();
|
||||
|
||||
/**
|
||||
* 获取业务的类别编码
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:05
|
||||
*/
|
||||
String getBusinessTypeCode();
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ package cn.stylefeng.roses.kernel.stat.api.constants;
|
|||
* 点击统计业务
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023-05-10 10:10:15
|
||||
* @since 2023-05-10 10:10:15
|
||||
*/
|
||||
public interface StatConstants {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Getter;
|
|||
* 一个示例
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023-05-10 10:10:15
|
||||
* @since 2023-05-10 10:10:15
|
||||
*/
|
||||
@Getter
|
||||
public enum DemoEnum {
|
||||
|
|
|
@ -33,7 +33,7 @@ import cn.stylefeng.roses.kernel.stat.api.constants.StatConstants;
|
|||
* 点击统计异常
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023-05-10 10:10:15
|
||||
* @since 2023-05-10 10:10:15
|
||||
*/
|
||||
public class StatException extends ServiceException {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import lombok.Getter;
|
|||
* 点击统计的异常枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023-05-10 10:10:15
|
||||
* @since 2023-05-10 10:10:15
|
||||
*/
|
||||
@Getter
|
||||
public enum StatExceptionEnum implements AbstractExceptionEnum {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.controller;
|
|
@ -0,0 +1,58 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
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 lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户点击数量统计实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@TableName("portal_click_count")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ClickCount extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "click_count_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键id")
|
||||
private Long clickCountId;
|
||||
|
||||
/**
|
||||
* 业务的分类标识
|
||||
*/
|
||||
@TableField("business_type")
|
||||
@ChineseDescription("业务的分类标识")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 业务的主键id
|
||||
*/
|
||||
@TableField("business_key_id")
|
||||
@ChineseDescription("业务的主键id")
|
||||
private Long businessKeyId;
|
||||
|
||||
/**
|
||||
* 点击次数
|
||||
*/
|
||||
@TableField("click_count")
|
||||
@ChineseDescription("点击次数")
|
||||
private Long clickCount;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
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 lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户点击状态实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@TableName("portal_click_status")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ClickStatus extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "click_status_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键id")
|
||||
private Long clickStatusId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@ChineseDescription("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 业务的主键id
|
||||
*/
|
||||
@TableField("business_key_id")
|
||||
@ChineseDescription("业务的主键id")
|
||||
private Long businessKeyId;
|
||||
|
||||
/**
|
||||
* 业务的分类标识
|
||||
*/
|
||||
@TableField("business_type")
|
||||
@ChineseDescription("业务的分类标识")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.entity;
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 用户点击数量统计异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@Getter
|
||||
public enum ClickCountExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
PORTAL_CLICK_COUNT_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
ClickCountExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 用户点击状态异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@Getter
|
||||
public enum ClickStatusExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
PORTAL_CLICK_STATUS_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
ClickStatusExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.enums;
|
|
@ -0,0 +1,15 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.stat.modular.entity.ClickCount;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 用户点击数量统计 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
public interface ClickCountMapper extends BaseMapper<ClickCount> {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.stat.modular.entity.ClickStatus;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 用户点击状态 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
public interface ClickStatusMapper extends BaseMapper<ClickStatus> {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?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="cn.stylefeng.roses.kernel.stat.modular.mapper.ClickCountMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?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="cn.stylefeng.roses.kernel.stat.modular.mapper.ClickStatusMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.mapper;
|
|
@ -1 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.pojo;
|
|
@ -0,0 +1,51 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用户点击数量统计封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ClickCountRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键id")
|
||||
private Long clickCountId;
|
||||
|
||||
/**
|
||||
* 业务的分类标识
|
||||
*/
|
||||
@ChineseDescription("业务的分类标识")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 业务的主键id
|
||||
*/
|
||||
@ChineseDescription("业务的主键id")
|
||||
private Long businessKeyId;
|
||||
|
||||
/**
|
||||
* 点击次数
|
||||
*/
|
||||
@ChineseDescription("点击次数")
|
||||
private Long clickCount;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用户点击状态封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ClickStatusRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键id")
|
||||
private Long clickStatusId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ChineseDescription("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 业务的主键id
|
||||
*/
|
||||
@ChineseDescription("业务的主键id")
|
||||
private Long businessKeyId;
|
||||
|
||||
/**
|
||||
* 业务的分类标识
|
||||
*/
|
||||
@ChineseDescription("业务的分类标识")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.stat.api.ClickCountCalcApi;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.entity.ClickCount;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.request.ClickCountRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户点击数量统计 服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
public interface ClickCountService extends IService<ClickCount>, ClickCountCalcApi {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param portalClickCountRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
void add(ClickCountRequest portalClickCountRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param portalClickCountRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
void del(ClickCountRequest portalClickCountRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param portalClickCountRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
void edit(ClickCountRequest portalClickCountRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param portalClickCountRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
ClickCount detail(ClickCountRequest portalClickCountRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param portalClickCountRequest 请求参数
|
||||
* @return List<PortalClickCount> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
List<ClickCount> findList(ClickCountRequest portalClickCountRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param portalClickCountRequest 请求参数
|
||||
* @return PageResult<PortalClickCount> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
PageResult<ClickCount> findPage(ClickCountRequest portalClickCountRequest);
|
||||
|
||||
/**
|
||||
* 获取某个业务记录的点击次数总数
|
||||
*
|
||||
* @param businessId 业务id
|
||||
* @return 点击次数统计总数
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:31
|
||||
*/
|
||||
Long getBusinessCount(Long businessId);
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.stat.api.ClickStatusCalcApi;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.entity.ClickStatus;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.request.ClickStatusRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户点击状态 服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
public interface ClickStatusService extends IService<ClickStatus>, ClickStatusCalcApi {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param portalClickStatusRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
void add(ClickStatusRequest portalClickStatusRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param portalClickStatusRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
void del(ClickStatusRequest portalClickStatusRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param portalClickStatusRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
void edit(ClickStatusRequest portalClickStatusRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param portalClickStatusRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
ClickStatus detail(ClickStatusRequest portalClickStatusRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param portalClickStatusRequest 请求参数
|
||||
* @return List<PortalClickStatus> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
List<ClickStatus> findList(ClickStatusRequest portalClickStatusRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param portalClickStatusRequest 请求参数
|
||||
* @return PageResult<PortalClickStatus> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
PageResult<ClickStatus> findPage(ClickStatusRequest portalClickStatusRequest);
|
||||
|
||||
/**
|
||||
* 获取用户是否点击过这条记录
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param businessId 业务id
|
||||
* @return 用户点击状态,true-点击过,false-没点击过
|
||||
* @author fengshuonan
|
||||
* @since 2023/3/28 15:31
|
||||
*/
|
||||
boolean getUserBusinessClickFlag(Long userId, Long businessId);
|
||||
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.stat.api.callback.ClickCountCallback;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.entity.ClickCount;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.enums.ClickCountExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.mapper.ClickCountMapper;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.request.ClickCountRequest;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.service.ClickCountService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户点击数量统计业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@Service
|
||||
public class ClickCountServiceImpl extends ServiceImpl<ClickCountMapper, ClickCount> implements ClickCountService {
|
||||
|
||||
@Override
|
||||
public void add(ClickCountRequest portalClickCountRequest) {
|
||||
ClickCount portalClickCount = new ClickCount();
|
||||
BeanUtil.copyProperties(portalClickCountRequest, portalClickCount);
|
||||
this.save(portalClickCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(ClickCountRequest portalClickCountRequest) {
|
||||
ClickCount portalClickCount = this.queryPortalClickCount(portalClickCountRequest);
|
||||
this.removeById(portalClickCount.getClickCountId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(ClickCountRequest portalClickCountRequest) {
|
||||
ClickCount portalClickCount = this.queryPortalClickCount(portalClickCountRequest);
|
||||
BeanUtil.copyProperties(portalClickCountRequest, portalClickCount);
|
||||
this.updateById(portalClickCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickCount detail(ClickCountRequest portalClickCountRequest) {
|
||||
return this.queryPortalClickCount(portalClickCountRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ClickCount> findPage(ClickCountRequest portalClickCountRequest) {
|
||||
LambdaQueryWrapper<ClickCount> wrapper = createWrapper(portalClickCountRequest);
|
||||
Page<ClickCount> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getBusinessCount(Long businessId) {
|
||||
LambdaQueryWrapper<ClickCount> portalClickCountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
portalClickCountLambdaQueryWrapper.eq(ClickCount::getBusinessKeyId, businessId);
|
||||
portalClickCountLambdaQueryWrapper.select(ClickCount::getClickCount);
|
||||
ClickCount one = this.getOne(portalClickCountLambdaQueryWrapper, false);
|
||||
if (one != null) {
|
||||
return one.getClickCount();
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClickCount> findList(ClickCountRequest portalClickCountRequest) {
|
||||
LambdaQueryWrapper<ClickCount> wrapper = this.createWrapper(portalClickCountRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ClickCountCallback> void calcClickCount(List<T> clickCountCallbackList) {
|
||||
|
||||
if (ObjectUtil.isEmpty(clickCountCallbackList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (T clickCountCallback : clickCountCallbackList) {
|
||||
Long businessId = clickCountCallback.getBusinessId();
|
||||
Long clickCount = this.getBusinessCount(businessId);
|
||||
clickCountCallback.addClickCount(clickCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long addOneClickCount(ClickCountCallback clickCountCallback) {
|
||||
LambdaQueryWrapper<ClickCount> portalClickCountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
portalClickCountLambdaQueryWrapper.eq(ClickCount::getBusinessKeyId, clickCountCallback.getBusinessId());
|
||||
ClickCount portalClickCount = this.getOne(portalClickCountLambdaQueryWrapper, false);
|
||||
|
||||
// 记录不存在,则直接新增一条记录
|
||||
if (portalClickCount == null) {
|
||||
portalClickCount = new ClickCount();
|
||||
portalClickCount.setBusinessType(clickCountCallback.getBusinessTypeCode());
|
||||
portalClickCount.setBusinessKeyId(clickCountCallback.getBusinessId());
|
||||
portalClickCount.setClickCount(1L);
|
||||
this.save(portalClickCount);
|
||||
} else {
|
||||
// 如果记录存在则直接加1
|
||||
portalClickCount.setClickCount(portalClickCount.getClickCount() + 1);
|
||||
this.updateById(portalClickCount);
|
||||
}
|
||||
|
||||
return portalClickCount.getClickCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
private ClickCount queryPortalClickCount(ClickCountRequest portalClickCountRequest) {
|
||||
ClickCount portalClickCount = this.getById(portalClickCountRequest.getClickCountId());
|
||||
if (ObjectUtil.isEmpty(portalClickCount)) {
|
||||
throw new ServiceException(ClickCountExceptionEnum.PORTAL_CLICK_COUNT_NOT_EXISTED);
|
||||
}
|
||||
return portalClickCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
private LambdaQueryWrapper<ClickCount> createWrapper(ClickCountRequest portalClickCountRequest) {
|
||||
LambdaQueryWrapper<ClickCount> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long clickCountId = portalClickCountRequest.getClickCountId();
|
||||
String businessType = portalClickCountRequest.getBusinessType();
|
||||
Long businessKeyId = portalClickCountRequest.getBusinessKeyId();
|
||||
Long clickCount = portalClickCountRequest.getClickCount();
|
||||
Long tenantId = portalClickCountRequest.getTenantId();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(clickCountId), ClickCount::getClickCountId, clickCountId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(businessType), ClickCount::getBusinessType, businessType);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(businessKeyId), ClickCount::getBusinessKeyId, businessKeyId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(clickCount), ClickCount::getClickCount, clickCount);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), ClickCount::getTenantId, tenantId);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.stat.api.callback.ClickStatusCallback;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.entity.ClickStatus;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.enums.ClickStatusExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.mapper.ClickStatusMapper;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.request.ClickStatusRequest;
|
||||
import cn.stylefeng.roses.kernel.stat.modular.service.ClickStatusService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户点击状态业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
@Service
|
||||
public class ClickStatusServiceImpl extends ServiceImpl<ClickStatusMapper, ClickStatus> implements ClickStatusService {
|
||||
|
||||
@Override
|
||||
public void add(ClickStatusRequest portalClickStatusRequest) {
|
||||
ClickStatus portalClickStatus = new ClickStatus();
|
||||
BeanUtil.copyProperties(portalClickStatusRequest, portalClickStatus);
|
||||
this.save(portalClickStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(ClickStatusRequest portalClickStatusRequest) {
|
||||
ClickStatus portalClickStatus = this.queryPortalClickStatus(portalClickStatusRequest);
|
||||
this.removeById(portalClickStatus.getClickStatusId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(ClickStatusRequest portalClickStatusRequest) {
|
||||
ClickStatus portalClickStatus = this.queryPortalClickStatus(portalClickStatusRequest);
|
||||
BeanUtil.copyProperties(portalClickStatusRequest, portalClickStatus);
|
||||
this.updateById(portalClickStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickStatus detail(ClickStatusRequest portalClickStatusRequest) {
|
||||
return this.queryPortalClickStatus(portalClickStatusRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ClickStatus> findPage(ClickStatusRequest portalClickStatusRequest) {
|
||||
LambdaQueryWrapper<ClickStatus> wrapper = createWrapper(portalClickStatusRequest);
|
||||
Page<ClickStatus> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUserBusinessClickFlag(Long userId, Long businessId) {
|
||||
LambdaQueryWrapper<ClickStatus> portalClickStatusLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
portalClickStatusLambdaQueryWrapper.eq(ClickStatus::getUserId, userId);
|
||||
portalClickStatusLambdaQueryWrapper.eq(ClickStatus::getBusinessKeyId, businessId);
|
||||
long count = this.count(portalClickStatusLambdaQueryWrapper);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClickStatus> findList(ClickStatusRequest portalClickStatusRequest) {
|
||||
LambdaQueryWrapper<ClickStatus> wrapper = this.createWrapper(portalClickStatusRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ClickStatusCallback> void calcClickStatus(List<T> clickStatusCallbackList) {
|
||||
|
||||
if (ObjectUtil.isEmpty(clickStatusCallbackList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (T clickStatusCallback : clickStatusCallbackList) {
|
||||
|
||||
// 获取这条记录的用户id
|
||||
Long userId = clickStatusCallback.getUserId();
|
||||
|
||||
// 获取这条记录的业务id
|
||||
Long businessId = clickStatusCallback.getBusinessId();
|
||||
|
||||
// 查询这个用户有没有点击过这个记录
|
||||
boolean userBusinessClickFlag = this.getUserBusinessClickFlag(userId, businessId);
|
||||
if (userBusinessClickFlag) {
|
||||
clickStatusCallback.addClickStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClickStatus(ClickStatusCallback clickStatusCallback) {
|
||||
|
||||
Long userId = clickStatusCallback.getUserId();
|
||||
Long businessId = clickStatusCallback.getBusinessId();
|
||||
|
||||
// 获取是否已经点击过,点击过就不记录了
|
||||
boolean userBusinessClickFlag = this.getUserBusinessClickFlag(userId, businessId);
|
||||
if (userBusinessClickFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加点击录
|
||||
ClickStatus portalClickStatus = new ClickStatus();
|
||||
portalClickStatus.setUserId(userId);
|
||||
portalClickStatus.setBusinessType(clickStatusCallback.getBusinessTypeCode());
|
||||
portalClickStatus.setBusinessKeyId(businessId);
|
||||
this.save(portalClickStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
private ClickStatus queryPortalClickStatus(ClickStatusRequest portalClickStatusRequest) {
|
||||
ClickStatus portalClickStatus = this.getById(portalClickStatusRequest.getClickStatusId());
|
||||
if (ObjectUtil.isEmpty(portalClickStatus)) {
|
||||
throw new ServiceException(ClickStatusExceptionEnum.PORTAL_CLICK_STATUS_NOT_EXISTED);
|
||||
}
|
||||
return portalClickStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/03/28 14:52
|
||||
*/
|
||||
private LambdaQueryWrapper<ClickStatus> createWrapper(ClickStatusRequest portalClickStatusRequest) {
|
||||
LambdaQueryWrapper<ClickStatus> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long clickStatusId = portalClickStatusRequest.getClickStatusId();
|
||||
Long userId = portalClickStatusRequest.getUserId();
|
||||
Long businessKeyId = portalClickStatusRequest.getBusinessKeyId();
|
||||
String businessType = portalClickStatusRequest.getBusinessType();
|
||||
Long tenantId = portalClickStatusRequest.getTenantId();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(clickStatusId), ClickStatus::getClickStatusId, clickStatusId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(userId), ClickStatus::getUserId, userId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(businessKeyId), ClickStatus::getBusinessKeyId, businessKeyId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(businessType), ClickStatus::getBusinessType, businessType);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), ClickStatus::getTenantId, tenantId);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.stat.modular.service;
|
|
@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
* 点击统计自动装配
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023-05-10 10:10:15
|
||||
* @since 2023-05-10 10:10:15
|
||||
*/
|
||||
@Configuration
|
||||
public class StatAutoConfiguration {
|
||||
|
|
Loading…
Reference in New Issue