引人lombok

This commit is contained in:
bwcx_jzy 2019-06-20 17:14:45 +08:00
parent c874370e05
commit e71c706059
7 changed files with 43 additions and 225 deletions

View File

@ -1,28 +1,21 @@
package cn.keepbx.jpom.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* 基础实体带id
*
* @author jiangzeyin
* @date 2019/3/14
*/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public abstract class BaseModel extends BaseJsonModel {
private String id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@ -6,10 +6,12 @@ import cn.keepbx.jpom.common.forward.NodeUrl;
import cn.keepbx.jpom.model.BaseModel;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* 节点实体
@ -17,6 +19,9 @@ import java.util.Objects;
* @author jiangzeyin
* @date 2019/4/16
*/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class NodeModel extends BaseModel {
private String url;
@ -37,18 +42,6 @@ public class NodeModel extends BaseModel {
*/
private boolean openStatus;
public boolean isOpenStatus() {
return openStatus;
}
public void setOpenStatus(boolean openStatus) {
this.openStatus = openStatus;
}
public JSONArray getProjects() {
return projects;
}
/**
* 返回按照项目分组 排列的数组
*
@ -77,42 +70,6 @@ public class NodeModel extends BaseModel {
return newArray;
}
public void setProjects(JSONArray projects) {
this.projects = projects;
}
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol.toLowerCase();
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getLoginPwd() {
return loginPwd;
}
public void setLoginPwd(String loginPwd) {
this.loginPwd = loginPwd;
}
public String getAuthorize(boolean get) {
if (authorize == null) {
authorize = SecureUtil.sha1(loginName + "@" + loginPwd);
@ -123,27 +80,4 @@ public class NodeModel extends BaseModel {
public String getRealUrl(NodeUrl nodeUrl) {
return StrUtil.format("{}://{}{}", getProtocol(), getUrl(), nodeUrl.getUrl());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NodeModel nodeModel = (NodeModel) o;
return openStatus == nodeModel.openStatus &&
Objects.equals(url, nodeModel.url) &&
Objects.equals(loginName, nodeModel.loginName) &&
Objects.equals(loginPwd, nodeModel.loginPwd) &&
Objects.equals(protocol, nodeModel.protocol) &&
Objects.equals(authorize, nodeModel.authorize) &&
Objects.equals(projects, nodeModel.projects);
}
@Override
public int hashCode() {
return Objects.hash(url, loginName, loginPwd, protocol, authorize, projects, openStatus);
}
}

View File

@ -16,6 +16,9 @@ import cn.keepbx.jpom.model.BaseModel;
import cn.keepbx.jpom.service.node.NodeService;
import cn.keepbx.jpom.service.node.OutGivingServer;
import com.alibaba.fastjson.JSONObject;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.File;
import java.io.IOException;
@ -31,6 +34,9 @@ import java.util.function.Consumer;
* @author jiangzeyin
* @date 2019/4/21
*/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class OutGivingModel extends BaseModel {
/**
* 节点下的项目列表
@ -49,38 +55,6 @@ public class OutGivingModel extends BaseModel {
*/
private boolean outGivingProject;
public boolean isOutGivingProject() {
return outGivingProject;
}
public void setOutGivingProject(boolean outGivingProject) {
this.outGivingProject = outGivingProject;
}
public Map<NodeModel, JSONObject> getTempCacheMap() {
return tempCacheMap;
}
public void setTempCacheMap(Map<NodeModel, JSONObject> tempCacheMap) {
this.tempCacheMap = tempCacheMap;
}
public int getAfterOpt() {
return afterOpt;
}
public void setAfterOpt(int afterOpt) {
this.afterOpt = afterOpt;
}
public List<OutGivingNodeProject> getOutGivingNodeProjectList() {
return outGivingNodeProjectList;
}
public void setOutGivingNodeProjectList(List<OutGivingNodeProject> outGivingNodeProjectList) {
this.outGivingNodeProjectList = outGivingNodeProjectList;
}
/**
* 判断是否包含某个项目id
*

View File

@ -8,6 +8,9 @@ import cn.keepbx.jpom.model.BaseJsonModel;
import cn.keepbx.jpom.service.manage.ProjectInfoService;
import cn.keepbx.jpom.service.node.NodeService;
import com.alibaba.fastjson.JSONObject;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* 节点项目
@ -15,6 +18,9 @@ import com.alibaba.fastjson.JSONObject;
* @author jiangzeyin
* @date 2019/4/22
*/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class OutGivingNodeProject extends BaseJsonModel {
private static ProjectInfoService projectInfoService;
private static NodeService nodeService;
@ -24,53 +30,16 @@ public class OutGivingNodeProject extends BaseJsonModel {
private String lastOutGivingTime;
private int status = Status.No.getCode();
private String result;
private JSONObject projectInfo;
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public int getStatus() {
return status;
}
public String getStatusMsg() {
return BaseEnum.getDescByCode(Status.class, getStatus());
}
public void setStatus(int status) {
this.status = status;
}
public String getLastOutGivingTime() {
return StrUtil.emptyToDefault(lastOutGivingTime, StrUtil.DASHED);
}
public void setLastOutGivingTime(String lastOutGivingTime) {
this.lastOutGivingTime = lastOutGivingTime;
}
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
/**
* 获取对应的项目数据
*

View File

@ -1,6 +1,9 @@
package cn.keepbx.jpom.model.data;
import cn.keepbx.jpom.model.BaseJsonModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@ -10,14 +13,9 @@ import java.util.List;
* @author jiangzeyin
* @date 2019/4/22
*/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class ServerWhitelist extends BaseJsonModel {
private List<String> outGiving;
public List<String> getOutGiving() {
return outGiving;
}
public void setOutGiving(List<String> outGiving) {
this.outGiving = outGiving;
}
}

View File

@ -5,6 +5,9 @@ import cn.hutool.core.util.StrUtil;
import cn.keepbx.jpom.BaseJpomApplication;
import cn.keepbx.jpom.model.BaseEnum;
import cn.keepbx.jpom.model.BaseJsonModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* 用户操作日志
@ -12,6 +15,9 @@ import cn.keepbx.jpom.model.BaseJsonModel;
* @author jiangzeyin
* @date 2019/4/19
*/
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class UserOperateLogV1 extends BaseJsonModel {
public static final String TABLE_NAME = UserOperateLogV1.class.getSimpleName().toUpperCase();
/**
@ -60,18 +66,11 @@ public class UserOperateLogV1 extends BaseJsonModel {
*/
private String userAgent;
public String getReqData() {
return reqData;
}
public void setReqData(String reqData) {
this.reqData = StrUtil.maxLength(reqData, 999999990);
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = StrUtil.maxLength(userAgent, 280);
}
@ -80,10 +79,6 @@ public class UserOperateLogV1 extends BaseJsonModel {
return StrUtil.emptyToDefault(dataId, StrUtil.DASHED);
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public UserOperateLogV1(String reqId) {
if (reqId == null) {
this.reqId = IdUtil.fastUUID();
@ -98,34 +93,11 @@ public class UserOperateLogV1 extends BaseJsonModel {
public UserOperateLogV1() {
}
public String getReqId() {
return reqId;
}
public void setReqId(String reqId) {
this.reqId = reqId;
}
public String getNodeId() {
return StrUtil.emptyToDefault(nodeId, StrUtil.DASHED);
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
if (UserModel.SYSTEM_OCCUPY_NAME.equals(userId)) {
this.userId = BaseJpomApplication.SYSTEM_ID;
@ -134,30 +106,10 @@ public class UserOperateLogV1 extends BaseJsonModel {
}
}
public long getOptTime() {
return optTime;
}
public void setOptTime(long optTime) {
this.optTime = optTime;
}
public int getOptType() {
return optType;
}
public String getOptTypeMsg() {
return BaseEnum.getDescByCode(OptType.class, getOptType());
}
public void setOptType(int optType) {
this.optType = optType;
}
public int getOptStatus() {
return optStatus;
}
/**
* 获取执行结果的描述消息
*
@ -170,14 +122,6 @@ public class UserOperateLogV1 extends BaseJsonModel {
return Status.Fail.getDesc() + ":" + getOptStatus();
}
public void setOptStatus(int optStatus) {
this.optStatus = optStatus;
}
public String getResultMsg() {
return resultMsg;
}
public void setResultMsg(String resultMsg) {
this.resultMsg = StrUtil.maxLength(resultMsg, 999999990);
}

View File

@ -49,6 +49,12 @@
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>