Browse Source

通用模块

hym 4 years ago
parent
commit
abb9825dd9

+ 15 - 0
common/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>platform</artifactId>
+        <groupId>com.huaxu</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>common</artifactId>
+
+
+</project>

+ 92 - 0
common/src/main/java/com/huaxu/model/AjaxMessage.java

@@ -0,0 +1,92 @@
+package com.huaxu.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Ajax信息
+ *
+ */
+@ApiModel("返回信息")
+public class AjaxMessage<T> {
+
+    @ApiModelProperty(value = "返回状态", position = 0)
+    private int status;
+    @ApiModelProperty(value = "返回信息", position = 1)
+    private String msg;
+    @ApiModelProperty(value = "返回内容", position = 2)
+    private T data;
+
+    public AjaxMessage() {
+    }
+
+    public AjaxMessage(int status, String msg, T data) {
+        this.status = status;
+        this.msg = msg;
+        this.data = data;
+    }
+
+    public AjaxMessage(ResultStatus resultStatus, T data) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();
+        this.data = data;
+    }
+
+    public AjaxMessage(ResultStatus resultStatus) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();
+    }
+
+
+
+    public void setMsg(int status, String msg, T data) {
+        this.status = status;
+        this.msg = msg;
+        this.data = data;
+    }
+
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public T getData() {
+        return data;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    public void setMsg(int status, String msg) {
+        this.status = status;
+        this.msg = msg;
+        this.data = null;
+    }
+
+    public void setMsg(ResultStatus resultStatus, T data) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();;
+        this.data = data;
+    }
+
+    public void setMsg(ResultStatus resultStatus) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();;
+        this.data = null;
+    }
+
+
+}

+ 39 - 0
common/src/main/java/com/huaxu/model/Pagination.java

@@ -0,0 +1,39 @@
+package com.huaxu.model;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 自定义分页
+ * @param <T>
+ */
+@Data
+public class Pagination<T> implements Serializable {
+    private static final long serialVersionUID = -4899829840696212229L;
+    @ApiModelProperty("总记录数")
+    private long total;
+
+    @ApiModelProperty("结果集")
+    private List<T> list;
+
+
+    public Pagination(){
+
+    };
+
+    /**
+     * 包装Page对象
+     *
+     * @param list
+     */
+    public Pagination(IPage<T> page) {
+
+        this.list = page.getRecords();
+        this.total = page.getTotal();
+    }
+}

+ 85 - 0
common/src/main/java/com/huaxu/model/Permission.java

@@ -0,0 +1,85 @@
+package com.huaxu.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@ApiModel(value="功能权限")
+@Data
+public class Permission {
+
+    @ApiModelProperty(value="id",position = 1)
+    private Integer id;
+
+    @ApiModelProperty(value="父类id,最上层值为0",position = 2)
+    private Integer parentId;
+    @JsonIgnore
+    @ApiModelProperty(value="数据权限类型")
+    private Integer permissionType;
+
+    @ApiModelProperty(value="产品分类id",position = 3)
+    private Integer productCategoryId;
+
+    @ApiModelProperty(value="名称",position = 4)
+    private String name;
+
+    @ApiModelProperty(value="别名",position = 5)
+    private String alias;
+
+    @ApiModelProperty(value="权限code",position = 6)
+    private String permission;
+
+    @ApiModelProperty(value="非选中图标",position = 7)
+    private String icon;
+
+    @ApiModelProperty(value="选中图标",position = 8)
+    private String overIcon;
+
+    @ApiModelProperty(value="路径",position = 9)
+    private String path;
+
+    @ApiModelProperty(value="排序",position = 10)
+    private Integer sort;
+
+    @ApiModelProperty(value="是否是菜单",position = 11)
+    private Boolean isMenu;
+
+    @ApiModelProperty(value="所属超级管理员",position = 12)
+    private Boolean isSuperAdmin;
+
+    @ApiModelProperty(value="所属站点",position = 13)
+    private Boolean isSite;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态",hidden = true)
+    private Boolean status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间",hidden = true)
+    private LocalDateTime createDate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人",hidden = true)
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间",hidden = true)
+    private LocalDateTime updateDate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人",hidden = true)
+    private String updateBy;
+
+    @ApiModelProperty(value = "父节点id集合", position = 100)
+    private List<Integer> collections;
+
+    @ApiModelProperty(value = "子集",position = 101)
+    private List<Permission> children;
+
+    @ApiModelProperty(value = "权限",position = 102)
+    private List<Permission> permissionList;
+}

+ 22 - 0
common/src/main/java/com/huaxu/model/ProgramItem.java

