Browse Source

创建项目

master
wangzijian 1 year ago
commit
ebb872a982
100 changed files with 7720 additions and 0 deletions
  1. 5
    0
      .gitignore
  2. 308
    0
      pom.xml
  3. 118
    0
      src/main/java/AutoIncrMember.java
  4. 17
    0
      src/main/java/com/cirle/scientific/ScientificCirleApplication.java
  5. 35
    0
      src/main/java/com/cirle/scientific/component/SpringUtil.java
  6. 37
    0
      src/main/java/com/cirle/scientific/config/AsyncConfig.java
  7. 25
    0
      src/main/java/com/cirle/scientific/config/CirleConfigurer.java
  8. 192
    0
      src/main/java/com/cirle/scientific/config/CirleInterceptor.java
  9. 104
    0
      src/main/java/com/cirle/scientific/config/OnlineSessionListener.java
  10. 57
    0
      src/main/java/com/cirle/scientific/config/RedisSessionConfiguration.java
  11. 42
    0
      src/main/java/com/cirle/scientific/config/SwaggerConfig.java
  12. 14
    0
      src/main/java/com/cirle/scientific/config/WebConfig.java
  13. 14
    0
      src/main/java/com/cirle/scientific/config/WebSocketConfig.java
  14. 95
    0
      src/main/java/com/cirle/scientific/config/redis/RedisConfig.java
  15. 17
    0
      src/main/java/com/cirle/scientific/constants/CheckWindowIdTypeConsts.java
  16. 12
    0
      src/main/java/com/cirle/scientific/constants/CourseWareConsts.java
  17. 11
    0
      src/main/java/com/cirle/scientific/constants/DictConsts.java
  18. 67
    0
      src/main/java/com/cirle/scientific/constants/LoginConsts.java
  19. 9
    0
      src/main/java/com/cirle/scientific/constants/PlayRecordLogConstants.java
  20. 16
    0
      src/main/java/com/cirle/scientific/constants/RedisKeyConstants.java
  21. 18
    0
      src/main/java/com/cirle/scientific/constants/SaveYsAndSmConsts.java
  22. 9
    0
      src/main/java/com/cirle/scientific/constants/ServerConstants.java
  23. 11
    0
      src/main/java/com/cirle/scientific/constants/ShareConsts.java
  24. 19
    0
      src/main/java/com/cirle/scientific/constants/StatusConsts.java
  25. 22
    0
      src/main/java/com/cirle/scientific/constants/TaskConsts.java
  26. 12
    0
      src/main/java/com/cirle/scientific/constants/UserInfoConsts.java
  27. 20
    0
      src/main/java/com/cirle/scientific/constants/WeixinConsts.java
  28. 73
    0
      src/main/java/com/cirle/scientific/controller/brandProduct/BrandProductController.java
  29. 235
    0
      src/main/java/com/cirle/scientific/controller/course/CourseController.java
  30. 270
    0
      src/main/java/com/cirle/scientific/controller/courseware/CourseWareController.java
  31. 20
    0
      src/main/java/com/cirle/scientific/controller/error/ErrorPageController.java
  32. 63
    0
      src/main/java/com/cirle/scientific/controller/error/UncaughtErrorControllor.java
  33. 157
    0
      src/main/java/com/cirle/scientific/controller/index/IndexController.java
  34. 74
    0
      src/main/java/com/cirle/scientific/controller/index/PcIndexController.java
  35. 33
    0
      src/main/java/com/cirle/scientific/controller/index/RootIndexController.java
  36. 64
    0
      src/main/java/com/cirle/scientific/controller/live/CounterController.java
  37. 469
    0
      src/main/java/com/cirle/scientific/controller/live/LiveController.java
  38. 26
    0
      src/main/java/com/cirle/scientific/controller/live/resp/LiveUserinfoResp.java
  39. 780
    0
      src/main/java/com/cirle/scientific/controller/login/LoginController.java
  40. 315
    0
      src/main/java/com/cirle/scientific/controller/meeting/MeetingController.java
  41. 64
    0
      src/main/java/com/cirle/scientific/controller/pay/PayCallbackController.java
  42. 204
    0
      src/main/java/com/cirle/scientific/controller/pay/PayController.java
  43. 399
    0
      src/main/java/com/cirle/scientific/controller/pay/WeixinController.java
  44. 77
    0
      src/main/java/com/cirle/scientific/controller/popupWindow/PopuWIndowController.java
  45. 34
    0
      src/main/java/com/cirle/scientific/controller/questionnaireSurvey/questionnaireSurveyController.java
  46. 163
    0
      src/main/java/com/cirle/scientific/controller/register/RegisterController.java
  47. 120
    0
      src/main/java/com/cirle/scientific/controller/signatrue/SignatrueDetailController.java
  48. 51
    0
      src/main/java/com/cirle/scientific/controller/sys/SysController.java
  49. 1222
    0
      src/main/java/com/cirle/scientific/controller/user/UserController.java
  50. 117
    0
      src/main/java/com/cirle/scientific/controller/view/ViewController.java
  51. 24
    0
      src/main/java/com/cirle/scientific/dao/CollectionDao.java
  52. 14
    0
      src/main/java/com/cirle/scientific/dao/DictDao.java
  53. 16
    0
      src/main/java/com/cirle/scientific/dao/DictDetailDao.java
  54. 51
    0
      src/main/java/com/cirle/scientific/dao/MemberDao.java
  55. 58
    0
      src/main/java/com/cirle/scientific/dao/OrderDao.java
  56. 32
    0
      src/main/java/com/cirle/scientific/dao/QkjArticleDao.java
  57. 23
    0
      src/main/java/com/cirle/scientific/dao/QkjAuditingDao.java
  58. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjBrandProductDao.java
  59. 20
    0
      src/main/java/com/cirle/scientific/dao/QkjBrandProductDetailDao.java
  60. 24
    0
      src/main/java/com/cirle/scientific/dao/QkjCatalogsDao.java
  61. 29
    0
      src/main/java/com/cirle/scientific/dao/QkjCatalogsDetailDao.java
  62. 23
    0
      src/main/java/com/cirle/scientific/dao/QkjCertificatePhysiciansDao.java
  63. 23
    0
      src/main/java/com/cirle/scientific/dao/QkjColumnistDao.java
  64. 25
    0
      src/main/java/com/cirle/scientific/dao/QkjColumnistDetailDao.java
  65. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjCommunityDao.java
  66. 43
    0
      src/main/java/com/cirle/scientific/dao/QkjConferenceDao.java
  67. 19
    0
      src/main/java/com/cirle/scientific/dao/QkjConferenceMenuDao.java
  68. 20
    0
      src/main/java/com/cirle/scientific/dao/QkjConferencePeopelDao.java
  69. 34
    0
      src/main/java/com/cirle/scientific/dao/QkjConferenceRecordDao.java
  70. 45
    0
      src/main/java/com/cirle/scientific/dao/QkjCourseWareDao.java
  71. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjExaminationDetailDao.java
  72. 22
    0
      src/main/java/com/cirle/scientific/dao/QkjIntegralDetailDao.java
  73. 101
    0
      src/main/java/com/cirle/scientific/dao/QkjIntegralGoodsDao.java
  74. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjLiveCommentsDao.java
  75. 96
    0
      src/main/java/com/cirle/scientific/dao/QkjLiveDao.java
  76. 23
    0
      src/main/java/com/cirle/scientific/dao/QkjLiveRemindDao.java
  77. 19
    0
      src/main/java/com/cirle/scientific/dao/QkjLiveSeriesDao.java
  78. 22
    0
      src/main/java/com/cirle/scientific/dao/QkjMemberDorecDao.java
  79. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjMemberOpenidDao.java
  80. 16
    0
      src/main/java/com/cirle/scientific/dao/QkjMemberPersonalAuthDao.java
  81. 19
    0
      src/main/java/com/cirle/scientific/dao/QkjMemberTaskDao.java
  82. 29
    0
      src/main/java/com/cirle/scientific/dao/QkjMemberTaskDetailDao.java
  83. 25
    0
      src/main/java/com/cirle/scientific/dao/QkjMemberTaskInfoDao.java
  84. 25
    0
      src/main/java/com/cirle/scientific/dao/QkjPhotoWallDao.java
  85. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjPositonsDao.java
  86. 17
    0
      src/main/java/com/cirle/scientific/dao/QkjPurchasedRecordsDao.java
  87. 32
    0
      src/main/java/com/cirle/scientific/dao/QkjQuestionAnswerDao.java
  88. 20
    0
      src/main/java/com/cirle/scientific/dao/QkjQuestionDetailDao.java
  89. 38
    0
      src/main/java/com/cirle/scientific/dao/QkjRecommendDao.java
  90. 22
    0
      src/main/java/com/cirle/scientific/dao/QkjShareDao.java
  91. 21
    0
      src/main/java/com/cirle/scientific/dao/QkjTagsDao.java
  92. 14
    0
      src/main/java/com/cirle/scientific/dao/QkjTagsDetailDao.java
  93. 15
    0
      src/main/java/com/cirle/scientific/dao/QkjTqcourseCommentsDao.java
  94. 20
    0
      src/main/java/com/cirle/scientific/dao/QkjTqcourseCourseDao.java
  95. 71
    0
      src/main/java/com/cirle/scientific/dao/QkjTqcourseDao.java
  96. 31
    0
      src/main/java/com/cirle/scientific/dao/QkjVedioPlayRecordDao.java
  97. 27
    0
      src/main/java/com/cirle/scientific/dao/QkjVedioPlayRecordLogDao.java
  98. 26
    0
      src/main/java/com/cirle/scientific/dao/QkjVideoPlayLogDao.java
  99. 8
    0
      src/main/java/com/cirle/scientific/dao/QkjVodinfoDao.java
  100. 0
    0
      src/main/java/com/cirle/scientific/dao/QkjXySiginDao.java

+ 5
- 0
.gitignore View File

@@ -0,0 +1,5 @@
1
+/.idea/
2
+/target/
3
+/scientific-cirle.iml
4
+.logback-spring.xml
5
+/data/log/

+ 308
- 0
pom.xml View File

@@ -0,0 +1,308 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5
+    <packaging>jar</packaging>
6
+    <parent>
7
+        <groupId>org.springframework.boot</groupId>
8
+        <artifactId>spring-boot-starter-parent</artifactId>
9
+        <version>2.1.7.RELEASE</version>
10
+    </parent>
11
+    <groupId>com.cirle</groupId>
12
+    <artifactId>scientific-cirle</artifactId>
13
+    <version>0.0.1-SNAPSHOT</version>
14
+    <name>scientific-cirle</name>
15
+    <description>全科界项目</description>
16
+    <properties>
17
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
19
+        <java.version>1.8</java.version>
20
+        <lombok.version>1.18.2</lombok.version>
21
+        <ehcache.version>2.10.5</ehcache.version>
22
+        <mysql.connector.version>8.0.13</mysql.connector.version>
23
+        <jsoup.version>1.11.3</jsoup.version>
24
+        <!--excel工具框架版本:component.excel-->
25
+        <poi.version>4.0.0</poi.version>
26
+        <!--jwt处理框架版本:component.jwt-->
27
+        <jwt.version>3.4.0</jwt.version>
28
+        <!--swagger2接口文档版本:component.jwt-->
29
+        <swagger.version>2.9.2</swagger.version>
30
+        <!--swagger-knife4j接口文档页面:component.jwt-->
31
+        <swagger.knife4j.version>2.0.1</swagger.knife4j.version>
32
+        <commons.beanutils.version>1.8.0</commons.beanutils.version>
33
+        <commons-collections.version>3.2.2</commons-collections.version>
34
+        <aliyun-sdk-oss.version>3.5.0</aliyun-sdk-oss.version>
35
+        <commons-fileupload.version>1.3.1</commons-fileupload.version>
36
+        <jackson.version>2.12.3</jackson.version>
37
+        <bcprov-jdk16.version>1.46</bcprov-jdk16.version>
38
+        <codec.version>1.8</codec.version>
39
+        <oshi-json.version>3.6.1</oshi-json.version>
40
+        <commons-lang3.version>3.8</commons-lang3.version>
41
+        <thymeleaf-extras-springsecurity4.version>3.0.2.RELEASE</thymeleaf-extras-springsecurity4.version>
42
+        <skipTests>true</skipTests>
43
+        <tea-openapi.version>0.2.2</tea-openapi.version>
44
+        <dysmsapi2017052.version>2.0.9</dysmsapi2017052.version>
45
+        <weixin.version>0.0.3</weixin.version>
46
+        <aliyun-sdk-opensearch.version>3.1.3</aliyun-sdk-opensearch.version>
47
+    </properties>
48
+
49
+    <dependencies>
50
+        <dependency>
51
+            <groupId>org.springframework.boot</groupId>
52
+            <artifactId>spring-boot-starter-web</artifactId>
53
+        </dependency>
54
+        <dependency>
55
+            <groupId>org.springframework.session</groupId>
56
+            <artifactId>spring-session-data-redis</artifactId>
57
+<!--            <version>2.6.3</version>-->
58
+        </dependency>
59
+        <!-- thymeleaf模板 -->
60
+        <dependency>
61
+            <groupId>org.springframework.boot</groupId>
62
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
63
+        </dependency>
64
+        <!--spring data jpa持久层框架-->
65
+        <dependency>
66
+            <groupId>org.springframework.boot</groupId>
67
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
68
+        </dependency>
69
+        <dependency>
70
+            <groupId>org.springframework.boot</groupId>
71
+            <artifactId>spring-boot-configuration-processor</artifactId>
72
+            <optional>true</optional>
73
+        </dependency>
74
+        <dependency>
75
+            <groupId>org.springframework.boot</groupId>
76
+            <artifactId>spring-boot-starter-cache</artifactId>
77
+        </dependency>
78
+
79
+        <dependency>
80
+            <groupId>org.springframework.boot</groupId>
81
+            <artifactId>spring-boot-devtools</artifactId>
82
+            <optional>true</optional>
83
+            <scope>runtime</scope>
84
+        </dependency>
85
+        <dependency>
86
+            <groupId>org.springframework.boot</groupId>
87
+            <artifactId>spring-boot-starter-test</artifactId>
88
+            <scope>test</scope>
89
+        </dependency>
90
+
91
+        <!--mysql连接驱动-->
92
+        <dependency>
93
+            <groupId>mysql</groupId>
94
+            <artifactId>mysql-connector-java</artifactId>
95
+            <version>${mysql.connector.version}</version>
96
+            <scope>runtime</scope>
97
+        </dependency>
98
+
99
+        <!--lombok语法糖-->
100
+        <dependency>
101
+            <groupId>org.projectlombok</groupId>
102
+            <artifactId>lombok</artifactId>
103
+            <version>${lombok.version}</version>
104
+            <optional>true</optional>
105
+        </dependency>
106
+
107
+        <!--html解析工具,处理xss攻击-->
108
+        <dependency>
109
+            <groupId>org.jsoup</groupId>
110
+            <artifactId>jsoup</artifactId>
111
+            <version>${jsoup.version}</version>
112
+        </dependency>
113
+
114
+        <!--swagger2接口文档-->
115
+        <dependency>
116
+            <groupId>io.springfox</groupId>
117
+            <artifactId>springfox-swagger2</artifactId>
118
+            <version>${swagger.version}</version>
119
+        </dependency>
120
+        <dependency>
121
+            <groupId>io.springfox</groupId>
122
+            <artifactId>springfox-swagger-ui</artifactId>
123
+            <version>${swagger.version}</version>
124
+        </dependency>
125
+        <!--knife4j(swagger-bootstrap-ui)接口文档页面-->
126
+        <dependency>
127
+            <groupId>com.github.xiaoymin</groupId>
128
+            <artifactId>knife4j-spring-ui</artifactId>
129
+            <version>${swagger.knife4j.version}</version>
130
+        </dependency>
131
+        <!-- CopyUtil需要用到 -->
132
+        <dependency>
133
+            <groupId>commons-beanutils</groupId>
134
+            <artifactId>commons-beanutils</artifactId>
135
+            <version>${commons.beanutils.version}</version>
136
+        </dependency>
137
+        <dependency>
138
+            <groupId>commons-collections</groupId>
139
+            <artifactId>commons-collections</artifactId>
140
+            <version>${commons-collections.version}</version>
141
+        </dependency>
142
+
143
+        <!--阿里云相关-->
144
+        <dependency>
145
+            <groupId>com.aliyun.oss</groupId>
146
+            <artifactId>aliyun-sdk-oss</artifactId>
147
+            <version>${aliyun-sdk-oss.version}</version>
148
+        </dependency>
149
+        <dependency>
150
+            <groupId>com.aliyun</groupId>
151
+            <artifactId>tea-openapi</artifactId>
152
+            <version>${tea-openapi.version}</version>
153
+        </dependency>
154
+        <dependency>
155
+            <groupId>com.aliyun</groupId>
156
+            <artifactId>dysmsapi20170525</artifactId>
157
+            <version>${dysmsapi2017052.version}</version>
158
+        </dependency>
159
+        <dependency>
160
+            <groupId>com.alibaba</groupId>
161
+            <artifactId>fastjson</artifactId>
162
+            <version>1.2.49</version>
163
+        </dependency>
164
+        <dependency>
165
+            <groupId>com.aliyun.opensearch</groupId>
166
+            <artifactId>aliyun-sdk-opensearch</artifactId>
167
+            <version>${aliyun-sdk-opensearch.version}</version>
168
+        </dependency>
169
+
170
+        <!-- 微信相关 -->
171
+        <dependency>
172
+            <groupId>com.github.wxpay</groupId>
173
+            <artifactId>wxpay-sdk</artifactId>
174
+            <version>${weixin.version}</version>
175
+        </dependency>
176
+
177
+        <!--文件上传相关-->
178
+        <dependency>
179
+            <groupId>commons-fileupload</groupId>
180
+            <artifactId>commons-fileupload</artifactId>
181
+            <version>${commons-fileupload.version}</version>
182
+        </dependency>
183
+        <!-- Jackson Json处理工具包 -->
184
+        <dependency>
185
+            <groupId>com.fasterxml.jackson.core</groupId>
186
+            <artifactId>jackson-databind</artifactId>
187
+            <version>${jackson.version}</version>
188
+        </dependency>
189
+        <dependency>
190
+            <groupId>com.fasterxml.jackson.core</groupId>
191
+            <artifactId>jackson-core</artifactId>
192
+            <version>${jackson.version}</version>
193
+        </dependency>
194
+        <dependency>
195
+            <groupId>com.fasterxml.jackson.core</groupId>
196
+            <artifactId>jackson-annotations</artifactId>
197
+            <version>${jackson.version}</version>
198
+        </dependency>
199
+        <!--提供更多的加密、填充方式-->
200
+        <dependency>
201
+            <groupId>org.bouncycastle</groupId>
202
+            <artifactId>bcprov-jdk16</artifactId>
203
+            <version>${bcprov-jdk16.version}</version>
204
+        </dependency>
205
+        <!-- 引入redis -->
206
+        <dependency>
207
+            <groupId>org.springframework.boot</groupId>
208
+            <artifactId>spring-boot-starter-data-redis</artifactId>
209
+        </dependency>
210
+
211
+        <!-- Base64编码需要  -->
212
+        <dependency>
213
+            <groupId>org.apache.directory.studio</groupId>
214
+            <artifactId>org.apache.commons.codec</artifactId>
215
+            <version>${codec.version}</version>
216
+        </dependency>
217
+
218
+        <dependency>
219
+            <groupId>com.google.code.gson</groupId>
220
+            <artifactId>gson</artifactId>
221
+            <version>2.8.5</version>
222
+        </dependency>
223
+
224
+        <!--https://github.com/oshi/oshi。-->
225
+        <dependency>
226
+            <groupId>com.github.oshi</groupId>
227
+            <artifactId>oshi-json</artifactId>
228
+            <version>${oshi-json.version}</version>
229
+        </dependency>
230
+
231
+        <dependency>
232
+            <groupId>org.springframework.boot</groupId>
233
+            <artifactId>spring-boot-starter-websocket</artifactId>
234
+        </dependency>
235
+
236
+        <dependency>
237
+            <groupId>org.apache.commons</groupId>
238
+            <artifactId>commons-lang3</artifactId>
239
+            <version>${commons-lang3.version}</version>
240
+        </dependency>
241
+
242
+        <!--集成redis-->
243
+        <dependency>
244
+            <groupId>org.springframework.boot</groupId>
245
+            <artifactId>spring-boot-starter-data-redis</artifactId>
246
+        </dependency>
247
+        <dependency>
248
+            <groupId>org.apache.commons</groupId>
249
+            <artifactId>commons-pool2</artifactId>
250
+            <version>2.8.1</version>
251
+        </dependency>
252
+        <dependency>
253
+            <groupId>com.google.zxing</groupId>
254
+            <artifactId>core</artifactId>
255
+            <version>3.3.3</version>
256
+        </dependency>
257
+        <dependency>
258
+            <groupId>cn.hutool</groupId>
259
+            <artifactId>hutool-all</artifactId>
260
+            <version>5.3.4</version>
261
+        </dependency>
262
+    </dependencies>
263
+
264
+    <build>
265
+        <resources>
266
+            <resource>
267
+                <directory>src/main/java</directory><!--java文件的路径-->
268
+                <includes>
269
+                    <include>**/*.*</include>
270
+                </includes>
271
+                 <filtering>false</filtering>
272
+            </resource>
273
+            <resource>
274
+                <directory>src/main/resources</directory><!--资源文件的路径-->
275
+                <includes>
276
+                    <include>**/*.*</include>
277
+                </includes>
278
+                 <filtering>false</filtering>
279
+            </resource>
280
+        </resources>
281
+        <plugins>
282
+            <plugin>
283
+                <groupId>org.springframework.boot</groupId>
284
+                <artifactId>spring-boot-maven-plugin</artifactId>
285
+                <configuration>
286
+                    <fork>true</fork>
287
+                    <addResources>true</addResources>
288
+                </configuration>
289
+                <executions>
290
+                    <execution>
291
+                        <goals>
292
+                            <goal>repackage</goal>
293
+                        </goals>
294
+                    </execution>
295
+                </executions>
296
+            </plugin>
297
+            <plugin>
298
+                <groupId>org.apache.maven.plugins</groupId>
299
+                <artifactId>maven-compiler-plugin</artifactId>
300
+                <configuration>
301
+                    <source>8</source>
302
+                    <target>8</target>
303
+                </configuration>
304
+            </plugin>
305
+        </plugins>
306
+    </build>
307
+
308
+</project>

+ 118
- 0
src/main/java/AutoIncrMember.java View File

@@ -0,0 +1,118 @@
1
+
2
+import java.sql.*;
3
+import java.text.SimpleDateFormat;
4
+import java.util.Date;
5
+import java.util.HashMap;
6
+import java.util.Map;
7
+
8
+public class AutoIncrMember {
9
+
10
+    public static Map<String, Long> totalmap = new HashMap();
11
+    public static void main(String[] args) throws Exception {
12
+
13
+
14
+
15
+
16
+        Class.forName("com.mysql.cj.jdbc.Driver");
17
+        Connection conn = DriverManager.getConnection("jdbc:mysql://bj-cdb-ihmswuq0.sql.tencentcdb.com:59832/qkyxzx?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false","qunke#u03","Qk@mYPw2o2O6+6");
18
+
19
+        while(true){
20
+            SimpleDateFormat format = new SimpleDateFormat("HH:mm");
21
+            String now = format.format(new Date());
22
+            add(now,conn);
23
+
24
+            Thread.sleep(30000);
25
+        }
26
+        //conn.close();
27
+
28
+
29
+    }
30
+
31
+    public void updateparent( Connection conn,String parentid) throws SQLException {
32
+        String sql = "select sum(b.purchased_members) from qkj_live b where b.id in ("+parentid+") and live_status=1";
33
+            Statement stmt = conn.createStatement();
34
+            //6、执行sql
35
+            ResultSet rs = stmt.executeQuery(sql);
36
+            //7、处理结果
37
+            if(rs.next()){
38
+                int count =rs.getInt(1);
39
+                sql = "update    qkj_live  set  purchased_members  =  "+count+" where id=199";
40
+                System.out.println(sql);
41
+                updatesql(sql,conn);
42
+            }
43
+            rs.close();
44
+            //8、释放资源
45
+            stmt.close();
46
+    }
47
+
48
+
49
+    public static void add(String now,Connection conn) throws Exception{
50
+
51
+        String[] times = {"18:00-19:00,60","19:00-19:40,40"};
52
+        String[] lives = {"201:8102"};//,"164:58000"
53
+        realincr(now,conn,times,lives);
54
+    }
55
+
56
+    public static void realincr( String now,Connection conn,String[] times ,String[] lives ) throws Exception{
57
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
58
+        for(String live:lives){
59
+            String liveid = live.split(":")[0];
60
+            Integer count = Integer.parseInt(live.split(":")[1]);
61
+
62
+            for(String time:times){
63
+                String start = time.split(",")[0].split("-")[0];
64
+                String end = time.split(",")[0].split("-")[1];
65
+                if(now.compareTo(start)>=0 &&  now.compareTo(end)<0){
66
+
67
+                }else{
68
+                    System.out.println("no start now="+now+" start="+start+" end="+end);
69
+                    continue;
70
+                }
71
+                long last = (format.parse("2022-07-16 "+end+":00").getTime()-format.parse("2022-07-16 "+start+":00").getTime())/1000;
72
+                String percent = time.split(",")[1];
73
+                int currenttotal = count*Integer.parseInt(percent)/100;
74
+                long incr = currenttotal*30/last;
75
+                long num = getnum(now,start,end,incr);
76
+                System.out.println("liveid="+liveid+" num="+num+" incr="+incr+" currenttotal="+currenttotal+" count="+count);
77
+                if(totalmap.get(liveid)==null){
78
+                    totalmap.put(liveid,num);
79
+                }else{
80
+                    totalmap.put(liveid,totalmap.get(liveid)+num);
81
+                }
82
+                String sql = "update    qkj_live set  purchased_members  =  purchased_members+"+num+" where id = "+liveid+" and live_status=1";
83
+                updatesql(sql,conn);
84
+            }
85
+
86
+
87
+        }
88
+    }
89
+
90
+    public static long getnum(String now,String start,String end,long incr){
91
+
92
+        System.out.print(now+" ");
93
+        if(now.compareTo(start)>=0 &&  now.compareTo(end)<0){
94
+
95
+        }else{
96
+            int random2 =    (int) ((Math.random() *10) ) ;
97
+            incr = random2;
98
+        }
99
+        int random =    (int) ((Math.random() *10+1) +incr) ;
100
+        if(random<0){
101
+            random=0;
102
+        }
103
+        int MAX = 10000;
104
+        if(random>MAX ){
105
+            random = random%MAX;
106
+        }
107
+        return random;
108
+
109
+    }
110
+
111
+
112
+    public static void updatesql(String sql,Connection conn) throws SQLException {
113
+        Statement s = conn.createStatement();
114
+        s.execute(sql);
115
+        s.close();
116
+    }
117
+
118
+}

+ 17
- 0
src/main/java/com/cirle/scientific/ScientificCirleApplication.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+import org.springframework.scheduling.annotation.EnableAsync;
6
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
7
+
8
+@SpringBootApplication
9
+@EnableAsync
10
+@EnableSwagger2
11
+public class ScientificCirleApplication {
12
+
13
+    public static void main(String[] args) {
14
+        SpringApplication.run(ScientificCirleApplication.class, args);
15
+    }
16
+    
17
+}

+ 35
- 0
src/main/java/com/cirle/scientific/component/SpringUtil.java View File

@@ -0,0 +1,35 @@
1
+package com.cirle.scientific.component;
2
+
3
+import com.sun.istack.logging.Logger;
4
+import org.springframework.beans.BeansException;
5
+import org.springframework.context.ApplicationContext;
6
+import org.springframework.context.ApplicationContextAware;
7
+import org.springframework.stereotype.Component;
8
+
9
+/**
10
+ * 获取bean的工具类
11
+ */
12
+@Component
13
+public class SpringUtil implements ApplicationContextAware {
14
+
15
+    private static Logger logger = Logger.getLogger(SpringUtil.class);
16
+    private static ApplicationContext applicationContext;
17
+    @Override
18
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
19
+        SpringUtil.applicationContext = applicationContext;
20
+
21
+    }
22
+
23
+    public ApplicationContext getApplicationContext(){
24
+        return applicationContext;
25
+    }
26
+
27
+    public static Object getBean(String beanName){
28
+        return applicationContext.getBean(beanName);
29
+    }
30
+
31
+    public static <T> T getBean(Class<T> clazz) {
32
+        logger.info("applicationContext======="+applicationContext);
33
+        return (T) applicationContext.getBean(clazz);
34
+    }
35
+}

+ 37
- 0
src/main/java/com/cirle/scientific/config/AsyncConfig.java View File

@@ -0,0 +1,37 @@
1
+package com.cirle.scientific.config;
2
+
3
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
4
+import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
5
+import org.springframework.context.annotation.Configuration;
6
+import org.springframework.scheduling.annotation.AsyncConfigurer;
7
+import org.springframework.scheduling.annotation.EnableAsync;
8
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
9
+
10
+import java.util.concurrent.Executor;
11
+import java.util.concurrent.ThreadPoolExecutor;
12
+
13
+@EnableAsync
14
+@Configuration
15
+public class AsyncConfig implements AsyncConfigurer {
16
+
17
+    @Override
18
+    public Executor getAsyncExecutor() {
19
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
20
+
21
+        executor.setCorePoolSize(5); //核心线程数
22
+        executor.setMaxPoolSize(10);  //最大线程数
23
+        executor.setQueueCapacity(500); //队列大小
24
+        executor.setKeepAliveSeconds(150); //线程最大空闲时间
25
+        executor.setThreadNamePrefix("fsx-Executor-"); //指定用于新创建的线程名称的前缀。
26
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 拒绝策略(一共四种,此处省略)
27
+
28
+        executor.initialize();
29
+        return executor;
30
+    }
31
+
32
+    // 异常处理器:当然你也可以自定义的,这里我就这么简单写了~~~
33
+    @Override
34
+    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
35
+        return new SimpleAsyncUncaughtExceptionHandler();
36
+    }
37
+}

+ 25
- 0
src/main/java/com/cirle/scientific/config/CirleConfigurer.java View File

@@ -0,0 +1,25 @@
1
+package com.cirle.scientific.config;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
6
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7
+
8
+
9
+@Configuration
10
+public class CirleConfigurer implements WebMvcConfigurer {
11
+    @Bean
12
+    public CirleInterceptor getInterceptor(){
13
+        return new CirleInterceptor();
14
+    }
15
+
16
+    @Override
17
+    public void addInterceptors(InterceptorRegistry registry) {
18
+
19
+        /**
20
+         * 自定义拦截器,添加拦截路径和排除拦截路径
21
+         * addPathPatterns():添加需要拦截的路径
22
+         */
23
+        registry.addInterceptor(getInterceptor()).addPathPatterns("/**");
24
+    }
25
+}

+ 192
- 0
src/main/java/com/cirle/scientific/config/CirleInterceptor.java View File

@@ -0,0 +1,192 @@
1
+package com.cirle.scientific.config;
2
+
3
+import com.cirle.scientific.constants.LoginConsts;
4
+import com.cirle.scientific.utils.CookieUtil;
5
+import com.cirle.scientific.utils.StringUtil;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.apache.commons.lang3.StringUtils;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.data.redis.core.StringRedisTemplate;
10
+import org.springframework.stereotype.Component;
11
+import org.springframework.web.servlet.ModelAndView;
12
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
13
+
14
+import javax.servlet.http.Cookie;
15
+import javax.servlet.http.HttpServletRequest;
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.io.UnsupportedEncodingException;
18
+import java.net.URLDecoder;
19
+import java.net.URLEncoder;
20
+import java.util.concurrent.TimeUnit;
21
+
22
+
23
+@Component
24
+@Slf4j
25
+public class CirleInterceptor extends HandlerInterceptorAdapter {
26
+
27
+    @Autowired
28
+    StringRedisTemplate stringRedisTemplate;
29
+
30
+    /*
31
+     * 视图渲染之后的操作
32
+     */
33
+    @Override
34
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3) throws Exception {
35
+
36
+        System.out.println("执行到了afterCompletion方法");
37
+    }
38
+
39
+    /*
40
+     * 处理请求完成后视图渲染之前的处理操作
41
+     * 通过ModelAndView参数改变显示的视图,或发往视图的方法
42
+     */
43
+    @Override
44
+    public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception {
45
+        arg0.setAttribute("memToken",arg0.getParameter("memToken"));
46
+    }
47
+
48
+    /*
49
+     * 进入controller层之前拦截请求
50
+     * 返回值:表示是否将当前的请求拦截下来  false:拦截请求,请求别终止。true:请求不被拦截,继续执行
51
+     * Object obj:表示被拦的请求的目标对象(controller中方法)
52
+     */
53
+    @Override
54
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
55
+        String memToken = getValueByCookie(request,"memToken");
56
+        if(StringUtils.isBlank(memToken)){
57
+            memToken = request.getParameter("memToken");
58
+        }
59
+        log.info("当前访问memToken:"+memToken);
60
+        String memCard = "";
61
+        if (StringUtils.isBlank(memToken)) {
62
+            memCard = request.getParameter("memCard");
63
+            log.info("当前访问memCard :{}", memCard);
64
+        } else {
65
+            Object memCard1 = stringRedisTemplate.opsForValue().get(memToken);
66
+            if(memCard1 != null){
67
+                memCard = memCard1.toString();
68
+                //更新m端redis存的登录状态的有效期
69
+                stringRedisTemplate.expire(memToken,LoginConsts.M_LOGIN_EXPIRE, TimeUnit.MINUTES);
70
+                String loginKeyToM = String.format(LoginConsts.M_LOGIN_USER_KEY, memCard);
71
+                stringRedisTemplate.expire(loginKeyToM, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
72
+                CookieUtil.setMainCookie(response, memToken, memCard, StringUtil.getdomain(request));
73
+                log.info("续上了 memCard:{} memToken:{}", memCard, memToken);
74
+            }else {
75
+                clearCookies(response, StringUtil.getdomain(request), "/", "memToken");
76
+                clearCookies(response, StringUtil.getdomain(request), "/", "memNickname");
77
+                clearCookies(response, StringUtil.getdomain(request), "/", "memHeadImg");
78
+                clearCookies(response, StringUtil.getdomain(request), "/", "bindMobile");
79
+                //clearCookies(response, StringUtil.getdomain(request), "/", "memCard"); 需要判断是否是被顶掉,判断完再删掉
80
+            }
81
+        }
82
+        //memCard = "1fe53103fc6c48cb98ba4fb3586cc307";
83
+
84
+        if(StringUtils.isBlank(memCard)){
85
+            memCard = (String)request.getSession().getAttribute(LoginConsts.PC_LOGIN_SESSION_KEY);
86
+            if(StringUtils.isNotBlank(memCard)){//把账号的有效期续一下
87
+                String loginKey = String.format(LoginConsts.PC_LOGIN_USER_KEY, memCard);
88
+                stringRedisTemplate.expire(loginKey, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
89
+            }
90
+            log.info("preHandle getSession memCard:{}", memCard);
91
+        }
92
+        log.info("preHandle memCard:{}", memCard);
93
+        if (StringUtils.isNotBlank(memCard)) {
94
+            request.setAttribute(LoginConsts.M_MEMCARD_KEY,memCard);
95
+
96
+        }
97
+
98
+        String fromMemCard = request.getParameter("fromMemCard");
99
+        if(StringUtils.isNotBlank(fromMemCard)){
100
+            addValue2Cookie(response, StringUtil.getdomain(request), "/", "fromMemCard", fromMemCard, 3600);
101
+        }
102
+        return true;
103
+    }
104
+
105
+    /**
106
+     * 获取cookie里的值
107
+     *
108
+     * @param request
109
+     * @param key
110
+     * @return 不存在 返回null
111
+     */
112
+    public String getValueByCookie(HttpServletRequest request, String key) {
113
+        String cookievalue = null;
114
+        Cookie[] cookies = request.getCookies();
115
+        if (null != cookies && cookies.length != 0) {
116
+            for (int i = 0; i < cookies.length; i++) {
117
+                Cookie cookie = cookies[i];
118
+                if (cookie.getName().equals(key)) {
119
+                    // String value = cookie.getValue();
120
+                    try {
121
+                        cookievalue = URLDecoder.decode(cookie.getValue(), "UTF-8");
122
+                    } catch (UnsupportedEncodingException e) {
123
+                        e.printStackTrace();
124
+                    }
125
+                    // cookievalue = value;
126
+                    break;
127
+                }
128
+            }
129
+        }
130
+        return cookievalue;
131
+    }
132
+    /**
133
+     * 将值存入cookie
134
+     *
135
+     * @param response
136
+     * @param key
137
+     * @param val
138
+     */
139
+    public void addValue2Cookie(HttpServletResponse response, String domain, String path, String key, String val,
140
+                                int time) {
141
+        if(val == null || "".equals(val)){
142
+            return;
143
+        }
144
+        try {
145
+            val = URLEncoder.encode(val, "UTF-8");
146
+        } catch (UnsupportedEncodingException e) {
147
+            e.printStackTrace();
148
+        }
149
+        response.addHeader("P3P", "CP=CAO PSA OUR");
150
+        Cookie c = new Cookie(key, val);
151
+        c.setDomain(domain);
152
+        c.setMaxAge(time);
153
+        c.setPath(path);
154
+        response.addCookie(c);
155
+    }
156
+
157
+
158
+    /**
159
+     * 清除cookie
160
+     * @param response
161
+     */
162
+    public void clearCookies(HttpServletResponse response, String domain, String path, String key) {
163
+        Cookie c = new Cookie(key, null);
164
+        c.setDomain(domain);
165
+        c.setMaxAge(0);
166
+        c.setPath(path);
167
+        response.addCookie(c);
168
+    }
169
+
170
+    public static void main(String[] args) {
171
+        String tmp = "http://www.qkyxzx.com/";
172
+        String domain = "";
173
+        if(tmp.split(":").length>2){
174
+            domain = tmp.substring(0,tmp.lastIndexOf(":"));
175
+        }else{
176
+            if(tmp.endsWith("/")){
177
+                tmp = tmp.substring(0,tmp.length()-1);
178
+            }
179
+            domain = tmp;
180
+        }
181
+        if(domain.contains("http:")){
182
+            domain = domain.replaceAll("http://","");
183
+        }
184
+        if(domain.contains("https:")){
185
+            domain = domain.replaceAll("https://","");
186
+        }
187
+        if(domain.contains("www")){
188
+            domain = domain.replaceAll("www\\.","");
189
+        }
190
+        System.out.println(domain);
191
+    }
192
+}

