mirror of
https://gitee.com/lijiahangmax/orion-ops.git
synced 2026-09-24 15:30:00 +08:00
check tag present.
This commit is contained in:
@@ -66,7 +66,7 @@ public class MessageConst {
|
||||
|
||||
public static final String INVALID_MACHINE = "未知的机器";
|
||||
|
||||
public static final String MACHINE_NOT_ENABLE = "机器未启用";
|
||||
public static final String MACHINE_DISABLE = "机器未启用";
|
||||
|
||||
public static final String INVALID_PROXY = "未查询到代理信息";
|
||||
|
||||
@@ -110,6 +110,8 @@ public class MessageConst {
|
||||
|
||||
public static final String NAME_PRESENT = "名称重复";
|
||||
|
||||
public static final String TAG_PRESENT = "唯一标识重复";
|
||||
|
||||
public static final String FORBID_DELETE = "禁止删除";
|
||||
|
||||
public static final String APP_ABSENT = "应用不存在";
|
||||
|
||||
@@ -134,6 +134,7 @@ public class MachineInfoController {
|
||||
Valid.gt(sshPort, 0, "ssh端口不正确");
|
||||
Valid.lte(sshPort, 65535, "ssh端口不正确");
|
||||
Valid.notBlank(request.getName());
|
||||
Valid.notBlank(request.getTag());
|
||||
Valid.notBlank(request.getUsername());
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MachineInfoDO implements Serializable {
|
||||
private String machineName;
|
||||
|
||||
/**
|
||||
* 机器标签
|
||||
* 机器标识符
|
||||
*/
|
||||
@TableField("machine_tag")
|
||||
private String machineTag;
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class MachineInfoRequest extends PageRequest {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 机器标签
|
||||
* 机器标识符
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class CommandExecVO {
|
||||
private String machineHost;
|
||||
|
||||
/**
|
||||
* 机器标签
|
||||
* 机器标识符
|
||||
*/
|
||||
private String machineTag;
|
||||
|
||||
|
||||
@@ -48,6 +48,14 @@ public class FileTailVO {
|
||||
*/
|
||||
private String machineHost;
|
||||
|
||||
/**
|
||||
* 机器状态 1有效 2无效
|
||||
*
|
||||
* @see com.orion.ops.consts.Const#ENABLE
|
||||
* @see com.orion.ops.consts.Const#DISABLE
|
||||
*/
|
||||
private Integer machineStatus;
|
||||
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MachineInfoVO {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 机器标签
|
||||
* 机器标识符
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
|
||||
+28
-7
@@ -68,14 +68,16 @@ public class ApplicationInfoServiceImpl implements ApplicationInfoService {
|
||||
|
||||
@Override
|
||||
public Long insertApp(ApplicationInfoRequest request) {
|
||||
// 检查是否存在
|
||||
String name = request.getName();
|
||||
// 重复检查
|
||||
String tag = request.getTag();
|
||||
// 名称重复检查
|
||||
this.checkNamePresent(null, name);
|
||||
// 标识重复检查
|
||||
this.checkTagPresent(null, tag);
|
||||
// 插入
|
||||
ApplicationInfoDO insert = new ApplicationInfoDO();
|
||||
insert.setAppName(name);
|
||||
insert.setAppTag(request.getTag());
|
||||
insert.setAppTag(tag);
|
||||
insert.setVcsId(request.getVcsId());
|
||||
insert.setDescription(request.getDescription());
|
||||
insert.setAppSort(this.getNextSort());
|
||||
@@ -89,15 +91,18 @@ public class ApplicationInfoServiceImpl implements ApplicationInfoService {
|
||||
public Integer updateApp(ApplicationInfoRequest request) {
|
||||
Long id = request.getId();
|
||||
String name = request.getName();
|
||||
String tag = request.getTag();
|
||||
// 查询应用
|
||||
ApplicationInfoDO app = Valid.notNull(applicationInfoDAO.selectById(id), MessageConst.APP_ABSENT);
|
||||
// 重复检查
|
||||
// 名称重复检查
|
||||
this.checkNamePresent(id, name);
|
||||
// 标识重复检查
|
||||
this.checkTagPresent(id, tag);
|
||||
// 更新
|
||||
ApplicationInfoDO update = new ApplicationInfoDO();
|
||||
update.setId(id);
|
||||
update.setAppName(name);
|
||||
update.setAppTag(request.getTag());
|
||||
update.setAppTag(tag);
|
||||
update.setVcsId(request.getVcsId());
|
||||
update.setDescription(request.getDescription());
|
||||
update.setUpdateTime(new Date());
|
||||
@@ -362,7 +367,9 @@ public class ApplicationInfoServiceImpl implements ApplicationInfoService {
|
||||
ApplicationInfoDO app = Valid.notNull(applicationInfoDAO.selectById(appId), MessageConst.APP_ABSENT);
|
||||
String beforeName = app.getAppName();
|
||||
app.setId(null);
|
||||
app.setAppName(app.getAppName() + Utils.getCopySuffix());
|
||||
String copySuffix = Utils.getCopySuffix();
|
||||
app.setAppName(beforeName + copySuffix);
|
||||
app.setAppTag(app.getAppTag() + copySuffix);
|
||||
app.setAppSort(this.getNextSort());
|
||||
app.setCreateTime(null);
|
||||
app.setUpdateTime(null);
|
||||
@@ -386,7 +393,7 @@ public class ApplicationInfoServiceImpl implements ApplicationInfoService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否存在
|
||||
* 检查名称是否存在
|
||||
*
|
||||
* @param id id
|
||||
* @param name name
|
||||
@@ -399,6 +406,20 @@ public class ApplicationInfoServiceImpl implements ApplicationInfoService {
|
||||
Valid.isTrue(!present, MessageConst.NAME_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查标签是否存在
|
||||
*
|
||||
* @param id id
|
||||
* @param tag tag
|
||||
*/
|
||||
private void checkTagPresent(Long id, String tag) {
|
||||
LambdaQueryWrapper<ApplicationInfoDO> presentWrapper = new LambdaQueryWrapper<ApplicationInfoDO>()
|
||||
.ne(id != null, ApplicationInfoDO::getId, id)
|
||||
.eq(ApplicationInfoDO::getAppTag, tag);
|
||||
boolean present = DataQuery.of(applicationInfoDAO).wrapper(presentWrapper).present();
|
||||
Valid.isTrue(!present, MessageConst.TAG_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个排序
|
||||
*
|
||||
|
||||
+27
-7
@@ -61,12 +61,15 @@ public class ApplicationProfileServiceImpl implements ApplicationProfileService
|
||||
@Override
|
||||
public Long addProfile(ApplicationProfileRequest request) {
|
||||
String name = request.getName();
|
||||
// 重复检查
|
||||
String tag = request.getTag();
|
||||
// 重复名称检查
|
||||
this.checkNamePresent(null, name);
|
||||
// 重复标识检查
|
||||
this.checkTagPresent(null, tag);
|
||||
// 插入
|
||||
ApplicationProfileDO insert = new ApplicationProfileDO();
|
||||
insert.setProfileName(request.getName());
|
||||
insert.setProfileTag(request.getTag());
|
||||
insert.setProfileName(name);
|
||||
insert.setProfileTag(tag);
|
||||
insert.setDescription(request.getDescription());
|
||||
insert.setReleaseAudit(request.getReleaseAudit());
|
||||
applicationProfileDAO.insert(insert);
|
||||
@@ -85,13 +88,16 @@ public class ApplicationProfileServiceImpl implements ApplicationProfileService
|
||||
ApplicationProfileDO beforeProfile = applicationProfileDAO.selectById(id);
|
||||
Valid.notNull(beforeProfile, MessageConst.PROFILE_ABSENT);
|
||||
String name = request.getName();
|
||||
// 重复检查
|
||||
String tag = request.getTag();
|
||||
// 重复名称检查
|
||||
this.checkNamePresent(id, name);
|
||||
// 重复标识检查
|
||||
this.checkTagPresent(id, tag);
|
||||
// 修改
|
||||
ApplicationProfileDO update = new ApplicationProfileDO();
|
||||
update.setId(id);
|
||||
update.setProfileName(request.getName());
|
||||
update.setProfileTag(request.getTag());
|
||||
update.setProfileName(name);
|
||||
update.setProfileTag(tag);
|
||||
update.setDescription(request.getDescription());
|
||||
update.setReleaseAudit(request.getReleaseAudit());
|
||||
update.setUpdateTime(new Date());
|
||||
@@ -177,7 +183,7 @@ public class ApplicationProfileServiceImpl implements ApplicationProfileService
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否存在
|
||||
* 检查名称是否存在
|
||||
*
|
||||
* @param id id
|
||||
* @param name name
|
||||
@@ -190,6 +196,20 @@ public class ApplicationProfileServiceImpl implements ApplicationProfileService
|
||||
Valid.isTrue(!present, MessageConst.NAME_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查标识符是否存在
|
||||
*
|
||||
* @param id id
|
||||
* @param tag tag
|
||||
*/
|
||||
private void checkTagPresent(Long id, String tag) {
|
||||
LambdaQueryWrapper<ApplicationProfileDO> presentWrapper = new LambdaQueryWrapper<ApplicationProfileDO>()
|
||||
.ne(id != null, ApplicationProfileDO::getId, id)
|
||||
.eq(ApplicationProfileDO::getProfileTag, tag);
|
||||
boolean present = DataQuery.of(applicationProfileDAO).wrapper(presentWrapper).present();
|
||||
Valid.isTrue(!present, MessageConst.TAG_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置环境缓存
|
||||
*
|
||||
|
||||
@@ -103,6 +103,7 @@ public class FileTailServiceImpl implements FileTailService {
|
||||
res.setMachineId(machine.getId());
|
||||
res.setMachineName(machine.getMachineName());
|
||||
res.setMachineHost(machine.getMachineHost());
|
||||
res.setMachineStatus(machine.getMachineStatus());
|
||||
// 设置token
|
||||
String token = UUIds.random19();
|
||||
res.setToken(token);
|
||||
@@ -205,6 +206,7 @@ public class FileTailServiceImpl implements FileTailService {
|
||||
if (machine != null) {
|
||||
p.setMachineName(machine.getMachineName());
|
||||
p.setMachineHost(machine.getMachineHost());
|
||||
p.setMachineStatus(machine.getMachineStatus());
|
||||
}
|
||||
});
|
||||
return dataGrid;
|
||||
@@ -220,6 +222,7 @@ public class FileTailServiceImpl implements FileTailService {
|
||||
Valid.notNull(machine, MessageConst.INVALID_MACHINE);
|
||||
vo.setMachineName(machine.getMachineName());
|
||||
vo.setMachineHost(machine.getMachineHost());
|
||||
vo.setMachineStatus(machine.getMachineStatus());
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.orion.ops.entity.domain.ApplicationPipelineDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="profile_id" property="profileId" />
|
||||
<result column="pipeline_name" property="pipelineName" />
|
||||
<result column="description" property="description" />
|
||||
<result column="deleted" property="deleted" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<id column="id" property="id"/>
|
||||
<result column="profile_id" property="profileId"/>
|
||||
<result column="pipeline_name" property="pipelineName"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
|
||||
Reference in New Issue
Block a user