my-csc-config-file.git лет назад: 5
Родитель
Сommit
6946089509

+ 76 - 0
pom.xml

@@ -0,0 +1,76 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <parent>
6
+        <artifactId>csc-szls-parent</artifactId>
7
+        <groupId>com.unissoft</groupId>
8
+        <version>1.0-SNAPSHOT</version>
9
+        <relativePath>../csc-szls-parent/pom.xml</relativePath>
10
+    </parent>
11
+    <modelVersion>4.0.0</modelVersion>
12
+
13
+    <artifactId>csc-szls-common-utils</artifactId>
14
+    <version>1.0-SNAPSHOT</version>
15
+    <packaging>jar</packaging>
16
+    <description>公共工具</description>
17
+
18
+    <properties>
19
+        <java.version>1.8</java.version>
20
+        <spring-cloud.version>2020.0.0-SNAPSHOT</spring-cloud.version>
21
+    </properties>
22
+
23
+    <dependencies>
24
+        <dependency>
25
+            <groupId>org.springframework.boot</groupId>
26
+            <artifactId>spring-boot-starter-web</artifactId>
27
+        </dependency>
28
+        <dependency>
29
+            <groupId>org.springframework.boot</groupId>
30
+            <artifactId>spring-boot-starter-test</artifactId>
31
+            <scope>test</scope>
32
+        </dependency>
33
+        <!--redis-->
34
+        <dependency>
35
+            <groupId>org.springframework.boot</groupId>
36
+            <artifactId>spring-boot-starter-data-redis</artifactId>
37
+        </dependency>
38
+        <dependency>
39
+            <groupId>org.springframework.session</groupId>
40
+            <artifactId>spring-session-data-redis</artifactId>
41
+        </dependency>
42
+        <!-- mybatisplus与springboot整合 -->
43
+        <dependency>
44
+            <groupId>com.baomidou</groupId>
45
+            <artifactId>mybatis-plus-boot-starter</artifactId>
46
+        </dependency>
47
+    </dependencies>
48
+    <build>
49
+        <plugins>
50
+            <plugin>
51
+                <groupId>org.springframework.boot</groupId>
52
+                <artifactId>spring-boot-maven-plugin</artifactId>
53
+                <configuration>
54
+                    <!--被依赖的公共模块必须加上这个,打包之后启动,选择后面带EXE的启动,依赖该模块的其他模块就不会因为找不到依赖而打包出错-->
55
+                    <classifier>exe</classifier>
56
+                </configuration>
57
+            </plugin>
58
+        </plugins>
59
+    </build>
60
+
61
+    <repositories>
62
+        <repository>
63
+            <id>spring-snapshots</id>
64
+            <name>Spring Snapshots</name>
65
+            <url>https://repo.spring.io/snapshot</url>
66
+            <snapshots>
67
+                <enabled>true</enabled>
68
+            </snapshots>
69
+        </repository>
70
+        <repository>
71
+            <id>spring-milestones</id>
72
+            <name>Spring Milestones</name>
73
+            <url>https://repo.spring.io/milestone</url>
74
+        </repository>
75
+    </repositories>
76
+</project>

+ 15 - 0
src/main/java/com/unissoft/CommonStart.java

@@ -0,0 +1,15 @@
1
+package com.unissoft;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+import org.springframework.context.annotation.Bean;
6
+import org.springframework.web.client.RestTemplate;
7
+
8
+@SpringBootApplication
9
+public class CommonStart {
10
+
11
+    public static void main(String[] args) {
12
+        SpringApplication.run(CommonStart.class, args);
13
+    }
14
+
15
+}

+ 44 - 0
src/main/java/com/unissoft/MyConstant.java

@@ -0,0 +1,44 @@
1
+package com.unissoft;
2
+
3
+/**
4
+ * 常量类
5
+ */
6
+public class MyConstant {
7
+
8
+    //服务名
9
+    public static final String CSC_SZLS_CONFIG_SERVER = "csc-szls-config-server";
10
+    public static final String CSC_SZLS_GATEWAY = "csc-szls-gateway";
11
+    public static final String CSC_SZLS_OAUTH = "csc-szls-oauth";
12
+    public static final String CSC_SZLS_PUBLIC = "csc-szls-public";
13
+    public static final String CSC_SZLS_UPMS_SYSTEM_MANAGE = "csc-szls-system-manage";
14
+    public static final String OURL_HTTP = "http://";
15
+    public static final String OURL_PORT = ":9601/";
16
+    public static final String OURL_URL = "/public/loadResourceDefine";
17
+//        public static final String OAUTH_TOKEN = "http://172.16.0.46:9601/csc-szls-oauth/oauth/token";
18
+//public static final String OAUTH_TOKEN = "http://localhost:9601/csc-szls-oauth/oauth/token";
19
+    public static final String OAUTH_TOKEN = "http://localhost:9602/oauth/token";
20
+    //文件系统桶名称,相当于文件目录
21
+    public static final String BUCKET_NAME = "csc";
22
+
23
+    //是否
24
+    public static final int ZERO = 0;
25
+    public static final int ONE = 1;
26
+    public static final int TWO = 2;
27
+    public static final int THREE = 3;
28
+
29
+
30
+    public static final String TEN = "10";
31
+    public static final String TWENTY = "20";
32
+    public static final String THIRTY = "30";
33
+    public static final String FORTY = "40";
34
+
35
+    public static final String LOGIN_USER = "loginUser";
36
+
37
+    public static final String CLIENT_ID = "client_id";
38
+    public static final String CLIENT_SECRET = "client_secret";
39
+    public static final String USERNAME = "username";
40
+    public static final String PASSWORD = "password";
41
+    public static final String GRANT_TYPE = "grant_type";
42
+    public static final String SCOPE = "scope";
43
+
44
+}