+ 104
- 0
src/main/java/com/cirle/scientific/config/OnlineSessionListener.java View File

@@ -0,0 +1,104 @@
1
+package com.cirle.scientific.config;/*
2
+ *24901
3
+ *2022/10/8
4
+ *22:00
5
+ */
6
+
7
+
8
+import com.cirle.scientific.constants.RedisKeyConstants;
9
+import com.cirle.scientific.utils.StringContextUtil;
10
+import com.cirle.scientific.utils.redis.DistributedLockCache;
11
+import com.cirle.scientific.utils.redis.QkLock;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.apache.commons.lang3.StringUtils;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.context.annotation.Configuration;
16
+import org.springframework.data.redis.core.StringRedisTemplate;
17
+import org.springframework.data.redis.core.ValueOperations;
18
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
19
+
20
+import javax.servlet.ServletContextListener;
21
+import javax.servlet.ServletRequestEvent;
22
+import javax.servlet.ServletRequestListener;
23
+import javax.servlet.annotation.WebListener;
24
+import javax.servlet.http.*;
25
+import java.util.Set;
26
+import java.util.concurrent.TimeUnit;
27
+
28
+
29
+@Slf4j
30
+@Configuration
31
+@WebListener
32
+public class OnlineSessionListener implements HttpSessionListener, ServletContextListener,ServletRequestListener {
33
+
34
+
35
+
36
+    private StringRedisTemplate stringRedisTemplate;
37
+
38
+
39
+
40
+    @Override
41
+    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
42
+        int online = 1;
43
+        HttpSession session = httpSessionEvent.getSession();
44
+        QkLock qkLock = new QkLock();
45
+        qkLock.setName("soles "+session.getId());
46
+        qkLock.setValue(session.getId());
47
+        if(stringRedisTemplate == null){
48
+            stringRedisTemplate = StringContextUtil.getBean(StringRedisTemplate.class);
49
+        }
50
+        String onlineNumber = stringRedisTemplate.opsForValue().get(RedisKeyConstants.redisOnlinePerson);
51
+        try {
52
+            boolean b = soleVerify(qkLock , 2);
53
+            if(b){
54
+                if (!StringUtils.isBlank(onlineNumber) && Integer.parseInt(onlineNumber) >= 1) {
55
+                    online = online + Integer.parseInt(onlineNumber);
56
+                }
57
+                stringRedisTemplate.opsForValue().set(RedisKeyConstants.redisOnlinePerson, String.valueOf(online));
58
+                log.info("新增一位在线用户!"+ session.getId() + "在线用户为" + online + "人");
59
+            }else{
60
+                log.info("重复了一位在线用户!"+ session.getId()+ "在线用户为" + online + "人");
61
+            }
62
+        } catch (Exception e) {
63
+            e.printStackTrace();
64
+            log.info("新增在线用户出现异常 e->{}" ,  e);
65
+        }
66
+    }
67
+
68
+
69
+    @Override
70
+    public void sessionDestroyed(HttpSessionEvent se) {
71
+        int online = 1;
72
+        HttpSession session = se.getSession();
73
+        if(stringRedisTemplate == null){
74
+            stringRedisTemplate = StringContextUtil.getBean(StringRedisTemplate.class);
75
+        }
76
+        String onlineNumber = stringRedisTemplate.opsForValue().get(RedisKeyConstants.redisOnlinePerson);
77
+        if(onlineNumber == null || Integer.parseInt(onlineNumber) == 1){
78
+            stringRedisTemplate.opsForValue().set(RedisKeyConstants.redisOnlinePerson, String.valueOf(1));
79
+        }else{
80
+            online = Integer.parseInt(onlineNumber) - online;
81
+            stringRedisTemplate.opsForValue().set(RedisKeyConstants.redisOnlinePerson, String.valueOf(online));
82
+        }
83
+        log.info("一位用户离线"+ session.getId() + "在线用户为" + online + "人");
84
+    }
85
+
86
+    /**
87
+     *
88
+     * @param lock 要锁的key 和 value
89
+     * @param lockExpireTime 保存redis的有效期
90
+     * @return 保存成功返回true 失败false
91
+     */
92
+    public boolean soleVerify(QkLock lock, long lockExpireTime){
93
+        try {
94
+            if (stringRedisTemplate.opsForValue().setIfAbsent(lock.getName(), lock.getValue())) {
95
+                Boolean flag = stringRedisTemplate.expire(lock.getName(), lockExpireTime, TimeUnit.MINUTES);
96
+                return flag;
97
+            }
98
+        } catch (Exception e) {
99
+            e.printStackTrace();
100
+            log.info("锁报错了  e->{}",e);
101
+        }
102
+        return false;
103
+    }
104
+}

+ 57
- 0
src/main/java/com/cirle/scientific/config/RedisSessionConfiguration.java View File

@@ -0,0 +1,57 @@
1
+package com.cirle.scientific.config;
2
+
3
+import io.swagger.annotations.ApiOperation;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.beans.factory.annotation.Value;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.session.data.redis.RedisOperationsSessionRepository;
10
+import org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration;
11
+import org.springframework.session.web.http.CookieHttpSessionIdResolver;
12
+import org.springframework.session.web.http.DefaultCookieSerializer;
13
+import springfox.documentation.builders.ApiInfoBuilder;
14
+import springfox.documentation.builders.PathSelectors;
15
+import springfox.documentation.builders.RequestHandlerSelectors;
16
+import springfox.documentation.service.ApiInfo;
17
+import springfox.documentation.spi.DocumentationType;
18
+import springfox.documentation.spring.web.plugins.Docket;
19
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
20
+
21
+import javax.annotation.PostConstruct;
22
+
23
+
24
+@Configuration
25
+@Slf4j
26
+public class RedisSessionConfiguration extends RedisHttpSessionConfiguration {
27
+
28
+
29
+    @Value("${spring.session.cookieName:JSESSIONID}")
30
+    private String cookieName;
31
+
32
+    @Value("${spring.session.timeout:30}")
33
+    int sessionTimeoutInMinuts;
34
+
35
+    @PostConstruct
36
+    @Override
37
+    public void init() {
38
+        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
39
+        cookieSerializer.setCookieName(cookieName);//sessionId名称
40
+        cookieSerializer.setUseBase64Encoding(false);
41
+        CookieHttpSessionIdResolver cookieHttpSessionIdResolver = new CookieHttpSessionIdResolver();
42
+        cookieHttpSessionIdResolver.setCookieSerializer(cookieSerializer);
43
+        super.setHttpSessionIdResolver(cookieHttpSessionIdResolver);
44
+        super.setCookieSerializer(cookieSerializer);
45
+    }
46
+
47
+    @Autowired
48
+    private RedisOperationsSessionRepository sessionRepository;
49
+    @PostConstruct
50
+    private void afterPropertiesSet() {
51
+        log.info("setting sesion 超时时间 = [{}]分钟",sessionTimeoutInMinuts);
52
+        sessionRepository.setDefaultMaxInactiveInterval(sessionTimeoutInMinuts * 60);
53
+        //sessionRepository.setRedisKeyNamespace(redisnamespace);
54
+
55
+    }
56
+
57
+}

+ 42
- 0
src/main/java/com/cirle/scientific/config/SwaggerConfig.java View File

@@ -0,0 +1,42 @@
1
+package com.cirle.scientific.config;
2
+
3
+import io.swagger.annotations.ApiOperation;
4
+import io.swagger.annotations.Contact;
5
+import org.springframework.context.annotation.Bean;
6
+import org.springframework.context.annotation.Configuration;
7
+import springfox.documentation.builders.ApiInfoBuilder;
8
+import springfox.documentation.builders.ParameterBuilder;
9
+import springfox.documentation.builders.PathSelectors;
10
+import springfox.documentation.builders.RequestHandlerSelectors;
11
+import springfox.documentation.service.ApiInfo;
12
+import springfox.documentation.spi.DocumentationType;
13
+import springfox.documentation.spring.web.plugins.Docket;
14
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
15
+
16
+
17
+@Configuration
18
+@EnableSwagger2
19
+public class SwaggerConfig {
20
+
21
+
22
+    @Bean
23
+    public Docket api() {
24
+        return new Docket(DocumentationType.SWAGGER_2)
25
+                .select()
26
+                .apis(RequestHandlerSelectors.basePackage("com.cirle.scientific.controller"))
27
+                //加了ApiOperation注解的类,才生成接口文档
28
+                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
29
+                .paths(PathSelectors.any())
30
+                .build()
31
+                .apiInfo(apiInfo());
32
+    }
33
+
34
+    private ApiInfo apiInfo() {
35
+        return new ApiInfoBuilder()
36
+                .title("SpringBoot API Doc")
37
+                .description("This is a restful api document of Spring Boot.")
38
+                .version("1.0")
39
+                .build();
40
+    }
41
+
42
+}

+ 14
- 0
src/main/java/com/cirle/scientific/config/WebConfig.java View File

@@ -0,0 +1,14 @@
1
+package com.cirle.scientific.config;
2
+
3
+import org.springframework.stereotype.Component;
4
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
5
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6
+@Component
7
+public class WebConfig implements WebMvcConfigurer {
8
+
9
+    @Override
10
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
11
+        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
12
+    }
13
+
14
+}

+ 14
- 0
src/main/java/com/cirle/scientific/config/WebSocketConfig.java View File

@@ -0,0 +1,14 @@
1
+package com.cirle.scientific.config;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
6
+
7
+
8
+@Configuration
9
+public class WebSocketConfig {
10
+    @Bean
11
+    public ServerEndpointExporter serverEndpointExporter() {
12
+        return new ServerEndpointExporter();
13
+    }
14
+}

+ 95
- 0
src/main/java/com/cirle/scientific/config/redis/RedisConfig.java View File

@@ -0,0 +1,95 @@
1
+package com.cirle.scientific.config.redis;
2
+ 
3
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
4
+import com.fasterxml.jackson.annotation.PropertyAccessor;
5
+import com.fasterxml.jackson.databind.ObjectMapper;
6
+import org.springframework.cache.annotation.CachingConfigurerSupport;
7
+import org.springframework.cache.annotation.EnableCaching;
8
+import org.springframework.context.annotation.Bean;
9
+import org.springframework.context.annotation.Configuration;
10
+import org.springframework.data.redis.connection.RedisConnectionFactory;
11
+import org.springframework.data.redis.core.*;
12
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
13
+import org.springframework.data.redis.serializer.StringRedisSerializer;
14
+ 
15
+/**
16
+ * redis配置类
17
+ */
18
+@Configuration
19
+@EnableCaching //开启注解
20
+public class RedisConfig extends CachingConfigurerSupport {
21
+ 
22
+    /**
23
+     * retemplate相关配置
24
+     */
25
+    @Bean
26
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
27
+ 
28
+        RedisTemplate<String, Object> template = new RedisTemplate<>();
29
+        // 配置连接工厂
30
+        template.setConnectionFactory(factory);
31
+ 
32
+        //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
33
+        Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
34
+ 
35
+        ObjectMapper om = new ObjectMapper();
36
+        // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
37
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
38
+        // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
39
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
40
+        jacksonSeial.setObjectMapper(om);
41
+ 
42
+        // 值采用json序列化
43
+        template.setValueSerializer(jacksonSeial);
44
+        //使用StringRedisSerializer来序列化和反序列化redis的key值
45
+        template.setKeySerializer(new StringRedisSerializer());
46
+ 
47
+        // 设置hash key 和value序列化模式
48
+        template.setHashKeySerializer(new StringRedisSerializer());
49
+        template.setHashValueSerializer(jacksonSeial);
50
+        template.afterPropertiesSet();
51
+ 
52
+        return template;
53
+    }
54
+ 
55
+    /**
56
+     * 对hash类型的数据操作
57
+     */
58
+    @Bean
59
+    public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
60
+        return redisTemplate.opsForHash();
61
+    }
62
+ 
63
+    /**
64
+     * 对redis字符串类型数据操作
65
+     */
66
+    @Bean
67
+    public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
68
+        return redisTemplate.opsForValue();
69
+    }
70
+ 
71
+    /**
72
+     * 对链表类型的数据操作
73
+     */
74
+    @Bean
75
+    public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
76
+        return redisTemplate.opsForList();
77
+    }
78
+ 
79
+    /**
80
+     * 对无序集合类型的数据操作
81
+     */
82
+    @Bean
83
+    public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
84
+        return redisTemplate.opsForSet();
85
+    }
86
+ 
87
+    /**
88
+     * 对有序集合类型的数据操作
89
+     */
90
+    @Bean
91
+    public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
92
+        return redisTemplate.opsForZSet();
93
+    }
94
+ 
95
+}

+ 17
- 0
src/main/java/com/cirle/scientific/constants/CheckWindowIdTypeConsts.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.constants;
2
+
3
+/**
4
+ * 弹窗的页面的类型
5
+ */
6
+public class CheckWindowIdTypeConsts {
7
+
8
+
9
+    //直播页面请求
10
+    public static final int ID_TYPE_LIVE = 1;
11
+    //品牌页面请求
12
+    public static final int ID_TYPE_BRAND = 2;
13
+    //课程页面请求
14
+    public static final int ID_TYPE_COURSE = 3;
15
+    //会议页面请求
16
+    public static final int ID_TYPE_MEETING = 4;
17
+}

+ 12
- 0
src/main/java/com/cirle/scientific/constants/CourseWareConsts.java View File

@@ -0,0 +1,12 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class CourseWareConsts {
4
+
5
+    /**
6
+     *  课件上传默认封面图
7
+     */
8
+    public final static String DEFAULT_PPT = "http://files.qkyxzx.com/html5/ppt.png";
9
+    public final static String DEFAULT_WORD = "http://files.qkyxzx.com/html5/word.png";
10
+    public final static String DEFAULT_PDF = "http://files.qkyxzx.com/html5/pdf.png";
11
+    public final static String DEFAULT_EXCEL = "http://files.qkyxzx.com/html5/excel.png";
12
+}

+ 11
- 0
src/main/java/com/cirle/scientific/constants/DictConsts.java View File

@@ -0,0 +1,11 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class DictConsts {
4
+
5
+    /**
6
+     *  字典项的key
7
+     */
8
+
9
+    //品牌专区的详情页的课件上传的图标的tital
10
+    public final static String BRAND_PRODUCT_TITLE_KEY = "brand_product_title";
11
+}

+ 67
- 0
src/main/java/com/cirle/scientific/constants/LoginConsts.java View File

@@ -0,0 +1,67 @@
1
+package com.cirle.scientific.constants;
2
+
3
+import java.util.concurrent.TimeUnit;
4
+
5
+/**
6
+ * 登录相关
7
+ */
8
+public class LoginConsts {
9
+
10
+    //redis
11
+    /**
12
+     * pc登录后 把用户信息和session的对应关系 放进redis
13
+     */
14
+    public final static String PC_LOGIN_USER_KEY = "pc_login_user_%s";
15
+
16
+    /**
17
+     * m登录后 把用户信息和token的对应关系 放进redis
18
+     */
19
+    public final static String M_LOGIN_USER_KEY = "m_login_user_%s";
20
+
21
+
22
+
23
+
24
+    //session或者request
25
+    /**
26
+     * pc登录后 把用户id放进session里面
27
+     */
28
+    public final static String PC_LOGIN_SESSION_KEY = "UserCard";
29
+
30
+    /**
31
+     * m端从cookie解析的memcard放入request
32
+     */
33
+    public final static String M_MEMCARD_KEY = "memCard";
34
+
35
+    /**
36
+     * m端登录后存在cookie里的值的key
37
+     */
38
+    public final static String M_COOKIE_MEMCARD_KEY = "memCard";
39
+
40
+
41
+
42
+
43
+    /**
44
+     * m端登录有效期:数值 web的有效期在配置文件里改
45
+     */
46
+    public final static int M_LOGIN_EXPIRE = 30;
47
+
48
+    /**
49
+     * m端登录有效期:单位
50
+     */
51
+    public final static TimeUnit UNIT = TimeUnit.MINUTES;
52
+
53
+
54
+    /**
55
+     * m端cookie 有效期 :秒
56
+     */
57
+    public final static int M_LOGIN_COOKIE_EXPIRE = 60*30;
58
+
59
+    /**
60
+     * m端或者pc端被顶掉的标志
61
+     */
62
+    public final static String M_OR_PC_LOG_REPLACE_KEY = "replace_user_%s";
63
+
64
+
65
+
66
+
67
+}

+ 9
- 0
src/main/java/com/cirle/scientific/constants/PlayRecordLogConstants.java View File

@@ -0,0 +1,9 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class PlayRecordLogConstants {
4
+
5
+    /**
6
+     * 增加观看记录的固定时间间隔 毫秒
7
+     */
8
+    public final static Integer TIME_GAP = 30000;
9
+}

+ 16
- 0
src/main/java/com/cirle/scientific/constants/RedisKeyConstants.java View File

@@ -0,0 +1,16 @@
1
+package com.cirle.scientific.constants;/*
2
+ *24901
3
+ *2022/10/10
4
+ *14:47
5
+ */
6
+
7
+/**
8
+ * @author 24901
9
+ */
10
+public class RedisKeyConstants {
11
+
12
+    /**
13
+     * 获取redis中的在线人数key
14
+     */
15
+    public final static String redisOnlinePerson ="OnlineNumber1";
16
+}

+ 18
- 0
src/main/java/com/cirle/scientific/constants/SaveYsAndSmConsts.java View File

@@ -0,0 +1,18 @@
1
+package com.cirle.scientific.constants;
2
+
3
+/**
4
+ * 认证类型常量需要进行的认证的类型 如果没有则不需要 1:以前的医师认证 2:以前的实名认证 3:欧佳龙医师认证 4:欧佳龙实名 5:不需要
5
+ */
6
+public class SaveYsAndSmConsts {
7
+
8
+
9
+    //1:以前的医师认证
10
+    public static final int ATTEST_TYPE_A = 1;
11
+
12
+    //2:以前的实名认证
13
+    public static final int ATTEST_TYPE_B = 2;
14
+    //3:欧佳龙医师认证
15
+    public static final int ATTEST_TYPE_C = 3;
16
+    //4.4:欧佳龙实名
17
+    public static final int ATTEST_TYPE_D = 4;
18
+}

+ 9
- 0
src/main/java/com/cirle/scientific/constants/ServerConstants.java View File

@@ -0,0 +1,9 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class ServerConstants {
4
+
5
+    /**
6
+     * 首次登陆送200积分
7
+     */
8
+    public final static Integer IRST_LOGIN_TASK = 29;
9
+}

+ 11
- 0
src/main/java/com/cirle/scientific/constants/ShareConsts.java View File

@@ -0,0 +1,11 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class ShareConsts {
4
+
5
+    /**
6
+     *  分享表活动类型常量
7
+     */
8
+
9
+    //直播
10
+    public final static Integer obj_type_live = 2;
11
+}

+ 19
- 0
src/main/java/com/cirle/scientific/constants/StatusConsts.java View File

@@ -0,0 +1,19 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class StatusConsts {
4
+
5
+    /**
6
+     *  审核状态:1:未审核 2:通过 3:拒绝
7
+     */
8
+
9
+    //未审核
10
+    public final static Integer auditingStatus_no_auditing = 1;
11
+
12
+    //通过
13
+    public final static Integer auditingStatus_adopt_auditing = 2;
14
+
15
+    //拒绝
16
+    public final static Integer auditingStatus_refuse_auditing = 3;
17
+
18
+
19
+}

+ 22
- 0
src/main/java/com/cirle/scientific/constants/TaskConsts.java View File

@@ -0,0 +1,22 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class TaskConsts {
4
+
5
+
6
+    //积分任务ID常数
7
+    /**
8
+     * 首次登录
9
+     */
10
+    public final static Integer FIRST_LOGIN_TASK = 29;
11
+
12
+    /**
13
+     * 分享的直播被点击一次
14
+     */
15
+    public final static Integer SHARE_TASK = 30;
16
+
17
+    //实名认证增加积分数量
18
+    public final static Integer TASK_22_POINTS = 200;
19
+
20
+    //医师认证增加积分数量
21
+    public final static Integer TASK_25_POINTS = 500;
22
+}

+ 12
- 0
src/main/java/com/cirle/scientific/constants/UserInfoConsts.java View File

@@ -0,0 +1,12 @@
1
+package com.cirle.scientific.constants;
2
+
3
+public class UserInfoConsts {
4
+
5
+
6
+    //用户信息常用参数
7
+
8
+    /**
9
+     * 用户默认头像
10
+     */
11
+    public final static String MEM_HEADIMG = "https://files.qkyxzx.com/html5/mem_headimg_default.png";
12
+}

+ 20
- 0
src/main/java/com/cirle/scientific/constants/WeixinConsts.java View File

@@ -0,0 +1,20 @@
1
+package com.cirle.scientific.constants;
2
+
3
+/**
4
+ *  微信相关的常量
5
+ */
6
+public class WeixinConsts {
7
+
8
+    /**
9
+     * 微信服务号- AppID(应用ID)-测试的应用ID
10
+     * 测试的:wxc931944ad7df2918
11
+     */
12
+    public final static String appId = "wxac5d392b940d1f6f";
13
+    /**
14
+     * 微信服务号-AppSecret(应用密钥)
15
+     *
16
+     * 测试的:107bb13d38ad3849a557d29fa2f5daee
17
+     */
18
+    public static String appSecret = "9a8e8a0f1500f3e2e2e44fa78f20cf1f";
19
+
20
+}

+ 73
- 0
src/main/java/com/cirle/scientific/controller/brandProduct/BrandProductController.java View File

@@ -0,0 +1,73 @@
1
+package com.cirle.scientific.controller.brandProduct;
2
+
3
+
4
+import com.cirle.scientific.pojo.Result;
5
+import com.cirle.scientific.service.BrandProductService;
6
+import com.cirle.scientific.utils.DeviceUtil;
7
+import io.swagger.annotations.Api;
8
+import io.swagger.annotations.ApiOperation;
9
+import io.swagger.annotations.ApiParam;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Controller;
12
+import org.springframework.web.bind.annotation.*;
13
+
14
+import javax.servlet.http.HttpServletRequest;
15
+
16
+@Controller
17
+@RequestMapping("/brand")
18
+@Api("品牌专区相关接口")
19
+public class BrandProductController {
20
+
21
+    @Autowired
22
+    private BrandProductService brandProductService;
23
+
24
+    @GetMapping("/detail")
25
+    @ApiOperation("跳转详情页")
26
+    public String detail(
27
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
28
+            @RequestParam(value = "productId") Long productId,
29
+            HttpServletRequest request
30
+    ) {
31
+        request.setAttribute("productId", productId);
32
+        boolean isM = DeviceUtil.isMobileDevice(request);
33
+        if (isM) {
34
+            return "html5/prefecture/prefecture";
35
+        } else {
36
+            return "web/brand/brand";
37
+        }
38
+//
39
+//        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
40
+//            return "html5/prefecture/prefecture";
41
+//        } else if (StringUtils.isNotBlank(from) && from.equals("web")) {
42
+//            return "web/brand/brand";
43
+//        } else {
44
+//            return "";
45
+//        }
46
+    }
47
+    @GetMapping("/upload")
48
+    @ApiOperation("跳转课件上传页")
49
+    public String upload(
50
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
51
+            @RequestParam(value = "productId") Long productId,
52
+            HttpServletRequest request
53
+    ) {
54
+        request.setAttribute("productId", productId);
55
+        boolean isM = DeviceUtil.isMobileDevice(request);
56
+        if (isM) {
57
+            return "html5/prefecture/upload";
58
+        } else {
59
+            return "web/brand/upload";
60
+        }
61
+    }
62
+
63
+    @PostMapping("/getDetailData")
64
+    @ApiOperation("详情接口数据")
65
+    @ResponseBody
66
+    public Result getDetailData(
67
+            @RequestParam(value = "productId") Long productId
68
+    ) {
69
+        return brandProductService.getDetailData(productId);
70
+
71
+    }
72
+
73
+}

+ 235
- 0
src/main/java/com/cirle/scientific/controller/course/CourseController.java View File

@@ -0,0 +1,235 @@
1
+package com.cirle.scientific.controller.course;
2
+
3
+
4
+import com.cirle.scientific.constants.LoginConsts;
5
+import com.cirle.scientific.controller.index.RootIndexController;
6
+import com.cirle.scientific.dto.QkjRecommendDTO;
7
+import com.cirle.scientific.dto.QkjTqcourseCourseDto;
8
+import com.cirle.scientific.po.QkjCatalogs;
9
+import com.cirle.scientific.po.QkjTqcourse;
10
+import com.cirle.scientific.pojo.BizCodeEnum;
11
+import com.cirle.scientific.pojo.Result;
12
+import com.cirle.scientific.service.CommonService;
13
+import com.cirle.scientific.service.CourseService;
14
+import com.cirle.scientific.service.RecommendService;
15
+import com.cirle.scientific.utils.DeviceUtil;
16
+import com.cirle.scientific.utils.IpUtil;
17
+import com.cirle.scientific.utils.LoginUtil;
18
+import com.cirle.scientific.utils.UserLoginUtil;
19
+import io.swagger.annotations.Api;
20
+import io.swagger.annotations.ApiOperation;
21
+import io.swagger.annotations.ApiParam;
22
+import org.apache.commons.lang3.StringUtils;
23
+import org.springframework.beans.factory.annotation.Autowired;
24
+import org.springframework.data.redis.core.StringRedisTemplate;
25
+import org.springframework.stereotype.Controller;
26
+import org.springframework.ui.Model;
27
+import org.springframework.web.bind.annotation.*;
28
+
29
+import javax.servlet.http.HttpServletRequest;
30
+import javax.servlet.http.HttpServletResponse;
31
+import java.util.List;
32
+
33
+@Controller
34
+@RequestMapping("/course")
35
+@Api("精品课相关接口")
36
+public class CourseController {
37
+
38
+
39
+    @Autowired
40
+    CourseService courseService;
41
+    @Autowired
42
+    CommonService commonService;
43
+    @Autowired
44
+    RecommendService recommendService;
45
+
46
+    @Autowired
47
+    LoginUtil loginUtil;
48
+
49
+
50
+    @GetMapping("/index")
51
+    @ApiOperation(value = "去往精品课首页")
52
+    public String courseIndex(@ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from) {
53
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
54
+            return "html5/course/course-index";
55
+        } else {
56
+            return "web/course/course-index";
57
+        }
58
+    }
59
+
60
+    @GetMapping("/courseDetails")
61
+    @ApiOperation(value = "去往精品课详情页")
62
+    public String courseDetails(
63
+            HttpServletRequest request,
64
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
65
+            @ApiParam(name = "id", value = "专区id") @RequestParam(name = "id", required = true) Integer id, Model model
66
+    ) {
67
+        String refererUrl = request.getHeader("Referer");
68
+        if(refererUrl!=null && refererUrl.contains("login")){
69
+            model.addAttribute("fromlogin","1");
70
+        }else{
71
+            model.addAttribute("fromlogin","0");
72
+        }
73
+        request.setAttribute("id", id);
74
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
75
+            QkjTqcourse qkjTqcourse = courseService.findById(id);
76
+            if (qkjTqcourse.getZq() == 2) {
77
+                //专区
78
+                return "html5/course/course-prefecture-list";
79
+            } else {
80
+                //普通课程
81
+                return "html5/course/course-details";
82
+            }
83
+
84
+        } else {
85
+            return "web/course/course-details";
86
+        }
87
+    }
88
+
89
+
90
+    @GetMapping("/coursePrefectureList")
91
+    @ApiOperation(value = "去往精品课专区列表页")
92
+    public String coursePrefectureList(
93
+            HttpServletRequest request,
94
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
95
+            @ApiParam(name = "id", value = "专区id") @RequestParam(name = "id", required = true) Integer id
96
+    ) {
97
+        request.setAttribute("id", id);
98
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
99
+            return "html5/course/course-prefecture-list";
100
+        } else {
101
+            return "web/course/course-prefecture-list";
102
+        }
103
+    }
104
+
105
+    @PostMapping("/getIndexData")
106
+    @ResponseBody
107
+    @ApiOperation(value = "课程数据接口")
108
+    public Result getIndexData(HttpServletRequest request,
109
+            Integer start, Integer size, Integer cataId, Integer fId, String sortBy,String from,
110
+            @ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(name = "memCard", required = false) String memCard
111
+    ) {
112
+        if (request.getSession().getAttribute("UserCard") != null) {
113
+            memCard = (String) request.getSession().getAttribute("UserCard");
114
+        }
115
+        boolean isPC=DeviceUtil.isMobileDevice(request);
116
+        return courseService.getIndexData(cataId, fId, start, size, memCard, sortBy, from,isPC);
117
+    }
118
+
119
+
120
+    @PostMapping("/getCataList")
121
+    @ResponseBody
122
+    @ApiOperation(value = "课程首页获取分类")
123
+    public Result<List<QkjCatalogs>> getCataList(Integer fId, Integer type) {
124
+        return Result.success(commonService.getCatalogsByFuId(fId, type));
125
+    }
126
+
127
+    @PostMapping("/getCataListForThreeLevel")
128
+    @ResponseBody
129
+    @ApiOperation(value = "课程首页获取分类")
130
+    public Result<List<QkjCatalogs>> getCataListForTreeLevel(Integer fId, Integer type) {
131
+        return Result.success(commonService.getCatalogsByFuIdForThreeLevel(fId, type));
132
+    }
133
+
134
+    @PostMapping("/getCataListForCourseware")
135
+    @ResponseBody
136
+    @ApiOperation(value = "课程首页获取分类")
137
+    public Result<List<QkjCatalogs>> getCataListForCourseware(Integer fId, Integer type) {
138
+        return Result.success(commonService.getCatalogsByFuIdForCourseware(fId, type));
139
+    }
140
+
141
+    @PostMapping("/addVideoPlayRecorde")
142
+    @ResponseBody
143
+    @ApiOperation(value = "保存学习记录")
144
+    public Result addVideoPlayRecorde(
145
+            HttpServletRequest request,
146
+            HttpServletResponse response,
147
+            @ApiParam(name = "memCard", value = "memCard") @RequestAttribute(value = "memCard", required = false) String memCard,
148
+            @ApiParam(name = "objType", value = "课程类型 1-精品课子课时  2-专栏子课时  3-直播  4.知识点  5.精品课背书 6.专栏背书") @RequestParam(name = "objType") int objType,
149
+            @ApiParam(name = "objId", value = "课程id") @RequestParam(name = "objId") int objId,
150
+            @ApiParam(name = "playTime", value = "视频播放截止时间(毫秒)") @RequestParam(name = "playTime") int playTime,
151
+            @ApiParam(name = "totalLearnTime", value = "学习时长(毫秒)") @RequestParam(name = "totalLearnTime") int totalLearnTime
152
+    ) {
153
+
154
+        boolean replace = loginUtil.isReplace(request, response, memCard);
155
+        if(replace){
156
+            return Result.failed(BizCodeEnum.NO_LOGIN_REPLACE);
157
+        }
158
+        String ipAddr = IpUtil.getIpAddr(request);
159
+        return Result.success(courseService.addVideoPlayRecorde(memCard, objType, objId, playTime, totalLearnTime, ipAddr));
160
+    }
161
+
162
+    @PostMapping("/saveplaylog")
163
+    @ResponseBody
164
+    @ApiOperation(value = "保存视频播放记录")
165
+    public Result saveplaylog(HttpServletRequest request,
166
+                                      @ApiParam(name = "memCard", value = "memCard") @RequestAttribute(value = "memCard", required = false) String memCard,
167
+                                      @ApiParam(name = "liveId", value = "直播id") @RequestParam(name = "liveId") int liveId,
168
+                                      @ApiParam(name = "learnTime", value = "学习时长(秒)") @RequestParam(name = "learnTime") int learnTime
169
+    ) {
170
+        if (request.getSession().getAttribute("UserCard") != null) {
171
+            memCard = (String) request.getSession().getAttribute("UserCard");
172
+        }
173
+        return Result.success(courseService.saveplaylog(memCard, liveId, learnTime));
174
+    }
175
+
176
+    @PostMapping("/getAdInfo")
177
+    @ResponseBody
178
+    @ApiOperation(value = "课程首页获取广告位")
179
+    public Result<List<QkjRecommendDTO>> getAdInfo(HttpServletRequest request) {
180
+        // 默认展示pc端内容
181
+        Integer status = 3;
182
+        if(DeviceUtil.isMobileDevice(request)) {
183
+            status = 2;
184
+        }
185
+        List<QkjRecommendDTO> recmdTop = recommendService.findByPosIdLimit(3L, status, 1, 10);
186
+        return Result.success(recmdTop);
187
+    }
188
+
189
+    @PostMapping("/getAdInfoNew")
190
+    @ResponseBody
191
+    @ApiOperation(value = "课程首页获取广告位")
192
+    public Result<List<QkjRecommendDTO>> getAdInfoNew(
193
+            @RequestParam(name = "id", required = true) Long id
194
+    ) {
195
+        QkjTqcourse byId = courseService.findById(id.intValue());
196
+        List<QkjRecommendDTO> recmdTop = recommendService.findByPostTypeAndObjId(1, byId.getId().intValue(), 1, 100);
197
+        return Result.success(recmdTop);
198
+    }
199
+
200
+    @PostMapping("/findTqCourseCourseInfo")
201
+    @ResponseBody
202
+    @ApiOperation(value = "获取子课时详情")
203
+    public Result<QkjTqcourseCourseDto> findTqCourseCourseInfo(@RequestParam(name = "id", required = true) Long id) {
204
+        return courseService.findTqCourseCourseInfo(id);
205
+    }
206
+
207
+
208
+    @PostMapping("/saveCommon")
209
+    @ResponseBody
210
+    @ApiOperation(value = "保存用户留言")
211
+    public Result saveCommon(HttpServletRequest request,
212
+            @ApiParam(name = "memCard", value = "memCard") @RequestAttribute(value = "memCard", required = false) String memCard,
213
+            @ApiParam(name = "content", value = "content") @RequestParam(value = "content", required = false) String content,
214
+            @RequestParam(name = "id", required = true) Long id
215
+    ) {
216
+        if (request.getSession().getAttribute("UserCard") != null) {
217
+            memCard = (String) request.getSession().getAttribute("UserCard");
218
+        }
219
+        return courseService.saveCommon(id, memCard, content);
220
+    }
221
+    @GetMapping("/checkCode")
222
+    @ResponseBody
223
+    @ApiOperation(value = "校验提取码")
224
+    public Result checkCode(HttpServletRequest request,
225
+                             @ApiParam(name = "memCard", value = "memCard") @RequestAttribute(value = "memCard", required = false) String memCard,
226
+                             @ApiParam(name = "code", value = "code") @RequestParam(value = "code", required = true) String code,
227
+                             @RequestParam(name = "id", required = true) Long id
228
+    ) {
229
+        if (request.getSession().getAttribute("UserCard") != null) {
230
+            memCard = (String) request.getSession().getAttribute("UserCard");
231
+        }
232
+        String ip = IpUtil.getIpAddr(request);
233
+        return courseService.checkCode(ip, memCard, code,id);
234
+    }
235
+}

+ 270
- 0
src/main/java/com/cirle/scientific/controller/courseware/CourseWareController.java View File

@@ -0,0 +1,270 @@
1
+package com.cirle.scientific.controller.courseware;
2
+
3
+
4
+import com.aliyun.opensearch.sdk.dependencies.com.google.common.collect.Lists;
5
+import com.cirle.scientific.dto.QkjCourseWareDto;
6
+import com.cirle.scientific.dto.QkjRecommendDTO;
7
+import com.cirle.scientific.po.QkjCourseWare;
8
+import com.cirle.scientific.pojo.BizCodeEnum;
9
+import com.cirle.scientific.pojo.Result;
10
+import com.cirle.scientific.service.QkjCourseWareService;
11
+import com.cirle.scientific.service.RecommendService;
12
+import com.cirle.scientific.utils.DeviceUtil;
13
+import com.cirle.scientific.utils.UserLoginUtil;
14
+import com.cirle.scientific.utils.page.ResultPage;
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import io.swagger.annotations.ApiParam;
18
+import lombok.extern.slf4j.Slf4j;
19
+import org.apache.commons.lang3.StringUtils;
20
+import org.springframework.beans.factory.annotation.Autowired;
21
+import org.springframework.http.HttpStatus;
22
+import org.springframework.http.ResponseEntity;
23
+import org.springframework.stereotype.Controller;
24
+import org.springframework.ui.Model;
25
+import org.springframework.validation.annotation.Validated;
26
+import org.springframework.web.bind.annotation.*;
27
+
28
+import javax.servlet.http.HttpServletRequest;
29
+import javax.servlet.http.HttpServletResponse;
30
+import java.util.ArrayList;
31
+import java.util.List;
32
+import java.util.Objects;
33
+
34
+@Controller
35
+@RequestMapping("/courseware")
36
+@Api("课件相关接口")
37
+@Slf4j
38
+public class CourseWareController {
39
+
40
+    @Autowired
41
+    QkjCourseWareService courseWareService;
42
+
43
+    @Autowired
44
+    RecommendService recommendService;
45
+
46
+    @GetMapping("/index")
47
+    @ApiOperation(value = "去往课件列表页")
48
+    public String index(HttpServletRequest request,
49
+            @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from, Model model
50
+    ){
51
+        String refererUrl = request.getHeader("Referer");
52
+        if(refererUrl!=null && refererUrl.contains("login")){
53
+            model.addAttribute("fromlogin","1");
54
+        }else{
55
+            model.addAttribute("fromlogin","0");
56
+        }
57
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
58
+            return "html5/courseware/courseware";
59
+        } else {
60
+            return "web/courseware/courseware";
61
+        }
62
+    }
63
+
64
+    @GetMapping("/details")
65
+    @ApiOperation(value = "去往课件详情页")
66
+    public String detail(
67
+            HttpServletRequest request,
68
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
69
+            @ApiParam(name = "id", value = "课件id") @RequestParam(name = "id", required = true) Long id
70
+    ) {
71
+        request.setAttribute("id", id);
72
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
73
+            return "html5/courseware/courseware-details";
74
+        } else {
75
+            return "web/courseware/courseware-details";
76
+        }
77
+    }
78
+
79
+    @PostMapping("/getAdInfo")
80
+    @ResponseBody
81
+    @ApiOperation(value = "课程首页获取广告位")
82
+    public Result<List<QkjRecommendDTO>> getAdInfo(HttpServletRequest request) {
83
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
84
+        Integer status = 3;
85
+        if(DeviceUtil.isMobileDevice(request)) {
86
+            status = 2;
87
+        }
88
+        List<QkjRecommendDTO> recmdTop = recommendService.findByPosIdLimit(19L, status, 1, 10);
89
+        return Result.success(recmdTop);
90
+    }
91
+
92
+    @PostMapping("/getlistData")
93
+    @ApiOperation(value = "获取课件列表")
94
+    @ResponseBody
95
+    public Result getArtListData(
96
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
97
+            @ApiParam(name = "cataId",value = "分类id") @RequestParam(name = "cataId",required = false) Integer cataId,
98
+            @ApiParam(name = "page",value = "分页") @RequestParam(name = "page",required = true,defaultValue="1") Integer page,
99
+            @ApiParam(name = "size",value = "每页数量") @RequestParam(name = "size",required = true,defaultValue="10") Integer size
100
+    ){
101
+        return courseWareService.getListData(memCard, cataId, page, size);
102
+    }
103
+
104
+    @PostMapping("/getPageData")
105
+    @ApiOperation(value = "获取课件列表分页")
106
+    @ResponseBody
107
+    public ResultPage getPageData(
108
+            HttpServletRequest request,
109
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
110
+            @ApiParam(name = "cataId",value = "分类id") @RequestParam(name = "cataId",required = false) Integer cataId,
111
+            @ApiParam(name = "page",value = "当前页") @RequestParam(name = "page",required = true,defaultValue="1") Integer page,
112
+            @ApiParam(name = "size",value = "每页数量") @RequestParam(name = "size",required = true,defaultValue="10") Integer size
113
+    ){
114
+        if (request.getSession().getAttribute("UserCard") != null) {
115
+            memCard = (String) request.getSession().getAttribute("UserCard");
116
+        }
117
+        return courseWareService.getPageData(memCard, cataId, page, size);
118
+    }
119
+
120
+    @GetMapping("/downFilebyWeb")
121
+    @ApiOperation(value = "web下载课件")
122
+    public String downFilebyWeb(
123
+            HttpServletResponse response, HttpServletRequest request,
124
+            @ApiParam(name = "id",value = "课件ID") @RequestParam(name = "id",required = true) Long id
125
+    ){
126
+        if(request.getSession().getAttribute("UserCard")==null){
127
+            return "web/user/login";
128
+        }
129
+        String memCard = (String)request.getSession().getAttribute("UserCard");
130
+        courseWareService.downFile(response, memCard, id);
131
+        return null;
132
+    }
133
+
134
+    @GetMapping("/downFile")
135
+    @ApiOperation(value = "下载课件")
136
+    public String downFile(
137
+            HttpServletResponse response,
138
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
139
+            @ApiParam(name = "id",value = "课件ID") @RequestParam(name = "id",required = true) Long id
140
+    ){
141
+        if(StringUtils.isBlank(memCard)){
142
+            return "html5/user/login";
143
+        }
144
+        courseWareService.downFile(response, memCard, id);
145
+        return null;
146
+    }
147
+    //自传课件相关接口
148
+    @GetMapping("/getlistData/forme")
149
+    @ApiOperation(value = "获取自传课件列表")
150
+    @ResponseBody
151
+    public ResultPage getArtListDataForMe(
152
+            HttpServletRequest request,
153
+            @ApiParam(name = "memCard", value = "memCard") @RequestAttribute(value = "memCard", required = false) String memCard,
154
+            @ApiParam(name = "belongBrandid", value = "品牌ID") @RequestParam(name = "belongBrandid", required = false) Integer belongBrandid,
155
+            @ApiParam(name = "page", value = "分页") @RequestParam(name = "page", required = true, defaultValue = "1") Integer page,
156
+            @ApiParam(name = "size", value = "每页数量") @RequestParam(name = "size", required = true, defaultValue = "10") Integer size
157
+    ) {
158
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
159
+            memCard = UserLoginUtil.isUserLogin(request);
160
+        }
161
+        return courseWareService.getListDataForMe(memCard, belongBrandid, page, size);
162
+    }
163
+
164
+    /**
165
+     * QkjCourseWare
166
+     *
167
+     * @param resources
168
+     * @return
169
+     */
170
+    @PostMapping(value = "/add")
171
+    @ApiOperation("新增课件")
172
+    @ResponseBody
173
+    public Result createQkjCourseware(
174
+            HttpServletRequest request,
175
+            @RequestAttribute(value = "memCard", required = false) String memCard,
176
+            QkjCourseWareDto resources) {
177
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
178
+            memCard = UserLoginUtil.isUserLogin(request);
179
+        }
180
+        resources.setUploader(memCard);
181
+        return courseWareService.add(resources);
182
+    }
183
+
184
+    @PostMapping(value = "/delete")
185
+    @ApiOperation("删除自传课件")
186
+    @ResponseBody
187
+    public Result delete(@ApiParam(name = "courseWareId", value = "课件ID") @RequestParam(name = "courseWareId", required = false) Long courseWareId) {
188
+
189
+        log.info("delete join courseWareId:{}", courseWareId);
190
+        if (Objects.isNull(courseWareId)) {
191
+            return Result.failed(BizCodeEnum.PARAM_NULL);
192
+        }
193
+        return courseWareService.deleteAll(Lists.newArrayList(courseWareId));
194
+    }
195
+
196
+    @GetMapping("/downFile/ppt/web")
197
+    @ApiOperation(value = "下载课件")
198
+    public String downFilePptWeb(
199
+            HttpServletRequest request,
200
+            HttpServletResponse response,
201
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
202
+            @ApiParam(name = "id",value = "课件ID") @RequestParam(name = "id",required = true) Long id
203
+    ){
204
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
205
+            memCard = UserLoginUtil.isUserLogin(request);
206
+        }
207
+        if(StringUtils.isBlank(memCard)){
208
+            return "web/user/login";
209
+        }
210
+        courseWareService.downFileForPPt(response, memCard, id);
211
+        return null;
212
+    }
213
+
214
+    @GetMapping("/downFile/ppt")
215
+    @ApiOperation(value = "下载课件")
216
+    public String downFilePpt(
217
+            HttpServletRequest request,
218
+            HttpServletResponse response,
219
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
220
+            @ApiParam(name = "id",value = "课件ID") @RequestParam(name = "id",required = true) Long id
221
+    ){
222
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
223
+            memCard = UserLoginUtil.isUserLogin(request);
224
+        }
225
+        if(StringUtils.isBlank(memCard)){
226
+            return "html5/user/login";
227
+        }
228
+        courseWareService.downFileForPPt(response, memCard, id);
229
+        return null;
230
+    }
231
+
232
+    @GetMapping("/downFile/ppt/batch/web")
233
+    @ApiOperation(value = "批量下载课件")
234
+    public String downFilePptBatchWeb(
235
+            HttpServletRequest request,
236
+            HttpServletResponse response,
237
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
238
+            @ApiParam(name = "ids",value = "课件ID集合") @RequestBody List<Integer> ids
239
+    ){
240
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
241
+            memCard = UserLoginUtil.isUserLogin(request);
242
+        }
243
+        if(StringUtils.isBlank(memCard)){
244
+            return "web/user/login";
245
+        }
246
+        courseWareService.downFileForPPtBatch(response, ids);
247
+        return null;
248
+    }
249
+    @GetMapping("/downFile/ppt/batch")
250
+    @ApiOperation(value = "下载课件")
251
+    public String downFilePptBatch(
252
+            HttpServletRequest request,
253
+            HttpServletResponse response,
254
+            @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
255
+            @ApiParam(name = "ids",value = "课件ID集合")  @RequestBody List<Integer> ids
256
+    ){
257
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
258
+            memCard = UserLoginUtil.isUserLogin(request);
259
+        }
260
+        if(StringUtils.isBlank(memCard)){
261
+            return "html5/user/login";
262
+        }
263
+        courseWareService.downFileForPPtBatch(response, ids);
264
+        return null;
265
+    }
266
+
267
+
268
+
269
+
270
+}

+ 20
- 0
src/main/java/com/cirle/scientific/controller/error/ErrorPageController.java View File

@@ -0,0 +1,20 @@
1
+package com.cirle.scientific.controller.error;
2
+
3
+import org.springframework.stereotype.Controller;
4
+import org.springframework.web.bind.annotation.GetMapping;
5
+
6
+@Controller
7
+public class ErrorPageController {
8
+
9
+    @GetMapping("/404")
10
+    public String to404() {
11
+        return "/error/404.html";
12
+    }
13
+
14
+
15
+    @GetMapping("/other")
16
+    public String toOther() {
17
+        return "/error/other.html";
18
+    }
19
+
20
+}

+ 63
- 0
src/main/java/com/cirle/scientific/controller/error/UncaughtErrorControllor.java View File

@@ -0,0 +1,63 @@
1
+package com.cirle.scientific.controller.error;
2
+
3
+import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.boot.web.servlet.error.ErrorController;
5
+import org.springframework.http.HttpStatus;
6
+import org.springframework.stereotype.Controller;
7
+import org.springframework.web.bind.annotation.RequestMapping;
8
+
9
+import javax.servlet.RequestDispatcher;
10
+import javax.servlet.http.HttpServletRequest;
11
+import javax.servlet.http.HttpServletResponse;
12
+import java.io.IOException;
13
+
14
+@Controller
15
+@RequestMapping("${server.error.path:${error.path:/error}}")
16
+public class UncaughtErrorControllor implements ErrorController {
17
+    @Value("${server.error.path:${error.path:/error}}")
18
+    protected String errorPath;
19
+
20
+    @Override
21
+    public String getErrorPath() {
22
+        return errorPath;
23
+    }
24
+
25
+    /**
26
+     * @param request
27
+     * @param response
28
+     * @return java.lang.Object
29
+     */
30
+    @RequestMapping(value = "")
31
+    public void error(HttpServletRequest request, HttpServletResponse response) {
32
+//        try {
33
+//            HttpStatus statusCode = getHttpStatusCode(request);
34
+//            if (statusCode.equals(HttpStatus.NOT_FOUND)) {
35
+//                String from = request.getParameter("from");
36
+//                if ("H5".equals(from)) {
37
+//                    response.sendRedirect("/index/index?from=H5");
38
+//                } else {
39
+//                    response.sendRedirect("/index/index?from=web");
40
+//                }
41
+////                response.sendRedirect("/404");
42
+//            } else {
43
+//                response.sendRedirect("/other?code=" + statusCode);
44
+//            }
45
+//        } catch (IOException e) {
46
+//            e.printStackTrace();
47
+//        }
48
+    }
49
+
50
+    private HttpStatus getHttpStatusCode(HttpServletRequest request) {
51
+        try {
52
+            Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
53
+            if (statusCode == null) {
54
+                return HttpStatus.INTERNAL_SERVER_ERROR;
55
+            }
56
+            return HttpStatus.valueOf(statusCode);
57
+        } catch (Exception e) {
58
+            return HttpStatus.INTERNAL_SERVER_ERROR;
59
+        }
60
+    }
61
+
62
+}
63
+

+ 157
- 0
src/main/java/com/cirle/scientific/controller/index/IndexController.java View File

@@ -0,0 +1,157 @@
1
+package com.cirle.scientific.controller.index;
2
+
3
+
4
+import com.alibaba.fastjson.JSONArray;
5
+import com.alibaba.fastjson.JSONObject;
6
+import com.cirle.scientific.constants.LoginConsts;
7
+import com.cirle.scientific.dto.QkjPeopleCounDTO;
8
+import com.cirle.scientific.dto.QkjSearchdataDto;
9
+import com.cirle.scientific.pojo.BizCodeEnum;
10
+import com.cirle.scientific.utils.DeviceUtil;
11
+import com.cirle.scientific.utils.LoginUtil;
12
+import com.cirle.scientific.utils.UserLoginUtil;
13
+import org.apache.commons.collections.CollectionUtils;
14
+import org.apache.commons.lang3.StringUtils;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.data.redis.core.StringRedisTemplate;
17
+import org.springframework.stereotype.Controller;
18
+import org.springframework.ui.Model;
19
+import org.springframework.web.bind.annotation.GetMapping;
20
+import org.springframework.web.bind.annotation.PostMapping;
21
+import org.springframework.web.bind.annotation.RequestAttribute;
22
+import org.springframework.web.bind.annotation.RequestMapping;
23
+import org.springframework.web.bind.annotation.RequestParam;
24
+import org.springframework.web.bind.annotation.ResponseBody;
25
+
26
+import com.cirle.scientific.dto.HomeDataDTO;
27
+import com.cirle.scientific.pojo.Result;
28
+import com.cirle.scientific.service.HomeService;
29
+
30
+import io.swagger.annotations.Api;
31
+import io.swagger.annotations.ApiOperation;
32
+import io.swagger.annotations.ApiParam;
33
+
34
+import javax.servlet.http.*;
35
+import java.util.List;
36
+import java.util.Objects;
37
+import java.util.Random;
38
+import java.util.stream.Collectors;
39
+
40
+@Controller
41
+@RequestMapping("/index")
42
+@Api("首页相关接口")
43
+public class IndexController {
44
+
45
+	@Autowired
46
+	private HomeService homeService;
47
+
48
+    @Autowired
49
+    LoginUtil loginUtil;
50
+
51
+
52
+
53
+    @GetMapping("/index")
54
+    @ApiOperation("首页接口")
55
+    public String index(HttpServletRequest request,
56
+                        @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from, Model model){
57
+        String refererUrl = request.getHeader("Referer");
58
+        if(refererUrl!=null && refererUrl.contains("login")){
59
+            model.addAttribute("fromlogin","1");
60
+        }else{
61
+            model.addAttribute("fromlogin","0");
62
+        }
63
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
64
+            return "html5/index/index1";
65
+        }else if (StringUtils.isNotBlank(from) && from.equals("web")){
66
+            return "web/index";
67
+        } else {
68
+            return "";
69
+        }
70
+    }
71
+
72
+    @GetMapping("/search")
73
+    @ApiOperation("搜索页面")
74
+    public String search(@ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from){
75
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
76
+            return "html5/search/search";
77
+        } else if (StringUtils.isNotBlank(from) && from.equals("web")){
78
+            return "web/search";
79
+        }else {
80
+            return "";
81
+        }
82
+    }
83
+
84
+    @PostMapping("/homeData")
85
+    @ApiOperation("首页接口数据")
86
+    @ResponseBody
87
+    public Result<HomeDataDTO> homeData(
88
+    		@RequestAttribute(value = "memCard",required = false) String memCard,HttpServletRequest request) {
89
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
90
+        Integer status = 3;
91
+        if(DeviceUtil.isMobileDevice(request)) {
92
+            status = 2;
93
+        }
94
+    		return homeService.getHomeData(memCard, status);
95
+    }
96
+
97
+    @PostMapping("/isLogin")
98
+    @ApiOperation("判断是否登录")
99
+    @ResponseBody
100
+    public Result isLogin(HttpServletRequest request, HttpServletResponse response,
101
+                          @RequestAttribute(value = "memCard", required = false) String memCard){
102
+
103
+        boolean replace = loginUtil.isReplace(request, response, memCard);
104
+        if(replace){
105
+            return Result.failed(BizCodeEnum.NO_LOGIN_REPLACE);
106
+        }
107
+
108
+        if(StringUtils.isBlank(memCard)){
109
+            return Result.success(BizCodeEnum.NO_LOGIN);
110
+        }
111
+
112
+        return Result.success(memCard);
113
+    }
114
+
115
+    /**
116
+     * 开放搜索接口
117
+     * @return
118
+     */
119
+    @PostMapping(value = "/search")
120
+    @ResponseBody
121
+    @ApiOperation("首页搜索接口")
122
+    public Result<Object> search(@RequestParam int start, @RequestParam int size
123
+            , @RequestParam String searchKw){
124
+        try {
125
+            String rdlist = homeService.search(searchKw, start, size);
126
+            JSONObject jsonObject = JSONObject.parseObject(rdlist);
127
+            String items  = jsonObject.getString("items");
128
+            List<QkjSearchdataDto> qkjSearchdataDtos = JSONArray.parseArray(items, QkjSearchdataDto.class);
129
+            if(CollectionUtils.isNotEmpty(qkjSearchdataDtos)){
130
+                qkjSearchdataDtos = qkjSearchdataDtos.stream().filter(e -> e.getObj_pid()==0).collect(Collectors.toList());
131
+            }
132
+            Object o = JSONArray.toJSON(qkjSearchdataDtos);
133
+            jsonObject.put("items",o);
134
+            //Object parse = JSONObject.parse(rdlist);
135
+            return Result.success(jsonObject);
136
+        } catch (Exception e) {
137
+            e.printStackTrace();
138
+            return Result.failed("搜索错误");
139
+        }
140
+    }
141
+
142
+    @GetMapping("/peopleCoun")
143
+    @ResponseBody
144
+    @ApiOperation("注册人数以及在线人数的接口")
145
+    public Result<Object> peopleCoun(HttpServletRequest request ) {
146
+        QkjPeopleCounDTO qkjPeopleCounDTO = homeService.peopleCount(request);
147
+        //进行虚拟填充
148
+        if (Objects.nonNull(qkjPeopleCounDTO)) {
149
+            qkjPeopleCounDTO.setRegisterPerson(qkjPeopleCounDTO.getRegisterPerson() + 150000);
150
+
151
+            Random random = new Random();
152
+            int randomInt = random.nextInt(50) + 51;
153
+            qkjPeopleCounDTO.setOnlinePerson(qkjPeopleCounDTO.getOnlinePerson() + randomInt);
154
+        }
155
+        return Result.success(qkjPeopleCounDTO);
156
+    }
157
+}

+ 74
- 0
src/main/java/com/cirle/scientific/controller/index/PcIndexController.java View File

@@ -0,0 +1,74 @@
1
+package com.cirle.scientific.controller.index;
2
+
3
+import com.cirle.scientific.dto.HomeDataDTO;
4
+import com.cirle.scientific.dto.QkjPositionsDTO;
5
+import com.cirle.scientific.pojo.Result;
6
+import com.cirle.scientific.service.HomeService;
7
+import com.cirle.scientific.service.RecommendService;
8
+import com.cirle.scientific.utils.DeviceUtil;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Controller;
13
+import org.springframework.web.bind.annotation.PostMapping;
14
+import org.springframework.web.bind.annotation.RequestAttribute;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.ResponseBody;
17
+
18
+import javax.servlet.http.HttpServletRequest;
19
+import java.util.ArrayList;
20
+import java.util.Iterator;
21
+import java.util.List;
22
+
23
+@Controller
24
+@RequestMapping("/web/index")
25
+@Api("首页相关测试")
26
+public class PcIndexController {
27
+
28
+    @Autowired
29
+    private RecommendService recommendService;
30
+
31
+    @Autowired
32
+    private HomeService homeService;
33
+
34
+
35
+    @PostMapping("/information")
36
+    @ApiOperation("首页资讯接口")
37
+    @ResponseBody
38
+    public Result<List<QkjPositionsDTO>> getInformation(
39
+            @RequestAttribute(value = "memCard",required = false) String memCard, HttpServletRequest request) {
40
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
41
+        Integer status = 3;
42
+        if(DeviceUtil.isMobileDevice(request)) {
43
+            status = 2;
44
+        }
45
+        List<QkjPositionsDTO> qkjPositionsDTOList = new ArrayList<>();
46
+        //long array[] = {8,9,10};
47
+        long array[] = {27,9,10};
48
+        for (long l : array) {
49
+            qkjPositionsDTOList.add(recommendService.findByPosId(l,status));
50
+        }
51
+        return Result.success(qkjPositionsDTOList);
52
+    }
53
+
54
+    @PostMapping("/homeData")
55
+    @ApiOperation("Web首页接口数据")
56
+    @ResponseBody
57
+    public Result<HomeDataDTO> homeData(
58
+            @RequestAttribute(value = "memCard",required = false) String memCard,HttpServletRequest request) {
59
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
60
+        Integer status = 3;
61
+        if(DeviceUtil.isMobileDevice(request)) {
62
+            status = 2;
63
+        }
64
+        Result<HomeDataDTO> homeData = homeService.getHomeData(memCard, status);
65
+        List<QkjPositionsDTO> children = homeData.getData().getSeriesRecommends().getChildren();
66
+        for (Iterator<QkjPositionsDTO> iterator=children.iterator(); iterator.hasNext();) {
67
+            QkjPositionsDTO next = iterator.next();
68
+            if (next.getPosName().contains("资讯")){
69
+                iterator.remove();
70
+            }
71
+        }
72
+        return homeData;
73
+    }
74
+}

+ 33
- 0
src/main/java/com/cirle/scientific/controller/index/RootIndexController.java View File

@@ -0,0 +1,33 @@
1
+package com.cirle.scientific.controller.index;
2
+
3
+import com.cirle.scientific.utils.DeviceUtil;
4
+import io.swagger.annotations.Api;
5
+import io.swagger.annotations.ApiOperation;
6
+import io.swagger.annotations.ApiParam;
7
+import org.apache.commons.lang3.StringUtils;
8
+import org.springframework.stereotype.Controller;
9
+import org.springframework.web.bind.annotation.GetMapping;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestParam;
12
+
13
+import javax.servlet.http.HttpServletRequest;
14
+
15
+@Controller
16
+@RequestMapping("/")
17
+@Api("首页相关接口")
18
+public class RootIndexController {
19
+
20
+    @GetMapping("")
21
+    @ApiOperation("")
22
+    public String index(HttpServletRequest request){
23
+
24
+        if(DeviceUtil.isMobileDevice(request)){
25
+            System.out.println("手机端----------------------");
26
+            return "html5/index/index1";
27
+        }else{
28
+            System.out.println("pc端------------------------");
29
+            return "web/index";
30
+        }
31
+    }
32
+
33
+}

+ 64
- 0
src/main/java/com/cirle/scientific/controller/live/CounterController.java View File

@@ -0,0 +1,64 @@
1
+package com.cirle.scientific.controller.live;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.cirle.scientific.dao.QkjLiveDao;
5
+import com.cirle.scientific.dto.QkjRecommendDTO;
6
+import com.cirle.scientific.po.QkjLive;
7
+import com.cirle.scientific.pojo.BizCodeEnum;
8
+import com.cirle.scientific.pojo.Result;
9
+import com.cirle.scientific.service.LiveService;
10
+import com.cirle.scientific.utils.DeviceUtil;
11
+import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiOperation;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.stereotype.Controller;
15
+import org.springframework.web.bind.annotation.GetMapping;
16
+import org.springframework.web.bind.annotation.RequestBody;
17
+import org.springframework.web.bind.annotation.RequestMapping;
18
+import org.springframework.web.bind.annotation.ResponseBody;
19
+
20
+import java.util.ArrayList;
21
+import java.util.HashMap;
22
+import java.util.List;
23
+import java.util.Map;
24
+
25
+@Controller
26
+@RequestMapping("/livecounter")
27
+@Api("直播统计")
28
+public class CounterController {
29
+
30
+
31
+    @Autowired
32
+    LiveService liveService;
33
+
34
+    @Autowired
35
+    private QkjLiveDao qkjLiveDao;
36
+
37
+    @GetMapping("/getcounter")
38
+    @ResponseBody
39
+    @ApiOperation("获取当前学习人总数")
40
+    public Result getcounter(String liveId) {
41
+
42
+        JSONObject data = new JSONObject();
43
+        //
44
+        QkjLive live = liveService.getLiveInfo(Long.parseLong(liveId));
45
+        if(live.getLiveType()==2){
46
+            List<QkjLive> lives = qkjLiveDao.findSonList(live.getId().intValue(), 0, 100);
47
+            List<Map> listmap = new ArrayList();
48
+            for(QkjLive son : lives){
49
+                Map map = new HashMap();
50
+                map.put("liveId",son.getId());
51
+                map.put("count",son.getPurchasedMembers());
52
+                listmap.add(map);
53
+            }
54
+            data.put("children",listmap);
55
+        }else{
56
+            data.put("children",new ArrayList());
57
+        }
58
+        data.put("liveid", liveId);
59
+        data.put("count", live.getPurchasedMembers());
60
+        return Result.success(data);
61
+    }
62
+
63
+
64
+}

+ 469
- 0
src/main/java/com/cirle/scientific/controller/live/LiveController.java View File

@@ -0,0 +1,469 @@
1
+package com.cirle.scientific.controller.live;
2
+
3
+
4
+import java.time.LocalDateTime;
5
+import java.util.LinkedHashMap;
6
+import java.util.List;
7
+import java.util.Map;
8
+import java.util.Objects;
9
+
10
+import javax.servlet.http.HttpServletRequest;
11
+
12
+import com.alibaba.fastjson.JSON;
13
+import com.alibaba.fastjson.JSONArray;
14
+import com.cirle.scientific.constants.ShareConsts;
15
+import com.cirle.scientific.constants.TaskConsts;
16
+import com.cirle.scientific.dao.QkjLiveDao;
17
+import com.cirle.scientific.dto.ShareRankDto;
18
+import com.cirle.scientific.po.QkjShare;
19
+import com.cirle.scientific.service.QkjShareService;
20
+import com.cirle.scientific.utils.DeviceUtil;
21
+import com.cirle.scientific.utils.UserLoginUtil;
22
+import lombok.extern.slf4j.Slf4j;
23
+import org.apache.commons.collections.CollectionUtils;
24
+import org.apache.commons.lang3.StringUtils;
25
+import org.springframework.beans.factory.annotation.Autowired;
26
+import org.springframework.stereotype.Controller;
27
+import org.springframework.ui.Model;
28
+import org.springframework.web.bind.annotation.*;
29
+
30
+import com.alibaba.fastjson.JSONObject;
31
+import com.cirle.scientific.dto.QkjLiveCommentsDTO;
32
+import com.cirle.scientific.dto.QkjLiveDetailDTO;
33
+import com.cirle.scientific.po.QkjLive;
34
+import com.cirle.scientific.po.QkjQuestionAnswer;
35
+import com.cirle.scientific.pojo.BizCodeEnum;
36
+import com.cirle.scientific.pojo.Result;
37
+import com.cirle.scientific.server.WebSocketOneToMany;
38
+import com.cirle.scientific.service.LiveService;
39
+import com.cirle.scientific.service.OrderService;
40
+import com.fasterxml.jackson.core.JsonProcessingException;
41
+import com.fasterxml.jackson.core.type.TypeReference;
42
+import com.fasterxml.jackson.databind.JsonMappingException;
43
+import com.fasterxml.jackson.databind.ObjectMapper;
44
+
45
+import io.swagger.annotations.Api;
46
+import io.swagger.annotations.ApiOperation;
47
+import io.swagger.annotations.ApiParam;
48
+
49
+@Controller
50
+@RequestMapping("/live")
51
+@Api("直播相关接口")
52
+@Slf4j
53
+public class LiveController {
54
+
55
+    @Autowired
56
+    private LiveService liveService;
57
+
58
+    @Autowired
59
+    private QkjLiveDao qkjLiveDao;
60
+
61
+    @Autowired
62
+    private WebSocketOneToMany webSocketOneToMany;
63
+
64
+    @Autowired
65
+    private OrderService orderService;
66
+
67
+
68
+    @Autowired
69
+    private QkjShareService qkjShareService;
70
+
71
+    @PostMapping("/pushUser")
72
+    @ResponseBody
73
+    @ApiOperation("推送流量")
74
+    /**
75
+     * JSONObject
76
+     * {
77
+     *  "liveId":117,
78
+     *  "users":[
79
+     *      张三,李四,王五
80
+     *  ]
81
+     * }
82
+     * users:用户数组
83
+     */
84
+    public Result pushUser(@RequestBody JSONObject data) {
85
+        webSocketOneToMany.sendComing(data);
86
+        return Result.success(BizCodeEnum.SUCCESS);
87
+    }
88
+
89
+    @PostMapping("/sendStartLive")
90
+    @ResponseBody
91
+    @ApiOperation("推送开启或者关闭直播")
92
+    public Result sendStartLive(
93
+            @RequestParam(name = "liveId", required = true) Long liveId,
94
+            @RequestParam(name = "liveStatus", required = true) Integer liveStatus
95
+    ) {
96
+        webSocketOneToMany.sendStartOrStopLive(liveId, liveStatus);
97
+        return Result.success(BizCodeEnum.SUCCESS);
98
+    }
99
+
100
+    @PostMapping("/sendImgPath")
101
+    @ResponseBody
102
+    @ApiOperation("推送图片")
103
+    public Result sendImgPath(
104
+            @RequestParam(name = "liveId", required = true) Long liveId,
105
+            @RequestParam(name = "imgPath", required = true) String imgPath
106
+    ) {
107
+        webSocketOneToMany.sendImgPath(liveId, imgPath);
108
+        return Result.success(BizCodeEnum.SUCCESS);
109
+    }
110
+
111
+    @PostMapping("/sendLiveUserCount")
112
+    @ResponseBody
113
+    @ApiOperation("推送直播人气(当前在线人数)")
114
+    public Result sendLiveUserCount(
115
+            @RequestParam(name = "liveId", required = true) Long liveId,
116
+            @RequestParam(name = "count", required = true) Integer count
117
+    ) {
118
+        webSocketOneToMany.sendLiveUserCount(liveId, count);
119
+        return Result.success(BizCodeEnum.SUCCESS);
120
+    }
121
+
122
+    @PostMapping("/pushBarrage")
123
+    @ResponseBody
124
+    @ApiOperation("推送弹幕")
125
+    /**
126
+     * JSONObject
127
+     * {
128
+     *  "liveId":117,
129
+     *  "barrage":[
130
+     *     {
131
+     *         "name":"李四",
132
+     *         "time":"11:11:11"  只要时分秒,
133
+     *         "headImg":"xxxxxxxx.png",
134
+     *         "content":"你好"
135
+     *     },
136
+     *     {
137
+     *      *         "name":"李四",
138
+     *      *         "time":"11:11:11"  只要时分秒,
139
+     *      *         "headImg":"xxxxxxxx.png",
140
+     *      *         "content":"你好"
141
+     *      *     }
142
+     *  ],
143
+     * }
144
+     * barrage :弹幕数组
145
+     */
146
+    public Result pushBarrage(@RequestBody JSONObject data) {
147
+        webSocketOneToMany.pushBarrage(data);
148
+        return Result.success(BizCodeEnum.SUCCESS);
149
+    }
150
+
151
+    @GetMapping("/getOnlineUser")
152
+    @ResponseBody
153
+    @ApiOperation("获取当前在线用户的memcard")
154
+    public Result<JSONArray> getOnlineUser(@RequestParam(name = "liveId", required = true) Long liveId
155
+    ) {
156
+        Result<JSONArray> onlineUser = webSocketOneToMany.getOnlineUser(liveId);
157
+        return onlineUser;
158
+    }
159
+
160
+    @GetMapping("/getOnlineUserCount")
161
+    @ResponseBody
162
+    @ApiOperation("获取当前在线人数")
163
+    public Result<Integer> getOnlineUserCount(@RequestParam(name = "liveId", required = true) Long liveId
164
+    ) {
165
+        Result<Integer> onlineUsers = webSocketOneToMany.getOnlineUserCount(liveId);
166
+        return onlineUsers;
167
+    }
168
+
169
+    @GetMapping("/index")
170
+    @ApiOperation(value = "去往直播首页")
171
+    public String gotoLiveIndex(
172
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from
173
+    ) {
174
+
175
+
176
+
177
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
178
+            return "html5/live/live-index";
179
+        } else {
180
+            return "web/live/live-index";
181
+        }
182
+    }
183
+
184
+    @GetMapping("/liveQuestion")
185
+    @ApiOperation(value = "去往直播专区问卷")
186
+    public String gotoLiveQuestion(
187
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from
188
+    ) {
189
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
190
+            return "html5/live/live-questionnaire";
191
+        } else {
192
+            return "";
193
+        }
194
+    }
195
+
196
+    @PostMapping("/getIndexData")
197
+    @ApiOperation(value = "获取首页数据")
198
+    @ResponseBody
199
+    public Result indexData(HttpServletRequest request, @RequestAttribute(value = "memCard", required = false) String memCard) {
200
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
201
+        Integer status = 3;
202
+        if(DeviceUtil.isMobileDevice(request)) {
203
+            status = 2;
204
+        }
205
+        if (request.getSession().getAttribute("UserCard") != null) {
206
+            memCard = (String) request.getSession().getAttribute("UserCard");
207
+        }
208
+        return Result.success(liveService.indexData(memCard, status));
209
+    }
210
+
211
+    @PostMapping("/liveList")
212
+    @ApiOperation(value = "获取首页直播列表")
213
+    @ResponseBody
214
+    public Result<List<QkjLiveDetailDTO>> liveList(HttpServletRequest request,
215
+                                                   @RequestAttribute(value = "memCard", required = false) String memCard,
216
+                                                   @ApiParam(name = "cId", value = "分类ID") @RequestParam(name = "cId", required = true) Integer cId,
217
+                                                   @ApiParam(name = "page", value = "分页") @RequestParam(name = "page", required = true, defaultValue = "1") Integer page,
218
+                                                   @ApiParam(name = "size", value = "每页数量") @RequestParam(name = "size", required = true, defaultValue = "10") Integer size
219
+    ) {
220
+        if (request.getSession().getAttribute("UserCard") != null) {
221
+            memCard = (String) request.getSession().getAttribute("UserCard");
222
+        }
223
+        return Result.success(liveService.getLiveList(memCard, cId, page, size));
224
+    }
225
+
226
+    @PostMapping("/livepage")
227
+    @ApiOperation(value = "获取首页直播列表")
228
+    @ResponseBody
229
+    public Result<Map> livePage(HttpServletRequest request,
230
+                                @RequestAttribute(value = "memCard", required = false) String memCard,
231
+                                @ApiParam(name = "cId", value = "分类ID") @RequestParam(name = "cId", required = true) Integer cId,
232
+                                @ApiParam(name = "page", value = "分页") @RequestParam(name = "page", required = true, defaultValue = "1") Integer page,
233
+                                @ApiParam(name = "size", value = "每页数量") @RequestParam(name = "size", required = true, defaultValue = "10") Integer size
234
+    ) {
235
+        if (request.getSession().getAttribute("UserCard") != null) {
236
+            memCard = (String) request.getSession().getAttribute("UserCard");
237
+        }
238
+        boolean isPC= DeviceUtil.isMobileDevice(request);
239
+        return Result.success(liveService.pageLiveList(memCard, cId, page, size,isPC));
240
+    }
241
+
242
+    @GetMapping("/detail")
243
+    @ApiOperation(value = "去往直播详情页面")
244
+    public String detail(
245
+            HttpServletRequest request,
246
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
247
+            @ApiParam(name = "fromMemCard", value = "分享者的ID") @RequestParam(name = "fromMemCard", required = false) String fromMemCard,
248
+            @ApiParam(name = "liveId", value = "分类ID") @RequestParam(name = "liveId", required = true) Long liveId, Model model
249
+    ) {
250
+        String refererUrl = request.getHeader("Referer");
251
+        if(refererUrl!=null && refererUrl.contains("login")){
252
+            model.addAttribute("fromlogin","1");
253
+        }else{
254
+            model.addAttribute("fromlogin","0");
255
+        }
256
+        //获取详情
257
+        QkjLive liveInfo = liveService.getLiveInfo(liveId);
258
+        request.setAttribute("liveId", liveId);
259
+        if(StringUtils.isNotBlank(fromMemCard)){
260
+            request.setAttribute("fromMemCard", fromMemCard);
261
+        }
262
+
263
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
264
+            if (liveInfo.getLiveType() == 2) {
265
+                return "html5/live/live-prefecture";
266
+            } else {
267
+                return "html5/live/live-alive";
268
+            }
269
+        } else {
270
+            if (liveInfo.getLiveType() == 2) {
271
+                return "web/live/live-zhuanquxq";
272
+            } else {
273
+                return "web/live/live-prefecture";
274
+            }
275
+        }
276
+    }
277
+
278
+    @PostMapping("/getDetailData")
279
+    @ApiOperation(value = "获取直播详情")
280
+    @ResponseBody
281
+    public Result<QkjLiveDetailDTO> getDetailData(HttpServletRequest request,
282
+                                                  @RequestHeader(value="referer", defaultValue = "0") String referer,
283
+                                                  @RequestHeader(value="user-agent", defaultValue = "0") String userAgent,
284
+                                                  @RequestAttribute(value = "memCard", required = false) String memCard,
285
+                                                  @RequestParam(value = "fromMemCard", required = false) String fromMemCard,
286
+                                                  @ApiParam(name = "liveId", value = "直播ID") @RequestParam(name = "liveId", required = true) Long liveId
287
+    ) {
288
+        log.info("getDetailData  memCard:{} fromMemCard:{} referer:{} userAgent:{}", memCard, fromMemCard, referer, userAgent);
289
+        //借助详情的接口做分享的保存,点记者从分享者的链接进入必定调用这个接口
290
+        QkjShare share = QkjShare.builder()
291
+                .shareMemcard(fromMemCard)
292
+                .clickMemcard(memCard)
293
+                .objType(ShareConsts.obj_type_live)
294
+                .objId(liveId.intValue())
295
+                .createTime(LocalDateTime.now())
296
+                .updateTime(LocalDateTime.now())
297
+                .build();
298
+        qkjShareService.saveQkjShare(share);
299
+        return liveService.getLiveDetail(liveId, memCard);
300
+    }
301
+
302
+    @PostMapping("/infoByMember")
303
+    @ApiOperation(value = "获取直播详情")
304
+    @ResponseBody
305
+    public Result infoByMember(HttpServletRequest request,
306
+                               @RequestAttribute(value = "memCard", required = false) String memCard,
307
+                               @ApiParam(name = "liveId", value = "直播ID") @RequestParam(name = "liveId", required = true) Long liveId
308
+    ) {
309
+        if (request.getSession().getAttribute("UserCard") != null) {
310
+            memCard = (String) request.getSession().getAttribute("UserCard");
311
+        }
312
+        return liveService.infoByMember(liveId, memCard);
313
+    }
314
+
315
+    @PostMapping("/commentList")
316
+    @ApiOperation(value = "获取直播评论列表")
317
+    @ResponseBody
318
+    public Result<List<QkjLiveCommentsDTO>> commentList(HttpServletRequest request,
319
+                                                        @RequestAttribute(value = "memCard", required = false) String memCard,
320
+                                                        @ApiParam(name = "liveId", value = "直播ID") @RequestParam(name = "liveId", required = true) Long liveId,
321
+                                                        @ApiParam(name = "cId", value = "分页") @RequestParam(name = "cId", required = true) Integer cId
322
+    ) {
323
+        if (request.getSession().getAttribute("UserCard") != null) {
324
+            memCard = (String) request.getSession().getAttribute("UserCard");
325
+        }
326
+        return liveService.getLiveComments(memCard, liveId, cId);
327
+    }
328
+
329
+    @PostMapping("/addLiveComment")
330
+    @ApiOperation(value = "添加直播评论")
331
+    @ResponseBody
332
+    public Result<Boolean> addLiveComment(HttpServletRequest request,
333
+                                          @RequestAttribute(value = "memCard", required = false) String memCard,
334
+                                          @ApiParam(name = "liveId", value = "直播ID") @RequestParam(name = "liveId", required = true) Long liveId,
335
+                                          @ApiParam(name = "content", value = "评论内容") @RequestParam(name = "content", required = true) String content
336
+    ) {
337
+        if (memCard == null && request.getSession().getAttribute("UserCard") == null) {
338
+            return Result.failed(BizCodeEnum.NO_LOGIN);
339
+        }
340
+        memCard = memCard == null ? (String) request.getSession().getAttribute("UserCard") : memCard;
341
+        return Result.success(liveService.addLiveComment(liveId, memCard, content));
342
+    }
343
+
344
+    @GetMapping("/liveRanking")
345
+    @ApiOperation(value = "去往直播榜单页面")
346
+    public String liveRanking(
347
+            HttpServletRequest request,
348
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
349
+            @ApiParam(name = "liveId", value = "直播ID") @RequestParam(name = "liveId", required = true) Long liveId
350
+    ) {
351
+        request.setAttribute("liveId", liveId);
352
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
353
+            return "html5/live/live-ranking";
354
+        } else {
355
+            return "";
356
+        }
357
+    }
358
+
359
+    @PostMapping("/rankList")
360
+    @ResponseBody
361
+    public Result<JSONObject> rankList(
362
+            @RequestAttribute(value = "memCard", required = false) String memCard,
363
+            @RequestParam Integer objType,
364
+            @RequestParam Integer objId
365
+    ) {
366
+        List<ShareRankDto> rs = qkjShareService.inviteRank("", objType, objId);
367
+        JSONArray jsonArray = new JSONArray();
368
+        if (CollectionUtils.isNotEmpty(rs)) {
369
+            jsonArray = JSONArray.parseArray(JSON.toJSONString(rs));
370
+        }
371
+        JSONObject rstData = new JSONObject();
372
+        rstData.put("rankList", jsonArray);
373
+        return Result.success(rstData);
374
+    }
375
+
376
+    @RequestMapping(value = "/addRemind", method = RequestMethod.POST)
377
+    @ResponseBody
378
+    public Result<Map<String, Object>> addRemind(HttpServletRequest request,
379
+                                                 @RequestAttribute(value = "memCard", required = false) String memCard,
380
+                                                 @RequestParam Long liveId
381
+    ) {
382
+        if (memCard == null && request.getSession().getAttribute("UserCard") == null) {
383
+            return Result.failed(BizCodeEnum.NO_LOGIN);
384
+        }
385
+        memCard = memCard == null ? (String) request.getSession().getAttribute("UserCard") : memCard;
386
+        return liveService.reserveOrBets(memCard, liveId.toString());
387
+    }
388
+
389
+    @RequestMapping(value = "/saveQuestionAnswer", method = RequestMethod.POST)
390
+    @ResponseBody
391
+    public Result saveQuestionAnswer(HttpServletRequest request,
392
+                                     @RequestAttribute(value = "memCard", required = false) String memCard,
393
+                                     @RequestParam String questions,
394
+                                     @RequestParam Integer liveId
395
+    ) {
396
+        if (memCard == null && request.getSession().getAttribute("UserCard") == null) {
397
+            return Result.failed(BizCodeEnum.NO_LOGIN);
398
+        }
399
+        memCard = memCard == null ? (String) request.getSession().getAttribute("UserCard") : memCard;
400
+        return liveService.saveQuestionAnswer(memCard, questions, liveId);
401
+    }
402
+
403
+    /**
404
+     * 阿里云监听推流回调通知
405
+     * @param request
406
+     * @return
407
+     */
408
+    @GetMapping("/pushStreamCallback")
409
+    @ResponseBody
410
+    public Result pushStreamCallback(HttpServletRequest request) {
411
+        liveService.pushStreamCallback(request);
412
+        return Result.success(true);
413
+    }
414
+
415
+
416
+    @GetMapping("/auto/inc")
417
+    @ResponseBody
418
+    @ApiOperation("自动增长参与人数和预约人数")
419
+    public Result aotuLiveNum(
420
+            HttpServletRequest request,
421
+            @ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(name = "memCard", required = false) String memCard,
422
+            @RequestParam(value = "params", required = false) String params
423
+    ) {
424
+        if (StringUtils.isBlank(memCard)) {//pc从session去 m从参数取
425
+            memCard = UserLoginUtil.isUserLogin(request);
426
+        }
427
+        log.info("aotuLiveNum memCard is null   {}",params);
428
+
429
+        return Result.success(liveService.autoIncNum(params));
430
+    }
431
+
432
+    @GetMapping("/shenmi")
433
+    @ResponseBody
434
+    @ApiOperation("运营人员操作改变joinnumber")
435
+    public Result updateJoinNumber(
436
+            HttpServletRequest request,
437
+            @ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(name = "memCard", required = false) String memCard,
438
+            @RequestParam(value = "liveId", required = true) Long liveId,
439
+            @RequestParam(value = "num", required = true) Long num
440
+    ) {
441
+        log.info("updateJoinNumber liveId :{} num:{}", liveId, num);
442
+
443
+        if(num>0){
444
+            qkjLiveDao.updateJoinMembers(num, liveId);
445
+        }else  if (num<0){
446
+            qkjLiveDao.reduceJoinMembers(Math.abs(num), liveId);
447
+        } else if (num ==0) {
448
+            QkjLive byLiveId = qkjLiveDao.findById(String.valueOf(liveId));
449
+            if(Objects.nonNull(byLiveId)){
450
+                return Result.success(byLiveId.getJoinMembers());
451
+            }
452
+        }
453
+        return Result.success("修改成功");
454
+    }
455
+
456
+    @GetMapping("/getUserInfoByLiveId")
457
+    @ResponseBody
458
+    @ApiOperation("获取当前观看直播的人的信息")
459
+    public Result getUserInfoByLiveId(
460
+            @RequestParam(name = "liveId", required = true) Integer liveId,
461
+            @RequestAttribute(value = "memCard", required = false) String memCard
462
+    ) {
463
+
464
+        if(StringUtils.isBlank(memCard)){
465
+            return Result.failed(BizCodeEnum.NO_LOGIN);
466
+        }
467
+        return liveService.getUserInfoByLiveId(memCard, liveId);
468
+    }
469
+}

