Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #26] CRUD the basic tables of Topic, Group, GroupMember, and Operation #28

Merged
merged 22 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public class LogEntity {

private Integer status;

private String description;
private String content;

private Timestamp createTime;

private Timestamp endTime;

private String operationUser;

private String resultContent;
private String result;

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable {
try {
proceed = joinPoint.proceed();
logEntity.setStatus(2);
logEntity.setResultContent(Objects.isNull(proceed) ? "" : proceed.toString());
logEntity.setResult(Objects.isNull(proceed) ? "" : proceed.toString());
return proceed;
} catch (Throwable e) {
logEntity.setStatus(3);
throw new RuntimeException(e);
} finally {
logEntity.setResultContent(proceed.toString());
logEntity.setResult(proceed.toString());
logService.updateLog(logEntity);
}

Expand All @@ -94,7 +94,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j
Long opClusterPhyId = (Long) clusterPhyId.get(model);
//The clusterId is obtained from the parameter object, and the operation is described as the object itself
logEntity.setClusterId(opClusterPhyId);
logEntity.setDescription(model.toString());
logEntity.setContent(model.toString());
logEntity.setOperationType(declaredAnnotation.OprType());
logEntity.setTargetType(declaredAnnotation.OprTarget());
logEntity.setStatus(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface OprGroupMapper {
+ "and is_delete=0"
+ "</where>"
+ "</script>")
List<GroupEntity> selectGroupByDynamic(GroupEntity groupEntity);
List<GroupEntity> selectGroup(GroupEntity groupEntity);


}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public interface OprGroupMemberMapper {
+ "</where>"
+ "and is_delete=0"
+ "</script>")
List<GroupMemberEntity> selectAllMemberByDynamic(GroupMemberEntity groupMemberEntity);
List<GroupMemberEntity> selectMember(GroupMemberEntity groupMemberEntity);

@Update("update group_member set state=#{state} where topic_name=#{topicName}")
void updateMemberByTopic(GroupMemberEntity groupMemberEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
@Mapper
public interface TopicMapper {


@Select("<script>"
@Select(
"<script>"
+ "select * from topic"
zzxxiansheng marked this conversation as resolved.
Show resolved Hide resolved
+ "<where>"
+ "<if test='topicName!=null'>"
Expand All @@ -48,7 +48,7 @@ public interface TopicMapper {
+ "and is_delete=0"
+ "</where>"
+ "</script>")
List<TopicEntity> getTopicListByDynamic(TopicEntity topicEntity);
List<TopicEntity> getTopicList(TopicEntity topicEntity);

@Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) "
+ "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface GroupService {

GroupEntity selectGroup(GroupEntity groupEntity);

Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity);
Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity);

Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity);
Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class GroupServiceImpl implements GroupService {
@EmLog(OprType = "search", OprTarget = "Group")
@Override
public List<GroupEntity> getGroupByClusterId(GroupEntity groupEntity) {
return oprGroupMapper.selectGroupByDynamic(groupEntity);
return oprGroupMapper.selectGroup(groupEntity);

}

Expand All @@ -68,7 +68,7 @@ public GroupEntity selectGroup(GroupEntity groupEntity) {
}

@Override
public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) {
public Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity) {
groupMemberService.addGroupMember(groupMemberEntity);
GroupEntity groupEntity = new GroupEntity();
groupEntity.setName(groupMemberEntity.getGroupName());
Expand All @@ -85,7 +85,7 @@ public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) {
}

@Override
public Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity) {
public Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity) {
groupMemberService.deleteGroupMember(groupMemberEntity);
GroupEntity groupEntity = new GroupEntity();
groupEntity.setName(groupMemberEntity.getGroupName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public List<GroupMemberEntity> selectGroupMemberByGroup(GroupEntity groupEntity)
groupMemberEntity.setGroupName(groupEntity.getName());
groupMemberEntity.setClusterId(groupEntity.getClusterId());
//Obtain a member who meets the conditions of a group
return oprGroupMemberMapper.selectAllMemberByDynamic(groupMemberEntity);
return oprGroupMemberMapper.selectMember(groupMemberEntity);
}

@Override
public List<GroupMemberEntity> selectAllMemberByTopic(GroupMemberEntity groupMemberEntity) {
List<GroupMemberEntity> groupMemberEntities = oprGroupMemberMapper.selectAllMemberByDynamic(groupMemberEntity);
List<GroupMemberEntity> groupMemberEntities = oprGroupMemberMapper.selectMember(groupMemberEntity);
return groupMemberEntities;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public interface TopicService {

void updateTopic(TopicEntity topicEntity);

void deleteTopic(TopicEntity topicEntity);
void deleteTopicById(TopicEntity topicEntity);

TopicEntity selectTopicById(TopicEntity topicEntity);

TopicEntity selectTopicByUnique(TopicEntity topicEntity);

void deleteTopic_plus(TopicEntity topicEntity);
void deleteTopic(TopicEntity topicEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TopicServiceImpl implements TopicService {

@Override
public List<TopicEntity> getTopicList(TopicEntity topicEntity) {
return topicMapper.getTopicListByDynamic(topicEntity);
return topicMapper.getTopicList(topicEntity);
}

@Override
Expand All @@ -57,7 +57,7 @@ public void updateTopic(TopicEntity topicEntity) {
}

@Override
public void deleteTopic(TopicEntity topicEntity) {
public void deleteTopicById(TopicEntity topicEntity) {
topicMapper.deleteTopic(topicEntity);
}

Expand All @@ -72,7 +72,7 @@ public TopicEntity selectTopicByUnique(TopicEntity topicEntity) {
}

@Override
public void deleteTopic_plus(TopicEntity topicEntity) {
public void deleteTopic(TopicEntity topicEntity) {
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
groupMemberEntity.setTopicName(topicEntity.getTopicName());
groupMemberEntity.setState("empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ CREATE TABLE `operation_log`
`cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '物理集群ID',
`operation_type` varchar(192) NOT NULL DEFAULT '' COMMENT '操作类型,如:启动,停止,重启,添加,删除,修改',
`status` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败',
`description` text COMMENT '备注信息',
`contain` text COMMENT '备注信息',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
zzxxiansheng marked this conversation as resolved.
Show resolved Hide resolved
`end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间',
`operation_user` varchar(192) DEFAULT NULL,
`result_content` text,
`result` text,
`target_type` varchar(192) NOT NULL,
`is_delete` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class TestOprLog {
private LogService logService;

@Test
public void test_groupService_OprLog() {
public void testGroupServiceOprLog() {
GroupEntity groupEntity = new GroupEntity(null, 1L, "logTest", 0, null, 1, "OK", null, null);
GroupEntity groupEntity1 = groupService.addGroup(groupEntity);
LogEntity logEntity = new LogEntity(null, 1L, "add", "Group", 2, groupEntity1.toString(), null, null, null, null);
logEntity.setResultContent(groupEntity.toString());
logEntity.setResult(groupEntity.toString());
logEntity.setId(groupEntity1.getId());
List<LogEntity> logListByCluster = logService.getLogListByCluster(logEntity);
logListByCluster.get(0).setId(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public List<GroupEntity> insertGroupData(String name) {
public List<GroupEntity> getRemovedTimeList(String name) {
GroupEntity groupEntity = new GroupEntity();
groupEntity.setName(name);
List<GroupEntity> groupEntities = groupMapper.selectGroupByDynamic(groupEntity);
List<GroupEntity> groupEntities = groupMapper.selectGroup(groupEntity);
for (GroupEntity groupEntity1 : groupEntities) {
groupEntity1.setCreateTime(null);
groupEntity1.setUpdateTime(null);
Expand All @@ -44,16 +44,16 @@ public List<GroupEntity> getRemovedTimeList(String name) {
}

@Test
public void test_addGroup() {
public void testAddGroup() {
List<GroupEntity> groupEntities = this.insertGroupData("addGroup");
GroupEntity groupEntity = new GroupEntity();
groupEntity.setName("addGroup");
List<GroupEntity> groupEntities1 = groupMapper.selectGroupByDynamic(groupEntity);
List<GroupEntity> groupEntities1 = groupMapper.selectGroup(groupEntity);
Assert.assertEquals(groupEntities, this.getRemovedTimeList("addGroup"));
}

@Test
public void test_updateGroupById() {
public void testUpdateGroupById() {
List<GroupEntity> groupEntities = this.insertGroupData("updateById2");
GroupEntity groupEntity = groupEntities.get(9);
groupEntity.setType(3);
Expand All @@ -65,7 +65,7 @@ public void test_updateGroupById() {
}

@Test
public void test_deleteGroupById() {
public void testDeleteGroupById() {
List<GroupEntity> groupEntities = this.insertGroupData("deleteById");
GroupEntity groupEntity = groupEntities.get(9);
groupMapper.deleteGroup(groupEntity);
Expand All @@ -74,7 +74,7 @@ public void test_deleteGroupById() {
}

@Test
public void test_selectGroupById() {
public void testSelectGroupById() {
List<GroupEntity> groupEntities = this.insertGroupData("selectById");
GroupEntity groupEntity = groupMapper.selectGroupById(groupEntities.get(0));
groupEntity.setCreateTime(null);
Expand All @@ -83,7 +83,7 @@ public void test_selectGroupById() {
}

@Test
public void test_selectGroupByClusterId() {
public void testSelectGroupByClusterId() {
List<GroupEntity> groupEntities = this.insertGroupData("selectByUnique");
GroupEntity groupEntity1 = new GroupEntity();
groupEntity1.setClusterId(groupEntities.get(0).getClusterId());
Expand All @@ -95,7 +95,7 @@ public void test_selectGroupByClusterId() {
}

@Test
public void test_selectGroupByDynamic() {
public void testSelectGroupByDynamic() {
List<GroupEntity> groupEntities = this.insertGroupData("selectByDynamic1");
zzxxiansheng marked this conversation as resolved.
Show resolved Hide resolved
Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic1"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public List<GroupMemberEntity> getRemovedTimeList(String topicName, String group
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
groupMemberEntity.setTopicName(topicName);
groupMemberEntity.setGroupName(groupName);
List<GroupMemberEntity> groupEntities = groupMemberMapper.selectAllMemberByDynamic(groupMemberEntity);
List<GroupMemberEntity> groupEntities = groupMemberMapper.selectMember(groupMemberEntity);
for (GroupMemberEntity groupEntity1 : groupEntities) {
groupEntity1.setCreateTime(null);
groupEntity1.setUpdateTime(null);
Expand All @@ -44,13 +44,13 @@ public List<GroupMemberEntity> getRemovedTimeList(String topicName, String group
}

@Test
public void test_addGroupMember() {
public void testAddGroupMember() {
List<GroupMemberEntity> add1 = this.insertGroupData("add1", "groupMember");
Assert.assertEquals(add1, this.getRemovedTimeList("add1", "groupMember"));
}

@Test
public void test_getGroupMemberByClusterId() {
public void testGetGroupMemberByClusterId() {
List<GroupMemberEntity> add1 = this.insertGroupData("getByCluster", "groupMember");
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
groupMemberEntity.setClusterId(add1.get(1).getClusterId());
Expand All @@ -63,7 +63,7 @@ public void test_getGroupMemberByClusterId() {
}

@Test
public void test_deleteGroupMemberById() {
public void testDeleteGroupMemberById() {
List<GroupMemberEntity> add1 = this.insertGroupData("getById", "groupMember");
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
groupMemberEntity.setId(add1.get(2).getId());
Expand All @@ -74,7 +74,7 @@ public void test_deleteGroupMemberById() {
}

@Test
public void test_updateGroupMemberById() {
public void testUpdateGroupMemberById() {
List<GroupMemberEntity> add1 = this.insertGroupData("updateById", "groupMember");
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
add1.get(1).setState("fail1");
Expand All @@ -88,7 +88,7 @@ public void test_updateGroupMemberById() {
}

@Test
public void test_selectGroupMemberByUnique() {
public void testSelectGroupMemberByUnique() {
List<GroupMemberEntity> groupMemberEntities = this.insertGroupData("selectByUnique", "groupMember");
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
groupMemberEntity.setClusterId(groupMemberEntities.get(1).getClusterId());
Expand All @@ -101,21 +101,21 @@ public void test_selectGroupMemberByUnique() {
}

@Test
public void test_selectGroupMemberByGroup() {
public void testSelectGroupMemberByGroup() {
List<GroupMemberEntity> groupMemberEntities = this.insertGroupData("selectByGroup1", "groupMember1");
List<GroupMemberEntity> removedTimeList = this.getRemovedTimeList(null, "groupMember1");
Assert.assertEquals(groupMemberEntities, removedTimeList);
}

@Test
public void test_selectGroupMemberByTopic() {
public void testSelectGroupMemberByTopic() {
List<GroupMemberEntity> groupMemberEntities = this.insertGroupData("selectByTopic1", "groupMember2");
List<GroupMemberEntity> removedTimeList = this.getRemovedTimeList("selectByTopic1", null);
Assert.assertEquals(groupMemberEntities, removedTimeList);
}

@Test
public void test_updateGroupMemberByTopic() {
public void testUpdateGroupMemberByTopic() {
List<GroupMemberEntity> groupMemberEntities = this.insertGroupData("updateByTopic1", "groupMember2");
for (GroupMemberEntity groupMemberEntity : groupMemberEntities) {
groupMemberEntity.setState("fail2");
Expand All @@ -128,7 +128,7 @@ public void test_updateGroupMemberByTopic() {
}

@Test
public void test_selectGroupMemberById() {
public void testSelectGroupMemberById() {
List<GroupMemberEntity> groupMemberEntities = this.insertGroupData("updateById1", "groupMember2");
GroupMemberEntity groupMemberEntity = new GroupMemberEntity();
groupMemberEntity.setId(groupMemberEntities.get(5).getId());
Expand Down
Loading
Loading