+ 40 - 0
src/main/java/com/unissoft/dto/BaseDto.java

@@ -0,0 +1,40 @@
1
+package com.unissoft.dto;
2
+
3
+/**
4
+ * 文件描述
5
+ *
6
+ * @author tongxi.xia
7
+ * @date 2020年11月17日 14:32
8
+ */
9
+public class BaseDto {
10
+
11
+    private int id;
12
+    /**
13
+     *  名称
14
+     */
15
+    private String name;
16
+
17
+    public int getId() {
18
+        return id;
19
+    }
20
+
21
+    public void setId(int id) {
22
+        this.id = id;
23
+    }
24
+
25
+    public String getName() {
26
+        return name;
27
+    }
28
+
29
+    public void setName(String name) {
30
+        this.name = name;
31
+    }
32
+
33
+    @Override
34
+    public String toString() {
35
+        return "BaseDto{" +
36
+                "id=" + id +
37
+                ", name='" + name + '\'' +
38
+                '}';
39
+    }
40
+}

+ 64 - 0
src/main/java/com/unissoft/dto/ResourceRoleInfoDto.java

@@ -0,0 +1,64 @@
1
+package com.unissoft.dto;
2
+
3
+
4
+import com.unissoft.model.SysResourceRole;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * 文件描述
10
+ *
11
+ * @author tongxi.xia
12
+ * @date 2020年11月17日 14:32
13
+ */
14
+public class ResourceRoleInfoDto {
15
+
16
+    /**
17
+     * 权限API路径匹配(注:即后台控制器名,后面带authority,或者authority_button(对应button字段)代表受权限控制)
18
+     */
19
+    private String urlPattern;
20
+    /**
21
+     * 按钮(页面要权限控制的按钮,也是后台接口方法名,多个用逗号分隔)
22
+     */
23
+    private String button;
24
+
25
+    private Integer roleId;
26
+
27
+    public Integer getRoleId() {
28
+        return roleId;
29
+    }
30
+
31
+    public void setRoleId(Integer roleId) {
32
+        this.roleId = roleId;
33
+    }
34
+
35
+    /**
36
+     * 权限API路径匹配(注:即后台控制器名,后面带authority,或者authority_button(对应button字段)代表受权限控制)
37
+     * 所对应的角色信息
38
+     */
39
+    private List<SysResourceRole> sysResourceRoles;
40
+
41
+    public String getUrlPattern() {
42
+        return urlPattern;
43
+    }
44
+
45
+    public void setUrlPattern(String urlPattern) {
46
+        this.urlPattern = urlPattern;
47
+    }
48
+
49
+    public String getButton() {
50
+        return button;
51
+    }
52
+
53
+    public void setButton(String button) {
54
+        this.button = button;
55
+    }
56
+
57
+    public List<SysResourceRole> getsysResourceRoles() {
58
+        return sysResourceRoles;
59
+    }
60
+
61
+    public void setsysResourceRoles(List<SysResourceRole> sysResourceRoles) {
62
+        this.sysResourceRoles = sysResourceRoles;
63
+    }
64
+}

+ 27 - 0
src/main/java/com/unissoft/exception/MyRuntimeException.java

@@ -0,0 +1,27 @@
1
+package com.unissoft.exception;
2
+
3
+import com.unissoft.result.ResultView;
4
+
5
+/**
6
+ * 文件描述:自定义运行时异常
7
+ *
8
+ * @author tongxi.xia
9
+ * @date 2020年11月17日 14:32
10
+ */
11
+public class MyRuntimeException extends RuntimeException {
12
+
13
+    private ResultView resultView;
14
+
15
+    public MyRuntimeException(ResultView resultView) {
16
+        super(resultView.getMsg());
17
+        this.resultView = resultView;
18
+    }
19
+
20
+    public ResultView getResultView() {
21
+        return resultView;
22
+    }
23
+
24
+    public void setResultView(ResultView resultView) {
25
+        this.resultView = resultView;
26
+    }
27
+}

+ 130 - 0
src/main/java/com/unissoft/model/BasicsWarehouse.java