+ 26
- 0
src/main/java/com/cirle/scientific/controller/live/resp/LiveUserinfoResp.java View File

@@ -0,0 +1,26 @@
1
+package com.cirle.scientific.controller.live.resp;
2
+
3
+
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Builder;
6
+import lombok.Data;
7
+
8
+import java.time.LocalDateTime;
9
+import java.util.Calendar;
10
+
11
+@Data
12
+@Builder
13
+public class LiveUserinfoResp {
14
+
15
+    @ApiModelProperty(value = "微信昵称")
16
+    private String wxName;
17
+    @ApiModelProperty(value = "微信头像")
18
+    private String wxHeadImg;
19
+    @ApiModelProperty(value = "直播标题")
20
+    private String liveTitle;
21
+    @ApiModelProperty(value = "直播封面")
22
+    private String liveCoverImg;
23
+    @ApiModelProperty(value = "直播时间")
24
+    private String liveBeginTime;
25
+
26
+}

+ 780
- 0
src/main/java/com/cirle/scientific/controller/login/LoginController.java View File

@@ -0,0 +1,780 @@
1
+package com.cirle.scientific.controller.login;
2
+
3
+import cn.hutool.core.collection.CollectionUtil;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.cirle.scientific.constants.LoginConsts;
6
+import com.cirle.scientific.constants.WeixinConsts;
7
+import com.cirle.scientific.dao.MemberDao;
8
+import com.cirle.scientific.dao.QkjMemberOpenidDao;
9
+import com.cirle.scientific.dao.QkjMemberTaskInfoDao;
10
+import com.cirle.scientific.dto.WxUerInfoDTO;
11
+import com.cirle.scientific.po.QkjMember;
12
+import com.cirle.scientific.po.QkjMemberOpenid;
13
+import com.cirle.scientific.po.QkjMemberTaskInfo;
14
+import com.cirle.scientific.pojo.BizCodeEnum;
15
+import com.cirle.scientific.pojo.Result;
16
+import com.cirle.scientific.service.MemberService;
17
+import com.cirle.scientific.service.MemberTaskInfoService;
18
+import com.cirle.scientific.service.WeixinService;
19
+import com.cirle.scientific.service.impl.MemberServiceImpl;
20
+import com.cirle.scientific.utils.*;
21
+import com.cirle.scientific.utils.weixin.WeixinpayConfig;
22
+import com.google.common.collect.Lists;
23
+import com.google.common.collect.Maps;
24
+import com.google.gson.JsonObject;
25
+import io.swagger.annotations.Api;
26
+import io.swagger.annotations.ApiOperation;
27
+import io.swagger.annotations.ApiParam;
28
+import lombok.extern.slf4j.Slf4j;
29
+import org.apache.commons.lang3.StringUtils;
30
+import org.springframework.beans.factory.annotation.Autowired;
31
+import org.springframework.data.redis.core.StringRedisTemplate;
32
+import org.springframework.session.Session;
33
+import org.springframework.session.SessionRepository;
34
+import org.springframework.session.web.http.SessionRepositoryFilter;
35
+import org.springframework.stereotype.Controller;
36
+import org.springframework.ui.Model;
37
+import org.springframework.util.CollectionUtils;
38
+import org.springframework.util.DigestUtils;
39
+import org.springframework.web.bind.annotation.*;
40
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
41
+
42
+import javax.servlet.http.*;
43
+import java.io.IOException;
44
+import java.io.UnsupportedEncodingException;
45
+import java.net.URLDecoder;
46
+import java.net.URLEncoder;
47
+import java.util.LinkedHashMap;
48
+import java.util.List;
49
+import java.util.Map;
50
+import java.util.Objects;
51
+import java.util.concurrent.TimeUnit;
52
+import java.util.stream.Collectors;
53
+
54
+@Controller
55
+@RequestMapping("/login")
56
+@Api("登录相关接口")
57
+@Slf4j
58
+public class LoginController {
59
+
60
+    @Autowired
61
+    MemberDao memberDao;
62
+    @Autowired
63
+    StringRedisTemplate stringRedisTemplate;
64
+    @Autowired
65
+    WeixinService weixinService;
66
+    @Autowired
67
+    MemberService memberService;
68
+    @Autowired
69
+    MemberTaskInfoService memberTaskInfoService;
70
+    @Autowired
71
+    QkjMemberOpenidDao openidDao;
72
+
73
+    @GetMapping("")
74
+    @ApiOperation(value = "手机号登录页面")
75
+    public String login(
76
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
77
+            @ApiParam(name = "redirectUrl", value = "回调地址") @RequestParam(name = "redirectUrl", required = false) String redirectUrl,
78
+            HttpServletRequest request
79
+    ) {
80
+        request.setAttribute("redirectUrl", redirectUrl);
81
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
82
+            return "html5/user/login";
83
+        } else {
84
+            return "";
85
+        }
86
+    }
87
+
88
+    /**
89
+     * 获取所有的白名单用户
90
+     * @return
91
+     */
92
+    @GetMapping(value = "/getWhitelist")
93
+    @ResponseBody
94
+    public Result getWhitelist() {
95
+        List<QkjMember> members = memberDao.findAllWhitelist();
96
+        List<String> userNameList = Lists.newArrayList();
97
+        if(CollectionUtil.isNotEmpty(members)){
98
+            userNameList = members.stream().map(QkjMember::getMemNickname).collect(Collectors.toList());
99
+        }
100
+        log.info("getWhitelist userNameList:{}", userNameList);
101
+        return Result.success(userNameList);
102
+    }
103
+
104
+    @RequestMapping(value = "/mobileLogin", method = {RequestMethod.POST, RequestMethod.GET})
105
+    @ResponseBody
106
+    @ApiOperation(value = "m登录")
107
+    public Result mobileLogin(
108
+            @ApiParam(name = "memMobile", value = "用户手机号") @RequestParam(name = "memMobile", required = true) String memMobile,
109
+            @ApiParam(name = "valCode", value = "验证码") @RequestParam(name = "valCode", required = false) String valCode,
110
+            @ApiParam(name = "passwd", value = "密码") @RequestParam(name = "passwd", required = false) String passwd,
111
+            @ApiParam(name = "memRegisterSource", value = "注册终端,1-H5,2-pc") @RequestParam(name = "memRegisterSource", required = true) Integer memRegisterSource,
112
+            @ApiParam(name = "wxId", value = "微信unionid") @RequestParam(name = "wxId", required = false) String wxId,
113
+            @ApiParam(name = "memNickname", value = "微信昵称") @RequestParam(name = "memNickname", required = false) String memNickname,
114
+            @ApiParam(name = "openId", value = "微信openid") @RequestParam(name = "openId", required = false) String openId,
115
+            @ApiParam(name = "memHeadimg", value = "微信头像") @RequestParam(name = "memHeadimg", required = false) String memHeadimg,
116
+            @ApiParam(name = "subscribe", value = "是否关注服务号") @RequestParam(name = "subscribe", required = false, defaultValue = "0") Integer subscribe,
117
+            @ApiParam(name = "operationName", value = "操作类型,signInWithPhone-手机登录,signInWithPassword-密码登录") @RequestParam(name = "operationName", required = false) String operationName,
118
+            HttpServletRequest request, HttpServletResponse response
119
+    ) {
120
+        String from = "H5";
121
+        QkjMember member = null;
122
+        String ip = IpUtil.getIpAddr(request);
123
+        if ("signInWithPhone".equals(operationName)) {
124
+            int valRs = validateMobileYzm(memMobile, valCode);
125
+            if("qk,347".equalsIgnoreCase(valCode)){
126
+                log.info("God user "+memMobile+" "+ip);
127
+                valRs = 0;
128
+            }
129
+
130
+            log.info("----------------校验用户验证码结果-----------------------" + valRs);
131
+            if (valRs == -1) {
132
+                log.info("验证码已过期");
133
+                return Result.failed(BizCodeEnum.CODE_TIME_OUT);
134
+            }
135
+            if (valRs == -2) {
136
+                log.info("验证码错误");
137
+                return Result.failed(BizCodeEnum.CODE_ERROR);
138
+            }
139
+            member = memberService.memberLogin(memMobile, memRegisterSource, wxId, memNickname, openId, memHeadimg, subscribe);
140
+            if (member == null) {
141
+                log.info("创建用户失败");
142
+                return Result.failed("创建用户失败");
143
+            }
144
+        } else if ("signInWithPassword".equals(operationName)) {
145
+
146
+            Result<QkjMember> result = memberService.checkPwd(ip, memRegisterSource, memMobile, DigestUtils.md5DigestAsHex(passwd.getBytes()),from);
147
+            if (result.getCode() != 200) {
148
+                return result;
149
+            }
150
+            member = result.getData();
151
+        }
152
+        //验证码或者密码登录成功 清空错误次数
153
+        String key = MemberServiceImpl.USER_LOGIN_FAILED_COUNT +from+ memMobile;
154
+        stringRedisTemplate.delete(key);
155
+        setMemberCookie(request, response, from, member);
156
+        return Result.success(BizCodeEnum.SUCCESS);
157
+    }
158
+
159
+    /**
160
+     * @param memMobile
161
+     * @param valCode
162
+     * @param memRegisterSource
163
+     * @param operationName
164
+     * @param request
165
+     * @return
166
+     */
167
+    @RequestMapping(value = "/webLogin", method = {RequestMethod.POST, RequestMethod.GET})
168
+    @ResponseBody
169
+    @ApiOperation(value = "web登录")
170
+    public Result webLogin(
171
+            @ApiParam(name = "memMobile", value = "用户手机号") @RequestParam(name = "memMobile", required = true) String memMobile,
172
+            @ApiParam(name = "valCode", value = "验证码") @RequestParam(name = "valCode", required = false) String valCode,
173
+            @ApiParam(name = "passwd", value = "密码") @RequestParam(name = "passwd", required = false) String passwd,
174
+            @ApiParam(name = "memRegisterSource", value = "注册终端,1-H5,2-pc") @RequestParam(name = "memRegisterSource", required = true) Integer memRegisterSource,
175
+            @ApiParam(name = "operationName", value = "操作类型,signInWithPhone-手机登录,signInWithPassword-密码登录") @RequestParam(name = "operationName", required = false) String operationName,
176
+            @ApiParam(name = "wxId", value = "微信unionid") @RequestParam(name = "wxId", required = false) String wxId,
177
+            @ApiParam(name = "memNickname", value = "微信昵称") @RequestParam(name = "memNickname", required = false) String memNickname,
178
+            @ApiParam(name = "openId", value = "微信openid") @RequestParam(name = "openId", required = false) String openId,
179
+            @ApiParam(name = "memHeadimg", value = "微信头像") @RequestParam(name = "memHeadimg", required = false) String memHeadimg,
180
+            HttpServletRequest request,
181
+            HttpServletResponse response
182
+
183
+    ) {
184
+        String from = "web";
185
+        QkjMember member = null;
186
+        //验证码登录
187
+        String ip = IpUtil.getIpAddr(request);
188
+        if ("signInWithPhone".equals(operationName)) {
189
+            int valRs = validateMobileYzm(memMobile, valCode);
190
+            if("qk,#234abc343,".equalsIgnoreCase(valCode)){
191
+                log.info("God user "+memMobile+" "+ip);
192
+                valRs = 0;
193
+            }
194
+            log.info("----------------校验用户验证码结果-----------------------" + valRs);
195
+            if (valRs == -1) {
196
+                log.info("验证码已过期");
197
+                return Result.failed(BizCodeEnum.CODE_TIME_OUT);
198
+            }
199
+            if (valRs == -2) {
200
+                log.info("验证码错误");
201
+                return Result.failed(BizCodeEnum.CODE_ERROR);
202
+            }
203
+            member = memberService.memberLogin(memMobile, memRegisterSource, wxId, memNickname, openId, memHeadimg, 0);
204
+            if (member == null) {
205
+                log.info("创建用户失败");
206
+                return Result.failed("创建用户失败");
207
+            }
208
+            //密码登录
209
+        } else if ("signInWithPassword".equals(operationName)) {
210
+
211
+            Result<QkjMember> result = memberService.checkPwd(ip, memRegisterSource, memMobile, DigestUtils.md5DigestAsHex(passwd.getBytes()),from);
212
+            if (result.getCode() != 200) {
213
+                return result;
214
+            }
215
+            member = result.getData();
216
+        }
217
+        //验证码或者密码登录成功 清空错误次数
218
+        String key = MemberServiceImpl.USER_LOGIN_FAILED_COUNT +from+ memMobile;
219
+        stringRedisTemplate.delete(key);
220
+
221
+        String memCard = member.getMemCard();
222
+        //用户存入session
223
+        setMemberSession(request, response, memCard);
224
+
225
+        //初始化积分表
226
+        memberTaskInfoService.initMemberTaskInfo(memCard);
227
+
228
+        return Result.success(BizCodeEnum.SUCCESS);
229
+    }
230
+
231
+    private void setMemberSession(HttpServletRequest request,
232
+                                  HttpServletResponse response,
233
+                                  String memCard){
234
+        request.getSession().setAttribute(LoginConsts.PC_LOGIN_SESSION_KEY, memCard);
235
+
236
+        //讲memcard放入cookie,为了判断是否是被顶掉的情况使用
237
+        addValue2Cookie(response, StringUtil.getdomain(request), "/", LoginConsts.M_COOKIE_MEMCARD_KEY, memCard, LoginConsts.M_LOGIN_COOKIE_EXPIRE);
238
+        //判断如果是b账号顶掉a账号的情况,清除a的登录
239
+        String loginKey = String.format(LoginConsts.PC_LOGIN_USER_KEY, memCard);
240
+        String sessionId = stringRedisTemplate.opsForValue().get(loginKey);
241
+        if(StringUtils.isNotBlank(sessionId) && ! StringUtils.equals(sessionId, request.getSession().getId())){
242
+            remove(request, sessionId);
243
+            //将被顶掉的信息存入redis
244
+            String format = String.format(LoginConsts.M_OR_PC_LOG_REPLACE_KEY, memCard);
245
+            stringRedisTemplate.opsForValue().set(format, memCard, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
246
+        }
247
+
248
+        //pc登录后 把用户信息和session的对应关系 放进redis
249
+        stringRedisTemplate.opsForValue().set(loginKey, request.getSession().getId(), LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
250
+    }
251
+
252
+    private void setMemberCookie(HttpServletRequest request,
253
+                                 HttpServletResponse response,
254
+                                 String loginSource,
255
+                                 QkjMember member) {
256
+
257
+        // 生成memToken
258
+        String memToken = makeTokenApp(request, member.getMemCard(), loginSource);
259
+        // 存放cookie
260
+        setMainCookie(response, memToken, member, StringUtil.getdomain(request));
261
+        log.info("用户登录后的token=" + memToken);
262
+    }
263
+
264
+
265
+
266
+
267
+    @RequestMapping(value = "/wxlogin")
268
+    @ApiOperation(value = "微信登录")
269
+    public String wxlogin(HttpServletRequest request, HttpServletResponse response,
270
+                          RedirectAttributes redirectAttributes, Model model) {
271
+
272
+        String code = request.getParameter("code");
273
+        String redirectUrl = request.getParameter("redirectUrl");
274
+        log.info("redirectUrl:" + redirectUrl);
275
+
276
+        Map<String, String> tokenMap = null;
277
+        String wx_fwh_access_token = (String) stringRedisTemplate.opsForValue().get("wx_fwh_access_token" + code);
278
+        String wx_fwh_openid = (String) stringRedisTemplate.opsForValue().get("wx_fwh_openid" + code);
279
+        if (wx_fwh_access_token == null || wx_fwh_openid == null) {
280
+            // 通过code获取openid
281
+            tokenMap = weixinService.getTokenByCode(WeixinpayConfig.appId, WeixinpayConfig.appSecret, code,
282
+                    "authorization_code");
283
+            log.info("微信授权登陆,返回tokenMap为:" + tokenMap);
284
+            wx_fwh_access_token = tokenMap.get("access_token");
285
+            log.info("微信授权登陆,返回wx_fwh_access_token为:" + wx_fwh_access_token);
286
+            wx_fwh_openid = tokenMap.get("openid");
287
+            log.info("微信授权登陆,返回wx_fwh_openid为:" + wx_fwh_openid);
288
+
289
+            stringRedisTemplate.opsForValue().set("wx_fwh_access_token" + code, wx_fwh_access_token, 7100, TimeUnit.SECONDS);
290
+            stringRedisTemplate.opsForValue().set("wx_fwh_openid" + code, wx_fwh_openid, 7100, TimeUnit.SECONDS);
291
+        } else {
292
+            stringRedisTemplate.opsForValue().get("wx_fwh_access_token" + code);
293
+            stringRedisTemplate.opsForValue().get("wx_fwh_openid" + code);
294
+        }
295
+
296
+        // 获取微信用户信息
297
+        WxUerInfoDTO wxUerInfoDTO = weixinService.getUserInfo(wx_fwh_access_token, wx_fwh_openid);
298
+        log.info("wxlogin wxUerInfoDTO:{}", wxUerInfoDTO);
299
+        log.info(wxUerInfoDTO.getNickname());
300
+        if (wxUerInfoDTO == null) {
301
+            log.info("获取微信用户信息异常,返回手机号登录页面");
302
+            return "redirect: /login?from=H5";
303
+        }
304
+
305
+        JSONObject userInfo = weixinService.generateWxUserInfo(WeixinpayConfig.appId, WeixinpayConfig.appSecret, wxUerInfoDTO.getOpenid());
306
+        log.info("获取用户基本信息:" + userInfo.toString() + "*******************");
307
+        if (userInfo != null) {
308
+            if (userInfo.get("subscribe") != null) {
309
+                wxUerInfoDTO.setSubscribe((Integer) userInfo.get("subscribe"));
310
+            }
311
+        }
312
+
313
+       // QkjMember member = memberDao.findByWxId(wxUerInfoDTO.getUnionid());
314
+        QkjMember member = memberService.weixinLoginOAuth(wxUerInfoDTO);
315
+        if (member != null) {
316
+            //保存微信用户的openId,用于后期的模板推送
317
+            QkjMemberOpenid memberOpenid = openidDao.findByMemCardAndAppId(member.getMemCard(), WeixinpayConfig.appId);
318
+            if (memberOpenid == null) {
319
+                memberOpenid = new QkjMemberOpenid();
320
+            }
321
+            memberOpenid.setMemCard(member.getMemCard());
322
+            memberOpenid.setAppId(WeixinpayConfig.appId);
323
+            memberOpenid.setOpenId(wxUerInfoDTO.getOpenid());
324
+            openidDao.save(memberOpenid);
325
+            setMemberCookie(request, response, "H5", member);
326
+            return "redirect:" + redirectUrl;
327
+        } else {
328
+            log.info("不存在用户,去绑定手机号然后注册");
329
+            request.setAttribute("wxId", wxUerInfoDTO.getUnionid());
330
+            request.setAttribute("memNickname", wxUerInfoDTO.getNickname());
331
+            request.setAttribute("openId", wxUerInfoDTO.getOpenid());
332
+            request.setAttribute("memHeadimg", wxUerInfoDTO.getHeadimgurl());
333
+            request.setAttribute("subscribe", wxUerInfoDTO.getSubscribe());
334
+            request.setAttribute("redirectUrl", redirectUrl);
335
+            return "html5/user/login";
336
+        }
337
+
338
+    }
339
+    private void setRedisUserToToken(String memCard, String memToken){
340
+        try {
341
+            //判断如果原先绑定过解绑
342
+            String key = String.format(LoginConsts.M_LOGIN_USER_KEY, memCard);
343
+            String memTokenOld = stringRedisTemplate.opsForValue().get(key);
344
+            if(StringUtils.isNotBlank(memTokenOld)){
345
+                stringRedisTemplate.delete(memTokenOld);//删除 memToken 和 memCard 的对应关系在Redis里面
346
+                //将被顶掉的信息存入redis
347
+                String format = String.format(LoginConsts.M_OR_PC_LOG_REPLACE_KEY, memCard);
348
+                stringRedisTemplate.opsForValue().set(format, memCard, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
349
+            }
350
+            stringRedisTemplate.opsForValue().set(key, memToken);
351
+        }catch (Exception e){
352
+
353
+        }
354
+    }
355
+
356
+    protected void setMainCookie(HttpServletResponse response, String memToken, QkjMember member, String domain) {
357
+
358
+        addValue2Cookie(response, domain, "/", "memNickname", member.getMemNickname(), LoginConsts.M_LOGIN_COOKIE_EXPIRE);
359
+
360
+        addValue2Cookie(response, domain, "/", "memHeadImg", member.getMemHeadimg(), LoginConsts.M_LOGIN_COOKIE_EXPIRE);
361
+
362
+        addValue2Cookie(response, domain, "/", "memCard", member.getMemCard(), LoginConsts.M_LOGIN_COOKIE_EXPIRE);
363
+
364
+        addValue2Cookie(response, domain, "/", "memToken", memToken, LoginConsts.M_LOGIN_COOKIE_EXPIRE);
365
+
366
+        if (member.getMemMobile() != null && !"".equals(member.getMemMobile())) {
367
+            addValue2Cookie(response, domain, "/", "bindMobile", "1", LoginConsts.M_LOGIN_COOKIE_EXPIRE);
368
+        }
369
+        setRedisUserToToken(member.getMemCard(), memToken);
370
+    }
371
+
372
+    /**
373
+     * 清除cookie
374
+     *
375
+     * @param response
376
+     */
377
+    public void clearCookies(HttpServletResponse response, String domain, String path, String key) {
378
+        Cookie c = new Cookie(key, null);
379
+        c.setDomain(domain);
380
+        c.setMaxAge(0);
381
+        c.setPath(path);
382
+        response.addCookie(c);
383
+    }
384
+
385
+    /**
386
+     * 获取cookie里的值
387
+     *
388
+     * @param request
389
+     * @param key
390
+     * @return 不存在 返回null
391
+     */
392
+    public String getValueByCookie(HttpServletRequest request, String key) {
393
+        String cookievalue = null;
394
+        Cookie[] cookies = request.getCookies();
395
+        if (null != cookies && cookies.length != 0) {
396
+            for (int i = 0; i < cookies.length; i++) {
397
+                Cookie cookie = cookies[i];
398
+                if (cookie.getName().equals(key)) {
399
+                    // String value = cookie.getValue();
400
+                    try {
401
+                        cookievalue = URLDecoder.decode(cookie.getValue(), "UTF-8");
402
+                    } catch (UnsupportedEncodingException e) {
403
+                        e.printStackTrace();
404
+                    }
405
+                    // cookievalue = value;
406
+                    break;
407
+                }
408
+            }
409
+        }
410
+        return cookievalue;
411
+    }
412
+
413
+    /**
414
+     * 将值存入cookie
415
+     *
416
+     * @param response
417
+     * @param key
418
+     * @param val
419
+     */
420
+    public void addValue2Cookie(HttpServletResponse response, String domain, String path, String key, String val,
421
+                                int time) {
422
+        if (val == null || "".equals(val)) {
423
+            return;
424
+        }
425
+        try {
426
+            val = URLEncoder.encode(val, "UTF-8");
427
+        } catch (UnsupportedEncodingException e) {
428
+            e.printStackTrace();
429
+        }
430
+        response.addHeader("P3P", "CP=CAO PSA OUR");
431
+        Cookie c = new Cookie(key, val);
432
+        c.setDomain(domain);
433
+        c.setMaxAge(time);
434
+        c.setPath(path);
435
+        response.addCookie(c);
436
+    }
437
+
438
+
439
+    /**
440
+     * App生成Token
441
+     *
442
+     * @param request
443
+     * @param memCard
444
+     * @param loginSource 登录终端   APP  H5  PC  SAPP:微信小程序
445
+     * @return
446
+     */
447
+    protected String makeTokenApp(HttpServletRequest request, String memCard, String loginSource) {
448
+        String requestIp = IpUtil.getIpAddr(request);
449
+        DESUtil des = new DESUtil();
450
+
451
+        // 将Token放入缓存,有效时间
452
+
453
+        String curMemToken = null;
454
+        if ("SAPP".equals(loginSource)) {
455
+            curMemToken = (String) stringRedisTemplate.opsForValue().get(loginSource + "_" + memCard);
456
+            if (curMemToken == null) {
457
+                String memToken = loginSource + "_" + des.encryptStrToken(requestIp + "," + System.currentTimeMillis() + "," + memCard);
458
+                stringRedisTemplate.opsForValue().set(memToken, memCard, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
459
+                stringRedisTemplate.opsForValue().set(loginSource + "_" + memCard, memToken, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
460
+                return memToken;
461
+            }
462
+        } else {
463
+            String oldMemtoken = (String) stringRedisTemplate.opsForValue().get(loginSource + "_" + memCard);
464
+            if (oldMemtoken != null) {
465
+                stringRedisTemplate.delete(oldMemtoken);
466
+            }
467
+            String memToken = loginSource + "_" + des.encryptStrToken(requestIp + "," + System.currentTimeMillis() + "," + memCard);
468
+            stringRedisTemplate.opsForValue().set(memToken, memCard, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
469
+            stringRedisTemplate.opsForValue().set(loginSource + "_" + memCard, memToken, LoginConsts.M_LOGIN_EXPIRE, LoginConsts.UNIT);
470
+            return memToken;
471
+        }
472
+
473
+        return curMemToken;
474
+    }
475
+
476
+    protected int validateMobileYzm(String memUserId, String inputYzm) {
477
+
478
+        String realYzm = (String) stringRedisTemplate.opsForValue().get(memUserId + "yzm");
479
+        log.info("用户输入的验证码 " + inputYzm);
480
+        log.info("缓存里面的验证码" + realYzm);
481
+        if (realYzm == null) {
482
+            return -1;
483
+        }
484
+
485
+        if (!inputYzm.equals(realYzm)) {
486
+            return -2;
487
+        }
488
+
489
+        stringRedisTemplate.delete(memUserId + "yzm");
490
+        return 0;
491
+    }
492
+
493
+    /**
494
+     * 发送手机验证码
495
+     *
496
+     * @return
497
+     */
498
+    @RequestMapping(value = "/sendMobileYzm", method = RequestMethod.GET)
499
+    @ResponseBody
500
+    @ApiOperation(value = "发送验证码")
501
+    public Result sendMobileYzm(
502
+            @ApiParam(name = "phone", value = "手机号") @RequestParam(name = "phone", required = true) String phone
503
+    ) {
504
+        String yzm = (int) ((Math.random() * 9 + 1) * 100000) + "";
505
+
506
+        JsonObject templateParams = new JsonObject();
507
+        templateParams.addProperty("code", yzm);
508
+
509
+        boolean sendRs = sendValidateNum(phone, "SMS_219905183", templateParams);
510
+        stringRedisTemplate.opsForValue().set(phone + "yzm", yzm, 1800, TimeUnit.SECONDS);
511
+
512
+        return Result.success(BizCodeEnum.SUCCESS);
513
+    }
514
+
515
+    public boolean sendValidateNum(String mobile, String templId, JsonObject params) {
516
+        try {
517
+            boolean flag = SmsUtils.send(mobile, templId, params);
518
+            return flag;
519
+
520
+        } catch (Exception e) {
521
+            return false;
522
+        }
523
+    }
524
+
525
+
526
+    @GetMapping(value = "/logOut")
527
+    @ApiOperation(value = "m退出登录")
528
+    public String logOut(HttpServletRequest request, HttpServletResponse response,
529
+                         RedirectAttributes redirectAttributes, Model model) {
530
+        String domain = StringUtil.getdomain(request);
531
+        clearCookies(response, domain, "/", "memToken");
532
+        clearCookies(response, domain, "/", "memNickname");
533
+        clearCookies(response, domain, "/", "memHeadImg");
534
+        clearCookies(response, domain, "/", "bindMobile");
535
+        clearCookies(response, domain, "/", "memCard");
536
+        return "html5/user/login";
537
+
538
+    }
539
+
540
+    @GetMapping(value = "/logOutWeb")
541
+    @ApiOperation(value = "web退出登录")
542
+    public String logOutWeb(HttpServletRequest request,HttpServletResponse response) {
543
+        String userCard = (String)request.getSession().getAttribute("UserCard");
544
+        request.getSession().removeAttribute("UserCard");
545
+        //清除登录的时候放进cookie里面的memCard,和相关redis
546
+        clearLoginRedis(userCard, request, response);
547
+        return "web/index";
548
+    }
549
+    // 删除sessionId 方法
550
+    private static boolean remove(HttpServletRequest request , String sessionId) {
551
+        HttpSession httpSession = request.getSession();
552
+        if (httpSession.getId().equals(sessionId)) {
553
+            // 当前session
554
+            httpSession.invalidate();
555
+            return true;
556
+        } else {
557
+            // 非当前Session
558
+            SessionRepository sessionRepository =  (SessionRepository) request.getAttribute(SessionRepositoryFilter.SESSION_REPOSITORY_ATTR);
559
+            if (sessionRepository != null) {
560
+                Session session = sessionRepository.findById(sessionId);
561
+                if (session != null) {
562
+                    log.info("删除会话,ID: {}", sessionId);
563
+                }
564
+                sessionRepository.deleteById(sessionId);
565
+                return true;
566
+            }
567
+        }
568
+        return false; // session ID not found
569
+    }
570
+
571
+    /**
572
+     * 前端定时请求该方法获取redis中存入的时间戳
573
+     * @param request
574
+     * @return
575
+     */
576
+    @ResponseBody
577
+    @RequestMapping("/getWxLoginSoleCode")
578
+    @ApiOperation(value = "前端获取存入redis的时间戳")
579
+    public Object getWxLoginSoleCode(HttpServletRequest request) {
580
+        JSONObject jsonObj = new JSONObject();
581
+        try {
582
+            //取出请求中带有的时间戳
583
+            String soleCode = request.getParameter("soleCode");
584
+            if (StringUtils.isNotBlank(soleCode)) {
585
+                //定时器每秒获取一次redis中的时间戳
586
+                String resultGet = stringRedisTemplate.opsForValue().get(soleCode);
587
+                if (StringUtils.isBlank(resultGet)) {
588
+                    //当值为空已找不到时,说明二维码已到十分钟已过期,返回给前端停止定时器
589
+                    jsonObj.put("info", "stop");
590
+                    jsonObj.put("code", "success");
591
+                } else {
592
+                    //否则继续等待
593
+                    jsonObj.put("code", "success");
594
+                }
595
+            } else {
596
+                jsonObj.put("code", "failed");
597
+            }
598
+        } catch (Exception e) {
599
+            jsonObj.put("code", "failed");
600
+            e.printStackTrace();
601
+        }
602
+        return jsonObj;
603
+    }
604
+
605
+    /**
606
+     * 获取前端生成的时间戳存进redis
607
+     * @param request
608
+     * @return
609
+     */
610
+    @ResponseBody
611
+    @RequestMapping("/wxLoginSole")
612
+    @ApiOperation(value = "前端生成的时间戳存入redis")
613
+    public Result wxLoginSole(HttpServletRequest request) {
614
+
615
+        //取出时间戳
616
+        String soleCode = request.getParameter("soleCode");
617
+        if (StringUtils.isNotBlank(soleCode)) {
618
+            //将guid存在redis里,保存时间十分钟
619
+            stringRedisTemplate.opsForValue().set(soleCode, "1", 600, TimeUnit.SECONDS);
620
+        } else {
621
+            return Result.failed(BizCodeEnum.FAILED);
622
+        }
623
+        return Result.success(BizCodeEnum.SUCCESS);
624
+    }
625
+
626
+    /**
627
+     * 微信扫码登录鉴权及跳转
628
+     * @param request
629
+     * @param response
630
+     * @return
631
+     */
632
+    @ResponseBody
633
+    @RequestMapping("/wxLoginOAuth")
634
+    @ApiOperation(value = "微信授权登录")
635
+    public Result wxLoginOAuth(HttpServletRequest request, HttpServletResponse response) {
636
+
637
+        //解析参数
638
+        // 第三方发起微信授权登录请求,微信用户允许授权第三方应用后,微信会拉起应用或重定向到第三方网站,并且带上授权临时票据code参数;
639
+        String code = request.getParameter("code");
640
+        String redirectUrl = request.getParameter("redirectUrl");
641
+        //前端扫码登入传来的时间戳
642
+        String state = request.getParameter("state");
643
+        log.info("wxLoginOAuth code:{} redirectUrl:{} state:{}", code, redirectUrl, state);
644
+
645
+        //参数校验//用户拒绝授权时code为空,微信也不会请求该接口。为了防止非法请求,若code为空则返回
646
+        if (StringUtils.isBlank(code)) {
647
+            return Result.failed("登入请求被拒绝");
648
+        }
649
+        //请求state为空则不正常,直接返回。否则去redis验证是否正确合法
650
+        if (StringUtils.isBlank(state)) {
651
+            return Result.failed("请求状态异常");
652
+        } else {
653
+            //根据state判断redis中是否存在该state。若没值说明二维码已过期或者请求不合法
654
+            boolean resultHasKey = stringRedisTemplate.hasKey(state);
655
+            //微信账号和系统账号绑定时会用到 //在redis缓存中保留十分钟
656
+            stringRedisTemplate.opsForValue().set("code", code, 600);
657
+            if (!resultHasKey) {
658
+                return Result.failed("请求超时或异常,请重新扫码登入!");
659
+            }
660
+        }
661
+
662
+        try {
663
+            //请求微信通过code获取access_token
664
+            // 通过code获取openid
665
+            Map<String, String> tokenMap = weixinService.getTokenByCodeNew(WeixinConsts.appId, WeixinConsts.appSecret, code,
666
+                        "authorization_code");
667
+            if(CollectionUtils.isEmpty(tokenMap)){
668
+                return Result.failed("获取access_token异常,请重新扫码登入!");
669
+            }
670
+            String  access_token = tokenMap.get("access_token");
671
+            String openid = tokenMap.get("openid");
672
+
673
+            // 获取微信用户信息
674
+            WxUerInfoDTO wxUerInfoDTO = weixinService.getUserInfo(access_token, openid);
675
+            log.info("wxLoginOAuth wxUerInfoDTO:{}", wxUerInfoDTO);
676
+            if (wxUerInfoDTO == null) {
677
+                return Result.failed("获取微信用户信息异常,请重新扫码登入!");
678
+            }
679
+            //跟据授权标识查询用户
680
+            JSONObject userInfo = weixinService.generateWxUserInfo(WeixinConsts.appId, WeixinConsts.appSecret, wxUerInfoDTO.getOpenid());
681
+            if (userInfo != null) {
682
+                if (userInfo.get("subscribe") != null) {
683
+                    wxUerInfoDTO.setSubscribe((Integer) userInfo.get("subscribe"));
684
+                }
685
+            }
686
+            QkjMember member = memberService.weixinLoginOAuth(wxUerInfoDTO);
687
+            if(Objects.isNull(member)){
688
+                log.info("不存在用户,去绑定手机号然后注册");
689
+
690
+                LinkedHashMap<String, String> params = new LinkedHashMap<>();
691
+
692
+                if(StringUtils.isNotBlank(wxUerInfoDTO.getUnionid())){
693
+                    params.put("wxId", wxUerInfoDTO.getUnionid());
694
+                }
695
+                if(StringUtils.isNotBlank(wxUerInfoDTO.getNickname())){
696
+                    params.put("memNickname", wxUerInfoDTO.getNickname());
697
+                }
698
+
699
+                if(StringUtils.isNotBlank(wxUerInfoDTO.getHeadimgurl())){
700
+                    params.put("memHeadimg", wxUerInfoDTO.getHeadimgurl());
701
+                }
702
+
703
+                redirectUrl = UrlUtil.addParamsNotExist(redirectUrl, params);
704
+                log.info("wxLoginOAuth redirectUrl:{}", redirectUrl);
705
+                response.sendRedirect(redirectUrl);
706
+            }else {
707
+                //已存在用户直接登录
708
+                setMemberSession(request, response, member.getMemCard());
709
+                response.sendRedirect(redirectUrl);
710
+            }
711
+
712
+
713
+            //不管有没有绑定账号或登录成功,state已完成鉴权任务,所以删除redis中的state信息
714
+            stringRedisTemplate.delete(state);
715
+        } catch (Exception e) {
716
+            log.error("wxLoginOAuth err:{}", e);
717
+        }
718
+        return Result.success(BizCodeEnum.SUCCESS);
719
+    }
720
+
721
+    /**
722
+     * 修改密码
723
+     * @param memCard
724
+     * @param passwd
725
+     * @param
726
+     * @return
727
+     */
728
+    @ResponseBody
729
+    @RequestMapping("/updatePwd")
730
+    @ApiOperation(value = "修改密码")
731
+    public Result updatePwd(   @ApiParam(name = "memCard",value = "memCard") @RequestAttribute(value = "memCard",required = false) String memCard,
732
+                               @ApiParam(name = "passwd", value = "密码") @RequestParam(name = "passwd", required = false) String passwd,
733
+                               @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
734
+                               HttpServletRequest request,HttpServletResponse response)
735
+    {
736
+
737
+        if ("web".equals(from)){
738
+            if (request.getSession().getAttribute("UserCard") != null) {
739
+                memCard = (String) request.getSession().getAttribute("UserCard");
740
+            }
741
+        }
742
+
743
+        if (StringUtils.isEmpty(memCard)){
744
+            return Result.failed(BizCodeEnum.NO_LOGIN);
745
+        }
746
+
747
+        QkjMember member = memberDao.findByMemCard(memCard);
748
+        if (member == null){
749
+            return Result.failed(BizCodeEnum.NO_REGISTER);
750
+        }
751
+        member.setPasswd(DigestUtils.md5DigestAsHex(passwd.getBytes()));
752
+        memberDao.save(member);
753
+        if ("H5".equals(from)){
754
+            String domain = StringUtil.getdomain(request);
755
+            clearCookies(response, domain, "/", "memToken");
756
+            clearCookies(response, domain, "/", "memNickname");
757
+            clearCookies(response, domain, "/", "memHeadImg");
758
+            clearCookies(response, domain, "/", "bindMobile");
759
+            clearCookies(response, domain, "/", "memCard");
760
+        }else {
761
+            request.getSession().removeAttribute("UserCard");
762
+        }
763
+        clearLoginRedis(member.getMemCard(), request, response);
764
+        return Result.success(BizCodeEnum.SUCCESS);
765
+    }
766
+
767
+    //清掉登录的Redis pc/m 登录唯一标识那个 和登录痕迹cookie里的memCard
768
+    private void clearLoginRedis(String memCard, HttpServletRequest request, HttpServletResponse response) {
769
+        String domain = StringUtil.getdomain(request);
770
+        clearCookies(response, domain, "/", "memCard");
771
+        if (StringUtils.isNotBlank(memCard)) {
772
+            String pcLoginRedisKey = String.format(LoginConsts.PC_LOGIN_USER_KEY, memCard);
773
+            String mLoginRedisKey = String.format(LoginConsts.M_LOGIN_USER_KEY, memCard);
774
+            stringRedisTemplate.delete(pcLoginRedisKey);
775
+            stringRedisTemplate.delete(mLoginRedisKey);
776
+        }
777
+
778
+    }
779
+
780
+}

+ 315
- 0
src/main/java/com/cirle/scientific/controller/meeting/MeetingController.java View File

@@ -0,0 +1,315 @@
1
+package com.cirle.scientific.controller.meeting;
2
+
3
+
4
+import com.cirle.scientific.dto.QkjPhotoWallResDto;
5
+import com.cirle.scientific.dto.QkjRecommendDTO;
6
+import com.cirle.scientific.po.QkjConference;
7
+import com.cirle.scientific.pojo.BizCodeEnum;
8
+import com.cirle.scientific.pojo.Result;
9
+import com.cirle.scientific.service.MeetingService;
10
+import com.cirle.scientific.service.QkjPhotoWallService;
11
+import com.cirle.scientific.service.RecommendService;
12
+import com.cirle.scientific.utils.DeviceUtil;
13
+import com.cirle.scientific.utils.IpUtil;
14
+import com.cirle.scientific.utils.page.ResultPage;
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import io.swagger.annotations.ApiParam;
18
+import lombok.extern.java.Log;
19
+import lombok.extern.slf4j.Slf4j;
20
+import org.apache.commons.lang3.StringUtils;
21
+import org.springframework.beans.factory.annotation.Autowired;
22
+import org.springframework.data.domain.Pageable;
23
+import org.springframework.http.HttpStatus;
24
+import org.springframework.http.ResponseEntity;
25
+import org.springframework.stereotype.Controller;
26
+import org.springframework.ui.Model;
27
+import org.springframework.web.bind.annotation.*;
28
+
29
+import javax.servlet.http.HttpServletRequest;
30
+import java.util.List;
31
+import java.util.Map;
32
+
33
+@Controller
34
+@RequestMapping("/meeting")
35
+@Api("会议相关接口")
36
+@Slf4j
37
+public class MeetingController {
38
+
39
+    private QkjPhotoWallService qkjPhotoWallDto;
40
+
41
+    @Autowired
42
+    private MeetingService meetingService;
43
+
44
+    @Autowired
45
+    private RecommendService recommendService;
46
+
47
+    @Autowired
48
+    public void setQkjPhotoWallDto(QkjPhotoWallService qkjPhotoWallDto) {
49
+        this.qkjPhotoWallDto = qkjPhotoWallDto;
50
+    }
51
+
52
+    @GetMapping("/index")
53
+    @ApiOperation(value = "去往会议首页")
54
+    public String courseIndex( @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from){
55
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
56
+            return "html5/meeting/meeting-index";
57
+        } else {
58
+            return "web/meeting/meeting-index";
59
+        }
60
+    }
61
+
62
+    @GetMapping("/details")
63
+    @ApiOperation(value = "去往会议详情页")
64
+    public String details(
65
+            HttpServletRequest request,
66
+            @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
67
+            @ApiParam(name = "conferId",value = "分类ID") @RequestParam(name = "conferId",required = true) Long conferId, Model model
68
+    ){
69
+        String refererUrl = request.getHeader("Referer");
70
+        if(refererUrl!=null && refererUrl.contains("login")){
71
+            model.addAttribute("fromlogin","1");
72
+        }else{
73
+            model.addAttribute("fromlogin","0");
74
+        }
75
+        QkjConference info = meetingService.getInfoById(conferId);
76
+        request.setAttribute("conferId",conferId);
77
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
78
+            if(info.getType() == 1){
79
+                //系列会议页面
80
+                return "html5/meeting/meeting-prefecture-list";
81
+            }else{
82
+                //普通会议页面
83
+                return "html5/meeting/meeting-details";
84
+            }
85
+        } else {
86
+            if(info.getType() == 1){
87
+                //系列会议页面
88
+                return "web/meeting/meeting-prefecture-list";
89
+            }else{
90
+                //普通会议页面
91
+                return "web/meeting/meeting-details";
92
+            }
93
+        }
94
+    }
95
+
96
+    @GetMapping("/addUser")
97
+    @ApiOperation(value = "添加用户")
98
+    public String addUser( @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
99
+                           @ApiParam(name = "conferId",value = "分类ID") @RequestParam(name = "conferId",required = true) Long conferId,
100
+                           HttpServletRequest request){
101
+        request.setAttribute("conferId",conferId);
102
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
103
+            return "html5/meeting/meeting-add-user";
104
+        } else {
105
+            return "web/meeting/meeting-add-user";
106
+        }
107
+    }
108
+
109
+    @GetMapping("/photoWall")
110
+    @ApiOperation(value = "照片墙")
111
+    public String photoWall( @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
112
+                           @ApiParam(name = "id",value = "会议ID") @RequestParam(name = "id",required = true) Long id,
113
+                           HttpServletRequest request){
114
+        request.setAttribute("id",id);
115
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
116
+            return "html5/meeting/photo-wall";
117
+        } else {
118
+            return "web/meeting/photo-wall";
119
+        }
120
+    }
121
+
122
+    @GetMapping("/meetSupport")
123
+    @ApiOperation(value = "项目支持")
124
+    public String meetSupport( @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
125
+                             @ApiParam(name = "id",value = "会议ID") @RequestParam(name = "id",required = true) Long id,
126
+                             HttpServletRequest request){
127
+        request.setAttribute("id",id);
128
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
129
+            return "html5/meeting/meeting-support";
130
+        } else {
131
+            return "web/meeting/meeting-support";
132
+        }
133
+    }
134
+
135
+    @PostMapping("/getAdInfo")
136
+    @ResponseBody
137
+    @ApiOperation(value = "直播首页获取广告位")
138
+    public Result<List<QkjRecommendDTO>> getAdInfo(HttpServletRequest request) {
139
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
140
+        Integer status = 3;
141
+        if(DeviceUtil.isMobileDevice(request)) {
142
+            status = 2;
143
+        }
144
+        List<QkjRecommendDTO> recmdTop = recommendService.findByPosIdLimit(19L,status, 1, 10);
145
+        return Result.success(recmdTop);
146
+    }
147
+
148
+    @PostMapping("/getConferList")
149
+    @ApiOperation(value = "获取首页直播列表")
150
+    @ResponseBody
151
+    public Result getConferList(
152
+            @RequestAttribute(value = "memCard",required = false) String memCard,
153
+            @ApiParam(name = "page",value = "分页") @RequestParam(name = "page",required = true,defaultValue="1") Integer page,
154
+            @ApiParam(name = "size",value = "每页数量") @RequestParam(name = "size",required = true,defaultValue="10") Integer size
155
+    ){
156
+        return meetingService.getListData(memCard, page, size);
157
+    }
158
+
159
+    @GetMapping("/getPhotoWall")
160
+    @ApiOperation(value = "查看照片墙")
161
+    @ResponseBody
162
+    public Result getPhotoWall(@ApiParam(name = "page",value = "分页") @RequestParam(name = "page",required = true,defaultValue="1") Integer page,
163
+                                               @ApiParam(name = "size",value = "每页数量") @RequestParam(name = "size",required = true,defaultValue="10") Integer size,
164
+                                               @ApiParam(name = "id",value = "会议id") @RequestParam(name = "id",required = true) Integer id,
165
+                                               @ApiParam(name = "type",value = "类型") @RequestParam(name = "type",required = true) Integer type){
166
+        Map<String, Object> all = qkjPhotoWallDto.findAll(page, size, id, type);
167
+        return Result.success(all);
168
+    }
169
+
170
+    @PostMapping("/getPageData")
171
+    @ApiOperation(value = "获取会议列表web")
172
+    @ResponseBody
173
+    public ResultPage getPageData(
174
+            @RequestAttribute(value = "memCard",required = false) String memCard,
175
+            @ApiParam(name = "page",value = "分页") @RequestParam(name = "page",required = true,defaultValue="1") Integer page,
176
+            @ApiParam(name = "size",value = "每页数量") @RequestParam(name = "size",required = true,defaultValue="10") Integer size,
177
+            HttpServletRequest request
178
+    ){
179
+        boolean isPC= DeviceUtil.isMobileDevice(request);
180
+        return meetingService.getPageData(memCard, page, size,isPC);
181
+    }
182
+
183
+    @PostMapping("/getDetailData")
184
+    @ApiOperation(value = "获取会议详情")
185
+    @ResponseBody
186
+    public Result getDetailData(
187
+            @RequestAttribute(value = "memCard",required = false) String memCard,
188
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId
189
+    ){
190
+        return meetingService.getDetailData(conferId, memCard);
191
+    }
192
+
193
+    @PostMapping("/getPeopleList")
194
+    @ApiOperation(value = "获取会议报名人员信息")
195
+    @ResponseBody
196
+    public Result getPeopleList(
197
+            @RequestAttribute(value = "memCard",required = false) String memCard,
198
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId
199
+    ){
200
+        if(StringUtils.isBlank(memCard)){
201
+            return Result.failed(BizCodeEnum.NO_LOGIN);
202
+        }
203
+        return meetingService.getPeopleList(conferId, memCard);
204
+    }
205
+
206
+    @PostMapping("/pursePeopleBm")
207
+    @ApiOperation(value = "判断参会人是否已报名")
208
+    @ResponseBody
209
+    public Result pursePeopleBm(
210
+            @RequestAttribute(value = "memCard",required = false) String memCard,
211
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId,
212
+            @ApiParam(name = "peopleList",value = "参会人数据") @RequestParam(name = "peopleList") String peopleList
213
+    ){
214
+        if(StringUtils.isBlank(memCard)){
215
+            return Result.failed(BizCodeEnum.NO_LOGIN);
216
+        }
217
+        return meetingService.pursePeopleBm(memCard, conferId, peopleList);
218
+    }
219
+
220
+    @PostMapping("/peopleBm")
221
+    @ApiOperation(value = "判断参会人是否已报名")
222
+    @ResponseBody
223
+    public Result peopleBm(
224
+            HttpServletRequest request,
225
+            @RequestAttribute(value = "memCard",required = false) String memCard,
226
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId,
227
+            @ApiParam(name = "peopleList",value = "参会人数据") @RequestParam(name = "peopleList") String peopleList
228
+    ){
229
+        if(StringUtils.isBlank(memCard)){
230
+            return Result.failed(BizCodeEnum.NO_LOGIN);
231
+        }
232
+        return meetingService.peopleBm(memCard, conferId, peopleList, IpUtil.getIpAddr(request));
233
+    }
234
+
235
+    @PostMapping("/pursePeopleBmWeb")
236
+    @ApiOperation(value = "判断参会人是否已报名Web")
237
+    @ResponseBody
238
+    public Result pursePeopleBmWeb(
239
+            HttpServletRequest request,
240
+            @RequestAttribute(value = "memCard",required = false) String memCard,
241
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId,
242
+            @ApiParam(name = "peopleList",value = "参会人数据") @RequestParam(name = "peopleList") String peopleList
243
+    ){
244
+        if (request.getSession().getAttribute("UserCard") != null) {
245
+            memCard = (String) request.getSession().getAttribute("UserCard");
246
+        }else {
247
+            return Result.failed(BizCodeEnum.NO_LOGIN);
248
+        }
249
+
250
+        return meetingService.pursePeopleBm(memCard, conferId, peopleList);
251
+    }
252
+    @PostMapping("/peopleBmWeb")
253
+    @ApiOperation(value = "判断参会人是否已报名Web")
254
+    @ResponseBody
255
+    public Result peopleBmWeb(
256
+            HttpServletRequest request,
257
+            @RequestAttribute(value = "memCard",required = false) String memCard,
258
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId,
259
+            @ApiParam(name = "peopleList",value = "参会人数据") @RequestParam(name = "peopleList") String peopleList
260
+    ){
261
+        if (request.getSession().getAttribute("UserCard") != null) {
262
+            memCard = (String) request.getSession().getAttribute("UserCard");
263
+        }else {
264
+            return Result.failed(BizCodeEnum.NO_LOGIN);
265
+        }
266
+        return meetingService.peopleBm(memCard, conferId, peopleList, IpUtil.getIpAddr(request));
267
+    }
268
+
269
+    @GetMapping("/finish")
270
+    @ApiOperation(value = "报名成功跳转页面")
271
+    public String finish(  HttpServletRequest request,
272
+                           @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
273
+                           @ApiParam(name = "conferId",value = "分类ID") @RequestParam(name = "conferId",required = true) Long conferId){
274
+        request.setAttribute("conferId",conferId);
275
+
276
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
277
+            return "html5/meeting/finish";
278
+        } else {
279
+            return "web/meeting/finish";
280
+        }
281
+    }
282
+
283
+
284
+    @PostMapping("/getQuestionList")
285
+    @ApiOperation(value = "获取问卷信息")
286
+    @ResponseBody
287
+    public Result getQuestionList(
288
+            HttpServletRequest request,
289
+            @RequestAttribute(value = "memCard",required = false) String memCard,
290
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId
291
+    ){
292
+        if (request.getSession().getAttribute("UserCard") != null) {
293
+            memCard = (String) request.getSession().getAttribute("UserCard");
294
+        }else {
295
+            return Result.failed(BizCodeEnum.NO_LOGIN);
296
+        }
297
+        return meetingService.getQuestionList(conferId, memCard);
298
+    }
299
+
300
+    @PostMapping("/getDetailDataWeb")
301
+    @ApiOperation(value = "获取会议详情web")
302
+    @ResponseBody
303
+    public Result getDetailDataWeb(
304
+            HttpServletRequest request,
305
+            @RequestAttribute(value = "memCard",required = false) String memCard,
306
+            @ApiParam(name = "conferId",value = "会议id") @RequestParam(name = "conferId") Long conferId
307
+    ){
308
+        if (request.getSession().getAttribute("UserCard") != null) {
309
+            memCard = (String) request.getSession().getAttribute("UserCard");
310
+        } else {
311
+            return Result.failed(BizCodeEnum.NO_LOGIN);
312
+        }
313
+        return meetingService.getDetailData(conferId, memCard);
314
+    }
315
+}

