Yansen 2 лет назад
Родитель
Сommit
852f9a413c

+ 6
- 0
db/init.sql Просмотреть файл

@@ -0,0 +1,6 @@
1
+
2
+CREATE DATABASE `civilizedcity` DEFAULT CHARACTER SET utf8mb4;
3
+
4
+CREATE USER `civilizedcity`@`localhost` IDENTIFIED BY 'mYysYctlX*r5-@7^3$umS!J$n~nJTgnS';
5
+
6
+GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables, Create View, Delete, Drop, Event, Execute, Grant Option, Index, Insert, Lock Tables, References, Select, Show View, Trigger, Update ON `civilizedcity`.* TO `civilizedcity`@`localhost`;

+ 13
- 0
deploy/city.service Просмотреть файл

@@ -0,0 +1,13 @@
1
+[Unit]
2
+Description=Civilized City
3
+After=mysqld.target
4
+
5
+[Service]
6
+Type=forking
7
+ExecStart=/opt/civilizedcity/service/service.sh start
8
+ExecReload=/opt/civilizedcity/service/service.sh restart
9
+ExecStop=/opt/civilizedcity/service/service.sh stop
10
+PrivateTmp=true
11
+
12
+[Install]
13
+WantedBy=multi-user.target

+ 60
- 0
deploy/service.sh Просмотреть файл