@@ -0,0 +1,130 @@
1
+package com.unissoft.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * <p>
12
+ *
13
+ * </p>
14
+ *
15
+ * @author root
16
+ * @since 2020-12-03
17
+ */
18
+
19
+public class BasicsWarehouse implements Serializable {
20
+
21
+    private static final long serialVersionUID = 1L;
22
+
23
+//    @ApiModelProperty(value = "仓房id")
24
+    @TableId(value = "h_id", type = IdType.AUTO)
25
+    private Integer hId;
26
+
27
+//    @ApiModelProperty(value = "仓房名称")
28
+    @TableField("h_name")
29
+    private String hName;
30
+
31
+//    @ApiModelProperty(value = "粮食品种")
32
+    @TableField("grain_varieties")
33
+    private String grainVarieties;
34
+
35
+//    @ApiModelProperty(value = "储粮状态")
36
+    @TableField("storage_status")
37
+    private String storageStatus;
38
+
39
+//    @ApiModelProperty(value = "仓房状态")
40
+    @TableField("warehouse_status")
41
+    private String warehouseStatus;
42
+
43
+//    @ApiModelProperty(value = "所属公司")
44
+    @TableField("company_id")
45
+    private Integer companyId;
46
+
47
+//    @ApiModelProperty(value = "所属库")
48
+    @TableField("depot_id")
49
+    private Integer depotId;
50
+
51
+//    @ApiModelProperty(value = "创建人")
52
+    @TableField("create_people")
53
+    private String createPeople;
54
+
55
+//    @ApiModelProperty(value = "创建时间")
56
+    @TableField("create_time")
57
+    private Date createTime;
58
+
59
+    public Integer gethId() {
60
+        return hId;
61
+    }
62
+
63
+    public void sethId(Integer hId) {
64
+        this.hId = hId;
65
+    }
66
+
67
+    public String gethName() {
68
+        return hName;
69
+    }
70
+
71
+    public void sethName(String hName) {
72
+        this.hName = hName;
73
+    }
74
+
75
+    public String getGrainVarieties() {
76
+        return grainVarieties;
77
+    }
78
+
79
+    public void setGrainVarieties(String grainVarieties) {
80
+        this.grainVarieties = grainVarieties;
81
+    }
82
+
83
+    public String getStorageStatus() {
84
+        return storageStatus;
85
+    }
86
+
87
+    public void setStorageStatus(String storageStatus) {
88
+        this.storageStatus = storageStatus;
89
+    }
90
+
91
+    public String getWarehouseStatus() {
92
+        return warehouseStatus;
93
+    }
94
+
95
+    public void setWarehouseStatus(String warehouseStatus) {
96
+        this.warehouseStatus = warehouseStatus;
97
+    }
98
+
99
+    public Integer getCompanyId() {
100
+        return companyId;
101
+    }
102
+
103
+    public void setCompanyId(Integer companyId) {
104
+        this.companyId = companyId;
105
+    }
106
+
107
+    public Integer getDepotId() {
108
+        return depotId;
109
+    }
110
+
111
+    public void setDepotId(Integer depotId) {
112
+        this.depotId = depotId;
113
+    }
114
+
115
+    public String getCreatePeople() {
116
+        return createPeople;
117
+    }
118
+
119
+    public void setCreatePeople(String createPeople) {
120
+        this.createPeople = createPeople;
121
+    }
122
+
123
+    public Date getCreateTime() {
124
+        return createTime;
125
+    }
126
+
127
+    public void setCreateTime(Date createTime) {
128
+        this.createTime = createTime;
129
+    }
130
+}

+ 61 - 0
src/main/java/com/unissoft/model/ResourceRoleModel.java

@@ -0,0 +1,61 @@
1
+package com.unissoft.model;
2
+
3
+import java.io.Serializable;
4
+
5
+/**
6
+ * 文件描述:资源-角色-关系表
7
+ *
8
+ * @author tongxi.xia
9
+ * @date 2020年11月17日 14:32
10
+ */
11
+public class ResourceRoleModel implements Serializable {
12
+
13
+    private static final long serialVersionUID = 1L;
14
+
15
+    /**
16
+     * 资源id
17
+     */
18
+    private Long resourceId;
19
+    /**
20
+     * 资源按钮(页面要权限控制的按钮,也是后台接口方法名,多个用逗号分隔)
21
+     */
22
+    private String resourceButton;
23
+    /**
24
+     * 角色id
25
+     */
26
+    private Long roleId;
27
+
28
+
29
+    public Long getResourceId() {
30
+        return resourceId;
31
+    }
32
+
33
+    public void setResourceId(Long resourceId) {
34
+        this.resourceId = resourceId;
35
+    }
36
+
37
+    public String getResourceButton() {
38
+        return resourceButton;
39
+    }
40
+
41
+    public void setResourceButton(String resourceButton) {
42
+        this.resourceButton = resourceButton;
43
+    }
44
+
45
+    public Long getRoleId() {
46
+        return roleId;
47
+    }
48
+
49
+    public void setRoleId(Long roleId) {
50
+        this.roleId = roleId;
51
+    }
52
+
53
+    @Override
54
+    public String toString() {
55
+        return "ResourceRoleModel{" +
56
+                ", resourceId=" + resourceId +
57
+                ", resourceButton=" + resourceButton +
58
+                ", roleId=" + roleId +
59
+                "}";
60
+    }
61
+}

+ 84 - 0
src/main/java/com/unissoft/model/SysResourceRole.java

@@ -0,0 +1,84 @@
1
+package com.unissoft.model;
2
+
3
+
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableField;
6
+import com.baomidou.mybatisplus.annotation.TableId;
7
+import com.baomidou.mybatisplus.annotation.TableName;
8
+
9
+import java.io.Serializable;
10
+
11
+/**
12
+ * <p>
13
+ * 资源-角色-关系表
14
+ * </p>
15
+ *
16
+ * @author wsm
17
+ * @since 2020-11-25
18
+ */
19
+@TableName("sys_resource_role")
20
+public class SysResourceRole implements Serializable {
21
+
22
+    private static final long serialVersionUID = 1L;
23
+
24
+    @TableId(value = "rre_id", type = IdType.AUTO)
25
+    private Integer rreId;
26
+    /**
27
+     * 资源id
28
+     */
29
+    @TableField("resource_id")
30
+    private Integer resourceId;
31
+    /**
32
+     * 资源按钮(页面要权限控制的按钮,也是后台接口方法名,多个用逗号分隔)
33
+     */
34
+    @TableField("resource_button")
35
+    private String resourceButton;
36
+    /**
37
+     * 角色id
38
+     */
39
+    @TableField("role_id")
40
+    private Integer roleId;
41
+
42
+
43
+    public Integer getRreId() {
44
+        return rreId;
45
+    }
46
+
47
+    public void setRreId(Integer rreId) {
48
+        this.rreId = rreId;
49
+    }
50
+
51
+    public Integer getResourceId() {
52
+        return resourceId;
53
+    }
54
+
55
+    public void setResourceId(Integer resourceId) {
56
+        this.resourceId = resourceId;
57
+    }
58
+
59
+    public String getResourceButton() {
60
+        return resourceButton;
61
+    }
62
+
63
+    public void setResourceButton(String resourceButton) {
64
+        this.resourceButton = resourceButton;
65
+    }
66
+
67
+    public Integer getRoleId() {
68
+        return roleId;
69
+    }
70
+
71
+    public void setRoleId(Integer roleId) {
72
+        this.roleId = roleId;
73
+    }
74
+
75
+    @Override
76
+    public String toString() {
77
+        return "SysResourceRole{" +
78
+        ", rreId=" + rreId +
79
+        ", resourceId=" + resourceId +
80
+        ", resourceButton=" + resourceButton +
81
+        ", roleId=" + roleId +
82
+        "}";
83
+    }
84
+}