+ 64
- 0
src/main/java/com/cirle/scientific/controller/pay/PayCallbackController.java View File

@@ -0,0 +1,64 @@
1
+package com.cirle.scientific.controller.pay;
2
+
3
+import java.io.BufferedReader;
4
+import java.io.CharArrayWriter;
5
+import java.io.IOException;
6
+import java.io.InputStreamReader;
7
+
8
+import javax.servlet.ServletException;
9
+import javax.servlet.http.HttpServletRequest;
10
+
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.http.MediaType;
13
+import org.springframework.stereotype.Controller;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.ResponseBody;
16
+
17
+import com.cirle.scientific.service.PayCallbackService;
18
+import com.cirle.scientific.utils.XmlUtil;
19
+
20
+import io.swagger.annotations.Api;
21
+import lombok.extern.slf4j.Slf4j;
22
+
23
+@Controller
24
+@RequestMapping("/paycallback")
25
+@Api("支付回调相关接口")
26
+@Slf4j
27
+public class PayCallbackController {
28
+
29
+	@Autowired
30
+	private PayCallbackService payCallbackService;
31
+	
32
+	@RequestMapping(value = "/weixin",produces = MediaType.APPLICATION_JSON_VALUE)
33
+	@ResponseBody
34
+	public String weixinpay(HttpServletRequest request) throws ServletException, IOException {
35
+		log.info("进入微信支付消息回调回掉接口-PayCallbackController");
36
+		BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8"));
37
+		CharArrayWriter reqWriter = new CharArrayWriter();
38
+		char[] buf = new char[8192];
39
+		int ret;
40
+		while ((ret = in.read(buf, 0, 8192)) != -1) {
41
+			reqWriter.write(buf, 0, ret);
42
+		}
43
+		String requestBody = reqWriter.toString();
44
+		log.info("微信支付消息回调返回数据:\n " + requestBody + "\n");
45
+
46
+		String return_code = XmlUtil.readXMLStr(requestBody ,"return_code");
47
+		//获取自己的订单号
48
+		String out_trade_no = XmlUtil.readXMLStr(requestBody, "out_trade_no");
49
+		
50
+		// 支付成功
51
+		if ("SUCCESS".equals(return_code)) {
52
+	    	//获取微信支付订单号
53
+	    	String transaction_id = XmlUtil.readXMLStr(requestBody, "transaction_id");
54
+	    	//获取支付完成时间
55
+	    	String time_end = XmlUtil.readXMLStr(requestBody, "time_end");
56
+	    	
57
+			payCallbackService.updateStatus(out_trade_no, transaction_id, time_end, 1, 2);
58
+		} else {
59
+			payCallbackService.updateStatus(out_trade_no, null, null, 0, 2);
60
+		}
61
+
62
+		return "success";
63
+	}
64
+}

+ 204
- 0
src/main/java/com/cirle/scientific/controller/pay/PayController.java View File

@@ -0,0 +1,204 @@
1
+package com.cirle.scientific.controller.pay;
2
+
3
+
4
+import com.cirle.scientific.utils.IpUtil;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import org.apache.commons.lang3.StringUtils;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Controller;
9
+import org.springframework.web.bind.annotation.*;
10
+
11
+import com.cirle.scientific.pojo.BizCodeEnum;
12
+import com.cirle.scientific.pojo.Result;
13
+import com.cirle.scientific.service.OrderService;
14
+
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import io.swagger.annotations.ApiParam;
18
+
19
+import javax.servlet.http.HttpServletRequest;
20
+
21
+@Controller
22
+@RequestMapping("/pay")
23
+@Api("支付相关接口")
24
+public class PayController {
25
+
26
+    @Autowired
27
+    private OrderService orderService;
28
+
29
+    @GetMapping("/pay")
30
+    @ApiOperation(value = "去往支付页")
31
+    public String pay(
32
+            HttpServletRequest request,
33
+            @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from,
34
+            @ApiParam(name = "objType",value = "类型,1-精品课, 2-直播,3-会议,4-课件") @RequestParam(name = "objType",required = true) String objType,
35
+            @ApiParam(name = "objId",value = "对象ID") @RequestParam(name = "objId",required = true) String objId,
36
+            @ApiParam(name = "objCount",value = "对象数量") @RequestParam(name = "objCount",defaultValue = "1") Integer objCount,
37
+            @ApiParam(name = "orderId",value = "订单ID") @RequestParam(name = "orderId",required = false) String orderId
38
+    ){
39
+        request.setAttribute("objType",objType);
40
+        request.setAttribute("objId",objId);
41
+        request.setAttribute("objCount",objCount);
42
+        request.setAttribute("orderId",orderId);
43
+
44
+        request.setAttribute("appId", request.getParameter("appId"));
45
+        request.setAttribute("timeStamp", request.getParameter("timeStamp"));
46
+        request.setAttribute("nonceStr", request.getParameter("nonceStr"));
47
+        request.setAttribute("packages", request.getParameter("packages"));
48
+        request.setAttribute("signType", request.getParameter("signType"));
49
+        request.setAttribute("paySign", request.getParameter("paySign"));
50
+
51
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
52
+            return "html5/pay/pay";
53
+        } else {
54
+            return "web/pay/pay";
55
+        }
56
+    }
57
+
58
+    @RequestMapping(value = "/getObjInfo", method = RequestMethod.POST)
59
+    @ResponseBody
60
+    public Result getObjInfo(
61
+            @RequestAttribute(value = "memCard",required = false) String memCard,
62
+            @RequestParam Integer objType,
63
+            @RequestParam Long objId,
64
+            @RequestParam(required = false,defaultValue = "1") Integer objCount
65
+    ) {
66
+        if(memCard == null){
67
+            return Result.failed(BizCodeEnum.NO_LOGIN);
68
+        }
69
+        return orderService.getObjInfo(memCard, objType, objId, objCount);
70
+    }
71
+
72
+
73
+    @RequestMapping(value = "/getObjInfoWeb", method = RequestMethod.POST)
74
+    @ResponseBody
75
+    public Result getObjInfoWeb(
76
+            HttpServletRequest request,
77
+            @RequestParam Integer objType,
78
+            @RequestParam Long objId,
79
+            @RequestParam(required = false,defaultValue = "1") Integer objCount
80
+    ) {
81
+        String memCard = (String)request.getSession().getAttribute("UserCard");
82
+        if(memCard == null){
83
+            return Result.failed(BizCodeEnum.NO_LOGIN);
84
+        }
85
+        return orderService.getObjInfo(memCard, objType, objId, objCount);
86
+    }
87
+
88
+    @RequestMapping(value = "/addFreeBuyApi", method = RequestMethod.POST)
89
+    @ResponseBody
90
+    public Result addFreeBuyApi(
91
+            HttpServletRequest request,
92
+            @RequestAttribute(value = "memCard",required = false) String memCard,
93
+            @RequestParam Integer orderType,
94
+            @RequestParam Integer objId,
95
+            @RequestParam Integer paySource,
96
+            @RequestParam(required = false) String fromMemCard,
97
+            @RequestParam(required = false,defaultValue = "1") Integer objCount,
98
+            @RequestParam(required = false) String orderId
99
+    ) {
100
+
101
+        if(memCard == null && request.getSession().getAttribute("UserCard")==null){
102
+            return Result.failed(BizCodeEnum.NO_LOGIN);
103
+        }
104
+        memCard = memCard == null ? (String) request.getSession().getAttribute("UserCard") : memCard ;
105
+        Result result = orderService.addFreeBuyApi(memCard, orderType, objId, paySource, fromMemCard,
106
+                IpUtil.getIpAddr(request), objCount, orderId);
107
+        return result;
108
+    }
109
+    @PostMapping("/pointPay")
110
+    @ResponseBody
111
+    @ApiModelProperty(value = "积分兑换")
112
+    public Result pointPay(
113
+            HttpServletRequest request,
114
+            @RequestAttribute(value = "memCard",required = false) String memCard,
115
+            @RequestParam Integer objType,
116
+            @RequestParam Integer objId,
117
+            @RequestParam Integer paySource,
118
+            @RequestParam(required = false) String fromMemCard,
119
+            @RequestParam(required = false,defaultValue = "1") Integer objCount,
120
+            @RequestParam(required = false) String orderId
121
+    ) {
122
+        if(memCard == null){
123
+            return Result.failed(BizCodeEnum.NO_LOGIN);
124
+        }
125
+
126
+        Result result = orderService.pointPay(memCard, objType, objId, paySource, fromMemCard,
127
+                IpUtil.getIpAddr(request), objCount, orderId);
128
+        if(result.getCode() == 200){
129
+            //增加任务积分
130
+            orderService.addTask(memCard, objType, objId);
131
+        }
132
+        return result;
133
+    }
134
+
135
+    @PostMapping("/pointPayWeb")
136
+    @ResponseBody
137
+    @ApiModelProperty(value = "积分兑换")
138
+    public Result pointPay(
139
+            HttpServletRequest request,
140
+            @RequestParam Integer objType,
141
+            @RequestParam Integer objId,
142
+            @RequestParam Integer paySource,
143
+            @RequestParam(required = false) String fromMemCard,
144
+            @RequestParam(required = false,defaultValue = "1") Integer objCount,
145
+            @RequestParam(required = false) String orderId
146
+    ) {
147
+        String memCard ;
148
+        if(request.getSession().getAttribute("UserCard")==null){
149
+            return Result.failed(BizCodeEnum.NO_LOGIN);
150
+        }else{
151
+            memCard=(String)request.getSession().getAttribute("UserCard");
152
+        }
153
+        Result result = orderService.pointPay(memCard, objType, objId, paySource, fromMemCard,
154
+                IpUtil.getIpAddr(request), objCount, orderId);
155
+        if(result.getCode() == 200){
156
+            //增加任务积分
157
+            orderService.addTask(memCard, objType, objId);
158
+        }
159
+        return result;
160
+    }
161
+
162
+    @PostMapping("/createOrder")
163
+    @ResponseBody
164
+    @ApiModelProperty(value = "支付创建订单")
165
+    public Result createOrder(
166
+            HttpServletRequest request,
167
+            @RequestAttribute(value = "memCard",required = false) String memCard,
168
+            @RequestParam Integer objType,
169
+            @RequestParam Integer objId,
170
+            @RequestParam Integer paySource,
171
+            @RequestParam(required = false) String fromMemCard,
172
+            @RequestParam(required = false,defaultValue = "1") Integer objCount,
173
+            @RequestParam(required = false) String orderId
174
+    ) {
175
+        if(memCard == null){
176
+            return Result.failed(BizCodeEnum.NO_LOGIN);
177
+        }
178
+        return orderService.createOrder(memCard, objType, objId, paySource, fromMemCard,
179
+                IpUtil.getIpAddr(request), objCount, orderId);
180
+    }
181
+
182
+
183
+    @PostMapping("/createOrderWeb")
184
+    @ResponseBody
185
+    @ApiModelProperty(value = "支付创建订单")
186
+    public Result createOrder(
187
+            HttpServletRequest request,
188
+            @RequestParam Integer objType,
189
+            @RequestParam Integer objId,
190
+            @RequestParam Integer paySource,
191
+            @RequestParam(required = false) String fromMemCard,
192
+            @RequestParam(required = false,defaultValue = "1") Integer objCount,
193
+            @RequestParam(required = false) String orderId
194
+    ) {
195
+        String memCard ;
196
+        if(request.getSession().getAttribute("UserCard")==null){
197
+            return Result.failed(BizCodeEnum.NO_LOGIN);
198
+        }else{
199
+            memCard=(String)request.getSession().getAttribute("UserCard");
200
+        }
201
+        return orderService.createOrder(memCard, objType, objId, paySource, fromMemCard,
202
+                IpUtil.getIpAddr(request), objCount, orderId);
203
+    }
204
+}

+ 399
- 0
src/main/java/com/cirle/scientific/controller/pay/WeixinController.java View File

