From cc4d12af51a1213922096567c00d4129c396edf9 Mon Sep 17 00:00:00 2001 From: wxz Date: Mon, 2 Dec 2024 10:42:18 +0800 Subject: [PATCH] init --- .gitignore | 25 ++ pom.xml | 230 ++++++++++++++++++ zhongyun-common/pom.xml | 16 ++ .../zhongyun/common/constant/Constant.java | 215 ++++++++++++++++ .../java/com/zhongyun/common/dao/BaseDao.java | 15 ++ .../zhongyun/common/entity/BaseEntity.java | 35 +++ .../zhongyun/common/exception/ErrorCode.java | 67 +++++ .../common/exception/RenException.java | 69 ++++++ .../com/zhongyun/common/page/PageData.java | 37 +++ .../zhongyun/common/service/BaseService.java | 110 +++++++++ .../zhongyun/common/service/CrudService.java | 28 +++ .../common/service/impl/BaseServiceImpl.java | 213 ++++++++++++++++ .../common/service/impl/CrudServiceImpl.java | 72 ++++++ .../zhongyun/common/utils/ConvertUtils.java | 54 ++++ .../com/zhongyun/common/utils/DateUtils.java | 176 ++++++++++++++ .../zhongyun/common/utils/MessageUtils.java | 27 ++ .../com/zhongyun/common/utils/Result.java | 92 +++++++ .../common/utils/SpringContextUtils.java | 49 ++++ .../common/validator/AssertUtils.java | 92 +++++++ .../common/validator/ValidatorUtils.java | 51 ++++ .../common/validator/group/AddGroup.java | 13 + .../common/validator/group/DefaultGroup.java | 13 + .../common/validator/group/Group.java | 16 ++ .../common/validator/group/UpdateGroup.java | 13 + zhongyun-points-admin/pom.xml | 197 +++++++++++++++ .../com/zhongyun/PointsAdminApplication.java | 23 ++ .../com/zhongyun/annotation/LogOperation.java | 18 ++ .../cloud/LocalCloudStorageService.java | 66 +++++ .../config/LocalCloudStorageConfig.java | 23 ++ .../common/config/MybatisPlusConfig.java | 37 +++ .../zhongyun/common/config/SwaggerConfig.java | 65 +++++ .../com/zhongyun/common/group/LocalGroup.java | 11 + .../handler/FieldMetaObjectHandler.java | 36 +++ .../zhongyun/controller/DetailController.java | 73 ++++++ .../zhongyun/controller/LevelController.java | 58 +++++ .../zhongyun/controller/RuleController.java | 61 +++++ .../controller/StatisticsController.java | 64 +++++ .../zhongyun/controller/SysOssController.java | 54 ++++ .../zhongyun/controller/UserController.java | 90 +++++++ .../controller/ValidityController.java | 59 +++++ .../main/java/com/zhongyun/dao/DetailDao.java | 21 ++ .../main/java/com/zhongyun/dao/LevelDao.java | 22 ++ .../main/java/com/zhongyun/dao/RuleDao.java | 22 ++ .../java/com/zhongyun/dao/StatisticsDao.java | 29 +++ .../main/java/com/zhongyun/dao/SysOssDao.java | 18 ++ .../main/java/com/zhongyun/dao/UserDao.java | 28 +++ .../java/com/zhongyun/dao/ValidityDao.java | 19 ++ .../main/java/com/zhongyun/dto/DetailDTO.java | 48 ++++ .../main/java/com/zhongyun/dto/EarnDTO.java | 26 ++ .../main/java/com/zhongyun/dto/LevelDTO.java | 50 ++++ .../main/java/com/zhongyun/dto/MonthDTO.java | 28 +++ .../main/java/com/zhongyun/dto/RuleDTO.java | 54 ++++ .../java/com/zhongyun/dto/StatisticsDTO.java | 30 +++ .../java/com/zhongyun/dto/TransformDTO.java | 40 +++ .../main/java/com/zhongyun/dto/UserDTO.java | 51 ++++ .../java/com/zhongyun/dto/ValidityDTO.java | 25 ++ .../com/zhongyun/entity/DetailEntity.java | 73 ++++++ .../java/com/zhongyun/entity/LevelEntity.java | 63 +++++ .../java/com/zhongyun/entity/RuleEntity.java | 62 +++++ .../com/zhongyun/entity/SysOssEntity.java | 43 ++++ .../java/com/zhongyun/entity/UserEntity.java | 75 ++++++ .../com/zhongyun/entity/ValidityEntity.java | 39 +++ .../scheduler/PointExpirationScheduler.java | 28 +++ .../com/zhongyun/service/DetailService.java | 31 +++ .../com/zhongyun/service/LevelService.java | 25 ++ .../com/zhongyun/service/RuleService.java | 28 +++ .../zhongyun/service/StatisticsService.java | 30 +++ .../com/zhongyun/service/UserService.java | 28 +++ .../com/zhongyun/service/ValidityService.java | 19 ++ .../service/impl/DetailServiceImpl.java | 202 +++++++++++++++ .../service/impl/LevelServiceImpl.java | 44 ++++ .../service/impl/RulelServiceImpl.java | 44 ++++ .../service/impl/StatisticsServiceImpl.java | 62 +++++ .../service/impl/UserServiceImpl.java | 74 ++++++ .../service/impl/ValidityServiceImpl.java | 41 ++++ .../src/main/resources/bootstrap-dev.yml | 108 ++++++++ .../src/main/resources/bootstrap.yml | 16 ++ .../src/main/resources/logback-spring.xml | 21 ++ .../src/main/resources/mapper/DetaiDao.xml | 20 ++ .../src/main/resources/mapper/LevelDao.xml | 13 + .../src/main/resources/mapper/RuleDao.xml | 10 + .../main/resources/mapper/StatisticsDao.xml | 97 ++++++++ .../src/main/resources/mapper/UserDao.xml | 39 +++ .../src/main/resources/mapper/ValidityDao.xml | 19 ++ 84 files changed, 4528 insertions(+) create mode 100644 pom.xml create mode 100644 zhongyun-common/pom.xml create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/constant/Constant.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/dao/BaseDao.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/entity/BaseEntity.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/exception/ErrorCode.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/exception/RenException.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/page/PageData.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/service/BaseService.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/service/CrudService.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/service/impl/BaseServiceImpl.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/service/impl/CrudServiceImpl.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/utils/ConvertUtils.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/utils/DateUtils.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/utils/MessageUtils.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/utils/Result.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/utils/SpringContextUtils.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/validator/AssertUtils.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/validator/ValidatorUtils.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/validator/group/AddGroup.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/validator/group/DefaultGroup.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/validator/group/Group.java create mode 100644 zhongyun-common/src/main/java/com/zhongyun/common/validator/group/UpdateGroup.java create mode 100644 zhongyun-points-admin/pom.xml create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/PointsAdminApplication.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/annotation/LogOperation.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/common/cloud/LocalCloudStorageService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/common/config/LocalCloudStorageConfig.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/common/config/MybatisPlusConfig.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/common/config/SwaggerConfig.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/common/group/LocalGroup.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/common/handler/FieldMetaObjectHandler.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/DetailController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/LevelController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/RuleController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/StatisticsController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/SysOssController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/UserController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/controller/ValidityController.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/DetailDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/LevelDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/RuleDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/StatisticsDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/SysOssDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/UserDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dao/ValidityDao.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/DetailDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/EarnDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/LevelDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/MonthDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/RuleDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/StatisticsDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/TransformDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/UserDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/dto/ValidityDTO.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/entity/DetailEntity.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/entity/LevelEntity.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/entity/RuleEntity.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/entity/SysOssEntity.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/entity/UserEntity.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/entity/ValidityEntity.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/scheduler/PointExpirationScheduler.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/DetailService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/LevelService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/RuleService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/StatisticsService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/UserService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/ValidityService.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/DetailServiceImpl.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/LevelServiceImpl.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/RulelServiceImpl.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/StatisticsServiceImpl.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/UserServiceImpl.java create mode 100644 zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/ValidityServiceImpl.java create mode 100644 zhongyun-points-admin/src/main/resources/bootstrap-dev.yml create mode 100644 zhongyun-points-admin/src/main/resources/bootstrap.yml create mode 100644 zhongyun-points-admin/src/main/resources/logback-spring.xml create mode 100644 zhongyun-points-admin/src/main/resources/mapper/DetaiDao.xml create mode 100644 zhongyun-points-admin/src/main/resources/mapper/LevelDao.xml create mode 100644 zhongyun-points-admin/src/main/resources/mapper/RuleDao.xml create mode 100644 zhongyun-points-admin/src/main/resources/mapper/StatisticsDao.xml create mode 100644 zhongyun-points-admin/src/main/resources/mapper/UserDao.xml create mode 100644 zhongyun-points-admin/src/main/resources/mapper/ValidityDao.xml diff --git a/.gitignore b/.gitignore index cea1456..ab8e712 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,15 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ +target # ---> JetBrains # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 @@ -74,3 +86,16 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar +*.iml +.idea + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..91ecc78 --- /dev/null +++ b/pom.xml @@ -0,0 +1,230 @@ + + 4.0.0 + com.zhongyun + zhongyun-points + 1.0.0 + pom + + points + points + https://www.xxxxx.io + + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.11.RELEASE + + + + zhongyun-common + zhongyun-points-admin + + + + UTF-8 + UTF-8 + 1.8 + 4.12 + 3.5.2 + 1.2.14 + 3.4.2 + 4.0 + 11.2.0.3 + 8.1.2.141 + 3.7 + 1.3.1 + 2.5 + 1.10 + 20.0 + 2.9.9 + 5.7.22 + 8.0.20 + 2.8.6 + 1.11.3 + 2.0.9 + 1.18.4 + 1.1.1 + Greenwich.SR4 + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + 2.1.0.RELEASE + pom + import + + + junit + junit + ${junit.version} + test + + + org.springframework.boot + spring-boot-starter-test + test + + + log4j-api + org.apache.logging.log4j + + + log4j-to-slf4j + org.apache.logging.log4j + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + mysql + mysql-connector-java + ${mysql.version} + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + com.baomidou + mybatis-plus-boot-starter + ${mybatisplus.version} + + + org.apache.commons + commons-lang3 + ${commons.lang.version} + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + + commons-io + commons-io + ${commons.io.version} + + + commons-codec + commons-codec + ${commons.codec.version} + + + com.google.guava + guava + ${guava.version} + + + joda-time + joda-time + ${joda.time.version} + + + com.google.code.gson + gson + ${gson.version} + + + cn.hutool + hutool-all + ${hutool.version} + + + org.jsoup + jsoup + ${jsoup.version} + + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + + org.springframework.plugin + spring-plugin-core + + + + + + org.springframework.plugin + spring-plugin-core + 2.0.0.RELEASE + + + org.springframework.plugin + spring-plugin-metadata + 2.0.0.RELEASE + + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public/ + + true + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public/ + + true + + + false + + + + \ No newline at end of file diff --git a/zhongyun-common/pom.xml b/zhongyun-common/pom.xml new file mode 100644 index 0000000..467b6f7 --- /dev/null +++ b/zhongyun-common/pom.xml @@ -0,0 +1,16 @@ + + + com.zhongyun + zhongyun-points + 1.0.0 + + 4.0.0 + zhongyun-common + jar + zhongyun-common + + + ${project.artifactId} + + + \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/constant/Constant.java b/zhongyun-common/src/main/java/com/zhongyun/common/constant/Constant.java new file mode 100644 index 0000000..0320a2d --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/constant/Constant.java @@ -0,0 +1,215 @@ + + +package com.zhongyun.common.constant; + +/** + * 常量 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public interface Constant { + /** + * 成功 + */ + int SUCCESS = 1; + /** + * 失败 + */ + int FAIL = 0; + /** + * OK + */ + String OK = "OK"; + /** + * 用户标识 + */ + String USER_KEY = "userId"; + /** + * 菜单根节点标识 + */ + Long MENU_ROOT = 0L; + /** + * 部门根节点标识 + */ + Long DEPT_ROOT = 0L; + /** + * 数据字典根节点标识 + */ + Long DICT_ROOT = 0L; + /** + * 升序 + */ + String ASC = "asc"; + /** + * 降序 + */ + String DESC = "desc"; + /** + * 创建时间字段名 + */ + String CREATE_DATE = "create_date"; + + /** + * 创建时间字段名 + */ + String ID = "id"; + + /** + * 数据权限过滤 + */ + String SQL_FILTER = "sqlFilter"; + + /** + * 当前页码 + */ + String PAGE = "page"; + /** + * 每页显示记录数 + */ + String LIMIT = "limit"; + /** + * 排序字段 + */ + String ORDER_FIELD = "orderField"; + /** + * 排序方式 + */ + String ORDER = "order"; + /** + * token header + */ + String TOKEN_HEADER = "token"; + + /** + * 云存储配置KEY + */ + String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY"; + /** + * 邮件配置KEY + */ + String MAIL_CONFIG_KEY = "MAIL_CONFIG_KEY"; + /** + * 代码生成参数KEY + */ + String DEV_TOOLS_PARAM_KEY = "DEV_TOOLS_PARAM_KEY"; + + /** + * 定时任务状态 + */ + enum ScheduleStatus { + /** + * 暂停 + */ + PAUSE(0), + /** + * 正常 + */ + NORMAL(1); + + private int value; + + ScheduleStatus(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 云服务商 + */ + enum CloudService { + /** + * 七牛云 + */ + QINIU(1), + /** + * 阿里云 + */ + ALIYUN(2), + /** + * 腾讯云 + */ + QCLOUD(3), + /** + * FASTDFS + */ + FASTDFS(4), + /** + * 本地 + */ + LOCAL(5), + /** + * MinIO + */ + MINIO(6); + + private int value; + + CloudService(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 短信服务商 + */ + enum SmsService { + /** + * 阿里云 + */ + ALIYUN(1), + /** + * 腾讯云 + */ + QCLOUD(2), + /** + * 七牛 + */ + QINIU(3); + + private int value; + + SmsService(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + /** + * 订单状态 + */ + enum OrderStatus { + /** + * 已取消 + */ + CANCEL(-1), + /** + * 等待付款 + */ + WAITING(0), + /** + * 已完成 + */ + FINISH(1); + + private int value; + + OrderStatus(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/dao/BaseDao.java b/zhongyun-common/src/main/java/com/zhongyun/common/dao/BaseDao.java new file mode 100644 index 0000000..602c767 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/dao/BaseDao.java @@ -0,0 +1,15 @@ + + +package com.zhongyun.common.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * 基础Dao + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public interface BaseDao extends BaseMapper { + +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/entity/BaseEntity.java b/zhongyun-common/src/main/java/com/zhongyun/common/entity/BaseEntity.java new file mode 100644 index 0000000..6afa87a --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/entity/BaseEntity.java @@ -0,0 +1,35 @@ + + +package com.zhongyun.common.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 基础实体类,所有实体都需要继承 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +public abstract class BaseEntity implements Serializable { + /** + * id + */ + @TableId + private Long id; + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/exception/ErrorCode.java b/zhongyun-common/src/main/java/com/zhongyun/common/exception/ErrorCode.java new file mode 100644 index 0000000..9c480b7 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/exception/ErrorCode.java @@ -0,0 +1,67 @@ + + +package com.zhongyun.common.exception; + +/** + * 错误编码,由5位数字组成,前2位为模块编码,后3位为业务编码 + *

