Commit bb673013 authored by 郭凡凡's avatar 郭凡凡

Merge remote-tracking branch 'origin/master'

parents beb55d1a 88873369
......@@ -12,6 +12,7 @@ import com.pms.ocp.service.OcpApiTreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -48,7 +49,11 @@ public class OcpApiTreeController {
@ApiOperation("服务树分类--新增")
public ResponseVO inseter(@RequestBody OcpApiGroup ocpApiGroup){
OcpApiGroup ocpApiGroup1 = service.insertTree(ocpApiGroup);
if (StringUtils.isBlank(ocpApiGroup1.getApiGroupName())){
return ResponseVO.error("服务名称已经存在");
}else {
return ResponseVO.ok(ocpApiGroup1);
}
}
......
......@@ -42,4 +42,8 @@ public interface OcpApiTreeMapper extends BaseMapper<OcpApiGroup> {
//根据code查询是否含有下级服务
List<OcpApiGroup> selectGroupPcode(String apiGroupCode);
//groupName重复问题
List<OcpApiGroup> selectGroupName(String apiGroupName);
}
......@@ -78,11 +78,13 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper, OcpApiG
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String code = RandomStringUtils.getRandomString(6);
boolean flag = true;
List<OcpApiGroup> ocpApiGroups = mapper.selectList(null);
Stream<OcpApiGroup> ocpApiGroupStream = ocpApiGroups.stream().filter(item -> item.getApiGroupCode().equals(ocpApiGroup.getApiGroupPcode()));
Stream<OcpApiGroup> apiGroupStream1 = ocpApiGroupStream.filter(ocp -> ocp.getApiGroupName().equals(ocpApiGroup.getApiGroupName()));
// List<OcpApiGroup> ocpApiGroups = mapper.selectList(null);
// Stream<OcpApiGroup> ocpApiGroupStream = ocpApiGroups.stream().filter(item -> item.getApiGroupCode().equals(ocpApiGroup.getApiGroupPcode()));
// Stream<OcpApiGroup> apiGroupStream1 = ocpApiGroupStream.filter(ocp -> ocp.getApiGroupName().equals(ocpApiGroup.getApiGroupName()));
List<OcpApiGroup> ocpApiGroups1 = mapper.selectGroupName(ocpApiGroup.getApiGroupName());
OcpApiGroup ocpApi = new OcpApiGroup();
if (!(StringUtils.isBlank(apiGroupStream1.toString()))) {
if (ocpApiGroups1.size() == 0) {
ocpApi.setApiGroupPromotionType(ocpApiGroup.getApiGroupPromotionType());
BeanUtils.copyProperties(ocpApiGroup, ocpApi);
......
......@@ -35,4 +35,10 @@
SELECT * FROM ocp_api_group where api_group_pcode = #{apiGroupCode};
</select>
<!-- 根据名称查询名称是否重复-->
<select id="selectGroupName" resultType="com.pms.ocp.model.entity.OcpApiGroup">
SELECT * FROM ocp_api_group where api_group_name = #{apiGroupName};
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment