Commit 159ce7fe authored by zhaochengming's avatar zhaochengming

赵呈明 --服务应用

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