+ 222 - 0
src/main/java/com/unissoft/model/SysUserPO.java

@@ -0,0 +1,222 @@
1
+package com.unissoft.model;
2
+
3
+
4
+
5
+import java.io.Serializable;
6
+
7
+/**
8
+ * <p>
9
+ * 用户表
10
+ * </p>
11
+ *
12
+ * @author root
13
+ * @since 2020-12-02
14
+ */
15
+public class SysUserPO implements Serializable {
16
+
17
+    private static final long serialVersionUID = 1L;
18
+
19
+    private Integer uId;
20
+//    用户名
21
+    private String uName;
22
+//    人员名称(姓名)
23
+    private String personnelName;
24
+//    人员id必填
25
+    private Integer personnelId;
26
+//    电话
27
+    private String uPhone;
28
+//    岗位(职务)
29
+    private String pPost;
30
+//    用户状态(1:正常,2:异常,3:禁用)
31
+    private Integer uStatus;
32
+//    头像地址
33
+    private String pHeadPortrait;
34
+//    所属库id
35
+    private Integer depotId;
36
+//    所属库名称
37
+    private String depotName;
38
+//    仓房id,多个使用‘,’号隔开
39
+    private String storehouseIds;
40
+//    仓房名称,多个使用‘,’号隔开
41
+    private String storehouseNames;
42
+//    角色id,多个使用‘,’号隔开
43
+    private String roleIds;
44
+//    角色名称,多个使用‘,’号隔开
45
+    private String roleName;
46
+//    所属公司id
47
+    private Integer companyId;
48
+//    所属公司名称
49
+    private String companyName;
50
+//    所属部门id
51
+    private Integer departmentId;
52
+//    所属部门名称
53
+    private String departmentName;
54
+
55
+    public Integer getuId() {
56
+        return uId;
57
+    }
58
+
59
+    public void setuId(Integer uId) {
60
+        this.uId = uId;
61
+    }
62
+
63
+    public String getuName() {
64
+        return uName;
65
+    }
66
+
67
+    public void setuName(String uName) {
68
+        this.uName = uName;
69
+    }
70
+
71
+    public String getPersonnelName() {
72
+        return personnelName;
73
+    }
74
+
75
+    public void setPersonnelName(String personnelName) {
76
+        this.personnelName = personnelName;
77
+    }
78
+
79
+    public Integer getPersonnelId() {
80
+        return personnelId;
81
+    }
82
+
83
+    public void setPersonnelId(Integer personnelId) {
84
+        this.personnelId = personnelId;
85
+    }
86
+
87
+    public String getuPhone() {
88
+        return uPhone;
89
+    }
90
+
91
+    public void setuPhone(String uPhone) {
92
+        this.uPhone = uPhone;
93
+    }
94
+
95
+    public String getpPost() {
96
+        return pPost;
97
+    }
98
+
99
+    public void setpPost(String pPost) {
100
+        this.pPost = pPost;
101
+    }
102
+
103
+    public Integer getuStatus() {
104
+        return uStatus;
105
+    }
106
+
107
+    public void setuStatus(Integer uStatus) {
108
+        this.uStatus = uStatus;
109
+    }
110
+
111
+    public String getpHeadPortrait() {
112
+        return pHeadPortrait;
113
+    }
114
+
115
+    public void setpHeadPortrait(String pHeadPortrait) {
116
+        this.pHeadPortrait = pHeadPortrait;
117
+    }
118
+
119
+    public Integer getDepotId() {
120
+        return depotId;
121
+    }
122
+
123
+    public void setDepotId(Integer depotId) {
124
+        this.depotId = depotId;
125
+    }
126
+
127
+    public String getDepotName() {
128
+        return depotName;
129
+    }
130
+
131
+    public void setDepotName(String depotName) {
132
+        this.depotName = depotName;
133
+    }
134
+
135
+    public String getStorehouseIds() {
136
+        return storehouseIds;
137
+    }
138
+
139
+    public void setStorehouseIds(String storehouseIds) {
140
+        this.storehouseIds = storehouseIds;
141
+    }
142
+
143
+    public String getStorehouseNames() {
144
+        return storehouseNames;
145
+    }
146
+
147
+    public void setStorehouseNames(String storehouseNames) {
148
+        this.storehouseNames = storehouseNames;
149
+    }
150
+
151
+    public String getRoleIds() {
152
+        return roleIds;
153
+    }
154
+
155
+    public void setRoleIds(String roleIds) {
156
+        this.roleIds = roleIds;
157
+    }
158
+
159
+    public String getRoleName() {
160
+        return roleName;
161
+    }
162
+
163
+    public void setRoleName(String roleName) {
164
+        this.roleName = roleName;
165
+    }
166
+
167
+    public Integer getCompanyId() {
168
+        return companyId;
169
+    }
170
+
171
+    public void setCompanyId(Integer companyId) {
172
+        this.companyId = companyId;
173
+    }
174
+
175
+    public String getCompanyName() {
176
+        return companyName;
177
+    }
178
+
179
+    public void setCompanyName(String companyName) {
180
+        this.companyName = companyName;
181
+    }
182
+
183
+    public Integer getDepartmentId() {
184
+        return departmentId;
185
+    }
186
+
187
+    public void setDepartmentId(Integer departmentId) {
188
+        this.departmentId = departmentId;
189
+    }
190
+
191
+    public String getDepartmentName() {
192
+        return departmentName;
193
+    }
194
+
195
+    public void setDepartmentName(String departmentName) {
196
+        this.departmentName = departmentName;
197
+    }
198
+
199
+    @Override
200
+    public String toString() {
201
+        return "SysUserPO{" +
202
+                "uId=" + uId +
203
+                ", uName='" + uName + '\'' +
204
+                ", personnelName='" + personnelName + '\'' +
205
+                ", personnelId=" + personnelId +
206
+                ", uPhone='" + uPhone + '\'' +
207
+                ", pPost='" + pPost + '\'' +
208
+                ", uStatus=" + uStatus +
209
+                ", pHeadPortrait='" + pHeadPortrait + '\'' +
210
+                ", depotId=" + depotId +
211
+                ", depotName='" + depotName + '\'' +
212
+                ", storehouseIds='" + storehouseIds + '\'' +
213
+                ", storehouseNames='" + storehouseNames + '\'' +
214
+                ", roleIds='" + roleIds + '\'' +
215
+                ", roleName='" + roleName + '\'' +
216
+                ", companyId=" + companyId +
217
+                ", companyName='" + companyName + '\'' +
218
+                ", departmentId=" + departmentId +
219
+                ", departmentName='" + departmentName + '\'' +
220
+                '}';
221
+    }
222
+}