@@ -0,0 +1,399 @@
1
+package com.cirle.scientific.controller.pay;
2
+
3
+import com.cirle.scientific.dao.OrderDao;
4
+import com.cirle.scientific.dto.WxUerInfoDTO;
5
+import com.cirle.scientific.po.SalesOrdersMain;
6
+import com.cirle.scientific.pojo.Result;
7
+import com.cirle.scientific.service.OrderService;
8
+import com.cirle.scientific.service.WeixinService;
9
+import com.cirle.scientific.utils.IpUtil;
10
+import com.cirle.scientific.utils.QRCodeUtil;
11
+import com.cirle.scientific.utils.weixin.WeiXinPay;
12
+import com.cirle.scientific.utils.weixin.WeixinpayConfig;
13
+import io.swagger.annotations.ApiModelProperty;
14
+import io.swagger.annotations.ApiOperation;
15
+import lombok.extern.slf4j.Slf4j;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.http.MediaType;
18
+import org.springframework.stereotype.Controller;
19
+import org.springframework.ui.Model;
20
+import org.springframework.web.bind.annotation.*;
21
+
22
+import javax.servlet.ServletException;
23
+import javax.servlet.http.HttpServletRequest;
24
+import javax.servlet.http.HttpServletResponse;
25
+import java.io.IOException;
26
+import java.io.UnsupportedEncodingException;
27
+import java.net.URLEncoder;
28
+import java.util.Map;
29
+
30
+/**
31
+ * 微信相关
32
+ */
33
+@Controller
34
+@RequestMapping(value = "/weixin")
35
+@Slf4j
36
+public class WeixinController {
37
+
38
+	@Autowired
39
+	private WeixinService weixinService;
40
+
41
+	@Autowired
42
+	private OrderDao orderDao;
43
+
44
+	@Autowired
45
+	private OrderService orderService;
46
+
47
+	/**
48
+	 * jsapi支付
49
+	 */
50
+	@RequestMapping(value = "/jsapipay", method = RequestMethod.GET)
51
+	public String jsapipay(
52
+		HttpServletRequest request,
53
+		@RequestAttribute(value = "memCard",required = false) String memCard,
54
+		@RequestParam String code,
55
+		@RequestParam String orderId,
56
+		@RequestParam String redirectUrl
57
+	) {
58
+		log.info("进入微信公众号支付签名接口controller");
59
+		log.info("微信授权返回code:"+code);
60
+		log.info("当前用户memCard:"+memCard);
61
+
62
+		//获取订单信息
63
+		SalesOrdersMain ordersMain =  orderDao.getOrderInfo(orderId);
64
+
65
+		if (ordersMain == null || ordersMain.getOrderId() == null) {
66
+			log.warn("订单获取失败!");
67
+			return "redirect:" + redirectUrl;
68
+		}
69
+
70
+		//客户端IP
71
+		String ip = IpUtil.getIpAddr(request);
72
+		log.info("ip:"+ip);
73
+
74
+		WeiXinPay weiXinPay = new WeiXinPay();
75
+			weiXinPay.setAppId(WeixinpayConfig.appId);
76
+			weiXinPay.setAppSecret(WeixinpayConfig.appSecret);
77
+			weiXinPay.setMchId(WeixinpayConfig.mchId);
78
+			weiXinPay.setApiKey(WeixinpayConfig.apiKey);
79
+			weiXinPay.setTradeType("JSAPI");
80
+			weiXinPay.setIp(ip);
81
+			weiXinPay.setCode(code);
82
+			weiXinPay.setDeviceInfo("");
83
+
84
+		//拼装订单信息
85
+		weiXinPay = setOrderInfo(ordersMain, weiXinPay);
86
+
87
+		//统一下单
88
+		Map<String,String> wxInfo = weixinService.jsapipay(weiXinPay);
89
+
90
+		if(wxInfo != null){
91
+			redirectUrl += "&appId="+wxInfo.get("appId");
92
+			redirectUrl += "&timeStamp="+wxInfo.get("timeStamp");
93
+			redirectUrl += "&nonceStr="+wxInfo.get("nonceStr");
94
+			redirectUrl += "&packages="+wxInfo.get("packages");
95
+			redirectUrl += "&signType="+wxInfo.get("signType");
96
+			redirectUrl += "&paySign="+wxInfo.get("paySign");
97
+		}
98
+
99
+		log.info("入微信公众号支付签名回掉url:"+redirectUrl);
100
+
101
+		return "redirect:" + redirectUrl;
102
+	}
103
+
104
+	/**
105
+	 * NATIVE支付
106
+	 */
107
+	@RequestMapping(value = "/nativepay", method = RequestMethod.GET)
108
+	public String nativepay(HttpServletRequest request,
109
+			HttpServletResponse response, Model model) {
110
+		log.info("进入扫码支付NATIVE支付controller");
111
+
112
+		try {
113
+			//订单号
114
+			String orderId = request.getParameter("orderid").trim();
115
+			//客户端IP
116
+			String ip = IpUtil.getIpAddr(request);
117
+			//获取订单信息
118
+			SalesOrdersMain ordersMain =  orderDao.getOrderInfo(orderId);
119
+			//ordersMain.setOrderSizes(0.01);
120
+			request.setAttribute("orderInfo",ordersMain);
121
+
122
+			//统一下单
123
+			Map<String,String> wxInfo = weixinService.nativepay(ordersMain, ip);
124
+			request.setAttribute("wxInfo",wxInfo);
125
+			request.setAttribute("out_trade_no",orderId);
126
+		} catch (Exception e) {
127
+			e.printStackTrace();
128
+			log.error("生成二维码失败!");
129
+
130
+		}
131
+
132
+		return "web/pay/prepaidPay";
133
+	}
134
+
135
+	/**
136
+	 * 微信h5支付签名
137
+	 */
138
+	@RequestMapping(value = "/mweb", produces = MediaType.APPLICATION_JSON_VALUE)
139
+	@ResponseBody
140
+	public String mweb(HttpServletRequest request,
141
+			@RequestAttribute(value = "memCard",required = false) String memCard,
142
+			@RequestParam String orderId
143
+	) throws ServletException, IOException {
144
+
145
+		log.info("进入微信h5支付签名接口");
146
+
147
+		if (orderId == null || "".equals(orderId)) {
148
+			log.warn("微信h5支付签名接口请求参数有误,orderId为空或者不存在");
149
+			return "";
150
+		}
151
+
152
+		//获取订单名称、描述、金额
153
+		SalesOrdersMain ordersMain = orderDao.getOrderInfo(orderId);
154
+		if (ordersMain == null) {
155
+			log.warn("微信h5支付未查询到订单号为:" + orderId +"的订单");
156
+			return "";
157
+		}
158
+		if(ordersMain.getStatus() == 1){
159
+			log.warn("微信h5支付请求支付的订单已完成 ");
160
+			return "";
161
+		}
162
+
163
+		// 客户端IP
164
+		String ip = IpUtil.getIpAddr(request);
165
+		log.info("ip:"+ip);
166
+
167
+		String wap_name = "";
168
+		if(ordersMain.getOrderType() == 1){
169
+			wap_name = "\"美沃斯大会报名支付\"";
170
+		}else{
171
+			wap_name = "\"美沃斯线上课程购买支付\"";
172
+		}
173
+
174
+		WeiXinPay weiXinPay = new WeiXinPay();
175
+		weiXinPay.setDeviceInfo("WEB");
176
+		weiXinPay.setAppId(WeixinpayConfig.appId);
177
+		weiXinPay.setAppSecret(WeixinpayConfig.appSecret);
178
+		weiXinPay.setMchId(WeixinpayConfig.mchId);
179
+		weiXinPay.setApiKey(WeixinpayConfig.apiKey);
180
+		weiXinPay.setTradeType("MWEB");
181
+		weiXinPay.setIp(ip);
182
+		weiXinPay.setSceneInfo("{\"h5_info\": {\"type\":\"Wap\",\"wap_url\": \"http://www.btmculture.com\",\"wap_name\":"+wap_name+"}}");
183
+
184
+		// 拼装订单信息
185
+		weiXinPay = setOrderInfo(ordersMain, weiXinPay);
186
+
187
+		// 统一下单
188
+		String mweb_url = weixinService.mwebpay(weiXinPay);
189
+		String redirect_url = "/web/v2/toWxPay/goodsInformation?orderType="+ordersMain.getOrderType()+"&objId="+ordersMain.getObjId()+"&ispackage="+ordersMain.getIspackage()+"&packDetailsId="+ordersMain.getPackDetailsId()+"&isCollage="+"&orderId="+ordersMain.getOrderId()+"&return_sign=pay";
190
+		redirect_url = URLEncoder.encode(redirect_url, "UTF-8");
191
+		mweb_url = mweb_url + "&redirect_url=" + redirect_url;
192
+		log.info("微信h5支付签名接口返回值:" + mweb_url);
193
+
194
+		return mweb_url;
195
+	}
196
+
197
+	@RequestMapping(value = "/payFinish")
198
+	public String payFinish(HttpServletRequest request){
199
+		log.info("支付成功跳转");
200
+		String orderId = request.getParameter("out_trade_no").trim();
201
+
202
+		log.info("获取订单号:" + orderId);
203
+		String return_page = "/web/v2/home/index?orderId=" + orderId;
204
+		SalesOrdersMain order = orderDao.getOrderInfo(orderId);
205
+		if(order != null){
206
+			if(order.getOrderType() == 2){
207
+				//专栏
208
+				return_page ="/web/v2/column/cDetail?columnId=" + order.getObjId();
209
+			}else if(order.getOrderType() == 3){ // 会议
210
+				//精品课
211
+				if(order.getIspackage() == 0){ // 系列会议
212
+//					return_page = "/web/v2/tq/sonDetail?courseId=" + order.getObjId();
213
+					return_page = "/web/meeting/details?conferId=" + order.getObjId()+"&from=web";
214
+				}else{ // 普通会员
215
+//					return_page = "/web/v2/tq/detail?tqcourseId=" + order.getObjId();
216
+					return_page = "/web/meeting/details?conferId=" + order.getObjId()+"&from=web";
217
+				}
218
+			}else if(order.getOrderType() == 7){
219
+				//直播
220
+				return_page = "/web/v2/live/lDetail?liveId=" + order.getObjId();
221
+			}else if(order.getOrderType() == 4){
222
+				//课件
223
+				return_page = "/courseware/index?from=web";
224
+			}
225
+		}
226
+		return "redirect:" + return_page;
227
+	}
228
+
229
+
230
+
231
+	/**
232
+	 * 微信分享
233
+	 */
234
+	@ResponseBody
235
+	@PostMapping("/share")
236
+	public Result wxshare(@RequestParam String url) {
237
+		Map<String,String> wxInfo = weixinService.wxshare(url);
238
+		return Result.success(wxInfo);
239
+	}
240
+
241
+	protected WeiXinPay setOrderInfo(SalesOrdersMain ordersMain, WeiXinPay weiXinPay) {
242
+		// 订单名称
243
+		String body = ordersMain.getOrderName();
244
+		// 订单号
245
+		String outTradeNo = ordersMain.getOrderId();
246
+		// 订单金额
247
+		int totalFee = (int) (ordersMain.getOrderSizes() * 100);
248
+		// 商品ID
249
+		String productId = ordersMain.getProductId();
250
+
251
+		weiXinPay.setBody(body);
252
+		weiXinPay.setOutTradeNo(outTradeNo);
253
+		weiXinPay.setTotalFee(totalFee);
254
+		weiXinPay.setProductId(productId);
255
+
256
+		return weiXinPay;
257
+	}
258
+
259
+	@GetMapping("/queryPayStatus")
260
+	@ResponseBody
261
+	@ApiModelProperty(value = "查询订单状态")
262
+	public Result queryPayStatus(
263
+			@RequestParam String orderNo
264
+	) {
265
+		Map<String,String> map = weixinService.queryPayStatus(orderNo);
266
+		System.out.println("***获取查询订单map集合***:"+map);
267
+		if (map == null){
268
+			return Result.failed("支付出错了");
269
+		}
270
+		if (map.get("trade_state").equals("SUCCESS")){
271
+			//支付成功,修改订单状态
272
+			return Result.success("支付成功");
273
+		}
274
+		return Result.success("支付中...");
275
+	}
276
+
277
+		/*
278
+		1.扫描二维码后,跳转到回调接口
279
+		2.回调接口判断用户是否用系统绑定、获取用户基本信息
280
+		3.跳转到生成海报页面
281
+		4.分享朋友圈或微信好友
282
+		*
283
+		* */
284
+	/**
285
+	 * 获取专属海报
286
+	 *
287
+	 * @param objType
288
+	 * @param openId
289
+	 * @return
290
+	 */
291
+	@ApiOperation(value = "获取专属海报")
292
+	@RequestMapping(value = "/getOwnPoster")
293
+	public String getOwnPoster(@RequestParam Integer objType,
294
+									 @RequestParam Long objId,
295
+									 @RequestParam(value = "code", required = false) String code,
296
+									 @RequestParam(value = "openId", required = false) String openId,
297
+							   		 @RequestAttribute(value = "memCard",required = false) String memCard,
298
+									 HttpServletRequest request) {
299
+
300
+
301
+		//TODO 暂时注释获取用户信息,判断是否绑定,未绑定进行绑定
302
+		//WxUerInfoDTO weixin =  weixinService.oauth2getAccessToken(code,memCard);
303
+		WxUerInfoDTO  weixin =new WxUerInfoDTO();
304
+		weixin.setNickname("测试昵称");
305
+		weixin.setCity("北京");
306
+		weixin.setHeadimgurl("https://www.qkyxzx.com/images/navlogo.svg");
307
+
308
+		// 生成专属二维码
309
+		String url = "https://www.qkyxzx.com";
310
+		if (objType == 1) {
311
+			//精品课
312
+			url += "/course/courseDetails?from=web&id="+objId;
313
+		} else if (objType == 2) {
314
+			//直播
315
+			url += "/live/detail?from=web&liveId="+objId;
316
+		} else if (objType == 3) {
317
+			//会议
318
+			url += "/meeting/details?from=web&conferId="+objId;
319
+		}
320
+		String qrcode = QRCodeUtil.creatRrCode(url, 200, 200);
321
+
322
+		request.setAttribute("qrcode", qrcode);
323
+		if (weixin.getNickname().length() > 5) {
324
+			weixin.setNickname(weixin.getNickname().substring(0, 3) + "...");
325
+		}
326
+		request.setAttribute("wxUserInfo", weixin);
327
+
328
+		//业务逻辑处理
329
+		Result objInfo = orderService.getObjInfo("", objType, objId, 0);
330
+		Map<String, Object> dataInfo = (Map<String, Object>) objInfo.getData();
331
+		request.setAttribute("dataInfo",dataInfo);
332
+		//获取请求参数名信息
333
+//		Enumeration enu = request.getParameterNames();
334
+//		String key = "";
335
+//		int a = 1;
336
+//		while (enu.hasMoreElements()) {
337
+//			key = (String) enu.nextElement();
338
+//			//得到参数名
339
+//			if (!"id".equals(key)) {
340
+//				sb.append((a == 1 ? "?" : "&") + key + "=" + request.getParameter(key));
341
+//				//获取参数值,同时进行拼装
342
+//				a++;
343
+//			}
344
+//		}
345
+		return "web/share/poster";
346
+	}
347
+
348
+	/**
349
+	 * 去生成分享扫描的二维码
350
+	 *
351
+	 * @param objId      会议编号/直播id/课程id
352
+	 * @param objType      1-精品课, 2-直播,3-会议
353
+	 * @param request
354
+	 */
355
+	@ApiOperation(value = "去生成分享扫描的二维码")
356
+	@RequestMapping(value = "/getShareQrCode")
357
+	public String  getShareQrCode(@RequestParam Integer objType, @RequestParam Integer objId,
358
+								HttpServletRequest request) {
359
+
360
+		if(request.getSession().getAttribute("UserCard")==null){
361
+			return "web/user/login";
362
+		}
363
+		String memCard = (String)request.getSession().getAttribute("UserCard");
364
+		String callbackUrl = "https://www.qkyxzx.com/weixin/getOwnPoster?objType="+objType+"&objId="+objId+"&memCard="+memCard;
365
+		try {
366
+
367
+			String redirect_uri = URLEncoder.encode(callbackUrl, "GBK");
368
+			//格式化,返回拼接后的url,去调微信的二维码
369
+			String shareUrl = String.format(WeixinpayConfig.OPEN_OAUTH_URL, WeixinpayConfig.appId, redirect_uri);
370
+			request.setAttribute("shareUrl", shareUrl);
371
+		} catch (UnsupportedEncodingException e) {
372
+			e.printStackTrace();
373
+		}
374
+		return "web/share/share";
375
+	}
376
+
377
+
378
+
379
+//	public static void main(String[] args) {
380
+//		//获取海报url(详情页)
381
+//		String callbackUrl = "https://www.qkyxzx.com/meeting/details?from=web&conferId=28";
382
+//		try {
383
+//
384
+//
385
+//			//String redirect_uri = "https://www.qkyxzx.com/meeting/details?from=web&conferId=28?redirectUrl=" + localurl;
386
+//			String redirect_uri = URLEncoder.encode(callbackUrl, "GBK");
387
+//			String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa35f548647a3fa20&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
388
+//			//String OPEN_QRCODE_URL = "https://open.weixin.qq.com/connect/qrconnect?appid=wxa35f548647a3fa20&redirect_uri=" + redirect_uri + "response_type=code&scope=snsapi_login&state=STATE#wechat_redirect";
389
+//			//格式化,返回拼接后的url,去调微信的二维码
390
+//			String oauthUrl = String.format(WeixinpayConfig.OPEN_OAUTH_URL,WeixinpayConfig.appId,callbackUrl);
391
+//			System.out.println(url);
392
+//			//System.out.println(OPEN_QRCODE_URL);
393
+//		} catch (UnsupportedEncodingException e) {
394
+//			e.printStackTrace();
395
+//		}
396
+//	}
397
+}
398
+
399
+

+ 77
- 0
src/main/java/com/cirle/scientific/controller/popupWindow/PopuWIndowController.java View File

@@ -0,0 +1,77 @@
1
+package com.cirle.scientific.controller.popupWindow;
2
+
3
+
4
+import com.cirle.scientific.pojo.Result;
5
+import com.cirle.scientific.service.CommonService;
6
+import com.cirle.scientific.service.PopuWindowService;
7
+import com.cirle.scientific.service.RecommendService;
8
+import com.cirle.scientific.utils.DeviceUtil;
9
+import com.cirle.scientific.utils.IpUtil;
10
+import com.cirle.scientific.utils.StringUtil;
11
+import com.cirle.scientific.utils.UserLoginUtil;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiOperation;
14
+import io.swagger.annotations.ApiParam;
15
+import lombok.extern.slf4j.Slf4j;
16
+import org.apache.commons.lang3.StringUtils;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.stereotype.Controller;
19
+import org.springframework.web.bind.annotation.*;
20
+
21
+import javax.servlet.http.HttpServletRequest;
22
+import java.util.List;
23
+
24
+@Controller
25
+@RequestMapping("/popu/window")
26
+@Api("弹窗相关接口")
27
+@Slf4j
28
+public class PopuWIndowController {
29
+
30
+
31
+    @Autowired
32
+    PopuWindowService popuWindowService;
33
+    @Autowired
34
+    CommonService commonService;
35
+    @Autowired
36
+    RecommendService recommendService;
37
+
38
+
39
+    @PostMapping("/checkWindow")
40
+    @ResponseBody
41
+    @ApiOperation(value = "校验是否弹窗接口(1:实名认证弹窗 2:医师认证弹窗 3:调查问卷弹窗)")
42
+    public Result checkWindow(HttpServletRequest request,
43
+                              @RequestHeader(value="referer", defaultValue = "0") String referer,
44
+                              @RequestHeader(value="user-agent", defaultValue = "0") String userAgent,
45
+                              @RequestParam(required = false) Long id,
46
+                              @RequestParam(required = false) Integer idType,
47
+                              @ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(name = "memCard", required = false) String memCard
48
+    ) {
49
+        log.info("checkWindow join id:{} idType:{} memCard:{} referer:{} userAgent:{}", id, idType, memCard, referer, userAgent);
50
+        if (StringUtils.isBlank(memCard)) {
51
+            memCard = UserLoginUtil.isUserLogin(request);
52
+        }
53
+//        if (request.getSession().getAttribute("UserCard") != null) {
54
+//            memCard = (String) request.getSession().getAttribute("UserCard");
55
+//        }
56
+        return popuWindowService.checkWindowNew(id, idType, memCard);
57
+    }
58
+
59
+    @PostMapping("/checkWindow/question")
60
+    @ResponseBody
61
+    @ApiOperation(value = "校验是否弹调查问卷弹窗)")
62
+    public Result checkWindowQuestion(HttpServletRequest request,
63
+                              @RequestHeader(value="referer", defaultValue = "0") String referer,
64
+                              @RequestHeader(value="user-agent", defaultValue = "0") String userAgent,
65
+                              @RequestParam(required = false) Long id,
66
+                              @RequestParam(required = false) Integer idType,
67
+                              @ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(name = "memCard", required = false) String memCard
68
+    ) {
69
+        log.info("checkWindow join id:{} idType:{} memCard:{} referer:{} userAgent:{}", id, idType, memCard, referer, userAgent);
70
+        if (StringUtils.isBlank(memCard)) {
71
+            memCard = UserLoginUtil.isUserLogin(request);
72
+        }
73
+
74
+        return popuWindowService.checkWindowNew(id, idType, memCard);
75
+    }
76
+
77
+}

+ 34
- 0
src/main/java/com/cirle/scientific/controller/questionnaireSurvey/questionnaireSurveyController.java View File

@@ -0,0 +1,34 @@
1
+package com.cirle.scientific.controller.questionnaireSurvey;
2
+
3
+
4
+import com.cirle.scientific.questionnaire.service.QuestionnaireService;
5
+import io.swagger.annotations.Api;
6
+import io.swagger.annotations.ApiOperation;
7
+import io.swagger.annotations.ApiParam;
8
+import org.apache.commons.lang3.StringUtils;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.stereotype.Controller;
11
+import org.springframework.web.bind.annotation.*;
12
+
13
+import javax.servlet.http.HttpServletRequest;
14
+
15
+@Controller
16
+@RequestMapping("/questionnaire")
17
+@Api("品牌专区相关接口")
18
+public class questionnaireSurveyController {
19
+
20
+    @GetMapping("/page")
21
+    @ApiOperation("问卷调查页")
22
+    public String page(
23
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
24
+            HttpServletRequest request
25
+    ) {
26
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
27
+            return "html5/questionnaire/index";
28
+        } else if (StringUtils.isNotBlank(from) && from.equals("web")) {
29
+            return "web/questionnaire/index";
30
+        } else {
31
+            return "";
32
+        }
33
+    }
34
+}

+ 163
- 0
src/main/java/com/cirle/scientific/controller/register/RegisterController.java View File

@@ -0,0 +1,163 @@
1
+package com.cirle.scientific.controller.register;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.cirle.scientific.dao.MemberDao;
5
+import com.cirle.scientific.dao.QkjMemberOpenidDao;
6
+import com.cirle.scientific.dao.QkjMemberTaskInfoDao;
7
+import com.cirle.scientific.dto.WxUerInfoDTO;
8
+import com.cirle.scientific.po.QkjMember;
9
+import com.cirle.scientific.po.QkjMemberOpenid;
10
+import com.cirle.scientific.po.QkjMemberTaskInfo;
11
+import com.cirle.scientific.pojo.BizCodeEnum;
12
+import com.cirle.scientific.pojo.Result;
13
+import com.cirle.scientific.service.MemberService;
14
+import com.cirle.scientific.service.WeixinService;
15
+import com.cirle.scientific.utils.DESUtil;
16
+import com.cirle.scientific.utils.IpUtil;
17
+import com.cirle.scientific.utils.SmsUtils;
18
+import com.cirle.scientific.utils.StringUtil;
19
+import com.cirle.scientific.utils.weixin.WeixinpayConfig;
20
+import com.google.common.collect.Maps;
21
+import com.google.gson.JsonObject;
22
+import io.swagger.annotations.Api;
23
+import io.swagger.annotations.ApiOperation;
24
+import io.swagger.annotations.ApiParam;
25
+import lombok.extern.slf4j.Slf4j;
26
+import org.apache.commons.collections.CollectionUtils;
27
+import org.apache.commons.lang3.StringUtils;
28
+import org.springframework.beans.factory.annotation.Autowired;
29
+import org.springframework.data.redis.core.StringRedisTemplate;
30
+import org.springframework.stereotype.Controller;
31
+import org.springframework.ui.Model;
32
+import org.springframework.util.DigestUtils;
33
+import org.springframework.web.bind.annotation.*;
34
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
35
+
36
+import javax.servlet.http.Cookie;
37
+import javax.servlet.http.HttpServletRequest;
38
+import javax.servlet.http.HttpServletResponse;
39
+import java.io.UnsupportedEncodingException;
40
+import java.net.URLDecoder;
41
+import java.net.URLEncoder;
42
+import java.util.List;
43
+import java.util.Map;
44
+import java.util.Objects;
45
+import java.util.concurrent.TimeUnit;
46
+
47
+@Controller
48
+@RequestMapping("/register")
49
+@Api("登录相关接口")
50
+@Slf4j
51
+public class RegisterController {
52
+
53
+    @Autowired
54
+    MemberDao memberDao;
55
+    @Autowired
56
+    StringRedisTemplate stringRedisTemplate;
57
+    @Autowired
58
+    WeixinService weixinService;
59
+    @Autowired
60
+    MemberService memberService;
61
+    @Autowired
62
+    QkjMemberTaskInfoDao qkjMemberTaskInfoDao;
63
+    @Autowired
64
+    QkjMemberOpenidDao openidDao;
65
+
66
+    @GetMapping("")
67
+    @ApiOperation(value = "手机号登录页面")
68
+    public String login(
69
+            @ApiParam(name = "from", value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from", required = true) String from,
70
+            @ApiParam(name = "redirectUrl", value = "回调地址") @RequestParam(name = "redirectUrl", required = false) String redirectUrl,
71
+            HttpServletRequest request
72
+    ) {
73
+        request.setAttribute("redirectUrl", redirectUrl);
74
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
75
+            return "html5/user/register";
76
+        } else {
77
+            return "";
78
+        }
79
+    }
80
+
81
+    @GetMapping(value = "/isRegister")
82
+    @ResponseBody
83
+    public Result isRegister(
84
+            @ApiParam(name = "wxId", value = "微信ID") @RequestParam(name = "wxId", required = false) String wxId
85
+    ) {
86
+        Map<String, Boolean> map = Maps.newHashMap();
87
+        boolean isRegister = true;
88
+        if (StringUtils.isNotBlank(wxId)) {
89
+            QkjMember member = memberDao.findByWxId(wxId);
90
+            if (Objects.isNull(member)) {
91
+                isRegister = false;
92
+            }
93
+        }
94
+        map.put("isRegister", isRegister);
95
+        return Result.success(map);
96
+    }
97
+
98
+    @RequestMapping(value = "/mobilReg", method = {RequestMethod.POST, RequestMethod.GET})
99
+    @ResponseBody
100
+    public Result register(
101
+            @ApiParam(name = "memMobile", value = "用户手机号") @RequestParam(name = "memMobile", required = true) String memMobile,
102
+            @ApiParam(name = "memMobile", value = "用户名") @RequestParam(name = "userName", required = false) String userName,
103
+            @ApiParam(name = "valCode", value = "验证码") @RequestParam(name = "valCode", required = true) String valCode,
104
+            @ApiParam(name = "passwd", value = "密码") @RequestParam(name = "passwd", required = true) String passwd,
105
+            @ApiParam(name = "memRegisterSource", value = "注册终端,1-H5,2-pc") @RequestParam(name = "memRegisterSource", required = true) Integer memRegisterSource,
106
+            HttpServletRequest request
107
+    ) {
108
+
109
+        //校验用户名的唯一性
110
+        if(StringUtils.isNotBlank(userName)){
111
+            List<QkjMember> qkjMembers = memberDao.listByMemNickname(userName);
112
+            if(CollectionUtils.isNotEmpty(qkjMembers) && qkjMembers.size() >=1){
113
+                return Result.failed(BizCodeEnum.NAME_REPEAT);
114
+            }
115
+        }
116
+        //注册:修改密码
117
+        QkjMember member = memberDao.findByMemMobile(memMobile);
118
+
119
+        int valRs = validateMobileYzm(memMobile, valCode);
120
+        if (valRs == -1) {
121
+            return Result.failed(BizCodeEnum.CODE_TIME_OUT);
122
+        }
123
+        if (valRs == -2) {
124
+            return Result.failed(BizCodeEnum.CODE_ERROR);
125
+        }
126
+        if (member != null) {
127
+            member.setPasswd(DigestUtils.md5DigestAsHex(passwd.getBytes()));
128
+            if(StringUtils.isNotBlank(userName)){
129
+                member.setMemNickname(userName);
130
+            }
131
+            memberDao.save(member);
132
+            return Result.success("","手机号已注册,密码重置成功");
133
+        }
134
+
135
+
136
+        //注册:添加用户
137
+        member = memberService.register(memMobile, memRegisterSource, 0, DigestUtils.md5DigestAsHex(passwd.getBytes()), userName);
138
+        if (member == null) {
139
+            log.info("创建用户失败");
140
+            return Result.failed("创建用户失败");
141
+        }
142
+        return Result.success("","创建用户成功,请登录!");
143
+    }
144
+
145
+    protected int validateMobileYzm(String memUserId, String inputYzm) {
146
+
147
+        String realYzm = (String) stringRedisTemplate.opsForValue().get(memUserId + "yzm");
148
+        log.info("用户输入的验证码 " + inputYzm);
149
+        log.info("缓存里面的验证码" + realYzm);
150
+        if (realYzm == null) {
151
+            return -1;
152
+        }
153
+
154
+        if (!inputYzm.equals(realYzm)) {
155
+            return -2;
156
+        }
157
+
158
+        stringRedisTemplate.delete(memUserId + "yzm");
159
+        return 0;
160
+    }
161
+
162
+
163
+}

+ 120
- 0
src/main/java/com/cirle/scientific/controller/signatrue/SignatrueDetailController.java View File

@@ -0,0 +1,120 @@
1
+package com.cirle.scientific.controller.signatrue;
2
+
3
+
4
+
5
+import com.cirle.scientific.pojo.BizCodeEnum;
6
+import com.cirle.scientific.pojo.Result;
7
+import com.cirle.scientific.service.SignatrueService;
8
+import io.swagger.annotations.ApiOperation;
9
+import io.swagger.annotations.ApiParam;
10
+import org.apache.commons.lang3.StringUtils;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Controller;
13
+import org.springframework.web.bind.annotation.*;
14
+import javax.servlet.http.HttpServletRequest;
15
+
16
+
17
+/**
18
+ * @author 24901
19
+ */
20
+@Controller
21
+@RequestMapping(value = "/signatrue")
22
+public class SignatrueDetailController {
23
+
24
+
25
+    private SignatrueService signatrueService;
26
+
27
+    @Autowired
28
+    public void setSignatrueService(SignatrueService signatrueService) {
29
+        this.signatrueService = signatrueService;
30
+    }
31
+
32
+    @PostMapping(value = "/checkSign")
33
+    @ResponseBody
34
+    @ApiOperation(value = "查询签名信息")
35
+    public Result checkSign(HttpServletRequest request,
36
+                            @ApiParam(name = "memCard", value = "memCard") @RequestAttribute(value = "memCard", required = false) String memCard,
37
+                            @ApiParam(name = "conferenceId", value = "会议id") @RequestParam() String conferenceId){
38
+        if (request.getSession().getAttribute("UserCard") != null) {
39
+            memCard = (String) request.getSession().getAttribute("UserCard");
40
+        }
41
+        if(memCard==null){
42
+            return Result.failed(BizCodeEnum.NO_LOGIN);
43
+        }
44
+        return Result.success(signatrueService.selectSignatrue(memCard , conferenceId));
45
+    }
46
+
47
+    @GetMapping("/info")
48
+    @ApiOperation("签名页面")
49
+    public String search(@ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from){
50
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
51
+            return "html5/sign/info";
52
+        }else {
53
+            return "";
54
+        }
55
+    }
56
+
57
+    @GetMapping("/sign")
58
+    @ApiOperation("签名页面")
59
+    public String sign(@ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from){
60
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
61
+            return "html5/sign/sign";
62
+        } else if (StringUtils.isNotBlank(from) && from.equals("web")){
63
+            return "html5/sign/sign";
64
+        }else {
65
+            return "";
66
+        }
67
+    }
68
+
69
+
70
+
71
+    @PostMapping(value = "/addSign")
72
+    @ResponseBody
73
+    @ApiOperation(value = "用户劳务合同签名")
74
+    public Result addSign(HttpServletRequest request,
75
+                      @ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(value = "memCard", required = false) String memCard,
76
+                      @ApiParam(name = "conferenceId", value = "会议id") @RequestParam() String conferenceId,
77
+                      @ApiParam(name = "formId", value = "模板id") @RequestParam() String formId,
78
+                      @ApiParam(name = "partyB", value = "乙方") @RequestParam String partyB,
79
+                      @ApiParam(name = "identityId", value = "身份证号") @RequestParam String identityId,
80
+                      @ApiParam(name = "courseMatter", value = "讲课内容") @RequestParam String courseMatter,
81
+                      @ApiParam(name = "courseTime", value = "讲课时间") @RequestParam String courseTime,
82
+                      @ApiParam(name = "courseSite", value = "讲课地点") @RequestParam String courseSite,
83
+                      @ApiParam(name = "m", value = "费用") @RequestParam String m,
84
+                      @ApiParam(name = "bankProvince",value = "开户行省市") @RequestParam String bankProvince,
85
+                      @ApiParam(name = "bankOfDepositName",value = "开户行名称") @RequestParam String bankOfDepositName,
86
+                      @ApiParam(name = "bankId",value = "银行卡号") @RequestParam String bankId,
87
+                      @ApiParam(name = "bankName",value = "户名") @RequestParam String bankName,
88
+                      @ApiParam(name = "phone",value = "手机号") @RequestParam String phone,
89
+                      @ApiParam(name = "signImg",value = "签名的图片") @RequestParam String signImg,
90
+                      @ApiParam(name = "isSubmit", value = "用户是否提交") @RequestParam Integer isSubmit){
91
+        if (request.getSession().getAttribute("UserCard") != null) {
92
+            memCard = (String) request.getSession().getAttribute("UserCard");
93
+        }
94
+        if(memCard==null){
95
+            return Result.failed(BizCodeEnum.NO_LOGIN);
96
+        }
97
+        if(request.getParameter("money")!=null){
98
+            m = request.getParameter("money");
99
+        }
100
+        if("a".equalsIgnoreCase(m)){
101
+//                { value: 'a', label: '1000' },
102
+//                { value: 'b', label: '1500' },
103
+//                { value: 'c', label: '2000' },
104
+//                { value: 'd', label: '2500' }
105
+            m = "1000";
106
+        }else if("b".equalsIgnoreCase(m)){
107
+            m = "1500";
108
+        }else if("c".equalsIgnoreCase(m)){
109
+            m = "2000";
110
+        }else if("d".equalsIgnoreCase(m)){
111
+            m = "2500";
112
+        }else if("e".equalsIgnoreCase(m)){
113
+            m = "3000";
114
+        }
115
+        Result result = signatrueService.addSignatrue(memCard, conferenceId, formId, partyB, identityId, courseMatter, courseTime, courseSite, m, bankProvince, bankOfDepositName, bankId, bankName, phone, signImg, isSubmit);
116
+        return result;
117
+
118
+    }
119
+
120
+}

+ 51
- 0
src/main/java/com/cirle/scientific/controller/sys/SysController.java View File

@@ -0,0 +1,51 @@
1
+package com.cirle.scientific.controller.sys;
2
+
3
+import com.cirle.scientific.dao.MemberDao;
4
+import com.cirle.scientific.dao.QkjMemberOpenidDao;
5
+import com.cirle.scientific.dao.QkjMemberTaskInfoDao;
6
+import com.cirle.scientific.dao.RegionDao;
7
+import com.cirle.scientific.dto.QkjMemberDto;
8
+import com.cirle.scientific.po.QkjMember;
9
+import com.cirle.scientific.po.SysRegion;
10
+import com.cirle.scientific.pojo.BizCodeEnum;
11
+import com.cirle.scientific.pojo.Result;
12
+import com.cirle.scientific.service.MemberService;
13
+import com.cirle.scientific.service.SysRegionService;
14
+import com.cirle.scientific.service.WeixinService;
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import io.swagger.annotations.ApiParam;
18
+import lombok.extern.slf4j.Slf4j;
19
+import org.apache.commons.lang3.StringUtils;
20
+import org.springframework.beans.factory.annotation.Autowired;
21
+import org.springframework.data.redis.core.StringRedisTemplate;
22
+import org.springframework.stereotype.Controller;
23
+import org.springframework.util.DigestUtils;
24
+import org.springframework.web.bind.annotation.*;
25
+
26
+import javax.servlet.http.HttpServletRequest;
27
+import java.util.List;
28
+import java.util.Map;
29
+
30
+@Controller
31
+@RequestMapping("/sys")
32
+@Api("后台配置相关接口")
33
+@Slf4j
34
+public class SysController {
35
+
36
+    @Autowired
37
+    SysRegionService sysRegionService;
38
+
39
+    @GetMapping("/getRegion")
40
+    @ApiOperation(value = "获取二级联动的省市信息")
41
+    @ResponseBody
42
+    public Result<List<SysRegion>> getRegion(
43
+            @ApiParam(name = "parentId", value = "父ID") @RequestParam(name = "parentId", required = false) Integer parentId
44
+    ) {
45
+       return Result.success(sysRegionService.getRegion(parentId));
46
+    }
47
+
48
+
49
+
50
+
51
+}

+ 1222
- 0
src/main/java/com/cirle/scientific/controller/user/UserController.java
File diff suppressed because it is too large
View File


+ 117
- 0
src/main/java/com/cirle/scientific/controller/view/ViewController.java View File

@@ -0,0 +1,117 @@
1
+package com.cirle.scientific.controller.view;
2
+
3
+import com.cirle.scientific.dao.QkjArticleDao;
4
+import com.cirle.scientific.dto.QkjRecommendDTO;
5
+import com.cirle.scientific.po.QkjArticle;
6
+import com.cirle.scientific.pojo.Result;
7
+import com.cirle.scientific.service.ArticleService;
8
+import com.cirle.scientific.service.RecommendService;
9
+import com.cirle.scientific.utils.DeviceUtil;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.apache.commons.lang3.StringUtils;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Controller;
16
+import org.springframework.web.bind.annotation.*;
17
+
18
+import javax.servlet.http.HttpServletRequest;
19
+import java.util.List;
20
+
21
+@Controller
22
+@RequestMapping("/view")
23
+@Api("资讯相关接口")
24
+public class ViewController {
25
+
26
+    @Autowired
27
+    private ArticleService articleService;
28
+
29
+    @Autowired
30
+    private RecommendService recommendService;
31
+
32
+    @Autowired
33
+    private QkjArticleDao articleDao;
34
+
35
+
36
+    @GetMapping("/index")
37
+    @ApiOperation(value = "去往资讯首页")
38
+    public String index(
39
+            HttpServletRequest request,
40
+            @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = true) String from
41
+    ){
42
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
43
+            return "html5/view/view-index";
44
+        } else {
45
+            return "web/view/view-index";
46
+        }
47
+    }
48
+
49
+    @GetMapping("/detail")
50
+    @ApiOperation(value = "去往文章详情页面")
51
+    public String detail(
52
+            HttpServletRequest request,
53
+            @ApiParam(name = "from",value = "请求类型 web:网站 H5:手机端") @RequestParam(name = "from",required = false) String from,
54
+            @ApiParam(name = "artId",value = "文章ID") @RequestParam(name = "artId",required = true) Long artId
55
+    ){
56
+        //获取详情
57
+        request.setAttribute("artId", artId);
58
+        QkjArticle art = articleDao.findById(artId).get();
59
+        if(art.getType() == 2){
60
+            String redirectUrl = "redirect:"+art.getContent().trim();
61
+            return redirectUrl;
62
+        }
63
+        if (StringUtils.isNotBlank(from) && from.equals("H5")) {
64
+            return "html5/view/view-detail";
65
+        } else {
66
+            return "web/view/view-detail";
67
+        }
68
+    }
69
+
70
+    @PostMapping("/getArtListData")
71
+    @ApiOperation(value = "获取文章列表")
72
+    @ResponseBody
73
+    public Result getArtListData(
74
+            @RequestAttribute(value = "memCard",required = false) String memCard,
75
+            @ApiParam(name = "cataId",value = "分类ID") @RequestParam(name = "cataId",required = true) Integer cataId,
76
+            @ApiParam(name = "sortBy",value = "排序字段") @RequestParam(name = "sortBy",required = false) String sortBy,
77
+            @ApiParam(name = "page",value = "分页") @RequestParam(name = "page",required = true,defaultValue="1") Integer page,
78
+            @ApiParam(name = "size",value = "每页数量") @RequestParam(name = "size",required = true,defaultValue="10") Integer size,
79
+            HttpServletRequest request
80
+    ){
81
+        boolean isPC= DeviceUtil.isMobileDevice(request);
82
+        return Result.success(articleService.getArtListData(memCard, cataId, page, size,sortBy,isPC));
83
+    }
84
+
85
+    @PostMapping("/getAdInfo")
86
+    @ResponseBody
87
+    @ApiOperation(value = "课程首页获取广告位")
88
+    public Result<List<QkjRecommendDTO>> getAdInfo(HttpServletRequest request) {
89
+        // 默认展示pc端内容  0全部不显示 、1全部显示 、2m端显示、3pc端显示
90
+        Integer status = 3;
91
+        if(DeviceUtil.isMobileDevice(request)) {
92
+            status = 2;
93
+        }
94
+        List<QkjRecommendDTO> recmdTop = recommendService.findByPosIdLimit(18L, status, 1, 10);
95
+        return Result.success(recmdTop);
96
+    }
97
+
98
+    @PostMapping("/updataClick")
99
+    @ResponseBody
100
+    @ApiOperation(value = "课程首页获取广告位")
101
+    public Result updataClick(
102
+            @RequestAttribute(value = "memCard",required = false) String memCard,
103
+            @ApiParam(name = "artId",value = "咨询id") @RequestParam(name = "artId",required = true) Long artId
104
+    ){
105
+        return  articleService.updataClick(artId);
106
+    }
107
+
108
+    @PostMapping("/getDetailData")
109
+    @ApiOperation(value = "获取资讯详情")
110
+    @ResponseBody
111
+    public Result getDetailData(
112
+            @RequestAttribute(value = "memCard",required = false) String memCard,
113
+            @ApiParam(name = "artId",value = "直播ID") @RequestParam(name = "artId",required = true) Long artId
114
+    ){
115
+        return articleService.getDetailData(artId, memCard);
116
+    }
117
+}

+ 24
- 0
src/main/java/com/cirle/scientific/dao/CollectionDao.java View File

@@ -0,0 +1,24 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.SalesCollectionMain;
4
+import com.cirle.scientific.po.SalesOrdersMain;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import java.util.List;
11
+
12
+
13
+@Repository
14
+public interface CollectionDao extends PagingAndSortingRepository<SalesCollectionMain, Long>, JpaSpecificationExecutor<SalesCollectionMain> {
15
+    @Query(value = "SELECT * FROM qkj_integral_collection WHERE mem_card = ?1 AND type_id = ?2 AND type = ?3",nativeQuery = true)
16
+    List<SalesCollectionMain> getCollectionInfo(String memCard, String typeId, Integer type);
17
+
18
+    @Query(value = "SELECT * FROM qkj_integral_collection WHERE mem_card = ?1 AND type = ?2 ORDER BY collection_time DESC LIMIT ?3,?4",nativeQuery = true)
19
+    List<SalesCollectionMain> findMyCollectionListAllByType(String memCard , Integer type, Integer start, Integer size);
20
+
21
+    @Query(value = "SELECT * FROM qkj_integral_collection WHERE mem_card = ?1 ORDER BY collection_time DESC LIMIT ?2,?3",nativeQuery = true)
22
+    List<SalesCollectionMain> findMyCollectionListAll(String memCard , Integer start, Integer size);
23
+
24
+}

+ 14
- 0
src/main/java/com/cirle/scientific/dao/DictDao.java View File

@@ -0,0 +1,14 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.Dict;
4
+import com.cirle.scientific.po.QkjMember;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+public interface DictDao extends PagingAndSortingRepository<Dict, Long>, JpaSpecificationExecutor<Dict> {
10
+
11
+
12
+    @Query(value = "select * from sys_dict  where name = ?1",nativeQuery = true)
13
+    Dict findDictByName(String dictName);
14
+}

+ 16
- 0
src/main/java/com/cirle/scientific/dao/DictDetailDao.java View File