@@ -0,0 +1,22 @@
+package com.huaxu.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@ApiModel(value="数据权限")
+@Data
+public class ProgramItem implements Serializable {
+
+    private static final long serialVersionUID = 6581649172496070363L;
+    @ApiModelProperty(value="租户标识")
+    private String code;
+
+    @ApiModelProperty(value="机构id")
+    private Integer orgId;
+
+}

+ 112 - 0
common/src/main/java/com/huaxu/model/ResultStatus.java

@@ -0,0 +1,112 @@
+package com.huaxu.model;
+
+import lombok.Getter;
+
+/**
+ * 
+ * @Description  
+ * <p> 全局错误码定义
+  *  错误码由6位数字组成,3位模块编码+3位错误描述码
+  *  模块编码如下: 
+ * 100 用户模块
+ * 200 设备模块
+ * 300 工单模块
+ * 400 工作流模块
+ * 500 系统模块
+ * 900 其他
+ * </p>
+ * @author wilian.peng
+ * @date 2019年10月28日 下午2:33:13
+ */
+@Getter
+public enum ResultStatus {
+
+    /**
+     *返回状态
+     */
+    OK(0, "成功"),
+
+    //100 人员模块
+    MEMBER_TELPHONE_ALREADY_EXISTS(100001,"手机号码已存在"),
+    PERSON_TYPE_ALREADY_EXISTS(1000002,"该场景下的人员类型已存在"),
+    PERSON_TYPE_NAME_ALREADY_EXISTS(100003,"该人员类型名称已存在"),
+
+    //200 设备模块
+    DEVICE_NO_EXISTS(200001,"该设备编号已存在,请修改"),
+    DEVICE_NO_FORMAT_WRONG(200002,"请输入16位设备编号"),
+    UNIT_FORMAT_WRONG(200003,"单元号限输入不超过4个字符"),
+    LOCATION_FORMAT_WRONG(200004,"注册地址限输入不超过100个字符"),
+
+
+
+    //300 工单模块
+    //NODE_APP_SAVE_FAILED(300007,"保存节点信息信息失败"),
+    //NODE_IS_NOT_EXISTS(300009,"操作节点不存在"),
+    //NODE_DEL_FAILED(300008,"删除节点信息失败"),
+    //NODE_EDIT_FAILED(300008,"编辑节点信息失败"),
+    //DEVICE_NO_DUPLICATE(300301,"设备编号重复"),
+
+
+    //400 工作流模块
+    PROCESS_DEPLOY_FAILED(400006,"流程部署失败"),
+    TASK_IS_NOT_EXISTS(400001,"查找不到当前任务,任务可能已经被处理完成"),
+    TASK_NO_AUTHENTICATION(400002,"不具备当前任务操作权限"),
+    TASK_OPERATE_FAILED(400003,"任务操作失败"),
+    CREATE_ALARM_FAILED(400004,"系统错误,无法创建工单"),
+    NO_MATCH_WORKFLOW(400005,"系统配置错误,无对应工单流程"),
+    PROCESS_ALREADY_EXISTS(400006,"该情况下的流程已存在"),
+    PROCESS_KEY_ALREADY_EXISTS(400007,"该流程的processKey已经存在"),
+    PROCESS_DEL_FAILED(400008,"删除流程失败"),
+    PROCESS_NAME_ALREADY_EXISTS(400009,"该流程的名称已经存在"),
+
+
+    //500 系统模块
+    PHONE_NUMBER_ALREADY_EXISTS(500001,"该手机号已存在,请修改"),
+    USERNAME_ALREADY_EXISTS(500002,"该用户名已存在,请修改"),
+    UNABLE_ENABLE_USER(500003,"普通用户无法启用、禁用用户"),
+    SITE_NAME_ALREADY_EXISTS(500004,"该站点名称已存在,请修改"),
+    NAME_ALREADY_EXISTS(500005,"该名称已经存在,请修改"),
+    ROLE_NAME_ALREADY_EXISTS(500006,"该角色名已存在,请修改"),
+    ORGAN_NAME_ALREADY_EXISTS(500007,"该组织名称已存在,请修改"),
+    PROGRAM_NAME_ALREADY_EXISTS(500008,"该权限名称已存在,请修改"),
+    CUSTOMER_NAME_ALREADY_EXISTS(500009, "该客户名称已存在,请修改"),
+    PROJECT_NAME_ALREADY_EXISTS(500010,"该项目已存在,请修改"),
+    CHANNEL_NAME_ALREADY_EXISTS(500011, "该场景名称已存在,请修改"),
+    PROJECT_DELETE_ERROR(500012,"项目使用中暂不可删除"),
+    COMMUNITY_NAME_ALREADY_EXISTS(500013, "该小区已存在,请修改"),
+    PRODUCT_CATEGORY_ALREADY_EXISTS(500014, "该产品类型已存在,请修改"),
+    PRODUCT_CATEGORY_DELETE_ERROR(500015,"该产品类型已经有设备安装,无法删除"),
+    BUILDING_NAME_ALREADY_EXISTS(500016, "该建筑已存在,请修改"),
+    ALARM_NAME_ALREADY_EXISTS(500017, "该告警名称已存在,请修改"),
+    PRODUCT_DELETE_ERROR(500018,"该产品已经有设备安装,无法删除"),
+    CUSTOMER_DELETE_ERROR(500019,"该客户已经有设备安装,无法删除"),
+
+    //900 其他
+    ERROR(900000, "失败"),
+    APPLICATION_ERROR(900001, "应用异常"),
+    SERVICE_ERROR(900002, "业务逻辑验证错误。"),
+    ACCESS_DENIED_ERROR(900003, "权限不足,无法访问。"),
+    USERNAME_NOT_FOUND_ERROR(900004, "账户未注册。"),
+    PHONE_NUMBER_NOT_FOUND_ERROR(900005, "您的手机号尚未注册,请注册后进行登录。"),
+    VALIDATE_CODE_EXPIRED_ERROR(900006, "您输入的验证码已过期,请刷新重试。"),
+    VALIDATE_CODE_ERROR(900007, "您输入的验证码有误,请重新输入。"),
+    UNABLE_SEND_ERROR(900008, "60秒内无法发送。"),
+
+    PHONE_VALIDATE_CODE_EXPIRED_ERROR(900010, "您输入的手机验证码已过期,请重新输入。"),
+    PHONE_VALIDATE_CODE_ERROR_ERROR(900011, "您输入的手机验证码有误,请重新输入。"),
+    PHONE_VALIDATE_CODE_EMPTY_ERROR(900012, "请输入手机验证码。"),
+    ACCESS_DISABLED_ERROR(900013, "您的账号已被禁用,如有问题请联系管理员。"),
+    PHONE_NUMBER_NOT_FOUND_WECHAT_ERROR(900014, "您微信绑定的手机号尚未注册,请使用平台注册账号进行登录。"),
+
+    SYSTEM_ERROR(999999, "系统错误"),
+    ;
+
+    private final int status;
+
+    private final String message;
+
+    ResultStatus(int status, String message) {
+        this.status = status;
+        this.message = message;
+    }
+}

