Commit 159ce7fe authored by zhaochengming's avatar zhaochengming

赵呈明 --服务应用

parent 68e1dab2
package com.pms.ocp.controller;
import com.baomidou.mybatisplus.extension.api.R;
import com.github.pagehelper.PageInfo;
import com.pms.ocp.model.dto.*;
......@@ -14,7 +13,6 @@ 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.*;
......
......@@ -36,4 +36,7 @@ public interface OcpApiTreeMapper extends BaseMapper<OcpApiGroup> {
//code重复问题
List<OcpApiGroup> selectGroupCode();
//根据code查询整条数据
OcpApiGroup selectCode(String code);
}
......@@ -101,7 +101,7 @@ public class TenanBaseDto extends OcpTenantGroup {
* 应用树层级 1:应用分组层 2:应用层
*/
@ApiModelProperty("应用树层级 1:应用分组层 2:应用层")
private Short tenantGroupLevel;
private String tenantGroupLevel;
......
......@@ -58,15 +58,14 @@ public class OcpApiGroup {
private long isDelete;
@ApiModelProperty("分层树层级 1中台层 2中心层 3 服务组层 4服务层 ")
private long apiGroupLevel;
private String apiGroupLevel;
public long getApiGroupLevel() {
public String getApiGroupLevel() {
return apiGroupLevel;
}
public void setApiGroupLevel(long apiGroupLevel) {
public void setApiGroupLevel(String apiGroupLevel) {
this.apiGroupLevel = apiGroupLevel;
}
......
......@@ -106,7 +106,7 @@ public class OcpTenantGroup implements Serializable {
* 应用树层级 1:应用分组层 2:应用层
*/
@ApiModelProperty("应用树层级 1:应用分组层 2:应用层")
private Short tenantGroupLevel;
private String tenantGroupLevel;
@TableField(exist = false)
......@@ -309,19 +309,18 @@ public class OcpTenantGroup implements Serializable {
this.isDelete = isDelete;
}
/**
* 应用树层级 1:应用分组层 2:应用层
*/
public Short getTenantGroupLevel() {
public String getTenantGroupLevel() {
return tenantGroupLevel;
}
public void setTenantGroupLevel(String tenantGroupLevel) {
this.tenantGroupLevel = tenantGroupLevel;
}
/**
* 应用树层级 1:应用分组层 2:应用层
*/
public void setTenantGroupLevel(Short tenantGroupLevel) {
this.tenantGroupLevel = tenantGroupLevel;
}
@Override
public boolean equals(Object that) {
......
......@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
@Service
......@@ -69,13 +70,23 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String code = RandomStringUtils.getRandomString(6);
boolean flag = true;
ocpApiGroup.setObjId("");
ocpApiGroup.setApiGroupMtime(timestamp);
ocpApiGroup.setApiGroupCtime(timestamp);
ocpApiGroup.setApiGroupPcode(ocpApiGroup.getApiGroupCode());
ocpApiGroup.setApiGroupCode(code);
mapper.insert(ocpApiGroup);
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()));
if (!(apiGroupStream1.isParallel())){
OcpApiGroup ocpApi = new OcpApiGroup();
BeanUtils.copyProperties(ocpApiGroup,ocpApi);
ocpApi.setApiGroupPromotionType(ocpApiGroup.getApiGroupPromotionType());
ocpApi.setObjId("");
ocpApi.setApiGroupMtime(timestamp);
ocpApi.setApiGroupCtime(timestamp);
ocpApi.setApiGroupPcode(ocpApiGroup.getApiGroupCode());
ocpApi.setApiGroupCode(code);
mapper.insert(ocpApi);
ocpApiGroup.setApiGroupLevel(ocpApiGroup.getApiGroupLevel() + 1);
}else {
return false;
}
return flag;
}
......@@ -113,16 +124,15 @@ public class OcpApiTreeServiceImpl extends ServiceImpl<OcpApiTreeMapper,OcpApiGr
String objId = ocpApiGroup.getObjId();
OcpApiGroup ocpApiGroup1 = mapper.selectById(objId);
List<OcpApiGroup> ocpApiGroups = mapper.selectList(null);
if (StringUtils.isBlank(ocpApiGroup1.getApiGroupPcode())) {
for (OcpApiGroup apiGroup : ocpApiGroups) {
if ((ocpApiGroup1.getApiGroupCode()).equals(apiGroup.getApiGroupPcode())){
flag = false;
break;
}
}
}
if (flag){
mapper.deleteById(objId);
}
return flag;
}
......
......@@ -77,7 +77,9 @@ public class TenantServiceImpl extends ServiceImpl<TenantMapper, OcpTenantGroup>
group.setTenantGroupCtime(timestamp);
group.setTenantGroupMtime(timestamp);
group.setTenantGroupVersion("1.0");
group.setTenantGroupLevel((short) (tenanBaseDto.getTenantGroupLevel() + (short) 1));
int i = (Integer.parseInt(tenanBaseDto.getTenantGroupLevel()) + 1);
group.setTenantGroupLevel(String.valueOf(i));
for (OcpTenantGroup tenantGroup : ocpTenantGroups) {
if (tenantGroup.getTenantGroupCode().equals(tenantGroupCode)) {
......
......@@ -15,7 +15,7 @@
</select>
<!--服务树 -查询-->
<select id="selectLists" resultType="com.pms.ocp.model.entity.OcpApiGroup">
SELECT * FROM ocp_api_group WHERE api_group_promotion_type = #{apiGroupPromotionType} and api_group_pcode = #{apiGroupCode} and api_group_level = #{apiGroupLevel};
SELECT * FROM ocp_api_group WHERE api_group_promotion_type = #{apiGroupPromotionType} and api_group_pcode = #{apiGroupCode} and api_group_level == #{apiGroupLevel + 0};
</select>
......@@ -25,4 +25,10 @@
</select>
<!-- 根据code查询整条数据-->
<select id="selectCode" resultType="com.pms.ocp.model.entity.OcpApiGroup">
SELECT * FROM ocp_api_group where api_group_code = #{apiGroupCode};
</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