diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateRobotResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateRobotResourceService.java index 8f5a43d655..568e38636d 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateRobotResourceService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CreateRobotResourceService.java @@ -12,7 +12,6 @@ import io.metersphere.project.mapper.MessageTaskMapper; import io.metersphere.project.mapper.ProjectRobotMapper; import io.metersphere.sdk.dto.OptionDTO; import io.metersphere.sdk.util.JSON; -import io.metersphere.sdk.util.Translator; import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.service.CreateProjectResourceService; import io.metersphere.system.uid.UUID; @@ -48,7 +47,7 @@ public class CreateRobotResourceService implements CreateProjectResourceService String inSiteId = UUID.randomUUID().toString(); projectRobot.setId(inSiteId); projectRobot.setProjectId(projectId); - projectRobot.setName(Translator.get("robot_in_site")); + projectRobot.setName("robot_in_site"); projectRobot.setPlatform(ProjectRobotPlatform.IN_SITE.toString()); projectRobot.setWebhook("NONE"); projectRobot.setCreateUser("admin"); @@ -56,17 +55,17 @@ public class CreateRobotResourceService implements CreateProjectResourceService projectRobot.setUpdateUser("admin"); projectRobot.setUpdateTime(System.currentTimeMillis()); projectRobot.setEnable(true); - projectRobot.setDescription(Translator.get("robot_in_site_description")); + projectRobot.setDescription("robot_in_site_description"); list.add(projectRobot); ProjectRobot projectRobotMail = new ProjectRobot(); projectRobotMail.setId(UUID.randomUUID().toString()); projectRobotMail.setProjectId(projectId); - projectRobotMail.setName(Translator.get("robot_mail")); + projectRobotMail.setName("robot_mail"); projectRobotMail.setPlatform(ProjectRobotPlatform.MAIL.toString()); projectRobotMail.setWebhook("NONE"); projectRobotMail.setCreateUser("admin"); projectRobotMail.setEnable(true); - projectRobotMail.setDescription(Translator.get("robot_mail_description")); + projectRobotMail.setDescription("robot_mail_description"); projectRobotMail.setCreateTime(System.currentTimeMillis()); projectRobotMail.setUpdateUser("admin"); projectRobotMail.setUpdateTime(System.currentTimeMillis()); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java index 933cba50a4..0a25c897ec 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java @@ -122,8 +122,14 @@ public class ProjectRobotService { ProjectRobotExample.Criteria criteria = projectExample.createCriteria(); criteria.andProjectIdEqualTo(projectId); projectExample.setOrderByClause("create_time desc"); - - return robotMapper.selectByExample(projectExample); + List projectRobots = robotMapper.selectByExample(projectExample); + for (ProjectRobot projectRobot : projectRobots) { + if ((StringUtils.equalsIgnoreCase(projectRobot.getPlatform(), ProjectRobotPlatform.IN_SITE.toString()) || StringUtils.equalsIgnoreCase(projectRobot.getPlatform(), ProjectRobotPlatform.MAIL.toString())) && StringUtils.isNotBlank(projectRobot.getDescription())) { + projectRobot.setDescription(Translator.get(projectRobot.getDescription())); + projectRobot.setName(Translator.get(projectRobot.getName())); + } + } + return projectRobots; } public ProjectRobotDTO getDetail(String robotId) { diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateRobotResourceTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateRobotResourceTests.java index 39df110be8..f33ef9a7ee 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateRobotResourceTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateRobotResourceTests.java @@ -61,7 +61,6 @@ public class CreateRobotResourceTests extends BaseTest { Assertions.assertEquals(2, projectRobotAfters.size()); List messageList = getMessageList(id); Assertions.assertTrue(messageList.size() > 0); - System.out.println(messageList); } private List getList(String id) throws Exception {