+ 18 - 35
pom.xml

@@ -11,6 +11,7 @@
         <module>user_auth</module>
         <module>user_center</module>
         <module>gateway</module>
+        <module>common</module>
     </modules>
 
     <!--父工程打包方式为pom-->
@@ -53,6 +54,10 @@
 
     <dependencies>
         <!--web依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
@@ -75,33 +80,18 @@
             <version>1.18.4</version>
             <scope>provided</scope>
         </dependency>
+
+
         <!-- Actuator可以帮助你监控和管理Spring Boot应用-->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
         </dependency>
-        <!--热部署-->
-        <!--<dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-devtools</artifactId>
-            <optional>true</optional>
-        </dependency>
--->
-
-
-        <!--&lt;!&ndash;spring cloud commons模块引入&ndash;&gt;
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-commons</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.retry</groupId>
-            <artifactId>spring-retry</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-aop</artifactId>
-        </dependency>-->
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-jdbc</artifactId>
@@ -115,10 +105,6 @@
                     <artifactId>guava</artifactId>
                     <groupId>com.google.guava</groupId>
                 </exclusion>
-                <exclusion>
-                    <artifactId>guava</artifactId>
-                    <groupId>com.google.guava</groupId>
-                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
@@ -134,18 +120,7 @@
                     <artifactId>guava</artifactId>
                     <groupId>com.google.guava</groupId>
                 </exclusion>
-                <exclusion>
-                    <artifactId>guava</artifactId>
-                    <groupId>com.google.guava</groupId>
-                </exclusion>
-                <exclusion>
-                    <artifactId>guava</artifactId>
-                    <groupId>com.google.guava</groupId>
-                </exclusion>
-                <exclusion>
-                    <artifactId>guava</artifactId>
-                    <groupId>com.google.guava</groupId>
-                </exclusion>
+
             </exclusions>
         </dependency>
         <dependency>
@@ -171,6 +146,14 @@
             </exclusions>
 
         </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-commons</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springframework.security.oauth.boot</groupId>
             <artifactId>spring-security-oauth2-autoconfigure</artifactId>
@@ -195,8 +178,8 @@
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>20.0</version>
-            <scope>compile</scope>
         </dependency>
+
     </dependencies>
 
     <build>