@@ -0,0 +1,16 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.Dict;
4
+import com.cirle.scientific.po.DictDetail;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+import java.util.List;
10
+
11
+public interface DictDetailDao extends PagingAndSortingRepository<DictDetail, Long>, JpaSpecificationExecutor<DictDetail> {
12
+
13
+
14
+    @Query(value = "select a.* from sys_dict_detail a left join sys_dict b on a.dict_id = b.dict_id where b.name = ?1 and label = ?2 ",nativeQuery = true)
15
+    List<DictDetail> listByNameAndLabel(String name, Long id);
16
+}

+ 51
- 0
src/main/java/com/cirle/scientific/dao/MemberDao.java View File

@@ -0,0 +1,51 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
4
+import org.springframework.data.jpa.repository.Query;
5
+import org.springframework.data.repository.PagingAndSortingRepository;
6
+import org.springframework.stereotype.Repository;
7
+
8
+import com.cirle.scientific.po.QkjMember;
9
+
10
+import java.time.LocalDateTime;
11
+import java.util.List;
12
+
13
+
14
+@Repository
15
+public interface MemberDao extends PagingAndSortingRepository<QkjMember, Long>, JpaSpecificationExecutor<QkjMember> {
16
+
17
+    @Query(value = "select * from qkj_member where mem_card = ?1 and mem_status=0",nativeQuery = true)
18
+    public QkjMember findByMemCard(String memCard);
19
+
20
+    @Query(value = "select mem_mobile from qkj_member where mem_card = ?1 and mem_status=0",nativeQuery = true)
21
+    String findByMemCardA(String memCard);
22
+
23
+    @Query(value = "select * from qkj_member where mem_mobile = ?1 and mem_status=0",nativeQuery = true)
24
+    QkjMember findByMemMobile(String mobile);
25
+
26
+    @Query(value = "select * from qkj_member where mem_nickname = ?1 and mem_status=0",nativeQuery = true)
27
+    QkjMember findByMemNickname(String mobile);
28
+
29
+    @Query(value = "SELECT * FROM qkj_member WHERE wx_id = ?1 AND mem_status <> 1", nativeQuery = true)
30
+    QkjMember findByWxId(String wxId);
31
+
32
+
33
+    @Query(value = "SELECT * FROM qkj_member WHERE mem_card in (?1)", nativeQuery = true)
34
+    List<QkjMember> findAllBymemCards(List<String> memCards);
35
+
36
+    @Query(value = "select * from qkj_member where mem_nickname = ?1 and mem_status=0",nativeQuery = true)
37
+    List<QkjMember> listByMemNickname(String mobile);
38
+
39
+    @Query(value = "SELECT * FROM qkj_member WHERE is_whitelist = 1 AND mem_status <> 1", nativeQuery = true)
40
+    List<QkjMember> findAllWhitelist();
41
+
42
+    @Query(value = "select count(*) from qkj_member where mem_status = 0", nativeQuery = true)
43
+    Integer findPeople();
44
+
45
+
46
+    @Query(value = "select max(user_id) from qkj_member where mem_register_time between ?1 and ?2 and  mem_status = 0", nativeQuery = true)
47
+    Long getMaxUserId(LocalDateTime start, LocalDateTime end);
48
+
49
+    @Query(value = "select * from qkj_member where mem_register_time between ?1 and ?2 and  mem_status = 0", nativeQuery = true)
50
+    List<QkjMember> listByRegisterTime(LocalDateTime start, LocalDateTime end);
51
+}

+ 58
- 0
src/main/java/com/cirle/scientific/dao/OrderDao.java View File

@@ -0,0 +1,58 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+import com.cirle.scientific.dto.UserOderDto;
7
+import io.lettuce.core.dynamic.annotation.Param;
8
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
9
+import org.springframework.data.jpa.repository.Query;
10
+import org.springframework.data.repository.PagingAndSortingRepository;
11
+import org.springframework.stereotype.Repository;
12
+
13
+import com.cirle.scientific.po.SalesOrdersMain;
14
+
15
+
16
+@Repository
17
+public interface OrderDao extends PagingAndSortingRepository<SalesOrdersMain, Long>, JpaSpecificationExecutor<SalesOrdersMain> {
18
+    @Query(value = "SELECT * FROM sales_orders_main WHERE mem_card = ?1 AND order_id = ?2",nativeQuery = true)
19
+    SalesOrdersMain getOrderInfo(String memCard, String orderId);
20
+
21
+    @Query(value = "SELECT order_id FROM sales_orders_main WHERE mem_card = ?1 AND obj_id = ?2 and order_type = ?3 ",nativeQuery = true)
22
+    List<String> getOrderByMemCardAndObjIdAndOrderType(String memCard, String objId ,  Integer orderType);
23
+
24
+//    查询积分或金钱购买的订单
25
+    @Query(value = "SELECT * FROM sales_orders_main WHERE mem_card = ?1 AND status = 1 AND pay_type = ?4 ORDER BY createtime DESC LIMIT ?2,?3",nativeQuery = true)
26
+    List<SalesOrdersMain> findMyOrderList(String memCard, Integer payType);
27
+
28
+    @Query(value = "SELECT * FROM sales_orders_main WHERE mem_card = ?1 AND status = 1 AND order_type = ?4 ORDER BY createtime DESC LIMIT ?2,?3",nativeQuery = true)
29
+    List<SalesOrdersMain> findMyOrderListAll(String memCard,Integer start, Integer size,Integer orderType);
30
+
31
+    @Query(value = "SELECT * FROM sales_orders_main WHERE mem_card = ?1 AND status = 1 ORDER BY createtime DESC ",nativeQuery = true)
32
+    List<SalesOrdersMain> findUserAllOrderList(String memCard);
33
+
34
+    @Query(value = "SELECT * FROM sales_orders_main WHERE mem_card = ?1 AND status = 1 ORDER BY createtime DESC ",nativeQuery = true)
35
+    List<SalesOrdersMain> findMyOrderListAll(String memCard, Integer start, Integer size);
36
+
37
+    @Query(value = "SELECT * FROM sales_orders_main WHERE mem_card = ?1 AND status = ?2 AND is_shipping = ?3 AND order_type = 15 ORDER BY createtime DESC  LIMIT ?4,?5",nativeQuery = true)
38
+    List<SalesOrdersMain> findMyOrderListConditions(String memCard, Integer status, Integer isShipping, Integer start, Integer size);
39
+    
40
+    @Query(value = "SELECT * FROM sales_orders_main WHERE order_id = ?1",nativeQuery = true)
41
+    SalesOrdersMain getOrderInfo(String orderId);
42
+
43
+    @Query(value = "SELECT m.mem_nickname, m.mem_headimg, count(s.id) as num from sales_orders_main s "
44
+            +"	INNER JOIN qkj_member m on s.from_mem_card = m.mem_card "
45
+            +" where s.order_type=?1 and s.obj_id=?2 and s.ispackage=1 and s.`status`=1 and s.from_mem_card is not null GROUP BY s.from_mem_card ORDER BY num desc",nativeQuery = true)
46
+    List<Object[]> inviteRank(Integer objType, Integer objId);
47
+
48
+    @Query(value = "SELECT m.mem_nickname, m.mem_headimg, count(s.id) from sales_orders_main s "
49
+            +"	INNER JOIN qkj_member m on s.from_mem_card = m.mem_card "
50
+            +" where s.order_type=?1 and s.obj_id=?2 and s.`status`=1 and s.from_mem_card=?3",nativeQuery = true)
51
+    Object[] inviteRankByMember(Integer objType, Integer objId, String memCard);
52
+
53
+    List<SalesOrdersMain> findByWxpayOrderId(String orderId);
54
+
55
+
56
+    @Query(value = "select  * from sales_orders_main where mem_card = ?1 and obj_id = ?3 and order_type = ?2 and status = 1",nativeQuery = true)
57
+    List<SalesOrdersMain> findTqcourseOrderList(String memCard,Integer orderType,Integer productId);
58
+}

+ 32
- 0
src/main/java/com/cirle/scientific/dao/QkjArticleDao.java View File

@@ -0,0 +1,32 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjArticle;
5
+import com.cirle.scientific.po.QkjBrandProduct;
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+import org.springframework.stereotype.Repository;
10
+
11
+import java.util.List;
12
+
13
+
14
+@Repository
15
+public interface QkjArticleDao extends PagingAndSortingRepository<QkjArticle, Long>, JpaSpecificationExecutor<QkjArticle> {
16
+
17
+    @Query(value = "SELECT a.* FROM qkj_article a WHERE a.status=1 and m_or_pc in (?3) order by a.publish_time desc limit ?1, ?2",nativeQuery = true)
18
+    List<QkjArticle> findList(Integer start, Integer size,Integer[] mOrPc);
19
+
20
+    @Query(value = "SELECT a.* FROM qkj_article a WHERE a.status=1 and m_or_pc in (?3) order by a.click desc limit ?1, ?2",nativeQuery = true)
21
+    List<QkjArticle> findListByHottest(Integer start, Integer size,Integer[] mOrPc);
22
+
23
+    @Query(value = "SELECT a.* FROM qkj_catalogs_detail d " +
24
+                        "INNER JOIN qkj_article a on d.obj_id=a.id " +
25
+                    "WHERE d.catalogs_id=?1 and d.obj_type=4 and a.status=1 and m_or_pc in (?4) order by a.publish_time desc limit ?2, ?3",nativeQuery = true)
26
+    List<QkjArticle> findByCataId(Integer cataId, Integer start, Integer size,Integer[] mOrPc);
27
+
28
+    @Query(value = "SELECT a.* FROM qkj_catalogs_detail d " +
29
+            "INNER JOIN qkj_article a on d.obj_id=a.id " +
30
+            "WHERE d.catalogs_id=?1 and d.obj_type=4 and a.status=1 and m_or_pc in (?4) order by a.click desc limit ?2, ?3",nativeQuery = true)
31
+    List<QkjArticle> ByCataIdHottest(Integer cataId, Integer start, Integer size,Integer[] mOrPc);
32
+}

+ 23
- 0
src/main/java/com/cirle/scientific/dao/QkjAuditingDao.java View File