+ 84 - 0
src/main/java/com/unissoft/result/PageParam.java

@@ -0,0 +1,84 @@
1
+package com.unissoft.result;
2
+
3
+/**
4
+ * 分页参数类
5
+ */
6
+public class PageParam {
7
+    /**
8
+     * 当前页
9
+     */
10
+    private int pageIndex;
11
+    /**
12
+     * 当前页有多少数据
13
+     */
14
+    private int pageSize;
15
+    /**
16
+     * 要查的字段(别名=model属性名)
17
+     */
18
+    private String sqlColumns;
19
+    /**
20
+     * 排序
21
+     */
22
+    private String sort;
23
+    /**
24
+     * 条件
25
+     */
26
+    private String condition;
27
+
28
+    public PageParam() {
29
+    }
30
+
31
+    public PageParam(int pageIndex, int pageSize, String sort, String condition) {
32
+        this.pageIndex = pageIndex;
33
+        this.pageSize = pageSize;
34
+        this.sort = sort;
35
+        this.condition = condition;
36
+    }
37
+
38
+    public String getSort() {
39
+        return sort;
40
+    }
41
+
42
+    public void setSort(String sort) {
43
+        this.sort = sort;
44
+    }
45
+
46
+    public String getSqlColumns() {
47
+        return sqlColumns;
48
+    }
49
+
50
+    public void setSqlColumns(String sqlColumns) {
51
+        this.sqlColumns = sqlColumns;
52
+    }
53
+
54
+    public int getPageStart() {
55
+        if (pageIndex > 0) {
56
+            return (pageIndex - 1) * pageSize;
57
+        }
58
+        return pageIndex;
59
+    }
60
+
61
+    public int getPageIndex() {
62
+        return pageIndex;
63
+    }
64
+
65
+    public void setPageIndex(int pageIndex) {
66
+        this.pageIndex = pageIndex;
67
+    }
68
+
69
+    public int getPageSize() {
70
+        return pageSize;
71
+    }
72
+
73
+    public void setPageSize(int pageSize) {
74
+        this.pageSize = pageSize;
75
+    }
76
+
77
+    public String getCondition() {
78
+        return condition;
79
+    }
80
+
81
+    public void setCondition(String condition) {
82
+        this.condition = condition;
83
+    }
84
+}

+ 68 - 0
src/main/java/com/unissoft/result/PageResult.java

@@ -0,0 +1,68 @@
1
+package com.unissoft.result;
2
+
3
+import java.util.List;
4
+
5
+/**
6
+ * 分页结果
7
+ */
8
+public class PageResult {
9
+
10
+    /**
11
+     * 当前页
12
+     */
13
+    private Integer pageIndex;
14
+    /**
15
+     * 当前页多少数据
16
+     */
17
+    private Integer pageSize;
18
+    /**
19
+     * 总记录数
20
+     */
21
+    private Integer total;
22
+    /**
23
+     * 记录
24
+     */
25
+    private List records;
26
+
27
+    public PageResult() {
28
+    }
29
+
30
+    public PageResult(Integer pageIndex, Integer pageSize, Integer total, List records) {
31
+        this.pageIndex = pageIndex;
32
+        this.pageSize = pageSize;
33
+        this.total = total;
34
+        this.records = records;
35
+    }
36
+
37
+    public Integer getPageIndex() {
38
+        return pageIndex;
39
+    }
40
+
41
+    public void setPageIndex(Integer pageIndex) {
42
+        this.pageIndex = pageIndex;
43
+    }
44
+
45
+    public Integer getPageSize() {
46
+        return pageSize;
47
+    }
48
+
49
+    public void setPageSize(Integer pageSize) {
50
+        this.pageSize = pageSize;
51
+    }
52
+
53
+    public Integer getTotal() {
54
+        return total;
55
+    }
56
+
57
+    public void setTotal(Integer total) {
58
+        this.total = total;
59
+    }
60
+
61
+    public List getRecords() {
62
+        return records;
63
+    }
64
+
65
+    public void setRecords(List records) {
66
+        this.records = records;
67
+    }
68
+}

+ 130 - 0
src/main/java/com/unissoft/result/ResultEnum.java

@@ -0,0 +1,130 @@
1
+package com.unissoft.result;
2
+
3
+
4
+/**
5
+ * 结果枚举
6
+ */
7
+public enum ResultEnum {
8
+    /**
9
+     * 操作成功!
10
+     */
11
+    CODE_1(200, "操作成功!"),
12
+    /**
13
+     * 操作失败!
14
+     */
15
+    CODE_2(666, "操作失败!"),
16
+    /**
17
+     * 调用xxx服务失败!
18
+     */
19
+    CODE_3(3, "调用xxx服务失败!"),
20
+    /**
21
+     * 验证码错误或已过期!
22
+     */
23
+    CODE_4(4, "验证码错误或已过期!"),
24
+    /**
25
+     * 用户名或者密码错误!
26
+     */
27
+    CODE_5(200, "用户名或者密码错误!"),
28
+    /**
29
+     * 账号已存在!
30
+     */
31
+    CODE_6(6, "账号已存在!"),
32
+    /**
33
+     * 该client_id不存在
34
+     */
35
+    CODE_7(200, "该client_id不存在!"),
36
+    /**
37
+     * token已失效或者已经注销登录过了!
38
+     */
39
+    CODE_8(200, "token已失效或者已经注销登录过了!"),
40
+
41
+    /**
42
+     * 文件不能为空!
43
+     */
44
+    CODE_9(9, "文件不能为空!"),
45
+    /**
46
+     * 文件格式不正确!
47
+     */
48
+    CODE_10(10, "文件格式不正确!"),
49
+    /**
50
+     * 文件不存在,下载失败!
51
+     */
52
+    CODE_11(11, "文件不存在,下载失败!"),
53
+
54
+
55
+    /**
56
+     * token无效!
57
+     */
58
+    CODE_401(401, "token无效!"),
59
+    /**
60
+     * 抱歉,您没有访问权限!
61
+     */
62
+    CODE_403(403, "抱歉,您没有访问权限!"),
63
+
64
+    /**
65
+     * 请求超时,请稍后再试!
66
+     */
67
+    CODE_504(504, "请求超时,请稍后再试!"),
68
+
69
+    /**
70
+     * 服务器神游中!
71
+     */
72
+    CODE_666(666, "服务器神游中!");
73
+
74
+
75
+    /**
76
+     * 状态码
77
+     */
78
+    private Integer code;
79
+
80
+    /**
81
+     * 消息
82
+     */
83
+    private String msg;
84
+
85
+    ResultEnum(Integer code, String msg) {
86
+        this.code = code;
87
+        this.msg = msg;
88
+    }
89
+
90
+    public Integer getCode() {
91
+        return code;
92
+    }
93
+
94
+    public void setCode(Integer code) {
95
+        this.code = code;
96
+    }
97
+
98
+    public String getMsg() {
99
+        return msg;
100
+    }
101
+
102
+    public void setMsg(String msg) {
103
+        this.msg = msg;
104
+    }
105
+}
106
+
107
+//    CODE_4(4, "账号或者密码错误!"),
108
+//    CODE_5(5, "图像数据为空!"),
109
+//    CODE_6(6, "图像数据传输异常!"),
110
+//    CODE_7(7, "图片上传大小不能超过5M!"),
111
+//    CODE_8(8, "图片上传格式错误!"),
112
+//    CODE_9(9, "手机号码不能为空!"),
113
+//    CODE_10(10, "短信验证码不能为空!"),
114
+//    CODE_11(11, "短信验证码错误!"),
115
+//    CODE_12(12, "登陆类型不能为空!"),
116
+//    CODE_13(13, "openId不能为空!"),
117
+//    CODE_14(14, "该手机号码已被注册!"),
118
+//    CODE_15(15, "userId不能为空!"),
119
+//    CODE_16(16, "姓名不能为空!"),
120
+//    CODE_17(17, "身份证号码不能为空!"),
121
+//    CODE_18(18, "身份证正面照不能为空!"),
122
+//    CODE_19(19, "身份证反面照不能为空!"),
123
+//    CODE_20(20, "行驶证正面照不能为空!"),
124
+//    CODE_21(21, "行驶证反面照不能为空!"),
125
+//    CODE_22(22, "该用户还没通过审核!"),
126
+//    CODE_23(23, "账号不能为空!"),
127
+//    CODE_24(24, "密码不能为空!"),
128
+//    CODE_25(25, "该账号已被占用!"),
129
+//    CODE_26(26, "参数错误!"),
130
+//    CODE_50(50, "过期时间不能为空!"),

+ 130 - 0
src/main/java/com/unissoft/result/ResultView.java

