Commit e942669b authored by itcast's avatar itcast

服务库服务基础管理接口-修改版

parent 5b560a6b
...@@ -3,16 +3,15 @@ package com.pms.ocp.controller; ...@@ -3,16 +3,15 @@ package com.pms.ocp.controller;
import com.baomidou.mybatisplus.extension.api.R; 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.*;
import com.pms.ocp.model.entity.OcpApiGroup;
import com.pms.ocp.model.entity.OcpTenantBase;
import com.pms.ocp.model.entity.OcpTenantGroup; import com.pms.ocp.model.entity.OcpTenantGroup;
import com.pms.ocp.model.vo.Menu;
import com.pms.ocp.model.vo.OcpApiBaseVo;
import com.pms.ocp.model.vo.ResponseVO; import com.pms.ocp.model.vo.ResponseVO;
import com.pms.ocp.service.TenantBasicManagementService; import com.pms.ocp.service.TenantBasicManagementService;
import com.pms.ocp.service.TenantService; import com.pms.ocp.service.TenantService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
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.apache.commons.lang3.StringUtils;
...@@ -33,7 +32,6 @@ public class TenantBasicManagementController { ...@@ -33,7 +32,6 @@ public class TenantBasicManagementController {
@Autowired @Autowired
private TenantService tenantService; private TenantService tenantService;
@ApiOperation("条件查询") @ApiOperation("条件查询")
@GetMapping("/queryOcpTenantBaseDto") @GetMapping("/queryOcpTenantBaseDto")
public ResponseVO<List<OcpTenantBaseDto>> queryOcpTenantBaseDto( public ResponseVO<List<OcpTenantBaseDto>> queryOcpTenantBaseDto(
...@@ -47,13 +45,12 @@ public class TenantBasicManagementController { ...@@ -47,13 +45,12 @@ public class TenantBasicManagementController {
@RequestParam(required = false) Integer pageNum @RequestParam(required = false) Integer pageNum
) { ) {
List<OcpTenantBaseDto> ocpTenantBaseDto = tenantBasicManagementService.queryOcpTenantBaseDto(tenantGroupCode, tenantCode, keyword, tenantUnit, startTime, endTime, pageSize, pageNum);
List<OcpTenantBaseDto> ocpTenantBaseDto = tenantBasicManagementService.queryOcpTenantBaseDto(tenantGroupCode,tenantCode, keyword, tenantUnit, startTime, endTime, pageSize, pageNum);
return ResponseVO.ok(ocpTenantBaseDto); return ResponseVO.ok(ocpTenantBaseDto);
} }
@ApiOperation("应用发布") @ApiOperation("应用发布")
@PostMapping("/issue") @GetMapping("/issue")
public ResponseVO TenantIssue( public ResponseVO TenantIssue(
@RequestParam(required = false) String tenantCodes) { @RequestParam(required = false) String tenantCodes) {
...@@ -61,7 +58,7 @@ public class TenantBasicManagementController { ...@@ -61,7 +58,7 @@ public class TenantBasicManagementController {
} }
@ApiOperation("应用订阅") @ApiOperation("应用订阅")
@PostMapping("/login") @GetMapping("/login")
public ResponseVO TenantLogin( public ResponseVO TenantLogin(
@RequestParam(required = false) String tenantCodes, @RequestParam(required = false) String tenantCodes,
@RequestParam(required = false) String companyCode) { @RequestParam(required = false) String companyCode) {
...@@ -71,7 +68,7 @@ public class TenantBasicManagementController { ...@@ -71,7 +68,7 @@ public class TenantBasicManagementController {
} }
@ApiOperation("应用下线") @ApiOperation("应用下线")
@PostMapping("/cancel") @GetMapping("/cancel")
public ResponseVO TenantCancel( public ResponseVO TenantCancel(
@RequestParam(required = false) String tenantCodes) { @RequestParam(required = false) String tenantCodes) {
return tenantBasicManagementService.tenantCancel(tenantCodes); return tenantBasicManagementService.tenantCancel(tenantCodes);
...@@ -92,14 +89,24 @@ public class TenantBasicManagementController { ...@@ -92,14 +89,24 @@ public class TenantBasicManagementController {
return ResponseVO.ok(ocpApiGroups); return ResponseVO.ok(ocpApiGroups);
} }
@ApiOperation("应用树底层")
@GetMapping("/tenantBaseTree")
public ResponseVO<List<OcpTenantBase>> tenantBaseTree(@RequestParam(required = false) String tenantGroupCode,
@RequestParam(required = false) String tenantGroupCompanyCode) {
List<OcpTenantBase> ocpTenantBases = tenantBasicManagementService.tenantBaseTree(tenantGroupCode, tenantGroupCompanyCode);
return ResponseVO.ok(ocpTenantBases);
}
@ApiOperation("应用列表") @ApiOperation("应用列表")
@GetMapping("/tenantListQuery") @GetMapping("/tenantListQuery")
public ResponseVO<PageInfo<OcpTenantBaseDto>> tenantListQuery(HttpServletRequest request, TenantDto tenantDto) { public ResponseVO<PageInfo<OcpTenantBaseDto>> tenantListQuery(HttpServletRequest request, TenantDto tenantDto) {
return tenantBasicManagementService.getBaseByGroupCode(tenantDto); return tenantBasicManagementService.getBaseByGroupCode(tenantDto);
} }
@ApiOperation("注册查询信息")
@GetMapping("/select/register")
public ResponseVO<OcpTenantGroup> selectRegister(@RequestParam(required = false) String tenantGroupCode,
@RequestParam(required = false) String tenantGroupCompanyCode){
OcpTenantGroup ocpTenantGroup= tenantBasicManagementService.selectRegister(tenantGroupCode,tenantGroupCompanyCode);
return ResponseVO.ok(ocpTenantGroup);
}
} }
...@@ -18,5 +18,5 @@ public interface OcpTenantGroupMapper extends BaseMapper<OcpTenantGroup> { ...@@ -18,5 +18,5 @@ public interface OcpTenantGroupMapper extends BaseMapper<OcpTenantGroup> {
List<OcpTenantBaseDto> selectPageLists(TenantDto tenantDto); List<OcpTenantBaseDto> selectPageLists(TenantDto tenantDto);
OcpTenantGroup selectRegister(@Param("tenantGroupCode") String tenantGroupCode, @Param("tenantGroupCompanyCode") String tenantGroupCompanyCode);
} }
...@@ -24,6 +24,9 @@ public class TenantDto implements Serializable { ...@@ -24,6 +24,9 @@ public class TenantDto implements Serializable {
@ApiModelProperty("应用分类编码") @ApiModelProperty("应用分类编码")
private String tenantGroupCode; private String tenantGroupCode;
@ApiModelProperty("应用分类名称")
private String tenantGroupName;
@ApiModelProperty("应用分类公司") @ApiModelProperty("应用分类公司")
private String tenantGroupCompanyCode; private String tenantGroupCompanyCode;
...@@ -53,7 +56,7 @@ public class TenantDto implements Serializable { ...@@ -53,7 +56,7 @@ public class TenantDto implements Serializable {
private String keyword; private String keyword;
@ApiModelProperty("当前页") @ApiModelProperty("当前页")
private Integer pageNum; private Integer currentPage;
@ApiModelProperty("每页条数") @ApiModelProperty("每页条数")
private Integer pageSize; private Integer pageSize;
...@@ -139,13 +142,13 @@ public class TenantDto implements Serializable { ...@@ -139,13 +142,13 @@ public class TenantDto implements Serializable {
this.keyword = keyword; this.keyword = keyword;
} }
public Integer getPageNum() { // public Integer getPageNum() {
return pageNum; // return pageNum;
} // }
//
public void setPageNum(Integer pageNum) { // public void setPageNum(Integer pageNum) {
this.pageNum = pageNum; // this.pageNum = pageNum;
} // }
public Integer getPageSize() { public Integer getPageSize() {
return pageSize; return pageSize;
...@@ -154,4 +157,12 @@ public class TenantDto implements Serializable { ...@@ -154,4 +157,12 @@ public class TenantDto implements Serializable {
public void setPageSize(Integer pageSize) { public void setPageSize(Integer pageSize) {
this.pageSize = pageSize; this.pageSize = pageSize;
} }
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
} }
...@@ -72,6 +72,21 @@ public interface TenantBasicManagementService extends IService<OcpTenantBase> { ...@@ -72,6 +72,21 @@ public interface TenantBasicManagementService extends IService<OcpTenantBase> {
/**
* 应用树底层
* @param tenantGroupCode
* @param tenantGroupCompanyCode
* @return
*/
List<OcpTenantBase> tenantBaseTree(String tenantGroupCode, String tenantGroupCompanyCode);
/**
* 应用注册查询
* @param tenantGroupCode
* @param tenantGroupCompanyCode
* @return
*/
OcpTenantGroup selectRegister(String tenantGroupCode, String tenantGroupCompanyCode);
/** /**
* 应用树 * 应用树
......
...@@ -60,12 +60,12 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -60,12 +60,12 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
* @return * @return
*/ */
@Override @Override
public List<OcpTenantBaseDto> queryOcpTenantBaseDto(String tenantGroupCode,String tenantCode, String keyword, String tenantUnit, Timestamp startTime, Timestamp endTime, Integer pageSize, Integer pageNum) { public List<OcpTenantBaseDto> queryOcpTenantBaseDto(String tenantGroupCode, String tenantCode, String keyword, String tenantUnit, Timestamp startTime, Timestamp endTime, Integer pageSize, Integer pageNum) {
// if (pageSize == 0 || pageNum == 0) { // if (pageSize == 0 || pageNum == 0) {
// ResponseVO.error("分页参数不能为空"); // ResponseVO.error("分页参数不能为空");
// } // }
pageSize = (pageSize - 1) * pageNum; pageSize = (pageSize - 1) * pageNum;
return tenantBasicManagementMapper.queryOcpTenantBaseDto(tenantGroupCode,keyword, tenantUnit, startTime, endTime, tenantCode, pageSize, pageNum); return tenantBasicManagementMapper.queryOcpTenantBaseDto(tenantGroupCode, keyword, tenantUnit, startTime, endTime, tenantCode, pageSize, pageNum);
} }
/** /**
...@@ -77,7 +77,7 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -77,7 +77,7 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
@Override @Override
public ResponseVO tenantIssue(String tenantCodes) { public ResponseVO tenantIssue(String tenantCodes) {
if (StringUtils.isEmpty(tenantCodes)) { if (StringUtils.isEmpty(tenantCodes)) {
return ResponseVO.error("请选择要下线的应用"); return ResponseVO.error("请选择要发布的应用");
} }
String[] split = tenantCodes.split(","); String[] split = tenantCodes.split(",");
List<String> list = Arrays.asList(split); List<String> list = Arrays.asList(split);
...@@ -103,11 +103,11 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -103,11 +103,11 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
@Override @Override
public ResponseVO tenantLogin(String tenantCodes, String companyCode) { public ResponseVO tenantLogin(String tenantCodes, String companyCode) {
if (StringUtils.isEmpty(tenantCodes)) { if (StringUtils.isEmpty(tenantCodes)) {
return ResponseVO.error("请选择要下线的应用"); return ResponseVO.error("请选择要订阅的应用");
}
if (StringUtils.isEmpty(companyCode)) {
return ResponseVO.error("公司编码为空");
} }
// if (StringUtils.isEmpty(companyCode)) {
// return ResponseVO.error("公司编码为空");
// }
String[] split = tenantCodes.split(","); String[] split = tenantCodes.split(",");
List<String> tenantCode = Arrays.asList(split); List<String> tenantCode = Arrays.asList(split);
for (String s : tenantCode) { for (String s : tenantCode) {
...@@ -143,9 +143,13 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -143,9 +143,13 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
for (OcpTenantExtent ocpTenantExtent : ocpTenantExtents) { for (OcpTenantExtent ocpTenantExtent : ocpTenantExtents) {
// if (ocpTenantExtent == null) { // if (ocpTenantExtent == null) {
// return ResponseVO.error("未知错误"); // return ResponseVO.error("未知错误");
// } //
if (ocpTenantExtent.getTenantState() == 2) {
return ResponseVO.error("已下线"); if (ocpTenantExtent.getTenantState() == null) {
return ResponseVO.error("系统错误,状态为空");
} else if (ocpTenantExtent.getTenantState() == 2) {
return ResponseVO.error("有一个应用已下线,请勿重复下线");
} else { } else {
ocpTenantExtent.setTenantState((short) 2); ocpTenantExtent.setTenantState((short) 2);
ocpTenantExtentMapper.updateById(ocpTenantExtent); ocpTenantExtentMapper.updateById(ocpTenantExtent);
...@@ -231,12 +235,12 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -231,12 +235,12 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
*/ */
@Override @Override
public ResponseVO<PageInfo<OcpTenantBaseDto>> getBaseByGroupCode(TenantDto tenantDto) { public ResponseVO<PageInfo<OcpTenantBaseDto>> getBaseByGroupCode(TenantDto tenantDto) {
if (tenantDto.getPageNum() == null || tenantDto.getPageSize() == null) { if (tenantDto.getCurrentPage() == null || tenantDto.getPageSize() == null) {
return ResponseVO.error("分页参数不能为空"); return ResponseVO.error("分页参数不能为空");
} }
tenantGroup.add(tenantDto.getTenantGroupCode()); tenantGroup.add(tenantDto.getTenantGroupCode());
setGroupIdValue(tenantDto.getTenantGroupCompanyCode(), tenantDto.getTenantGroupCode()); setGroupIdValue(tenantDto.getTenantGroupCompanyCode(), tenantDto.getTenantGroupCode());
PageHelper.startPage(tenantDto.getPageNum(), tenantDto.getPageSize()); PageHelper.startPage(tenantDto.getCurrentPage(), tenantDto.getPageSize());
tenantDto.setApiGroupCodeList(tenantGroup); tenantDto.setApiGroupCodeList(tenantGroup);
List<OcpTenantBaseDto> ocpTenantBaseDto = ocpTenantGroupMapper.selectPageLists(tenantDto); List<OcpTenantBaseDto> ocpTenantBaseDto = ocpTenantGroupMapper.selectPageLists(tenantDto);
tenantGroup.clear(); tenantGroup.clear();
...@@ -246,14 +250,41 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -246,14 +250,41 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
} }
/** /**
* 应用树2 * 应用树底层
* *
* @param tenantGroupCode * @param tenantGroupCode
* @param tenantGroupCompanyCode
* @return * @return
*/ */
@Override
public List<OcpTenantBase> tenantBaseTree(String tenantGroupCode, String tenantGroupCompanyCode) {
LambdaQueryWrapper<OcpTenantBase> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OcpTenantBase::getOwnerCompanyCode, tenantGroupCompanyCode);
lambdaQueryWrapper.eq(OcpTenantBase::getTenantCode, tenantGroupCode);
List<OcpTenantBase> ocpTenantBases = tenantBasicManagementMapper.selectList(lambdaQueryWrapper);
return ocpTenantBases;
}
/**
* 应用注册查询
*
* @param tenantGroupCode
* @param tenantGroupCompanyCode
* @return
*/
@Override
public OcpTenantGroup selectRegister(String tenantGroupCode, String tenantGroupCompanyCode) {
OcpTenantGroup ocpTenantGroup = ocpTenantGroupMapper.selectRegister(tenantGroupCode, tenantGroupCompanyCode);
return ocpTenantGroup;
}
/**
* 应用树2
*
* @param tenantGroupCode
* @return
*/
public void setGroupIdValue(String tenantGroupCompanyCode, String tenantGroupCode) { public void setGroupIdValue(String tenantGroupCompanyCode, String tenantGroupCode) {
List<String> codes = getIdsByPIdPub(tenantGroupCompanyCode, tenantGroupCode); List<String> codes = getIdsByPIdPub(tenantGroupCompanyCode, tenantGroupCode);
...@@ -268,7 +299,7 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan ...@@ -268,7 +299,7 @@ public class TenantBasicManagementServiceImpl extends ServiceImpl<TenantBasicMan
} }
public List<String> getIdsByPIdPub(String tenantGroupCompanyCode, String tenantGroupCode) { public List<String> getIdsByPIdPub(String tenantGroupCompanyCode, String tenantGroupCode) {
List<GroupDto> ocpTenantGroups = ocpTenantGroupMapper.tenantBaseTreeOther(tenantGroupCompanyCode, tenantGroupCode); List<GroupDto> ocpTenantGroups = ocpTenantGroupMapper.tenantBaseTreeOther(tenantGroupCode, tenantGroupCompanyCode);
return ocpTenantGroups.stream().map(OcpTenantGroup::getTenantGroupCode).collect(Collectors.toList()); return ocpTenantGroups.stream().map(OcpTenantGroup::getTenantGroupCode).collect(Collectors.toList());
} }
......
...@@ -3,36 +3,34 @@ ...@@ -3,36 +3,34 @@
<mapper namespace="com.pms.ocp.mapper.OcpTenantGroupMapper"> <mapper namespace="com.pms.ocp.mapper.OcpTenantGroupMapper">
<resultMap id="ctbMap" type="com.pms.ocp.model.dto.OcpTenantBaseDto"> <resultMap id="ctbMap" type="com.pms.ocp.model.dto.OcpTenantBaseDto">
<result property="objId" column="obj_id"/> <result property="objId" column="obj_id"/>
<result property="tenantCode" column="api_code"/> <result property="tenantCode" column="tenant_code"/>
<result property="tenantName" column="api_name"/> <result property="tenantName" column="tenant_name"/>
<result property="tenantGroupName" column="cluster_name"/> <result property="tenantGroupName" column="tenant_group_name"/>
<result property="tenantUrl" column="space_name"/> <result property="tenantUrl" column="tenant_url"/>
<result property="clusterName" column="api_unit"/> <result property="clusterName" column="cluster_name"/>
<result property="spaceName" column="api_ctime"/> <result property="spaceName" column="space_name"/>
<result property="deploymentName" column="api_state"/> <result property="deploymentName" column="deployment_name"/>
<result property="tenantZone" column="api_url"/> <result property="tenantZone" column="tenant_zone"/>
<result property="tenantCtime" column="api_code"/> <result property="tenantCtime" column="tenant_ctime"/>
<result property="tenantUnit" column="api_code"/> <result property="tenantUnit" column="tenant_unit"/>
</resultMap> </resultMap>
<select id="tenantBaseTreeOther" resultType="com.pms.ocp.model.dto.GroupDto"> <select id="tenantBaseTreeOther" resultType="com.pms.ocp.model.dto.GroupDto">
select otb.tenant_name,otb.tenant_code, select
otg.tenant_group_code,otg.tenant_group_name,otg.tenant_group_pcode ,otg.tenant_group_level from ocp_tenant_group tenant_group_code,tenant_group_name,tenant_group_pcode ,tenant_group_level from ocp_tenant_group
otg
left join ocp_tenant_base otb on otg.tenant_group_code=otb.tenant_group_code -- LEFT join ocp_tenant_base otb on otg.tenant_group_code=otb.tenant_group_code
where otg.is_delete = 0 where is_delete = 0
<if test="tenantGroupCode == null"> <if test="tenantGroupCode == null">
and otg.tenant_group_pcode = '' and tenant_group_pcode = ''
</if> </if>
<if test="tenantGroupCompanyCode !=null and tenantGroupCompanyCode!=''"> <if test="tenantGroupCompanyCode !=null and tenantGroupCompanyCode !=''">
and otg.tenant_group_company_code=#{tenantGroupCompanyCode} and tenant_group_company_code=#{tenantGroupCompanyCode}
</if> </if>
<if test="tenantGroupCode !=null and tenantGroupCode!=''"> <if test="tenantGroupCode !=null and tenantGroupCode!=''">
and otg.tenant_group_pcode=#{tenantGroupCode} and tenant_group_pcode=#{tenantGroupCode}
</if> </if>
</select> </select>
...@@ -45,7 +43,7 @@ ...@@ -45,7 +43,7 @@
join ocp_tenant_group otg on otb.tenant_group_code =otg.tenant_group_code join ocp_tenant_group otg on otb.tenant_group_code =otg.tenant_group_code
WHERE otg.is_delete=0 WHERE otg.is_delete=0
<if test="apiGroupCodeList !=null "> <if test="apiGroupCodeList !=null ">
and otb.tenant_code in and otb.tenant_group_code in
<foreach item="tenantGroupCode" collection="apiGroupCodeList" open="(" separator="," <foreach item="tenantGroupCode" collection="apiGroupCodeList" open="(" separator=","
close=")"> close=")">
#{tenantGroupCode} #{tenantGroupCode}
...@@ -54,9 +52,7 @@ ...@@ -54,9 +52,7 @@
<if test="tenantUnit !=null and tenantUnit!=''"> <if test="tenantUnit !=null and tenantUnit!=''">
and otb.tenant_unit = #{apiUnit} and otb.tenant_unit = #{apiUnit}
</if> </if>
<!-- <if test="tenantCode !=null and tenantCode!=''">-->
<!-- and otb.tenant_code = #{tenantCode}-->
<!-- </if>-->
<!-- <if test="tenantGroupCode !=null and tenantGroupCode!=''">--> <!-- <if test="tenantGroupCode !=null and tenantGroupCode!=''">-->
<!-- and otb.tenant_group_code = #{tenantGroupCode}--> <!-- and otb.tenant_group_code = #{tenantGroupCode}-->
<!-- </if>--> <!-- </if>-->
...@@ -78,5 +74,16 @@ ...@@ -78,5 +74,16 @@
and otb.tenant_code like CONCAT('%', #{keyword}::text,'%') and otb.tenant_code like CONCAT('%', #{keyword}::text,'%')
</if> </if>
</select> </select>
<select id="selectRegister" resultType="com.pms.ocp.model.entity.OcpTenantGroup">
select * from ocp_tenant_group where is_delete = 0
<if test="tenantGroupCode !=null and tenantGroupCode!=''">
and tenant_group_code=#{tenantGroupCode}
</if>
<if test="tenantGroupCompanyCode !=null and tenantGroupCompanyCode !=''">
and tenant_group_company_code=#{tenantGroupCompanyCode}
</if>
</select>
</mapper> </mapper>
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