+ * 如:10001(10代表系统模块,001代表业务代码) + *

+ * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public interface ErrorCode { + int INTERNAL_SERVER_ERROR = 500; + int UNAUTHORIZED = 401; + int FORBIDDEN = 403; + + int NOT_NULL = 10001; + int DB_RECORD_EXISTS = 10002; + int PARAMS_GET_ERROR = 10003; + int ACCOUNT_PASSWORD_ERROR = 10004; + int ACCOUNT_DISABLE = 10005; + int IDENTIFIER_NOT_NULL = 10006; + int CAPTCHA_ERROR = 10007; + int SUB_MENU_EXIST = 10008; + int PASSWORD_ERROR = 10009; + int ACCOUNT_NOT_EXIST = 10010; + int SUPERIOR_DEPT_ERROR = 10011; + int SUPERIOR_MENU_ERROR = 10012; + int DATA_SCOPE_PARAMS_ERROR = 10013; + int DEPT_SUB_DELETE_ERROR = 10014; + int DEPT_USER_DELETE_ERROR = 10015; + int ACT_DEPLOY_ERROR = 10016; + int ACT_MODEL_IMG_ERROR = 10017; + int ACT_MODEL_EXPORT_ERROR = 10018; + int UPLOAD_FILE_EMPTY = 10019; + int TOKEN_NOT_EMPTY = 10020; + int TOKEN_INVALID = 10021; + int ACCOUNT_LOCK = 10022; + int ACT_DEPLOY_FORMAT_ERROR = 10023; + int OSS_UPLOAD_FILE_ERROR = 10024; + int SEND_SMS_ERROR = 10025; + int MAIL_TEMPLATE_NOT_EXISTS = 10026; + int REDIS_ERROR = 10027; + int JOB_ERROR = 10028; + int INVALID_SYMBOL = 10029; + int JSON_FORMAT_ERROR = 10030; + int SMS_CONFIG = 10031; + int TASK_CLIME_FAIL = 10032; + int NONE_EXIST_PROCESS = 10033; + int SUPERIOR_NOT_EXIST = 10034; + int REJECT_MESSAGE = 10035; + int ROLLBACK_MESSAGE = 10036; + int UNCLAIM_ERROR_MESSAGE = 10037; + int SUPERIOR_REGION_ERROR = 10038; + int REGION_SUB_DELETE_ERROR = 10039; + int PROCESS_START_ERROR = 10040; + int REJECT_PROCESS_PARALLEL_ERROR = 10041; + int REJECT_PROCESS_HANDLEING_ERROR = 10042; + int END_PROCESS_PARALLEL_ERROR = 10043; + int END_PROCESS_HANDLEING_ERROR = 10044; + int END_PROCESS_MESSAGE = 10045; + int BACK_PROCESS_PARALLEL_ERROR = 10046; + int BACK_PROCESS_HANDLEING_ERROR = 10047; + int DEL_MYSELF_ERROR = 10048; +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/exception/RenException.java b/zhongyun-common/src/main/java/com/zhongyun/common/exception/RenException.java new file mode 100644 index 0000000..5acbbfa --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/exception/RenException.java @@ -0,0 +1,69 @@ + + +package com.zhongyun.common.exception; + + +import com.zhongyun.common.utils.MessageUtils; + +/** + * 自定义异常 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public class RenException extends RuntimeException { + private static final long serialVersionUID = 1L; + + private int code; + private String msg; + + public RenException(int code) { + this.code = code; + this.msg = MessageUtils.getMessage(code); + } + + public RenException(int code, String... params) { + this.code = code; + this.msg = MessageUtils.getMessage(code, params); + } + + public RenException(int code, Throwable e) { + super(e); + this.code = code; + this.msg = MessageUtils.getMessage(code); + } + + public RenException(int code, Throwable e, String... params) { + super(e); + this.code = code; + this.msg = MessageUtils.getMessage(code, params); + } + + public RenException(String msg) { + super(msg); + this.code = ErrorCode.INTERNAL_SERVER_ERROR; + this.msg = msg; + } + + public RenException(String msg, Throwable e) { + super(msg, e); + this.code = ErrorCode.INTERNAL_SERVER_ERROR; + this.msg = msg; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/page/PageData.java b/zhongyun-common/src/main/java/com/zhongyun/common/page/PageData.java new file mode 100644 index 0000000..135f757 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/page/PageData.java @@ -0,0 +1,37 @@ + + +package com.zhongyun.common.page; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 分页工具类 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +@ApiModel(value = "分页数据") +public class PageData implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "总记录数") + private int total; + + @ApiModelProperty(value = "列表数据") + private List list; + + /** + * 分页 + * @param list 列表数据 + * @param total 总记录数 + */ + public PageData(List list, long total) { + this.list = list; + this.total = (int)total; + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/service/BaseService.java b/zhongyun-common/src/main/java/com/zhongyun/common/service/BaseService.java new file mode 100644 index 0000000..57e2bed --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/service/BaseService.java @@ -0,0 +1,110 @@ + + +package com.zhongyun.common.service; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; + +import java.io.Serializable; +import java.util.Collection; + +/** + * 基础服务接口,所有Service接口都要继承 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public interface BaseService { + Class currentModelClass(); + + /** + *

+ * 插入一条记录(选择字段,策略插入) + *

+ * + * @param entity 实体对象 + */ + boolean insert(T entity); + + /** + *

+ * 插入(批量),该方法不支持 Oracle、SQL Server + *

+ * + * @param entityList 实体对象集合 + */ + boolean insertBatch(Collection entityList); + + /** + *

+ * 插入(批量),该方法不支持 Oracle、SQL Server + *

+ * + * @param entityList 实体对象集合 + * @param batchSize 插入批次数量 + */ + boolean insertBatch(Collection entityList, int batchSize); + + /** + *

+ * 根据 ID 选择修改 + *

+ * + * @param entity 实体对象 + */ + boolean updateById(T entity); + + /** + *

+ * 根据 whereEntity 条件,更新记录 + *

+ * + * @param entity 实体对象 + * @param updateWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper} + */ + boolean update(T entity, Wrapper updateWrapper); + + /** + *

+ * 根据ID 批量更新 + *

+ * + * @param entityList 实体对象集合 + */ + boolean updateBatchById(Collection entityList); + + /** + *

+ * 根据ID 批量更新 + *

+ * + * @param entityList 实体对象集合 + * @param batchSize 更新批次数量 + */ + boolean updateBatchById(Collection entityList, int batchSize); + + /** + *

+ * 根据 ID 查询 + *

+ * + * @param id 主键ID + */ + T selectById(Serializable id); + + /** + *

+ * 根据 ID 删除 + *

+ * + * @param id 主键ID + */ + boolean deleteById(Serializable id); + + /** + *

+ * 删除(根据ID 批量删除) + *

+ * + * @param idList 主键ID列表 + */ + boolean deleteBatchIds(Collection idList); +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/service/CrudService.java b/zhongyun-common/src/main/java/com/zhongyun/common/service/CrudService.java new file mode 100644 index 0000000..9fa1617 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/service/CrudService.java @@ -0,0 +1,28 @@ +package com.zhongyun.common.service; + + +import com.zhongyun.common.page.PageData; + +import java.util.List; +import java.util.Map; + +/** + * CRUD基础服务接口 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public interface CrudService extends BaseService { + + PageData page(Map params); + + List list(Map params); + + D get(Long id); + + void save(D dto); + + void update(D dto); + + void delete(Long[] ids); + +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/service/impl/BaseServiceImpl.java b/zhongyun-common/src/main/java/com/zhongyun/common/service/impl/BaseServiceImpl.java new file mode 100644 index 0000000..8311ea8 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/service/impl/BaseServiceImpl.java @@ -0,0 +1,213 @@ + + +package com.zhongyun.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.enums.SqlMethod; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.zhongyun.common.constant.Constant; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.BaseService; +import com.zhongyun.common.utils.ConvertUtils; +import org.apache.ibatis.binding.MapperMethod; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.logging.LogFactory; +import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; + +/** + * 基础服务类,所有Service都要继承 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public abstract class BaseServiceImpl, T> implements BaseService { + @Autowired + protected M baseDao; + protected Log log = LogFactory.getLog(getClass()); + + /** + * 获取分页对象 + * @param params 分页查询参数 + * @param defaultOrderField 默认排序字段 + * @param isAsc 排序方式 + */ + protected IPage getPage(Map params, String defaultOrderField, boolean isAsc) { + //分页参数 + long curPage = 1; + long limit = 10; + + if(params.get(Constant.PAGE) != null){ + curPage = Long.parseLong((String)params.get(Constant.PAGE)); + } + if(params.get(Constant.LIMIT) != null){ + limit = Long.parseLong((String)params.get(Constant.LIMIT)); + } + + //分页对象 + Page page = new Page<>(curPage, limit); + + //分页参数 + params.put(Constant.PAGE, page); + + //排序字段 + String orderField = (String)params.get(Constant.ORDER_FIELD); + String order = (String)params.get(Constant.ORDER); + + //前端字段排序 + if(StringUtils.isNotBlank(orderField) && StringUtils.isNotBlank(order)){ + if(Constant.ASC.equalsIgnoreCase(order)) { + return page.addOrder(OrderItem.asc(orderField)); + }else { + return page.addOrder(OrderItem.desc(orderField)); + } + } + + //没有排序字段,则不排序 + if(StringUtils.isBlank(defaultOrderField)){ + return page; + } + + //默认排序 + if(isAsc) { + page.addOrder(OrderItem.asc(defaultOrderField)); + }else { + page.addOrder(OrderItem.desc(defaultOrderField)); + } + + return page; + } + + protected PageData getPageData(List list, long total, Class target){ + List targetList = ConvertUtils.sourceToTarget(list, target); + + return new PageData<>(targetList, total); + } + + protected PageData getPageData(IPage page, Class target){ + return getPageData(page.getRecords(), page.getTotal(), target); + } + + protected void paramsToLike(Map params, String... likes){ + for (String like : likes){ + String val = (String)params.get(like); + if (StringUtils.isNotBlank(val)){ + params.put(like, "%" + val + "%"); + }else { + params.put(like, null); + } + } + } + + /** + *

+ * 判断数据库操作是否成功 + *

+ *

+ * 注意!! 该方法为 Integer 判断,不可传入 int 基本类型 + *

+ * + * @param result 数据库操作返回影响条数 + * @return boolean + */ + protected static boolean retBool(Integer result) { + return SqlHelper.retBool(result); + } + + protected Class currentMapperClass() { + return (Class) ReflectionKit.getSuperClassGenericType(getClass(), 0); + } + + @Override + public Class currentModelClass() { + return (Class)ReflectionKit.getSuperClassGenericType(getClass(), 1); + } + + protected String getSqlStatement(SqlMethod sqlMethod) { + return SqlHelper.getSqlStatement(this.currentMapperClass(), sqlMethod); + } + + @Override + public boolean insert(T entity) { + return BaseServiceImpl.retBool(baseDao.insert(entity)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean insertBatch(Collection entityList) { + return insertBatch(entityList, 100); + } + + /** + * 批量插入 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean insertBatch(Collection entityList, int batchSize) { + String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE); + return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity)); + } + + /** + * 执行批量操作 + */ + protected boolean executeBatch(Collection list, int batchSize, BiConsumer consumer) { + return SqlHelper.executeBatch(this.currentModelClass(), this.log, list, batchSize, consumer); + } + + + @Override + public boolean updateById(T entity) { + return BaseServiceImpl.retBool(baseDao.updateById(entity)); + } + + @Override + public boolean update(T entity, Wrapper updateWrapper) { + return BaseServiceImpl.retBool(baseDao.update(entity, updateWrapper)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateBatchById(Collection entityList) { + return updateBatchById(entityList, 30); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateBatchById(Collection entityList, int batchSize) { + String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID); + return executeBatch(entityList, batchSize, (sqlSession, entity) -> { + MapperMethod.ParamMap param = new MapperMethod.ParamMap<>(); + param.put(Constants.ENTITY, entity); + sqlSession.update(sqlStatement, param); + }); + } + + @Override + public T selectById(Serializable id) { + return baseDao.selectById(id); + } + + @Override + public boolean deleteById(Serializable id) { + return SqlHelper.retBool(baseDao.deleteById(id)); + } + + @Override + public boolean deleteBatchIds(Collection idList) { + return SqlHelper.retBool(baseDao.deleteBatchIds(idList)); + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/service/impl/CrudServiceImpl.java b/zhongyun-common/src/main/java/com/zhongyun/common/service/impl/CrudServiceImpl.java new file mode 100644 index 0000000..b3b20ca --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/service/impl/CrudServiceImpl.java @@ -0,0 +1,72 @@ +package com.zhongyun.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.CrudService; +import com.zhongyun.common.utils.ConvertUtils; +import org.springframework.beans.BeanUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * CRUD基础服务类 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public abstract class CrudServiceImpl, T, D> extends BaseServiceImpl implements CrudService { + + protected Class currentDtoClass() { + return (Class)ReflectionKit.getSuperClassGenericType(getClass(), 2); + } + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, null, false), + getWrapper(params) + ); + + return getPageData(page, currentDtoClass()); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, currentDtoClass()); + } + + public abstract QueryWrapper getWrapper(Map params); + + @Override + public D get(Long id) { + T entity = baseDao.selectById(id); + + return ConvertUtils.sourceToTarget(entity, currentDtoClass()); + } + + @Override + public void save(D dto) { + T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); + insert(entity); + + //copy主键值到dto + BeanUtils.copyProperties(entity, dto); + } + + @Override + public void update(D dto) { + T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); + updateById(entity); + } + + @Override + public void delete(Long[] ids) { + baseDao.deleteBatchIds(Arrays.asList(ids)); + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/utils/ConvertUtils.java b/zhongyun-common/src/main/java/com/zhongyun/common/utils/ConvertUtils.java new file mode 100644 index 0000000..7a3d393 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/utils/ConvertUtils.java @@ -0,0 +1,54 @@ + + +package com.zhongyun.common.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * 转换工具类 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public class ConvertUtils { + private static Logger logger = LoggerFactory.getLogger(ConvertUtils.class); + + public static T sourceToTarget(Object source, Class target){ + if(source == null){ + return null; + } + T targetObject = null; + try { + targetObject = target.newInstance(); + BeanUtils.copyProperties(source, targetObject); + } catch (Exception e) { + logger.error("convert error ", e); + } + + return targetObject; + } + + public static List sourceToTarget(Collection sourceList, Class target){ + if(sourceList == null){ + return null; + } + + List targetList = new ArrayList<>(sourceList.size()); + try { + for(Object source : sourceList){ + T targetObject = target.newInstance(); + BeanUtils.copyProperties(source, targetObject); + targetList.add(targetObject); + } + }catch (Exception e){ + logger.error("convert error ", e); + } + + return targetList; + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/utils/DateUtils.java b/zhongyun-common/src/main/java/com/zhongyun/common/utils/DateUtils.java new file mode 100644 index 0000000..9eacf9b --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/utils/DateUtils.java @@ -0,0 +1,176 @@ + + +package com.zhongyun.common.utils; + +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 日期处理 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public class DateUtils { + /** 时间格式(yyyy-MM-dd) */ + public final static String DATE_PATTERN = "yyyy-MM-dd"; + /** 时间格式(yyyy-MM-dd HH:mm:ss) */ + public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; + + /** + * 日期格式化 日期格式为:yyyy-MM-dd + * @param date 日期 + * @return 返回yyyy-MM-dd格式日期 + */ + public static String format(Date date) { + return format(date, DATE_PATTERN); + } + + /** + * 日期格式化 日期格式为:yyyy-MM-dd + * @param date 日期 + * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN + * @return 返回yyyy-MM-dd格式日期 + */ + public static String format(Date date, String pattern) { + if(date != null){ + SimpleDateFormat df = new SimpleDateFormat(pattern); + return df.format(date); + } + return null; + } + + /** + * 日期解析 + * @param date 日期 + * @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN + * @return 返回Date + */ + public static Date parse(String date, String pattern) { + try { + return new SimpleDateFormat(pattern).parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + /** + * 字符串转换成日期 + * @param strDate 日期字符串 + * @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN + */ + public static Date stringToDate(String strDate, String pattern) { + if (StringUtils.isBlank(strDate)){ + return null; + } + + DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + return fmt.parseLocalDateTime(strDate).toDate(); + } + + /** + * 根据周数,获取开始日期、结束日期 + * @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周 + * @return 返回date[0]开始日期、date[1]结束日期 + */ + public static Date[] getWeekStartAndEnd(int week) { + DateTime dateTime = new DateTime(); + LocalDate date = new LocalDate(dateTime.plusWeeks(week)); + + date = date.dayOfWeek().withMinimumValue(); + Date beginDate = date.toDate(); + Date endDate = date.plusDays(6).toDate(); + return new Date[]{beginDate, endDate}; + } + + /** + * 对日期的【秒】进行加/减 + * + * @param date 日期 + * @param seconds 秒数,负数为减 + * @return 加/减几秒后的日期 + */ + public static Date addDateSeconds(Date date, int seconds) { + DateTime dateTime = new DateTime(date); + return dateTime.plusSeconds(seconds).toDate(); + } + + /** + * 对日期的【分钟】进行加/减 + * + * @param date 日期 + * @param minutes 分钟数,负数为减 + * @return 加/减几分钟后的日期 + */ + public static Date addDateMinutes(Date date, int minutes) { + DateTime dateTime = new DateTime(date); + return dateTime.plusMinutes(minutes).toDate(); + } + + /** + * 对日期的【小时】进行加/减 + * + * @param date 日期 + * @param hours 小时数,负数为减 + * @return 加/减几小时后的日期 + */ + public static Date addDateHours(Date date, int hours) { + DateTime dateTime = new DateTime(date); + return dateTime.plusHours(hours).toDate(); + } + + /** + * 对日期的【天】进行加/减 + * + * @param date 日期 + * @param days 天数,负数为减 + * @return 加/减几天后的日期 + */ + public static Date addDateDays(Date date, int days) { + DateTime dateTime = new DateTime(date); + return dateTime.plusDays(days).toDate(); + } + + /** + * 对日期的【周】进行加/减 + * + * @param date 日期 + * @param weeks 周数,负数为减 + * @return 加/减几周后的日期 + */ + public static Date addDateWeeks(Date date, int weeks) { + DateTime dateTime = new DateTime(date); + return dateTime.plusWeeks(weeks).toDate(); + } + + /** + * 对日期的【月】进行加/减 + * + * @param date 日期 + * @param months 月数,负数为减 + * @return 加/减几月后的日期 + */ + public static Date addDateMonths(Date date, int months) { + DateTime dateTime = new DateTime(date); + return dateTime.plusMonths(months).toDate(); + } + + /** + * 对日期的【年】进行加/减 + * + * @param date 日期 + * @param years 年数,负数为减 + * @return 加/减几年后的日期 + */ + public static Date addDateYears(Date date, int years) { + DateTime dateTime = new DateTime(date); + return dateTime.plusYears(years).toDate(); + } +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/utils/MessageUtils.java b/zhongyun-common/src/main/java/com/zhongyun/common/utils/MessageUtils.java new file mode 100644 index 0000000..742761b --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/utils/MessageUtils.java @@ -0,0 +1,27 @@ + + +package com.zhongyun.common.utils; + +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +/** + * 国际化 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public class MessageUtils { + private static MessageSource messageSource; + static { + messageSource = (MessageSource)SpringContextUtils.getBean("messageSource"); + } + + public static String getMessage(int code){ + return getMessage(code, new String[0]); + } + + public static String getMessage(int code, String... params){ + return messageSource.getMessage(code+"", params, LocaleContextHolder.getLocale()); + } +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/utils/Result.java b/zhongyun-common/src/main/java/com/zhongyun/common/utils/Result.java new file mode 100644 index 0000000..06786ed --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/utils/Result.java @@ -0,0 +1,92 @@ + + +package com.zhongyun.common.utils; + +import com.zhongyun.common.exception.ErrorCode; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * 响应数据 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +@ApiModel(value = "响应") +public class Result implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 编码:0表示成功,其他值表示失败 + */ + @ApiModelProperty(value = "编码:0表示成功,其他值表示失败") + private int code = 0; + /** + * 消息内容 + */ + @ApiModelProperty(value = "消息内容") + private String msg = "success"; + /** + * 响应数据 + */ + @ApiModelProperty(value = "响应数据") + private T data; + + public Result ok(T data) { + this.setData(data); + return this; + } + + public boolean success(){ + return code == 0 ? true : false; + } + + public Result error() { + this.code = ErrorCode.INTERNAL_SERVER_ERROR; + this.msg = MessageUtils.getMessage(this.code); + return this; + } + + public Result error(int code) { + this.code = code; + this.msg = MessageUtils.getMessage(this.code); + return this; + } + + public Result error(int code, String msg) { + this.code = code; + this.msg = msg; + return this; + } + + public Result error(String msg) { + this.code = ErrorCode.INTERNAL_SERVER_ERROR; + this.msg = msg; + return this; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/utils/SpringContextUtils.java b/zhongyun-common/src/main/java/com/zhongyun/common/utils/SpringContextUtils.java new file mode 100644 index 0000000..03359ec --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/utils/SpringContextUtils.java @@ -0,0 +1,49 @@ + + +package com.zhongyun.common.utils; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * Spring Context 工具类 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Component +public class SpringContextUtils implements ApplicationContextAware { + public static ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + SpringContextUtils.applicationContext = applicationContext; + } + + public static Object getBean(String name) { + return applicationContext.getBean(name); + } + + public static T getBean(Class requiredType) { + return applicationContext.getBean(requiredType); + } + + public static T getBean(String name, Class requiredType) { + return applicationContext.getBean(name, requiredType); + } + + public static boolean containsBean(String name) { + return applicationContext.containsBean(name); + } + + public static boolean isSingleton(String name) { + return applicationContext.isSingleton(name); + } + + public static Class getType(String name) { + return applicationContext.getType(name); + } + +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/validator/AssertUtils.java b/zhongyun-common/src/main/java/com/zhongyun/common/validator/AssertUtils.java new file mode 100644 index 0000000..895db10 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/validator/AssertUtils.java @@ -0,0 +1,92 @@ + + +package com.zhongyun.common.validator; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ArrayUtil; +import com.zhongyun.common.exception.ErrorCode; +import com.zhongyun.common.exception.RenException; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Map; + +/** + * 校验工具类 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public class AssertUtils { + + public static void isBlank(String str, String... params) { + isBlank(str, ErrorCode.NOT_NULL, params); + } + + public static void isBlank(String str, Integer code, String... params) { + if(code == null){ + throw new RenException(ErrorCode.NOT_NULL, "code"); + } + + if (StringUtils.isBlank(str)) { + throw new RenException(code, params); + } + } + + public static void isNull(Object object, String... params) { + isNull(object, ErrorCode.NOT_NULL, params); + } + + public static void isNull(Object object, Integer code, String... params) { + if(code == null){ + throw new RenException(ErrorCode.NOT_NULL, "code"); + } + + if (object == null) { + throw new RenException(code, params); + } + } + + public static void isArrayEmpty(Object[] array, String... params) { + isArrayEmpty(array, ErrorCode.NOT_NULL, params); + } + + public static void isArrayEmpty(Object[] array, Integer code, String... params) { + if(code == null){ + throw new RenException(ErrorCode.NOT_NULL, "code"); + } + + if(ArrayUtil.isEmpty(array)){ + throw new RenException(code, params); + } + } + + public static void isListEmpty(List list, String... params) { + isListEmpty(list, ErrorCode.NOT_NULL, params); + } + + public static void isListEmpty(List list, Integer code, String... params) { + if(code == null){ + throw new RenException(ErrorCode.NOT_NULL, "code"); + } + + if(CollUtil.isEmpty(list)){ + throw new RenException(code, params); + } + } + + public static void isMapEmpty(Map map, String... params) { + isMapEmpty(map, ErrorCode.NOT_NULL, params); + } + + public static void isMapEmpty(Map map, Integer code, String... params) { + if(code == null){ + throw new RenException(ErrorCode.NOT_NULL, "code"); + } + + if(MapUtil.isEmpty(map)){ + throw new RenException(code, params); + } + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/validator/ValidatorUtils.java b/zhongyun-common/src/main/java/com/zhongyun/common/validator/ValidatorUtils.java new file mode 100644 index 0000000..c0d1828 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/validator/ValidatorUtils.java @@ -0,0 +1,51 @@ + + +package com.zhongyun.common.validator; + +import com.zhongyun.common.exception.RenException; +import org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.validation.beanvalidation.MessageSourceResourceBundleLocator; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import java.util.Locale; +import java.util.Set; + +/** + * hibernate-validator校验工具类 + * 参考文档:http://docs.jboss.org/hibernate/validator/6.0/reference/en-US/html_single/ + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public class ValidatorUtils { + + private static ResourceBundleMessageSource getMessageSource() { + ResourceBundleMessageSource bundleMessageSource = new ResourceBundleMessageSource(); + bundleMessageSource.setDefaultEncoding("UTF-8"); + bundleMessageSource.setBasenames("i18n/validation"); + return bundleMessageSource; + } + + /** + * 校验对象 + * @param object 待校验对象 + * @param groups 待校验的组 + */ + public static void validateEntity(Object object, Class... groups) + throws RenException { + Locale.setDefault(LocaleContextHolder.getLocale()); + Validator validator = Validation.byDefaultProvider().configure().messageInterpolator( + new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(getMessageSource()))) + .buildValidatorFactory().getValidator(); + + Set> constraintViolations = validator.validate(object, groups); + if (!constraintViolations.isEmpty()) { + ConstraintViolation constraint = constraintViolations.iterator().next(); + throw new RenException(constraint.getMessage()); + } + } +} \ No newline at end of file diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/AddGroup.java b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/AddGroup.java new file mode 100644 index 0000000..f064c99 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/AddGroup.java @@ -0,0 +1,13 @@ + + +package com.zhongyun.common.validator.group; + +/** + * 新增 Group + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public interface AddGroup { + +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/DefaultGroup.java b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/DefaultGroup.java new file mode 100644 index 0000000..545a431 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/DefaultGroup.java @@ -0,0 +1,13 @@ + + +package com.zhongyun.common.validator.group; + +/** + * 默认 Group + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public interface DefaultGroup { + +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/Group.java b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/Group.java new file mode 100644 index 0000000..74681fe --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/Group.java @@ -0,0 +1,16 @@ + + +package com.zhongyun.common.validator.group; + +import javax.validation.GroupSequence; + +/** + * 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +@GroupSequence({AddGroup.class, UpdateGroup.class}) +public interface Group { + +} diff --git a/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/UpdateGroup.java b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/UpdateGroup.java new file mode 100644 index 0000000..5e68ef7 --- /dev/null +++ b/zhongyun-common/src/main/java/com/zhongyun/common/validator/group/UpdateGroup.java @@ -0,0 +1,13 @@ + + +package com.zhongyun.common.validator.group; + +/** + * 修改 Group + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +public interface UpdateGroup { + +} diff --git a/zhongyun-points-admin/pom.xml b/zhongyun-points-admin/pom.xml new file mode 100644 index 0000000..96e2d0b --- /dev/null +++ b/zhongyun-points-admin/pom.xml @@ -0,0 +1,197 @@ + + + com.zhongyun + zhongyun-points + 1.0.0 + + 4.0.0 + zhongyun-points-admin + jar + zhongyun-points-admin + + + 1.10.1 + 1.6.2 + 3.0.5 + 7.2.27 + 2.8.3 + 3.2.2 + 1.1.0 + 5.4.4 + 1.0.5 + 1.26.2 + 8.4.5 + 1.6.2 + 2.3.31 + 2.2.9 + 2.8.2 + + + + + com.zhongyun + zhongyun-common + 1.0.0 + + + + + org.apache.shiro + shiro-core + ${shiro.version} + + + org.apache.shiro + shiro-spring + ${shiro.version} + + + com.github.whvcse + easy-captcha + ${captcha.version} + + + com.alibaba + easyexcel + ${easyexcel.version} + + + com.qiniu + qiniu-java-sdk + ${qiniu.version} + + + com.aliyun.oss + aliyun-sdk-oss + ${aliyun.oss.version} + + + com.qcloud + cos_api + ${qcloud.cos.version} + + + org.slf4j + slf4j-log4j12 + + + + + com.aliyun + aliyun-java-sdk-core + ${aliyun.core.version} + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + 2.1.0.RELEASE + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + 2.1.0.RELEASE + + + + com.aliyun + aliyun-java-sdk-dysmsapi + ${aliyun.dysmsapi.version} + + + com.github.qcloudsms + qcloudsms + ${qcloud.qcloudsms.version} + + + com.sun.mail + javax.mail + ${mail.version} + + + org.freemarker + freemarker + ${freemarker.version} + + + com.github.tobato + fastdfs-client + ${fastdfs.version} + + + io.minio + minio + ${minio.version} + + + org.springframework.boot + spring-boot-starter-websocket + + + com.bstek.ureport + ureport2-console + ${ureport2.version} + + + com.github.javen205 + IJPay-AliPay + ${IJPay.version} + + + fastjson + com.alibaba + + + + + com.github.binarywang + weixin-java-mp + 4.2.0 + + + com.thoughtworks.xstream + xstream + 1.4.20 + + + + + + + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + com.spotify + docker-maven-plugin + ${docker.plugin.version} + + zhongyun/${project.artifactId} + ${project.basedir}/ + + + / + ${project.build.directory} + ${project.build.finalName}.jar + + + + + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/PointsAdminApplication.java b/zhongyun-points-admin/src/main/java/com/zhongyun/PointsAdminApplication.java new file mode 100644 index 0000000..24ee45e --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/PointsAdminApplication.java @@ -0,0 +1,23 @@ + + +package com.zhongyun; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class PointsAdminApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(PointsAdminApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(PointsAdminApplication.class); + } +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/annotation/LogOperation.java b/zhongyun-points-admin/src/main/java/com/zhongyun/annotation/LogOperation.java new file mode 100644 index 0000000..4fa8992 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/annotation/LogOperation.java @@ -0,0 +1,18 @@ + + +package com.zhongyun.annotation; + +import java.lang.annotation.*; + +/** + * 操作日志注解 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface LogOperation { + + String value() default ""; +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/common/cloud/LocalCloudStorageService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/common/cloud/LocalCloudStorageService.java new file mode 100644 index 0000000..bc65ae9 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/common/cloud/LocalCloudStorageService.java @@ -0,0 +1,66 @@ + + +package com.zhongyun.common.cloud; + +import com.zhongyun.common.config.LocalCloudStorageConfig; +import com.zhongyun.common.exception.ErrorCode; +import com.zhongyun.common.exception.RenException; +import com.zhongyun.common.utils.DateUtils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Date; +import java.util.UUID; + +/** + * 本地上传 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Component +public class LocalCloudStorageService{ + + @Autowired + LocalCloudStorageConfig config; + + public String upload(byte[] data, String path) { + return upload(new ByteArrayInputStream(data), path); + } + + public String upload(InputStream inputStream, String path) { + File file = new File(config.getLocalPath() + File.separator + path); + try { + FileUtils.copyToFile(inputStream, file); + } catch (IOException e) { + throw new RenException(ErrorCode.OSS_UPLOAD_FILE_ERROR, e, ""); + } + return config.getLocalDomain() + "/" + path; + } + + public String uploadSuffix(byte[] data, String suffix) { + return upload(data, getPath(config.getLocalPrefix(), suffix)); + } + + public String uploadSuffix(InputStream inputStream, String suffix) { + return upload(inputStream, getPath(config.getLocalPrefix(), suffix)); + } + + public String getPath(String prefix, String suffix) { + //生成uuid + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + //文件路径 + String path = DateUtils.format(new Date(), "yyyyMMdd") + "/" + uuid; + + if(StringUtils.isNotBlank(prefix)){ + path = prefix + "/" + path; + } + + return path + "." + suffix; + } +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/LocalCloudStorageConfig.java b/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/LocalCloudStorageConfig.java new file mode 100644 index 0000000..dd20123 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/LocalCloudStorageConfig.java @@ -0,0 +1,23 @@ +package com.zhongyun.common.config; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LocalCloudStorageConfig { + + @Value("${local.localDomain}") + private String localDomain; + + @Value("${local.localPrefix}") + private String localPrefix; + + @Value("${local.localPath}") + private String localPath; +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/MybatisPlusConfig.java b/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/MybatisPlusConfig.java new file mode 100644 index 0000000..e9ca201 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/MybatisPlusConfig.java @@ -0,0 +1,37 @@ + + +package com.zhongyun.common.config; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +//import com.zhongyun.common.interceptor.DataFilterInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * mybatis-plus配置 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0.0 + */ +@Configuration +public class MybatisPlusConfig { + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); + // 数据权限 +// mybatisPlusInterceptor.addInnerInterceptor(new DataFilterInterceptor()); + // 分页插件 + mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + // 乐观锁 + mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); + // 防止全表更新与删除 +// mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); + + return mybatisPlusInterceptor; + } + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/SwaggerConfig.java b/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/SwaggerConfig.java new file mode 100644 index 0000000..b32afd2 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/common/config/SwaggerConfig.java @@ -0,0 +1,65 @@ + + +package com.zhongyun.common.config; + +import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; +import com.zhongyun.common.constant.Constant; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.ApiKey; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +import java.util.List; +import static com.google.common.collect.Lists.newArrayList; + + +/** + * Swagger配置 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Configuration +@EnableSwagger2WebMvc +@AllArgsConstructor +public class SwaggerConfig { + private final OpenApiExtensionResolver openApiExtensionResolver; + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + //加了ApiOperation注解的类,生成接口文档 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //包下的类,生成接口文档 + //.apis(RequestHandlerSelectors.basePackage("com.zhongyun.modules.job.controller")) + .paths(PathSelectors.any()) + .build() + .extensions(openApiExtensionResolver.buildExtensions("Zhongyun")) + .directModelSubstitute(java.util.Date.class, String.class) + .securitySchemes(security()); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("积分管理") + .description("points-admin文档") + .termsOfServiceUrl("") + .version("1.x") + .build(); + } + + private List security() { + return newArrayList( + new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") + ); + } +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/common/group/LocalGroup.java b/zhongyun-points-admin/src/main/java/com/zhongyun/common/group/LocalGroup.java new file mode 100644 index 0000000..b226036 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/common/group/LocalGroup.java @@ -0,0 +1,11 @@ + + +package com.zhongyun.common.group; + +/** + * 本地上传 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public interface LocalGroup { +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/common/handler/FieldMetaObjectHandler.java b/zhongyun-points-admin/src/main/java/com/zhongyun/common/handler/FieldMetaObjectHandler.java new file mode 100644 index 0000000..6c34a04 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/common/handler/FieldMetaObjectHandler.java @@ -0,0 +1,36 @@ + + +package com.zhongyun.common.handler; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * 公共字段,自动填充值 + * + * @author Mark sunlightcs@gmail.com + */ +@Component +public class FieldMetaObjectHandler implements MetaObjectHandler { + private final static String CREATE_DATE = "createDate"; + private final static String UPDATE_DATE = "updateDate"; + + @Override + public void insertFill(MetaObject metaObject) { + Date date = new Date(); + + //创建时间 + strictInsertFill(metaObject, CREATE_DATE, Date.class, date); + //更新时间 + strictInsertFill(metaObject, UPDATE_DATE, Date.class, date); + } + + @Override + public void updateFill(MetaObject metaObject) { + //更新时间 + strictUpdateFill(metaObject, UPDATE_DATE, Date.class, new Date()); + } +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/DetailController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/DetailController.java new file mode 100644 index 0000000..c6a3053 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/DetailController.java @@ -0,0 +1,73 @@ +package com.zhongyun.controller; + +import com.zhongyun.annotation.LogOperation; +import com.zhongyun.common.constant.Constant; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.utils.Result; +import com.zhongyun.common.validator.AssertUtils; +import com.zhongyun.common.validator.ValidatorUtils; +import com.zhongyun.common.validator.group.AddGroup; +import com.zhongyun.common.validator.group.DefaultGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import com.zhongyun.dto.DetailDTO; +import com.zhongyun.dto.EarnDTO; +import com.zhongyun.dto.UserDTO; +import com.zhongyun.service.DetailService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; +import java.util.Map; + + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@RestController +@RequestMapping("points/detail") +@Api(tags="积分明细") +public class DetailController { + @Autowired + private DetailService detailService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "startTime", value = "开始时间,格式2021-01-01", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "endTime", value = "结束时间,格式2021-01-01", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "id", value = "用户id", paramType = "query", dataType="Long") + + }) + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = detailService.page(params); + + return new Result>().ok(page); + } + + + + @PostMapping("/earn") + @ApiOperation("获得积分") + @LogOperation("获得积分") + public Result earn(@RequestBody EarnDTO dto){ + + detailService.earn(dto); + + return new Result(); + } + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/LevelController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/LevelController.java new file mode 100644 index 0000000..6180769 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/LevelController.java @@ -0,0 +1,58 @@ + + +package com.zhongyun.controller; + + +import com.zhongyun.annotation.LogOperation; +import com.zhongyun.common.constant.Constant; +import com.zhongyun.common.utils.Result; +import com.zhongyun.dto.LevelDTO; +import com.zhongyun.service.LevelService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; +import java.util.Map; + +/** + * 等级 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@RestController +@RefreshScope +@RequestMapping("points/level") +@Api(tags="等级管理") +public class LevelController { + @Autowired + private LevelService levelService; + + @GetMapping("list") + @ApiOperation("列表") + public Result> list(){ + List list = levelService.list(); + + return new Result>().ok(list); + } + + @PostMapping + @ApiOperation("保存并生效") + @LogOperation("保存并生效") + public Result save(@RequestBody List dto){ + + levelService.updateBatch(dto); + + return new Result(); + } + + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/RuleController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/RuleController.java new file mode 100644 index 0000000..5a78d6a --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/RuleController.java @@ -0,0 +1,61 @@ +package com.zhongyun.controller; + + +import com.zhongyun.annotation.LogOperation; +import com.zhongyun.common.utils.Result; +import com.zhongyun.common.validator.ValidatorUtils; +import com.zhongyun.common.validator.group.DefaultGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.service.RuleService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; +import java.util.Map; + +/** + * 规则 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@RestController +@RefreshScope +@RequestMapping("points/rule") +@Api(tags="规则管理") +public class RuleController { + @Autowired + private RuleService ruleService; + + @GetMapping("list") + @ApiOperation("列表") + @ApiImplicitParams({ + }) + public Result> list(@ApiIgnore @RequestParam Map params){ + List list = ruleService.list(params); + + return new Result>().ok(list); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + public Result update(RuleDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + ruleService.update(dto); + + return new Result(); + } + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/StatisticsController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/StatisticsController.java new file mode 100644 index 0000000..de69d60 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/StatisticsController.java @@ -0,0 +1,64 @@ +package com.zhongyun.controller; + +import com.zhongyun.annotation.LogOperation; +import com.zhongyun.common.constant.Constant; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.utils.Result; +import com.zhongyun.common.validator.AssertUtils; +import com.zhongyun.common.validator.ValidatorUtils; +import com.zhongyun.common.validator.group.AddGroup; +import com.zhongyun.common.validator.group.DefaultGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import com.zhongyun.dto.*; +import com.zhongyun.service.DetailService; +import com.zhongyun.service.StatisticsService; +import io.swagger.annotations.*; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; +import java.util.Map; + + +/** +* 数据概况 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@RestController +@RequestMapping("points/statistics") +@Api(tags="数据概况") +public class StatisticsController { + @Autowired + private StatisticsService statisticsService; + + @GetMapping("month") + @ApiOperation("积分趋势") + public Result> page(){ + List list = statisticsService.month(); + + return new Result>().ok(list); + } + + @GetMapping("statistics") + @ApiOperation("数据总况") + public Result statistics(){ + StatisticsDTO list = statisticsService.statistics(); + + return new Result().ok(list); + } + + + @GetMapping("transform/{period}") + @ApiOperation("转化概况") + @ApiImplicitParam(name = "period", value = "统计周期可以取值all.year,month,day,week", paramType = "query", dataType="string") + public Result transform(@PathVariable("period") String period){ + TransformDTO transform = statisticsService.transform(period); + return new Result().ok(transform); + } + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/SysOssController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/SysOssController.java new file mode 100644 index 0000000..53943ed --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/SysOssController.java @@ -0,0 +1,54 @@ + + +package com.zhongyun.controller; + +import com.zhongyun.common.cloud.LocalCloudStorageService; +import com.zhongyun.common.exception.ErrorCode; +import com.zhongyun.common.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.HashMap; +import java.util.Map; + +/** + * 文件上传 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@RestController +@RefreshScope +@RequestMapping("sys/oss") +@Api(tags="文件上传") +public class SysOssController { + + + @Autowired + private LocalCloudStorageService localCloudStorageService; + + @PostMapping("upload") + @ApiOperation(value = "上传文件") + public Result> upload(@RequestParam("file") MultipartFile file) throws Exception { + if (file.isEmpty()) { + return new Result>().error(ErrorCode.UPLOAD_FILE_EMPTY); + } + + //上传文件 + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + String url = localCloudStorageService.uploadSuffix(file.getBytes(), extension); + + Map data = new HashMap<>(1); + data.put("src", url); + + return new Result>().ok(data); + } + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/UserController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/UserController.java new file mode 100644 index 0000000..a963eaf --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/UserController.java @@ -0,0 +1,90 @@ +package com.zhongyun.controller; + +import com.zhongyun.annotation.LogOperation; +import com.zhongyun.common.constant.Constant; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.utils.Result; +import com.zhongyun.common.validator.AssertUtils; +import com.zhongyun.common.validator.ValidatorUtils; +import com.zhongyun.common.validator.group.AddGroup; +import com.zhongyun.common.validator.group.DefaultGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import com.zhongyun.dto.UserDTO; +import com.zhongyun.service.UserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** +* 积分用户 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 1.0 2024-11-20 +*/ +@RestController +@RequestMapping("points/user") +@Api(tags="积分用户") +public class UserController { + @Autowired + private UserService userService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "startTime", value = "开始时间,格式2021-01-01", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "endTime", value = "结束时间,格式2021-01-01", paramType = "query", dataType="String"), + @ApiImplicitParam(name = "mobile", value = "手机号", paramType = "query", dataType="String") + + }) + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = userService.page(params); + + return new Result>().ok(page); + } + @GetMapping("total-top") + @ApiOperation("获取积分top") + public Result> totalTop(){ + List list = userService.top("total"); + + return new Result>().ok(list); + } + @GetMapping("used-top") + @ApiOperation("使用积分top") + public Result> useTop(){ + List list = userService.top("used"); + + return new Result< List>().ok(list); + } + + @PostMapping("list") + @ApiOperation("通过id获取用户信息") + @LogOperation("通过id获取用户信息") + public Result> list(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + List list = userService.getInfobyIds(ids); + + return new Result< List>().ok(list); + } + + + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/controller/ValidityController.java b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/ValidityController.java new file mode 100644 index 0000000..381691b --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/controller/ValidityController.java @@ -0,0 +1,59 @@ +package com.zhongyun.controller; + +import com.zhongyun.annotation.LogOperation; +import com.zhongyun.common.constant.Constant; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.utils.Result; +import com.zhongyun.common.validator.AssertUtils; +import com.zhongyun.common.validator.ValidatorUtils; +import com.zhongyun.common.validator.group.AddGroup; +import com.zhongyun.common.validator.group.DefaultGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import com.zhongyun.dto.ValidityDTO; +import com.zhongyun.service.ValidityService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.Map; + + +/** +* 积分有效期 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@RestController +@RequestMapping("points/validity") +@Api(tags="积分有效期") +public class ValidityController { + @Autowired + private ValidityService validityService; + + @GetMapping("") + @ApiOperation("信息") + public Result get(){ + ValidityDTO data = validityService.getInfo(); + + return new Result().ok(data); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + public Result update(@RequestBody ValidityDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + validityService.update(dto); + + return new Result(); + } + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/DetailDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/DetailDao.java new file mode 100644 index 0000000..596a2e2 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/DetailDao.java @@ -0,0 +1,21 @@ +package com.zhongyun.dao; + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.entity.DetailEntity; +import com.zhongyun.entity.UserEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Mapper +public interface DetailDao extends BaseDao { + List getList(Map params); + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/LevelDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/LevelDao.java new file mode 100644 index 0000000..daa7d27 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/LevelDao.java @@ -0,0 +1,22 @@ + + +package com.zhongyun.dao; + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.entity.LevelEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * 新闻 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Mapper +public interface LevelDao extends BaseDao { + + List getList(); + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/RuleDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/RuleDao.java new file mode 100644 index 0000000..d0c9fcf --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/RuleDao.java @@ -0,0 +1,22 @@ + + +package com.zhongyun.dao; + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.entity.RuleEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * 新闻 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Mapper +public interface RuleDao extends BaseDao { + + List getList(Map params); + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/StatisticsDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/StatisticsDao.java new file mode 100644 index 0000000..60794df --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/StatisticsDao.java @@ -0,0 +1,29 @@ +package com.zhongyun.dao; + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.dto.MonthDTO; +import com.zhongyun.dto.StatisticsDTO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** +* 积分有效期 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Mapper +public interface StatisticsDao extends BaseDao { + + + List month(); + StatisticsDTO getStatistics(); + + int getEarnPeople(String period); + int getUsedPeople(String period); + int getEarnNum(String period); + int getUsedNum(String period); + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/SysOssDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/SysOssDao.java new file mode 100644 index 0000000..d8de037 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/SysOssDao.java @@ -0,0 +1,18 @@ + + +package com.zhongyun.dao; + + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.entity.SysOssEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 文件上传 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Mapper +public interface SysOssDao extends BaseDao { + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/UserDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/UserDao.java new file mode 100644 index 0000000..8ab6b14 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/UserDao.java @@ -0,0 +1,28 @@ +package com.zhongyun.dao; + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.dto.UserDTO; +import com.zhongyun.entity.UserEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** +* 积分用户 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 1.0 2024-11-20 +*/ +@Mapper +public interface UserDao extends BaseDao { + + List getList(Map params); + + List getTop(String orderField); + + List getInfobyIds(Long[] ids); + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dao/ValidityDao.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/ValidityDao.java new file mode 100644 index 0000000..1030b24 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dao/ValidityDao.java @@ -0,0 +1,19 @@ +package com.zhongyun.dao; + +import com.zhongyun.common.dao.BaseDao; +import com.zhongyun.entity.ValidityEntity; +import org.apache.ibatis.annotations.Mapper; + +/** +* 积分有效期 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Mapper +public interface ValidityDao extends BaseDao { + + + void updateUserPoints(); + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/DetailDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/DetailDTO.java new file mode 100644 index 0000000..314a902 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/DetailDTO.java @@ -0,0 +1,48 @@ +package com.zhongyun.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhongyun.common.utils.DateUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Data +@ApiModel(value = "积分明细") +public class DetailDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "id") + private Long id; + @ApiModelProperty(value = "规则id") + private Long ruleId; + @ApiModelProperty(value = "时间") + private Date createDate; + @ApiModelProperty(value = "积分变化") + private Integer num; + @ApiModelProperty(value = "可用积分") + private Integer availability; + @ApiModelProperty(value = "积分用户id") + private Long pointsId; + @ApiModelProperty(value = "0消耗1获得") + private Integer flag; + @ApiModelProperty(value = "有效时间") + private Date validityDate; + @ApiModelProperty(value = "有效期(月)") + private Integer validityMonth; + @ApiModelProperty(value = "有效标志0无效1有效") + private Integer validityFlag; + @ApiModelProperty(value = "活动名称") + private String ruleName; + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/EarnDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/EarnDTO.java new file mode 100644 index 0000000..83b7d69 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/EarnDTO.java @@ -0,0 +1,26 @@ +package com.zhongyun.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Data +@ApiModel(value = "获得积分") +public class EarnDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + @ApiModelProperty(value = "规则id") + private Long ruleId; + @ApiModelProperty(value = "user_wechat_h5的id") + private String wechatH5Id; +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/LevelDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/LevelDTO.java new file mode 100644 index 0000000..4b31780 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/LevelDTO.java @@ -0,0 +1,50 @@ + + +package com.zhongyun.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.zhongyun.common.utils.DateUtils; +import com.zhongyun.common.validator.group.AddGroup; +import com.zhongyun.common.validator.group.DefaultGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.util.Date; + +/** + *等级管理 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +@ApiModel(value = "等级管理") +public class LevelDTO implements Serializable { + + + + @ApiModelProperty(value = "等级名称") + private String name; + + @ApiModelProperty(value = "等级勋章") + private String icon; + + @ApiModelProperty(value = "所需积分") + private int points; + + @ApiModelProperty(value = "排序") + private int sort; + + + @ApiModelProperty(value = "创建时间") + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) + private Date updateDate; + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/MonthDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/MonthDTO.java new file mode 100644 index 0000000..f28a6ef --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/MonthDTO.java @@ -0,0 +1,28 @@ +package com.zhongyun.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Data +@ApiModel(value = "积分趋势") +public class MonthDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "发放文明币数") + private Integer total; + @ApiModelProperty(value = "使用文明币数") + private Integer used; + @ApiModelProperty(value = "年月") + private String month; + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/RuleDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/RuleDTO.java new file mode 100644 index 0000000..2a1510e --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/RuleDTO.java @@ -0,0 +1,54 @@ + + +package com.zhongyun.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.zhongyun.common.utils.DateUtils; +import com.zhongyun.common.validator.group.AddGroup; +import com.zhongyun.common.validator.group.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; +import java.io.Serializable; +import java.util.Date; + +/** + *规则管理 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +@ApiModel(value = "规则管理") +public class RuleDTO implements Serializable { + + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "活动名称") + private String name; + + @ApiModelProperty(value = "规则类型(0:具体值,1:按公式计算)") + private int flag; + + @ApiModelProperty(value = "获得积分") + private int points; + + @ApiModelProperty(value = "启用状态(0:不启用,1:启用)") + private int status; + + @ApiModelProperty(value = "更新时间") + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) + private Date updateDate; + + + @ApiModelProperty(value = "更新者") + private Long updater; + + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/StatisticsDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/StatisticsDTO.java new file mode 100644 index 0000000..35f2830 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/StatisticsDTO.java @@ -0,0 +1,30 @@ +package com.zhongyun.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Data +@ApiModel(value = "数据总况") +public class StatisticsDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "可用文明币") + private Integer availability; + @ApiModelProperty(value = "冻结文明币") + private Integer blocked; + @ApiModelProperty(value = "发放文明币") + private Integer total; + @ApiModelProperty(value = "使用文明币") + private Integer used; + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/TransformDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/TransformDTO.java new file mode 100644 index 0000000..d05a76a --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/TransformDTO.java @@ -0,0 +1,40 @@ +package com.zhongyun.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** +* 积分明细 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Data +@ApiModel(value = "转化概况") +public class TransformDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "平台访客总数") + private int userNum; + @ApiModelProperty(value = "获取人数") + private int earnPeople; + @ApiModelProperty(value = "使用人数") + private int usedPeople; + @ApiModelProperty(value = "累计发放数") + private int earnNum; + @ApiModelProperty(value = "累计使用数") + private int usedNum; + @ApiModelProperty(value = "人均使用数") + private String avgUsed; + @ApiModelProperty(value = "访客获取转化率") + private String earnPercent; + @ApiModelProperty(value = "获取使用转化率") + private String usedPercent; + @ApiModelProperty(value = "访客使用转化率") + private String userUsedPercent; + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/UserDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/UserDTO.java new file mode 100644 index 0000000..bf18780 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/UserDTO.java @@ -0,0 +1,51 @@ +package com.zhongyun.dto; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhongyun.common.utils.DateUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 积分用户 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 1.0 2024-11-20 +*/ +@Data +@ApiModel(value = "积分用户") +public class UserDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "积分用户id") + private Long id; + @ApiModelProperty(value = "user_wechat_h5的id") + private String wechatH5Id; + @ApiModelProperty(value = "总积分") + private Integer total; + @ApiModelProperty(value = "可用积分") + private Integer availability; + @ApiModelProperty(value = "冻结积分") + private Integer blocked; + @ApiModelProperty(value = "首次时间") + private Date firstDate; + @ApiModelProperty(value = "活动次数") + private Integer actNum; + @ApiModelProperty(value = "等级id") + private Long levelId; + @ApiModelProperty(value = "等级名称") + private String levelName; + @ApiModelProperty(value = "手机号") + private String mobile; + @ApiModelProperty(value = "昵称") + private String nickname; + @ApiModelProperty(value = "使用总积分") + private Integer used; + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/dto/ValidityDTO.java b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/ValidityDTO.java new file mode 100644 index 0000000..e636c7b --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/dto/ValidityDTO.java @@ -0,0 +1,25 @@ +package com.zhongyun.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +/** +* 积分有效期 +* +* @author Gaoming fangaoming0208@aliyun.com +* @since 3.0 2024-11-20 +*/ +@Data +@ApiModel(value = "积分有效期") +public class ValidityDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "id") + private Long id; + @ApiModelProperty(value = "有效期月份") + private Integer month; + @ApiModelProperty(value = "有效期类型0:具体值,1:永久有效") + private Integer flag; + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/entity/DetailEntity.java b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/DetailEntity.java new file mode 100644 index 0000000..be76549 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/DetailEntity.java @@ -0,0 +1,73 @@ +package com.zhongyun.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.baomidou.mybatisplus.annotation.*; +import com.zhongyun.common.entity.BaseEntity; + +import java.util.Date; + +/** + * 积分明细 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("points_detail") +public class DetailEntity { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long id; + + /** + * 规则id + */ + private Long ruleId; + /** + * 积分变化 + */ + private Integer num; + /** + * 可用积分 + */ + private Integer availability; + /** + * 积分用户id + */ + private Long pointsId; + /** + * 0消耗1获得 + */ + private Integer flag; + /** + * 创建时间 + */ + private Date createDate; + /** + * 有效时间 + */ + private Date validityDate; + /** + * 有效期(月) + */ + private Integer validityMonth; + /** + * 有效标志0无效1有效 + */ + private Integer validityFlag; + /** + * 活动名称 + */ + @TableField(exist=false) + private String ruleName; + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/entity/LevelEntity.java b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/LevelEntity.java new file mode 100644 index 0000000..643adde --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/LevelEntity.java @@ -0,0 +1,63 @@ + + +package com.zhongyun.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.zhongyun.common.entity.BaseEntity; +import com.zhongyun.common.utils.DateUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * 新闻 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("points_level") +public class LevelEntity implements Serializable { + private static final long serialVersionUID = 1L; + + + /** + * id + */ + @TableId + private Long id; + + /** + * 等级名称 + */ + private String name; + + /** + * 等级勋章 + */ + private String icon; + + /** + * 所需积分 + */ + private int points; + + /** + * 排序 + */ + private int sort; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/entity/RuleEntity.java b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/RuleEntity.java new file mode 100644 index 0000000..743d6b3 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/RuleEntity.java @@ -0,0 +1,62 @@ + + +package com.zhongyun.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.zhongyun.common.utils.DateUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * 新闻 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("points_rule") +public class RuleEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + /** + * 活动名称 + */ + private String name; + /** + * 规则类型(0:具体值,1:按公式计算) + */ + private int flag; + /** + * 获得积分 + */ + private int points; + /** + * 启用状态(0:不启用,1:启用) + */ + private int status; + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + + /** + * 更新者 + */ + private Long updater; + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/entity/SysOssEntity.java b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/SysOssEntity.java new file mode 100644 index 0000000..735031b --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/SysOssEntity.java @@ -0,0 +1,43 @@ + + +package com.zhongyun.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhongyun.common.utils.DateUtils; +import lombok.Data; + +import java.util.Date; + +/** + * 文件上传 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +@Data +@TableName("points_oss") +public class SysOssEntity { + /** + * id + */ + @TableId + private Long id; + /** + * URL地址 + */ + private String url; + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) + private Date createDate; +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/entity/UserEntity.java b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/UserEntity.java new file mode 100644 index 0000000..53a8f27 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/UserEntity.java @@ -0,0 +1,75 @@ +package com.zhongyun.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.baomidou.mybatisplus.annotation.*; +import java.util.Date; +import com.zhongyun.common.entity.BaseEntity; + +/** + * 积分用户 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("points_user") +public class UserEntity { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long id; + + /** + * 总积分 + */ + private Integer total; + /** + * 使用总积分 + */ + private Integer used; + /** + * 可用积分 + */ + private Integer availability; + /** + * 冻结积分 + */ + private Integer blocked; + /** + * 首次时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; /** + * 活动次数 + */ + private Integer actNum; + /** + * 等级id + */ + private Long levelId; + + + private String wechatH5Id; + /** + * 等级名称 + */ + @TableField(exist=false) + private String levelName; + /** + * 手机号 + */ + @TableField(exist=false) + private String mobile; + /** + * 昵称 + */ + @TableField(exist=false) + private String nickname; + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/entity/ValidityEntity.java b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/ValidityEntity.java new file mode 100644 index 0000000..757bc84 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/entity/ValidityEntity.java @@ -0,0 +1,39 @@ +package com.zhongyun.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 积分有效期 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("points_validity") +public class ValidityEntity { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long id; + + /** + * 有效期月份 + */ + private Integer month; + /** + * 有效期类型(0:具体值,1:永久有效) + */ + private Integer flag; + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/scheduler/PointExpirationScheduler.java b/zhongyun-points-admin/src/main/java/com/zhongyun/scheduler/PointExpirationScheduler.java new file mode 100644 index 0000000..a9560f0 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/scheduler/PointExpirationScheduler.java @@ -0,0 +1,28 @@ +package com.zhongyun.scheduler; + +import com.zhongyun.service.DetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import lombok.extern.slf4j.Slf4j; + +import java.util.concurrent.ScheduledExecutorService; + + +@Component +@EnableScheduling +@Slf4j +public class PointExpirationScheduler { + private ScheduledExecutorService scheduler; + @Autowired + private DetailService detailService; + + @Scheduled(cron = "0 0 23 * * ?") + public void start() { + detailService.PointExpiration(); + log.info("开始释放积分"); + } + + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/DetailService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/DetailService.java new file mode 100644 index 0000000..6bb6a3d --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/DetailService.java @@ -0,0 +1,31 @@ +package com.zhongyun.service; + + +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.CrudService; +import com.zhongyun.dto.DetailDTO; +import com.zhongyun.dto.EarnDTO; +import com.zhongyun.dto.LevelDTO; +import com.zhongyun.dto.UserDTO; +import com.zhongyun.entity.DetailEntity; + +import java.util.List; +import java.util.Map; + +/** + * 积分明细 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +public interface DetailService extends CrudService { + + void earn(EarnDTO dto); + + void PointExpiration() ; + + PageData page(Map params); + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/LevelService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/LevelService.java new file mode 100644 index 0000000..43f7ddd --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/LevelService.java @@ -0,0 +1,25 @@ + + +package com.zhongyun.service; + +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.BaseService; +import com.zhongyun.dto.LevelDTO; +import com.zhongyun.entity.LevelEntity; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 新闻 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public interface LevelService extends BaseService { + + List list(); + void updateBatch(List dtoList); + +} + diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/RuleService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/RuleService.java new file mode 100644 index 0000000..fcf9c0d --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/RuleService.java @@ -0,0 +1,28 @@ + + +package com.zhongyun.service; + +import com.zhongyun.common.service.BaseService; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.entity.RuleEntity; + +import java.util.List; +import java.util.Map; + +/** + * 新闻 + * + * @author Gaoming fangaoming0208@aliyun.com + */ +public interface RuleService extends BaseService { + + List list(Map params); + + void update(RuleDTO dto); + + + + +} + diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/StatisticsService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/StatisticsService.java new file mode 100644 index 0000000..4908b91 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/StatisticsService.java @@ -0,0 +1,30 @@ +package com.zhongyun.service; + + +import com.zhongyun.common.service.BaseService; +import com.zhongyun.common.service.CrudService; +import com.zhongyun.dto.MonthDTO; +import com.zhongyun.dto.StatisticsDTO; +import com.zhongyun.dto.TransformDTO; +import com.zhongyun.dto.ValidityDTO; +import com.zhongyun.entity.RuleEntity; +import com.zhongyun.entity.ValidityEntity; + +import java.util.List; + +/** + * 积分有效期 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +public interface StatisticsService extends BaseService { + + List month(); + StatisticsDTO statistics(); + TransformDTO transform(String period); + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/UserService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/UserService.java new file mode 100644 index 0000000..e90c2fd --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/UserService.java @@ -0,0 +1,28 @@ +package com.zhongyun.service; + + +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.CrudService; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.dto.UserDTO; +import com.zhongyun.entity.UserEntity; + +import java.util.List; +import java.util.Map; + +/** + * 积分用户 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0 2024-11-20 + */ +public interface UserService extends CrudService { + + PageData page(Map params); + + List top(String orderField); + + List getInfobyIds(Long[] ids); + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/ValidityService.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/ValidityService.java new file mode 100644 index 0000000..ece3400 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/ValidityService.java @@ -0,0 +1,19 @@ +package com.zhongyun.service; + + +import com.zhongyun.common.service.CrudService; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.dto.ValidityDTO; +import com.zhongyun.entity.ValidityEntity; + +/** + * 积分有效期 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +public interface ValidityService extends CrudService { + + ValidityDTO getInfo(); + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/DetailServiceImpl.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/DetailServiceImpl.java new file mode 100644 index 0000000..f4585fb --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/DetailServiceImpl.java @@ -0,0 +1,202 @@ +package com.zhongyun.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.zhongyun.common.exception.RenException; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.impl.CrudServiceImpl; +import com.zhongyun.common.utils.ConvertUtils; +import com.zhongyun.dao.*; +import com.zhongyun.dto.*; +import com.zhongyun.entity.DetailEntity; +import com.zhongyun.entity.LevelEntity; +import com.zhongyun.entity.RuleEntity; +import com.zhongyun.entity.UserEntity; +import com.zhongyun.service.DetailService; +import com.zhongyun.service.LevelService; +import com.zhongyun.service.UserService; +import com.zhongyun.service.ValidityService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 积分明细 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +@Service +public class DetailServiceImpl extends CrudServiceImpl implements DetailService { + @Autowired + private UserDao userDao; + @Autowired + private UserService userService; + @Autowired + private RuleDao ruleDao; + @Autowired + private ValidityService validityService; + @Autowired + private LevelDao levelDao; + @Autowired + private ValidityDao validityDao; + + + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + @Override + public PageData page(Map params) { + //转换成like + IPage page = getPage(params, "create_date", false); + + List list = baseDao.getList(params); + getPageData(list, page.getTotal(), DetailDTO.class); + + return getPageData(list, page.getTotal(), DetailDTO.class); + + } + + @Override + @Transactional + public void PointExpiration() { + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.le("validity_date",new Date()); + wrapper.eq("validity_flag",1); + DetailEntity detail = new DetailEntity(); + detail.setValidityFlag(0); + update(detail,wrapper); + validityDao.updateUserPoints(); + } + + + + @Override + @Transactional + public void earn(EarnDTO dto) { +// 获得积分规则 + QueryWrapper roleWrapper = new QueryWrapper<>(); + Long ruleId = dto.getRuleId(); + roleWrapper.eq("id", ruleId); + RuleEntity ruleEntity = ruleDao.selectOne(roleWrapper); + UserDTO userDTO = new UserDTO(); + DetailDTO detailDTO = new DetailDTO(); + ValidityDTO validity = validityService.getInfo(); + // 获得积分规则是否关闭 + if (ruleEntity.getStatus()==1){ + if(ruleEntity.getFlag()==0){ + // 检查是否存在用户,不存在则插入,存在则更新 + QueryWrapper wrapper = new QueryWrapper<>(); + String wechatH5Id = dto.getWechatH5Id(); + wrapper.eq(StringUtils.isNotBlank(wechatH5Id), "wechat_h5_id", wechatH5Id); + UserEntity userEntity = userDao.selectOne(wrapper); + if (userEntity == null){ + userDTO.setActNum(1); + userDTO.setAvailability(ruleEntity.getPoints()); + userDTO.setBlocked(0); + userDTO.setTotal(ruleEntity.getPoints()); + userDTO.setLevelId(getLevel(userDTO.getTotal())); + userDTO.setWechatH5Id(wechatH5Id); + userService.save(userDTO); + userEntity = userDao.selectOne(wrapper); + }else { + userDTO.setId(userEntity.getId()); + userDTO.setActNum(userEntity.getActNum()+1); + userDTO.setAvailability(ruleEntity.getPoints()+userEntity.getTotal()); + userDTO.setTotal(ruleEntity.getPoints()+userEntity.getAvailability()); + userDTO.setLevelId(getLevel(userDTO.getTotal())); + userDTO.setWechatH5Id(wechatH5Id); + userService.update(userDTO); + } + if (validity.getFlag()==0){ + detailDTO.setValidityDate(getValidityDate(validity.getMonth(),0)); + detailDTO.setValidityMonth(validity.getMonth()); + }else { + //长期有效去最大时间 + detailDTO.setValidityDate(getValidityDate(0,1)); + } + + detailDTO.setRuleId(ruleId); + detailDTO.setAvailability(userDTO.getAvailability()); + detailDTO.setNum(ruleEntity.getPoints()); + detailDTO.setFlag(1); + detailDTO.setPointsId(userEntity.getId()); + detailDTO.setCreateDate(new Date()); + detailDTO.setValidityFlag(1); + save(detailDTO); + + }else { + //积分规则flag=1,也就是计算公式方式,如何处理??? + } + }else { + //积分规则status !=1 说明规则关闭 + throw new RenException(ruleEntity.getName() + "已关闭"); + } + + } + +// 根据数值测算积分等级 + private Long getLevel(int points){ + List list = levelDao.getList(); + Long level =null; + if (points=list.get(list.size()-1).getPoints()){ + return list.get(list.size()-1).getId(); + }else { + for (int i = 0; i < list.size(); i++) { + if (points>=list.get(i).getPoints() && points implements LevelService { + + + + @Override + public List list() { + + List list = baseDao.getList(); + + + return ConvertUtils.sourceToTarget(list,LevelDTO.class); + } + + @Override + @Transactional + public void updateBatch(List dtoList) { + List levelEntities = ConvertUtils.sourceToTarget(dtoList, LevelEntity.class); + QueryWrapper wrapper = new QueryWrapper<>(); + baseDao.delete(wrapper); + insertBatch(levelEntities); + } +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/RulelServiceImpl.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/RulelServiceImpl.java new file mode 100644 index 0000000..bb0b132 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/RulelServiceImpl.java @@ -0,0 +1,44 @@ + + +package com.zhongyun.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.zhongyun.common.service.impl.BaseServiceImpl; +import com.zhongyun.common.utils.ConvertUtils; +import com.zhongyun.dao.RuleDao; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.dto.RuleDTO; +import com.zhongyun.entity.RuleEntity; +import com.zhongyun.entity.RuleEntity; +import com.zhongyun.entity.RuleEntity; +import com.zhongyun.service.RuleService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + + +@Service +public class RulelServiceImpl extends BaseServiceImpl implements RuleService { + + + + @Override + public List list(Map params) { + + List list = baseDao.getList(params); + + return ConvertUtils.sourceToTarget(list,RuleDTO.class); + } + + + @Override + public void update(RuleDTO dto) { + RuleEntity entity = ConvertUtils.sourceToTarget(dto, RuleEntity.class); + + updateById(entity); + } + +} diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/StatisticsServiceImpl.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/StatisticsServiceImpl.java new file mode 100644 index 0000000..2c72624 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/StatisticsServiceImpl.java @@ -0,0 +1,62 @@ +package com.zhongyun.service.impl; + + +import com.zhongyun.common.service.impl.BaseServiceImpl; +import com.zhongyun.dao.StatisticsDao; +import com.zhongyun.dto.MonthDTO; +import com.zhongyun.dto.StatisticsDTO; +import com.zhongyun.dto.TransformDTO; +import com.zhongyun.service.StatisticsService; +import org.springframework.stereotype.Service; +import cn.hutool.core.util.NumberUtil; + + +import java.util.List; + +/** + * 积分有效期 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +@Service +public class StatisticsServiceImpl extends BaseServiceImpl implements StatisticsService { + + @Override + public List month() { + return baseDao.month(); + } + + @Override + public StatisticsDTO statistics() { + return baseDao.getStatistics(); + } + + @Override + public TransformDTO transform(String period) { + + TransformDTO transformDTO = new TransformDTO(); + + int earnPeople = baseDao.getEarnPeople(period); + int usedPeople = baseDao.getUsedPeople(period); + int earnNum = baseDao.getEarnNum(period); + int usedNum = baseDao.getUsedNum(period); + int totalPeople = 10000;//怎么获取平台访客总数,先定义10000 + + transformDTO.setUserNum(totalPeople); + transformDTO.setEarnPeople(earnPeople); + transformDTO.setUsedPeople(usedPeople); + transformDTO.setEarnNum(earnNum); + transformDTO.setUsedNum(usedNum); + + transformDTO.setAvgUsed(NumberUtil.decimalFormat("0.00",(double)usedNum/usedPeople) ); + transformDTO.setEarnPercent(NumberUtil.decimalFormat("0.00",(double)earnPeople/totalPeople)); + transformDTO.setUsedPercent(NumberUtil.decimalFormat("0.00",(double)usedPeople/earnPeople)); + transformDTO.setUserUsedPercent(NumberUtil.decimalFormat("0.00",(double)usedPeople/totalPeople) ); + + return transformDTO; + + + + } +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/UserServiceImpl.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..1364608 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/UserServiceImpl.java @@ -0,0 +1,74 @@ +package com.zhongyun.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.zhongyun.common.page.PageData; +import com.zhongyun.common.service.impl.CrudServiceImpl; +import com.zhongyun.common.utils.ConvertUtils; +import com.zhongyun.dao.UserDao; +import com.zhongyun.dto.UserDTO; +import com.zhongyun.dto.ValidityDTO; +import com.zhongyun.entity.UserEntity; +import com.zhongyun.service.UserService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 积分用户 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 1.0 2024-11-20 + */ +@Service +public class UserServiceImpl extends CrudServiceImpl implements UserService { + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + + } + + @Override + public PageData page(Map params) { + //转换成like + paramsToLike(params, "mobile"); + + IPage page = getPage(params, "u.create_date", false); + + List list = baseDao.getList(params); + getPageData(list, page.getTotal(), UserDTO.class); + + return getPageData(list, page.getTotal(), UserDTO.class); + + } + + @Override + public List top(String orderField) { + + List list = baseDao.getTop(orderField); + + return ConvertUtils.sourceToTarget(list, UserDTO.class); + + } + @Override + public List getInfobyIds(Long[] ids) { + + List list = baseDao.getInfobyIds(ids); + + return ConvertUtils.sourceToTarget(list, UserDTO.class); + + } + + + + + + + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/ValidityServiceImpl.java b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/ValidityServiceImpl.java new file mode 100644 index 0000000..4116b87 --- /dev/null +++ b/zhongyun-points-admin/src/main/java/com/zhongyun/service/impl/ValidityServiceImpl.java @@ -0,0 +1,41 @@ +package com.zhongyun.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.zhongyun.common.service.impl.CrudServiceImpl; +import com.zhongyun.common.utils.ConvertUtils; +import com.zhongyun.dao.ValidityDao; +import com.zhongyun.dto.ValidityDTO; +import com.zhongyun.entity.ValidityEntity; +import com.zhongyun.service.ValidityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 积分有效期 + * + * @author Gaoming fangaoming0208@aliyun.com + * @since 3.0 2024-11-20 + */ +@Service +public class ValidityServiceImpl extends CrudServiceImpl implements ValidityService { + + + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + @Override + public ValidityDTO getInfo() { + QueryWrapper wrapper = new QueryWrapper<>(); + ValidityEntity validityEntity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(validityEntity, ValidityDTO.class); + } + +} \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/bootstrap-dev.yml b/zhongyun-points-admin/src/main/resources/bootstrap-dev.yml new file mode 100644 index 0000000..11955cf --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/bootstrap-dev.yml @@ -0,0 +1,108 @@ +spring: + messages: + encoding: UTF-8 + basename: i18n/messages + mvc: + pathmatch: + matching-strategy: ANT_PATH_MATCHER + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + enabled: true + application: + name: epmet-points-plugin + cloud: + nacos: + discovery: + server-addr: 192.168.1.140:8848 + #nacos的命名空间ID,默认是public + namespace: epmet_saas_dev + #不把自己注册到注册中心的地址 + register-enabled: true + config: + server-addr: 192.168.1.140:8848 #nacos地址 + file-extension: yml # 文件后缀名 + enabled: false + main: + allow-bean-definition-overriding: true + datasource: + druid: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.1.140:3306/epmet_user?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: epmet + password: EpmEt_UsEr@sAAs + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 6000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + +logging: + level: + org.flowable.engine.impl.persistence.entity.*: debug + org.flowable.task.service.impl.persistence.entity.*: debug + + +knife4j: + enable: true + basic: + enable: false + username: admin + password: admin + setting: + enableFooter: false + +fdfs: + so-timeout: 600000 + connect-timeout: 6000 + tracker-list: #TrackerList参数,支持多个 + - 192.168.10.10:22122 + + +#mybatis +mybatis-plus: + mapper-locations: classpath*:/mapper/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.zhongyun.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 + id-type: ASSIGN_ID + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + configuration-properties: + prefix: + blobType: BLOB + boolValue: TRUE +# 本地上传路径 +local: + localDomain: 127.0.0.1 + localPrefix: + localPath: D:/upload + + diff --git a/zhongyun-points-admin/src/main/resources/bootstrap.yml b/zhongyun-points-admin/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..0a9a909 --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/bootstrap.yml @@ -0,0 +1,16 @@ +server: + tomcat: + uri-encoding: UTF-8 + threads: + max: 1000 + min-spare: 30 + port: 8121 + servlet: + context-path: /points + session: + cookie: + http-only: true + +spring: + profiles: + active: dev diff --git a/zhongyun-points-admin/src/main/resources/logback-spring.xml b/zhongyun-points-admin/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..18144d8 --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/logback-spring.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/mapper/DetaiDao.xml b/zhongyun-points-admin/src/main/resources/mapper/DetaiDao.xml new file mode 100644 index 0000000..8c2b76b --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/mapper/DetaiDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/mapper/LevelDao.xml b/zhongyun-points-admin/src/main/resources/mapper/LevelDao.xml new file mode 100644 index 0000000..4ce40c9 --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/mapper/LevelDao.xml @@ -0,0 +1,13 @@ + + + + + + + + delete from points_level + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/mapper/RuleDao.xml b/zhongyun-points-admin/src/main/resources/mapper/RuleDao.xml new file mode 100644 index 0000000..963ec8c --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/mapper/RuleDao.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/mapper/StatisticsDao.xml b/zhongyun-points-admin/src/main/resources/mapper/StatisticsDao.xml new file mode 100644 index 0000000..c53734c --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/mapper/StatisticsDao.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/mapper/UserDao.xml b/zhongyun-points-admin/src/main/resources/mapper/UserDao.xml new file mode 100644 index 0000000..17f3734 --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/mapper/UserDao.xml @@ -0,0 +1,39 @@ + + + + + + + + + + \ No newline at end of file diff --git a/zhongyun-points-admin/src/main/resources/mapper/ValidityDao.xml b/zhongyun-points-admin/src/main/resources/mapper/ValidityDao.xml new file mode 100644 index 0000000..09d890a --- /dev/null +++ b/zhongyun-points-admin/src/main/resources/mapper/ValidityDao.xml @@ -0,0 +1,19 @@ + + + + + + + UPDATE points_user u LEFT JOIN (SELECT + sum( CASE WHEN flag = 1 THEN num ELSE 0 END ) total, + sum( CASE WHEN flag = 1 AND validity_flag = 1 THEN num ELSE 0 END ) availability, + sum( CASE WHEN flag = 1 AND validity_flag = 0 THEN num ELSE 0 END ) blocked, + points_id + FROM + points_detail + GROUP BY + points_id + ) d on u.id= d.points_id SET u.total=d.total,u.availability=d.availability,u.blocked=d.blocked + + + \ No newline at end of file