@@ -0,0 +1,130 @@
1
+package com.unissoft.result;
2
+
3
+/**
4
+ * 结果视图类
5
+ */
6
+public class ResultView {
7
+    /**
8
+     * 状态码
9
+     */
10
+    private Integer code;
11
+
12
+    /**
13
+     * 消息
14
+     */
15
+    private String msg;
16
+
17
+    /**
18
+     * 数据
19
+     */
20
+    private Object data;
21
+
22
+    /**
23
+     * 成功
24
+     *
25
+     * @return 结果视图
26
+     */
27
+    public static ResultView success() {
28
+        return new ResultView();
29
+    }
30
+
31
+    /**
32
+     * 成功
33
+     *
34
+     * @param data 数据
35
+     * @return 结果视图
36
+     */
37
+    public static ResultView success(Object data) {
38
+        return new ResultView(data);
39
+    }
40
+
41
+    /**
42
+     * 错误
43
+     *
44
+     * @return 结果视图
45
+     */
46
+    public static ResultView error() {
47
+        return new ResultView(ResultEnum.CODE_2.getCode(), ResultEnum.CODE_2.getMsg());
48
+    }
49
+
50
+    /**
51
+     * 错误
52
+     *
53
+     * @param resultEnum 结果枚举
54
+     * @return 结果视图
55
+     */
56
+    public static ResultView error(ResultEnum resultEnum) {
57
+        return new ResultView(resultEnum.getCode(), resultEnum.getMsg());
58
+    }
59
+
60
+    /**
61
+     * 调用服务的错误
62
+     *
63
+     * @param serviceName 服务名
64
+     * @return 结果视图
65
+     */
66
+    public static ResultView hystrixError(String serviceName) {
67
+        ResultEnum resultEnum = ResultEnum.CODE_3;
68
+        String msg = resultEnum.getMsg().replace("xxx", serviceName);
69
+        return new ResultView(resultEnum.getCode(), msg);
70
+    }
71
+
72
+    /**
73
+     * 自定义错误消息
74
+     *
75
+     * @param msg 错误消息
76
+     * @return 结果视图
77
+     */
78
+    public static ResultView error(String msg) {
79
+        return new ResultView(ResultEnum.CODE_2.getCode(), msg);
80
+    }
81
+
82
+    private ResultView() {
83
+        this.code = ResultEnum.CODE_1.getCode();
84
+        this.msg = ResultEnum.CODE_1.getMsg();
85
+    }
86
+
87
+    private ResultView(Object data) {
88
+        this.data = data;
89
+        this.code = ResultEnum.CODE_1.getCode();
90
+        this.msg = ResultEnum.CODE_1.getMsg();
91
+    }
92
+
93
+    private ResultView(Integer code, String msg) {
94
+        this.code = code;
95
+        this.msg = msg;
96
+    }
97
+
98
+    public Integer getCode() {
99
+        return code;
100
+    }
101
+
102
+    public void setCode(Integer code) {
103
+        this.code = code;
104
+    }
105
+
106
+    public String getMsg() {
107
+        return msg;
108
+    }
109
+
110
+    public void setMsg(String msg) {
111
+        this.msg = msg;
112
+    }
113
+
114
+    public Object getData() {
115
+        return data;
116
+    }
117
+
118
+    public void setData(Object data) {
119
+        this.data = data;
120
+    }
121
+
122
+    @Override
123
+    public String toString() {
124
+        return "ResultView{" +
125
+                "code=" + code +
126
+                ", msg='" + msg + '\'' +
127
+                ", data=" + data +
128
+                '}';
129
+    }
130
+}

+ 50 - 0
src/main/java/com/unissoft/utils/CreateUtil.java

@@ -0,0 +1,50 @@
1
+package com.unissoft.utils;
2
+
3
+import java.text.Format;
4
+import java.text.SimpleDateFormat;
5
+import java.util.Date;
6
+import java.util.Random;
7
+
8
+/**
9
+ * 生成id工具类
10
+ */
11
+public class CreateUtil {
12
+
13
+    /**
14
+     * 生成id
15
+     *
16
+     * @return
17
+     */
18
+    public static Long id() {
19
+        Format format = new SimpleDateFormat("yyyyMMddHHmmss");
20
+        int a = (int) (Math.random() * 10.0D);
21
+        int b = (int) (Math.random() * 10.0D);
22
+        int c = (int) (Math.random() * 10.0D);
23
+        int d = (int) (Math.random() * 10.0D);
24
+        String date = format.format(new Date());
25
+        StringBuffer sb = new StringBuffer();
26
+        sb.append(date).insert(a, b);
27
+        sb.insert(b, c);
28
+        sb.insert(c, d);
29
+        sb.insert(d, a);
30
+        sb.insert(d, b);
31
+        String createdId = sb.toString();
32
+        return Long.parseLong(createdId);
33
+    }
34
+
35
+    /**
36
+     * 生成指定长度的数字验证码
37
+     *
38
+     * @param length
39
+     * @return
40
+     */
41
+    public static String validateCode(int length) {
42
+        String validateCode = "";
43
+        Random random = new Random();
44
+        for (int i = 0; i < length; i++) {
45
+            validateCode += random.nextInt(9);
46
+        }
47
+        return validateCode;
48
+    }
49
+
50
+}

+ 148 - 0
src/main/java/com/unissoft/utils/DateUtil.java

