Pārlūkot izejas kodu

公共模块、接口服务

tags/正式3.2.0
王宁 pirms 2 gadiem
vecāks
revīzija
200acbdbac

+ 16
- 2
sapi/pom.xml Parādīt failu

@@ -22,10 +22,10 @@
22 22
             <groupId>org.springframework.boot</groupId>
23 23
             <artifactId>spring-boot-starter-web</artifactId>
24 24
         </dependency>
25
-        <dependency>
25
+        <!--<dependency>
26 26
             <groupId>org.springframework.cloud</groupId>
27 27
             <artifactId>spring-cloud-starter-config</artifactId>
28
-        </dependency>
28
+        </dependency>-->
29 29
         <dependency>
30 30
             <groupId>org.springframework.cloud</groupId>
31 31
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
@@ -45,6 +45,20 @@
45 45
             <artifactId>spring-boot-starter-test</artifactId>
46 46
             <scope>test</scope>
47 47
         </dependency>
48
+
49
+        <!--mybatis通用mapper依赖-->
50
+        <dependency>
51
+            <groupId>tk.mybatis</groupId>
52
+            <artifactId>mapper-spring-boot-starter</artifactId>
53
+            <version>2.0.2</version>
54
+        </dependency>
55
+
56
+        <dependency>
57
+            <groupId>com.xhkjedu</groupId>
58
+            <artifactId>scommons</artifactId>
59
+            <version>0.0.1-SNAPSHOT</version>
60
+        </dependency>
61
+
48 62
     </dependencies>
49 63
     <dependencyManagement>
50 64
         <dependencies>

+ 2
- 0
sapi/src/main/java/com/xhkjedu/sapi/SapiApplication.java Parādīt failu

@@ -2,8 +2,10 @@ package com.xhkjedu.sapi;
2 2
 
3 3
 import org.springframework.boot.SpringApplication;
4 4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
5 6
 
6 7
 @SpringBootApplication
8
+@EnableDiscoveryClient
7 9
 public class SapiApplication {
8 10
 
9 11
     public static void main(String[] args) {

+ 9
- 0
sapi/src/main/java/com/xhkjedu/sapi/base/TkMapper.java Parādīt failu

@@ -0,0 +1,9 @@
1
+package com.xhkjedu.sapi.base;
2
+
3
+import tk.mybatis.mapper.common.IdsMapper;
4
+import tk.mybatis.mapper.common.Mapper;
5
+import tk.mybatis.mapper.common.MySqlMapper;
6
+
7
+public interface TkMapper<T> extends Mapper<T>, MySqlMapper<T>, IdsMapper<T> {
8
+
9
+}

+ 48
- 0
sapi/src/main/java/com/xhkjedu/sapi/config/ConfigKey.java Parādīt failu

@@ -0,0 +1,48 @@
1
+package com.xhkjedu.sapi.config;
2
+
3
+import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.stereotype.Component;
5
+
6
+import java.io.UnsupportedEncodingException;
7
+
8
+/**
9
+ * @author ywx
10
+ * @classname ConfigKey
11
+ * @description 读取配置文件类
12
+ * @date 2020/10/16 9:19
13
+ **/
14
+@Component
15
+public class ConfigKey {
16
+
17
+    public static Integer nummin;
18
+    public static Integer nummax;
19
+    public static Integer numadd;
20
+
21
+    @Value("${nummin}")
22
+    public void setNummin(Integer nummin) {
23
+        ConfigKey.nummin = nummin;
24
+    }
25
+
26
+    @Value("${nummax}")
27
+    public void setNummax(Integer nummax) {
28
+        ConfigKey.nummax = nummax;
29
+    }
30
+
31
+    @Value("${numadd}")
32
+    public void setNumadd(Integer numadd) {
33
+        ConfigKey.numadd = numadd;
34
+    }
35
+
36
+    public static Integer redisdatatime;//缓存访问数据有效时长
37
+    public static String secretKey;//secretKey必须为24位
38
+
39
+    @Value("${redisdatatime}")
40
+    public void setRedisdatatime(Integer redisdatatime) {
41
+        ConfigKey.redisdatatime = redisdatatime;
42
+    }
43
+
44
+    @Value("${secretKey}")
45
+    public void setSecretKey(String secretKey) {
46
+        ConfigKey.secretKey = secretKey;
47
+    }
48
+}

+ 30
- 0
sapi/src/main/java/com/xhkjedu/sapi/utils/ApiUtil.java Parādīt failu

@@ -0,0 +1,30 @@
1
+package com.xhkjedu.sapi.utils;
2
+
3
+import com.xhkjedu.sapi.config.ConfigKey;
4
+
5
+import static com.xhkjedu.utils.N_Utils.getSecondTimestamp;
6
+
7
+/**
8
+ * @ClassName ApiUtil
9
+ * Description api工具类
10
+ * Author WN
11
+ * Date 2022/2/21 11:08
12
+ **/
13
+
14
+public class ApiUtil {
15
+    public static Integer id = 0;
16
+
17
+    //获取id
18
+    public static String getId(){
19
+        Integer nummin = ConfigKey.nummin;
20
+        Integer nummax = ConfigKey.nummax;
21
+        if (id == 0 || id.equals(nummax)) {
22
+            id = nummin;
23
+        } else {
24
+            id ++;
25
+        }
26
+        String _num = (getSecondTimestamp() + ConfigKey.numadd) +"" + id;
27
+        long num = Long.parseLong(_num);
28
+        return Long.toString(num,36).toUpperCase();
29
+    }
30
+}

+ 7
- 2
sapi/src/main/resources/application.properties Parādīt failu

@@ -27,9 +27,9 @@ spring.datasource.hikari.connection-timeout=20000
27 27
 spring.datasource.hikari.connection-test-query=SELECT 1
28 28
 
29 29
 # 所有Entity别名类所在包
30
-mybatis.type-aliases-package=com.xhkjedu.model,com.xhkjedu.vo
30
+mybatis.type-aliases-package=com.xhkjedu.sapi.model,com.xhkjedu.sapi.vo
31 31
 mybatis.mapper-Locations=classpath*:mapper/**/*.xml
32
-mapper.mappers=com.xhkjedu.base.TkMapper
32
+#mapper.mappers=com.xhkjedu.sapi.base.TkMapper
33 33
 mapper.identity=MYSQL
34 34
 #打印日志的两种方式第一种可以指定包名,第二种都可以打印
35 35
 logging.level.com.xhkjedu.mapper=debug
@@ -52,3 +52,8 @@ spring.redis.jedis.pool.max-active=60000
52 52
 redisdatatime=604800
53 53
 #secretKey必须为24位
54 54
 secretKey=nanhuakaizhangjianwangni
55
+
56
+#生成id的数值区间
57
+nummin=10000
58
+nummax=50000
59
+numadd=100000000

+ 7
- 1
scommons/pom.xml Parādīt failu

@@ -23,7 +23,13 @@
23 23
         <dependency>
24 24
             <groupId>com.github.pagehelper</groupId>
25 25
             <artifactId>pagehelper-spring-boot-starter</artifactId>
26
-            <version>1.2.10</version>
26
+            <version>1.2.13</version>
27
+            <exclusions>
28
+                <exclusion>
29
+                    <artifactId>mybatis-spring-boot-starter</artifactId>
30
+                    <groupId>org.mybatis.spring.boot</groupId>
31
+                </exclusion>
32
+            </exclusions>
27 33
         </dependency>
28 34
     </dependencies>
29 35
 

+ 1
- 0
scommons/src/main/java/com/xhkjedu/utils/PageUtil.java Parādīt failu

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.utils;
2 2
 
3
+
3 4
 import com.github.pagehelper.PageInfo;
4 5
 import com.xhkjedu.vo.PageResult;
5 6
 

+ 2
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/utils/StudyUtil.java Parādīt failu

@@ -14,6 +14,8 @@ import static com.xhkjedu.utils.N_Utils.getSecondTimestamp;
14 14
 @Slf4j
15 15
 public class StudyUtil {
16 16
     public static Integer id = 0;
17
+
18
+    //获取id
17 19
     public static String getId(){
18 20
         Integer nummin = ConfigKey.nummin;
19 21
         Integer nummax = ConfigKey.nummax;

+ 1
- 1
sstudy/src/main/resources/application.properties Parādīt failu

@@ -27,7 +27,7 @@ spring.datasource.hikari.connection-timeout=20000
27 27
 spring.datasource.hikari.connection-test-query=SELECT 1
28 28
 
29 29
 # 所有Entity别名类所在包
30
-mybatis.type-aliases-package=com.xhkjedu.model,com.xhkjedu.vo
30
+mybatis.type-aliases-package=com.xhkjedu.sstudy.model,com.sstudy.xhkjedu.vo
31 31
 mybatis.mapper-Locations=classpath*:mapper/**/*.xml
32 32
 mapper.mappers=com.xhkjedu.sstudy.base.TkMapper
33 33
 mapper.identity=MYSQL

Notiek ielāde…
Atcelt
Saglabāt