4.0.0
+
+
+ com.zaxxer
+ HikariCP
+ 3.4.5
+ compile
+
+
+ mysql
+ mysql-connector-java
+
+
- io.geekidea.springbootplus
- parent
- 2.0
+ io.geekidea.boot
+ spring-boot-plus
+ 2.1-SNAPSHOT
config
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/constant/CacheKey.java b/config/src/main/java/io/geekidea/boot/config/constant/CacheKey.java
similarity index 93%
rename from config/src/main/java/io/geekidea/springbootplus/config/constant/CacheKey.java
rename to config/src/main/java/io/geekidea/boot/config/constant/CacheKey.java
index 8d348c8f5dacfb5f5993b80ee59ccfb34dbcefc9..7585cfa4b6299592b08fb45689e8d6158bccd3fe 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/constant/CacheKey.java
+++ b/config/src/main/java/io/geekidea/boot/config/constant/CacheKey.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.constant;
+package io.geekidea.boot.config.constant;
/**
* 可排序查询参数对象
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/constant/CommonConstant.java b/config/src/main/java/io/geekidea/boot/config/constant/CommonConstant.java
similarity index 96%
rename from config/src/main/java/io/geekidea/springbootplus/config/constant/CommonConstant.java
rename to config/src/main/java/io/geekidea/boot/config/constant/CommonConstant.java
index 634d3d27bc7ef9e18a95950b1dd43cbfdabad897..bc292463023722544718a021205b2599976c42b0 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/constant/CommonConstant.java
+++ b/config/src/main/java/io/geekidea/boot/config/constant/CommonConstant.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.constant;
+package io.geekidea.boot.config.constant;
/**
* 公共常量
@@ -88,7 +88,7 @@ public interface CommonConstant {
/**
* JWT 默认过期时间,3600L,单位秒
*/
- Long JWT_DEFAULT_EXPIRE_SECOND = 3600L;
+ Long JWT_DEFAULT_EXPIRE_SECOND = 3600 * 24L;
/**
* 默认头像
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/constant/CommonRedisKey.java b/config/src/main/java/io/geekidea/boot/config/constant/CommonRedisKey.java
similarity index 96%
rename from config/src/main/java/io/geekidea/springbootplus/config/constant/CommonRedisKey.java
rename to config/src/main/java/io/geekidea/boot/config/constant/CommonRedisKey.java
index f3d79bd1105177fbef18d5e9a765f9389dd9b8e4..77cdae77191efed958fc9359b4e0fdd4c0c60d8b 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/constant/CommonRedisKey.java
+++ b/config/src/main/java/io/geekidea/boot/config/constant/CommonRedisKey.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.constant;
+package io.geekidea.boot.config.constant;
/**
*
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/constant/DatePattern.java b/config/src/main/java/io/geekidea/boot/config/constant/DatePattern.java
similarity index 96%
rename from config/src/main/java/io/geekidea/springbootplus/config/constant/DatePattern.java
rename to config/src/main/java/io/geekidea/boot/config/constant/DatePattern.java
index a7d5735e6da3fcd4a4452b0e66d23af49e703122..3478c6598b18519695adfe07e365efd3911f9804 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/constant/DatePattern.java
+++ b/config/src/main/java/io/geekidea/boot/config/constant/DatePattern.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.constant;
+package io.geekidea.boot.config.constant;
/**
*
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/JwtProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/JwtProperties.java
similarity index 94%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/JwtProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/JwtProperties.java
index c66377eff9ef0b4ec838fb9d14ab23c9e9f595f6..8d04832b8cc703a0d3c5213c1db01293f08dc98b 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/JwtProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/JwtProperties.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
-import io.geekidea.springbootplus.config.constant.CommonConstant;
+import io.geekidea.boot.config.constant.CommonConstant;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/ShiroPermissionProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/ShiroPermissionProperties.java
similarity index 94%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/ShiroPermissionProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/ShiroPermissionProperties.java
index 39847e93d0764479131c567dc7ed370c4c876739..1754442e42663d0e3da0741a9735469f8e4a415c 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/ShiroPermissionProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/ShiroPermissionProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/ShiroProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/ShiroProperties.java
similarity index 96%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/ShiroProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/ShiroProperties.java
index 3acc6ba3e8c3ed6ae871e60bde2fdd4c8e31fd57..bcf9e35a93b1b0bc0bccae20d92e86f53e5b56da 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/ShiroProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/ShiroProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusAopProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusAopProperties.java
similarity index 98%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusAopProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusAopProperties.java
index d294b60ff5582fcdb5cdfc321d3f54675249c85d..d3a087261153c2b2b6b68efc893fb2347ff0ba69 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusAopProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusAopProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import lombok.EqualsAndHashCode;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusCorsProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusCorsProperties.java
similarity index 97%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusCorsProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusCorsProperties.java
index b6eda2b46a2a4b366cdd0202c78274c04e67355e..83585a642336ac1e9836692a50783b105ebbc968 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusCorsProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusCorsProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusFilterProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusFilterProperties.java
similarity index 96%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusFilterProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusFilterProperties.java
index 16fc40d8868e1b64a2dde4d23171ad3dfeb04fd7..258c69df3a2f6f3bd8e5ec3ee0fc5fe0ff4ab90e 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusFilterProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusFilterProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusInterceptorProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusInterceptorProperties.java
similarity index 97%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusInterceptorProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusInterceptorProperties.java
index 5224a78361db7b1af7fe5ce7e89501ef7c61a93f..1855b5e32a3598d4338a21f6b93b587f98c8cfba 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusInterceptorProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusInterceptorProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusProperties.java
similarity index 98%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusProperties.java
index b486ad9ea78403db3ae767fab5ff2dcad9e79c1b..b0c75dda999aefd1b71153c2a439f3ce74052251 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusStaticProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusStaticProperties.java
similarity index 96%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusStaticProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusStaticProperties.java
index 5e338c8bb9c3e9bff9e5ead51dbd9dff74a787b4..94cc0017ea23c150fc621fd0e36f307715f8c187 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SpringBootPlusStaticProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SpringBootPlusStaticProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/SwaggerProperties.java b/config/src/main/java/io/geekidea/boot/config/properties/SwaggerProperties.java
similarity index 98%
rename from config/src/main/java/io/geekidea/springbootplus/config/properties/SwaggerProperties.java
rename to config/src/main/java/io/geekidea/boot/config/properties/SwaggerProperties.java
index c400475b0e237c05106db583e31cbcf4838c078f..a5a3a3406194c9d2839b0b10f1a1511bfc65032a 100644
--- a/config/src/main/java/io/geekidea/springbootplus/config/properties/SwaggerProperties.java
+++ b/config/src/main/java/io/geekidea/boot/config/properties/SwaggerProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.geekidea.springbootplus.config.properties;
+package io.geekidea.boot.config.properties;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
diff --git a/config/src/main/java/io/geekidea/springbootplus/config/properties/QiniuProperties.java b/config/src/main/java/io/geekidea/springbootplus/config/properties/QiniuProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..d76e884b5d891e6c56e274fbb6c0bcfc6bc8fc2a
--- /dev/null
+++ b/config/src/main/java/io/geekidea/springbootplus/config/properties/QiniuProperties.java
@@ -0,0 +1,17 @@
+package io.geekidea.springbootplus.config.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@Data
+@ConfigurationProperties(prefix = "qiniu")
+public class QiniuProperties {
+
+ private String accessKey;
+
+ private String secretKey;
+
+ private String bucket;
+
+ private String prefix;
+}
diff --git a/config/src/main/resources/config/application-dev.yml b/config/src/main/resources/config/application-dev.yml
index eb3e3dcf59cc01f84526b6c3af8405fb2d972095..9c080306446cc1c59113bbd329dcaecaa6b026c1 100644
--- a/config/src/main/resources/config/application-dev.yml
+++ b/config/src/main/resources/config/application-dev.yml
@@ -9,7 +9,7 @@ spring-boot-plus:
spring:
datasource:
- url: jdbc:mysql://localhost:3306/spring_boot_plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
+ url: jdbc:mysql://localhost:3306/spring_boot_pmp?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
@@ -20,7 +20,35 @@ spring:
password:
port: 6379
+ servlet:
+ multipart:
+ location: /Users/limingguang/upload_tmp
+
# 打印SQL语句和结果集,本地开发环境可开启,线上注释掉
mybatis-plus:
configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+# 七牛云配置
+qiniu:
+ accessKey: VNddBCSpToUG5AHuQHpQSHX2X1v_CWDgbbTCk-Mw
+ secretKey: t7eYfFBBsyj7RNas5N2l_z8mzKvGgIsHf49EfCQk
+ bucket: pmp-sys
+ zone: huadong
+ domain: cdn.koronol.com
+
+# 微信配置
+wechat:
+ appId: wx89e746383cc2cf6a
+ secret: 9f1bf70209fb0feb97d577f5f4e163f7
+ mchId: 1606561696
+ partnerKey: 765d11bba1ce4c00bf343e087d25865a
+ apiV3Key: eb79f964741711eb87f88c8590719960
+ mchSerialNo: 6223053CFC87658408133AB1DAE52F24B9BA85C1
+ notifyUrl: http://l17424255.gicp.net/api
+ certPath: cert/apiclient_cert.p12
+
+# 头条小程序配置
+toutiao:
+ appId: tt6f6419d9f05c9be001
+ secret: 9889be8caf652f947e07144e519036ab3619e350
\ No newline at end of file
diff --git a/config/src/main/resources/config/application-prod.yml b/config/src/main/resources/config/application-prod.yml
index 0e22cd9a7ba7366a4ccfc86c3af4a8c592e760ec..5f61b540ddb0fb0946548b106eec6c86bf31674f 100644
--- a/config/src/main/resources/config/application-prod.yml
+++ b/config/src/main/resources/config/application-prod.yml
@@ -2,7 +2,7 @@ spring-boot-plus:
# 是否启用ansi控制台输出有颜色的字体,local环境建议开启,服务器环境设置为false
enable-ansi: false
# 当前环境服务IP地址
- server-ip:
+ server-ip: 127.0.0.1
# 生产环境禁用Swagger
swagger:
enable: false
@@ -16,14 +16,37 @@ spring-boot-plus:
spring:
datasource:
- url:
- username:
- password:
+ url: jdbc:mysql://localhost:3306/spring_boot_pmp?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
+ username: root
+ password: Springboot666!
# Redis配置
redis:
- database:
- host:
+ database: 0
+ host: localhost
password:
- port:
+ port: 6379
+
+# 七牛云配置
+qiniu:
+ accessKey: VNddBCSpToUG5AHuQHpQSHX2X1v_CWDgbbTCk-Mw
+ secretKey: t7eYfFBBsyj7RNas5N2l_z8mzKvGgIsHf49EfCQk
+ bucket: pmp-sys
+ zone: huadong
+ domain: cdn.koronol.com
+
+# 微信配置
+wechat:
+ appId: wx89e746383cc2cf6a
+ secret: 9f1bf70209fb0feb97d577f5f4e163f7
+ mchId: 1606561696
+ partnerKey: 765d11bba1ce4c00bf343e087d25865a
+ apiV3Key: eb79f964741711eb87f88c8590719960
+ mchSerialNo: 6223053CFC87658408133AB1DAE52F24B9BA85C1
+ notifyUrl: https://pmp.koronol.com/api
+ certPath: /data/pmp/apiclient_cert.p12
+# 头条小程序配置
+toutiao:
+ appId: tt6f6419d9f05c9be001
+ secret: 9889be8caf652f947e07144e519036ab3619e350
diff --git a/config/src/main/resources/config/application.yml b/config/src/main/resources/config/application.yml
index 831a00dd3f2aded5fb2c8642442062d5a57391f9..47b5d952e1c0400053206a6e7e33f4f0c59fff67 100644
--- a/config/src/main/resources/config/application.yml
+++ b/config/src/main/resources/config/application.yml
@@ -5,6 +5,10 @@ server:
port: 8888
servlet:
context-path: /api
+ encoding:
+ charset: UTF-8
+ enabled: true
+ force: true
tomcat:
max-threads: 1000
min-spare-threads: 30
@@ -40,7 +44,8 @@ spring:
---
spring:
profiles:
- active: @profileActive@
+ active: prod
+# active: @profileActive@
# logback.xml中有详细的日志配置
logging:
@@ -184,12 +189,19 @@ spring-boot-plus:
anon:
# 排除登录登出
- /login,/logout
+ - /profile/signIn
+ - /profile/signInByToutiao
+ - /profile/signInByPhone
+ - /**/wechat/**
+ # 微信支付异步通知
+ - /wxPay/payNotify
# 排除静态资源
- /static/**,/templates/**
# 排除Swagger
- ${spring-boot-plus.swagger-paths}
# 排除actuator
- /actuator/**
+ - /paper/wechat/getOpenPaper
- # 排除首页
- /,/index.html
# 排除测试路径
@@ -221,7 +233,7 @@ spring-boot-plus:
# 刷新token的时间间隔,默认10分钟,单位:秒
refresh-token-countdown: 600
# redis校验jwt token是否存在,可选
- redis-check: true
+ redis-check: false
# true: 同一个账号只能是最后一次登录token有效,false:同一个账号可多次登录
single-login: false
# 盐值校验,如果不加自定义盐值,则使用secret校验
@@ -236,7 +248,7 @@ mybatis-plus:
# 启动时是否检查MyBatis XML文件是否存在
check-config-location: true
# 支持统配符 * 或者 ; 分割
- typeEnumsPackage: io.geekidea.springbootplus.*.enums
+ typeEnumsPackage: io.geekidea.boot.*.enums
# MyBatis原生配置
configuration:
# 字段名称下划线转驼峰命名
@@ -302,7 +314,7 @@ spring-boot-plus:
enable: true
base:
# 扫描的包,多个包使用逗号隔开
- package: io.geekidea.springbootplus,com.example
+ package: io.geekidea.boot,com.example,com.koronol
contact:
email: geekidea@qq.com
name: springboot.plus
diff --git a/config/src/main/resources/config/logback.xml b/config/src/main/resources/config/logback.xml
index dbe0c96888696319c216883b9cdaeb735418b7d0..df5b4ce76e711c875fa340fad2b72c65d1d95aae 100644
--- a/config/src/main/resources/config/logback.xml
+++ b/config/src/main/resources/config/logback.xml
@@ -89,7 +89,7 @@
-
+
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 85b89ce7093952e654538001ea2bea925f549b6d..3ecb1e0aaa176b5c8177186dec95309f62d6ba95 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -21,9 +21,9 @@
4.0.0
- io.geekidea.springbootplus
- parent
- 2.0
+ io.geekidea.boot
+ spring-boot-plus
+ 2.1-SNAPSHOT
distribution
@@ -35,7 +35,7 @@
release
- io.geekidea.springbootplus
+ io.geekidea.boot
bootstrap
diff --git a/distribution/release.xml b/distribution/release.xml
index b46646fa5909374d972b798f056f7d18f61adef7..81ce21de57b23ce17586b2e006a140c3d56b7375 100644
--- a/distribution/release.xml
+++ b/distribution/release.xml
@@ -67,7 +67,7 @@
true
- io.geekidea.springbootplus:bootstrap
+ io.geekidea.boot:bootstrap
diff --git a/docs/db/mysql_spring_boot_plus.sql b/docs/db/mysql_spring_boot_plus.sql
index 1c9f6167cd7295a20602b7dc32e87f47786bde42..d05adc6a9e5c821a4fc4ea5a73c62272143b51ad 100644
--- a/docs/db/mysql_spring_boot_plus.sql
+++ b/docs/db/mysql_spring_boot_plus.sql
@@ -406,5 +406,5 @@ INSERT INTO sys_login_log (id, request_id, username, ip, area, operator, token,
INSERT INTO sys_login_log (id, request_id, username, ip, area, operator, token, type, success, code, exception_message, user_agent, browser_name, browser_version, engine_name, engine_version, os_name, platform_name, mobile, device_name, device_model, remark, create_time, update_time) VALUES (3, '1242814069371625474', 'admin', '127.0.0.1', '本机地址', null, null, 1, 0, null, '用户名或密码错误', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36', 'Chrome', '80.0.3987.149', 'Webkit', '537.36', 'OSX', 'Mac', 0, null, null, null, '2020-03-25 22:02:25', null);
INSERT INTO sys_login_log (id, request_id, username, ip, area, operator, token, type, success, code, exception_message, user_agent, browser_name, browser_version, engine_name, engine_version, os_name, platform_name, mobile, device_name, device_model, remark, create_time, update_time) VALUES (4, '1242814192096960513', null, '127.0.0.1', '本机地址', null, null, 2, 0, null, 'token不能为空', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36', 'Chrome', '80.0.3987.149', 'Webkit', '537.36', 'OSX', 'Mac', 0, null, null, null, '2020-03-25 22:02:54', null);
-INSERT INTO sys_operation_log (id, request_id, user_id, user_name, name, ip, area, operator, path, module, class_name, method_name, request_method, content_type, request_body, param, token, type, success, code, message, exception_name, exception_message, browser_name, browser_version, engine_name, engine_version, os_name, platform_name, mobile, device_name, device_model, remark, create_time, update_time) VALUES (1, '1242805276474634241', null, null, 'helloWorld', '127.0.0.1', '本机地址', null, '/api/hello/world', null, 'io.geekidea.springbootplus.system.controller.HelloWorldController', 'helloWorld', 'GET', null, 0, null, null, 0, 1, 200, '操作成功', null, null, 'Chrome', '80.0.3987.149', 'Webkit', '537.36', 'OSX', 'Mac', 0, null, null, '', '2020-03-25 21:27:22', null);
+INSERT INTO sys_operation_log (id, request_id, user_id, user_name, name, ip, area, operator, path, module, class_name, method_name, request_method, content_type, request_body, param, token, type, success, code, message, exception_name, exception_message, browser_name, browser_version, engine_name, engine_version, os_name, platform_name, mobile, device_name, device_model, remark, create_time, update_time) VALUES (1, '1242805276474634241', null, null, 'helloWorld', '127.0.0.1', '本机地址', null, '/api/hello/world', null, 'io.geekidea.boot.system.controller.HelloWorldController', 'helloWorld', 'GET', null, 0, null, null, 0, 1, 200, '操作成功', null, null, 'Chrome', '80.0.3987.149', 'Webkit', '537.36', 'OSX', 'Mac', 0, null, null, '', '2020-03-25 21:27:22', null);
INSERT INTO sys_operation_log (id, request_id, user_id, user_name, name, ip, area, operator, path, module, class_name, method_name, request_method, content_type, request_body, param, token, type, success, code, message, exception_name, exception_message, browser_name, browser_version, engine_name, engine_version, os_name, platform_name, mobile, device_name, device_model, remark, create_time, update_time) VALUES (2, '1242820418688049153', null, null, 'FooBar分页列表', '127.0.0.1', '本机地址', null, '/api/fooBar/getPageList', 'foobar', 'com.example.foobar.controller.FooBarController', 'getFooBarPageList', 'POST', 'application/json', 1, '{"pageIndex":1,"pageSize":10}', null, 7, 1, 200, '操作成功', null, null, 'Chrome', '80.0.3987.149', 'Webkit', '537.36', 'OSX', 'Mac', 0, null, null, '', '2020-03-25 22:27:33', null);
diff --git a/example/pom.xml b/example/pom.xml
index afed3bd513310886771364f2afa518590aa60663..9929884c2da0c0d81145747efce827555d405b01 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -21,9 +21,9 @@
4.0.0
- io.geekidea.springbootplus
- parent
- 2.0
+ io.geekidea.boot
+ spring-boot-plus
+ 2.1-SNAPSHOT
example
@@ -32,7 +32,7 @@
- io.geekidea.springbootplus
+ io.geekidea.boot
framework
diff --git a/example/src/main/java/com/example/category/controller/CategoryController.java b/example/src/main/java/com/example/category/controller/CategoryController.java
new file mode 100644
index 0000000000000000000000000000000000000000..323b10bd1a57b01a2064c78d6ffdb861a6db5048
--- /dev/null
+++ b/example/src/main/java/com/example/category/controller/CategoryController.java
@@ -0,0 +1,131 @@
+package com.example.category.controller;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.category.entity.Category;
+import com.example.category.service.CategoryService;
+import com.example.category.vo.CategoryDetailVo;
+import com.example.order.entity.Order;
+import com.example.order.service.OrderService;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.util.LoginUtil;
+import lombok.extern.slf4j.Slf4j;
+import com.example.category.param.CategoryPageParam;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 题目分类 控制器
+ *
+ * @author geekidea
+ * @since 2021-01-26
+ */
+@Slf4j
+@RestController
+@RequestMapping("/category")
+@Module("category")
+@Api(value = "题目分类API", tags = {"题目分类"})
+public class CategoryController extends BaseController {
+
+ @Autowired
+ private CategoryService categoryService;
+
+ @Autowired
+ private OrderService orderService;
+
+ /**
+ * 添加题目分类
+ */
+ @PostMapping("/submit")
+ @OperationLog(name = "添加题目分类", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加题目分类", response = ApiResult.class)
+ @CacheEvict(cacheNames = "category", allEntries = true)
+ public ApiResult addPCategory(@Validated(Add.class) @RequestBody Category category) throws Exception {
+ boolean flag = category.insertOrUpdate();
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改题目分类
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改题目分类", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改题目分类", response = ApiResult.class)
+ public ApiResult updatePCategory(@Validated(Update.class) @RequestBody Category pCategory) throws Exception {
+ boolean flag = categoryService.updateById(pCategory);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除题目分类
+ */
+ @PostMapping("/delete")
+ @OperationLog(name = "删除题目分类", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除题目分类", response = ApiResult.class)
+ @CacheEvict(cacheNames = "category", allEntries = true)
+ public ApiResult deleteCategory(@RequestBody List ids) throws Exception {
+ boolean flag = categoryService.deletePCategory(ids);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取题目分类详情
+ */
+ @GetMapping("/wechat/info/{code}")
+ @OperationLog(name = "题目分类详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "题目分类详情", response = Category.class)
+ public ApiResult getCategory(@PathVariable("code") String code) throws Exception {
+ Category category = categoryService.getOne(new LambdaQueryWrapper().eq(Category::getCode, code));
+ CategoryDetailVo detailVo = Convert.convert(CategoryDetailVo.class, category);
+
+ if (StrUtil.isEmpty(LoginUtil.getAppUserId())) {
+ detailVo.setIsBuy(false);
+ } else {
+ int count = orderService.count(new LambdaQueryWrapper()
+ .eq(Order::getGroupId, code)
+ .eq(Order::getUserId, LoginUtil.getAppUserId())
+ .eq(Order::getStatus, "2")
+ );
+ detailVo.setIsBuy(count > 0 ? true : false);
+ }
+
+ return ApiResult.ok(detailVo);
+ }
+
+ /**
+ * 题目分类分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "题目分类分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "题目分类分页列表", response = Category.class)
+ @Cacheable(cacheNames = "category", key = "#categoryPageParam.getPageIndex()+'::'+#categoryPageParam.getPageSize()")
+ public ApiResult> getPCategoryPageList(@Validated @RequestBody CategoryPageParam categoryPageParam) throws Exception {
+ Paging paging = categoryService.getCategoryPageList(categoryPageParam);
+ return ApiResult.ok(paging);
+ }
+
+ @GetMapping("/wechat/getAllList")
+ @OperationLog(name = "题目分类列表", type = OperationLogType.LIST)
+ @ApiOperation(value = "题目分类列表", response = Category.class)
+ @Cacheable(cacheNames = "category", key = "#root.method.name")
+ public ApiResult> getAllCategoryList() throws Exception {
+ return ApiResult.ok(categoryService.list());
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/category/entity/Category.java b/example/src/main/java/com/example/category/entity/Category.java
new file mode 100644
index 0000000000000000000000000000000000000000..fd4d254c78609013a93099081c8e23f5e6bc8aa1
--- /dev/null
+++ b/example/src/main/java/com/example/category/entity/Category.java
@@ -0,0 +1,85 @@
+package com.example.category.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 题目分类
+ *
+ * @author geekidea
+ * @since 2021-01-26
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "p_category")
+@ApiModel(value = "Category对象")
+public class Category extends Model {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("标题")
+ @TableField("SUBJECT")
+ private String subject;
+
+ @ApiModelProperty("封面图片")
+ @TableField("COVER_IMG")
+ private String coverImg;
+
+ @ApiModelProperty("编号")
+ @TableField("CODE")
+ private String code;
+
+ @ApiModelProperty("价格")
+ @TableField("PRICE")
+ @NotNull(message = "请输入价格", groups = {Add.class, Update.class})
+ @Min(value = 0, message = "价格不能小于0")
+ @Max(value = 99999, message = "价格不能超过99999")
+ private BigDecimal price;
+
+ @ApiModelProperty("描述")
+ @TableField("REMARK")
+ private String remark;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ @Version
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField("CREATED_TIME")
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/category/mapper/CategoryMapper.java b/example/src/main/java/com/example/category/mapper/CategoryMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..31f5d7e1daa95b14eab0370091d580990ccafe6a
--- /dev/null
+++ b/example/src/main/java/com/example/category/mapper/CategoryMapper.java
@@ -0,0 +1,23 @@
+package com.example.category.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.category.entity.Category;
+import com.example.category.param.CategoryPageParam;
+
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+
+/**
+ * 题目分类 Mapper 接口
+ *
+ * @author geekidea
+ * @since 2021-01-26
+ */
+@Repository
+public interface CategoryMapper extends BaseMapper {
+
+}
diff --git a/example/src/main/java/com/example/category/param/CategoryPageParam.java b/example/src/main/java/com/example/category/param/CategoryPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..3843c4dd7156fa7827a72f6d06ada7bb20fb648f
--- /dev/null
+++ b/example/src/main/java/com/example/category/param/CategoryPageParam.java
@@ -0,0 +1,23 @@
+package com.example.category.param;
+
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ *
+ * 题目分类 分页参数对象
+ *
+ *
+ * @author geekidea
+ * @date 2021-01-26
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "题目分类分页参数")
+public class CategoryPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+}
diff --git a/example/src/main/java/com/example/category/service/CategoryService.java b/example/src/main/java/com/example/category/service/CategoryService.java
new file mode 100644
index 0000000000000000000000000000000000000000..8c9690b7c11f19495e62f9f5e9245b56e9b20719
--- /dev/null
+++ b/example/src/main/java/com/example/category/service/CategoryService.java
@@ -0,0 +1,55 @@
+package com.example.category.service;
+
+import com.example.category.entity.Category;
+import com.example.category.param.CategoryPageParam;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+import java.util.List;
+
+/**
+ * 题目分类 服务类
+ *
+ * @author geekidea
+ * @since 2021-01-26
+ */
+public interface CategoryService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param pCategory
+ * @return
+ * @throws Exception
+ */
+ boolean savePCategory(Category pCategory) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param pCategory
+ * @return
+ * @throws Exception
+ */
+ boolean updatePCategory(Category pCategory) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deletePCategory(List id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param categoryPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getCategoryPageList(CategoryPageParam categoryPageParam) throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/category/service/impl/CategoryServiceImpl.java b/example/src/main/java/com/example/category/service/impl/CategoryServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..0789be764f7824b97df11face1d4df16b622ddc0
--- /dev/null
+++ b/example/src/main/java/com/example/category/service/impl/CategoryServiceImpl.java
@@ -0,0 +1,60 @@
+package com.example.category.service.impl;
+
+import com.example.category.entity.Category;
+import com.example.category.mapper.CategoryMapper;
+import com.example.category.service.CategoryService;
+import com.example.category.param.CategoryPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.geekidea.boot.framework.util.LoginUtil;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * 题目分类 服务实现类
+ *
+ * @author geekidea
+ * @since 2021-01-26
+ */
+@Slf4j
+@Service
+public class CategoryServiceImpl extends BaseServiceImpl implements CategoryService {
+
+ @Autowired
+ private CategoryMapper categoryMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean savePCategory(Category pCategory) throws Exception {
+ return super.save(pCategory);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updatePCategory(Category pCategory) throws Exception {
+ return super.updateById(pCategory);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deletePCategory(List ids) throws Exception {
+ return super.removeByIds(ids);
+ }
+
+ @Override
+ public Paging getCategoryPageList(CategoryPageParam getCategoryPageList) throws Exception {
+ Page page = new PageInfo<>(getCategoryPageList, OrderItem.desc(getLambdaColumn(Category::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = categoryMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+}
diff --git a/example/src/main/java/com/example/category/vo/CategoryDetailVo.java b/example/src/main/java/com/example/category/vo/CategoryDetailVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..3bf207177999f13b940652b637580af9489cc727
--- /dev/null
+++ b/example/src/main/java/com/example/category/vo/CategoryDetailVo.java
@@ -0,0 +1,45 @@
+package com.example.category.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "CategoryDetailVo对象", description = "小程序专题详情对象")
+public class CategoryDetailVo implements Serializable {
+ private static final long serialVersionUID = 6599710269043866693L;
+
+ @ApiModelProperty("ID")
+ private Integer id;
+
+ @ApiModelProperty("标题")
+ private String subject;
+
+ @ApiModelProperty("封面图片")
+ private String coverImg;
+
+ @ApiModelProperty("编号")
+ private String code;
+
+ @ApiModelProperty("价格")
+ private BigDecimal price;
+
+ @ApiModelProperty("描述")
+ private String remark;
+
+ @ApiModelProperty("是否购买")
+ private Boolean isBuy;
+}
diff --git a/example/src/main/java/com/example/chapter/controller/ChapterController.java b/example/src/main/java/com/example/chapter/controller/ChapterController.java
new file mode 100644
index 0000000000000000000000000000000000000000..fd497722c1b2a0aa5a8db9e7794d6626e8b5f5c9
--- /dev/null
+++ b/example/src/main/java/com/example/chapter/controller/ChapterController.java
@@ -0,0 +1,104 @@
+package com.example.chapter.controller;
+
+import com.example.chapter.entity.Chapter;
+import com.example.chapter.service.ChapterService;
+import lombok.extern.slf4j.Slf4j;
+import com.example.chapter.param.ChapterPageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.common.param.IdParam;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 控制器
+ *
+ * @author limg
+ * @since 2021-02-18
+ */
+@Slf4j
+@RestController
+@RequestMapping("/chapter")
+@Module("chapter")
+@Api(value = "章节管理API", tags = {"章节管理"})
+public class ChapterController extends BaseController {
+
+ @Autowired
+ private ChapterService chapterService;
+
+ /**
+ * 添加
+ */
+ @PostMapping("/submit")
+ @OperationLog(name = "添加", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加", response = ApiResult.class)
+ @CacheEvict(cacheNames = "chapter", allEntries = true)
+ public ApiResult addChapter(@Validated(Add.class) @RequestBody Chapter chapter) throws Exception {
+// boolean flag = chapterService.saveChapter(chapter);
+ boolean flag = chapter.insertOrUpdate();
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除
+ */
+ @PostMapping("/delete/{id}")
+ @OperationLog(name = "删除", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除", response = ApiResult.class)
+ @CacheEvict(cacheNames = "chapter", allEntries = true)
+ public ApiResult deleteChapter(@PathVariable("id") Long id) throws Exception {
+ boolean flag = chapterService.deleteChapter(id);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "详情", response = Chapter.class)
+ public ApiResult getChapter(@PathVariable("id") Long id) throws Exception {
+ Chapter chapter = chapterService.getById(id);
+ return ApiResult.ok(chapter);
+ }
+
+ /**
+ * 分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "分页列表", response = Chapter.class)
+ @Cacheable(cacheNames = "chapter", key = "#chapterPageParam.getPageIndex()+'::'+#chapterPageParam.getPageSize()")
+ public ApiResult> getChapterPageList(@Validated @RequestBody ChapterPageParam chapterPageParam) throws Exception {
+ Paging paging = chapterService.getChapterPageList(chapterPageParam);
+ return ApiResult.ok(paging);
+ }
+
+ /**
+ * 分页列表
+ */
+ @GetMapping("/wechat/getPageList")
+ @OperationLog(name = "小程序端分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "小程序端分页列表", response = Chapter.class)
+ @Cacheable(cacheNames = "chapter", key = "#root.methodName")
+ public ApiResult> getWechatChapterPageList() throws Exception {
+ ChapterPageParam chapterPageParam = new ChapterPageParam();
+ chapterPageParam.setPageIndex(1L);
+ chapterPageParam.setPageSize(100L);
+ Paging paging = chapterService.getChapterPageList(chapterPageParam);
+ return ApiResult.ok(paging);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/chapter/entity/Chapter.java b/example/src/main/java/com/example/chapter/entity/Chapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..e412faf85d53a0da55a06a1a5cc0abdeb0467d3d
--- /dev/null
+++ b/example/src/main/java/com/example/chapter/entity/Chapter.java
@@ -0,0 +1,60 @@
+package com.example.chapter.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+/**
+ *
+ *
+ * @author limg
+ * @since 2021-02-18
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_chapter")
+@ApiModel(value = "Chapter对象")
+public class Chapter extends Model {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("章节名称")
+ @TableField("NAME")
+ private String name;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/chapter/mapper/ChapterMapper.java b/example/src/main/java/com/example/chapter/mapper/ChapterMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..5141079ddc038de1d71721d544e19d04c51c27b3
--- /dev/null
+++ b/example/src/main/java/com/example/chapter/mapper/ChapterMapper.java
@@ -0,0 +1,24 @@
+package com.example.chapter.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.chapter.entity.Chapter;
+import com.example.chapter.param.ChapterPageParam;
+
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+
+/**
+ * Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-18
+ */
+@Repository
+public interface ChapterMapper extends BaseMapper {
+
+
+}
diff --git a/example/src/main/java/com/example/chapter/param/ChapterPageParam.java b/example/src/main/java/com/example/chapter/param/ChapterPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7e8415477a63fdbe7dde57804083f1f20ee4267
--- /dev/null
+++ b/example/src/main/java/com/example/chapter/param/ChapterPageParam.java
@@ -0,0 +1,23 @@
+package com.example.chapter.param;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+/**
+ *
+ * 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-18
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "分页参数")
+public class ChapterPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+}
diff --git a/example/src/main/java/com/example/chapter/service/ChapterService.java b/example/src/main/java/com/example/chapter/service/ChapterService.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ccfb310379c73108b2b373c9088e202f9898cd3
--- /dev/null
+++ b/example/src/main/java/com/example/chapter/service/ChapterService.java
@@ -0,0 +1,53 @@
+package com.example.chapter.service;
+
+import com.example.chapter.entity.Chapter;
+import com.example.chapter.param.ChapterPageParam;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+/**
+ * 服务类
+ *
+ * @author limg
+ * @since 2021-02-18
+ */
+public interface ChapterService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param chapter
+ * @return
+ * @throws Exception
+ */
+ boolean saveChapter(Chapter chapter) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param chapter
+ * @return
+ * @throws Exception
+ */
+ boolean updateChapter(Chapter chapter) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deleteChapter(Long id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param chapterPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getChapterPageList(ChapterPageParam chapterPageParam) throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/chapter/service/impl/ChapterServiceImpl.java b/example/src/main/java/com/example/chapter/service/impl/ChapterServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..0bb526db71b7c7d14218a1d6c222db0a4a63fd2d
--- /dev/null
+++ b/example/src/main/java/com/example/chapter/service/impl/ChapterServiceImpl.java
@@ -0,0 +1,58 @@
+package com.example.chapter.service.impl;
+
+import com.example.chapter.entity.Chapter;
+import com.example.chapter.mapper.ChapterMapper;
+import com.example.chapter.service.ChapterService;
+import com.example.chapter.param.ChapterPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-18
+ */
+@Slf4j
+@Service
+public class ChapterServiceImpl extends BaseServiceImpl implements ChapterService {
+
+ @Autowired
+ private ChapterMapper chapterMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveChapter(Chapter chapter) throws Exception {
+ return super.save(chapter);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateChapter(Chapter chapter) throws Exception {
+ return super.updateById(chapter);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteChapter(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Paging getChapterPageList(ChapterPageParam chapterPageParam) throws Exception {
+ Page page = new PageInfo<>(chapterPageParam, OrderItem.asc(getLambdaColumn(Chapter::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = chapterMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+
+}
diff --git a/example/src/main/java/com/example/examDate/controller/DateController.java b/example/src/main/java/com/example/examDate/controller/DateController.java
new file mode 100644
index 0000000000000000000000000000000000000000..22404000b53a26d3d9a4f6d515c23fa6bb412060
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/controller/DateController.java
@@ -0,0 +1,100 @@
+package com.example.examDate.controller;
+
+import com.example.examDate.entity.ExamDate;
+import com.example.examDate.service.DateService;
+import com.example.examDate.vo.ExamDateGoodVo;
+import lombok.extern.slf4j.Slf4j;
+import com.example.examDate.param.DatePageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 考试日期设置 控制器
+ *
+ * @author limg
+ * @since 2021-02-27
+ */
+@Slf4j
+@RestController
+@RequestMapping("/date")
+@Module("examDate")
+@Api(value = "考试日期设置API", tags = {"考试日期设置"})
+public class DateController extends BaseController {
+
+ @Autowired
+ private DateService dateService;
+
+ /**
+ * 添加考试日期设置
+ */
+ @PostMapping("/add")
+ @OperationLog(name = "添加考试日期设置", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加考试日期设置", response = ApiResult.class)
+ @CacheEvict(value = "userRank", allEntries = true)
+ public ApiResult addDate(@Validated(Add.class) @RequestBody ExamDate date) throws Exception {
+ boolean flag = dateService.saveDate(date);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改考试日期设置
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改考试日期设置", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改考试日期设置", response = ApiResult.class)
+ @CacheEvict(value = "userRank", allEntries = true)
+ public ApiResult updateDate(@Validated(Update.class) @RequestBody ExamDate date) throws Exception {
+ boolean flag = dateService.updateDate(date);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除考试日期设置
+ */
+ @PostMapping("/delete/{id}")
+ @OperationLog(name = "删除考试日期设置", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除考试日期设置", response = ApiResult.class)
+ @CacheEvict(value = "userRank", allEntries = true)
+ public ApiResult deleteDate(@PathVariable("id") Long id) throws Exception {
+ boolean flag = dateService.deleteDate(id);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 考试日期设置分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "考试日期设置分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "考试日期设置分页列表", response = ExamDate.class)
+ public ApiResult> getDatePageList(@Validated @RequestBody DatePageParam datePageParam) throws Exception {
+ Paging paging = dateService.getDatePageList(datePageParam);
+ return ApiResult.ok(paging);
+ }
+
+ /**
+ * 考试日期商品信息
+ */
+ @GetMapping("/wechat/getExamDateInfo")
+ @OperationLog(name = "考试日期商品信息", type = OperationLogType.INFO)
+ @ApiOperation(value = "考试日期商品信息", response = ExamDateGoodVo.class)
+ @Cacheable(value = "userRank", key = "#root.methodName")
+ public ApiResult getExamDateInfo() throws Exception {
+ ExamDateGoodVo examDateGoodVo = dateService.calcOrderAmount();
+ return ApiResult.ok(examDateGoodVo);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/examDate/entity/ExamDate.java b/example/src/main/java/com/example/examDate/entity/ExamDate.java
new file mode 100644
index 0000000000000000000000000000000000000000..b56dd366c1764058e2fc0e81fba96d648843a2c3
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/entity/ExamDate.java
@@ -0,0 +1,63 @@
+package com.example.examDate.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+import java.time.LocalDate;
+import java.util.Date;
+
+/**
+ * 考试日期设置
+ *
+ * @author limg
+ * @since 2021-02-27
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("sys_date")
+@ApiModel(value = "examDate对象")
+public class ExamDate extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("考试时间")
+ @TableField("EXAM_DATE")
+ private LocalDate examDate;
+
+ @ApiModelProperty("备注")
+ @TableField("REMARK")
+ private String remark;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/examDate/mapper/DateMapper.java b/example/src/main/java/com/example/examDate/mapper/DateMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..f1d247650a6104cf88b30e146cb85748ea303c57
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/mapper/DateMapper.java
@@ -0,0 +1,23 @@
+package com.example.examDate.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.examDate.entity.ExamDate;
+
+import org.springframework.stereotype.Repository;
+
+/**
+ * 考试日期设置 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-27
+ */
+@Repository
+public interface DateMapper extends BaseMapper {
+
+
+ /**
+ * 查询距离当天最早的一次考试
+ * @return
+ */
+ ExamDate selectEarliestOne();
+}
diff --git a/example/src/main/java/com/example/examDate/param/DatePageParam.java b/example/src/main/java/com/example/examDate/param/DatePageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..e88c1cf42b4734e72650174ae2344f8c5353a376
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/param/DatePageParam.java
@@ -0,0 +1,23 @@
+package com.example.examDate.param;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+/**
+ *
+ * 考试日期设置 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-27
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "考试日期设置分页参数")
+public class DatePageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+}
diff --git a/example/src/main/java/com/example/examDate/service/DateService.java b/example/src/main/java/com/example/examDate/service/DateService.java
new file mode 100644
index 0000000000000000000000000000000000000000..00052f49cf8f22afcccee941a3049d6692431ed2
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/service/DateService.java
@@ -0,0 +1,58 @@
+package com.example.examDate.service;
+
+import com.example.examDate.entity.ExamDate;
+import com.example.examDate.param.DatePageParam;
+import com.example.examDate.vo.ExamDateGoodVo;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+import java.math.BigDecimal;
+
+/**
+ * 考试日期设置 服务类
+ *
+ * @author limg
+ * @since 2021-02-27
+ */
+public interface DateService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param date
+ * @return
+ * @throws Exception
+ */
+ boolean saveDate(ExamDate date) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param date
+ * @return
+ * @throws Exception
+ */
+ boolean updateDate(ExamDate date) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deleteDate(Long id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param datePageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getDatePageList(DatePageParam datePageParam) throws Exception;
+
+ ExamDateGoodVo calcOrderAmount() throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/examDate/service/impl/DateServiceImpl.java b/example/src/main/java/com/example/examDate/service/impl/DateServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..d11033719155edb1bb055f05a7a79ce7eec48c75
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/service/impl/DateServiceImpl.java
@@ -0,0 +1,91 @@
+package com.example.examDate.service.impl;
+
+import cn.hutool.core.convert.Convert;
+import com.example.examDate.entity.ExamDate;
+import com.example.examDate.mapper.DateMapper;
+import com.example.examDate.service.DateService;
+import com.example.examDate.param.DatePageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.examDate.vo.ExamDateGoodVo;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.Period;
+
+/**
+ * 考试日期设置 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-27
+ */
+@Slf4j
+@Service
+public class DateServiceImpl extends BaseServiceImpl implements DateService {
+
+ @Autowired
+ private DateMapper dateMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveDate(ExamDate date) throws Exception {
+ return super.save(date);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateDate(ExamDate date) throws Exception {
+ return super.updateById(date);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteDate(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Paging getDatePageList(DatePageParam datePageParam) throws Exception {
+ Page page = new PageInfo<>(datePageParam, OrderItem.desc(getLambdaColumn(ExamDate::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = dateMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+
+ @Override
+ public ExamDateGoodVo calcOrderAmount() throws Exception {
+ BigDecimal total = new BigDecimal(90); // 90天会员
+ ExamDate examDate = dateMapper.selectEarliestOne();
+
+ // 如果没有查询到考试日期,则按照最低金额9.9元计算
+ if (examDate == null) {
+ ExamDateGoodVo examDateGoodVo = new ExamDateGoodVo();
+ examDateGoodVo.setExamDate(null);
+ examDateGoodVo.setAmount(new BigDecimal(9.9));
+ examDateGoodVo.setPrice(new BigDecimal(0.11));
+ return examDateGoodVo;
+ }
+ ExamDateGoodVo examDateGoodVo = Convert.convert(ExamDateGoodVo.class, examDate);
+ // 计算考试日期距离当天的天数差
+ long days = examDate.getExamDate().toEpochDay() - LocalDate.now().toEpochDay();
+ // 最少需要支付9.9
+ double minDays = Math.max(75 - days, 9.9);
+ BigDecimal amount = new BigDecimal(minDays);
+ examDateGoodVo.setAmount(amount);
+ examDateGoodVo.setPrice(amount.divide(total,2, BigDecimal.ROUND_HALF_UP));
+// 取消价格计算,统一按照9.9元收费2021-6-5
+// examDateGoodVo.setAmount(new BigDecimal(9.9));
+// examDateGoodVo.setPrice(new BigDecimal(0.11));
+ return examDateGoodVo;
+ }
+
+}
diff --git a/example/src/main/java/com/example/examDate/vo/ExamDateGoodVo.java b/example/src/main/java/com/example/examDate/vo/ExamDateGoodVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..b302fc4b34d800dfd555a998b3b991883bd2363a
--- /dev/null
+++ b/example/src/main/java/com/example/examDate/vo/ExamDateGoodVo.java
@@ -0,0 +1,32 @@
+package com.example.examDate.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "ExamDateGoodVo对象", description = "小程序获取考试信息对象")
+public class ExamDateGoodVo implements Serializable {
+ private static final long serialVersionUID = 8101678988453788458L;
+
+ @ApiModelProperty("编号")
+ private Integer id;
+
+ @ApiModelProperty("考试时间")
+ private LocalDate examDate;
+
+ @ApiModelProperty("总金额")
+ private BigDecimal amount;
+
+ @ApiModelProperty("平均每日价格")
+ private BigDecimal price;
+
+ @ApiModelProperty("备注")
+ private String remark;
+}
diff --git a/example/src/main/java/com/example/favorite/controller/FavorController.java b/example/src/main/java/com/example/favorite/controller/FavorController.java
new file mode 100644
index 0000000000000000000000000000000000000000..f2437878463c891a54c088698d4c37ac17742381
--- /dev/null
+++ b/example/src/main/java/com/example/favorite/controller/FavorController.java
@@ -0,0 +1,129 @@
+package com.example.favorite.controller;
+
+import com.example.favorite.entity.Favor;
+import com.example.favorite.service.FavorService;
+import com.example.history.entity.History;
+import com.example.notes.vo.WrongVo;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.util.LoginUtil;
+import lombok.extern.slf4j.Slf4j;
+import com.example.favorite.param.FavorPageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.common.param.IdParam;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 收藏记录 控制器
+ *
+ * @author limg
+ * @since 2021-02-12
+ */
+@Slf4j
+@RestController
+@RequestMapping("/favor")
+@Module("favorite")
+@Api(value = "收藏记录API", tags = {"收藏记录"})
+public class FavorController extends BaseController {
+
+ @Autowired
+ private FavorService favorService;
+
+ /**
+ * 添加收藏记录
+ */
+ @PostMapping("/add")
+ @OperationLog(name = "添加收藏记录", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加收藏记录", response = ApiResult.class)
+ @CacheEvict(cacheNames = {"favorite", "question"}, allEntries = true)
+ public ApiResult addFavor(@Validated(Add.class) @RequestBody Favor favor) throws Exception {
+ boolean flag = favorService.saveFavor(favor);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改收藏记录
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改收藏记录", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改收藏记录", response = ApiResult.class)
+ public ApiResult updateFavor(@Validated(Update.class) @RequestBody Favor favor) throws Exception {
+ boolean flag = favorService.updateFavor(favor);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除收藏记录
+ */
+ @PostMapping("/delete/{questionId}")
+ @OperationLog(name = "删除收藏记录", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除收藏记录", response = ApiResult.class)
+ @CacheEvict(cacheNames = {"favorite", "question"}, allEntries = true)
+ public ApiResult deleteFavor(@PathVariable String questionId) throws Exception {
+ boolean flag = favorService.deleteFavor(questionId);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除收藏记录
+ */
+ @PostMapping("/remove/{id}")
+ @OperationLog(name = "根据id删除收藏记录", type = OperationLogType.DELETE)
+ @ApiOperation(value = "根据id删除收藏记录", response = ApiResult.class)
+ @CacheEvict(cacheNames = {"favorite", "question"}, allEntries = true)
+ public ApiResult removeFavor(@PathVariable String id) throws Exception {
+ boolean flag = favorService.removeById(id);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取收藏记录详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "收藏记录详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "收藏记录详情", response = Favor.class)
+ public ApiResult getFavor(@PathVariable Long id) throws Exception {
+ Favor favor = favorService.getById(id);
+ return ApiResult.ok(favor);
+ }
+
+ /**
+ * 收藏试题汇总列表
+ */
+ @GetMapping("/getFavoList")
+ @OperationLog(name = "收藏试题汇总列表", type = OperationLogType.LIST)
+ @ApiOperation(value = "收藏试题汇总列表", response = History.class)
+ public ApiResult> getFavoList() throws Exception {
+ List list = favorService.getFavoList();
+ return ApiResult.ok(list);
+ }
+
+ /**
+ * 收藏列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "收藏列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "收藏列表", response = QuestionPageVo.class)
+ @Cacheable(value = "favorite", key = "#p0.toString()")
+ public ApiResult> getFavoQuestionList(@Validated @RequestBody QuestionPageParam questionPageParam) throws Exception {
+ Paging paging = favorService.getQuestionPageList(questionPageParam);
+ return ApiResult.ok(paging);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/favorite/entity/Favor.java b/example/src/main/java/com/example/favorite/entity/Favor.java
new file mode 100644
index 0000000000000000000000000000000000000000..85695264551527807511d81303b5cc752a8510d1
--- /dev/null
+++ b/example/src/main/java/com/example/favorite/entity/Favor.java
@@ -0,0 +1,70 @@
+package com.example.favorite.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+
+/**
+ * 收藏记录
+ *
+ * @author limg
+ * @since 2021-02-12
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_favor")
+@ApiModel(value = "Favor对象")
+public class Favor extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("用户编号")
+ @TableField("USER_ID")
+ private Integer userId;
+
+ @ApiModelProperty("章节编号")
+ @TableField("CHAPTER_ID")
+ private Integer chapterId;
+
+ @ApiModelProperty("试题编号")
+ @TableField("QUESTION_ID")
+ @NotNull(message = "试题编号不能为空", groups = {Add.class, Update.class})
+ private Integer questionId;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/favorite/mapper/FavorMapper.java b/example/src/main/java/com/example/favorite/mapper/FavorMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..399bc62ecbb621c6d56da209c2012a882d612838
--- /dev/null
+++ b/example/src/main/java/com/example/favorite/mapper/FavorMapper.java
@@ -0,0 +1,31 @@
+package com.example.favorite.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.favorite.entity.Favor;
+import com.example.favorite.param.FavorPageParam;
+
+import com.example.notes.vo.WrongVo;
+import com.example.question.vo.QuestionPageVo;
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 收藏记录 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-12
+ */
+@Repository
+public interface FavorMapper extends BaseMapper {
+
+
+ List selectFavoriteList(String appUserId);
+
+ IPage getQuestionPageList(Page page, @Param("appUserId") String appUserId, @Param("chapterId") String chapterId);
+}
diff --git a/example/src/main/java/com/example/favorite/param/FavorPageParam.java b/example/src/main/java/com/example/favorite/param/FavorPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..ecc400d61bfc1a89c649aadd8210a191e176cfef
--- /dev/null
+++ b/example/src/main/java/com/example/favorite/param/FavorPageParam.java
@@ -0,0 +1,27 @@
+package com.example.favorite.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+/**
+ *
+ * 收藏记录 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-12
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "收藏记录分页参数")
+public class FavorPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("章节编号")
+ private Integer chapterId;
+}
diff --git a/example/src/main/java/com/example/favorite/service/FavorService.java b/example/src/main/java/com/example/favorite/service/FavorService.java
new file mode 100644
index 0000000000000000000000000000000000000000..d99df0b6b82ca84b4a35050d4a80d71f251e9424
--- /dev/null
+++ b/example/src/main/java/com/example/favorite/service/FavorService.java
@@ -0,0 +1,68 @@
+package com.example.favorite.service;
+
+import com.example.favorite.entity.Favor;
+import com.example.favorite.param.FavorPageParam;
+import com.example.notes.vo.WrongVo;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+import java.util.List;
+
+/**
+ * 收藏记录 服务类
+ *
+ * @author limg
+ * @since 2021-02-12
+ */
+public interface FavorService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param favor
+ * @return
+ * @throws Exception
+ */
+ boolean saveFavor(Favor favor) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param favor
+ * @return
+ * @throws Exception
+ */
+ boolean updateFavor(Favor favor) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param questionId
+ * @return
+ * @throws Exception
+ */
+ boolean deleteFavor(String questionId) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param favorPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getFavorPageList(FavorPageParam favorPageParam) throws Exception;
+
+ List getFavoList() throws Exception;
+
+ /**
+ * 获取分页对象
+ *
+ * @param questionPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getQuestionPageList(QuestionPageParam questionPageParam) throws Exception;
+}
diff --git a/example/src/main/java/com/example/favorite/service/impl/FavorServiceImpl.java b/example/src/main/java/com/example/favorite/service/impl/FavorServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..5ab7a01c190760224568483468a88404893a7924
--- /dev/null
+++ b/example/src/main/java/com/example/favorite/service/impl/FavorServiceImpl.java
@@ -0,0 +1,115 @@
+package com.example.favorite.service.impl;
+
+import cn.hutool.core.convert.Convert;
+import com.example.favorite.entity.Favor;
+import com.example.favorite.mapper.FavorMapper;
+import com.example.favorite.service.FavorService;
+import com.example.favorite.param.FavorPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.notes.vo.WrongVo;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.geekidea.boot.framework.util.LoginUtil;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 收藏记录 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-12
+ */
+@Slf4j
+@Service
+public class FavorServiceImpl extends BaseServiceImpl implements FavorService {
+
+ @Autowired
+ private FavorMapper favorMapper;
+
+ @Lazy
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveFavor(Favor favor) throws Exception {
+ String appUserId = LoginUtil.getAppUserId();
+ String key = String.format("favoriteList-%s", appUserId);
+ int count = favorMapper.selectCount(new LambdaQueryWrapper()
+ .eq(Favor::getUserId, appUserId)
+ .eq(Favor::getQuestionId, favor.getQuestionId()));
+ if (count > 0) {
+ return true;
+ }
+
+ favor.setUserId(Convert.toInt(appUserId));
+ // 清空缓存
+ redisTemplate.delete(key);
+ return super.save(favor);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateFavor(Favor favor) throws Exception {
+ favor.setUserId(Convert.toInt(LoginUtil.getAppUserId()));
+ return super.updateById(favor);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteFavor(String questionId) throws Exception {
+ String appUserId = LoginUtil.getAppUserId();
+ String key = String.format("favoriteList-%s", appUserId);
+ // 清空缓存
+ redisTemplate.delete(key);
+ return super.remove(new LambdaQueryWrapper()
+ .eq(Favor::getUserId, appUserId)
+ .eq(Favor::getQuestionId, questionId)
+ );
+ }
+
+ @Override
+ public Paging getFavorPageList(FavorPageParam favorPageParam) throws Exception {
+ Page page = new PageInfo<>(favorPageParam, OrderItem.desc(getLambdaColumn(Favor::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = favorMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+
+ @Override
+ public List getFavoList() throws Exception {
+ String appUserId = LoginUtil.getAppUserId();
+ String key = String.format("favoriteList-%s", appUserId);
+ List redisList = (List) redisTemplate.opsForValue().get(key);
+ if (redisList != null) {
+ return redisList;
+ }
+ List list = favorMapper.selectFavoriteList(appUserId);
+ redisTemplate.opsForValue().set(key, list, 3, TimeUnit.DAYS);
+
+ return list;
+ }
+
+ @Override
+ public Paging getQuestionPageList(QuestionPageParam questionPageParam) throws Exception {
+ Page page = new PageInfo<>(questionPageParam, OrderItem.asc(getLambdaColumn(Favor::getId)));
+ IPage iPage = favorMapper.getQuestionPageList(page, LoginUtil.getAppUserId(), questionPageParam.getChapterId());
+ return new Paging<>(iPage);
+ }
+
+}
diff --git a/example/src/main/java/com/example/foobar/controller/FooBarController.java b/example/src/main/java/com/example/foobar/controller/FooBarController.java
index a5e98a8c90c157bc90387fe30c52e41fbc5fbe44..a63db027b982520e416b41829cf8fc7acc807aaa 100644
--- a/example/src/main/java/com/example/foobar/controller/FooBarController.java
+++ b/example/src/main/java/com/example/foobar/controller/FooBarController.java
@@ -16,24 +16,28 @@
package com.example.foobar.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.foobar.entity.FooBar;
import com.example.foobar.param.FooBarPageParam;
import com.example.foobar.service.FooBarService;
-import io.geekidea.springbootplus.framework.common.api.ApiResult;
-import io.geekidea.springbootplus.framework.common.controller.BaseController;
-import io.geekidea.springbootplus.framework.core.pagination.Paging;
-import io.geekidea.springbootplus.framework.core.validator.groups.Add;
-import io.geekidea.springbootplus.framework.core.validator.groups.Update;
-import io.geekidea.springbootplus.framework.log.annotation.Module;
-import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
-import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
/**
* FooBar 控制器
*
diff --git a/example/src/main/java/com/example/foobar/entity/FooBar.java b/example/src/main/java/com/example/foobar/entity/FooBar.java
index 42df4c6502a441a17ea66bdfa6223533dccffc75..db4fcaac4d3ac54e059c962c8572696eabc0e7c3 100644
--- a/example/src/main/java/com/example/foobar/entity/FooBar.java
+++ b/example/src/main/java/com/example/foobar/entity/FooBar.java
@@ -19,8 +19,8 @@ package com.example.foobar.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
-import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
-import io.geekidea.springbootplus.framework.core.validator.groups.Update;
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.geekidea.boot.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
diff --git a/example/src/main/java/com/example/foobar/mapper/FooBarMapper.java b/example/src/main/java/com/example/foobar/mapper/FooBarMapper.java
index 9e26e2cc2bd1861e720cef94f02b0cea9885f18a..9c9fb0e823ef2dc14419597ddeb32e682e65fc4e 100644
--- a/example/src/main/java/com/example/foobar/mapper/FooBarMapper.java
+++ b/example/src/main/java/com/example/foobar/mapper/FooBarMapper.java
@@ -18,6 +18,7 @@ package com.example.foobar.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.foobar.entity.FooBar;
+import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
/**
@@ -29,5 +30,4 @@ import org.springframework.stereotype.Repository;
@Repository
public interface FooBarMapper extends BaseMapper {
-
}
diff --git a/example/src/main/java/com/example/foobar/param/FooBarPageParam.java b/example/src/main/java/com/example/foobar/param/FooBarPageParam.java
index 8baca6491c2417faacf960339641f1547f802f67..1d30469280e4cd1b9f00db03f33778c385c72976 100644
--- a/example/src/main/java/com/example/foobar/param/FooBarPageParam.java
+++ b/example/src/main/java/com/example/foobar/param/FooBarPageParam.java
@@ -16,7 +16,7 @@
package com.example.foobar.param;
-import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
diff --git a/example/src/main/java/com/example/foobar/service/FooBarService.java b/example/src/main/java/com/example/foobar/service/FooBarService.java
index 1f9d085751b8a8d1b0a20030937024adc6d2aa13..2347ecb2a572a02fd41c7803e31d2d4e925839db 100644
--- a/example/src/main/java/com/example/foobar/service/FooBarService.java
+++ b/example/src/main/java/com/example/foobar/service/FooBarService.java
@@ -18,8 +18,8 @@ package com.example.foobar.service;
import com.example.foobar.entity.FooBar;
import com.example.foobar.param.FooBarPageParam;
-import io.geekidea.springbootplus.framework.common.service.BaseService;
-import io.geekidea.springbootplus.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
/**
* FooBar 服务类
diff --git a/example/src/main/java/com/example/foobar/service/impl/FooBarServiceImpl.java b/example/src/main/java/com/example/foobar/service/impl/FooBarServiceImpl.java
index 5488a1225c942a3e99eec8f6a62395287276078e..2057c3b8b84e2328c3aa8d2307c56748f1faf874 100644
--- a/example/src/main/java/com/example/foobar/service/impl/FooBarServiceImpl.java
+++ b/example/src/main/java/com/example/foobar/service/impl/FooBarServiceImpl.java
@@ -24,10 +24,10 @@ import com.example.foobar.entity.FooBar;
import com.example.foobar.mapper.FooBarMapper;
import com.example.foobar.param.FooBarPageParam;
import com.example.foobar.service.FooBarService;
-import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
-import io.geekidea.springbootplus.framework.core.pagination.OrderMapping;
-import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
-import io.geekidea.springbootplus.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.OrderMapping;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import io.geekidea.boot.framework.core.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
diff --git a/example/src/main/java/com/example/group/controller/GroupController.java b/example/src/main/java/com/example/group/controller/GroupController.java
new file mode 100644
index 0000000000000000000000000000000000000000..c5c43cb8e12c03f35cc3ee4208ee716a9451460e
--- /dev/null
+++ b/example/src/main/java/com/example/group/controller/GroupController.java
@@ -0,0 +1,106 @@
+package com.example.group.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.group.entity.Group;
+import com.example.group.service.GroupService;
+import lombok.extern.slf4j.Slf4j;
+import com.example.group.param.GroupPageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.common.param.IdParam;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 微信群 控制器
+ *
+ * @author limg
+ * @since 2021-03-14
+ */
+@Slf4j
+@RestController
+@RequestMapping("/group")
+@Module("group")
+@Api(value = "微信群API", tags = {"微信群"})
+public class GroupController extends BaseController {
+
+ @Autowired
+ private GroupService groupService;
+
+ /**
+ * 添加微信群
+ */
+ @PostMapping("/add")
+ @OperationLog(name = "添加微信群", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加微信群", response = ApiResult.class)
+ public ApiResult addGroup(@Validated(Add.class) @RequestBody Group group) throws Exception {
+ boolean flag = groupService.saveGroup(group);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改微信群
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改微信群", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改微信群", response = ApiResult.class)
+ public ApiResult updateGroup(@Validated(Update.class) @RequestBody Group group) throws Exception {
+ boolean flag = groupService.updateGroup(group);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除微信群
+ */
+ @PostMapping("/delete/{id}")
+ @OperationLog(name = "删除微信群", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除微信群", response = ApiResult.class)
+ public ApiResult deleteGroup(@PathVariable("id") Long id) throws Exception {
+ boolean flag = groupService.deleteGroup(id);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取微信群详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "微信群详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "微信群详情", response = Group.class)
+ public ApiResult getGroup(@PathVariable("id") Long id) throws Exception {
+ Group group = groupService.getById(id);
+ return ApiResult.ok(group);
+ }
+
+ /**
+ * 获取当前正在答疑的群
+ */
+ @GetMapping("/wechat/getGroup")
+ @OperationLog(name = "获取微信群", type = OperationLogType.INFO)
+ @ApiOperation(value = "获取微信群", response = Group.class)
+ public ApiResult getCurrentGroup() throws Exception {
+ Group group = groupService.getOne(new LambdaQueryWrapper().eq(Group::getStatus, 1));
+ return ApiResult.ok(group);
+ }
+
+ /**
+ * 微信群分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "微信群分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "微信群分页列表", response = Group.class)
+ public ApiResult> getGroupPageList(@Validated @RequestBody GroupPageParam groupPageParam) throws Exception {
+ Paging paging = groupService.getGroupPageList(groupPageParam);
+ return ApiResult.ok(paging);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/group/entity/Group.java b/example/src/main/java/com/example/group/entity/Group.java
new file mode 100644
index 0000000000000000000000000000000000000000..77587d3f2bdd53211841f73ac8c24484c17fb316
--- /dev/null
+++ b/example/src/main/java/com/example/group/entity/Group.java
@@ -0,0 +1,68 @@
+package com.example.group.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+/**
+ * 微信群
+ *
+ * @author limg
+ * @since 2021-03-14
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_group")
+@ApiModel(value = "Group对象")
+public class Group extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("ID")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("群名称")
+ @TableField("NAME")
+ private String name;
+
+ @ApiModelProperty("群二维码")
+ @TableField("GROUP_QRCODE")
+ private String qrCode;
+
+ @ApiModelProperty("状态")
+ @TableField("STATUS")
+ private Integer status;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/group/mapper/GroupMapper.java b/example/src/main/java/com/example/group/mapper/GroupMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..b9fff4fd021964a64e5a805baac7416de73a8dce
--- /dev/null
+++ b/example/src/main/java/com/example/group/mapper/GroupMapper.java
@@ -0,0 +1,24 @@
+package com.example.group.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.group.entity.Group;
+import com.example.group.param.GroupPageParam;
+
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+
+/**
+ * 微信群 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-03-14
+ */
+@Repository
+public interface GroupMapper extends BaseMapper {
+
+
+}
diff --git a/example/src/main/java/com/example/group/param/GroupPageParam.java b/example/src/main/java/com/example/group/param/GroupPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..26a9bc8bd5c209bbf1db04bd51f125657421412b
--- /dev/null
+++ b/example/src/main/java/com/example/group/param/GroupPageParam.java
@@ -0,0 +1,23 @@
+package com.example.group.param;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+/**
+ *
+ * 微信群 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-03-14
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "微信群分页参数")
+public class GroupPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+}
diff --git a/example/src/main/java/com/example/group/service/GroupService.java b/example/src/main/java/com/example/group/service/GroupService.java
new file mode 100644
index 0000000000000000000000000000000000000000..50846e07fb8ec691c4705be23c35fbac66b33adf
--- /dev/null
+++ b/example/src/main/java/com/example/group/service/GroupService.java
@@ -0,0 +1,53 @@
+package com.example.group.service;
+
+import com.example.group.entity.Group;
+import com.example.group.param.GroupPageParam;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+/**
+ * 微信群 服务类
+ *
+ * @author limg
+ * @since 2021-03-14
+ */
+public interface GroupService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param group
+ * @return
+ * @throws Exception
+ */
+ boolean saveGroup(Group group) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param group
+ * @return
+ * @throws Exception
+ */
+ boolean updateGroup(Group group) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deleteGroup(Long id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param groupQueryParam
+ * @return
+ * @throws Exception
+ */
+ Paging getGroupPageList(GroupPageParam groupPageParam) throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/group/service/impl/GroupServiceImpl.java b/example/src/main/java/com/example/group/service/impl/GroupServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3c2f2069af537ed799da38afec947b903747617
--- /dev/null
+++ b/example/src/main/java/com/example/group/service/impl/GroupServiceImpl.java
@@ -0,0 +1,58 @@
+package com.example.group.service.impl;
+
+import com.example.group.entity.Group;
+import com.example.group.mapper.GroupMapper;
+import com.example.group.service.GroupService;
+import com.example.group.param.GroupPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 微信群 服务实现类
+ *
+ * @author limg
+ * @since 2021-03-14
+ */
+@Slf4j
+@Service
+public class GroupServiceImpl extends BaseServiceImpl implements GroupService {
+
+ @Autowired
+ private GroupMapper groupMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveGroup(Group group) throws Exception {
+ return super.save(group);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateGroup(Group group) throws Exception {
+ return super.updateById(group);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteGroup(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Paging getGroupPageList(GroupPageParam groupPageParam) throws Exception {
+ Page page = new PageInfo<>(groupPageParam, OrderItem.desc(getLambdaColumn(Group::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = groupMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+
+}
diff --git a/example/src/main/java/com/example/history/controller/HistoryController.java b/example/src/main/java/com/example/history/controller/HistoryController.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee0a1bff2011efad12005607c3cc8432f5f7c0ee
--- /dev/null
+++ b/example/src/main/java/com/example/history/controller/HistoryController.java
@@ -0,0 +1,70 @@
+package com.example.history.controller;
+
+import com.example.history.entity.History;
+import com.example.history.service.HistoryService;
+import lombok.extern.slf4j.Slf4j;
+import com.example.history.param.HistoryPageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 做题记录 控制器
+ *
+ * @author limg
+ * @since 2021-02-15
+ */
+@Slf4j
+@RestController
+@RequestMapping("/history")
+@Module("history")
+@Api(value = "做题记录API", tags = {"做题记录"})
+public class HistoryController extends BaseController {
+
+ @Autowired
+ private HistoryService historyService;
+
+ /**
+ * 添加做题记录
+ */
+ @PostMapping("/add")
+ @OperationLog(name = "添加做题记录", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加做题记录", response = ApiResult.class)
+ public ApiResult addHistory(@Validated(Add.class) @RequestBody History history) throws Exception {
+ boolean flag = historyService.saveHistory(history);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取做题记录详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "做题记录详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "做题记录详情", response = History.class)
+ public ApiResult getHistory(@PathVariable("id") Long id) throws Exception {
+ History history = historyService.getById(id);
+ return ApiResult.ok(history);
+ }
+
+ /**
+ * 做题记录分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "做题记录分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "做题记录分页列表", response = History.class)
+ public ApiResult> getHistoryPageList(@Validated @RequestBody HistoryPageParam historyPageParam) throws Exception {
+ Paging paging = historyService.getHistoryPageList(historyPageParam);
+ return ApiResult.ok(paging);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/history/entity/History.java b/example/src/main/java/com/example/history/entity/History.java
new file mode 100644
index 0000000000000000000000000000000000000000..a1d49dd73555f50b654254a5b52d32813a747451
--- /dev/null
+++ b/example/src/main/java/com/example/history/entity/History.java
@@ -0,0 +1,76 @@
+package com.example.history.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+/**
+ * 做题记录
+ *
+ * @author limg
+ * @since 2021-02-15
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_history")
+@ApiModel(value = "History对象")
+public class History extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("用户编号")
+ @TableField("USER_ID")
+ private Integer userId;
+
+ @ApiModelProperty("章节编号")
+ @TableField("CHAPTER_ID")
+ private Integer chapterId;
+
+ @ApiModelProperty("试题编号")
+ @TableField("QUESTION_ID")
+ private Integer questionId;
+
+ @ApiModelProperty("用户选择")
+ @TableField("USER_ANSWER")
+ private String userAnswer;
+
+ @ApiModelProperty("是否正确 0-错误,1-正确")
+ @TableField("IS_RIGHT")
+ private String isRight;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField("CREATED_BY")
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField("UPDATED_BY")
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/history/mapper/HistoryMapper.java b/example/src/main/java/com/example/history/mapper/HistoryMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee3bc4fed54b9fa140db5c91d90a451c08c5a5e3
--- /dev/null
+++ b/example/src/main/java/com/example/history/mapper/HistoryMapper.java
@@ -0,0 +1,17 @@
+package com.example.history.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.history.entity.History;
+
+import org.springframework.stereotype.Repository;
+
+/**
+ * 做题记录 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-15
+ */
+@Repository
+public interface HistoryMapper extends BaseMapper {
+
+}
diff --git a/example/src/main/java/com/example/history/param/HistoryPageParam.java b/example/src/main/java/com/example/history/param/HistoryPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..e1a8062ff5d0a5fab57c7d1cc3332adff7ccc037
--- /dev/null
+++ b/example/src/main/java/com/example/history/param/HistoryPageParam.java
@@ -0,0 +1,23 @@
+package com.example.history.param;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+/**
+ *
+ * 做题记录 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-15
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "做题记录分页参数")
+public class HistoryPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+}
diff --git a/example/src/main/java/com/example/history/service/HistoryService.java b/example/src/main/java/com/example/history/service/HistoryService.java
new file mode 100644
index 0000000000000000000000000000000000000000..c878049384428d486d209308ea60f2811b9b0b22
--- /dev/null
+++ b/example/src/main/java/com/example/history/service/HistoryService.java
@@ -0,0 +1,34 @@
+package com.example.history.service;
+
+import com.example.history.entity.History;
+import com.example.history.param.HistoryPageParam;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+/**
+ * 做题记录 服务类
+ *
+ * @author limg
+ * @since 2021-02-15
+ */
+public interface HistoryService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param history
+ * @return
+ * @throws Exception
+ */
+ boolean saveHistory(History history) throws Exception;
+
+ /**
+ * 获取分页对象
+ *
+ * @param historyPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getHistoryPageList(HistoryPageParam historyPageParam) throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/history/service/impl/HistoryServiceImpl.java b/example/src/main/java/com/example/history/service/impl/HistoryServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..b28077cfa3acdf33c28ccc0ec62784187c1400df
--- /dev/null
+++ b/example/src/main/java/com/example/history/service/impl/HistoryServiceImpl.java
@@ -0,0 +1,46 @@
+package com.example.history.service.impl;
+
+import com.example.history.entity.History;
+import com.example.history.mapper.HistoryMapper;
+import com.example.history.service.HistoryService;
+import com.example.history.param.HistoryPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 做题记录 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-15
+ */
+@Slf4j
+@Service
+public class HistoryServiceImpl extends BaseServiceImpl implements HistoryService {
+
+ @Autowired
+ private HistoryMapper historyMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveHistory(History history) throws Exception {
+ return super.save(history);
+ }
+
+ @Override
+ public Paging getHistoryPageList(HistoryPageParam historyPageParam) throws Exception {
+ Page page = new PageInfo<>(historyPageParam, OrderItem.desc(getLambdaColumn(History::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = historyMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+
+}
diff --git a/example/src/main/java/com/example/interceptor/UpdateUserInterceptor.java b/example/src/main/java/com/example/interceptor/UpdateUserInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..54aed4e3fa212ce3ccc6f574f18d0f563c1df269
--- /dev/null
+++ b/example/src/main/java/com/example/interceptor/UpdateUserInterceptor.java
@@ -0,0 +1,44 @@
+package com.example.interceptor;
+
+import com.example.category.entity.Category;
+import io.geekidea.boot.framework.util.LoginUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.executor.Executor;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlCommandType;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Signature;
+
+import java.lang.reflect.Field;
+
+@Slf4j
+@Intercepts({@Signature(
+ type = Executor.class,
+ method = "update",
+ args = {MappedStatement.class, Object.class})})
+public class UpdateUserInterceptor implements Interceptor {
+ @Override
+ public Object intercept(Invocation invocation) throws Throwable {
+
+ MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
+ SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
+ Object parameter = invocation.getArgs()[1];
+ if (parameter instanceof Category) {
+ log.info("更新人");
+ }
+ Field[] declaredFields = parameter.getClass().getDeclaredFields();
+ for (Field field : declaredFields) {
+ log.info(field.getName());
+ if ("updatedBy".equals(field.getName())) {
+ if (SqlCommandType.INSERT.equals(sqlCommandType) || SqlCommandType.UPDATE.equals(sqlCommandType)) {
+ field.setAccessible(true);
+ field.set(parameter, LoginUtil.getUserId());
+ }
+ }
+ }
+
+ return invocation.proceed();
+ }
+}
diff --git a/example/src/main/java/com/example/notes/controller/NotesController.java b/example/src/main/java/com/example/notes/controller/NotesController.java
new file mode 100644
index 0000000000000000000000000000000000000000..2b7f6a1b0a2c941bf9ec4e1a56300ee069705369
--- /dev/null
+++ b/example/src/main/java/com/example/notes/controller/NotesController.java
@@ -0,0 +1,140 @@
+package com.example.notes.controller;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.notes.entity.Notes;
+import com.example.notes.service.NotesService;
+import com.example.notes.vo.WrongVo;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.util.LoginUtil;
+import lombok.extern.slf4j.Slf4j;
+import com.example.notes.param.NotesPageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 错题记录 控制器
+ *
+ * @author limg
+ * @since 2021-02-16
+ */
+@Slf4j
+@RestController
+@RequestMapping("/notes")
+@Module("notes")
+@Api(value = "错题记录API", tags = {"错题记录"})
+public class NotesController extends BaseController {
+
+ @Autowired
+ private NotesService notesService;
+
+ @Lazy
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ /**
+ * 添加错题记录
+ */
+ @PostMapping("/add")
+ @OperationLog(name = "添加错题记录", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加错题记录", response = ApiResult.class)
+ public ApiResult addNotes(@Validated(Add.class) @RequestBody Notes notes) throws Exception {
+ boolean flag = notesService.saveNotes(notes);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改错题记录
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改错题记录", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改错题记录", response = ApiResult.class)
+ public ApiResult updateNotes(@Validated(Update.class) @RequestBody Notes notes) throws Exception {
+ boolean flag = notesService.updateNotes(notes);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除错题记录
+ */
+ @PostMapping("/delete")
+ @OperationLog(name = "删除错题记录", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除错题记录", response = ApiResult.class)
+ public ApiResult deleteNotes(@RequestParam("id") String id) throws Exception {
+ boolean flag = false;
+ String appUserId = LoginUtil.getAppUserId();
+ String key1 = String.format("wrongPaperList-%s-1", appUserId);
+ String key2 = String.format("wrongPaperList-%s-2", appUserId);
+
+ if (StrUtil.isNotBlank(id)) {
+ flag = notesService.remove(new LambdaQueryWrapper().eq(Notes::getUserId, appUserId).eq(Notes::getQuestionId, id));
+ } else {
+ flag = notesService.remove(new LambdaQueryWrapper().eq(Notes::getUserId, appUserId));
+ }
+ redisTemplate.delete(key1);
+ redisTemplate.delete(key2);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取错题记录详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "错题记录详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "错题记录详情", response = Notes.class)
+ public ApiResult getNotes(@PathVariable("id") Long id) throws Exception {
+ Notes notes = notesService.getById(id);
+ return ApiResult.ok(notes);
+ }
+
+ /**
+ * 错题记录分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "错题记录分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "错题记录分页列表", response = Notes.class)
+ public ApiResult> getNotesPageList(@Validated @RequestBody NotesPageParam notesPageParam) throws Exception {
+ Paging paging = notesService.getNotesPageList(notesPageParam);
+ return ApiResult.ok(paging);
+ }
+
+ /**
+ * 错题试卷列表
+ */
+ @GetMapping("/getWrongList")
+ @OperationLog(name = "错题试卷列表", type = OperationLogType.LIST)
+ @ApiOperation(value = "错题试卷列表", response = WrongVo.class)
+ public ApiResult> getWrongList(@RequestParam(value = "type", required = false) String type) throws Exception {
+ List list = notesService.getHistoryWrongList(type);
+ return ApiResult.ok(list);
+ }
+
+ /**
+ * 错题列表
+ */
+ @PostMapping("/getWrongQuestionList")
+ @OperationLog(name = "错题列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "错题列表", response = QuestionPageVo.class)
+ public ApiResult> getWrongQuestionList(@Validated @RequestBody QuestionPageParam questionPageParam) throws Exception {
+ List list = notesService.getQuestionPageList(questionPageParam);
+ return ApiResult.ok(list);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/notes/entity/Notes.java b/example/src/main/java/com/example/notes/entity/Notes.java
new file mode 100644
index 0000000000000000000000000000000000000000..f96680192957358e07a84d2ce99fd8f3466486e7
--- /dev/null
+++ b/example/src/main/java/com/example/notes/entity/Notes.java
@@ -0,0 +1,72 @@
+package com.example.notes.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+/**
+ * 错题记录
+ *
+ * @author limg
+ * @since 2021-02-16
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_notes")
+@ApiModel(value = "Notes对象")
+public class Notes extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("用户编号")
+ @TableField("USER_ID")
+ private Integer userId;
+
+ @ApiModelProperty("章节编号")
+ @TableField("CHAPTER_ID")
+ private Integer chapterId;
+
+ @ApiModelProperty("试题编号")
+ @TableField("QUESTION_ID")
+ private Integer questionId;
+
+ @ApiModelProperty("用户选择")
+ @TableField("USER_ANSWER")
+ private String userAnswer;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField("CREATED_BY")
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField("UPDATED_BY")
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/notes/mapper/NotesMapper.java b/example/src/main/java/com/example/notes/mapper/NotesMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..d50c09653041b3610c859471a897833044ac3ee9
--- /dev/null
+++ b/example/src/main/java/com/example/notes/mapper/NotesMapper.java
@@ -0,0 +1,31 @@
+package com.example.notes.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.example.notes.entity.Notes;
+
+import com.example.notes.vo.WrongVo;
+import com.example.question.vo.QuestionPageVo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * 错题记录 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-16
+ */
+@Repository
+public interface NotesMapper extends BaseMapper {
+
+ // 根据试卷汇总错题集
+ List selectWrongPaperList(String appUserId);
+
+ // 根据章节汇总错题集
+ List selectWrongChapterList(String appUserId);
+
+ List selectWrongQuestionPageList(@Param("appUserId") String appUserId, @Param("chapterId") String chapterId, @Param("paperId") String paperId);
+}
diff --git a/example/src/main/java/com/example/notes/param/NotesPageParam.java b/example/src/main/java/com/example/notes/param/NotesPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..30bd95d6785b90882476506e169e954740a03269
--- /dev/null
+++ b/example/src/main/java/com/example/notes/param/NotesPageParam.java
@@ -0,0 +1,23 @@
+package com.example.notes.param;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+/**
+ *
+ * 错题记录 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-16
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "错题记录分页参数")
+public class NotesPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+}
diff --git a/example/src/main/java/com/example/notes/service/NotesService.java b/example/src/main/java/com/example/notes/service/NotesService.java
new file mode 100644
index 0000000000000000000000000000000000000000..23fd3be3c7cfe2718d419f6adfa03b62578dcbe0
--- /dev/null
+++ b/example/src/main/java/com/example/notes/service/NotesService.java
@@ -0,0 +1,68 @@
+package com.example.notes.service;
+
+import com.example.notes.entity.Notes;
+import com.example.notes.param.NotesPageParam;
+import com.example.notes.vo.WrongVo;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+import java.util.List;
+
+/**
+ * 错题记录 服务类
+ *
+ * @author limg
+ * @since 2021-02-16
+ */
+public interface NotesService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param notes
+ * @return
+ * @throws Exception
+ */
+ boolean saveNotes(Notes notes) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param notes
+ * @return
+ * @throws Exception
+ */
+ boolean updateNotes(Notes notes) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deleteNotes(Long id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param notesPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getNotesPageList(NotesPageParam notesPageParam) throws Exception;
+
+ /**
+ * 获取错题列表
+ * @param questionPageParam
+ * @return
+ * @throws Exception
+ */
+ List getQuestionPageList(QuestionPageParam questionPageParam) throws Exception;
+
+ List getHistoryWrongList(String type) throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/notes/service/impl/NotesServiceImpl.java b/example/src/main/java/com/example/notes/service/impl/NotesServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..47ad760b2ccd4516b79b607b2c78cd2e6c92cfad
--- /dev/null
+++ b/example/src/main/java/com/example/notes/service/impl/NotesServiceImpl.java
@@ -0,0 +1,97 @@
+package com.example.notes.service.impl;
+
+import com.example.notes.entity.Notes;
+import com.example.notes.mapper.NotesMapper;
+import com.example.notes.service.NotesService;
+import com.example.notes.param.NotesPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.notes.vo.WrongVo;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.geekidea.boot.framework.util.LoginUtil;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 错题记录 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-16
+ */
+@Slf4j
+@Service
+public class NotesServiceImpl extends BaseServiceImpl implements NotesService {
+
+ @Autowired
+ private NotesMapper notesMapper;
+
+ @Lazy
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveNotes(Notes notes) throws Exception {
+ return super.save(notes);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateNotes(Notes notes) throws Exception {
+ return super.updateById(notes);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteNotes(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Paging getNotesPageList(NotesPageParam notesPageParam) throws Exception {
+ Page page = new PageInfo<>(notesPageParam, OrderItem.desc(getLambdaColumn(Notes::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ IPage iPage = notesMapper.selectPage(page, wrapper);
+ return new Paging(iPage);
+ }
+
+ @Override
+ public List getQuestionPageList(QuestionPageParam questionPageParam) throws Exception {
+ List list = notesMapper.selectWrongQuestionPageList(LoginUtil.getAppUserId(), questionPageParam.getChapterId(), questionPageParam.getPaperId());
+ return list;
+ }
+
+ @Override
+ public List getHistoryWrongList(String type) throws Exception {
+ String appUserId = LoginUtil.getAppUserId();
+ String key = String.format("wrongPaperList-%s-%s", appUserId, type);
+ List redisList = (List) redisTemplate.opsForValue().get(key);
+ if (redisList != null) {
+ return redisList;
+ }
+ List list;
+ // 按照章节分类
+ if ("2".equals(type)) {
+ list = notesMapper.selectWrongChapterList(appUserId);
+ } else {
+ list = notesMapper.selectWrongPaperList(appUserId);
+ }
+ redisTemplate.opsForValue().set(key, list, 3, TimeUnit.DAYS);
+
+ return list;
+ }
+
+}
diff --git a/example/src/main/java/com/example/notes/vo/WrongVo.java b/example/src/main/java/com/example/notes/vo/WrongVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..201fb64919f75011b198de1efd8fe95162d89c12
--- /dev/null
+++ b/example/src/main/java/com/example/notes/vo/WrongVo.java
@@ -0,0 +1,24 @@
+package com.example.notes.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "做错试卷列表对象", description = "小程序用户做错试题列表")
+public class WrongVo implements Serializable {
+ private static final long serialVersionUID = -5160036959137826314L;
+
+ @ApiModelProperty("章节编号")
+ private Integer id;
+
+ @ApiModelProperty("章节名称")
+ private String name;
+
+ @ApiModelProperty("错题数")
+ private Integer count;
+}
diff --git a/example/src/main/java/com/example/order/controller/ExampleOrderController.java b/example/src/main/java/com/example/order/controller/ExampleOrderController.java
deleted file mode 100644
index f5de7e02994f2df525aca9f5f38b4c8ee67d46b2..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/example/order/controller/ExampleOrderController.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.order.controller;
-
-import com.example.order.entity.ExampleOrder;
-import com.example.order.service.ExampleOrderService;
-import lombok.extern.slf4j.Slf4j;
-import com.example.order.param.ExampleOrderPageParam;
-import io.geekidea.springbootplus.framework.common.controller.BaseController;
-import io.geekidea.springbootplus.framework.common.api.ApiResult;
-import io.geekidea.springbootplus.framework.core.pagination.Paging;
-import io.geekidea.springbootplus.framework.common.param.IdParam;
-import io.geekidea.springbootplus.framework.log.annotation.Module;
-import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
-import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
-import io.geekidea.springbootplus.framework.core.validator.groups.Add;
-import io.geekidea.springbootplus.framework.core.validator.groups.Update;
-import org.springframework.validation.annotation.Validated;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * 订单示例 控制器
- *
- * @author geekidea
- * @since 2020-03-27
- */
-@Slf4j
-@RestController
-@RequestMapping("/exampleOrder")
-@Module("order")
-@Api(value = "ExampleOrderAPI", tags = {"ExampleOrder"})
-public class ExampleOrderController extends BaseController {
-
- @Autowired
- private ExampleOrderService exampleOrderService;
-
- /**
- * 添加订单示例
- */
- @PostMapping("/add")
- @OperationLog(name = "添加订单示例", type = OperationLogType.ADD)
- @ApiOperation(value = "添加订单示例", response = ApiResult.class)
- public ApiResult addExampleOrder(@Validated(Add.class) @RequestBody ExampleOrder exampleOrder) throws Exception {
- boolean flag = exampleOrderService.saveExampleOrder(exampleOrder);
- return ApiResult.result(flag);
- }
-
- /**
- * 修改订单示例
- */
- @PostMapping("/update")
- @OperationLog(name = "修改订单示例", type = OperationLogType.UPDATE)
- @ApiOperation(value = "修改订单示例", response = ApiResult.class)
- public ApiResult updateExampleOrder(@Validated(Update.class) @RequestBody ExampleOrder exampleOrder) throws Exception {
- boolean flag = exampleOrderService.updateExampleOrder(exampleOrder);
- return ApiResult.result(flag);
- }
-
- /**
- * 删除订单示例
- */
- @PostMapping("/delete/{id}")
- @OperationLog(name = "删除订单示例", type = OperationLogType.DELETE)
- @ApiOperation(value = "删除订单示例", response = ApiResult.class)
- public ApiResult deleteExampleOrder(@PathVariable("id") Long id) throws Exception {
- boolean flag = exampleOrderService.deleteExampleOrder(id);
- return ApiResult.result(flag);
- }
-
- /**
- * 获取订单示例详情
- */
- @GetMapping("/info/{id}")
- @OperationLog(name = "订单示例详情", type = OperationLogType.INFO)
- @ApiOperation(value = "订单示例详情", response = ExampleOrder.class)
- public ApiResult getExampleOrder(@PathVariable("id") Long id) throws Exception {
- ExampleOrder exampleOrder = exampleOrderService.getById(id);
- return ApiResult.ok(exampleOrder);
- }
-
- /**
- * 订单示例分页列表
- */
- @PostMapping("/getPageList")
- @OperationLog(name = "订单示例分页列表", type = OperationLogType.PAGE)
- @ApiOperation(value = "订单示例分页列表", response = ExampleOrder.class)
- public ApiResult> getExampleOrderPageList(@Validated @RequestBody ExampleOrderPageParam exampleOrderPageParam) throws Exception {
- Paging paging = exampleOrderService.getExampleOrderPageList(exampleOrderPageParam);
- return ApiResult.ok(paging);
- }
-
-}
-
diff --git a/example/src/main/java/com/example/order/controller/OrderController.java b/example/src/main/java/com/example/order/controller/OrderController.java
new file mode 100644
index 0000000000000000000000000000000000000000..bf2f8beb6a2b741630ae1a43ae8b919ab21b5770
--- /dev/null
+++ b/example/src/main/java/com/example/order/controller/OrderController.java
@@ -0,0 +1,144 @@
+package com.example.order.controller;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.RandomUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.category.entity.Category;
+import com.example.category.service.CategoryService;
+import com.example.order.entity.Order;
+import com.example.order.param.CategoryOrderParam;
+import com.example.order.service.OrderService;
+import com.example.order.vo.OrderPageVo;
+import com.example.order.vo.OrderVo;
+import io.geekidea.boot.framework.common.exception.BusinessException;
+import io.geekidea.boot.framework.util.LoginUtil;
+import lombok.extern.slf4j.Slf4j;
+import com.example.order.param.OrderPageParam;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.common.param.IdParam;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 订单表 控制器
+ *
+ * @author limg
+ * @since 2021-02-20
+ */
+@Slf4j
+@RestController
+@RequestMapping("/order")
+@Module("order")
+@Api(value = "订单表API", tags = {"订单表"})
+public class OrderController extends BaseController {
+
+ @Autowired
+ private OrderService orderService;
+
+ @Autowired
+ private CategoryService categoryService;
+
+ /**
+ * 添加订单表
+ */
+ @PostMapping("/add")
+ @OperationLog(name = "添加订单表", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加订单表", response = ApiResult.class)
+ public ApiResult addOrder(@Validated(Add.class) @RequestBody Order order) throws Exception {
+ boolean flag = orderService.saveOrder(order);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 提交专题订单
+ */
+ @PostMapping("/categoryOrder")
+ @OperationLog(name = "提交专题订单", type = OperationLogType.ADD)
+ @ApiOperation(value = "提交专题订单", response = ApiResult.class)
+ public ApiResult categoryOrder(@Validated @RequestBody CategoryOrderParam categoryOrderParam) throws Exception {
+ Category category = categoryService.getOne(new LambdaQueryWrapper().eq(Category::getCode, categoryOrderParam.getCode()));
+
+ if (category == null) {
+ throw new BusinessException("专题不存在");
+ }
+
+ String format = DateUtil.format(new Date(),"yyyyMMddHHmmss");
+ String numbers = RandomUtil.randomNumbers(5);
+ String orderId = format+numbers;
+
+ Order order = new Order();
+ order.setOrderId(orderId);
+ order.setOrderType("1");
+ order.setGroupId(category.getCode());
+ order.setAmount(category.getPrice());
+ order.setUserId(LoginUtil.getAppUserId());
+ order.setRemark(String.format("购买%s", category.getSubject()));
+
+ boolean flag = orderService.saveOrder(order);
+
+ if (!flag) {
+ throw new BusinessException("创建订单失败");
+ }
+
+ return ApiResult.ok(order);
+ }
+
+ /**
+ * 删除订单表
+ */
+ @PostMapping("/delete/{id}")
+ @OperationLog(name = "删除订单表", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除订单表", response = ApiResult.class)
+ public ApiResult deleteOrder(@PathVariable("id") Long id) throws Exception {
+ boolean flag = orderService.deleteOrder(id);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取订单表详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "订单表详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "订单表详情", response = Order.class)
+ public ApiResult getOrder(@PathVariable("id") Long id) throws Exception {
+ Order order = orderService.getById(id);
+ return ApiResult.ok(order);
+ }
+
+ /**
+ * 订单表分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "订单表分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "订单表分页列表", response = Order.class)
+ public ApiResult> getOrderPageList(@Validated @RequestBody OrderPageParam orderPageParam) throws Exception {
+ Paging paging = orderService.getOrderPageList(orderPageParam);
+ return ApiResult.ok(paging);
+ }
+
+ /**
+ * 订单表分页列表
+ */
+ @PostMapping("/getList")
+ @OperationLog(name = "用户订单列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "用户订单列表", response = Order.class)
+ public ApiResult> getWechatOrderPageList(@Validated @RequestBody OrderPageParam orderPageParam) throws Exception {
+ Paging paging = orderService.getOrderList(orderPageParam);
+ return ApiResult.ok(paging);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/order/entity/ExampleOrder.java b/example/src/main/java/com/example/order/entity/ExampleOrder.java
deleted file mode 100644
index e7a0290b69d1ad833f73a22ee98d750bd83956f3..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/example/order/entity/ExampleOrder.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.order.entity;
-
-import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
-import com.baomidou.mybatisplus.annotation.IdType;
-import java.util.Date;
-import com.baomidou.mybatisplus.annotation.Version;
-import com.baomidou.mybatisplus.annotation.TableId;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import io.geekidea.springbootplus.framework.core.validator.groups.Update;
-
-/**
- * 订单示例
- *
- * @author geekidea
- * @since 2020-03-27
- */
-@Data
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "ExampleOrder对象")
-public class ExampleOrder extends BaseEntity {
- private static final long serialVersionUID = 1L;
-
- @NotNull(message = "id不能为空", groups = {Update.class})
- @ApiModelProperty("主键")
- @TableId(value = "id", type = IdType.AUTO)
- private Long id;
-
- @NotBlank(message = "订单名称不能为空")
- @ApiModelProperty("订单名称")
- private String name;
-
- @ApiModelProperty("订单编号")
- private String orderNo;
-
- @ApiModelProperty("备注")
- private String remark;
-
- @ApiModelProperty("状态,0:禁用,1:启用")
- private Integer state;
-
- @ApiModelProperty("版本")
- @Version
- private Integer version;
-
- @ApiModelProperty("创建时间")
- private Date createTime;
-
- @ApiModelProperty("修改时间")
- private Date updateTime;
-
-}
diff --git a/example/src/main/java/com/example/order/entity/Order.java b/example/src/main/java/com/example/order/entity/Order.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ff856704dedccc1dffd8ce679f1b11171e3258a
--- /dev/null
+++ b/example/src/main/java/com/example/order/entity/Order.java
@@ -0,0 +1,98 @@
+package com.example.order.entity;
+
+import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+
+/**
+ * 订单表
+ *
+ * @author limg
+ * @since 2021-02-20
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_order")
+@ApiModel(value = "Order对象")
+public class Order extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("订单号")
+ @TableField("ORDER_ID")
+ private String orderId;
+
+ @ApiModelProperty("用户编号")
+ @TableField("USER_ID")
+ private String userId;
+
+ @ApiModelProperty("订单类型 1-购买试题,2-充值会员")
+ @TableField("ORDER_TYPE")
+ private String orderType;
+
+ @ApiModelProperty("金额")
+ @TableField("AMOUNT")
+ private BigDecimal amount;
+
+ @ApiModelProperty("试卷编号")
+ @TableField("PAPER_ID")
+ private Integer paperId;
+
+ @ApiModelProperty("专题编号")
+ @TableField("GROUP_ID")
+ private String groupId;
+
+ @ApiModelProperty("支付流水号")
+ @TableField("TRADE_NO")
+ private String tradeNo;
+
+ @ApiModelProperty("状态 1-新建,2-支付成功,3-已取消")
+ @TableField("STATUS")
+ private String status;
+
+ @ApiModelProperty("支付时间")
+ @TableField("PAY_TIME")
+ private Date payTime;
+
+ @ApiModelProperty("备注")
+ @TableField("REMARK")
+ private String remark;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField("CREATED_BY")
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/order/mapper/ExampleOrderMapper.java b/example/src/main/java/com/example/order/mapper/ExampleOrderMapper.java
deleted file mode 100644
index 3e677f412571e4359aabc34d3914dfae63af6370..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/example/order/mapper/ExampleOrderMapper.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.order.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.example.order.entity.ExampleOrder;
-import com.example.order.param.ExampleOrderPageParam;
-
-import org.springframework.stereotype.Repository;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.apache.ibatis.annotations.Param;
-import java.io.Serializable;
-
-/**
- * 订单示例 Mapper 接口
- *
- * @author geekidea
- * @since 2020-03-27
- */
-@Repository
-public interface ExampleOrderMapper extends BaseMapper {
-
-
-}
diff --git a/example/src/main/java/com/example/order/mapper/OrderMapper.java b/example/src/main/java/com/example/order/mapper/OrderMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..48b13fa64ef01ba9168720cf9b849f8e21bdc766
--- /dev/null
+++ b/example/src/main/java/com/example/order/mapper/OrderMapper.java
@@ -0,0 +1,30 @@
+package com.example.order.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.order.entity.Order;
+import com.example.order.param.OrderPageParam;
+
+import com.example.order.vo.OrderPageVo;
+import com.example.order.vo.OrderVo;
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+
+/**
+ * 订单表 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-20
+ */
+@Repository
+public interface OrderMapper extends BaseMapper {
+
+
+ IPage selectUserOrder(Page page, @Param("userId") String userId);
+
+ IPage selectOrderPage(Page page, @Param("param") OrderPageParam orderPageParam);
+}
diff --git a/example/src/main/java/com/example/order/param/CategoryOrderParam.java b/example/src/main/java/com/example/order/param/CategoryOrderParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..57ab1684ed633b22b45aca93939751bc122e24fd
--- /dev/null
+++ b/example/src/main/java/com/example/order/param/CategoryOrderParam.java
@@ -0,0 +1,20 @@
+package com.example.order.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "提交专题订单对象")
+public class CategoryOrderParam implements Serializable {
+ private static final long serialVersionUID = 6278016382933563028L;
+
+ @ApiModelProperty("专题编号")
+ @NotNull(message = "专题编号不能为空")
+ private String code;
+}
diff --git a/example/src/main/java/com/example/order/param/ExampleOrderPageParam.java b/example/src/main/java/com/example/order/param/ExampleOrderPageParam.java
deleted file mode 100644
index 6b25f18d5d704776fde64d8eedc58cdecbffb638..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/example/order/param/ExampleOrderPageParam.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.order.param;
-
-import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- *
- * 订单示例 分页参数对象
- *
- *
- * @author geekidea
- * @date 2020-03-27
- */
-@Data
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "订单示例分页参数")
-public class ExampleOrderPageParam extends BasePageOrderParam {
- private static final long serialVersionUID = 6092080418269664419L;
-
- @ApiModelProperty("订单名称")
- private String name;
-
- @ApiModelProperty("订单编号")
- private String orderNo;
-
-}
diff --git a/example/src/main/java/com/example/order/param/OrderPageParam.java b/example/src/main/java/com/example/order/param/OrderPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..5ef20e18bbcc54c9169699d3c222c7c0faaa7edc
--- /dev/null
+++ b/example/src/main/java/com/example/order/param/OrderPageParam.java
@@ -0,0 +1,41 @@
+package com.example.order.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+
+import java.time.LocalDate;
+
+/**
+ *
+ * 订单表 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-20
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "订单表分页参数")
+public class OrderPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("订单开始日期")
+ private LocalDate startDate;
+
+ @ApiModelProperty("订单开始日期")
+ private LocalDate endDate;
+
+ @ApiModelProperty("订单类型")
+ private Integer orderType;
+
+ @ApiModelProperty("订单状态")
+ private Integer status;
+
+ @ApiModelProperty("用户昵称")
+ private String nickName;
+}
diff --git a/example/src/main/java/com/example/order/service/ExampleOrderService.java b/example/src/main/java/com/example/order/service/ExampleOrderService.java
deleted file mode 100644
index 3246ca71d0456c47127a2c1c91b9ba58883399fc..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/example/order/service/ExampleOrderService.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.order.service;
-
-import com.example.order.entity.ExampleOrder;
-import com.example.order.param.ExampleOrderPageParam;
-import io.geekidea.springbootplus.framework.common.service.BaseService;
-import io.geekidea.springbootplus.framework.core.pagination.Paging;
-
-/**
- * 订单示例 服务类
- *
- * @author geekidea
- * @since 2020-03-27
- */
-public interface ExampleOrderService extends BaseService {
-
- /**
- * 保存
- *
- * @param exampleOrder
- * @return
- * @throws Exception
- */
- boolean saveExampleOrder(ExampleOrder exampleOrder) throws Exception;
-
- /**
- * 修改
- *
- * @param exampleOrder
- * @return
- * @throws Exception
- */
- boolean updateExampleOrder(ExampleOrder exampleOrder) throws Exception;
-
- /**
- * 删除
- *
- * @param id
- * @return
- * @throws Exception
- */
- boolean deleteExampleOrder(Long id) throws Exception;
-
-
- /**
- * 获取分页对象
- *
- * @param exampleOrderQueryParam
- * @return
- * @throws Exception
- */
- Paging getExampleOrderPageList(ExampleOrderPageParam exampleOrderPageParam) throws Exception;
-
-}
diff --git a/example/src/main/java/com/example/order/service/OrderService.java b/example/src/main/java/com/example/order/service/OrderService.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a3863101bd73e48d2d9b48c1545d9e5c85cd094
--- /dev/null
+++ b/example/src/main/java/com/example/order/service/OrderService.java
@@ -0,0 +1,56 @@
+package com.example.order.service;
+
+import com.example.order.entity.Order;
+import com.example.order.param.OrderPageParam;
+import com.example.order.vo.OrderPageVo;
+import com.example.order.vo.OrderVo;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+/**
+ * 订单表 服务类
+ *
+ * @author limg
+ * @since 2021-02-20
+ */
+public interface OrderService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param order
+ * @return
+ * @throws Exception
+ */
+ boolean saveOrder(Order order) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param order
+ * @return
+ * @throws Exception
+ */
+ boolean updateOrder(Order order) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deleteOrder(Long id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param orderPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getOrderPageList(OrderPageParam orderPageParam) throws Exception;
+
+ Paging getOrderList(OrderPageParam orderPageParam) throws Exception;
+}
diff --git a/example/src/main/java/com/example/order/service/impl/ExampleOrderServiceImpl.java b/example/src/main/java/com/example/order/service/impl/ExampleOrderServiceImpl.java
deleted file mode 100644
index f3b0880fe39af1268e995e98443fcb187573653b..0000000000000000000000000000000000000000
--- a/example/src/main/java/com/example/order/service/impl/ExampleOrderServiceImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.order.service.impl;
-
-import com.example.order.entity.ExampleOrder;
-import com.example.order.mapper.ExampleOrderMapper;
-import com.example.order.service.ExampleOrderService;
-import com.example.order.param.ExampleOrderPageParam;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
-import io.geekidea.springbootplus.framework.core.pagination.Paging;
-import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.metadata.OrderItem;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.transaction.annotation.Transactional;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * 订单示例 服务实现类
- *
- * @author geekidea
- * @since 2020-03-27
- */
-@Slf4j
-@Service
-public class ExampleOrderServiceImpl extends BaseServiceImpl implements ExampleOrderService {
-
- @Autowired
- private ExampleOrderMapper exampleOrderMapper;
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public boolean saveExampleOrder(ExampleOrder exampleOrder) throws Exception {
- return super.save(exampleOrder);
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public boolean updateExampleOrder(ExampleOrder exampleOrder) throws Exception {
- return super.updateById(exampleOrder);
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public boolean deleteExampleOrder(Long id) throws Exception {
- return super.removeById(id);
- }
-
- @Override
- public Paging getExampleOrderPageList(ExampleOrderPageParam exampleOrderPageParam) throws Exception {
- Page page = new PageInfo<>(exampleOrderPageParam, OrderItem.desc(getLambdaColumn(ExampleOrder::getCreateTime)));
- LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
- String keyword = exampleOrderPageParam.getKeyword();
- String name = exampleOrderPageParam.getName();
- String orderNo = exampleOrderPageParam.getOrderNo();
- // keyword模糊查询
- if (StringUtils.isNotBlank(keyword)) {
- wrapper.like(ExampleOrder::getName, keyword).or().like(ExampleOrder::getOrderNo, keyword);
- }
- // name模糊查询
- if (StringUtils.isNotBlank(name)) {
- wrapper.like(ExampleOrder::getName, name);
- }
- // 订单号模糊查询
- if (StringUtils.isNotBlank(orderNo)) {
- wrapper.like(ExampleOrder::getOrderNo, orderNo);
- }
- IPage iPage = exampleOrderMapper.selectPage(page, wrapper);
- return new Paging(iPage);
- }
-
-}
diff --git a/example/src/main/java/com/example/order/service/impl/OrderServiceImpl.java b/example/src/main/java/com/example/order/service/impl/OrderServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..823619c51bd60870563b89d6b951b6fe6a9eac99
--- /dev/null
+++ b/example/src/main/java/com/example/order/service/impl/OrderServiceImpl.java
@@ -0,0 +1,67 @@
+package com.example.order.service.impl;
+
+import com.example.order.entity.Order;
+import com.example.order.mapper.OrderMapper;
+import com.example.order.service.OrderService;
+import com.example.order.param.OrderPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.order.vo.OrderPageVo;
+import com.example.order.vo.OrderVo;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.geekidea.boot.framework.util.LoginUtil;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 订单表 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-20
+ */
+@Slf4j
+@Service
+public class OrderServiceImpl extends BaseServiceImpl implements OrderService {
+
+ @Autowired
+ private OrderMapper orderMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveOrder(Order order) throws Exception {
+ return super.save(order);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateOrder(Order order) throws Exception {
+ return super.updateById(order);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteOrder(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Paging getOrderPageList(OrderPageParam orderPageParam) throws Exception {
+ Page page = new PageInfo<>(orderPageParam, OrderItem.desc(getLambdaColumn(Order::getCreatedTime)));
+ IPage iPage = orderMapper.selectOrderPage(page, orderPageParam);
+ return new Paging(iPage);
+ }
+
+ @Override
+ public Paging getOrderList(OrderPageParam orderPageParam) throws Exception {
+ Page page = new PageInfo<>(orderPageParam, OrderItem.desc(getLambdaColumn(Order::getCreatedTime)));
+ IPage iPage = orderMapper.selectUserOrder(page, LoginUtil.getAppUserId());
+ return new Paging(iPage);
+ }
+
+}
diff --git a/example/src/main/java/com/example/order/vo/OrderPageVo.java b/example/src/main/java/com/example/order/vo/OrderPageVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..f3e33abcbe1d3630ed0a1835e9cc6bade620911b
--- /dev/null
+++ b/example/src/main/java/com/example/order/vo/OrderPageVo.java
@@ -0,0 +1,51 @@
+package com.example.order.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "OrderPageVo对象", description = "小程序订单列表对象")
+public class OrderPageVo implements Serializable {
+ private static final long serialVersionUID = -8270719309957728936L;
+
+ @ApiModelProperty("ID")
+ private Integer id;
+
+ @ApiModelProperty("订单号")
+ private String orderId;
+
+ @ApiModelProperty("用户编号")
+ private String userId;
+
+ @ApiModelProperty("金额")
+ private BigDecimal amount;
+
+ @ApiModelProperty("专题编号")
+ private String code;
+
+ @ApiModelProperty("支付流水号")
+ private String tradeNo;
+
+ @ApiModelProperty("状态 1-新建,2-支付成功,3-已取消")
+ private String status;
+
+ @ApiModelProperty("订单创建时间")
+ private Date createdTime;
+
+ @ApiModelProperty("专题名称")
+ private String subject;
+
+ @ApiModelProperty("封面")
+ private String coverImg;
+
+ @ApiModelProperty("描述")
+ private String remark;
+}
diff --git a/example/src/main/java/com/example/order/vo/OrderVo.java b/example/src/main/java/com/example/order/vo/OrderVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..4cc61d966a1dd3bd3b5213f68a2c55d3af7ac4c5
--- /dev/null
+++ b/example/src/main/java/com/example/order/vo/OrderVo.java
@@ -0,0 +1,50 @@
+package com.example.order.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "OrderVo对象", description = "订单列表对象")
+public class OrderVo implements Serializable {
+ private static final long serialVersionUID = -7797671947919534428L;
+
+ @ApiModelProperty("ID")
+ private Integer id;
+
+ @ApiModelProperty("订单号")
+ private String orderId;
+
+ @ApiModelProperty("用户编号")
+ private String userId;
+
+ @ApiModelProperty("用户昵称")
+ private String nickName;
+
+ @ApiModelProperty("用户头像")
+ private String avatarUrl;
+
+ @ApiModelProperty("金额")
+ private BigDecimal amount;
+
+ @ApiModelProperty("支付流水号")
+ private String tradeNo;
+
+ @ApiModelProperty("订单类型")
+ private String orderType;
+
+ @ApiModelProperty("状态 1-新建,2-支付成功,3-已取消")
+ private String status;
+
+ @ApiModelProperty("订单创建时间")
+ private Date createdTime;
+
+ @ApiModelProperty("订单备注")
+ private String remark;
+}
diff --git a/example/src/main/java/com/example/paper/controller/PaperController.java b/example/src/main/java/com/example/paper/controller/PaperController.java
new file mode 100644
index 0000000000000000000000000000000000000000..760d0bb9576705461ff096a432d1c6981a012519
--- /dev/null
+++ b/example/src/main/java/com/example/paper/controller/PaperController.java
@@ -0,0 +1,121 @@
+package com.example.paper.controller;
+
+import com.example.paper.entity.Paper;
+import com.example.paper.service.PaperService;
+import com.example.paper.vo.PaperAppVo;
+import com.example.paper.vo.PaperQueryVo;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import lombok.extern.slf4j.Slf4j;
+import com.example.paper.param.PaperPageParam;
+import org.apache.shiro.SecurityUtils;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 试卷实体 控制器
+ *
+ * @author limg
+ * @since 2021-01-31
+ */
+@Slf4j
+@RestController
+@RequestMapping("/paper")
+@Module("paper")
+@Api(value = "试卷实体API", tags = {"试卷实体"})
+public class PaperController extends BaseController {
+
+ @Autowired
+ private PaperService paperService;
+
+ /**
+ * 添加试卷实体
+ */
+ @PostMapping("/submit")
+ @OperationLog(name = "添加试卷实体", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加试卷实体", response = ApiResult.class)
+ @CacheEvict(cacheNames = "p_paper", allEntries = true)
+ public ApiResult addPaper(@Validated(Add.class) @RequestBody Paper paper) throws Exception {
+ boolean flag = paper.insertOrUpdate();
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改试卷实体
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改试卷实体", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改试卷实体", response = ApiResult.class)
+ @CacheEvict(cacheNames = "p_paper", allEntries = true)
+ public ApiResult updatePaper(@Validated(Update.class) @RequestBody Paper paper) throws Exception {
+ Paper paper1 = new Paper();
+ paper1.setId(paper.getId());
+ paper1.setIsOpen(paper.getIsOpen());
+ boolean flag = paperService.updatePaper(paper1);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除试卷实体
+ */
+ @PostMapping("/delete/{id}")
+ @OperationLog(name = "删除试卷实体", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除试卷实体", response = ApiResult.class)
+ @CacheEvict(cacheNames = "p_paper", allEntries = true)
+ public ApiResult deletePaper(@PathVariable("id") Long id) throws Exception {
+ boolean flag = paperService.deletePaper(id);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 获取试卷实体详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "试卷实体详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "试卷实体详情", response = Paper.class)
+ public ApiResult getPaper(@PathVariable("id") Long id) throws Exception {
+ Paper paper = paperService.getById(id);
+ return ApiResult.ok(paper);
+ }
+
+ /**
+ * 试卷实体分页列表
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "试卷实体分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "试卷实体分页列表", response = Paper.class)
+ @Cacheable(cacheNames = "p_paper", key = "#paperPageParam.getPageIndex() " +
+ "+ '::' +#paperPageParam.getPageSize() " +
+ "+ ':' + #paperPageParam.getName() " +
+ "+ ':' + #paperPageParam.getCategoryId()")
+ public ApiResult> getPaperPageList(@Validated @RequestBody PaperPageParam paperPageParam) throws Exception {
+// Paging paging = paperService.getPaperPageList(paperPageParam);
+ Paging paging = paperService.getPaperPageList(paperPageParam);
+ return ApiResult.ok(paging);
+ }
+
+
+ @GetMapping("/wechat/getOpenPaper")
+ @OperationLog(name = "获取开放试卷分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "获取开放试卷分页列表", response = Paper.class)
+ public ApiResult> getOpenPaperList(@RequestParam("categoryCode") String code) throws Exception {
+ List list = paperService.getOpenPaperList(code);
+ return ApiResult.ok(list);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/paper/entity/Paper.java b/example/src/main/java/com/example/paper/entity/Paper.java
new file mode 100644
index 0000000000000000000000000000000000000000..c1c5caab655ba7dc10a79fa1a5ec735ad469e0a9
--- /dev/null
+++ b/example/src/main/java/com/example/paper/entity/Paper.java
@@ -0,0 +1,80 @@
+package com.example.paper.entity;
+
+import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.*;
+
+/**
+ * 试卷实体
+ *
+ * @author limg
+ * @since 2021-01-31
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_paper")
+@ApiModel(value = "Paper对象")
+public class Paper extends Model {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "编号不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("试卷名称")
+ @TableField("PAPER_NAME")
+ @NotNull(message = "试卷名称不能为空", groups = Add.class)
+ private String paperName;
+
+ @ApiModelProperty("是否开放")
+ @TableField("IS_OPEN")
+ private String isOpen;
+
+ @ApiModelProperty("价格")
+ @TableField("PRICE")
+ @NotNull(message = "请输入价格", groups = Add.class)
+ @Min(value = 0, message = "价格不能小于0")
+ @Max(value = 99999, message = "价格不能超过99999")
+ private BigDecimal price;
+
+ @ApiModelProperty("所属分类")
+ @TableField("CATEGORY_ID")
+ private String categoryId;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ @Version
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/paper/mapper/PaperMapper.java b/example/src/main/java/com/example/paper/mapper/PaperMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..1e83ac582252896e5f7c6526f3240ace536750ed
--- /dev/null
+++ b/example/src/main/java/com/example/paper/mapper/PaperMapper.java
@@ -0,0 +1,36 @@
+package com.example.paper.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.paper.entity.Paper;
+import com.example.paper.param.PaperPageParam;
+
+import com.example.paper.vo.PaperAppVo;
+import com.example.paper.vo.PaperQueryVo;
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 试卷实体 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-01-31
+ */
+@Repository
+public interface PaperMapper extends BaseMapper {
+
+ /**
+ * 获取分页对象
+ *
+ * @param page
+ * @param paperPageParam
+ * @return
+ */
+ IPage getPaperPageList(@Param("page") Page page, @Param("param") PaperPageParam paperPageParam);
+
+ List getOpenPaperList(@Param("userId") String userId, @Param("code") String code);
+}
diff --git a/example/src/main/java/com/example/paper/param/PaperPageParam.java b/example/src/main/java/com/example/paper/param/PaperPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..aa056d15ffffa42587cf00aa96ca808d4ae2f0e2
--- /dev/null
+++ b/example/src/main/java/com/example/paper/param/PaperPageParam.java
@@ -0,0 +1,30 @@
+package com.example.paper.param;
+
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ *
+ * 试卷实体 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-01-31
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "试卷实体分页参数")
+public class PaperPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("试卷名称")
+ private String name;
+
+ @ApiModelProperty("试卷分类")
+ private String categoryId;
+}
diff --git a/example/src/main/java/com/example/paper/service/PaperService.java b/example/src/main/java/com/example/paper/service/PaperService.java
new file mode 100644
index 0000000000000000000000000000000000000000..71282213c225f490ec74b888de4cdfd62c557416
--- /dev/null
+++ b/example/src/main/java/com/example/paper/service/PaperService.java
@@ -0,0 +1,59 @@
+package com.example.paper.service;
+
+import com.example.paper.entity.Paper;
+import com.example.paper.param.PaperPageParam;
+import com.example.paper.vo.PaperAppVo;
+import com.example.paper.vo.PaperQueryVo;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+import java.util.List;
+
+/**
+ * 试卷实体 服务类
+ *
+ * @author limg
+ * @since 2021-01-31
+ */
+public interface PaperService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param paper
+ * @return
+ * @throws Exception
+ */
+ boolean savePaper(Paper paper) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param paper
+ * @return
+ * @throws Exception
+ */
+ boolean updatePaper(Paper paper) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deletePaper(Long id) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param paperPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getPaperPageList(PaperPageParam paperPageParam) throws Exception;
+
+ List getOpenPaperList(String code) throws Exception;
+
+}
diff --git a/example/src/main/java/com/example/paper/service/impl/PaperServiceImpl.java b/example/src/main/java/com/example/paper/service/impl/PaperServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..916d028c5cbcc6cd62908153646dc648d4012627
--- /dev/null
+++ b/example/src/main/java/com/example/paper/service/impl/PaperServiceImpl.java
@@ -0,0 +1,70 @@
+package com.example.paper.service.impl;
+
+import com.example.paper.entity.Paper;
+import com.example.paper.mapper.PaperMapper;
+import com.example.paper.service.PaperService;
+import com.example.paper.param.PaperPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.paper.vo.PaperAppVo;
+import com.example.paper.vo.PaperQueryVo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.util.LoginUtil;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * 试卷实体 服务实现类
+ *
+ * @author limg
+ * @since 2021-01-31
+ */
+@Slf4j
+@Service
+public class PaperServiceImpl extends BaseServiceImpl implements PaperService {
+
+ @Autowired
+ private PaperMapper paperMapper;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean savePaper(Paper paper) throws Exception {
+ return super.save(paper);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updatePaper(Paper paper) throws Exception {
+ return super.updateById(paper);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deletePaper(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Paging getPaperPageList(PaperPageParam paperPageParam) throws Exception {
+ Page page = new PageInfo<>(paperPageParam, OrderItem.desc(getLambdaColumn(Paper::getCreatedTime)));
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+// IPage iPage = paperMapper.selectPage(page, wrapper);
+ IPage iPage = paperMapper.getPaperPageList(page, paperPageParam);
+ return new Paging(iPage);
+ }
+
+ @Override
+ public List getOpenPaperList(String code) throws Exception {
+ String userId = LoginUtil.getAppUserId();
+ return paperMapper.getOpenPaperList(userId, code);
+ }
+
+}
diff --git a/example/src/main/java/com/example/paper/vo/PaperAppVo.java b/example/src/main/java/com/example/paper/vo/PaperAppVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..b5a914204e3ad2cda329f5e0852ad5933413b912
--- /dev/null
+++ b/example/src/main/java/com/example/paper/vo/PaperAppVo.java
@@ -0,0 +1,38 @@
+package com.example.paper.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "PaperAppVo对象", description = "小程序试卷对象")
+public class PaperAppVo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("主键")
+ private Long id;
+
+ @ApiModelProperty("试卷名称")
+ private String paperName;
+
+ @ApiModelProperty("价格")
+ private BigDecimal price;
+
+ @ApiModelProperty("试题数量")
+ private Integer count;
+
+ @ApiModelProperty("记录编号")
+ private Long recordId;
+
+ @ApiModelProperty("当前进度")
+ private Integer progress;
+
+ @ApiModelProperty("正确数量")
+ private Integer correctCount;
+
+}
diff --git a/example/src/main/java/com/example/paper/vo/PaperQueryVo.java b/example/src/main/java/com/example/paper/vo/PaperQueryVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..d11795fd30d32028bd403e9a9b0b1b1f487099e1
--- /dev/null
+++ b/example/src/main/java/com/example/paper/vo/PaperQueryVo.java
@@ -0,0 +1,49 @@
+package com.example.paper.vo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "PaperQueryVo对象", description = "试卷查询对象")
+public class PaperQueryVo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("主键")
+ private Long id;
+
+ @ApiModelProperty("试卷名称")
+ private String name;
+
+ @ApiModelProperty("是否开放")
+ private String isOpen;
+
+ @ApiModelProperty("价格")
+ private BigDecimal price;
+
+ @ApiModelProperty("所属分类")
+ private String categoryId;
+
+ @ApiModelProperty("试题数量")
+ private Integer count;
+
+ @ApiModelProperty("创建人")
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ private Date updatedTime;
+}
diff --git a/example/src/main/java/com/example/question/controller/QuestionController.java b/example/src/main/java/com/example/question/controller/QuestionController.java
new file mode 100644
index 0000000000000000000000000000000000000000..c717767482ed4ea77ed54a07a096b2af6af48259
--- /dev/null
+++ b/example/src/main/java/com/example/question/controller/QuestionController.java
@@ -0,0 +1,145 @@
+package com.example.question.controller;
+
+import com.example.question.entity.Question;
+import com.example.question.param.QuestionAnswerParam;
+import com.example.question.param.QuestionCategoryParam;
+import com.example.question.param.QuestionParam;
+import com.example.question.service.QuestionService;
+import com.example.question.vo.QuestionCategoryPageVo;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.common.api.ApiResult;
+import io.geekidea.boot.framework.common.controller.BaseController;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import io.geekidea.boot.framework.core.validator.groups.Add;
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.geekidea.boot.framework.log.annotation.Module;
+import io.geekidea.boot.framework.log.annotation.OperationLog;
+import io.geekidea.boot.framework.log.enums.OperationLogType;
+import lombok.extern.slf4j.Slf4j;
+import com.example.question.param.QuestionPageParam;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.validation.annotation.Validated;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 题目信息 控制器
+ *
+ * @author limg
+ * @since 2021-02-03
+ */
+@Slf4j
+@RestController
+@RequestMapping("/question")
+@Module("question")
+@Api(value = "题目信息API", tags = {"题目信息"})
+public class QuestionController extends BaseController {
+
+ @Autowired
+ private QuestionService questionService;
+
+ /**
+ * 添加题目信息
+ */
+ @PostMapping("/submit")
+ @OperationLog(name = "添加题目信息", type = OperationLogType.ADD)
+ @ApiOperation(value = "添加题目信息", response = ApiResult.class)
+ @CacheEvict( value = "question", allEntries = true)
+ public ApiResult addQuestion(@Validated(Add.class) @RequestBody Question question) throws Exception {
+// boolean flag = questionService.saveQuestion(question);
+ boolean flag = question.insertOrUpdate();
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 修改题目信息
+ */
+ @PostMapping("/update")
+ @OperationLog(name = "修改题目信息", type = OperationLogType.UPDATE)
+ @ApiOperation(value = "修改题目信息", response = ApiResult.class)
+ @CacheEvict(value = "question", allEntries = true)
+ public ApiResult updateQuestion(@Validated(Update.class) @RequestBody Question question) throws Exception {
+ boolean flag = questionService.updateQuestion(question);
+ return ApiResult.result(flag);
+ }
+
+ /**
+ * 删除题目信息
+ */
+ @PostMapping("/delete/{id}")
+ @OperationLog(name = "删除题目信息", type = OperationLogType.DELETE)
+ @ApiOperation(value = "删除题目信息", response = ApiResult.class)
+ @CacheEvict(value = "question", allEntries = true)
+ public ApiResult deleteQuestion(@PathVariable("id") Long id) throws Exception {
+ boolean flag = questionService.deleteQuestion(id);
+ return ApiResult.result(flag);
+ }
+
+ @GetMapping("/maxorder/{pid}")
+ @OperationLog(name = "查询最大单号", type = OperationLogType.OTHER_QUERY)
+ @ApiOperation(value = "查询最大单号", response = ApiResult.class)
+ public ApiResult getMaxOrder(@PathVariable("pid") Long pid) throws Exception {
+ Integer order = questionService.getCountByPid(pid);
+ return ApiResult.ok(order + 1);
+ }
+
+ /**
+ * 获取题目信息详情
+ */
+ @GetMapping("/info/{id}")
+ @OperationLog(name = "题目信息详情", type = OperationLogType.INFO)
+ @ApiOperation(value = "题目信息详情", response = Question.class)
+ public ApiResult getQuestion(@PathVariable("id") Long id) throws Exception {
+ Question question = questionService.getById(id);
+ return ApiResult.ok(question);
+ }
+
+ /**
+ * 题目信息分页列表-小程序端
+ */
+ @PostMapping("/getPageList")
+ @OperationLog(name = "题目信息分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "题目信息分页列表", response = Question.class)
+// @Cacheable(cacheNames = "question", key = "#p0.toString()")
+ public ApiResult> getQuestionPageList(@Validated @RequestBody QuestionPageParam questionPageParam) throws Exception {
+ Paging paging = questionService.getQuestionPageList(questionPageParam);
+ return ApiResult.ok(paging);
+ }
+
+ /**
+ * 专题详情页题目分页列表-小程序端
+ */
+ @PostMapping("/wechat/getPageList")
+ @OperationLog(name = "题目信息分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "题目信息分页列表", response = Question.class)
+ @Cacheable(cacheNames = "question", key = "#p0.toString()")
+ public ApiResult> getCategoryQuestionPageList(@Validated @RequestBody QuestionCategoryParam questionCategoryParam) throws Exception {
+ Paging paging = questionService.getCategoryQuestionPageList(questionCategoryParam);
+ return ApiResult.ok(paging);
+ }
+
+ /**
+ * 题目分页列表-PC端
+ */
+ @PostMapping("/getList")
+ @OperationLog(name = "题目信息分页列表", type = OperationLogType.PAGE)
+ @ApiOperation(value = "题目信息分页列表", response = Question.class)
+ @Cacheable(value = "question", key = "#p0.toString()")
+ public ApiResult> getPageList(@Validated @RequestBody QuestionParam questionParam) throws Exception {
+ Paging paging = questionService.getPageList(questionParam);
+ return ApiResult.ok(paging);
+ }
+
+ @PostMapping("/submitAnswer")
+ @OperationLog(name = "提交答案", type = OperationLogType.ADD)
+ @ApiOperation(value = "提交答案", response = Question.class)
+ public ApiResult submitAnswer(@Validated @RequestBody QuestionAnswerParam questionAnswerParam) throws Exception {
+ Boolean flag = questionService.sumitAnswer(questionAnswerParam);
+ return ApiResult.ok(flag);
+ }
+
+}
+
diff --git a/example/src/main/java/com/example/question/entity/Question.java b/example/src/main/java/com/example/question/entity/Question.java
new file mode 100644
index 0000000000000000000000000000000000000000..d0193b4fc75b7b6b377cf32085abd038e82fd04f
--- /dev/null
+++ b/example/src/main/java/com/example/question/entity/Question.java
@@ -0,0 +1,126 @@
+package com.example.question.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+
+import java.util.Date;
+
+import io.geekidea.boot.framework.core.validator.groups.Update;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 题目信息
+ *
+ * @author limg
+ * @since 2021-02-03
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName("p_question")
+@ApiModel(value = "Question对象")
+public class Question extends Model {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull(message = "id不能为空", groups = {Update.class})
+ @ApiModelProperty("编号")
+ @TableId(value = "ID", type = IdType.AUTO)
+ private Integer id;
+
+ @ApiModelProperty("题目编号")
+ @TableField("SERIAL")
+ private Integer serial;
+
+ @ApiModelProperty("标题")
+ @TableField("SUBJECT")
+ @NotNull(message = "标题不能为空")
+ private String subject;
+
+ @ApiModelProperty("标题-英文")
+ @TableField("SUBJECT_EN")
+ private String subjectEn;
+
+ @ApiModelProperty("所属试卷")
+ @TableField("PAPER_ID")
+ private Integer paperId;
+
+ @ApiModelProperty("图片")
+ @TableField("IMG_URL")
+ private String imgUrl;
+
+ @ApiModelProperty("选项A")
+ @TableField("OPTION_A")
+ private String optionA;
+
+ @ApiModelProperty("选项A-英文")
+ @TableField("OPTION_A_EN")
+ private String optionAEn;
+
+ @ApiModelProperty("选项B")
+ @TableField("OPTION_B")
+ private String optionB;
+
+ @ApiModelProperty("选项B-英文")
+ @TableField("OPTION_B_EN")
+ private String optionBEn;
+
+ @ApiModelProperty("选项C")
+ @TableField("OPTION_C")
+ private String optionC;
+
+ @ApiModelProperty("选项C-英文")
+ @TableField("OPTION_C_EN")
+ private String optionCEn;
+
+ @ApiModelProperty("选项D")
+ @TableField("OPTION_D")
+ private String optionD;
+
+ @ApiModelProperty("选项D-英文")
+ @TableField("OPTION_D_EN")
+ private String optionDEn;
+
+ @ApiModelProperty("正确答案")
+ @TableField("ANSWER")
+ @NotNull(message = "请选择正确答案")
+ private String answer;
+
+ @ApiModelProperty("解析")
+ @TableField("ANSWER_DETAIL")
+ private String answerDetail;
+
+ @ApiModelProperty("所属过程组")
+ @TableField("GROUP_ID")
+ private String groupId;
+
+ @ApiModelProperty("所属章节")
+ @TableField("CHAPTER_ID")
+ private Integer chapterId;
+
+ @ApiModelProperty("乐观锁")
+ @TableField("REVISION")
+ private Integer revision;
+
+ @ApiModelProperty("创建人")
+ @TableField(value = "CREATED_BY", fill = FieldFill.INSERT)
+ private String createdBy;
+
+ @ApiModelProperty("创建时间")
+ @TableField(value = "CREATED_TIME", fill = FieldFill.INSERT)
+ private Date createdTime;
+
+ @ApiModelProperty("更新人")
+ @TableField(value = "UPDATED_BY", fill = FieldFill.UPDATE)
+ private String updatedBy;
+
+ @ApiModelProperty("更新时间")
+ @TableField(value = "UPDATED_TIME", fill = FieldFill.UPDATE)
+ private Date updatedTime;
+
+}
diff --git a/example/src/main/java/com/example/question/mapper/QuestionMapper.java b/example/src/main/java/com/example/question/mapper/QuestionMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..6029249276a8ab8f5e2ef09ab0144a088488f423
--- /dev/null
+++ b/example/src/main/java/com/example/question/mapper/QuestionMapper.java
@@ -0,0 +1,37 @@
+package com.example.question.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.paper.param.PaperPageParam;
+import com.example.paper.vo.PaperQueryVo;
+import com.example.question.entity.Question;
+import com.example.question.param.QuestionPageParam;
+
+import com.example.question.vo.QuestionCategoryPageVo;
+import com.example.question.vo.QuestionPageVo;
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import java.io.Serializable;
+
+/**
+ * 题目信息 Mapper 接口
+ *
+ * @author limg
+ * @since 2021-02-03
+ */
+@Repository
+public interface QuestionMapper extends BaseMapper {
+
+ /**
+ * 获取分页对象
+ *
+ * @param page
+ * @param paperPageParam
+ * @return
+ */
+ IPage getQuestionPageList(@Param("page") Page page, @Param("param") QuestionPageParam paperPageParam, @Param("userId") String userId);
+
+ IPage getQuestionCategoryPageList(@Param("page") Page page, @Param("groupId") String groupId);
+}
diff --git a/example/src/main/java/com/example/question/param/QuestionAnswerParam.java b/example/src/main/java/com/example/question/param/QuestionAnswerParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..9355502c0d13315b61f1a5ae86156dd48ee95c73
--- /dev/null
+++ b/example/src/main/java/com/example/question/param/QuestionAnswerParam.java
@@ -0,0 +1,40 @@
+package com.example.question.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ *
+ * 题目信息 提交答案表单对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-03
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "提交答案表单对象")
+public class QuestionAnswerParam implements Serializable {
+ private static final long serialVersionUID = 5364321420976152006L;
+
+ @ApiModelProperty("试卷id")
+ private String paperId;
+
+ @ApiModelProperty("考试id")
+ private Long recordId;
+
+ @ApiModelProperty("试题id")
+ @NotNull(message = "试题id不能为空")
+ private Long questionId;
+
+ @ApiModelProperty("用户选择的答案")
+ @NotNull(message = "答案不能为空")
+ private String answer;
+
+}
diff --git a/example/src/main/java/com/example/question/param/QuestionCategoryParam.java b/example/src/main/java/com/example/question/param/QuestionCategoryParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..ed71170ad6b1ea15596f0a369b4a9e8ab083b7ba
--- /dev/null
+++ b/example/src/main/java/com/example/question/param/QuestionCategoryParam.java
@@ -0,0 +1,35 @@
+package com.example.question.param;
+
+import cn.hutool.core.text.StrFormatter;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+import io.geekidea.boot.framework.util.LoginUtil;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "题目信息分页参数")
+public class QuestionCategoryParam extends BasePageOrderParam {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("所属专题id")
+ @NotNull(message = "专题编号不能为空")
+ private String groupId;
+
+ @Override
+ public String toString() {
+ String key = StrFormatter.format("{}-{}-{}",
+ this.getGroupId() == null ? "" : this.getGroupId(),
+ this.getPageIndex() == null ? "1" : this.getPageIndex(),
+ this.getPageSize() == null ? "10" : this.getPageSize());
+ return key;
+ }
+
+}
diff --git a/example/src/main/java/com/example/question/param/QuestionPageParam.java b/example/src/main/java/com/example/question/param/QuestionPageParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..1e17476fe6e5cc2279d228141587b588d25df47c
--- /dev/null
+++ b/example/src/main/java/com/example/question/param/QuestionPageParam.java
@@ -0,0 +1,49 @@
+package com.example.question.param;
+
+import cn.hutool.core.text.StrFormatter;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+import io.geekidea.boot.framework.util.LoginUtil;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ *
+ * 题目信息 分页参数对象
+ *
+ *
+ * @author limg
+ * @date 2021-02-03
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "题目信息分页参数")
+public class QuestionPageParam extends BasePageOrderParam {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("试卷id")
+ private String paperId;
+
+ @ApiModelProperty("所属专题id")
+ private String groupId;
+
+ @ApiModelProperty("所属章节id")
+ private String chapterId;
+
+ @Override
+ public String toString() {
+ String key = StrFormatter.format("{}-{}-{}-{}-{}", LoginUtil.getAppUserId(),
+ this.getChapterId() == null ? "" : this.getChapterId(),
+ this.getGroupId() == null ? "" : this.getGroupId(),
+ this.getPageIndex() == null ? "1" : this.getPageIndex(),
+ this.getPageSize() == null ? "10" : this.getPageSize());
+ System.out.printf("key:", key);
+ return key;
+ }
+
+}
diff --git a/example/src/main/java/com/example/question/param/QuestionParam.java b/example/src/main/java/com/example/question/param/QuestionParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..757733e2bb67ff66a5415d69530dc6de328fe8fc
--- /dev/null
+++ b/example/src/main/java/com/example/question/param/QuestionParam.java
@@ -0,0 +1,44 @@
+package com.example.question.param;
+
+import cn.hutool.core.text.StrFormatter;
+import io.geekidea.boot.framework.core.pagination.BasePageOrderParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "题目信息分页参数")
+public class QuestionParam extends BasePageOrderParam {
+
+ private static final long serialVersionUID = 5431374571367066733L;
+
+ @ApiModelProperty("试卷id")
+ private String paperId;
+
+ @ApiModelProperty("标题")
+ private String subject;
+
+ @ApiModelProperty("专项ID")
+ private String groupId;
+
+ @ApiModelProperty("章节ID")
+ private String chapterId;
+
+ @Override
+ public String toString() {
+ String key = StrFormatter.format("{}-{}-{}-{}-{}", this.getSubject() == null ? "" : this.getSubject(),
+ this.getChapterId() == null ? "" : this.getChapterId(),
+ this.getGroupId() == null ? "" : this.getGroupId(),
+ this.getPageIndex() == null ? "1" : this.getPageIndex(),
+ this.getPageSize() == null ? "10" : this.getPageSize());
+ System.out.printf("key:", key);
+ return key;
+ }
+
+}
diff --git a/example/src/main/java/com/example/question/service/QuestionService.java b/example/src/main/java/com/example/question/service/QuestionService.java
new file mode 100644
index 0000000000000000000000000000000000000000..74294c37d71b1f31b5599c7266e5a5ff788a32a0
--- /dev/null
+++ b/example/src/main/java/com/example/question/service/QuestionService.java
@@ -0,0 +1,65 @@
+package com.example.question.service;
+
+import com.example.question.entity.Question;
+import com.example.question.param.QuestionAnswerParam;
+import com.example.question.param.QuestionCategoryParam;
+import com.example.question.param.QuestionPageParam;
+import com.example.question.param.QuestionParam;
+import com.example.question.vo.QuestionCategoryPageVo;
+import com.example.question.vo.QuestionPageVo;
+import io.geekidea.boot.framework.common.service.BaseService;
+import io.geekidea.boot.framework.core.pagination.Paging;
+
+/**
+ * 题目信息 服务类
+ *
+ * @author limg
+ * @since 2021-02-03
+ */
+public interface QuestionService extends BaseService {
+
+ /**
+ * 保存
+ *
+ * @param question
+ * @return
+ * @throws Exception
+ */
+ boolean saveQuestion(Question question) throws Exception;
+
+ /**
+ * 修改
+ *
+ * @param question
+ * @return
+ * @throws Exception
+ */
+ boolean updateQuestion(Question question) throws Exception;
+
+ /**
+ * 删除
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ boolean deleteQuestion(Long id) throws Exception;
+
+ Integer getCountByPid(Long pid) throws Exception;
+
+
+ /**
+ * 获取分页对象
+ *
+ * @param questionPageParam
+ * @return
+ * @throws Exception
+ */
+ Paging getQuestionPageList(QuestionPageParam questionPageParam) throws Exception;
+
+ Boolean sumitAnswer(QuestionAnswerParam questionAnswerParam) throws Exception;
+
+ Paging getPageList(QuestionParam questionParam);
+
+ Paging getCategoryQuestionPageList(QuestionCategoryParam questionCategoryParam) throws Exception;
+}
diff --git a/example/src/main/java/com/example/question/service/impl/QuestionServiceImpl.java b/example/src/main/java/com/example/question/service/impl/QuestionServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..e64383557d12a352483186dba59756be84ba8368
--- /dev/null
+++ b/example/src/main/java/com/example/question/service/impl/QuestionServiceImpl.java
@@ -0,0 +1,187 @@
+package com.example.question.service.impl;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.StrUtil;
+import com.example.history.entity.History;
+import com.example.history.service.HistoryService;
+import com.example.notes.entity.Notes;
+import com.example.notes.service.NotesService;
+import com.example.order.entity.Order;
+import com.example.order.service.OrderService;
+import com.example.question.entity.Question;
+import com.example.question.mapper.QuestionMapper;
+import com.example.question.param.QuestionAnswerParam;
+import com.example.question.param.QuestionCategoryParam;
+import com.example.question.param.QuestionParam;
+import com.example.question.service.QuestionService;
+import com.example.question.param.QuestionPageParam;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.question.vo.QuestionCategoryPageVo;
+import com.example.question.vo.QuestionPageVo;
+import com.example.userPaper.entity.UserPaper;
+import com.example.userPaper.service.UserPaperService;
+import io.geekidea.boot.framework.common.exception.BusinessException;
+import io.geekidea.boot.framework.common.service.impl.BaseServiceImpl;
+import io.geekidea.boot.framework.core.pagination.PageInfo;
+import io.geekidea.boot.framework.core.pagination.Paging;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.geekidea.boot.framework.util.LoginUtil;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+/**
+ * 题目信息 服务实现类
+ *
+ * @author limg
+ * @since 2021-02-03
+ */
+@Slf4j
+@Service
+public class QuestionServiceImpl extends BaseServiceImpl implements QuestionService {
+
+ @Autowired
+ private QuestionMapper questionMapper;
+
+ @Lazy
+ @Autowired
+ private HistoryService historyService;
+
+ @Lazy
+ @Autowired
+ private UserPaperService userPaperService;
+
+ @Lazy
+ @Autowired
+ private NotesService notesService;
+
+ @Lazy
+ @Autowired
+ private OrderService orderService;
+
+ @Lazy
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean saveQuestion(Question question) throws Exception {
+ return super.save(question);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean updateQuestion(Question question) throws Exception {
+ return super.updateById(question);
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public boolean deleteQuestion(Long id) throws Exception {
+ return super.removeById(id);
+ }
+
+ @Override
+ public Integer getCountByPid(Long pid) throws Exception {
+ return questionMapper.selectCount(new LambdaQueryWrapper().eq(Question::getPaperId, pid));
+ }
+
+ @Override
+// @Cacheable(cacheNames = "question", key = "#p0")
+ public Paging getQuestionPageList(QuestionPageParam questionPageParam) throws Exception {
+ // 暂时取消是否购买的判断
+// if (questionPageParam.getGroupId() != null) {
+// int count = orderService.count(new LambdaQueryWrapper()
+// .eq(Order::getUserId, LoginUtil.getAppUserId())
+// .eq(Order::getGroupId, questionPageParam.getGroupId())
+// .eq(Order::getStatus, 2));
+// if (count < 1) {
+// throw new BusinessException(401, "您还未购买该专题");
+// }
+// }
+ Page page = new PageInfo<>(questionPageParam, OrderItem.asc(getLambdaColumn(Question::getSerial)));
+ IPage iPage = questionMapper.getQuestionPageList(page, questionPageParam, LoginUtil.getAppUserId());
+ return new Paging(iPage);
+ }
+
+ @Override
+ public Paging getCategoryQuestionPageList(QuestionCategoryParam questionCategoryParam) throws Exception {
+ Page page = new PageInfo<>(questionCategoryParam, OrderItem.asc(getLambdaColumn(Question::getSerial)));
+ IPage iPage = questionMapper.getQuestionCategoryPageList(page, questionCategoryParam.getGroupId());
+ return new Paging(iPage);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Boolean sumitAnswer(QuestionAnswerParam questionAnswerParam) throws Exception {
+ Question question = super.getById(questionAnswerParam.getQuestionId());
+ if (question == null) {
+ throw new BusinessException("试题不存在");
+ }
+ String appUserId = LoginUtil.getAppUserId();
+ // 插入历史记录
+ History history = new History();
+ history.setChapterId(Convert.toInt(question.getChapterId()));
+ history.setQuestionId(question.getId());
+ history.setUserAnswer(questionAnswerParam.getAnswer());
+ history.setIsRight(questionAnswerParam.getAnswer().equals(question.getAnswer()) ? "1" : "0");
+ history.setUserId(Convert.toInt(appUserId));
+ boolean flag = historyService.saveOrUpdate(history, new LambdaQueryWrapper().eq(History::getQuestionId, question.getId()).eq(History::getUserId, appUserId));
+ // 更新考试正确题数和当前进度
+ UserPaper userPaper = userPaperService.getById(questionAnswerParam.getRecordId());
+ if (userPaper != null) {
+ userPaper.setPaperId(questionAnswerParam.getPaperId());
+ if (questionAnswerParam.getAnswer().equals(question.getAnswer())) {
+ userPaper.setCorrectCount(userPaper.getCorrectCount() + 1);
+ } else {
+ userPaper.setErrorCount(userPaper.getErrorCount() + 1);
+ }
+ userPaper.setProgress(question.getSerial());
+ userPaper.setUserId(appUserId);
+ userPaperService.updateById(userPaper);
+ }
+
+ // 如果答错,插入错题集
+ if (!questionAnswerParam.getAnswer().equals(question.getAnswer())) {
+ Integer count = notesService.count(new LambdaQueryWrapper().eq(Notes::getUserId, appUserId).eq(Notes::getQuestionId, question.getId()));
+ if (count == 0) {
+ String key1 = String.format("wrongPaperList-%s-1", appUserId);
+ String key2 = String.format("wrongPaperList-%s-2", appUserId);
+ Notes notes = new Notes();
+ notes.setChapterId(Convert.toInt(question.getChapterId()));
+ notes.setQuestionId(question.getId());
+ notes.setUserAnswer(questionAnswerParam.getAnswer());
+ notes.setUserId(Convert.toInt(appUserId));
+ notesService.saveNotes(notes);
+ redisTemplate.delete(key1);
+ redisTemplate.delete(key2);
+ }
+ }
+
+ return flag;
+ }
+
+ @Override
+ public Paging getPageList(QuestionParam questionParam) {
+ Page page = new PageInfo<>(questionParam, OrderItem.asc(getLambdaColumn(Question::getId)));
+ LambdaQueryWrapper