@@ -0,0 +1,148 @@
1
+package com.unissoft.utils;
2
+
3
+import java.text.Format;
4
+import java.text.ParseException;
5
+import java.text.SimpleDateFormat;
6
+import java.util.Calendar;
7
+import java.util.Date;
8
+
9
+/**
10
+ * 时间工具类
11
+ */
12
+public class DateUtil {
13
+
14
+    /**
15
+     * yyyy-MM-dd HH:mm:ss转date类型
16
+     */
17
+    public static Date formatDate(String stringDate, String pattern) {
18
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
19
+        Date date = null;
20
+        try {
21
+            date = sdf.parse(stringDate);
22
+        } catch (ParseException e) {
23
+            e.printStackTrace();
24
+        }
25
+        return date;
26
+    }
27
+
28
+
29
+    /**
30
+     * yyyy-MM-dd HH:mm:ss转date类型
31
+     */
32
+    public static Date formatDate(String stringDate) {
33
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
34
+        Date date = null;
35
+        try {
36
+            date = sdf.parse(stringDate);
37
+        } catch (ParseException e) {
38
+            e.printStackTrace();
39
+        }
40
+        return date;
41
+    }
42
+
43
+    /**
44
+     * date类型转yyyy-MM-dd HH:mm:ss
45
+     */
46
+    public static String formatDate(Date date) {
47
+        Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
48
+        String stringDate = format.format(date);
49
+        return stringDate;
50
+    }
51
+
52
+    /**
53
+     * "2018-03-01T16:00:00.000Z"格式转换成date类型。
54
+     */
55
+    public static Date formatDate_Z(String stringDate) {
56
+        //注意是空格+UTC
57
+        stringDate = stringDate.replace("Z", " UTC");
58
+        //注意格式化的表达式
59
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
60
+        Date date = null;
61
+        try {
62
+            date = format.parse(stringDate);
63
+        } catch (ParseException e) {
64
+            e.printStackTrace();
65
+        }
66
+        return date;
67
+    }
68
+
69
+    /**
70
+     * 时间相加减转yyyy-MM-dd HH:mm:ss
71
+     *
72
+     * @param date
73
+     * @param str  x年 或者x个月 或者x日/天
74
+     * @return
75
+     */
76
+    public static String addTime(Date date, String str) {
77
+        int size = 0;
78
+        Calendar cal = Calendar.getInstance();
79
+        cal.setTime(date);//设置起时间
80
+        if (str.contains("年")) {
81
+            size = Integer.parseInt(str.substring(0, str.length() - 1));
82
+            cal.add(Calendar.YEAR, size);//增加年
83
+        }
84
+        if (str.contains("个月")) {
85
+            size = Integer.parseInt(str.substring(0, str.length() - 2));
86
+            cal.add(Calendar.MONTH, size);//增加月
87
+        }
88
+        if (str.contains("日") || str.contains("天")) {
89
+            size = Integer.parseInt(str.substring(0, str.length() - 1));
90
+            cal.add(Calendar.DATE, size);//增加日/天
91
+        }
92
+        date = cal.getTime();
93
+        Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
94
+        return format.format(date);
95
+    }
96
+
97
+    /**
98
+     * date2比date1多的天数
99
+     *
100
+     * @param date1
101
+     * @param date2
102
+     * @return
103
+     */
104
+    public static int differentDays(Date date1, Date date2) {
105
+        Calendar cal1 = Calendar.getInstance();
106
+        cal1.setTime(date1);
107
+
108
+        Calendar cal2 = Calendar.getInstance();
109
+        cal2.setTime(date2);
110
+        int day1 = cal1.get(Calendar.DAY_OF_YEAR);
111
+        int day2 = cal2.get(Calendar.DAY_OF_YEAR);
112
+
113
+        int year1 = cal1.get(Calendar.YEAR);
114
+        int year2 = cal2.get(Calendar.YEAR);
115
+        if (year1 != year2)   //同一年
116
+        {
117
+            int timeDistance = 0;
118
+            for (int i = year1; i < year2; i++) {
119
+                if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)    //闰年
120
+                {
121
+                    timeDistance += 366;
122
+                } else    //不是闰年
123
+                {
124
+                    timeDistance += 365;
125
+                }
126
+            }
127
+
128
+            return timeDistance + (day2 - day1);
129
+        } else    //不同年
130
+        {
131
+            System.err.println("判断day2 - day1 : " + (day2 - day1));
132
+            return day2 - day1;
133
+        }
134
+    }
135
+
136
+    /**
137
+     * date2比date1多的秒数
138
+     *
139
+     * @param date1
140
+     * @param date2
141
+     * @return
142
+     */
143
+    public static int differentSecond(Date date1, Date date2) {
144
+        long time = date2.getTime() - date1.getTime();
145
+        int second = (int) time / 1000;
146
+        return second;
147
+    }
148
+}

+ 24 - 0
src/main/java/com/unissoft/utils/HttpUtil.java

@@ -0,0 +1,24 @@
1
+package com.unissoft.utils;
2
+
3
+import org.springframework.web.context.request.RequestContextHolder;
4
+import org.springframework.web.context.request.ServletRequestAttributes;
5
+
6
+import javax.servlet.http.HttpServletRequest;
7
+import javax.servlet.http.HttpServletResponse;
8
+
9
+/**
10
+ * 文件描述
11
+ *
12
+ * @author tongxi.xia
13
+ * @date 2020年12月12日 12:40
14
+ */
15
+public class HttpUtil {
16
+
17
+    public static HttpServletRequest getRequest() {
18
+        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
19
+    }
20
+
21
+    public static HttpServletResponse getResponse() {
22
+        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
23
+    }
24
+}

+ 23 - 0
src/main/java/com/unissoft/utils/UserUtils.java

@@ -0,0 +1,23 @@
1
+package com.unissoft.utils;
2
+
3
+import com.unissoft.MyConstant;
4
+import com.unissoft.model.SysUserPO;
5
+import org.springframework.stereotype.Component;
6
+
7
+/**
8
+ * 文件描述
9
+ *
10
+ * @author tongxi.xia
11
+ * @date 2020年12月12日 12:32
12
+ */
13
+@Component
14
+public class UserUtils {
15
+
16
+    public static SysUserPO getCurrUserInfo() {
17
+        SysUserPO loginUser = null;
18
+        if (HttpUtil.getRequest().getSession().getAttribute(MyConstant.LOGIN_USER) != null) {
19
+            loginUser = (SysUserPO) HttpUtil.getRequest().getSession().getAttribute(MyConstant.LOGIN_USER);
20
+        }
21
+        return loginUser;
22
+    }
23
+}