@@ -0,0 +1,23 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjAuditing;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Modifying;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import java.util.List;
11
+
12
+@Repository
13
+public interface QkjAuditingDao extends PagingAndSortingRepository<QkjAuditing, Long>, JpaSpecificationExecutor<QkjAuditing> {
14
+
15
+    @Query(value = "SELECT a.* FROM qkj_auditing a WHERE a.mem_card=?1 and a.obj_type= ?2 and a.obj_id= ?3 ", nativeQuery = true)
16
+    List<QkjAuditing> getQkjAuditingList(String memCard, Integer objType, Integer objId);
17
+
18
+    @Modifying
19
+    @Query(value = "delete from qkj_auditing where mem_card = ?1 and obj_type=?2 and obj_id=?3", nativeQuery = true)
20
+    void deleteByMemberAndObjTypeAndOjbId(String memCard, Integer objType, Integer objId);
21
+
22
+
23
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjBrandProductDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjBrandProduct;
5
+import com.cirle.scientific.po.QkjCatalogs;
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+import org.springframework.stereotype.Repository;
10
+
11
+import java.util.List;
12
+
13
+
14
+@Repository
15
+public interface QkjBrandProductDao extends PagingAndSortingRepository<QkjBrandProduct, Long>, JpaSpecificationExecutor<QkjBrandProduct> {
16
+
17
+}

+ 20
- 0
src/main/java/com/cirle/scientific/dao/QkjBrandProductDetailDao.java View File

@@ -0,0 +1,20 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjBrandProduct;
5
+import com.cirle.scientific.po.QkjBrandProductDetail;
6
+import com.cirle.scientific.po.QkjCatalogs;
7
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.PagingAndSortingRepository;
10
+import org.springframework.stereotype.Repository;
11
+
12
+import java.util.List;
13
+
14
+
15
+@Repository
16
+public interface QkjBrandProductDetailDao extends PagingAndSortingRepository<QkjBrandProductDetail, Long>, JpaSpecificationExecutor<QkjBrandProductDetail> {
17
+
18
+	@Query(value = "select * from qkj_brand_product_detail where product_id = ?1 order by sqn desc",nativeQuery = true)
19
+	List<QkjBrandProductDetail> findByProductId(Long productId);
20
+}

+ 24
- 0
src/main/java/com/cirle/scientific/dao/QkjCatalogsDao.java View File

@@ -0,0 +1,24 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjCatalogs;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import java.util.List;
11
+
12
+
13
+@Repository
14
+public interface QkjCatalogsDao extends PagingAndSortingRepository<QkjCatalogs, Long>, JpaSpecificationExecutor<QkjCatalogs> {
15
+
16
+    @Query(value = "select * from qkj_catalogs where fu_id = ?1 order by sqn asc", nativeQuery = true)
17
+    List<QkjCatalogs> findByFuId(int fuId);
18
+
19
+    @Query(value = "select * from qkj_catalogs", nativeQuery = true)
20
+    List<QkjCatalogs> findAll();
21
+
22
+    @Query(value = "select description from qkj_catalogs where id = ?1 ", nativeQuery = true)
23
+    String findById(Integer id);
24
+}

+ 29
- 0
src/main/java/com/cirle/scientific/dao/QkjCatalogsDetailDao.java View File

@@ -0,0 +1,29 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import io.lettuce.core.dynamic.annotation.Param;
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+import org.springframework.stereotype.Repository;
10
+
11
+import com.cirle.scientific.po.QkjCatalogsDetail;
12
+
13
+
14
+@Repository
15
+public interface QkjCatalogsDetailDao extends PagingAndSortingRepository<QkjCatalogsDetail, Long>, JpaSpecificationExecutor<QkjCatalogsDetail> {
16
+
17
+    @Query(value = "SELECT obj_id FROM qkj_catalogs_detail  WHERE obj_type=?1 AND catalogs_id=?2 ", nativeQuery = true)
18
+    List<Integer> findByObjTypeAndCatalogsId(Integer objType, Integer catalogsId);
19
+
20
+    @Query(value = "SELECT catalogs_id FROM qkj_catalogs_detail  WHERE obj_type=?1 AND obj_id=?2 ", nativeQuery = true)
21
+    List<Integer> findByObjTypeAndobjId(Integer objType, Integer objId);
22
+
23
+    @Query(value = "SELECT * FROM qkj_catalogs_detail  WHERE obj_type=?1 ", nativeQuery = true)
24
+    List<QkjCatalogsDetail> findByObjType(Integer objType);
25
+
26
+    @Query(value = "select * from  qkj_catalogs_detail where obj_type = :type  and  obj_id = :objId",nativeQuery = true)
27
+    List<QkjCatalogsDetail> findObjectByObjTypeAndObjId(@Param("type") Integer type, @Param("objId")Long objId);
28
+
29
+}

+ 23
- 0
src/main/java/com/cirle/scientific/dao/QkjCertificatePhysiciansDao.java View File

@@ -0,0 +1,23 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjCertificatePhysicians;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjCertificatePhysiciansDao extends PagingAndSortingRepository<QkjCertificatePhysicians, Long>, JpaSpecificationExecutor<QkjCertificatePhysicians> {
11
+
12
+    @Query(value = "select  * from  qkj_certificate_physicians where mem_card = ?1", nativeQuery = true)
13
+    QkjCertificatePhysicians findByMemCard(String memCard);
14
+
15
+    @Query(value = "select  professional_two from  qkj_certificate_physicians where mem_card = ?1", nativeQuery = true)
16
+    Integer findByMemCardA(String memCard);
17
+
18
+    @Query(value = "select  * from  qkj_certificate_physicians where mem_card = ?1", nativeQuery = true)
19
+    List<QkjCertificatePhysicians> check(String businessLicense);
20
+
21
+    QkjCertificatePhysicians findByNum(String num);
22
+
23
+}

+ 23
- 0
src/main/java/com/cirle/scientific/dao/QkjColumnistDao.java View File

@@ -0,0 +1,23 @@
1
+/*
2
+* create by mybatis-plus-generator  https://github.com/xiweile
3
+*/
4
+package com.cirle.scientific.dao;
5
+
6
+import java.util.List;
7
+
8
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
9
+import org.springframework.data.jpa.repository.Query;
10
+import org.springframework.data.repository.PagingAndSortingRepository;
11
+import org.springframework.stereotype.Repository;
12
+
13
+import com.cirle.scientific.po.QkjColumnist;
14
+
15
+@Repository
16
+public interface QkjColumnistDao extends PagingAndSortingRepository<QkjColumnist, Long>, JpaSpecificationExecutor<QkjColumnist> {
17
+	
18
+	QkjColumnist findByMemCard(String memCard);
19
+	
20
+	@Query(value = "SELECT * FROM qkj_columnist WHERE status = 0", nativeQuery = true)
21
+	List<QkjColumnist> findAllList();
22
+}
23
+

+ 25
- 0
src/main/java/com/cirle/scientific/dao/QkjColumnistDetailDao.java View File

@@ -0,0 +1,25 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import com.cirle.scientific.po.QkjColumnistDetail;
11
+
12
+
13
+@Repository
14
+public interface QkjColumnistDetailDao extends PagingAndSortingRepository<QkjColumnistDetail, Long>, JpaSpecificationExecutor<QkjColumnistDetail> {
15
+	
16
+	@Query(value = "select mpr.* from qkj_columnist_detail mpr where mpr.obj_type=?1 and mpr.obj_id=?2 ", nativeQuery = true)
17
+	List<QkjColumnistDetail> findByobjTypeAndobjId(Integer objType, long objId);
18
+	
19
+	@Query(value = "select mpr.obj_id from qkj_columnist_detail mpr where mpr.obj_type=?1 and mpr.mem_card in ?2", nativeQuery = true)
20
+	List<Integer> findByobjTypeAndMemCard(Integer objType, List<String> memCards);
21
+
22
+
23
+	@Query(value = "select * from qkj_columnist_detail where obj_type=?1 and obj_id=?2", nativeQuery = true)
24
+	List<QkjColumnistDetail> findByobjTypeAndobjIdAuthor(Integer objType, long objId);
25
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjCommunityDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjCommunity;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+import org.springframework.stereotype.Repository;
8
+
9
+import java.util.List;
10
+
11
+
12
+@Repository
13
+public interface QkjCommunityDao  extends PagingAndSortingRepository<QkjCommunity, Long>, JpaSpecificationExecutor<QkjCommunity> {
14
+
15
+    @Query(value = "select * from qkj_community where stauts = 0 ", nativeQuery = true)
16
+    List<QkjCommunity> getQrImg();
17
+}

+ 43
- 0
src/main/java/com/cirle/scientific/dao/QkjConferenceDao.java View File

@@ -0,0 +1,43 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjArticle;
5
+import com.cirle.scientific.po.QkjConference;
6
+import com.cirle.scientific.po.QkjLive;
7
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.PagingAndSortingRepository;
10
+import org.springframework.stereotype.Repository;
11
+
12
+import java.util.List;
13
+
14
+
15
+@Repository
16
+public interface QkjConferenceDao extends PagingAndSortingRepository<QkjConference, Long>, JpaSpecificationExecutor<QkjConference> {
17
+
18
+    @Query(value = "(SELECT a.* FROM (SELECT * FROM qkj_conference WHERE status=2 and is_visiable=1 and m_or_pc in (?3) ORDER BY bigen_time ASC) a) "
19
+                    +"	UNION all "
20
+                    +"	(SELECT b.* FROM (SELECT * FROM qkj_conference WHERE status=1 and is_visiable=1 and m_or_pc in (?3) ORDER BY bigen_time ASC) b) "
21
+                    +"	UNION all "
22
+                    +"	(SELECT d.* FROM (SELECT * FROM qkj_conference WHERE status=3 and is_visiable=1 and m_or_pc in (?3) ORDER BY bigen_time desc) d) "
23
+                    +"	limit ?1,?2",nativeQuery = true)
24
+    List<QkjConference> findList(int start, int size,Integer[] mOrPc);
25
+
26
+    @Query(value = "select sum(tmpcount) from ((SELECT count(*) tmpcount FROM qkj_conference WHERE status=2 and is_visiable=1 and m_or_pc in (?1) ORDER BY bigen_time ASC) " +
27
+            "          UNION all " +
28
+            "          (SELECT count(*) tmpcount FROM qkj_conference WHERE status=1 and is_visiable=1 and m_or_pc in (?1) ORDER BY bigen_time ASC) " +
29
+            "          UNION all " +
30
+            "          (SELECT count(*) tmpcount FROM qkj_conference WHERE status=3 and is_visiable=1 and m_or_pc in (?1) ORDER BY bigen_time desc) ) a ",
31
+            nativeQuery = true)
32
+    Integer findTotalList(Integer[] mOrPc);
33
+
34
+    @Query(value = "(SELECT a.* FROM (SELECT * FROM qkj_conference WHERE id in (SELECT confer_id from qkj_conference_series where series_id=?1) and status=2 ORDER BY bigen_time ASC) a) "
35
+            +"	UNION all "
36
+            +"	(SELECT b.* FROM (SELECT * FROM qkj_conference WHERE id in (SELECT confer_id from qkj_conference_series where series_id=?1) and status=1 ORDER BY bigen_time ASC) b) "
37
+            +"	UNION all "
38
+            +"	(SELECT d.* FROM (SELECT * FROM qkj_conference WHERE id in (SELECT confer_id from qkj_conference_series where series_id=?1) and status=3 ORDER BY bigen_time desc) d) ",nativeQuery = true)
39
+    List<QkjConference> findSonList(Long conferId);
40
+
41
+    @Query(value = "select * from qkj_conference q WHERE q.id = ?1",nativeQuery = true)
42
+    QkjConference findConferAllById(long Id);
43
+}

+ 19
- 0
src/main/java/com/cirle/scientific/dao/QkjConferenceMenuDao.java View File

@@ -0,0 +1,19 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjArticle;
5
+import com.cirle.scientific.po.QkjConferenceMenu;
6
+import com.cirle.scientific.po.QkjLive;
7
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.PagingAndSortingRepository;
10
+import org.springframework.stereotype.Repository;
11
+
12
+import java.util.List;
13
+
14
+
15
+@Repository
16
+public interface QkjConferenceMenuDao extends PagingAndSortingRepository<QkjConferenceMenu, Long>, JpaSpecificationExecutor<QkjConferenceMenu> {
17
+
18
+    List<QkjConferenceMenu> findByConferIdOrderBySqnAsc(Integer conferId);
19
+}

+ 20
- 0
src/main/java/com/cirle/scientific/dao/QkjConferencePeopelDao.java View File

@@ -0,0 +1,20 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjArticle;
5
+import com.cirle.scientific.po.QkjConferencePeopel;
6
+import com.cirle.scientific.po.QkjLive;
7
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.PagingAndSortingRepository;
10
+import org.springframework.stereotype.Repository;
11
+
12
+import java.util.List;
13
+
14
+
15
+@Repository
16
+public interface QkjConferencePeopelDao extends PagingAndSortingRepository<QkjConferencePeopel, Long>, JpaSpecificationExecutor<QkjConferencePeopel> {
17
+
18
+    QkjConferencePeopel findByMobile(String mobile);
19
+
20
+}

+ 34
- 0
src/main/java/com/cirle/scientific/dao/QkjConferenceRecordDao.java View File

@@ -0,0 +1,34 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjArticle;
5
+import com.cirle.scientific.po.QkjConferenceRecord;
6
+import com.cirle.scientific.po.QkjLive;
7
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
+import org.springframework.data.jpa.repository.Modifying;
9
+import org.springframework.data.jpa.repository.Query;
10
+import org.springframework.data.repository.PagingAndSortingRepository;
11
+import org.springframework.stereotype.Repository;
12
+
13
+import java.util.List;
14
+
15
+
16
+@Repository
17
+public interface QkjConferenceRecordDao extends PagingAndSortingRepository<QkjConferenceRecord, Long>, JpaSpecificationExecutor<QkjConferenceRecord> {
18
+
19
+    @Query(value = "select * from qkj_conference_record where mem_card=?2 and confer_id=?1 and status = 0 order by id asc", nativeQuery = true)
20
+    List<QkjConferenceRecord> findByConferIdAndMemCard(Long conferId, String memCard);
21
+
22
+    @Query(value = "SELECT r.* from qkj_conference_record r " +
23
+                        "INNER JOIN qkj_conference_peopel p on r.people_id=p.id " +
24
+                   "where r.confer_id=?1 and p.mobile=?2 and r.pay_status=1 and r.`status`=0", nativeQuery = true)
25
+    QkjConferenceRecord findByConferIdAndMobile(Long conferId, String mobile);
26
+
27
+    @Query(value = "select * from qkj_conference_record where mem_card=?2 and confer_id=?1 and pay_status=?3 and status=0  order by id asc", nativeQuery = true)
28
+    List<QkjConferenceRecord> findByConferIdAndMemCard(Long conferId, String memCard, Integer payStatus);
29
+
30
+    @Query(value = "select * from qkj_conference_record where order_id=?3 and mem_card=?2 and confer_id=?1 and status = 0 order by id asc", nativeQuery = true)
31
+    List<QkjConferenceRecord> findByConferIdAndMemCardAndOrderId(Long conferId, String memCard, String orderId);
32
+
33
+
34
+}

+ 45
- 0
src/main/java/com/cirle/scientific/dao/QkjCourseWareDao.java View File

@@ -0,0 +1,45 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjCourseWare;
4
+import com.cirle.scientific.po.QkjTqcourse;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+import java.util.List;
10
+
11
+public interface QkjCourseWareDao extends PagingAndSortingRepository<QkjCourseWare, Long>, JpaSpecificationExecutor<QkjCourseWare> {
12
+
13
+    @Query(value = "SELECT a.* FROM qkj_courseware a WHERE a.status=1 and a.is_visiable = 1 order by top_status desc, a.create_time desc limit ?1, ?2",nativeQuery = true)
14
+    List<QkjCourseWare> findList(Integer start, Integer size);
15
+
16
+    @Query(value = "select qt.* from qkj_courseware qt " +
17
+                        "inner join qkj_catalogs_detail qcd on qcd.obj_id = qt.id " +
18
+                    "where qcd.catalogs_id in (?1) and qcd.obj_type = 5 and qt.status = 1 and qt.is_visiable = 1 order by qt.top_status desc, qt.create_time desc limit ?2,?3",nativeQuery = true)
19
+    List<QkjCourseWare> findList(String cataIds, Integer start, Integer size);
20
+
21
+
22
+    @Query(value = "SELECT  count(*)  FROM qkj_courseware  WHERE status=1  and is_visiable = 1 ",nativeQuery = true)
23
+    Integer findListCount();
24
+
25
+    @Query(value = "select count(*)  from qkj_courseware qt " +
26
+            "inner join qkj_catalogs_detail qcd on qcd.obj_id = qt.id " +
27
+            "where qcd.catalogs_id in (?1) and qcd.obj_type = 5 and qt.status = 1 and qt.is_visiable = 1 ",nativeQuery = true)
28
+    Integer findListCount(String cataIds);
29
+
30
+    @Query(value = "select DISTINCT qt.* from qkj_courseware qt inner join qkj_catalogs_detail qcd on qcd.obj_id = qt.id where qcd.catalogs_id = ?1 and qcd.obj_type = 5 and qt.status = 1 and qt.is_visiable = 1 ", nativeQuery = true)
31
+    List<QkjCourseWare> getByCataIds(Integer intValue);
32
+
33
+    @Query(value = "SELECT a.* FROM qkj_courseware a WHERE a.uploader= ?1 and  a.status=1 and a.is_visiable in(0 ,1 , 2) order by top_status desc, a.create_time desc limit ?2, ?3",nativeQuery = true)
34
+    List<QkjCourseWare> findListByMember(String memCard,Integer start, Integer size);
35
+
36
+    @Query(value = "SELECT * FROM qkj_courseware  WHERE id = ?1",nativeQuery = true)
37
+    QkjCourseWare getQkjCourseWare(Long id);
38
+
39
+    @Query(value = "SELECT  count(*)  FROM qkj_courseware  WHERE status=1  and is_visiable = 2 and uploader = ?1 ",nativeQuery = true)
40
+    Integer findListCountPpt(String memCard);
41
+
42
+
43
+    @Query(value = "SELECT * FROM qkj_courseware  WHERE id in (?1) ",nativeQuery = true)
44
+    List<QkjCourseWare> listQkjCourseWare(List<Integer> ids);
45
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjExaminationDetailDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+
5
+
6
+import com.cirle.scientific.po.QkjExaminationDetail;
7
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.PagingAndSortingRepository;
10
+
11
+public interface QkjExaminationDetailDao  extends PagingAndSortingRepository<QkjExaminationDetail, Long>, JpaSpecificationExecutor<QkjExaminationDetail> {
12
+
13
+
14
+    @Query(value = "select ex_id from qkj_examination_detail where obj_type = ?1 and obj_id = ?2 and state = 0",nativeQuery = true)
15
+    Integer findExIdByObjTypeAndObjId(int objType , int objId);
16
+
17
+}

+ 22
- 0
src/main/java/com/cirle/scientific/dao/QkjIntegralDetailDao.java View File

@@ -0,0 +1,22 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.dto.UserOderDto;
4
+import com.cirle.scientific.po.QkjIntegralDetail;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+import java.util.List;
10
+
11
+public interface QkjIntegralDetailDao extends
12
+        PagingAndSortingRepository<QkjIntegralDetail, Long>, JpaSpecificationExecutor<QkjIntegralDetail> {
13
+
14
+	@Query(value = "SELECT * FROM qkj_integral_detail WHERE mem_card = ?1 ORDER BY change_time DESC LIMIT ?2,?3" ,nativeQuery = true)
15
+    List<QkjIntegralDetail> findByMemCard(String memCard,Integer start,Integer size);
16
+
17
+    @Query(value = "SELECT * FROM qkj_integral_detail WHERE mem_card = ?1 ORDER BY change_time DESC" ,nativeQuery = true)
18
+    List<QkjIntegralDetail> findUserOder(String memCard);
19
+
20
+	@Query(value = "SELECT * FROM qkj_integral_detail ORDER BY change_time DESC LIMIT ?1,?2" ,nativeQuery = true)
21
+    List<QkjIntegralDetail> findByNewChange(Integer start,Integer size);
22
+}

+ 101
- 0
src/main/java/com/cirle/scientific/dao/QkjIntegralGoodsDao.java View File

@@ -0,0 +1,101 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjIntegralGoods;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+import java.util.Map;
10
+
11
+public interface QkjIntegralGoodsDao  extends PagingAndSortingRepository<QkjIntegralGoods, Long>, JpaSpecificationExecutor<QkjIntegralGoods> {
12
+
13
+
14
+    @Query(value = "select  * from qkj_integral_goods where goods_status = 0 order by sqn desc limit ?1,?2",nativeQuery = true)
15
+    List<QkjIntegralGoods> findGoodMallList(Integer page,Integer size);
16
+
17
+    @Query(value = "select  count(*) from qkj_integral_goods where goods_status = 0 order by sqn desc ",nativeQuery = true)
18
+    Integer findGoodMallListSize();
19
+
20
+    @Query(value = "SELECT\n" +
21
+            "\tcount(*) \n" +
22
+            "FROM\n" +
23
+            "\t(\n" +
24
+            "\tSELECT\n" +
25
+            "\t\tid,\n" +
26
+            "\t\tgoods_img AS 'img',\n" +
27
+            "\t\tgoods_name AS 'name',\n" +
28
+            "\t\t\"商品\" AS 'type',\n" +
29
+            "\t\t`goods_status` AS 'goodsStatus',\n" +
30
+            "\t\tNULL AS 'status',\n" +
31
+            "\t\tgoods_need_points AS \"points\",\n" +
32
+            "\t\tNULL AS \"price\",\n" +
33
+            "\t\tNULL AS \"zq\",\n" +
34
+            "\t\tNULL AS \"purchasedMembers\",\n" +
35
+            "\t\tNULL AS \"totalClassHours\" \n" +
36
+            "\tFROM\n" +
37
+            "\t\tqkj_integral_goods \n" +
38
+            "\tWHERE\n" +
39
+            "\t\tgoods_status = 0 UNION ALL\n" +
40
+            "\tSELECT\n" +
41
+            "\t\tid,\n" +
42
+            "\t\tcover_img AS 'img',\n" +
43
+            "\t\ttitle AS 'name',\n" +
44
+            "\t\t\"课程\" AS 'type',\n" +
45
+            "\t\tNULL AS \"goodsStatus\",\n" +
46
+            "\t\t`status` AS 'status',\n" +
47
+            "\t\tpoint AS \"points\",\n" +
48
+            "\t\tprice AS \"price\",\n" +
49
+            "\t\tzq AS \"zq\",\n" +
50
+            "\t\tpurchased_members AS \"purchasedMembers\",\n" +
51
+            "\t\ttotal_class_hours AS \"totalClassHours\" \n" +
52
+            "\tFROM\n" +
53
+            "\t\tqkj_tqcourse \n" +
54
+            "\tWHERE\n" +
55
+            "\t\tSTATUS = 1 \n" +
56
+            "\tAND is_visiable = 1 \n" +
57
+            "\t) AS test",nativeQuery = true)
58
+    Integer findAllListSize();
59
+
60
+    @Query(value = "SELECT\n" +
61
+            " *\n" +
62
+            "FROM\n" +
63
+            "\t(\n" +
64
+            "\tSELECT\n" +
65
+            "\t\tid AS 'id',\n" +
66
+            "\t\tgoods_img AS 'img',\n" +
67
+            "\t\tgoods_name AS 'name',\n" +
68
+            "\t\t\"商品\" AS 'type',\n" +
69
+            "\t\t`goods_status` AS 'goodsStatus',\n" +
70
+            "\t\tNULL AS 'status',\n" +
71
+            "\t\tgoods_need_points AS \"points\",\n" +
72
+            "\t\tNULL AS \"price\",\n" +
73
+            "\t\tNULL AS \"zq\",\n" +
74
+            "\t\tNULL AS \"purchasedMembers\",\n" +
75
+            "\t\tNULL AS \"totalClassHours\" \n" +
76
+            "\tFROM\n" +
77
+            "\t\tqkj_integral_goods \n" +
78
+            "\tWHERE\n" +
79
+            "\t\tgoods_status = 0 UNION ALL\n" +
80
+            "\tSELECT\n" +
81
+            "\t\tid AS 'id',\n" +
82
+            "\t\tcover_img AS 'img',\n" +
83
+            "\t\ttitle AS 'name',\n" +
84
+            "\t\t\"课程\" AS 'type',\n" +
85
+            "\t\tNULL AS \"goodsStatus\",\n" +
86
+            "\t\t`status` AS 'status',\n" +
87
+            "\t\tpoint AS \"points\",\n" +
88
+            "\t\tprice AS \"price\",\n" +
89
+            "\t\tzq AS \"zq\",\n" +
90
+            "\t\tpurchased_members AS \"purchasedMembers\",\n" +
91
+            "\t\ttotal_class_hours AS \"totalClassHours\" \n" +
92
+            "\tFROM\n" +
93
+            "\t\tqkj_tqcourse \n" +
94
+            "\tWHERE\n" +
95
+            "\t\tSTATUS = 1 \n" +
96
+            "\tAND is_visiable = 1 \n" +
97
+            "\t) AS test limit ?1, ?2\n" +
98
+            "\t",nativeQuery = true)
99
+    List<Map<String,Object>> findLimitAllList(Integer page,Integer size);
100
+
101
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjLiveCommentsDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import com.cirle.scientific.po.QkjLiveComments;
11
+
12
+
13
+@Repository
14
+public interface QkjLiveCommentsDao extends PagingAndSortingRepository<QkjLiveComments, Long>, JpaSpecificationExecutor<QkjLiveComments> {
15
+    @Query(value = "SELECT * from qkj_live_comments where live_id = ?1 and content != '' ORDER BY opr_time desc LIMIT 10",nativeQuery = true)
16
+    List<QkjLiveComments> getComments(Long liveId);
17
+}

+ 96
- 0
src/main/java/com/cirle/scientific/dao/QkjLiveDao.java View File

@@ -0,0 +1,96 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Modifying;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.PagingAndSortingRepository;
10
+import org.springframework.data.repository.query.Param;
11
+import org.springframework.stereotype.Repository;
12
+
13
+import com.cirle.scientific.po.QkjLive;
14
+import org.springframework.transaction.annotation.Propagation;
15
+import org.springframework.transaction.annotation.Transactional;
16
+
17
+@Repository
18
+public interface QkjLiveDao extends PagingAndSortingRepository<QkjLive, Long>, JpaSpecificationExecutor<QkjLive> {
19
+
20
+	QkjLive findByLiveId(String liveId);
21
+
22
+	@Query(value = "(SELECT a.* FROM (SELECT * FROM qkj_live WHERE live_status=1 and status=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?3) ORDER BY live_begin_time ASC) a) "
23
+					+"	UNION all "
24
+					+"	(SELECT b.* FROM (SELECT * FROM qkj_live WHERE live_status=0 AND STATUS=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?3) ORDER BY live_begin_time ASC) b) "
25
+					+"	UNION all "
26
+					+"	(SELECT b.* FROM (SELECT * FROM qkj_live WHERE STATUS=1 and live_type=2 and m_or_pc in (?3) ORDER BY create_time desc) b) "
27
+					+"	UNION all "
28
+					+"	(SELECT d.* FROM (SELECT * FROM qkj_live WHERE live_status=3 AND STATUS=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?3) ORDER BY live_begin_time desc) d) "
29
+					+"	UNION all "
30
+					+"	(SELECT d.* FROM (SELECT * FROM qkj_live WHERE live_status=2 AND STATUS=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?3) ORDER BY live_begin_time desc) d) "
31
+					+" order by istop  desc , create_time  desc  limit ?1,?2",nativeQuery = true)
32
+    List<QkjLive> findList(int start, int size,Integer[] mOrPc);
33
+
34
+	@Query(value = "(SELECT a.* FROM (SELECT * FROM qkj_live WHERE id in(SELECT d.live_id from qkj_live_series d where d.series_id = ?1) and live_status=1 and status=1 and is_visiable =1 ORDER BY live_begin_time ASC) a) "
35
+			+"	UNION all "
36
+			+"	(SELECT b.* FROM (SELECT * FROM qkj_live WHERE id in(SELECT d.live_id from qkj_live_series d where d.series_id = ?1) and live_status=0 AND STATUS=1 and is_visiable =1  ORDER BY live_begin_time ASC) b) "
37
+			+"	UNION all "
38
+			+"	(SELECT d.* FROM (SELECT * FROM qkj_live WHERE id in(SELECT d.live_id from qkj_live_series d where d.series_id = ?1) and live_status>=2 AND STATUS=1 and is_visiable =1  ORDER BY live_begin_time desc) d) "
39
+			+"  order by istop desc limit ?2,?3",nativeQuery = true)
40
+	List<QkjLive> findSonList(int seriesId, int start, int size);
41
+
42
+	/**
43
+	 * 更具系列直播id 查出子系列的直播的数据(过滤掉已隐藏的直播)
44
+	 * @param seriesId  系列直播的id
45
+	 * @param start  分页的页数
46
+	 * @param size   每页的行数
47
+	 * @return
48
+	 */
49
+	@Query(value = "SELECT * FROM qkj_live WHERE id = ?1 and  status=1 and is_visiable=1  limit ?2,?3",nativeQuery = true)
50
+	QkjLive selectSonList(int seriesId, int start, int size);
51
+
52
+	@Query(value = "SELECT d.live_id from qkj_live_series d where d.series_id = ?1 order by sqn asc ",nativeQuery = true)
53
+	List<Integer> selectLiveIdBySqn(int seriesId);
54
+
55
+	@Query(value = "select count(*) from ("
56
+			+"(SELECT a.* FROM (SELECT * FROM qkj_live WHERE live_status=1 and status=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?1) ORDER BY live_begin_time ASC) a) "
57
+			+"	UNION all "
58
+			+"	(SELECT b.* FROM (SELECT * FROM qkj_live WHERE live_status=0 AND STATUS=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?1) ORDER BY live_begin_time ASC) b) "
59
+			+"	UNION all "
60
+			+"	(SELECT b.* FROM (SELECT * FROM qkj_live WHERE STATUS=1 and live_type=2 and m_or_pc in (?1) ORDER BY create_time desc) b) "
61
+			+"	UNION all "
62
+			+"	(SELECT d.* FROM (SELECT * FROM qkj_live WHERE live_status=3 AND STATUS=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?1) ORDER BY live_begin_time desc) d) "
63
+			+"	UNION all "
64
+			+"	(SELECT d.* FROM (SELECT * FROM qkj_live WHERE live_status=2 AND STATUS=1 and live_type!=2 and is_visiable=1 and m_or_pc in (?1) ORDER BY live_begin_time desc) d)" +
65
+			")m ",nativeQuery = true)
66
+	Integer selectAllCounts(Integer[] mOrPc);
67
+
68
+
69
+	@Query(value = "select a.* from qkj_live a where live_status=1  and  is_visiable=1 ",nativeQuery = true)
70
+	List<QkjLive> findMy();
71
+
72
+	@Transactional(propagation= Propagation.REQUIRES_NEW)
73
+	@Modifying
74
+	@Query(value = "update qkj_live set  purchased_members  =  purchased_members + :num where id = :liveId and live_status=1",nativeQuery = true)
75
+	void updatePurchasedMembers(@Param(value = "num")long num, @Param(value = "liveId")long liveId);
76
+
77
+	@Transactional(propagation= Propagation.REQUIRES_NEW)
78
+	@Modifying
79
+	@Query(value = "update qkj_live set  join_members  =  join_members + :num where id = :liveId and live_status=1",nativeQuery = true)
80
+	void updateJoinMembers(@Param(value = "num")long num, @Param(value = "liveId")long liveId);
81
+
82
+	@Transactional(propagation= Propagation.REQUIRES_NEW)
83
+	@Modifying
84
+	@Query(value = "update qkj_live set  join_members  =  join_members - :num where id = :liveId and live_status=1",nativeQuery = true)
85
+	void reduceJoinMembers(@Param(value = "num")long num, @Param(value = "liveId")long liveId);
86
+
87
+	@Query(value = "SELECT * FROM qkj_live WHERE id = ?1 ",nativeQuery = true)
88
+	QkjLive findById(String liveId);
89
+//
90
+//	@Transactional(propagation= Propagation.REQUIRES_NEW)
91
+//	@Modifying
92
+//	@Query("update QkjLive lv set lv.purchasedMembers=lv.purchasedMembers+: num where lv.id=:liveId and lv.liveStatus=1")
93
+//	void updatePurchasedMembers(@Param(value = "num") long num, @Param(value = "liveId")long liveId);
94
+
95
+
96
+}

+ 23
- 0
src/main/java/com/cirle/scientific/dao/QkjLiveRemindDao.java View File

@@ -0,0 +1,23 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.math.BigInteger;
4
+import java.util.List;
5
+
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+import org.springframework.stereotype.Repository;
10
+
11
+import com.cirle.scientific.po.QkjLiveRemind;
12
+
13
+
14
+@Repository
15
+public interface QkjLiveRemindDao extends PagingAndSortingRepository<QkjLiveRemind, Long>, JpaSpecificationExecutor<QkjLiveRemind> {
16
+
17
+	QkjLiveRemind findByLiveIdAndMemCard(String liveId, String memCard);
18
+
19
+    List<QkjLiveRemind> findByLiveId(String liveId);
20
+
21
+    @Query(value = "SELECT COUNT(id) FROM qkj_live_remind WHERE live_id = ?1",nativeQuery = true)
22
+    BigInteger findRemindCount(String liveId);
23
+}

+ 19
- 0
src/main/java/com/cirle/scientific/dao/QkjLiveSeriesDao.java View File

@@ -0,0 +1,19 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjLiveRemind;
4
+import com.cirle.scientific.po.QkjLiveSeries;
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import java.math.BigInteger;
11
+import java.util.List;
12
+
13
+
14
+@Repository
15
+public interface QkjLiveSeriesDao extends PagingAndSortingRepository<QkjLiveSeries, Long>, JpaSpecificationExecutor<QkjLiveSeries> {
16
+
17
+	List<QkjLiveSeries> findByLiveId(Integer liveId);
18
+
19
+}

+ 22
- 0
src/main/java/com/cirle/scientific/dao/QkjMemberDorecDao.java View File

@@ -0,0 +1,22 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjArticle;
5
+import com.cirle.scientific.po.QkjMemberDorec;
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+import org.springframework.stereotype.Repository;
10
+
11
+import java.util.List;
12
+
13
+
14
+@Repository
15
+public interface QkjMemberDorecDao extends PagingAndSortingRepository<QkjMemberDorec, Long>, JpaSpecificationExecutor<QkjMemberDorec> {
16
+
17
+    @Query(value = "SELECT * FROM qkj_member_dorec WHERE mem_card=?1 and opr_type=?2 and obj_type=?3 and obj_id=?4 and TO_DAYS(NOW())=TO_DAYS(opr_time)",nativeQuery = true)
18
+    List<QkjMemberDorec> findTodayLogs(String memCard, Integer oprType, Integer objType, Integer objId);
19
+
20
+    @Query(value = "SELECT * FROM qkj_member_dorec WHERE mem_card=?1 and opr_type=?2 and url=?3 and TO_DAYS(NOW())=TO_DAYS(opr_time)",nativeQuery = true)
21
+    List<QkjMemberDorec> findTodayLogs(String memCard, Integer oprType, String url);
22
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjMemberOpenidDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import com.cirle.scientific.po.QkjBrandProductDetail;
5
+import com.cirle.scientific.po.QkjMemberOpenid;
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import java.util.List;
11
+
12
+
13
+@Repository
14
+public interface QkjMemberOpenidDao extends PagingAndSortingRepository<QkjMemberOpenid, Long>, JpaSpecificationExecutor<QkjMemberOpenid> {
15
+
16
+	QkjMemberOpenid findByMemCardAndAppId(String memCard, String appId);
17
+}

+ 16
- 0
src/main/java/com/cirle/scientific/dao/QkjMemberPersonalAuthDao.java View File

@@ -0,0 +1,16 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjMemberPersonalAuth;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+public interface QkjMemberPersonalAuthDao extends PagingAndSortingRepository<QkjMemberPersonalAuth, Long>, JpaSpecificationExecutor<QkjMemberPersonalAuth> {
9
+
10
+    @Query(value = "select  * from  qkj_member_personal_auth where mem_card = ?1", nativeQuery = true)
11
+    QkjMemberPersonalAuth findByMemCard(String memCard);
12
+
13
+    @Query(value = "select  * from  qkj_member_personal_auth where mem_identity_id = ?1", nativeQuery = true)
14
+    QkjMemberPersonalAuth checkCard(String card);
15
+
16
+}

+ 19
- 0
src/main/java/com/cirle/scientific/dao/QkjMemberTaskDao.java View File

@@ -0,0 +1,19 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjMemberTask;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjMemberTaskDao extends PagingAndSortingRepository<QkjMemberTask, Long>, JpaSpecificationExecutor<QkjMemberTask> {
11
+
12
+
13
+    @Query(value = "SELECT * FROM qkj_member_task WHERE task_type = ?1 AND task_status = 0" ,nativeQuery = true)
14
+    public List<QkjMemberTask> findByTaskType(Integer taskType);
15
+
16
+
17
+    @Query(value = "SELECT * FROM qkj_member_task order by sqn desc" ,nativeQuery = true)
18
+    List<QkjMemberTask> findUserTaskList();
19
+}

+ 29
- 0
src/main/java/com/cirle/scientific/dao/QkjMemberTaskDetailDao.java View File

@@ -0,0 +1,29 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjMemberTaskDetail;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjMemberTaskDetailDao extends PagingAndSortingRepository<QkjMemberTaskDetail, Long>, JpaSpecificationExecutor<QkjMemberTaskDetail> {
11
+
12
+    @Query(value = "SELECT * FROM qkj_member_task_detail WHERE mem_card = ?1 AND task_id = ?2 And type=0" ,nativeQuery = true)
13
+    List<QkjMemberTaskDetail> findMemberAndTaskId(String memCard, Integer taskId);
14
+
15
+    @Query(value = "SELECT * FROM qkj_member_task_detail WHERE mem_card = ?1 AND task_id = ?2 And type=0 AND TO_DAYS(complete_time) = TO_DAYS(NOW())" ,nativeQuery = true)
16
+    List<QkjMemberTaskDetail> findDailyTask(String memCard, Integer taskId);
17
+
18
+    @Query(value = "select DATE_FORMAT(complete_time, '%Y-%m-%d') as date from qkj_member_task_detail where DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d'), interval 6 DAY) <= DATE_FORMAT(complete_time, '%Y-%m-%d') AND mem_card =?1 AND complete_time>=?2 AND task_id = 18 And type=0 group by date" ,nativeQuery = true)
19
+    List<Object> sevenDayCheckIn(String memCard,String time);
20
+
21
+    @Query(value = "select  DATE_FORMAT(complete_time, '%Y-%m-%d') as date from qkj_member_task_detail where DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d'), interval 7 DAY) <= DATE_FORMAT(complete_time, '%Y-%m-%d') AND mem_card =?1 AND complete_time>=?2 AND task_id = 18 And type=0 group by date " ,nativeQuery = true)
22
+    List<Object> sevenDayCheckInEn(String memCard, String time);
23
+
24
+    @Query(value = "select  DATE_FORMAT(complete_time, '%Y-%m-%d') as date from qkj_member_task_detail where DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d'), interval 6 DAY) <= DATE_FORMAT(complete_time, '%Y-%m-%d') AND mem_card =?1 AND complete_time>=?2 AND task_id = 18 And type=0 AND points=10 group by date" ,nativeQuery = true)
25
+    List<Object> sevenDayCheckInFirst(String memCard, String time);
26
+
27
+    @Query(value = "SELECT qmt.task_desc,qmtd.points,qmtd.change_type,qmtd.complete_time FROM qkj_member_task_detail qmtd left join qkj_member_task qmt on qmtd.task_id = qmt.id WHERE mem_card = ?1 order by qmtd.complete_time desc" ,nativeQuery = true)
28
+    List<Object[]> findUserTaskInfo(String memCard);
29
+}

+ 25
- 0
src/main/java/com/cirle/scientific/dao/QkjMemberTaskInfoDao.java View File

@@ -0,0 +1,25 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjMemberTaskInfo;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjMemberTaskInfoDao  extends PagingAndSortingRepository<QkjMemberTaskInfo, Long>, JpaSpecificationExecutor<QkjMemberTaskInfo> {
11
+
12
+
13
+    @Query(value = "SELECT * FROM qkj_member_task_info WHERE mem_card = ?1 " ,nativeQuery = true)
14
+    public QkjMemberTaskInfo findByMemCard (String memCard);
15
+
16
+//    @Query(value = "SELECT * FROM qkj_member_task_info order by mem_total_points desc" ,nativeQuery = true)
17
+//    List<QkjMemberTaskInfo> findUserjfRanking();
18
+
19
+    @Query(value = "SELECT a.* FROM qkj_member_task_info a left join qkj_member b on a.mem_card = b.mem_card " +
20
+            "where b.mem_nickname is not null order by a.mem_residual_points desc ,b.mem_register_time asc limit 50" ,nativeQuery = true)
21
+    List<QkjMemberTaskInfo> findUserjfRanking();
22
+
23
+    @Query(value = "SELECT * FROM qkj_member_task_info order by mem_residual_points desc limit 50" ,nativeQuery = true)
24
+    List<QkjMemberTaskInfo> findUserjfRankingNew();
25
+}

+ 25
- 0
src/main/java/com/cirle/scientific/dao/QkjPhotoWallDao.java View File

@@ -0,0 +1,25 @@
1
+package com.cirle.scientific.dao;/*
2
+ *24901
3
+ *2022/11/10
4
+ *14:14
5
+ */
6
+
7
+import com.cirle.scientific.po.QkjPhotoWall;
8
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
9
+import org.springframework.data.jpa.repository.Query;
10
+import org.springframework.data.repository.PagingAndSortingRepository;
11
+
12
+import java.util.List;
13
+
14
+/**
15
+ * @author 24901
16
+ */
17
+public interface QkjPhotoWallDao extends PagingAndSortingRepository<QkjPhotoWall, Long>, JpaSpecificationExecutor<QkjPhotoWall> {
18
+
19
+    @Query(value = "select * from qkj_photowall where type = ?1 and obj_id = ?2 and state = 0 limit ?3 ,?4",nativeQuery = true)
20
+    List<QkjPhotoWall> findAllByTypeAndObjId(Integer type, Integer id, Integer start, Integer size);
21
+
22
+    @Query(value = "select count(*) from qkj_photowall where type = ?1 and obj_id = ?2 and state = 0 ",nativeQuery = true)
23
+    Integer findAllByTypeAndObjId(Integer type, Integer id);
24
+
25
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjPositonsDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+import com.cirle.scientific.po.QkjPositions;
10
+
11
+public interface QkjPositonsDao
12
+						extends PagingAndSortingRepository<QkjPositions, Long>, JpaSpecificationExecutor<QkjPositions> {
13
+	
14
+	@Query(value = "SELECT * FROM qkj_positions WHERE p_posid = ?1 order by sqn DESC" ,nativeQuery = true)
15
+	List<QkjPositions> findBypPosId(Integer pid);
16
+
17
+}

+ 17
- 0
src/main/java/com/cirle/scientific/dao/QkjPurchasedRecordsDao.java View File

@@ -0,0 +1,17 @@
1
+package com.cirle.scientific.dao;
2
+
3
+
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+import org.springframework.stereotype.Repository;
8
+
9
+import com.cirle.scientific.po.QkjPurchasedRecords;
10
+
11
+@Repository
12
+public interface QkjPurchasedRecordsDao extends PagingAndSortingRepository<QkjPurchasedRecords, Long>, JpaSpecificationExecutor<QkjPurchasedRecords> {
13
+
14
+    @Query(value = "select mpr.* from qkj_purchased_records mpr where mpr.status=0 and mpr.obj_type=?2 and mpr.mem_card=?1 and mpr.obj_id=?3 and mpr.ispackage=?4 limit 0,1", nativeQuery = true)
15
+    QkjPurchasedRecords findByMemCardAndObjId(String memCard, Integer objType, Integer objId, Integer ispackage);
16
+
17
+}

+ 32
- 0
src/main/java/com/cirle/scientific/dao/QkjQuestionAnswerDao.java View File

@@ -0,0 +1,32 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Modifying;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+import org.springframework.stereotype.Repository;
10
+
11
+import com.cirle.scientific.po.QkjQuestionAnswer;
12
+
13
+@Repository
14
+public interface QkjQuestionAnswerDao extends PagingAndSortingRepository<QkjQuestionAnswer, Long>, JpaSpecificationExecutor<QkjQuestionAnswer> {
15
+	
16
+	List<QkjQuestionAnswer> findByMemCardAndObjTypeAndObjId(String memCard, Integer objType, Integer objId);
17
+	
18
+	@Modifying
19
+	@Query(value = "delete from qkj_question_answer where mem_card = ?1 and obj_type=?2 and obj_id=?3", nativeQuery = true)
20
+	void deleteByMemberAndObjTypeAndOjbId(String memCard, Integer objType, Integer objId);
21
+
22
+	@Modifying
23
+	@Query(value = "delete from qkj_question_answer where mem_card = ?1 and obj_type=?2 and obj_id=?3 and record_id=?4", nativeQuery = true)
24
+	void deleteByMemberAndObjTypeAndOjbIdAndRecordId(String memCard, Integer objType, Integer objId, Integer recordId);
25
+
26
+	@Query(value = "SELECT a.* FROM qkj_question_answer a WHERE a.mem_card=?1 and a.obj_type=2 and a.obj_id=?2 and a.record_id=?3",nativeQuery = true)
27
+	List<QkjQuestionAnswer> findConferPeopleAttribute(String memCard,Integer conferId, Integer recordId);
28
+
29
+
30
+	@Query(value = "SELECT a.* FROM qkj_question_answer a WHERE  mem_card = ?1 and obj_type=?2 and obj_id=?3", nativeQuery = true)
31
+	List<QkjQuestionAnswer> findByCardAndTypeAndId(String memCard, Integer objType, Integer objId);
32
+}

+ 20
- 0
src/main/java/com/cirle/scientific/dao/QkjQuestionDetailDao.java View File

@@ -0,0 +1,20 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import com.cirle.scientific.po.QkjQuestionDetail;
11
+
12
+@Repository
13
+public interface QkjQuestionDetailDao extends PagingAndSortingRepository<QkjQuestionDetail, Long>, JpaSpecificationExecutor<QkjQuestionDetail> {
14
+	
15
+	@Query(value = "SELECT * FROM qkj_question_detail WHERE obj_type=?1 and obj_id=?2 and status=0 order by sqn desc",nativeQuery = true)
16
+	List<QkjQuestionDetail> findByObjTypeAndObjId(Integer objType, Integer objId);
17
+
18
+	@Query(value = "SELECT * FROM qkj_question_detail WHERE obj_type=?1 and obj_id=?2 and status=0 order by sqn asc",nativeQuery = true)
19
+	List<QkjQuestionDetail> SelectByObjTypeAndObjId(Integer objType, Integer objId);
20
+}

+ 38
- 0
src/main/java/com/cirle/scientific/dao/QkjRecommendDao.java View File

@@ -0,0 +1,38 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import java.util.List;
4
+
5
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+import com.cirle.scientific.po.QkjRecommend;
10
+
11
+public interface QkjRecommendDao
12
+		extends PagingAndSortingRepository<QkjRecommend, Long>, JpaSpecificationExecutor<QkjRecommend> {
13
+
14
+	@Query(value = "select a.* from qkj_recommend a where a.pos_id=?1 and a.status = 1 order by a.sort_num desc limit ?2,?3", nativeQuery = true)
15
+	List<QkjRecommend> findByPosId(Integer posId, int start, int size);
16
+
17
+	@Query(value = "select a.* from qkj_recommend a where a.pos_id=?1 and (a.status = 1 or a.status=?2) order by a.sort_num desc limit ?3,?4", nativeQuery = true)
18
+	List<QkjRecommend> findByPosId(Integer posId, Integer status, int start, int size);
19
+
20
+	@Query(value = "SELECT * FROM qkj_recommend WHERE pos_id IN (SELECT id FROM sys_positions WHERE p_posid = ?1) LIMIT ?2,?3" ,nativeQuery = true)
21
+	List<QkjRecommend> findBypPosId(Integer pid, Integer start, Integer size);
22
+
23
+	@Query(value = "SELECT * FROM qkj_recommend WHERE pos_id IN (SELECT id FROM sys_positions WHERE p_posid = ?1) AND rcmd_obj_id = ?4 LIMIT ?2,?3",nativeQuery = true)
24
+	List<QkjRecommend> findByPosIdAndObjId(Integer posId, int i, int size, Long objId);
25
+
26
+	@Query(value = "SELECT * FROM qkj_recommend WHERE status=1 AND id = ?1",nativeQuery = true)
27
+	QkjRecommend findByIdAndStatus(Long id);
28
+
29
+	@Query(value = "SELECT r.* FROM qkj_recommend_detail d"
30
+					+"	LEFT JOIN qkj_recommend r on d.rcmd_id = r.id"
31
+					+" WHERE post_type=?1 and obj_id=?2 and d.`status`=0 and r.`status`=1 ORDER BY d.sqn desc LIMIT ?3,?4" ,nativeQuery = true)
32
+	List<QkjRecommend> findByPostTypeAndObjId(Integer postType, Integer objId, Integer start, Integer size);
33
+
34
+
35
+	@Query(value = "select * from qkj_recommend where rcmd_obj_id = ?1  and  rcmd_type =?2",nativeQuery = true)
36
+	List<QkjRecommend> findListByObjIdAndType(Long id, Integer type);
37
+
38
+}

+ 22
- 0
src/main/java/com/cirle/scientific/dao/QkjShareDao.java View File

@@ -0,0 +1,22 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjShare;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+import org.springframework.stereotype.Repository;
8
+
9
+import java.util.List;
10
+
11
+
12
+@Repository
13
+public interface QkjShareDao extends PagingAndSortingRepository<QkjShare, Long>, JpaSpecificationExecutor<QkjShare> {
14
+    @Query(value = "SELECT * FROM qkj_share WHERE share_memcard = ?1 AND click_memcard = ?2" +
15
+            " AND obj_type = ?3 and obj_id= ?4", nativeQuery = true)
16
+    List<QkjShare> getQkjShare(String shareMemcard, String clickMemcard, Integer objType, Integer objId);
17
+
18
+
19
+    @Query(value = "SELECT * FROM qkj_share WHERE  obj_type = ?1 and obj_id= ?2", nativeQuery = true)
20
+    List<QkjShare> getQkjShareByObjTYpeAndObjId(Integer objType, Integer objId);
21
+
22
+}

+ 21
- 0
src/main/java/com/cirle/scientific/dao/QkjTagsDao.java View File

@@ -0,0 +1,21 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjTags;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjTagsDao  extends PagingAndSortingRepository<QkjTags, Long>, JpaSpecificationExecutor<QkjTags> {
11
+
12
+    @Query(value = "select qt.* from qkj_tags qt inner join qkj_tags_detail qtd on qtd.tag_id = qt.id where qtd.obj_id = ?1 and qtd.obj_type = 2 order by qtd.sqn desc limit 0,2",nativeQuery = true)
13
+    List<QkjTags> findCourseTagsByCourseId(Long id);
14
+
15
+
16
+    @Query(value = "select qt.* from qkj_tags qt inner join qkj_tags_detail qtd on qtd.tag_id = qt.id where qtd.obj_id = ?1 and qtd.obj_type = ?2 order by qtd.sqn desc ",nativeQuery = true)
17
+    List<QkjTags> findTagsByObjIdAndObjType(Long objId,Integer objType);
18
+
19
+    @Query(value = "select qt.* from qkj_tags qt inner join qkj_tags_detail qtd on qtd.tag_id = qt.id where qtd.obj_id in (?1) and qtd.obj_type = 2 order by qtd.sqn desc",nativeQuery = true)
20
+    List<QkjTags> findAllTags(String ids);
21
+}

+ 14
- 0
src/main/java/com/cirle/scientific/dao/QkjTagsDetailDao.java View File

@@ -0,0 +1,14 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjTagsDetail;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Modifying;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.PagingAndSortingRepository;
8
+
9
+public interface QkjTagsDetailDao extends PagingAndSortingRepository<QkjTagsDetail, Long>, JpaSpecificationExecutor<QkjTagsDetail> {
10
+
11
+    @Modifying
12
+    @Query(value = "delete from qkj_tags_detail where obj_id = ?1 and obj_type = ?2",nativeQuery = true)
13
+    void deleteByObjIdAndObjType(Long objId, int type);
14
+}

+ 15
- 0
src/main/java/com/cirle/scientific/dao/QkjTqcourseCommentsDao.java View File

@@ -0,0 +1,15 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjTqcourseComments;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjTqcourseCommentsDao extends PagingAndSortingRepository<QkjTqcourseComments, Long>, JpaSpecificationExecutor<QkjTqcourseComments> {
11
+
12
+
13
+    @Query(value = "select * from qkj_tqcourse_comments where tqcourse_id = ?1 order by opr_time desc",nativeQuery = true)
14
+    List<QkjTqcourseComments> findCommentsByCourseId(Long id);
15
+}

+ 20
- 0
src/main/java/com/cirle/scientific/dao/QkjTqcourseCourseDao.java View File

@@ -0,0 +1,20 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjTqcourseCourse;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjTqcourseCourseDao extends PagingAndSortingRepository<QkjTqcourseCourse, Long>, JpaSpecificationExecutor<QkjTqcourseCourse> {
11
+
12
+
13
+
14
+    @Query(value = "select * from qkj_tqcourse_course where status = 1 and tqcourse_id = ?1 order by sort_num desc",nativeQuery = true)
15
+    List<QkjTqcourseCourse> findCourseCourse(Integer zqId);
16
+
17
+
18
+    @Query(value = "select id from qkj_tqcourse_course where status = 1 and tqcourse_id = ?1 order by sort_num desc",nativeQuery = true)
19
+    List<Long> findCourseCourseIds(Integer zqId);
20
+}

+ 71
- 0
src/main/java/com/cirle/scientific/dao/QkjTqcourseDao.java View File

@@ -0,0 +1,71 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjTqcourse;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjTqcourseDao extends PagingAndSortingRepository<QkjTqcourse, Long>, JpaSpecificationExecutor<QkjTqcourse> {
11
+
12
+
13
+    @Query(value = "select DISTINCT qt.* from qkj_tqcourse qt inner join qkj_catalogs_detail qcd on qcd.obj_id = qt.id where qcd.catalogs_id in ?1 and qcd.obj_type = 2 and qt.status = 1 and qt.is_visiable = 1  order by qt.top_status desc, qt.create_time desc limit ?2,?3", nativeQuery = true)
14
+    List<QkjTqcourse> getIndexData(List cataId, Integer start, Integer size);
15
+
16
+    @Query(value = "select DISTINCT qt.* from qkj_tqcourse qt inner join qkj_catalogs_detail qcd on qcd.obj_id = qt.id where qcd.catalogs_id = ?1 and qcd.obj_type = 2 and qt.status = 1 and qt.is_visiable = 1 ", nativeQuery = true)
17
+    List<QkjTqcourse> getTqByCataIds(Integer cataId);
18
+
19
+    @Query(value = "select qzt.tqcoursezq_id from qkj_tqcourse qt inner join qkj_zq_tqcourse_detail qzt on qzt.tqcourse_id = qt.id where tqcourse_id = ?1", nativeQuery = true)
20
+    List<Integer> getTqcoursezqIdByTqcourseId(Long TqcourseId);
21
+
22
+    @Query(value = "select count(*) from (select DISTINCT qt.* from qkj_tqcourse qt inner join qkj_catalogs_detail qcd on qcd.obj_id = qt.id where qcd.catalogs_id in ?1 and qcd.obj_type = 2 and qt.status = 1 and qt.is_visiable = 1) a", nativeQuery = true)
23
+    Integer getIndexDataCounts(List cataId);
24
+
25
+    @Query(value = "select * from qkj_tqcourse where status = 1 and is_visiable = 1 and m_or_pc in (?3) order by top_status desc, create_time desc , sort_num desc limit ?1,?2", nativeQuery = true)
26
+    List<QkjTqcourse> getIndexDataBysortNum(Integer start, Integer size, Integer[] mOrPc);
27
+
28
+    @Query(value = "select * from qkj_tqcourse where status = 1 and is_visiable = 1 and m_or_pc in (?3) order by top_status desc, create_time desc limit ?1,?2", nativeQuery = true)
29
+    List<QkjTqcourse> getIndexNewestData(Integer start, Integer size, Integer[] mOrPc);
30
+
31
+    @Query(value = "select * from qkj_tqcourse where status = 1 and is_visiable = 1 order by top_status desc, create_time desc limit ?1,?2", nativeQuery = true)
32
+    List<QkjTqcourse> getIndexDataAll(Integer page, Integer size);
33
+
34
+    @Query(value = "select count(*) from qkj_tqcourse where status = 1 and is_visiable = 1 order by top_status desc, create_time desc", nativeQuery = true)
35
+    Integer getIndexDataAllSize();
36
+
37
+
38
+    @Query(value = "select * from qkj_tqcourse where status = 1 and is_visiable = 1 and m_or_pc in (?3) order by study_num desc limit ?1,?2", nativeQuery = true)
39
+    List<QkjTqcourse> getIndexHottestData(Integer start, Integer size, Integer[] mOrPc);
40
+
41
+    @Query(value = "select count(*) from qkj_tqcourse where status = 1 and is_visiable = 1 order by study_num desc", nativeQuery = true)
42
+    Integer getIndexDataCounts();
43
+
44
+
45
+    @Query(value = "select count(*) from qkj_tqcourse where status = 1 and is_visiable = 1 and m_or_pc in (?1) order by study_num desc", nativeQuery = true)
46
+    Integer getIndexDataCounts(Integer[] mOrPc);
47
+
48
+    @Query(value = "select qt.* from qkj_tqcourse qt inner join qkj_zq_tqcourse_detail qzt on qzt.tqcourse_id = qt.id where qt.status = 1 and qt.is_visiable = 1 and qzt.tqcoursezq_id = ?1 order by qt.create_time desc,qzt.sort desc limit ?2,?3", nativeQuery = true)
49
+    List<QkjTqcourse> findTqListForZq(Integer zqId, int start, Integer size);
50
+
51
+    @Query(value = "select qt.* from qkj_tqcourse qt inner join qkj_zq_tqcourse_detail qzt on qzt.tqcourse_id = qt.id where qt.status = 1 and qt.is_visiable = 1 and qzt.tqcoursezq_id = ?1 order by qzt.sort asc limit ?2,?3", nativeQuery = true)
52
+    List<QkjTqcourse> findTqListForZq1(Integer zqId, int start, Integer size);
53
+
54
+
55
+    @Query(value = "select qt.* from qkj_tqcourse qt inner join qkj_zq_tqcourse_detail qzt on qzt.tqcourse_id = qt.id where qt.status = 1 and qt.is_visiable = 1 and qzt.tqcoursezq_id = ?1 order by qt.create_time desc,qzt.sort desc", nativeQuery = true)
56
+    List<QkjTqcourse> findTqListForZq(Integer zqId);
57
+
58
+    @Query(value = "select qt.* from qkj_tqcourse qt inner join qkj_zq_tqcourse_detail qzt on qzt.tqcoursezq_id = qt.id where qt.status = 1 and qt.is_visiable = 1 and qzt.tqcourse_id = ?1 order by qt.create_time desc,qzt.sort desc", nativeQuery = true)
59
+    List<QkjTqcourse> findTqListFortqId(Integer tqId);
60
+
61
+    @Query(value = "select qt.* from qkj_catalogs_detail qcd inner join qkj_tqcourse qt on qt.id = qcd.obj_id where qcd.catalogs_id in (?1) and qt.id != ?2 and qcd.obj_type = 2 and qt.status = 1 order by qt.create_time desc,qcd.sqn desc limit 0,10", nativeQuery = true)
62
+    List<QkjTqcourse> findTqListForCataList(String ids, Long id);
63
+
64
+    @Query(value = "SELECT DISTINCT qt.* from qkj_tqcourse qt left JOIN qkj_tqcourse_course qtc on qtc.tqcourse_id = qt.id left JOIN qkj_tags_detail qtd on qtd.obj_id = qtc.id where qtd.tag_id in (1,2) and qt.status = 1", nativeQuery = true)
65
+    List<QkjTqcourse> findTqListByTags(String tagIds);
66
+
67
+
68
+    @Query(value = "SELECT * from qkj_tqcourse qt  where qt.tag_ids like %?1% and qt.status = 1 and qt.id != ?2", nativeQuery = true)
69
+    List<QkjTqcourse> findTqListByTagIds(String tagIds, Long id);
70
+
71
+}

+ 31
- 0
src/main/java/com/cirle/scientific/dao/QkjVedioPlayRecordDao.java View File

@@ -0,0 +1,31 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjVedioPlayRecord;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.math.BigDecimal;
9
+import java.util.List;
10
+
11
+public interface QkjVedioPlayRecordDao extends PagingAndSortingRepository<QkjVedioPlayRecord, Long>, JpaSpecificationExecutor<QkjVedioPlayRecord> {
12
+    QkjVedioPlayRecord findByMemCardAndObjTypeAndObjId(String memCard, int objType, int objId);
13
+
14
+
15
+    @Query(value = "select SUM(l.study_percent) from qkj_video_play_record l where l.mem_card =?1 and l.obj_type=?2 and l.pobj_id=?3",nativeQuery = true)
16
+    BigDecimal findTotalPercentByPobjId(String memCard, Integer objType, int intValue);
17
+
18
+
19
+    @Query(value = "SELECT * from (SELECT l.* from qkj_video_play_record l INNER JOIN qkj_tqcourse qt on qt.id = l.obj_id  where l.mem_card = ?1 and l.obj_type = 7  and qt.status = 1\n" +
20
+            "UNION\n" +
21
+            "SELECT l.* from qkj_video_play_record l INNER JOIN qkj_live ql on ql.id = l.obj_id  where l.mem_card = ?1 and l.obj_type = 2  and ql.status = 1) as a order by opr_time desc limit ?2,?3",nativeQuery = true)
22
+    List<QkjVedioPlayRecord> findUserStudyList(String memCard, int start,int size);
23
+
24
+
25
+    @Query(value = "select COUNT(DISTINCT l.mem_card) from qkj_video_play_record l where l.obj_type=?1 and l.pobj_id=?2",nativeQuery = true)
26
+    BigDecimal findMemberCountByPobjId(int objType, int pobjId);
27
+
28
+
29
+    @Query(value = "select * from qkj_video_play_record where mem_card = ?1 and obj_type =?2 and pobj_id = ?3",nativeQuery = true)
30
+    List<QkjVedioPlayRecord> findPlayTimeByMemCardAndObjIdAndObjTypeAndPobjId(String memCard , int objType , int pobjId);
31
+}

+ 27
- 0
src/main/java/com/cirle/scientific/dao/QkjVedioPlayRecordLogDao.java View File

@@ -0,0 +1,27 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjVedioPlayRecordLog;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+
8
+import java.util.List;
9
+
10
+public interface QkjVedioPlayRecordLogDao extends PagingAndSortingRepository<QkjVedioPlayRecordLog, Long>, JpaSpecificationExecutor<QkjVedioPlayRecordLog> {
11
+
12
+    @Query(value = "select * from qkj_video_play_record_log where mem_card = ?1 limit ?2,?3",nativeQuery = true)
13
+    List<QkjVedioPlayRecordLog> findUserStudyRecord(String memCard, int i, Integer size);
14
+
15
+
16
+    @Query(value = "select l.* from qkj_video_play_record_log l where l.mem_card =?1 and l.obj_type=?2 and l.obj_id=?3 order by l.opr_time desc limit 0,1",nativeQuery = true)
17
+    QkjVedioPlayRecordLog findMaxEndPlayTime(String memCard, Integer objType, Integer objId);
18
+
19
+    @Query(value = "select * from qkj_video_play_record_log l where l.mem_card =?1 and l.obj_type=?2 and l.obj_id=?3 and look_up = ?4",nativeQuery = true)
20
+    List<QkjVedioPlayRecordLog> findAllByMemCardAndObjIdAndObjTypeAndObjType(String memCard, Integer objType, Integer objId ,Integer lookUp);
21
+
22
+    @Query(value = "select learn_time from qkj_video_play_record_log l where l.mem_card =?1 and l.obj_type=?2 and l.obj_id=?3 and look_up = ?4",nativeQuery = true)
23
+    List<Integer> findCountPlayTime(String memCard, Integer objType, Integer objId ,Integer lookUp);
24
+
25
+    @Query(value = "SELECT * FROM qkj_video_play_record_log WHERE mem_card =?1 and obj_type = ?2 and obj_id = ?3 order by opr_time asc " , nativeQuery = true)
26
+    List<QkjVedioPlayRecordLog> listPlayRecordLog(String memCard, Integer objType, long objId);
27
+}

+ 26
- 0
src/main/java/com/cirle/scientific/dao/QkjVideoPlayLogDao.java View File

@@ -0,0 +1,26 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjLive;
4
+import com.cirle.scientific.po.QkjVedioPlayRecord;
5
+import com.cirle.scientific.po.QkjVideoPlayLog;
6
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.data.repository.PagingAndSortingRepository;
9
+
10
+import java.math.BigDecimal;
11
+import java.util.List;
12
+
13
+public interface QkjVideoPlayLogDao extends PagingAndSortingRepository<QkjVideoPlayLog, Long>, JpaSpecificationExecutor<QkjVideoPlayLog> {
14
+
15
+    @Query(value = "SELECT t1.id , courseid , liveid , logtime , t1.mem_card , SUM(learntime) learntime FROM (\n" +
16
+            "\tSELECT * FROM qkj_video_play_log WHERE learntime > 0 and  mem_card = ?1 \n" +
17
+            ") t1 INNER JOIN(\n" +
18
+            "\tSELECT * FROM qkj_tqcourse_course WHERE tqcourse_id = ?2 \n" +
19
+            ") t2 ON t1.courseid = t2.id",nativeQuery = true)
20
+    QkjVideoPlayLog findCourseLogList(String memCard , Long tqcourseId);
21
+
22
+    @Query(value = "SELECT id,courseid,liveid,logtime,mem_card,SUM(learntime) learntime " +
23
+                   "FROM qkj_video_play_log WHERE mem_card = ?1 AND liveid = ?2 AND learntime > 0",nativeQuery = true)
24
+    QkjVideoPlayLog findLiveLogList(String memCard , Long liveId);
25
+
26
+}

+ 8
- 0
src/main/java/com/cirle/scientific/dao/QkjVodinfoDao.java View File

@@ -0,0 +1,8 @@
1
+package com.cirle.scientific.dao;
2
+
3
+import com.cirle.scientific.po.QkjVodinfo;
4
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
5
+import org.springframework.data.repository.PagingAndSortingRepository;
6
+
7
+public interface QkjVodinfoDao extends PagingAndSortingRepository<QkjVodinfo, Long>, JpaSpecificationExecutor<QkjVodinfo> {
8
+}

+ 0
- 0
src/main/java/com/cirle/scientific/dao/QkjXySiginDao.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save