@@ -0,0 +1,60 @@
1
+#!/bin/sh
2
+#
3
+#
4
+source /etc/profile
5
+
6
+SERVICE_HOME="/opt/civilizedcity/service"
7
+LOG="$SERVICE_HOME/logs/nohup.log"
8
+JAR=$(ls -lt ${SERVICE_HOME}/*.jar|head -n1|rev|cut -d" " -f1|rev)
9
+CONFIG_FILE="/opt/civilizedcity/service/config"
10
+LIB_FILES="/opt/civilizedcity/service/libs"
11
+PROCESS_CHARS="civilizedCity-"
12
+
13
+start() {
14
+    PID=`ps -ef|grep $PROCESS_CHARS|grep -v grep|awk '{print $2}'`
15
+    if [[ "$PID" != "" ]]; then
16
+        echo ""
17
+        echo "Service is running. pid=$PID"
18
+        echo ""
19
+        exit 0
20
+    else
21
+        echo ""
22
+        echo "Start service ..."
23
+        echo "FILE: $JAR"
24
+
25
+        nohup java -Dloader.path=$LIB_FILES -Dspring.config.location=$CONFIG_FILE/application.yml -jar $JAR > $LOG 2>&1 &
26
+
27
+        echo "Start finished"
28
+        echo "Pls goto $LOG see process status"
29
+        echo ""
30
+        # tail -f $LOG
31
+    fi
32
+}
33
+
34
+stop() {
35
+    echo ""
36
+    echo "Stoping service ..."
37
+
38
+    PID=`ps -ef|grep $PROCESS_CHARS|grep -v grep|awk '{print $2}'`
39
+    if [[ "$PID" != "" ]]; then
40
+        kill -9 $PID
41
+    fi
42
+
43
+    # 这个延迟不能去掉
44
+    sleep 2s
45
+    echo "Service is stoped"
46
+    echo ""
47
+}
48
+
49
+case $1 in
50
+    "start")
51
+        start ;;
52
+    "stop")
53
+        stop ;;
54
+    "reload"|"restart")
55
+        stop
56
+        start ;;
57
+    *)
58
+        echo "Usage: `basename $0` {start|stop|restart}"
59
+        exit 1
60
+esac

+ 35
- 0
pom.xml Просмотреть файл

@@ -134,15 +134,50 @@
134 134
                 <groupId>org.springframework.boot</groupId>
135 135
                 <artifactId>spring-boot-maven-plugin</artifactId>
136 136
                 <configuration>
137
+                    <mainClass>com.example.civilizedcity.CivilizedCityApplication</mainClass>
138
+                    <layout>ZIP</layout>
139
+                    <includes>
140
+                        <include>
141
+                            <groupId>nothing</groupId>
142
+                            <artifactId>nothing</artifactId>
143
+                        </include>
144
+                    </includes>
137 145
                     <excludes>
138 146
                         <exclude>
139 147
                             <groupId>org.projectlombok</groupId>
140 148
                             <artifactId>lombok</artifactId>
141 149
                         </exclude>
142 150
                     </excludes>
151
+                    <executions>
152
+                        <execution>
153
+                            <goals>
154
+                                <goal>repackage</goal>
155
+                            </goals>
156
+                        </execution>
157
+                    </executions>
143 158
                 </configuration>
144 159
             </plugin>
160
+
161
+            <plugin>
162
+                <groupId>org.apache.maven.plugins</groupId>
163
+                <artifactId>maven-dependency-plugin</artifactId>
164
+                <version>2.10</version>
165
+                <executions>
166
+                    <execution>
167
+                        <id>copy-dependencies</id>
168
+                        <phase>package</phase>
169
+                        <goals>
170
+                            <goal>copy-dependencies</goal>
171
+                        </goals>
172
+                        <configuration>
173
+                            <outputDirectory>${project.build.directory}/libs</outputDirectory>
174
+                        </configuration>
175
+                    </execution>
176
+                </executions>
177
+            </plugin>
178
+
145 179
         </plugins>
180
+
146 181
         <resources>
147 182
             <resource>
148 183
                 <directory>src/main/resources</directory>

+ 17
- 28
src/main/java/com/example/civilizedcity/controller/CommController.java Просмотреть файл

@@ -49,37 +49,26 @@ public class CommController extends BaseController {
49 49
     public ResponseBean uploadImage(@ApiParam("客户端") @PathVariable String client,
50 50
                                     @ApiParam("文件") @RequestParam("file") MultipartFile multipartFile,
51 51
                                     @ApiParam("文件类型") @RequestParam(value = "fileType", defaultValue = "image") String fileType) throws Exception {
52
-        try {
53
-            String url = ossUtils.putObject(multipartFile);
54
-
55
-            Map<String, Object> resp = new HashMap<>();
56
-            resp.put("url", url);
57
-            resp.put("fileType", fileType);
58
-            return ResponseBean.success(resp);
59
-        } catch (IOException e) {
60
-            return ResponseBean.error("上传图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
52
+
53
+        //获取文件名
54
+        String fileName = multipartFile.getOriginalFilename();
55
+        String newFileName = String.format("%s/%d-%s", getMonth(), System.currentTimeMillis(), fileName);
56
+
57
+        // 上传目录以日期分类
58
+        File tmp = new File(String.format("%s/%s", getUploadPath(), getMonth()));
59
+        if (!tmp.exists()) {
60
+            tmp.mkdir();
61 61
         }
62 62
 
63
+        //
64
+        File upFile = new File(String.format("%s/%s", getUploadPath(), newFileName));
65
+        multipartFile.transferTo(upFile);
63 66
 
64
-//        //获取文件名
65
-//        String fileName = multipartFile.getOriginalFilename();
66
-//        String newFileName = String.format("%s/%d-%s", getMonth(), System.currentTimeMillis(), fileName);
67
-//
68
-//        // 上传目录以日期分类
69
-//        File tmp = new File(String.format("%s/%s", getUploadPath(), getMonth()));
70
-//        if (!tmp.exists()) {
71
-//            tmp.mkdir();
72
-//        }
73
-//
74
-//        //
75
-//        File upFile = new File(String.format("%s/%s", getUploadPath(), newFileName));
76
-//        multipartFile.transferTo(upFile);
77
-//
78
-//        String url = String.format("%s/%s", uploadPrefix, newFileName);
79
-//        return ResponseBean.success(new HashMap<String, Object>(){{
80
-//            put("url", url);
81
-//            put("fileType", fileType);
82
-//        }});
67
+        String url = String.format("%s/%s", uploadPrefix, newFileName);
68
+        return ResponseBean.success(new HashMap<String, Object>(){{
69
+            put("url", url);
70
+            put("fileType", fileType);
71
+        }});
83 72
     }
84 73
 
85 74
     private String getUploadPath() {

+ 0
- 1
src/main/java/com/example/civilizedcity/controller/TaIssueApplyController.java Просмотреть файл

@@ -11,7 +11,6 @@ import com.example.civilizedcity.common.StringUtils;
11 11
 import com.example.civilizedcity.entity.SysUser;
12 12
 import com.example.civilizedcity.service.TaIssueService;
13 13
 import com.example.civilizedcity.service.TaOrgIssueService;
14
-import com.sun.org.apache.xpath.internal.operations.Bool;
15 14
 import io.swagger.annotations.Api;
16 15
 import io.swagger.annotations.ApiOperation;
17 16
 import io.swagger.annotations.ApiParam;

+ 1
- 16
src/main/java/com/example/civilizedcity/service/impl/TaCheckServiceImpl.java Просмотреть файл

@@ -60,27 +60,12 @@ public class TaCheckServiceImpl extends BaseServiceImpl<TaCheckMapper, TaCheck>
60 60
         List<TaCheckItem> checkItemList = taCheckItemMapper.getListBy(taCheck.getCheckId(), Constants.CHECK_OF_LOC);
61 61
         if (null == checkItemList || checkItemList.size() == 0) return 0.0;
62 62
 
63
-        // 所有卷得分的和
63
+        // 所有卷得分的和
64 64
         double totalScore = 0.0;
65 65
         for (TaCheckItem checkItem : checkItemList) {
66 66
             Double score = taCheckAnswerMapper.sumScore(checkItem.getItemId(), checkItem.getNum());
67 67
             double s = null == score ? 0.0 : score;
68 68
 
69
-            double maxScore = checkItem.getFullScore() / checkItem.getNum();
70
-
71
-            // 如果得到正分, 说明试卷得了满分
72
-            if (s > 0) {
73
-                s = maxScore;
74
-            }
75
-
76
-            // 如果产生扣分项
77
-            if (s < 0) {
78
-                s = maxScore + s;
79
-                if (s < 0) {
80
-                    s = 0;
81
-                }
82
-            }
83
-
84 69
             checkItem.setScore(s);
85 70
             taCheckItemMapper.updateById(checkItem);
86 71
 

+ 47
- 0
src/main/resources/application-dev.yml Просмотреть файл

@@ -0,0 +1,47 @@
1
+
2
+spring:
3
+  datasource:
4
+    url: jdbc:mysql://110.40.183.156:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
5
+    username: civilizedcity
6
+    password: civilizedcity@ABCD1234
7
+    hikari:
8
+      # 最小空闲连接数
9
+      minimum-idle: 10
10
+      # 空闲连接存活最大时间, 默认 600000 - 10分钟
11
+      idle-timeout: 120000 # 2min
12
+      # 最大连接池数, 默认 10
13
+      maximum-pool-size: 30
14
+      # 连接池最长生命 0 无限期, 1800000 - 30分钟
15
+      max-lifetime: 180000 # 3min
16
+      # 连接超时 默认 30000 - 30秒
17
+      connection-timeout: 30000
18
+      connection-test-query: SELECT 1
19
+      # 连接活性检测 6000 - 1 分钟
20
+      keepalive-time: 6000
21
+
22
+###
23
+yz:
24
+  upload:
25
+    path: E:\work\public-upload
26
+    prefix: http://127.0.0.1:8000
27
+
28
+wx:
29
+  miniapp:
30
+    appid: wx39d721c54a0a11c4
31
+    secret: e970bf3e11f4dbf71ad91581c99702e6
32
+    token:
33
+    aesKey:
34
+
35
+###
36
+aliyun:
37
+  accessKeyId: LTAI5tGjnZY6k799BHxhmqcm
38
+  accessKeySecret: eU1DmULbgHe2dnIg3P93634PO2vEh5
39
+  oss:
40
+    roleSessionName: shigongli
41
+    accessKeyId: LTAI4G9zCefU1m7sKmmBnzTc
42
+    accessKeySecret: Vaax5O7wTL0KZdSgd8L9cGBf8AgUqJ
43
+    arn: acs:ram::1636896505560465:role/ramosssts
44
+    region: oss-cn-shanghai
45
+    endpoint: oss-accelerate.aliyuncs.com
46
+    bucketName: yz-shigongli
47
+    bucketURL: https://yz-shigongli.oss-accelerate.aliyuncs.com

+ 60
- 0
src/main/resources/application-prod.yml Просмотреть файл

@@ -0,0 +1,60 @@
1
+server:
2
+  port: 9001
3
+
4
+spring:
5
+  datasource:
6
+    url: jdbc:mysql://127.0.0.1:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
7
+    username: civilizedcity
8
+    password: mYysYctlX*r5-@7^3$umS!J$n~nJTgnS
9
+    hikari:
10
+      # 最小空闲连接数
11
+      minimum-idle: 10
12
+      # 空闲连接存活最大时间, 默认 600000 - 10分钟
13
+      idle-timeout: 120000 # 2min
14
+      # 最大连接池数, 默认 10
15
+      maximum-pool-size: 30
16
+      # 连接池最长生命 0 无限期, 1800000 - 30分钟
17
+      max-lifetime: 180000 # 3min
18
+      # 连接超时 默认 30000 - 30秒
19
+      connection-timeout: 30000
20
+      connection-test-query: SELECT 1
21
+      # 连接活性检测 6000 - 1 分钟
22
+      keepalive-time: 6000
23
+
24
+###
25
+yz:
26
+  upload:
27
+    path: E:\work\public-upload
28
+    prefix: http://127.0.0.1:8000
29
+  filter:
30
+    annList:
31
+      - "/swagger-ui/**"
32
+      - "/swagger-resources/**"
33
+      - "/v2/**"
34
+      - "/static/**"
35
+      - "/**/login"
36
+      - "/**/signin"
37
+      - "/ma/captcha"
38
+      - "/ma/change-password"
39
+      - "/ma/auth-phone"
40
+
41
+wx:
42
+  miniapp:
43
+    appid: wx39d721c54a0a11c4
44
+    secret: e970bf3e11f4dbf71ad91581c99702e6
45
+    token:
46
+    aesKey:
47
+
48
+###
49
+aliyun:
50
+  accessKeyId:
51
+  accessKeySecret:
52
+  oss:
53
+    roleSessionName:
54
+    accessKeyId:
55
+    accessKeySecret:
56
+    arn:
57
+    region:
58
+    endpoint:
59
+    bucketName:
60
+    bucketURL:

+ 0
- 45
src/main/resources/application.yml Просмотреть файл

@@ -4,26 +4,6 @@ server:
4 4
     context-path: /api
5 5
 
6 6
 spring:
7
-  datasource:
8
-    url: jdbc:mysql://110.40.183.156:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
9
-    username: civilizedcity
10
-    password: civilizedcity@ABCD1234
11
-    hikari:
12
-      # 最小空闲连接数
13
-      minimum-idle: 10
14
-      # 空闲连接存活最大时间, 默认 600000 - 10分钟
15
-      idle-timeout: 120000 # 2min
16
-      # 最大连接池数, 默认 10
17
-      maximum-pool-size: 30
18
-      # 连接池最长生命 0 无限期, 1800000 - 30分钟
19
-      max-lifetime: 180000 # 3min
20
-      # 连接超时 默认 30000 - 30秒
21
-      connection-timeout: 30000
22
-      connection-test-query: SELECT 1
23
-      # 连接活性检测 6000 - 1 分钟
24
-      keepalive-time: 6000
25
-
26
-
27 7
   mvc:
28 8
     pathmatch:
29 9
       matching-strategy: ANT_PATH_MATCHER
@@ -36,9 +16,6 @@ spring:
36 16
 
37 17
 ###
38 18
 yz:
39
-  upload:
40
-    path: E:\work\public-upload
41
-    prefix: http://127.0.0.1:8000
42 19
   filter:
43 20
     annList:
44 21
       - "/swagger-ui/**"
@@ -51,28 +28,6 @@ yz:
51 28
       - "/ma/change-password"
52 29
       - "/ma/auth-phone"
53 30
 
54
-wx:
55
-  miniapp:
56
-    appid: wx39d721c54a0a11c4
57
-    secret: e970bf3e11f4dbf71ad91581c99702e6
58
-    token:
59
-    aesKey:
60
-
61
-###
62
-aliyun:
63
-  accessKeyId: LTAI5tGjnZY6k799BHxhmqcm
64
-  accessKeySecret: eU1DmULbgHe2dnIg3P93634PO2vEh5
65
-  oss:
66
-    roleSessionName: shigongli
67
-    accessKeyId: LTAI4G9zCefU1m7sKmmBnzTc
68
-    accessKeySecret: Vaax5O7wTL0KZdSgd8L9cGBf8AgUqJ
69
-    arn: acs:ram::1636896505560465:role/ramosssts
70
-    region: oss-cn-shanghai
71
-    endpoint: oss-accelerate.aliyuncs.com
72
-    bucketName: yz-shigongli
73
-    bucketURL: https://yz-shigongli.oss-accelerate.aliyuncs.com
74
-
75
-
76 31
 sa-token:
77 32
   # jwt秘钥
78 33
   jwt-secret-key: d4d778d279cf11ed9b1d525400e8554f