Skip to content

Commit 0cdf920

Browse files
committed
增加覆盖平台
1 parent 8e74c34 commit 0cdf920

6 files changed

Lines changed: 279 additions & 0 deletions

File tree

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
package com.test.diff.services.entity;
2+
3+
import com.baomidou.mybatisplus.annotation.IdType;
4+
import com.baomidou.mybatisplus.annotation.TableField;
5+
import com.baomidou.mybatisplus.annotation.TableId;
6+
import com.baomidou.mybatisplus.annotation.TableName;
7+
import java.io.Serializable;
8+
import java.util.Date;
9+
import lombok.Data;
10+
11+
/**
12+
*
13+
* @TableName coverage_app
14+
*/
15+
@TableName(value ="coverage_app")
16+
@Data
17+
public class CoverageApp implements Serializable {
18+
/**
19+
* 自增id
20+
*/
21+
@TableId(value = "id", type = IdType.AUTO)
22+
private Long id;
23+
24+
/**
25+
* 项目id
26+
*/
27+
@TableField(value = "project_id")
28+
private Integer projectId;
29+
30+
/**
31+
* 应用名
32+
*/
33+
@TableField(value = "app_name")
34+
private String appName;
35+
36+
/**
37+
* 收集状态:收集中:未收集
38+
*/
39+
@TableField(value = "status")
40+
private Boolean status;
41+
42+
/**
43+
* 服务器ip
44+
*/
45+
@TableField(value = "host")
46+
private String host;
47+
48+
/**
49+
* jacoco端口
50+
*/
51+
@TableField(value = "port")
52+
private String port;
53+
54+
/**
55+
* 是否禁用
56+
*/
57+
@TableField(value = "is_disable")
58+
private Boolean isDisable;
59+
60+
/**
61+
* 是否删除
62+
*/
63+
@TableField(value = "is_delete")
64+
private Boolean isDelete;
65+
66+
/**
67+
* 添加时间
68+
*/
69+
@TableField(value = "add_time")
70+
private Date addTime;
71+
72+
/**
73+
* 修改时间
74+
*/
75+
@TableField(value = "last_time")
76+
private Date lastTime;
77+
78+
@TableField(exist = false)
79+
private static final long serialVersionUID = 1L;
80+
81+
@Override
82+
public boolean equals(Object that) {
83+
if (this == that) {
84+
return true;
85+
}
86+
if (that == null) {
87+
return false;
88+
}
89+
if (getClass() != that.getClass()) {
90+
return false;
91+
}
92+
CoverageApp other = (CoverageApp) that;
93+
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
94+
&& (this.getProjectId() == null ? other.getProjectId() == null : this.getProjectId().equals(other.getProjectId()))
95+
&& (this.getAppName() == null ? other.getAppName() == null : this.getAppName().equals(other.getAppName()))
96+
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
97+
&& (this.getHost() == null ? other.getHost() == null : this.getHost().equals(other.getHost()))
98+
&& (this.getPort() == null ? other.getPort() == null : this.getPort().equals(other.getPort()))
99+
&& (this.getIsDisable() == null ? other.getIsDisable() == null : this.getIsDisable().equals(other.getIsDisable()))
100+
&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
101+
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
102+
&& (this.getLastTime() == null ? other.getLastTime() == null : this.getLastTime().equals(other.getLastTime()));
103+
}
104+
105+
@Override
106+
public int hashCode() {
107+
final int prime = 31;
108+
int result = 1;
109+
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
110+
result = prime * result + ((getProjectId() == null) ? 0 : getProjectId().hashCode());
111+
result = prime * result + ((getAppName() == null) ? 0 : getAppName().hashCode());
112+
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
113+
result = prime * result + ((getHost() == null) ? 0 : getHost().hashCode());
114+
result = prime * result + ((getPort() == null) ? 0 : getPort().hashCode());
115+
result = prime * result + ((getIsDisable() == null) ? 0 : getIsDisable().hashCode());
116+
result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
117+
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
118+
result = prime * result + ((getLastTime() == null) ? 0 : getLastTime().hashCode());
119+
return result;
120+
}
121+
122+
@Override
123+
public String toString() {
124+
StringBuilder sb = new StringBuilder();
125+
sb.append(getClass().getSimpleName());
126+
sb.append(" [");
127+
sb.append("Hash = ").append(hashCode());
128+
sb.append(", id=").append(id);
129+
sb.append(", projectId=").append(projectId);
130+
sb.append(", appName=").append(appName);
131+
sb.append(", status=").append(status);
132+
sb.append(", host=").append(host);
133+
sb.append(", port=").append(port);
134+
sb.append(", isDisable=").append(isDisable);
135+
sb.append(", isDelete=").append(isDelete);
136+
sb.append(", addTime=").append(addTime);
137+
sb.append(", lastTime=").append(lastTime);
138+
sb.append(", serialVersionUID=").append(serialVersionUID);
139+
sb.append("]");
140+
return sb.toString();
141+
}
142+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.test.diff.services.mapper;
2+
3+
import com.test.diff.services.entity.CoverageApp;
4+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5+
6+
/**
7+
* @Entity com.test.diff.services.entity.CoverageApp
8+
*/
9+
public interface CoverageAppMapper extends BaseMapper<CoverageApp> {
10+
11+
}
12+
13+
14+
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.test.diff.services.mapper;
2+
3+
import com.test.diff.services.entity.CoverageReport;
4+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5+
6+
/**
7+
* @Entity com.test.diff.services.entity.CoverageReport
8+
*/
9+
public interface CoverageReportMapper extends BaseMapper<CoverageReport> {
10+
11+
}
12+
13+
14+
15+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.test.diff.services.service;
2+
3+
import com.test.diff.services.entity.CoverageApp;
4+
import com.baomidou.mybatisplus.extension.service.IService;
5+
6+
import java.util.List;
7+
8+
/**
9+
*
10+
*/
11+
public interface CoverageAppService extends IService<CoverageApp> {
12+
13+
List<CoverageApp> getListByProjectId(long projectId);
14+
15+
int create(int projectId, CoverageApp app);
16+
17+
/**
18+
* 根据projectId和jacocoPort,查出正在收集中的应用
19+
* @param projectId
20+
* @param jacocoPort
21+
* @return
22+
*/
23+
CoverageApp getAppByProjectIdAndPort(int projectId, int jacocoPort);
24+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.test.diff.services.service.impl;
2+
3+
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4+
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5+
import com.test.diff.services.entity.CoverageApp;
6+
import com.test.diff.services.service.CoverageAppService;
7+
import com.test.diff.services.mapper.CoverageAppMapper;
8+
import org.springframework.stereotype.Service;
9+
10+
import javax.annotation.Resource;
11+
import java.util.Date;
12+
import java.util.List;
13+
14+
/**
15+
*
16+
*/
17+
@Service
18+
public class CoverageAppServiceImpl extends ServiceImpl<CoverageAppMapper, CoverageApp>
19+
implements CoverageAppService{
20+
21+
@Resource
22+
private CoverageAppMapper coverageAppMapper;
23+
24+
@Override
25+
public List<CoverageApp> getListByProjectId(long projectId) {
26+
LambdaQueryWrapper<CoverageApp> query = new LambdaQueryWrapper<>();
27+
query.eq(CoverageApp::getIsDelete, false);
28+
query.eq(CoverageApp::getIsDisable, false);
29+
query.eq(CoverageApp::getProjectId, projectId);
30+
return coverageAppMapper.selectList(query);
31+
}
32+
33+
@Override
34+
public int create(int projectId, CoverageApp app) {
35+
app.setStatus(false);
36+
app.setAddTime(new Date());
37+
app.setLastTime(new Date());
38+
app.setIsDelete(false);
39+
app.setIsDisable(false);
40+
app.setProjectId(projectId);
41+
coverageAppMapper.insert(app);
42+
return app.getId().intValue();
43+
}
44+
45+
@Override
46+
public CoverageApp getAppByProjectIdAndPort(int projectId, int jacocoPort) {
47+
LambdaQueryWrapper<CoverageApp> query = new LambdaQueryWrapper<>();
48+
query.eq(CoverageApp::getProjectId, projectId);
49+
query.eq(CoverageApp::getPort, jacocoPort);
50+
query.eq(CoverageApp::getStatus, true);
51+
return coverageAppMapper.selectOne(query);
52+
}
53+
}
54+
55+
56+
57+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE mapper
3+
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4+
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5+
<mapper namespace="com.test.diff.services.mapper.CoverageAppMapper">
6+
7+
<resultMap id="BaseResultMap" type="com.test.diff.services.entity.CoverageApp">
8+
<id property="id" column="id" jdbcType="BIGINT"/>
9+
<result property="projectId" column="project_id" jdbcType="INTEGER"/>
10+
<result property="appName" column="app_name" jdbcType="VARCHAR"/>
11+
<result property="status" column="status" jdbcType="BOOLEAN"/>
12+
<result property="host" column="host" jdbcType="VARCHAR"/>
13+
<result property="port" column="port" jdbcType="VARCHAR"/>
14+
<result property="isDisable" column="is_disable" jdbcType="BOOLEAN"/>
15+
<result property="isDelete" column="is_delete" jdbcType="BOOLEAN"/>
16+
<result property="addTime" column="add_time" jdbcType="TIMESTAMP"/>
17+
<result property="lastTime" column="last_time" jdbcType="TIMESTAMP"/>
18+
</resultMap>
19+
20+
<sql id="Base_Column_List">
21+
id,project_id,app_name,
22+
status,host,port,
23+
is_disable,is_delete,add_time,
24+
last_time
25+
</sql>
26+
</mapper>

0 commit comments

Comments
 (0)