Copilot commented on code in PR #6096:
URL: https://github.com/apache/shenyu/pull/6096#discussion_r2272184974


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RegistryServiceImpl.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.service.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.exception.ShenyuAdminException;
+import org.apache.shenyu.admin.mapper.RegistryMapper;
+import org.apache.shenyu.admin.model.dto.RegistryDTO;
+import org.apache.shenyu.admin.model.entity.RegistryDO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageResultUtils;
+import org.apache.shenyu.admin.model.query.RegistryQuery;
+import org.apache.shenyu.admin.model.vo.RegistryVO;
+import org.apache.shenyu.admin.service.RegistryService;
+import org.apache.shenyu.admin.transfer.RegistryTransfer;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.common.utils.UUIDUtils;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+public class RegistryServiceImpl implements RegistryService {
+
+    private final RegistryMapper registryMapper;
+
+    public RegistryServiceImpl(final RegistryMapper registryMapper) {
+        this.registryMapper = registryMapper;
+    }
+
+    @Override
+    public RegistryVO createOrUpdate(final RegistryDTO registryDTO) {
+        return StringUtils.isBlank(registryDTO.getId())
+                ? this.create(registryDTO) : this.update(registryDTO);
+    }
+
+    @Override
+    public CommonPager<RegistryVO> listByPage(final RegistryQuery 
registryQuery) {
+        return PageResultUtils.result(registryQuery.getPageParameter(), () -> 
registryMapper.countByQuery(registryQuery), () -> 
registryMapper.selectByQuery(registryQuery)
+                .stream()
+                .map(RegistryTransfer.INSTANCE::mapToVo)
+                .collect(Collectors.toList()));
+    }
+
+    @Override
+    public String delete(final List<String> ids) {
+        // todo check selector handle
+        registryMapper.deleteByIds(ids);
+        return ShenyuResultMessage.DELETE_SUCCESS;
+    }
+
+    @Override
+    public RegistryVO findById(final String id) {
+        return 
RegistryTransfer.INSTANCE.mapToVo(registryMapper.selectById(id));
+    }
+
+    @Override
+    public RegistryVO findByRegistryId(final String registryId) {
+        return 
RegistryTransfer.INSTANCE.mapToVo(registryMapper.selectByRegistryId(registryId));
+    }
+
+    @Override
+    public List<RegistryVO> listAll() {
+        List<RegistryDO> registryDOS = registryMapper.selectAll();
+        return 
registryDOS.stream().map(RegistryTransfer.INSTANCE::mapToVo).collect(Collectors.toList());
+    }
+
+
+    private RegistryVO create(final RegistryDTO registryDTO) {
+        RegistryDO existRegistryDO = 
registryMapper.selectByRegistryId(registryDTO.getId());

Review Comment:
   The method is using `registryDTO.getId()` but should use 
`registryDTO.getRegistryId()` to check for existing registry by registryId.
   ```suggestion
           RegistryDO existRegistryDO = 
registryMapper.selectByRegistryId(registryDTO.getRegistryId());
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/RegistryDTO.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import java.io.Serializable;
+
+import jakarta.validation.constraints.NotNull;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * RegistryDTO.
+ */
+public class RegistryDTO implements Serializable {
+
+    private String id;
+
+    @Length(max = 128, message = "The maximum length is 128")
+    @NotNull(message = "registry code not null")
+    private String registryId;
+
+    @Length(max = 128, message = "The maximum length is 128")
+    @NotNull(message = "registry protocol not null")
+    private String protocol;
+
+    @Length(max = 100, message = "The maximum length is 100")
+    @NotNull(message = "address null")
+    private String address;
+
+    @Length(max = 50, message = "The maximum length is 50")
+    private String username;
+
+    @Length(max = 100, message = "The maximum length is 100")
+    private String password;
+
+    @Length(max = 100, message = "The maximum length is 100")
+    private String namespace;
+
+    @Length(max = 20, message = "The maximum length is 100")

Review Comment:
   The error message states 'The maximum length is 100' but the annotation 
specifies max = 20. The message should be 'The maximum length is 20'.
   ```suggestion
       @Length(max = 20, message = "The maximum length is 20")
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/RegistryDO.java:
##########
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.entity;
+
+import java.sql.Timestamp;
+
+/**
+ * Registry do.
+ */
+public class RegistryDO extends BaseDO {
+
+    /**
+     * the model registryId.
+     */
+    private String registryId;
+
+    /**
+     * the model protocol.
+     */
+    private String protocol;
+
+    /**
+     * the model address.
+     */
+    private String address;
+
+    /**
+     * the model username.
+     */
+    private String username;
+
+    /**
+     * the model password.
+     */
+    private String password;
+
+    /**
+     * the model namespace.
+     */
+    private String namespace;
+
+    /**
+     * the model code.
+     */
+    private String group;
+
+    /**
+     * Gets the value of code.
+     *
+     * @return the value of code

Review Comment:
   The JavaDoc comment incorrectly refers to 'code' but the method returns 
registryId. It should be 'Gets the value of registryId.'
   ```suggestion
        * Gets the value of registryId.
        *
        * @return the value of registryId
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/RegistryTransfer.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.transfer;
+
+import org.apache.shenyu.admin.model.entity.RegistryDO;
+import org.apache.shenyu.admin.model.vo.RegistryVO;
+
+import java.util.Optional;
+
+public enum RegistryTransfer {
+    /**
+     * The constant INSTANCE.
+     */
+    INSTANCE;
+
+    /**
+     * mapToVo.
+     *
+     * @param registryDO registryDO
+     * @return NamespaceVO

Review Comment:
   The return type in the JavaDoc should be `RegistryVO` instead of 
`NamespaceVO`.
   ```suggestion
        * @return RegistryVO
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to