diff --git a/mcp b/mcp new file mode 160000 index 0000000000000000000000000000000000000000..2181e0521bc55700d3c2a3a7b4f29ac5c13bdf97 --- /dev/null +++ b/mcp @@ -0,0 +1 @@ +Subproject commit 2181e0521bc55700d3c2a3a7b4f29ac5c13bdf97 diff --git a/mcp-cloud-core/pom.xml b/mcp-cloud-core/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..60a1cf2ced401f8ec2f32f1568b563e4e678915b --- /dev/null +++ b/mcp-cloud-core/pom.xml @@ -0,0 +1,56 @@ + + + + mcp + com.hnkylin + 1.0-SNAPSHOT + + 4.0.0 + + mcp-cloud-core + + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.3.0 + + + org.projectlombok + lombok + + + com.auth0 + java-jwt + 3.7.0 + + + org.apache.commons + commons-lang3 + 3.7 + + + + org.apache.commons + commons-pool2 + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + org.apache.httpcomponents + httpclient + 4.5.6 + + + + + + \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/FieldCheck.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/FieldCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..eb00425b55bd91efaf42b0ea6af61386d26e254b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/FieldCheck.java @@ -0,0 +1,102 @@ +package com.hnkylin.cloud.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.PARAMETER, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface FieldCheck { + + /** + * 参数校验错误默认返回的信息 + * + * @return + */ + public String defaultMessage() default ""; + + /** + * 不允许为空 + * + * @return + */ + public boolean notNull() default false; + + /** + * 为空时返回信息 + * + * @return + */ + public String notNullMessage() default ""; + + /** + * 只允许数字 + * + * @return + */ + public boolean numeric() default false; + + /** + * 只允许数字错误信息 + * + * @return + */ + public String numericMessage() default ""; + + /** + * 只对字符串、List起效,最小长度 + * + * @return + */ + public int minLen() default -1; + + /** + * 只对字符串、List起效,最大长度 + * + * @return + */ + public int maxLen() default -1; + + /** + * maxLen的错误信息 + * + * @return + */ + public String minLenMessage() default ""; + + /** + * maxLen的错误信息 + * + * @return + */ + public String maxLenMessage() default ""; + + /** + * 最小数字 + * + * @return + */ + public double minNum() default -999999999; + + /** + * 最大数字 + * + * @return + */ + public double maxNum() default -999999999; + + /** + * minNum错误信息 + * + * @return + */ + public String minNumMessage() default ""; + + /** + * maxNum错误信息 + * + * @return + */ + public String maxNumMessage() default ""; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ListCheck.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ListCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..1117ee186725222d3631b69d07fe2e28d1b336f5 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ListCheck.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.PARAMETER, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ListCheck { + + public boolean notNull() default false; + + public String notNullMessage() default ""; + + public int minLen() default -1; + + public String minLenMessage() default ""; + + public int maxLen() default -1; + + public String maxLenMessage() default ""; + + public String defaultMessage() default ""; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/LoginUser.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/LoginUser.java new file mode 100644 index 0000000000000000000000000000000000000000..74288d121385317aa53e9d8e1d76d4a0ca2b9f93 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/LoginUser.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Target({ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface LoginUser { + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ModelCheck.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ModelCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..5af5703c4d3bc5a5eb57c34d45bac684dafc85bb --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ModelCheck.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ModelCheck { + public boolean notNull() default false; + + public String notNullMessage() default ""; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ParamCheck.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ParamCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..95b59f5213af9387669ce00776b2947802b48c6d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/annotation/ParamCheck.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.core.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface ParamCheck { + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/aop/LogAop.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/aop/LogAop.java new file mode 100644 index 0000000000000000000000000000000000000000..94a227456b243a61031b433bc0d9586276cfd436 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/aop/LogAop.java @@ -0,0 +1,65 @@ +/** + * Copyright © 2018 com.yishouapp All rights reserved. + * + * @Package: com.yishou.pss.api.aop + * @author: wanglei + * @date: 2018年5月24日 上午11:28:59 + */ +package com.hnkylin.cloud.core.aop; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ArrayUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + + +@Aspect +@Component +@Slf4j +public class LogAop { + + @Autowired + private ObjectMapper objectMapper; + + + @Pointcut("execution(* com.hnkylin.cloud.*.ctrl..*(..))") + public void webLog() { + } + + private static final String LOG = "url:{} ,params: {}"; + + + @Before("webLog()") + public void doBefore(JoinPoint joinPoint) throws Throwable { + // 开始打印请求日志 + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest request = attributes.getRequest(); + Object[] args = joinPoint.getArgs(); + //过滤后序列化无异常 + log.info(LOG, request.getRequestURI(), ArrayUtils.toString(args)); + } + + + @Around("webLog()") + public Object doAroud(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + long startTime = System.currentTimeMillis(); + Object result = proceedingJoinPoint.proceed(); + //打印出参 + log.info("Response Args : {},Time-Consuming:{}", objectMapper.writeValueAsString(result), + System.currentTimeMillis() - startTime); + + return result; + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/aop/ParamAOP.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/aop/ParamAOP.java new file mode 100644 index 0000000000000000000000000000000000000000..298c22c224bfe4322bb703cb554fda18dcbf5fc7 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/aop/ParamAOP.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.core.aop; + +import com.hnkylin.cloud.core.config.ParamterCheckCompent; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Aspect +public class ParamAOP { + + @Autowired + private ParamterCheckCompent paramterCheckComp; + + @Pointcut("@annotation(com.hnkylin.cloud.core.annotation.ParamCheck)") + public void check() { + + } + + @Around(value = "check()") + public Object doBefore(JoinPoint joinPoint) throws Throwable { + Object object = null; + // 参数校验,未抛出异常表示验证OK + paramterCheckComp.checkAnnoValid(joinPoint.getSignature().getName(), joinPoint.getTarget(), + joinPoint.getArgs()); + object = ((ProceedingJoinPoint) joinPoint).proceed(); + return object; + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisCache.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisCache.java new file mode 100644 index 0000000000000000000000000000000000000000..d354cf4f2fb12edaabe3ea8bf64f674160829cb8 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisCache.java @@ -0,0 +1,216 @@ +package com.ruoyi.common.core.redis; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.BoundSetOperations; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Component; + +/** + * spring redis 工具类 + * + * @author ruoyi + **/ +@SuppressWarnings(value = {"unchecked", "rawtypes"}) +@Component +public class RedisCache { + @Autowired + public RedisTemplate redisTemplate; + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + */ + public void setCacheObject(final String key, final T value) { + redisTemplate.opsForValue().set(key, value); + } + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + * @param timeout 时间 + * @param timeUnit 时间颗粒度 + */ + public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { + redisTemplate.opsForValue().set(key, value, timeout, timeUnit); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout) { + return expire(key, timeout, TimeUnit.SECONDS); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @param unit 时间单位 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout, final TimeUnit unit) { + return redisTemplate.expire(key, timeout, unit); + } + + /** + * 获得缓存的基本对象。 + * + * @param key 缓存键值 + * @return 缓存键值对应的数据 + */ + public T getCacheObject(final String key) { + ValueOperations operation = redisTemplate.opsForValue(); + return operation.get(key); + } + + /** + * 删除单个对象 + * + * @param key + */ + public boolean deleteObject(final String key) { + return redisTemplate.delete(key); + } + + /** + * 删除集合对象 + * + * @param collection 多个对象 + * @return + */ + public long deleteObject(final Collection collection) { + return redisTemplate.delete(collection); + } + + /** + * 缓存List数据 + * + * @param key 缓存的键值 + * @param dataList 待缓存的List数据 + * @return 缓存的对象 + */ + public long setCacheList(final String key, final List dataList) { + Long count = redisTemplate.opsForList().rightPushAll(key, dataList); + return count == null ? 0 : count; + } + + /** + * 获得缓存的list对象 + * + * @param key 缓存的键值 + * @return 缓存键值对应的数据 + */ + public List getCacheList(final String key) { + return redisTemplate.opsForList().range(key, 0, -1); + } + + /** + * 缓存Set + * + * @param key 缓存键值 + * @param dataSet 缓存的数据 + * @return 缓存数据的对象 + */ + public BoundSetOperations setCacheSet(final String key, final Set dataSet) { + BoundSetOperations setOperation = redisTemplate.boundSetOps(key); + Iterator it = dataSet.iterator(); + while (it.hasNext()) { + setOperation.add(it.next()); + } + return setOperation; + } + + /** + * 获得缓存的set + * + * @param key + * @return + */ + public Set getCacheSet(final String key) { + return redisTemplate.opsForSet().members(key); + } + + /** + * 缓存Map + * + * @param key + * @param dataMap + */ + public void setCacheMap(final String key, final Map dataMap) { + if (dataMap != null) { + redisTemplate.opsForHash().putAll(key, dataMap); + } + } + + /** + * 获得缓存的Map + * + * @param key + * @return + */ + public Map getCacheMap(final String key) { + return redisTemplate.opsForHash().entries(key); + } + + /** + * 往Hash中存入数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @param value 值 + */ + public void setCacheMapValue(final String key, final String hKey, final T value) { + redisTemplate.opsForHash().put(key, hKey, value); + } + + /** + * 获取Hash中的数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return Hash中的对象 + */ + public T getCacheMapValue(final String key, final String hKey) { + HashOperations opsForHash = redisTemplate.opsForHash(); + return opsForHash.get(key, hKey); + } + + /** + * 获取多个Hash中的数据 + * + * @param key Redis键 + * @param hKeys Hash键集合 + * @return Hash对象集合 + */ + public List getMultiCacheMapValue(final String key, final Collection hKeys) { + return redisTemplate.opsForHash().multiGet(key, hKeys); + } + + /** + * 获得缓存的基本对象列表 + * + * @param pattern 字符串前缀 + * @return 对象列表 + */ + public Collection keys(final String pattern) { + return redisTemplate.keys(pattern); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisConstant.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..31269432e61c3c780154de593b2b7e5bb5264ba0 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisConstant.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.cache; + +public interface RedisConstant { + + + String UID = "uid:"; + + long SELF_SERVICE_LOGIN_USER_CACHE_EXPIRE = 2 * 60 * 60 * 1000; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisService.java new file mode 100644 index 0000000000000000000000000000000000000000..083b3d1f33fed78171160e46d7edb2bc46c38246 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisService.java @@ -0,0 +1,334 @@ +package com.hnkylin.cloud.core.cache; + +import org.springframework.data.redis.connection.RedisZSetCommands.Limit; +import org.springframework.data.redis.connection.RedisZSetCommands.Range; +import org.springframework.data.redis.core.Cursor; +import org.springframework.data.redis.core.RedisOperations; +import org.springframework.data.redis.core.ScanOptions; +import org.springframework.data.redis.core.ZSetOperations.TypedTuple; +import org.springframework.data.redis.core.script.RedisScript; +import org.springframework.lang.Nullable; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public interface RedisService { + + + void expirTime(String key, long timeout, TimeUnit unit); + + // ---------------value ops------------- + void vSet(String key, Object value); + + void vSet(String key, Object value, long timeout, TimeUnit unit); + + @Nullable + Boolean vSetIfAbsent(String key, Object value); + + void vMultiSet(Map map); + + @Nullable + Boolean vMultiSetIfAbsent(Map map); + + @Nullable + Object vGet(String key); + + @Nullable + Boolean vDelete(String key); + + @Nullable + Object vGetAndSet(String key, Object value); + + @Nullable + List vMultiGet(Collection keys); + + @Nullable + Long vIncrement(String key, long delta); + + @Nullable + Double vIncrement(String key, double delta); + + @Nullable + Integer vAppend(String key, String value); + + @Nullable + String vGet(String key, long start, long end); + + void vSet(String key, Object value, long offset); + + @Nullable + Long vSize(String key); + + @Nullable + Boolean vSetBit(String key, long offset, boolean value); + + @Nullable + Boolean vGetBit(String key, long offset); + + RedisOperations getOperations(); + + Object executeLuaScript(RedisScript redisScript, List keys, Object... argvs); + + // ----------------Set ops---------------------- + @Nullable + Long sAdd(String key, Object... values); + + @Nullable + Long sRemove(String key, Object... values); + + @Nullable + Object sPop(String key); + + @Nullable + List sPop(String key, long count); + + @Nullable + Boolean sMove(String key, Object value, String destKey); + + @Nullable + Long sSize(String key); + + @Nullable + Boolean sIsMember(String key, Object o); + + @Nullable + Set sIntersect(String key, String otherKey); + + @Nullable + Set sIntersect(String key, Collection otherKeys); + + @Nullable + Long sIntersectAndStore(String key, String otherKey, String destKey); + + @Nullable + Long sIntersectAndStore(String key, Collection otherKeys, String destKey); + + @Nullable + Set sUnion(String key, String otherKey); + + @Nullable + Set sUnion(String key, Collection otherKeys); + + @Nullable + Long sUnionAndStore(String key, String otherKey, String destKey); + + @Nullable + Long sUnionAndStore(String key, Collection otherKeys, String destKey); + + @Nullable + Set sDifference(String key, String otherKey); + + @Nullable + Set sDifference(String key, Collection otherKeys); + + @Nullable + Long sDifferenceAndStore(String key, String otherKey, String destKey); + + @Nullable + Long sDifferenceAndStore(String key, Collection otherKeys, String destKey); + + @Nullable + Set sMembers(String key); + + Object sRandomMember(String key); + + @Nullable + Set sDistinctRandomMembers(String key, long count); + + @Nullable + List sRandomMembers(String key, long count); + + Cursor sScan(String key, ScanOptions options); + + // ------------------------hash----------------------- + Long hDelete(String key, String... hashKeys); + + Boolean hHasKey(String key, String hashKey); + + @Nullable + Object hGet(String key, String hashKey); + + List hMultiGet(String key, Collection hashKeys); + + Long hIncrement(String key, String hashKey, long delta); + + Double hIncrement(String key, String hashKey, double delta); + + @Deprecated + Set hKeys(String key); + + Long hSize(String key); + + void hPutAll(String key, Map m); + + void hPut(String key, String hashKey, Object value); + + Boolean hPutIfAbsent(String key, String hashKey, Object value); + + List hValues(String key); + + Map hEntries(String key); + + Cursor> hScan(String key, ScanOptions options); + // ---------------------List ops----------------------- + + @Nullable + List lRange(String key, long start, long end); + + void lTrim(String key, long start, long end); + + @Nullable + Long lSize(String key); + + @Nullable + Long lLeftPush(String key, Object value); + + @Nullable + Long lLeftPushAll(String key, Object... values); + + @Nullable + Long lLeftPushAll(String key, Collection values); + + @Nullable + Long lLeftPushIfPresent(String key, Object value); + + @Nullable + Long lLeftPush(String key, Object pivot, Object value); + + @Nullable + Long lRightPush(String key, Object value); + + @Nullable + Long lRightPushAll(String key, Object... values); + + @Nullable + Long lRightPushAll(String key, Collection values); + + @Nullable + Long lRightPushIfPresent(String key, Object value); + + @Nullable + Long lRightPush(String key, Object pivot, Object value); + + void lSet(String key, long index, Object value); + + @Nullable + Long lRemove(String key, long count, Object value); + + @Nullable + Object lIndex(String key, long index); + + @Nullable + Object lLeftPop(String key); + + @Nullable + Object lLeftPop(String key, long timeout, TimeUnit unit); + + @Nullable + Object lRightPop(String key); + + @Nullable + Object lRightPop(String key, long timeout, TimeUnit unit); + + @Nullable + Object lRightPopAndLeftPush(String sourceKey, String destinationKey); + + @Nullable + Object lRightPopAndLeftPush(String sourceKey, String destinationKey, long timeout, TimeUnit unit); + + // ---------------------zset ops---------------------- + @Nullable + Boolean zAdd(String key, Object value, double score); + + @Nullable + Long zAdd(String key, Set> tuples); + + @Nullable + Long zRemove(String key, Object... values); + + @Nullable + Double zIncrementScore(String key, Object value, double delta); + + @Nullable + Long zRank(String key, Object o); + + @Nullable + Long zReverseRank(String key, Object o); + + @Nullable + Set zRange(String key, long start, long end); + + @Nullable + Set> zRangeWithScores(String key, long start, long end); + + @Nullable + Set zRangeByScore(String key, double min, double max); + + @Nullable + Set> zRangeByScoreWithScores(String key, double min, double max); + + @Nullable + Set zRangeByScore(String key, double min, double max, long offset, long count); + + @Nullable + Set> zRangeByScoreWithScores(String key, double min, double max, long offset, long count); + + @Nullable + Set zReverseRange(String key, long start, long end); + + @Nullable + Set> zReverseRangeWithScores(String key, long start, long end); + + @Nullable + Set zReverseRangeByScore(String key, double min, double max); + + @Nullable + Set> zReverseRangeByScoreWithScores(String key, double min, double max); + + @Nullable + Set zReverseRangeByScore(String key, double min, double max, long offset, long count); + + @Nullable + Set> zReverseRangeByScoreWithScores(String key, double min, double max, long offset, long count); + + @Nullable + Long zCount(String key, double min, double max); + + @Nullable + Long zSize(String key); + + @Nullable + Long zZCard(String key); + + @Nullable + Double zScore(String key, Object o); + + @Nullable + Long zRemoveRange(String key, long start, long end); + + @Nullable + Long zRemoveRangeByScore(String key, double min, double max); + + @Nullable + Long zUnionAndStore(String key, String otherKey, String destKey); + + @Nullable + Long zUnionAndStore(String key, Collection otherKeys, String destKey); + + @Nullable + Long zIntersectAndStore(String key, String otherKey, String destKey); + + @Nullable + Long zIntersectAndStore(String key, Collection otherKeys, String destKey); + + Cursor> zScan(String key, ScanOptions options); + + @Nullable + Set zRangeByLex(String key, Range range); + + @Nullable + Set zRangeByLex(String key, Range range, Limit limit); +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..30f55000dc5a23dd9896f33c7486b9d3148f0076 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/cache/RedisServiceImpl.java @@ -0,0 +1,541 @@ +package com.hnkylin.cloud.core.cache; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.connection.RedisZSetCommands.Limit; +import org.springframework.data.redis.connection.RedisZSetCommands.Range; +import org.springframework.data.redis.core.*; +import org.springframework.data.redis.core.ZSetOperations.TypedTuple; +import org.springframework.data.redis.core.script.RedisScript; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; + +public abstract class RedisServiceImpl { + /** + * key 前缀 + */ + protected String prefixKey; + + @Autowired + protected RedisTemplate redisTemplate; + @Resource(name = "redisTemplate") + protected ValueOperations valueOps; + @Resource(name = "redisTemplate") + protected SetOperations setOps; + @Resource(name = "redisTemplate") + protected HashOperations hashOps; + @Resource(name = "redisTemplate") + protected ListOperations listOps; + @Resource(name = "redisTemplate") + protected ZSetOperations zSetOps; + + @PostConstruct + public void init() { + this.prefixKey = initPrefixKey() + ":"; + } + + protected abstract String initPrefixKey(); + + protected String fixKey(String key) { + return this.prefixKey + key; + } + + protected List fixKeys(Collection otherKeys) { + List fkoks = null; + if (otherKeys != null) { + fkoks = new ArrayList(); + for (String ok : otherKeys) { + fkoks.add(fixKey(ok)); + } + } + return fkoks; + } + + public void expirTime(String key, long timeout, TimeUnit unit) { + valueOps.getOperations().expire(fixKey(key), timeout, unit); + } + + public void vSet(String key, Object value) { + valueOps.set(fixKey(key), value); + } + + public void vSet(String key, Object value, long timeout, TimeUnit unit) { + valueOps.set(fixKey(key), value, timeout, unit); + } + + public Boolean vSetIfAbsent(String key, Object value) { + return valueOps.setIfAbsent(fixKey(key), value); + } + + public void vMultiSet(Map map) { + if (map.isEmpty()) { + return; + } + Map rawKeys = new LinkedHashMap<>(map.size()); + for (Entry entry : map.entrySet()) { + rawKeys.put(fixKey(entry.getKey()), entry.getValue()); + } + valueOps.multiSet(rawKeys); + } + + public Boolean vMultiSetIfAbsent(Map map) { + if (map.isEmpty()) { + return true; + } + Map rawKeys = new LinkedHashMap<>(map.size()); + for (Entry entry : map.entrySet()) { + rawKeys.put(fixKey(entry.getKey()), entry.getValue()); + } + return valueOps.multiSetIfAbsent(rawKeys); + } + + public Object vGet(String key) { + return valueOps.get(fixKey(key)); + } + + public Boolean vDelete(String key) { + return getOperations().delete(fixKey(key)); + } + + + public Object executeLuaScript(RedisScript redisScript, List keys, Object... argvs) { + List newKyes = new ArrayList<>(keys.size()); + keys.forEach(key -> { + newKyes.add(fixKey(key)); + }); + + return valueOps.getOperations().execute(redisScript, newKyes, argvs); + } + + + public Object vGetAndSet(String key, Object value) { + return valueOps.getAndSet(fixKey(key), value); + } + + public List vMultiGet(Collection keys) { + if (keys.isEmpty()) { + return Collections.emptyList(); + } + return valueOps.multiGet(fixKeys(keys)); + } + + public Long vIncrement(String key, long delta) { + return valueOps.increment(fixKey(key), delta); + } + + public Double vIncrement(String key, double delta) { + return valueOps.increment(fixKey(key), delta); + } + + public Integer vAppend(String key, String value) { + return valueOps.append(fixKey(key), value); + } + + public String vGet(String key, long start, long end) { + return valueOps.get(fixKey(key), start, end); + } + + public void vSet(String key, Object value, long offset) { + valueOps.set(fixKey(key), value, offset); + } + + public Long vSize(String key) { + return valueOps.size(fixKey(key)); + } + + public Boolean vSetBit(String key, long offset, boolean value) { + return valueOps.setBit(fixKey(key), offset, value); + } + + public Boolean vGetBit(String key, long offset) { + return valueOps.getBit(fixKey(key), offset); + } + + public RedisOperations getOperations() { + return valueOps.getOperations(); + } + + public Long sAdd(String key, Object... values) { + return setOps.add(fixKey(key), values); + } + + public Long sRemove(String key, Object... values) { + return setOps.remove(fixKey(key), values); + } + + public Object sPop(String key) { + return setOps.pop(fixKey(key)); + } + + public List sPop(String key, long count) { + return setOps.pop(fixKey(key), count); + } + + public Boolean sMove(String key, Object value, String destKey) { + return setOps.move(fixKey(key), value, destKey); + } + + public Long sSize(String key) { + return setOps.size(fixKey(key)); + } + + public Boolean sIsMember(String key, Object o) { + return setOps.isMember(fixKey(key), o); + } + + public Set sIntersect(String key, String otherKey) { + return setOps.intersect(fixKey(otherKey), fixKey(otherKey)); + } + + public Set sIntersect(String key, Collection otherKeys) { + return setOps.intersect(fixKey(key), fixKeys(otherKeys)); + } + + public Long sIntersectAndStore(String key, String otherKey, String destKey) { + return setOps.intersectAndStore(fixKey(key), fixKey(otherKey), fixKey(destKey)); + } + + public Long sIntersectAndStore(String key, Collection otherKeys, String destKey) { + return setOps.intersectAndStore(fixKey(key), fixKeys(otherKeys), fixKey(destKey)); + } + + public Set sUnion(String key, String otherKey) { + return setOps.union(fixKey(key), fixKey(otherKey)); + } + + public Set sUnion(String key, Collection otherKeys) { + return setOps.union(fixKey(key), fixKeys(otherKeys)); + } + + public Long sUnionAndStore(String key, String otherKey, String destKey) { + return setOps.unionAndStore(fixKey(key), fixKey(otherKey), fixKey(destKey)); + } + + public Long sUnionAndStore(String key, Collection otherKeys, String destKey) { + return setOps.unionAndStore(fixKey(key), fixKeys(otherKeys), fixKey(destKey)); + } + + public Set sDifference(String key, String otherKey) { + return setOps.difference(fixKey(key), fixKey(otherKey)); + } + + public Set sDifference(String key, Collection otherKeys) { + return setOps.difference(fixKey(key), fixKeys(otherKeys)); + } + + public Long sDifferenceAndStore(String key, String otherKey, String destKey) { + return setOps.differenceAndStore(fixKey(key), fixKey(otherKey), fixKey(destKey)); + } + + public Long sDifferenceAndStore(String key, Collection otherKeys, String destKey) { + return setOps.differenceAndStore(fixKey(key), fixKeys(otherKeys), destKey); + } + + public Set sMembers(String key) { + return setOps.members(fixKey(key)); + } + + public Object sRandomMember(String key) { + return setOps.randomMember(fixKey(key)); + } + + public Set sDistinctRandomMembers(String key, long count) { + return setOps.distinctRandomMembers(fixKey(key), count); + } + + public List sRandomMembers(String key, long count) { + return setOps.randomMembers(fixKey(key), count); + } + + public Cursor sScan(String key, ScanOptions options) { + return setOps.scan(fixKey(key), options); + } + + public Long hDelete(String key, String... hashKeys) { + String[] hks = null; + if (hashKeys != null && hashKeys.length > 0) { + hks = new String[hashKeys.length]; + for (int i = 0; i < hashKeys.length; i++) { + hks[i] = fixKey(hashKeys[i]); + } + } + return hashOps.delete(fixKey(key), hks); + } + + public Boolean hHasKey(String key, String hashKey) { + return hashOps.hasKey(fixKey(key), fixKey(hashKey)); + } + + public Object hGet(String key, String hashKey) { + return hashOps.get(fixKey(key), fixKey(hashKey)); + } + + public List hMultiGet(String key, Collection hashKeys) { + return hashOps.multiGet(fixKey(key), fixKeys(hashKeys)); + } + + public Long hIncrement(String key, String hashKey, long delta) { + return hashOps.increment(fixKey(key), fixKey(hashKey), delta); + } + + public Double hIncrement(String key, String hashKey, double delta) { + return hashOps.increment(fixKey(key), fixKey(hashKey), delta); + } + + public Set hKeys(String key) { + return hashOps.keys(fixKey(key)); + } + + public Long hSize(String key) { + return hashOps.size(fixKey(key)); + } + + public void hPutAll(String key, Map map) { + if (map.isEmpty()) { + return; + } + Map rawKeys = new LinkedHashMap<>(map.size()); + for (Entry entry : map.entrySet()) { + rawKeys.put(fixKey(entry.getKey()), entry.getValue()); + } + hashOps.putAll(fixKey(key), rawKeys); + } + + public void hPut(String key, String hashKey, Object value) { + hashOps.put(fixKey(key), fixKey(hashKey), value); + } + + public Boolean hPutIfAbsent(String key, String hashKey, Object value) { + return hashOps.putIfAbsent(fixKey(key), fixKey(hashKey), value); + } + + public List hValues(String key) { + return hashOps.values(fixKey(key)); + } + + public Map hEntries(String key) { + return hashOps.entries(fixKey(key)); + } + + public Cursor> hScan(String key, ScanOptions options) { + return hashOps.scan(fixKey(key), options); + } + + public List lRange(String key, long start, long end) { + return listOps.range(fixKey(key), start, end); + } + + public void lTrim(String key, long start, long end) { + listOps.trim(fixKey(key), start, end); + } + + public Long lSize(String key) { + return listOps.size(fixKey(key)); + } + + public Long lLeftPush(String key, Object value) { + return listOps.leftPush(fixKey(key), value); + } + + public Long lLeftPushAll(String key, Object... values) { + return listOps.leftPushAll(fixKey(key), values); + } + + public Long lLeftPushAll(String key, Collection values) { + return listOps.leftPushAll(fixKey(key), values); + } + + public Long lLeftPushIfPresent(String key, Object value) { + return listOps.leftPushIfPresent(fixKey(key), value); + } + + public Long lLeftPush(String key, Object pivot, Object value) { + return listOps.leftPush(fixKey(key), pivot, value); + } + + public Long lRightPush(String key, Object value) { + return listOps.rightPush(fixKey(key), value); + } + + public Long lRightPushAll(String key, Object... values) { + return listOps.rightPushAll(fixKey(key), values); + } + + public Long lRightPushAll(String key, Collection values) { + return listOps.rightPushAll(fixKey(key), values); + } + + public Long lRightPushIfPresent(String key, Object value) { + return listOps.rightPushIfPresent(fixKey(key), value); + } + + public Long lRightPush(String key, Object pivot, Object value) { + return listOps.rightPush(fixKey(key), pivot, value); + } + + public void lSet(String key, long index, Object value) { + listOps.set(fixKey(key), index, value); + } + + public Long lRemove(String key, long count, Object value) { + return listOps.remove(fixKey(key), count, value); + } + + public Object lIndex(String key, long index) { + return listOps.index(fixKey(key), index); + } + + public Object lLeftPop(String key) { + return listOps.leftPop(fixKey(key)); + } + + public Object lLeftPop(String key, long timeout, TimeUnit unit) { + return listOps.leftPop(fixKey(key), timeout, unit); + } + + public Object lRightPop(String key) { + return listOps.rightPop(fixKey(key)); + } + + public Object lRightPop(String key, long timeout, TimeUnit unit) { + return listOps.rightPop(fixKey(key), timeout, unit); + } + + public Object lRightPopAndLeftPush(String sourceKey, String destinationKey) { + return listOps.rightPopAndLeftPush(fixKey(sourceKey), fixKey(destinationKey)); + } + + public Object lRightPopAndLeftPush(String sourceKey, String destinationKey, long timeout, TimeUnit unit) { + return listOps.rightPopAndLeftPush(fixKey(sourceKey), fixKey(destinationKey), timeout, unit); + } + + public Boolean zAdd(String key, Object value, double score) { + return zSetOps.add(fixKey(key), value, score); + } + + public Long zAdd(String key, Set> tuples) { + return zSetOps.add(fixKey(key), tuples); + } + + public Long zRemove(String key, Object... values) { + return zSetOps.remove(fixKey(key), values); + } + + public Double zIncrementScore(String key, Object value, double delta) { + return zSetOps.incrementScore(fixKey(key), value, delta); + } + + public Long zRank(String key, Object o) { + return zSetOps.rank(fixKey(key), o); + } + + public Long zReverseRank(String key, Object o) { + return zSetOps.reverseRank(fixKey(key), o); + } + + public Set zRange(String key, long start, long end) { + return zSetOps.range(fixKey(key), start, end); + } + + public Set> zRangeWithScores(String key, long start, long end) { + return zSetOps.rangeWithScores(fixKey(key), start, end); + } + + public Set zRangeByScore(String key, double min, double max) { + return zSetOps.rangeByScore(fixKey(key), min, max); + } + + public Set> zRangeByScoreWithScores(String key, double min, double max) { + return zSetOps.rangeByScoreWithScores(fixKey(key), min, max); + } + + public Set zRangeByScore(String key, double min, double max, long offset, long count) { + return zSetOps.rangeByScore(fixKey(key), min, max, offset, count); + } + + public Set> zRangeByScoreWithScores(String key, double min, double max, long offset, + long count) { + return zSetOps.rangeByScoreWithScores(fixKey(key), min, max, offset, count); + } + + public Set zReverseRange(String key, long start, long end) { + return zSetOps.reverseRange(fixKey(key), start, end); + } + + public Set> zReverseRangeWithScores(String key, long start, long end) { + return zSetOps.reverseRangeWithScores(fixKey(key), start, end); + } + + public Set zReverseRangeByScore(String key, double min, double max) { + return zSetOps.reverseRangeByScore(fixKey(key), min, max); + } + + public Set> zReverseRangeByScoreWithScores(String key, double min, double max) { + return zSetOps.reverseRangeByScoreWithScores(fixKey(key), min, max); + } + + public Set zReverseRangeByScore(String key, double min, double max, long offset, long count) { + return zSetOps.reverseRangeByScore(fixKey(key), min, max, offset, count); + } + + public Set> zReverseRangeByScoreWithScores(String key, double min, double max, long offset, + long count) { + return zSetOps.reverseRangeByScoreWithScores(fixKey(key), min, max, offset, count); + } + + public Long zCount(String key, double min, double max) { + return zSetOps.count(fixKey(key), min, max); + } + + public Long zSize(String key) { + return zSetOps.size(fixKey(key)); + } + + public Long zZCard(String key) { + return zSetOps.zCard(fixKey(key)); + } + + public Double zScore(String key, Object o) { + return zSetOps.score(fixKey(key), o); + } + + public Long zRemoveRange(String key, long start, long end) { + return zSetOps.removeRange(fixKey(key), start, end); + } + + public Long zRemoveRangeByScore(String key, double min, double max) { + return zSetOps.removeRangeByScore(fixKey(key), min, max); + } + + public Long zUnionAndStore(String key, String otherKey, String destKey) { + return zSetOps.unionAndStore(fixKey(key), fixKey(otherKey), fixKey(destKey)); + } + + public Long zUnionAndStore(String key, Collection otherKeys, String destKey) { + return zSetOps.unionAndStore(fixKey(key), fixKeys(otherKeys), fixKey(destKey)); + } + + public Long zIntersectAndStore(String key, String otherKey, String destKey) { + return zSetOps.unionAndStore(fixKey(key), fixKey(otherKey), fixKey(destKey)); + } + + public Long zIntersectAndStore(String key, Collection otherKeys, String destKey) { + return zSetOps.intersectAndStore(fixKey(key), fixKeys(otherKeys), fixKey(destKey)); + } + + public Cursor> zScan(String key, ScanOptions options) { + return zSetOps.scan(fixKey(key), options); + } + + public Set zRangeByLex(String key, Range range) { + return zSetOps.rangeByLex(fixKey(key), range); + } + + public Set zRangeByLex(String key, Range range, Limit limit) { + return zSetOps.rangeByLex(fixKey(key), range, limit); + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/AESUtil.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/AESUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..88c9aea4388508ffe5af3ea51f3d9079b419c712 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/AESUtil.java @@ -0,0 +1,66 @@ +package com.hnkylin.cloud.core.common; + +import org.apache.commons.codec.binary.Hex; + +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; + +public class AESUtil { + private static Cipher AES_CIPHER; + private static SecretKey AES_KEY; + + static { + try { + AES_CIPHER = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE"); + AES_KEY = new SecretKeySpec("ksksvdd's secret".getBytes("UTF-8"), "AES"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String obfuscateHex(byte[] data) throws Exception { + AES_CIPHER.init(Cipher.ENCRYPT_MODE, AES_KEY); + byte[] cipherText = AES_CIPHER.doFinal(data); + return new Hex().encodeHexString(cipherText); + } + + public static byte[] revealHex(String codedText) throws Exception { + byte[] encypted = new Hex().decode(codedText.getBytes("UTF-8")); + AES_CIPHER.init(Cipher.DECRYPT_MODE, AES_KEY); + byte[] decrypted = AES_CIPHER.doFinal(encypted); + return decrypted; + } + + /** + * 加密 + * + * @param plainText + * @return + * @throws Exception + */ + public static String obfuscate(String plainText) throws Exception { + AES_CIPHER.init(Cipher.ENCRYPT_MODE, AES_KEY); + byte[] cipherText = AES_CIPHER.doFinal(plainText.getBytes("UTF-8")); + return new Hex().encodeHexString(cipherText); + } + + /** + * 解密 + * + * @param codedText + * @return + * @throws Exception + */ + public static String reveal(String codedText) throws Exception { + byte[] encypted = new Hex().decode(codedText.getBytes("UTF-8")); + AES_CIPHER.init(Cipher.DECRYPT_MODE, AES_KEY); + byte[] decrypted = AES_CIPHER.doFinal(encypted); + return new String(decrypted); + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/BasePageParam.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/BasePageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..216b936fc0bf971496328a6071f41992f41d4762 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/BasePageParam.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.core.common; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BasePageParam { + @FieldCheck(minNum = 1, minNumMessage = "分页数不能小于1") + private Integer pageNo; + + @FieldCheck(minNum = 1, minNumMessage = "每页显示数量不能小于1") + private Integer pageSize; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/BaseResult.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/BaseResult.java new file mode 100644 index 0000000000000000000000000000000000000000..1b0262a4bf65aaa07060cf00745854f5cef9936a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/BaseResult.java @@ -0,0 +1,59 @@ +package com.hnkylin.cloud.core.common; + +import lombok.Data; + +@Data +public class BaseResult { + + /** + * 请求结果编码 + */ + private int code; + /** + * 请求结果描述 + */ + private String desc; + /** + * 请求结果数据 + */ + private T data; + + public BaseResult() { + + } + + public BaseResult(int code, String desc, T data) { + this.code = code; + this.desc = desc; + this.data = data; + } + + public static BaseResult success(T data) { + return new BaseResult(R.SUCCESS, R.CodeEnum.SUCCESS.getDesc(), data); + } + + public static BaseResult success(T data, String desc) { + return new BaseResult(R.SUCCESS, desc, data); + } + + + public static BaseResult paramError(String desc) { + return new BaseResult(R.PARAM_ERROR, desc, null); + } + + + public static BaseResult error(String desc) { + return new BaseResult(R.SERVER_ERROR, desc, null); + } + + + public static BaseResult tokenExpire(String desc) { + return new BaseResult(R.TOKEN_EXPIRE, desc, null); + } + + public static BaseResult customSuccess(String desc, T data) { + return new BaseResult(R.SUCCESS, desc, data); + } + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/DateUtils.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/DateUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..4f86a936d733fa35adf92e1dbaad6143665d8e2d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/DateUtils.java @@ -0,0 +1,226 @@ +package com.hnkylin.cloud.core.common; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Calendar; +import java.util.Date; +import java.util.Objects; + +/** + * 日期处理 + */ +public class DateUtils { + + /** + * 时间格式(yyyy-MM-dd) + */ + public final static String DATE_YYYY_MM_DD = "yyyy-MM-dd"; + + /** + * 时间格式(yyyy-MM-dd HH:mm:ss) + */ + public final static String DATE_ALL_PATTEN = "yyyy-MM-dd HH:mm:ss"; + + /** + * 时间格式(yyyy-MM-dd HH:mm:ss) + */ + public final static String DATE_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm"; + + /** + * 时间格式(HH:mm:ss) + */ + public final static String DATE_TIME_PATTERN_HOUR = "HH:mm:ss"; + + /** + * 时间格式(yyyyMMddHHmmss) + */ + public final static String DATE_YYYYMMddHHmmss = "yyyyMMddHHmmss"; + + /** + * 时间格式(yyyyMMdd) + */ + public final static String DATE_YYYYMMdd = "yyyyMMdd"; + + /** + * 时间格式(yyyyMM) + */ + public final static String DATE_YYYYMM = "yyyyMM"; + /** + * 时间格式(yyyy-MM) + */ + public final static String DATE_YYYY_MM = "yyyy-MM"; + /** + * 时间格式(yyyy年M月) + */ + public final static String DATE_YYYY_M = "yyyy年M月"; + + + public final static String DAY_END = " 23:59:59"; + + + public final static String DAY_START = " 00:00:00"; + + public static String format(Date date) { + return format(date, DATE_YYYY_MM_DD); + } + + public static Date strFormatDate(String date) { + SimpleDateFormat df = new SimpleDateFormat(DATE_ALL_PATTEN); + try { + return df.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return new Date(); + } + + public static String format(Date date, String pattern) { + if (date != null) { + SimpleDateFormat df = new SimpleDateFormat(pattern); + return df.format(date); + } + return null; + } + + public static String formatYYYYMMDD(Date date) { + return format(date, DATE_YYYYMMdd); + } + + + /** + * 计算几个月后的时间 + */ + + public static Date getMonthAfter(Date initialDate, int afterMonth) { + initialDate = Objects.isNull(initialDate) ? new Date() : initialDate; + LocalDateTime localDateTime = initialDate.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDateTime().plusMonths(afterMonth); + Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + return date; + } + + + /** + * 计算时间的最后一秒 2021-6-25 12:01:00 得到 2021-6-25 23:59:59 + */ + public static Date getDayEndTime(Date date) { + + return parse(format(date, DateUtils.DATE_YYYY_MM_DD) + DAY_END, DATE_ALL_PATTEN); + + } + + /** + * 通过时间秒毫秒数判断两个时间的间隔。天 + * + * @param date1 + * @param date2 + * @return + */ + public static int differentDaysByMillisecond(Date date1, Date date2) { + Date startDate = parse(format(date1, DATE_YYYY_MM_DD), DATE_YYYY_MM_DD); + Date endDate = parse(format(date2, DATE_YYYY_MM_DD), DATE_YYYY_MM_DD); + Calendar cal = Calendar.getInstance(); + cal.setTime(startDate); + long time1 = cal.getTimeInMillis(); + cal.setTime(endDate); + long time2 = cal.getTimeInMillis(); + long between_days = (time2 - time1) / (1000 * 3600 * 24); + + return Integer.parseInt(String.valueOf(between_days)); + } + + /** + * 计算距离现在多久,精确 + * + * @param date + * @return + */ + public static String getTimeBeforeAccurate(Date date) { + Date now = new Date(); + long l = now.getTime() - date.getTime(); + long day = l / (24 * 60 * 60 * 1000); + long hour = (l / (60 * 60 * 1000) - day * 24); + long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60); + long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60); + String r = ""; + if (day > 0) { + r += day + "天"; + } + if (hour > 0) { + r += hour + "小时"; + } + if (min > 0) { + r += min + "分"; + } + if (s > 0) { + r += s + "秒"; + } + r += "前"; + return r; + } + + /** + * 两个时间的间隔秒 + * + * @param one 当前时间 + * @param other 旧的时间 + * @return + */ + public static int getBetweenTime(Date one, Date other) { + return (int) (Math.abs(one.getTime() - other.getTime()) / 1000); + } + + public static Date parse(String date, String pattern) { + if (date != null) { + SimpleDateFormat df = new SimpleDateFormat(pattern); + try { + return df.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + } + return null; + } + + public static Date getStartTime(String date) { + if (date != null) { + return parse(date + " 00:00:00", DATE_ALL_PATTEN); + } + return null; + } + + public static Date getEndTime(String date) { + if (date != null) { + return parse(date + " 23:59:59", DATE_ALL_PATTEN); + } + return null; + } + + + /** + * 生成时间戳 + */ + public static String getDateTime() { + DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + return sdf.format(new Date()); + } + + + public static void main(String[] args) { +// System.out.println(parse("2018-12-27 00:00:00", DATE_ALL_PATTEN).getTime()); +// System.out.println(parse("2018-12-27 23:59:59", DATE_ALL_PATTEN).getTime()); +// System.out.println(format(secondToDate(1543852800000L),DATE_ALL_PATTEN)); +// String day="2019-01-04"; +// System.out.println(day.substring(5)); + + + System.out.println(parse("2018-06-01 00:00:00", DATE_ALL_PATTEN).getTime()); + System.out.println(parse("2018-12-31 23:59:59", DATE_ALL_PATTEN).getTime()); + System.out.printf(format(getMonthAfter(new Date(), 2), DATE_ALL_PATTEN)); + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/GenerateUtils.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/GenerateUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..a6813adf1398824030a6a7e164616b15a5c040d3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/GenerateUtils.java @@ -0,0 +1,73 @@ +package com.hnkylin.cloud.core.common; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Random; +import java.util.UUID; + +import com.hnkylin.cloud.core.config.exception.KylinException; +import lombok.extern.slf4j.Slf4j; + + +@Slf4j +public class GenerateUtils { + + private static final char[] hexCode = "0123456789abcdef".toCharArray(); + + public static String generateValue() { + return generateValue(UUID.randomUUID().toString()); + } + + public static String toHexString(byte[] data) { + if (data == null) { + return null; + } + StringBuilder r = new StringBuilder(data.length * 2); + byte[] arrayOfByte = data; + int j = data.length; + for (int i = 0; i < j; i++) { + byte b = arrayOfByte[i]; + r.append(hexCode[(b >> 4 & 0xF)]); + r.append(hexCode[(b & 0xF)]); + } + return r.toString(); + } + + public static String generateValue(String param) { + try { + MessageDigest algorithm; + algorithm = MessageDigest.getInstance("MD5"); + algorithm.reset(); + algorithm.update(param.getBytes()); + byte[] messageDigest = algorithm.digest(); + return toHexString(messageDigest); + + } catch (NoSuchAlgorithmException e) { + log.error(e.getMessage()); + throw new KylinException("失败"); + } + + } + + public static void main(String[] args) { + System.out.println(getRandomPwd(8)); + } + + + public static String getRandomPwd(int n) { + String val = ""; + Random random = new Random(); + for (int i = 0; i < n; i++) { + String str = random.nextInt(2) % 2 == 0 ? "num" : "char"; + if ("char".equalsIgnoreCase(str)) { // 产生字母 + int nextInt = random.nextInt(2) % 2 == 0 ? 65 : 97; + // System.out.println(nextInt + "!!!!"); 1,0,1,1,1,0,0 + val += (char) (nextInt + random.nextInt(26)); + } else if ("num".equalsIgnoreCase(str)) { // 产生数字 + val += String.valueOf(random.nextInt(10)); + } + } + return val; + } + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/HttpCode.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/HttpCode.java new file mode 100644 index 0000000000000000000000000000000000000000..683cfb8f07452ba80dead0b6610fe49c03727ed9 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/HttpCode.java @@ -0,0 +1,35 @@ +package com.hnkylin.cloud.core.common; + +public class HttpCode { + + public final static int SUCCESS = 200; + public final static int FAIL = 3000; + public final static int PARAM_ERROR = 4000; + public final static int AUTHORIZATION_ERROR = 4100; + public final static int TOKEN_EXPIRE = 401; + public final static int ACCESS_KEY_ERROR = 4200; + public final static int SERVER_ERROR = 5000; + + public static enum CodeEnum { + SUCCESS(200, "请求成功"), FAIL(3000, "请求失败"), PARAM_ERROR(4000, "参数错误"), AUTHORIZATION_ERROR(4100, "权限不足"), + TOKEN_EXPIRE(401, "Token过期"), ACCESS_KEY_ERROR(4200, "密钥错误"), SERVER_ERROR(5000, "服务器错误"), + ; + + private int code; + private String desc; + + CodeEnum(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return this.code; + } + + public String getDesc() { + return this.desc; + } + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/HttpUtil.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/HttpUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..58782d9558741b2521e1d2bcb5b326e1d4619424 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/HttpUtil.java @@ -0,0 +1,72 @@ +package com.hnkylin.cloud.core.common; + +import javax.net.ssl.*; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.security.SecureRandom; + +public class HttpUtil { + + //从mc下载图片,保存在本地中 + public static File downLoadMcServerVmLogo(String downLoadUrl, String localFile) { + File file = null; + try { + + TrustManager[] tm = {new MyX509TrustManager()};//1.生成trustmanager数组 + SSLContext ssl = SSLContext.getInstance("TLS"); //2.得到sslcontext实例。SSL TSL 是一种https使用的安全传输协议 + ssl.init(null, tm, new SecureRandom());//初始化sslcontext + SSLSocketFactory sslSocketFactory = ssl.getSocketFactory();//得到sslSocketFactory实例 + + // 统一资源 + URL url = new URL(downLoadUrl); + HostnameVerifier ignoreHostnameVerifier = new HostnameVerifier() { + public boolean verify(String s, SSLSession sslsession) { + System.out.println("WARNING: Hostname is not matched for cert."); + return true; + } + }; + // 连接类的父类,抽象类 + URLConnection urlConnection = url.openConnection(); + // http的连接类 + HttpsURLConnection httpsURLConnection = (HttpsURLConnection) urlConnection; + + httpsURLConnection.setHostnameVerifier(ignoreHostnameVerifier); + httpsURLConnection.setSSLSocketFactory(sslSocketFactory); + + // 设定请求的方法,默认是GET + httpsURLConnection.setRequestMethod("GET"); + // 设置字符编码 + httpsURLConnection.setRequestProperty("Charset", "UTF-8"); + // 打开到此 URL 引用的资源的通信链接(如果尚未建立这样的连接)。 + httpsURLConnection.connect(); + // 文件大小 + int fileLength = httpsURLConnection.getContentLength(); + URLConnection con = url.openConnection(); + BufferedInputStream bin = new BufferedInputStream(httpsURLConnection.getInputStream()); + file = new File(localFile); + if (!file.exists()) { + OutputStream out = new FileOutputStream(file); + int size = 0; + int len = 0; + byte[] buf = new byte[1024]; + while ((size = bin.read(buf)) != -1) { + len += size; + out.write(buf, 0, size); + } + out.flush(); + out.close(); + } + bin.close(); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + return file; + } + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/JwtUtil.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/JwtUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..6dd6980b4b28c0062c646d99db7d339f8278abe3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/JwtUtil.java @@ -0,0 +1,87 @@ +package com.hnkylin.cloud.core.common; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; + +import java.util.Date; + +/** + * JWT工具类 + **/ +public class JwtUtil { + + + public final static String USER_NAME = "userName"; + + public final static String USER_ID = "userId"; + + + /** + * 校验token是否正确 + * + * @param token 密钥 + * @param secret 用户的密码 + * @return 是否正确 + */ + public static boolean verify(String token, String username, String secret) { + try { + // 根据密码生成JWT效验器 + Algorithm algorithm = Algorithm.HMAC256(secret); + JWTVerifier verifier = JWT.require(algorithm).withClaim(USER_NAME, username).build(); + // 效验TOKEN + DecodedJWT jwt = verifier.verify(token); + return true; + } catch (Exception exception) { + return false; + } + } + + /** + * 获得token中的信息无需secret解密也能获得 + * + * @return token中包含的用户名 + */ + public static String getUsername(String token) { + try { + DecodedJWT jwt = JWT.decode(token); + return jwt.getClaim(USER_NAME).asString(); + } catch (Exception e) { + return null; + } + } + + /** + * 获得token中的信息无需secret解密也能获得 + * + * @return token中包含的用户id + */ + public static String getUserId(String token) { + try { + DecodedJWT jwt = JWT.decode(token); + return jwt.getClaim(USER_ID).asString(); + } catch (Exception e) { + return null; + } + } + + /** + * 生成签名 + * + * @param username 用户名 + * @param userId 用户id + * @param secret 用户的密码 + * @return 加密的token + */ + public static String sign(String username, String userId, String secret) { + Date date = new Date(System.currentTimeMillis() + KylinCommonConstants.TOKEN_EXPIRE_TIME); + Algorithm algorithm = Algorithm.HMAC256(secret); + return JWT.create().withClaim(USER_NAME, username).withClaim(USER_ID, userId). + withClaim("create_time", System.currentTimeMillis()).withExpiresAt(date) + .sign(algorithm); + + } + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/KcpCommonUtil.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/KcpCommonUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..e59c3368db203b402ec67478d3bf8d1e595c85cc --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/KcpCommonUtil.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.core.common; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.McArchitectureType; + +import java.util.Objects; + +public class KcpCommonUtil { + public static ArchitectureType changeToKcpArchitectureType(String plateformType) { + + if (Objects.equals(plateformType, McArchitectureType.X86_64.getName()) || Objects.equals(plateformType, + McArchitectureType.LOWER_86_64.getName())) { + return ArchitectureType.X86_64; + } + if (Objects.equals(plateformType, McArchitectureType.ARM.getName()) || Objects.equals(plateformType, + McArchitectureType.AARCH64.name()) || Objects.equals(plateformType, + McArchitectureType.AARCH64.getName())) { + return ArchitectureType.ARM64; + } + if (Objects.equals(plateformType, McArchitectureType.MIPS.getName())) { + return ArchitectureType.MIPS64; + } + if (Objects.equals(plateformType, McArchitectureType.sw_64.getName())) { + return ArchitectureType.SW64; + } + return ArchitectureType.X86_64; + } +} + diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/KylinCommonConstants.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/KylinCommonConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..c6b5d1baa4c6124e6f27066981794ce69bc020e9 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/KylinCommonConstants.java @@ -0,0 +1,49 @@ +package com.hnkylin.cloud.core.common; + + +public interface KylinCommonConstants { + + + long TOKEN_EXPIRE_TIME = 2 * 60 * 60 * 1000; + + + String MC_TOKEN_KEY = "ksvd_token_secret"; + + + /** + * 文件路径标识符 + */ + + String FILE_SEPARATOR = "/"; + + /** + * 时间分隔符 + */ + String DATE_SPLIT = " "; + + + /** + * 天开始时间 + */ + String DAY_START = " 00:00:00"; + + /** + * 天结束时间 + */ + String DAY_END = " 23:59:59"; + + + Integer TOP_PARENT_ID = 0; + + //初始页码 + int FIRST_PAGE = 1; + + int DEFAULT_MAX_SIZE = 10 * 10000; + + //集群主几点最大数 + int MAX_CLUSTER_MASTER_NODE_NUM = 1000; + + int MC_MASTER_PORT = 8443; + + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MCResponseData.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MCResponseData.java new file mode 100644 index 0000000000000000000000000000000000000000..b27d4bfb41c3ffa170bd877f61a60095e010d191 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MCResponseData.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.core.common; + +import lombok.Data; + +@Data +public class MCResponseData { + private String status; + /** + * 请求结果数据 + */ + private T data; + + private String msg; + + private String message; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MCServerVmConstants.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MCServerVmConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..2896ef0df4b6e7a57a0c589cd6ce31014f967497 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MCServerVmConstants.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.common; + + +public interface MCServerVmConstants { + + + String TEMPLATE_DETAIL_URL = "/getTemplateDetail"; + + + //获取模板列表接口 + String TIMESTAMP = "timeStamp"; + + String AUTH_TOKEN = "Auth-Token"; + + String USER_NAME = "userName"; + + String TOKEN_SECRET = "mcp@2023"; + + String SUCCESS = "success"; + + String ERROR = "error"; + + + // + String TEMPLATE_DETAIL_ERR = "获取模板信息错误"; + + + String OPERATE_ERR = "mc请求错误"; + + String MC_NODE_NOT_VISIT = "服务暂不可用,请联系管理员管理员"; + + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McPageInfo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McPageInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..7d4e6b727d183127fad52055a3145b2cdd0a286b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McPageInfo.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.core.common; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +@Data +public class McPageInfo { + + private Integer pager; + + //总页数 + private Integer total; + + //总记录数 + private Integer records; + + private Integer pageSize; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McPageResp.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McPageResp.java new file mode 100644 index 0000000000000000000000000000000000000000..8a2c9020ebf081818acee3efacce04ea674ab6f9 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McPageResp.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.core.common; + +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-7-16. + */ +@Data +public class McPageResp { + + private Integer pager; + + //总页数 + private Integer total; + + //总记录数 + private Integer records; + + private List rows; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McUtils.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..690443f82ba778001cc96976723fbae49ae5b13e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/McUtils.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.core.common; + +import org.springframework.http.HttpHeaders; + +public class McUtils { + + public static HttpHeaders createMcHeaders(String userName) { + Long current = System.currentTimeMillis(); + String authToken = SHAUtil.getSHA256(current + MCServerVmConstants.TOKEN_SECRET); + HttpHeaders headers = new HttpHeaders(); + headers.add(MCServerVmConstants.TIMESTAMP, current.toString()); + headers.add(MCServerVmConstants.USER_NAME, userName); + headers.add(MCServerVmConstants.AUTH_TOKEN, authToken); + //headers.add("Content-Type","application/x-www-form-urlencoded"); + return headers; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MyX509TrustManager.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MyX509TrustManager.java new file mode 100644 index 0000000000000000000000000000000000000000..d1deb6976c7c94eb9b57ab436af8f079f91d0869 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/MyX509TrustManager.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.core.common; + +import javax.net.ssl.X509TrustManager; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +public class MyX509TrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate certificates[], String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] ax509certificate, String s) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/PageData.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/PageData.java new file mode 100644 index 0000000000000000000000000000000000000000..6afa1527e2efbc92cd4ae9e6b033b07b44b001e6 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/PageData.java @@ -0,0 +1,64 @@ +package com.hnkylin.cloud.core.common; + +import com.github.pagehelper.PageInfo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + + +@Data +public class PageData { + + private List list; + + private PageDetail pageInfo; + + + public PageData(PageInfo data) { + + if (data != null) { + this.list = data.getList(); + } else { + this.list = new ArrayList(); + } + changePageInfo(data); + } + + public PageData(McPageInfo mcPageInfo, List data) { + + if (data != null) { + this.list = data; + } else { + this.list = null; + } + changeMcPageInfo(mcPageInfo); + } + + private void changePageInfo(PageInfo data) { + this.pageInfo = new PageDetail(); + if (data != null) { + pageInfo.setCurrentPage(data.getPageNum()); + pageInfo.setCurrentSize(data.getSize()); + pageInfo.setTotal(data.getTotal()); + pageInfo.setTotalPage(data.getPages()); + } else { + pageInfo.setCurrentPage(0); + pageInfo.setCurrentSize(0); + pageInfo.setTotal(0L); + pageInfo.setTotalPage(0); + } + } + + private void changeMcPageInfo(McPageInfo mcPageInfo) { + + this.pageInfo = new PageDetail(); + pageInfo.setCurrentPage(mcPageInfo.getPager()); + pageInfo.setCurrentSize(mcPageInfo.getPageSize()); + pageInfo.setTotal(mcPageInfo.getRecords()); + pageInfo.setTotalPage(mcPageInfo.getTotal()); + + + } + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/PageDetail.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/PageDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..436ce6aa48d2671b2823e6bff990aaf85b4d87fd --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/PageDetail.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.core.common; + +import lombok.Data; + +@Data +public class PageDetail { + + + private Integer currentPage; + + private Integer currentSize; + + private long total; + + private Integer totalPage; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/SHAUtil.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/SHAUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..d4a13bc585c42552d6c1c714d155116947b4b21e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/SHAUtil.java @@ -0,0 +1,50 @@ +package com.hnkylin.cloud.core.common; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class SHAUtil { + + /** + * 利用java原生的类实现SHA256加密 + * + * @param str 加密后的报文 + * @return + */ + public static String getSHA256(String str) { + MessageDigest messageDigest; + String encodestr = ""; + try { + messageDigest = MessageDigest.getInstance("SHA-256"); + messageDigest.update(str.getBytes("UTF-8")); + encodestr = byte2Hex(messageDigest.digest()); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return encodestr; + } + + /** + * 将byte转为16进制 + * + * @param bytes + * @return + */ + private static String byte2Hex(byte[] bytes) { + StringBuffer stringBuffer = new StringBuffer(); + String temp = null; + for (int i = 0; i < bytes.length; i++) { + temp = Integer.toHexString(bytes[i] & 0xFF); + if (temp.length() == 1) { + //1得到一位的进行补0操作 + stringBuffer.append("0"); + } + stringBuffer.append(temp); + } + return stringBuffer.toString(); + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmLogResp.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmLogResp.java new file mode 100644 index 0000000000000000000000000000000000000000..9861e7131329f48a766fa2852ee144b73041696c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmLogResp.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.core.common.servervm; + +import lombok.Data; + +/** + * 云服务器操作日志 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McServerVmLogResp { + + //操作 + private String action; + + //对象名称 + private String objName; + + //操作用户 + private String operUser; + + //原因 + private String reason; + + + //详情 + private String detail; + + //开始时间 + private String startTime; + + //结束时间 + private String finishTime; + + //状态 + private String status; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmMonitorDetailResp.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmMonitorDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..6fce5e682bd26f7028a25764edfe4a8db1a15a54 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmMonitorDetailResp.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.common.servervm; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 云服务器详情-健康信息 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McServerVmMonitorDetailResp { + + + private BigDecimal cpuUtil; + + private String dateShow; + + private Integer diskReadSpeed; + + private Integer diskWriteSpeed; + + private BigDecimal memUtil; + + private Integer netWorkInSpeed; + + private Integer netWorkOutSpeed; + + +} + diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmPageDetailResp.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmPageDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..e688465ecdd4474a574f091d83e95cb61327312d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/McServerVmPageDetailResp.java @@ -0,0 +1,69 @@ +package com.hnkylin.cloud.core.common.servervm; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.McServerVmTaskStatus; +import lombok.Data; + +/** + * 分页获取云服务器列表 + * Created by kylin-ksvd on 21-7-9. + */ +@Data +public class McServerVmPageDetailResp { + + + //云服务器id + private Integer id; + + //云服务器uuid + private String uuid; + + //云服务器名称 + private String aliasName; + + //云服务器状态 + private McServerVmStatus status; + + //云服务器任务状态 + private McServerVmTaskStatus taskStatus; + + private String architecture; + + //云服务器ip + private String ip; + + //操作系统 + private String os; + + //cpu数 + private Integer cpus; + + //内存大小 + private Integer memory; + + //磁盘大小 + private String disks; + + //cpu利用率 + private String cpuRate; + + //内存利用率 + private String memoryRate; + + //磁盘利用率 + private String diskRate; + + //创建时间 + private String createDate; + + //内存单位 + private String memoryUnit; + + //描述 + private String description; + + private String logo; + + private String logoName; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBaseParam.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBaseParam.java new file mode 100644 index 0000000000000000000000000000000000000000..60f05f78f7a6d65bc9406a97378fac40b3c995cf --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBaseParam.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.core.common.servervm; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class ServerVmBaseParam { + + + @FieldCheck(notNull = true, notNullMessage = "云服务器ID") + private String serverVmUuid; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBaseReq.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBaseReq.java new file mode 100644 index 0000000000000000000000000000000000000000..a688b3978ec0aaa6a2ef00739d936e19c388b4bf --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBaseReq.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.core.common.servervm; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-7-12. + */ +@Data +public class ServerVmBaseReq { + private String uuid; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBatchOperateParam.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBatchOperateParam.java new file mode 100644 index 0000000000000000000000000000000000000000..32ce9466f898c8e925f62aab676d4b9092d95de7 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBatchOperateParam.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.core.common.servervm; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +import java.util.List; + +@Data +public class ServerVmBatchOperateParam { + + + @FieldCheck(notNull = true, notNullMessage = "云服务uuid集合不能为空") + private List serverVmUuids; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBatchReq.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBatchReq.java new file mode 100644 index 0000000000000000000000000000000000000000..5bbd4faf0cf2c0fe9eb44b290fa36fce2cafacbb --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmBatchReq.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.core.common.servervm; + +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-7-12. + */ +@Data +public class ServerVmBatchReq { + private String uuid; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmListReq.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmListReq.java new file mode 100644 index 0000000000000000000000000000000000000000..f0cb7b4285dfaf29a0435fc5406a6b86c1e99c91 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmListReq.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.core.common.servervm; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +@Data +public class ServerVmListReq { + + private String vmName; + + private McServerVmStatus vmStatus; + + private Integer page; + + private Integer rows; + + private List uuidList; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmMonitorInfoRespDto.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmMonitorInfoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..1845ba1faf05bbc2fb2fe66e3a0de039a90fcc6b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/common/servervm/ServerVmMonitorInfoRespDto.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.core.common.servervm; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * Created by kylin-ksvd on 21-8-11. + */ +@Data +public class ServerVmMonitorInfoRespDto { + + private List timeList; + + private List cpuUsed; + + private List memUsed; + + private List diskReadSpeed; + + private List diskWriteSpeed; + + private List netWorkInSpeed; + + private List netWorkOutSpeed; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/CorsConfig.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/CorsConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..f9e47ef59a190a232d149b680389c0e516bf8fae --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/CorsConfig.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.core.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +@Configuration +public class CorsConfig { + private CorsConfiguration buildConfig() { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedOrigin("*"); // 允许任何域名使用 + corsConfiguration.addAllowedHeader("*"); // 允许任何头 + corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等) + return corsConfiguration; + } + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", buildConfig()); // 对接口配置跨域设置 + return new CorsFilter(source); + } + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinCloudCommonConfig.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinCloudCommonConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..db7e0aee246bfcbfc77caf9dcab70f080c5c2ab5 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinCloudCommonConfig.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.config; + + +import com.github.pagehelper.PageHelper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + + +@Configuration +public class KylinCloudCommonConfig { + + + @Bean + public PageHelper pageHelper() { + PageHelper pageHelper = new PageHelper(); + Properties properties = new Properties(); + properties.setProperty("helperDialect", "mysql"); + properties.setProperty("reasonable", "true"); + properties.setProperty("supportMethodsArguments", "true"); + properties.setProperty("params", "count=countSql"); + pageHelper.setProperties(properties); + return pageHelper; + } + + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinRedisConfig.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinRedisConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..3e242314457249087e59a36099c0de4b5b7ea056 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinRedisConfig.java @@ -0,0 +1,83 @@ +package com.hnkylin.cloud.core.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.*; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +@AutoConfigureAfter(RedisAutoConfiguration.class) +public class KylinRedisConfig { + + @Bean + public RedisTemplate redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(lettuceConnectionFactory); + redisTemplate.setDefaultSerializer(jackson2JsonRedisSerializer()); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); + + return redisTemplate; + } + + @Bean + public Jackson2JsonRedisSerializer jackson2JsonRedisSerializer() { + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer( + Object.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); + jackson2JsonRedisSerializer.setObjectMapper(om); + return jackson2JsonRedisSerializer; + } + + /** + * 实例化 HashOperations 对象,可以使用 Hash 类型操作 + */ + @Bean + public HashOperations hashOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForHash(); + } + + /** + * 实例化 ValueOperations 对象,可以使用 String 操作 + */ + @Bean + public ValueOperations valueOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForValue(); + } + + /** + * 实例化 ListOperations 对象,可以使用 List 操作 + * + * @return + */ + @Bean + public ListOperations listOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForList(); + } + + /** + * 实例化 SetOperations 对象,可以使用 Set 操作 + */ + @Bean + public SetOperations setOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForSet(); + } + + /** + * 实例化 ZSetOperations 对象,可以使用 ZSet 操作 + */ + @Bean + public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForZSet(); + } + +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinRestTemplateConfig.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinRestTemplateConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..6a3c0c7adc3dd691537410ecdd0ff9cdd0c2fd36 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/KylinRestTemplateConfig.java @@ -0,0 +1,74 @@ +package com.hnkylin.cloud.core.config; + + +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.impl.client.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.web.client.RestTemplate; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.ssl.TrustStrategy; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import javax.net.ssl.SSLContext; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + + +@Configuration +public class KylinRestTemplateConfig { + + @Bean + public ClientHttpRequestFactory simpleClientHttpRequestFactory() { + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setReadTimeout(50000);//单位为ms + factory.setConnectTimeout(5000);//单位为ms + return factory; + } + + + @Bean + public RestTemplate restTemplate(ClientHttpRequestFactory simpleClientHttpRequestFactory) { + RestTemplate restTemplate = new RestTemplate(simpleClientHttpRequestFactory); + // 支持中文编码 + restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(Charset.forName("UTF-8"))); + return restTemplate; + } + + @Bean + public RestTemplate httpsRestTemplate(HttpComponentsClientHttpRequestFactory generateHttpRequestFactory) { + RestTemplate restTemplate = new RestTemplate(generateHttpRequestFactory); + restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); + + return restTemplate; + } + + @Bean + public HttpComponentsClientHttpRequestFactory generateHttpRequestFactory() + throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { + TrustStrategy acceptingTrustStrategy = (x509Certificates, authType) -> true; + SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); + SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext, + new NoopHostnameVerifier()); + + HttpClientBuilder httpClientBuilder = HttpClients.custom(); + httpClientBuilder.setSSLSocketFactory(connectionSocketFactory); + httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false)); + HttpClient httpClient = httpClientBuilder.build(); + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); + factory.setHttpClient(httpClient); + factory.setReadTimeout(5000);//单位为ms + factory.setConnectTimeout(5000);//单位为ms + return factory; + } + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/ParamterCheckCompent.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/ParamterCheckCompent.java new file mode 100644 index 0000000000000000000000000000000000000000..474cdad61b436545ffaae084e46c7a26d7f1c82e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/ParamterCheckCompent.java @@ -0,0 +1,596 @@ +package com.hnkylin.cloud.core.config; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.annotation.ListCheck; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.config.exception.KylinParamException; +import org.aspectj.lang.ProceedingJoinPoint; +import org.springframework.core.LocalVariableTableParameterNameDiscoverer; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Component +public class ParamterCheckCompent { + LocalVariableTableParameterNameDiscoverer disc = new LocalVariableTableParameterNameDiscoverer(); + + /** + * 校验带注解的方法 + * + * @param methodName + * @param target + * @param args + * @throws KylinParamException + */ + public void checkAnnoValid(String methodName, Object target, Object[] args) throws KylinParamException { + String str = ""; + try { + Method method = getMethodByClassAndName(target.getClass(), methodName, args); + Annotation[][] annotations = method.getParameterAnnotations(); + String[] paramNames = disc.getParameterNames(method); + if (annotations != null) { + for (int i = 0; i < annotations.length; i++) { + Annotation[] anno = annotations[i]; + for (int j = 0; j < anno.length; j++) { + if (annotations[i][j].annotationType().equals(ModelCheck.class)) { + ModelCheck mcheck = (ModelCheck) annotations[i][j]; + str = checkModel(args[i], mcheck, paramNames[i]); + } else if (annotations[i][j].annotationType().equals(ListCheck.class)) {// List + ListCheck lcheck = (ListCheck) annotations[i][j]; + str = checkListParam(args[i], lcheck, paramNames[i]); + } else if (annotations[i][j].annotationType().equals(FieldCheck.class)) {// Field + FieldCheck fcheck = (FieldCheck) annotations[i][j]; + str = checkField(fcheck, args[i], paramNames[i]); + } + if (StringUtils.hasText(str)) { + throw new KylinParamException(str); + } + } + } + } + } catch (Throwable e) { +// System.out.println(e.getMessage()); + e.printStackTrace(); + throw new KylinParamException(str); + } + } + + public void checkValid(ProceedingJoinPoint joinPoint) throws KylinParamException { + // TODO Auto-generated method stub + Object[] args = null; + Method method = null; + Object target = null; + String methodName = null; + String str = ""; + try { + methodName = joinPoint.getSignature().getName(); + target = joinPoint.getTarget(); + args = joinPoint.getArgs(); // 方法的参数 + method = getMethodByClassAndName(target.getClass(), methodName, args); + Annotation[][] annotations = method.getParameterAnnotations(); + String[] paramNames = disc.getParameterNames(method); + if (annotations != null) { + for (int i = 0; i < annotations.length; i++) { + Annotation[] anno = annotations[i]; + for (int j = 0; j < anno.length; j++) { + if (annotations[i][j].annotationType().equals(ModelCheck.class)) { + ModelCheck mcheck = (ModelCheck) annotations[i][j]; + str = checkModel(args[i], mcheck, paramNames[i]); + } else if (annotations[i][j].annotationType().equals(ListCheck.class)) {// List + ListCheck lcheck = (ListCheck) annotations[i][j]; + str = checkListParam(args[i], lcheck, paramNames[i]); + } else if (annotations[i][j].annotationType().equals(FieldCheck.class)) {// Field + FieldCheck fcheck = (FieldCheck) annotations[i][j]; + str = checkField(fcheck, args[i], paramNames[i]); + } + if (StringUtils.hasText(str)) { + throw new KylinParamException(str); + } + } + } + } + } catch (Throwable e) { +// System.out.println(e.getMessage()); + throw new KylinParamException(str); + } + } + + @SuppressWarnings("unchecked") + private String checkField(FieldCheck check, Object arg, String paramNames) { + int length = 0; + if (arg == null) { + if (check.notNull()) { + return getNotNullMessage(paramNames, check); + } else if (check.numeric()) { + return getNumericMessage(paramNames, check); + } else if (check.minLen() > 0) { + return getMinLenMessage(paramNames, check); + } else if (check.maxLen() > 0) { + return getMaxLenMessage(paramNames, check); + } else if (check.minNum() != -999999999) { + return getMinNumMessage(paramNames, check, false); + } else if (check.maxNum() != -999999999) { + return getMaxNumMessage(paramNames, check, false); + } else { + return ""; + } + } + Class cls = arg.getClass(); + String clname = cls.getName(); +// System.out.println("field-class: " + cls.getName()); + boolean arraybl = false, strbl = false, intbl = false, longbl = false, doublebl = false, floatbl = false, + blbl = false; + // 判断是否为数字 + if (clname.equals("java.lang.Integer") || clname.equals("int")) { + intbl = true; + } else if (clname.equals("java.lang.Long") || clname.equals("long")) { + longbl = true; + } else if (clname.equals("java.lang.Double") || clname.equals("double")) { + doublebl = true; + } else if (clname.equals("java.lang.Float") || clname.equals("float")) { + floatbl = true; + } else if (clname.equals("java.lang.String")) {// 判断是否为字符串 + strbl = true; + } else if (clname.equals("java.util.ArrayList")) { + // 判断是否为List + arraybl = true; + } else if (clname.equals("java.util.Boolean")) {// 判断是否为Boolean + blbl = true; + } + + boolean numbl = intbl || longbl || floatbl || doublebl; + boolean lenbl = arraybl || strbl; + if (arg != null) { + if (strbl) + length = (String.valueOf(arg)).length(); + if (arraybl) + length = ((List) arg).size(); + } + + if (check.numeric() && arg != null) { + try { + new BigDecimal(String.valueOf(arg)); + } catch (Exception e) { + return getNumericMessage(paramNames, check); + } + } + if (lenbl) { + if (check.maxLen() > 0 && (length > check.maxLen())) { + return getMaxLenMessage(paramNames, check); + } + + if (check.minLen() > 0 && (length < check.minLen())) { + return getMinLenMessage(paramNames, check); + } + } + if (numbl) { + if (check.minNum() != -999999999) { + try { + boolean errbl = false; + if (longbl || intbl) { + long fieldValue = Long.parseLong(String.valueOf(arg)); + if (fieldValue < check.minNum()) { + errbl = true; + } + } + if (floatbl || doublebl) { + double fieldValue = Double.parseDouble(String.valueOf(arg)); + if (fieldValue < check.minNum()) { + errbl = true; + } + } + if (errbl) { + return getMinNumMessage(paramNames, check, false); + } + } catch (Exception e) { + return getMinNumMessage(paramNames, check, true); + } + } + + if (check.maxNum() != -999999999) { + try { + boolean errbl = false; + if (longbl || intbl) { + long fieldValue = Long.parseLong(String.valueOf(arg)); + if (fieldValue > check.maxNum()) { + errbl = true; + } + } else if (floatbl || doublebl) { + double fieldValue = Double.parseDouble(String.valueOf(arg)); + if (fieldValue > check.maxNum()) { + errbl = true; + } + } + if (errbl) { + return getMaxNumMessage(paramNames, check, false); + } + } catch (Exception e) { + return getMaxNumMessage(paramNames, check, true); + } + } + } + + // if(arraybl){ + // checkListParam(args, lcheck) + // } + return ""; + } + + /** + * 校验List入参 + * + * @param args + * @param lcheck + * @param paramNames + * @return + * @throws Exception + */ + private String checkListParam(Object args, ListCheck lcheck, String paramNames) throws Exception { + String retStr = ""; + if (args == null) { + if (lcheck.notNull()) { + if (lcheck.notNullMessage().equals("")) { + return paramNames + "不允许为空"; + } else { + return lcheck.defaultMessage(); + } + } else if (lcheck.maxLen() != -1) { + if (lcheck.defaultMessage().equals("")) { + return paramNames + "不允许为空"; + } else { + return lcheck.defaultMessage(); + } + } else if (lcheck.minLen() != -1) { + if (lcheck.minLenMessage().equals("")) { + return paramNames + "不允许为空"; + } else { + return lcheck.defaultMessage(); + } + } + } + if (args != null) { + String aclz = args.getClass().getName(); +// System.out.println("args-class: " + aclz); + if (aclz.equals("java.util.ArrayList")) { + @SuppressWarnings("unchecked") + List argList = (List) args; + int size = argList.size(); + if (lcheck.minLen() != -1) { + if (size < lcheck.minLen()) { + retStr = lcheck.minLenMessage(); + if (retStr.equals("")) { + retStr = lcheck.defaultMessage(); + } + if (retStr.equals("")) { + retStr = paramNames + "集合大小最小为" + lcheck.minLen(); + } + return retStr; + } + } + if (lcheck.maxLen() != -1) { + if (size > lcheck.maxLen()) { + retStr = lcheck.maxLenMessage(); + if (retStr.equals("")) { + retStr = lcheck.defaultMessage(); + } + if (retStr.equals("")) { + retStr = paramNames + "集合大小最大为" + lcheck.maxLen(); + } + return retStr; + } + } + // else + for (Object arg : argList) { + if (arg != null) { + retStr = checkModel(arg, null, ""); + } + if (!retStr.equals("")) { + break; + } + } + } + } + + return retStr; + } + + /** + * 校验参数 + * + * @param args + * @param mcheck + * @param paramNames + * @return + * @throws Exception + */ + private String checkModel(Object args, ModelCheck mcheck, String paramNames) throws Exception { + String retStr = ""; + if (args == null) { + if (mcheck.notNull()) { + if (mcheck.notNullMessage().equals("")) { + return paramNames + "不允许为空"; + } else { + return mcheck.notNullMessage(); + } + } + return ""; + } + Field[] field = getBeanFields(args);// 获取实体及父类的field + // args.getClass().getDeclaredFields();// 获取方法参数(实体)的field + for (int j = 0; j < field.length; j++) { + FieldCheck check = field[j].getAnnotation(FieldCheck.class);// 获取方法参数(实体)的field上的注解Check + if (check != null) { + retStr = validateFiled(check, field[j], args); + if (StringUtils.hasText(retStr)) { + return retStr; + } + } else { + ListCheck lcheck = field[j].getAnnotation(ListCheck.class); + if (lcheck != null) { + field[j].setAccessible(true); + retStr = checkListParam(field[j].get(args), lcheck, field[j].getName()); + if (StringUtils.hasText(retStr)) { + return retStr; + } + } + } + } + return retStr; + } + + public Field[] getBeanFields(Object obj) { + List fieldList = new ArrayList<>(); + Class tmp = obj.getClass(); + while (tmp != null && tmp instanceof Object) { + fieldList.addAll(Arrays.asList(tmp.getDeclaredFields())); + tmp = tmp.getSuperclass(); + } + return fieldList.toArray(new Field[fieldList.size()]); + } + + /** + * 校验参数规则 + * + * @param check + * @param field + * @param args + * @return + * @throws Exception + */ + public String validateFiled(FieldCheck check, Field field, Object args) throws Exception { + field.setAccessible(true); + // 获取field长度 + int length = 0; + Class cls = field.getType(); + String clname = cls.getName(); +// System.out.println("field-class: " + cls.getName()); + boolean arraybl = false, strbl = false, intbl = false, longbl = false, doublebl = false, floatbl = false, + blbl = false; + // 判断是否为数字 + if (clname.equals("java.lang.Integer") || clname.equals("int")) { + intbl = true; + } else if (clname.equals("java.lang.Long") || clname.equals("long")) { + longbl = true; + } else if (clname.equals("java.lang.Double") || clname.equals("double")) { + doublebl = true; + } else if (clname.equals("java.lang.Float") || clname.equals("float")) { + floatbl = true; + } else if (clname.equals("java.lang.String")) {// 判断是否为字符串 + strbl = true; + } else if (clname.equals("java.util.ArrayList")) { + // 判断是否为List + arraybl = true; + } else if (clname.equals("java.util.Boolean")) {// 判断是否为Boolean + blbl = true; + } + + boolean numbl = intbl || longbl || floatbl || doublebl; + boolean lenbl = arraybl || strbl; + if (field.get(args) != null) { + if (strbl) + length = (String.valueOf(field.get(args))).length(); + if (arraybl) + length = ((List) field.get(args)).size(); + } + if (check.notNull()) { + if (field.get(args) == null || "".equals(String.valueOf(field.get(args)))) { + return getNotNullMessage(field.getName(), check); + } + } + + if (check.numeric() && field.get(args) != null) { + try { + new BigDecimal(String.valueOf(field.get(args))); + } catch (Exception e) { + return getNumericMessage(field.getName(), check); + } + } + // spring mvc 默认会把null值设置成false,json非true | false 请求出错 + // 此处判定无用 + /* + * if (blbl) { try { Boolean.parseBoolean(String.valueOf(field.get(args))); } + * catch (Exception e) { if (check.defaultMessage().length() > 0) { return + * check.defaultMessage(); } else { return field.getName() + "必须为true或者false"; } + * } } + */ + if (lenbl) { + if (check.maxLen() > 0 && (length > check.maxLen())) { + return getMaxLenMessage(field.getName(), check); + } + + if (check.minLen() > 0 && (length < check.minLen())) { + return getMinLenMessage(field.getName(), check); + } + } + if (numbl) { + if (check.minNum() != -999999999) { + try { + boolean errbl = false; + if (longbl || intbl) { + long fieldValue = Long.parseLong(String.valueOf(field.get(args))); + if (fieldValue < check.minNum()) { + errbl = true; + } + } + if (floatbl || doublebl) { + double fieldValue = Double.parseDouble(String.valueOf(field.get(args))); + if (fieldValue < check.minNum()) { + errbl = true; + } + } + if (errbl) { + return getMinNumMessage(field.getName(), check, false); + } + } catch (Exception e) { + return getMinNumMessage(field.getName(), check, true); + } + } + + if (check.maxNum() != -999999999) { + try { + boolean errbl = false; + if (longbl || intbl) { + long fieldValue = Long.parseLong(String.valueOf(field.get(args))); + if (fieldValue > check.maxNum()) { + errbl = true; + } + } else if (floatbl || doublebl) { + double fieldValue = Double.parseDouble(String.valueOf(field.get(args))); + if (fieldValue > check.maxNum()) { + errbl = true; + } + } + if (errbl) { + return getMaxNumMessage(field.getName(), check, false); + } + } catch (Exception e) { + return getMaxNumMessage(field.getName(), check, true); + } + } + } + + // if(arraybl){ + // checkListParam(args, lcheck) + // } + return ""; + } + + private String getMaxNumMessage(String name, FieldCheck check, boolean err) { + if (check.maxNumMessage().length() > 0) { + return check.maxNumMessage(); + } + if (check.defaultMessage().length() > 0) { + return check.defaultMessage(); + } + if (!err) + return name + "必须不大于" + check.maxNum(); + else + return name + "必须为数值型,且不大于" + check.maxNum(); + } + + private String getMinNumMessage(String name, FieldCheck check, boolean err) { + if (check.minNumMessage().length() > 0) { + return check.minNumMessage(); + } + if (check.defaultMessage().length() > 0) { + return check.defaultMessage(); + } + if (!err) + return name + "必须不小于" + check.minNum(); + else + return name + "必须为数值型,且不小于" + check.minNum(); + } + + private String getMinLenMessage(String name, FieldCheck check) { + if (check.minLenMessage().length() > 0) { + return check.minLenMessage(); + } + if (check.defaultMessage().length() > 0) { + return check.defaultMessage(); + } + return name + "长度不能小于" + check.minLen(); + } + + private String getMaxLenMessage(String name, FieldCheck check) { + if (check.maxLenMessage().length() > 0) { + return check.maxLenMessage(); + } + if (check.defaultMessage().length() > 0) { + return check.defaultMessage(); + } + return name + "长度不能大于" + check.maxLen(); + } + + private String getNumericMessage(String name, FieldCheck check) { + if (check.numericMessage().length() > 0) { + return check.numericMessage(); + } + if (check.defaultMessage().length() > 0) { + return check.defaultMessage(); + } + return name + "必须为数值型"; + } + + private String getNotNullMessage(String fieldName, FieldCheck check) { + if (check.notNullMessage().length() > 0) { + return check.notNullMessage(); + } + if (check.defaultMessage().length() > 0) { + return check.defaultMessage(); + } + return fieldName + "不能为空"; + } + + /** + * 根据类和方法名得到方法 + * + * @param args + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public Method getMethodByClassAndName(Class c, String methodName, Object[] args) throws Exception { + boolean pbl = true; + if (args != null && args.length > 0) { + Class[] parameterTypes = new Class[args.length]; + if (args != null && args.length > 0) { + int i = 0; + for (Object obj : args) { + if (obj != null) { + Class clz = obj.getClass(); + if (clz.getName().equals("java.util.ArrayList")) { + clz = List.class; + } + parameterTypes[i++] = clz; + } else { + pbl = false; + break; + } + } + if (pbl) { + return c.getDeclaredMethod(methodName, parameterTypes); + } + } + } + + Method[] methods = c.getDeclaredMethods(); + for (Method method : methods) { + if (method.getName().equals(methodName)) { + if (args != null) { + if (method.getParameterCount() == args.length) { + return method; + } + } else { + return method; + } + } + } + return null; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinException.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinException.java new file mode 100644 index 0000000000000000000000000000000000000000..a5b65e80fdb94c0f911a11846ac5ae8d9f58c877 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinException.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.config.exception; + +public class KylinException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String message; + + public KylinException() { + super(); + } + + public KylinException(String message) { + super(); + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinExceptionHandler.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinExceptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..fcefaa1f2b12cfe66516b783a46d42c6bc6b00a3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinExceptionHandler.java @@ -0,0 +1,63 @@ +package com.hnkylin.cloud.core.config.exception; + + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.HttpCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; + +@ControllerAdvice +public class KylinExceptionHandler { + + protected final Logger log = LoggerFactory.getLogger(getClass()); + + @ExceptionHandler(value = KylinException.class) + @ResponseBody + public ResponseEntity custKylinTokenExpireException(HttpServletRequest request, KylinException exception) { + log.error(request.getRequestURI(), exception); + return new ResponseEntity(BaseResult.error(exception.getMessage()), HttpStatus.OK); + } + + @ExceptionHandler(value = KylinTokenException.class) + @ResponseBody + public ResponseEntity kylinTokenExpireException(HttpServletRequest request, KylinTokenException exception) { + log.error(request.getRequestURI(), exception); + return new ResponseEntity(BaseResult.tokenExpire(exception.getMessage()), HttpStatus.OK); + } + + @ExceptionHandler(value = KylinParamException.class) + @ResponseBody + public ResponseEntity validateParameterException(HttpServletRequest request, KylinParamException pe) { + log.error(request.getRequestURI(), pe); + return new ResponseEntity(BaseResult.paramError(pe.getMessage()), HttpStatus.OK); + } + + @ExceptionHandler(value = KylinMcRequestException.class) + @ResponseBody + public ResponseEntity kylinMcRequestException(HttpServletRequest request, KylinMcRequestException pe) { + log.error(request.getRequestURI(), pe); + return new ResponseEntity(BaseResult.error(pe.getMessage()), HttpStatus.OK); + } + + @ExceptionHandler(value = HttpMessageNotReadableException.class) + @ResponseBody + public ResponseEntity notReadable(HttpServletRequest request, HttpMessageNotReadableException re) { + log.error(request.getRequestURI(), re); + return new ResponseEntity(BaseResult.paramError(re.getMessage()), HttpStatus.OK); + } + + @ExceptionHandler(value = Exception.class) + @ResponseBody + public ResponseEntity serverErr(HttpServletRequest request, Exception re) { + log.error(request.getRequestURI(), re); + return new ResponseEntity(BaseResult.error(HttpCode.CodeEnum.SERVER_ERROR.getDesc()), HttpStatus.OK); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinMcRequestException.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinMcRequestException.java new file mode 100644 index 0000000000000000000000000000000000000000..8d6d4f3709f504fb4724f6477a5e26caa70a5618 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinMcRequestException.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.config.exception; + +public class KylinMcRequestException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String message; + + public KylinMcRequestException() { + super(); + } + + public KylinMcRequestException(String message) { + super(); + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinParamException.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinParamException.java new file mode 100644 index 0000000000000000000000000000000000000000..5594f651dd72967b5b4491bde9dcc855377abcad --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinParamException.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.config.exception; + +public class KylinParamException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String message; + + public KylinParamException() { + super(); + } + + public KylinParamException(String message) { + super(); + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinTokenException.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinTokenException.java new file mode 100644 index 0000000000000000000000000000000000000000..e6d7f284e3164afc047e07e0b6719f22c70c9654 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/config/exception/KylinTokenException.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.config.exception; + +public class KylinTokenException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String message; + + public KylinTokenException() { + super(); + } + + public KylinTokenException(String message) { + super(); + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/BaseDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/BaseDo.java new file mode 100644 index 0000000000000000000000000000000000000000..a13301724ec0c585624c14ad8f0981cb5a9a324e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/BaseDo.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.core.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +@Data +public class BaseDo { + + + @TableId(type = IdType.AUTO) + private Integer id; + + //创建时间 + private Date createTime; + + //创建者 + private Integer createBy; + + //更新时间 + private Date updateTime; + + //更新者 + private Integer updateBy; + + + //删除者 + private Integer deleteBy; + + //删除标志 + private Boolean deleteFlag; + + //删除时间 + private Date deleteTime; +} \ No newline at end of file diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudAlarmConfigDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudAlarmConfigDo.java new file mode 100644 index 0000000000000000000000000000000000000000..3e0d5a60ff1dc9f0d320bef45d015056680f338b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudAlarmConfigDo.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.AlarmResourceType; +import com.hnkylin.cloud.core.enums.ArchitectureResourceType; +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_alarm_config") +public class CloudAlarmConfigDo extends BaseDo { + + + private AlarmResourceType resourceType; + + private Integer generalAlarm; + + private Integer severityAlarm; + + private Integer urgentAlarm; + + private Integer durationTime; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudAlarmLogDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudAlarmLogDo.java new file mode 100644 index 0000000000000000000000000000000000000000..b526c6f9b97100551b3b399789bd527beca8df9e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudAlarmLogDo.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.AlarmLevel; +import com.hnkylin.cloud.core.enums.AlarmResourceType; +import com.hnkylin.cloud.core.enums.AlarmTargetType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_alarm_log") +public class CloudAlarmLogDo extends BaseDo { + + + private AlarmResourceType resourceType; + + private AlarmLevel alarmLevel; + + private String alarmTarget; + + private AlarmTargetType targetType; + + private String alarmDetail; + + private Integer alarmTargetId; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudClusterDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudClusterDo.java new file mode 100644 index 0000000000000000000000000000000000000000..23c7982a2b0bff5515ffa70f2f7288ca5782d6d0 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudClusterDo.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_cluster") +public class CloudClusterDo extends BaseDo { + + + private String name; + + private String remark; + + private CloudClusterType type; + + + private String clusterAdminName; + + private String clusterAdminPassword; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudClusterNodeDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudClusterNodeDo.java new file mode 100644 index 0000000000000000000000000000000000000000..7ea933aef7c6d60623560c0ecdc8ab196f8406ee --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudClusterNodeDo.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_cluster_node") +public class CloudClusterNodeDo extends BaseDo { + + + private Integer clusterId; + + + private String httpType; + + private String ipAddress; + + + private Integer port; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudDeptDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudDeptDo.java new file mode 100644 index 0000000000000000000000000000000000000000..0ab370315aad006c90c8e3c2ccc8e20da8a7ef1b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudDeptDo.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_dept") +public class CloudDeptDo extends BaseDo { + + + private String deptName; + + private Integer parentId; + + private String remark; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudNetworkConfigDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudNetworkConfigDo.java new file mode 100644 index 0000000000000000000000000000000000000000..cb2a203430918c8a954f33aa3b6c3de37aafc4e7 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudNetworkConfigDo.java @@ -0,0 +1,51 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_network_config") +public class CloudNetworkConfigDo extends BaseDo { + + + private Integer vdcId; + + private Integer clusterId; + + private String networkName; + + private String interfaceType; + + private String addressPool; + + private Integer addressPoolId; + + private String virtualSwitch; + + private String modelType; + + private String portGroup; + + private String portGroupUuid; + + private NetworkSecurityPolicy securityPolicy; + + private String securityGroup; + + private String securityGroupUuid; + + private Integer virtualFirewallId; + + private String virtualFirewallName; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudOrgVdcDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudOrgVdcDo.java new file mode 100644 index 0000000000000000000000000000000000000000..95d4b7c48eae89f89a75b0dff6f3a40e49c9119f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudOrgVdcDo.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_org_vdc") +public class CloudOrgVdcDo extends BaseDo { + + + private Integer orgId; + + private Integer vdcId; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudOrganizationDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudOrganizationDo.java new file mode 100644 index 0000000000000000000000000000000000000000..98cf66572f36cc8deb27f0cef8f02f78d47d4410 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudOrganizationDo.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_organization") +public class CloudOrganizationDo extends BaseDo { + + + private String organizationName; + + private Integer parentId; + + private String remark; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudPermissionDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudPermissionDo.java new file mode 100644 index 0000000000000000000000000000000000000000..ef5c2807bffbd2ea4bd2670cd068635cd5a963bd --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudPermissionDo.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_permission") +public class CloudPermissionDo extends BaseDo { + + + private Integer parentId; + + private String name; + + private String icon; + + private String routeKey; + + private Boolean platformRolePermission; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudRoleDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudRoleDo.java new file mode 100644 index 0000000000000000000000000000000000000000..17bccbe4e20828e9be91bde48139f2695114b1d3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudRoleDo.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_role") +public class CloudRoleDo extends BaseDo { + + + private String roleName; + + private RoleType roleType; + + private String remark; + + //是否是系统默认内置用户 + private Boolean defaultRole; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudRolePermissionDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudRolePermissionDo.java new file mode 100644 index 0000000000000000000000000000000000000000..3a387ca87e9f10614b0bbd8a62f51d474dc9ffb2 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudRolePermissionDo.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_role_permission") +public class CloudRolePermissionDo extends BaseDo { + + + private Integer roleId; + + private Integer permissionId; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserDo.java new file mode 100644 index 0000000000000000000000000000000000000000..323ea79661e7409eea4121234d0442f203d9789a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserDo.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.UserType; +import lombok.*; + + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("cloud_user") +public class CloudUserDo extends BaseDo { + + private String userName; + + private String realName; + + private String password; + + private String mobile; + + private String remark; + + private CloudUserStatus status; + + private Integer organizationId; + + private UserType userType; + + //是否超级管理员 + private Boolean superUser; + + //是否是系统默认内置用户 + private Boolean defaultUser; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserMachineDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserMachineDo.java new file mode 100644 index 0000000000000000000000000000000000000000..6e764e4ff2a2d6a45f32cac3a05b9f77c4ef72c0 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserMachineDo.java @@ -0,0 +1,37 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_user_machine") +public class CloudUserMachineDo extends BaseDo { + + + private Integer userId; + + + private String machineUuid; + + private Date deadlineTime; + + //是否过期 + private Boolean deadlineFlag; + + private ServerVmDeadlineType deadlineType; + + private Integer clusterId; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserRoleDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserRoleDo.java new file mode 100644 index 0000000000000000000000000000000000000000..f4860ae76271dd50cd22883e36f8e6217cf5bdcf --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudUserRoleDo.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_user_role") +public class CloudUserRoleDo extends BaseDo { + + + private Integer userId; + + private Integer roleId; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcCpuDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcCpuDo.java new file mode 100644 index 0000000000000000000000000000000000000000..4bff3832e65b96c3277a8a7151e5f9ed1982d3a8 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcCpuDo.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_vdc_cpu") +public class CloudVdcCpuDo extends BaseDo { + + + private Integer vdcId; + + private Integer vcpus; + + private ArchitectureType architecture; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcDo.java new file mode 100644 index 0000000000000000000000000000000000000000..3bd1ae436cd074a81c604b1f594345e2a3f7ceec --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcDo.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_vdc") +public class CloudVdcDo extends BaseDo { + + + private String vdcName; + + private Integer parentId; + + private Integer zoneId; + + + private String remark; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcMemDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcMemDo.java new file mode 100644 index 0000000000000000000000000000000000000000..64c8a27b3c91618482d9cb9f83866d1300a266f3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcMemDo.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_vdc_mem") +public class CloudVdcMemDo extends BaseDo { + + + private Integer vdcId; + + private Integer mem; + + private ArchitectureType architecture; + + private MemUnit memUnit; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcStorageDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcStorageDo.java new file mode 100644 index 0000000000000000000000000000000000000000..00e998906959dac9bbc9170e1b3fecf6fe5a5871 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudVdcStorageDo.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_vdc_storage") +public class CloudVdcStorageDo extends BaseDo { + + + private Integer vdcId; + + private Integer storage; + + + private StorageUnit unit; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderDeferredMachineDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderDeferredMachineDo.java new file mode 100644 index 0000000000000000000000000000000000000000..daf276d53ba36265efad38a6b8adaaa1f940b842 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderDeferredMachineDo.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_deferred_machine") +public class CloudWorkOrderDeferredMachineDo extends BaseDo { + + + private Integer workOrderId; + + + private String userMachineUuid; + + private Date deadlineTime; + + private Date oldDeadlineTime; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderDo.java new file mode 100644 index 0000000000000000000000000000000000000000..39bcde236edc761a0799ba0c4fea44e3e2172f7e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderDo.java @@ -0,0 +1,40 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order") +public class CloudWorkOrderDo extends BaseDo { + + + private Integer userId; + + private WorkOrderType type; + + private String target; + + private String applyReason; + + private WorkOrderStatus status; + + private Integer auditBy; + + private Date auditTime; + + private String auditOpinion; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderModifyServerVmDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderModifyServerVmDo.java new file mode 100644 index 0000000000000000000000000000000000000000..155533ff4ca4b41417f3b146bb4ba3e02a8db4f9 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderModifyServerVmDo.java @@ -0,0 +1,58 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_modify_servervm") +public class CloudWorkOrderModifyServerVmDo extends BaseDo { + + + private Integer workOrderId; + + //虚拟机名称 + private String servervmName; + + //云服务器uuid + private String machineUuid; + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + //操作系统 + private String osMachine; + //架构 + private String architecture; + + private String systemType; + + //cpu + private Integer cpu; + + //变更前cpu + private Integer originalCpu; + + //内存 + private Integer mem; + + //变更前内存 + private Integer originalMem; + + //内存单位 + private MemUnit memUnit; + + private Date deadlineTime; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmDiskDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmDiskDo.java new file mode 100644 index 0000000000000000000000000000000000000000..95fd764a19e0ca12103e95ce34420ccb65b6539a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmDiskDo.java @@ -0,0 +1,44 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.DiskUnit; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_servervm_disk") +public class CloudWorkOrderServerVmDiskDo extends BaseDo { + + //工单ID + private Integer workOrderId; + + //硬盘大小 + private Integer diskSize; + + private DiskUnit diskUnit = DiskUnit.GB; + + //用途 + private String purpose; + + //类型 + private ApplyMcServerVmType type; + + private Long diskId; + + private ModifyType modifyType; + + private Integer oldDiskSize; + + private DiskUnit oldDiskUnit = DiskUnit.GB; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmDo.java new file mode 100644 index 0000000000000000000000000000000000000000..608f4d3c32ad5ee87986d847334610eaae49a777 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmDo.java @@ -0,0 +1,72 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ApplyServerVmType; +import com.hnkylin.cloud.core.enums.McCloneType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_servervm") +public class CloudWorkOrderServerVmDo extends BaseDo { + + + private Integer workOrderId; + + private ApplyServerVmType applyServervmType; + + //克隆类型 + private McCloneType cloneType; + + //虚拟机名称 + private String servervmName; + //申请个数 + private Integer applyNum; + + + //变更后个数 + private Integer modifyApplyNum; + + + //使用月数 + private Integer useMonth; + //到期处理策略 + private ServerVmDeadlineType deadlineType; + //操作系统 + private String osMachine; + //架构 + private String architecture; + + private String systemType; + //模板ID + private Integer templateId; + + //集群ID + private Integer clusterId; + + //cpu + private Integer cpu; + + //变更后CPU + private Integer modifyCpu; + //内存 + private Integer mem; + + //变更后内存 + private Integer modifyMem; + //内存单位 + private MemUnit memUnit; + + private String description; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmIsoDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmIsoDo.java new file mode 100644 index 0000000000000000000000000000000000000000..53d51d361c500c1b6fed013547677cdcf643d896 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmIsoDo.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.DiskUnit; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_servervm_iso") +public class CloudWorkOrderServerVmIsoDo extends BaseDo { + + //工单ID + private Integer workOrderId; + + private String isoFile; + + private ModifyType modifyType; + + + private String oldIsoFile; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmNetworkDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmNetworkDo.java new file mode 100644 index 0000000000000000000000000000000000000000..76274ba6ed0d96e8d02e3c7d4896d92b988d1cfc --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderServerVmNetworkDo.java @@ -0,0 +1,47 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_servervm_network") +public class CloudWorkOrderServerVmNetworkDo extends BaseDo { + + //申请ID + private Integer workOrderId; + + //用途 + private String purpose; + + + private ApplyMcServerVmType type; + + private Long interfaceId; + + private ModifyType modifyType; + + private Boolean ipBindMac; + + private Boolean manualSetIp; + + private Boolean automaticAcqIp; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderUserDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderUserDo.java new file mode 100644 index 0000000000000000000000000000000000000000..a322cae5f19d06fd04e519c25ff46667cc821572 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderUserDo.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_user") +public class CloudWorkOrderUserDo extends BaseDo { + + + private Integer workOrderId; + + + private String oldRealName; + + private String newRealName; + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderVdcCpuMemDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderVdcCpuMemDo.java new file mode 100644 index 0000000000000000000000000000000000000000..949d3e05095753a0ba9c95c951d515cebf0a7643 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderVdcCpuMemDo.java @@ -0,0 +1,36 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.ArchitectureResourceType; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_vdc_cpu_mem") +public class CloudWorkOrderVdcCpuMemDo extends BaseDo { + + + private Integer workOrderId; + + private ArchitectureResourceType resourceType; + + private ArchitectureType architecture; + + private Integer oldSize; + + private Integer applySize; + + private Integer realSize; + + private MemUnit unit; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderVdcDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderVdcDo.java new file mode 100644 index 0000000000000000000000000000000000000000..a00d53cb05305cbf31cedd7332a54dc03f47cb2c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudWorkOrderVdcDo.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_work_order_vdc") +public class CloudWorkOrderVdcDo extends BaseDo { + + + private Integer workOrderId; + + + private Integer vdcId; + + private Integer oldStorage; + + private Integer applyStorage; + + private Integer realStorage; + + private StorageUnit storageUnit; + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudZoneClusterDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudZoneClusterDo.java new file mode 100644 index 0000000000000000000000000000000000000000..b06427a50b05439960fa13284b220dfbdb40632d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudZoneClusterDo.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_zone_cluster") +public class CloudZoneClusterDo extends BaseDo { + + + private Integer zoneId; + + private Integer clusterId; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudZoneDo.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudZoneDo.java new file mode 100644 index 0000000000000000000000000000000000000000..2f745509c34f7eaa45b4bc61eebffa72e455d904 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/domain/CloudZoneDo.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.core.domain; + + +import com.baomidou.mybatisplus.annotation.TableName; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("cloud_zone") +public class CloudZoneDo extends BaseDo { + + + private String name; + + private String remark; + + //资源类型 + private CloudClusterType type; +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmLevel.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmLevel.java new file mode 100644 index 0000000000000000000000000000000000000000..7e79871d35eabdaa4995b6e0776fa9957c1b8984 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmLevel.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +public enum AlarmLevel { + GENERAL(0, "一般告警"), + SEVERITY(1, "严重告警"), + URGENT(1, "经济告警"), + ; + + + AlarmLevel(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmResourceType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmResourceType.java new file mode 100644 index 0000000000000000000000000000000000000000..d7c75198b5bdc4286b98f1d2fcde9e54813f9ecc --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmResourceType.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +public enum AlarmResourceType { + VDC_CPU(0, "CPU使用率"), + VDC_MEM(1, "内存使用率"), + VDC_STORAGE(1, "存储使用率"), + ; + + + AlarmResourceType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmTargetType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmTargetType.java new file mode 100644 index 0000000000000000000000000000000000000000..a92405a721531053528da297f8b5f460ff7ddb59 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/AlarmTargetType.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.core.enums; + +public enum AlarmTargetType { + PLATFORM(0, "平台告警"), + ; + + + AlarmTargetType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ApplyMcServerVmType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ApplyMcServerVmType.java new file mode 100644 index 0000000000000000000000000000000000000000..66f2b7ef67ba6a4eebd6f93c7a3e360d586b0c33 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ApplyMcServerVmType.java @@ -0,0 +1,37 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +public enum ApplyMcServerVmType { + + + original(0, "原始"), + custom(1, "自定义"), + ; + + + ApplyMcServerVmType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ApplyServerVmType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ApplyServerVmType.java new file mode 100644 index 0000000000000000000000000000000000000000..a0e8aa31b3ed539ccf86df309d19532d6f14a330 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ApplyServerVmType.java @@ -0,0 +1,37 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +public enum ApplyServerVmType { + + + TEMPLATE(0, "基于模板创建"), + ISO(1, "ISO创建"), + ; + + + ApplyServerVmType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ArchitectureResourceType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ArchitectureResourceType.java new file mode 100644 index 0000000000000000000000000000000000000000..868e124c50a0e2b61f409907e372d2bdbc655e3c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ArchitectureResourceType.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +public enum ArchitectureResourceType { + CPU(0, "CPU"), + MEM(1, "MEM"), + STORAGE(1, "MEM"), + ; + + + ArchitectureResourceType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ArchitectureType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ArchitectureType.java new file mode 100644 index 0000000000000000000000000000000000000000..55f8e565e0c84fe70d99f93ef53533ca9dc3acb0 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ArchitectureType.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +public enum ArchitectureType { + + X86_64(0, "X86_64"), + ARM64(0, "ARM64"), + MIPS64(0, "MIPS64"), + SW64(0, "SW64"); + + ArchitectureType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/CloudClusterType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/CloudClusterType.java new file mode 100644 index 0000000000000000000000000000000000000000..770ed6e6900efaf5ea3275417b0e2102cb597b02 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/CloudClusterType.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.core.enums; + +public enum CloudClusterType { + KSVD(0, "KSVD集群"); + + + CloudClusterType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/CloudUserStatus.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/CloudUserStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..633339e63734a6ae1de9167acf98b38806a6b586 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/CloudUserStatus.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.core.enums; + +public enum CloudUserStatus { + NO_ACTIVATE(0, "未激活"), + ACTIVATE(1, "激活"); + + + CloudUserStatus(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/DiskUnit.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/DiskUnit.java new file mode 100644 index 0000000000000000000000000000000000000000..60ae4de85a232f3776a21edbfe62eeefe090986b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/DiskUnit.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.enums; + +public enum DiskUnit { + GB(0, "GB"), + TB(1, "TB"), + ; + + + DiskUnit(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/HttpTypes.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/HttpTypes.java new file mode 100644 index 0000000000000000000000000000000000000000..15be214ec38b1fca59cf6c01a0d42360ff5cf3f6 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/HttpTypes.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.core.enums; + +public enum HttpTypes { + + HTTP("http://"), + HTTPS("https://"); + + + HttpTypes(String value) { + this.value = value; + } + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} + + + diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/LastUpdateType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/LastUpdateType.java new file mode 100644 index 0000000000000000000000000000000000000000..d7eb62219b52321091ce346f0c884e8ef1f7baf3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/LastUpdateType.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +public enum LastUpdateType { + + add("add", "添加"), + update("update", "修改"), + delete("delete", "删除"); + + + LastUpdateType(String value, String desc) { + this.value = value; + this.desc = desc; + } + + private String value; + private String desc; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McAlarmSettingsType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McAlarmSettingsType.java new file mode 100644 index 0000000000000000000000000000000000000000..461121a77f3f41100e5b8f595a3429d88680aae4 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McAlarmSettingsType.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.core.enums; + +public enum McAlarmSettingsType { + ServerVirtualization(0, "云服务器告警策略"), + Server(1, "物理服务器告警策略"); + + McAlarmSettingsType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McArchitectureType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McArchitectureType.java new file mode 100644 index 0000000000000000000000000000000000000000..f2c42035dcebd76f23cf8738cdb69db7d0ddc2a8 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McArchitectureType.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.core.enums; + +public enum McArchitectureType { + + X86_64("x86_64"), + ARM("arm"), + AARCH64("aarch64"), + MIPS("mips"), + sw_64("sw_64"), + LOWER_86_64("x86_64"); + + McArchitectureType(String name) { + this.name = name; + } + + private String name; + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McCloneType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McCloneType.java new file mode 100644 index 0000000000000000000000000000000000000000..8b17fafe8a2a1d35392f041f8559da60242442c1 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McCloneType.java @@ -0,0 +1,36 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +public enum McCloneType { + + + FULL_CLONE(0, "full clone"), + LINK_CLONE(1, "link clone"); + + + McCloneType(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + private Integer value; + private String desc; + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McKsvdServerType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McKsvdServerType.java new file mode 100644 index 0000000000000000000000000000000000000000..8e99252389355225ee562621f7a00d976534497d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McKsvdServerType.java @@ -0,0 +1,39 @@ +package com.hnkylin.cloud.core.enums; + +public enum McKsvdServerType { + + CM(1, "Cluster Master (no VDI)"), + VDI(2, "VDI"), + LEAF_DESKTOP(3, "VDE"), + LEAF_DRIVE(4, "LEAF Drive"), + CB_CM(5, "Cloud Branch (CM, no VDI)"), + CB_VDI(6, "Cloud Branch (VDI)"), + CM_VDI(7, "CM and VDI"), + CB_CM_VDI(8, "Cloud Branch (CM and VDI)"), + GATEWAY(9, "Gateway"); + + McKsvdServerType(int value, String name) { + this.value = value; + this.name = name; + } + + private int value; + private String name; + + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerClusterType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerClusterType.java new file mode 100644 index 0000000000000000000000000000000000000000..125a82e91aba1e1ac13c7c3a549f016ad6a2985a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerClusterType.java @@ -0,0 +1,37 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +public enum McServerClusterType { + + + AUTO(0, "自动"), + CUSTOM(1, "自定义"), + BIND_RESOURCE(2, "绑定资源"); + + + McServerClusterType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerVmStatus.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerVmStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..6cfdbeb9435188f382b61213906aac767fe613c0 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerVmStatus.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +public enum McServerVmStatus { + + + AVAILABLE("在线"), + OFFLINE("离线"), + CONNECTED("已连接"), + INSTALLING("安装"), + SUSPEND("暂停"), + OVERDUE("已过期"), + UNKNOWN("其他"), + ALL("全部"); + + + McServerVmStatus(String desc) { + this.desc = desc; + } + + private String desc; + + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerVmTaskStatus.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerVmTaskStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..80f3798b13b2f42422027d2162f7097200dbe827 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McServerVmTaskStatus.java @@ -0,0 +1,44 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-10-08. + */ +public enum McServerVmTaskStatus { + + NEW("新建"), + INSTALLING("安装中"), + NEWFAILED("新建失败"), + INSTALLFAILED("安装失败"), + CREATING("正在创建"), + STARTING("正在开机"), + SHUTDOWNING("正在关机"), + REBOOTING("正在重启"), + SUSPENDING("正在暂停"), + RESUMING("正在唤醒"), + + VOLUME_MIGRATING("正在存储迁移"), + HOST_MIGRATING("正在主机迁移"), + BACKUP_RUNNING("正在备份"), + BACKUP_RECOVERING("正在备份恢复"), + SNAPSHOT_RUNNING("正在快照"), + SNAPSHOT_RECOVERING("正在快照恢复"), + IMPORTING("正在导入"), + EXPORTING("正在导出"), + CLONING("正在克隆"), + DISK_COPYING("正在磁盘复制"), + LEISURE("空闲状态"); + + McServerVmTaskStatus(String desc) { + this.desc = desc; + } + + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McStartVmErrorCode.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McStartVmErrorCode.java new file mode 100644 index 0000000000000000000000000000000000000000..45f80bb6d4939fd87619042fae3e541fc43c8c06 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/McStartVmErrorCode.java @@ -0,0 +1,45 @@ +package com.hnkylin.cloud.core.enums; + +public enum McStartVmErrorCode { + SUCCESS(0, "开机成功"), + OTHER_REASON(1, "开机失败,请联系管理员"), + TICKET_EXPIRED(67, "票据过期,请联系管理员"), + RUNTIME_SERVER_ERR(70, "runtime-server 错误,请联系管理员"), + ERR_SYSTEM(85, "系统内部错误,请联系管理员"), + NO_MATCHING_SERVER(104, "桌面未被任何服务器缓存,请联系管理员"), + LAUNCH_SUSPENDED(105, "暂停启动新会话,请联系管理员"), + AT_LICENSE_CAPACITY(106, "群集已达到许可证限制,请联系管理员"), + LICENSE_EXPIRED(122, "许可过期,请联系管理员"), + LICENSE_INVALID(123, "许可不可用,请联系管理员"), + LICENSE_MISSING(124, "许可不存在,请联系管理员"), + RESOURCE_REQUIREMENTS_GPU(205, "无法满足gpu的资源需求,请联系管理员"), + RESOURCE_REQUIREMENTS_ARCH(206, "无法满足arch的资源需求,请联系管理员"), + RESOURCE_REQUIREMENTS_OTHER(207, "无法满足组织、客户或网络的资源需求,请联系管理员"), + ALL_SERVER_NOREADY(208, "服务器均未就绪,请联系管理员"), + ALL_SERVER_OFFLINE(209, "服务器脱机,请联系管理员"), + AT_RESOURCE_CAPACITY_MEM(210, "集群的内存资源容量不足,请联系管理员"), + AT_RESOURCE_CAPACITY_SESS(211, "群集的会话资源容量不足,请联系管理员"), + NO_STORAGE_LOCATION(218, "服务器没有存储,请联系管理员"), + LICENSE_NO_GPU_CAPABILITY(219, "GPU桌面需要Pro许可证,请联系管理员"), + LICENSE_CONCURRENT_USERS_EXCEEDED(220, "并发用户数超过许可限制,请释放部分用户或更新许可证!请联系管理员"), + LICENSE_SV_CPUS_EXCEEDED(221, "服务器虚拟化CPU数量超过许可限制,请更新或升级许可证!,请联系管理员"), + AFFINEGROUP_NO_SERVER(226, "亲和组策略限制,请联系管理员"); + + + private Integer errorCode; + + private String errorMsg; + + McStartVmErrorCode(Integer errorCode, String errorMsg) { + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } + + public Integer getErrorCode() { + return errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/MemUnit.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/MemUnit.java new file mode 100644 index 0000000000000000000000000000000000000000..8c5ba9e749c7a8b16808dc1056661eafb3d86074 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/MemUnit.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.enums; + +public enum MemUnit { + MB(0, "MB"), + GB(1, "GB"), + ; + + + MemUnit(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ModifyType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ModifyType.java new file mode 100644 index 0000000000000000000000000000000000000000..895d584158bf9c4cf8f37936d08110bbdbc271fa --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ModifyType.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.core.enums; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +public enum ModifyType { + + + NONE(0, "没有变动"), + ADD(1, "新增"), + MODIFY(2, "变更"), + DELETE(3, "删除"); + + + ModifyType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/NetworkSecurityPolicy.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/NetworkSecurityPolicy.java new file mode 100644 index 0000000000000000000000000000000000000000..cbb2230109439821a6c400dd7befe117fe27767f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/NetworkSecurityPolicy.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.enums; + +public enum NetworkSecurityPolicy { + + NONE("0", "无"), + SECURITY_GROUP("1", "安全组"), + VIRTUAL_FIREWALL("2", "虚拟防火墙"); + + NetworkSecurityPolicy(String value, String desc) { + this.value = value; + this.desc = desc; + } + + private String value; + private String desc; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/RoleType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/RoleType.java new file mode 100644 index 0000000000000000000000000000000000000000..0cf6d7d76f12db431a82219a99939f7ad4cb2c07 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/RoleType.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.core.enums; + +public enum RoleType { + PLATFORM(0, "平台管理"), + ORG(1, "组织管理"), + SELF_SERVICE(2, "自服务用户"), + ; + + + RoleType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ServerVmDeadlineType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ServerVmDeadlineType.java new file mode 100644 index 0000000000000000000000000000000000000000..1d3318bb1c65d795afb2d81d26266627bd553262 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/ServerVmDeadlineType.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.core.enums; + +public enum ServerVmDeadlineType { + POWER_OFF(0, "关机"), + DESTROY(1, "销毁"); + + + ServerVmDeadlineType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/StorageUnit.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/StorageUnit.java new file mode 100644 index 0000000000000000000000000000000000000000..9659158d3fce66dc548f7dd696b5c876384f4c8c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/StorageUnit.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.enums; + +public enum StorageUnit { + GB(0, "GB"), + TB(1, "TB"), + ; + + + StorageUnit(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/UserType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/UserType.java new file mode 100644 index 0000000000000000000000000000000000000000..d7acc41aac95c06037d88354d82b91bcc7d80c61 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/UserType.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.enums; + +public enum UserType { + selfServiceUser(0, "自服务用户"), + cloudUser(1, "云管用户"), + ; + + + UserType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/WorkOrderStatus.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/WorkOrderStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..e47ccf78772590a73761e893c41c70c586cec05e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/WorkOrderStatus.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.core.enums; + +public enum WorkOrderStatus { + + WAIT_CHECK(0, "待审核"), + CHECK_PASS(1, "已通过"), + CHECK_NO_PASS(2, "已拒绝"), + ALL(-1, "全部"); + + + WorkOrderStatus(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/WorkOrderType.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/WorkOrderType.java new file mode 100644 index 0000000000000000000000000000000000000000..fd08630fd541c60128b19cc0749fb3c85fae618e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/enums/WorkOrderType.java @@ -0,0 +1,36 @@ +package com.hnkylin.cloud.core.enums; + +public enum WorkOrderType { + REGISTER_USER(0, "注册账号"), + MODIFY_USER(1, "修改账号"), + APPLY_SERVERVM(2, "申请云服务器"), + MODIFY_SERVERVM(3, "变更云服务器"), + DEFERRED_SERVERVM(4, "延期云服务器"), + MODIFY_VDC(5, "变更VDC资源"), + ALL(-1, "全部"); + + + WorkOrderType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudAlarmConfigMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudAlarmConfigMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..5098b05a4a74f00ce01241aaa534c4972a507a87 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudAlarmConfigMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudAlarmConfigDo; + +public interface CloudAlarmConfigMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudAlarmLogMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudAlarmLogMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..608617cd343194b98ab96848b540dfb1b9112b78 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudAlarmLogMapper.java @@ -0,0 +1,8 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudAlarmConfigDo; +import com.hnkylin.cloud.core.domain.CloudAlarmLogDo; + +public interface CloudAlarmLogMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudClusterMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudClusterMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..09a30b439b8e503350ddd60572366a714c1f83e4 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudClusterMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudClusterDo; + +public interface CloudClusterMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudClusterNodeMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudClusterNodeMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..cd04ab0efdf613db3e0f0e555ec728957c605190 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudClusterNodeMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudClusterNodeDo; + +public interface CloudClusterNodeMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudDeptMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudDeptMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..45317fabfae8e1b5a27cbbc693d48f89da61982f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudDeptMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudDeptDo; + +public interface CloudDeptMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudNetworkConfigMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudNetworkConfigMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..09df37b6efc164be6e24fb290af5b79aa0071bb6 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudNetworkConfigMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudNetworkConfigDo; + +public interface CloudNetworkConfigMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudOrgVdcMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudOrgVdcMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..5c7d04540d78e0adafab817ad258667cd4df60bc --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudOrgVdcMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudOrgVdcDo; + +public interface CloudOrgVdcMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudOrganizationMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudOrganizationMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..ff5f2950f1ac4eca93e048c1a24382268dd44cd3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudOrganizationMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudOrganizationDo; + +public interface CloudOrganizationMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudPermissionMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudPermissionMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..297086083f6a861504af96c35dcd37f0a1428b4b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudPermissionMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudPermissionDo; + +public interface CloudPermissionMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudRoleMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudRoleMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..81819bcd6f6725af1925fd220aa6a73b513edb5e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudRoleMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudRoleDo; + +public interface CloudRoleMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudRolePermissionMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudRolePermissionMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..2dcc7af3b714748d2013ac040fd794634abe3231 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudRolePermissionMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudRolePermissionDo; + +public interface CloudRolePermissionMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserMachineMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserMachineMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..864060ee9e1b63074032211ae68297c75cebca1a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserMachineMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; + +public interface CloudUserMachineMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..d8fd67f97115d96a745255f86734f90942a17e11 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudUserDo; + +public interface CloudUserMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserRoleMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserRoleMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..46c5c8c09e82d13c13808a49a87bae76864d9938 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudUserRoleMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudUserRoleDo; + +public interface CloudUserRoleMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcCpuMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcCpuMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..6157aff54a1c8430de133bb9f726cda2be8d7313 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcCpuMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudVdcCpuDo; + +public interface CloudVdcCpuMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b7725adf80527593d91327bc9129d42668d98e13 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudVdcDo; + +public interface CloudVdcMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcMemMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcMemMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..de1b6ff94d1e55ef4954e1725994613156fce10c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcMemMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudVdcMemDo; + +public interface CloudVdcMemMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcStorageMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcStorageMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..179c7bd9ecd05d70ddceec8dbc3bcf524176b0fd --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudVdcStorageMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudVdcStorageDo; + +public interface CloudVdcStorageMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderDeferredMachineMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderDeferredMachineMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..8ae3aff0cd0156a0d5049bb5a67ca99692b9ad7d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderDeferredMachineMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDeferredMachineDo; + +public interface CloudWorkOrderDeferredMachineMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..94df28fabdd69f4c2ac009ce2810f5b1d0e20d48 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDo; + +public interface CloudWorkOrderMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderModifyServerVmMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderModifyServerVmMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..fb82d6af83f7771678c18829f271b65ca081aa7a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderModifyServerVmMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderModifyServerVmDo; + +public interface CloudWorkOrderModifyServerVmMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmDiskMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmDiskMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..886f9127c4555537221d0b5aa4109f16bca79940 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmDiskMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmDiskDo; + +public interface CloudWorkOrderServerVmDiskMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmIsoMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmIsoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..50222cb8bbc0e47c2040c234767acd34a28ebb5b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmIsoMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmIsoDo; + +public interface CloudWorkOrderServerVmIsoMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..95f54a62526c01e15f3142dc8d38b5625691cd2c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmDo; + +public interface CloudWorkOrderServerVmMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmNetworkMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmNetworkMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..1b8cb8dbbd9859590537271147c07fbc7bb60750 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderServerVmNetworkMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmNetworkDo; + +public interface CloudWorkOrderServerVmNetworkMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderUserMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderUserMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..212c081ad715ad6f72a66e7aa2faae5ec3bf9480 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderUserMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderUserDo; + +public interface CloudWorkOrderUserMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderVdcCpuMemMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderVdcCpuMemMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..2abab91cec35bcbbffeafec68192d7c3bae56c3d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderVdcCpuMemMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcCpuMemDo; + +public interface CloudWorkOrderVdcCpuMemMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderVdcMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderVdcMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..082f32ea0090807b63a88bccd684662f02cda6ca --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudWorkOrderVdcMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcDo; + +public interface CloudWorkOrderVdcMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudZoneClusterMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudZoneClusterMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..d0d467de06874cae9595bdce4cc006ae271408de --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudZoneClusterMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudZoneClusterDo; + +public interface CloudZoneClusterMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudZoneMapper.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudZoneMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..a2f873d3a05d8fa5f9933726638fc1a76006b131 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/mapper/CloudZoneMapper.java @@ -0,0 +1,7 @@ +package com.hnkylin.cloud.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudZoneDo; + +public interface CloudZoneMapper extends BaseMapper { +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudAlarmConfigService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudAlarmConfigService.java new file mode 100644 index 0000000000000000000000000000000000000000..bc0feb8bb86102c72af70caec38a0013e5c7c26c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudAlarmConfigService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudAlarmConfigDo; + +public interface CloudAlarmConfigService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudAlarmLogService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudAlarmLogService.java new file mode 100644 index 0000000000000000000000000000000000000000..0bcb1dfeef3587eea99db6d945a452d5a9de3a6f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudAlarmLogService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudAlarmLogDo; + +public interface CloudAlarmLogService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudClusterNodeService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudClusterNodeService.java new file mode 100644 index 0000000000000000000000000000000000000000..8246dc0822744cbb5bc8fa8079a34a4cd9fe5543 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudClusterNodeService.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudClusterNodeDo; + +import java.util.List; + + +public interface CloudClusterNodeService extends IService { + + + List getClusterNodeListByClusterId(Integer clusterId); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudClusterService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudClusterService.java new file mode 100644 index 0000000000000000000000000000000000000000..49469beb79351aedc88c0a33a2ce86d82eff4e7b --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudClusterService.java @@ -0,0 +1,37 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudClusterDo; + +import java.util.List; + + +public interface CloudClusterService extends IService { + + /** + * 封装集群请求ip集合 + * + * @param clusterId + * @return + */ + List formatClusterNodeList(Integer clusterId); + + /** + * 根据用户获取,用户拥有的集群权限 + * + * @param userId + * @return + */ + List clusterListByUserId(Integer userId); + + + /** + * 根据可用区ID获取集群列表 + * + * @param zoneId + * @return + */ + List listClusterBYZoneId(Integer zoneId); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudDeptService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudDeptService.java new file mode 100644 index 0000000000000000000000000000000000000000..f30ed9cbe039db37d23636f247a5f6c49335c11a --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudDeptService.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudDeptDo; + +import java.util.List; + +public interface CloudDeptService extends IService { + + List queryAllDeptList(); + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudNetworkConfigService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudNetworkConfigService.java new file mode 100644 index 0000000000000000000000000000000000000000..05ee9bbea4ce2213071b1c1e5f164fffef336c4c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudNetworkConfigService.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudNetworkConfigDo; +import com.hnkylin.cloud.core.domain.CloudVdcMemDo; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + + +public interface CloudNetworkConfigService extends IService { + + + /** + * 根据vdc 获取网络列表 + * + * @param vdcId + * @return + */ + List listNetworkListByVdcId(Integer vdcId); + + + /** + * 通过vdc删除 + * + * @param vdcId + */ + void deleteByVdcId(Integer vdcId, Integer deleteUser); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudOrgVdcService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudOrgVdcService.java new file mode 100644 index 0000000000000000000000000000000000000000..f842f27fa8bca0826d1eebabed71759fff0b45e9 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudOrgVdcService.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudOrgVdcDo; + +import java.util.List; + + +public interface CloudOrgVdcService extends IService { + + /** + * 根据组织ID获取 组织和VDC对应关系 + * + * @param orgId + * @return + */ + CloudOrgVdcDo queryOrgVdcByOrgId(Integer orgId); + + + /** + * 获取可用区下组织和vdc关联记录 + * + * @param zoneId + * @return + */ + List orgIdListByZoneId(Integer zoneId); + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudOrganizationService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudOrganizationService.java new file mode 100644 index 0000000000000000000000000000000000000000..41d2fa4b547eb0d1b30f4eccd831874d0b73c0a4 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudOrganizationService.java @@ -0,0 +1,39 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudOrganizationDo; + +import java.util.List; + +public interface CloudOrganizationService extends IService { + + List queryAllOrgList(); + + + /** + * 通过组织名称获取组织 + * + * @param organizationName + * @return + */ + CloudOrganizationDo queryByOrganizationNameName(String organizationName); + + + /** + * 根据组织ID获取所有子组织(包括自己) + * + * @param orgId + * @return + */ + List listChildOrgByOrgId(Integer orgId); + + + /** + * 获取系统默认最顶级组织 + * + * @return + */ + CloudOrganizationDo getDefaultTopOrg(); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudPermissionService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudPermissionService.java new file mode 100644 index 0000000000000000000000000000000000000000..18737812195274ff2280286a672b311971f4fbbe --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudPermissionService.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudPermissionDo; + +import java.util.List; + + +public interface CloudPermissionService extends IService { + + + /** + * 所有权限 + * + * @return + */ + List allPermissions(); + + + /** + * 获取自定义的平台管理角色默认最大权限集合 + * + * @return + */ + List customPlatformRoleMaxPermission(); + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudRolePermissionService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudRolePermissionService.java new file mode 100644 index 0000000000000000000000000000000000000000..c0ada612a1d8ae713a7401758969027e9e153152 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudRolePermissionService.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudRolePermissionDo; + +import java.util.Date; +import java.util.List; + + +public interface CloudRolePermissionService extends IService { + + /** + * 根据角色ID查询角色具有的权限列表 + * + * @param roleId + * @return + */ + List listRolePermissionByRoleId(Integer roleId); + + /** + * 根据角色删除角色已有权限 + * + * @param roleId + * @param deleteBy + * @param deleteTime + */ + void deleteRolePermissionByRole(Integer roleId, Integer deleteBy, Date deleteTime); + + + /** + * 插入加上拥有的权限 + * + * @param roleId + * @param permissionIds + * @param createBy + * @param createTime + */ + void insertRolePermission(Integer roleId, List permissionIds, Integer createBy, Date createTime); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudRoleService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudRoleService.java new file mode 100644 index 0000000000000000000000000000000000000000..8ba37f4c758d16fdff72dd83edd4a4ce1cdf1fe1 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudRoleService.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudRoleDo; + + +public interface CloudRoleService extends IService { + + + /** + * 获取组织管理员角色 + * + * @return + */ + CloudRoleDo getOrgRole(); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserMachineService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserMachineService.java new file mode 100644 index 0000000000000000000000000000000000000000..12b180e2b09249b5d7e2c48ea70c5693b619e84d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserMachineService.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; + +import java.util.List; + +public interface CloudUserMachineService extends IService { + + + /** + * @param uuid + * @return + */ + CloudUserMachineDo getUserMachineDoByUuid(String uuid); + + + CloudUserMachineDo getUserMachineDoByUuidAndUserId(String uuid, Integer userId); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserRoleService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserRoleService.java new file mode 100644 index 0000000000000000000000000000000000000000..ac9bad3924d14c9dd159a062558bdba5e59a4ddf --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserRoleService.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudUserRoleDo; + + +public interface CloudUserRoleService extends IService { + + + CloudUserRoleDo getUserRoleByUserId(Integer userId); + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserService.java new file mode 100644 index 0000000000000000000000000000000000000000..f29f1b8aa2edd6a93f365cdf67bcf18c4fffefdf --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudUserService.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudUserDo; + +public interface CloudUserService extends IService { + + CloudUserDo queryUserByUserName(String userName); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcCpuService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcCpuService.java new file mode 100644 index 0000000000000000000000000000000000000000..635bae6a480b47be993bcb7f2c402498be235834 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcCpuService.java @@ -0,0 +1,57 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudVdcCpuDo; +import com.hnkylin.cloud.core.enums.ArchitectureType; + +import java.util.List; + + +public interface CloudVdcCpuService extends IService { + + /** + * 根据VDC获取总cpu + * + * @param vdcId + * @return + */ + Integer totalCpuByVdcId(Integer vdcId); + + + /** + * 获取vdc下不同架构的cpu数 + * + * @param vdcId + * @param architectureType + * @return + */ + Integer totalCpuByVdcIdAndArchitectureType(Integer vdcId, ArchitectureType architectureType); + + + /** + * 获取下级VDC 架构下的cpu数 + * + * @param parentVdcId + * @param architectureType + * @return + */ + Integer totalChildVdcCpuByParentIdAndArchitectureType(Integer parentVdcId, ArchitectureType architectureType); + + + /** + * 根据vdcId 获取vdc的cpu列表 + * + * @param vdcId + * @return + */ + List listVDdcCpuByVdc(Integer vdcId); + + /** + * 通过vdc删除 + * + * @param vdcId + */ + void deleteByVdcId(Integer vdcId, Integer deleteUser); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcMemService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcMemService.java new file mode 100644 index 0000000000000000000000000000000000000000..787af10ab32ed22cc5b692b41933cc282204e76e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcMemService.java @@ -0,0 +1,53 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudVdcMemDo; +import com.hnkylin.cloud.core.enums.ArchitectureType; + +import java.util.List; + + +public interface CloudVdcMemService extends IService { + + /** + * 根据vdc获取内存大小 + * + * @param vdcId + * @return + */ + CloudVdcMemDo totalMemByVdcId(Integer vdcId); + + /** + * 获取vdc下不同架构的内存 + * + * @param vdcId + * @param architectureType + * @return + */ + CloudVdcMemDo totalMemByVdcIdAndArchitectureType(Integer vdcId, ArchitectureType architectureType); + + + /** + * 获取下级VDC 架构下的内存 + * + * @param parentVdcId + * @param architectureType + * @return + */ + CloudVdcMemDo totalChildVdcMemByParentIdAndArchitectureType(Integer parentVdcId, ArchitectureType architectureType); + + /** + * 根据vdcId获取vdc内存列表 + * + * @param vdcId + * @return + */ + List listVdcMemByVdcId(Integer vdcId); + + /** + * 通过vdc删除 + * + * @param vdcId + */ + void deleteByVdcId(Integer vdcId, Integer deleteUser); +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcService.java new file mode 100644 index 0000000000000000000000000000000000000000..dbd71399900d63a6540c700c833a080dfd58f3df --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcService.java @@ -0,0 +1,63 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudVdcDo; + +import java.util.List; + + +public interface CloudVdcService extends IService { + + + /** + * 获取下级VDC列表 + * + * @param parentVdcId + * @return + */ + List getChildVdcList(Integer parentVdcId); + + /** + * 获取下级VDC id列表 + * + * @param parentVdcId + * @return + */ + List getChildVdcIdList(Integer parentVdcId); + + /** + * 根据可用区获取可用区下vdc列表 + * + * @param zoneId + * @return + */ + List vdcListByZone(Integer zoneId); + + + /** + * 根据组织ID获取对应的vdc + * + * @param orgId + * @return + */ + CloudVdcDo getVdcByOrgId(Integer orgId); + + + /** + * 获取可用区所有一级VDC列表 + * + * @param zoneId + * @return + */ + List getFirstVdcListByZone(Integer zoneId); + + + /** + * 获取所有下级VDC列表 + * + * @param parentVdcId + * @return + */ + List getAllChildVdcList(Integer parentVdcId); + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcStorageService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcStorageService.java new file mode 100644 index 0000000000000000000000000000000000000000..54776b7e0851c3f48e2d23c412d1d2cb4a29da53 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudVdcStorageService.java @@ -0,0 +1,43 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudVdcStorageDo; + + +public interface CloudVdcStorageService extends IService { + + + /** + * 根据VDC获取总存储大小 + * + * @param vdcId + * @return + */ + CloudVdcStorageDo getTotalStorageByVdcId(Integer vdcId); + + + /** + * 根据父VDC获取分配给下级VDC的存储大小 + * + * @param parentVdcId + * @return + */ + CloudVdcStorageDo getChildVdcTotalStorage(Integer parentVdcId); + + + /** + * 通过vdc删除 + * + * @param vdcId + */ + void deleteByVdcId(Integer vdcId, Integer deleteUser); + + + /** + * 获取VDC的存储资源 + * + * @param vdcId + * @return + */ + CloudVdcStorageDo getByVdcId(Integer vdcId); +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderDeferredMachineService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderDeferredMachineService.java new file mode 100644 index 0000000000000000000000000000000000000000..dd807fad3c8204d1ff7520beeb7d0f49e5667e6c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderDeferredMachineService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDeferredMachineDo; + +public interface CloudWorkOrderDeferredMachineService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderModifyServerVmService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderModifyServerVmService.java new file mode 100644 index 0000000000000000000000000000000000000000..322060f6168dd1f13fc711d300921e835d8dee81 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderModifyServerVmService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderModifyServerVmDo; + +public interface CloudWorkOrderModifyServerVmService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmDiskService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmDiskService.java new file mode 100644 index 0000000000000000000000000000000000000000..f2e241e7c2b9623e32dfbfd2429489e6820b7066 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmDiskService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmDiskDo; + +public interface CloudWorkOrderServerVmDiskService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmIsoService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmIsoService.java new file mode 100644 index 0000000000000000000000000000000000000000..1f086082cb7d38b3fd6f53b784458ae7d3267c80 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmIsoService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmIsoDo; + +public interface CloudWorkOrderServerVmIsoService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmNetworkService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmNetworkService.java new file mode 100644 index 0000000000000000000000000000000000000000..a0569dac8224ee62b42758b5bc2f3fc9211c0641 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmNetworkService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmNetworkDo; + +public interface CloudWorkOrderServerVmNetworkService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmService.java new file mode 100644 index 0000000000000000000000000000000000000000..9e78d9b012de230d800ce0586dca3d1e757de961 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderServerVmService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmDo; + +public interface CloudWorkOrderServerVmService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderService.java new file mode 100644 index 0000000000000000000000000000000000000000..1ece7cb6ef971eb2a852dd2f6930a404306643ac --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDo; + +public interface CloudWorkOrderService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderUserService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderUserService.java new file mode 100644 index 0000000000000000000000000000000000000000..aa7b57ca6610467e24adeddc32150280f3737cec --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderUserService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderUserDo; + +public interface CloudWorkOrderUserService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderVdcCpuMemService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderVdcCpuMemService.java new file mode 100644 index 0000000000000000000000000000000000000000..ba35d3e9f70445fbcd2b372f9ed5c9a3189bf07d --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderVdcCpuMemService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcCpuMemDo; + +public interface CloudWorkOrderVdcCpuMemService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderVdcService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderVdcService.java new file mode 100644 index 0000000000000000000000000000000000000000..2562ad30c89c1611b1fc5c9b7d0dd6142ca28541 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudWorkOrderVdcService.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcDo; + +public interface CloudWorkOrderVdcService extends IService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudZoneClusterService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudZoneClusterService.java new file mode 100644 index 0000000000000000000000000000000000000000..5d41da289956489c58a3c49e6b0147c542129aa5 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudZoneClusterService.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudZoneClusterDo; + +import java.util.List; + + +public interface CloudZoneClusterService extends IService { + + /** + * 根据集群id获取集群和可用区关联关系 + * + * @param clusterId + * @return + */ + CloudZoneClusterDo getByClusterId(Integer clusterId); + + + List listZoneClusterByZone(Integer zoneId); + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudZoneService.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudZoneService.java new file mode 100644 index 0000000000000000000000000000000000000000..b376d7296088ecaddbeae0772f532e3e858aafe2 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/CloudZoneService.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.core.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnkylin.cloud.core.domain.CloudZoneDo; + + +public interface CloudZoneService extends IService { + + + /** + * 通过集群ID获取可用区 + * + * @param clusterId + * @return + */ + CloudZoneDo getByClusterId(Integer clusterId); + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudAlarmConfigServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudAlarmConfigServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..faa54e7cea90a1ad5853b6868e38fb708b8da2c7 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudAlarmConfigServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudAlarmConfigDo; +import com.hnkylin.cloud.core.mapper.CloudAlarmConfigMapper; +import com.hnkylin.cloud.core.service.CloudAlarmConfigService; +import org.springframework.stereotype.Service; + +@Service +public class CloudAlarmConfigServiceImpl extends ServiceImpl + implements CloudAlarmConfigService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudAlarmLogServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudAlarmLogServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b76df0478e1ede7b98cec03367a6c1d5fe0193a3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudAlarmLogServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudAlarmLogDo; +import com.hnkylin.cloud.core.mapper.CloudAlarmLogMapper; +import com.hnkylin.cloud.core.service.CloudAlarmLogService; +import org.springframework.stereotype.Service; + +@Service +public class CloudAlarmLogServiceImpl extends ServiceImpl + implements CloudAlarmLogService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudClusterNodeServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudClusterNodeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..271357136f9bc2c049ce8ff4d1a0bc79a6a9673f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudClusterNodeServiceImpl.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudClusterNodeDo; +import com.hnkylin.cloud.core.mapper.CloudClusterNodeMapper; +import com.hnkylin.cloud.core.service.CloudClusterNodeService; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class CloudClusterNodeServiceImpl extends ServiceImpl + implements CloudClusterNodeService { + + + @Override + public List getClusterNodeListByClusterId(Integer clusterId) { + CloudClusterNodeDo clusterNodeDo = new CloudClusterNodeDo(); + clusterNodeDo.setDeleteFlag(false); + clusterNodeDo.setClusterId(clusterId); + Wrapper wrapper = new QueryWrapper<>(clusterNodeDo); + List clusterNodeDoList = getBaseMapper().selectList(wrapper); + return clusterNodeDoList; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudClusterServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudClusterServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e43170122ffadb1ec40fb6c8799993f3f402dd52 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudClusterServiceImpl.java @@ -0,0 +1,88 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.mapper.CloudClusterMapper; +import com.hnkylin.cloud.core.service.*; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class CloudClusterServiceImpl extends ServiceImpl + implements CloudClusterService { + + @Resource + private CloudClusterNodeService cloudClusterNodeService; + + @Resource + private CloudUserService cloudUserService; + + @Resource + private CloudOrganizationService organizationService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private CloudZoneClusterService cloudZoneClusterService; + + /** + * 封装集群请求ip集合 + * + * @param clusterId + * @return + */ + @Override + public List formatClusterNodeList(Integer clusterId) { + + List clusterNodeDoList = cloudClusterNodeService.getClusterNodeListByClusterId(clusterId); + List mcNodeList = new ArrayList<>(clusterNodeDoList.size()); + clusterNodeDoList.stream().forEach(item -> { + StringBuilder sb = new StringBuilder(item.getHttpType()); + sb.append(item.getIpAddress()).append(":").append(item.getPort()); + mcNodeList.add(sb.toString()); + }); + + return mcNodeList; + } + + @Override + public List clusterListByUserId(Integer userId) { + //先根据用户得到组织,组织获取VDC,VDC在获取可用区,可用区在获取集群列表 + CloudUserDo userDo = cloudUserService.getById(userId); + CloudOrganizationDo organizationDo = organizationService.getById(userDo.getOrganizationId()); + if (Objects.equals(organizationDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + //用户属于顶级组织,则可见为全部集群 + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(clusterDo); + return getBaseMapper().selectList(wrapper); + } + CloudVdcDo vdcDo = cloudVdcService.getVdcByOrgId(organizationDo.getId()); + return listClusterBYZoneId(vdcDo.getZoneId()); + } + + @Override + public List listClusterBYZoneId(Integer zoneId) { + List zoneClusterIdList = + cloudZoneClusterService.listZoneClusterByZone(zoneId).stream().map(CloudZoneClusterDo::getClusterId + ).collect(Collectors.toList()); + List clusterDoList = new ArrayList<>(); + if (!zoneClusterIdList.isEmpty()) { + CloudClusterDo queryClusterDo = new CloudClusterDo(); + queryClusterDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(queryClusterDo); + wrapper.in("id", zoneClusterIdList); + clusterDoList = getBaseMapper().selectList(wrapper); + } + return clusterDoList; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudDeptServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudDeptServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..46eda4e8088664256192c223a71419c67e19b33e --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudDeptServiceImpl.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudDeptDo; +import com.hnkylin.cloud.core.mapper.CloudDeptMapper; +import com.hnkylin.cloud.core.service.CloudDeptService; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class CloudDeptServiceImpl extends ServiceImpl implements CloudDeptService { + + @Override + public List queryAllDeptList() { + CloudDeptDo deptDo = new CloudDeptDo(); + deptDo.setDeleteFlag(Boolean.FALSE); + Wrapper wrapper = new QueryWrapper<>(deptDo); + return baseMapper.selectList(wrapper); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudNetworkConfigServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudNetworkConfigServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..16fe82745c61f4b00ca6ba02526273e2c5c8c321 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudNetworkConfigServiceImpl.java @@ -0,0 +1,42 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudNetworkConfigDo; +import com.hnkylin.cloud.core.mapper.CloudNetworkConfigMapper; +import com.hnkylin.cloud.core.service.CloudNetworkConfigService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + + +@Service +public class CloudNetworkConfigServiceImpl extends ServiceImpl implements CloudNetworkConfigService { + + + @Override + public List listNetworkListByVdcId(Integer vdcId) { + CloudNetworkConfigDo networkConfigDo = new CloudNetworkConfigDo(); + networkConfigDo.setDeleteFlag(false); + networkConfigDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(networkConfigDo); + List list = getBaseMapper().selectList(wrapper); + return list; + } + + @Override + @Transactional + public void deleteByVdcId(Integer vdcId, Integer deleteUser) { + List list = listNetworkListByVdcId(vdcId); + if (!list.isEmpty()) { + list.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(deleteUser); + item.setDeleteTime(new Date()); + }); + updateBatchById(list); + } + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudOrgVdcServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudOrgVdcServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2af3c768366cb657e7e09a7f45a730b874bc6d50 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudOrgVdcServiceImpl.java @@ -0,0 +1,53 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudOrgVdcDo; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.core.mapper.CloudOrgVdcMapper; +import com.hnkylin.cloud.core.service.CloudOrgVdcService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class CloudOrgVdcServiceImpl extends ServiceImpl + implements CloudOrgVdcService { + + + @Resource + private CloudVdcService cloudVdcService; + + @Override + public CloudOrgVdcDo queryOrgVdcByOrgId(Integer orgId) { + CloudOrgVdcDo orgVdcDo = new CloudOrgVdcDo(); + orgVdcDo.setOrgId(orgId); + orgVdcDo.setDeleteFlag(Boolean.FALSE); + Wrapper wrapper = new QueryWrapper<>(orgVdcDo); + List orgVdcDoList = baseMapper.selectList(wrapper); + + return orgVdcDoList.isEmpty() ? null : orgVdcDoList.get(0); + } + + + @Override + public List orgIdListByZoneId(Integer zoneId) { + List vdcList = cloudVdcService.vdcListByZone(zoneId); + List vdcIdList = vdcList.stream().map(CloudVdcDo::getId).collect(Collectors.toList()); + if (vdcIdList.isEmpty()) { + return new ArrayList<>(); + } + CloudOrgVdcDo orgVdcDo = new CloudOrgVdcDo(); + orgVdcDo.setDeleteFlag(Boolean.FALSE); + QueryWrapper wrapper = new QueryWrapper<>(orgVdcDo); + wrapper.in("vdc_id", vdcIdList); + List orgVdcDoList = baseMapper.selectList(wrapper); + return orgVdcDoList.isEmpty() ? new ArrayList<>() : + orgVdcDoList.stream().map(CloudOrgVdcDo::getOrgId).collect(Collectors.toList()); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudOrganizationServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudOrganizationServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b3848c6253e3894a3b02dd26997e6cba9d5451e4 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudOrganizationServiceImpl.java @@ -0,0 +1,80 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.domain.CloudOrganizationDo; +import com.hnkylin.cloud.core.mapper.CloudOrganizationMapper; +import com.hnkylin.cloud.core.service.CloudOrganizationService; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class CloudOrganizationServiceImpl extends ServiceImpl + implements CloudOrganizationService { + + @Override + public List queryAllOrgList() { + CloudOrganizationDo organizationDo = new CloudOrganizationDo(); + organizationDo.setDeleteFlag(Boolean.FALSE); + Wrapper wrapper = new QueryWrapper<>(organizationDo); + return baseMapper.selectList(wrapper); + } + + + @Override + public CloudOrganizationDo queryByOrganizationNameName(String organizationName) { + CloudOrganizationDo orgDo = new CloudOrganizationDo(); + orgDo.setOrganizationName(organizationName); + orgDo.setDeleteFlag(Boolean.FALSE); + Wrapper wrapper = new QueryWrapper<>(orgDo); + List list = baseMapper.selectList(wrapper); + + return list.isEmpty() ? null : list.get(0); + } + + @Override + public List listChildOrgByOrgId(Integer orgId) { + List allOrgList = queryAllOrgList(); + CloudOrganizationDo parentDo = getById(orgId); + List childOrgList = new ArrayList<>(); + childOrgList.add(parentDo); + List parentIds = new ArrayList<>(); + parentIds.add(orgId); + getChildList(parentIds, childOrgList, allOrgList); + return childOrgList; + + } + + /** + * 递归获取子部门 + * + * @param parentIds + * @param childOrgList + * @param allOrgList + */ + private void getChildList(List parentIds, List childOrgList, + List allOrgList) { + List childList = + allOrgList.stream().filter(item -> parentIds.contains(item.getParentId())).collect(Collectors.toList()); + if (childList.isEmpty()) { + return; + } + List newParentIds = childList.stream().map(CloudOrganizationDo::getId).collect(Collectors.toList()); + childOrgList.addAll(childList); + getChildList(newParentIds, childOrgList, allOrgList); + } + + @Override + public CloudOrganizationDo getDefaultTopOrg() { + CloudOrganizationDo userOrgDo = new CloudOrganizationDo(); + userOrgDo.setDeleteFlag(false); + userOrgDo.setParentId(KylinCommonConstants.TOP_PARENT_ID); + Wrapper wrapper = + new QueryWrapper<>(userOrgDo); + return getOne(wrapper); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudPermissionServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudPermissionServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..28584e24679186d3907f5a321b0a54556310d284 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudPermissionServiceImpl.java @@ -0,0 +1,42 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.domain.CloudPermissionDo; +import com.hnkylin.cloud.core.domain.CloudRolePermissionDo; +import com.hnkylin.cloud.core.mapper.CloudPermissionMapper; +import com.hnkylin.cloud.core.service.CloudPermissionService; +import com.hnkylin.cloud.core.service.CloudRolePermissionService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class CloudPermissionServiceImpl extends ServiceImpl + implements CloudPermissionService { + + + @Override + public List allPermissions() { + + CloudPermissionDo permissionDo = new CloudPermissionDo(); + permissionDo.setDeleteFlag(Boolean.FALSE); + Wrapper wrapper = new QueryWrapper<>(permissionDo); + return baseMapper.selectList(wrapper); + } + + @Override + public List customPlatformRoleMaxPermission() { + CloudPermissionDo permissionDo = new CloudPermissionDo(); + permissionDo.setDeleteFlag(Boolean.FALSE); + permissionDo.setPlatformRolePermission(Boolean.TRUE); + Wrapper wrapper = new QueryWrapper<>(permissionDo); + return baseMapper.selectList(wrapper); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudRolePermissionServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudRolePermissionServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..17161974391de76217dc9e0525d6f67db32239ed --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudRolePermissionServiceImpl.java @@ -0,0 +1,67 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudPermissionDo; +import com.hnkylin.cloud.core.domain.CloudRolePermissionDo; +import com.hnkylin.cloud.core.mapper.CloudRolePermissionMapper; +import com.hnkylin.cloud.core.service.CloudRolePermissionService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +@Service +public class CloudRolePermissionServiceImpl extends ServiceImpl + implements CloudRolePermissionService { + + + @Override + public List listRolePermissionByRoleId(Integer roleId) { + CloudRolePermissionDo rolePermissionDo = new CloudRolePermissionDo(); + rolePermissionDo.setDeleteFlag(Boolean.FALSE); + rolePermissionDo.setRoleId(roleId); + Wrapper wrapper = new QueryWrapper<>(rolePermissionDo); + return baseMapper.selectList(wrapper); + } + + @Override + @Transactional + public void deleteRolePermissionByRole(Integer roleId, Integer deleteBy, Date deleteTime) { + //删除角色拥有的权限 + CloudRolePermissionDo rolePermissionDo = new CloudRolePermissionDo(); + rolePermissionDo.setRoleId(roleId); + rolePermissionDo.setDeleteFlag(Boolean.FALSE); + Wrapper rolePermissionWrapper = new QueryWrapper<>(rolePermissionDo); + List rolePermissionList = baseMapper.selectList(rolePermissionWrapper); + if (!rolePermissionList.isEmpty()) { + rolePermissionList.forEach(item -> { + item.setDeleteFlag(Boolean.TRUE); + item.setDeleteBy(deleteBy); + item.setDeleteTime(deleteTime); + }); + updateBatchById(rolePermissionList); + } + } + + @Override + @Transactional + public void insertRolePermission(Integer roleId, List permissionIds, Integer createBy, Date createTime) { + if (Objects.nonNull(permissionIds) && !permissionIds.isEmpty()) { + List rolePermissionList = new ArrayList<>(permissionIds.size()); + permissionIds.forEach(item -> { + CloudRolePermissionDo cloudRolePermissionDo = CloudRolePermissionDo.builder() + .roleId(roleId).permissionId(item).build(); + cloudRolePermissionDo.setCreateBy(createBy); + cloudRolePermissionDo.setCreateTime(createTime); + rolePermissionList.add(cloudRolePermissionDo); + + }); + saveBatch(rolePermissionList); + } + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudRoleServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudRoleServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b56c5c70145bd91ca17cf738ac7082ce3edb255f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudRoleServiceImpl.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.mapper.CloudRoleMapper; +import com.hnkylin.cloud.core.service.CloudRoleService; +import org.springframework.stereotype.Service; + +@Service +public class CloudRoleServiceImpl extends ServiceImpl + implements CloudRoleService { + + + @Override + public CloudRoleDo getOrgRole() { + CloudRoleDo cloudRoleDo = new CloudRoleDo(); + cloudRoleDo.setRoleType(RoleType.ORG); + cloudRoleDo.setDeleteFlag(false); + QueryWrapper queryWrapper = new QueryWrapper(cloudRoleDo); + return getOne(queryWrapper); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserMachineServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserMachineServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..34ac589c473604c4b2efad354d85ca9aeb87c0d3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserMachineServiceImpl.java @@ -0,0 +1,40 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.mapper.CloudUserMachineMapper; +import com.hnkylin.cloud.core.service.CloudUserMachineService; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class CloudUserMachineServiceImpl extends ServiceImpl implements + CloudUserMachineService { + + + @Override + public CloudUserMachineDo getUserMachineDoByUuid(String uuid) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setMachineUuid(uuid); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + CloudUserMachineDo userMachineDo = getOne(queryWrapper); + return userMachineDo; + } + + @Override + public CloudUserMachineDo getUserMachineDoByUuidAndUserId(String uuid, Integer userId) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setMachineUuid(uuid); + cloudUserMachineDo.setUserId(userId); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + CloudUserMachineDo userMachineDo = getOne(queryWrapper); + return userMachineDo; + } + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserRoleServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserRoleServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..da29b759f687ab97d0c6afc462e4c3dab1682050 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserRoleServiceImpl.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.core.domain.CloudUserRoleDo; +import com.hnkylin.cloud.core.mapper.CloudUserRoleMapper; +import com.hnkylin.cloud.core.service.CloudUserRoleService; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class CloudUserRoleServiceImpl extends ServiceImpl + implements CloudUserRoleService { + + + @Override + public CloudUserRoleDo getUserRoleByUserId(Integer userId) { + CloudUserRoleDo userRoleDo = new CloudUserRoleDo(); + userRoleDo.setDeleteFlag(Boolean.FALSE); + userRoleDo.setUserId(userId); + Wrapper wrapper = new QueryWrapper<>(userRoleDo); + List userRoleDoList = baseMapper.selectList(wrapper); + + return userRoleDoList.isEmpty() ? null : userRoleDoList.get(0); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..af0ef907db026246d861aa2e4d5ba2edddaefbec --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudUserServiceImpl.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudUserRoleDo; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.mapper.CloudUserMapper; +import com.hnkylin.cloud.core.service.CloudRoleService; +import com.hnkylin.cloud.core.service.CloudUserRoleService; +import com.hnkylin.cloud.core.service.CloudUserService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +@Service +public class CloudUserServiceImpl extends ServiceImpl implements CloudUserService { + + + @Override + public CloudUserDo queryUserByUserName(String userName) { + CloudUserDo cloudUserDo = CloudUserDo.builder().userName(userName).build(); + cloudUserDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(cloudUserDo); + List list = baseMapper.selectList(wrapper); + return list.isEmpty() ? null : list.get(0); + } + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcCpuServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcCpuServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..37eb517aa97b8657c7188fccedb18799bfc8b747 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcCpuServiceImpl.java @@ -0,0 +1,97 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudVdcCpuDo; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.mapper.CloudVdcCpuMapper; +import com.hnkylin.cloud.core.service.CloudVdcCpuService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class CloudVdcCpuServiceImpl extends ServiceImpl + implements CloudVdcCpuService { + + + @Resource + private CloudVdcService vdcService; + + @Override + public Integer totalCpuByVdcId(Integer vdcId) { + CloudVdcCpuDo queryVdcCpuDo = new CloudVdcCpuDo(); + queryVdcCpuDo.setDeleteFlag(false); + queryVdcCpuDo.setVdcId(vdcId); + QueryWrapper vdcCpuWrapper = new QueryWrapper<>(queryVdcCpuDo); + List vdcCpuList = getBaseMapper().selectList(vdcCpuWrapper); + return vdcCpuList.isEmpty() ? 0 : vdcCpuList.stream().collect(Collectors.summingInt(CloudVdcCpuDo::getVcpus)); + } + + + @Override + public Integer totalCpuByVdcIdAndArchitectureType(Integer vdcId, ArchitectureType architectureType) { + CloudVdcCpuDo queryVdcCpuDo = new CloudVdcCpuDo(); + queryVdcCpuDo.setDeleteFlag(false); + queryVdcCpuDo.setVdcId(vdcId); + queryVdcCpuDo.setArchitecture(architectureType); + QueryWrapper vdcCpuWrapper = new QueryWrapper<>(queryVdcCpuDo); + List vdcCpuList = getBaseMapper().selectList(vdcCpuWrapper); + return vdcCpuList.isEmpty() ? null : + vdcCpuList.stream().collect(Collectors.summingInt(CloudVdcCpuDo::getVcpus)); + } + + + @Override + public Integer totalChildVdcCpuByParentIdAndArchitectureType(Integer parentVdcId, + ArchitectureType architectureType) { + List childVdcIdList = vdcService.getChildVdcIdList(parentVdcId); + + if (childVdcIdList.isEmpty()) { + return 0; + } + CloudVdcCpuDo queryVdcCpuDo = new CloudVdcCpuDo(); + queryVdcCpuDo.setDeleteFlag(false); + if (Objects.nonNull(architectureType)) { + queryVdcCpuDo.setArchitecture(architectureType); + } + + QueryWrapper vdcCpuWrapper = new QueryWrapper<>(queryVdcCpuDo); + vdcCpuWrapper.in("vdc_id", childVdcIdList); + List vdcCpuList = getBaseMapper().selectList(vdcCpuWrapper); + return vdcCpuList.isEmpty() ? 0 : vdcCpuList.stream().collect(Collectors.summingInt(CloudVdcCpuDo::getVcpus)); + } + + + @Override + public List listVDdcCpuByVdc(Integer vdcId) { + CloudVdcCpuDo queryVdcCpuDo = new CloudVdcCpuDo(); + queryVdcCpuDo.setDeleteFlag(false); + queryVdcCpuDo.setVdcId(vdcId); + QueryWrapper vdcCpuWrapper = new QueryWrapper<>(queryVdcCpuDo); + List vdcCpuList = getBaseMapper().selectList(vdcCpuWrapper); + return vdcCpuList; + } + + + @Override + @Transactional + public void deleteByVdcId(Integer vdcId, Integer deleteUser) { + List cpuDoList = listVDdcCpuByVdc(vdcId); + if (!cpuDoList.isEmpty()) { + cpuDoList.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(deleteUser); + item.setDeleteTime(new Date()); + }); + updateBatchById(cpuDoList); + } + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcMemServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcMemServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7c2d6518ee8cc5124addafa47d26688688f59f --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcMemServiceImpl.java @@ -0,0 +1,121 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudVdcMemDo; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.mapper.CloudVdcMemMapper; +import com.hnkylin.cloud.core.service.CloudVdcMemService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class CloudVdcMemServiceImpl extends ServiceImpl + implements CloudVdcMemService { + + + @Resource + private CloudVdcService vdcService; + + @Override + public CloudVdcMemDo totalMemByVdcId(Integer vdcId) { + CloudVdcMemDo totalMemDo = new CloudVdcMemDo(); + totalMemDo.setMem(0); + totalMemDo.setMemUnit(MemUnit.GB); + + CloudVdcMemDo queryVdcMemDo = new CloudVdcMemDo(); + queryVdcMemDo.setDeleteFlag(false); + queryVdcMemDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcMemDo); + List list = getBaseMapper().selectList(wrapper); + if (!list.isEmpty()) { + int totalMem = list.stream().collect(Collectors.summingInt(CloudVdcMemDo::getMem)); + totalMemDo.setMem(totalMem); + totalMemDo.setMemUnit(list.get(0).getMemUnit()); + } + return totalMemDo; + } + + + @Override + public CloudVdcMemDo totalMemByVdcIdAndArchitectureType(Integer vdcId, ArchitectureType architectureType) { + + CloudVdcMemDo queryVdcMemDo = new CloudVdcMemDo(); + queryVdcMemDo.setDeleteFlag(false); + queryVdcMemDo.setVdcId(vdcId); + queryVdcMemDo.setArchitecture(architectureType); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcMemDo); + List list = getBaseMapper().selectList(wrapper); + + if (!list.isEmpty()) { + CloudVdcMemDo totalMemDo = new CloudVdcMemDo(); + int totalMem = list.stream().collect(Collectors.summingInt(CloudVdcMemDo::getMem)); + totalMemDo.setMem(totalMem); + totalMemDo.setMemUnit(list.get(0).getMemUnit()); + return totalMemDo; + } + return null; + } + + @Override + public CloudVdcMemDo totalChildVdcMemByParentIdAndArchitectureType(Integer parentVdcId, + ArchitectureType architectureType) { + CloudVdcMemDo totalChildMemDo = new CloudVdcMemDo(); + totalChildMemDo.setMem(0); + totalChildMemDo.setMemUnit(MemUnit.GB); + List childVdcIdList = vdcService.getChildVdcIdList(parentVdcId); + + if (childVdcIdList.isEmpty()) { + return totalChildMemDo; + } + CloudVdcMemDo queryVdcMemDo = new CloudVdcMemDo(); + queryVdcMemDo.setDeleteFlag(false); + if (Objects.nonNull(architectureType)) { + queryVdcMemDo.setArchitecture(architectureType); + } + + QueryWrapper wrapper = new QueryWrapper<>(queryVdcMemDo); + wrapper.in("vdc_id", childVdcIdList); + List list = getBaseMapper().selectList(wrapper); + if (!list.isEmpty()) { + int totalMem = list.stream().collect(Collectors.summingInt(CloudVdcMemDo::getMem)); + totalChildMemDo.setMem(totalMem); + totalChildMemDo.setMemUnit(list.get(0).getMemUnit()); + + } + return totalChildMemDo; + } + + + @Override + public List listVdcMemByVdcId(Integer vdcId) { + CloudVdcMemDo queryVdcMemDo = new CloudVdcMemDo(); + queryVdcMemDo.setDeleteFlag(false); + queryVdcMemDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcMemDo); + List list = getBaseMapper().selectList(wrapper); + return list; + } + + @Override + @Transactional + public void deleteByVdcId(Integer vdcId, Integer deleteUser) { + List list = listVdcMemByVdcId(vdcId); + if (!list.isEmpty()) { + list.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(deleteUser); + item.setDeleteTime(new Date()); + }); + updateBatchById(list); + } + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..aebda01ea19ef80640212cfeb6c4ecb1b36d7be4 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcServiceImpl.java @@ -0,0 +1,99 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.domain.CloudOrgVdcDo; +import com.hnkylin.cloud.core.domain.CloudOrganizationDo; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.core.mapper.CloudVdcMapper; +import com.hnkylin.cloud.core.service.CloudOrgVdcService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class CloudVdcServiceImpl extends ServiceImpl + implements CloudVdcService { + + + @Resource + private CloudOrgVdcService cloudOrgVdcService; + + + @Override + public List getChildVdcList(Integer parentVdcId) { + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + queryVdcDo.setParentId(parentVdcId); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + return getBaseMapper().selectList(vdcWrapper); + } + + @Override + public List getChildVdcIdList(Integer parentVdcId) { + List childVdcLIst = getChildVdcList(parentVdcId); + return childVdcLIst.stream().map(CloudVdcDo::getId).collect(Collectors.toList()); + } + + @Override + public List vdcListByZone(Integer zoneId) { + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + queryVdcDo.setZoneId(zoneId); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + return getBaseMapper().selectList(vdcWrapper); + } + + @Override + public CloudVdcDo getVdcByOrgId(Integer orgId) { + CloudOrgVdcDo orgVdc = cloudOrgVdcService.queryOrgVdcByOrgId(orgId); + return Objects.nonNull(orgVdc) ? getById(orgVdc.getVdcId()) : null; + } + + @Override + public List getFirstVdcListByZone(Integer zoneId) { + CloudVdcDo vdcDo = new CloudVdcDo(); + vdcDo.setZoneId(zoneId); + vdcDo.setParentId(KylinCommonConstants.TOP_PARENT_ID); + Wrapper wrapper = new QueryWrapper<>(vdcDo); + return getBaseMapper().selectList(wrapper); + } + + @Override + public List getAllChildVdcList(Integer parentVdcId) { + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + List allVdcList = list(vdcWrapper); + List allChildVdcList = new ArrayList<>(); + List parents = new ArrayList<>(); + parents.add(parentVdcId); + allChildVdcList.add(getById(parentVdcId)); + getChildList(parents, allChildVdcList, allVdcList); + return allChildVdcList; + } + + /** + * 递归获取子VDC + * + * @param parentIds + * @param childVdcList + * @param allVdcList + */ + private void getChildList(List parentIds, List childVdcList, + List allVdcList) { + List childList = + allVdcList.stream().filter(item -> parentIds.contains(item.getParentId())).collect(Collectors.toList()); + if (childList.isEmpty()) { + return; + } + List newParentIds = childList.stream().map(CloudVdcDo::getId).collect(Collectors.toList()); + childVdcList.addAll(childList); + getChildList(newParentIds, childVdcList, allVdcList); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcStorageServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcStorageServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..849f9367ea263eb505239e6405e3bfe3f8148a90 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudVdcStorageServiceImpl.java @@ -0,0 +1,103 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudVdcCpuDo; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.core.domain.CloudVdcMemDo; +import com.hnkylin.cloud.core.domain.CloudVdcStorageDo; +import com.hnkylin.cloud.core.enums.StorageUnit; +import com.hnkylin.cloud.core.mapper.CloudVdcStorageMapper; +import com.hnkylin.cloud.core.service.CloudVdcService; +import com.hnkylin.cloud.core.service.CloudVdcStorageService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class CloudVdcStorageServiceImpl extends ServiceImpl + implements CloudVdcStorageService { + + + @Resource + private CloudVdcService vdcService; + + @Override + public CloudVdcStorageDo getTotalStorageByVdcId(Integer vdcId) { + CloudVdcStorageDo totalStorageDo = new CloudVdcStorageDo(); + totalStorageDo.setStorage(0); + totalStorageDo.setUnit(StorageUnit.GB); + + CloudVdcStorageDo queryVdcStorageDo = new CloudVdcStorageDo(); + queryVdcStorageDo.setDeleteFlag(false); + queryVdcStorageDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcStorageDo); + List list = getBaseMapper().selectList(wrapper); + if (!list.isEmpty()) { + int totalStorage = list.stream().collect(Collectors.summingInt(CloudVdcStorageDo::getStorage)); + totalStorageDo.setStorage(totalStorage); + totalStorageDo.setUnit(list.get(0).getUnit()); + } + + + return totalStorageDo; + } + + + @Override + public CloudVdcStorageDo getChildVdcTotalStorage(Integer parentVdcId) { + List childVdcIdList = vdcService.getChildVdcIdList(parentVdcId); + CloudVdcStorageDo childTotalStorageDo = new CloudVdcStorageDo(); + childTotalStorageDo.setStorage(0); + childTotalStorageDo.setUnit(StorageUnit.GB); + if (!childVdcIdList.isEmpty()) { + CloudVdcStorageDo queryVdcStorageDo = new CloudVdcStorageDo(); + queryVdcStorageDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcStorageDo); + wrapper.in("vdc_id", childVdcIdList); + List list = getBaseMapper().selectList(wrapper); + if (!list.isEmpty()) { + int totalStorage = list.stream().collect(Collectors.summingInt(CloudVdcStorageDo::getStorage)); + childTotalStorageDo.setStorage(totalStorage); + childTotalStorageDo.setUnit(list.get(0).getUnit()); + } + } + + return childTotalStorageDo; + } + + @Override + @Transactional + public void deleteByVdcId(Integer vdcId, Integer deleteUser) { + CloudVdcStorageDo queryVdcStorageDo = new CloudVdcStorageDo(); + queryVdcStorageDo.setDeleteFlag(false); + queryVdcStorageDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcStorageDo); + List list = getBaseMapper().selectList(wrapper); + if (!list.isEmpty()) { + list.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(deleteUser); + item.setDeleteTime(new Date()); + }); + updateBatchById(list); + } + } + + @Override + public CloudVdcStorageDo getByVdcId(Integer vdcId) { + CloudVdcStorageDo queryVdcStorageDo = new CloudVdcStorageDo(); + queryVdcStorageDo.setDeleteFlag(false); + queryVdcStorageDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryVdcStorageDo); + List list = getBaseMapper().selectList(wrapper); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderDeferredMachineServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderDeferredMachineServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f8735bdd934387c9d381ac93d5a013758c3bedde --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderDeferredMachineServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDeferredMachineDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderDeferredMachineMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderDeferredMachineService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderDeferredMachineServiceImpl extends ServiceImpl implements CloudWorkOrderDeferredMachineService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderModifyServerVmServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderModifyServerVmServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0bb5eb45988a2d9f9f6655527e69589573c05601 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderModifyServerVmServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderModifyServerVmDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderModifyServerVmMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderModifyServerVmService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderModifyServerVmServiceImpl extends ServiceImpl implements CloudWorkOrderModifyServerVmService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmDiskServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmDiskServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5b09070226325b20466e009e7485fd5916fbe334 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmDiskServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmDiskDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderServerVmDiskMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderServerVmDiskService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderServerVmDiskServiceImpl extends ServiceImpl implements CloudWorkOrderServerVmDiskService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmIsoServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmIsoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..017f4b6af49c9a17b51d3cc14bd6cde6e5c76691 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmIsoServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmIsoDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderServerVmIsoMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderServerVmIsoService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderServerVmIsoServiceImpl extends ServiceImpl implements CloudWorkOrderServerVmIsoService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmNetworkServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmNetworkServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..59d3551cf9f2919aeff7531c3ea598bd45385f53 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmNetworkServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmNetworkDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderServerVmNetworkMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderServerVmNetworkService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderServerVmNetworkServiceImpl extends ServiceImpl implements CloudWorkOrderServerVmNetworkService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..65dab298323526cbd2bef8ea0ac4321f99856198 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServerVmServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderServerVmDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderServerVmMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderServerVmService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderServerVmServiceImpl extends ServiceImpl implements CloudWorkOrderServerVmService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4dec1bd1ca71a74e81b3fdf202a3b77bf0c2e782 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderServiceImpl extends ServiceImpl implements + CloudWorkOrderService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderUserServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderUserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e95ad64195815b9c246b0758834a6b0a84472606 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderUserServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderUserDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderUserMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderUserService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderUserServiceImpl extends ServiceImpl + implements CloudWorkOrderUserService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderVdcCpuMemServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderVdcCpuMemServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..07e1e26f51ca39a02701980e62e84c8ed876ebd6 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderVdcCpuMemServiceImpl.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcCpuMemDo; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderVdcCpuMemMapper; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderVdcMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderVdcCpuMemService; +import com.hnkylin.cloud.core.service.CloudWorkOrderVdcService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderVdcCpuMemServiceImpl extends ServiceImpl + implements CloudWorkOrderVdcCpuMemService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderVdcServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderVdcServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..23dd252f0f49d0107e538c7b71f9c59d1e66fb7c --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudWorkOrderVdcServiceImpl.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudWorkOrderVdcDo; +import com.hnkylin.cloud.core.mapper.CloudWorkOrderVdcMapper; +import com.hnkylin.cloud.core.service.CloudWorkOrderVdcService; +import org.springframework.stereotype.Service; + +@Service +public class CloudWorkOrderVdcServiceImpl extends ServiceImpl + implements CloudWorkOrderVdcService { + + +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudZoneClusterServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudZoneClusterServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..09cb3fe5db411c8d1bad1802ff38369dc499e2d3 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudZoneClusterServiceImpl.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudVdcCpuDo; +import com.hnkylin.cloud.core.domain.CloudZoneClusterDo; +import com.hnkylin.cloud.core.mapper.CloudZoneClusterMapper; +import com.hnkylin.cloud.core.service.CloudZoneClusterService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class CloudZoneClusterServiceImpl extends ServiceImpl + implements CloudZoneClusterService { + + @Override + public CloudZoneClusterDo getByClusterId(Integer clusterId) { + CloudZoneClusterDo zoneClusterDo = new CloudZoneClusterDo(); + zoneClusterDo.setDeleteFlag(false); + zoneClusterDo.setClusterId(clusterId); + QueryWrapper wrapper = new QueryWrapper<>(zoneClusterDo); + List zoneClusterList = getBaseMapper().selectList(wrapper); + return zoneClusterList.isEmpty() ? null : zoneClusterList.get(0); + + } + + @Override + public List listZoneClusterByZone(Integer zoneId) { + CloudZoneClusterDo queryZoneClusterDo = new CloudZoneClusterDo(); + queryZoneClusterDo.setDeleteFlag(false); + queryZoneClusterDo.setZoneId(zoneId); + Wrapper zoneClusterWrapper = new QueryWrapper<>(queryZoneClusterDo); + return getBaseMapper().selectList(zoneClusterWrapper); + } +} diff --git a/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudZoneServiceImpl.java b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudZoneServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5e3fe4f1c6667e2c710f2f8df152c3fb9c0d5145 --- /dev/null +++ b/mcp-cloud-core/src/main/java/com/hnkylin/cloud/core/service/impl/CloudZoneServiceImpl.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.core.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnkylin.cloud.core.domain.CloudZoneClusterDo; +import com.hnkylin.cloud.core.domain.CloudZoneDo; +import com.hnkylin.cloud.core.mapper.CloudZoneMapper; +import com.hnkylin.cloud.core.service.CloudZoneClusterService; +import com.hnkylin.cloud.core.service.CloudZoneService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Objects; + +@Service +public class CloudZoneServiceImpl extends ServiceImpl + implements CloudZoneService { + + + @Resource + private CloudZoneClusterService zoneClusterService; + + @Override + public CloudZoneDo getByClusterId(Integer clusterId) { + CloudZoneClusterDo zoneClusterDo = zoneClusterService.getByClusterId(clusterId); + return Objects.nonNull(zoneClusterDo) ? getById(zoneClusterDo.getZoneId()) : null; + } +} diff --git a/mcp-cloud-manage/pom.xml b/mcp-cloud-manage/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..daadb985b30f7ebb527478c72f93c1a50e1c09a3 --- /dev/null +++ b/mcp-cloud-manage/pom.xml @@ -0,0 +1,53 @@ + + + + mcp + com.hnkylin + 1.0-SNAPSHOT + + 4.0.0 + + mcp-cloud-manage + + + + + + mysql + mysql-connector-java + + + + + com.alibaba + druid-spring-boot-starter + 1.1.10 + + + + + com.hnkylin + mcp-cloud-core + ${project.version} + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + kcp + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/KylinCloudManageApplication.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/KylinCloudManageApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..a8a52b32a4d19428960c2995ff45473affb8ad1c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/KylinCloudManageApplication.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.manage; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@SpringBootApplication +@ComponentScan(basePackages = {"com.hnkylin"}) +@MapperScan({"com.hnkylin.cloud.core.mapper", "com.hnkylin.cloud.manage.mapper"}) +public class KylinCloudManageApplication { + + public static void main(String[] args) { + SpringApplication.run(KylinCloudManageApplication.class, args); + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/AuthExcludeApiProperties.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/AuthExcludeApiProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..909fc1fed1dd06c63da020a2bb2fd4742dc55d93 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/AuthExcludeApiProperties.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.List; + + +@Component +@ConfigurationProperties("auth") +public class AuthExcludeApiProperties { + + private List authExcludeApis; + + public List getAuthExcludeApis() { + return authExcludeApis; + } + + public void setAuthExcludeApis(List authExcludeApis) { + this.authExcludeApis = authExcludeApis; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/KcpTaskPoolConfig.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/KcpTaskPoolConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..c39db808d7596fa9e594bf103bfda93314846245 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/KcpTaskPoolConfig.java @@ -0,0 +1,42 @@ +package com.hnkylin.cloud.manage.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadPoolExecutor; + +@EnableAsync +@Configuration +public class KcpTaskPoolConfig { + + @Bean("mcClusterInfoExecutor") + public ThreadPoolTaskExecutor mcClusterInfoExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(10); + executor.setMaxPoolSize(20); + executor.setQueueCapacity(500); + executor.setKeepAliveSeconds(60); + executor.setThreadNamePrefix("mcClusterInfoExecutor-"); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.setWaitForTasksToCompleteOnShutdown(true); + executor.setAwaitTerminationSeconds(60); + return executor; + } + + @Bean("mcServerVmListExecutor") + public ThreadPoolTaskExecutor mcServerVmListExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(10); + executor.setMaxPoolSize(20); + executor.setQueueCapacity(500); + executor.setKeepAliveSeconds(60); + executor.setThreadNamePrefix("mcServerVmListExecutor-"); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.setWaitForTasksToCompleteOnShutdown(true); + executor.setAwaitTerminationSeconds(60); + return executor; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/MCConfigProperties.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/MCConfigProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..284d043a47330b8ee1033f4e9e8ea7fdef3eb2b7 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/config/MCConfigProperties.java @@ -0,0 +1,164 @@ +package com.hnkylin.cloud.manage.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.List; + + +@Component +@ConfigurationProperties("mc-config") +@Data +public class MCConfigProperties { + + + private String mcPrefix; + + + private String openPrefix; + + //mc请求统一地址 + private String commonPrefix; + + //创建云服务器 + private String createServerVmUrl; + + //基于ISO创建云服务器 + private String createServerVmByIsoUrl; + + //变更 + private String modifyServerVmUrl; + + //获取网络配置接口地址 + private String networkConfigUrl; + + //根据虚拟机交换机,获取端口组名称 + private String listPortGroupByNameUrl; + + //获取存储位置 + private String storageLocationsListUrl; + + //获取计算资源 + private String getRealServiceListUrl; + + //通过云服务器ID获取云服务器详情 + private String getServervmDetailByServevmIdUrl; + + + //通过云服务器ID获取云服务器详情 + private String getServervmDetailByUuidUrl; + + + //获取存储资源详情 + private String getDataStoreInfoByNameUrl; + + private String isoListUrl; + + private String checkVmServerNameUrl; + + + //分页查询存储资源 + private String pageStorageUrl; + + //分页获取物理主机 + private String pagePhysicalHostUrl; + + //快捷登录 + private String mcQuickLogin; + + + //获取集群基础资源 + private String mcClusterBaseResourceUrl; + + + //获取模板列表 + private String serverVmList; + + //开机 + private String startServerVmUrl; + //关闭云服务器 + private String shutdownServerVmUrl; + //重启云服务器 + private String restartServerVmUrl; + + //强制关闭云服务器 + private String forcedShutdownServerVmUrl; + //强制重启云服务器 + private String forcedRestartServerVmUrl; + + //批量开机 + private String batchStartServerVmUrl; + //批量关机 + private String batchShutdownServerVmUrl; + + //批量重启 + private String batchRebootServerVmUrl; + + //批量把云服务器放入回收站中 + private String batchRemoveMachineToRecycleUrl; + + private String mcLogoLocalFilePath; + + private String logoPath; + + //vncUrl + private String serverVmVncUrl; + + private String serverVmInfoUrl; + private String serverVmSummaryUrl; + private String serverVmAlarmEventUrl; + private String serverVmNetworkUrl; + private String serverVmDiskUrl; + private String serverVmMonitorInfoUrl; + private String serverVmOperateLogUrl; + + //物理主机事件类型查询 + private String serverEventsFilterUrl; + //分页查询物理主机事件 + private String pagePhysicalHostEventUrl; + + //告警日志类型查询 + private String alarmLogFilterUrl; + //分页查询告警日志 + private String pageAlarmLogUrl; + + //服务器虚拟化事件类型 + private String serverVirtualizationEventsFilterUrl; + //分页查询服务器虚拟化事件 + private String pageServerVirtualizationEventUrl; + + //查询告警设置 + private String listAlarmSettingsUrl; + + //修改告警设置 + private String updateAlarmSettingsUrl; + + //获取告警持续时间 + private String getAlarmIntervalUrl; + + //修改告警持续时间 + private String updateAlarmIntervalUrl; + + + //获取告警数量接口 + private String alarmNotificationsUrl; + + + //校验账号密码 + private String checkClusterUserNameAndPasswordUrl; + + + //获取计算资源绑定列表 + private String getClusterBindResourceListUrl; + + //获取云服务器占用已使用资源 + private String serverVmsUsedResourceUrl; + + //云服务器运行情况 + private String serverVmRunningInfoUrl; + + //已读告警 + private String ignoreNotificationsUrl; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/CloudManageRedisConstant.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/CloudManageRedisConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..e3bd3c324b808f9c06c25ddfdde17e549c0d52a2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/CloudManageRedisConstant.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.constant; + +public interface CloudManageRedisConstant { + + /** + * 自服务用户Token令牌缓存KEY前缀 + */ + String CLOUD_MANAGE_LOGIN_USER_CACHE = "kcp:logintoken"; + + String CLOUD_MANAGE_MC_LEADER_NODE = "kcp:mcnode"; + + + String MC_LEADER_URL_KEY = "mcLeaderUrl_"; + + String CLOUD_MANAGE_MC_NODE_LIST_KEY = "nodeList_"; + + + String UID = "uid:"; + + long CLOUD_MANAGE_LOGIN_USER_CACHE_EXPIRE = 2 * 60 * 60 * 1000; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinCloudManageConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinCloudManageConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..890444d0ca9952a2f2bf1fd19d10824898450b66 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinCloudManageConstants.java @@ -0,0 +1,79 @@ +package com.hnkylin.cloud.manage.constant; + + +public interface KylinCloudManageConstants { + + + /** + * JWT加密密钥 + */ + public final static String KYLIN_TOKEN_SECRET = "kylin-ksvd-cloud-manage"; + + /** + * 请求头中token标识 + */ + String KYLIN_ACCESS_TOKEN = "KYLIN_ACCESS_TOKEN"; + /** + * 网卡-网络类型 + */ + String NETWORK_TYPE = "网络类型"; + + /** + * 网卡-网卡类型 + */ + String MODEL_TYPE = "网卡类型"; + /** + * 网卡-交换机 + */ + String NETWORK_SWITCH = "交换机"; + + + /** + * 网卡-端口组 + */ + String NETWORK_PORT = "端口组"; + + String LEFT_BRACKET = "("; + String RIGHT_BRACKET = ")"; + + String SPACE = " "; + + String CHECK_PASS = "审核通过"; + + String OLD_PASSWORD_ERR = "原生密码错误"; + + + Integer TOP_PARENT_ID = 0; + + Integer TOP_ORG_ID = 1; + + String BACKSLASH = "/"; + + String DHCP = "dhcp"; + + //初始页码 + int FIRST_PAGE = 1; + + String BRIDGE = "bridge"; + + String SYSADMINUSER = "sysadmin"; + + String EXCEED_STORAGE = ",存储"; + + String ARCHITECTURE = "架构"; + + String EXCEED_CPU = ",CPU"; + + String EXCEED_MEM = ",内存"; + + String EXCEED_ALLOCATE = ",分配资源不足"; + + + //用户管理标识 + String MANAGE_USER_PERMISSION = "user"; + + //权限管理标识 + String MANAGE_CLUSTER_PERMISSION = "cluster"; + + +} \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseClusterConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseClusterConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..5048f429479fb2680edba2b1b408c2982548b0ed --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseClusterConstants.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseClusterConstants { + + + String EXIST_CLUSTER_NAME = "集群名称已存在,请核对"; + + String CLUSTER_NODE_IS_NOT_EMPTY = "集群节点不能为空"; + + String CLUSTER_NODE_IS_EXIST = "集群节点已存在,请核对"; + + String CLUSTER_NAME_AND_PASSWORD_ERR = "集群账号密码错误,请核对后输入"; + + String CLUSTER_NODE_NOT_VISIT = "节点不能访问,请检查节点是否正确"; + + String CLUSTER_HAS_MACHINE_NOT_DELETE = "有用户拥有该集群下的云服务器,不能删除集群"; + + String ZONE_BIND_CLUSTER_NOT_DELETE = "有可用区绑定了集群,不能删除集群"; + + String MASTER_NODE_CANNOT_DELETE = "当前主节点不能删除"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..4bd901af94dec534ae6890aa9af63fd6cb34b431 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseConstants.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.constant; + +public interface KylinHttpResponseConstants { + + + //------token + String NOT_EXIST_TOKEN = "token不存在"; + String TOKEN_EXPIRE = "token已过期,请重新登录"; + + + //--------用户 + + + String UPDATE_REAL_NAME = "修改真实姓名"; + + + String NOT_LOGIN_KCP_PERMISSION = "你的账号不能登录云管平台"; + + //网络名称重复 + String EXIST_NETWORK_NAME = "网络名称已存在,请核对后重新输入"; + + + String SERVER_VM_NAME_EXIST = "云服务器名称已存在,请修改云服务器名称"; + + String OPERATE_ERR = "操作失败,请联系管理员"; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseOrderConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseOrderConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..6bdf3977ad4044913440d7a192982cb2a1f20c3a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseOrderConstants.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseOrderConstants { + + + //创建虚拟及失败 + String CREATE_SERVERVM_ERR = "创建云服务器失败"; + + String MODIFY_SERVERVM_ERR = "变更云服务器失败"; + // + String WORK_ORDER_ALREADY_CHECK = "该工单已经审核过,不能重复审核"; + + String NOT_PERMISSION_WAIT_LEADER_CHECK = "你不能审核该VDC变更申请,请等到上级管理员进行审核"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseOrgConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseOrgConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..f0909473f0d746b42b1dab4a3140c3b191e7b193 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseOrgConstants.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseOrgConstants { + + + String EXIST_ORG = "组织名已存在,请核对组织名"; + + String HAS_CHILD_NOT_DELETE = "组织存在下级组织,不能删除"; + + String HAS_USER_NOT_DELETE = "组织中存在用户,不能删除"; + + String HAS_SERVERVM_NOT_DELETE = "组织中存在云服务器,不能删除"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseRoleConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseRoleConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..cfd36eb962c550987e2507017b8931ec1c6fd410 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseRoleConstants.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseRoleConstants { + + + String EXIST_ROLE_NAME = "角色名称已存在,请核对"; + + String USER_BIND_ROLE_NOT_DELETE = "存在用户绑定该角色,不能删除"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseServerVmConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseServerVmConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..48fda1d2f773c7c2f679e68d971908bc141c1395 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseServerVmConstants.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseServerVmConstants { + + + String OPERATE_SUCCESS = "操作成功"; + + String OPERATE_ERR = "操作失败"; + + String START_VM_ERR = "开机失败,请联系管理员"; + + String SHUTDOWN_VM_ERR = "关机失败,请联系管理员"; + + String FORCED_SHUTDOWN_VM_ERR = "强制关机失败,请联系管理员"; + + String RESTART_VM_ERR = "重启失败,请联系管理员"; + + String FORCED_RESTART_VM_ERR = "强制重启失败,请联系管理员"; + + String SERVERVM_OVERDUE_NOT_OPERATE = "云服务器已过期不能操作"; + + String BATCH_OPERATE_ERR = "批量操作失败"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseUserConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseUserConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..4f517c8aeb3516063b0c93ebc420575979453224 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseUserConstants.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseUserConstants { + + + String EXIST_USER = "该用户名已存在,请核对用户姓名"; + + String EXIST_REAI_NAME = "该真实姓名存在,请核对真实姓名"; + + String NOT_EXIST_USER = "用户不存在,请重新输入"; + + String PASSWORD_ERR = "密码错误,请重新输入"; + + String USER_NOT_ACTIVATE = "你的账号处于未激活状态,请联系管理员"; + + String OLD_PASSWORD_ERR = "原密码错误,请重新输入"; + + String USER_HAS_MACHINE_NO_DELETE = "拥有云服务器,禁止删除"; + + String SELF_SERVICE_USER_NOT_LOGIN = "你的自服务账号不能管理管理平台"; + + String ORG_EXIST_LEADER_USER = "该组织已存在组织管理员,不能重新添加"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseVdcConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseVdcConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..26b93339003eaed1cb30d6d01c2136ef12544bec --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseVdcConstants.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseVdcConstants { + + + String ZONE_EXIST_BIND = "该可用区已经被绑定,请检查"; + + String VDC_EXCEED_TIER = "已超出5级层级结构限制"; + + Integer VDC_MAX_TIRE = 5; + + String EXIST_VDC_NAME = "名称已存在,请核对"; + + String EXIST_CHILD_VDC = "存在下级VDC,不能删除"; + + String VDC_BIND_ORG = "已有组织绑定该VDC,不能删除"; + + String APPLY_MODIFY_VDC_CHECK_PASS = "变更VDC资源成功"; + + String APPLY_MODIFY_VDC_CHECK_WAIT = "申请变更VDC资源已提交,请等待上级管理员审核"; + + String NOT_PERMISSION_CREATE_FIRST_VDC = "你不能创建一级VDC,请选择上级VDC"; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseZoneConstants.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseZoneConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..9f04c00f7ec2f74234f7b7d785d0b005c85dbf85 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/constant/KylinHttpResponseZoneConstants.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.manage.constant; + +/** + * 组织管理-响应信息 + */ +public interface KylinHttpResponseZoneConstants { + + + String EXIST_ZONE_NAME = "可用区名称已存在,请核对"; + + String EXIST_VDC_NOT_DELETE = "有VDC绑定了该可用区,不能删除"; + + + String ZONE_BIND_VDC_NOT_UNBIND_CLUSTER = "有VDC绑定了该可用区,不能解绑物理集群"; + + String CLUSTER_IS_NOT_EMPTY = "请选择物理集群"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ClusterCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ClusterCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..88096d7028b10a6adf63d246fde3d8fdca24ef74 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ClusterCtrl.java @@ -0,0 +1,175 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.domain.CloudClusterDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterPhysicalHostResp; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterStorageResp; +import com.hnkylin.cloud.manage.entity.mc.resp.NetworkConfigResp; +import com.hnkylin.cloud.manage.entity.mc.resp.NetworkPortGroupResp; +import com.hnkylin.cloud.manage.entity.req.cluster.*; +import com.hnkylin.cloud.manage.entity.req.workorder.QueryPortGroupParam; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.resp.cluster.*; +import com.hnkylin.cloud.manage.service.ClusterService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequestMapping("/api/cluster") +public class ClusterCtrl { + + + @Resource + private ClusterService clusterService; + + + @PostMapping("/checkClusterUserNameAndPassword") + @ParamCheck + public BaseResult checkClusterUserNameAndPassword(@ModelCheck(notNull = true) @RequestBody + CheckClusterNameAndPasswordParam checkClusterNameAndPasswordParam, + @LoginUser LoginUserVo loginUserVo) { + return clusterService.checkClusterUserNameAndPassword(checkClusterNameAndPasswordParam, loginUserVo); + + } + + @PostMapping("/pageStorage") + @ParamCheck + public BaseResult> pageStorage(@ModelCheck(notNull = true) @RequestBody + ClusterStoragePageParam clusterStoragePageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.pageStorage(clusterStoragePageParam, loginUserVo)); + + } + + @PostMapping("/creatCluster") + @ParamCheck + public BaseResult creatCluster(@ModelCheck(notNull = true) @RequestBody CreateClusterParam createClusterParam, + @LoginUser LoginUserVo loginUserVo) { + + clusterService.creatCluster(createClusterParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/pageCluster") + @ParamCheck + public BaseResult> pageCluster(@ModelCheck(notNull = true) @RequestBody + ClusterPageParam clusterPageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.pageCluster(clusterPageParam, loginUserVo)); + + } + + @PostMapping("/getQuickLoginUrl") + @ParamCheck + public BaseResult getQuickLoginUrl(@ModelCheck(notNull = true) @RequestBody + BaseClusterParam baseClusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.getQuickLoginUrl(baseClusterParam, loginUserVo)); + + } + + + @PostMapping("/clusterInfo") + @ParamCheck + public BaseResult clusterInfo(@ModelCheck(notNull = true) @RequestBody + BaseClusterParam baseClusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.clusterInfo(baseClusterParam, loginUserVo)); + + } + + @PostMapping("/pagePhysicalHost") + @ParamCheck + public BaseResult> pagePhysicalHost(@ModelCheck(notNull = true) @RequestBody + ClusterPhysicalHostPageParam clusterPhysicalHostPageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.pagePhysicalHost(clusterPhysicalHostPageParam, loginUserVo)); + + } + + @PostMapping("/clusterDetail") + @ParamCheck + public BaseResult clusterDetail(@ModelCheck(notNull = true) @RequestBody + BaseClusterParam baseClusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.clusterDetail(baseClusterParam, loginUserVo)); + + } + + + @PostMapping("/modifyCluster") + @ParamCheck + public BaseResult modifyCluster(@ModelCheck(notNull = true) @RequestBody ModifyClusterParam modifyClusterParam, + @LoginUser LoginUserVo loginUserVo) { + + clusterService.modifyCluster(modifyClusterParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/deleteCluster") + @ParamCheck + public BaseResult deleteCluster(@ModelCheck(notNull = true) @RequestBody BaseClusterParam baseClusterParam, + @LoginUser LoginUserVo loginUserVo) { + + clusterService.deleteCluster(baseClusterParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/clusterNetworkConfig") + @ParamCheck + public BaseResult mcNetworkConfig(@ModelCheck(notNull = true) @RequestBody + BaseClusterParam baseClusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.mcClusterNetWorkConfig(baseClusterParam, loginUserVo)); + + } + + @PostMapping("/mcPortGroupListByVirtualSwitch") + @ParamCheck + public BaseResult> mcPortGroupListByVirtualSwitch(@RequestBody QueryPortGroupParam queryPortGroupParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.mcPortGroupListByVirtualSwitch(queryPortGroupParam, + loginUserVo)); + + } + + + @PostMapping("/zoneClusterList") + @ParamCheck + public BaseResult> zoneClusterList(@ModelCheck(notNull = true) @RequestBody + BaseZoneParam baseZoneParam) { + return BaseResult.success(clusterService.zoneClusterList(baseZoneParam.getZoneId())); + + } + + @PostMapping("/getLoginUserCluster") + public BaseResult> getLoginUserCluster(@LoginUser LoginUserVo loginUserVo) { + List userVisibleClusterList = clusterService.visibleClusterByUserId(loginUserVo.getUserId()); + List clusterDtoList = new ArrayList<>(); + userVisibleClusterList.forEach(clusterDo -> { + ClusterDto clusterDto = new ClusterDto(); + clusterDto.setClusterId(clusterDo.getId()); + clusterDto.setClusterName(clusterDo.getName()); + clusterDtoList.add(clusterDto); + }); + return BaseResult.success(clusterDtoList); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/IndexCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/IndexCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..2dd02ab477274d19f8fe5afc748d12139158d38b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/IndexCtrl.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.cluster.CheckClusterNameAndPasswordParam; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +/** + * Created by kylin-ksvd on 21-8-5. + */ +@RestController +@RequestMapping("/") +public class IndexCtrl { + + @RequestMapping("/index") + public ModelAndView index() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("index"); + return mv; + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/IndexStatisticCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/IndexStatisticCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..a0a3c4bddcbae68b51a81d1ea4b03e0f72e1252b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/IndexStatisticCtrl.java @@ -0,0 +1,50 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.cluster.CheckClusterNameAndPasswordParam; +import com.hnkylin.cloud.manage.entity.resp.index.IndexStatisticData; +import com.hnkylin.cloud.manage.entity.resp.index.OrgLeaderIndexStatisticData; +import com.hnkylin.cloud.manage.service.IndexStatisticService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; + +/** + * Created by kylin-ksvd on 21-8-5. + */ +@RestController +@RequestMapping("/api") +public class IndexStatisticCtrl { + + @Resource + private IndexStatisticService indexStatisticService; + + @PostMapping("/indexStatistic") + public BaseResult statisticData(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(indexStatisticService.statisticData(loginUserVo)); + + } + + + /** + * 组织管理员登录首页数据 + * + * @param loginUserVo + * @return + */ + @PostMapping("/orgLeaderStatistic") + public BaseResult orgLeaderStatistic(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(indexStatisticService.orgLeaderStatistic(loginUserVo)); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/LoginCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/LoginCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..708a522083140dc1babb876af108d5567f1325bb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/LoginCtrl.java @@ -0,0 +1,48 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.workorder.LoginUserParam; +import com.hnkylin.cloud.manage.entity.resp.TokenRespDto; +import com.hnkylin.cloud.manage.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@RestController +@RequestMapping("/api/") +@Slf4j +public class LoginCtrl { + + @Resource + private UserService userService; + + /** + * 用户登录 + * + * @param loginUserParam 用户参数 + * @return + */ + @ParamCheck + @PostMapping("/login") + public BaseResult login(@ModelCheck(notNull = true) @RequestBody LoginUserParam loginUserParam) { + + return BaseResult.success(userService.login(loginUserParam)); + } + + @PostMapping("/loginOut") + public BaseResult loginOut(@LoginUser LoginUserVo loginUserVo) { + userService.loginOut(loginUserVo); + return BaseResult.success(null); + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/MonitoringCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/MonitoringCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..9a6f62486fab18ca468b94272dcc189449cd96c3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/MonitoringCtrl.java @@ -0,0 +1,165 @@ +package com.hnkylin.cloud.manage.ctrl; + + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.McUpdateAlarmIntervalParam; +import com.hnkylin.cloud.manage.entity.mc.req.McUpdateAlarmSettingsParam; +import com.hnkylin.cloud.manage.entity.mc.req.QueryMcAlarmSettingsParam; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.cluster.ClusterStoragePageParam; +import com.hnkylin.cloud.manage.entity.req.monitor.*; +import com.hnkylin.cloud.manage.entity.resp.monitor.KcpAlarmSettingsResp; +import com.hnkylin.cloud.manage.entity.resp.monitor.PageKcpAlarmLogResp; +import com.hnkylin.cloud.manage.service.MonitorService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + + +@RestController +@RequestMapping("/api/monitoring") +public class MonitoringCtrl { + + @Resource + private MonitorService monitorService; + + @PostMapping("/serverEventTypeList") + @ParamCheck + public BaseResult serverEventTypeList(@ModelCheck(notNull = true) @RequestBody BaseClusterParam clusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.serverEventTypeList(clusterParam, loginUserVo)); + + } + + @PostMapping("/pagePhysicalHostEvent") + @ParamCheck + public BaseResult> pagePhysicalHostEvent(@ModelCheck(notNull = true) @RequestBody PhysicalHostEventParam physicalHostEventParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.pagePhysicalHostEvent(physicalHostEventParam, loginUserVo)); + + } + + @PostMapping("/alarmLogFilterList") + @ParamCheck + public BaseResult alarmLogFilterList(@ModelCheck(notNull = true) @RequestBody BaseClusterParam clusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.alarmLogFilterList(clusterParam, loginUserVo)); + + } + + @PostMapping("/pageAlarmLog") + @ParamCheck + public BaseResult> pageAlarmLog(@ModelCheck(notNull = true) @RequestBody AlarmLogParam alarmLogParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.pageAlarmLog(alarmLogParam, loginUserVo)); + + } + + @PostMapping("/serverVirtualizationEventsFilter") + @ParamCheck + public BaseResult serverVirtualizationEventsFilter(@ModelCheck(notNull = true) @RequestBody BaseClusterParam clusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.serverVirtualizationEventsFilter(clusterParam, loginUserVo)); + + } + + @PostMapping("/pageServerVirtualizationEvent") + @ParamCheck + public BaseResult> pageServerVirtualizationEvent(@ModelCheck(notNull = + true) @RequestBody ServerVirtualizationEventParam serverVirtualizationEventParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.pageServerVirtualizationEvent(serverVirtualizationEventParam, + loginUserVo)); + + } + + + @PostMapping("/listAlarmSettings") + @ParamCheck + public BaseResult> listAlarmSettings(@ModelCheck(notNull = true) @RequestBody QueryMcAlarmSettingsParam queryMcAlarmSettingsParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.listAlarmSettings(queryMcAlarmSettingsParam, loginUserVo)); + + } + + @PostMapping("/updateAlarmSettings") + @ParamCheck + public BaseResult updateAlarmSettings(@ModelCheck(notNull = true) @RequestBody McUpdateAlarmSettingsParam updateAlarmSettingsParam, + @LoginUser LoginUserVo loginUserVo) { + + boolean result = monitorService.updateAlarmSettings(updateAlarmSettingsParam, loginUserVo); + if (result) { + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + + } + + @PostMapping("/getAlarmInterval") + @ParamCheck + public BaseResult getAlarmInterval(@ModelCheck(notNull = true) @RequestBody BaseClusterParam clusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.getAlarmInterval(clusterParam, loginUserVo)); + + } + + @PostMapping("/updateAlarmInterval") + @ParamCheck + public BaseResult updateAlarmInterval(@ModelCheck(notNull = true) @RequestBody McUpdateAlarmIntervalParam updateAlarmIntervalParam, + @LoginUser LoginUserVo loginUserVo) { + + boolean result = monitorService.updateAlarmInterval(updateAlarmIntervalParam, loginUserVo); + if (result) { + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + + } + + @PostMapping("/alarmNotifications") + public BaseResult alarmNotifications(@LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(monitorService.alarmNotifications(loginUserVo)); + + } + + + @PostMapping("/listKcpAlarmSettings") + @ParamCheck + public BaseResult> listKcpAlarmSettings(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.listKcpAlarmSettings(loginUserVo)); + + } + + @PostMapping("/updateKcpAlarmSetting") + @ParamCheck + public BaseResult updateKcpAlarmSetting(@ModelCheck(notNull = true) @RequestBody UpdateKcpAlarmSettingParam updateAlarmIntervalParam, + @LoginUser LoginUserVo loginUserVo) { + + monitorService.updateKcpAlarmSetting(updateAlarmIntervalParam, loginUserVo); + + return BaseResult.success(null); + + } + + @PostMapping("/pageKcpAlarmLog") + @ParamCheck + public BaseResult> pageKcpAlarmLog(@ModelCheck(notNull = true) @RequestBody + PagKcpAlarmLogParam kcpAlarmLogParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(monitorService.pageKcpAlarmLog(kcpAlarmLogParam, loginUserVo)); + + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/NetworkConfigCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/NetworkConfigCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..4e7d488949fbecc56fb54c725e3c55fd931bacbd --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/NetworkConfigCtrl.java @@ -0,0 +1,79 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.NetworkConfigResp; +import com.hnkylin.cloud.manage.entity.mc.resp.NetworkPortGroupResp; +import com.hnkylin.cloud.manage.entity.req.network.BaseNetworkParam; +import com.hnkylin.cloud.manage.entity.req.network.CreateNetworkParam; +import com.hnkylin.cloud.manage.entity.req.network.ModifyNetworkParam; +import com.hnkylin.cloud.manage.entity.req.vdc.BaseVdcParam; +import com.hnkylin.cloud.manage.entity.req.workorder.QueryPortGroupParam; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkConfigRespDto; +import com.hnkylin.cloud.manage.service.NetworkConfigService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/networkConfig") +@Slf4j +public class NetworkConfigCtrl { + + + @Resource + private NetworkConfigService networkConfigService; + + + @PostMapping("/pageNetworkConfig") + public BaseResult> pageNetworkConfig(@RequestBody BasePageParam basePageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(networkConfigService.pageNetworkConfig(basePageParam, loginUserVo)); + + } + + @PostMapping("/listNetworkListByVdcId") + public BaseResult> listNetworkListByVdcId(@RequestBody BaseVdcParam baseVdcParam) { + return BaseResult.success(networkConfigService.listNetworkListByVdcId(baseVdcParam.getVdcId())); + + } + + + @PostMapping("/createNetwork") + @ParamCheck + public BaseResult createNetwork(@ModelCheck(notNull = true) @RequestBody CreateNetworkParam createNetworkParam, + @LoginUser LoginUserVo loginUserVo) { + networkConfigService.createNetwork(createNetworkParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/networkDetail") + @ParamCheck + public BaseResult networkDetail(@ModelCheck(notNull = true) @RequestBody BaseNetworkParam baseNetworkParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(networkConfigService.networkDetail(baseNetworkParam.getNetworkId())); + + } + + @PostMapping("/modifyNetwork") + @ParamCheck + public BaseResult modifyNetwork(@ModelCheck(notNull = true) @RequestBody ModifyNetworkParam modifyNetworkParam, + @LoginUser LoginUserVo loginUserVo) { + networkConfigService.modifyNetwork(modifyNetworkParam, loginUserVo); + return BaseResult.success(null); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/OrganizationCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/OrganizationCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..ed244d6fe6df54303a686c9cc5fc2375e133443e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/OrganizationCtrl.java @@ -0,0 +1,139 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.org.*; +import com.hnkylin.cloud.manage.entity.resp.org.OrgDetailRespDto; +import com.hnkylin.cloud.manage.entity.resp.org.OrgSummaryRespDto; +import com.hnkylin.cloud.manage.entity.resp.org.OrganizationRespDto; +import com.hnkylin.cloud.manage.entity.resp.org.ParentOrgRespDto; +import com.hnkylin.cloud.manage.entity.resp.role.OrgStatisticTreeDto; +import com.hnkylin.cloud.manage.service.OrgService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/org") +@Slf4j +public class OrganizationCtrl { + + @Resource + private OrgService orgService; + + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构 + * + * @param loginUserVo + * @return + */ + @PostMapping("/queryParentOrg") + public BaseResult> queryParentOrg(@ModelCheck(notNull = true) @RequestBody QueryParentOrgParam queryParentOrgParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(orgService.queryParentOrg(queryParentOrgParam, loginUserVo)); + + } + + /** + * 组织管理-主列表 + * + * @param loginUserVo + * @return + */ + @PostMapping("/queryOrgList") + public BaseResult> queryOrgList(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(orgService.queryOrgList(loginUserVo)); + + } + + + @PostMapping("/createOrg") + @ParamCheck + public BaseResult createOrg(@ModelCheck(notNull = true) @RequestBody CreateOrgParam createOrgParam, + @LoginUser LoginUserVo loginUserVo) { + orgService.createOrg(createOrgParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/deleteOrg") + @ParamCheck + public BaseResult deleteOrg(@ModelCheck(notNull = true) @RequestBody BaseOrgParam baseOrgParam, + @LoginUser LoginUserVo loginUserVo) { + orgService.deleteOrg(baseOrgParam, loginUserVo); + return BaseResult.success(null); + } + + /** + * 编辑组织时-获取组织详情 + */ + @PostMapping("/orgDetail") + @ParamCheck + public BaseResult orgDetail(@ModelCheck(notNull = true) @RequestBody BaseOrgParam baseOrgParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(orgService.orgDetail(baseOrgParam, loginUserVo)); + } + + + /** + * 编辑组织 + */ + @PostMapping("/modifyOrg") + @ParamCheck + public BaseResult modifyOrg(@ModelCheck(notNull = true) @RequestBody ModifyOrgParam modifyOrgParam, + @LoginUser LoginUserVo loginUserVo) { + + orgService.modifyOrg(modifyOrgParam, loginUserVo); + return BaseResult.success(null); + } + + + /** + * 修改顶层组织名称 + */ + @PostMapping("/modifyTopOrgName") + @ParamCheck + public BaseResult modifyTopOrgName(@ModelCheck(notNull = true) @RequestBody ModifyTopOrgNameParam modifyOrgParam, + @LoginUser LoginUserVo loginUserVo) { + + orgService.modifyTopOrgName(modifyOrgParam, loginUserVo); + return BaseResult.success(null); + } + + /** + * 组织管理-组织统计树 + * + * @param loginUserVo + * @return + */ + @PostMapping("/orgStatisticTree") + @ParamCheck + public BaseResult> orgStatisticTree(@ModelCheck(notNull = true) @RequestBody + OrgStatisticTreeParam orgStatisticTreeParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(orgService.orgStatisticTree(loginUserVo, orgStatisticTreeParam.getStatisticType())); + + } + + + @PostMapping("/orgSummary") + @ParamCheck + public BaseResult orgSummary(@ModelCheck(notNull = true) @RequestBody + BaseOrgParam baseOrgParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(orgService.orgSummary(baseOrgParam, loginUserVo)); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/PermissionCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/PermissionCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..466f7b1a705950cea4e16142ccc7e54c4e1128f8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/PermissionCtrl.java @@ -0,0 +1,44 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.domain.CloudUserRoleDo; +import com.hnkylin.cloud.core.service.CloudUserRoleService; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.role.BaseRoleParam; +import com.hnkylin.cloud.manage.entity.resp.role.PermissionTreeDto; +import com.hnkylin.cloud.manage.service.PermissionService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/permission") +@Slf4j +public class PermissionCtrl { + + @Resource + private PermissionService permissionService; + + + /** + * 获取自定义平台管理最大可分配权限树 + * + * @return + */ + @PostMapping("/customPlatformRoleMaxPermission") + public BaseResult> customPlatformRoleMaxPermission() { + List permissionTree = + permissionService.customPlatformRoleMaxPermission(); + return BaseResult.success(permissionTree); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/RoleCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/RoleCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..4ab2eb855f9f1384a469289fdf43cc57fa90b8f0 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/RoleCtrl.java @@ -0,0 +1,106 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.org.BaseOrgParam; +import com.hnkylin.cloud.manage.entity.req.role.*; +import com.hnkylin.cloud.manage.entity.resp.role.*; +import com.hnkylin.cloud.manage.service.RoleService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/role") +@Slf4j +public class RoleCtrl { + + + @Resource + private RoleService roleService; + + + @PostMapping("/createRole") + @ParamCheck + public BaseResult createRole(@ModelCheck(notNull = true) @RequestBody CreateRoleParam createRoleParam, + @LoginUser LoginUserVo loginUserVo) { + roleService.createPlatformRole(createRoleParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/deleteRole") + @ParamCheck + public BaseResult deleteRole(@ModelCheck(notNull = true) @RequestBody BaseRoleParam baseRoleParam, + @LoginUser LoginUserVo loginUserVo) { + roleService.deleteRole(baseRoleParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/modifyRole") + @ParamCheck + public BaseResult modifyRole(@ModelCheck(notNull = true) @RequestBody ModifyRoleParam modifyRoleParam, + @LoginUser LoginUserVo loginUserVo) { + roleService.modifyRole(modifyRoleParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/modifyRoleDetail") + @ParamCheck + public BaseResult modifyRoleDetail(@ModelCheck(notNull = true) @RequestBody BaseRoleParam baseRoleParam) { + + return BaseResult.success(roleService.modifyRoleDetail(baseRoleParam)); + + } + + + @PostMapping("/roleInfo") + @ParamCheck + public BaseResult roleInfo(@ModelCheck(notNull = true) @RequestBody BaseRoleParam baseRoleParam) { + return BaseResult.success(roleService.roleInfo(baseRoleParam)); + + } + + + @PostMapping("/pageRole") + @ParamCheck + public BaseResult> pageRole(@ModelCheck(notNull = true) @RequestBody + RolePageParam rolePageParam) { + + return BaseResult.success(roleService.pageRole(rolePageParam)); + + } + + + @PostMapping("/listRole") + @ParamCheck + public BaseResult> listRole(@ModelCheck(notNull = true) @RequestBody + SearchRoleParam searchRoleParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(roleService.listRole(searchRoleParam, loginUserVo)); + + } + + @PostMapping("/allocateRolePermission") + public BaseResult> allocateRolePermission(@RequestBody AllocateRolePermissionParam + allocateRolePermissionParam, + @LoginUser LoginUserVo loginUserVo) { + roleService.allocateRolePermission(allocateRolePermissionParam, loginUserVo); + return BaseResult.success(null); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ServerVmCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ServerVmCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..ea501ac5e1f9a96b3f45b4d98ac68171c4cb43e3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ServerVmCtrl.java @@ -0,0 +1,263 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.common.servervm.McServerVmLogResp; +import com.hnkylin.cloud.core.common.servervm.ServerVmBaseParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchOperateParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmMonitorInfoRespDto; +import com.hnkylin.cloud.core.enums.McStartVmErrorCode; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseServerVmConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmOperateLogPageParam; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmPageParam; +import com.hnkylin.cloud.manage.entity.resp.serverVm.PageServerVmRespDto; +import com.hnkylin.cloud.manage.entity.resp.serverVm.ServerVmZoneOrgTreeRespDto; +import com.hnkylin.cloud.manage.service.ServerVmService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +@RestController +@RequestMapping("/api/serverVm") +public class ServerVmCtrl { + + + @Resource + private ServerVmService serverVmService; + + + @PostMapping("/zoneOrgTree") + public BaseResult> serverVmZoneTree(@ModelCheck(notNull = true) @RequestBody BaseClusterParam baseClusterParam + , @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(serverVmService.serverVmZoneTree(baseClusterParam.getClusterId(), loginUserVo)); + + } + + + @PostMapping("/serverVmList") + @ParamCheck + public BaseResult> serverVmList(@ModelCheck(notNull = true) @RequestBody ServerVmPageParam serverVmPageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(serverVmService.serverVmList(serverVmPageParam, loginUserVo)); + + } + + @PostMapping("/startServerVm") + @ParamCheck + public BaseResult startServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + + McStartVmErrorCode errorCode = serverVmService.startServerVm(serverVmBaseParam, loginUserVo); + if (Objects.equals(errorCode, McStartVmErrorCode.SUCCESS)) { + return BaseResult.success(null); + } + return BaseResult.error(errorCode.getErrorMsg()); + + } + + + @PostMapping("/shutdownServerVm") + @ParamCheck + public BaseResult shutdownServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + boolean result = serverVmService.shutdownServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseServerVmConstants.SHUTDOWN_VM_ERR); + + } + + @PostMapping("/forcedShutdownServerVm") + @ParamCheck + public BaseResult forcedShutdownServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + boolean result = serverVmService.forcedShutdownServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseServerVmConstants.FORCED_SHUTDOWN_VM_ERR); + + } + + + @PostMapping("/restartServerVm") + @ParamCheck + public BaseResult restartServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + boolean result = serverVmService.restartServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseServerVmConstants.RESTART_VM_ERR); + + } + + @PostMapping("/forcedRestartServerVm") + @ParamCheck + public BaseResult forcedRestartServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + boolean result = serverVmService.forcedRestartServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseServerVmConstants.FORCED_RESTART_VM_ERR); + + } + + @PostMapping("/batchStartServerVm") + @ParamCheck + public BaseResult batchStartServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + + return serverVmService.batchStartServerVm(serverVmBatchOperateParam, loginUserVo); + + + } + + @PostMapping("/batchShutdownServerVm") + @ParamCheck + public BaseResult batchShutdownServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + return serverVmService.batchShutdownServerVm(serverVmBatchOperateParam, loginUserVo); + + } + + @PostMapping("/batchRebootServerVm") + @ParamCheck + public BaseResult batchRebootServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + return serverVmService.batchRebootServerVm(serverVmBatchOperateParam, loginUserVo); + } + + @PostMapping("/deleteServerVm") + @ParamCheck + public BaseResult deleteServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + + return serverVmService.deleteServerVm(serverVmBaseParam, loginUserVo); + } + + @PostMapping("/batchDeleteServerVm") + @ParamCheck + public BaseResult batchDeleteServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + + return serverVmService.batchDeleteServerVm(serverVmBatchOperateParam, loginUserVo); + } + + @GetMapping("/downLoadServerVmLog") + public BaseResult> downLoadServerVmLog(@RequestParam(name = "mcServerVmLogoPath") String mcServerVmLogoPath, + @RequestParam(name = "mcServerVmLogoName") String mcServerVmLogoName, + @RequestParam(name = "serverVmUuid") String serverVmUuid) { + + return BaseResult.success(serverVmService.downLoadServerVmLog(mcServerVmLogoPath, mcServerVmLogoName, + serverVmUuid)); + + } + + @PostMapping("/getVncUrl") + @ParamCheck + public BaseResult getVncUrl(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.getVncUrl(serverVmBaseParam, loginUserVo)); + } + + @PostMapping("/serverVmInfo") + @ParamCheck + public BaseResult serverVmInfo(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.serverVmInfo(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmSummary") + @ParamCheck + public BaseResult serverVmSummary(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.serverVmSummary(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmAlarmEvent") + @ParamCheck + public BaseResult> serverVmAlarmEvent(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam + , @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.serverVmAlarmEvent(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmNetwork") + @ParamCheck + public BaseResult> serverVmNetwork(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, + @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.serverVmNetwork(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmDisk") + @ParamCheck + public BaseResult> serverVmDisk(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.serverVmDisk(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmMonitor") + @ParamCheck + public BaseResult serverVmMonitor(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(serverVmService.serverVmMonitor(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmOperateLog") + @ParamCheck + public BaseResult> serverVmOperateLog(@ModelCheck(notNull = true) @RequestBody + ServerVmOperateLogPageParam + serverVmOperateLogPageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(serverVmService.serverVmOperateLog(serverVmOperateLogPageParam, loginUserVo)); + + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/UserCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/UserCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..6b3f710c97093686307975b2fc0569d4413f37ed --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/UserCtrl.java @@ -0,0 +1,103 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.user.*; +import com.hnkylin.cloud.manage.entity.resp.user.ModifyUserInfoRespDto; +import com.hnkylin.cloud.manage.entity.resp.user.PageUserRespDto; +import com.hnkylin.cloud.manage.entity.resp.user.UserInfoRespDto; +import com.hnkylin.cloud.manage.service.UserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/api/user") +@Slf4j +public class UserCtrl { + + + @Resource + private UserService userService; + + + @PostMapping("/userInfo") + public BaseResult userInfo(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(userService.userInfo(loginUserVo)); + + } + + + @PostMapping("/resetPassword") + @ParamCheck + public BaseResult resetPassword(@ModelCheck(notNull = true) @RequestBody ResetPasswordParam resetPasswordParam, @LoginUser LoginUserVo loginUserVo) { + userService.resetPassword(loginUserVo, resetPasswordParam); + return BaseResult.success("success"); + + } + + @PostMapping("/createUser") + @ParamCheck + public BaseResult createUser(@ModelCheck(notNull = true) @RequestBody CreateUserParam createUserParam, + @LoginUser LoginUserVo loginUserVo) { + userService.createUser(createUserParam, loginUserVo); + return BaseResult.success("success"); + + } + + @PostMapping("/modifyUser") + @ParamCheck + public BaseResult modifyUser(@ModelCheck(notNull = true) @RequestBody ModifyUserParam modifyUserParam, + @LoginUser LoginUserVo loginUserVo) { + userService.modifyUser(modifyUserParam, loginUserVo); + return BaseResult.success("success"); + + } + + + @PostMapping("/modifyUserInfo") + @ParamCheck + public BaseResult modifyUserInfo(@ModelCheck(notNull = true) @RequestBody BaseUserParam baseUserParam) { + return BaseResult.success(userService.modifyUserInfo(baseUserParam)); + + } + + @PostMapping("/deleteUser") + @ParamCheck + public BaseResult deleteUser(@ModelCheck(notNull = true) @RequestBody BaseUserParam baseUserParam, + @LoginUser LoginUserVo loginUserVo) { + userService.deleteUser(baseUserParam, loginUserVo); + return BaseResult.success("success"); + + } + + @PostMapping("/batchDeleteUser") + @ParamCheck + public BaseResult batchDeleteUser(@ModelCheck(notNull = true) @RequestBody BatchDeleteUserParam batchDeleteUserParam, + @LoginUser LoginUserVo loginUserVo) { + userService.batchDeleteUser(batchDeleteUserParam, loginUserVo); + return BaseResult.success("success"); + + } + + + @PostMapping("/pageUser") + @ParamCheck + public BaseResult> pageUser(@ModelCheck(notNull = true) @RequestBody + PageUserParam pageUserParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(userService.pageUser(pageUserParam, loginUserVo)); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/VdcCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/VdcCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..ef56f5787a52da06de2bbedc98ebdf4dc9895682 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/VdcCtrl.java @@ -0,0 +1,133 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.org.BaseOrgParam; +import com.hnkylin.cloud.manage.entity.req.vdc.*; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.resp.vdc.*; +import com.hnkylin.cloud.manage.service.VdcService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/vdc") +@Slf4j +public class VdcCtrl { + + + @Resource + private VdcService vdcService; + + @PostMapping("/queryNotBindVdcByParentOrgId") + public BaseResult> queryNotBindVdcByParentOrgId(@ModelCheck(notNull = true) @RequestBody BaseOrgParam baseOrgParam + , @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.queryNotBindVdcByParentOrgId(baseOrgParam, loginUserVo)); + + } + + + @PostMapping("/queryClusterBaseResource") + public BaseResult queryClusterBaseResource(@ModelCheck(notNull = true) @RequestBody BaseClusterParam baseClusterParam + , @LoginUser LoginUserVo loginUserVo) { + vdcService.queryClusterBaseResource(baseClusterParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/vdcTreeByZone") + @ParamCheck + public BaseResult> vdcTreeByZone(@ModelCheck(notNull = true) @RequestBody BaseZoneParam baseZoneParam, @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.vdcTreeByZone(baseZoneParam, loginUserVo)); + + } + + + @PostMapping("/checkCreateVdc") + @ParamCheck + public BaseResult checkCreateVdc(@ModelCheck(notNull = true) @RequestBody CheckCreateVdcParam checkCreateVdcParam + , @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.checkCreateVdc(checkCreateVdcParam, loginUserVo)); + + } + + + @PostMapping("/createVdc") + @ParamCheck + public BaseResult createVdc(@ModelCheck(notNull = true) @RequestBody CreateVdcParam createVdcParam + , @LoginUser LoginUserVo loginUserVo) { + vdcService.createVdc(createVdcParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/vdcTree") + public BaseResult> vdcTree(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.vdcTree(loginUserVo)); + + } + + @PostMapping("/vdcDetail") + @ParamCheck + public BaseResult vdcDetail(@ModelCheck(notNull = true) @RequestBody BaseVdcParam baseVdcParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.vdcDetail(baseVdcParam, loginUserVo)); + + } + + + @PostMapping("/deleteVdc") + @ParamCheck + public BaseResult deleteVdc(@ModelCheck(notNull = true) @RequestBody BaseVdcParam baseVdcParam, + @LoginUser LoginUserVo loginUserVo) { + vdcService.deleteVdc(baseVdcParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/modifyVdcDetail") + @ParamCheck + public BaseResult modifyVdcDetail(@ModelCheck(notNull = true) @RequestBody BaseVdcParam baseVdcParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.modifyVdcDetail(baseVdcParam, loginUserVo)); + + } + + + @PostMapping("/modifyVdc") + @ParamCheck + public BaseResult modifyVdc(@ModelCheck(notNull = true) @RequestBody ModifyVdcParam modifyVdcParam + , @LoginUser LoginUserVo loginUserVo) { + vdcService.modifyVdc(modifyVdcParam, loginUserVo); + return BaseResult.success(null); + } + + + @PostMapping("/modifyVdcResourceDetail") + @ParamCheck + public BaseResult modifyVdcResourceDetail(@ModelCheck(notNull = true) @RequestBody BaseVdcParam baseVdcParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(vdcService.modifyVdcResourceDetail(baseVdcParam.getVdcId(), loginUserVo)); + + } + + @PostMapping("/applyModifyVdcResource") + @ParamCheck + public BaseResult applyModifyVdcResource(@ModelCheck(notNull = true) @RequestBody ApplyModifyVdcResourceParam applyModifyVdcResourceParam, + @LoginUser LoginUserVo loginUserVo) { + return vdcService.applyModifyVdcResource(applyModifyVdcResourceParam, loginUserVo); + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/WorkOrderCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/WorkOrderCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..409d44ae8cde93502f7c49975ddb6c5810305986 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/WorkOrderCtrl.java @@ -0,0 +1,272 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.workorder.*; +import com.hnkylin.cloud.manage.entity.resp.workorder.*; +import com.hnkylin.cloud.manage.service.WorkOrderService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@RestController +@RequestMapping("/api/workOrder") +@Slf4j +public class WorkOrderCtrl { + + + @Resource + private WorkOrderService workOrderService; + + + @PostMapping("/pageWorkOrder") + @ParamCheck + public BaseResult> pageWorkOrder(@ModelCheck(notNull = true) @RequestBody + WorkOrderPageParam workOrderPageParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(workOrderService.pageWorkOrder(workOrderPageParam, loginUserVo)); + + } + + + /** + * 批量审核 + * + * @param batchCheckParam + * @return + */ + @ParamCheck + @PostMapping("/batchCheck") + public BaseResult batchCheck(@ModelCheck(notNull = true) @RequestBody BatchCheckParam batchCheckParam, + @LoginUser LoginUserVo loginUserVo) { + workOrderService.batchCheck(batchCheckParam, loginUserVo); + return BaseResult.success(null); + } + + + /** + * 注册审核 + * + * @param commonCheckParam 用户参数 + * @return + */ + @ParamCheck + @PostMapping("/checkPassRegister") + public BaseResult checkPassRegister(@ModelCheck(notNull = true) @RequestBody CommonCheckParam commonCheckParam, + @LoginUser LoginUserVo loginUserVo) { + workOrderService.checkPassRegister(commonCheckParam, loginUserVo); + return BaseResult.success(null); + } + + /** + * 修改帐号审核 + * + * @param commonCheckParam 用户参数 + * @return + */ + @ParamCheck + @PostMapping("/checkPassUpdateUser") + public BaseResult checkPassUpdateUser(@ModelCheck(notNull = true) @RequestBody CommonCheckParam + commonCheckParam, @LoginUser LoginUserVo loginUserVo) { + workOrderService.checkPassUpdateUser(commonCheckParam, loginUserVo); + return BaseResult.success(null); + } + + /** + * 延期云服务器审核 + * + * @param commonCheckParam 用户参数 + * @return + */ + @ParamCheck + @PostMapping("/checkPassDeferred") + public BaseResult checkPassDeferred(@ModelCheck(notNull = true) @RequestBody CommonCheckParam + commonCheckParam, @LoginUser LoginUserVo loginUserVo) { + workOrderService.checkPassDeferred(commonCheckParam, loginUserVo); + return BaseResult.success(null); + } + + /** + * 拒绝工单 + */ + @PostMapping("/refuseWorkOrder") + @ParamCheck + public BaseResult refuseWorkOrder(@ModelCheck(notNull = true) @RequestBody CommonCheckParam + commonCheckParam, @LoginUser LoginUserVo loginUserVo) { + workOrderService.refuseWorkOrder(commonCheckParam, loginUserVo); + return BaseResult.success(null); + + } + + /** + * 申请虚拟机 通过 + */ + @PostMapping("/passApplyServerVm") + @ParamCheck + public BaseResult passApplyServerVm(@ModelCheck(notNull = true) @RequestBody PassApplyServerVmParam + passApplyServerVmParam, @LoginUser LoginUserVo + loginUserVo) { + workOrderService.passApplyServerVm(passApplyServerVmParam, loginUserVo); + return BaseResult.success(null); + + } + + + /** + * 审核云服务器申请时-获取申请详情,及模板详情,计算资源等信息 + */ + @PostMapping("/passApplyServerVmDetail") + @ParamCheck + public BaseResult passApplyServerVmDetail(@ModelCheck(notNull = true) @RequestBody WorkOrderDetailParam workOrderDetailParam, @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(workOrderService.passApplyServerVmDetailRespDto(workOrderDetailParam, loginUserVo)); + + } + + /** + * 申请虚拟机详情 + */ + @PostMapping("/applyServerVmDetail") + @ParamCheck + public BaseResult getApplyServerVmDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(workOrderService.getApplyServerVmDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId(), loginUserVo)); + + } + + + /** + * 审核云服务器变更申请时-获取申请详情,及模板详情,计算资源等信息 + */ + @PostMapping("/passModifyServerVmDetail") + @ParamCheck + public BaseResult passModifyServerVmDetail(@ModelCheck(notNull = true) @RequestBody WorkOrderDetailParam workOrderDetailParam, @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(workOrderService.passModifyServerVmDetail(workOrderDetailParam, loginUserVo)); + + } + + + /** + * 变更云服务器 通过 + */ + @PostMapping("/passModifyServerVm") + @ParamCheck + public BaseResult passModifyServerVm(@ModelCheck(notNull = true) @RequestBody PassModifyServerVmParam + passModifyServerVmParam, @LoginUser LoginUserVo + loginUserVo) { + workOrderService.passModifyServerVm(passModifyServerVmParam, loginUserVo); + return BaseResult.success(null); + + } + + /** + * 变更云服务器详情 + */ + @PostMapping("/modifyServerVmDetail") + @ParamCheck + public BaseResult modifyServerVmDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(workOrderService.getModifyServerVmDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + /** + * 注册账号详情 + */ + @PostMapping("/registerUserDetail") + @ParamCheck + public BaseResult registerUserDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(workOrderService.getWorkOrderUserDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + /** + * 修改账号详情 + */ + @PostMapping("/updateUserDetail") + @ParamCheck + public BaseResult updateUserDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(workOrderService.getWorkOrderUserDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + /** + * 申请延期云服务器详情 + */ + @PostMapping("/applyDeferredDetail") + @ParamCheck + public BaseResult applyDeferredDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(workOrderService.applyDeferredDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + /** + * 申请延期云服务器详情 + */ + @PostMapping("/getWaitCheckCount") + public BaseResult getWaitCheckCount(@LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(workOrderService.getWaitCheckCount(loginUserVo)); + + } + + /** + * 审核变更VDC-获取变更详情 + */ + @PostMapping("/passModifyVdcDetail") + @ParamCheck + public BaseResult passModifyVdcDetail(@ModelCheck(notNull = true) @RequestBody WorkOrderDetailParam workOrderDetailParam, @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(workOrderService.passModifyVdcDetail(workOrderDetailParam, loginUserVo)); + + } + + + @PostMapping("/passModifyVdc") + @ParamCheck + public BaseResult passModifyVdc(@ModelCheck(notNull = true) @RequestBody PassModifyVdcResourceParam passModifyVdcResourceParam, @LoginUser LoginUserVo loginUserVo) { + workOrderService.passModifyVdc(passModifyVdcResourceParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/applyModifyVdcDetail") + @ParamCheck + public BaseResult applyModifyVdcDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + return BaseResult.success(workOrderService.applyModifyVdcDetail(workOrderDetailParam)); + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ZoneCtrl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ZoneCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..934f25319b19d716762b1383fdd80726b819064a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/ctrl/ZoneCtrl.java @@ -0,0 +1,140 @@ +package com.hnkylin.cloud.manage.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.cluster.CanBindClusterParam; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.CreateZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.ModifyZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.PageZoneParam; +import com.hnkylin.cloud.manage.entity.resp.cluster.PageClusterDetailDto; +import com.hnkylin.cloud.manage.entity.resp.zone.PageZoneRespDto; +import com.hnkylin.cloud.manage.entity.resp.zone.ZoneDetailDto; +import com.hnkylin.cloud.manage.entity.resp.zone.ZoneInfoDto; +import com.hnkylin.cloud.manage.service.ClusterService; +import com.hnkylin.cloud.manage.service.ZoneService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/zone") +public class ZoneCtrl { + + + @Resource + private ZoneService zoneService; + + @Resource + private ClusterService clusterService; + + @PostMapping("/createZone") + @ParamCheck + public BaseResult createZone(@ModelCheck(notNull = true) @RequestBody CreateZoneParam zoneParam, + @LoginUser LoginUserVo loginUserVo) { + + zoneService.createZone(zoneParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/modifyZone") + @ParamCheck + public BaseResult modifyZone(@ModelCheck(notNull = true) @RequestBody ModifyZoneParam modifyZoneParam, + @LoginUser LoginUserVo loginUserVo) { + + zoneService.modifyZone(modifyZoneParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/pageZone") + @ParamCheck + public BaseResult> pageZone(@ModelCheck(notNull = true) @RequestBody + PageZoneParam pageZoneParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(zoneService.pageZone(pageZoneParam, loginUserVo)); + + } + + + @PostMapping("/modifyZoneDetail") + @ParamCheck + public BaseResult modifyZoneDetail(@ModelCheck(notNull = true) @RequestBody BaseZoneParam baseZoneParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(zoneService.modifyZoneDetail(baseZoneParam, loginUserVo)); + + } + + + @PostMapping("/zoneDetail") + @ParamCheck + public BaseResult zoneDetail(@ModelCheck(notNull = true) @RequestBody BaseZoneParam baseZoneParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(zoneService.zoneDetail(baseZoneParam, loginUserVo)); + + } + + + /** + * 可用区获取可以绑定的物理集群 + * + * @param canBindClusterParam + * @param loginUserVo + * @return + */ + @PostMapping("/canBindCluster") + @ParamCheck + public BaseResult> canBindCluster(@ModelCheck(notNull = true) @RequestBody + CanBindClusterParam canBindClusterParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.canBindCluster(canBindClusterParam, loginUserVo)); + + } + + + /** + * 可用区已绑定的物理集群 + * + * @param baseZoneParam + * @param loginUserVo + * @return + */ + @PostMapping("/clusterListByZone") + @ParamCheck + public BaseResult> clusterListByZone(@ModelCheck(notNull = true) @RequestBody + BaseZoneParam baseZoneParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(clusterService.clusterListByZone(baseZoneParam, loginUserVo)); + + } + + + @PostMapping("/zoneList") + public BaseResult> zoneList(@LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(zoneService.zoneList(loginUserVo)); + } + + + @PostMapping("/deleteZone") + @ParamCheck + public BaseResult deleteZone(@ModelCheck(notNull = true) @RequestBody BaseZoneParam BaseZoneParam, + @LoginUser LoginUserVo loginUserVo) { + + zoneService.deleteZone(BaseZoneParam, loginUserVo); + return BaseResult.success(null); + + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/LoginUserVo.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/LoginUserVo.java new file mode 100644 index 0000000000000000000000000000000000000000..10a4192e283f84bf7ddbbfbd6057fcb5c2b03ee1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/LoginUserVo.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity; + +import lombok.Data; + +@Data +public class LoginUserVo { + + private String userName; + + private Integer userId; + + private String token; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/CheckServerNameParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/CheckServerNameParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..7b5dceebf12c219a27fa2ca6adf99bfd10cd05fd --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/CheckServerNameParamReq.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +@Data +public class CheckServerNameParamReq { + + + private String servervmName; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/CommonPageParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/CommonPageParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..387d3d3ce8a52b2d5ba2640736e4d9ad1178f736 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/CommonPageParamReq.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +@Data +public class CommonPageParamReq { + + private Integer page; + + private Integer rows; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/ListPortGroupParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/ListPortGroupParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c05c9f4eaf9de7d6afc883c776ef96bd29139ed2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/ListPortGroupParam.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class ListPortGroupParam { + + //虚拟交换机名称 + private String vsname; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McAlarmLogParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McAlarmLogParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..35986b5853ad750c406dacca31db0506406dfb8a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McAlarmLogParamReq.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McAlarmLogParamReq { + + + private Integer page; + + private Integer rows; + + private String sidx; + + private String sord; + + private String startDate; + + private String endDate; + + private String search; + + private String type; + + private String severity; + + private String objectType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCheckClusterNameAndPasswordParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCheckClusterNameAndPasswordParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..e64f62c25daa22f3a811f9a8235421371e8489e7 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCheckClusterNameAndPasswordParamReq.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McCheckClusterNameAndPasswordParamReq { + + + private String clusterAdminName; + + private String clusterAdminPassword; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmDiskParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmDiskParam.java new file mode 100644 index 0000000000000000000000000000000000000000..55ae6566c6754b0daccdf3014a4e8213009fead9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmDiskParam.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McCreateServerVmDiskParam { + + //网络类型 + private String id; + + //磁盘大小 + private Integer diskCapacity; + //变更类型 + private String lastUpdateType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmInterfacesParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmInterfacesParam.java new file mode 100644 index 0000000000000000000000000000000000000000..5b8bffca448d2692847136be100fec40aa93529d --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmInterfacesParam.java @@ -0,0 +1,59 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McCreateServerVmInterfacesParam { + + //网络类型 + private String interfaceType; + + //虚拟交换机 + private String virtualSwitch; + + //端口组 + private String portGroup; + + //网卡类型 + private String modeltype; + + //mac地址 + private String macAddress; + + //安全策略 + private String securityStrategy = NetworkSecurityPolicy.NONE.getValue(); + + //安全组 + private List securityGroup; + + //虚拟防火墙 + private Integer virtualFirewall; + + private String lastUpdateType; + + private Boolean lsbind = false; + + private Boolean manualSetIP = false; + + private Boolean automaticAcqIp = false; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; + + private String queueCount = "0"; + + private String mtuCount = "1500"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmIsoParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmIsoParam.java new file mode 100644 index 0000000000000000000000000000000000000000..1adf9372e29481d762f8338ab818b071f005d884 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmIsoParam.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import com.hnkylin.cloud.core.enums.LastUpdateType; +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McCreateServerVmIsoParam { + + private Integer id = null; + + private String lastUpdateType = LastUpdateType.add.getValue(); + + private String isoSelect; + + private Integer index; + + private String deviceName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..db0165e849598821afe9e7d2e307b58c84774635 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McCreateServerVmParamReq.java @@ -0,0 +1,71 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.McCloneType; +import com.hnkylin.cloud.core.enums.McServerClusterType; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McCreateServerVmParamReq { + + + private String aliasName; + + private String selectCluster; + + private String selectClusterUuid; + + private Integer storageLocationId; + + + private Integer vcpus; + + private Integer memory; + + private String memUnit; + + private String plateformtype; + + private String systemVersion; + + private String operatingSystem; + + private String systemType; + + private Integer vmNumber; + + private String isOpenRemote = "1"; + + private String remotePassword; + + private String description; + + + private List diskCapacity; + + + private List interfaces; + + private String serviceTemplateId; + + private List isoSelect; + + private String applyUser; + + private boolean existHostIpConfig = false; + + //主机模式类型 + private Integer clusterType = McServerClusterType.CUSTOM.getValue(); + + private String selectResourceTagId; + + private String cloneType = McCloneType.FULL_CLONE.getValue().toString(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmDiskParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmDiskParam.java new file mode 100644 index 0000000000000000000000000000000000000000..eb8646e01d636d7f69ae71f31484d470063113c5 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmDiskParam.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McModifyServerVmDiskParam { + + //网络类型 + private String id; + + //磁盘大小 + private Integer diskCapacity; + + //变更类型 + private String lastUpdateType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmInterfacesParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmInterfacesParam.java new file mode 100644 index 0000000000000000000000000000000000000000..0dad990e24273b29f83df36cf5ee2f339630458c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmInterfacesParam.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McModifyServerVmInterfacesParam extends McCreateServerVmInterfacesParam { + + private Integer id; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..5273c5385cd40be549c09deddca832d1835763df --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McModifyServerVmParamReq.java @@ -0,0 +1,56 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import com.hnkylin.cloud.core.enums.McServerClusterType; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McModifyServerVmParamReq { + + + private String uuid; + + private String aliasName; + + private String selectCluster; + + + private String selectClusterUuid; + + private Integer storageLocationId; + + + private Integer vcpus; + + private Integer memory; + + private String memUnit; + + private String plateformtype; + + private String systemVersion; + + private String operatingSystem; + + private String systemType; + + + private List diskCapacity; + + + private List interfaces; + + private boolean existHostIpConfig = false; + + //主机模式类型 + private Integer clusterType = McServerClusterType.CUSTOM.getValue(); + + private String selectResourceTagId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McServerEventParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McServerEventParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..8aa9ce105f0eee30648f779850be880929e3526d --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McServerEventParamReq.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McServerEventParamReq { + + + private Integer page; + + private Integer rows; + + private String sidx; + + private String sord; + + private String startDate; + + private String endDate; + + private String search; + + private String severity; + + private String eventType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McServerVirtualizationEventParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McServerVirtualizationEventParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..4397ef41c3566a6c323257c81a95b0e3aab2ff79 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McServerVirtualizationEventParamReq.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McServerVirtualizationEventParamReq { + + + private Integer page; + + private Integer rows; + + private String sidx; + + private String sord; + + private String startDate; + + private String endDate; + + private String search; + + private String serverType; + + private String severity; + + private String eventType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McUpdateAlarmIntervalParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McUpdateAlarmIntervalParam.java new file mode 100644 index 0000000000000000000000000000000000000000..f62638c263ea01b1750f224c88c5e69ae5da3913 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McUpdateAlarmIntervalParam.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McUpdateAlarmIntervalParam { + + + private Integer clusterId; + + private Integer alarmInterval; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McUpdateAlarmSettingsParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McUpdateAlarmSettingsParam.java new file mode 100644 index 0000000000000000000000000000000000000000..cc9933e6c7c60cb1226c93cd11ab828e849067f6 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/McUpdateAlarmSettingsParam.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class McUpdateAlarmSettingsParam { + + + private Integer clusterId; + + private Integer alarmSettingId; + + + private String urgentValue; + + private String ordinaryValue; + + private String seriousValue; + + private String oper = "edit"; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcAlarmSettingsParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcAlarmSettingsParam.java new file mode 100644 index 0000000000000000000000000000000000000000..83d34798f1203a763b52ba85394ffe6821539a52 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcAlarmSettingsParam.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import com.hnkylin.cloud.core.enums.McAlarmSettingsType; +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Data +public class QueryMcAlarmSettingsParam { + + + private Integer clusterId; + + private McAlarmSettingsType alarmSettingType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcClusterParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcClusterParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..c7cafd3a301bb06bf9f30be80e7d9d8d97fdb526 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcClusterParamReq.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +@Data +public class QueryMcClusterParamReq { + + + private String plateformType; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcServerDetailParamReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcServerDetailParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..a507d8d25da59226a2792054a5ce3dde8843c638 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryMcServerDetailParamReq.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +@Data +public class QueryMcServerDetailParamReq { + + private Integer servervmId; + + private String uuid; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryVdcUsedResourceParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryVdcUsedResourceParam.java new file mode 100644 index 0000000000000000000000000000000000000000..84186d210aaf025990f63aa7f1296ffe12f4f93f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/QueryVdcUsedResourceParam.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + +import java.util.List; + +@Data +public class QueryVdcUsedResourceParam { + + private List uuidList; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/ServerVmOperateLogReq.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/ServerVmOperateLogReq.java new file mode 100644 index 0000000000000000000000000000000000000000..5168d3f59171780f711181d8e938eede3e63a4e1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/req/ServerVmOperateLogReq.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.mc.req; + +import lombok.Data; + + +/** + * Created by kylin-ksvd on 21-7-9. + */ +@Data +public class ServerVmOperateLogReq { + + private String sidx = "startTime"; + + + private String sord = "desc"; + private Integer page; + + private Integer rows; + + private String uuid; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmIntervalResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmIntervalResp.java new file mode 100644 index 0000000000000000000000000000000000000000..8e720b8e893db4c391f758b95b3cee353d4213c8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmIntervalResp.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class AlarmIntervalResp { + + private String alarmInterval; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmLogResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmLogResp.java new file mode 100644 index 0000000000000000000000000000000000000000..8aa1bbf7b53f5c2b7a9879e0e5ef5e3a0a23e8c3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmLogResp.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class AlarmLogResp { + + + private String severity; + + private String objectName; + + private String info; + + private String objectType; + + + private String date; + + private String type; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmLogTypeResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmLogTypeResp.java new file mode 100644 index 0000000000000000000000000000000000000000..2166bd7528883a45e38fce83fca011f54846a3c3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmLogTypeResp.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class AlarmLogTypeResp { + + private List level; + + private List type; + + private List targets; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmNotificationsResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmNotificationsResp.java new file mode 100644 index 0000000000000000000000000000000000000000..4bd0133e665aceec8fd1c051ae03bdcc9ed1288f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmNotificationsResp.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class AlarmNotificationsResp { + + private Integer notificationsCount = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmSettingsResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmSettingsResp.java new file mode 100644 index 0000000000000000000000000000000000000000..0497b274a88c26d4a745b590f53127954e92e821 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/AlarmSettingsResp.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class AlarmSettingsResp { + + private Integer alarmSettingId; + + private String type; + + private String urgentValue; + + private String ordinaryValue; + + private String seriousValue; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/CheckClusterNameAndPasswordResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/CheckClusterNameAndPasswordResp.java new file mode 100644 index 0000000000000000000000000000000000000000..9188f9edebe28a8de856fd47ffeb10c10696e4d8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/CheckClusterNameAndPasswordResp.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import com.hnkylin.cloud.manage.enums.DataStoreStatus; +import com.hnkylin.cloud.manage.enums.DataStoreType; +import com.hnkylin.cloud.manage.enums.DataStoreUsage; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 集群管理-数据存储 + */ +@Data +public class CheckClusterNameAndPasswordResp { + + + private Boolean userNameAndPassword; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/CheckServerNameResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/CheckServerNameResp.java new file mode 100644 index 0000000000000000000000000000000000000000..1be7c15f8a1f5fd5ae90462e1f04975c9d000865 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/CheckServerNameResp.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class CheckServerNameResp { + + + private Boolean exist; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmAlarmEventResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmAlarmEventResp.java new file mode 100644 index 0000000000000000000000000000000000000000..4c4dec11ae4820fcd05244a9605cd461d9b45aba --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmAlarmEventResp.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class KcpServerVmAlarmEventResp { + + + private String severity; + + private String objectType; + + private String objectName; + + private String info; + + private String date; + + private String type; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmDetailResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..51bb837a52b026dc2466e0243ca3a647b7270621 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmDetailResp.java @@ -0,0 +1,44 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class KcpServerVmDetailResp { + + + private String name; + + private String description; + + private String type; + + private String status; + + private String selectCluster; + + private String osName; + + private String operateSysType; + + private String logo; + + private String logoName; + + private String powerOnDate; + + private String nowDate; + + private String createDate; + + private String vncAddr; + + private String runMachine; + + private String uuid; + + private String userName; + + private String orgName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmDiskResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmDiskResp.java new file mode 100644 index 0000000000000000000000000000000000000000..f93d72bbb2de5dd373b55d8cd88b44cfd950310f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmDiskResp.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class KcpServerVmDiskResp { + + + private String diskId; + + private String deviceName; + + private String device; + + private String targetBus; + + private String diskCapacity; + + private String sourceFile; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmNetworkResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmNetworkResp.java new file mode 100644 index 0000000000000000000000000000000000000000..08b96d2589079b4bdd0eea84cd78965ea020b01c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmNetworkResp.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class KcpServerVmNetworkResp { + + + private String interfaceType; + + private String modeltype; + + private String virtualSwitch; + + private String portGroup; + + private String macAddress; + + private String ipAddress; + + private String pool; + + private String uploadSpend; + + private String downloadSpend; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmSummaryResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmSummaryResp.java new file mode 100644 index 0000000000000000000000000000000000000000..e68e8cd1cb483092b7fe81e0ac5de3be2d86e8e5 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/KcpServerVmSummaryResp.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class KcpServerVmSummaryResp { + + + private BigDecimal cpuCount; + + + private BigDecimal cpuPercent; + + private BigDecimal memoryPercent; + + private BigDecimal memoryTotal; + + private BigDecimal memoryUsed; + + private BigDecimal memorySurplus; + + private BigDecimal diskTotal; + + private BigDecimal diskTotalUsed; + + private BigDecimal diskSurplus; + + private BigDecimal diskPercent; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterBaseResource.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterBaseResource.java new file mode 100644 index 0000000000000000000000000000000000000000..24fce8c98cb291a047b2b367f6c4589ebbd08a64 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterBaseResource.java @@ -0,0 +1,40 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 集群管理-资源使用情况 + */ +@Data +public class McClusterBaseResource { + + + private List severs; + + + //集群资源使用情况 + private McClusterResourceUsedResp resourceInfo; + + private String ksvdVersion; + + private String licenseExpire; + + + private Integer onlinePhysicalHost = 0; + + private Integer offlinePhysicalHost = 0; + + private Integer totalPhysicalHost = 0; + + private Integer onlineMachine = 0; + + private Integer offlineMachine = 0; + + private Integer totalMachine = 0; + + private Integer clusterId = 0; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterBindResource.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterBindResource.java new file mode 100644 index 0000000000000000000000000000000000000000..dbe0d83068df4bdcf7a60a35d4de999ad46e2b4f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterBindResource.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class McClusterBindResource { + + + private String description; + + private Integer id; + + private String name; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterPhysicalHostResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterPhysicalHostResp.java new file mode 100644 index 0000000000000000000000000000000000000000..ff234be716bc0b05e29663e5a609f6e6b6a591db --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterPhysicalHostResp.java @@ -0,0 +1,40 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import com.hnkylin.cloud.manage.enums.McPhysicaHostStatus; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 集群管理-物理主机 + */ +@Data +public class McClusterPhysicalHostResp { + + //主机ID + private String serverId; + + //主机地址 + private String serverAddr; + + //服务器架构 + private String serverArch; + + + //cpu模型 + private String cpuModelName; + + //服务器类型 + private String serverType; + + //cpu使用率 + private BigDecimal cpuUtil = BigDecimal.ZERO; + + //内存使用率 + private BigDecimal memUtil = BigDecimal.ZERO; + + //主机状态 + private McPhysicaHostStatus status; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterResourceUsedResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterResourceUsedResp.java new file mode 100644 index 0000000000000000000000000000000000000000..0a8273e1362c065dab026836fde0e0d2670fc28a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterResourceUsedResp.java @@ -0,0 +1,48 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 集群管理-资源使用情况 + */ +@Data +public class McClusterResourceUsedResp { + + //cpu已使用 + private BigDecimal cpuUsed = BigDecimal.ZERO; + //cpu总大小 + private BigDecimal cpuTotal = BigDecimal.ZERO; + + private BigDecimal cpuSurplus = BigDecimal.ZERO; + //内存已使用 + private BigDecimal memUsed = BigDecimal.ZERO; + //内存总大小 + private BigDecimal memTotal = BigDecimal.ZERO; + + private BigDecimal memSurplus = BigDecimal.ZERO; + //存储已使用 + private BigDecimal storageUsed = BigDecimal.ZERO; + //存储总大小 + private BigDecimal storageTotal = BigDecimal.ZERO; + + private BigDecimal storageSurplus = BigDecimal.ZERO; + + + public void reCalculate() { + this.cpuTotal = this.cpuTotal.setScale(2, BigDecimal.ROUND_HALF_UP); + this.cpuUsed = this.cpuUsed.setScale(2, BigDecimal.ROUND_HALF_UP); + this.cpuSurplus = this.cpuTotal.subtract(this.cpuUsed).setScale(2, BigDecimal.ROUND_HALF_UP); + + this.memTotal = this.memTotal.setScale(2, BigDecimal.ROUND_HALF_UP); + this.memUsed = this.memUsed.setScale(2, BigDecimal.ROUND_HALF_UP); + this.memSurplus = this.memTotal.subtract(this.memUsed).setScale(2, BigDecimal.ROUND_HALF_UP); + + + this.storageTotal = this.storageTotal.setScale(2, BigDecimal.ROUND_HALF_UP); + this.storageUsed = this.storageUsed.setScale(2, BigDecimal.ROUND_HALF_UP); + this.storageSurplus = this.storageTotal.subtract(this.storageUsed).setScale(2, BigDecimal.ROUND_HALF_UP); + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterResp.java new file mode 100644 index 0000000000000000000000000000000000000000..4651f0b94ff01d9286dc2b8b6082b01527930f13 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterResp.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.sql.Timestamp; +import java.util.Date; + +@Data +public class McClusterResp { + + + private String serverAddr; + + private String serverArch; + + private String serverType; + + private String cpuUtil; + + private String memUtil; + + private Integer currentSessions; + + private String loadaverage; + + private String serverId; + + private String cpuModelName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterServerResourceResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterServerResourceResp.java new file mode 100644 index 0000000000000000000000000000000000000000..513508558bbfde5b7e7d0e721c999dda171f74a4 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterServerResourceResp.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 集群管理-资源使用情况 + */ +@Data +public class McClusterServerResourceResp { + + + private String serverIp; + private String serverUuid; + + private Integer vcpus; + + private BigDecimal memory; + + private ArchitectureType architecture; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterStorageResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterStorageResp.java new file mode 100644 index 0000000000000000000000000000000000000000..b4440916c4c45c7e1930b2118aa4f2775065a694 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McClusterStorageResp.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import com.hnkylin.cloud.manage.enums.DataStoreStatus; +import com.hnkylin.cloud.manage.enums.DataStoreType; +import com.hnkylin.cloud.manage.enums.DataStoreUsage; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 集群管理-数据存储 + */ +@Data +public class McClusterStorageResp { + + + //存储ID + private Integer id; + + //存储名称 + private String name; + + //存储用途 + private DataStoreUsage usage; + + //存储类型 + private DataStoreType type; + + //总大小 + private BigDecimal totalSize = BigDecimal.ZERO; + + //已使用 + private BigDecimal usedSize = BigDecimal.ZERO; + + //状态 + private DataStoreStatus status; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McDataStoreInfoResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McDataStoreInfoResp.java new file mode 100644 index 0000000000000000000000000000000000000000..1f179bf6d352f044dcc5ac27eabd7795fb2c3636 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McDataStoreInfoResp.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class McDataStoreInfoResp { + + + private String name; + + private BigDecimal totalSize; + + private BigDecimal usedSize; + + private BigDecimal availSize; + + private BigDecimal limitAvailSize; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McFilterTypeDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McFilterTypeDto.java new file mode 100644 index 0000000000000000000000000000000000000000..cb024d43b6872e7b7434f90f00431a1530142eb5 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McFilterTypeDto.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class McFilterTypeDto { + + private String value; + + private String label; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmDetailResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..42ca75c355457277f43a124dbf68317654764493 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmDetailResp.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class McServerVmDetailResp { + + private String alisname; + + private String osMachine; + + private String architecture; + + private String systemType; + + private Integer cpu; + + private Integer mem; + + private String memUnit; + + private String selectCluster; + + private String selectClusterUuid; + + private Integer storageLocationId; + + + private Integer serverClusterType; + + private String selectTagIds; + + private String selectTagNames; + + private List disks; + + private List interfaceList; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmDiskDetailResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmDiskDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..e608c92d99efb8131a70d464db8fa4aebc84b93f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmDiskDetailResp.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.LastUpdateType; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class McServerVmDiskDetailResp { + + //磁盘大小 + private Integer diskSize; + + //类型 + private ApplyMcServerVmType type = ApplyMcServerVmType.original; + + private Long id; + + private ModifyType modifyType; + + private Integer oldDiskSize; + + private Integer applyId; + + private ModifyType applyModifyType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmNetworkDetailResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmNetworkDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..47ef1317eb3a6e1813c0fcdb8f8231562fd3603a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmNetworkDetailResp.java @@ -0,0 +1,85 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.LastUpdateType; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +/** + * mc中网卡实体信息 + */ +@Data +public class McServerVmNetworkDetailResp { + + //虚拟交换机 + private String virtualSwitch; + + //端口组名称 + private String portGroup; + + //端口组uuid + private String portGroupUuid; + //mac地址 + private String macAddress; + + //地址池 + private String macAddressPool; + + //网络类型 + private String interfaceType; + + //网卡类型 + private String modelType; + + //网络id + private Long id; + + //安全策略 + private Integer securityStrategy; + + //安全组uuid + private String securityGroupUuid; + + //虚拟防火墙id + private Integer virtualFirewall; + + //网卡多队列 + private Integer queueCount = 0; + + //mtu值 + private Integer mtuCount = 1500; + + + //自定义网络ID + private Integer networkId = 0; + + private String networkName = ""; + //申请时填写的用途 + private String purpose; + + private ApplyMcServerVmType type = ApplyMcServerVmType.original; + + private ModifyType modifyType; + + private ModifyType applyModifyType; + + + //申请ID + private Integer applyId = 0; + + + private Boolean ipBindMac = false; + + private Boolean manualSetIp = false; + + private Boolean automaticAcqIp = false; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmRunningInfoDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmRunningInfoDto.java new file mode 100644 index 0000000000000000000000000000000000000000..6dabe49b2a31b6175c9ac56ba71b5e4b0754cb1f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmRunningInfoDto.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class McServerVmRunningInfoDto { + + private Integer onlineMachine = 0; + + private Integer offlineMachine = 0; + + private Integer totalMachine = 0; + + private List cpuTopList = new ArrayList<>(); + + private List memTopList = new ArrayList<>(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmUseRatioData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmUseRatioData.java new file mode 100644 index 0000000000000000000000000000000000000000..7fcd5bf038dcda551131dbf3a3fc3c64fafe93eb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McServerVmUseRatioData.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 首页统计数据 + */ +@Data +public class McServerVmUseRatioData { + + + //名称 + private String serverVmName; + + //cpu利用率 + private BigDecimal cpuUseRatio; + + //cpu利用率 + private BigDecimal memUseRatio; + + private String clusterName; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McStorageLocationResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McStorageLocationResp.java new file mode 100644 index 0000000000000000000000000000000000000000..679a15e6fb1366257e1aba73350ef1f47ed0731f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/McStorageLocationResp.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class McStorageLocationResp { + + private Integer id; + + private String name; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkAddressPoolResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkAddressPoolResp.java new file mode 100644 index 0000000000000000000000000000000000000000..520f38fcc5ae39329daba2b1ff8634999af43161 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkAddressPoolResp.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class NetworkAddressPoolResp { + + private String name; + + private Integer id; + + private Boolean defaultPool; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkConfigResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkConfigResp.java new file mode 100644 index 0000000000000000000000000000000000000000..aabcd93836c4c4e73b4042db8783729a6216144b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkConfigResp.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class NetworkConfigResp { + + private List virtualSwitchList; + + private List addressPoolList; + + private List securityGroupList; + + private List virtualFirewallList; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkPortGroupResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkPortGroupResp.java new file mode 100644 index 0000000000000000000000000000000000000000..159b2864753220aff17cf91a12b70c17631beffb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkPortGroupResp.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class NetworkPortGroupResp { + + private String name; + + private Integer id; + + private String uuid; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkSecurityGroupResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkSecurityGroupResp.java new file mode 100644 index 0000000000000000000000000000000000000000..8536101386b5905192f0c965cf36efd92dc1dd9f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkSecurityGroupResp.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class NetworkSecurityGroupResp { + + private String name; + + private String uuid; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkVirtualFirewallResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkVirtualFirewallResp.java new file mode 100644 index 0000000000000000000000000000000000000000..9b451dfe80853728a1972a317b72335428284a10 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkVirtualFirewallResp.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class NetworkVirtualFirewallResp { + + private Integer virtualFirewallId; + + private String virtualFirewallName; + + private String virtualFirewallRemark; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkVirtualSwitchResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkVirtualSwitchResp.java new file mode 100644 index 0000000000000000000000000000000000000000..499ac0586e302f8a936afb8dc7e58aead81c6857 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/NetworkVirtualSwitchResp.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class NetworkVirtualSwitchResp { + + private String name; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/PhysicalHostEventResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/PhysicalHostEventResp.java new file mode 100644 index 0000000000000000000000000000000000000000..804c70b2bde78f6ed92753accb721a23397a523e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/PhysicalHostEventResp.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class PhysicalHostEventResp { + + + private String severity; + + private String hostname; + + private String info; + + private String mutableTags; + + + private String timestamp; + + private String type; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/PhysicalHostEventTypeResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/PhysicalHostEventTypeResp.java new file mode 100644 index 0000000000000000000000000000000000000000..a622517795430143953a5b18edbdb741fce32281 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/PhysicalHostEventTypeResp.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class PhysicalHostEventTypeResp { + + private List level; + + private List type; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/ServerVirtualizationEventResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/ServerVirtualizationEventResp.java new file mode 100644 index 0000000000000000000000000000000000000000..868dc3cfeb2b3088b8ebe340711989492b2ece65 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/ServerVirtualizationEventResp.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class ServerVirtualizationEventResp { + + + private String deploymentMode; + + private String desktopName; + + private String goldMaster; + + private String hostname; + + + private String info; + + private String organization; + + private String severity; + + private String timestamp; + + private String type; + + private String username; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/ServerVirtualizationEventTypeResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/ServerVirtualizationEventTypeResp.java new file mode 100644 index 0000000000000000000000000000000000000000..82eedd7840a41c89e3416eca98e6dad08744d2f1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/ServerVirtualizationEventTypeResp.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class ServerVirtualizationEventTypeResp { + + private List level; + + private List type; + + private List servers; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/VncUrlDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/VncUrlDto.java new file mode 100644 index 0000000000000000000000000000000000000000..db06eb5dfba5649bb9f00c3e1670befa1ec4076c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/mc/resp/VncUrlDto.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.mc.resp; + +import lombok.Data; + +@Data +public class VncUrlDto { + + private String vncUrl; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/BaseClusterParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/BaseClusterParam.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b9e9bf0ab9e0ae1dbab9aed54e4586f4fedb7a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/BaseClusterParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BaseClusterParam { + + @FieldCheck(notNull = true, notNullMessage = "集群ID不能为空") + Integer clusterId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CanBindClusterParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CanBindClusterParam.java new file mode 100644 index 0000000000000000000000000000000000000000..4ecf1a882503266b85b50ae55bb235ae3d50e088 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CanBindClusterParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.Data; + +@Data +public class CanBindClusterParam { + + private Integer zoneId; + + private CloudClusterType type; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CheckClusterNameAndPasswordParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CheckClusterNameAndPasswordParam.java new file mode 100644 index 0000000000000000000000000000000000000000..b84e8344a6caffaae30b28decbddf4c32a51aa26 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CheckClusterNameAndPasswordParam.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +import java.util.List; + +@Data +public class CheckClusterNameAndPasswordParam { + + private Integer clusterId; + + private List clusterNodeList; + + @FieldCheck(notNull = true, notNullMessage = "集群管理员账号不能为空") + private String clusterAdminName; + + @FieldCheck(notNull = true, notNullMessage = "集群管理员密码不能为空") + private String clusterAdminPassword; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterNodeParams.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterNodeParams.java new file mode 100644 index 0000000000000000000000000000000000000000..fbc379d617a56bd84dbf90075fd8edfd44e02579 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterNodeParams.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + + +import lombok.Data; + +@Data +public class ClusterNodeParams { + + private String httpType; + + private String ipAddress; + + private Integer port; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterPageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..36080a9b0e0c3d22d076df6fc2039b61c2eee3d9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterPageParam.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.Data; + +@Data +public class ClusterPageParam extends BasePageParam { + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterPhysicalHostPageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterPhysicalHostPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..ed3c3a275bd24af7b2e40a9a84a9f1ccdd8c62f8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterPhysicalHostPageParam.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class ClusterPhysicalHostPageParam extends BasePageParam { + + @FieldCheck(notNull = true, notNullMessage = "集群不能为空") + private Integer clusterId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterStoragePageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterStoragePageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..914065772ac4e1c132d5e1e9294721ed556be706 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ClusterStoragePageParam.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.manage.entity.req.cluster.ClusterNodeParams; +import lombok.Data; + +import java.util.List; + +@Data +public class ClusterStoragePageParam extends BasePageParam { + + private Integer clusterId; + + private List clusterNodeList; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CreateClusterParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CreateClusterParam.java new file mode 100644 index 0000000000000000000000000000000000000000..5d45431dc3b3be4e6860814173710d83ec542a83 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/CreateClusterParam.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import com.hnkylin.cloud.manage.entity.req.cluster.ClusterNodeParams; +import lombok.Data; + +import java.util.List; + +@Data +public class CreateClusterParam { + + @FieldCheck(notNull = true, notNullMessage = "集群名称不能为空") + private String name; + + + private String remark; + + @FieldCheck(notNull = true, notNullMessage = "集群名称类型不能为空") + private CloudClusterType type; + + + private List clusterNodeList; + + @FieldCheck(notNull = true, notNullMessage = "集群管理员账号不能为空") + private String clusterAdminName; + + @FieldCheck(notNull = true, notNullMessage = "集群管理员密码不能为空") + private String clusterAdminPassword; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ModifyClusterParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ModifyClusterParam.java new file mode 100644 index 0000000000000000000000000000000000000000..2e48aaf6c764063369fd18aef6c4651026be0380 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/cluster/ModifyClusterParam.java @@ -0,0 +1,39 @@ +package com.hnkylin.cloud.manage.entity.req.cluster; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import com.hnkylin.cloud.manage.entity.req.cluster.ClusterNodeParams; +import lombok.Data; + +import java.util.List; + +@Data + +public class ModifyClusterParam { + + @FieldCheck(notNull = true, notNullMessage = "集群ID不能为空") + private Integer clusterId; + + @FieldCheck(notNull = true, notNullMessage = "集群名称不能为空") + private String name; + + + private String remark; + + @FieldCheck(notNull = true, notNullMessage = "集群名称类型不能为空") + private CloudClusterType type; + + + private List clusterNodeList; + + @FieldCheck(notNull = true, notNullMessage = "集群管理员账号不能为空") + private String clusterAdminName; + + @FieldCheck(notNull = true, notNullMessage = "集群管理员密码不能为空") + private String clusterAdminPassword; + + private Boolean ifModifyPassword = false; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/AlarmLogParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/AlarmLogParam.java new file mode 100644 index 0000000000000000000000000000000000000000..02a5970fc1d127fe983777d8953be1f23a12d246 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/AlarmLogParam.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.req.monitor; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class AlarmLogParam extends BasePageParam { + + private Integer clusterId; + + private String sidx; + + private String sord; + + private String startDate; + + private String endDate; + + private String search; + + private String type; + + private String severity; + + private String objectType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/PagKcpAlarmLogParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/PagKcpAlarmLogParam.java new file mode 100644 index 0000000000000000000000000000000000000000..9503729feb29b8f2e968883d0933e6f674f668bc --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/PagKcpAlarmLogParam.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.manage.entity.req.monitor; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class PagKcpAlarmLogParam extends BasePageParam { + + + private String startDate; + + private String endDate; + + private Integer zoneId = 0; + + private Integer orgId = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/PhysicalHostEventParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/PhysicalHostEventParam.java new file mode 100644 index 0000000000000000000000000000000000000000..eff42d5c595cec9a83fe0b5d40c0f3d58691d2cf --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/PhysicalHostEventParam.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.entity.req.monitor; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class PhysicalHostEventParam extends BasePageParam { + + private Integer clusterId; + + private String sidx; + + private String sord; + + private String startDate; + + private String endDate; + + private String search; + + private String severity; + + private String eventType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/ServerVirtualizationEventParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/ServerVirtualizationEventParam.java new file mode 100644 index 0000000000000000000000000000000000000000..0b0de1c5c61c3ac894fb14be682c6579848a0779 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/ServerVirtualizationEventParam.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.req.monitor; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class ServerVirtualizationEventParam extends BasePageParam { + + private Integer clusterId; + + private String sidx; + + private String sord; + + private String startDate; + + private String endDate; + + private String search; + + private String serverType; + + private String severity; + + private String eventType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/UpdateKcpAlarmSettingParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/UpdateKcpAlarmSettingParam.java new file mode 100644 index 0000000000000000000000000000000000000000..383067da3cfe0eac1a4fc43900ea7aec9e458b67 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/monitor/UpdateKcpAlarmSettingParam.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.req.monitor; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class UpdateKcpAlarmSettingParam { + + private Integer kcpSettingId; + @FieldCheck(notNull = true, notNullMessage = "一般告警不能为空") + private Integer generalAlarm; + @FieldCheck(notNull = true, notNullMessage = "严重告警不能为空") + private Integer severityAlarm; + @FieldCheck(notNull = true, notNullMessage = "紧急告警不能为空") + private Integer urgentAlarm; + + //private Integer durationTime; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/BaseNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/BaseNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..b51980a1613f05c2e33dac31157fdde4be52d3b1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/BaseNetworkParam.java @@ -0,0 +1,8 @@ +package com.hnkylin.cloud.manage.entity.req.network; + +import lombok.Data; + +@Data +public class BaseNetworkParam { + private Integer networkId; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/CreateNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/CreateNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..0dfdc0bf1e2519b502a19a611b32cb425b7b8e25 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/CreateNetworkParam.java @@ -0,0 +1,39 @@ +package com.hnkylin.cloud.manage.entity.req.network; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import lombok.Data; + +@Data +public class CreateNetworkParam { + + @FieldCheck(notNull = true, notNullMessage = "网络名称不能为空") + private String networkName; + + private String interfaceType; + + + @FieldCheck(notNull = true, notNullMessage = "地址池不能为空") + private String addressPool; + + + private Integer addressPoolId; + + @FieldCheck(notNull = true, notNullMessage = "虚拟交换机不能为空") + private String virtualSwitch; + + @FieldCheck(notNull = true, notNullMessage = "网卡类型不能为空") + private String modelType; + + + @FieldCheck(notNull = true, notNullMessage = "端口组不能为空") + private String portGroup; + + private String portGroupUuid; + + private String securityGroup; + + private String securityGroupUuid; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/ModifyNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/ModifyNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..dc7b38fd12fad5e3ad2f215b4df97f007c56862a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/network/ModifyNetworkParam.java @@ -0,0 +1,47 @@ +package com.hnkylin.cloud.manage.entity.req.network; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + +@Data +public class ModifyNetworkParam { + + private Integer networkId; + + @FieldCheck(notNull = true, notNullMessage = "网络名称不能为空") + private String networkName; + + private String interfaceType = "bridge"; + + + @FieldCheck(notNull = true, notNullMessage = "地址池不能为空") + private String addressPool; + + + private Integer addressPoolId; + + @FieldCheck(notNull = true, notNullMessage = "虚拟交换机不能为空") + private String virtualSwitch; + + @FieldCheck(notNull = true, notNullMessage = "网卡类型不能为空") + private String modelType; + + + @FieldCheck(notNull = true, notNullMessage = "端口组不能为空") + private String portGroup; + + private String portGroupUuid; + + private NetworkSecurityPolicy securityPolicy = NetworkSecurityPolicy.NONE; + + private String securityGroup; + + private String securityGroupUuid; + + private Integer virtualFirewallId = 0; + + private String virtualFirewallName; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/BaseOrgParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/BaseOrgParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c51668585705b8d4850662c674fd17a8be47ad80 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/BaseOrgParam.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.req.org; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BaseOrgParam { + + @FieldCheck(notNull = true, notNullMessage = "组织ID不能为空") + Integer orgId; + + private String searchKey; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/CreateOrgParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/CreateOrgParam.java new file mode 100644 index 0000000000000000000000000000000000000000..e062464f6cfc99fa05bd3d6af83f2f83dbb68acb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/CreateOrgParam.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.req.org; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class CreateOrgParam { + + @FieldCheck(notNull = true, notNullMessage = "组织名称不能为空") + private String organizationName; + + private String remark; + + private Integer parentId; + + @FieldCheck(notNull = true, notNullMessage = "VDC不能为空") + private Integer vdcId; + + private Boolean createLeader; + + private String leaderUserName; + + private String leaderRealName; + + private String leaderPassword; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/ModifyOrgParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/ModifyOrgParam.java new file mode 100644 index 0000000000000000000000000000000000000000..9c749fdb4f25264ecc70e86adfe0fcdcfc6446f2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/ModifyOrgParam.java @@ -0,0 +1,35 @@ +package com.hnkylin.cloud.manage.entity.req.org; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class ModifyOrgParam { + + @FieldCheck(notNull = true, notNullMessage = "组织ID不能为空") + Integer orgId; + + @FieldCheck(notNull = true, notNullMessage = "组织名称不能为空") + private String organizationName; + + private String remark; + + @FieldCheck(notNull = true, notNullMessage = "父组织ID不能为空") + private Integer parentId; + + @FieldCheck(notNull = true, notNullMessage = "VDC不能为空") + private Integer vdcId; + + + private Boolean createLeader; + + private Integer leaderUserId = 0; + + private String leaderUserName; + + private String leaderRealName; + + private String leaderPassword; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/ModifyTopOrgNameParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/ModifyTopOrgNameParam.java new file mode 100644 index 0000000000000000000000000000000000000000..42959671a221016c3efba6d34f1a5397a6491fc2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/ModifyTopOrgNameParam.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.req.org; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class ModifyTopOrgNameParam { + + @FieldCheck(notNull = true, notNullMessage = "组织ID不能为空") + Integer orgId; + + @FieldCheck(notNull = true, notNullMessage = "组织名称不能为空") + private String organizationName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/OrgStatisticTreeParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/OrgStatisticTreeParam.java new file mode 100644 index 0000000000000000000000000000000000000000..bd8552a62ffe04bf77aa132aec07dcff18c0633e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/OrgStatisticTreeParam.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.manage.entity.req.org; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.manage.enums.OrgStatisticTreeType; +import lombok.Data; + +@Data +public class OrgStatisticTreeParam { + + @FieldCheck(notNull = true, notNullMessage = "统计类型不能为空") + OrgStatisticTreeType statisticType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/QueryParentOrgParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/QueryParentOrgParam.java new file mode 100644 index 0000000000000000000000000000000000000000..d738a032f121555cc7e5edaa6000b947ca51dd2a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/org/QueryParentOrgParam.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.manage.entity.req.org; + + +import lombok.Data; + +@Data +public class QueryParentOrgParam { + + Integer organizationId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/AllocateRolePermissionParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/AllocateRolePermissionParam.java new file mode 100644 index 0000000000000000000000000000000000000000..30a5f3e5292490c32a4dbb159d0c657ce6b99620 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/AllocateRolePermissionParam.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.entity.req.role; + + +import lombok.Data; + +@Data +public class AllocateRolePermissionParam { + + private Integer roleId; + + private String permissionIds; + + public static void main(String[] args) { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < 63; i++) { + stringBuilder.append(i).append(","); + } + System.out.println(stringBuilder.toString()); + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/BaseRoleParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/BaseRoleParam.java new file mode 100644 index 0000000000000000000000000000000000000000..4f8bc12454caf57ea9612b6d1e6126d374b3ecb3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/BaseRoleParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.role; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BaseRoleParam { + + @FieldCheck(notNull = true, notNullMessage = "角色ID不能为空") + Integer roleId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/CreateRoleParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/CreateRoleParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c8cfe01e626ce940a6cf37515e4f60f18dde6b9f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/CreateRoleParam.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.entity.req.role; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +import java.util.List; + +@Data +public class CreateRoleParam { + + @FieldCheck(notNull = true, notNullMessage = "角色名称不能为空") + private String roleName; + + + private List permissions; + + + private String remark; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/ModifyRoleParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/ModifyRoleParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c21c1432de97ef9e4d61165fc4628e0623cb2f60 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/ModifyRoleParam.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.manage.entity.req.role; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +import java.util.List; + +@Data +public class ModifyRoleParam { + + + @FieldCheck(notNull = true, notNullMessage = "角色ID不能为空") + private Integer roleId; + + @FieldCheck(notNull = true, notNullMessage = "角色名称不能为空") + private String roleName; + + + private List permissions; + + private String remark; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/RolePageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/RolePageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..791b509f686bf19d5630114f26b395ac96276f40 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/RolePageParam.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.manage.entity.req.role; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class RolePageParam extends BasePageParam { + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/SearchRoleParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/SearchRoleParam.java new file mode 100644 index 0000000000000000000000000000000000000000..b668a85630143b368ee69a7575bf1817b835da22 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/role/SearchRoleParam.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.manage.entity.req.role; + +import lombok.Data; + +@Data +public class SearchRoleParam { + + private String searchKey; + + private Integer orgId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/servervm/ServerVmOperateLogPageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/servervm/ServerVmOperateLogPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..ef87b53493277d4df39cf25a0b997b9fde604799 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/servervm/ServerVmOperateLogPageParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.servervm; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class ServerVmOperateLogPageParam extends BasePageParam { + + + @FieldCheck(notNull = true, notNullMessage = "云服务uuid不能为空") + private String serverVmUuid; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/servervm/ServerVmPageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/servervm/ServerVmPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..a4918c65407920a62cf065ff603ef457f114e1ba --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/servervm/ServerVmPageParam.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.entity.req.servervm; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.manage.enums.ZoneOrgUserType; +import lombok.Data; + +@Data +public class ServerVmPageParam extends BasePageParam { + + @FieldCheck(notNull = true, notNullMessage = "角色名称不能为空") + private ZoneOrgUserType type; + + + private String searchKey; + + private McServerVmStatus vmStatus; + + + private Integer uniqueId; + + private Integer clusterId = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/BaseUserParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/BaseUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..7436db7af4e9e7d3af70579601f9906834f2ebb8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/BaseUserParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.user; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BaseUserParam { + + @FieldCheck(notNull = true, notNullMessage = "用户ID不能为空") + Integer userId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/BatchDeleteUserParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/BatchDeleteUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..9601c75d5188defa2cf416b2083ad2aa3c457851 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/BatchDeleteUserParam.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.req.user; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +import java.util.List; + +@Data +public class BatchDeleteUserParam { + + @FieldCheck(notNull = true, notNullMessage = "用户ID不能为空") + List userIds; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/CreateUserParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/CreateUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c66c85d73feb696ae556b6a3637d7571443e7e90 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/CreateUserParam.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.manage.entity.req.user; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.UserType; +import lombok.Data; + + +@Data +public class CreateUserParam { + + @FieldCheck(notNull = true, notNullMessage = "用户名不能为空") + private String userName; + + @FieldCheck(notNull = true, notNullMessage = "真实姓名不能为空") + private String realName; + + @FieldCheck(notNull = true, notNullMessage = "密码不能为空") + private String password; + + private String mobile; + + private String remark; + + private CloudUserStatus status; + + @FieldCheck(notNull = true, notNullMessage = "组织不能为空") + private Integer organizationId; + + @FieldCheck(notNull = true, notNullMessage = "角色不能为空") + private Integer roleId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/ModifyUserParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/ModifyUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..d64f6985c0d0062d9baee67c54ada7d637f9c1bb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/ModifyUserParam.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.manage.entity.req.user; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import lombok.Data; + + +@Data +public class ModifyUserParam { + + @FieldCheck(notNull = true, notNullMessage = "用户名不能为空") + private Integer userId; + + + @FieldCheck(notNull = true, notNullMessage = "真实姓名不能为空") + private String realName; + + @FieldCheck(notNull = true, notNullMessage = "密码不能为空") + private String password; + + private String mobile; + + private String remark; + + private CloudUserStatus status; + + @FieldCheck(notNull = true, notNullMessage = "组织不能为空") + private Integer organizationId; + + @FieldCheck(notNull = true, notNullMessage = "角色不能为空") + private Integer roleId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/PageUserParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/PageUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c95a07c48feee756b30fe22c22511bd88b91ed40 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/PageUserParam.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.manage.entity.req.user; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class PageUserParam extends BasePageParam { + + private Integer orgId; + + private String searchKey; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/ResetPasswordParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/ResetPasswordParam.java new file mode 100644 index 0000000000000000000000000000000000000000..76a27c042e69c8a598c102a0ff0524a2addbf084 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/user/ResetPasswordParam.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.req.user; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + + +@Data +public class ResetPasswordParam { + + @FieldCheck(notNull = true, notNullMessage = "旧密码不能为空") + private String oldPassword; + + @FieldCheck(notNull = true, notNullMessage = "审核状态不能为空") + private String newPassword; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ApplyModifyArchitectureResourceParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ApplyModifyArchitectureResourceParam.java new file mode 100644 index 0000000000000000000000000000000000000000..d1107f0a9618368af689b32d1b35aed61439c494 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ApplyModifyArchitectureResourceParam.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class ApplyModifyArchitectureResourceParam { + + @FieldCheck(minNum = 1, minNumMessage = "分配CPU不能小于1") + private Integer applyCpu = 0; + + @FieldCheck(minNum = 1, minNumMessage = "分配内存不能小于1") + private Integer applyMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ApplyModifyVdcResourceParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ApplyModifyVdcResourceParam.java new file mode 100644 index 0000000000000000000000000000000000000000..96e44ac25e037130e134fe5682d99878221e9ecf --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ApplyModifyVdcResourceParam.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.List; + +/** + * 申请变更-vdc资源 + */ +@Data +public class ApplyModifyVdcResourceParam { + + + private Integer vdcId; + + private List architectureResourceList; + + @FieldCheck(notNull = true, notNullMessage = "存储不能为空") + private Integer applyStorage; + + private StorageUnit storageUnit = StorageUnit.GB; + + @FieldCheck(notNull = true, notNullMessage = "申请原因不能为空") + private String applyReason; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/BaseVdcParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/BaseVdcParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c94bb293f6392aad34115ddd44b56d4eea10a7a7 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/BaseVdcParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BaseVdcParam { + + @FieldCheck(notNull = true, notNullMessage = "vdcId不能为空") + Integer vdcId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/CheckCreateVdcParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/CheckCreateVdcParam.java new file mode 100644 index 0000000000000000000000000000000000000000..96f6a2ce25ea2166de06d9b8179a58886d1c14d8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/CheckCreateVdcParam.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +/** + * 创建VDC时检查是否能创建 + */ +@Data +public class CheckCreateVdcParam { + + @FieldCheck(notNull = true, notNullMessage = "可用区不能为空") + private Integer zoneId; + + @FieldCheck(notNull = true, notNullMessage = "上级VDC不能为空") + private Integer parentVdcId; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/CreateVdcParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/CreateVdcParam.java new file mode 100644 index 0000000000000000000000000000000000000000..8575cb63acadcb7f9e673c1f8ab54fda10770836 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/CreateVdcParam.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.List; + +/** + * 创建VDC时检查是否能创建 + */ +@Data +public class CreateVdcParam { + + @FieldCheck(notNull = true, notNullMessage = "可用区不能为空") + private Integer zoneId; + + @FieldCheck(notNull = true, notNullMessage = "上级VDC不能为空") + private Integer parentVdcId; + + + @FieldCheck(notNull = true, notNullMessage = "上级VDC不能为空") + private String vdcName; + + private String remark; + + + @FieldCheck(minNum = 1, minNumMessage = "分配存储不能小于1") + private Integer allocationStorage; + + + private StorageUnit storageUnit; + + + private List architectureResourceList; + + + private List networkList; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ModifyVdcNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ModifyVdcNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..032df3c989cd7d79233c35887b900ea724d55659 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ModifyVdcNetworkParam.java @@ -0,0 +1,53 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.ModifyType; +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + +@Data +public class ModifyVdcNetworkParam { + + + private Integer networkId; + + private Integer clusterId; + + @FieldCheck(notNull = true, notNullMessage = "网络名称不能为空") + private String networkName; + + private String interfaceType = "bridge"; + + + @FieldCheck(notNull = true, notNullMessage = "地址池不能为空") + private String addressPool; + + + private Integer addressPoolId; + + @FieldCheck(notNull = true, notNullMessage = "虚拟交换机不能为空") + private String virtualSwitch; + + @FieldCheck(notNull = true, notNullMessage = "网卡类型不能为空") + private String modelType; + + + @FieldCheck(notNull = true, notNullMessage = "端口组不能为空") + private String portGroup; + + private String portGroupUuid; + + private NetworkSecurityPolicy securityPolicy = NetworkSecurityPolicy.NONE; + + private String securityGroup; + + private String securityGroupUuid; + + private Integer virtualFirewallId = 0; + + private String virtualFirewallName; + + private ModifyType modifyType; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ModifyVdcParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ModifyVdcParam.java new file mode 100644 index 0000000000000000000000000000000000000000..4ed204c1dfb6fda2ebf2d1f51e8e4794169d7488 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/ModifyVdcParam.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.List; + +/** + * 创建VDC时检查是否能创建 + */ +@Data +public class ModifyVdcParam { + + + private Integer vdcId; + + + @FieldCheck(notNull = true, notNullMessage = "上级VDC不能为空") + private String vdcName; + + private String remark; + + + private List networkList; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/VdcArchitectureResourceParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/VdcArchitectureResourceParam.java new file mode 100644 index 0000000000000000000000000000000000000000..12da6fd0c6445f7983fa1c6aae265b9bc4cb1d52 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/VdcArchitectureResourceParam.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class VdcArchitectureResourceParam { + + @FieldCheck(minNum = 1, minNumMessage = "分配CPU不能小于1") + private Integer allocationCpu = 0; + + @FieldCheck(minNum = 1, minNumMessage = "分配内存不能小于1") + private Integer allocationMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/VdcNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/VdcNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..f8a67e48bdff6b4b59fb9ba3b884227910d6dee9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/vdc/VdcNetworkParam.java @@ -0,0 +1,47 @@ +package com.hnkylin.cloud.manage.entity.req.vdc; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + +@Data +public class VdcNetworkParam { + + + private Integer clusterId; + + @FieldCheck(notNull = true, notNullMessage = "网络名称不能为空") + private String networkName; + + private String interfaceType = "bridge"; + + @FieldCheck(notNull = true, notNullMessage = "地址池不能为空") + private String addressPool; + + + private Integer addressPoolId; + + @FieldCheck(notNull = true, notNullMessage = "虚拟交换机不能为空") + private String virtualSwitch; + + @FieldCheck(notNull = true, notNullMessage = "网卡类型不能为空") + private String modelType; + + + @FieldCheck(notNull = true, notNullMessage = "端口组不能为空") + private String portGroup; + + private String portGroupUuid; + + private NetworkSecurityPolicy securityPolicy = NetworkSecurityPolicy.NONE; + + private String securityGroup; + + private String securityGroupUuid; + + private Integer virtualFirewallId = 0; + + private String virtualFirewallName; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/BatchCheckParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/BatchCheckParam.java new file mode 100644 index 0000000000000000000000000000000000000000..e61589d97533ead7d304fb904c36c8178c2cd450 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/BatchCheckParam.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import lombok.Data; + +import java.util.List; + +@Data +public class BatchCheckParam { + + @FieldCheck(notNull = true, notNullMessage = "工单ID不能为空") + private List workOrderIds; + + @FieldCheck(notNull = true, notNullMessage = "审核状态不能为空") + private WorkOrderStatus checkStatus; + + + @FieldCheck(notNull = true, notNullMessage = "审核意见不能为空") + private String auditOpinion; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/CommonCheckParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/CommonCheckParam.java new file mode 100644 index 0000000000000000000000000000000000000000..dbe47bdf6a0bc3ed0430d673c7477b8c581879a0 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/CommonCheckParam.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import lombok.Data; + +@Data +public class CommonCheckParam { + + @FieldCheck(notNull = true, notNullMessage = "工单ID不能为空") + private Integer workOrderId; + + + @FieldCheck(notNull = true, notNullMessage = "审核意见不能为空") + private String auditOpinion; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/LoginUserParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/LoginUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..b2a45a6c0aecc7bea80550c879acef2451a5411b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/LoginUserParam.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class LoginUserParam { + + @FieldCheck(notNull = true, notNullMessage = "用户名不能为空") + private String userName; + + @FieldCheck(notNull = true, notNullMessage = "密码不能为空") + private String password; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassApplyServerVmParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassApplyServerVmParam.java new file mode 100644 index 0000000000000000000000000000000000000000..a89ec385148744461240d8092e1466fa783e0214 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassApplyServerVmParam.java @@ -0,0 +1,72 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.McCloneType; +import com.hnkylin.cloud.core.enums.McServerClusterType; +import lombok.Data; + +import java.util.List; + +@Data +public class PassApplyServerVmParam { + + @FieldCheck(notNull = true, notNullMessage = "工单ID不能为空") + private Integer workOrderId; + + @FieldCheck(notNull = true, notNullMessage = "审核意见不能为空") + private String auditOpinion; + + @FieldCheck(notNull = true, notNullMessage = "服务器名称不能为空") + private String aliasName; + + private String selectCluster; + + private String selectClusterUuid; + + @FieldCheck(notNull = true, notNullMessage = "存储位置不能为空") + private Integer storageLocationId; + + + @FieldCheck(notNull = true, notNullMessage = "cpu不能为空") + private Integer vcpus; + + @FieldCheck(notNull = true, notNullMessage = "内存不能为空") + private Integer memory; + + private String memUnit; + + @FieldCheck(notNull = true, notNullMessage = "架构不能为空") + private String plateformType; + + @FieldCheck(notNull = true, notNullMessage = "操作系统不能为空") + private String operatingSystem; + + private String systemType; + + @FieldCheck(notNull = true, notNullMessage = "申请个数不能为空") + private Integer vmNumber; + + private String remotePassword; + + + //磁盘列表 + private List diskList; + + //网卡信息 + private List networkList; + + //iso信息 + private List isoList; + + //主机模式类型 + private McServerClusterType serverClusterType = McServerClusterType.CUSTOM; + + //主机绑定资源 + private String selectResourceTagId; + + //创建方式 链接克隆 完整克隆 + private McCloneType cloneType = McCloneType.FULL_CLONE; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyArchitectureResourceParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyArchitectureResourceParam.java new file mode 100644 index 0000000000000000000000000000000000000000..e618c949e7f5bb51ce640a0687cb2e630a2995af --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyArchitectureResourceParam.java @@ -0,0 +1,26 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class PassModifyArchitectureResourceParam { + + @FieldCheck(minNum = 1, minNumMessage = "CPU不能小于1") + private Integer realCpu = 0; + + @FieldCheck(minNum = 1, minNumMessage = "内存不能小于1") + private Integer realMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyServerVmParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyServerVmParam.java new file mode 100644 index 0000000000000000000000000000000000000000..ba0c8f224dd10af37c8cc56926ccb9622077b88f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyServerVmParam.java @@ -0,0 +1,58 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.McServerClusterType; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class PassModifyServerVmParam { + + @FieldCheck(notNull = true, notNullMessage = "工单ID不能为空") + private Integer workOrderId; + + @FieldCheck(notNull = true, notNullMessage = "审核意见不能为空") + private String auditOpinion; + + @FieldCheck(notNull = true, notNullMessage = "服务器名称不能为空") + private String aliasName; + + private String selectCluster; + + private String selectClusterUuid; + + @FieldCheck(notNull = true, notNullMessage = "存储位置不能为空") + private Integer storageLocationId; + + + @FieldCheck(notNull = true, notNullMessage = "cpu不能为空") + private Integer vcpus; + + @FieldCheck(notNull = true, notNullMessage = "内存不能为空") + private Integer memory; + + private String memUnit; + + @FieldCheck(notNull = true, notNullMessage = "架构不能为空") + private String plateformType; + + @FieldCheck(notNull = true, notNullMessage = "操作系统不能为空") + private String operatingSystem; + + private String systemType; + + + private List diskList = new ArrayList<>(); + + + private List networkList = new ArrayList<>(); + + //主机模式类型 + private McServerClusterType serverClusterType = McServerClusterType.CUSTOM; + + private String selectResourceTagId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyVdcResourceParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyVdcResourceParam.java new file mode 100644 index 0000000000000000000000000000000000000000..e31db6facab95c6d5fab484a288c145dc18163c4 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassModifyVdcResourceParam.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.StorageUnit; +import com.hnkylin.cloud.manage.entity.req.vdc.ApplyModifyArchitectureResourceParam; +import lombok.Data; + +import java.util.List; + +/** + * 申请变更-vdc资源 + */ +@Data +public class PassModifyVdcResourceParam { + + + private Integer workOrderId; + + private List architectureResourceList; + + @FieldCheck(notNull = true, notNullMessage = "存储不能为空") + private Integer realStorage; + + private StorageUnit storageUnit = StorageUnit.GB; + + @FieldCheck(notNull = true, notNullMessage = "审核意见不能为空") + private String auditOpinion; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmDiskParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmDiskParam.java new file mode 100644 index 0000000000000000000000000000000000000000..bcacd8c514f35e3e4795c123b8a44fd01a13ac33 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmDiskParam.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class PassServerVmDiskParam { + + //磁盘ID + private Integer id; + + //磁盘大小 + private Integer diskCapacity; + + //变更类型 + private ModifyType modifyType; + + private Integer applyId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmIsoParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmIsoParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c54b81d763d193f746453a55b5abeb2823594951 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmIsoParam.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PassServerVmIsoParam { + + //磁盘ID + private String isoFile; + + //变更类型 + private ModifyType modifyType; + + private Integer applyId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..c1857d635b1e4d0b53a149ace9ad017e1804ea93 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/PassServerVmNetworkParam.java @@ -0,0 +1,74 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.LastUpdateType; +import com.hnkylin.cloud.core.enums.ModifyType; +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + +@Data +public class PassServerVmNetworkParam { + + //网络类型 + private String interfaceType; + + //虚拟交换机 + private String virtualSwitch; + + //端口组 + private String portGroup; + + private String portGroupUuid; + + //网卡类型 + private String modelType; + + //地址池 + private String macAddressPool; + + //网卡多队列 + private Integer queueCount = 0; + + //mtu值 + private Integer mtuCount = 1500; + + //安全策略 + private String securityStrategy = NetworkSecurityPolicy.NONE.getValue(); + + //安全组UUID + private String securityGroupUuid; + + //虚拟防火墙id + private Integer virtualFirewall = 0; + + + //自定义网卡ID + private Integer networkId; + + private ApplyMcServerVmType type = ApplyMcServerVmType.custom; + + private Integer id; + + + private Integer applyId; + + //变更类型 + private ModifyType modifyType; + + + //是否绑定mac地址 + private Boolean ipBindMac = false; + + //是否手动设置ip + private Boolean manualSetIp = false; + + //是否自动设置ip + private Boolean automaticAcqIp = false; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/QueryPortGroupParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/QueryPortGroupParam.java new file mode 100644 index 0000000000000000000000000000000000000000..cfa1cfd08a1b7703c1d4fdf12a4b455803d04833 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/QueryPortGroupParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + + +import lombok.Data; + + +@Data +public class QueryPortGroupParam { + + private String virtualSwitchName; + + private Integer clusterId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/ServerVmNetworkParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/ServerVmNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..df54be8a046be9ff1379d217b1d74f8bee99063a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/ServerVmNetworkParam.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-24. + */ +@Data +public class ServerVmNetworkParam { + + @FieldCheck(notNull = true, notNullMessage = "工单ID不能为空", minNum = 1, minNumMessage = "工单ID不能为空") + private Integer workOrderId; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/WorkOrderDetailParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/WorkOrderDetailParam.java new file mode 100644 index 0000000000000000000000000000000000000000..97b9773a074d9db122373eaeb8b0d9a5aec85d5c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/WorkOrderDetailParam.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import lombok.Data; + +@Data +public class WorkOrderDetailParam { + + private Integer workOrderId; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/WorkOrderPageParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/WorkOrderPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..be0a2cc23eab220a8a3972915cc01526c3e7494b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/workorder/WorkOrderPageParam.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.entity.req.workorder; + +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import lombok.Data; + +import java.util.List; + +@Data +public class WorkOrderPageParam extends BasePageParam { + + private WorkOrderStatus searchOrderStatus; + + private WorkOrderType searchOrderType; + + //private Integer organizationId; + + private String searchKey; + + + private List visibleUserIdList; + + private String startTime; + + private String endTime; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/BaseZoneParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/BaseZoneParam.java new file mode 100644 index 0000000000000000000000000000000000000000..954423b86ab255b7e2383ad62a3acc1a8a4afa8b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/BaseZoneParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.req.zone; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class BaseZoneParam { + + @FieldCheck(notNull = true, notNullMessage = "可用区ID不能为空") + Integer zoneId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/CreateZoneParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/CreateZoneParam.java new file mode 100644 index 0000000000000000000000000000000000000000..4c12ad20cbdd2da538192e02296c5b976ca81f28 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/CreateZoneParam.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.req.zone; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import com.hnkylin.cloud.manage.entity.req.cluster.ClusterNodeParams; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +@Data +public class CreateZoneParam { + + @FieldCheck(notNull = true, notNullMessage = "可用区名称不能为空") + private String name; + + + private String remark; + + @FieldCheck(notNull = true, notNullMessage = "可用区类型不能为空") + private CloudClusterType type; + + + private Set clusterIdList; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/ModifyZoneParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/ModifyZoneParam.java new file mode 100644 index 0000000000000000000000000000000000000000..6b96c4906203711843026d2b998ad1263832b149 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/ModifyZoneParam.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.manage.entity.req.zone; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +@Data +public class ModifyZoneParam { + + private Integer zoneId; + + @FieldCheck(notNull = true, notNullMessage = "可用区名称不能为空") + private String name; + + + private String remark; + + @FieldCheck(notNull = true, notNullMessage = "可用区类型不能为空") + private CloudClusterType type; + + + private Set clusterIdList; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/PageZoneParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/PageZoneParam.java new file mode 100644 index 0000000000000000000000000000000000000000..48d27669769448fd3295b27362b9d4d03c2d6fee --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/req/zone/PageZoneParam.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.req.zone; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class PageZoneParam extends BasePageParam { + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/TokenRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/TokenRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..dab47abf5a66026f5ca02c92f49cefd150c7d1b7 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/TokenRespDto.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.manage.entity.resp; + +import lombok.Data; + +@Data +public class TokenRespDto { + + private String token; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterDetailDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..36c30e57217b48d524c045c408995660ea4a1a43 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterDetailDto.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.manage.entity.resp.cluster; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.Data; + +import java.util.List; + +@Data +public class ClusterDetailDto { + + + private Integer clusterId; + + private String name; + + + private String remark; + + private CloudClusterType type; + + + private String clusterAdminName; + + + private String clusterAdminPassword; + + private List clusterNodeList; + + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d06d029f48b770ce161ead52b3065e7d7d69ebd4 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterDto.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.resp.cluster; + +import lombok.Data; + +@Data +public class ClusterDto { + + + private Integer clusterId; + + private String clusterName; +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterInfoDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterInfoDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0886f441e7e9eee62731ac5d60ba55f5984f62f9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterInfoDto.java @@ -0,0 +1,43 @@ +package com.hnkylin.cloud.manage.entity.resp.cluster; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterResourceUsedResp; +import com.hnkylin.cloud.manage.enums.ClusterStatus; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class ClusterInfoDto { + + + private String name; + + private ClusterStatus status; + + private String remark; + + private CloudClusterType type; + + private String clusterVersion; + + private String clusterUrl; + + private Integer zoneId; + + private String zoneName; + + private String clusterAdminUser; + + private String createTime; + + + private McClusterResourceUsedResp resourceUsedInfo; + + private String quickLoginUrl; + + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterNodeInfoDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterNodeInfoDto.java new file mode 100644 index 0000000000000000000000000000000000000000..70e9f36ce06c3d6dab239009b10f4fbf9b414a5b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/ClusterNodeInfoDto.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.resp.cluster; + +import lombok.Data; + +@Data +public class ClusterNodeInfoDto { + + + private String httpType; + + private String ipAddress; + + private Integer port; + + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/LoginClusterRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/LoginClusterRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..1fb3ed8b37e6ee816969ddcacdd71e806cb17c28 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/LoginClusterRespDto.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.entity.resp.cluster; + +import lombok.Data; + +@Data +public class LoginClusterRespDto { + + private String quickLoginUrl; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/PageClusterDetailDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/PageClusterDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0198407eda539c953336a424a80ed23942d9671c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/cluster/PageClusterDetailDto.java @@ -0,0 +1,59 @@ +package com.hnkylin.cloud.manage.entity.resp.cluster; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.manage.enums.ClusterStatus; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class PageClusterDetailDto { + + //集群ID + private Integer clusterId; + + //集群名称 + private String name; + + //描述信息 + private String remark; + + //可用区ID + private Integer zoneId = 1; + + //可用区名称 + private String zoneName = ""; + + //集群URL + private String clusterUrl; + + + //集群类型 + private CloudClusterType type; + + private ClusterStatus status = ClusterStatus.OFFLINE; + + //cpu已使用 + private BigDecimal cpuUsed; + //cpu总大小 + private BigDecimal cpuTotal; + //内存已使用 + private BigDecimal memUsed; + //内存总大小 + private BigDecimal memTotal; + //存储已使用 + private BigDecimal storageUsed; + //存储总大小 + private BigDecimal storageTotal; + + private String quickLoginUrl; + + + private List mcNodeList; + + private boolean selected = false; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexClusterData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexClusterData.java new file mode 100644 index 0000000000000000000000000000000000000000..a1819b4a202ad78cca98a909e202b80856d3d090 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexClusterData.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexClusterData { + + + //集群总数 + private Integer totalCluster = 0; + + //在线集群数 + private Integer onlineCluster = 0; + + //离线集群数 + private Integer offlineCluster = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexCommonData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexCommonData.java new file mode 100644 index 0000000000000000000000000000000000000000..4cee0366141b64b21e964554edfff49c8c62e61c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexCommonData.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + +import com.hnkylin.cloud.manage.entity.mc.resp.McServerVmUseRatioData; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class IndexCommonData { + + + //vdc数据 + private IndexVdcData vdcData = new IndexVdcData(); + + + //云服务器数据 + private IndexServerVmData serverVmData = new IndexServerVmData(); + + //用户数据 + private IndexUserData userData = new IndexUserData(); + + + //提醒数据 + private IndexNoticeData noticeData = new IndexNoticeData(); + + //云服务器cpu利用率top5 + private List serverVmCpuTopUseRatioList = new ArrayList<>(); + //云服务器内存利用率top5 + private List serverVmMemTopUseRatioList = new ArrayList<>(); +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexCpuData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexCpuData.java new file mode 100644 index 0000000000000000000000000000000000000000..0177e458c6ba1a8d2c5a0e51b94b5cf5e9a253e8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexCpuData.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 首页统计数据 + */ +@Data +public class IndexCpuData { + //总Cpu + private BigDecimal totalCpu = BigDecimal.ZERO; + ; + + //已使用cpu + private BigDecimal usedCpu = BigDecimal.ZERO; + ; + + //剩余可用CPU + private BigDecimal usableCpu = BigDecimal.ZERO; + ; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexMemData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexMemData.java new file mode 100644 index 0000000000000000000000000000000000000000..e7d6275185ebb56206e87f80fa04b4ecee7d67ca --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexMemData.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 首页统计数据 + */ +@Data +public class IndexMemData { + + //总内存 + private BigDecimal totalMem = BigDecimal.ZERO; + + //已使用内存 + private BigDecimal usedMem = BigDecimal.ZERO; + ; + + //已使用内存 + private BigDecimal usableMem = BigDecimal.ZERO; + ; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexNoticeData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexNoticeData.java new file mode 100644 index 0000000000000000000000000000000000000000..ce83300f247d35df2d9b3c020caa1b9e03c54056 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexNoticeData.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexNoticeData { + + + //待审核工单 + private Integer waitCheckCount = 0; + + //告警数 + private Integer alarmCount = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexPhysicalHostData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexPhysicalHostData.java new file mode 100644 index 0000000000000000000000000000000000000000..a1bdab41a633a4ec9a67866d3c3418700f6cb4dc --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexPhysicalHostData.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexPhysicalHostData { + + //总物理主机数 + private Integer totalPhysicalHost = 0; + + //在线物理主机数 + private Integer onlinePhysicalHost = 0; + + + //离线物理主机数 + private Integer offlinePhysicalHost = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexServerVmData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexServerVmData.java new file mode 100644 index 0000000000000000000000000000000000000000..c9a04bac5183728d98835181d9b6790f5a4768fd --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexServerVmData.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexServerVmData { + //总云服务器数 + private Integer totalServerVm = 0; + + //在线云服务器数 + private Integer onlineServerVm = 0; + + //离线云服务器数 + private Integer offlineServerVm = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexStatisticData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexStatisticData.java new file mode 100644 index 0000000000000000000000000000000000000000..17e71328de4eae916139331a8a6d633389518bd2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexStatisticData.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import com.hnkylin.cloud.manage.entity.mc.resp.McServerVmUseRatioData; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * 首页统计数据 + */ +@Data +public class IndexStatisticData extends IndexCommonData { + + //可用区数据 + private IndexZoneData zoneData = new IndexZoneData(); + + //集群数据 + private IndexClusterData clusterData = new IndexClusterData(); + + //物理主机数据 + private IndexPhysicalHostData physicalHostData = new IndexPhysicalHostData(); + + + //cpu数据 + private IndexCpuData cpuData = new IndexCpuData(); + + //内存数据 + private IndexMemData memData = new IndexMemData(); + + //储存数据 + private IndexStorageData storageData = new IndexStorageData(); + + + //物理主机cpu利用率top5 + private List physicalHostCpuTopUseRatioList = new ArrayList<>(); + //物理主机内存利用率top5 + private List physicalHostMemTopUseRatioList = new ArrayList<>(); + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexStorageData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexStorageData.java new file mode 100644 index 0000000000000000000000000000000000000000..3a8579ad6d3f0eccc3622cb988b6f9c6c0106273 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexStorageData.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 首页统计数据 + */ +@Data +public class IndexStorageData { + + //总存储 + private BigDecimal totalStorage = BigDecimal.ZERO; + ; + + //已使用存储 + private BigDecimal usedStorage = BigDecimal.ZERO; + ; + + //剩余存储 + private BigDecimal usableStorage = BigDecimal.ZERO; + ; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexTopPhysicalHostUsedRatioData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexTopPhysicalHostUsedRatioData.java new file mode 100644 index 0000000000000000000000000000000000000000..aa3cf26224c5f3f2b901298bd51f8b9d06cedbbe --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexTopPhysicalHostUsedRatioData.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 首页统计数据 + */ +@Data +public class IndexTopPhysicalHostUsedRatioData { + + private String serverIp; + + private BigDecimal usedRatio; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexUserData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexUserData.java new file mode 100644 index 0000000000000000000000000000000000000000..1d3c7a8b64b32f3e972989f732146232f5dacf8c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexUserData.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexUserData { + + //平台管理用户 + private Integer platformManageUserCount = 0; + + //组织管理员账号 + private Integer orgManageUserCount = 0; + + //自服务用户 + private Integer selfServiceUserCount = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexVdcData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexVdcData.java new file mode 100644 index 0000000000000000000000000000000000000000..3e2c4657888bd9c4abe7765059b9c57d2a2a5a0e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexVdcData.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexVdcData { + + + //总VDC数 + private Integer totalVdc = 0; + + //已分配VDC + private Integer alreadyAllocateVdc = 0; + + //未分配VDC + private Integer noAllocateVdc = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexZoneData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexZoneData.java new file mode 100644 index 0000000000000000000000000000000000000000..a3fd826b07424eca3a14fabc769fedd05dca9679 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/IndexZoneData.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页统计数据 + */ +@Data +public class IndexZoneData { + + //可用区总数 + private Integer totalZone = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/OrgLeaderIndexStatisticData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/OrgLeaderIndexStatisticData.java new file mode 100644 index 0000000000000000000000000000000000000000..4e15e8d7baf1195a695fced3a0e51ca4ced52600 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/OrgLeaderIndexStatisticData.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + +import lombok.Data; + +@Data +public class OrgLeaderIndexStatisticData extends IndexCommonData { + + + //vdc-cpu资源 + private OrgLeaderVdcUsedData vdcCpuUsedData = new OrgLeaderVdcUsedData(); + + //vdc-内存 + private OrgLeaderVdcUsedData vdcMemUsedData = new OrgLeaderVdcUsedData(); + + + //vdc-存储 + private OrgLeaderVdcUsedData vdcStorageUsedData = new OrgLeaderVdcUsedData(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/OrgLeaderVdcUsedData.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/OrgLeaderVdcUsedData.java new file mode 100644 index 0000000000000000000000000000000000000000..64edcba5244fa78c0f0712d5eb6631bf88e4789d --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/index/OrgLeaderVdcUsedData.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.entity.resp.index; + + +import lombok.Data; + +/** + * 首页VDC各资源使用情况 + */ +@Data +public class OrgLeaderVdcUsedData { + + //总资源 + private Integer total = 0; + + //分配下级资源 + private Integer allocateChild = 0; + + //本级已使用 + private Integer sameUsed = 0; + + //剩余可用 + private Integer usable = 0; + + private String unit; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/monitor/KcpAlarmSettingsResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/monitor/KcpAlarmSettingsResp.java new file mode 100644 index 0000000000000000000000000000000000000000..af46644f63cf9d444f16751166a9b81eb603cd63 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/monitor/KcpAlarmSettingsResp.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.manage.entity.resp.monitor; + +import com.hnkylin.cloud.core.enums.AlarmResourceType; +import com.hnkylin.cloud.core.enums.ArchitectureResourceType; +import lombok.Data; + +@Data +public class KcpAlarmSettingsResp { + + private Integer kcpSettingId; + + private AlarmResourceType resourceType; + + private Integer generalAlarm; + + private Integer severityAlarm; + + private Integer urgentAlarm; + + //private Integer durationTime; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/monitor/PageKcpAlarmLogResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/monitor/PageKcpAlarmLogResp.java new file mode 100644 index 0000000000000000000000000000000000000000..2e69cef26b1f3e73ba9720eba1b9e46dbee9a5bf --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/monitor/PageKcpAlarmLogResp.java @@ -0,0 +1,36 @@ +package com.hnkylin.cloud.manage.entity.resp.monitor; + +import com.hnkylin.cloud.core.enums.AlarmLevel; +import com.hnkylin.cloud.core.enums.AlarmResourceType; +import com.hnkylin.cloud.core.enums.AlarmTargetType; +import lombok.Data; + +@Data +public class PageKcpAlarmLogResp { + + //告警类型 + private AlarmResourceType resourceType; + + //告警等级 + private AlarmLevel alarmLevel; + + //告警对象 + private String alarmTarget; + + //对象类型 + private AlarmTargetType targetType; + + //告警详情 + private String alarmDetail; + + + //告警时间 + private String alarmTime; + + //可用区名称 + private String zoneName; + + //组织名称 + private String orgName; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/network/NetworkConfigRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/network/NetworkConfigRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..b4e9c1f70a027c583aeb6d7b8cf8c42cdffc0e4c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/network/NetworkConfigRespDto.java @@ -0,0 +1,47 @@ +package com.hnkylin.cloud.manage.entity.resp.network; + + +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + +@Data +public class NetworkConfigRespDto { + + private Integer networkId; + + private String networkName; + + private String interfaceType; + + private String addressPool; + + private String virtualSwitch; + + private String modelType; + + private String portGroup; + + private String portGroupUuid; + + private NetworkSecurityPolicy securityPolicy; + + private String securityGroup; + + private String securityGroupUuid; + + private Integer virtualFirewallId = 0; + + private String virtualFirewallName; + + private String createTime; + + private String vdcName; + + private String clusterName; + + private Integer clusterId; + + private Integer vdcId; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/network/NetworkDetailDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/network/NetworkDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..ee8d33f76e8d8961a2b317cf9dc9e9bcb5810a2c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/network/NetworkDetailDto.java @@ -0,0 +1,44 @@ +package com.hnkylin.cloud.manage.entity.resp.network; + +import com.hnkylin.cloud.core.enums.NetworkSecurityPolicy; +import lombok.Data; + + +@Data +public class NetworkDetailDto { + + + private Integer networkId; + + private Integer clusterId; + + private String clusterName; + + private String networkName; + + private String interfaceType; + + private String addressPool; + + private Integer addressPoolId; + + private String virtualSwitch; + + private String modelType; + + private String portGroup; + + private String portGroupUuid; + + private NetworkSecurityPolicy securityPolicy; + + private String securityGroup; + + private String securityGroupUuid; + + private Integer virtualFirewallId; + + private String virtualFirewallName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/CommonOrgTreeRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/CommonOrgTreeRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0fda4914c63fd3c19d68d572c08428ad12b38633 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/CommonOrgTreeRespDto.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.entity.resp.org; + + +import lombok.Data; + +@Data +public class CommonOrgTreeRespDto { + + private Integer organizationId; + + private String organizationName; + + private Integer parentId; + + private String parentName; + + private String remark; + + private Boolean topOrg = false; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrgDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrgDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..954ad9ea245a8dfc8fd6e3536e67754ae92fa321 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrgDetailRespDto.java @@ -0,0 +1,51 @@ +package com.hnkylin.cloud.manage.entity.resp.org; + +import lombok.Data; + + +@Data +public class OrgDetailRespDto { + + //组织id + private Integer organizationId; + //组织名称 + private String organizationName; + + //父组织ID + private Integer parentId; + + //父组织名称 + private String parentName; + + + //描述信息 + private String remark; + + //vdc-ID + private Integer vdcId; + //VDC名称 + private String vdcName; + + //是否拥有组织管理员 + private boolean hasOrgLeader; + + //是否能编辑父组织 + private boolean canModifyParent; + + //是否能编辑VDC + private boolean canModifyVdc; + + //组织管理员ID + private Integer orgLeaderUserId = 0; + + //组织管理员用户名 + private String orgLeaderUserName; + + //组织管理员真实姓名 + private String orgLeaderRealName; + + //组织管理员密码 + private String orgLeaderUserPassword; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrgSummaryRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrgSummaryRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..15ba6bb20d28ee0a027ae0267ed87484e3eb0ede --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrgSummaryRespDto.java @@ -0,0 +1,61 @@ +package com.hnkylin.cloud.manage.entity.resp.org; + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + + +@Data +public class OrgSummaryRespDto { + + private String orgName; + + + private String vdcName; + + private String parentOrgName; + + private String remark; + + private String createTime; + + + private Integer totalCpu; + + private Integer allocationCpu; + + private Integer surplusCpu; + + private Integer totalMem; + + private Integer allocationMem; + + private Integer surplusMem; + + private MemUnit memUnit; + + private Integer totalStorage; + + private Integer allocationStorage; + + private Integer surplusStorage; + + private StorageUnit storageUnit; + + + private Integer totalUser; + + private Integer activeUser; + + private Integer noActiveUser; + + + //总云服务器个数 + private Integer machineTotal; + //在线云服务器 + private Integer machineOnline; + //离线云服务器 + private Integer machineOffline; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrganizationRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrganizationRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..743a3ae06f1a4cbfd526239e441f7a7b25710fe2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/OrganizationRespDto.java @@ -0,0 +1,56 @@ +package com.hnkylin.cloud.manage.entity.resp.org; + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class OrganizationRespDto extends CommonOrgTreeRespDto { + + + //vdcId + private Integer vdcId = 0; + + //vdc名称 + private String vdcName = "-"; + + //用户数 + private Integer userNum; + + //云服务器数量 + private Integer serverVmNum; + + //分配cpu + private Integer allocationCpu = 0; + + //已使用Cpu + private Integer usedCpu = 0; + + //分配内存 + private BigDecimal allocationMem = BigDecimal.ZERO; + + //已使用内存 + private BigDecimal usedMem = BigDecimal.ZERO; + + private MemUnit memUnit = MemUnit.GB; + + //分配磁盘 + private BigDecimal allocationDisk = BigDecimal.ZERO; + + //已使用磁盘 + private BigDecimal usedDisk = BigDecimal.ZERO; + + private StorageUnit storageUnit = StorageUnit.GB; + +// //组织管理员ID +// private Integer orgLeaderUserId; +// +// //组织管理员名称 +// private String orgLeaderUserName; + + //子组织列表 + private List children; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/ParentOrgRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/ParentOrgRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..b973bb268b4d05bda412c850e40f6912c30fb57b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/org/ParentOrgRespDto.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.manage.entity.resp.org; + +import lombok.Data; + +import java.util.List; + +@Data +public class ParentOrgRespDto extends CommonOrgTreeRespDto { + + + //子组织列表 + private List children; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/CommonRoleDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/CommonRoleDto.java new file mode 100644 index 0000000000000000000000000000000000000000..084a54c7f0faba97966c494d049fc51dc8157f4c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/CommonRoleDto.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.Data; + +@Data +public class CommonRoleDto { + + //角色ID + private Integer roleId; + //组织名称 + private String roleName; + + //角色类型 + private RoleType roleType; + + //描述 + private String remark; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/OrgStatisticTreeDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/OrgStatisticTreeDto.java new file mode 100644 index 0000000000000000000000000000000000000000..99e5d8733d05525fa58619e79a9ed4795235b4b5 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/OrgStatisticTreeDto.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import com.hnkylin.cloud.manage.entity.resp.org.CommonOrgTreeRespDto; +import lombok.Data; + +import java.util.List; + +@Data +public class OrgStatisticTreeDto extends CommonOrgTreeRespDto { + + //统计数量 + private Integer statisticNum; + + //子组织列表 + private List children; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/PageRoleRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/PageRoleRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..ed9c1fa7724346c165764ca367808427bbe0cbbe --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/PageRoleRespDto.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.Data; + +@Data +public class PageRoleRespDto { + + private Integer roleId; + + private String roleName; + + private RoleType roleType; + + private String roleTypeDesc; + + private String remark; + + private Boolean canDelete; + + private Boolean canModify; + + private String createTime; + + private Boolean defaultRole; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/PermissionTreeDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/PermissionTreeDto.java new file mode 100644 index 0000000000000000000000000000000000000000..7e3fcb5790ce513d11152244ecf4957fb96e7e33 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/PermissionTreeDto.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PermissionTreeDto { + + private Integer permissionId; + + private String name; + + private String icon; + + private String routeKey; + + private Integer parentId; + + + private List children; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleDetailDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..118fb85c38a507dfb30d51345e60112393608b03 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleDetailDto.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import com.hnkylin.cloud.manage.entity.resp.role.CommonRoleDto; +import lombok.Data; + +import java.util.List; + +@Data +public class RoleDetailDto extends CommonRoleDto { + + + //角色拥有的权限 + private List permissions; + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleInfoRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleInfoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..b4fcfe25849d34b296234edf676e42dc4539994b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleInfoRespDto.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import lombok.Data; + +import java.util.List; + +@Data +public class RoleInfoRespDto extends CommonRoleDto { + + + //角色拥有的权限 + private List permissionTree; + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RolePermissionTreeDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RolePermissionTreeDto.java new file mode 100644 index 0000000000000000000000000000000000000000..b4a1f42fd53e34a7a82796cbcd4a0e7379ca565f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RolePermissionTreeDto.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +public class RolePermissionTreeDto { + + private Integer permissionId; + + private String name; + + private String icon; + + private String routeKey; + + private Integer parentId; + + + private List child; + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..23d96ab26fbf18ab86614a637ed8913d09a7b988 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/role/RoleRespDto.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.manage.entity.resp.role; + +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.Data; + +import java.util.List; + +@Data +public class RoleRespDto { + + //角色ID + private Integer roleId; + //组织名称 + private String roleName; + + //角色类型 + private RoleType roleType; + + //描述 + private String remark; + + +} + + diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/serverVm/PageServerVmRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/serverVm/PageServerVmRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..98757437e8bde7d6f1437246e8ea1145b6225e73 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/serverVm/PageServerVmRespDto.java @@ -0,0 +1,97 @@ +package com.hnkylin.cloud.manage.entity.resp.serverVm; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.McServerVmTaskStatus; +import lombok.Data; + +import java.util.Objects; + +@Data +public class PageServerVmRespDto implements Comparable { + + //云服务器id + private Integer serverVmId; + + //云服务器uuid + private String serverVmUuid; + + //云服务器名称 + private String aliasName; + + //云服务器状态 + private McServerVmStatus status; + + //云服务器任务状态 + private McServerVmTaskStatus taskStatus; + + //云服务器ip + private String ip; + + //操作系统 + private String os; + + private String architecture; + + //cpu数 + private Integer cpus; + + //内存大小 + private Integer memory; + + //磁盘大小 + private String disks; + + + private String usage; + + //创建时间 + private String createDate; + + //内存单位 + private String memoryUnit; + + //过期时间 + private Integer deadlineTime; + + //是否已经过期 + private Boolean deadlineFlag; + + //描述 + private String description; + + private String vdcName; + + private String orgName; + + private String zoneName; + + private String userName; + + private String clusterName; + + private String logo; + + private String logoName; + + + /** + * 根据电源状态自定义排序 + * + * @return + */ + @Override + public int compareTo(PageServerVmRespDto obj) { + + if (Objects.equals(obj.getStatus(), this.getStatus())) { + return 0; + } else { + if (Objects.equals(obj.getStatus(), McServerVmStatus.AVAILABLE) || Objects.equals(obj.getStatus(), + McServerVmStatus.INSTALLING) || Objects.equals(obj.getStatus(), McServerVmStatus.SUSPEND) || Objects.equals(obj.getStatus(), + McServerVmStatus.CONNECTED)) { + return 1; + } else { + return -1; + } + } + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/serverVm/ServerVmZoneOrgTreeRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/serverVm/ServerVmZoneOrgTreeRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..917c33a5d6c6cb6568068bcfcc07a48e8f3e3f67 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/serverVm/ServerVmZoneOrgTreeRespDto.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.manage.entity.resp.serverVm; + +import com.hnkylin.cloud.manage.enums.ZoneOrgUserType; +import lombok.Data; + +import java.util.List; +import java.util.Objects; + + +/** + * 服务器模块-可用区组织数 + */ +@Data +public class ServerVmZoneOrgTreeRespDto { + + private Integer uniqueId; + + private String name; + + private Integer serverVmCount; + + private ZoneOrgUserType type; + + private String treeUniqueId; + + private List child; + + + public void countServerVmCount() { + if (Objects.nonNull(child) && !child.isEmpty()) { + int total = child.stream().mapToInt(ServerVmZoneOrgTreeRespDto::getServerVmCount).sum(); + this.serverVmCount = total; + } else { + this.serverVmCount = 0; + } + + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/ModifyUserInfoRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/ModifyUserInfoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..cbf7e39d110c6432fd7cf744905b9aa0a41c516e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/ModifyUserInfoRespDto.java @@ -0,0 +1,39 @@ +package com.hnkylin.cloud.manage.entity.resp.user; + +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.Data; + +@Data +public class ModifyUserInfoRespDto { + + private Integer userId; + + private String userName; + + private String realName; + + private String organizationName; + + private Integer organizationId; + + private String password; + + private String mobile; + + private String remark; + + private CloudUserStatus status; + + private String roleName; + + private Integer roleId; + + private boolean canModifyOrg; + + private boolean canModifyRole; + + private RoleType roleType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/PageUserRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/PageUserRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..71eda00ee7c3d69c7c755aac7b9ae26f1d14f8a1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/PageUserRespDto.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.resp.user; + +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.RoleType; +import lombok.Data; + +@Data +public class PageUserRespDto { + + //用户ID + private Integer userId; + + //用户名称 + private String userName; + + //角色名称 + private String roleName; + + private String realName; + + //角色类型 + private RoleType roleType; + + //手机号 + private String mobile; + + //状态 + private CloudUserStatus status; + + //创建时间 + private String createTime; + + + private Boolean canModifyUser = true; + + private Boolean canDeleteUser = true; + + private Boolean defaultUser = false; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserInfoRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserInfoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..67d2443e3e4268e2091da04c51d3d815bd691c77 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserInfoRespDto.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.manage.entity.resp.user; + +import lombok.Data; + +import java.util.List; + +@Data +public class UserInfoRespDto { + + private String userName; + + private String realName; + + private String organizationName; + + private Integer organizationId; + + private String mobile; + + private String remark; + + private List permissions; + + private boolean topUser; + + private Integer userId; + + private boolean superUser; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserMachineCountDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserMachineCountDto.java new file mode 100644 index 0000000000000000000000000000000000000000..005f889e59efd1a2f70f0b589293bca68bffc847 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserMachineCountDto.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.entity.resp.user; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UserMachineCountDto { + + private Integer userId; + + private Integer machineCount; + + private String realName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserPermissionDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserPermissionDto.java new file mode 100644 index 0000000000000000000000000000000000000000..ce1f951a3a0f6408c9281d2e23a9d5ceefe798bb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/user/UserPermissionDto.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.manage.entity.resp.user; + + +import lombok.Data; + +@Data +public class UserPermissionDto { + private Integer permissionId; + + private String icon; + + private String routeKey; + + + private Integer parentId; + + private String parentIcon; + + private String parentRouteKey; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/BaseVdcRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/BaseVdcRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..8ea9f68f717c31eb86e1863a1367b5ecc9a2eab6 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/BaseVdcRespDto.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import lombok.Data; + + +@Data +public class BaseVdcRespDto { + private Integer vdcId; + private String vdcName; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/CommonVdcArchitectureResource.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/CommonVdcArchitectureResource.java new file mode 100644 index 0000000000000000000000000000000000000000..1375ff77bed4e894b0a9531b4a94b33491782ca5 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/CommonVdcArchitectureResource.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.ArchitectureResourceType; +import com.hnkylin.cloud.core.enums.ArchitectureType; +import lombok.Data; + +@Data +public class CommonVdcArchitectureResource { + + + //架构类型 + private ArchitectureType architectureType; + + //资源类型 + private ArchitectureResourceType resourceType; + + //总 + private Integer total = 0; + + //已使用(本级已使用+已分配下级) + private Integer used = 0; + + //已分配下级 + private Integer allocationChild = 0; + + //本级用户已使用 + private Integer sameUserUsed = 0; + + + //剩余 + private Integer surplus = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/CommonVdcTreeRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/CommonVdcTreeRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0269c2ee8618bb639f742206c606087455031700 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/CommonVdcTreeRespDto.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +/** + * 通用vdc-树形结构对象 + */ +@Data +public class CommonVdcTreeRespDto { + + private Integer vdcId; + + private String vdcName; + + private Integer parentId; + + private String parentName; + + private String remark; + + private Integer vcpu; + + private Integer mem; + + private MemUnit memUnit; + + private Integer storage; + + private StorageUnit storageUnit; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/ModifyVdcDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/ModifyVdcDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d2bc85ae43c29d4f858b7d0928802f127a504007 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/ModifyVdcDetailRespDto.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + + +import com.hnkylin.cloud.manage.entity.resp.network.NetworkDetailDto; +import lombok.Data; + +import java.util.List; + +/** + * 编辑VDC时-VDC详情 + */ +@Data +public class ModifyVdcDetailRespDto { + + private Integer vdcId; + + private String vdcName; + + private Integer parentId; + + private String parentName; + + + private Integer zoneId; + + + private String zoneName; + + + private List networkList; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/ParentVdcRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/ParentVdcRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..68cd588774f19f72f3f3393ce8e61081abf647ad --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/ParentVdcRespDto.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import lombok.Data; + +import java.util.List; + +@Data +public class ParentVdcRespDto extends CommonVdcTreeRespDto { + + + //子组织列表 + private List children; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcArchitectureResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcArchitectureResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..a6e391200f1e7ceb4550af247b3bb8c00d4c0771 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcArchitectureResourceRespDto.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class VdcArchitectureResourceRespDto { + + + //可用cpu + private Integer usableVcpu = 0; + + //已使用CPU=本级VDC用户直接使用cpu+已分配给下级VDC CPU + private Integer usedCpu = 0; + + //总cpu + private Integer totalCpu; + + + //可用内存 + private Integer usableMem = 0; + + //已使用内存=本级VDC用户直接使用内存+已分配给下级VDC 内存 + private Integer usedMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + //总内存 + private Integer totalMem; + + //架构 + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcArchitectureUsedResourceDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcArchitectureUsedResourceDto.java new file mode 100644 index 0000000000000000000000000000000000000000..4ae139ac047eefeffdfb176eb82e8f0434ff8035 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcArchitectureUsedResourceDto.java @@ -0,0 +1,50 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +/** + * Vdc-架构已使用资源 + */ +@Data +public class VdcArchitectureUsedResourceDto { + + //总cpu + private Integer totalCpu; + + //已使用CPU(本级已使用+已分配下级) + private Integer usedCpu; + + //已分配下级 + private Integer allocationCpu; + + //本级用户已使用 + private Integer sameUserUsedCpu; + + //剩余cpu + private Integer surplusCpu; + + + //总内存 + private Integer totalMem; + + //已使用内存(本级已使用+已分配下级) + private Integer usedMem; + + //已分配下级 + private Integer allocationMem; + + //本级用户已使用 + private Integer sameUserUsedMem; + + private MemUnit memUnit; + + //剩余内存 + private Integer surplusMem; + + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..2a4f3d143c2bf80ebf6a9ae068623eebaa8c358a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcDetailRespDto.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import lombok.Data; + + +@Data +public class VdcDetailRespDto { + private Integer vdcId; + private String vdcName; + //分配cpu + private Integer allocationCpu; + + //分配内存 + private Integer allocationMem; + + //分配磁盘 + private Integer allocationDisk; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcInfoRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcInfoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..6970abf6743beb9fe283258627383e2961b5c121 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcInfoRespDto.java @@ -0,0 +1,91 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkDetailDto; +import lombok.Data; + +import java.util.List; + +@Data +public class VdcInfoRespDto { + + private Integer vdcId; + + private String vdcName; + + private Integer parentId; + + private String parentName; + + private String remark; + + private String orgName; + + + private Integer networkNum; + + private String zoneName; + + + private String createTime; + + + //总cpu + private Integer totalCpu; + + //已使用CPU(本级已使用+已分配下级) + private Integer usedCpu; + + //已分配下级 + private Integer allocationCpu; + + //本级用户已使用 + private Integer sameUserUsedCpu; + + //剩余cpu + private Integer surplusCpu; + + //总内存 + private Integer totalMem; + + //已使用内存(本级已使用+已分配下级) + private Integer usedMem; + + //已分配下级 + private Integer allocationMem; + + //本级用户已使用 + private Integer sameUserUsedMem; + + //剩余内存 + private Integer surplusMem; + + + private MemUnit memUnit; + + //总存储 + private Integer totalStorage; + + //已使用存储(本级已使用+已分配下级) + private Integer usedStorage; + + //已分配下级 + private Integer allocationStorage; + + //本级用户已使用 + private Integer sameUserUsedStorage; + + //剩余存储 + private Integer surplusStorage; + + private StorageUnit storageUnit; + + + private List networkList; + + //各个架构资源使用情况 + private List architectureUsedResourceList; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcModifyArchitectureResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcModifyArchitectureResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..1e7bcb127cd0f91d528ac5acb5762952f1af9620 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcModifyArchitectureResourceRespDto.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class VdcModifyArchitectureResourceRespDto { + + + //当前cpu + private Integer currentVcpu = 0; + + //已使用CPU=本级VDC用户直接使用cpu+已分配给下级VDC CPU + private Integer usedCpu = 0; + + //上级可用cpu + private Integer parentUsableCpu; + + + //当前内存 + private Integer currentMem = 0; + + //已使用内存=本级VDC用户直接使用内存+已分配给下级VDC 内存 + private Integer usedMem = 0; + + //上级可用内存 + private Integer parentUsableMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + + //架构 + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcModifyResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcModifyResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..a67f04d4f7253ce66d6981bf2ec38071f23372d9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcModifyResourceRespDto.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + + +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class VdcModifyResourceRespDto { + + //当前存储 + private Integer currentStorage = 0; + + private StorageUnit storageUnit = StorageUnit.GB; + + //已使用存储 + private Integer usedStorage = 0; + + //上级可用存储 + private Integer parentUsableStorage = 0; + + + //架构资源 + List architectureResourceList = new ArrayList<>(); + + private Boolean modifyChild = false; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..8868acdb403e1b78e53e4c6f2aa7b217e9a15734 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcResourceRespDto.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + + +@Data +public class VdcResourceRespDto { + + + //可用存储 + private Integer usableStorage = 0; + + + //已使用存储=本级VDC用户直接使用存储资源+已分配给下级VDC存储 + private Integer usedStorage = 0; + + private Integer totalStorage; + + + //存储单位 + private StorageUnit storageUnit = StorageUnit.TB; + + + private List architectureResourceList = new ArrayList<>(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcSameLevelUserUsedArchitectureResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcSameLevelUserUsedArchitectureResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..a605e4c63a3131db0b45dedadd555d456286e2cb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcSameLevelUserUsedArchitectureResourceRespDto.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class VdcSameLevelUserUsedArchitectureResourceRespDto { + + + //已使用cpu + private Integer usedVcpu = 0; + + //已使用 + private Integer usedMem = 0; + + //架构 + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcSameLevelUserUsedResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcSameLevelUserUsedResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d65e803aef7dc55f456f8715f25469a926ef491c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcSameLevelUserUsedResourceRespDto.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 直接挂在本级VDC(组织)下用户云服务器占用资源 + */ +@Data +public class VdcSameLevelUserUsedResourceRespDto { + + //总存储大小 + private Integer usedStorage = 0; + + //各个架构总使用CPU + private Integer usedCpu = 0; + + //各个架构总使用内存 + private Integer usedMem = 0; + + + private List userUsedArchitectureResourceList = + new ArrayList<>(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcTreeRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcTreeRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..ee33b9476dc3fe64e03283efbc7fb299e210d231 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcTreeRespDto.java @@ -0,0 +1,62 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.List; + +@Data +public class VdcTreeRespDto extends VdcInfoRespDto { + + + private Integer vdcId; + + private String vdcName; + + private Integer parentId; + + private String parentName; + + private String remark; + + private String orgName; + + + private Integer networkNum; + + private String zoneName; + + + //总cpu + private Integer totalCpu; + + //已使用CPU(本级已使用+已分配下级) + private Integer usedCpu; + + + //总内存 + private Integer totalMem; + + //已使用内存(本级已使用+已分配下级) + private Integer usedMem; + + + private MemUnit memUnit; + + //总存储 + private Integer totalStorage; + + //已使用存储(本级已使用+已分配下级) + private Integer usedStorage; + + + //剩余存储 + private Integer surplusStorage; + + private StorageUnit storageUnit; + + + //子组织列表 + private List children; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcUsedResourceDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcUsedResourceDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0a3de43e825f39abc679ad55a08a8f15a97c6efc --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/vdc/VdcUsedResourceDto.java @@ -0,0 +1,67 @@ +package com.hnkylin.cloud.manage.entity.resp.vdc; + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class VdcUsedResourceDto { + + //总cpu + private Integer totalCpu; + + //已使用CPU(本级已使用+已分配下级) + private Integer usedCpu; + + //已分配下级 + private Integer allocationCpu; + + //本级用户已使用 + private Integer sameUserUsedCpu; + + //剩余cpu + private Integer surplusCpu; + + + //总内存 + private Integer totalMem; + + //已使用内存(本级已使用+已分配下级) + private Integer usedMem; + + //已分配下级 + private Integer allocationMem; + + //本级用户已使用 + private Integer sameUserUsedMem; + + private MemUnit memUnit; + + //剩余内存 + private Integer surplusMem; + + //总存储 + private Integer totalStorage; + + //已使用存储(本级已使用+已分配下级) + private Integer usedStorage; + + //已分配下级 + private Integer allocationStorage; + + //本级用户已使用 + private Integer sameUserUsedStorage; + + private StorageUnit storageUnit; + + //剩余存储 + private Integer surplusStorage; + + + private List vdcArchitectureUsedResourceList = new ArrayList<>(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyDeferredDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyDeferredDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0deb80f39eaae074c7ddf188b67b397b7b8622e8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyDeferredDetailRespDto.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import lombok.Data; + +@Data +public class ApplyDeferredDetailRespDto extends BaseWorkOrderDetailDto { + + + //原过期时间 + private String oldDeadlineTime; + + //新过期时间 + private String newDeadlineTime; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyModifyVdcArchitectureResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyModifyVdcArchitectureResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..67622b0c874f88ac6212db484faf4d5ea05f5cc2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyModifyVdcArchitectureResourceRespDto.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class ApplyModifyVdcArchitectureResourceRespDto { + + + //原始cpu大小 + private Integer oldCpu = 0; + + //申请存储大小 + private Integer applyCpu = 0; + + //审核后存储大小 + private Integer realCpu = 0; + + + //原始内存 + private Integer oldMem = 0; + + //申请内存大小 + private Integer applyMem = 0; + + //审核后存储大小 + private Integer realMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + + //架构 + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyModifyVdcDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyModifyVdcDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..27c95e0373f5bb33e58e4587e0c812b442221b64 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyModifyVdcDetailRespDto.java @@ -0,0 +1,38 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import com.hnkylin.cloud.core.enums.StorageUnit; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 申请云服务器审核通过时,响应的申请详情,包括 + */ +@Data +public class ApplyModifyVdcDetailRespDto extends BaseWorkOrderDetailDto { + + + private String vdcName; + + private String orgName; + + + //原始存储大小 + private Integer oldStorage = 0; + + //申请存储大小 + private Integer applyStorage = 0; + + + //审核后存储大小 + private Integer realStorage = 0; + + private StorageUnit storageUnit = StorageUnit.GB; + + private List applyArchitectureResourceList = new ArrayList<>(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyServerVmDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..47a1f99db0e41b482ce3d070b778be608f8612e9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyServerVmDetailRespDto.java @@ -0,0 +1,82 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import com.hnkylin.cloud.core.enums.ApplyServerVmType; +import com.hnkylin.cloud.core.enums.McCloneType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ApplyServerVmDetailRespDto extends BaseWorkOrderDetailDto { + + + private ApplyServerVmType applyServerVmType; + + private String templateName; + + //操作系统 + private String osMachine; + + private String architecture; + + //使用时间 + private Integer useMonth; + + //申请个数 + private Integer applyNum; + + + //变更后申请个数(审核时管理员可能修改) + private Integer modifyApplyNum; + + //审核时是否变更了申请个数 + private boolean ifModifyApplyNum; + + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + private String deadlineTypeDesc; + + //cpu + private Integer cpu; + + //变更后cpu(审核时管理员可能修改) + private Integer modifyCpu; + + //审核时是否变更了CPU + private boolean ifModifyCpu; + + //内存 + private Integer mem; + + private MemUnit menUtil; + + //变更后(审核时管理员可能修改) + private Integer modifyMem; + + //审核时是否变更了内存 + private boolean ifModifyMem; + + //申请时间 + private String applyTime; + + private String description; + + //硬盘信息 + private List disks; + + //网卡信息 + private List networks; + + private List isoList; + + private String clusterName; + + private McCloneType mcCloneType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyServerVmIsoDetailResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyServerVmIsoDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..e0ef616789144a9d9698215418493af6be1f2c2b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ApplyServerVmIsoDetailResp.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ApplyServerVmIsoDetailResp { + + + private String isoFile; + + private ModifyType modifyType; + + + private Integer applyId; + + private ModifyType applyModifyType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/BaseWorkOrderDetailDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/BaseWorkOrderDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..b391f41c0b940db48e2279a4f0eb9e90fb75d5eb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/BaseWorkOrderDetailDto.java @@ -0,0 +1,47 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import lombok.Data; + +@Data +public class BaseWorkOrderDetailDto { + + //工单类型 + private WorkOrderType workOrderType; + + private String workOrderTypeDesc; + + //工单对象 + private String workOrderTarget; + + //工单状态 + private WorkOrderStatus status; + + //状态描述 + private String statusDesc; + + //申请人 + private String applyUser; + + //申请时间 + private String applyTime; + + //申请原因 + private String applyReason; + + + //审核意见 + private String auditOpinion; + + //审核时间 + private String auditionTime; + + //审核者 + private String auditionUser; + + //用户Id + private Integer userId; + + private String orgName; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/CommonServerVmDetailResp.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/CommonServerVmDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..fc381c4d65d0cef655fd00c4792cdcefd63cb63c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/CommonServerVmDetailResp.java @@ -0,0 +1,70 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.McServerClusterType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkConfigRespDto; +import lombok.Data; + +import java.util.List; + +@Data +public class CommonServerVmDetailResp { + //申请云服务器名称 + private String aliasName; + + //申请时-cpu + private Integer cpu; + + //申请时-内存 + private Integer mem; + //申请时内存单位 + private MemUnit memUnit; + + + //模板-操作系统 + private String osMachine; + + //模板-架构 + private String architecture; + + private String systemType; + + //主机模式类型 + private McServerClusterType serverClusterType = McServerClusterType.CUSTOM; + + //模板选中的计算资源 + private String selectCluster; + + //计算资源uudi + private String selectClusterUuid; + + //主机资源模式id + private String selectTagIds; + + //主机资源模式名称 + private String selectTagNames; + + //模板选中的计存储位置 + private Integer storageLocationId; + + + //磁盘列表 + private List disks; + + //网卡信息 + private List interfaceList; + + //模板对应可选择的计算资源节点 + private List clusterList; + + //mc中可选的存储位置 + private List storageLocationList; + + //云管中自定义的网络信息 + private List networkConfigList; + + + //绑定的资源列表 + private List clusterBindResourceList; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ModifyServerVmDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ModifyServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..ad533f36259286209cee0e383866f90ae5abe6cf --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ModifyServerVmDetailRespDto.java @@ -0,0 +1,54 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ModifyServerVmDetailRespDto extends BaseWorkOrderDetailDto { + + + //操作系统 + private String osMachine; + + private String architecture; + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + private String deadlineTypeDesc; + + + private String deadLineTime; + + //cpu + private Integer cpu; + //变更前cpu(审核时管理员可能修改) + private Integer originalCpu; + + //审核时是否变更了CPU + private boolean ifModifyCpu; + + //内存 + private Integer mem; + + //变更前(审核时管理员可能修改) + private Integer originalMem; + + //审核时是否变更了内存 + private boolean ifModifyMem; + + private MemUnit menUtil; + + //申请时间 + private String applyTime; + + //硬盘信息 + private List disks; + + //网卡信息 + private List networks; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ModifyVdcArchitectureResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ModifyVdcArchitectureResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..a2242d5489605cfc62a6827a3b908162e35b2e5c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ModifyVdcArchitectureResourceRespDto.java @@ -0,0 +1,46 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.ArchitectureType; +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + + +/** + * vdc架构资源 + */ +@Data +public class ModifyVdcArchitectureResourceRespDto { + + + //当前cpu + private Integer currentVcpu = 0; + + //已使用CPU=本级VDC用户直接使用cpu+已分配给下级VDC CPU + private Integer usedCpu = 0; + + //上级可用cpu + private Integer parentUsableCpu = 0; + + private Integer applyCpu = 0; + + + //当前内存 + private Integer currentMem = 0; + + //已使用内存=本级VDC用户直接使用内存+已分配给下级VDC 内存 + private Integer usedMem = 0; + + //上级可用内存 + private Integer parentUsableMem = 0; + + private MemUnit memUnit = MemUnit.GB; + + + private Integer applyMem = 0; + + + //架构 + private ArchitectureType architectureType; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PageWorkOrderRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PageWorkOrderRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..26a20bef48a14df777700f8c5227a1fb17c2479e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PageWorkOrderRespDto.java @@ -0,0 +1,40 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import lombok.Data; + +@Data +public class PageWorkOrderRespDto { + + private String applyUser; + +// private String organizationName; + + private Integer workOrderId; + + private WorkOrderType type; + + private String typeDesc; + + private String target; + + private WorkOrderStatus status; + + private String statusDesc; + + private String applyReason; + + private String auditOpinion; + + private String applyTime; + + + private String auditTime; + + private Integer applyUserId; + + private String userName; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassApplyServerVmDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassApplyServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d16af0cfe1348b37bff927d99337a8b16c1c264d --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassApplyServerVmDetailRespDto.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import com.hnkylin.cloud.core.enums.ApplyServerVmType; +import com.hnkylin.cloud.core.enums.McServerClusterType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkConfigRespDto; +import com.hnkylin.cloud.manage.entity.resp.workorder.ApplyServerVmIsoDetailResp; +import lombok.Data; + +import java.util.List; + +/** + * 申请云服务器审核通过时,响应的申请详情,包括 + */ +@Data +public class PassApplyServerVmDetailRespDto extends CommonServerVmDetailResp { + + private ApplyServerVmType applyServerVmType; + + + //申请个数 + private Integer applyNum; + + + //模板名称 + private String templateName; + + + //模板ID + private Integer templateId; + + + //光驱文件列表 + private List applyIsoList; + + private List allIsoList; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassModifyServerVmDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassModifyServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..15a1f5a4b974c95accbb175a5083a07b17ce9c72 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassModifyServerVmDetailRespDto.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import lombok.Data; + + +/** + * 申请云服务器审核通过时,响应的申请详情,包括 + */ +@Data +public class PassModifyServerVmDetailRespDto extends CommonServerVmDetailResp { + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassModifyVdcDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassModifyVdcDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..f18255f3a292d456e236afa639344b422c967c54 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/PassModifyVdcDetailRespDto.java @@ -0,0 +1,43 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import com.hnkylin.cloud.core.enums.StorageUnit; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcModifyResourceRespDto; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 申请云服务器审核通过时,响应的申请详情,包括 + */ +@Data +public class PassModifyVdcDetailRespDto { + + + private Integer workOrderId; + + private String vdcName; + + private String orgName; + + private boolean firstVdc = false; + + //当前存储 + private Integer currentStorage = 0; + + private StorageUnit storageUnit = StorageUnit.GB; + + //已使用存储 + private Integer usedStorage = 0; + + //上级可用存储 + private Integer parentUsableStorage = 0; + + private Integer applyStorage; + + private List applyArchitectureResourceList = new ArrayList<>(); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmDiskDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmDiskDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d7a21b5cbe09e0eae9bcc9c3271f5bfe2338d769 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmDiskDto.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ServerVmDiskDto { + + //硬盘大小 + private Integer diskSize; + //用途 + private String purpose; + + private ModifyType modifyType; + + private Integer oldDiskSize; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmIsoDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmIsoDto.java new file mode 100644 index 0000000000000000000000000000000000000000..2880634729308b177f8bd21e1bf912c771cd0b9c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmIsoDto.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ServerVmIsoDto { + + //用途 + private String isoFile; + + private ModifyType modifyType; + + private String oldIsoFile; + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmNetworkDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmNetworkDto.java new file mode 100644 index 0000000000000000000000000000000000000000..41801f63824b701269711ee3fdc6b6400c4433e3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/ServerVmNetworkDto.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ServerVmNetworkDto { + //网卡用途 + private String purpose; + + private ModifyType modifyType; + + private Boolean setIpInfo; + + private Boolean ipBindMac; + + private Boolean manualSetIp; + + private Boolean automaticAcqIp; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/UserWaitCheckCountParam.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/UserWaitCheckCountParam.java new file mode 100644 index 0000000000000000000000000000000000000000..539c91f80ea598a99e049c329ac1b0137e8d92ec --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/UserWaitCheckCountParam.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + +import lombok.Data; + +@Data +public class UserWaitCheckCountParam { + + + private Integer waitCheckCount = 0; +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/WorkOrderUserDetailRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/WorkOrderUserDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..2b6914c476d916ca8916fce95db6d27d243403d2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/workorder/WorkOrderUserDetailRespDto.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.manage.entity.resp.workorder; + + +import com.hnkylin.cloud.manage.entity.resp.workorder.BaseWorkOrderDetailDto; +import lombok.Data; + +@Data +public class WorkOrderUserDetailRespDto extends BaseWorkOrderDetailDto { + + + //账号 + private String userName; + + //真实姓名 + private String realName; + + //新真实姓名 + private String newRealName; + + //组织名 + private String organizationName; + + //部门名称 + private String deptName; + + //手机号 + private String mobile; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/PageZoneRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/PageZoneRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..b0a90a335cea2a75bd2fc111b1319443c7200c6a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/PageZoneRespDto.java @@ -0,0 +1,40 @@ +package com.hnkylin.cloud.manage.entity.resp.zone; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import com.hnkylin.cloud.manage.enums.ClusterStatus; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class PageZoneRespDto { + + //可用区ID + private Integer zoneId; + + //可用区名称 + private String name; + + //可用区描述 + private String remark; + + + //集群类型 + private CloudClusterType type; + + private String clusterNames = "--"; + + //总cpu + private Integer cpuTotal = 0; + + + //总内存 + private Integer memTotal = 0; + + + //总存储 + private Integer storageTotal = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneDetailDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..8ab7fc3df2287536b4b1bff7b746232bce3883f4 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneDetailDto.java @@ -0,0 +1,67 @@ +package com.hnkylin.cloud.manage.entity.resp.zone; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.Data; + +@Data +public class ZoneDetailDto { + + //可用区ID + private Integer zoneId; + + //可用区名称 + private String name; + + //可用区描述 + private String remark; + + + //资源类型 + private CloudClusterType type; + + //创建时间 + private String createTime; + + //总cpu + private Integer cpuTotal = 0; + //已使用cpu + private Integer cpuUsed = 0; + + + //总内存 + private Integer memTotal = 0; + //已使用内存 + private Integer memUsed = 0; + + + //总存储 + private Integer storageTotal = 0; + //已使用存储 + private Integer storageUsed = 0; + + + //集群个数 + private Integer clusterTotal = 0; + //在线集群个数 + private Integer clusterOnline = 0; + //离线集群个数 + private Integer clusterOffline = 0; + + + //物理主机个数 + private Integer physicalHostTotal = 0; + //在线物理主机个数 + private Integer physicalHostOnline = 0; + //离线物理主机个数 + private Integer physicalHostOffline = 0; + + + //总云服务器个数 + private Integer machineTotal = 0; + //在线云服务器 + private Integer machineOnline = 0; + //离线云服务器 + private Integer machineOffline = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneInfoDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneInfoDto.java new file mode 100644 index 0000000000000000000000000000000000000000..09f5ceaf57e0c78673fb4a54ed492b09c5fb3b37 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneInfoDto.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.manage.entity.resp.zone; + +import com.hnkylin.cloud.core.enums.CloudClusterType; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class ZoneInfoDto { + + //可用区ID + private Integer zoneId; + + //可用区名称 + private String name; + + //可用区描述 + private String remark; + + + //集群类型 + private CloudClusterType type; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneVdcResourceRespDto.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneVdcResourceRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..9148be426957f79ae20b654d471bb51514db2429 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/entity/resp/zone/ZoneVdcResourceRespDto.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.entity.resp.zone; + +import lombok.Data; + + +/** + * 可用区下已分配所有一级VDC资源 + */ +@Data +public class ZoneVdcResourceRespDto { + + //分配cpu和 + private Integer totalAllocationCpu = 0; + + //分配内存和 + private Integer totalAllocationMem = 0; + + //分配存储和 + private Integer totalAllocationStorage = 0; + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/ClusterStatus.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/ClusterStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..ca8f0a778293d61493def7c0f05646c19226675a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/ClusterStatus.java @@ -0,0 +1,32 @@ +package com.hnkylin.cloud.manage.enums; + +public enum ClusterStatus { + ONLINE(1, "ONLINE"), + OFFLINE(0, "OFFLINE"), + EXCEPTION(-1, "EXCEPTION"); + + + ClusterStatus(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreStatus.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..bb2839b9f7ee53c16449daf713a986e18bce9c27 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreStatus.java @@ -0,0 +1,36 @@ +package com.hnkylin.cloud.manage.enums; + +/** + * mc 存储状态 + */ +public enum DataStoreStatus { + + NORMAL(0, "NORMAL"), + WARNING(1, "WARNING"), + ERROR(2, "ERROR"); + + + DataStoreStatus(int id, String name) { + this.id = id; + this.name = name; + } + + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreType.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreType.java new file mode 100644 index 0000000000000000000000000000000000000000..b821222b6b693a3ea887919426b886040b3b114e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreType.java @@ -0,0 +1,39 @@ +package com.hnkylin.cloud.manage.enums; + +/** + * mc 存储类型 + */ +public enum DataStoreType { + + LOCAL(0, "LOCAL"), + NFS(1, "NFS"), + DISTRIBUTED(2, "Distributed"), + CIFS(3, "CIFS"), + IPSAN(4, "IPSAN"), + FCSAN(5, "FCSAN"); + + + DataStoreType(int id, String name) { + this.id = id; + this.name = name; + } + + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreUsage.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreUsage.java new file mode 100644 index 0000000000000000000000000000000000000000..4c7586380daf13b54f72f55ed37b80db45bf2baa --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/DataStoreUsage.java @@ -0,0 +1,35 @@ +package com.hnkylin.cloud.manage.enums; + +/** + * mc 存储用途 + */ +public enum DataStoreUsage { + + MANAGE(0, "Manage"), + DATA(1, "Data"); + + + DataStoreUsage(int id, String name) { + this.id = id; + this.name = name; + } + + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/McPhysicaHostStatus.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/McPhysicaHostStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..b6776570f7b699b9b68e07034dbaa6329e93eb29 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/McPhysicaHostStatus.java @@ -0,0 +1,36 @@ +package com.hnkylin.cloud.manage.enums; + +/** + * mc 存储状态 + */ +public enum McPhysicaHostStatus { + + ONLINE(1, "ONLINE"), + OFFLINE(0, "OFFLINE"), + HALT(-1, "HALT"); + + + McPhysicaHostStatus(int id, String name) { + this.id = id; + this.name = name; + } + + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/OrgStatisticTreeType.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/OrgStatisticTreeType.java new file mode 100644 index 0000000000000000000000000000000000000000..7c62af9cf453e218432c71ef90d10d80740e1d8f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/OrgStatisticTreeType.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.enums; + +public enum OrgStatisticTreeType { + + USER(0, "用户数量"), + ; + + + OrgStatisticTreeType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/ZoneOrgUserType.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/ZoneOrgUserType.java new file mode 100644 index 0000000000000000000000000000000000000000..6b7c1798a68e4270d5d0715c3583f174a066fd98 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/enums/ZoneOrgUserType.java @@ -0,0 +1,34 @@ +package com.hnkylin.cloud.manage.enums; + +public enum ZoneOrgUserType { + + ZONE(0, "可用区"), + ORG(1, "组织"), + USER(2, "用户"); + + + ZoneOrgUserType(int value, String desc) { + this.value = value; + this.desc = desc; + } + + private int value; + private String desc; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/CloudServiceInterceptor.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/CloudServiceInterceptor.java new file mode 100644 index 0000000000000000000000000000000000000000..7d6edab95f1ab2d057773c7863c3dfe04f0d2bf9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/CloudServiceInterceptor.java @@ -0,0 +1,76 @@ +package com.hnkylin.cloud.manage.interceptor; + + +import com.hnkylin.cloud.core.config.exception.KylinTokenException; +import com.hnkylin.cloud.manage.config.AuthExcludeApiProperties; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.manage.constant.CloudManageRedisConstant; +import com.hnkylin.cloud.manage.service.cache.LoginUserCacheService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + + +@Slf4j +public class CloudServiceInterceptor implements HandlerInterceptor { + + @Autowired + private AuthExcludeApiProperties authExcludeApiProperties; + + @Resource + private LoginUserCacheService loginUserCacheService; + + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws + Exception { + String uri = request.getRequestURI(); + String token = request.getHeader(KylinCloudManageConstants.KYLIN_ACCESS_TOKEN); + log.info("deal request: {}", uri); + List exApis = authExcludeApiProperties.getAuthExcludeApis(); + + if (exApis.contains(uri)) { + return true; + } + + + //判断token是否存在 + if (StringUtils.isBlank(token)) { + throw new KylinTokenException(KylinHttpResponseConstants.NOT_EXIST_TOKEN); + } + Object redisToken = loginUserCacheService.vGet(token); + if (Objects.isNull(redisToken)) { + //token过期,重新登录 + throw new KylinTokenException(KylinHttpResponseConstants.TOKEN_EXPIRE); + } + //重新设置token过期时间 + loginUserCacheService.vSet(token, redisToken, CloudManageRedisConstant.CLOUD_MANAGE_LOGIN_USER_CACHE_EXPIRE, + TimeUnit.MILLISECONDS); + loginUserCacheService.vSet(CloudManageRedisConstant.UID + redisToken, token, CloudManageRedisConstant + .CLOUD_MANAGE_LOGIN_USER_CACHE_EXPIRE, TimeUnit.MILLISECONDS); + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable + ModelAndView modelAndView) throws Exception { + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable + Exception ex) throws Exception { + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/InterceptorConfig.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/InterceptorConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..23605b80975a817f719218d824efc109454f406f --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/InterceptorConfig.java @@ -0,0 +1,49 @@ +package com.hnkylin.cloud.manage.interceptor; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.List; + +/** + * @program: ddi-server + * @Company: sinohealth + * @description: + * @author: wanglei + * @create: 2020-10-14 10:06 + **/ +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(managerInterceptor()).excludePathPatterns("/static/**").addPathPatterns("/**"); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); + } + + @Bean + public CloudServiceInterceptor managerInterceptor() { + + return new CloudServiceInterceptor(); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + argumentResolvers.add(loginUserMethodArgumentResolver()); + + } + + @Bean + public LoginUserMethodArgumentResolver loginUserMethodArgumentResolver() { + return new LoginUserMethodArgumentResolver(); + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/LoginUserMethodArgumentResolver.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/LoginUserMethodArgumentResolver.java new file mode 100644 index 0000000000000000000000000000000000000000..7ece7533ed3b8a55c4552992083bbedbfce63a08 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/interceptor/LoginUserMethodArgumentResolver.java @@ -0,0 +1,52 @@ +package com.hnkylin.cloud.manage.interceptor; + + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.common.JwtUtil; +import com.hnkylin.cloud.core.config.exception.KylinTokenException; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import org.springframework.core.MethodParameter; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +import java.util.Objects; + + +public class LoginUserMethodArgumentResolver implements HandlerMethodArgumentResolver { + + + public LoginUserMethodArgumentResolver() { + + } + + @Override + public boolean supportsParameter(MethodParameter parameter) { + + return parameter.hasParameterAnnotation(LoginUser.class) && parameter.getParameterType().equals(LoginUserVo + .class); + } + + @Override + public Object resolveArgument( + MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, + WebDataBinderFactory binderFactory) { + + String token = webRequest.getHeader(KylinCloudManageConstants.KYLIN_ACCESS_TOKEN); + if (Objects.isNull(token)) { + throw new KylinTokenException(KylinHttpResponseConstants.NOT_EXIST_TOKEN); + } + String username = JwtUtil.getUsername(token); + String userId = JwtUtil.getUserId(token); + + LoginUserVo loginUserVo = new LoginUserVo(); + loginUserVo.setUserId(Integer.parseInt(userId)); + loginUserVo.setUserName(username); + loginUserVo.setToken(token); + return loginUserVo; + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/NetworkMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/NetworkMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..73acacb90ba1acfd1046cf39867c57991df9c272 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/NetworkMapper.java @@ -0,0 +1,25 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudNetworkConfigDo; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkDetailDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-11-23. + */ +public interface NetworkMapper extends BaseMapper { + + + /** + * 根据vdc获取网络列表 + * + * @param vdcId + * @return + */ + List networkListByVdcId(@Param("vdcId") Integer vdcId); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/PermissionMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/PermissionMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..8cbd5019f552eda9269fea6a51aa5dce606411de --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/PermissionMapper.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudPermissionDo; +import com.hnkylin.cloud.manage.entity.resp.user.UserPermissionDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-11-24. + */ +public interface PermissionMapper extends BaseMapper { + + + List listPermissionByRoleId(@Param("roleId") Integer roleId); + + + List rolePermissionByRoleId(@Param("roleId") Integer roleId); +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/RoleMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/RoleMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..d3624182cd421c305d5f50c782471297819d10b8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/RoleMapper.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.manage.entity.resp.role.PageRoleRespDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-11-23. + */ +public interface RoleMapper extends BaseMapper { + + + /** + * 根据父VDCID获取未绑定的vdc列表 + * + * @param + * @return + */ + List pageRole(); + + + Integer getOrgUserIdList(@Param("orgId") Integer orgId); + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/UserMachineMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/UserMachineMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..6785de53a01594b1f6c1a2ac8c8d0a73e07a0253 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/UserMachineMapper.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.manage.entity.resp.user.UserMachineCountDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-11-27. + */ +public interface UserMachineMapper extends BaseMapper { + + + List userMachineCountGroupByUserId(@Param("userIds") List userIds); + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/UserMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/UserMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..4e54b0f8178bc1ed905e74c53f4bfabe8c125624 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/UserMapper.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.manage.entity.resp.user.PageUserRespDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-11-23. + */ +public interface UserMapper extends BaseMapper { + + + /** + * 分页查询用户 + * + * @param orgIdList + * @return + */ + List pageUser(@Param("orgIdList") List orgIdList, String searchKey); + + /** + * 根据校色类型获取用户数量 + * + * @param roleType + * @return + */ + Integer getUserCountByRoleType(@Param("orgIdList") List orgIdList, @Param("roleType") Integer roleType); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/VdcMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/VdcMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..5b5c7c3854f7b3b67a8101925088d701bbc9d2c7 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/VdcMapper.java @@ -0,0 +1,24 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcDetailRespDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-11-23. + */ +public interface VdcMapper extends BaseMapper { + + + /** + * 根据父VDCID获取未绑定的vdc列表 + * + * @param parentVdcId + * @return + */ + List getNotBindVdcListByParentId(@Param("parentVdcId") Integer parentVdcId); + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/WorkOrderMapper.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/WorkOrderMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b70a3cf9a9cded7534c6097f15f81d8841331423 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/mapper/WorkOrderMapper.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.manage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDo; +import com.hnkylin.cloud.manage.entity.req.workorder.WorkOrderPageParam; +import com.hnkylin.cloud.manage.entity.resp.workorder.PageWorkOrderRespDto; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-24. + */ +public interface WorkOrderMapper extends BaseMapper { + + List pageWorkOrder(WorkOrderPageParam workOrderPageParam); +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/runner/KylinCloudManagerRunner.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/runner/KylinCloudManagerRunner.java new file mode 100644 index 0000000000000000000000000000000000000000..aad668b7cd8d24a5ee17858b3aadabf534cc28e3 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/runner/KylinCloudManagerRunner.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.manage.runner; + +import com.hnkylin.cloud.manage.service.McNodeService; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +public class KylinCloudManagerRunner implements ApplicationRunner { + + @Resource + private McNodeService mcNodeService; + + @Override + public void run(ApplicationArguments args) throws Exception { + mcNodeService.initMcNodeListToCache(); + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/schedule/VdcUsedResourceAlarmTask.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/schedule/VdcUsedResourceAlarmTask.java new file mode 100644 index 0000000000000000000000000000000000000000..718cbe3758722c71f74c7e79823d5268290f3f9a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/schedule/VdcUsedResourceAlarmTask.java @@ -0,0 +1,265 @@ +package com.hnkylin.cloud.manage.schedule; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.domain.CloudAlarmConfigDo; +import com.hnkylin.cloud.core.domain.CloudAlarmLogDo; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.core.enums.AlarmLevel; +import com.hnkylin.cloud.core.enums.AlarmResourceType; +import com.hnkylin.cloud.core.enums.AlarmTargetType; +import com.hnkylin.cloud.core.service.CloudAlarmConfigService; +import com.hnkylin.cloud.core.service.CloudAlarmLogService; +import com.hnkylin.cloud.core.service.CloudUserService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcUsedResourceDto; +import com.hnkylin.cloud.manage.service.VdcService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + + +/** + * VDC-已使用资源告警 + */ +@Configuration +@EnableScheduling +@Slf4j +public class VdcUsedResourceAlarmTask { + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private CloudAlarmConfigService cloudAlarmConfigService; + + @Resource + private VdcService vdcService; + + private static final int ZERO = 0; + + @Resource + private CloudUserService cloudUserService; + + private static final String EXCEED = "超过"; + + private static final String PERCENT = "%"; + + @Resource + private CloudAlarmLogService cloudAlarmLogService; + + + /** + * 每5分钟执行一次 校验VDC资源使用率 + */ + @Scheduled(cron = "0 0/10 * * * ?") + private void runServerVmExpireTask() { + log.info("VdcUsedResourceAlarmTask-start"); + + + //查询告警设置 + CloudAlarmConfigDo cloudAlarmConfigDo = new CloudAlarmConfigDo(); + cloudAlarmConfigDo.setDeleteFlag(false); + QueryWrapper alarmSettingWrapper = new QueryWrapper(cloudAlarmConfigDo); + List alarmConfigDoList = cloudAlarmConfigService.list(alarmSettingWrapper); + + + //查询VDC列表 + CloudVdcDo cloudVdcDo = new CloudVdcDo(); + cloudVdcDo.setDeleteFlag(false); + QueryWrapper vdcQueryWrapper = new QueryWrapper(cloudVdcDo); + List vdcDoList = cloudVdcService.list(vdcQueryWrapper); + List alarmLogDoList = new ArrayList<>(); + vdcDoList.forEach(vdcDo -> { + alarmLogDoList.addAll(verifyVdcAlarmSetting(vdcDo, alarmConfigDoList)); + + }); + + if (!alarmLogDoList.isEmpty()) { + cloudAlarmLogService.saveBatch(alarmLogDoList); + } + log.info("VdcUsedResourceAlarmTask-alarmLogDoList-size:" + alarmLogDoList.size()); + } + + /** + * 校验VDC资源设置 + * + * @param vdcDo + * @param alarmConfigDoList + */ + private List verifyVdcAlarmSetting(CloudVdcDo vdcDo, List alarmConfigDoList) { + + List vdcAlarmLogDoList = new ArrayList<>(); + + + //Cpu 告警设置 + CloudAlarmConfigDo vdcCpuAlarm = + alarmConfigDoList.stream().filter(item -> Objects.equals(item.getResourceType(), + AlarmResourceType.VDC_CPU)) + .findFirst().orElse(null); + //内存告警设置 + CloudAlarmConfigDo vdcMemAlarm = + alarmConfigDoList.stream().filter(item -> Objects.equals(item.getResourceType(), + AlarmResourceType.VDC_MEM)) + .findFirst().orElse(null); + //存储告警设置 + CloudAlarmConfigDo vdcStorageAlarm = + alarmConfigDoList.stream().filter(item -> Objects.equals(item.getResourceType(), + AlarmResourceType.VDC_STORAGE)) + .findFirst().orElse(null); + + LoginUserVo sysAdminUser = getSysAdminUser(); + + //获取VDC资源情况 + VdcUsedResourceDto vdcResourceDto = vdcService.getVdcResourceInfo(vdcDo.getId(), sysAdminUser); + + vdcAlarmLogDoList.addAll(verifyExceedAlarmSetting(vdcDo, vdcCpuAlarm, AlarmResourceType.VDC_CPU, sysAdminUser + , vdcResourceDto)); + vdcAlarmLogDoList.addAll(verifyExceedAlarmSetting(vdcDo, vdcMemAlarm, AlarmResourceType.VDC_MEM, sysAdminUser + , vdcResourceDto)); + vdcAlarmLogDoList.addAll(verifyExceedAlarmSetting(vdcDo, vdcStorageAlarm, AlarmResourceType.VDC_STORAGE, + sysAdminUser, vdcResourceDto)); + return vdcAlarmLogDoList; + + } + + /** + * 校验各个资源是否超出阈值设置 + * + * @param vdcDo + * @param alarmConfigDo + * @param alarmResourceType + * @param sysAdminUser + * @param vdcResourceDto + * @return + */ + private List verifyExceedAlarmSetting(CloudVdcDo vdcDo, CloudAlarmConfigDo alarmConfigDo, + AlarmResourceType alarmResourceType, + LoginUserVo sysAdminUser, + VdcUsedResourceDto vdcResourceDto) { + + List alarmLogDoList = new ArrayList<>(); + + Integer generalAlarm = alarmConfigDo.getGeneralAlarm(); + Integer severityAlarm = alarmConfigDo.getSeverityAlarm(); + Integer urgentAlarm = alarmConfigDo.getUrgentAlarm(); + if (Objects.equals(generalAlarm, ZERO) && Objects.equals(severityAlarm, ZERO) && Objects.equals(urgentAlarm, + ZERO)) { + return alarmLogDoList; + } + + int total = 0; + int used = 0; + switch (alarmResourceType) { + case VDC_CPU: + total = vdcResourceDto.getTotalCpu(); + used = vdcResourceDto.getUsedCpu(); + break; + case VDC_MEM: + total = vdcResourceDto.getTotalMem(); + used = vdcResourceDto.getUsedMem(); + break; + case VDC_STORAGE: + total = vdcResourceDto.getTotalStorage(); + used = vdcResourceDto.getUsedMem(); + break; + default: + } + //使用率 + if (total > 0) { + BigDecimal totalResource = new BigDecimal(total + ""); + BigDecimal usedResource = new BigDecimal(used + ""); + BigDecimal usageRate = + usedResource.divide(totalResource, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100 + "")); + + //判断顺序,紧急告警->严重告警->一般告警 + if (!Objects.equals(urgentAlarm, ZERO) && Objects.nonNull(urgentAlarm)) { + //紧急告警 + BigDecimal urgentAlarmBig = new BigDecimal(urgentAlarm + ""); + if (usageRate.compareTo(urgentAlarmBig) >= 0) { + alarmLogDoList.add(createAlarmLog(vdcDo, sysAdminUser, AlarmLevel.URGENT, alarmResourceType, + urgentAlarm)); + return alarmLogDoList; + } + + } + if (!Objects.equals(severityAlarm, ZERO) && Objects.nonNull(severityAlarm)) { + //严重告警 + BigDecimal severityAlarmBig = new BigDecimal(severityAlarm + ""); + if (usageRate.compareTo(severityAlarmBig) >= 0) { + alarmLogDoList.add(createAlarmLog(vdcDo, sysAdminUser, AlarmLevel.SEVERITY, alarmResourceType, + severityAlarm)); + return alarmLogDoList; + } + } + if (!Objects.equals(generalAlarm, ZERO) && Objects.nonNull(generalAlarm)) { + //一般告警 + BigDecimal generalAlarmBig = new BigDecimal(generalAlarm + ""); + if (usageRate.compareTo(generalAlarmBig) >= 0) { + alarmLogDoList.add(createAlarmLog(vdcDo, sysAdminUser, AlarmLevel.GENERAL, alarmResourceType, + generalAlarm)); + } + } + + + } + return alarmLogDoList; + } + + + /** + * 创建告警对象 + * + * @param vdcDo + * @param loginUserVo + * @param alarmLevel + * @param alarmResourceType + * @param alarmValue + * @return + */ + private CloudAlarmLogDo createAlarmLog(CloudVdcDo vdcDo, LoginUserVo loginUserVo, AlarmLevel alarmLevel, + AlarmResourceType alarmResourceType, Integer alarmValue) { + CloudAlarmLogDo cloudAlarmLogDo = new CloudAlarmLogDo(); + cloudAlarmLogDo.setAlarmLevel(alarmLevel); + cloudAlarmLogDo.setAlarmTargetId(vdcDo.getId()); + cloudAlarmLogDo.setAlarmTarget(vdcDo.getVdcName()); + cloudAlarmLogDo.setResourceType(alarmResourceType); + cloudAlarmLogDo.setTargetType(AlarmTargetType.PLATFORM); + cloudAlarmLogDo.setCreateBy(loginUserVo.getUserId()); + StringBuilder targetDetail = new StringBuilder(vdcDo.getVdcName()); + targetDetail.append("--").append(alarmResourceType.getDesc()).append(EXCEED).append(alarmValue).append(PERCENT); + cloudAlarmLogDo.setAlarmDetail(targetDetail.toString()); + cloudAlarmLogDo.setCreateTime(new Date()); + return cloudAlarmLogDo; + } + + /** + * 获取系统管理员 + * + * @return + */ + private LoginUserVo getSysAdminUser() { + CloudUserDo cloudUserDo = new CloudUserDo(); + cloudUserDo.setUserName(KylinCloudManageConstants.SYSADMINUSER); + cloudUserDo.setOrganizationId(KylinCloudManageConstants.TOP_ORG_ID); + QueryWrapper queryWrapper = new QueryWrapper(cloudUserDo); + CloudUserDo sysAdmin = cloudUserService.getOne(queryWrapper); + LoginUserVo sysAdminUser = new LoginUserVo(); + sysAdminUser.setUserId(sysAdmin.getId()); + sysAdminUser.setUserName(sysAdmin.getUserName()); + return sysAdminUser; + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ClusterService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ClusterService.java new file mode 100644 index 0000000000000000000000000000000000000000..693bc0f75381b0922c9954b5fae913679cd740f6 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ClusterService.java @@ -0,0 +1,221 @@ +package com.hnkylin.cloud.manage.service; + + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchReq; +import com.hnkylin.cloud.core.domain.CloudClusterDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.cluster.*; +import com.hnkylin.cloud.manage.entity.req.workorder.QueryPortGroupParam; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.resp.cluster.*; +import com.hnkylin.cloud.manage.entity.mc.resp.McServerVmUseRatioData; + +import java.util.List; + +/** + * 集群管理 + */ +public interface ClusterService { + + + /** + * 校验集群账号密码 + * + * @param checkClusterNameAndPasswordParam + * @param loginUserVo + * @return + */ + BaseResult checkClusterUserNameAndPassword(CheckClusterNameAndPasswordParam checkClusterNameAndPasswordParam, + LoginUserVo loginUserVo); + + /** + * 分页查询数据存储列表 + * + * @param clusterStoragePageParam + * @param loginUserVo + * @return + */ + PageData pageStorage(ClusterStoragePageParam clusterStoragePageParam, + LoginUserVo loginUserVo); + + + /** + * 创建集群 + * + * @param createClusterParam + * @param loginUserVo + */ + void creatCluster(CreateClusterParam createClusterParam, LoginUserVo loginUserVo); + + /** + * 分页查询集群 + * + * @param clusterPageParam + * @param loginUserVo + * @return + */ + PageData pageCluster(ClusterPageParam clusterPageParam, LoginUserVo loginUserVo); + + /** + * 获取快捷登录集群地址 + * + * @param baseClusterParam + * @param loginUserVo + * @return + */ + LoginClusterRespDto getQuickLoginUrl(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo); + + + /** + * 集群详情 + */ + ClusterInfoDto clusterInfo(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo); + + + /** + * 获取集群物理主机列表 + * + * @param clusterPhysicalHostPageParam + * @param loginUserVo + * @return + */ + PageData pagePhysicalHost(ClusterPhysicalHostPageParam clusterPhysicalHostPageParam, + LoginUserVo loginUserVo); + + + /** + * 编辑时获取详情 + * + * @param baseClusterParam + * @param loginUserVo + * @return + */ + ClusterDetailDto clusterDetail(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo); + + + /** + * 编辑集群 + * + * @param modifyClusterParam + * @param loginUserVo + */ + void modifyCluster(ModifyClusterParam modifyClusterParam, LoginUserVo loginUserVo); + + /** + * 删除集群 + * + * @param baseClusterParam + * @param loginUserVo + */ + void deleteCluster(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo); + + /** + * 可用区获取可以绑定的五路集群 + * + * @param canBindClusterParam + * @param loginUserVo + * @return + */ + List canBindCluster(CanBindClusterParam canBindClusterParam, LoginUserVo loginUserVo); + + + /** + * 获取可用区-已绑定的物理集群 + * + * @param baseZoneParam + * @param loginUserVo + * @return + */ + List clusterListByZone(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo); + + + /** + * 获取集群网络配置 + * + * @param baseClusterParam + * @param loginUserVo + * @return + */ + NetworkConfigResp mcClusterNetWorkConfig(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo); + + + /** + * 根据虚拟交换机获取端口组 + * + * @param queryPortGroupParam + * @param loginUserVo + * @return + */ + List mcPortGroupListByVirtualSwitch(QueryPortGroupParam queryPortGroupParam, + LoginUserVo loginUserVo); + + + /** + * 获取可用区集群列表 + * + * @param zoneId + * @return + */ + List zoneClusterList(Integer zoneId); + + + /** + * 用户可见的物理集群 + * + * @param userId + * @return + */ + List visibleClusterByUserId(Integer userId); + + + /** + * 调用mc接口获取mc集群基础资源 + * + * @param cloudClusterDo + * @param loginUserName + * @return + */ + McClusterBaseResource getMcClusterBaseResource(CloudClusterDo cloudClusterDo, String loginUserName); + + + /** + * 获取集群资源 + */ + McClusterBaseResource getMcBaseResource(Integer clusterId, String loginUserName); + + /** + * 获取多个集群中mc的资源 + * + * @param clusterDoList + * @param loginUserName + * @return + */ + List moreClusterGetMcResource(List clusterDoList, String loginUserName); + + + /** + * 获取多个集群中 云服务器 cpu,内存使用率TOP + * + * @param clusterDoList + * @param loginUserName + * @return + */ + List moreClusterServerVmRunningInfo(List serverVmUuidList, + List clusterDoList, + String loginUserName); + + /** + * 获取多个集群中物理主机 + * + * @param clusterDoList + * @param loginUserName + * @return + */ + List moreClusterPhysicalHost(List clusterDoList, + String loginUserName); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/IndexStatisticService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/IndexStatisticService.java new file mode 100644 index 0000000000000000000000000000000000000000..72dff637fb22f6a9428fc5ddedf901b3b15d0d1a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/IndexStatisticService.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.resp.index.IndexStatisticData; +import com.hnkylin.cloud.manage.entity.resp.index.OrgLeaderIndexStatisticData; + +public interface IndexStatisticService { + + /** + * 系统管理员-首页数据统计 + * + * @param loginUserVo + * @return + */ + IndexStatisticData statisticData(LoginUserVo loginUserVo); + + + /** + * 非系统管理员-首页数据 + * + * @param loginUserVo + * @return + */ + OrgLeaderIndexStatisticData orgLeaderStatistic(LoginUserVo loginUserVo); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McClusterThreadService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McClusterThreadService.java new file mode 100644 index 0000000000000000000000000000000000000000..004987c21ff6698b1cf1abdd27a41f166b6f7569 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McClusterThreadService.java @@ -0,0 +1,95 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.threadTask.McClusterNoDataThread; +import com.hnkylin.cloud.manage.threadTask.McClusterThread; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; + +@Service +public class McClusterThreadService { + + + @Resource + private McHttpService mcHttpService; + + + @Resource + private ThreadPoolTaskExecutor mcClusterInfoExecutor; + + /** + * 多集群向mc发送带数据获取的请求 + * + * @param clusterIdList + * @param loginName + */ + public List threadGetMcResponse(List clusterIdList, + String loginName, String mcInterfaceUrl, List requestObjList) { + //使用线程池 + List> taskList = new ArrayList<>(); + + for (int i = 0; i < clusterIdList.size(); i++) { + McClusterThread thread = new McClusterThread(mcHttpService, loginName, clusterIdList.get(i), mcInterfaceUrl, + requestObjList.isEmpty() ? null : requestObjList.get(i)); + FutureTask futureTask = new FutureTask<>(thread); + taskList.add(futureTask); + mcClusterInfoExecutor.submit(futureTask); + } + + List mcResponseList = new ArrayList<>(); + for (FutureTask task : taskList) { + try { + String mcClusterResponse = task.get(); + mcResponseList.add(mcClusterResponse); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + return mcResponseList; + + } + + /** + * 多集群向mc发送无数据获取的请求 + * + * @param clusterIdList + * @param loginName + */ + public List> threadSendToMc(List clusterIdList, + String loginName, String mcInterfaceUrl, + List requestObjList) { + //使用线程池 + List>> taskList = new ArrayList<>(); + + for (int i = 0; i < clusterIdList.size(); i++) { + McClusterNoDataThread thread = new McClusterNoDataThread(mcHttpService, + loginName, clusterIdList.get(i), mcInterfaceUrl, requestObjList.isEmpty() ? null : + requestObjList.get(i)); + FutureTask> futureTask = new FutureTask<>(thread); + taskList.add(futureTask); + mcClusterInfoExecutor.submit(futureTask); + } + + List> mcResponseList = new ArrayList<>(); + for (FutureTask> task : taskList) { + try { + MCResponseData responseData = task.get(); + mcResponseList.add(responseData); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + return mcResponseList; + + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McHttpService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McHttpService.java new file mode 100644 index 0000000000000000000000000000000000000000..dc6827f34f954078ef21f370930093d344eac32c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McHttpService.java @@ -0,0 +1,189 @@ +package com.hnkylin.cloud.manage.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.core.common.McUtils; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import jdk.nashorn.api.scripting.JSObject; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Service +@Slf4j +public class McHttpService { + + + @Resource + private RestTemplate httpsRestTemplate; + + + @Resource + private McNodeService mcNodeService; + + @Resource + private MCConfigProperties mcConfigProperties; + + + /* + * 不需要响应data的通用和mc请求 + */ + public boolean noDataCommonMcRequest(Integer clusterId, Object requestObj, String httpMcUrl, String userName, + Integer retryIndex) { + try { + List mcNodeList = mcNodeService.getMcNodeListFromCache(clusterId); + int mcNodeListSize = mcNodeList.size(); + if (retryIndex < mcNodeListSize) { + + String mcLeaderUrl = getMcLeaderUrl(clusterId, retryIndex); + + String requestUrl = mcLeaderUrl + mcConfigProperties.getCommonPrefix() + httpMcUrl; + + MCResponseData result = commonSendToMc(userName, requestObj, requestUrl); + log.info("noDataCommonMcRequest-retryIndex:{},response:{}", retryIndex, JSON.toJSONString(result)); + if (Objects.isNull(result) && retryIndex < mcNodeListSize - 1) { + return noDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + + if (Objects.equals(MCServerVmConstants.SUCCESS, result.getStatus())) { + mcNodeService.setMcLeaderUrlToCache(mcLeaderUrl, clusterId); + return true; + } + } + } catch (Exception exception) { + exception.printStackTrace(); + return noDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + throw new KylinException(MCServerVmConstants.MC_NODE_NOT_VISIT); + } + + /** + * 无缓存带有数据响应 + * + * @param requestObj + * @param mcNodeList + * @param interfaceUrl + * @param userName + * @param retryIndex + * @return + */ + public MCResponseData noCacheHasDataMcRequest(Object requestObj, List mcNodeList, + String interfaceUrl, + String userName, + Integer retryIndex) { + try { + int mcNodeListSize = mcNodeList.size(); + if (retryIndex < mcNodeListSize) { + + String mcLeaderUrl = mcNodeList.get(retryIndex); + + String requestUrl = mcLeaderUrl + mcConfigProperties.getCommonPrefix() + interfaceUrl; + MCResponseData result = commonSendToMc(userName, requestObj, requestUrl); + log.info("noDataCommonMcRequest-retryIndex:{},response:{}", retryIndex, JSON.toJSONString(result)); + if (Objects.isNull(result) && retryIndex < mcNodeListSize - 1) { + return noCacheHasDataMcRequest(requestObj, mcNodeList, interfaceUrl, userName, retryIndex + 1); + } + return result; + } + } catch (Exception exception) { + exception.printStackTrace(); + return noCacheHasDataMcRequest(requestObj, mcNodeList, interfaceUrl, userName, retryIndex + 1); + } + throw new KylinException(MCServerVmConstants.MC_NODE_NOT_VISIT); + } + + + /** + * 向MC发送 + * + * @param userName + * @param requestObj + * @param requestUrl + * @return + */ + public MCResponseData commonSendToMc(String userName, Object requestObj, String requestUrl) { + MCResponseData result = null; + try { + HttpHeaders httpHeaders = McUtils.createMcHeaders(userName); + log.info("sendToMc-headers:{}", JSON.toJSONString(httpHeaders)); + requestObj = Objects.isNull(requestObj) ? new Object() : requestObj; + JSONObject reqBodyObj = JSONObject.parseObject(JSON.toJSONString(requestObj)); + log.info("sendToMc-url:{},body:{}", requestUrl, reqBodyObj.toJSONString()); + HttpEntity httpEntity = new HttpEntity(reqBodyObj, httpHeaders); + result = httpsRestTemplate.postForObject(requestUrl, httpEntity, MCResponseData.class); + log.info("sendToMc-response:{}", JSON.toJSONString(result)); + } catch (Exception exception) { + exception.printStackTrace(); + throw exception; + } + return result; + } + + /* + * 带data响应的的通用和mc请求 + */ + public MCResponseData hasDataCommonMcRequest(Integer clusterId, Object requestObj, String httpMcUrl, + String userName, + Integer retryIndex) { + List mcNodeList = mcNodeService.getMcNodeListFromCache(clusterId); + int mcNodeListSize = mcNodeList.size(); + try { + if (retryIndex < mcNodeListSize) { + String mcLeaderUrl = getMcLeaderUrl(clusterId, retryIndex); + + String requestUrl = mcLeaderUrl + mcConfigProperties.getCommonPrefix() + httpMcUrl; + + MCResponseData result = commonSendToMc(userName, requestObj, requestUrl); + + log.info("hasDataCommonMcRequest-retryIndex:{},response:{}", retryIndex, JSON.toJSONString(result)); + if (Objects.isNull(result) && retryIndex < mcNodeListSize - 1) { + return hasDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + if (Objects.nonNull(result) && Objects.equals(result.getStatus(), MCServerVmConstants.SUCCESS)) { + mcNodeService.setMcLeaderUrlToCache(mcLeaderUrl, clusterId); + } + return result; + } + + } catch (Exception exception) { + exception.printStackTrace(); + log.debug(exception.getMessage()); + if (retryIndex < mcNodeListSize - 1) { + return hasDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + } + throw new KylinException(MCServerVmConstants.MC_NODE_NOT_VISIT); + } + + + /** + * 获取mc主节点Url + */ + private String getMcLeaderUrl(Integer clusterId, Integer retryIndex) { + + String mcLeaderUrl = null; + if (Objects.equals(retryIndex, 0)) { + mcLeaderUrl = mcNodeService.getMcLeaderUrlFromCache(clusterId); + if (Objects.nonNull(mcLeaderUrl)) { + return mcLeaderUrl; + } + } + List mcNodeList = mcNodeService.getMcNodeListFromCache(clusterId); + + return mcNodeList.isEmpty() ? null : mcNodeList.get(retryIndex); + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McNodeService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McNodeService.java new file mode 100644 index 0000000000000000000000000000000000000000..8dae537929c071c18b9d83cfb188128c4e1a5787 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McNodeService.java @@ -0,0 +1,128 @@ +package com.hnkylin.cloud.manage.service; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.domain.CloudClusterDo; +import com.hnkylin.cloud.core.service.CloudClusterService; +import com.hnkylin.cloud.manage.constant.CloudManageRedisConstant; +import com.hnkylin.cloud.manage.service.cache.McLeaderNodeCacheService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + + +@Service +public class McNodeService { + + + @Resource + private McLeaderNodeCacheService mcLeaderNodeCacheService; + + @Resource + private CloudClusterService cloudClusterService; + + + /** + * 初始化将mcNode节点列表,放入缓存中 + */ + public void initMcNodeListToCache() { + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(clusterDo); + List clusterDoList = cloudClusterService.list(wrapper); + if (!clusterDoList.isEmpty()) { + clusterDoList.forEach(item -> { + Integer clusterId = item.getId(); + List mcNodeList = cloudClusterService.formatClusterNodeList(item.getId()); + if (!mcNodeList.isEmpty()) { + setMcNodeListToCache(mcNodeList, clusterId); + } + String mcLeaderUrl = getMcLeaderUrlFromCache(clusterId); + if (!mcNodeList.contains(mcLeaderUrl)) { + mcLeaderNodeCacheService.vDelete(CloudManageRedisConstant.MC_LEADER_URL_KEY + clusterId); + } + if (!mcNodeList.isEmpty()) { + setMcLeaderUrlToCache(mcNodeList.get(0), clusterId); + } + }); + + } + + } + + + /** + * 获取缓存中的mc主节点的url + */ + public String getMcLeaderUrlFromCache(Integer clusterId) { + Object mcLeaderUrl = mcLeaderNodeCacheService.vGet(CloudManageRedisConstant.MC_LEADER_URL_KEY + clusterId); + if (Objects.nonNull(mcLeaderUrl)) { + return mcLeaderUrl.toString(); + } + List mcNodeList = cloudClusterService.formatClusterNodeList(clusterId); + return mcNodeList.isEmpty() ? null : mcNodeList.get(0); + } + + /** + * 设置mc主节点额url到缓存中 + */ + public void setMcLeaderUrlToCache(String mcLeaderUrl, Integer clusterId) { + mcLeaderNodeCacheService.vSet(CloudManageRedisConstant.MC_LEADER_URL_KEY + clusterId, mcLeaderUrl); + //修改缓存中的mcNodeList 将当前可用的节点放在list中第一位 + setLeaderUrlFirst(mcLeaderUrl, clusterId); + } + + + /** + * 删除缓存中mc主节点额url + * + * @param clusterId + */ + public void deleteMcLeaderUrlToCache(Integer clusterId) { + mcLeaderNodeCacheService.vDelete(CloudManageRedisConstant.MC_LEADER_URL_KEY + clusterId); + } + + /** + * 删除缓存中mc节点列表 + * + * @param clusterId + */ + public void deleteMcNodeListToCache(Integer clusterId) { + mcLeaderNodeCacheService.vDelete(CloudManageRedisConstant.CLOUD_MANAGE_MC_NODE_LIST_KEY + clusterId); + } + + /** + * 设置mc的CM节点到缓存中 + */ + public void setMcNodeListToCache(List mcNodeList, Integer clusterId) { + mcLeaderNodeCacheService.vSet(CloudManageRedisConstant.CLOUD_MANAGE_MC_NODE_LIST_KEY + clusterId, mcNodeList); + } + + /** + * 从缓存中读取mc的cm节点列表 + */ + public List getMcNodeListFromCache(Integer clusterId) { + Object mcNodeList = + mcLeaderNodeCacheService.vGet(CloudManageRedisConstant.CLOUD_MANAGE_MC_NODE_LIST_KEY + clusterId); + if (Objects.isNull(mcNodeList)) { + return cloudClusterService.formatClusterNodeList(clusterId); + } + return (List) mcNodeList; + } + + /** + * 修改缓存中的mcNodeList 将当前可用的节点放在list中第一位 + */ + private void setLeaderUrlFirst(String mcLeaderUrl, Integer clusterId) { + List mcNodeList = getMcNodeListFromCache(clusterId); + if (!mcNodeList.isEmpty()) { + mcNodeList.remove(mcLeaderUrl); + mcNodeList.add(0, mcLeaderUrl); + setMcNodeListToCache(mcNodeList, clusterId); + } + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McServerVmService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McServerVmService.java new file mode 100644 index 0000000000000000000000000000000000000000..d96a5a48a05c7ad325d3a47b467e7839a3b0effe --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/McServerVmService.java @@ -0,0 +1,254 @@ +package com.hnkylin.cloud.manage.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.enums.ApplyServerVmType; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseOrderConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.*; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +@Slf4j +public class McServerVmService { + + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private McHttpService mcHttpService; + + + /** + * 获取mc网络资源 + */ + public NetworkConfigResp mcClusterNetworkConfig(Integer clusterId, LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getNetworkConfigUrl(); + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, null, + httpUrl, loginUserVo.getUserName(), 0); + NetworkConfigResp networkConfigResp = new NetworkConfigResp(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String mcNetworkConfigStr = JSON.toJSONString(mcResponse.getData()); + networkConfigResp = JSON.parseObject(mcNetworkConfigStr, NetworkConfigResp.class); + + } + return networkConfigResp; + } + + + /** + * 网络资源-根据虚拟交换机,获取端口组信息 + */ + public List mcClusterPortGroupListByVirtualSwitch(Integer clusterId, + ListPortGroupParam listPortGroupParam, + LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getListPortGroupByNameUrl(); + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, listPortGroupParam, httpUrl, + loginUserVo.getUserName(), 0); + List portGroupRespList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String portGroupListStr = JSONArray.toJSONString(mcResponse.getData()); + portGroupRespList = JSON.parseArray(portGroupListStr, NetworkPortGroupResp.class); + } + return portGroupRespList; + } + + /** + * 根据云服务器ID(UUID)获取云服务器(模板详情) + */ + public McServerVmDetailResp getMcServerVmDetailByServerVmId(Integer clusterId, + QueryMcServerDetailParamReq queryMcServerDetailParamReq, + LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getGetServervmDetailByServevmIdUrl(); + return getMcServerVmDetail(clusterId, queryMcServerDetailParamReq, loginUserVo, httpUrl); + } + + public McServerVmDetailResp getMcServerVmDetailByServerVmUuid(Integer clusterId, + QueryMcServerDetailParamReq queryMcServerDetailParamReq, + LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getGetServervmDetailByUuidUrl(); + return getMcServerVmDetail(clusterId, queryMcServerDetailParamReq, loginUserVo, httpUrl); + + } + + + /** + * 根据云服务器ID(UUID)获取云服务器(模板详情) + */ + private McServerVmDetailResp getMcServerVmDetail(Integer clusterId, + QueryMcServerDetailParamReq queryMcServerDetailParamReq, + LoginUserVo loginUserVo, String httpUrl) { + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, + queryMcServerDetailParamReq, httpUrl, + loginUserVo.getUserName(), 0); + McServerVmDetailResp mcServerVmDetailResp = new McServerVmDetailResp(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String mcServerVmDetailStr = JSON.toJSONString(mcResponse.getData()); + mcServerVmDetailResp = JSON.parseObject(mcServerVmDetailStr, McServerVmDetailResp.class); + } + return mcServerVmDetailResp; + } + + + /** + * 获取mc中计算资源列表 + * + * @param clusterId + * @param queryMcClusterParamReq + * @param loginUserVo + * @return + */ + public List getMcClusterList(Integer clusterId, QueryMcClusterParamReq queryMcClusterParamReq, + LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getGetRealServiceListUrl(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, queryMcClusterParamReq, + httpUrl, + loginUserVo.getUserName(), 0); + List clusterRespList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String clusterListStr = JSONArray.toJSONString(mcResponse.getData()); + clusterRespList = JSON.parseArray(clusterListStr, McClusterResp.class); + } + return clusterRespList; + } + + /** + * 获取mc中主机绑定资源 + * + * @param clusterId + * @param loginUserVo + * @return + */ + public List getMcClusterBindResourceList(Integer clusterId, LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getGetClusterBindResourceListUrl(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, null, + httpUrl, loginUserVo.getUserName(), 0); + List clusterBindResourceList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + clusterBindResourceList = JSON.parseArray(JSONArray.toJSONString(mcResponse.getData()), + McClusterBindResource.class); + } + return clusterBindResourceList; + } + + + /** + * 获取MC的存储位置列表 + */ + public List getMcStorageLocationList(Integer clusterId, LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getStorageLocationsListUrl(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, null, httpUrl, + loginUserVo.getUserName(), 0); + List storageLocationRespList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String storageLocationListStr = JSONArray.toJSONString(mcResponse.getData()); + storageLocationRespList = JSON.parseArray(storageLocationListStr, McStorageLocationResp.class); + } + return storageLocationRespList; + } + + /** + * 获取mc所以iso光驱列表 + * + * @param loginUserVo + * @return + */ + public List mcAllIsoList(Integer clusterId, LoginUserVo loginUserVo) { + List isoList = new ArrayList<>(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, null, + mcConfigProperties.getIsoListUrl(), loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String templateListStr = JSON.toJSONString(mcResponse.getData()); + isoList = (List) mcResponse.getData(); + } + return isoList; + + } + + /** + * 创建云服务器 + */ + public List createMcServerVm(Integer clusterId, McCreateServerVmParamReq mcCreateServerVmParamReq, + LoginUserVo loginUserVo, + ApplyServerVmType applyServerVmType) { + try { + + String createUrl = Objects.equals(applyServerVmType, ApplyServerVmType.TEMPLATE) ? + mcConfigProperties.getCreateServerVmUrl() + : mcConfigProperties.getCreateServerVmByIsoUrl(); + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, + mcCreateServerVmParamReq, + createUrl, + loginUserVo.getUserName(), 0); + List uuidList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String uusListStr = JSONArray.toJSONString(mcResponse.getData()); + uuidList = JSON.parseArray(uusListStr, String.class); + } + return uuidList; + } catch (Exception exception) { + exception.printStackTrace(); + throw new KylinException(KylinHttpResponseOrderConstants.CREATE_SERVERVM_ERR); + } + } + + public void checkServerNameExist(Integer clusterId, CheckServerNameParamReq checkServerNameParamReq, + LoginUserVo loginUserVo) { + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, checkServerNameParamReq, + mcConfigProperties.getCheckVmServerNameUrl(), + loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String existStr = JSONArray.toJSONString(mcResponse.getData()); + CheckServerNameResp checkServerNameResp = JSON.parseObject(existStr, CheckServerNameResp.class); + if (Objects.nonNull(checkServerNameResp) && checkServerNameResp.getExist()) { + throw new KylinException(KylinHttpResponseConstants.SERVER_VM_NAME_EXIST); + } + } + + } + + + /** + * 创建云服务器 + */ + public boolean modifyMcServerVm(Integer clusterId, McModifyServerVmParamReq mcModifyServerVmParamReq, + LoginUserVo loginUserVo) { + try { + + String httpUrl = mcConfigProperties.getModifyServerVmUrl(); + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, + mcModifyServerVmParamReq, httpUrl, + loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + return true; + } + } catch (Exception exception) { + exception.printStackTrace(); + throw new KylinException(KylinHttpResponseOrderConstants.MODIFY_SERVERVM_ERR); + } + return false; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/MonitorService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/MonitorService.java new file mode 100644 index 0000000000000000000000000000000000000000..57b721cc1b70bec8177c7a6c9179418201612391 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/MonitorService.java @@ -0,0 +1,157 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.McUpdateAlarmIntervalParam; +import com.hnkylin.cloud.manage.entity.mc.req.McUpdateAlarmSettingsParam; +import com.hnkylin.cloud.manage.entity.mc.req.QueryMcAlarmSettingsParam; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.monitor.*; +import com.hnkylin.cloud.manage.entity.resp.monitor.KcpAlarmSettingsResp; +import com.hnkylin.cloud.manage.entity.resp.monitor.PageKcpAlarmLogResp; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +public interface MonitorService { + + /** + * 物理主机事件类型查询 + * + * @param clusterParam + * @param loginUserVo + * @return + */ + PhysicalHostEventTypeResp serverEventTypeList(BaseClusterParam clusterParam, LoginUserVo loginUserVo); + + /** + * 分页查询物理主机事件 + * + * @param physicalHostEventParam + * @param loginUserVo + * @return + */ + PageData pagePhysicalHostEvent(PhysicalHostEventParam physicalHostEventParam, + LoginUserVo loginUserVo); + + /** + * 告警日志类型查询 + * + * @param clusterParam + * @param loginUserVo + * @return + */ + AlarmLogTypeResp alarmLogFilterList(BaseClusterParam clusterParam, LoginUserVo loginUserVo); + + + /** + * 分页查询告警日志 + * + * @param alarmLogParam + * @param loginUserVo + * @return + */ + PageData pageAlarmLog(AlarmLogParam alarmLogParam, LoginUserVo loginUserVo); + + + /** + * 服务器虚拟化事件类型 + * + * @param clusterParam + * @param loginUserVo + * @return + */ + ServerVirtualizationEventTypeResp serverVirtualizationEventsFilter(BaseClusterParam clusterParam, + LoginUserVo loginUserVo); + + + /** + * 分页查询告警日志 + * + * @param serverVirtualizationEventParam + * @param loginUserVo + * @return + */ + PageData pageServerVirtualizationEvent(ServerVirtualizationEventParam serverVirtualizationEventParam, LoginUserVo loginUserVo); + + + /** + * 查询告警设置 + * + * @param queryMcAlarmSettingsParam + * @param loginUserVo + * @return + */ + List listAlarmSettings(QueryMcAlarmSettingsParam queryMcAlarmSettingsParam, + LoginUserVo loginUserVo); + + /** + * 修改mc告警设置接口 + * + * @param updateAlarmSettingsParam + * @param loginUserVo + * @return + */ + boolean updateAlarmSettings(McUpdateAlarmSettingsParam updateAlarmSettingsParam, LoginUserVo loginUserVo); + + /** + * 获取告警持续时间 + * + * @param clusterParam + * @param loginUserVo + * @return + */ + AlarmIntervalResp getAlarmInterval(BaseClusterParam clusterParam, LoginUserVo loginUserVo); + + /** + * 修改告警持续时间 + * + * @param updateAlarmIntervalParam + * @param loginUserVo + * @return + */ + boolean updateAlarmInterval(McUpdateAlarmIntervalParam updateAlarmIntervalParam, LoginUserVo loginUserVo); + + /** + * 根据登录用户获取告警数量 + * + * @param loginUserVo + * @return + */ + AlarmNotificationsResp alarmNotifications(LoginUserVo loginUserVo); + + + /** + * 查询平台告警日志 + * + * @param loginUserVo + * @return + */ + List listKcpAlarmSettings(LoginUserVo loginUserVo); + + /** + * 修改平台告警设置 + * + * @param updateAlarmIntervalParam + * @param loginUserVo + */ + void updateKcpAlarmSetting(UpdateKcpAlarmSettingParam updateAlarmIntervalParam, LoginUserVo loginUserVo); + + + /** + * 分页查询kcp平台告警 + * + * @param kcpAlarmLogParam + * @param loginUserVo + * @return + */ + PageData pageKcpAlarmLog(PagKcpAlarmLogParam kcpAlarmLogParam, LoginUserVo loginUserVo); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/NetworkConfigService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/NetworkConfigService.java new file mode 100644 index 0000000000000000000000000000000000000000..4e3a7502e28db9ac3681f55cd92ec56e3dbbd4bb --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/NetworkConfigService.java @@ -0,0 +1,67 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.domain.CloudNetworkConfigDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.network.CreateNetworkParam; +import com.hnkylin.cloud.manage.entity.req.network.ModifyNetworkParam; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkConfigRespDto; + +import java.util.List; + +public interface NetworkConfigService { + + /** + * 分页查询网络设置 + */ + PageData pageNetworkConfig(BasePageParam basePageParam, LoginUserVo loginUserVo); + + /** + * 创建网络设置 + */ + void createNetwork(CreateNetworkParam createNetworkParam, LoginUserVo loginUserVo); + + + /** + * 获取网络配置列表 + */ + List listNetworkListByVdcId(Integer vdcId); + + /** + * 获取网络配置列表 + */ + List listNetworkListByVdcIdAndClusterId(Integer vdcId, Integer clusterId); + + /** + * 通过网络id,获取网络配置详情 + */ + CloudNetworkConfigDo getById(Integer networkId); + + + /** + * 根据VDC获取网络数量 + * + * @param vdcId + * @return + */ + int getNetWorkCountByVdcId(Integer vdcId); + + /** + * 网卡详情 + * + * @param networkId + * @return + */ + NetworkConfigRespDto networkDetail(Integer networkId); + + /** + * 变更网络 + * + * @param modifyNetworkParam + * @param loginUserVo + */ + void modifyNetwork(ModifyNetworkParam modifyNetworkParam, LoginUserVo loginUserVo); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/OrgService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/OrgService.java new file mode 100644 index 0000000000000000000000000000000000000000..62ac4b927486a06cf3d3f257918a26e9a1d599f1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/OrgService.java @@ -0,0 +1,115 @@ +package com.hnkylin.cloud.manage.service; + + +import com.hnkylin.cloud.core.domain.CloudOrganizationDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.org.*; +import com.hnkylin.cloud.manage.entity.resp.org.OrgDetailRespDto; +import com.hnkylin.cloud.manage.entity.resp.org.OrgSummaryRespDto; +import com.hnkylin.cloud.manage.entity.resp.org.OrganizationRespDto; +import com.hnkylin.cloud.manage.entity.resp.org.ParentOrgRespDto; +import com.hnkylin.cloud.manage.entity.resp.role.OrgStatisticTreeDto; +import com.hnkylin.cloud.manage.enums.OrgStatisticTreeType; + +import java.util.List; + +/** + * 组织管理 + */ +public interface OrgService { + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构 + */ + List queryParentOrg(QueryParentOrgParam queryParentOrgParam, LoginUserVo loginUserVo); + + /** + * 创建组织 + */ + void createOrg(CreateOrgParam createOrgParam, LoginUserVo loginUserVo); + + + /** + * 组织管理-主列表 + */ + List queryOrgList(LoginUserVo loginUserVo); + + + /** + * 删除组织 + */ + void deleteOrg(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo); + + + /** + * 编辑组织时-获取组织详情 + */ + OrgDetailRespDto orgDetail(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo); + + + /** + * 编辑组织 + */ + void modifyOrg(ModifyOrgParam modifyOrgParam, LoginUserVo loginUserVo); + + /** + * 修改顶层组织名称 + */ + void modifyTopOrgName(ModifyTopOrgNameParam modifyOrgParam, LoginUserVo loginUserVo); + + + /** + * 通用组织统计数 + * + * @param loginUserVo + * @param orgTreeType + * @return + */ + List orgStatisticTree(LoginUserVo loginUserVo, OrgStatisticTreeType orgTreeType); + + + /** + * 获取组织的子组织ID集合 + * + * @param parentOrgId + * @return + */ + List getOrgChildIdList(Integer parentOrgId); + + + /** + * 根据vdcId获取对应的组织 + * + * @param vdcId + * @return + */ + CloudOrganizationDo getOrgByVdcId(Integer vdcId); + + + /** + * 用户是否拥有该组织的操作权限 + * + * @param userId + * @param orgId + * @return + */ + boolean userHasOrgPermission(Integer userId, Integer orgId); + + + /** + * 根据用户ID获取组织 + */ + CloudOrganizationDo getByUserId(Integer userId); + + + /** + * 组织概要 + * + * @param baseOrgParam + * @param loginUserVo + * @return + */ + OrgSummaryRespDto orgSummary(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/PermissionService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/PermissionService.java new file mode 100644 index 0000000000000000000000000000000000000000..20beebc48b2f37faf7ba2f50bdacd53bf0940e13 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/PermissionService.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.manage.service; + + +import com.hnkylin.cloud.core.domain.CloudPermissionDo; +import com.hnkylin.cloud.manage.entity.resp.role.PermissionTreeDto; + +import java.util.List; + +public interface PermissionService { + + List listPermissionByRoleId(Integer roleId); + + + /** + * 获取自定义平台管理最大权限树 + */ + List customPlatformRoleMaxPermission(); + + + /** + * 根据权限路由查询权限 + * + * @param routeKey + * @return + */ + CloudPermissionDo getPermissionByRouteKey(String routeKey); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/RoleService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/RoleService.java new file mode 100644 index 0000000000000000000000000000000000000000..ab53f972e50400fb52c0e9187cd367950622a35e --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/RoleService.java @@ -0,0 +1,95 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.org.BaseOrgParam; +import com.hnkylin.cloud.manage.entity.req.role.*; +import com.hnkylin.cloud.manage.entity.resp.role.CommonRoleDto; +import com.hnkylin.cloud.manage.entity.resp.role.PageRoleRespDto; +import com.hnkylin.cloud.manage.entity.resp.role.RoleDetailDto; +import com.hnkylin.cloud.manage.entity.resp.role.RoleInfoRespDto; + +import java.util.List; + +public interface RoleService { + + + /** + * 创建平台管理角色 + * + * @param createRoleParam + * @param loginUserVo + */ + void createPlatformRole(CreateRoleParam createRoleParam, LoginUserVo loginUserVo); + + + /** + * 删除角色 + * + * @param baseRoleParam + * @param loginUserVo + */ + void deleteRole(BaseRoleParam baseRoleParam, LoginUserVo loginUserVo); + + + /** + * 编辑角色 + * + * @param modifyRoleParam + * @param loginUserVo + */ + void modifyRole(ModifyRoleParam modifyRoleParam, LoginUserVo loginUserVo); + + + /** + * 编辑角色时获取详情 + */ + RoleDetailDto modifyRoleDetail(BaseRoleParam baseRoleParam); + + /** + * 角色详情 + */ + RoleInfoRespDto roleInfo(BaseRoleParam baseRoleParam); + + + /** + * 分页获取角色列表 + */ + PageData pageRole(RolePageParam rolePageParam); + + + /** + * 角色列表 + * + * @param loginUserVo + * @return + */ + List listRole(SearchRoleParam searchRoleParam, LoginUserVo loginUserVo); + + + /** + * 获取模板的自服务角色 + * + * @return + */ + CloudRoleDo getSelfServiceRole(); + + /** + * 分配角色权限 + * + * @param allocateRolePermissionParam + * @param loginUserVo + */ + void allocateRolePermission(AllocateRolePermissionParam allocateRolePermissionParam, LoginUserVo loginUserVo); + + + /** + * 获取用户的角色 + * + * @param userId + * @return + */ + CloudRoleDo getUserRole(Integer userId); + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ServerVmService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ServerVmService.java new file mode 100644 index 0000000000000000000000000000000000000000..295944f9620f9564404f01dddfa398a305d31153 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ServerVmService.java @@ -0,0 +1,173 @@ +package com.hnkylin.cloud.manage.service; + + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.common.servervm.McServerVmLogResp; +import com.hnkylin.cloud.core.common.servervm.ServerVmBaseParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchOperateParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmMonitorInfoRespDto; +import com.hnkylin.cloud.core.enums.McStartVmErrorCode; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmOperateLogPageParam; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmPageParam; +import com.hnkylin.cloud.manage.entity.resp.serverVm.PageServerVmRespDto; +import com.hnkylin.cloud.manage.entity.resp.serverVm.ServerVmZoneOrgTreeRespDto; +import org.springframework.http.ResponseEntity; + +import java.util.List; + +/** + * 云服务器管理 + */ +public interface ServerVmService { + + /** + * 根据登录用户获取可用区组织数 + * + * @param loginUserVo + * @return + */ + List serverVmZoneTree(Integer clusterId, LoginUserVo loginUserVo); + + + /** + * 云服务器列表 + * + * @param serverVmPageParam + * @param loginUserVo + * @return + */ + PageData serverVmList(ServerVmPageParam serverVmPageParam, LoginUserVo loginUserVo); + + + /** + * 云服务器开机 + */ + McStartVmErrorCode startServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务器关机 + */ + boolean shutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务器强制关机 + */ + boolean forcedShutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器重启 + */ + boolean restartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器强制重启 + */ + boolean forcedRestartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器批量开机 + */ + BaseResult batchStartServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, LoginUserVo loginUserVo); + + + /** + * 云服务器批量关机 + */ + BaseResult batchShutdownServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo); + + /** + * 云服务器批量重启 + */ + BaseResult batchRebootServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo); + + /** + * 删除云服务器 + */ + BaseResult deleteServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 批量删除 + */ + BaseResult batchDeleteServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo); + + /** + * 获取mc云服务器图片 + */ + ResponseEntity downLoadServerVmLog(String mcServerVmLogoPath, String mcServerVmLogoName, + String serverVmUuid); + + + /* + * 获取vncUrl + */ + VncUrlDto getVncUrl(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务器详情-基础信息 + * + * @param serverVmBaseParam + * @param loginUserVo + * @return + */ + KcpServerVmDetailResp serverVmInfo(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器详情-概要信息 + * + * @param serverVmBaseParam + * @param loginUserVo + * @return + */ + KcpServerVmSummaryResp serverVmSummary(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器详情-日志告警信息 + * + * @param serverVmBaseParam + * @param loginUserVo + * @return + */ + List serverVmAlarmEvent(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务器详情-网络信息 + * + * @param serverVmBaseParam + * @param loginUserVo + * @return + */ + List serverVmNetwork(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器详情-磁盘信息 + * + * @param serverVmBaseParam + * @param loginUserVo + * @return + */ + List serverVmDisk(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务区器详情-监控 + */ + ServerVmMonitorInfoRespDto serverVmMonitor(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务区器详情-操作日志 + */ + PageData serverVmOperateLog(ServerVmOperateLogPageParam serverVmOperateLogPageParam, + LoginUserVo loginUserVo); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/UserMachineService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/UserMachineService.java new file mode 100644 index 0000000000000000000000000000000000000000..02366c095fe1a53acf07137da6d7d486d7799a6b --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/UserMachineService.java @@ -0,0 +1,55 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.servervm.McServerVmPageDetailResp; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; + +import java.util.List; + +public interface UserMachineService { + + /** + * 用户是否拥有云服务器 + * + * @param userId + * @return + */ + boolean userHasMachine(Integer userId); + + /** + * 根据用户ID列表计算云服务器数量 + * + * @param userIdList + * @return + */ + Integer countUserMachineByUserIdList(List userIdList); + + + /** + * 根据用户ID列表获取用户拥有的云服务器列表 + * + * @param userIdList + * @return + */ + List listUserMachineByUserIdList(List userIdList); + + + /** + * 从mc获取云服务器列表 + * + * @param userIdList + * @return + */ + List listUserMachineByUserIdListAndClusterId(Integer clusterId, List userIdList, + String userName); + + + /** + * 用户可见的云服务器 + * + * @param userId + * @return + */ + List userVisibleUserMachineList(Integer userId); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/UserService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/UserService.java new file mode 100644 index 0000000000000000000000000000000000000000..ab33d74dc86882510bf6d67a6477d6e0f4a24988 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/UserService.java @@ -0,0 +1,185 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.user.*; +import com.hnkylin.cloud.manage.entity.req.workorder.LoginUserParam; +import com.hnkylin.cloud.manage.entity.resp.user.ModifyUserInfoRespDto; +import com.hnkylin.cloud.manage.entity.resp.user.PageUserRespDto; +import com.hnkylin.cloud.manage.entity.resp.TokenRespDto; +import com.hnkylin.cloud.manage.entity.resp.user.UserInfoRespDto; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +public interface UserService { + + /** + * 登录 + */ + TokenRespDto login(LoginUserParam loginUserParam); + + /** + * 用户信息 + */ + UserInfoRespDto userInfo(LoginUserVo loginUserVo); + + /** + * 登出 + */ + void loginOut(LoginUserVo loginUserVo); + + /** + * 重置密码 + * + * @param loginUserVo + * @param resetPasswordParam + */ + void resetPassword(LoginUserVo loginUserVo, ResetPasswordParam resetPasswordParam); + + /** + * 根据组织ID统计用户数量(不包含子组织) + */ + Integer statisticOrgUserNumByOrgId(Integer orgId); + + /** + * 根据组织ID统计用户数量(包含子组织) + */ + Integer statisticOrgUserNumByOrgIdList(List orgIdList); + + + /** + * 创建用户 + */ + void createUser(CreateUserParam createUserParam, LoginUserVo loginUserVo); + + /** + * 编辑用户 + */ + void modifyUser(ModifyUserParam modifyUserParam, LoginUserVo loginUserVo); + + /** + * 获取编辑用户详情 + * + * @param baseUserParam + * @return + */ + ModifyUserInfoRespDto modifyUserInfo(BaseUserParam baseUserParam); + + /** + * 删除用户 + * + * @param baseUserParam + * @param loginUserVo + */ + void deleteUser(BaseUserParam baseUserParam, LoginUserVo loginUserVo); + + + /** + * 批量删除用户 + */ + void batchDeleteUser(BatchDeleteUserParam batchDeleteUserParam, LoginUserVo loginUserVo); + + /** + * 分页获取用户列表 + * + * @param pageUserParam + * @return + */ + PageData pageUser(PageUserParam pageUserParam, LoginUserVo loginUserVo); + + +// /** +// * 判断用户是否拥有最高权限 +// * 如果是系统管理员及顶级组织的组织管理员 +// * +// * @param userId +// * @return +// */ +// boolean judgeUserHasTopPermission(Integer userId); + + /** + * 判断用户是否是平台管理用户 + * + * @param userId + * @return + */ + boolean judgeIfPlatformUser(Integer userId); + + + /** + * 根据组织ID获取用户列表 + * + * @param orgId + * @return + */ + List listUserByOrgId(Integer orgId); + + /** + * 判断用户是否具有管理用户权限 + * + * @param userId + * @return + */ + boolean userHasManageUserPermission(Integer userId); + + + /** + * 判断用户是否拥有routekey的权限 + * + * @param userId + * @param routeKey + * @return + */ + boolean judgeUserHasRouteKeyPermission(Integer userId, String routeKey); + + + /** + * 根据组织ID获取用户列表(包含下级组织ID) + * + * @param orgId + * @return + */ + List listUserByOrgIdIncludeChildOrg(Integer orgId); + + + /** + * 根据组织ID获取用户列表 + * + * @param orgIdList + * @return + */ + List listUserByOrgList(List orgIdList, CloudUserStatus userStatus); + + + /** + * 根据用户id获取该用户可见的用户列表 + * + * @param userId + * @return + */ + List userVisibleUserList(Integer userId); + + + /** + * 获取组织自服务器用户数 + * + * @param orgIdList + * @return + */ + Integer countSelfServiceUserByOrgList(List orgIdList); + + + /** + * 获取组织管理员 + * + * @param orgId + * @return + */ + CloudUserDo orgLeaderUser(Integer orgId); + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/VdcService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/VdcService.java new file mode 100644 index 0000000000000000000000000000000000000000..c1f71b4d10a1ddeb97b6292ec959afae186398dc --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/VdcService.java @@ -0,0 +1,168 @@ +package com.hnkylin.cloud.manage.service; + + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterBaseResource; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.org.BaseOrgParam; +import com.hnkylin.cloud.manage.entity.req.vdc.*; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.resp.vdc.*; + +import java.util.List; + +/** + * 虚拟数据中心Vdc管理 + */ +public interface VdcService { + + /** + * 根据父组织ID,获取父组织对应VDC的子VDC列表(未绑定的) + */ + List queryNotBindVdcByParentOrgId(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo); + + + McClusterBaseResource queryClusterBaseResource(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo); + + + /** + * 获取可用区下可以绑定的VDC列表 + * + * @param baseZoneParam + * @return + */ + List vdcTreeByZone(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo); + + + /** + * 检查可用区下上级VDC能否被绑定 + * 能绑定:返回上级VDC的资源情况 + * + * @param checkCreateVdcParam + * @param loginUserVo + * @return + */ + VdcResourceRespDto checkCreateVdc(CheckCreateVdcParam checkCreateVdcParam, LoginUserVo loginUserVo); + + + /** + * 创建VDC + * + * @param createVdcParam + * @param loginUserVo + */ + void createVdc(CreateVdcParam createVdcParam, LoginUserVo loginUserVo); + + + /** + * 获取vdc树形结构 + * + * @param loginUserVo + * @return + */ + List vdcTree(LoginUserVo loginUserVo); + + + /** + * vdc详情 + * + * @param baseVdcParam + * @return + */ + VdcInfoRespDto vdcDetail(BaseVdcParam baseVdcParam, LoginUserVo loginUserVo); + + + /** + * 编辑vdc时-获取vdc详情 + * + * @param baseVdcParam + * @param loginUserVo + * @return + */ + ModifyVdcDetailRespDto modifyVdcDetail(BaseVdcParam baseVdcParam, LoginUserVo loginUserVo); + + + /** + * 编辑vdc + * + * @param modifyVdcParam + * @param loginUserVo + */ + void modifyVdc(ModifyVdcParam modifyVdcParam, LoginUserVo loginUserVo); + + + /** + * 删除VDC + * + * @param baseVdcParam + * @param loginUserVo + */ + void deleteVdc(BaseVdcParam baseVdcParam, LoginUserVo loginUserVo); + + + /** + * 根据用户ID获取Vdc + * + * @param userId + * @return + */ + CloudVdcDo getUserOrgBindVdc(Integer userId); + + + /** + * 根据组织获取组织绑定的VDC + * + * @param orgId + * @return + */ + CloudVdcDo getVdcByOrgId(Integer orgId); + + + /** + * 根据用户ID查询用户可见vdc列表 + * + * @param userId + * @return + */ + List visibleVdcListByUserId(Integer userId); + + /** + * 根据用户ID查询用户可见vdc列表 + * + * @param userId + * @return + */ + List visibleVdcListByUserIdAndZoneId(Integer userId, Integer zoneId); + + + /** + * 变更VDC资源-资源详情 + * + * @param vdcId + * @param loginUserVo + * @return + */ + VdcModifyResourceRespDto modifyVdcResourceDetail(Integer vdcId, LoginUserVo loginUserVo); + + + /** + * 申请变更VDC资源 + * + * @param applyModifyVdcResourceParam + * @param loginUserVo + */ + BaseResult applyModifyVdcResource(ApplyModifyVdcResourceParam applyModifyVdcResourceParam, + LoginUserVo loginUserVo); + + + /** + * 获取VDC资源情况 + * + * @return + */ + VdcUsedResourceDto getVdcResourceInfo(Integer vdcId, LoginUserVo loginUserVo); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/WorkOrderService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/WorkOrderService.java new file mode 100644 index 0000000000000000000000000000000000000000..4da8edf065787116e7677eab8f63c08fa3e67061 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/WorkOrderService.java @@ -0,0 +1,127 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.workorder.*; +import com.hnkylin.cloud.manage.entity.resp.workorder.*; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +public interface WorkOrderService { + + /** + * 分页获取工单 + */ + PageData pageWorkOrder(WorkOrderPageParam workOrderPageParam, LoginUserVo loginUserVo); + + /** + * 批量审核 + */ + void batchCheck(BatchCheckParam batchCheckParam, LoginUserVo loginUserVo); + + + /** + * 注册审核-通过 + */ + void checkPassRegister(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo); + + /** + * 修改帐号审核-通过 + */ + void checkPassUpdateUser(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo); + + + /** + * 拒绝工单 + */ + void refuseWorkOrder(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo); + + + /** + * 审核云服务器申请时-获取申请详情,及模板详情,计算资源等信息 + */ + PassApplyServerVmDetailRespDto passApplyServerVmDetailRespDto(WorkOrderDetailParam workOrderDetailParam, + LoginUserVo loginUserVo); + + /** + * 审核云服务器变更申请时-获取申请详情,及模板详情,计算资源等信息 + */ + PassModifyServerVmDetailRespDto passModifyServerVmDetail(WorkOrderDetailParam workOrderDetailParam, + LoginUserVo loginUserVo); + + /** + * 申请云服务器审核通过 + */ + void passApplyServerVm(PassApplyServerVmParam passApplyServerVmParam, LoginUserVo loginUserVo); + + /** + * 变更云服务器审核通过 + */ + void passModifyServerVm(PassModifyServerVmParam passModifyServerVmParam, LoginUserVo loginUserVo); + + /** + * 延期云服务器-通过 + */ + void checkPassDeferred(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo); + + + /** + * 根据工单ID获取申请服务器工单详情 + */ + ApplyServerVmDetailRespDto getApplyServerVmDetailByWorkOrderId(Integer workOrderId, LoginUserVo loginUserVo); + + + /** + * 根据工单ID获取变更云服务器详情 + */ + ModifyServerVmDetailRespDto getModifyServerVmDetailByWorkOrderId(Integer workOrderId); + + + /** + * 根据工单ID获取注册申请/修改账号 工单详情 + */ + WorkOrderUserDetailRespDto getWorkOrderUserDetailByWorkOrderId(Integer workOrderId); + + /** + * 根据工单ID获取延期云服务器详情 + */ + ApplyDeferredDetailRespDto applyDeferredDetailByWorkOrderId(Integer workOrderId); + + /** + * 获取登录用户待审核的工单数量 + * + * @param loginUserVo + * @return + */ + UserWaitCheckCountParam getWaitCheckCount(LoginUserVo loginUserVo); + + + /** + * 审核变更VDC-获取变更详情 + * + * @param workOrderDetailParam + * @param loginUserVo + * @return + */ + PassModifyVdcDetailRespDto passModifyVdcDetail(WorkOrderDetailParam workOrderDetailParam, LoginUserVo loginUserVo); + + /** + * 变更VDC通过 + * + * @param passModifyVdcResourceParam + * @param loginUserVo + */ + void passModifyVdc(PassModifyVdcResourceParam passModifyVdcResourceParam, LoginUserVo loginUserVo); + + + /** + * 申请变更VDC详情 + * + * @param workOrderDetailParam + * @return + */ + ApplyModifyVdcDetailRespDto applyModifyVdcDetail(WorkOrderDetailParam workOrderDetailParam); + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ZoneService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ZoneService.java new file mode 100644 index 0000000000000000000000000000000000000000..8e6fc9d7f744d316768896b079c7ec070b897db1 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/ZoneService.java @@ -0,0 +1,94 @@ +package com.hnkylin.cloud.manage.service; + +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.domain.CloudZoneDo; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.CreateZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.ModifyZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.PageZoneParam; +import com.hnkylin.cloud.manage.entity.resp.zone.PageZoneRespDto; +import com.hnkylin.cloud.manage.entity.resp.zone.ZoneDetailDto; +import com.hnkylin.cloud.manage.entity.resp.zone.ZoneInfoDto; + +import java.util.List; + +public interface ZoneService { + + /** + * 创建可用区 + * + * @param createZoneParam + * @param loginUserVo + */ + void createZone(CreateZoneParam createZoneParam, LoginUserVo loginUserVo); + + + /** + * 编辑可用区 + * + * @param modifyZoneParam + * @param loginUserVo + */ + void modifyZone(ModifyZoneParam modifyZoneParam, LoginUserVo loginUserVo); + + + /** + * 分页查询可用区 + * + * @param pageZoneParam + * @param loginUserVo + * @return + */ + PageData pageZone(PageZoneParam pageZoneParam, LoginUserVo loginUserVo); + + /** + * 编辑可用区时获取可用区详情 + * + * @param baseZoneParam + * @param loginUserVo + * @return + */ + ZoneInfoDto modifyZoneDetail(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo); + + + /** + * 可用区详情 + * + * @param baseZoneParam + * @param loginUserVo + * @return + */ + ZoneDetailDto zoneDetail(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo); + + + /** + * 获取登录用可以绑定的可用区 + */ + List zoneList(LoginUserVo loginUserVo); + + /** + * 根据集群获取可用区 + * + * @param clusterId + * @return + */ + CloudZoneDo getZoneByClusterId(Integer clusterId); + + + /** + * 查询用户可见可用区 + * + * @param userId + * @return + */ + List visibleZoneListByUserId(Integer userId); + + /** + * 删除可用区 + * + * @param baseZoneParam + * @param loginUserVo + */ + void deleteZone(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo); +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/LoginUserCacheService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/LoginUserCacheService.java new file mode 100644 index 0000000000000000000000000000000000000000..a13fa1da5abfd799b595ba11d8a5a6d85c3f14bc --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/LoginUserCacheService.java @@ -0,0 +1,8 @@ +package com.hnkylin.cloud.manage.service.cache; + +import com.hnkylin.cloud.core.cache.RedisService; + + +public interface LoginUserCacheService extends RedisService { + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/McLeaderNodeCacheService.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/McLeaderNodeCacheService.java new file mode 100644 index 0000000000000000000000000000000000000000..bb9d43a7e297beb8462f0af1ea3463e39449d2d8 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/McLeaderNodeCacheService.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.manage.service.cache; + +import com.hnkylin.cloud.core.cache.RedisService; + + +/** + * mc主节点缓存,记录切主后的mc主节点,避免频繁重试 + */ +public interface McLeaderNodeCacheService extends RedisService { + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/impl/LoginUserCacheServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/impl/LoginUserCacheServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5951ec2d66dc4b4393b5b6eda079598e448b426d --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/impl/LoginUserCacheServiceImpl.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.manage.service.cache.impl; + +import com.hnkylin.cloud.core.cache.RedisServiceImpl; +import com.hnkylin.cloud.manage.constant.CloudManageRedisConstant; +import com.hnkylin.cloud.manage.service.cache.LoginUserCacheService; +import org.springframework.stereotype.Service; + + +@Service +public class LoginUserCacheServiceImpl extends RedisServiceImpl implements LoginUserCacheService { + + + @Override + protected String initPrefixKey() { + return CloudManageRedisConstant.CLOUD_MANAGE_LOGIN_USER_CACHE; + } +} \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/impl/McLeaderNodeCacheServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/impl/McLeaderNodeCacheServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f27452f2e9a2f5bef948e0382e54a59e915cbe1c --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/cache/impl/McLeaderNodeCacheServiceImpl.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.manage.service.cache.impl; + +import com.hnkylin.cloud.core.cache.RedisServiceImpl; +import com.hnkylin.cloud.manage.constant.CloudManageRedisConstant; +import com.hnkylin.cloud.manage.service.cache.LoginUserCacheService; +import com.hnkylin.cloud.manage.service.cache.McLeaderNodeCacheService; +import org.springframework.stereotype.Service; + + +@Service +public class McLeaderNodeCacheServiceImpl extends RedisServiceImpl implements McLeaderNodeCacheService { + + + @Override + protected String initPrefixKey() { + return CloudManageRedisConstant.CLOUD_MANAGE_MC_LEADER_NODE; + } +} \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ClusterServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ClusterServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..d356a68aa0c41518af7cdbf6d0595f44576a5390 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ClusterServiceImpl.java @@ -0,0 +1,927 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchReq; +import com.hnkylin.cloud.core.common.servervm.ServerVmListReq; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.HttpTypes; +import com.hnkylin.cloud.core.enums.McKsvdServerType; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.service.CloudClusterNodeService; +import com.hnkylin.cloud.core.service.CloudClusterService; +import com.hnkylin.cloud.core.service.CloudUserMachineService; +import com.hnkylin.cloud.core.service.CloudZoneClusterService; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseClusterConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.CommonPageParamReq; +import com.hnkylin.cloud.manage.entity.mc.req.ListPortGroupParam; +import com.hnkylin.cloud.manage.entity.mc.req.McCheckClusterNameAndPasswordParamReq; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.cluster.*; +import com.hnkylin.cloud.manage.entity.req.workorder.QueryPortGroupParam; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.resp.cluster.*; +import com.hnkylin.cloud.manage.entity.mc.resp.McServerVmUseRatioData; +import com.hnkylin.cloud.manage.enums.ClusterStatus; +import com.hnkylin.cloud.manage.service.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.swing.text.html.parser.Entity; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +@Slf4j +public class ClusterServiceImpl implements ClusterService { + + @Resource + private McHttpService mcHttpService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private CloudClusterService cloudClusterService; + + + @Resource + private CloudClusterNodeService cloudClusterNodeService; + + @Resource + private CloudZoneClusterService cloudZoneClusterService; + + @Resource + private McClusterThreadService mcClusterThreadService; + + + @Resource + private McServerVmService mcServerVmService; + + @Resource + private McNodeService mcNodeService; + + @Resource + private UserService userService; + + @Resource + private VdcService vdcService; + + @Resource + private ZoneService zoneService; + + @Resource + private CloudUserMachineService cloudUserMachineService; + + @Override + public BaseResult checkClusterUserNameAndPassword(CheckClusterNameAndPasswordParam checkClusterNameAndPasswordParam, LoginUserVo loginUserVo) { + + McCheckClusterNameAndPasswordParamReq mcCheckClusterNameAndPasswordParamReq = + new McCheckClusterNameAndPasswordParamReq(); + mcCheckClusterNameAndPasswordParamReq.setClusterAdminName(checkClusterNameAndPasswordParam.getClusterAdminName()); + try { + mcCheckClusterNameAndPasswordParamReq.setClusterAdminPassword(AESUtil.obfuscate(checkClusterNameAndPasswordParam.getClusterAdminPassword())); + } catch (Exception e) { + e.printStackTrace(); + } + List mcNodeList = new ArrayList<>(); + for (ClusterNodeParams nodeParams : checkClusterNameAndPasswordParam.getClusterNodeList()) { + StringBuilder sb = new StringBuilder(nodeParams.getHttpType()); + sb.append(nodeParams.getIpAddress()).append(":").append(nodeParams.getPort()); + mcNodeList.add(sb.toString()); + } + try { + MCResponseData mcResponse = + mcHttpService.noCacheHasDataMcRequest(mcCheckClusterNameAndPasswordParamReq, mcNodeList, + mcConfigProperties.getCheckClusterUserNameAndPasswordUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + CheckClusterNameAndPasswordResp checkClusterNameAndPasswordResp = + JSONObject.parseObject(JSON.toJSONString(mcResponse.getData()), + CheckClusterNameAndPasswordResp.class); + if (Objects.nonNull(checkClusterNameAndPasswordParam) && checkClusterNameAndPasswordResp.getUserNameAndPassword()) { + return BaseResult.success("success"); + } + return BaseResult.error(KylinHttpResponseClusterConstants.CLUSTER_NAME_AND_PASSWORD_ERR); + } + return BaseResult.error(KylinHttpResponseClusterConstants.CLUSTER_NODE_NOT_VISIT); + } catch (KylinException kylinException) { + log.error("checkClusterUserNameAndPassword-,cluster not exist"); + return BaseResult.error(KylinHttpResponseClusterConstants.CLUSTER_NODE_NOT_VISIT); + } + + } + + @Override + public PageData pageStorage(ClusterStoragePageParam clusterStoragePageParam, + LoginUserVo loginUserVo) { + CommonPageParamReq commonPageParamReq = new CommonPageParamReq(); + commonPageParamReq.setPage(clusterStoragePageParam.getPageNo()); + commonPageParamReq.setRows(clusterStoragePageParam.getPageSize()); + + MCResponseData mcResponse = null; + List mcNodeList = new ArrayList<>(); + if (Objects.nonNull(clusterStoragePageParam.getClusterNodeList()) && !clusterStoragePageParam.getClusterNodeList().isEmpty()) { + //新增,编辑 集群时 + for (ClusterNodeParams nodeParams : clusterStoragePageParam.getClusterNodeList()) { + StringBuilder sb = new StringBuilder(nodeParams.getHttpType()); + sb.append(nodeParams.getIpAddress()).append(":").append(nodeParams.getPort()); + mcNodeList.add(sb.toString()); + } + mcResponse = mcHttpService.noCacheHasDataMcRequest(commonPageParamReq, mcNodeList, + mcConfigProperties.getPageStorageUrl(), loginUserVo.getUserName(), 0); + } else if (Objects.nonNull(clusterStoragePageParam.getClusterId()) && clusterStoragePageParam.getClusterId() > 0) { + mcResponse = mcHttpService.hasDataCommonMcRequest(clusterStoragePageParam.getClusterId(), + commonPageParamReq, mcConfigProperties.getPageStorageUrl(), loginUserVo.getUserName(), 0); + } + + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + McPageResp mcPageResp = JSONObject.parseObject(serverListTxt, new + TypeReference>() { + }); + + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcPageResp.getPager()); + mcPageInfo.setPageSize(clusterStoragePageParam.getPageSize()); + mcPageInfo.setRecords(mcPageResp.getRecords()); + mcPageInfo.setTotal(mcPageResp.getTotal()); + return new PageData(mcPageInfo, mcPageResp.getRows()); + } + return new PageData(null); + } + + + @Override + @Transactional + public void creatCluster(CreateClusterParam createClusterParam, LoginUserVo loginUserVo) { + + if (Objects.isNull(createClusterParam.getClusterNodeList()) || createClusterParam.getClusterNodeList().isEmpty()) { + throw new KylinException(KylinHttpResponseClusterConstants.CLUSTER_NODE_IS_NOT_EMPTY); + } + + //先查询是否重名 + checkIfExistClusterName(createClusterParam.getName()); + + //检查集群节点是否已经存在 + checkIfExistClusterNode(createClusterParam.getClusterNodeList(), new ArrayList<>()); + + Date now = new Date(); + CloudClusterDo clusterDo = new CloudClusterDo(); + BeanUtils.copyProperties(createClusterParam, clusterDo); + clusterDo.setCreateBy(loginUserVo.getUserId()); + clusterDo.setCreateTime(new Date()); + try { + String password = AESUtil.obfuscate(createClusterParam.getClusterAdminPassword()); + clusterDo.setClusterAdminPassword(password); + } catch (Exception e) { + e.printStackTrace(); + } + cloudClusterService.save(clusterDo); + //获取mc物理主机列表,获取CM/CM_VDI节点,防止在页面少输入CM/CM_VDI节点 + handleRealMasterNode(createClusterParam.getClusterNodeList(), loginUserVo, clusterDo.getId()); + } + + /** + * 获取mc可以成为主CM的节点 + * + * @param mcNodeList + * @param loginUserVo + * @return + */ + private List getClusterMasterNodeList(List mcNodeList, LoginUserVo loginUserVo) { + List mcMasterNodeList = new ArrayList<>(); + CommonPageParamReq commonPageParamReq = new CommonPageParamReq(); + commonPageParamReq.setPage(KylinCommonConstants.FIRST_PAGE); + commonPageParamReq.setRows(KylinCommonConstants.MAX_CLUSTER_MASTER_NODE_NUM); + MCResponseData mcResponse = + mcHttpService.noCacheHasDataMcRequest(commonPageParamReq, mcNodeList, + mcConfigProperties.getPagePhysicalHostUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String hostList = JSON.toJSONString(mcResponse.getData()); + + McPageResp mcPageResp = JSONObject.parseObject(hostList, new + TypeReference>() { + }); + List mcPhysicalHostRespList = mcPageResp.getRows(); + mcPhysicalHostRespList.forEach(item -> { + if (Objects.equals(item.getServerType(), McKsvdServerType.CM.name()) || + Objects.equals(item.getServerType(), McKsvdServerType.CM_VDI.name())) { + mcMasterNodeList.add(item.getServerAddr()); + } + }); + } + return mcMasterNodeList; + + } + + /** + * 真实的mc主节点处理 + * + * @param clusterNodeList + * @param loginUserVo + * @param clusterId + */ + private void handleRealMasterNode(List clusterNodeList, + LoginUserVo loginUserVo, Integer clusterId) { + + + List mcNodeList = new ArrayList<>(); + clusterNodeList.stream().forEach(item -> { + StringBuilder sb = new StringBuilder(item.getHttpType()); + sb.append(item.getIpAddress()).append(":").append(item.getPort()); + mcNodeList.add(sb.toString()); + }); + + //获取mc物理主机列表,获取CM/CM_VDI节点,防止在页面少输入CM/CM_VDI节点 + List mcMasterNodeList = getClusterMasterNodeList(mcNodeList, loginUserVo); + List mcRealNodeMasterList = new ArrayList<>(mcMasterNodeList.size()); + List cacheMcNodeList = new ArrayList<>(mcMasterNodeList.size()); + if (!mcMasterNodeList.isEmpty()) { + mcMasterNodeList.forEach(masterIp -> { + ClusterNodeParams clusterNodeParams = new ClusterNodeParams(); + clusterNodeParams.setHttpType(HttpTypes.HTTPS.getValue()); + clusterNodeParams.setIpAddress(masterIp); + clusterNodeParams.setPort(KylinCommonConstants.MC_MASTER_PORT); + mcRealNodeMasterList.add(clusterNodeParams); + + StringBuilder sb = new StringBuilder(HttpTypes.HTTPS.getValue()); + sb.append(masterIp).append(":").append(KylinCommonConstants.MC_MASTER_PORT); + cacheMcNodeList.add(sb.toString()); + }); + } + + List insertNodeList = createNodeList(mcRealNodeMasterList, + clusterId, new Date(), loginUserVo.getUserId()); + + if (!insertNodeList.isEmpty()) { + cloudClusterNodeService.saveBatch(insertNodeList); + } + + if (!mcNodeList.isEmpty()) { + mcNodeService.deleteMcLeaderUrlToCache(clusterId); + mcNodeService.setMcNodeListToCache(cacheMcNodeList, clusterId); + } + } + + + /** + * 检查是否存在同名集群 + */ + private void checkIfExistClusterName(String clusterName) { + //判断名称是否已经存在 + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setName(clusterName); + clusterDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(clusterDo); + List clusterDoList = cloudClusterService.getBaseMapper().selectList(wrapper); + if (!clusterDoList.isEmpty()) { + throw new KylinException(KylinHttpResponseClusterConstants.EXIST_CLUSTER_NAME); + } + } + + /** + * 变更集群时检查集群节点是否已经存在 + */ + private void checkIfExistClusterNode(List clusterNodeList, + List clusterHasNodeList) { + CloudClusterNodeDo clusterNodeDo = new CloudClusterNodeDo(); + clusterNodeDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(clusterNodeDo); + List nodeDoList = cloudClusterNodeService.getBaseMapper().selectList(wrapper); + + //数据库中所有的ip节点 + List allIpAddressList = + nodeDoList.stream().map(CloudClusterNodeDo::getIpAddress).collect(Collectors.toList()); + //新增的IP节点 + List insertIpAddressList = + clusterNodeList.stream().map(ClusterNodeParams::getIpAddress).collect(Collectors.toList()); + //集群已经已经拥有额节点 + List clusterAlreadyHasIpList = + clusterHasNodeList.stream().map(CloudClusterNodeDo::getIpAddress).collect(Collectors.toList()); + + insertIpAddressList.forEach(item -> { + if (!clusterAlreadyHasIpList.contains(item)) { + if (allIpAddressList.contains(item)) { + throw new KylinException(KylinHttpResponseClusterConstants.CLUSTER_NODE_IS_EXIST); + } + } + }); + } + + @Override + @Transactional + public void modifyCluster(ModifyClusterParam modifyClusterParam, LoginUserVo loginUserVo) { + + if (Objects.isNull(modifyClusterParam.getClusterNodeList()) || modifyClusterParam.getClusterNodeList().isEmpty()) { + throw new KylinException(KylinHttpResponseClusterConstants.CLUSTER_NODE_IS_NOT_EMPTY); + } + + CloudClusterDo clusterDo = cloudClusterService.getById(modifyClusterParam.getClusterId()); + if (!Objects.equals(clusterDo.getName(), modifyClusterParam.getName())) { + checkIfExistClusterName(modifyClusterParam.getName()); + } + + List clusterNodeDoList = + cloudClusterNodeService.getClusterNodeListByClusterId(modifyClusterParam.getClusterId()); + + + //查询集群节点是否已经存在 + checkIfExistClusterNode(modifyClusterParam.getClusterNodeList(), clusterNodeDoList); + + //获取当前主节点,当前主节点不能减少 + String mcLeaderUrl = mcNodeService.getMcLeaderUrlFromCache(modifyClusterParam.getClusterId()); + canNotDeleteNowMasterNode(mcLeaderUrl, modifyClusterParam.getClusterNodeList()); + + Date now = new Date(); + clusterDo.setName(modifyClusterParam.getName()); + clusterDo.setRemark(modifyClusterParam.getRemark()); + clusterDo.setClusterAdminName(modifyClusterParam.getClusterAdminName()); + if (modifyClusterParam.getIfModifyPassword()) { + try { + String password = AESUtil.obfuscate(modifyClusterParam.getClusterAdminPassword()); + clusterDo.setClusterAdminPassword(password); + } catch (Exception e) { + e.printStackTrace(); + } + } + clusterDo.setUpdateBy(loginUserVo.getUserId()); + clusterDo.setUpdateTime(now); + try { + if (!Objects.equals(modifyClusterParam.getClusterAdminPassword(), clusterDo.getClusterAdminPassword())) { + String password = AESUtil.obfuscate(modifyClusterParam.getClusterAdminPassword()); + clusterDo.setClusterAdminPassword(password); + } + + } catch (Exception e) { + e.printStackTrace(); + } + cloudClusterService.updateById(clusterDo); + + + //先把原来的节点删除 + clusterNodeDoList.stream().forEach(item -> { + item.setDeleteFlag(Boolean.TRUE); + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(now); + }); + if (!clusterNodeDoList.isEmpty()) { + cloudClusterNodeService.updateBatchById(clusterNodeDoList); + } + handleRealMasterNode(modifyClusterParam.getClusterNodeList(), loginUserVo, clusterDo.getId()); + + } + + + /** + * 检验当前主节点不能减少。 + */ + private void canNotDeleteNowMasterNode(String mcLeaderUrl, List clusterNodeList) { + //获取主节点Ip + if (Objects.nonNull(mcLeaderUrl)) { + String[] masterIpInfo = mcLeaderUrl.split("//"); + String masterIp = masterIpInfo[1].split(":")[0]; + + ClusterNodeParams masterNode = clusterNodeList.stream().filter(item -> Objects.equals(item.getIpAddress(), + masterIp)).findFirst().orElse(null); + if (Objects.isNull(masterNode)) { + throw new KylinException(KylinHttpResponseClusterConstants.MASTER_NODE_CANNOT_DELETE); + } + + } + } + + @Override + @Transactional + public void deleteCluster(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo) { + //限制条件: + //1:改集群下没有云服务器 + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeadlineFlag(false); + cloudUserMachineDo.setClusterId(baseClusterParam.getClusterId()); + Wrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + int clusterMachine = cloudUserMachineService.count(wrapper); + if (clusterMachine > 0) { + throw new KylinException(KylinHttpResponseClusterConstants.CLUSTER_HAS_MACHINE_NOT_DELETE); + } + //2:没有可用区绑定该集群 + CloudZoneClusterDo cloudZoneClusterDo = cloudZoneClusterService.getByClusterId(baseClusterParam.getClusterId()); + if (Objects.nonNull(cloudZoneClusterDo)) { + throw new KylinException(KylinHttpResponseClusterConstants.ZONE_BIND_CLUSTER_NOT_DELETE); + } + CloudClusterDo clusterDo = cloudClusterService.getById(baseClusterParam.getClusterId()); + clusterDo.setDeleteFlag(true); + clusterDo.setDeleteBy(loginUserVo.getUserId()); + clusterDo.setDeleteTime(new Date()); + cloudClusterService.updateById(clusterDo); + + //删除集群节点数据 + List clusterNodeDoList = + cloudClusterNodeService.getClusterNodeListByClusterId(baseClusterParam.getClusterId()); + clusterNodeDoList.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(new Date()); + }); + if (!clusterNodeDoList.isEmpty()) { + cloudClusterNodeService.updateBatchById(clusterNodeDoList); + } + + + //删除缓存数据 + mcNodeService.deleteMcLeaderUrlToCache(baseClusterParam.getClusterId()); + mcNodeService.deleteMcNodeListToCache(baseClusterParam.getClusterId()); + + + } + + + @Override + public LoginClusterRespDto getQuickLoginUrl(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo) { + LoginClusterRespDto loginClusterRespDto = new LoginClusterRespDto(); + + CloudClusterDo clusterDo = cloudClusterService.getById(baseClusterParam.getClusterId()); + + String mcLeaderUrl = mcNodeService.getMcLeaderUrlFromCache(baseClusterParam.getClusterId()); + String quickLoginUrl = + mcLeaderUrl + mcConfigProperties.getMcPrefix() + mcConfigProperties.getMcQuickLogin() + + "?username=" + clusterDo.getClusterAdminName() + "&password=" + clusterDo.getClusterAdminPassword(); + loginClusterRespDto.setQuickLoginUrl(quickLoginUrl); + + return loginClusterRespDto; + } + + @Override + public PageData pageCluster(ClusterPageParam clusterPageParam, LoginUserVo loginUserVo) { + + List userVisibleClusterList = visibleClusterByUserId(loginUserVo.getUserId()); + if (userVisibleClusterList.isEmpty()) { + return new PageData<>(null); + } + CloudClusterDo queryClusterDo = new CloudClusterDo(); + queryClusterDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(queryClusterDo); + wrapper.in("id", userVisibleClusterList.stream().map(CloudClusterDo::getId).collect(Collectors.toList())); + PageHelper.startPage(clusterPageParam.getPageNo(), clusterPageParam.getPageSize()); + List clusterDoList = cloudClusterService.getBaseMapper().selectList(wrapper); + PageInfo pageInfo = new PageInfo<>(clusterDoList); + List pageClusterDetailList = createPageClusterDetailList(clusterDoList, loginUserVo); + PageData pageData = new PageData(pageInfo); + pageData.setList(pageClusterDetailList); + return pageData; + } + + + /** + * 创建集群分页实体 + * + * @param clusterDoList + * @param loginUserVo + * @return + */ + private List createPageClusterDetailList(List clusterDoList, + LoginUserVo loginUserVo) { + List pageClusterDetailList = new ArrayList<>(); + + if (!clusterDoList.isEmpty()) { + //获取mc资源情况 + List mcClusterBaseResourceList = moreClusterGetMcResource(clusterDoList, + loginUserVo.getUserName()); + clusterDoList.forEach(clusterDo -> { + PageClusterDetailDto clusterRespDto = new PageClusterDetailDto(); + BeanUtils.copyProperties(clusterDo, clusterRespDto); + clusterRespDto.setClusterId(clusterDo.getId()); + List mcNodeList = cloudClusterService.formatClusterNodeList(clusterDo.getId()); + clusterRespDto.setClusterUrl(mcNodeList.get(0) + mcConfigProperties.getMcPrefix()); + CloudZoneDo zoneDo = zoneService.getZoneByClusterId(clusterDo.getId()); + if (Objects.nonNull(zoneDo)) { + clusterRespDto.setZoneName(zoneDo.getName()); + clusterRespDto.setZoneId(zoneDo.getId()); + } + + McClusterBaseResource mcClusterBaseResource = + mcClusterBaseResourceList.stream().filter(item -> Objects.equals(item.getClusterId(), + clusterDo.getId())).findFirst().orElse(null); + if (Objects.nonNull(mcClusterBaseResource)) { + clusterRespDto.setStatus(ClusterStatus.ONLINE); + String quickLoginUrl = + mcNodeList.get(0) + mcConfigProperties.getMcPrefix() + mcConfigProperties.getMcQuickLogin() + + "?username=" + clusterDo.getClusterAdminName() + "&password=" + clusterDo.getClusterAdminPassword(); + clusterRespDto.setQuickLoginUrl(quickLoginUrl); + if (Objects.nonNull(mcClusterBaseResource.getResourceInfo())) { + clusterRespDto.setCpuTotal(mcClusterBaseResource.getResourceInfo().getCpuTotal()); + clusterRespDto.setCpuUsed(mcClusterBaseResource.getResourceInfo().getCpuUsed()); + clusterRespDto.setMemTotal(mcClusterBaseResource.getResourceInfo().getMemTotal()); + clusterRespDto.setMemUsed(mcClusterBaseResource.getResourceInfo().getMemUsed()); + clusterRespDto.setStorageTotal(mcClusterBaseResource.getResourceInfo().getStorageTotal()); + clusterRespDto.setStorageUsed(mcClusterBaseResource.getResourceInfo().getStorageUsed()); + } + if (Objects.nonNull(mcClusterBaseResource.getLicenseExpire())) { + if (judgeLicenseExpire(mcClusterBaseResource.getLicenseExpire())) { + clusterRespDto.setStatus(ClusterStatus.EXCEPTION); + } + } + + } + pageClusterDetailList.add(clusterRespDto); + }); + } + + return pageClusterDetailList; + } + + + /** + * 判断集群是否过期 + * + * @param licenseExpire + * @return + */ + private boolean judgeLicenseExpire(String licenseExpire) { + + Long licenseExpireTime = + DateUtils.parse(licenseExpire + DateUtils.DAY_END, DateUtils.DATE_ALL_PATTEN).getTime(); + Long now = System.currentTimeMillis(); + + return licenseExpireTime < now; + } + + + /** + * 获取mc集群资源使用情况 + * + * @param loginUserName + * @return + */ + @Override + public McClusterBaseResource getMcBaseResource(Integer clusterId, String loginUserName) { + try { + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, null, + mcConfigProperties.getMcClusterBaseResourceUrl(), loginUserName, 0); + McClusterBaseResource mcClusterBaseResource = null; + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String mcClusterInfoStr = JSON.toJSONString(mcResponse.getData()); + mcClusterBaseResource = JSON.parseObject(mcClusterInfoStr, McClusterBaseResource.class); + + } + return mcClusterBaseResource; + } catch (Exception e) { + log.error(e.getMessage()); + } + return null; + + } + + @Override + public List moreClusterGetMcResource(List clusterDoList, + String loginUserName) { + + List resultList = + mcClusterThreadService.threadGetMcResponse(clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()), + loginUserName, + mcConfigProperties.getMcClusterBaseResourceUrl(), new ArrayList<>()); + List mcClusterBaseResourceList = new ArrayList<>(); + Stream.iterate(0, i -> i + 1).limit(clusterDoList.size()).forEach(i -> { + String mcClusterResource = resultList.get(i); + if (Objects.nonNull(mcClusterResource)) { + McClusterBaseResource mcClusterBaseResource = JSON.parseObject(mcClusterResource, + McClusterBaseResource.class); + mcClusterBaseResource.setClusterId(clusterDoList.get(i).getId()); + mcClusterBaseResourceList.add(mcClusterBaseResource); + } + }); + return mcClusterBaseResourceList; + } + + @Override + public List moreClusterServerVmRunningInfo(List serverVmUuidList, + List clusterDoList, + String loginUserName) { + List resultList = + mcClusterThreadService.threadGetMcResponse(clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()), + loginUserName, + mcConfigProperties.getServerVmRunningInfoUrl(), serverVmUuidList); + List mcServerVmRunningInfoList = new ArrayList<>(); + Stream.iterate(0, i -> i + 1).limit(clusterDoList.size()).forEach(i -> { + String mcServerVmRunningInfoStr = resultList.get(i); + if (Objects.nonNull(mcServerVmRunningInfoStr)) { + McServerVmRunningInfoDto mcServerVmRunningInfoDto = JSON.parseObject(mcServerVmRunningInfoStr, + McServerVmRunningInfoDto.class); + if (Objects.nonNull(mcServerVmRunningInfoDto)) { + mcServerVmRunningInfoDto.getCpuTopList().forEach(item -> { + item.setClusterName(clusterDoList.get(i).getName()); + }); + mcServerVmRunningInfoDto.getMemTopList().forEach(item -> { + item.setClusterName(clusterDoList.get(i).getName()); + }); + mcServerVmRunningInfoList.add(mcServerVmRunningInfoDto); + } + + } + }); + return mcServerVmRunningInfoList; + } + + @Override + public List moreClusterPhysicalHost(List clusterDoList, + String loginUserName) { + + List mcRequestObjectList = new ArrayList<>(); + clusterDoList.forEach(clusterId -> { + + CommonPageParamReq commonPageParamReq = new CommonPageParamReq(); + commonPageParamReq.setPage(KylinCommonConstants.FIRST_PAGE); + commonPageParamReq.setRows(KylinCommonConstants.DEFAULT_MAX_SIZE); + mcRequestObjectList.add(commonPageParamReq); + }); + List resultList = + mcClusterThreadService.threadGetMcResponse(clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()), + loginUserName, + mcConfigProperties.getPagePhysicalHostUrl(), mcRequestObjectList); + + List totalClusterPhysicalHostList = new ArrayList<>(); + Stream.iterate(0, i -> i + 1).limit(clusterDoList.size()).forEach(i -> { + String clusterPhysicalHostStr = resultList.get(i); + if (Objects.nonNull(clusterPhysicalHostStr)) { + + McPageResp mcPageResp = JSONObject.parseObject(clusterPhysicalHostStr, new + TypeReference>() { + }); + + + if (Objects.nonNull(mcPageResp) && Objects.nonNull(mcPageResp.getRows()) && !mcPageResp.getRows().isEmpty()) { + totalClusterPhysicalHostList.addAll(mcPageResp.getRows()); + } + } + }); + return totalClusterPhysicalHostList; + } + + @Override + public ClusterInfoDto clusterInfo(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo) { + CloudClusterDo clusterDo = cloudClusterService.getById(baseClusterParam.getClusterId()); + ClusterInfoDto clusterInfoDto = new ClusterInfoDto(); + clusterInfoDto.setName(clusterDo.getName()); + clusterInfoDto.setRemark(clusterDo.getRemark()); + clusterInfoDto.setClusterAdminUser(clusterDo.getClusterAdminName()); + CloudZoneDo zoneDo = zoneService.getZoneByClusterId(baseClusterParam.getClusterId()); + if (Objects.nonNull(zoneDo)) { + clusterInfoDto.setZoneName(zoneDo.getName()); + clusterInfoDto.setZoneId(zoneDo.getId()); + } + clusterInfoDto.setStatus(ClusterStatus.OFFLINE); + clusterInfoDto.setType(clusterDo.getType()); + clusterInfoDto.setCreateTime(DateUtils.format(clusterDo.getCreateTime(), DateUtils.DATE_ALL_PATTEN)); + + List mcNodeList = cloudClusterService.formatClusterNodeList(clusterDo.getId()); + clusterInfoDto.setClusterUrl(mcNodeList.get(0) + mcConfigProperties.getMcPrefix()); + + McClusterBaseResource mcClusterBaseResource = getMcClusterBaseResource(clusterDo, loginUserVo.getUserName()); + + if (Objects.nonNull(mcClusterBaseResource)) { + McClusterResourceUsedResp resourceUsedResp = mcClusterBaseResource.getResourceInfo(); + resourceUsedResp.reCalculate(); + clusterInfoDto.setResourceUsedInfo(resourceUsedResp); + + clusterInfoDto.setStatus(ClusterStatus.ONLINE); + clusterInfoDto.setClusterVersion(mcClusterBaseResource.getKsvdVersion()); + String quickLoginUrl = + mcNodeList.get(0) + mcConfigProperties.getMcPrefix() + mcConfigProperties.getMcQuickLogin() + + "?username=" + clusterDo.getClusterAdminName() + "&password=" + clusterDo.getClusterAdminPassword(); + clusterInfoDto.setQuickLoginUrl(quickLoginUrl); + } + if (Objects.nonNull(mcClusterBaseResource.getLicenseExpire())) { + if (judgeLicenseExpire(mcClusterBaseResource.getLicenseExpire())) { + clusterInfoDto.setStatus(ClusterStatus.EXCEPTION); + } + } + + return clusterInfoDto; + } + + + @Override + public PageData pagePhysicalHost(ClusterPhysicalHostPageParam clusterPhysicalHostPageParam, LoginUserVo loginUserVo) { + CommonPageParamReq commonPageParamReq = new CommonPageParamReq(); + commonPageParamReq.setPage(clusterPhysicalHostPageParam.getPageNo()); + commonPageParamReq.setRows(clusterPhysicalHostPageParam.getPageSize()); + + + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(clusterPhysicalHostPageParam.getClusterId(), commonPageParamReq, + mcConfigProperties.getPagePhysicalHostUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String hostList = JSON.toJSONString(mcResponse.getData()); + + McPageResp mcPageResp = JSONObject.parseObject(hostList, new + TypeReference>() { + }); + + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcPageResp.getPager()); + mcPageInfo.setPageSize(clusterPhysicalHostPageParam.getPageSize()); + mcPageInfo.setRecords(mcPageResp.getRecords()); + mcPageInfo.setTotal(mcPageResp.getTotal()); + return new PageData(mcPageInfo, mcPageResp.getRows()); + } + return new PageData(null); + } + + @Override + public ClusterDetailDto clusterDetail(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo) { + CloudClusterDo clusterDo = cloudClusterService.getById(baseClusterParam.getClusterId()); + ClusterDetailDto clusterDetailDto = new ClusterDetailDto(); + + BeanUtils.copyProperties(clusterDo, clusterDetailDto); + clusterDetailDto.setClusterId(clusterDo.getId()); + List clusterNodeDoList = + cloudClusterNodeService.getClusterNodeListByClusterId(baseClusterParam.getClusterId()); + List clusterNodeList = new ArrayList<>(clusterNodeDoList.size()); + clusterNodeDoList.stream().forEach(item -> { + ClusterNodeInfoDto nodeInfoDto = new ClusterNodeInfoDto(); + BeanUtils.copyProperties(item, nodeInfoDto); + clusterNodeList.add(nodeInfoDto); + }); + clusterDetailDto.setClusterNodeList(clusterNodeList); + + return clusterDetailDto; + } + + + /** + * 创建集群节点列表 + * + * @param clusterNodeList + * @param clusterId + * @param now + * @param createUserId + * @return + */ + private List createNodeList(List clusterNodeList, Integer clusterId, + Date now, Integer createUserId) { + List nodeDoList = new ArrayList<>(); + clusterNodeList.stream().forEach(item -> { + CloudClusterNodeDo clusterNodeDo = new CloudClusterNodeDo(); + BeanUtils.copyProperties(item, clusterNodeDo); + clusterNodeDo.setClusterId(clusterId); + clusterNodeDo.setCreateTime(now); + clusterNodeDo.setCreateBy(createUserId); + nodeDoList.add(clusterNodeDo); + }); + return nodeDoList; + } + + + @Override + public List canBindCluster(CanBindClusterParam canBindClusterParam, LoginUserVo loginUserVo) { + //获取可用区可绑定的物理集群 + //相同的资源类型,排除已经被其他可用区绑定的物理集群 + + + //查询所有的相同资源的物理集群 + CloudClusterDo queryClusterDo = new CloudClusterDo(); + queryClusterDo.setDeleteFlag(false); + queryClusterDo.setType(canBindClusterParam.getType()); + Wrapper wrapper = new QueryWrapper<>(queryClusterDo); + List clusterDoList = cloudClusterService.getBaseMapper().selectList(wrapper); + + + //获取已经被绑定过得物理集群 + CloudZoneClusterDo queryZoneClusterDo = new CloudZoneClusterDo(); + queryZoneClusterDo.setDeleteFlag(false); + Wrapper zoneClusterWrapper = new QueryWrapper<>(queryZoneClusterDo); + List alreadyBindClusterList = + cloudZoneClusterService.getBaseMapper().selectList(zoneClusterWrapper); + List alreadyBindClusterIdList = alreadyBindClusterList.stream().map(CloudZoneClusterDo::getClusterId + ).collect(Collectors.toList()); + + + //获取可以绑定的列表 + List canBindList = + clusterDoList.stream().filter(item -> !alreadyBindClusterIdList.contains(item.getId())).collect(Collectors.toList()); + + List zoneAlreadyBindList = new ArrayList<>(); + if (canBindClusterParam.getZoneId() > 0) { + //获取可用区已经绑定的物理集群 + zoneAlreadyBindList = + alreadyBindClusterList.stream().filter(item -> Objects.equals(item.getZoneId(), + canBindClusterParam.getZoneId())).map(CloudZoneClusterDo::getClusterId + ).collect(Collectors.toList()); + + zoneAlreadyBindList.forEach(clusterId -> { + CloudClusterDo bindClusterDo = clusterDoList.stream().filter(item -> Objects.equals(item.getId(), + clusterId)).findFirst().orElse(null); + + if (Objects.nonNull(bindClusterDo)) { + canBindList.add(0, bindClusterDo); + } + }); + } + + List pageClusterDetailList = createPageClusterDetailList(canBindList, loginUserVo); + if (pageClusterDetailList.size() > 0) { + //将当前可用区已绑定的物理集群设置成已选择 + for (PageClusterDetailDto item : pageClusterDetailList) { + if (zoneAlreadyBindList.contains(item.getClusterId())) { + item.setSelected(true); + item.setZoneId(canBindClusterParam.getZoneId()); + } else { + item.setZoneId(0); + } + + } + pageClusterDetailList.stream().sorted(Comparator.comparing(PageClusterDetailDto::getZoneId).reversed()).collect(Collectors.toList()); + + } + + return pageClusterDetailList; + } + + + @Override + public List clusterListByZone(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo) { + List clusterDoList = cloudClusterService.listClusterBYZoneId(baseZoneParam.getZoneId()); + List pageClusterDetailList = createPageClusterDetailList(clusterDoList, loginUserVo); + return pageClusterDetailList; + } + + + @Override + public NetworkConfigResp mcClusterNetWorkConfig(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo) { + return mcServerVmService.mcClusterNetworkConfig(baseClusterParam.getClusterId(), loginUserVo); + } + + @Override + public List mcPortGroupListByVirtualSwitch(QueryPortGroupParam queryPortGroupParam, + LoginUserVo loginUserVo) { + + ListPortGroupParam listPortGroupParam = new ListPortGroupParam(); + listPortGroupParam.setVsname(queryPortGroupParam.getVirtualSwitchName()); + return mcServerVmService.mcClusterPortGroupListByVirtualSwitch(queryPortGroupParam.getClusterId(), + listPortGroupParam, loginUserVo); + } + + + @Override + public List zoneClusterList(Integer zoneId) { + List clusterDoList = cloudClusterService.listClusterBYZoneId(zoneId); + List zoneCusterLIst = new ArrayList<>(); + clusterDoList.forEach(item -> { + ClusterDto clusterDto = new ClusterDto(); + clusterDto.setClusterId(item.getId()); + clusterDto.setClusterName(item.getName()); + zoneCusterLIst.add(clusterDto); + }); + return zoneCusterLIst; + } + + + @Override + public List visibleClusterByUserId(Integer userId) { + + + //平台管理类型角色, + boolean platformUser = userService.judgeIfPlatformUser(userId); + if (platformUser) { + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(clusterDo); + return cloudClusterService.list(wrapper); + } + //组织管理员用户对应组织,组织对应vdc,vdc对应可用区,可用区对应的物理集群 + CloudVdcDo vdcDo = vdcService.getUserOrgBindVdc(userId); + if (Objects.isNull(vdcDo)) { + return new ArrayList<>(); + } + return cloudClusterService.listClusterBYZoneId(vdcDo.getZoneId()); + } + + + @Override + public McClusterBaseResource getMcClusterBaseResource(CloudClusterDo cloudClusterDo, String loginUserName) { + McClusterBaseResource mcClusterBaseResource = null; + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(cloudClusterDo.getId(), null, + mcConfigProperties.getMcClusterBaseResourceUrl(), loginUserName, 0); + + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String mcBaseRseourceStr = JSON.toJSONString(mcResponse.getData()); + mcClusterBaseResource = new McClusterBaseResource(); + mcClusterBaseResource = JSON.parseObject(mcBaseRseourceStr, McClusterBaseResource.class); + } + return mcClusterBaseResource; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/IndexStatisticServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/IndexStatisticServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f70d2e5ec3842c46fbd7349b2710f90c96404605 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/IndexStatisticServiceImpl.java @@ -0,0 +1,499 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchReq; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.enums.StorageUnit; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.QueryVdcUsedResourceParam; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.resp.index.*; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcUsedResourceDto; +import com.hnkylin.cloud.manage.mapper.UserMapper; +import com.hnkylin.cloud.manage.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +public class IndexStatisticServiceImpl implements IndexStatisticService { + + @Resource + private CloudZoneService cloudZoneService; + + @Resource + private ClusterService clusterService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private CloudOrgVdcService cloudOrgVdcService; + + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private UserMapper userMapper; + + @Resource + private WorkOrderService workOrderService; + + @Resource + private MonitorService monitorService; + + @Resource + private CloudUserService cloudUserService; + + @Resource + private VdcService vdcService; + + @Resource + private UserService userService; + + @Resource + private UserMachineService userMachineService; + + @Resource + private OrgService orgService; + + + @Override + public IndexStatisticData statisticData(LoginUserVo loginUserVo) { + + IndexStatisticData indexStatisticData = new IndexStatisticData(); + indexStatisticData.setZoneData(statisticZoneDate()); + statisticClusterData(indexStatisticData, loginUserVo); + indexStatisticData.setVdcData(getVdcData()); + indexStatisticData.setUserData(getUserData()); + //提醒数据 + IndexNoticeData noticeData = new IndexNoticeData(); + noticeData.setWaitCheckCount(workOrderService.getWaitCheckCount(loginUserVo).getWaitCheckCount()); + noticeData.setAlarmCount(monitorService.alarmNotifications(loginUserVo).getNotificationsCount()); + indexStatisticData.setNoticeData(noticeData); + //云服务器top数据 + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper(clusterDo); + List clusterDoList = cloudClusterService.list(wrapper); + serverVmRunningInfo(clusterDoList, new ArrayList<>(), indexStatisticData, loginUserVo); + //物理主机top数据 + physicalHostUsedRatioData(indexStatisticData, loginUserVo); + return indexStatisticData; + } + + /** + * 可用区数据统计 + * + * @return + */ + private IndexZoneData statisticZoneDate() { + IndexZoneData zoneData = new IndexZoneData(); + CloudZoneDo cloudZoneDo = new CloudZoneDo(); + cloudZoneDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper(cloudZoneDo); + Integer zoneCount = cloudZoneService.getBaseMapper().selectCount(wrapper); + zoneData.setTotalZone(zoneCount); + return zoneData; + } + + /** + * 集群统计 + * + * @return + */ + private void statisticClusterData(IndexStatisticData indexStatisticData, LoginUserVo loginUserVo) { + IndexClusterData clusterData = new IndexClusterData(); + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper(clusterDo); + List clusterDoList = cloudClusterService.list(wrapper); + clusterData.setTotalCluster(clusterDoList.size()); + + if (!clusterDoList.isEmpty()) { + List mcClusterBaseResourceList = + clusterService.moreClusterGetMcResource(clusterDoList, + loginUserVo.getUserName()); + clusterData.setOnlineCluster(mcClusterBaseResourceList.size()); + if (!mcClusterBaseResourceList.isEmpty()) { + //物理主机个数 + Integer physicalHostTotal = + mcClusterBaseResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getTotalPhysicalHost)); + //在线物理主机个数 + Integer physicalHostOnline = + mcClusterBaseResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getOnlinePhysicalHost)); + ; + //离线物理主机个数 + Integer physicalHostOffline = + mcClusterBaseResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getOfflinePhysicalHost)); + ; + //物理主机数据 + IndexPhysicalHostData physicalHostData = new IndexPhysicalHostData(); + physicalHostData.setTotalPhysicalHost(physicalHostTotal); + physicalHostData.setOnlinePhysicalHost(physicalHostOnline); + physicalHostData.setOfflinePhysicalHost(physicalHostOffline); + indexStatisticData.setPhysicalHostData(physicalHostData); + + + //cpu数据 + IndexCpuData cpuData = new IndexCpuData(); + //内存数据 + IndexMemData memData = new IndexMemData(); + //储存数据 + IndexStorageData storageData = new IndexStorageData(); + + mcClusterBaseResourceList.forEach(item -> { + McClusterResourceUsedResp resourceUsedResp = item.getResourceInfo(); + cpuData.setTotalCpu(cpuData.getTotalCpu().add(resourceUsedResp.getCpuTotal()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + cpuData.setUsedCpu(cpuData.getUsedCpu().add(resourceUsedResp.getCpuUsed()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + memData.setTotalMem(memData.getTotalMem().add(resourceUsedResp.getMemTotal()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + memData.setUsedMem(memData.getUsedMem().add(resourceUsedResp.getMemUsed()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + storageData.setTotalStorage(storageData.getTotalStorage().add(resourceUsedResp.getStorageTotal()).setScale(2, BigDecimal.ROUND_HALF_UP)); + storageData.setUsedStorage(storageData.getUsedStorage().add(resourceUsedResp.getStorageUsed()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + }); + cpuData.setUsableCpu(cpuData.getTotalCpu().subtract(cpuData.getUsableCpu()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + memData.setUsableMem(memData.getTotalMem().subtract(memData.getUsedMem()).setScale(2, + BigDecimal.ROUND_HALF_UP)); + storageData.setUsableStorage(storageData.getTotalStorage().subtract(storageData.getUsedStorage()).setScale(2, BigDecimal.ROUND_HALF_UP)); + indexStatisticData.setCpuData(cpuData); + indexStatisticData.setMemData(memData); + indexStatisticData.setStorageData(storageData); + } + + } + clusterData.setOfflineCluster(clusterData.getTotalCluster() - clusterData.getOnlineCluster()); + indexStatisticData.setClusterData(clusterData); + } + + + /** + * 获取VDC数据 + * + * @return + */ + private IndexVdcData getVdcData() { + IndexVdcData indexVdcData = new IndexVdcData(); + CloudVdcDo queryVdc = new CloudVdcDo(); + queryVdc.setDeleteFlag(false); + QueryWrapper vdcWrapper = new QueryWrapper(queryVdc); + Integer totalVdc = cloudVdcService.count(vdcWrapper); + indexVdcData.setTotalVdc(totalVdc); + if (Objects.nonNull(totalVdc) && totalVdc > 0) { + //获取已经绑定组织的VDC + CloudOrgVdcDo queryOrgVdc = new CloudOrgVdcDo(); + queryOrgVdc.setDeleteFlag(false); + QueryWrapper orgVdcWrapper = new QueryWrapper(queryOrgVdc); + Integer alreadyAllocateVdc = cloudOrgVdcService.count(orgVdcWrapper); + indexVdcData.setAlreadyAllocateVdc(alreadyAllocateVdc); + indexVdcData.setNoAllocateVdc(totalVdc - alreadyAllocateVdc); + } + return indexVdcData; + } + + /** + * 获取用户数量 + * + * @return + */ + private IndexUserData getUserData() { + IndexUserData indexUserData = new IndexUserData(); + indexUserData.setOrgManageUserCount(userMapper.getUserCountByRoleType(null, RoleType.ORG.ordinal())); + indexUserData.setSelfServiceUserCount(userMapper.getUserCountByRoleType(null, RoleType.SELF_SERVICE.ordinal())); + indexUserData.setPlatformManageUserCount(userMapper.getUserCountByRoleType(null, RoleType.PLATFORM.ordinal())); + return indexUserData; + } + + /** + * 获取物理集群中云服务器使用率top + * + * @param indexCommonData + * @param loginUserVo + */ + private void serverVmRunningInfo(List clusterDoList, List serverVmUuidList, + IndexCommonData indexCommonData, + LoginUserVo loginUserVo) { + + + List mcServerVmRunningInfoList = + clusterService.moreClusterServerVmRunningInfo(serverVmUuidList, clusterDoList, + loginUserVo.getUserName()); + + List totalCpuTopList = new ArrayList<>(); + + List totalMemTopList = new ArrayList<>(); + + mcServerVmRunningInfoList.forEach(item -> { + if (Objects.nonNull(item.getCpuTopList()) && !item.getCpuTopList().isEmpty()) { + totalCpuTopList.addAll(item.getCpuTopList()); + } + if (Objects.nonNull(item.getMemTopList()) && !item.getMemTopList().isEmpty()) { + totalMemTopList.addAll(item.getMemTopList()); + } + }); + List cpuTopList = new ArrayList<>(); + List memTopList = new ArrayList<>(); + int topSize = 5; + if (!totalCpuTopList.isEmpty()) { + totalCpuTopList.sort((obj1, obj2) -> obj2.getCpuUseRatio().compareTo(obj1.getCpuUseRatio())); + int subSize = (totalCpuTopList.size() > topSize) ? topSize : totalCpuTopList.size(); + cpuTopList = totalCpuTopList.subList(0, subSize); + } + if (!totalMemTopList.isEmpty()) { + totalMemTopList.sort((obj1, obj2) -> obj2.getMemUseRatio().compareTo(obj1.getMemUseRatio())); + int subSize = (totalMemTopList.size() > topSize) ? topSize : totalMemTopList.size(); + memTopList = totalMemTopList.subList(0, subSize); + } + + indexCommonData.setServerVmCpuTopUseRatioList(cpuTopList); + indexCommonData.setServerVmMemTopUseRatioList(memTopList); + + //总云服务器个数 + Integer machineTotal = + mcServerVmRunningInfoList.stream().collect(Collectors.summingInt(McServerVmRunningInfoDto::getTotalMachine)); + //在线云服务器 + Integer machineOnline = + mcServerVmRunningInfoList.stream().collect(Collectors.summingInt(McServerVmRunningInfoDto::getOnlineMachine)); + //离线云服务器 + Integer machineOffline = + mcServerVmRunningInfoList.stream().collect(Collectors.summingInt(McServerVmRunningInfoDto::getOfflineMachine)); + IndexServerVmData serverVmData = new IndexServerVmData(); + //云服务器数据 + serverVmData.setTotalServerVm(machineTotal); + serverVmData.setOnlineServerVm(machineOnline); + serverVmData.setOfflineServerVm(machineOffline); + indexCommonData.setServerVmData(serverVmData); + + } + + /** + * 获取集群中物理主机top利用率 + * + * @param indexStatisticData + * @param loginUserVo + */ + private void physicalHostUsedRatioData(IndexStatisticData indexStatisticData, LoginUserVo loginUserVo) { + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper(clusterDo); + List clusterDoList = cloudClusterService.list(wrapper); + + List mcClusterPhysicalHostList = + clusterService.moreClusterPhysicalHost(clusterDoList, + loginUserVo.getUserName()); + + List physicalHostSortByCpuList = new ArrayList<>(); + List physicalHostSortByMemList = new ArrayList<>(); + + if (!mcClusterPhysicalHostList.isEmpty()) { + mcClusterPhysicalHostList.forEach(item -> { + IndexTopPhysicalHostUsedRatioData physicalHostCpuUsedRatio = new IndexTopPhysicalHostUsedRatioData(); + physicalHostCpuUsedRatio.setServerIp(item.getServerAddr()); + physicalHostCpuUsedRatio.setUsedRatio(item.getCpuUtil()); + physicalHostSortByCpuList.add(physicalHostCpuUsedRatio); + + IndexTopPhysicalHostUsedRatioData physicalHostMemUsedRatio = new IndexTopPhysicalHostUsedRatioData(); + physicalHostMemUsedRatio.setServerIp(item.getServerAddr()); + physicalHostMemUsedRatio.setUsedRatio(item.getMemUtil()); + physicalHostSortByMemList.add(physicalHostMemUsedRatio); + }); + + int topSize = 5; + physicalHostSortByCpuList.sort((obj1, obj2) -> obj2.getUsedRatio().compareTo(obj1.getUsedRatio())); + int subCpuSize = (physicalHostSortByCpuList.size() > topSize) ? topSize : + physicalHostSortByCpuList.size() - 1; + List topCpuList = physicalHostSortByCpuList.subList(0, subCpuSize); + + physicalHostSortByMemList.sort((obj1, obj2) -> obj2.getUsedRatio().compareTo(obj1.getUsedRatio())); + int subMemSize = (physicalHostSortByMemList.size() > topSize) ? topSize : + physicalHostSortByMemList.size() - 1; + List topMemList = physicalHostSortByMemList.subList(0, subMemSize); + + indexStatisticData.setPhysicalHostCpuTopUseRatioList(topCpuList); + indexStatisticData.setPhysicalHostMemTopUseRatioList(topMemList); + } + + } + + + @Override + public OrgLeaderIndexStatisticData orgLeaderStatistic(LoginUserVo loginUserVo) { + OrgLeaderIndexStatisticData orgLeaderIndexStatisticData = new OrgLeaderIndexStatisticData(); + //提醒数据 + IndexNoticeData noticeData = new IndexNoticeData(); + noticeData.setWaitCheckCount(workOrderService.getWaitCheckCount(loginUserVo).getWaitCheckCount()); + noticeData.setAlarmCount(monitorService.alarmNotifications(loginUserVo).getNotificationsCount()); + orgLeaderIndexStatisticData.setNoticeData(noticeData); + + //创建VDC-cpu,内存,存储数据 + createVdcResource(orgLeaderIndexStatisticData, loginUserVo); + //创建云服务器数据,top利用率数据 + createOrgLeaderServerVmData(orgLeaderIndexStatisticData, loginUserVo); + + //创建VDC数据 + orgLeaderIndexStatisticData.setVdcData(createOrgLeaderVdcData(loginUserVo)); + orgLeaderIndexStatisticData.setUserData(createOrgLeaderUserData(loginUserVo)); + return orgLeaderIndexStatisticData; + } + + /** + * 创建VDC-cpu,内存,存储数据 + * + * @param loginUserVo + */ + private void createVdcResource(OrgLeaderIndexStatisticData orgLeaderIndexStatisticData, LoginUserVo loginUserVo) { + //获取登录用户组织对应的VDC + CloudUserDo loginUserDo = cloudUserService.getById(loginUserVo.getUserId()); + CloudVdcDo loginUserVdc = vdcService.getVdcByOrgId(loginUserDo.getOrganizationId()); + //更具vdc获取VDC资源数据 + VdcUsedResourceDto vdcUsedResource = vdcService.getVdcResourceInfo(loginUserVdc.getId(), loginUserVo); + + //vdc-cpu资源 + OrgLeaderVdcUsedData vdcCpuUsedData = new OrgLeaderVdcUsedData(); + //vdc-内存 + OrgLeaderVdcUsedData vdcMemUsedData = new OrgLeaderVdcUsedData(); + + //vdc-存储 + OrgLeaderVdcUsedData vdcStorageUsedData = new OrgLeaderVdcUsedData(); + if (Objects.nonNull(vdcUsedResource)) { + //封cpu数据 + vdcCpuUsedData.setTotal(vdcUsedResource.getTotalCpu()); + vdcCpuUsedData.setAllocateChild(vdcUsedResource.getAllocationCpu()); + vdcCpuUsedData.setSameUsed(vdcUsedResource.getSameUserUsedCpu()); + vdcCpuUsedData.setUsable(vdcUsedResource.getSurplusCpu()); + orgLeaderIndexStatisticData.setVdcCpuUsedData(vdcCpuUsedData); + + //封装内存数据 + vdcMemUsedData.setTotal(vdcUsedResource.getTotalMem()); + vdcMemUsedData.setAllocateChild(vdcUsedResource.getAllocationMem()); + vdcMemUsedData.setSameUsed(vdcUsedResource.getSameUserUsedMem()); + vdcMemUsedData.setUsable(vdcUsedResource.getSurplusMem()); + vdcMemUsedData.setUnit(MemUnit.GB.name()); + orgLeaderIndexStatisticData.setVdcMemUsedData(vdcMemUsedData); + + //封装存储数据 + vdcStorageUsedData.setTotal(vdcUsedResource.getTotalStorage()); + vdcStorageUsedData.setAllocateChild(vdcUsedResource.getAllocationStorage()); + vdcStorageUsedData.setSameUsed(vdcUsedResource.getSameUserUsedStorage()); + vdcStorageUsedData.setUsable(vdcUsedResource.getSurplusStorage()); + vdcStorageUsedData.setUnit(StorageUnit.GB.name()); + orgLeaderIndexStatisticData.setVdcStorageUsedData(vdcStorageUsedData); + } + } + + /** + * 非系统管理员登录-云服务器数据,top利用率数据 + * + * @param orgLeaderIndexStatisticData + * @param loginUserVo + */ + private void createOrgLeaderServerVmData(OrgLeaderIndexStatisticData orgLeaderIndexStatisticData, + LoginUserVo loginUserVo) { + + CloudUserDo loginUserDo = cloudUserService.getById(loginUserVo.getUserId()); + List orgIdList = orgService.getOrgChildIdList(loginUserDo.getOrganizationId()); + + List userDoList = userService.listUserByOrgList(orgIdList, null); + + //获取组织下用户列表 + if (userDoList.isEmpty()) { + return; + } + + //用户用户拥有的云服务器关联关系 + List userMachineDoList = + userMachineService.listUserMachineByUserIdList(userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList())); + if (userMachineDoList.isEmpty()) { + return; + } + //将用户云服务器进行分组 + Map> clusterUserMachineMap = + userMachineDoList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + + List clusterDoList = new ArrayList<>(); + List serverVmUuidList = new ArrayList<>(); + + clusterUserMachineMap.forEach((clusterId, machineList) -> { + CloudClusterDo clusterDo = cloudClusterService.getById(clusterId); + clusterDoList.add(clusterDo); + List uuidList = + machineList.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + QueryVdcUsedResourceParam queryVdcUsedResourceParam = new QueryVdcUsedResourceParam(); + queryVdcUsedResourceParam.setUuidList(uuidList); + serverVmUuidList.add(queryVdcUsedResourceParam); + }); + serverVmRunningInfo(clusterDoList, serverVmUuidList, orgLeaderIndexStatisticData, loginUserVo); + } + + /** + * 创建VDC数量及已分配VDC + * + * @param loginUserVo + * @return + */ + private IndexVdcData createOrgLeaderVdcData(LoginUserVo loginUserVo) { + IndexVdcData indexVdcData = new IndexVdcData(); + //获取登录用户组织对应的VDC + CloudUserDo loginUserDo = cloudUserService.getById(loginUserVo.getUserId()); + CloudVdcDo loginUserVdc = vdcService.getVdcByOrgId(loginUserDo.getOrganizationId()); + + List allChildVdcList = cloudVdcService.getAllChildVdcList(loginUserVdc.getId()); + indexVdcData.setTotalVdc(allChildVdcList.size()); + if (!allChildVdcList.isEmpty()) { + //获取已经绑定组织的VDC + CloudOrgVdcDo queryOrgVdc = new CloudOrgVdcDo(); + queryOrgVdc.setDeleteFlag(false); + QueryWrapper orgVdcWrapper = new QueryWrapper(queryOrgVdc); + orgVdcWrapper.in("vdc_id", allChildVdcList.stream().map(CloudVdcDo::getId).collect(Collectors.toList())); + Integer alreadyAllocateVdc = cloudOrgVdcService.count(orgVdcWrapper); + indexVdcData.setAlreadyAllocateVdc(alreadyAllocateVdc); + indexVdcData.setNoAllocateVdc(indexVdcData.getTotalVdc() - indexVdcData.getAlreadyAllocateVdc()); + } + return indexVdcData; + } + + + /** + * 获取用户数量 + * + * @return + */ + private IndexUserData createOrgLeaderUserData(LoginUserVo loginUserVo) { + IndexUserData indexUserData = new IndexUserData(); + + CloudUserDo loginUserDo = cloudUserService.getById(loginUserVo.getUserId()); + //获取下级组织列表 + List orgIdList = orgService.getOrgChildIdList(loginUserDo.getOrganizationId()); + + //获取当前组织及下级组织中组织管理员数量 + indexUserData.setOrgManageUserCount(userMapper.getUserCountByRoleType(orgIdList, + RoleType.ORG.ordinal())); + //获取当前组织及下级组织中自服务用户 + indexUserData.setSelfServiceUserCount(userMapper.getUserCountByRoleType(orgIdList, + RoleType.SELF_SERVICE.ordinal())); + + + return indexUserData; + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/MonitorServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/MonitorServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a96bc767b7cad55abd99c24ba44f000eb840e08a --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/MonitorServiceImpl.java @@ -0,0 +1,425 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.service.CloudAlarmConfigService; +import com.hnkylin.cloud.core.service.CloudAlarmLogService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import com.hnkylin.cloud.core.service.CloudZoneService; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.*; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.monitor.*; +import com.hnkylin.cloud.manage.entity.resp.monitor.KcpAlarmSettingsResp; +import com.hnkylin.cloud.manage.entity.resp.monitor.PageKcpAlarmLogResp; +import com.hnkylin.cloud.manage.service.*; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +public class MonitorServiceImpl implements MonitorService { + + @Resource + private McHttpService mcHttpService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private ClusterService clusterService; + + @Resource + private McClusterThreadService mcClusterThreadService; + + @Resource + private CloudAlarmConfigService cloudAlarmConfigService; + + @Resource + private CloudAlarmLogService cloudAlarmLogService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private CloudZoneService cloudZoneService; + + @Resource + private OrgService orgService; + + + @Resource + private VdcService vdcService; + + + @Override + public PhysicalHostEventTypeResp serverEventTypeList(BaseClusterParam clusterParam, LoginUserVo loginUserVo) { + + + MCResponseData eventTypeResponse = mcHttpService.hasDataCommonMcRequest(clusterParam.getClusterId(), + null, mcConfigProperties.getServerEventsFilterUrl(), loginUserVo.getUserName(), 0); + PhysicalHostEventTypeResp eventTypeResp = new PhysicalHostEventTypeResp(); + if (Objects.nonNull(eventTypeResponse) && Objects.equals(MCServerVmConstants.SUCCESS, + eventTypeResponse.getStatus())) { + eventTypeResp = JSON.parseObject(JSON.toJSONString(eventTypeResponse.getData()), + PhysicalHostEventTypeResp.class); + + } + return eventTypeResp; + } + + @Override + public PageData pagePhysicalHostEvent(PhysicalHostEventParam physicalHostEventParam, + LoginUserVo loginUserVo) { + McServerEventParamReq mcServerEventParamReq = new McServerEventParamReq(); + BeanUtils.copyProperties(physicalHostEventParam, mcServerEventParamReq); + mcServerEventParamReq.setPage(physicalHostEventParam.getPageNo()); + mcServerEventParamReq.setRows(physicalHostEventParam.getPageSize()); + if (StringUtils.isBlank(mcServerEventParamReq.getSord())) { + mcServerEventParamReq.setSord("desc"); + } + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(physicalHostEventParam.getClusterId(), mcServerEventParamReq, + mcConfigProperties.getPagePhysicalHostEventUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + + McPageResp mcPageResp = + JSONObject.parseObject(JSON.toJSONString(mcResponse.getData()), new + TypeReference>() { + }); + + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcPageResp.getPager()); + mcPageInfo.setPageSize(mcPageResp.getRows().size()); + mcPageInfo.setRecords(mcPageResp.getRecords()); + mcPageInfo.setTotal(mcPageResp.getTotal()); + return new PageData(mcPageInfo, mcPageResp.getRows()); + } + return new PageData(null); + } + + @Override + public AlarmLogTypeResp alarmLogFilterList(BaseClusterParam clusterParam, LoginUserVo loginUserVo) { + + + MCResponseData eventTypeResponse = mcHttpService.hasDataCommonMcRequest(clusterParam.getClusterId(), + null, mcConfigProperties.getAlarmLogFilterUrl(), loginUserVo.getUserName(), 0); + AlarmLogTypeResp alarmLogTypeResp = new AlarmLogTypeResp(); + if (Objects.nonNull(eventTypeResponse) && Objects.equals(MCServerVmConstants.SUCCESS, + eventTypeResponse.getStatus())) { + alarmLogTypeResp = JSON.parseObject(JSON.toJSONString(eventTypeResponse.getData()), + AlarmLogTypeResp.class); + + } + return alarmLogTypeResp; + } + + @Override + public PageData pageAlarmLog(AlarmLogParam alarmLogParam, + LoginUserVo loginUserVo) { + McAlarmLogParamReq mcAlarmLogParamReq = new McAlarmLogParamReq(); + BeanUtils.copyProperties(alarmLogParam, mcAlarmLogParamReq); + mcAlarmLogParamReq.setPage(alarmLogParam.getPageNo()); + mcAlarmLogParamReq.setRows(alarmLogParam.getPageSize()); + + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(alarmLogParam.getClusterId(), mcAlarmLogParamReq, + mcConfigProperties.getPageAlarmLogUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + + McPageResp mcPageResp = JSONObject.parseObject(JSON.toJSONString(mcResponse.getData()), new + TypeReference>() { + }); + + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcPageResp.getPager()); + mcPageInfo.setPageSize(mcPageResp.getRows().size()); + mcPageInfo.setRecords(mcPageResp.getRecords()); + mcPageInfo.setTotal(mcPageResp.getTotal()); + + ignoreNotifications(loginUserVo, alarmLogParam.getClusterId()); + return new PageData(mcPageInfo, mcPageResp.getRows()); + } + + return new PageData(null); + } + + private void ignoreNotifications(LoginUserVo loginUserVo, Integer clusterId) { + + new Thread(() -> { //Lambda表达 + mcHttpService.hasDataCommonMcRequest(clusterId, + null, mcConfigProperties.getIgnoreNotificationsUrl(), loginUserVo.getUserName(), 0); + }).start(); + + } + + @Override + public ServerVirtualizationEventTypeResp serverVirtualizationEventsFilter(BaseClusterParam clusterParam, + LoginUserVo loginUserVo) { + + + MCResponseData eventTypeResponse = mcHttpService.hasDataCommonMcRequest(clusterParam.getClusterId(), + null, mcConfigProperties.getServerVirtualizationEventsFilterUrl(), loginUserVo.getUserName(), 0); + ServerVirtualizationEventTypeResp serverVirtualizationEventTypeResp = new ServerVirtualizationEventTypeResp(); + if (Objects.nonNull(eventTypeResponse) && Objects.equals(MCServerVmConstants.SUCCESS, + eventTypeResponse.getStatus())) { + serverVirtualizationEventTypeResp = JSON.parseObject(JSON.toJSONString(eventTypeResponse.getData()), + ServerVirtualizationEventTypeResp.class); + + } + return serverVirtualizationEventTypeResp; + } + + + @Override + public PageData pageServerVirtualizationEvent(ServerVirtualizationEventParam serverVirtualizationEventParam, + LoginUserVo loginUserVo) { + McServerVirtualizationEventParamReq mcServerVirtualizationEventParamReq = + new McServerVirtualizationEventParamReq(); + BeanUtils.copyProperties(serverVirtualizationEventParam, mcServerVirtualizationEventParamReq); + mcServerVirtualizationEventParamReq.setPage(serverVirtualizationEventParam.getPageNo()); + mcServerVirtualizationEventParamReq.setRows(serverVirtualizationEventParam.getPageSize()); + + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(serverVirtualizationEventParam.getClusterId(), + mcServerVirtualizationEventParamReq, + mcConfigProperties.getPageServerVirtualizationEventUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + + McPageResp mcPageResp = + JSONObject.parseObject(JSON.toJSONString(mcResponse.getData()), new + TypeReference>() { + }); + + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcPageResp.getPager()); + mcPageInfo.setPageSize(mcPageResp.getRows().size()); + mcPageInfo.setRecords(mcPageResp.getRecords()); + mcPageInfo.setTotal(mcPageResp.getTotal()); + return new PageData(mcPageInfo, mcPageResp.getRows()); + } + return new PageData(null); + } + + @Override + public List listAlarmSettings(QueryMcAlarmSettingsParam queryMcAlarmSettingsParam, + LoginUserVo loginUserVo) { + //调用mc获取响应 + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(queryMcAlarmSettingsParam.getClusterId(), + queryMcAlarmSettingsParam, mcConfigProperties.getListAlarmSettingsUrl(), + loginUserVo.getUserName(), 0); + List alarmSettingsList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + alarmSettingsList = JSON.parseArray(JSONArray.toJSONString(mcResponse.getData()), AlarmSettingsResp.class); + } + return alarmSettingsList; + } + + @Override + public boolean updateAlarmSettings(McUpdateAlarmSettingsParam updateAlarmSettingsParam, LoginUserVo loginUserVo) { + + return mcHttpService.noDataCommonMcRequest(updateAlarmSettingsParam.getClusterId(), updateAlarmSettingsParam, + mcConfigProperties.getUpdateAlarmSettingsUrl(), loginUserVo.getUserName(), 0); + } + + @Override + public AlarmIntervalResp getAlarmInterval(BaseClusterParam clusterParam, LoginUserVo loginUserVo) { + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterParam.getClusterId(), + null, mcConfigProperties.getGetAlarmIntervalUrl(), loginUserVo.getUserName(), 0); + AlarmIntervalResp alarmIntervalResp = new AlarmIntervalResp(); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + alarmIntervalResp = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), + AlarmIntervalResp.class); + } + return alarmIntervalResp; + } + + @Override + public boolean updateAlarmInterval(McUpdateAlarmIntervalParam updateAlarmIntervalParam, LoginUserVo loginUserVo) { + return mcHttpService.noDataCommonMcRequest(updateAlarmIntervalParam.getClusterId(), updateAlarmIntervalParam, + mcConfigProperties.getUpdateAlarmIntervalUrl(), loginUserVo.getUserName(), 0); + } + + + @Override + public AlarmNotificationsResp alarmNotifications(LoginUserVo loginUserVo) { + AlarmNotificationsResp alarmNotificationsResp = new AlarmNotificationsResp(); + List clusterDoList = clusterService.visibleClusterByUserId(loginUserVo.getUserId()); + if (!clusterDoList.isEmpty()) { + if (Objects.equals(clusterDoList.size(), 1)) { + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(clusterDoList.get(0).getId(), + null, mcConfigProperties.getAlarmNotificationsUrl(), loginUserVo.getUserName(), 0); + AlarmNotificationsResp mcAlarmNotificationsResp = new AlarmNotificationsResp(); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, + mcResponse.getStatus())) { + mcAlarmNotificationsResp = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), + AlarmNotificationsResp.class); + return mcAlarmNotificationsResp; + } + } else { + List resultList = + mcClusterThreadService.threadGetMcResponse(clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()), + loginUserVo.getUserName(), mcConfigProperties.getAlarmNotificationsUrl(), + new ArrayList<>()); + List mcAlarmNoticeList = new ArrayList<>(); + Stream.iterate(0, i -> i + 1).limit(clusterDoList.size()).forEach(i -> { + String mcAlarmNotificationsRespStr = resultList.get(i); + if (Objects.nonNull(mcAlarmNotificationsRespStr)) { + AlarmNotificationsResp mcAlarmNotificationsResp = JSON.parseObject(mcAlarmNotificationsRespStr, + AlarmNotificationsResp.class); + mcAlarmNoticeList.add(mcAlarmNotificationsResp); + } + }); + Integer notificationsCount = + mcAlarmNoticeList.stream().mapToInt(AlarmNotificationsResp::getNotificationsCount).sum(); + alarmNotificationsResp.setNotificationsCount(notificationsCount); + } + + } + //获取当天存VDC-资源告警情况 + int todayKcpNotice = getTodayKcpAlarmCount(loginUserVo); + alarmNotificationsResp.setNotificationsCount(alarmNotificationsResp.getNotificationsCount() + todayKcpNotice); + return alarmNotificationsResp; + } + + + /** + * 获取当天VDC-资源告警数量 + * + * @param loginUserVo + * @return + */ + private Integer getTodayKcpAlarmCount(LoginUserVo loginUserVo) { + CloudAlarmLogDo queryAlarmLogDo = new CloudAlarmLogDo(); + QueryWrapper queryWrapper = new QueryWrapper(queryAlarmLogDo); + + String today = DateUtils.format(new Date(), DateUtils.DATE_YYYY_MM_DD); + queryWrapper.ge("create_time", DateUtils.parse(today + DateUtils.DAY_START, + DateUtils.DATE_ALL_PATTEN)); + + List cloudVdcDoList = vdcService.visibleVdcListByUserId(loginUserVo.getUserId()); + if (cloudVdcDoList.isEmpty()) { + return 0; + } + queryWrapper.in("alarm_target_id", cloudVdcDoList.stream().map(CloudVdcDo::getId).collect(Collectors.toList())); + + return cloudAlarmLogService.count(queryWrapper); + } + + + @Override + public List listKcpAlarmSettings(LoginUserVo loginUserVo) { + + CloudAlarmConfigDo cloudAlarmConfigDo = new CloudAlarmConfigDo(); + cloudAlarmConfigDo.setDeleteFlag(false); + QueryWrapper queryWrapper = new QueryWrapper(cloudAlarmConfigDo); + List alarmConfigDoList = cloudAlarmConfigService.list(queryWrapper); + List kcpAlarmSettingsList = new ArrayList<>(); + alarmConfigDoList.forEach(item -> { + KcpAlarmSettingsResp kcpAlarmSettingsResp = new KcpAlarmSettingsResp(); + BeanUtils.copyProperties(item, kcpAlarmSettingsResp); + kcpAlarmSettingsResp.setKcpSettingId(item.getId()); + kcpAlarmSettingsList.add(kcpAlarmSettingsResp); + }); + return kcpAlarmSettingsList; + } + + @Override + public void updateKcpAlarmSetting(UpdateKcpAlarmSettingParam updateAlarmIntervalParam, LoginUserVo loginUserVo) { + CloudAlarmConfigDo cloudAlarmConfigDo = + cloudAlarmConfigService.getById(updateAlarmIntervalParam.getKcpSettingId()); + cloudAlarmConfigDo.setGeneralAlarm(updateAlarmIntervalParam.getGeneralAlarm()); + cloudAlarmConfigDo.setSeverityAlarm(updateAlarmIntervalParam.getSeverityAlarm()); + cloudAlarmConfigDo.setUrgentAlarm(updateAlarmIntervalParam.getUrgentAlarm()); + //cloudAlarmConfigDo.setDurationTime(updateAlarmIntervalParam.getDurationTime()); + cloudAlarmConfigDo.setUpdateBy(loginUserVo.getUserId()); + cloudAlarmConfigDo.setUpdateTime(new Date()); + cloudAlarmConfigService.updateById(cloudAlarmConfigDo); + } + + + @Override + public PageData pageKcpAlarmLog(PagKcpAlarmLogParam kcpAlarmLogParam, + LoginUserVo loginUserVo) { + + CloudAlarmLogDo queryAlarmLogDo = new CloudAlarmLogDo(); + QueryWrapper queryWrapper = new QueryWrapper(queryAlarmLogDo); + if (StringUtils.isNotBlank(kcpAlarmLogParam.getStartDate())) { + queryWrapper.ge("create_time", DateUtils.parse(kcpAlarmLogParam.getStartDate() + DateUtils.DAY_START, + DateUtils.DATE_ALL_PATTEN)); + } + if (StringUtils.isNotBlank(kcpAlarmLogParam.getEndDate())) { + queryWrapper.le("create_time", DateUtils.parse(kcpAlarmLogParam.getEndDate() + DateUtils.DAY_END, + DateUtils.DATE_ALL_PATTEN)); + } + + if (Objects.nonNull(kcpAlarmLogParam.getZoneId()) && kcpAlarmLogParam.getZoneId() > 0) { + + List cloudVdcDoList = vdcService.visibleVdcListByUserIdAndZoneId(loginUserVo.getUserId(), + kcpAlarmLogParam.getZoneId()); + if (cloudVdcDoList.isEmpty()) { + return new PageData(null); + } + queryWrapper.in("alarm_target_id", + cloudVdcDoList.stream().map(CloudVdcDo::getId).collect(Collectors.toList())); + } + if (Objects.nonNull(kcpAlarmLogParam.getOrgId()) && kcpAlarmLogParam.getOrgId() > 0) { + CloudVdcDo vdcDo = cloudVdcService.getVdcByOrgId(kcpAlarmLogParam.getOrgId()); + if (Objects.isNull(vdcDo)) { + return new PageData(null); + } + queryWrapper.eq("alarm_target_id", vdcDo.getId()); + } + + if (Objects.equals(kcpAlarmLogParam.getZoneId(), 0) || Objects.equals(kcpAlarmLogParam.getOrgId(), 0)) { + List cloudVdcDoList = vdcService.visibleVdcListByUserId(loginUserVo.getUserId()); + if (cloudVdcDoList.isEmpty()) { + return new PageData(null); + } + queryWrapper.in("alarm_target_id", + cloudVdcDoList.stream().map(CloudVdcDo::getId).collect(Collectors.toList())); + } + queryWrapper.orderByDesc("id"); + PageHelper.startPage(kcpAlarmLogParam.getPageNo(), kcpAlarmLogParam.getPageSize()); + List alarmLogDoList = cloudAlarmLogService.list(queryWrapper); + PageInfo pageInfo = new PageInfo<>(alarmLogDoList); + List kcpAlarmLogList = new ArrayList<>(); + alarmLogDoList.forEach(item -> { + PageKcpAlarmLogResp kcpAlarmLog = new PageKcpAlarmLogResp(); + BeanUtils.copyProperties(item, kcpAlarmLog); + CloudVdcDo vdcDo = cloudVdcService.getById(item.getAlarmTargetId()); + CloudZoneDo zoneDo = cloudZoneService.getById(vdcDo.getZoneId()); + kcpAlarmLog.setZoneName(zoneDo.getName()); + CloudOrganizationDo organizationDo = orgService.getOrgByVdcId(vdcDo.getId()); + kcpAlarmLog.setOrgName("---"); + if (Objects.nonNull(organizationDo)) { + kcpAlarmLog.setOrgName(organizationDo.getOrganizationName()); + } + kcpAlarmLog.setAlarmTime(DateUtils.format(item.getCreateTime(), DateUtils.DATE_ALL_PATTEN)); + kcpAlarmLogList.add(kcpAlarmLog); + }); + + PageData pageData = new PageData(pageInfo); + pageData.setList(kcpAlarmLogList); + return pageData; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/NetworkConfigServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/NetworkConfigServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0a44474099bde5d55a00c2c14eb9c82f23352401 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/NetworkConfigServiceImpl.java @@ -0,0 +1,218 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.CloudClusterDo; +import com.hnkylin.cloud.core.domain.CloudNetworkConfigDo; +import com.hnkylin.cloud.core.domain.CloudVdcDo; +import com.hnkylin.cloud.core.service.CloudClusterService; +import com.hnkylin.cloud.core.service.CloudNetworkConfigService; +import com.hnkylin.cloud.core.service.CloudVdcService; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.ListPortGroupParam; +import com.hnkylin.cloud.manage.entity.mc.resp.NetworkConfigResp; +import com.hnkylin.cloud.manage.entity.mc.resp.NetworkPortGroupResp; +import com.hnkylin.cloud.manage.entity.req.network.CreateNetworkParam; +import com.hnkylin.cloud.manage.entity.req.network.ModifyNetworkParam; +import com.hnkylin.cloud.manage.entity.req.vdc.BaseVdcParam; +import com.hnkylin.cloud.manage.entity.req.workorder.QueryPortGroupParam; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkConfigRespDto; +import com.hnkylin.cloud.manage.service.ClusterService; +import com.hnkylin.cloud.manage.service.McServerVmService; +import com.hnkylin.cloud.manage.service.NetworkConfigService; +import com.hnkylin.cloud.manage.service.VdcService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@Service +public class NetworkConfigServiceImpl implements NetworkConfigService { + + @Resource + private CloudNetworkConfigService cloudNetworkConfigService; + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private VdcService vdcService; + + @Resource + private CloudVdcService cloudVdcService; + + @Override + public List listNetworkListByVdcId(Integer vdcId) { + CloudNetworkConfigDo networkConfigDo = new CloudNetworkConfigDo(); + networkConfigDo.setDeleteFlag(Boolean.FALSE); + networkConfigDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(networkConfigDo); + wrapper.orderByDesc("id"); + List networkConfigDoList = cloudNetworkConfigService.list(wrapper); + + List vdcDoList = new ArrayList<>(); + vdcDoList.add(cloudVdcService.getById(vdcId)); + List networkList = formatNetworkConfigRespList(networkConfigDoList, vdcDoList); + return networkList; + } + + @Override + public List listNetworkListByVdcIdAndClusterId(Integer vdcId, Integer clusterId) { + CloudNetworkConfigDo networkConfigDo = new CloudNetworkConfigDo(); + networkConfigDo.setDeleteFlag(Boolean.FALSE); + networkConfigDo.setVdcId(vdcId); + networkConfigDo.setClusterId(clusterId); + QueryWrapper wrapper = new QueryWrapper<>(networkConfigDo); + wrapper.orderByDesc("id"); + List networkConfigDoList = cloudNetworkConfigService.list(wrapper); + + List vdcDoList = new ArrayList<>(); + vdcDoList.add(cloudVdcService.getById(vdcId)); + List networkList = formatNetworkConfigRespList(networkConfigDoList, vdcDoList); + return networkList; + } + + /** + * 封装网络信息 + */ + private List formatNetworkConfigRespList(List networkConfigDoList, + List vdcList) { + List networkList = new ArrayList<>(networkConfigDoList.size()); + networkConfigDoList.forEach(networkConfig -> { + CloudVdcDo vdcDo = + vdcList.stream().filter(item -> Objects.equals(item.getId(), networkConfig.getVdcId())) + .findFirst().orElse(null); + NetworkConfigRespDto networkConfigRespDto = new NetworkConfigRespDto(); + BeanUtils.copyProperties(networkConfig, networkConfigRespDto); + networkConfigRespDto.setCreateTime(DateUtils.format(networkConfig.getCreateTime(), + DateUtils.DATE_ALL_PATTEN)); + networkConfigRespDto.setNetworkId(networkConfig.getId()); + networkConfigRespDto.setVdcName(Objects.nonNull(vdcDo) ? vdcDo.getVdcName() : "-"); + networkConfigRespDto.setClusterId(networkConfig.getClusterId()); + networkConfigRespDto.setClusterName(cloudClusterService.getById(networkConfig.getClusterId()).getName()); + networkList.add(networkConfigRespDto); + }); + return networkList; + } + + + @Override + public PageData pageNetworkConfig(BasePageParam basePageParam, LoginUserVo loginUserVo) { + + List vdcList = vdcService.visibleVdcListByUserId(loginUserVo.getUserId()); + if (vdcList.isEmpty()) { + return new PageData(null); + } + CloudNetworkConfigDo networkConfigDo = new CloudNetworkConfigDo(); + networkConfigDo.setDeleteFlag(Boolean.FALSE); + + QueryWrapper wrapper = new QueryWrapper<>(networkConfigDo); + wrapper.in("vdc_id", vdcList.stream().map(CloudVdcDo::getId).collect(Collectors.toList())); + wrapper.orderByDesc("id"); + + PageHelper.startPage(basePageParam.getPageNo(), basePageParam.getPageSize()); + List networkConfigDoList = cloudNetworkConfigService.list(wrapper); + + PageInfo pageInfo = new PageInfo<>(networkConfigDoList); + List networkList = formatNetworkConfigRespList(networkConfigDoList, vdcList); + PageData pageData = new PageData(pageInfo); + pageData.setList(networkList); + return pageData; + } + + @Override + public void createNetwork(CreateNetworkParam createNetworkParam, LoginUserVo loginUserVo) { + //校验是否重名 + CloudNetworkConfigDo networkConfigDo = new CloudNetworkConfigDo(); + networkConfigDo.setDeleteFlag(Boolean.FALSE); + networkConfigDo.setNetworkName(createNetworkParam.getNetworkName()); + QueryWrapper wrapper = new QueryWrapper<>(networkConfigDo); + List existList = cloudNetworkConfigService.list(wrapper); + if (!existList.isEmpty()) { + throw new KylinException(KylinHttpResponseConstants.EXIST_NETWORK_NAME); + } + + CloudNetworkConfigDo cloudNetworkConfigDo = new CloudNetworkConfigDo(); + cloudNetworkConfigDo.setCreateBy(loginUserVo.getUserId()); + cloudNetworkConfigDo.setCreateTime(new Date()); + BeanUtils.copyProperties(createNetworkParam, cloudNetworkConfigDo); + cloudNetworkConfigService.save(cloudNetworkConfigDo); + } +// +// @Override +// public NetworkConfigResp mcNetworkConfig(LoginUserVo loginUserVo) { +// +// return mcServerVmService.mcNetworkConfig(loginUserVo); +// } + +// @Override +// public List mcPortGroupListByVirtualSwitch(QueryPortGroupParam queryPortGroupParam, +// LoginUserVo loginUserVo) { +// ListPortGroupParam listPortGroupParam = new ListPortGroupParam(); +// listPortGroupParam.setVsname(queryPortGroupParam.getVirtualSwitchName()); +// return mcServerVmService.mcPortGroupListByVirtualSwitch(listPortGroupParam, loginUserVo); +// } + + @Override + public CloudNetworkConfigDo getById(Integer networkId) { + return cloudNetworkConfigService.getById(networkId); + } + + + @Override + public int getNetWorkCountByVdcId(Integer vdcId) { + CloudNetworkConfigDo networkConfigDo = new CloudNetworkConfigDo(); + networkConfigDo.setDeleteFlag(Boolean.FALSE); + networkConfigDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(networkConfigDo); + + return cloudNetworkConfigService.getBaseMapper().selectCount(wrapper); + } + + @Override + public NetworkConfigRespDto networkDetail(Integer networkId) { + CloudNetworkConfigDo networkConfigDo = cloudNetworkConfigService.getById(networkId); + NetworkConfigRespDto networkConfigRespDto = new NetworkConfigRespDto(); + BeanUtils.copyProperties(networkConfigDo, networkConfigRespDto); + networkConfigRespDto.setNetworkId(networkConfigDo.getId()); + CloudVdcDo vdcDo = cloudVdcService.getById(networkConfigDo.getVdcId()); + networkConfigRespDto.setVdcName(Objects.nonNull(vdcDo) ? vdcDo.getVdcName() : "-"); + networkConfigRespDto.setClusterId(networkConfigDo.getClusterId()); + networkConfigRespDto.setClusterName(cloudClusterService.getById(networkConfigDo.getClusterId()).getName()); + return networkConfigRespDto; + } + + @Override + public void modifyNetwork(ModifyNetworkParam modifyNetworkParam, LoginUserVo loginUserVo) { + CloudNetworkConfigDo networkConfigDo = cloudNetworkConfigService.getById(modifyNetworkParam.getNetworkId()); + networkConfigDo.setInterfaceType(modifyNetworkParam.getInterfaceType()); + networkConfigDo.setNetworkName(modifyNetworkParam.getNetworkName()); + networkConfigDo.setModelType(modifyNetworkParam.getModelType()); + networkConfigDo.setAddressPool(modifyNetworkParam.getAddressPool()); + networkConfigDo.setAddressPoolId(modifyNetworkParam.getAddressPoolId()); + networkConfigDo.setPortGroup(modifyNetworkParam.getPortGroup()); + networkConfigDo.setPortGroupUuid(modifyNetworkParam.getPortGroupUuid()); + networkConfigDo.setVirtualSwitch(modifyNetworkParam.getVirtualSwitch()); + networkConfigDo.setSecurityPolicy(modifyNetworkParam.getSecurityPolicy()); + networkConfigDo.setSecurityGroup(modifyNetworkParam.getSecurityGroup()); + networkConfigDo.setSecurityGroupUuid(modifyNetworkParam.getSecurityGroupUuid()); + networkConfigDo.setVirtualFirewallId(modifyNetworkParam.getVirtualFirewallId()); + networkConfigDo.setVirtualFirewallName(modifyNetworkParam.getVirtualFirewallName()); + networkConfigDo.setUpdateBy(loginUserVo.getUserId()); + networkConfigDo.setUpdateTime(new Date()); + cloudNetworkConfigService.updateById(networkConfigDo); + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/OrgServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/OrgServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8327805b2001ada507fb22f355b702469cf60ece --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/OrgServiceImpl.java @@ -0,0 +1,724 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.DateUtils; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.common.servervm.McServerVmPageDetailResp; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.enums.UserType; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseOrgConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseUserConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.org.*; +import com.hnkylin.cloud.manage.entity.resp.org.*; +import com.hnkylin.cloud.manage.entity.resp.role.OrgStatisticTreeDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcUsedResourceDto; +import com.hnkylin.cloud.manage.enums.OrgStatisticTreeType; +import com.hnkylin.cloud.manage.service.*; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class OrgServiceImpl implements OrgService { + + + @Resource + private CloudOrganizationService cloudOrganizationService; + + @Resource + private CloudOrgVdcService cloudOrgVdcService; + + + @Resource + private CloudUserService cloudUserService; + + @Resource + private CloudRoleService cloudRoleService; + + @Resource + private CloudUserRoleService cloudUserRoleService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private RoleService roleService; + + @Resource + private UserService userService; + + + @Resource + private UserMachineService userMachineService; + + @Resource + private CloudPermissionService cloudPermissionService; + + @Resource + private CloudRolePermissionService cloudRolePermissionService; + + @Resource + private VdcService vdcService; + + @Override + @Transactional + public void createOrg(CreateOrgParam createOrgParam, LoginUserVo loginUserVo) { + + Date now = new Date(); + + //先判断是否重名 + CloudOrganizationDo existOrg = + cloudOrganizationService.queryByOrganizationNameName(createOrgParam.getOrganizationName()); + if (Objects.nonNull(existOrg)) { + throw new KylinException(KylinHttpResponseOrgConstants.EXIST_ORG); + } + Integer parentId = createOrgParam.getParentId(); + if (Objects.equals(createOrgParam.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + CloudOrganizationDo defaultTopOrg = cloudOrganizationService.getDefaultTopOrg(); + parentId = defaultTopOrg.getId(); + } + + //新增组织 + CloudOrganizationDo cloudOrganizationDo = new CloudOrganizationDo(); + cloudOrganizationDo.setOrganizationName(createOrgParam.getOrganizationName()); + cloudOrganizationDo.setParentId(parentId); + cloudOrganizationDo.setRemark(createOrgParam.getRemark()); + cloudOrganizationDo.setCreateBy(loginUserVo.getUserId()); + cloudOrganizationDo.setCreateTime(now); + cloudOrganizationService.save(cloudOrganizationDo); + //组织和VDC关联表 + CloudOrgVdcDo cloudOrgVdcDo = new CloudOrgVdcDo(); + cloudOrgVdcDo.setOrgId(cloudOrganizationDo.getId()); + cloudOrgVdcDo.setVdcId(createOrgParam.getVdcId()); + cloudOrgVdcDo.setCreateBy(loginUserVo.getUserId()); + cloudOrgVdcDo.setCreateTime(now); + cloudOrgVdcService.save(cloudOrgVdcDo); + + + if (createOrgParam.getCreateLeader()) { + //创建组织管理员和对应角色 + createOrgLeaderUser(loginUserVo, cloudOrganizationDo.getId(), + createOrgParam.getLeaderUserName(), createOrgParam.getLeaderRealName(), + createOrgParam.getLeaderPassword()); + } + + + } + + /** + * 创建组织管理员和对应角色,并赋予组织管理员权限 + */ + private void createOrgLeaderUser(LoginUserVo loginUserVo, Integer orgId, + String leaderUserName, String leaderRealName, String leaderPassword) { + + //验证用户名是否重复 + CloudUserDo userDo = new CloudUserDo(); + userDo.setUserName(leaderUserName); + userDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(userDo); + int existUserCount = cloudUserService.getBaseMapper().selectCount(wrapper); + if (existUserCount > 0) { + throw new KylinException(KylinHttpResponseUserConstants.EXIST_USER); + } + + //查询是否存在组织管理员角色 + CloudRoleDo orgRole = cloudRoleService.getOrgRole(); + + Integer roleId = orgRole.getId(); + //创建用户 + CloudUserDo cloudUserDo = createLeaderUser(loginUserVo, orgId, + leaderUserName, leaderRealName, leaderPassword); + CloudUserRoleDo userRoleDo = CloudUserRoleDo.builder().userId(cloudUserDo.getId()) + .roleId(roleId).build(); + userRoleDo.setCreateBy(loginUserVo.getUserId()); + userRoleDo.setCreateTime(new Date()); + cloudUserRoleService.save(userRoleDo); + + + } + + @Override + @Transactional + public void modifyOrg(ModifyOrgParam modifyOrgParam, LoginUserVo loginUserVo) { + + + CloudOrganizationDo existOrg = + cloudOrganizationService.queryByOrganizationNameName(modifyOrgParam.getOrganizationName()); + if (Objects.nonNull(existOrg) && !Objects.equals(existOrg.getId(), modifyOrgParam.getOrgId())) { + throw new KylinException(KylinHttpResponseOrgConstants.EXIST_ORG); + } + + + Date updateTime = new Date(); + + CloudOrganizationDo cloudOrganizationDo = cloudOrganizationService.getById(modifyOrgParam.getOrgId()); + cloudOrganizationDo.setOrganizationName(modifyOrgParam.getOrganizationName()); + cloudOrganizationDo.setRemark(modifyOrgParam.getRemark()); + cloudOrganizationDo.setParentId(modifyOrgParam.getParentId()); + cloudOrganizationDo.setUpdateBy(loginUserVo.getUserId()); + cloudOrganizationDo.setUpdateTime(updateTime); + cloudOrganizationService.updateById(cloudOrganizationDo); + + + //组织和VDC关联 + CloudOrgVdcDo cloudOrgVdcDo = new CloudOrgVdcDo(); + cloudOrgVdcDo.setOrgId(modifyOrgParam.getOrgId()); + cloudOrgVdcDo.setDeleteFlag(false); + Wrapper orgVdcDoWrapper = + new QueryWrapper<>(cloudOrgVdcDo); + CloudOrgVdcDo orgVdcDo = cloudOrgVdcService.getOne(orgVdcDoWrapper); + //如果变更了VDC + if (Objects.nonNull(orgVdcDo) && !Objects.equals(orgVdcDo.getVdcId(), modifyOrgParam.getVdcId())) { + orgVdcDo.setVdcId(modifyOrgParam.getVdcId()); + orgVdcDo.setUpdateBy(loginUserVo.getUserId()); + orgVdcDo.setUpdateTime(updateTime); + cloudOrgVdcService.updateById(orgVdcDo); + } + //创建组织管理员 + if (modifyOrgParam.getCreateLeader()) { + //新建的组织管理员 + if (Objects.equals(modifyOrgParam.getLeaderUserId(), 0) || Objects.isNull(modifyOrgParam.getLeaderUserId())) { + //创建组织管理员和对应角色,并赋予组织管理员权限 + createOrgLeaderUser(loginUserVo, cloudOrganizationDo.getId(), + modifyOrgParam.getLeaderUserName(), modifyOrgParam.getLeaderRealName(), + modifyOrgParam.getLeaderPassword()); + } else { + //修改原有的组织管理员 + CloudUserDo orgLeaderUser = cloudUserService.getById(modifyOrgParam.getLeaderUserId()); + orgLeaderUser.setUserName(modifyOrgParam.getLeaderUserName()); + orgLeaderUser.setRealName(modifyOrgParam.getLeaderRealName()); + orgLeaderUser.setPassword(modifyOrgParam.getLeaderPassword()); + orgLeaderUser.setUpdateBy(loginUserVo.getUserId()); + orgLeaderUser.setUpdateTime(updateTime); + cloudUserService.updateById(orgLeaderUser); + } + } + } + + + @Override + public void modifyTopOrgName(ModifyTopOrgNameParam modifyOrgParam, LoginUserVo loginUserVo) { + CloudOrganizationDo existOrg = + cloudOrganizationService.queryByOrganizationNameName(modifyOrgParam.getOrganizationName()); + if (Objects.nonNull(existOrg) && !Objects.equals(existOrg.getId(), modifyOrgParam.getOrgId())) { + throw new KylinException(KylinHttpResponseOrgConstants.EXIST_ORG); + } + + Date updateTime = new Date(); + + CloudOrganizationDo cloudOrganizationDo = cloudOrganizationService.getById(modifyOrgParam.getOrgId()); + cloudOrganizationDo.setOrganizationName(modifyOrgParam.getOrganizationName()); + cloudOrganizationDo.setUpdateBy(loginUserVo.getUserId()); + cloudOrganizationDo.setUpdateTime(updateTime); + cloudOrganizationService.updateById(cloudOrganizationDo); + } + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构 + */ + @Override + public List queryParentOrg(QueryParentOrgParam queryParentOrgParam, LoginUserVo loginUserVo) { + //获取登录用户组织 + CloudOrganizationDo loginUserOrg = getByUserId(loginUserVo.getUserId()); + //查询全部组织 + List orgDoList = cloudOrganizationService.queryAllOrgList(); + //编辑时,当前的组织,需要过滤不能选中自己做为上级分组 + Integer nowOrgId = queryParentOrgParam.getOrganizationId(); + List parentOrgList = new ArrayList<>(); + for (CloudOrganizationDo orgDo : orgDoList) { + + if (Objects.equals(orgDo.getId(), loginUserOrg.getId())) { + if (Objects.nonNull(nowOrgId) && nowOrgId > 0) { + if (!Objects.equals(orgDo.getId(), nowOrgId)) { + parentOrgList.add(formatParentOrgDto(orgDo, orgDoList, nowOrgId)); + } + } else { + parentOrgList.add(formatParentOrgDto(orgDo, orgDoList, nowOrgId)); + } + + } + } + return parentOrgList; + } + + + private void formatCommonOrgTree(CloudOrganizationDo cloudOrganizationDo, + List allOrgList, + CommonOrgTreeRespDto commonOrgTreeRespDto) { + commonOrgTreeRespDto.setOrganizationId(cloudOrganizationDo.getId()); + commonOrgTreeRespDto.setOrganizationName(cloudOrganizationDo.getOrganizationName()); + commonOrgTreeRespDto.setParentId(cloudOrganizationDo.getParentId()); + commonOrgTreeRespDto.setRemark(cloudOrganizationDo.getRemark()); + commonOrgTreeRespDto.setParentName(""); + CloudOrganizationDo parentDo = + allOrgList.stream().filter(item -> Objects.equals(item.getId(), cloudOrganizationDo.getParentId())).findFirst().orElse(null); + if (Objects.nonNull(parentDo)) { + commonOrgTreeRespDto.setParentName(parentDo.getOrganizationName()); + } + } + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构-封装组织数据 + */ + private ParentOrgRespDto formatParentOrgDto(CloudOrganizationDo cloudOrganizationDo, + List allOrgList, Integer nowOrgId) { + ParentOrgRespDto parentOrgRespDto = new ParentOrgRespDto(); + formatCommonOrgTree(cloudOrganizationDo, allOrgList, parentOrgRespDto); + parentOrgRespDto.setChildren(getParentChildOrg(cloudOrganizationDo.getId(), allOrgList, nowOrgId)); + return parentOrgRespDto; + } + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构-获取子组织 + */ + private List getParentChildOrg(Integer parentId, List allOrgList, + Integer nowOrgId) { + List childList = new ArrayList<>(); + for (CloudOrganizationDo organizationDo : allOrgList) { + if (Objects.equals(parentId, organizationDo.getParentId())) { + if (Objects.nonNull(nowOrgId) && nowOrgId > 0) { + if (!Objects.equals(organizationDo.getId(), nowOrgId) && !Objects.equals(organizationDo.getParentId(), + nowOrgId)) { + ParentOrgRespDto parentOrgRespDto = formatParentOrgDto(organizationDo, allOrgList, nowOrgId); + childList.add(parentOrgRespDto); + } + } else { + ParentOrgRespDto parentOrgRespDto = formatParentOrgDto(organizationDo, allOrgList, nowOrgId); + childList.add(parentOrgRespDto); + } + + } + } + return childList; + } + + /** + * 组织管理-主列表 + */ + @Override + public List queryOrgList(LoginUserVo loginUserVo) { + + //查询全部组织 + List orgDoList = cloudOrganizationService.queryAllOrgList(); + List organizationList = new ArrayList<>(); + //登录用户组织 + CloudOrganizationDo loginUserOrg = getByUserId(loginUserVo.getUserId()); + + for (CloudOrganizationDo orgDo : orgDoList) { + if (Objects.equals(orgDo.getId(), loginUserOrg.getId())) { + organizationList.add(formatOrgDto(orgDo, orgDoList, loginUserVo)); + } + } + return organizationList; + } + + + /** + * 组织管理主列表-创新主列表数据 + */ + private OrganizationRespDto formatOrgDto(CloudOrganizationDo cloudOrganizationDo, + List allOrgList, LoginUserVo loginUserVo) { + OrganizationRespDto organizationDto = new OrganizationRespDto(); + formatCommonOrgTree(cloudOrganizationDo, allOrgList, organizationDto); + orgStatistics(organizationDto, cloudOrganizationDo, loginUserVo); + + organizationDto.setChildren(getChild(cloudOrganizationDo.getId(), allOrgList, loginUserVo)); + return organizationDto; + } + + + /** + * 组织数据统计 + * + * @param organizationRespDto + */ + private void orgStatistics(OrganizationRespDto organizationRespDto, CloudOrganizationDo cloudOrganizationDo, + LoginUserVo loginUserVo) { + + + List userDoList = userService.listUserByOrgId(cloudOrganizationDo.getId()); + organizationRespDto.setUserNum(userDoList.size()); + organizationRespDto.setServerVmNum(0); + if (!userDoList.isEmpty()) { + List userIdList = userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList()); + organizationRespDto.setServerVmNum(userMachineService.countUserMachineByUserIdList(userIdList)); + } + if (Objects.equals(cloudOrganizationDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + organizationRespDto.setTopOrg(true); + return; + } + + CloudVdcDo vdcDo = cloudVdcService.getVdcByOrgId(cloudOrganizationDo.getId()); + organizationRespDto.setVdcId(vdcDo.getId()); + organizationRespDto.setVdcName(vdcDo.getVdcName()); + //获取VDC资源情况 + VdcUsedResourceDto vdcResourceDto = vdcService.getVdcResourceInfo(vdcDo.getId(), loginUserVo); + + organizationRespDto.setAllocationCpu(vdcResourceDto.getTotalCpu()); + organizationRespDto.setUsedCpu(vdcResourceDto.getUsedCpu()); + + organizationRespDto.setAllocationMem(new BigDecimal(vdcResourceDto.getTotalMem())); + + organizationRespDto.setUsedMem(new BigDecimal(vdcResourceDto.getUsedMem())); + organizationRespDto.setMemUnit(vdcResourceDto.getMemUnit()); + + organizationRespDto.setAllocationDisk(new BigDecimal(vdcResourceDto.getTotalStorage())); + organizationRespDto.setStorageUnit(vdcResourceDto.getStorageUnit()); + + organizationRespDto.setUsedDisk(new BigDecimal(vdcResourceDto.getUsedStorage())); + + } + + + /** + * 组织管理主列表-获取组织的子组织 + */ + private List getChild(Integer parentId, List allOrgList, + LoginUserVo loginUserVo) { + List childList = new ArrayList<>(); + for (CloudOrganizationDo organizationDo : allOrgList) { + if (Objects.equals(parentId, organizationDo.getParentId())) { + OrganizationRespDto organizationDto = formatOrgDto(organizationDo, allOrgList, loginUserVo); + childList.add(organizationDto); + } + } + return childList; + } + + + /** + * 是否拥有下级组织 + * return true:拥有 false:没有下级组织 + */ + private boolean ifHasChildOrg(Integer parentOrgId) { + CloudOrganizationDo parentOrg = new CloudOrganizationDo(); + parentOrg.setParentId(parentOrgId); + parentOrg.setDeleteFlag(Boolean.FALSE); + Wrapper wrapper = new QueryWrapper<>(parentOrg); + List childOrgList = cloudOrganizationService.getBaseMapper().selectList(wrapper); + return !childOrgList.isEmpty(); + } + + /** + * 删除组织,限制条件: + * 1:拥有下级组织不能删除 + * 2:组织及下级组织有用户不能删除 + */ + @Override + @Transactional + public void deleteOrg(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo) { + //1:查询是否拥有下级组织 + + boolean hasChildOrg = ifHasChildOrg(baseOrgParam.getOrgId()); + if (hasChildOrg) { + throw new KylinException(KylinHttpResponseOrgConstants.HAS_CHILD_NOT_DELETE); + } + + //查询组织是否拥有用户 + CloudUserDo cloudUserDo = new CloudUserDo(); + cloudUserDo.setOrganizationId(baseOrgParam.getOrgId()); + cloudUserDo.setDeleteFlag(false); + Wrapper userWrapper = new QueryWrapper<>(cloudUserDo); + List userList = cloudUserService.getBaseMapper().selectList(userWrapper); + if (!userList.isEmpty()) { + throw new KylinException(KylinHttpResponseOrgConstants.HAS_USER_NOT_DELETE); + } + Date deleteTime = new Date(); + //删除组织 + CloudOrganizationDo cloudOrganizationDo = cloudOrganizationService.getById(baseOrgParam.getOrgId()); + cloudOrganizationDo.setDeleteBy(loginUserVo.getUserId()); + cloudOrganizationDo.setDeleteTime(deleteTime); + cloudOrganizationDo.setDeleteFlag(true); + cloudOrganizationService.updateById(cloudOrganizationDo); + + //删除组织和VDC绑定关系 + Wrapper orgVdcDoWrapper = + new QueryWrapper<>(CloudOrgVdcDo.builder().orgId(baseOrgParam.getOrgId()).build()); + List orgVdcList = cloudOrgVdcService.getBaseMapper().selectList(orgVdcDoWrapper); + if (!orgVdcList.isEmpty()) { + orgVdcList.stream().forEach(item -> { + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(deleteTime); + item.setDeleteFlag(true); + }); + cloudOrgVdcService.updateBatchById(orgVdcList); + } + } + + + /** + * 组织明显是否拥有云服务器 + * return true:拥有 false:没有云服务器 + */ + private boolean ifHasServerVm(Integer orgId) { + return false; + } + + /** + * canModifyParent(能否修改上级组织) canModifyVdc(能否修改绑定的VDC)限制条件 + * 当前组织是没有下级,并且当前组织下没有任何云服务器, + */ + @Override + public OrgDetailRespDto orgDetail(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo) { + + CloudOrganizationDo cloudOrganizationDo = cloudOrganizationService.getById(baseOrgParam.getOrgId()); + + OrgDetailRespDto orgDetailRespDto = new OrgDetailRespDto(); + orgDetailRespDto.setOrganizationId(cloudOrganizationDo.getId()); + orgDetailRespDto.setOrganizationName(cloudOrganizationDo.getOrganizationName()); + orgDetailRespDto.setRemark(cloudOrganizationDo.getRemark()); + orgDetailRespDto.setParentId(cloudOrganizationDo.getParentId()); + orgDetailRespDto.setParentName(""); + if (!Objects.equals(cloudOrganizationDo.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + CloudOrganizationDo parentOrg = cloudOrganizationService.getById(cloudOrganizationDo.getParentId()); + orgDetailRespDto.setParentName(parentOrg.getOrganizationName()); + } + + //组织和VDC关联 + CloudOrgVdcDo cloudOrgVdcDo = new CloudOrgVdcDo(); + cloudOrgVdcDo.setOrgId(baseOrgParam.getOrgId()); + cloudOrgVdcDo.setDeleteFlag(false); + Wrapper orgVdcDoWrapper = + new QueryWrapper<>(cloudOrgVdcDo); + CloudOrgVdcDo orgVdcDo = cloudOrgVdcService.getOne(orgVdcDoWrapper); + + if (Objects.nonNull(orgVdcDo)) { + CloudVdcDo vdcDo = cloudVdcService.getById(orgVdcDo.getVdcId()); + orgDetailRespDto.setVdcId(vdcDo.getId()); + orgDetailRespDto.setVdcName(vdcDo.getVdcName()); + } + orgDetailRespDto.setCanModifyParent(false); + orgDetailRespDto.setCanModifyVdc(false); + + //是否拥有下级组织 + boolean hasChildOrg = ifHasChildOrg(baseOrgParam.getOrgId()); + if (!hasChildOrg && !Objects.equals(cloudOrganizationDo.getParentId(), + KylinCloudManageConstants.TOP_PARENT_ID)) { + //是否拥有云服务器 + boolean orgHasServerVm = ifHasServerVm(baseOrgParam.getOrgId()); + if (!orgHasServerVm) { + orgDetailRespDto.setCanModifyParent(true); + orgDetailRespDto.setCanModifyVdc(true); + } + } + + CloudUserDo orgLeaderUser = userService.orgLeaderUser(cloudOrganizationDo.getId()); + //组织是否有管理员 + orgDetailRespDto.setHasOrgLeader(Objects.nonNull(orgLeaderUser)); + if (Objects.nonNull(orgLeaderUser)) { + orgDetailRespDto.setOrgLeaderUserId(orgLeaderUser.getId()); + orgDetailRespDto.setOrgLeaderUserName(orgLeaderUser.getUserName()); + orgDetailRespDto.setOrgLeaderRealName(orgLeaderUser.getRealName()); + orgDetailRespDto.setOrgLeaderUserPassword(orgLeaderUser.getPassword()); + } + + + return orgDetailRespDto; + } + + + /** + * 创建组织管理员用户 + */ + private CloudUserDo createLeaderUser(LoginUserVo loginUserVo, + Integer orgId, + String leaderUserName, String leaderRealName, String leaderPassword) { + CloudUserDo cloudUserDo = new CloudUserDo(); + cloudUserDo.setUserName(leaderUserName); + cloudUserDo.setRealName(leaderRealName); + cloudUserDo.setPassword(leaderPassword); + cloudUserDo.setStatus(CloudUserStatus.ACTIVATE); + cloudUserDo.setUserType(UserType.cloudUser); + cloudUserDo.setOrganizationId(orgId); + cloudUserDo.setCreateBy(loginUserVo.getUserId()); + cloudUserDo.setCreateTime(new Date()); + cloudUserDo.setDefaultUser(false); + cloudUserDo.setSuperUser(false); + cloudUserService.save(cloudUserDo); + return cloudUserDo; + } + + @Override + public List orgStatisticTree(LoginUserVo loginUserVo, OrgStatisticTreeType orgTreeType) { + + + //查询全部组织 + List orgDoList = cloudOrganizationService.queryAllOrgList(); + CloudOrganizationDo loginUserOrg = getByUserId(loginUserVo.getUserId()); + List statisticOrgTrees = new ArrayList<>(); + for (CloudOrganizationDo orgDo : orgDoList) { + if (Objects.equals(orgDo.getId(), loginUserOrg.getId())) { + statisticOrgTrees.add(formatStatisticOrgTree(orgDo, orgDoList, orgTreeType)); + } + } + return statisticOrgTrees; + } + + /** + * 封装统计数实体 + */ + private OrgStatisticTreeDto formatStatisticOrgTree(CloudOrganizationDo cloudOrganizationDo, + List allOrgList, + OrgStatisticTreeType orgTreeType) { + + OrgStatisticTreeDto statisticOrgTree = new OrgStatisticTreeDto(); + formatCommonOrgTree(cloudOrganizationDo, allOrgList, statisticOrgTree); + List orgIdList = getOrgChildIdList(cloudOrganizationDo.getId()); + //统计数量 + switch (orgTreeType) { + case USER: + statisticOrgTree.setStatisticNum(userService.statisticOrgUserNumByOrgId(cloudOrganizationDo.getId())); + break; + default: + statisticOrgTree.setStatisticNum(0); + break; + } + statisticOrgTree.setChildren(getStatisticOrgTreeChild(cloudOrganizationDo.getId(), allOrgList, orgTreeType)); + return statisticOrgTree; + } + + + /** + * 获取统计树子组织 + */ + private List getStatisticOrgTreeChild(Integer parentId, List allOrgList, + OrgStatisticTreeType orgTreeType) { + List childList = new ArrayList<>(); + for (CloudOrganizationDo organizationDo : allOrgList) { + if (Objects.equals(parentId, organizationDo.getParentId())) { + OrgStatisticTreeDto statisticOrgTree = formatStatisticOrgTree(organizationDo, allOrgList, orgTreeType); + childList.add(statisticOrgTree); + } + } + return childList; + } + + + @Override + public List getOrgChildIdList(Integer parentOrgId) { + return cloudOrganizationService.listChildOrgByOrgId(parentOrgId).stream().map(CloudOrganizationDo::getId).collect(Collectors.toList()); + } + + + @Override + public CloudOrganizationDo getOrgByVdcId(Integer vdcId) { + CloudOrgVdcDo orgVdcDo = new CloudOrgVdcDo(); + orgVdcDo.setVdcId(vdcId); + orgVdcDo.setDeleteFlag(false); + Wrapper orgVdcDoWrapper = + new QueryWrapper<>(orgVdcDo); + List orgVdcList = cloudOrgVdcService.getBaseMapper().selectList(orgVdcDoWrapper); + return orgVdcList.isEmpty() ? null : cloudOrganizationService.getById(orgVdcList.get(0).getOrgId()); + } + + + @Override + public boolean userHasOrgPermission(Integer userId, Integer orgId) { + CloudRoleDo roleDo = roleService.getUserRole(userId); + if (Objects.isNull(roleDo)) { + return false; + } + CloudUserDo cloudUserDo = cloudUserService.getById(userId); + CloudOrganizationDo orgDo = cloudOrganizationService.getById(cloudUserDo.getOrganizationId()); + if (Objects.equals(roleDo.getRoleType(), RoleType.PLATFORM) || + (Objects.equals(roleDo.getRoleType(), RoleType.ORG) && Objects.equals(orgDo.getParentId(), + KylinCloudManageConstants.TOP_PARENT_ID))) { + return true; + } + + + if (Objects.equals(roleDo.getRoleType(), RoleType.ORG)) { + CloudUserDo userDo = cloudUserService.getById(userId); + CloudOrganizationDo userOrgDo = cloudOrganizationService.getById(userDo.getOrganizationId()); + List childOrgList = cloudOrganizationService.listChildOrgByOrgId(userOrgDo.getId()); + //判断用户子组织列表中是否存在orgId + //存在则说明拥有权限 + CloudOrganizationDo childOrg = + childOrgList.stream().filter(item -> Objects.equals(item.getId(), orgId)).findFirst().orElse(null); + return Objects.nonNull(childOrg); + + } + + return false; + } + + @Override + public CloudOrganizationDo getByUserId(Integer userId) { + CloudUserDo userDo = cloudUserService.getById(userId); + return cloudOrganizationService.getById(userDo.getOrganizationId()); + } + + + @Override + public OrgSummaryRespDto orgSummary(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo) { + CloudVdcDo vdcDo = cloudVdcService.getVdcByOrgId(baseOrgParam.getOrgId()); + + OrgSummaryRespDto orgSummary = new OrgSummaryRespDto(); + CloudOrganizationDo organizationDo = cloudOrganizationService.getById(baseOrgParam.getOrgId()); + orgSummary.setOrgName(organizationDo.getOrganizationName()); + orgSummary.setRemark(organizationDo.getRemark()); + orgSummary.setCreateTime(DateUtils.format(organizationDo.getCreateTime(), DateUtils.DATE_ALL_PATTEN)); + orgSummary.setParentOrgName("-"); + if (!Objects.equals(organizationDo.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + CloudOrganizationDo parentOrg = cloudOrganizationService.getById(organizationDo.getParentId()); + orgSummary.setParentOrgName(parentOrg.getOrganizationName()); + } + + orgSummary.setVdcName(vdcDo.getVdcName()); + List orgIdList = getOrgChildIdList(baseOrgParam.getOrgId()); + + List userDoList = userService.listUserByOrgList(orgIdList, null); + orgSummary.setTotalUser(userDoList.size()); + List activeUserDoList = userService.listUserByOrgList(orgIdList, CloudUserStatus.ACTIVATE); + orgSummary.setActiveUser(activeUserDoList.size()); + orgSummary.setNoActiveUser(userDoList.size() - activeUserDoList.size()); + + + //vdc资源使用情况 + VdcUsedResourceDto vdcResourceDto = vdcService.getVdcResourceInfo(vdcDo.getId(), loginUserVo); + + orgSummary.setTotalCpu(vdcResourceDto.getTotalCpu()); + orgSummary.setAllocationCpu(vdcResourceDto.getUsedCpu()); + orgSummary.setSurplusCpu(orgSummary.getTotalCpu() - orgSummary.getAllocationCpu()); + + orgSummary.setTotalMem(vdcResourceDto.getTotalMem()); + orgSummary.setMemUnit(vdcResourceDto.getMemUnit()); + + orgSummary.setAllocationMem(vdcResourceDto.getUsedMem()); + orgSummary.setSurplusMem(orgSummary.getTotalMem() - orgSummary.getAllocationMem()); + + orgSummary.setTotalStorage(vdcResourceDto.getTotalStorage()); + orgSummary.setStorageUnit(vdcResourceDto.getStorageUnit()); + orgSummary.setAllocationStorage(vdcResourceDto.getUsedStorage()); + orgSummary.setSurplusStorage(orgSummary.getTotalStorage() - orgSummary.getAllocationStorage()); + + + List mcServerVmList = + userMachineService.listUserMachineByUserIdListAndClusterId(0, + userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList()), + loginUserVo.getUserName()); + orgSummary.setMachineTotal(mcServerVmList.size()); + List runningMachine = + mcServerVmList.stream().filter(item -> (Objects.equals(item.getStatus(), McServerVmStatus.CONNECTED) || + Objects.equals(item.getStatus(), McServerVmStatus.SUSPEND) || + Objects.equals(item.getStatus(), McServerVmStatus.INSTALLING) || Objects.equals(item.getStatus(), + McServerVmStatus.AVAILABLE))) + .collect(Collectors.toList()); + orgSummary.setMachineOnline(runningMachine.size()); + orgSummary.setMachineOffline(orgSummary.getMachineTotal() - orgSummary.getMachineOnline()); + + return orgSummary; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/PermissionServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/PermissionServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..d262a45fe3bb13f62e6ea1c12262e9b562acc7c2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/PermissionServiceImpl.java @@ -0,0 +1,104 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.domain.CloudPermissionDo; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.core.domain.CloudRolePermissionDo; +import com.hnkylin.cloud.core.service.CloudPermissionService; +import com.hnkylin.cloud.core.service.CloudRolePermissionService; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.entity.resp.role.PermissionTreeDto; +import com.hnkylin.cloud.manage.mapper.PermissionMapper; +import com.hnkylin.cloud.manage.service.PermissionService; +import com.hnkylin.cloud.manage.service.RoleService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class PermissionServiceImpl implements PermissionService { + + @Resource + private PermissionMapper permissionMapper; + + @Resource + private CloudPermissionService cloudPermissionService; + + + @Override + public List listPermissionByRoleId(Integer roleId) { + return permissionMapper.listPermissionByRoleId(roleId); + } + + + @Override + public List customPlatformRoleMaxPermission() { + + //查询登录用户拥有的权限列表 + List customPlatformRoleMaxPermissionList = + cloudPermissionService.customPlatformRoleMaxPermission(); + + + List permissionTreeDtoList = new ArrayList<>(); + for (CloudPermissionDo permissionDo : customPlatformRoleMaxPermissionList) { + if (Objects.equals(permissionDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + PermissionTreeDto permissionTreeDto = createCustomRolePermissionTreeDto(permissionDo, + customPlatformRoleMaxPermissionList); + if (Objects.nonNull(permissionDo)) { + permissionTreeDtoList.add(permissionTreeDto); + } + + } + } + return permissionTreeDtoList; + } + + /** + * 创建PermissionTree对象 + */ + private PermissionTreeDto createCustomRolePermissionTreeDto(CloudPermissionDo permissionDo, List + customPlatformRoleMaxPermissionList) { + PermissionTreeDto permissionTreeDto = PermissionTreeDto.builder() + .permissionId(permissionDo.getId()).name(permissionDo.getName()) + .parentId(permissionDo.getParentId()).icon(permissionDo.getIcon()) + .routeKey(permissionDo.getRouteKey()).build(); + + + permissionTreeDto.setChildren(getChild(permissionDo.getId(), customPlatformRoleMaxPermissionList)); + return permissionTreeDto; + } + + /** + * 递归创建子权限 + */ + private List getChild(Integer parentId, + List customPlatformRoleMaxPermissionList) { + List childList = new ArrayList<>(); + for (CloudPermissionDo permissionDo : customPlatformRoleMaxPermissionList) { + if (Objects.equals(parentId, permissionDo.getParentId())) { + PermissionTreeDto permissionTreeDto = createCustomRolePermissionTreeDto(permissionDo, + customPlatformRoleMaxPermissionList); + if (Objects.nonNull(permissionTreeDto)) { + childList.add(permissionTreeDto); + } + } + } + return childList; + } + + @Override + public CloudPermissionDo getPermissionByRouteKey(String routeKey) { + CloudPermissionDo cloudPermissionDo = new CloudPermissionDo(); + cloudPermissionDo.setRouteKey(routeKey); + cloudPermissionDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper(cloudPermissionDo); + return cloudPermissionService.getOne(wrapper); + } + + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/RoleServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/RoleServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..6e8df21393a4e67a5f2c82f4f112af92a00245b6 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/RoleServiceImpl.java @@ -0,0 +1,332 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.service.CloudOrganizationService; +import com.hnkylin.cloud.core.service.CloudRolePermissionService; +import com.hnkylin.cloud.core.service.CloudRoleService; +import com.hnkylin.cloud.core.service.CloudUserRoleService; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseRoleConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.org.BaseOrgParam; +import com.hnkylin.cloud.manage.entity.req.role.*; +import com.hnkylin.cloud.manage.entity.resp.role.*; +import com.hnkylin.cloud.manage.mapper.RoleMapper; +import com.hnkylin.cloud.manage.service.OrgService; +import com.hnkylin.cloud.manage.service.PermissionService; +import com.hnkylin.cloud.manage.service.RoleService; +import com.hnkylin.cloud.manage.service.UserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class RoleServiceImpl implements RoleService { + + @Resource + private CloudRoleService cloudRoleService; + + @Resource + private CloudRolePermissionService cloudRolePermissionService; + + @Resource + private CloudUserRoleService cloudUserRoleService; + + @Resource + private PermissionService permissionService; + + @Resource + private RoleMapper roleMapper; + + @Resource + private UserService userService; + + @Resource + private CloudOrganizationService cloudOrganizationService; + + + @Override + @Transactional + public void createPlatformRole(CreateRoleParam createRoleParam, LoginUserVo loginUserVo) { + + + //查询是否同名 + checkIfExistRoleName(createRoleParam.getRoleName()); + + Date now = new Date(); + CloudRoleDo cloudRoleDo = new CloudRoleDo(); + cloudRoleDo.setRoleName(createRoleParam.getRoleName()); + cloudRoleDo.setRemark(createRoleParam.getRemark()); + cloudRoleDo.setRoleType(RoleType.PLATFORM); + cloudRoleDo.setCreateBy(loginUserVo.getUserId()); + cloudRoleDo.setCreateTime(now); + cloudRoleDo.setDefaultRole(false); + cloudRoleService.save(cloudRoleDo); + + //插入角色对应的权限 + cloudRolePermissionService.insertRolePermission(cloudRoleDo.getId(), createRoleParam.getPermissions(), + loginUserVo.getUserId(), now); + } + + /** + * 删除角色 限制条件:没有用户绑定该角色 + * + * @param baseRoleParam + * @param loginUserVo + */ + @Override + @Transactional + public void deleteRole(BaseRoleParam baseRoleParam, LoginUserVo loginUserVo) { + //查询是否有用户绑定该角色 + CloudUserRoleDo userRoleDo = new CloudUserRoleDo(); + userRoleDo.setRoleId(baseRoleParam.getRoleId()); + Wrapper wrapper = new QueryWrapper<>(userRoleDo); + List roleList = cloudUserRoleService.getBaseMapper().selectList(wrapper); + if (!roleList.isEmpty()) { + throw new KylinException(KylinHttpResponseRoleConstants.USER_BIND_ROLE_NOT_DELETE); + } + + Date deleteTime = new Date(); + CloudRoleDo cloudRoleDo = cloudRoleService.getById(baseRoleParam.getRoleId()); + cloudRoleDo.setDeleteFlag(true); + cloudRoleDo.setDeleteBy(loginUserVo.getUserId()); + cloudRoleDo.setDeleteTime(deleteTime); + cloudRoleService.updateById(cloudRoleDo); + + //删除角色拥有的权限 + cloudRolePermissionService.deleteRolePermissionByRole(baseRoleParam.getRoleId(), loginUserVo.getUserId(), + deleteTime); + } + + + /** + * 检查同组织下角色名称是否重复 + * + * @param roleName + */ + private void checkIfExistRoleName(String roleName) { + //判断名称是否已经存在 + CloudRoleDo roleDo = new CloudRoleDo(); + roleDo.setRoleName(roleName); + roleDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(roleDo); + List roleList = cloudRoleService.getBaseMapper().selectList(wrapper); + if (!roleList.isEmpty()) { + throw new KylinException(KylinHttpResponseRoleConstants.EXIST_ROLE_NAME); + } + } + + + @Override + public void modifyRole(ModifyRoleParam modifyRoleParam, LoginUserVo loginUserVo) { + CloudRoleDo cloudRoleDo = cloudRoleService.getById(modifyRoleParam.getRoleId()); + if (!Objects.equals(modifyRoleParam.getRoleName(), cloudRoleDo.getRoleName())) { + checkIfExistRoleName(modifyRoleParam.getRoleName()); + } + Date now = new Date(); + cloudRoleDo.setRoleName(modifyRoleParam.getRoleName()); + cloudRoleDo.setRemark(modifyRoleParam.getRemark()); + cloudRoleDo.setUpdateBy(loginUserVo.getUserId()); + cloudRoleDo.setUpdateTime(now); + + cloudRoleService.updateById(cloudRoleDo); + //删除角色拥有的权限 + cloudRolePermissionService.deleteRolePermissionByRole(cloudRoleDo.getId(), loginUserVo.getUserId(), + now); + //插入角色对应的权限 + cloudRolePermissionService.insertRolePermission(cloudRoleDo.getId(), modifyRoleParam.getPermissions(), + loginUserVo.getUserId(), now); + } + + + @Override + public RoleDetailDto modifyRoleDetail(BaseRoleParam baseRoleParam) { + CloudRoleDo cloudRoleDo = cloudRoleService.getById(baseRoleParam.getRoleId()); + RoleDetailDto detailDto = new RoleDetailDto(); + detailDto.setRoleId(cloudRoleDo.getId()); + detailDto.setRoleName(cloudRoleDo.getRoleName()); + detailDto.setRoleType(cloudRoleDo.getRoleType()); + detailDto.setRemark(cloudRoleDo.getRemark()); + List rolePermissionList = + permissionService.listPermissionByRoleId(baseRoleParam.getRoleId()); + List permissions = + rolePermissionList.stream().map(CloudPermissionDo::getId).collect(Collectors.toList()); + detailDto.setPermissions(permissions); + return detailDto; + } + + @Override + public RoleInfoRespDto roleInfo(BaseRoleParam baseRoleParam) { + CloudRoleDo cloudRoleDo = cloudRoleService.getById(baseRoleParam.getRoleId()); + RoleInfoRespDto roleInfoRespDto = new RoleInfoRespDto(); + roleInfoRespDto.setRoleId(cloudRoleDo.getId()); + roleInfoRespDto.setRoleName(cloudRoleDo.getRoleName()); + roleInfoRespDto.setRoleType(cloudRoleDo.getRoleType()); + roleInfoRespDto.setRemark(cloudRoleDo.getRemark()); + roleInfoRespDto.setPermissionTree(getRolePermission(cloudRoleDo.getId())); + return roleInfoRespDto; + } + + private List getRolePermission(Integer roleId) { + + List rolePermissionList = permissionService.listPermissionByRoleId(roleId); + List permissionTreeDtoList = new ArrayList<>(); + for (CloudPermissionDo permissionDo : rolePermissionList) { + if (Objects.equals(permissionDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + permissionTreeDtoList.add(formatRolePermissionTreeDto(permissionDo, rolePermissionList)); + } + } + return permissionTreeDtoList; + } + + + /** + * 封装RolePermissionTreeDto对象 + */ + private RolePermissionTreeDto formatRolePermissionTreeDto(CloudPermissionDo permissionDo, List + rolePermissionList) { + RolePermissionTreeDto rolePermissionTreeDto = RolePermissionTreeDto.builder() + .permissionId(permissionDo.getId()).name(permissionDo.getName()) + .parentId(permissionDo.getParentId()).icon(permissionDo.getIcon()) + .routeKey(permissionDo.getRouteKey()).build(); + + rolePermissionTreeDto.setChild(getChild(permissionDo.getId(), rolePermissionList)); + return rolePermissionTreeDto; + } + + /** + * 递归创建 + */ + private List getChild(Integer parentId, List rolePermissionList) { + List childList = new ArrayList<>(); + for (CloudPermissionDo permissionDo : rolePermissionList) { + if (Objects.equals(parentId, permissionDo.getParentId())) { + RolePermissionTreeDto rolePermissionTreeDto = formatRolePermissionTreeDto(permissionDo, + rolePermissionList); + childList.add(rolePermissionTreeDto); + } + } + return childList; + } + + + @Override + public List listRole(SearchRoleParam searchRoleParam, LoginUserVo loginUserVo) { + List commonRoleList = new ArrayList<>(); + boolean ifPlatformUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + if (ifPlatformUser) { + CloudRoleDo roleDo = new CloudRoleDo(); + roleDo.setDeleteFlag(false); + QueryWrapper queryWrapper = new QueryWrapper<>(roleDo); + if (StringUtils.isNotBlank(searchRoleParam.getSearchKey())) { + queryWrapper.and(wrapper -> wrapper.like("role_name", searchRoleParam.getSearchKey()) + .or().like("remark", searchRoleParam.getSearchKey())); + } + List roleDoList = cloudRoleService.list(queryWrapper); + CloudOrganizationDo organizationDo = cloudOrganizationService.getById(searchRoleParam.getOrgId()); + roleDoList.forEach(item -> { + CommonRoleDto commonRoleDto = new CommonRoleDto(); + commonRoleDto.setRoleId(item.getId()); + commonRoleDto.setRoleName(item.getRoleName()); + commonRoleDto.setRemark(item.getRemark()); + commonRoleDto.setRoleType(item.getRoleType()); + + //根组织,不能选择组织管理员,不能选择自服务用户 + if (Objects.equals(organizationDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + if (Objects.equals(item.getRoleType(), RoleType.PLATFORM) && !item.getDefaultRole()) { + commonRoleList.add(commonRoleDto); + } + } else { + if (Objects.equals(item.getRoleType(), RoleType.ORG) || Objects.equals(item.getRoleType(), + RoleType.SELF_SERVICE)) { + commonRoleList.add(commonRoleDto); + } + } + }); + } else { + CloudRoleDo selfRole = getSelfServiceRole(); + CommonRoleDto commonRoleDto = new CommonRoleDto(); + commonRoleDto.setRoleId(selfRole.getId()); + commonRoleDto.setRoleName(selfRole.getRoleName()); + commonRoleDto.setRemark(selfRole.getRemark()); + commonRoleDto.setRoleType(selfRole.getRoleType()); + commonRoleList.add(commonRoleDto); + } + return commonRoleList; + } + + @Override + public PageData pageRole(RolePageParam rolePageParam) { + + PageHelper.startPage(rolePageParam.getPageNo(), rolePageParam.getPageSize()); + + List list = roleMapper.pageRole(); + PageInfo pageInfo = new PageInfo<>(list); + + pageInfo.getList().forEach(role -> { + role.setRoleTypeDesc(role.getRoleType().getDesc()); + role.setCanDelete(false); + role.setCanModify(false); + if (!role.getDefaultRole() && Objects.equals(role.getRoleType(), RoleType.PLATFORM)) { + role.setCanDelete(true); + role.setCanModify(true); + } + }); + PageData pageData = new PageData(pageInfo); + return pageData; + } + + + @Override + public CloudRoleDo getSelfServiceRole() { + CloudRoleDo roleDo = new CloudRoleDo(); + roleDo.setDeleteFlag(false); + roleDo.setRoleType(RoleType.SELF_SERVICE); + Wrapper wrapper = new QueryWrapper<>(roleDo); + List listRole = cloudRoleService.list(wrapper); + return listRole.isEmpty() ? null : listRole.get(0); + } + + + @Override + public void allocateRolePermission(AllocateRolePermissionParam allocateRolePermissionParam, + LoginUserVo loginUserVo) { + + + List permissionIds = new ArrayList<>(); + String[] permissionArray = allocateRolePermissionParam.getPermissionIds().split(","); + + for (String s : permissionArray) { + permissionIds.add(Integer.parseInt(s)); + } + //插入角色对应的权限 + cloudRolePermissionService.insertRolePermission(allocateRolePermissionParam.getRoleId(), permissionIds, + loginUserVo.getUserId(), new Date()); + + } + + + @Override + public CloudRoleDo getUserRole(Integer userId) { + //获取用户的角色 + CloudUserRoleDo cloudUserRoleDo = cloudUserRoleService.getUserRoleByUserId(userId); + if (Objects.nonNull(cloudUserRoleDo)) { + return cloudRoleService.getById(cloudUserRoleDo.getRoleId()); + } + return null; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ServerVmServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ServerVmServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e666cbc42957e14a5e9f2ef2713138a3282a63c2 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ServerVmServiceImpl.java @@ -0,0 +1,1085 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.common.servervm.*; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.McStartVmErrorCode; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseServerVmConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.ServerVmOperateLogReq; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmOperateLogPageParam; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmPageParam; +import com.hnkylin.cloud.manage.entity.resp.serverVm.PageServerVmRespDto; +import com.hnkylin.cloud.manage.entity.resp.serverVm.ServerVmZoneOrgTreeRespDto; +import com.hnkylin.cloud.manage.entity.resp.zone.ZoneInfoDto; +import com.hnkylin.cloud.manage.enums.ZoneOrgUserType; +import com.hnkylin.cloud.manage.service.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class ServerVmServiceImpl implements ServerVmService { + + + @Resource + private UserService userService; + + @Resource + private ZoneService zoneService; + + @Resource + private VdcService vdcService; + + @Resource + private OrgService orgService; + + @Resource + private CloudOrganizationService cloudOrganizationService; + + @Resource + private CloudUserMachineService cloudUserMachineService; + + @Resource + private CloudOrgVdcService cloudOrgVdcService; + + + @Resource + private McHttpService mcHttpService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private McClusterThreadService mcClusterThreadService; + + @Resource + private CloudUserService cloudUserService; + + @Resource + private UserMachineService userMachineService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private RoleService roleService; + + @Override + public List serverVmZoneTree(Integer clusterId, LoginUserVo loginUserVo) { + + List loginUserZoneList = zoneService.zoneList(loginUserVo); + if (loginUserZoneList.isEmpty()) { + return new ArrayList<>(); + } + //获取登录用户角色 + CloudRoleDo loginUserRole = roleService.getUserRole(loginUserVo.getUserId()); + boolean platformUser = Objects.equals(loginUserRole.getRoleType(), RoleType.PLATFORM); + List zoneOrgTreeList = new ArrayList<>(); + loginUserZoneList.forEach(zone -> { + + List vdcDoList = new ArrayList<>(); + if (platformUser) { + vdcDoList = cloudVdcService.getFirstVdcListByZone(zone.getZoneId()); + } else { + CloudVdcDo userVdc = vdcService.getUserOrgBindVdc(loginUserVo.getUserId()); + if (Objects.nonNull(userVdc)) { + vdcDoList.add(userVdc); + } + } + ServerVmZoneOrgTreeRespDto zoneOrgDto = new ServerVmZoneOrgTreeRespDto(); + zoneOrgDto.setUniqueId(zone.getZoneId()); + zoneOrgDto.setTreeUniqueId(ZoneOrgUserType.ZONE.name() + "_" + zone.getZoneId()); + zoneOrgDto.setName(zone.getName()); + zoneOrgDto.setType(ZoneOrgUserType.ZONE); + zoneOrgDto.setServerVmCount(0); + List child = new ArrayList<>(); + vdcDoList.forEach(vdc -> { + CloudOrganizationDo organizationDo = orgService.getOrgByVdcId(vdc.getId()); + if (Objects.nonNull(organizationDo)) { + //获取vdc对应的组织 + List orgDoList = cloudOrganizationService.queryAllOrgList(); + List childOrgUser = new ArrayList<>(); + for (CloudOrganizationDo orgDo : orgDoList) { + if (Objects.equals(orgDo.getId(), organizationDo.getId())) { + childOrgUser.add(createZoneOrgObject(clusterId, orgDo, orgDoList, loginUserVo)); + } + } + child.addAll(childOrgUser); + + } + }); + zoneOrgDto.setChild(child); + zoneOrgDto.countServerVmCount(); + + zoneOrgTreeList.add(zoneOrgDto); + }); + return zoneOrgTreeList; + } + + + /** + * 封装可用区组织数实体 + */ + private ServerVmZoneOrgTreeRespDto createZoneOrgObject(Integer clusterId, CloudOrganizationDo cloudOrganizationDo, + List allOrgList, + LoginUserVo loginUserVo) { + ServerVmZoneOrgTreeRespDto serverVmZoneOrgRespDto = new ServerVmZoneOrgTreeRespDto(); + + serverVmZoneOrgRespDto.setUniqueId(cloudOrganizationDo.getId()); + serverVmZoneOrgRespDto.setName(cloudOrganizationDo.getOrganizationName()); + serverVmZoneOrgRespDto.setTreeUniqueId(ZoneOrgUserType.ORG.name() + "_" + cloudOrganizationDo.getId()); + serverVmZoneOrgRespDto.setType(ZoneOrgUserType.ORG); + + List childList = new ArrayList<>(); + List userDoList = userService.listUserByOrgId(cloudOrganizationDo.getId()); + + //判断登录用户是否是组织管理员,是则可以显示该组织全部用户,不是则只能返回自己 + boolean userHasOrgPermission = orgService.userHasOrgPermission(loginUserVo.getUserId(), + cloudOrganizationDo.getId()); + userDoList.forEach(item -> { + ServerVmZoneOrgTreeRespDto zoneUserRespDto = new ServerVmZoneOrgTreeRespDto(); + zoneUserRespDto.setUniqueId(item.getId()); + zoneUserRespDto.setName(item.getRealName()); + if (StringUtils.isBlank(item.getRealName())) { + zoneUserRespDto.setName(item.getUserName()); + } + zoneUserRespDto.setType(ZoneOrgUserType.USER); + zoneUserRespDto.setTreeUniqueId(ZoneOrgUserType.USER.name() + "_" + item.getId()); + zoneUserRespDto.setServerVmCount(countUserMachineNum(clusterId, item.getId(), loginUserVo)); + if (userHasOrgPermission) { + childList.add(zoneUserRespDto); + } else { + if (Objects.equals(item.getId(), loginUserVo.getUserId())) { + childList.add(zoneUserRespDto); + } + } + + }); + List orgChild = getParentChildZoneOrg(cloudOrganizationDo.getId(), allOrgList, + loginUserVo, clusterId); + childList.addAll(orgChild); + serverVmZoneOrgRespDto.setChild(childList); + serverVmZoneOrgRespDto.countServerVmCount(); + return serverVmZoneOrgRespDto; + } + + /** + * 获取云服务器数量 + * + * @param userId + * @param loginUserVo + * @return + */ + private Integer countUserMachineNum(Integer clusterId, Integer userId, LoginUserVo loginUserVo) { + List userIdList = new ArrayList<>(); + userIdList.add(userId); + +// CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); +// cloudUserMachineDo.setDeleteFlag(false); +// QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); +//// if (userIdList.isEmpty()) { +//// return new ArrayList<>(); +//// } +// queryWrapper.in("user_id", userIdList); + + List mcServerVmList = + userMachineService.listUserMachineByUserIdListAndClusterId(clusterId, userIdList, + loginUserVo.getUserName()); + return mcServerVmList.size(); + } + + /** + * 获取可用区-组织下级组织 + */ + private List getParentChildZoneOrg(Integer parentId, + List allOrgList, + LoginUserVo loginUserVo, Integer clusterId) { + List childList = new ArrayList<>(); + for (CloudOrganizationDo organizationDo : allOrgList) { + if (Objects.equals(parentId, organizationDo.getParentId())) { + ServerVmZoneOrgTreeRespDto zoneOrgObject = createZoneOrgObject(clusterId, organizationDo, allOrgList, + loginUserVo); + childList.add(zoneOrgObject); + } + } + return childList; + } + + + @Override + public PageData serverVmList(ServerVmPageParam serverVmPageParam, LoginUserVo loginUserVo) { + List userMachineList = getUserMachineList(serverVmPageParam, loginUserVo); + if (userMachineList.isEmpty()) { + return new PageData(null); + } + + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = + userMachineList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + + if (Objects.equals(clusterUserMachineMap.size(), 1)) { + //单集群 + return singleClusterUserMachine(userMachineList, serverVmPageParam, loginUserVo, + userMachineList.get(0).getClusterId()); + } else { + //多集群 + return manyClusterUserMachine(clusterUserMachineMap, serverVmPageParam, loginUserVo, + userMachineList.size()); + } + } + + /** + * 单个集群获取云服务器列表 + * + * @param userMachineList + * @param serverVmPageParam + * @param loginUserVo + * @return + */ + private PageData singleClusterUserMachine(List userMachineList, + ServerVmPageParam serverVmPageParam, + LoginUserVo loginUserVo, Integer clusterId) { + + List uuidList = + userMachineList.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmListReq serverVmListReq = formatSearchMcServerVmParam(serverVmPageParam, uuidList); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, serverVmListReq, + mcConfigProperties.getServerVmList(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + McPageResp mcServerVmPage = JSONObject.parseObject(serverListTxt, new + TypeReference>() { + }); + List pageServerVmRespDtoList = new ArrayList<>(); + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcServerVmPage.getPager()); + mcPageInfo.setPageSize(mcServerVmPage.getRows().size()); + mcPageInfo.setRecords(mcServerVmPage.getRecords()); + mcPageInfo.setTotal(mcServerVmPage.getTotal()); + + mcServerVmPage.getRows().forEach(mcServerVm -> { + PageServerVmRespDto pageServerVmRespDto = createMcServerVmPageDetail(clusterId, mcServerVm, + userMachineList, loginUserVo); + pageServerVmRespDtoList.add(pageServerVmRespDto); + }); + return new PageData(mcPageInfo, pageServerVmRespDtoList); + } + return new PageData(null); + } + + + /** + * 多集群云云服务器列表 + * + * @param clusterUserMachineMap + * @param serverVmPageParam + * @param loginUserVo + * @return + */ + private PageData manyClusterUserMachine(Map> clusterUserMachineMap, + ServerVmPageParam serverVmPageParam, + LoginUserVo loginUserVo, Integer maxServerVmSize) { + List clusterIdList = new ArrayList<>(); + clusterIdList.addAll(clusterUserMachineMap.keySet()); + List mcRequestObjectList = new ArrayList<>(); + clusterIdList.forEach(clusterId -> { + List uuidList = + clusterUserMachineMap.get(clusterId).stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmListReq serverVmListReq = formatSearchMcServerVmParam(serverVmPageParam, uuidList); + serverVmListReq.setPage(KylinCommonConstants.FIRST_PAGE); + serverVmListReq.setRows(maxServerVmSize); + mcRequestObjectList.add(serverVmListReq); + }); + + List mcServerVmList = mcClusterThreadService.threadGetMcResponse(clusterIdList, + loginUserVo.getUserName(), + mcConfigProperties.getServerVmList(), mcRequestObjectList); + + //多个集群中满足条件的所有的云服务器 + List totalServerVmRespDtoList = new ArrayList<>(); + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(serverVmPageParam.getPageNo()); + for (int i = 0; i < clusterIdList.size(); i++) { + Integer clusterId = clusterIdList.get(i); + String serverVmList = mcServerVmList.get(i); + if (Objects.nonNull(serverVmList)) { + McPageResp mcServerVmPage = JSONObject.parseObject(serverVmList, new + TypeReference>() { + }); + mcServerVmPage.getRows().forEach(mcServerVm -> { + PageServerVmRespDto pageServerVmRespDto = createMcServerVmPageDetail(clusterId, + mcServerVm, clusterUserMachineMap.get(clusterId), loginUserVo); + totalServerVmRespDtoList.add(pageServerVmRespDto); + }); + } + } + mcPageInfo.setTotal(mcPageInfo.getRecords()); + mcPageInfo.setRecords(totalServerVmRespDtoList.size()); + //总页数 + int totalPage = (mcPageInfo.getRecords() - 1) / serverVmPageParam.getPageSize() + 1; + mcPageInfo.setTotal(totalPage); + + //云服务器安装状态排序 + Collections.sort(totalServerVmRespDtoList); + //从所有云服务器列表中,截取页面查询的对应页码的数量 + int totalSize = totalServerVmRespDtoList.size(); + int subListStart = (serverVmPageParam.getPageNo() - 1) * serverVmPageParam.getPageSize(); + int subListEnd = serverVmPageParam.getPageNo() * serverVmPageParam.getPageSize(); + if (totalSize < subListStart) { + return new PageData(null); + } else if (totalSize >= subListStart && totalSize < subListEnd) { + mcPageInfo.setPageSize(totalSize - subListStart); + return new PageData(mcPageInfo, totalServerVmRespDtoList.subList(subListStart, totalSize)); + } else { + mcPageInfo.setPageSize(serverVmPageParam.getPageSize()); + return new PageData(mcPageInfo, totalServerVmRespDtoList.subList(subListStart, subListEnd)); + } + + } + + /** + * 创建云服务器列表数据 + * + * @param clusterId + * @param mcServerVm + * @return + */ + private PageServerVmRespDto createMcServerVmPageDetail(Integer clusterId, McServerVmPageDetailResp mcServerVm, + List userMachineList, + LoginUserVo loginUserVo) { + //根据uuid 过滤,保存起来的用户云服务器。 + CloudUserMachineDo userMachineDo = userMachineList.stream().filter(userMachine -> Objects.equals + (mcServerVm.getUuid(), userMachine.getMachineUuid())).findFirst().orElse(null); + PageServerVmRespDto serverVmRespDto = new PageServerVmRespDto(); + //过滤,防止MC中删除了该云服务器,但是自服务中还保留该用户和云服务器的关联关系 + if (Objects.nonNull(userMachineDo)) { + BeanUtils.copyProperties(mcServerVm, serverVmRespDto); + serverVmRespDto.setServerVmId(mcServerVm.getId()); + serverVmRespDto.setServerVmUuid(mcServerVm.getUuid()); + //设置到期时间 到期时间-当前时间=剩余天数 + serverVmRespDto.setDeadlineTime(DateUtils.differentDaysByMillisecond(new Date(), + userMachineDo.getDeadlineTime())); + serverVmRespDto.setDeadlineFlag(userMachineDo.getDeadlineFlag()); + serverVmRespDto.setCreateDate(DateUtils.format(userMachineDo.getCreateTime(), + DateUtils.DATE_YYYY_MM_DD)); + + + if (userMachineDo.getDeadlineFlag()) { + serverVmRespDto.setStatus(McServerVmStatus.OVERDUE); + } + + serverVmRespDto.setArchitecture(KcpCommonUtil.changeToKcpArchitectureType(mcServerVm.getArchitecture()).getDesc()); + //利用率 + JSONObject usage = new JSONObject(); + if (mcServerVm.getStatus().equals(McServerVmStatus.AVAILABLE) || + mcServerVm.getStatus().equals(McServerVmStatus.SUSPEND) || + mcServerVm.getStatus().equals(McServerVmStatus.INSTALLING) || + mcServerVm.getStatus().equals(McServerVmStatus.CONNECTED)) { + usage.put("cpu", "0"); + usage.put("mem", "0"); + } + if (StringUtils.isNotBlank(mcServerVm.getCpuRate())) { + usage.put("cpu", mcServerVm.getCpuRate().replaceAll("%", "")); + } + if (StringUtils.isNotBlank(mcServerVm.getMemoryRate())) { + usage.put("mem", mcServerVm.getMemoryRate().replaceAll("%", "")); + } + serverVmRespDto.setUsage(usage.toJSONString()); + + CloudClusterDo clusterDo = cloudClusterService.getById(clusterId); + //可用区名称 + CloudZoneDo cloudZoneDo = zoneService.getZoneByClusterId(clusterDo.getId()); + serverVmRespDto.setZoneName(Objects.nonNull(cloudZoneDo) ? cloudZoneDo.getName() : "未知集群"); + //集群名称 + serverVmRespDto.setClusterName(clusterDo.getName()); + //组织名称 + CloudOrganizationDo orgDo = orgService.getByUserId(userMachineDo.getUserId()); + serverVmRespDto.setOrgName(orgDo.getOrganizationName()); + //vdc名称 + CloudVdcDo vdcDo = vdcService.getVdcByOrgId(orgDo.getId()); + serverVmRespDto.setVdcName(Objects.nonNull(vdcDo) ? vdcDo.getVdcName() : "未知VDC"); + //用户名称 + serverVmRespDto.setUserName(loginUserVo.getUserName()); + } + return serverVmRespDto; + } + + /** + * 封装请求mc云服务器列表的参数 + * + * @param serverVmPageParam + * @param uuids + * @return + */ + private ServerVmListReq formatSearchMcServerVmParam(ServerVmPageParam serverVmPageParam, List uuids) { + ServerVmListReq serverVmListReq = new ServerVmListReq(); + serverVmListReq.setPage(serverVmPageParam.getPageNo()); + serverVmListReq.setRows(serverVmPageParam.getPageSize()); + serverVmListReq.setVmName(serverVmPageParam.getSearchKey()); + if (Objects.nonNull(serverVmPageParam.getVmStatus()) && !Objects.equals(McServerVmStatus.OVERDUE, + serverVmPageParam.getVmStatus()) && !Objects.equals(McServerVmStatus.ALL, + serverVmPageParam.getVmStatus())) { + serverVmListReq.setVmStatus(serverVmPageParam.getVmStatus()); + } + serverVmListReq.setUuidList(uuids); + return serverVmListReq; + } + + /** + * 获取用户管理云服务器关系记录 + * + * @param serverVmPageParam + * @param loginUserVo + * @return + */ + private List getUserMachineList(ServerVmPageParam serverVmPageParam, LoginUserVo loginUserVo) { + //查询用户拥有的云服务器uuid + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeleteFlag(false); + //是否过期过滤 + if (Objects.nonNull(serverVmPageParam.getVmStatus()) && !Objects.equals(McServerVmStatus.ALL, + serverVmPageParam.getVmStatus())) { + cloudUserMachineDo.setDeadlineFlag(Objects.equals(McServerVmStatus.OVERDUE, serverVmPageParam.getVmStatus + ())); + } + if (Objects.nonNull(serverVmPageParam.getClusterId()) && serverVmPageParam.getClusterId() > 0) { + cloudUserMachineDo.setClusterId(serverVmPageParam.getClusterId()); + } + + List userIdList = new ArrayList<>(); + if (Objects.equals(serverVmPageParam.getType(), ZoneOrgUserType.ZONE)) { + //查询的是可用区,则查询登录在可用区里可见的用户 + //根据可用区获取可用区下组织ID列表 + List orgIdList = cloudOrgVdcService.orgIdListByZoneId(serverVmPageParam.getUniqueId()); + if (!orgIdList.isEmpty()) { + Set userIdSet = new HashSet<>(); + orgIdList.forEach(orgId -> { + boolean userHasOrgPermission = orgService.userHasOrgPermission(loginUserVo.getUserId(), orgId); + if (userHasOrgPermission) { + List userDoList = userService.listUserByOrgId(orgId); + userIdSet.addAll(userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toSet())); + } else { + userIdSet.add(loginUserVo.getUserId()); + } + }); + userIdList.addAll(userIdSet); + } + } else if (Objects.equals(serverVmPageParam.getType(), ZoneOrgUserType.ORG)) { + //判断登录用户是否是组织管理员,是则可以显示该组织全部用户,不是则只能返回自己 + boolean userHasOrgPermission = orgService.userHasOrgPermission(loginUserVo.getUserId(), + serverVmPageParam.getUniqueId()); + if (userHasOrgPermission) { + List orgIdList = orgService.getOrgChildIdList(serverVmPageParam.getUniqueId()); + List userDoList = userService.listUserByOrgList(orgIdList, null); + userIdList = userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList()); + } else { + userIdList.add(loginUserVo.getUserId()); + } + + } + if (Objects.equals(serverVmPageParam.getType(), ZoneOrgUserType.USER)) { + userIdList.add(serverVmPageParam.getUniqueId()); + } + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + if (userIdList.isEmpty()) { + return new ArrayList<>(); + } + queryWrapper.in("user_id", userIdList); + + return cloudUserMachineService.list(queryWrapper); + } + + + /** + * 检查云服务器是否过期 + */ + private void checkUserMachineIfOverdue(String serverVmUuid) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setMachineUuid(serverVmUuid); + QueryWrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + + CloudUserMachineDo queryDo = cloudUserMachineService.getOne(wrapper); + if (Objects.isNull(queryDo)) { + throw new KylinException(KylinHttpResponseServerVmConstants.OPERATE_ERR); + } + if (queryDo.getDeadlineFlag()) { + throw new KylinException(KylinHttpResponseServerVmConstants.SERVERVM_OVERDUE_NOT_OPERATE); + } + } + + /** + * 根据云服务器uuid获取用户云服务器关联关系 + * + * @param uuid + * @return + */ + private CloudUserMachineDo getUserMachineByUuid(String uuid) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setMachineUuid(uuid); + QueryWrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + CloudUserMachineDo queryDo = cloudUserMachineService.getOne(wrapper); + return queryDo; + } + + + @Override + public McStartVmErrorCode startServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + checkUserMachineIfOverdue(serverVmBaseParam.getServerVmUuid()); + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, mcConfigProperties.getStartServerVmUrl(), loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + return McStartVmErrorCode.SUCCESS; + } + String error = JSON.parseObject(JSON.toJSONString(mcResponse.getData())).getString("errorCode"); + McStartVmErrorCode errorCode = McStartVmErrorCode.valueOf(error); + return errorCode; + } + + /** + * 单台云服务器操作 + * + * @param serverVmBaseParam + * @param loginUserVo + * @param httpUrl + * @return + */ + private boolean commonSingleOperate(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo, String httpUrl) { + checkUserMachineIfOverdue(serverVmBaseParam.getServerVmUuid()); + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + return mcHttpService.noDataCommonMcRequest(userMachineDo.getClusterId(), serverVmBaseReq, + httpUrl, loginUserVo.getUserName(), 0); + } + + @Override + public boolean shutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getShutdownServerVmUrl()); + } + + @Override + public boolean forcedShutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getForcedShutdownServerVmUrl()); + } + + @Override + public boolean restartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getRestartServerVmUrl()); + } + + @Override + public boolean forcedRestartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getForcedRestartServerVmUrl()); + } + + + /** + * 云服务器操作,批量开机/批量关机/批量重启/ + */ + private BaseResult serverVmBatchOperateToMc(ServerVmBatchOperateParam serverVmBatchOperateParam, LoginUserVo + loginUserVo, String httpUrl) { + + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = groupByClusterId(serverVmBatchOperateParam); + int clusterMachineMapSize = clusterUserMachineMap.size(); + //选择的云服务器是通一个集群中 + if (Objects.equals(clusterMachineMapSize, 1)) { + CloudUserMachineDo userMachineDo = + getUserMachineByUuid(serverVmBatchOperateParam.getServerVmUuids().get(0)); + boolean singleClusterBatchOperate = singleClusterBatchOperate(serverVmBatchOperateParam, loginUserVo, + httpUrl + , userMachineDo.getClusterId()); + if (singleClusterBatchOperate) { + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseServerVmConstants.OPERATE_ERR); + } else { + //选择的云服务器是不同的集群 + List failedClusterList = manyClusterBatchOperate(clusterUserMachineMap, loginUserVo, httpUrl); + if (failedClusterList.isEmpty()) { + return BaseResult.success(null); + } + StringBuilder manyClusterFailedMsg = new StringBuilder(); + failedClusterList.forEach(clusterId -> { + CloudClusterDo failedCluster = cloudClusterService.getById(clusterId); + manyClusterFailedMsg.append(failedCluster.getName()).append(",") + .append(KylinHttpResponseServerVmConstants.BATCH_OPERATE_ERR).append(";"); + }); + return BaseResult.error(manyClusterFailedMsg.toString()); + } + } + + /** + * 针对单个云服务器单个操作。 + * + * @param serverVmBatchOperateParam + * @param loginUserVo + * @param httpUrl + * @param clusterId + * @return + */ + private boolean singleClusterBatchOperate(ServerVmBatchOperateParam serverVmBatchOperateParam, LoginUserVo + loginUserVo, String httpUrl, Integer clusterId) { + ServerVmBatchReq serverVmBatchReq = new ServerVmBatchReq(); + serverVmBatchReq.setUuid(String.join(",", serverVmBatchOperateParam.getServerVmUuids())); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, serverVmBatchReq, httpUrl + , loginUserVo.getUserName(), 0); + return Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus()); + + } + + + /** + * 针对多个集群中的批量操作 + * + * @param clusterUserMachineMap + * @param loginUserVo + * @param httpUrl + * @return + */ + private List manyClusterBatchOperate(Map> clusterUserMachineMap, + LoginUserVo + loginUserVo, String httpUrl) { + List clusterIdList = new ArrayList<>(); + clusterIdList.addAll(clusterUserMachineMap.keySet()); + List mcRequestObjectList = new ArrayList<>(); + clusterIdList.forEach(clusterId -> { + List uuidList = + clusterUserMachineMap.get(clusterId).stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmBatchReq serverVmBatchReq = new ServerVmBatchReq(); + serverVmBatchReq.setUuid(String.join(",", uuidList)); + mcRequestObjectList.add(serverVmBatchReq); + }); + List> manyClusterBatchOperateResponse = + mcClusterThreadService.threadSendToMc(clusterIdList, + loginUserVo.getUserName(), + httpUrl, mcRequestObjectList); + + //操作失败的集群 + List failedClusterList = new ArrayList<>(); + for (int i = 0; i < clusterIdList.size(); i++) { + MCResponseData mcResponse = manyClusterBatchOperateResponse.get(i); + if (Objects.isNull(mcResponse) || Objects.equals(mcResponse.getStatus(), MCServerVmConstants.ERROR)) { + failedClusterList.add(clusterIdList.get(i)); + } + } + return failedClusterList; + } + + @Override + public BaseResult batchStartServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + return serverVmBatchOperateToMc(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchStartServerVmUrl()); + } + + + @Override + public BaseResult batchShutdownServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + return serverVmBatchOperateToMc(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchShutdownServerVmUrl()); + } + + @Override + public BaseResult batchRebootServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + return serverVmBatchOperateToMc(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchRebootServerVmUrl()); + } + + /** + * 根据集群ID,将批量操作进行分组 + * + * @param serverVmBatchOperateParam + * @return + */ + private Map> groupByClusterId(ServerVmBatchOperateParam serverVmBatchOperateParam) { + //根据云服务器列表,进行分类 + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + QueryWrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + wrapper.in("machine_uuid", serverVmBatchOperateParam.getServerVmUuids()); + List machineList = cloudUserMachineService.list(wrapper); + + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = + machineList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + return clusterUserMachineMap; + } + + /** + * 批量删除用户云服务器关联关系 + * + * @param loginUserVo + * @param userMachineUuidList + */ + private void deleteUserMachine(LoginUserVo loginUserVo, List userMachineUuidList) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + QueryWrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + wrapper.in("machine_uuid", userMachineUuidList); + List machineList = cloudUserMachineService.list(wrapper); + if (!machineList.isEmpty()) { + Date deleteTime = new Date(); + machineList.forEach(userMachine -> { + userMachine.setDeleteFlag(true); + userMachine.setDeleteBy(loginUserVo.getUserId()); + userMachine.setDeleteTime(deleteTime); + }); + cloudUserMachineService.updateBatchById(machineList); + } + } + + @Override + public BaseResult deleteServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + List serverVmUuids = new ArrayList(); + serverVmUuids.add(serverVmBaseParam.getServerVmUuid()); + ServerVmBatchOperateParam serverVmBatchOperateParam = new ServerVmBatchOperateParam(); + serverVmBatchOperateParam.setServerVmUuids(serverVmUuids); + + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + + boolean deleteFlag = singleClusterBatchOperate(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchRemoveMachineToRecycleUrl(), userMachineDo.getClusterId()); + //mc中成功将云服务器放入回收站后,将用户用户拥有的云服务器逻辑删除 + if (deleteFlag) { + deleteUserMachine(loginUserVo, serverVmUuids); + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseServerVmConstants.OPERATE_ERR); + } + + + @Override + @Transactional + public BaseResult batchDeleteServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + + Map> clusterUserMachineMap = groupByClusterId(serverVmBatchOperateParam); + if (Objects.equals(clusterUserMachineMap.size(), 1)) { + CloudUserMachineDo userMachineDo = + getUserMachineByUuid(serverVmBatchOperateParam.getServerVmUuids().get(0)); + boolean deleteFlag = singleClusterBatchOperate(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchRemoveMachineToRecycleUrl(), userMachineDo.getClusterId()); + //mc中成功将云服务器放入回收站后,将用户用户拥有的云服务器逻辑删除 + if (deleteFlag) { + deleteUserMachine(loginUserVo, serverVmBatchOperateParam.getServerVmUuids()); + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseServerVmConstants.OPERATE_ERR); + } else { + //选择的云服务器是不同的集群 + List failedClusterList = manyClusterBatchOperate(clusterUserMachineMap, loginUserVo, + mcConfigProperties.getBatchRemoveMachineToRecycleUrl()); + if (failedClusterList.isEmpty()) { + deleteUserMachine(loginUserVo, serverVmBatchOperateParam.getServerVmUuids()); + return BaseResult.success(null); + } + //将操作成功的集群中的,用户云服务器管理关系删除 + List deleteSuccessUuid = new ArrayList<>(); + clusterUserMachineMap.forEach((clusterId, value) -> { + if (!failedClusterList.contains(clusterId)) { + List deleteSuccessClusterUuid = + value.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + deleteSuccessUuid.addAll(deleteSuccessClusterUuid); + } + }); + if (!deleteSuccessUuid.isEmpty()) { + deleteUserMachine(loginUserVo, deleteSuccessUuid); + } + StringBuilder manyClusterFailedMsg = new StringBuilder(); + failedClusterList.forEach(clusterId -> { + CloudClusterDo failedCluster = cloudClusterService.getById(clusterId); + manyClusterFailedMsg.append(failedCluster.getName()).append(",") + .append(KylinHttpResponseServerVmConstants.BATCH_OPERATE_ERR).append(";"); + }); + } + return BaseResult.error(KylinHttpResponseServerVmConstants.OPERATE_ERR); + } + + @Override + public VncUrlDto getVncUrl(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + VncUrlDto vncUrlDto = new VncUrlDto(); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + String httpUrl = mcConfigProperties.getServerVmVncUrl(); + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, + httpUrl, loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + vncUrlDto = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), VncUrlDto.class); + + } + return vncUrlDto; + } + + + @Override + public KcpServerVmDetailResp serverVmInfo(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, + mcConfigProperties.getServerVmInfoUrl(), loginUserVo.getUserName(), 0); + KcpServerVmDetailResp kcpServerVmDetailResp = new KcpServerVmDetailResp(); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + kcpServerVmDetailResp = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), + KcpServerVmDetailResp.class); + CloudUserDo userDo = cloudUserService.getById(userMachineDo.getUserId()); + kcpServerVmDetailResp.setUserName(userDo.getRealName()); + CloudOrganizationDo organizationDo = cloudOrganizationService.getById(userDo.getOrganizationId()); + kcpServerVmDetailResp.setOrgName(organizationDo.getOrganizationName()); + + } + return kcpServerVmDetailResp; + } + + + @Override + public KcpServerVmSummaryResp serverVmSummary(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, mcConfigProperties.getServerVmSummaryUrl(), loginUserVo.getUserName(), 0); + KcpServerVmSummaryResp summary = new KcpServerVmSummaryResp(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + summary = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), KcpServerVmSummaryResp.class); + summary.setMemoryTotal(summary.getMemoryTotal().divide(new BigDecimal(1024)).setScale(0, + BigDecimal.ROUND_HALF_UP)); + summary.setMemoryUsed(summary.getMemoryUsed().divide(new BigDecimal(1024)).setScale(0, + BigDecimal.ROUND_HALF_UP)); + summary.setMemorySurplus(summary.getMemoryTotal().subtract(summary.getMemoryUsed())); + + summary.setDiskSurplus(summary.getDiskTotal().subtract(summary.getDiskTotalUsed())); + + } + return summary; + } + + @Override + public List serverVmAlarmEvent(ServerVmBaseParam serverVmBaseParam, + LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, + mcConfigProperties.getServerVmAlarmEventUrl(), loginUserVo.getUserName(), 0); + List alarmEventList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + alarmEventList = JSON.parseArray(JSONArray.toJSONString(mcResponse.getData()), + KcpServerVmAlarmEventResp.class); + } + return alarmEventList; + } + + @Override + public List serverVmNetwork(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, mcConfigProperties.getServerVmNetworkUrl(), loginUserVo.getUserName(), 0); + + List networkList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + networkList = JSON.parseArray(JSONArray.toJSONString(mcResponse.getData()), KcpServerVmNetworkResp.class); + } + return networkList; + } + + @Override + public List serverVmDisk(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, mcConfigProperties.getServerVmDiskUrl(), loginUserVo.getUserName(), 0); + + List diskList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + diskList = JSON.parseArray(JSONArray.toJSONString(mcResponse.getData()), KcpServerVmDiskResp.class); + } + return diskList; + } + + @Override + public ServerVmMonitorInfoRespDto serverVmMonitor(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmBaseParam.getServerVmUuid()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, mcConfigProperties.getServerVmMonitorInfoUrl(), loginUserVo.getUserName(), 0); + + ServerVmMonitorInfoRespDto serverVmMonitorInfoRespDto = new ServerVmMonitorInfoRespDto(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + List mcServerVmMonitorDetailList = new ArrayList<>(); + String serverVmMonitorTxt = JSON.toJSONString(mcResponse.getData()); + mcServerVmMonitorDetailList = JSON.parseArray(serverVmMonitorTxt, McServerVmMonitorDetailResp.class); + List timeList = new ArrayList<>(); + List cpuUsed = new ArrayList<>(); + List memUsed = new ArrayList(); + List diskReadSpeed = new ArrayList(); + List diskWriteSpeed = new ArrayList(); + List netWorkInSpeed = new ArrayList(); + List netWorkOutSpeed = new ArrayList(); + + if (!mcServerVmMonitorDetailList.isEmpty()) { + + mcServerVmMonitorDetailList.forEach(monitor -> { + timeList.add(monitor.getDateShow()); + cpuUsed.add(monitor.getCpuUtil()); + memUsed.add(monitor.getMemUtil()); + diskReadSpeed.add(monitor.getDiskReadSpeed()); + diskWriteSpeed.add(monitor.getDiskWriteSpeed()); + netWorkInSpeed.add(monitor.getNetWorkInSpeed()); + netWorkOutSpeed.add(monitor.getNetWorkOutSpeed()); + }); + serverVmMonitorInfoRespDto.setTimeList(timeList); + serverVmMonitorInfoRespDto.setCpuUsed(cpuUsed); + serverVmMonitorInfoRespDto.setMemUsed(memUsed); + serverVmMonitorInfoRespDto.setDiskReadSpeed(diskReadSpeed); + serverVmMonitorInfoRespDto.setDiskWriteSpeed(diskWriteSpeed); + serverVmMonitorInfoRespDto.setNetWorkInSpeed(netWorkInSpeed); + serverVmMonitorInfoRespDto.setNetWorkOutSpeed(netWorkOutSpeed); + } + } + + return serverVmMonitorInfoRespDto; + + } + + @Override + public PageData serverVmOperateLog(ServerVmOperateLogPageParam serverVmOperateLogPageParam, + LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmOperateLogPageParam.getServerVmUuid()); + PageData pageData = new PageData(null); + + + ServerVmOperateLogReq serverVmOperateLogReq = new ServerVmOperateLogReq(); + serverVmOperateLogReq.setUuid(serverVmOperateLogPageParam.getServerVmUuid()); + serverVmOperateLogReq.setPage(serverVmOperateLogPageParam.getPageNo()); + serverVmOperateLogReq.setRows(serverVmOperateLogPageParam.getPageSize()); + + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmOperateLogReq, mcConfigProperties.getServerVmOperateLogUrl(), loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + McPageResp mcServerLogPageResp = JSONObject.parseObject(serverListTxt, new + TypeReference>() { + }); + + if (Objects.nonNull(mcServerLogPageResp)) { + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcServerLogPageResp.getPager()); + mcPageInfo.setPageSize(mcServerLogPageResp.getRows().size()); + mcPageInfo.setRecords(mcServerLogPageResp.getRecords()); + mcPageInfo.setTotal(mcServerLogPageResp.getTotal()); + List mcServerVmLogList = new ArrayList<>(); + mcServerVmLogList = mcServerLogPageResp.getRows(); + pageData = new PageData(mcPageInfo, mcServerVmLogList); + + } + } + + return pageData; + } + + @Override + public ResponseEntity downLoadServerVmLog(String mcServerVmLogoPath, String mcServerVmLogoName, + String serverVmUuid) { + + try { + String localFilePath = mcConfigProperties.getMcLogoLocalFilePath() + mcServerVmLogoName; + File file = new File(localFilePath); + if (!file.exists()) { + String encodeName = URLEncoder.encode(mcServerVmLogoName, "UTF-8"); + CloudUserMachineDo userMachineDo = getUserMachineByUuid(serverVmUuid); + List mcNodeList = cloudClusterService.formatClusterNodeList(userMachineDo.getClusterId()); + + String mcDownLoadUrl = mcNodeList.get(0) + mcConfigProperties.getMcPrefix() + + mcConfigProperties.getLogoPath() + encodeName; + file = HttpUtil.downLoadMcServerVmLogo(mcDownLoadUrl, localFilePath); + } + byte[] imageContent; + imageContent = fileToByte(file); + + final HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.IMAGE_PNG); + return new ResponseEntity<>(imageContent, headers, HttpStatus.OK); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static byte[] fileToByte(File img) throws Exception { + byte[] bytes = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + BufferedImage bi; + bi = ImageIO.read(img); + ImageIO.write(bi, "png", baos); + bytes = baos.toByteArray(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + baos.close(); + } + return bytes; + } + +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/UserMachineServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/UserMachineServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..33764e6280b858c50ffb0e82642d0ea4c7459d91 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/UserMachineServiceImpl.java @@ -0,0 +1,190 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.common.servervm.McServerVmPageDetailResp; +import com.hnkylin.cloud.core.common.servervm.ServerVmListReq; +import com.hnkylin.cloud.core.domain.CloudRoleDo; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.service.CloudUserMachineService; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.servervm.ServerVmPageParam; +import com.hnkylin.cloud.manage.entity.resp.serverVm.PageServerVmRespDto; +import com.hnkylin.cloud.manage.service.*; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class UserMachineServiceImpl implements UserMachineService { + + @Resource + private CloudUserMachineService cloudUserMachineService; + + @Resource + private UserService userService; + + @Resource + private McHttpService mcHttpService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private McClusterThreadService mcClusterThreadService; + + @Resource + private RoleService roleService; + + @Override + public boolean userHasMachine(Integer userId) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setUserId(userId); + cloudUserMachineDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + int existUserCount = cloudUserMachineService.getBaseMapper().selectCount(wrapper); + return existUserCount > 0; + } + + @Override + public Integer countUserMachineByUserIdList(List userIdList) { + + return listUserMachineByUserIdList(userIdList).size(); + } + + @Override + public List listUserMachineByUserIdList(List userIdList) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeleteFlag(false); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + queryWrapper.in("user_id", userIdList); + return cloudUserMachineService.list(queryWrapper); + } + + @Override + public List listUserMachineByUserIdListAndClusterId(Integer clusterId, + List userIdList, + String userName) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeleteFlag(false); + if (Objects.nonNull(clusterId) && clusterId > 0) { + cloudUserMachineDo.setClusterId(clusterId); + } + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + if (userIdList.isEmpty()) { + return new ArrayList<>(); + } + queryWrapper.in("user_id", userIdList); + List userMachineList = cloudUserMachineService.list(queryWrapper); + + List list = new ArrayList<>(); + if (!userMachineList.isEmpty()) { + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = + userMachineList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + + if (Objects.equals(clusterUserMachineMap.size(), 1)) { + //单集群 + List uuidList = + userMachineList.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmListReq serverVmListReq = formatSearchMcServerVmParam(uuidList); + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(userMachineList.get(0).getClusterId(), serverVmListReq, + mcConfigProperties.getServerVmList(), userName, 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, + mcResponse.getStatus())) { + McPageResp mcServerVmPage = + JSONObject.parseObject(JSON.toJSONString(mcResponse.getData()), new + TypeReference>() { + }); + list = mcServerVmPage.getRows(); + } + } else { + //多集群 + list = manyClusterUserMachine(clusterUserMachineMap, userName, userMachineList.size()); + } + } + return list; + } + + /** + * 封装请求mc云服务器列表的参数 + * + * @param uuids + * @return + */ + private ServerVmListReq formatSearchMcServerVmParam(List uuids) { + ServerVmListReq serverVmListReq = new ServerVmListReq(); + serverVmListReq.setPage(KylinCloudManageConstants.FIRST_PAGE); + serverVmListReq.setRows(uuids.size()); + serverVmListReq.setUuidList(uuids); + return serverVmListReq; + } + + /** + * 多集群中获取云服务器列表 + * + * @param clusterUserMachineMap + * @param maxServerVmSize + * @return + */ + private List manyClusterUserMachine(Map> clusterUserMachineMap, + String userName, Integer maxServerVmSize) { + List clusterIdList = new ArrayList<>(); + clusterIdList.addAll(clusterUserMachineMap.keySet()); + List mcRequestObjectList = new ArrayList<>(); + clusterIdList.forEach(clusterId -> { + List uuidList = + clusterUserMachineMap.get(clusterId).stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmListReq serverVmListReq = formatSearchMcServerVmParam(uuidList); + serverVmListReq.setRows(maxServerVmSize); + mcRequestObjectList.add(serverVmListReq); + }); + + List mcServerVmList = mcClusterThreadService.threadGetMcResponse(clusterIdList, userName, + mcConfigProperties.getServerVmList(), mcRequestObjectList); + + List mcVmList = new ArrayList<>(); + for (int i = 0; i < clusterIdList.size(); i++) { + String serverVmList = mcServerVmList.get(i); + if (Objects.nonNull(serverVmList)) { + McPageResp mcServerVmPage = JSONObject.parseObject(serverVmList, new + TypeReference>() { + }); + mcVmList.addAll(mcServerVmPage.getRows()); + } + } + return mcVmList; + + } + + @Override + public List userVisibleUserMachineList(Integer userId) { + //查询用户拥有的云服务器uuid + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeleteFlag(false); + //是否是平台管理用户 + boolean platformUser = userService.judgeIfPlatformUser(userId); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + if (platformUser) { + return cloudUserMachineService.list(queryWrapper); + } + List visibleUserList = userService.userVisibleUserList(userId); + if (visibleUserList.isEmpty()) { + return new ArrayList<>(); + } + queryWrapper.in("user_id", visibleUserList.stream().map(CloudUserDo::getId).collect(Collectors.toList())); + return cloudUserMachineService.list(queryWrapper); + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/UserServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/UserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..91c74602480554975babb8ca8c16d8823b56e429 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/UserServiceImpl.java @@ -0,0 +1,560 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.JwtUtil; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.RoleType; +import com.hnkylin.cloud.core.enums.UserType; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.constant.CloudManageRedisConstant; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseUserConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.req.user.*; +import com.hnkylin.cloud.manage.entity.req.workorder.LoginUserParam; +import com.hnkylin.cloud.manage.entity.resp.*; +import com.hnkylin.cloud.manage.entity.resp.user.*; +import com.hnkylin.cloud.manage.mapper.PermissionMapper; +import com.hnkylin.cloud.manage.mapper.RoleMapper; +import com.hnkylin.cloud.manage.mapper.UserMachineMapper; +import com.hnkylin.cloud.manage.mapper.UserMapper; +import com.hnkylin.cloud.manage.service.*; +import com.hnkylin.cloud.manage.service.cache.LoginUserCacheService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@Service +public class UserServiceImpl implements UserService { + @Resource + private CloudUserService cloudUserService; + + @Resource + private LoginUserCacheService loginUserCacheService; + + @Resource + private CloudOrganizationService cloudOrganizationService; + + @Resource + private PermissionMapper permissionMapper; + + @Resource + private CloudUserRoleService cloudUserRoleService; + + @Resource + private CloudRoleService cloudRoleService; + + @Resource + private UserMachineService userMachineService; + + @Resource + private UserMachineMapper userMachineMapper; + + @Resource + private UserMapper userMapper; + + @Resource + private RoleService roleService; + + @Resource + private OrgService orgService; + + @Resource + private RoleMapper roleMapper; + + @Resource + private PermissionService permissionService; + + @Resource + private CloudRolePermissionService cloudRolePermissionService; + + @Override + public TokenRespDto login(LoginUserParam loginUserParam) { + CloudUserDo cloudUserDo = cloudUserService.queryUserByUserName(loginUserParam.getUserName()); + if (Objects.isNull(cloudUserDo)) { + throw new KylinException(KylinHttpResponseUserConstants.NOT_EXIST_USER); + } + if (!Objects.equals(loginUserParam.getPassword(), cloudUserDo.getPassword())) { + throw new KylinException(KylinHttpResponseUserConstants.PASSWORD_ERR); + } + if (Objects.equals(cloudUserDo.getStatus(), CloudUserStatus.NO_ACTIVATE)) { + throw new KylinException(KylinHttpResponseUserConstants.USER_NOT_ACTIVATE); + } + if (Objects.equals(cloudUserDo.getUserType(), UserType.selfServiceUser)) { + throw new KylinException(KylinHttpResponseUserConstants.SELF_SERVICE_USER_NOT_LOGIN); + } + //登录成功,生成token + String token = + JwtUtil.sign(cloudUserDo.getUserName(), cloudUserDo.getId().toString(), KylinCloudManageConstants + .KYLIN_TOKEN_SECRET); + + //同一用户互斥登录 + Object cacheToken = loginUserCacheService.vGet(CloudManageRedisConstant.UID + cloudUserDo.getId()); + if (Objects.nonNull(cacheToken)) { + loginUserCacheService.vDelete(CloudManageRedisConstant.UID + cloudUserDo.getId()); + loginUserCacheService.vDelete(cacheToken.toString()); + } + + //设置token缓存有效时间 + loginUserCacheService.vSet(token, cloudUserDo.getId(), CloudManageRedisConstant + .CLOUD_MANAGE_LOGIN_USER_CACHE_EXPIRE, + TimeUnit.MILLISECONDS); + loginUserCacheService.vSet(CloudManageRedisConstant.UID + cloudUserDo.getId(), token, + CloudManageRedisConstant.CLOUD_MANAGE_LOGIN_USER_CACHE_EXPIRE, TimeUnit.MILLISECONDS); + + + TokenRespDto tokenRespDto = new TokenRespDto(); + tokenRespDto.setToken(token); + return tokenRespDto; + } + + @Override + public void loginOut(LoginUserVo loginUserVo) { + Object cacheToken = loginUserCacheService.vGet(CloudManageRedisConstant.UID + loginUserVo.getUserId()); + if (Objects.nonNull(cacheToken)) { + loginUserCacheService.vDelete(CloudManageRedisConstant.UID + loginUserVo.getUserId()); + loginUserCacheService.vDelete(cacheToken.toString()); + } + } + + @Override + public UserInfoRespDto userInfo(LoginUserVo loginUserVo) { + UserInfoRespDto userInfoRespDto = new UserInfoRespDto(); + CloudUserDo cloudUserDo = cloudUserService.getById(loginUserVo.getUserId()); + userInfoRespDto.setUserName(cloudUserDo.getUserName()); + userInfoRespDto.setRealName(cloudUserDo.getRealName()); + userInfoRespDto.setMobile(cloudUserDo.getMobile()); + userInfoRespDto.setRemark(cloudUserDo.getRemark()); + CloudOrganizationDo cloudOrganizationDo = cloudOrganizationService.getById(cloudUserDo.getOrganizationId()); + userInfoRespDto.setOrganizationName(cloudOrganizationDo.getOrganizationName()); + userInfoRespDto.setOrganizationId(cloudOrganizationDo.getId()); + userInfoRespDto.setUserId(cloudUserDo.getId()); + //获取用户的角色 + CloudUserRoleDo cloudUserRoleDo = cloudUserRoleService.getUserRoleByUserId(loginUserVo.getUserId()); + + List userPermissions = + permissionMapper.rolePermissionByRoleId(cloudUserRoleDo.getRoleId()); + userInfoRespDto.setPermissions(userPermissions); + userInfoRespDto.setTopUser(judgeIfPlatformUser(loginUserVo.getUserId())); + userInfoRespDto.setSuperUser(cloudUserDo.getSuperUser()); + return userInfoRespDto; + } + + + @Override + public void resetPassword(LoginUserVo loginUserVo, ResetPasswordParam resetPasswordParam) { + CloudUserDo cloudUserDo = cloudUserService.getById(loginUserVo.getUserId()); + if (!Objects.equals(cloudUserDo.getPassword(), resetPasswordParam.getOldPassword())) { + throw new KylinException(KylinCloudManageConstants.OLD_PASSWORD_ERR); + } + cloudUserDo.setPassword(resetPasswordParam.getNewPassword()); + cloudUserService.updateById(cloudUserDo); + } + + @Override + public Integer statisticOrgUserNumByOrgId(Integer orgId) { + CloudUserDo userDo = new CloudUserDo(); + userDo.setOrganizationId(orgId); + userDo.setDeleteFlag(false); + userDo.setStatus(CloudUserStatus.ACTIVATE); + Wrapper wrapper = new QueryWrapper<>(userDo); + Integer userCount = cloudUserService.getBaseMapper().selectCount(wrapper); + return userCount; + } + + @Override + public Integer statisticOrgUserNumByOrgIdList(List orgIdList) { + CloudUserDo userDo = new CloudUserDo(); + userDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(userDo); + wrapper.in("organization_id", orgIdList); + Integer userCount = cloudUserService.getBaseMapper().selectCount(wrapper); + return userCount; + } + + + /** + * 查询真实姓名,组织查询用户 + */ + private CloudUserDo getUserByRealNameAndOrg(Integer orgId, String realName) { + CloudUserDo userDo = new CloudUserDo(); + userDo.setRealName(realName); + userDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(userDo); + List cloudUserDoList = cloudUserService.getBaseMapper().selectList(wrapper); + return cloudUserDoList.isEmpty() ? null : cloudUserDoList.get(0); + } + + + @Override + @Transactional + public void createUser(CreateUserParam createUserParam, LoginUserVo loginUserVo) { + //验证用户名是否重复 + CloudUserDo userDo = new CloudUserDo(); + userDo.setUserName(createUserParam.getUserName()); + userDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(userDo); + int existUserCount = cloudUserService.getBaseMapper().selectCount(wrapper); + if (existUserCount > 0) { + throw new KylinException(KylinHttpResponseUserConstants.EXIST_USER); + } + //验证通组织下真实姓名是否重复 + CloudUserDo existUser = getUserByRealNameAndOrg(createUserParam.getOrganizationId(), + createUserParam.getRealName()); + if (Objects.nonNull(existUser)) { + throw new KylinException(KylinHttpResponseUserConstants.EXIST_REAI_NAME); + } + CloudRoleDo roleDo = cloudRoleService.getById(createUserParam.getRoleId()); + //验证组织管理员是否已经存在 + if (Objects.equals(roleDo.getRoleType(), RoleType.ORG)) { + CloudUserDo orgLeaderUser = orgLeaderUser(createUserParam.getOrganizationId()); + if (Objects.nonNull(orgLeaderUser)) { + throw new KylinException(KylinHttpResponseUserConstants.ORG_EXIST_LEADER_USER); + } + } + Date now = new Date(); + CloudUserDo createUserDo = CloudUserDo.builder(). + userName(createUserParam.getUserName()).realName(createUserParam.getRealName()) + .password(createUserParam.getPassword()).mobile(createUserParam.getMobile()).defaultUser(false).superUser(false) + .remark(createUserParam.getRemark()).status(createUserParam.getStatus()).userType(UserType.cloudUser). + organizationId(createUserParam.getOrganizationId()) + .build(); + + if (Objects.equals(roleDo.getRoleType(), RoleType.SELF_SERVICE)) { + createUserDo.setUserType(UserType.selfServiceUser); + } + createUserDo.setCreateBy(loginUserVo.getUserId()); + createUserDo.setCreateTime(now); + cloudUserService.save(createUserDo); + + //插入用户角色关系 + CloudUserRoleDo cloudUserRoleDo = CloudUserRoleDo.builder().userId(createUserDo.getId()) + .roleId(createUserParam.getRoleId()).build(); + cloudUserRoleDo.setCreateBy(loginUserVo.getUserId()); + cloudUserRoleDo.setCreateTime(now); + cloudUserRoleService.save(cloudUserRoleDo); + } + + + @Override + @Transactional + public void modifyUser(ModifyUserParam modifyUserParam, LoginUserVo loginUserVo) { + + CloudUserDo cloudUserDo = cloudUserService.getById(modifyUserParam.getUserId()); + if (!Objects.equals(modifyUserParam.getRealName(), cloudUserDo.getRealName())) { + //验证通组织下真实姓名是否重复 + CloudUserDo existUser = getUserByRealNameAndOrg(modifyUserParam.getOrganizationId(), + modifyUserParam.getRealName()); + if (Objects.nonNull(existUser)) { + throw new KylinException(KylinHttpResponseUserConstants.EXIST_REAI_NAME); + } + } + Date updateTime = new Date(); + cloudUserDo.setRealName(modifyUserParam.getRealName()); + cloudUserDo.setRemark(modifyUserParam.getRemark()); + cloudUserDo.setMobile(modifyUserParam.getMobile()); + cloudUserDo.setPassword(modifyUserParam.getPassword()); + cloudUserDo.setOrganizationId(modifyUserParam.getOrganizationId()); + cloudUserDo.setStatus(modifyUserParam.getStatus()); + cloudUserDo.setUpdateBy(loginUserVo.getUserId()); + cloudUserDo.setUpdateTime(updateTime); + cloudUserService.updateById(cloudUserDo); + + //查询用户角色 + CloudUserRoleDo userRoleDo = cloudUserRoleService.getUserRoleByUserId(cloudUserDo.getId()); + //如果角色不一样,则更新用户拥有的角色 + if (!Objects.equals(userRoleDo.getRoleId(), modifyUserParam.getRoleId())) { + userRoleDo.setRoleId(modifyUserParam.getRoleId()); + userRoleDo.setUpdateBy(loginUserVo.getUserId()); + userRoleDo.setUpdateTime(updateTime); + cloudUserRoleService.updateById(userRoleDo); + } + } + + @Override + public ModifyUserInfoRespDto modifyUserInfo(BaseUserParam baseUserParam) { + ModifyUserInfoRespDto modifyUserInfoRespDto = new ModifyUserInfoRespDto(); + CloudUserDo cloudUserDo = cloudUserService.getById(baseUserParam.getUserId()); + modifyUserInfoRespDto.setUserId(cloudUserDo.getId()); + modifyUserInfoRespDto.setUserName(cloudUserDo.getUserName()); + modifyUserInfoRespDto.setRealName(cloudUserDo.getRealName()); + modifyUserInfoRespDto.setPassword(cloudUserDo.getPassword()); + modifyUserInfoRespDto.setRemark(cloudUserDo.getRemark()); + modifyUserInfoRespDto.setMobile(cloudUserDo.getMobile()); + + modifyUserInfoRespDto.setOrganizationId(cloudUserDo.getOrganizationId()); + CloudOrganizationDo cloudOrganizationDo = cloudOrganizationService.getById(cloudUserDo.getOrganizationId()); + modifyUserInfoRespDto.setOrganizationName(cloudOrganizationDo.getOrganizationName()); + modifyUserInfoRespDto.setStatus(cloudUserDo.getStatus()); + + //获取用户角色 + CloudUserRoleDo userRoleDo = cloudUserRoleService.getUserRoleByUserId(cloudUserDo.getId()); + CloudRoleDo roleDo = cloudRoleService.getById(userRoleDo.getRoleId()); + modifyUserInfoRespDto.setRoleName(roleDo.getRoleName()); + modifyUserInfoRespDto.setRoleId(roleDo.getId()); + modifyUserInfoRespDto.setCanModifyOrg(false); + modifyUserInfoRespDto.setCanModifyRole(false); + modifyUserInfoRespDto.setRoleType(roleDo.getRoleType()); + if (Objects.equals(roleDo.getRoleType(), RoleType.ORG)) { + modifyUserInfoRespDto.setCanModifyOrg(true); + modifyUserInfoRespDto.setCanModifyRole(true); + } else if (Objects.equals(roleDo.getRoleType(), RoleType.SELF_SERVICE)) { + boolean userHasMachine = userMachineService.userHasMachine(baseUserParam.getUserId()); + modifyUserInfoRespDto.setCanModifyOrg(!userHasMachine); + modifyUserInfoRespDto.setCanModifyRole(false); + } + + + return modifyUserInfoRespDto; + } + + + /** + * 删除用户 + * 限制条件:用户名下有云服务器, + * + * @param baseUserParam + * @param loginUserVo + */ + @Override + @Transactional + public void deleteUser(BaseUserParam baseUserParam, LoginUserVo loginUserVo) { + boolean userHasMachine = userMachineService.userHasMachine(baseUserParam.getUserId()); + if (userHasMachine) { + throw new KylinException(KylinHttpResponseUserConstants.USER_HAS_MACHINE_NO_DELETE); + } + + Date deleteTime = new Date(); + CloudUserDo cloudUserDo = cloudUserService.getById(baseUserParam.getUserId()); + cloudUserDo.setDeleteFlag(true); + cloudUserDo.setDeleteBy(loginUserVo.getUserId()); + cloudUserDo.setDeleteTime(deleteTime); + cloudUserService.updateById(cloudUserDo); + + //查询用户角色 + CloudUserRoleDo userRoleDo = cloudUserRoleService.getUserRoleByUserId(cloudUserDo.getId()); + //如果角色不一样,则更新用户拥有的角色 + if (Objects.nonNull(userRoleDo)) { + userRoleDo.setDeleteFlag(true); + userRoleDo.setDeleteBy(loginUserVo.getUserId()); + userRoleDo.setDeleteTime(deleteTime); + cloudUserRoleService.updateById(userRoleDo); + } + } + + + @Override + @Transactional + public void batchDeleteUser(BatchDeleteUserParam batchDeleteUserParam, LoginUserVo loginUserVo) { + + //根据用户ID,获取用户具有的虚拟机给个数 + List userMachineCounts = + userMachineMapper.userMachineCountGroupByUserId(batchDeleteUserParam.getUserIds()); + if (!userMachineCounts.isEmpty()) { + List realNames = + userMachineCounts.stream().map(UserMachineCountDto::getRealName).collect(Collectors.toList()); + String realNameStr = String.join(",", realNames); + throw new KylinException(realNameStr + "," + KylinHttpResponseUserConstants.USER_HAS_MACHINE_NO_DELETE); + } + + Date deleteTime = new Date(); + CloudUserDo userDo = new CloudUserDo(); + userDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(userDo); + wrapper.in("id", batchDeleteUserParam.getUserIds()); + List userList = cloudUserService.getBaseMapper().selectList(wrapper); + userList.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(deleteTime); + }); + if (!userList.isEmpty()) { + cloudUserService.updateBatchById(userList); + } + + //删除用户拥有的角色 + CloudUserRoleDo userRoleDo = new CloudUserRoleDo(); + userRoleDo.setDeleteFlag(false); + QueryWrapper userRoleWrapper = new QueryWrapper<>(userRoleDo); + userRoleWrapper.in("user_id", batchDeleteUserParam.getUserIds()); + List userRoleDoList = cloudUserRoleService.getBaseMapper().selectList(userRoleWrapper); + + userRoleDoList.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(deleteTime); + }); + if (!userRoleDoList.isEmpty()) { + cloudUserRoleService.updateBatchById(userRoleDoList); + } + } + + @Override + public PageData pageUser(PageUserParam pageUserParam, LoginUserVo loginUserVo) { + //List orgIdList = orgService.getOrgChildIdList(pageUserParam.getOrgId()); + List orgIdList = new ArrayList<>(); + orgIdList.add(pageUserParam.getOrgId()); + PageHelper.startPage(pageUserParam.getPageNo(), pageUserParam.getPageSize()); + List list = userMapper.pageUser(orgIdList, pageUserParam.getSearchKey()); + PageInfo pageInfo = new PageInfo<>(list); + list.forEach(item -> { + //内置用户不能编辑不能删除 + if (item.getDefaultUser()) { + item.setCanDeleteUser(false); + item.setCanModifyUser(false); + } + //自己删除和修改自己 + if (Objects.equals(item.getUserId(), loginUserVo.getUserId())) { + item.setCanDeleteUser(false); + item.setCanModifyUser(false); + } + }); + PageData pageData = new PageData(pageInfo); + return pageData; + } + +// @Override +// public boolean judgeUserHasTopPermission(Integer userId) { +//// CloudRoleDo roleDo = roleService.getUserRole(userId); +//// if (Objects.isNull(roleDo)) { +//// return false; +//// } +//// //判断用户是否拥有 +//// +//// CloudOrganizationDo orgDo = cloudOrganizationService.getById(roleDo.getOrgId()); +//// if (Objects.equals(roleDo.getRoleType(), RoleType.SYSTEM) || +//// (Objects.equals(roleDo.getRoleType(), RoleType.ORG) && Objects.equals(orgDo.getParentId(), +//// KylinCloudManageConstants.TOP_PARENT_ID))) { +//// return true; +//// } +// return false; +// } + + @Override + public List listUserByOrgId(Integer orgId) { + CloudUserDo userDo = new CloudUserDo(); + userDo.setDeleteFlag(false); + userDo.setOrganizationId(orgId); + userDo.setStatus(CloudUserStatus.ACTIVATE); + Wrapper wrapper = new QueryWrapper<>(userDo); + return cloudUserService.getBaseMapper().selectList(wrapper); + } + + @Override + public List listUserByOrgList(List orgIdList, CloudUserStatus userStatus) { + CloudUserDo userDo = new CloudUserDo(); + userDo.setDeleteFlag(false); + if (Objects.nonNull(userStatus)) { + userDo.setStatus(userStatus); + } + QueryWrapper wrapper = new QueryWrapper<>(userDo); + wrapper.in("organization_id", orgIdList); + return cloudUserService.getBaseMapper().selectList(wrapper); + } + + /** + * 根据用户ID获取该用户可见的用户列表 + * + * @param userId + * @return + */ + @Override + public List userVisibleUserList(Integer userId) { + + List userDoList = new ArrayList<>(); + + CloudUserDo userDo = cloudUserService.getById(userId); + //获取用户角色 + CloudRoleDo roleDo = roleService.getUserRole(userId); + if (Objects.isNull(roleDo)) { + userDoList.add(userDo); + return userDoList; + } + //组织管理员,可用用户为该组织及子组织下用户 + if (Objects.equals(roleDo.getRoleType(), RoleType.ORG)) { + return listUserByOrgIdIncludeChildOrg(userDo.getOrganizationId()); + } + + //角色类型是平台管理,判断用户是否用管理用户的权限,有全部用户为可见用户。 + boolean hasManageUserPermission = userHasManageUserPermission(userId); + if (hasManageUserPermission) { + CloudUserDo queryUserDo = new CloudUserDo(); + userDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(queryUserDo); + return cloudUserService.list(wrapper); + } + userDoList.add(userDo); + return userDoList; + } + + @Override + public boolean userHasManageUserPermission(Integer userId) { + + return judgeUserHasRouteKeyPermission(userId, KylinCloudManageConstants.MANAGE_USER_PERMISSION); + } + + @Override + public boolean judgeUserHasRouteKeyPermission(Integer userId, String routeKey) { + //获取用户角色 + CloudRoleDo roleDo = roleService.getUserRole(userId); + //查询用户管理全新 + CloudPermissionDo manageUserPermission = + permissionService.getPermissionByRouteKey(KylinCloudManageConstants.MANAGE_USER_PERMISSION); + //查询角色是否拥有用户管理权限 + CloudRolePermissionDo queryRolePermissionDo = new CloudRolePermissionDo(); + queryRolePermissionDo.setRoleId(roleDo.getId()); + queryRolePermissionDo.setPermissionId(manageUserPermission.getId()); + QueryWrapper queryWrapper = new QueryWrapper(queryRolePermissionDo); + return !cloudRolePermissionService.list(queryWrapper).isEmpty(); + } + + @Override + public List listUserByOrgIdIncludeChildOrg(Integer orgId) { + List childOrgList = orgService.getOrgChildIdList(orgId); + CloudUserDo userDo = new CloudUserDo(); + userDo.setDeleteFlag(false); + QueryWrapper queryWrapper = new QueryWrapper<>(userDo); + queryWrapper.in("organization_id", childOrgList); + return cloudUserService.list(queryWrapper); + } + + @Override + public Integer countSelfServiceUserByOrgList(List orgIdList) { + + return null; + } + + + @Override + public CloudUserDo orgLeaderUser(Integer orgId) { + Integer orgLeaderUserId = roleMapper.getOrgUserIdList(orgId); + if (Objects.nonNull(orgLeaderUserId)) { + + return cloudUserService.getById(orgLeaderUserId); + } + return null; + } + + @Override + public boolean judgeIfPlatformUser(Integer userId) { + //获取登录用户角色 + CloudRoleDo loginUserRole = roleService.getUserRole(userId); + return Objects.equals(loginUserRole.getRoleType(), RoleType.PLATFORM); + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/VdcServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/VdcServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9905328d68f67e2fbbe10dbbf43c191f3a130fed --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/VdcServiceImpl.java @@ -0,0 +1,1952 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.*; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseVdcConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.QueryVdcUsedResourceParam; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterBaseResource; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterServerResourceResp; +import com.hnkylin.cloud.manage.entity.req.cluster.BaseClusterParam; +import com.hnkylin.cloud.manage.entity.req.org.BaseOrgParam; +import com.hnkylin.cloud.manage.entity.req.vdc.*; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.resp.vdc.*; +import com.hnkylin.cloud.manage.mapper.NetworkMapper; +import com.hnkylin.cloud.manage.mapper.VdcMapper; +import com.hnkylin.cloud.manage.service.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +@Slf4j +public class VdcServiceImpl implements VdcService { + + @Resource + private CloudOrgVdcService cloudOrgVdcService; + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private McHttpService mcHttpService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private VdcMapper vdcMapper; + + @Resource + private CloudVdcCpuService cloudVdcCpuService; + + @Resource + private CloudVdcMemService cloudVdcMemService; + + @Resource + private CloudVdcStorageService cloudVdcStorageService; + + @Resource + private McClusterThreadService mcClusterThreadService; + + @Resource + private CloudNetworkConfigService cloudNetworkConfigService; + + + @Resource + private UserService userService; + + + @Resource + private CloudZoneService cloudZoneService; + + @Resource + private NetworkConfigService networkConfigService; + + @Resource + private NetworkMapper networkMapper; + + @Resource + private RoleService roleService; + + @Resource + private OrgService orgService; + + + @Resource + private ClusterService clusterService; + + @Resource + private UserMachineService userMachineService; + + @Resource + private CloudWorkOrderService cloudWorkOrderService; + + @Resource + private CloudWorkOrderVdcService cloudWorkOrderVdcService; + + @Resource + private CloudWorkOrderVdcCpuMemService cloudWorkOrderVdcCpuMemService; + + @Resource + private CloudOrganizationService cloudOrganizationService; + + + @Override + public List queryNotBindVdcByParentOrgId(BaseOrgParam baseOrgParam, LoginUserVo loginUserVo) { + + List vdcDetailList = new ArrayList<>(); + + + CloudOrganizationDo parentOrg = cloudOrganizationService.getById(baseOrgParam.getOrgId()); + Integer parentVdcId = 0; + //如果父组织是顶级组织,则获取父ID==0的vdc + //如果父组织不是顶级组织,则获取父组织对应的vdc的下级未绑定的VDC + if (Objects.equals(parentOrg.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + parentVdcId = 0; + } else { + CloudOrgVdcDo orgVdcDo = cloudOrgVdcService.queryOrgVdcByOrgId(baseOrgParam.getOrgId()); + if (Objects.isNull(orgVdcDo)) { + return vdcDetailList; + } + parentVdcId = orgVdcDo.getVdcId(); + } + vdcDetailList = vdcMapper.getNotBindVdcListByParentId(parentVdcId); + vdcDetailList.stream().forEach(item -> { + + item.setAllocationCpu(cloudVdcCpuService.totalCpuByVdcId(item.getVdcId())); + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(item.getVdcId()); + item.setAllocationDisk(vdcTotalStorage.getStorage()); + + CloudVdcMemDo vdcTotalMemDo = cloudVdcMemService.totalMemByVdcId(item.getVdcId()); + + item.setAllocationMem(vdcTotalMemDo.getMem()); + }); + return vdcDetailList; + } + + + @Override + public McClusterBaseResource queryClusterBaseResource(BaseClusterParam baseClusterParam, LoginUserVo loginUserVo) { + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(baseClusterParam.getClusterId(), + null, mcConfigProperties.getMcClusterBaseResourceUrl(), loginUserVo.getUserName(), 0); + + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + log.info("McClusterBaseResource-:" + serverListTxt); + } + return null; + } + + + @Override + public List vdcTreeByZone(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo) { + //获取可用区下可以绑定的上级VDC列表 + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + queryVdcDo.setZoneId(baseZoneParam.getZoneId()); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + vdcWrapper.orderByAsc("id"); + List vdcList = cloudVdcService.getBaseMapper().selectList(vdcWrapper); + + List parentVdcList = new ArrayList<>(); + + if (vdcList.isEmpty()) { + return parentVdcList; + } + //用户是否是平台管理用户 + boolean platformUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + + if (platformUser) { + //如果是系统管理员,则可查询当前可用区下全部VDC + for (CloudVdcDo vdcDo : vdcList) { + if (Objects.equals(vdcDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + parentVdcList.add(formatZoneVdcTree(vdcDo, vdcList)); + } + } + + } else { + //如果不是系统管理员, 只是组织管理员,则只能查询当前可用区下,登录用户拥有测VDC + //查询登录用户对应的VDC + CloudVdcDo loginUserVdc = getUserOrgBindVdc(loginUserVo.getUserId()); + if (Objects.nonNull(loginUserVdc)) { + for (CloudVdcDo vdcDo : vdcList) { + if (Objects.equals(vdcDo.getId(), loginUserVdc.getId())) { + parentVdcList.add(formatZoneVdcTree(vdcDo, vdcList)); + } + } + } + } + return parentVdcList; + } + + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构-封装组织数据 + */ + private ParentVdcRespDto formatZoneVdcTree(CloudVdcDo vdcDo, + List vdcList) { + ParentVdcRespDto parentVdcRespDto = new ParentVdcRespDto(); + createZoneVdcTreeDto(vdcDo, vdcList, parentVdcRespDto); + parentVdcRespDto.setChildren(getZoneChildVdc(vdcDo.getId(), vdcList)); + return parentVdcRespDto; + } + + /** + * 根据vdc获取下级vdc列表 + */ + private List getZoneChildVdc(Integer parentId, List vdcList) { + List childList = new ArrayList<>(); + for (CloudVdcDo vdcDo : vdcList) { + if (Objects.equals(parentId, vdcDo.getParentId())) { + ParentVdcRespDto vdcRespDto = formatZoneVdcTree(vdcDo, vdcList); + childList.add(vdcRespDto); + } + } + return childList; + } + + /** + * 创建vdc树形结构实体 + * + * @param vdcDo + * @param vdcList + * @param commonVdcTreeRespDto + */ + private void createZoneVdcTreeDto(CloudVdcDo vdcDo, + List vdcList, + CommonVdcTreeRespDto commonVdcTreeRespDto) { + commonVdcTreeRespDto.setVdcId(vdcDo.getId()); + commonVdcTreeRespDto.setVdcName(vdcDo.getVdcName()); + commonVdcTreeRespDto.setParentId(vdcDo.getParentId()); + commonVdcTreeRespDto.setParentName(""); + CloudVdcDo parentDo = + vdcList.stream().filter(item -> Objects.equals(item.getId(), vdcDo.getParentId())).findFirst().orElse(null); + if (Objects.nonNull(parentDo)) { + commonVdcTreeRespDto.setParentName(parentDo.getVdcName()); + } + commonVdcTreeRespDto.setVcpu(cloudVdcCpuService.totalCpuByVdcId(vdcDo.getId())); + + CloudVdcMemDo vdcTotalMemDo = cloudVdcMemService.totalMemByVdcId(vdcDo.getId()); + commonVdcTreeRespDto.setMem(vdcTotalMemDo.getMem()); + commonVdcTreeRespDto.setMemUnit(vdcTotalMemDo.getMemUnit()); + + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(vdcDo.getId()); + commonVdcTreeRespDto.setStorage(vdcTotalStorage.getStorage()); + commonVdcTreeRespDto.setStorageUnit(vdcTotalStorage.getUnit()); + } + + + /** + * 检查可用区下上级VDC能否被绑定 + * 规则:如果上级VDC为0: 检查可用区是否被背的VDC绑定,如果已绑定则提示 不能绑定该可用区, + * 如果上级VDC不为0 检查该条VDC连是否已超过最多5级的限制 + * 能绑定:返回上级VDC的资源情况 + * + * @param checkCreateVdcParam + * @param loginUserVo + * @return + */ + @Override + public VdcResourceRespDto checkCreateVdc(CheckCreateVdcParam checkCreateVdcParam, LoginUserVo loginUserVo) { + + + if (Objects.equals(checkCreateVdcParam.getParentVdcId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + + //校验用户是否拥有创建一级VDC权限 + //获取登录用户角色 + boolean topUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + if (!topUser) { + throw new KylinException(KylinHttpResponseVdcConstants.NOT_PERMISSION_CREATE_FIRST_VDC); + } + //如果上级VDC为0: 则说明是一级VDC,做不限制资源分陪 + return createZoneResource(checkCreateVdcParam.getZoneId(), loginUserVo); + } + //如果上级VDC不为0 检查该条VDC连是否已超过最多5级的限制 + boolean exceedVdcTire = checkExceedTire(checkCreateVdcParam.getParentVdcId()); + if (exceedVdcTire) { + throw new KylinException(KylinHttpResponseVdcConstants.VDC_EXCEED_TIER); + } + return createVdcResource(checkCreateVdcParam.getParentVdcId(), loginUserVo); + } + + /** + * 检查可用区是否被绑定 + * + * @param zoneId + * @return + */ + private boolean checkZoneIfBind(Integer zoneId) { + + //获取可用区下可以绑定的上级VDC列表 + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + queryVdcDo.setZoneId(zoneId); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + List vdcList = cloudVdcService.getBaseMapper().selectList(vdcWrapper); + + return !vdcList.isEmpty(); + } + + /** + * 检查是否超出5级的限制 + * + * @param parentVdcId + * @return + */ + private boolean checkExceedTire(Integer parentVdcId) { + int vdcTire = getVdcTire(parentVdcId, 1); + return vdcTire >= KylinHttpResponseVdcConstants.VDC_MAX_TIRE; + } + + + /** + * 地柜获取VDC的层数 + * + * @param vdcId + * @param tire + * @return + */ + private int getVdcTire(Integer vdcId, int tire) { + CloudVdcDo vdcDo = cloudVdcService.getById(vdcId); + if (!Objects.equals(vdcDo.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + tire++; + return getVdcTire(vdcDo.getParentId(), tire); + } else { + return tire; + } + } + + + /** + * 创建上级VDC的资源池对象 + * VDC已使用资源=直接挂在本级VDC(组织)下用户云服务器占用资源+已分配给下级VDC的资源 + * + * @param parentVdcId + * @return + */ + private VdcResourceRespDto createVdcResource(Integer parentVdcId, LoginUserVo loginUserVo) { + VdcResourceRespDto vdcResourceRespDto = new VdcResourceRespDto(); + + + //获取直接挂在本级VDC(组织)下用户云服务器占用资源 + VdcSameLevelUserUsedResourceRespDto vdcSameLevelUserUseResource = getVdcSameLevelUserUseResource(parentVdcId, + loginUserVo); + + //总存储 + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(parentVdcId); + vdcResourceRespDto.setStorageUnit(vdcTotalStorage.getUnit()); + //获取已分配给下级VDC的存储 + CloudVdcStorageDo childVdcStorage = cloudVdcStorageService.getChildVdcTotalStorage(parentVdcId); + //本级VDC用户直接使用存储资源 + Integer sameVdcUserUsedStorage = Objects.nonNull(vdcSameLevelUserUseResource) ? + vdcSameLevelUserUseResource.getUsedStorage() : 0; + //可用存储=vdc总存储-本级VDC用户直接使用存储资源-已分配给下级VDC存储 + vdcResourceRespDto.setUsableStorage(vdcTotalStorage.getStorage() - childVdcStorage.getStorage() - sameVdcUserUsedStorage); + //已使用存储=本级VDC用户直接使用存储资源+已分配给下级VDC存储 + vdcResourceRespDto.setUsedStorage(childVdcStorage.getStorage() + sameVdcUserUsedStorage); + vdcResourceRespDto.setTotalStorage(vdcTotalStorage.getStorage()); + //遍历架构获取架构资源 + List architectureTypeList = Arrays.asList(ArchitectureType.values()); + List architectureResourceList = new ArrayList<>(); + architectureTypeList.forEach(architectureType -> { + + //获取本级VDC用户直接使用该架构资源 + VdcSameLevelUserUsedArchitectureResourceRespDto sameUserUsedArchitectureResource = + Objects.isNull(vdcSameLevelUserUseResource) ? null : + vdcSameLevelUserUseResource.getUserUsedArchitectureResourceList().stream(). + filter(item -> Objects.equals(item.getArchitectureType(), architectureType)).findFirst().orElse(null); + + //VDC总CPU + Integer totalCpu = cloudVdcCpuService.totalCpuByVdcIdAndArchitectureType(parentVdcId, + architectureType); + + if (Objects.nonNull(totalCpu)) { + VdcArchitectureResourceRespDto vdcArchitectureResource = new VdcArchitectureResourceRespDto(); + vdcArchitectureResource.setArchitectureType(architectureType); + + //已分配给下级CPU + Integer childCpuTotal = cloudVdcCpuService.totalChildVdcCpuByParentIdAndArchitectureType(parentVdcId, + architectureType); + //本级VDC用户直接使用CPU + Integer sameVdcUserUsedCpu = Objects.nonNull(sameUserUsedArchitectureResource) ? + sameUserUsedArchitectureResource.getUsedVcpu() : 0; + //剩余可用CPU=总cpu-本级VDC用户直接使用cpu-已分配给下级cpu + vdcArchitectureResource.setUsableVcpu(totalCpu - childCpuTotal - sameVdcUserUsedCpu); + //已使用CPU=本级VDC用户直接使用cpu+已分配给下级cpu + vdcArchitectureResource.setUsedCpu(childCpuTotal + sameVdcUserUsedCpu); + vdcArchitectureResource.setTotalCpu(totalCpu); + //VDC总内存 + CloudVdcMemDo totalMem = cloudVdcMemService.totalMemByVdcIdAndArchitectureType(parentVdcId, + architectureType); + //已分配给下级VDC存储 + CloudVdcMemDo childTotalMem = + cloudVdcMemService.totalChildVdcMemByParentIdAndArchitectureType(parentVdcId, + architectureType); + + //本级VDC用户直接使用mem + Integer sameVdcUserUsedMem = Objects.nonNull(sameUserUsedArchitectureResource) ? + sameUserUsedArchitectureResource.getUsedMem() : 0; + + vdcArchitectureResource.setMemUnit(totalMem.getMemUnit()); + //剩余可用内存=总内存-本级VDC用户直接使用内存-已分配给下级内存 + vdcArchitectureResource.setUsableMem(totalMem.getMem() - childTotalMem.getMem() - sameVdcUserUsedMem); + //已使用内存=本级VDC用户直接使用内存+已分配给下级内存 + vdcArchitectureResource.setUsedMem(childTotalMem.getMem() + sameVdcUserUsedMem); + vdcArchitectureResource.setTotalMem(totalMem.getMem()); + architectureResourceList.add(vdcArchitectureResource); + } + + }); + vdcResourceRespDto.setArchitectureResourceList(architectureResourceList); + + + return vdcResourceRespDto; + } + + + /** + * 创建可用区中资源 + * 根据可用区获取集群列表,分别获取获取集群中的资源 + * + * @param zoneId + * @return + */ + private VdcResourceRespDto createZoneResource(Integer zoneId, LoginUserVo loginUserVo) { + + // + VdcResourceRespDto zoneResource = new VdcResourceRespDto(); + //可用区下所有物理集群资源和 + VdcResourceRespDto zoneClusterResource = new VdcResourceRespDto(); + List clusterDoList = cloudClusterService.listClusterBYZoneId(zoneId); + if (!clusterDoList.isEmpty()) { + if (clusterDoList.size() == 1) { + McClusterBaseResource mcClusterBaseResource = + clusterService.getMcClusterBaseResource(clusterDoList.get(0), + loginUserVo.getUserName()); + zoneClusterResource = changeMcClusterBaseResourceToVdcResource(mcClusterBaseResource); + } else { + zoneClusterResource = threadGetMcBaseResource(clusterDoList, loginUserVo.getUserName()); + } + } + + zoneResource.setUsableStorage(zoneClusterResource.getUsableStorage()); + zoneResource.setStorageUnit(zoneClusterResource.getStorageUnit()); + List zoneArchitectureResourceList = + zoneClusterResource.getArchitectureResourceList(); + zoneResource.setArchitectureResourceList(zoneArchitectureResourceList); + return zoneResource; + } + + + /** + * 获取直接挂在本级VDC(组织)下用户已使用资源 + * + * @param vdcId + * @param loginUserVo + * @return + */ + private VdcSameLevelUserUsedResourceRespDto getVdcSameLevelUserUseResource(Integer vdcId, LoginUserVo loginUserVo) { + + //获取VDC对应组织 + CloudOrganizationDo organizationDo = orgService.getOrgByVdcId(vdcId); + if (Objects.isNull(organizationDo)) { + return null; + } + //获取组织下用户列表 + List userDoList = userService.listUserByOrgId(organizationDo.getId()); + if (userDoList.isEmpty()) { + return null; + } + + //用户用户拥有的云服务器关联关系 + List userMachineDoList = + userMachineService.listUserMachineByUserIdList(userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList())); + if (userMachineDoList.isEmpty()) { + return null; + } + //请求mc 获取这些云服务器 所占用的资源(cpu,内存,存储) + //将用户云服务器进行分组 + Map> clusterUserMachineMap = + userMachineDoList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + if (clusterUserMachineMap.size() == 1) { + //如果是只有一个集群有云服务器,则直接请求 + return singleClusterVdcUsedResource(userMachineDoList, loginUserVo); + } else { + //如果是多集群,需线程池去调用,然后在数据进行汇总 + return threadGetVdcUserUsedResource(clusterUserMachineMap, loginUserVo); + } + + + } + + /** + * VDC下用户在单个集群中拥有云服务器,请求mc获取这些云服务器所占用资源 + */ + private VdcSameLevelUserUsedResourceRespDto singleClusterVdcUsedResource(List userMachineDoList, + LoginUserVo loginUserVo) { + List uuidList = + userMachineDoList.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + QueryVdcUsedResourceParam queryVdcUsedResourceParam = new QueryVdcUsedResourceParam(); + queryVdcUsedResourceParam.setUuidList(uuidList); + + try { + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(userMachineDoList.get(0).getClusterId(), + queryVdcUsedResourceParam, + mcConfigProperties.getServerVmsUsedResourceUrl(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + VdcSameLevelUserUsedResourceRespDto vdcSameUserUsedResource = + JSON.parseObject(JSON.toJSONString(mcResponse.getData()), + VdcSameLevelUserUsedResourceRespDto.class); + int totalUsedCpu = + vdcSameUserUsedResource.getUserUsedArchitectureResourceList().stream() + .collect(Collectors.summingInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedVcpu)); + vdcSameUserUsedResource.setUsedCpu(totalUsedCpu); + int totalUsedMem = + vdcSameUserUsedResource.getUserUsedArchitectureResourceList().stream() + .collect(Collectors.summingInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedMem)); + vdcSameUserUsedResource.setUsedMem(totalUsedMem); + return vdcSameUserUsedResource; + } + } catch (Exception e) { + return null; + } + return null; + } + + + /** + * VDC下用户在多个集群中拥有云服务器,多线程方式获取这些已使用的资源 + * + * @param + * @param + */ + private VdcSameLevelUserUsedResourceRespDto threadGetVdcUserUsedResource(Map> clusterUserMachineMap, LoginUserVo loginUserVo) { + + VdcSameLevelUserUsedResourceRespDto vdcSameUserUsedResource = new VdcSameLevelUserUsedResourceRespDto(); + List clusterIdList = new ArrayList<>(); + List mcRequestObjectList = new ArrayList<>(); + clusterUserMachineMap.forEach((key, value) -> { + clusterIdList.add(key); + List uuidList = value.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + QueryVdcUsedResourceParam queryVdcUsedResourceParam = new QueryVdcUsedResourceParam(); + queryVdcUsedResourceParam.setUuidList(uuidList); + mcRequestObjectList.add(queryVdcUsedResourceParam); + }); + + + List resultList = mcClusterThreadService.threadGetMcResponse(clusterIdList, + loginUserVo.getUserName(), + mcConfigProperties.getServerVmsUsedResourceUrl(), mcRequestObjectList); + + + List vdcSameUserUsedResourceList = new ArrayList<>(); + Stream.iterate(0, i -> i + 1).limit(clusterIdList.size()).forEach(i -> { + String mcBaseResourceStr = resultList.get(i); + if (Objects.nonNull(mcBaseResourceStr)) { + VdcSameLevelUserUsedResourceRespDto userUsedResourceRespDto = JSON.parseObject(mcBaseResourceStr, + VdcSameLevelUserUsedResourceRespDto.class); + vdcSameUserUsedResourceList.add(userUsedResourceRespDto); + } + }); + //将多个集群中的已使用存储汇总 + int usedTotalStorage = + vdcSameUserUsedResourceList.stream().collect(Collectors.summingInt(VdcSameLevelUserUsedResourceRespDto::getUsedStorage)); + vdcSameUserUsedResource.setUsedStorage(usedTotalStorage); + + //所有架构资源 + List usedArchitectureResourceList = new ArrayList<>(); + + for (VdcSameLevelUserUsedResourceRespDto userUsedResource : vdcSameUserUsedResourceList) { + //每一个mc集群中架构资源列表 + List eachArchitectureUsedResourceList = + userUsedResource.getUserUsedArchitectureResourceList(); + usedArchitectureResourceList.addAll(eachArchitectureUsedResourceList); + } + //将所有架构资源按照架构进行分组 + Map> differentArchitectureMap = + usedArchitectureResourceList.stream().collect(Collectors.groupingBy(VdcSameLevelUserUsedArchitectureResourceRespDto::getArchitectureType)); + + //相同架构合并和的资源列表 + List afterMergeResource = new ArrayList<>(); + differentArchitectureMap.forEach((architectureType, list) -> { + + VdcSameLevelUserUsedArchitectureResourceRespDto userUsedArchitectureResource = + new VdcSameLevelUserUsedArchitectureResourceRespDto(); + int totalUsedCpu = + list.stream().mapToInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedVcpu).sum(); + userUsedArchitectureResource.setUsedVcpu(totalUsedCpu); + int totalUsedMem = + list.stream().mapToInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedMem).sum(); + userUsedArchitectureResource.setUsedMem(totalUsedMem); + userUsedArchitectureResource.setArchitectureType(architectureType); + afterMergeResource.add(userUsedArchitectureResource); + }); + vdcSameUserUsedResource.setUserUsedArchitectureResourceList(afterMergeResource); + int totalUsedCpu = + vdcSameUserUsedResource.getUserUsedArchitectureResourceList().stream() + .collect(Collectors.summingInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedVcpu)); + vdcSameUserUsedResource.setUsedCpu(totalUsedCpu); + int totalUsedMem = + vdcSameUserUsedResource.getUserUsedArchitectureResourceList().stream() + .collect(Collectors.summingInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedMem)); + vdcSameUserUsedResource.setUsedMem(totalUsedMem); + return vdcSameUserUsedResource; + } + + +// /** +// * 获取可用区下一级所有一级VDC资源 +// * +// * @param zoneId +// * @return +// */ +// private VdcResourceRespDto getZoneFirstVdcResource(Integer zoneId) { +// +// VdcResourceRespDto zoneFirstVdcResource = new VdcResourceRespDto(); +// +// List zoneFirstVdcDoList = cloudVdcService.getFirstVdcListByZone(zoneId); +// if (!zoneFirstVdcDoList.isEmpty()) { +// //所有一级VDC的全部架构资源 +// List allVdcArchitectureResourceList = new ArrayList<>(); +// zoneFirstVdcDoList.forEach(vdc -> { +// CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(vdc.getId()); +// zoneFirstVdcResource.setStorageUnit(vdcTotalStorage.getUnit()); +// //遍历架构获取架构资源 +// List architectureTypeList = Arrays.asList(ArchitectureType.values()); +// architectureTypeList.forEach(architectureType -> { +// //不同架构下cpu数 +// Integer totalCpu = cloudVdcCpuService.totalCpuByVdcIdAndArchitectureType(vdc.getId(), +// architectureType); +// if (Objects.nonNull(totalCpu)) { +// //不同架构下的内存 +// CloudVdcMemDo totalMem = cloudVdcMemService.totalMemByVdcIdAndArchitectureType(vdc.getId(), +// architectureType); +// VdcArchitectureResourceRespDto vdcArchitectureResource = new VdcArchitectureResourceRespDto(); +// vdcArchitectureResource.setMemUnit(totalMem.getMemUnit()); +// vdcArchitectureResource.setArchitectureType(architectureType); +// allVdcArchitectureResourceList.add(vdcArchitectureResource); +// } +// +// }); +// }); +// //架构资源进行分组 +// Map> architectureResourceMap = +// allVdcArchitectureResourceList.stream().collect(Collectors.groupingBy +// (VdcArchitectureResourceRespDto::getArchitectureType)); +// +// List architectureResourceList = new ArrayList<>(); +// architectureResourceMap.forEach((architecture, equalArchitectureResourceList) -> { +// VdcArchitectureResourceRespDto vdcArchitectureResource = new VdcArchitectureResourceRespDto(); +// int totalCpu = +// equalArchitectureResourceList.stream().mapToInt +// (VdcArchitectureResourceRespDto::getTotalVcpu).sum(); +// vdcArchitectureResource.setTotalVcpu(totalCpu); +// int totalMem = +// equalArchitectureResourceList.stream().mapToInt +// (VdcArchitectureResourceRespDto::getTotalMem).sum(); +// vdcArchitectureResource.setMemUnit(equalArchitectureResourceList.get(0).getMemUnit()); +// vdcArchitectureResource.setTotalMem(totalMem); +// vdcArchitectureResource.setArchitectureType(architecture); +// architectureResourceList.add(vdcArchitectureResource); +// }); +// +// zoneFirstVdcResource.setArchitectureResourceList(architectureResourceList); +// } +// return zoneFirstVdcResource; +// } + + + /** + * 线程方式获取mc基础资源 + * + * @param clusterDoList + * @param loginName + */ + private VdcResourceRespDto threadGetMcBaseResource(List clusterDoList, String loginName) { + + VdcResourceRespDto parentVdcResourceRespDto = new VdcResourceRespDto(); + List resultList = + mcClusterThreadService.threadGetMcResponse(clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()), + loginName, + mcConfigProperties.getMcClusterBaseResourceUrl(), new ArrayList<>()); + + + //mc集群资源列表 + List vdcResourceList = new ArrayList<>(); + Stream.iterate(0, i -> i + 1).limit(clusterDoList.size()).forEach(i -> { + String mcBaseResourceStr = resultList.get(i); + if (Objects.nonNull(mcBaseResourceStr)) { + McClusterBaseResource baseResource = JSON.parseObject(mcBaseResourceStr, McClusterBaseResource.class); + vdcResourceList.add(changeMcClusterBaseResourceToVdcResource(baseResource)); + } + }); + //将多个mc基础资源机进行汇总 + int totalStorage = + vdcResourceList.stream().collect(Collectors.summingInt(VdcResourceRespDto::getUsableStorage)); + parentVdcResourceRespDto.setUsableStorage(totalStorage); + parentVdcResourceRespDto.setStorageUnit(StorageUnit.GB); + + //所有架构资源 + List allResourceList = new ArrayList<>(); + + for (VdcResourceRespDto item : vdcResourceList) { + //每一个mc集群中架构资源列表 + List eachClusterArchitectureResourceList = + item.getArchitectureResourceList(); + allResourceList.addAll(eachClusterArchitectureResourceList); + } + //将所有架构资源按照架构进行分组 + Map> differentArchitectureMap = + allResourceList.stream().collect(Collectors.groupingBy(VdcArchitectureResourceRespDto::getArchitectureType)); + + //相同架构合并和的资源列表 + List afterMergeResource = new ArrayList<>(); + differentArchitectureMap.forEach((architectureType, value) -> { + VdcArchitectureResourceRespDto resourceRespDto = mergeEqualArchitectureResource(value); + afterMergeResource.add(resourceRespDto); + }); + parentVdcResourceRespDto.setArchitectureResourceList(afterMergeResource); + return parentVdcResourceRespDto; + } + + + /** + * 将多个集群中相同架构资源进行汇总 + * + * @param equalArchitectureResourceList 相同架构的资源列表 + * @return + */ + private VdcArchitectureResourceRespDto mergeEqualArchitectureResource(List equalArchitectureResourceList) { + VdcArchitectureResourceRespDto vdcArchitectureResource = new VdcArchitectureResourceRespDto(); + int totalCpu = + equalArchitectureResourceList.stream().mapToInt(VdcArchitectureResourceRespDto::getUsableVcpu).sum(); + vdcArchitectureResource.setUsableVcpu(totalCpu); + + int totalMem = + equalArchitectureResourceList.stream().mapToInt(VdcArchitectureResourceRespDto::getUsableMem).sum(); + vdcArchitectureResource.setUsableMem(totalMem); + vdcArchitectureResource.setMemUnit(equalArchitectureResourceList.get(0).getMemUnit()); + vdcArchitectureResource.setArchitectureType(equalArchitectureResourceList.get(0).getArchitectureType()); + return vdcArchitectureResource; + } + + /** + * 将mc中集群资源转换成VDc资源对象 + * + * @param mcClusterBaseResource + * @return + */ + private VdcResourceRespDto changeMcClusterBaseResourceToVdcResource(McClusterBaseResource mcClusterBaseResource) { + VdcResourceRespDto vdcResource = new VdcResourceRespDto(); + if (Objects.nonNull(mcClusterBaseResource)) { + int totalStorage = mcClusterBaseResource.getResourceInfo().getStorageTotal().setScale(0, + BigDecimal.ROUND_HALF_UP).intValue(); + vdcResource.setUsableStorage(totalStorage); + vdcResource.setStorageUnit(StorageUnit.GB); + List architectureResourceList = new ArrayList<>(); + List mcSevers = mcClusterBaseResource.getSevers(); + if (!mcSevers.isEmpty()) { + //按照架构进行分组 + Map> architectureServersMap = + mcSevers.stream().collect(Collectors.groupingBy(McClusterServerResourceResp::getArchitecture)); + + architectureServersMap.forEach((architecture, servers) -> { + architectureResourceList.add(createArchitectureResource(servers, architecture)); + + }); + } + vdcResource.setArchitectureResourceList(architectureResourceList); + } + + return vdcResource; + } + + /** + * 根据mc服务器列表创建vdc架构资源 + * + * @return + */ + private VdcArchitectureResourceRespDto createArchitectureResource(List mcClusterServerResourceRespList + , ArchitectureType architectureType) { + VdcArchitectureResourceRespDto architectureResource = new VdcArchitectureResourceRespDto(); + int totalCpu = + mcClusterServerResourceRespList.stream().collect(Collectors.summingInt(McClusterServerResourceResp::getVcpus)); + architectureResource.setUsableVcpu(totalCpu); + +// BigDecimal totalMemory = +// mcClusterServerResourceRespList.stream().map(McClusterServerResourceResp::getMemory).reduce +// (BigDecimal.ZERO, +// BigDecimal::add); +// //转换成GB +// BigDecimal totalMemoryGB = totalMemory.divide(new BigDecimal("1024")).setScale(0, BigDecimal.ROUND_HALF_UP); + + //转换成GB + int totalMem = + mcClusterServerResourceRespList.stream().mapToInt(item -> item.getMemory().divide(new BigDecimal( + "1024")).setScale(0, BigDecimal.ROUND_HALF_UP).intValue()).sum(); + + + architectureResource.setUsableMem(totalMem); + architectureResource.setMemUnit(MemUnit.GB); + architectureResource.setArchitectureType(architectureType); + return architectureResource; + } + + + /** + * 检查是否存在同名Vdc + */ + private void checkIfExistVdcName(String vdcName) { + //判断名称是否已经存在 + CloudVdcDo cloudVdcDo = new CloudVdcDo(); + cloudVdcDo.setVdcName(vdcName); + cloudVdcDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(cloudVdcDo); + List vdcDoList = cloudVdcService.getBaseMapper().selectList(wrapper); + if (!vdcDoList.isEmpty()) { + throw new KylinException(KylinHttpResponseVdcConstants.EXIST_VDC_NAME); + } + } + + @Override + @Transactional + public void createVdc(CreateVdcParam createVdcParam, LoginUserVo loginUserVo) { + + checkIfExistVdcName(createVdcParam.getVdcName()); + + Date now = new Date(); + CloudVdcDo cloudVdcDo = new CloudVdcDo(); + cloudVdcDo.setParentId(createVdcParam.getParentVdcId()); + cloudVdcDo.setVdcName(createVdcParam.getVdcName()); + cloudVdcDo.setRemark(createVdcParam.getRemark()); + cloudVdcDo.setCreateBy(loginUserVo.getUserId()); + cloudVdcDo.setCreateTime(now); + cloudVdcDo.setZoneId(createVdcParam.getZoneId()); + cloudVdcService.save(cloudVdcDo); + + //插入VDC存储 + CloudVdcStorageDo vdcStorageDo = new CloudVdcStorageDo(); + vdcStorageDo.setVdcId(cloudVdcDo.getId()); + vdcStorageDo.setStorage(createVdcParam.getAllocationStorage()); + vdcStorageDo.setUnit(createVdcParam.getStorageUnit()); + vdcStorageDo.setCreateBy(loginUserVo.getUserId()); + vdcStorageDo.setCreateTime(now); + cloudVdcStorageService.save(vdcStorageDo); + + //插入架构资源 + List vdcCpuDoList = new ArrayList<>(); + List vdcMemDoList = new ArrayList<>(); + createVdcParam.getArchitectureResourceList().forEach(item -> { + + CloudVdcCpuDo vdcCpuDo = new CloudVdcCpuDo(); + vdcCpuDo.setVdcId(cloudVdcDo.getId()); + vdcCpuDo.setArchitecture(item.getArchitectureType()); + vdcCpuDo.setVcpus(item.getAllocationCpu()); + vdcCpuDo.setCreateBy(loginUserVo.getUserId()); + vdcCpuDo.setCreateTime(now); + vdcCpuDoList.add(vdcCpuDo); + + + CloudVdcMemDo vdcMemDo = new CloudVdcMemDo(); + vdcMemDo.setVdcId(cloudVdcDo.getId()); + vdcMemDo.setArchitecture(item.getArchitectureType()); + vdcMemDo.setMem(item.getAllocationMem()); + vdcMemDo.setMemUnit(item.getMemUnit()); + vdcMemDo.setCreateBy(loginUserVo.getUserId()); + vdcMemDo.setCreateTime(now); + vdcMemDoList.add(vdcMemDo); + + }); + + if (!vdcCpuDoList.isEmpty()) { + cloudVdcCpuService.saveBatch(vdcCpuDoList); + } + if (!vdcMemDoList.isEmpty()) { + cloudVdcMemService.saveBatch(vdcMemDoList); + } + + //网络资源处理 + List networkList = new ArrayList<>(); + createVdcParam.getNetworkList().forEach(network -> { + CloudNetworkConfigDo cloudNetworkConfigDo = new CloudNetworkConfigDo(); + cloudNetworkConfigDo.setCreateBy(loginUserVo.getUserId()); + cloudNetworkConfigDo.setVdcId(cloudVdcDo.getId()); + cloudNetworkConfigDo.setCreateTime(new Date()); + BeanUtils.copyProperties(network, cloudNetworkConfigDo); + cloudNetworkConfigDo.setInterfaceType(KylinCloudManageConstants.BRIDGE); + networkList.add(cloudNetworkConfigDo); + }); + if (!networkList.isEmpty()) { + cloudNetworkConfigService.saveBatch(networkList); + } + } + + + @Override + public List vdcTree(LoginUserVo loginUserVo) { + + CloudRoleDo roleDo = roleService.getUserRole(loginUserVo.getUserId()); + + if (Objects.isNull(roleDo)) { + return new ArrayList<>(); + } + + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + List vdcList = cloudVdcService.getBaseMapper().selectList(vdcWrapper); + + if (vdcList.isEmpty()) { + return new ArrayList<>(); + } + + List vdcTreeList = new ArrayList<>(); + //如果是系统管理员及顶级组织的组织管理员,则全部VDC都是该登录用户可见的 + boolean ifPlatformUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + if (ifPlatformUser) { + for (CloudVdcDo vdcDo : vdcList) { + if (Objects.equals(vdcDo.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + vdcTreeList.add(formatVdcTree(vdcDo, vdcList, loginUserVo)); + } + } + } else { + //如果不是则 查询登录用户对应组织拥有的VDC + + CloudVdcDo userVdcDo = getUserOrgBindVdc(loginUserVo.getUserId()); + if (Objects.isNull(userVdcDo)) { + return new ArrayList<>(); + } + for (CloudVdcDo vdcDo : vdcList) { + if (Objects.equals(vdcDo.getId(), userVdcDo.getId())) { + vdcTreeList.add(formatVdcTree(vdcDo, vdcList, loginUserVo)); + } + } + } + + return vdcTreeList; + + } + + /** + * VDC本级用户已使用已使用资源 + * + * @param vdcId + * @param loginUserVo + * @return + */ + private VdcSameLevelUserUsedResourceRespDto createVdcSameUsedResource(Integer vdcId, LoginUserVo loginUserVo) { + + //获取直接挂在本级VDC(组织)下用户云服务器占用资源 + VdcSameLevelUserUsedResourceRespDto vdcSameLevelUserUseResource = getVdcSameLevelUserUseResource(vdcId, + loginUserVo); + if (Objects.nonNull(vdcSameLevelUserUseResource)) { + vdcSameLevelUserUseResource.setUsedCpu(vdcSameLevelUserUseResource.getUserUsedArchitectureResourceList().stream() + .mapToInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedVcpu).sum()); + vdcSameLevelUserUseResource.setUsedMem(vdcSameLevelUserUseResource.getUserUsedArchitectureResourceList().stream() + .mapToInt(VdcSameLevelUserUsedArchitectureResourceRespDto::getUsedMem).sum()); + } + return Objects.isNull(vdcSameLevelUserUseResource) ? + new VdcSameLevelUserUsedResourceRespDto() : vdcSameLevelUserUseResource; + } + + /** + * 组织管理-创建(编辑)组织时选择的父组织结构-封装组织数据 + */ + private VdcTreeRespDto formatVdcTree(CloudVdcDo vdcDo, + List vdcList, LoginUserVo loginUserVo) { + VdcTreeRespDto vdcTree = new VdcTreeRespDto(); + createVdcTreeDto(vdcDo, vdcList, vdcTree, loginUserVo); + vdcTree.setChildren(getChildVdc(vdcDo.getId(), vdcList, loginUserVo)); + return vdcTree; + } + + /** + * 根据vdc获取下级vdc列表 + */ + private List getChildVdc(Integer parentId, List vdcList, LoginUserVo loginUserVo) { + List childList = new ArrayList<>(); + for (CloudVdcDo vdcDo : vdcList) { + if (Objects.equals(parentId, vdcDo.getParentId())) { + VdcTreeRespDto vecTree = formatVdcTree(vdcDo, vdcList, loginUserVo); + childList.add(vecTree); + } + } + return childList; + } + + /** + * 创建vdc树形结构实体 + * + * @param vdcDo + * @param vdcList + * @param vdcInfo + */ + private void createVdcTreeDto(CloudVdcDo vdcDo, + List vdcList, + VdcInfoRespDto vdcInfo, LoginUserVo loginUserVo) { + + + vdcInfo.setVdcId(vdcDo.getId()); + vdcInfo.setVdcName(vdcDo.getVdcName()); + vdcInfo.setParentId(vdcDo.getParentId()); + vdcInfo.setParentName("---"); + vdcInfo.setOrgName("---"); + + //根据vdcId,获取组织 + CloudOrganizationDo organizationDo = orgService.getOrgByVdcId(vdcDo.getId()); + if (Objects.nonNull(organizationDo)) { + vdcInfo.setOrgName(organizationDo.getOrganizationName()); + } + + //获取可用区 + CloudZoneDo zoneDo = cloudZoneService.getById(vdcDo.getZoneId()); + vdcInfo.setZoneName(zoneDo.getName()); + //获取vdc网络资源 + vdcInfo.setNetworkNum(networkConfigService.getNetWorkCountByVdcId(vdcDo.getId())); + + + //获取VDC资源使用情况 + VdcUsedResourceDto vdcResourceDto = getVdcResourceInfo(vdcDo.getId(), loginUserVo); + + vdcInfo.setTotalCpu(vdcResourceDto.getTotalCpu()); + vdcInfo.setUsedCpu(vdcResourceDto.getUsedCpu()); + vdcInfo.setTotalMem(vdcResourceDto.getTotalMem()); + vdcInfo.setUsedMem(vdcResourceDto.getUsedMem()); + vdcInfo.setMemUnit(vdcResourceDto.getMemUnit()); + vdcInfo.setTotalStorage(vdcResourceDto.getTotalStorage()); + vdcInfo.setUsedStorage(vdcResourceDto.getUsedStorage()); + vdcInfo.setStorageUnit(vdcResourceDto.getStorageUnit()); + + CloudVdcDo parentDo = + vdcList.stream().filter(item -> Objects.equals(item.getId(), vdcDo.getParentId())).findFirst().orElse(null); + if (Objects.nonNull(parentDo)) { + vdcInfo.setParentName(parentDo.getVdcName()); + } + } + + + /** + * 获取vdc资源使用情况 + * + * @param vdcId + * @param loginUserVo + * @return + */ + @Override + public VdcUsedResourceDto getVdcResourceInfo(Integer vdcId, LoginUserVo loginUserVo) { + + VdcUsedResourceDto vdcResourceDto = new VdcUsedResourceDto(); + + + //获取VDC本级用户已使用资源 + VdcSameLevelUserUsedResourceRespDto vdcSameLevelUserUseResource = createVdcSameUsedResource(vdcId, loginUserVo); + + //cpu + vdcResourceDto.setTotalCpu(cloudVdcCpuService.totalCpuByVdcId(vdcId)); + vdcResourceDto.setAllocationCpu(cloudVdcCpuService.totalChildVdcCpuByParentIdAndArchitectureType(vdcId, + null)); + vdcResourceDto.setSameUserUsedCpu(vdcSameLevelUserUseResource.getUsedCpu()); + vdcResourceDto.setUsedCpu(vdcResourceDto.getAllocationCpu() + vdcResourceDto.getSameUserUsedCpu()); + vdcResourceDto.setSurplusCpu(vdcResourceDto.getTotalCpu() - vdcResourceDto.getUsedCpu()); + //内存 + CloudVdcMemDo vdcTotalMemDo = cloudVdcMemService.totalMemByVdcId(vdcId); + vdcResourceDto.setTotalMem(vdcTotalMemDo.getMem()); + vdcResourceDto.setMemUnit(vdcTotalMemDo.getMemUnit()); + CloudVdcMemDo allocationMem = + cloudVdcMemService.totalChildVdcMemByParentIdAndArchitectureType(vdcId, null); + vdcResourceDto.setAllocationMem(allocationMem.getMem()); + vdcResourceDto.setSameUserUsedMem(vdcSameLevelUserUseResource.getUsedMem()); + vdcResourceDto.setUsedMem(vdcResourceDto.getAllocationMem() + vdcResourceDto.getSameUserUsedMem()); + vdcResourceDto.setSurplusMem(vdcResourceDto.getTotalMem() - vdcResourceDto.getUsedMem()); + //存储 + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(vdcId); + vdcResourceDto.setTotalStorage(vdcTotalStorage.getStorage()); + vdcResourceDto.setStorageUnit(vdcTotalStorage.getUnit()); + CloudVdcStorageDo allocationStorage = + cloudVdcStorageService.getChildVdcTotalStorage(vdcId); + vdcResourceDto.setAllocationStorage(allocationStorage.getStorage()); + vdcResourceDto.setSameUserUsedStorage(vdcSameLevelUserUseResource.getUsedStorage()); + vdcResourceDto.setUsedStorage(vdcResourceDto.getSameUserUsedStorage() + vdcResourceDto.getAllocationStorage()); + vdcResourceDto.setSurplusStorage(vdcResourceDto.getTotalStorage() - vdcResourceDto.getUsedStorage()); + + List architectureTypeList = Arrays.asList(ArchitectureType.values()); + //vdc-本级用户使用架构资源 + List vdcSameLevelUserUsedArchitectureResourceList = + vdcSameLevelUserUseResource.getUserUsedArchitectureResourceList(); + //封装各个架构使用资源情况 + List vdcArchitectureUsedResourceList = new ArrayList<>(); + architectureTypeList.forEach(architectureType -> { + //获取本级VDC用户直接使用该架构资源 + VdcSameLevelUserUsedArchitectureResourceRespDto sameUserUsedArchitectureResource = + Objects.isNull(vdcSameLevelUserUseResource) ? null : + vdcSameLevelUserUsedArchitectureResourceList.stream(). + filter(item -> Objects.equals(item.getArchitectureType(), architectureType)).findFirst().orElse(null); + + //VDC总CPU + Integer totalCpu = cloudVdcCpuService.totalCpuByVdcIdAndArchitectureType(vdcId, architectureType); + + if (Objects.nonNull(totalCpu)) { + VdcArchitectureUsedResourceDto vdcArchitectureResource = new VdcArchitectureUsedResourceDto(); + vdcArchitectureResource.setArchitectureType(architectureType); + + //已分配给下级CPU + Integer childCpuTotal = cloudVdcCpuService.totalChildVdcCpuByParentIdAndArchitectureType(vdcId, + architectureType); + //本级VDC用户直接使用CPU + Integer sameVdcUserUsedCpu = Objects.nonNull(sameUserUsedArchitectureResource) ? + sameUserUsedArchitectureResource.getUsedVcpu() : 0; + vdcArchitectureResource.setTotalCpu(totalCpu); + vdcArchitectureResource.setAllocationCpu(childCpuTotal); + vdcArchitectureResource.setSameUserUsedCpu(sameVdcUserUsedCpu); + vdcArchitectureResource.setUsedCpu(childCpuTotal + sameVdcUserUsedCpu); + vdcArchitectureResource.setSurplusCpu(totalCpu - childCpuTotal - sameVdcUserUsedCpu); + + //VDC总内存 + CloudVdcMemDo totalMem = cloudVdcMemService.totalMemByVdcIdAndArchitectureType(vdcId, + architectureType); + //已分配给下级VDC存储 + CloudVdcMemDo childTotalMem = + cloudVdcMemService.totalChildVdcMemByParentIdAndArchitectureType(vdcId, + architectureType); + //本级VDC用户直接使用mem + Integer sameVdcUserUsedMem = Objects.nonNull(sameUserUsedArchitectureResource) ? + sameUserUsedArchitectureResource.getUsedMem() : 0; + + vdcArchitectureResource.setTotalMem(totalMem.getMem()); + vdcArchitectureResource.setMemUnit(totalMem.getMemUnit()); + vdcArchitectureResource.setAllocationMem(childTotalMem.getMem()); + vdcArchitectureResource.setSameUserUsedMem(sameVdcUserUsedMem); + vdcArchitectureResource.setUsedMem(childTotalMem.getMem() + sameVdcUserUsedMem); + vdcArchitectureResource.setSurplusMem(totalMem.getMem() - childTotalMem.getMem() - sameVdcUserUsedMem); + vdcArchitectureUsedResourceList.add(vdcArchitectureResource); + } + + }); + vdcResourceDto.setVdcArchitectureUsedResourceList(vdcArchitectureUsedResourceList); + return vdcResourceDto; + } + + @Override + public VdcInfoRespDto vdcDetail(BaseVdcParam baseVdcParam, LoginUserVo loginUserVo) { + CloudVdcDo vdcDo = cloudVdcService.getById(baseVdcParam.getVdcId()); + VdcInfoRespDto vdcInfo = new VdcInfoRespDto(); + vdcInfo.setVdcId(vdcDo.getId()); + vdcInfo.setVdcName(vdcDo.getVdcName()); + vdcInfo.setParentId(vdcDo.getParentId()); + vdcInfo.setCreateTime(DateUtils.format(vdcDo.getCreateTime(), DateUtils.DATE_ALL_PATTEN)); + vdcInfo.setOrgName("---"); + vdcInfo.setRemark(vdcDo.getRemark()); + vdcInfo.setParentName("--"); + if (!Objects.equals(vdcDo.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + CloudVdcDo parentVdc = cloudVdcService.getById(vdcDo.getParentId()); + vdcInfo.setParentName(parentVdc.getVdcName()); + } + + //根据vdcId,获取组织 + CloudOrganizationDo organizationDo = orgService.getOrgByVdcId(vdcDo.getId()); + if (Objects.nonNull(organizationDo)) { + vdcInfo.setOrgName(organizationDo.getOrganizationName()); + } + + //获取可用区 + CloudZoneDo zoneDo = cloudZoneService.getById(vdcDo.getZoneId()); + vdcInfo.setZoneName(zoneDo.getName()); + //获取vdc网络资源 + vdcInfo.setNetworkNum(networkConfigService.getNetWorkCountByVdcId(vdcDo.getId())); + + //vdc资源使用情况 + VdcUsedResourceDto vdcResourceDto = getVdcResourceInfo(vdcDo.getId(), loginUserVo); + + //cpu 信息 + vdcInfo.setTotalCpu(vdcResourceDto.getTotalCpu()); + vdcInfo.setUsedCpu(vdcResourceDto.getUsedCpu()); + vdcInfo.setAllocationCpu(vdcResourceDto.getAllocationCpu()); + vdcInfo.setSameUserUsedCpu(vdcResourceDto.getSameUserUsedCpu()); + vdcInfo.setSurplusCpu(vdcResourceDto.getSurplusCpu()); + + //内存信息 + vdcInfo.setTotalMem(vdcResourceDto.getTotalMem()); + vdcInfo.setUsedMem(vdcResourceDto.getUsedMem()); + vdcInfo.setAllocationMem(vdcResourceDto.getAllocationMem()); + vdcInfo.setSameUserUsedMem(vdcResourceDto.getSameUserUsedMem()); + vdcInfo.setMemUnit(vdcResourceDto.getMemUnit()); + vdcInfo.setSurplusMem(vdcResourceDto.getSurplusMem()); + + //存储信息 + vdcInfo.setTotalStorage(vdcResourceDto.getTotalStorage()); + vdcInfo.setUsedStorage(vdcResourceDto.getUsedStorage()); + vdcInfo.setAllocationStorage(vdcResourceDto.getAllocationStorage()); + vdcInfo.setSameUserUsedStorage(vdcResourceDto.getSameUserUsedStorage()); + vdcInfo.setStorageUnit(vdcResourceDto.getStorageUnit()); + vdcInfo.setSurplusStorage(vdcResourceDto.getSurplusStorage()); + + //网络信息 + vdcInfo.setNetworkList(networkMapper.networkListByVdcId(vdcDo.getId())); + + //各个架构的资源信息 + List architectureUsedResourceList = new ArrayList<>(); + vdcResourceDto.getVdcArchitectureUsedResourceList().forEach(item -> { + //CPU资源 + CommonVdcArchitectureResource cpuResource = new CommonVdcArchitectureResource(); + cpuResource.setArchitectureType(item.getArchitectureType()); + cpuResource.setResourceType(ArchitectureResourceType.CPU); + cpuResource.setTotal(item.getTotalCpu()); + cpuResource.setUsed(item.getUsedCpu()); + cpuResource.setSameUserUsed(item.getSameUserUsedCpu()); + cpuResource.setAllocationChild(item.getAllocationCpu()); + cpuResource.setSurplus(item.getSurplusCpu()); + architectureUsedResourceList.add(cpuResource); + + //内存资源 + CommonVdcArchitectureResource memResource = new CommonVdcArchitectureResource(); + memResource.setArchitectureType(item.getArchitectureType()); + memResource.setResourceType(ArchitectureResourceType.MEM); + memResource.setTotal(item.getTotalMem()); + memResource.setUsed(item.getUsedMem()); + memResource.setSameUserUsed(item.getSameUserUsedMem()); + memResource.setAllocationChild(item.getAllocationMem()); + memResource.setSurplus(item.getSurplusMem()); + architectureUsedResourceList.add(memResource); + }); + vdcInfo.setArchitectureUsedResourceList(architectureUsedResourceList); + return vdcInfo; + } + + + @Override + public ModifyVdcDetailRespDto modifyVdcDetail(BaseVdcParam baseVdcParam, LoginUserVo loginUserVo) { + CloudVdcDo vdcDo = cloudVdcService.getById(baseVdcParam.getVdcId()); + ModifyVdcDetailRespDto vdcDetail = new ModifyVdcDetailRespDto(); + vdcDetail.setVdcId(vdcDo.getId()); + vdcDetail.setVdcName(vdcDo.getVdcName()); + vdcDetail.setParentId(vdcDo.getParentId()); + if (!Objects.equals(vdcDo.getParentId(), KylinCloudManageConstants.TOP_PARENT_ID)) { + vdcDetail.setParentName(cloudVdcService.getById(vdcDo.getParentId()).getVdcName()); + } + CloudZoneDo zoneDo = cloudZoneService.getById(vdcDo.getZoneId()); + vdcDetail.setZoneId(vdcDo.getZoneId()); + vdcDetail.setZoneName(zoneDo.getName()); + //网络设置 + vdcDetail.setNetworkList(networkMapper.networkListByVdcId(vdcDo.getId())); + + return vdcDetail; + } + + + @Override + @Transactional + public void modifyVdc(ModifyVdcParam modifyVdcParam, LoginUserVo loginUserVo) { + CloudVdcDo vdcDo = cloudVdcService.getById(modifyVdcParam.getVdcId()); + Date now = new Date(); + if (!Objects.equals(modifyVdcParam.getVdcName(), vdcDo.getVdcName())) { + checkIfExistVdcName(modifyVdcParam.getVdcName()); + vdcDo.setVdcName(modifyVdcParam.getVdcName()); + vdcDo.setUpdateBy(loginUserVo.getUserId()); + vdcDo.setUpdateTime(now); + cloudVdcService.updateById(vdcDo); + } + +// //获取已分配的存储 +// CloudVdcStorageDo queryStorageDo = new CloudVdcStorageDo(); +// queryStorageDo.setDeleteFlag(false); +// queryStorageDo.setVdcId(vdcDo.getId()); +// QueryWrapper storageWrapper = new QueryWrapper<>(queryStorageDo); +// List vdcStorageList = cloudVdcStorageService.getBaseMapper().selectList(storageWrapper); +// if (!vdcStorageList.isEmpty()) { +// CloudVdcStorageDo updateStorageDo = vdcStorageList.get(0); +// updateStorageDo.setStorage(modifyVdcParam.getAllocationStorage()); +// updateStorageDo.setUpdateBy(loginUserVo.getUserId()); +// updateStorageDo.setUpdateTime(now); +// cloudVdcStorageService.updateById(updateStorageDo); +// } else { +// CloudVdcStorageDo insertStorageDo = new CloudVdcStorageDo(); +// insertStorageDo.setVdcId(vdcDo.getId()); +// insertStorageDo.setStorage(modifyVdcParam.getAllocationStorage()); +// insertStorageDo.setUnit(modifyVdcParam.getStorageUnit()); +// insertStorageDo.setCreateBy(loginUserVo.getUserId()); +// insertStorageDo.setCreateTime(now); +// cloudVdcStorageService.save(insertStorageDo); +// } +// +// //插入架构资源 +// List vdcCpuDoList = cloudVdcCpuService.listVDdcCpuByVdc(vdcDo.getId()); +// List vdcMemDoList = cloudVdcMemService.listVdcMemByVdcId(vdcDo.getId()); +// +// List updateCpuDoList = new ArrayList<>(); +// List insertCpuDoList = new ArrayList<>(); +// +// List updateMemDoList = new ArrayList<>(); +// List insertMemDoList = new ArrayList<>(); +// +// modifyVdcParam.getArchitectureResourceList().forEach(item -> { +// +// +// CloudVdcCpuDo cpuDo = +// vdcCpuDoList.stream().filter(cpu -> Objects.equals(cpu.getArchitecture(), +// item.getArchitectureType())).findFirst().orElse(null); +// +// if (Objects.nonNull(cpuDo)) { +// cpuDo.setVcpus(item.getAllocationCpu()); +// cpuDo.setUpdateBy(loginUserVo.getUserId()); +// cpuDo.setUpdateTime(now); +// updateCpuDoList.add(cpuDo); +// } else { +// CloudVdcCpuDo vdcCpuDo = new CloudVdcCpuDo(); +// vdcCpuDo.setVdcId(vdcDo.getId()); +// vdcCpuDo.setArchitecture(item.getArchitectureType()); +// vdcCpuDo.setVcpus(item.getAllocationCpu()); +// vdcCpuDo.setCreateBy(loginUserVo.getUserId()); +// vdcCpuDo.setCreateTime(now); +// insertCpuDoList.add(vdcCpuDo); +// } +// +// +// CloudVdcMemDo memDo = +// vdcMemDoList.stream().filter(cpu -> Objects.equals(cpu.getArchitecture(), +// item.getArchitectureType())).findFirst().orElse(null); +// +// +// if (Objects.nonNull(memDo)) { +// memDo.setMem(item.getAllocationMem()); +// memDo.setUpdateBy(loginUserVo.getUserId()); +// memDo.setUpdateTime(now); +// updateMemDoList.add(memDo); +// } else { +// CloudVdcMemDo vdcMemDo = new CloudVdcMemDo(); +// vdcMemDo.setVdcId(vdcDo.getId()); +// vdcMemDo.setArchitecture(item.getArchitectureType()); +// vdcMemDo.setMem(item.getAllocationMem()); +// vdcMemDo.setMemUnit(item.getMemUnit()); +// vdcMemDo.setCreateBy(loginUserVo.getUserId()); +// vdcMemDo.setCreateTime(now); +// insertMemDoList.add(vdcMemDo); +// } +// }); +// +// if (!updateCpuDoList.isEmpty()) { +// cloudVdcCpuService.updateBatchById(updateCpuDoList); +// } +// +// if (!insertCpuDoList.isEmpty()) { +// cloudVdcCpuService.saveBatch(insertCpuDoList); +// } +// if (!updateMemDoList.isEmpty()) { +// cloudVdcMemService.updateBatchById(updateMemDoList); +// } +// if (!insertMemDoList.isEmpty()) { +// cloudVdcMemService.saveBatch(insertMemDoList); +// } + + //网络处理 + modifyVdcNetwork(vdcDo.getId(), modifyVdcParam, loginUserVo); + + } + + /** + * 编辑vdc网络 + * + * @param vdcId + * @param modifyVdcParam + */ + private void modifyVdcNetwork(Integer vdcId, ModifyVdcParam modifyVdcParam, LoginUserVo loginUserVo) { + + + List networkListDo = cloudNetworkConfigService.listNetworkListByVdcId(vdcId); + List insertNetworkList = new ArrayList<>(); + List updateNetworkList = new ArrayList<>(); + + modifyVdcParam.getNetworkList().forEach(network -> { + CloudNetworkConfigDo networkConfigDo = + networkListDo.stream().filter(item -> Objects.equals(item.getId(), network.getNetworkId())).findFirst().orElse(null); + if (Objects.isNull(networkConfigDo)) { + CloudNetworkConfigDo cloudNetworkConfigDo = new CloudNetworkConfigDo(); + BeanUtils.copyProperties(network, cloudNetworkConfigDo); + cloudNetworkConfigDo.setInterfaceType(KylinCloudManageConstants.BRIDGE); + cloudNetworkConfigDo.setCreateBy(loginUserVo.getUserId()); + cloudNetworkConfigDo.setVdcId(vdcId); + cloudNetworkConfigDo.setCreateTime(new Date()); + insertNetworkList.add(cloudNetworkConfigDo); + } else { + switch (network.getModifyType()) { + case NONE: + case MODIFY: + BeanUtils.copyProperties(network, networkConfigDo); + networkConfigDo.setInterfaceType(KylinCloudManageConstants.BRIDGE); + networkConfigDo.setUpdateBy(loginUserVo.getUserId()); + networkConfigDo.setUpdateTime(new Date()); + updateNetworkList.add(networkConfigDo); + break; + case DELETE: + networkConfigDo.setDeleteFlag(true); + networkConfigDo.setUpdateBy(loginUserVo.getUserId()); + networkConfigDo.setUpdateTime(new Date()); + networkConfigDo.setDeleteBy(loginUserVo.getUserId()); + networkConfigDo.setDeleteTime(new Date()); + updateNetworkList.add(networkConfigDo); + break; + } + } + }); + if (!insertNetworkList.isEmpty()) { + cloudNetworkConfigService.saveBatch(insertNetworkList); + } + if (!updateNetworkList.isEmpty()) { + cloudNetworkConfigService.updateBatchById(updateNetworkList); + } + } + + + @Override + public void deleteVdc(BaseVdcParam baseVdcParam, LoginUserVo loginUserVo) { + //删除VDC条件: + //1:无下级vdc + boolean hasChildVdc = checkExistChild(baseVdcParam.getVdcId()); + if (hasChildVdc) { + throw new KylinException(KylinHttpResponseVdcConstants.EXIST_CHILD_VDC); + } + //2:无组织和当前VDC绑定 + boolean bindVdc = checkOrgBindVdc(baseVdcParam.getVdcId()); + if (bindVdc) { + throw new KylinException(KylinHttpResponseVdcConstants.VDC_BIND_ORG); + } + + CloudVdcDo vdcDo = cloudVdcService.getById(baseVdcParam.getVdcId()); + vdcDo.setDeleteFlag(true); + vdcDo.setDeleteBy(loginUserVo.getUserId()); + vdcDo.setDeleteTime(new Date()); + cloudVdcService.updateById(vdcDo); + //删除资源 + cloudNetworkConfigService.deleteByVdcId(baseVdcParam.getVdcId(), loginUserVo.getUserId()); + cloudVdcCpuService.deleteByVdcId(baseVdcParam.getVdcId(), loginUserVo.getUserId()); + cloudVdcMemService.deleteByVdcId(baseVdcParam.getVdcId(), loginUserVo.getUserId()); + cloudVdcStorageService.deleteByVdcId(baseVdcParam.getVdcId(), loginUserVo.getUserId()); + + } + + /** + * 判断是否存在下级vdc + * + * @param vdcId + * @return + */ + private boolean checkExistChild(Integer vdcId) { + CloudVdcDo queryChildDo = new CloudVdcDo(); + queryChildDo.setDeleteFlag(false); + queryChildDo.setParentId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryChildDo); + List childList = cloudVdcService.getBaseMapper().selectList(wrapper); + return !childList.isEmpty(); + } + + + /** + * 检查是否有组织绑定该vdc + * + * @param vdcId + * @return + */ + private boolean checkOrgBindVdc(Integer vdcId) { + CloudOrgVdcDo queryBindDo = new CloudOrgVdcDo(); + queryBindDo.setDeleteFlag(false); + queryBindDo.setVdcId(vdcId); + QueryWrapper wrapper = new QueryWrapper<>(queryBindDo); + List bindList = cloudOrgVdcService.getBaseMapper().selectList(wrapper); + return !bindList.isEmpty(); + } + + + @Override + public CloudVdcDo getUserOrgBindVdc(Integer userId) { + CloudOrganizationDo loginUserOrgDo = orgService.getByUserId(userId); + CloudOrgVdcDo orgVdcDo = new CloudOrgVdcDo(); + orgVdcDo.setOrgId(loginUserOrgDo.getId()); + orgVdcDo.setDeleteFlag(false); + Wrapper orgVdcDoWrapper = + new QueryWrapper<>(orgVdcDo); + List orgVdcList = cloudOrgVdcService.getBaseMapper().selectList(orgVdcDoWrapper); + return orgVdcList.isEmpty() ? null : cloudVdcService.getById(orgVdcList.get(0).getVdcId()); + } + + @Override + public CloudVdcDo getVdcByOrgId(Integer orgId) { + + return cloudVdcService.getVdcByOrgId(orgId); + } + + @Override + public List visibleVdcListByUserId(Integer userId) { + boolean ifPlatformUser = userService.judgeIfPlatformUser(userId); + if (ifPlatformUser) { + return cloudVdcService.list(); + } + //如果不是则 查询登录用户对应组织拥有的VDC + CloudOrganizationDo userOrg = orgService.getByUserId(userId); + CloudVdcDo loginUserOrgVdc = getVdcByOrgId(userOrg.getId()); + return cloudVdcService.getAllChildVdcList(loginUserOrgVdc.getId()); + } + + + @Override + public List visibleVdcListByUserIdAndZoneId(Integer userId, Integer zoneId) { + boolean ifPlatformUser = userService.judgeIfPlatformUser(userId); + if (ifPlatformUser) { + return cloudVdcService.vdcListByZone(zoneId); + } + //如果不是则 查询登录用户对应组织拥有的VDC + CloudOrganizationDo userOrg = orgService.getByUserId(userId); + CloudVdcDo loginUserOrgVdc = getVdcByOrgId(userOrg.getId()); + return cloudVdcService.getAllChildVdcList(loginUserOrgVdc.getId()); + } + + @Override + public VdcModifyResourceRespDto modifyVdcResourceDetail(Integer vdcId, LoginUserVo loginUserVo) { + + CloudVdcDo vdcDo = cloudVdcService.getById(vdcId); + if (Objects.equals(vdcDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)) { + //可用区资源 + VdcResourceRespDto zoneClusterResource = createZoneResource(vdcDo.getZoneId(), loginUserVo); + VdcResourceRespDto firstVdcResource = createVdcResource(vdcDo.getId(), loginUserVo); + return createFirstVdcModifyResource(vdcDo.getId(), zoneClusterResource, firstVdcResource); + } else { + //上级VDC资源 + VdcResourceRespDto parentVdcResource = createVdcResource(vdcDo.getParentId(), loginUserVo); + //本级VDC资源 + VdcResourceRespDto sameVdcResource = createVdcResource(vdcDo.getId(), loginUserVo); + + return createNotFirstVdcModifyResource(vdcDo.getId(), parentVdcResource, sameVdcResource, loginUserVo); + + } + + } + + /** + * 创建一级VDC -资源变更申请详情 + * + * @param vdcId + * @param zoneClusterResource + * @param firstVdcResource + * @return + */ + private VdcModifyResourceRespDto createFirstVdcModifyResource(Integer vdcId, + VdcResourceRespDto zoneClusterResource, + VdcResourceRespDto firstVdcResource) { + VdcModifyResourceRespDto firstVdcModifyResource = new VdcModifyResourceRespDto(); + //获取当前VDC存储 + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(vdcId); + firstVdcModifyResource.setCurrentStorage(vdcTotalStorage.getStorage()); + firstVdcModifyResource.setStorageUnit(vdcTotalStorage.getUnit()); + firstVdcModifyResource.setUsedStorage(firstVdcResource.getUsedStorage()); + firstVdcModifyResource.setParentUsableStorage(zoneClusterResource.getUsableStorage()); + + List architectureResourceList = new ArrayList<>(); + List zoneClusterArchitectureResourceList = + zoneClusterResource.getArchitectureResourceList(); + List firstVdcArchitectureResourceList = + firstVdcResource.getArchitectureResourceList(); + //遍历架构获取架构资源 + List architectureTypeList = Arrays.asList(ArchitectureType.values()); + architectureTypeList.forEach(architectureType -> { + VdcArchitectureResourceRespDto zoneClusterArchitectureResource = + zoneClusterArchitectureResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), architectureType)) + .findFirst().orElse(null); + + VdcArchitectureResourceRespDto firstArchitectureResource = + firstVdcArchitectureResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), architectureType)) + .findFirst().orElse(null); + + //当前VDC cpu值 + Integer currentCpu = cloudVdcCpuService.totalCpuByVdcIdAndArchitectureType(vdcId, + architectureType); + + //当前VDC内存值 + CloudVdcMemDo currentMem = cloudVdcMemService.totalMemByVdcIdAndArchitectureType(vdcId, + architectureType); + + VdcModifyArchitectureResourceRespDto firstVdcArchitectureResource = + new VdcModifyArchitectureResourceRespDto(); + + boolean addFlag = false; + if (Objects.nonNull(currentCpu) & Objects.nonNull(currentMem)) { + firstVdcArchitectureResource.setCurrentVcpu(currentCpu); + firstVdcArchitectureResource.setCurrentMem(currentMem.getMem()); + firstVdcArchitectureResource.setMemUnit(currentMem.getMemUnit()); + firstVdcArchitectureResource.setArchitectureType(architectureType); + if (Objects.nonNull(firstArchitectureResource)) { + firstVdcArchitectureResource.setUsedCpu(firstArchitectureResource.getUsedCpu()); + firstVdcArchitectureResource.setUsedMem(firstArchitectureResource.getUsedMem()); + } + addFlag = true; + } + + if (Objects.nonNull(zoneClusterArchitectureResource)) { + firstVdcArchitectureResource.setParentUsableMem(zoneClusterArchitectureResource.getUsableMem()); + firstVdcArchitectureResource.setParentUsableCpu(zoneClusterArchitectureResource.getUsableVcpu()); + addFlag = true; + } + if (addFlag) { + architectureResourceList.add(firstVdcArchitectureResource); + firstVdcArchitectureResource.setArchitectureType(architectureType); + } + + }); + firstVdcModifyResource.setArchitectureResourceList(architectureResourceList); + return firstVdcModifyResource; + } + + + /** + * 创建非一级VDC -资源变更申请详情 + * + * @param parentVdcResource + * @param sameVdcResource + * @return + */ + private VdcModifyResourceRespDto createNotFirstVdcModifyResource(Integer vdcId, + VdcResourceRespDto parentVdcResource, + VdcResourceRespDto sameVdcResource, + LoginUserVo loginUserVo) { + //获取当前VDC存储 + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(vdcId); + + VdcModifyResourceRespDto vdcModifyResource = new VdcModifyResourceRespDto(); + vdcModifyResource.setCurrentStorage(vdcTotalStorage.getStorage()); + vdcModifyResource.setStorageUnit(vdcTotalStorage.getUnit()); + vdcModifyResource.setParentUsableStorage(parentVdcResource.getUsableStorage() + vdcTotalStorage.getStorage()); + vdcModifyResource.setUsedStorage(sameVdcResource.getUsedStorage()); + + + List architectureResourceList = new ArrayList<>(); + List parentArchitectureResourceList = + parentVdcResource.getArchitectureResourceList(); + List sameVdcArchitectureResourceList = + sameVdcResource.getArchitectureResourceList(); + //遍历架构获取架构资源 + List architectureTypeList = Arrays.asList(ArchitectureType.values()); + architectureTypeList.forEach(architectureType -> { + //当前VDC cpu值 + Integer currentCpu = cloudVdcCpuService.totalCpuByVdcIdAndArchitectureType(vdcId, + architectureType); + + //当前VDC内存值 + CloudVdcMemDo currentMem = cloudVdcMemService.totalMemByVdcIdAndArchitectureType(vdcId, + architectureType); + if (Objects.nonNull(currentCpu) && Objects.nonNull(currentMem)) { + VdcModifyArchitectureResourceRespDto architectureResource = new VdcModifyArchitectureResourceRespDto(); + architectureResource.setCurrentVcpu(currentCpu); + architectureResource.setCurrentMem(currentMem.getMem()); + architectureResource.setMemUnit(currentMem.getMemUnit()); + architectureResource.setArchitectureType(architectureType); + VdcArchitectureResourceRespDto parentArchitectureResource = + parentArchitectureResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), architectureType)) + .findFirst().orElse(null); + + if (Objects.nonNull(parentArchitectureResource)) { + architectureResource.setParentUsableCpu(parentArchitectureResource.getUsableVcpu() + currentCpu); + architectureResource.setParentUsableMem(parentArchitectureResource.getUsableMem() + currentMem.getMem()); + } + VdcArchitectureResourceRespDto sameVdcArchitectureResource = + sameVdcArchitectureResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), architectureType)) + .findFirst().orElse(null); + if (Objects.nonNull(sameVdcArchitectureResource)) { + architectureResource.setUsedCpu(sameVdcArchitectureResource.getUsedCpu()); + architectureResource.setUsedMem(sameVdcArchitectureResource.getUsedMem()); + } + architectureResourceList.add(architectureResource); + } + }); + vdcModifyResource.setArchitectureResourceList(architectureResourceList); + //获取当前用户是否是修改申请修改下级VDC + boolean ifPlatformUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + if (ifPlatformUser) { + vdcModifyResource.setModifyChild(true); + } else { + //vdc-对应的组织 + CloudOrganizationDo vdcBindOrg = orgService.getOrgByVdcId(vdcId); + if (Objects.isNull(vdcBindOrg)) { + //Vdc 还未绑定组织,则说明来变更改VDC只能是上级用户 + vdcModifyResource.setModifyChild(false); + } else { + CloudOrganizationDo loginUserOrg = orgService.getByUserId(loginUserVo.getUserId()); + //如果登录用户对应的组织和vdc对应的组织是同一个,则工单是待审核, + if (Objects.equals(vdcBindOrg.getId(), loginUserOrg.getId())) { + vdcModifyResource.setModifyChild(false); + } else { + vdcModifyResource.setModifyChild(true); + } + } + } + return vdcModifyResource; + } + + + /** + * 申请VDC-资源 工单 + * 登录用户如果是该VDC上级用户,工单则直接通过 + * 如果不是上级用户,则工单需要在审核 + * + * @param applyModifyVdcResourceParam + * @param loginUserVo + */ + @Override + @Transactional + public BaseResult applyModifyVdcResource(ApplyModifyVdcResourceParam applyModifyVdcResourceParam, + LoginUserVo loginUserVo) { + + Integer vdcId = applyModifyVdcResourceParam.getVdcId(); + + CloudVdcDo vdcDo = cloudVdcService.getById(vdcId); + + WorkOrderStatus workOrderStatus = WorkOrderStatus.WAIT_CHECK; + + boolean ifPlatformUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + if (ifPlatformUser) { + workOrderStatus = WorkOrderStatus.CHECK_PASS; + } else { + //vdc-对应的组织 + CloudOrganizationDo vdcBindOrg = orgService.getOrgByVdcId(vdcId); + if (Objects.isNull(vdcBindOrg)) { + //Vdc 还未绑定组织,则说明来变更改VDC只能是上级用户 + workOrderStatus = WorkOrderStatus.CHECK_PASS; + } else { + CloudOrganizationDo loginUserOrg = orgService.getByUserId(loginUserVo.getUserId()); + //如果登录用户对应的组织和vdc对应的组织是同一个,则工单是待审核, + if (Objects.equals(vdcBindOrg.getId(), loginUserOrg.getId())) { + workOrderStatus = WorkOrderStatus.WAIT_CHECK; + } else { + workOrderStatus = WorkOrderStatus.CHECK_PASS; + } + } + } + + + Date now = new Date(); + CloudWorkOrderDo workOrderDo = new CloudWorkOrderDo(); + workOrderDo.setType(WorkOrderType.MODIFY_VDC); + workOrderDo.setUserId(loginUserVo.getUserId()); + workOrderDo.setStatus(workOrderStatus); + workOrderDo.setTarget(vdcDo.getVdcName()); + workOrderDo.setApplyReason(applyModifyVdcResourceParam.getApplyReason()); + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + workOrderDo.setAuditBy(loginUserVo.getUserId()); + workOrderDo.setAuditTime(now); + workOrderDo.setAuditOpinion("auto pass"); + } + formatWorkOrderCommon(workOrderDo, loginUserVo, workOrderStatus); + cloudWorkOrderService.save(workOrderDo); + + //插入VDC工单详情 + insertWorkOrderVdcDetail(applyModifyVdcResourceParam, workOrderDo.getId(), loginUserVo, workOrderStatus); + + //插入VDC工单-架构资源详情 + insertWorkOrderVdcCpuMem(applyModifyVdcResourceParam, workOrderDo.getId(), loginUserVo, workOrderStatus); + + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + return BaseResult.customSuccess(KylinHttpResponseVdcConstants.APPLY_MODIFY_VDC_CHECK_PASS, null); + } + return BaseResult.customSuccess(KylinHttpResponseVdcConstants.APPLY_MODIFY_VDC_CHECK_WAIT, null); + } + + /** + * 插入VDC工单详情 + * + * @param applyModifyVdcResourceParam + * @param workOrderId + * @param loginUserVo + * @param workOrderStatus + */ + private void insertWorkOrderVdcDetail(ApplyModifyVdcResourceParam applyModifyVdcResourceParam, + Integer workOrderId, LoginUserVo loginUserVo, + WorkOrderStatus workOrderStatus) { + //工单-VDC详情表 + Integer vdcId = applyModifyVdcResourceParam.getVdcId(); + + CloudWorkOrderVdcDo cloudWorkOrderVdcDo = new CloudWorkOrderVdcDo(); + cloudWorkOrderVdcDo.setWorkOrderId(workOrderId); + cloudWorkOrderVdcDo.setVdcId(vdcId); + formatWorkOrderCommon(cloudWorkOrderVdcDo, loginUserVo, workOrderStatus); + + cloudWorkOrderVdcDo.setApplyStorage(applyModifyVdcResourceParam.getApplyStorage()); + cloudWorkOrderVdcDo.setStorageUnit(applyModifyVdcResourceParam.getStorageUnit()); + CloudVdcStorageDo cloudVdcStorageDo = + cloudVdcStorageService.getByVdcId(vdcId); + cloudWorkOrderVdcDo.setOldStorage(cloudVdcStorageDo.getStorage()); + cloudWorkOrderVdcDo.setRealStorage(0); + + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + cloudWorkOrderVdcDo.setRealStorage(applyModifyVdcResourceParam.getApplyStorage()); + //如果工单是直接通过状态,则删除VDC-原来的存储资源,删除新的存储资源 + cloudVdcStorageDo.setUpdateBy(loginUserVo.getUserId()); + cloudVdcStorageDo.setUpdateTime(new Date()); + cloudVdcStorageDo.setStorage(applyModifyVdcResourceParam.getApplyStorage()); + cloudVdcStorageService.updateById(cloudVdcStorageDo); + } + cloudWorkOrderVdcService.save(cloudWorkOrderVdcDo); + } + + /** + * 插入VDC资源申请-架构资源详情 + * + * @param applyModifyVdcResourceParam + * @param workOrderId + * @param loginUserVo + * @param workOrderStatus + */ + private void insertWorkOrderVdcCpuMem(ApplyModifyVdcResourceParam applyModifyVdcResourceParam, + Integer workOrderId, LoginUserVo loginUserVo, + WorkOrderStatus workOrderStatus) { + + Integer vdcId = applyModifyVdcResourceParam.getVdcId(); + + List oldVdcCpuList = cloudVdcCpuService.listVDdcCpuByVdc(vdcId); + List oldVdcMemList = cloudVdcMemService.listVdcMemByVdcId(vdcId); + + + //更新vdc的cpu和资源信息 + List batchUpdateVdcCpuList = new ArrayList<>(); + List batchUpdateVdcMemList = new ArrayList<>(); + + //批量新插入的 + List batchNewInsertVdcCpuList = new ArrayList<>(); + List batchNewInsertVdcMemList = new ArrayList<>(); + + List workOrderVdcCpuMemDoList = new ArrayList<>(); + List applyArchitectureList = + applyModifyVdcResourceParam.getArchitectureResourceList(); + applyArchitectureList.forEach(architectureResource -> { + + //cpu + CloudWorkOrderVdcCpuMemDo cpuDo = new CloudWorkOrderVdcCpuMemDo(); + formatWorkOrderCommon(cpuDo, loginUserVo, workOrderStatus); + cpuDo.setWorkOrderId(workOrderId); + cpuDo.setArchitecture(architectureResource.getArchitectureType()); + cpuDo.setResourceType(ArchitectureResourceType.CPU); + cpuDo.setUnit(MemUnit.GB); + cpuDo.setApplySize(architectureResource.getApplyCpu()); + cpuDo.setOldSize(0); + CloudVdcCpuDo oldVdcCpuDo = oldVdcCpuList.stream().filter(item -> Objects.equals(item.getArchitecture(), + architectureResource.getArchitectureType())) + .findFirst().orElse(null); + if (Objects.nonNull(oldVdcCpuDo)) { + cpuDo.setOldSize(oldVdcCpuDo.getVcpus()); + } else { + //变更前vdc该架构的车贷cpu资源不存在,则新增 + CloudVdcCpuDo newInsertVdcCpuDo = new CloudVdcCpuDo(); + newInsertVdcCpuDo.setVdcId(vdcId); + newInsertVdcCpuDo.setVcpus(architectureResource.getApplyCpu()); + newInsertVdcCpuDo.setArchitecture(architectureResource.getArchitectureType()); + newInsertVdcCpuDo.setCreateBy(loginUserVo.getUserId()); + newInsertVdcCpuDo.setCreateTime(new Date()); + batchNewInsertVdcCpuList.add(newInsertVdcCpuDo); + } + + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + cpuDo.setRealSize(architectureResource.getApplyCpu()); + + if (Objects.nonNull(oldVdcCpuDo)) { + oldVdcCpuDo.setVcpus(architectureResource.getApplyCpu()); + oldVdcCpuDo.setUpdateBy(loginUserVo.getUserId()); + oldVdcCpuDo.setUpdateTime(new Date()); + batchUpdateVdcCpuList.add(oldVdcCpuDo); + } + } + workOrderVdcCpuMemDoList.add(cpuDo); + + + //内存信息 + CloudWorkOrderVdcCpuMemDo memDo = new CloudWorkOrderVdcCpuMemDo(); + formatWorkOrderCommon(memDo, loginUserVo, workOrderStatus); + memDo.setWorkOrderId(workOrderId); + memDo.setArchitecture(architectureResource.getArchitectureType()); + memDo.setResourceType(ArchitectureResourceType.MEM); + memDo.setApplySize(architectureResource.getApplyMem()); + memDo.setUnit(MemUnit.GB); + memDo.setApplySize(architectureResource.getApplyMem()); + memDo.setOldSize(0); + CloudVdcMemDo oldVdcMemDo = oldVdcMemList.stream().filter(item -> Objects.equals(item.getArchitecture(), + architectureResource.getArchitectureType())) + .findFirst().orElse(null); + if (Objects.nonNull(oldVdcMemDo)) { + memDo.setOldSize(oldVdcMemDo.getMem()); + } else { + //变更前vdc该架构的车贷cpu资源不存在,则新增 + CloudVdcMemDo newInsertVdcMemDo = new CloudVdcMemDo(); + newInsertVdcMemDo.setVdcId(vdcId); + newInsertVdcMemDo.setMem(architectureResource.getApplyMem()); + newInsertVdcMemDo.setMemUnit(MemUnit.GB); + newInsertVdcMemDo.setArchitecture(architectureResource.getArchitectureType()); + newInsertVdcMemDo.setCreateBy(loginUserVo.getUserId()); + newInsertVdcMemDo.setCreateTime(new Date()); + batchNewInsertVdcMemList.add(newInsertVdcMemDo); + } + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + memDo.setRealSize(architectureResource.getApplyMem()); + + if (Objects.nonNull(oldVdcCpuDo)) { + oldVdcMemDo.setMem(architectureResource.getApplyMem()); + oldVdcMemDo.setUpdateBy(loginUserVo.getUserId()); + oldVdcMemDo.setUpdateTime(new Date()); + batchUpdateVdcMemList.add(oldVdcMemDo); + } + } + workOrderVdcCpuMemDoList.add(memDo); + }); + + if (!workOrderVdcCpuMemDoList.isEmpty()) { + cloudWorkOrderVdcCpuMemService.saveBatch(workOrderVdcCpuMemDoList); + } + + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + if (!batchUpdateVdcCpuList.isEmpty()) { + cloudVdcCpuService.updateBatchById(batchUpdateVdcCpuList); + } + if (!batchUpdateVdcMemList.isEmpty()) { + cloudVdcMemService.updateBatchById(batchUpdateVdcMemList); + } + if (!batchNewInsertVdcCpuList.isEmpty()) { + cloudVdcCpuService.saveBatch(batchNewInsertVdcCpuList); + } + if (!batchNewInsertVdcMemList.isEmpty()) { + cloudVdcMemService.saveBatch(batchNewInsertVdcMemList); + } + } + } + + /** + * 封装申请VDC工单相同部分 + * + * @param baseDo + * @param loginUserVo + * @param workOrderStatus + */ + private void formatWorkOrderCommon(BaseDo baseDo, LoginUserVo loginUserVo, WorkOrderStatus workOrderStatus) { + Date now = new Date(); + baseDo.setCreateTime(now); + baseDo.setCreateBy(loginUserVo.getUserId()); + if (Objects.equals(workOrderStatus, WorkOrderStatus.CHECK_PASS)) { + baseDo.setUpdateBy(loginUserVo.getUserId()); + baseDo.setUpdateTime(now); + } + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/WorkOrderServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/WorkOrderServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..67110c2a8f0939ec82bd4b73531f395f1e68c8a6 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/WorkOrderServiceImpl.java @@ -0,0 +1,2072 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.DateUtils; +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.*; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.constant.KylinCloudManageConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseOrderConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.req.*; +import com.hnkylin.cloud.manage.entity.mc.resp.*; +import com.hnkylin.cloud.manage.entity.req.workorder.*; +import com.hnkylin.cloud.manage.entity.resp.network.NetworkConfigRespDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcArchitectureUsedResourceDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcModifyArchitectureResourceRespDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcModifyResourceRespDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcUsedResourceDto; +import com.hnkylin.cloud.manage.entity.resp.workorder.*; +import com.hnkylin.cloud.manage.mapper.WorkOrderMapper; +import com.hnkylin.cloud.manage.service.*; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@Service +public class WorkOrderServiceImpl implements WorkOrderService { + + @Resource + private CloudWorkOrderService cloudWorkOrderService; + + @Resource + private CloudUserService cloudUserService; + + @Resource + private CloudWorkOrderUserService cloudWorkOrderUserService; + + @Resource + private CloudWorkOrderDeferredMachineService cloudWorkOrderDeferredMachineService; + + + @Resource + private CloudWorkOrderServerVmService cloudWorkOrderServerVmService; + + @Resource + private CloudWorkOrderModifyServerVmService cloudWorkOrderModifyServerVmService; + + @Resource + private CloudWorkOrderServerVmDiskService cloudWorkOrderServerVmDiskService; + + + @Resource + private CloudWorkOrderServerVmNetworkService cloudWorkOrderServerVmNetworkService; + + @Resource + private CloudOrganizationService cloudOrganizationService; + + @Resource + private CloudWorkOrderDeferredMachineService deferredMachineService; + + + @Resource + private WorkOrderMapper workOrderMapper; + + + @Resource + private CloudUserMachineService userMachineService; + + @Resource + private NetworkConfigService networkConfigService; + + + @Resource + private McServerVmService mcServerVmService; + + @Resource + private CloudWorkOrderServerVmIsoService cloudWorkOrderServerVmIsoService; + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private VdcService vdcService; + + @Resource + private UserService userService; + + @Resource + private RoleService roleService; + + @Resource + private CloudUserRoleService cloudUserRoleService; + + @Resource + private CloudWorkOrderVdcService cloudWorkOrderVdcService; + + @Resource + private CloudWorkOrderVdcCpuMemService cloudWorkOrderVdcCpuMemService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private OrgService orgService; + + @Resource + private CloudVdcStorageService cloudVdcStorageService; + + @Resource + private CloudVdcCpuService cloudVdcCpuService; + + @Resource + private CloudVdcMemService cloudVdcMemService; + + @Override + public PageData pageWorkOrder(WorkOrderPageParam workOrderPageParam, + LoginUserVo loginUserVo) { + + + //根据登录用户,登录用户可见的工单 + List userDoList = userService.userVisibleUserList(loginUserVo.getUserId()); + List userIdList = userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList()); + workOrderPageParam.setVisibleUserIdList(userIdList); + + PageHelper.startPage(workOrderPageParam.getPageNo(), workOrderPageParam.getPageSize()); + List list = workOrderMapper.pageWorkOrder(workOrderPageParam); + PageInfo pageInfo = new PageInfo<>(list); + + pageInfo.getList().forEach(workOrder -> { + workOrder.setTypeDesc(workOrder.getType().getDesc()); + workOrder.setStatusDesc(workOrder.getStatus().getDesc()); + if (StringUtils.isBlank(workOrder.getApplyUser())) { + workOrder.setApplyUser(workOrder.getUserName()); + } + }); + PageData pageData = new PageData(pageInfo); + return pageData; + } + + + @Override + @Transactional + public void batchCheck(BatchCheckParam batchCheckParam, LoginUserVo loginUserVo) { + CloudWorkOrderDo wrapperDo = new CloudWorkOrderDo(); + wrapperDo.setStatus(WorkOrderStatus.WAIT_CHECK); + QueryWrapper wrapper = new QueryWrapper<>(wrapperDo); + wrapper.in("id", batchCheckParam.getWorkOrderIds()); + List workOrderDoList = cloudWorkOrderService.list(wrapper); + if (workOrderDoList.size() > 0) { + + CommonCheckParam commonCheckParam = new CommonCheckParam(); + commonCheckParam.setAuditOpinion(batchCheckParam.getAuditOpinion()); + workOrderDoList.forEach(workOrderDo -> { + commonCheckParam.setWorkOrderId(workOrderDo.getId()); + + if (Objects.equals(batchCheckParam.getCheckStatus(), WorkOrderStatus.CHECK_NO_PASS)) { + refuseWorkOrder(commonCheckParam, loginUserVo); + } else { + //判断工单类型,遍历进行对应的审核 + switch (workOrderDo.getType()) { + case REGISTER_USER: + checkPassRegister(commonCheckParam, loginUserVo); + break; + case MODIFY_USER: + checkPassUpdateUser(commonCheckParam, loginUserVo); + break; + case DEFERRED_SERVERVM: + checkPassDeferred(commonCheckParam, loginUserVo); + break; + default: + break; + } + } + + + }); + } + } + + @Override + @Transactional + public void checkPassRegister(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo) { + + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(commonCheckParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_PASS, commonCheckParam + .getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + //审核通过,激活用户 + CloudUserDo cloudUserDo = cloudUserService.getById(cloudWorkOrderDo.getUserId()); + cloudUserDo.setStatus(CloudUserStatus.ACTIVATE); + cloudUserDo.setUpdateBy(loginUserVo.getUserId()); + cloudUserDo.setUpdateTime(new Date()); + cloudUserService.updateById(cloudUserDo); + + //插入,自服务用户,用户角色关联表 + CloudRoleDo selfServiceRole = roleService.getSelfServiceRole(); + CloudUserRoleDo userRoleDo = new CloudUserRoleDo(); + userRoleDo.setRoleId(selfServiceRole.getId()); + userRoleDo.setUserId(cloudUserDo.getId()); + userRoleDo.setCreateBy(loginUserVo.getUserId()); + userRoleDo.setCreateTime(new Date()); + cloudUserRoleService.save(userRoleDo); + + } + + /* + * 判断工单是否已审核过,防止重复审核 + */ + private void judgeAlreadyCheck(CloudWorkOrderDo cloudWorkOrderDo) { + if (!Objects.equals(cloudWorkOrderDo.getStatus(), WorkOrderStatus.WAIT_CHECK)) { + throw new KylinException(KylinHttpResponseOrderConstants.WORK_ORDER_ALREADY_CHECK); + } + } + + /** + * 封装基础审核信息 + */ + private void formatCommonCheckWorkOrder(CloudWorkOrderDo cloudWorkOrderDo, WorkOrderStatus status, String + auditOpinion, LoginUserVo loginUserVo) { + Date now = new Date(); + cloudWorkOrderDo.setStatus(status); + cloudWorkOrderDo.setAuditOpinion(auditOpinion); + cloudWorkOrderDo.setAuditBy(loginUserVo.getUserId()); + cloudWorkOrderDo.setAuditTime(now); + cloudWorkOrderDo.setUpdateBy(loginUserVo.getUserId()); + cloudWorkOrderDo.setUpdateTime(now); + + } + + @Override + @Transactional + public void checkPassUpdateUser(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo) { + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(commonCheckParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_PASS, commonCheckParam + .getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + //审核通过,修改用户真实姓名 + CloudWorkOrderUserDo wrapperDo = new CloudWorkOrderUserDo(); + wrapperDo.setWorkOrderId(commonCheckParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(wrapperDo); + CloudWorkOrderUserDo cloudWorkOrderUserDo = cloudWorkOrderUserService.getOne(wrapper); + + //设置用户真实姓名为新真实姓名 + CloudUserDo cloudUserDo = cloudUserService.getById(cloudWorkOrderDo.getUserId()); + cloudUserDo.setRealName(cloudWorkOrderUserDo.getNewRealName()); + cloudUserDo.setUpdateBy(loginUserVo.getUserId()); + cloudUserDo.setUpdateTime(new Date()); + cloudUserService.updateById(cloudUserDo); + + } + + @Override + @Transactional + public void checkPassDeferred(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo) { + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(commonCheckParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_PASS, commonCheckParam + .getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + + //审核通过,增加用户云服务器到期时间 + CloudWorkOrderDeferredMachineDo wrapperDo = new CloudWorkOrderDeferredMachineDo(); + wrapperDo.setWorkOrderId(commonCheckParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(wrapperDo); + + CloudWorkOrderDeferredMachineDo deferredMachineDo = cloudWorkOrderDeferredMachineService.getOne(wrapper); + + + CloudUserMachineDo userMachineDo = getUserMachineByUuid(deferredMachineDo.getUserMachineUuid(), + cloudWorkOrderDo.getUserId()); + + userMachineDo.setDeadlineTime(deferredMachineDo.getDeadlineTime()); + //新的截至时间大于当期时间,则该用户已拥有云服务器为非过期 + if (deferredMachineDo.getDeadlineTime().getTime() > System.currentTimeMillis()) { + userMachineDo.setDeadlineFlag(Boolean.FALSE); + } + userMachineDo.setUpdateBy(loginUserVo.getUserId()); + userMachineDo.setUpdateTime(new Date()); + userMachineService.updateById(userMachineDo); + } + + + /** + * 获取用户云服务器关系记录 + * + * @param uuid + * @param userId + * @return + */ + private CloudUserMachineDo getUserMachineByUuid(String uuid, Integer userId) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setUserId(userId); + cloudUserMachineDo.setMachineUuid(uuid); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + CloudUserMachineDo userMachineDo = userMachineService.getOne(queryWrapper); + return userMachineDo; + } + + @Override + public void refuseWorkOrder(CommonCheckParam commonCheckParam, LoginUserVo loginUserVo) { + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(commonCheckParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_NO_PASS, commonCheckParam + .getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + //如果是拒绝注册用户审核,则将申请用户标记为已删除 + if (Objects.equals(cloudWorkOrderDo.getType(), WorkOrderType.REGISTER_USER)) { + CloudUserDo cloudUserDo = cloudUserService.getById(cloudWorkOrderDo.getUserId()); + cloudUserDo.setDeleteFlag(true); + cloudUserDo.setDeleteBy(loginUserVo.getUserId()); + cloudUserDo.setDeleteTime(new Date()); + cloudUserService.updateById(cloudUserDo); + } + + } + + private void formatBaseWorkOrderDetail(Integer workOrderId, BaseWorkOrderDetailDto baseWorkOrderDetailDto) { + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderId); + CloudUserDo cloudUserDo = cloudUserService.getById(cloudWorkOrderDo.getUserId()); + baseWorkOrderDetailDto.setWorkOrderTarget(cloudWorkOrderDo.getTarget()); + baseWorkOrderDetailDto.setWorkOrderType(cloudWorkOrderDo.getType()); + baseWorkOrderDetailDto.setWorkOrderTypeDesc(cloudWorkOrderDo.getType().getDesc()); + baseWorkOrderDetailDto.setApplyReason(cloudWorkOrderDo.getApplyReason()); + baseWorkOrderDetailDto.setStatus(cloudWorkOrderDo.getStatus()); + baseWorkOrderDetailDto.setStatusDesc(cloudWorkOrderDo.getStatus().getDesc()); + baseWorkOrderDetailDto.setUserId(cloudWorkOrderDo.getUserId()); + baseWorkOrderDetailDto.setApplyUser(cloudUserDo.getUserName()); + if (StringUtils.isNotBlank(cloudUserDo.getRealName())) { + baseWorkOrderDetailDto.setApplyUser(cloudUserDo.getRealName()); + } + + baseWorkOrderDetailDto.setApplyTime(DateUtils.format(cloudWorkOrderDo.getCreateTime(), + DateUtils.DATE_ALL_PATTEN)); + baseWorkOrderDetailDto.setAuditOpinion(cloudWorkOrderDo.getAuditOpinion()); + + if (Objects.nonNull(cloudWorkOrderDo.getAuditTime())) { + baseWorkOrderDetailDto.setAuditionTime(DateUtils.format(cloudWorkOrderDo.getAuditTime(), + DateUtils.DATE_ALL_PATTEN)); + } + if (!Objects.equals(cloudWorkOrderDo.getStatus(), WorkOrderStatus.WAIT_CHECK) && Objects.nonNull(cloudWorkOrderDo.getAuditBy()) && cloudWorkOrderDo.getAuditBy() > 0) { + CloudUserDo auditionUser = cloudUserService.getById(cloudWorkOrderDo.getAuditBy()); + baseWorkOrderDetailDto.setAuditionUser(auditionUser.getUserName()); + if (StringUtils.isNotBlank(auditionUser.getRealName())) { + baseWorkOrderDetailDto.setAuditionUser(auditionUser.getRealName()); + } + + } + CloudOrganizationDo organizationDo = cloudOrganizationService.getById(cloudUserDo.getOrganizationId()); + baseWorkOrderDetailDto.setOrgName(organizationDo.getOrganizationName()); + + } + + @Override + public ApplyServerVmDetailRespDto getApplyServerVmDetailByWorkOrderId(Integer workOrderId, + LoginUserVo loginUserVo) { + ApplyServerVmDetailRespDto applyServerVmDetailRespDto = new ApplyServerVmDetailRespDto(); + + formatBaseWorkOrderDetail(workOrderId, applyServerVmDetailRespDto); + + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderId); + //查询服务器申请详情表 + CloudWorkOrderServerVmDo queryServerVmDo = new CloudWorkOrderServerVmDo(); + queryServerVmDo.setWorkOrderId(workOrderId); + QueryWrapper wrapper = new QueryWrapper<>(queryServerVmDo); + CloudWorkOrderServerVmDo serverVmDo = cloudWorkOrderServerVmService.getOne(wrapper); + + if (Objects.nonNull(serverVmDo)) { + applyServerVmDetailRespDto.setApplyNum(serverVmDo.getApplyNum()); + applyServerVmDetailRespDto.setApplyServerVmType(serverVmDo.getApplyServervmType()); + applyServerVmDetailRespDto.setIfModifyApplyNum(false); + applyServerVmDetailRespDto.setModifyApplyNum(serverVmDo.getModifyApplyNum()); + + applyServerVmDetailRespDto.setUseMonth(serverVmDo.getUseMonth()); + applyServerVmDetailRespDto.setDeadlineType(serverVmDo.getDeadlineType()); + applyServerVmDetailRespDto.setDeadlineTypeDesc(serverVmDo.getDeadlineType().getDesc()); + applyServerVmDetailRespDto.setOsMachine(serverVmDo.getOsMachine()); + applyServerVmDetailRespDto.setArchitecture(serverVmDo.getArchitecture()); + + + applyServerVmDetailRespDto.setCpu(serverVmDo.getCpu()); + applyServerVmDetailRespDto.setModifyCpu(serverVmDo.getModifyCpu()); + applyServerVmDetailRespDto.setIfModifyCpu(false); + applyServerVmDetailRespDto.setMem(serverVmDo.getMem()); + applyServerVmDetailRespDto.setModifyMem(serverVmDo.getModifyMem()); + applyServerVmDetailRespDto.setIfModifyMem(false); + applyServerVmDetailRespDto.setDescription(serverVmDo.getDescription()); + applyServerVmDetailRespDto.setMcCloneType(serverVmDo.getCloneType()); + applyServerVmDetailRespDto.setClusterName(cloudClusterService.getById(serverVmDo.getClusterId()).getName()); + + if (Objects.equals(cloudWorkOrderDo.getStatus(), WorkOrderStatus.CHECK_PASS)) { + if (!Objects.equals(serverVmDo.getCpu(), serverVmDo.getModifyCpu())) { + applyServerVmDetailRespDto.setIfModifyCpu(true); + } + if (!Objects.equals(serverVmDo.getMem(), serverVmDo.getModifyMem())) { + applyServerVmDetailRespDto.setIfModifyMem(true); + } + if (!Objects.equals(serverVmDo.getApplyNum(), serverVmDo.getModifyApplyNum())) { + applyServerVmDetailRespDto.setIfModifyApplyNum(true); + } + + } + applyServerVmDetailRespDto.setMenUtil(serverVmDo.getMemUnit()); + //查询硬盘信息 + + List diskDoList = getDisksByWorkOrderId(workOrderId); + List disks = new ArrayList<>(); + if (diskDoList.size() > 0) { + diskDoList.forEach(disk -> { + ServerVmDiskDto diskDto = new ServerVmDiskDto(); + diskDto.setDiskSize(disk.getDiskSize()); + diskDto.setPurpose(disk.getPurpose()); + diskDto.setOldDiskSize(disk.getOldDiskSize()); + diskDto.setModifyType(disk.getModifyType()); + disks.add(diskDto); + }); + } + applyServerVmDetailRespDto.setDisks(disks); + + //查询网卡信息 + List networkDoList = getNetworkListByWorkOrderId(workOrderId); + List networks = new ArrayList<>(); + networkDoList.forEach(network -> { + ServerVmNetworkDto serverVmNetworkDto = new ServerVmNetworkDto(); + serverVmNetworkDto.setPurpose(network.getPurpose()); + serverVmNetworkDto.setModifyType(network.getModifyType()); + serverVmNetworkDto.setIpBindMac(network.getIpBindMac()); + serverVmNetworkDto.setManualSetIp(network.getManualSetIp()); + serverVmNetworkDto.setAutomaticAcqIp(network.getAutomaticAcqIp()); + serverVmNetworkDto.setIp(network.getIp()); + serverVmNetworkDto.setMask(network.getMask()); + serverVmNetworkDto.setGw(network.getGw()); + serverVmNetworkDto.setDns1(network.getDns1()); + serverVmNetworkDto.setDns2(network.getDns2()); + boolean setIpInfo = network.getIpBindMac() || network.getManualSetIp() || network.getAutomaticAcqIp(); + serverVmNetworkDto.setSetIpInfo(setIpInfo); + networks.add(serverVmNetworkDto); + }); + applyServerVmDetailRespDto.setNetworks(networks); + + + List isoDoList = getIsoByWorkOrderId(serverVmDo.getWorkOrderId()); + List isoDtoList = new ArrayList<>(); + if (!isoDoList.isEmpty()) { + isoDoList.stream().forEach(iso -> { + ServerVmIsoDto vmIsoDto = new ServerVmIsoDto(); + vmIsoDto.setIsoFile(iso.getIsoFile()); + vmIsoDto.setModifyType(iso.getModifyType()); + vmIsoDto.setOldIsoFile(iso.getOldIsoFile()); + isoDtoList.add(vmIsoDto); + }); + } + applyServerVmDetailRespDto.setIsoList(isoDtoList); + + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.TEMPLATE)) { + //获取模板名称 + QueryMcServerDetailParamReq queryMcServerDetailParamReq = new QueryMcServerDetailParamReq(); + queryMcServerDetailParamReq.setServervmId(serverVmDo.getTemplateId()); + McServerVmDetailResp mcServerVmDetailResp = + mcServerVmService.getMcServerVmDetailByServerVmId(serverVmDo.getClusterId(), + queryMcServerDetailParamReq, + loginUserVo); + applyServerVmDetailRespDto.setTemplateName(mcServerVmDetailResp.getAlisname()); + } + + } + + return applyServerVmDetailRespDto; + } + + @Override + public ModifyServerVmDetailRespDto getModifyServerVmDetailByWorkOrderId(Integer workOrderId) { + ModifyServerVmDetailRespDto modifyServerVmDetailRespDto = new ModifyServerVmDetailRespDto(); + + formatBaseWorkOrderDetail(workOrderId, modifyServerVmDetailRespDto); + + //查询变更云服务器详情 + CloudWorkOrderModifyServerVmDo modifyServerVmDo = new CloudWorkOrderModifyServerVmDo(); + modifyServerVmDo.setWorkOrderId(workOrderId); + QueryWrapper wrapper = new QueryWrapper<>(modifyServerVmDo); + CloudWorkOrderModifyServerVmDo serverVmDo = cloudWorkOrderModifyServerVmService.getOne(wrapper); + + //查询用户已经拥有的云服务器 + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderId); + + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setUserId(cloudWorkOrderDo.getUserId()); + cloudUserMachineDo.setMachineUuid(serverVmDo.getMachineUuid()); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + + CloudUserMachineDo userMachineDo = userMachineService.getOne(queryWrapper); + if (Objects.nonNull(userMachineDo)) { + + + String deadLineTime = DateUtils.format(serverVmDo.getDeadlineTime(), DateUtils.DATE_ALL_PATTEN); + + modifyServerVmDetailRespDto.setDeadLineTime(deadLineTime); + modifyServerVmDetailRespDto.setDeadlineType(serverVmDo.getDeadlineType()); + modifyServerVmDetailRespDto.setDeadlineTypeDesc(serverVmDo.getDeadlineType().getDesc()); + modifyServerVmDetailRespDto.setOsMachine(serverVmDo.getOsMachine()); + modifyServerVmDetailRespDto.setArchitecture(serverVmDo.getArchitecture()); + modifyServerVmDetailRespDto.setCpu(serverVmDo.getCpu()); + modifyServerVmDetailRespDto.setIfModifyCpu(!Objects.equals(serverVmDo.getCpu(), + serverVmDo.getOriginalCpu())); + modifyServerVmDetailRespDto.setOriginalCpu(serverVmDo.getOriginalCpu()); + + modifyServerVmDetailRespDto.setMem(serverVmDo.getMem()); + modifyServerVmDetailRespDto.setMenUtil(serverVmDo.getMemUnit()); + modifyServerVmDetailRespDto.setOriginalMem(serverVmDo.getOriginalMem()); + modifyServerVmDetailRespDto.setIfModifyMem(!Objects.equals(serverVmDo.getMem(), + serverVmDo.getOriginalMem())); + + + //查询硬盘信息 + CloudWorkOrderServerVmDiskDo queryDiskDo = new CloudWorkOrderServerVmDiskDo(); + queryDiskDo.setWorkOrderId(workOrderId); + QueryWrapper diskQueryWrapper = new QueryWrapper<>(queryDiskDo); + List diskDoList = cloudWorkOrderServerVmDiskService.list(diskQueryWrapper); + List disks = new ArrayList<>(); + if (diskDoList.size() > 0) { + diskDoList.forEach(disk -> { + ServerVmDiskDto diskDto = new ServerVmDiskDto(); + diskDto.setDiskSize(disk.getDiskSize()); + diskDto.setPurpose(disk.getPurpose()); + diskDto.setModifyType(disk.getModifyType()); + diskDto.setOldDiskSize(disk.getOldDiskSize()); + disks.add(diskDto); + }); + } + modifyServerVmDetailRespDto.setDisks(disks); + + //查询网卡信息 + CloudWorkOrderServerVmNetworkDo queryNetworkDo = new CloudWorkOrderServerVmNetworkDo(); + queryNetworkDo.setWorkOrderId(workOrderId); + QueryWrapper networkQueryWrapper = new QueryWrapper<>(queryNetworkDo); + List networkDoList = + cloudWorkOrderServerVmNetworkService.list(networkQueryWrapper); + List networks = new ArrayList<>(); + networkDoList.forEach(network -> { + ServerVmNetworkDto serverVmNetworkDto = new ServerVmNetworkDto(); + serverVmNetworkDto.setPurpose(network.getPurpose()); + serverVmNetworkDto.setModifyType(network.getModifyType()); + serverVmNetworkDto.setIpBindMac(network.getIpBindMac()); + serverVmNetworkDto.setManualSetIp(network.getManualSetIp()); + serverVmNetworkDto.setAutomaticAcqIp(network.getAutomaticAcqIp()); + serverVmNetworkDto.setIp(network.getIp()); + serverVmNetworkDto.setMask(network.getMask()); + serverVmNetworkDto.setGw(network.getGw()); + serverVmNetworkDto.setDns1(network.getDns1()); + serverVmNetworkDto.setDns2(network.getDns2()); + boolean setIpInfo = network.getIpBindMac() || network.getManualSetIp() || network.getAutomaticAcqIp(); + serverVmNetworkDto.setSetIpInfo(setIpInfo); + networks.add(serverVmNetworkDto); + }); + modifyServerVmDetailRespDto.setNetworks(networks); + + } + return modifyServerVmDetailRespDto; + } + + @Override + public WorkOrderUserDetailRespDto getWorkOrderUserDetailByWorkOrderId(Integer workOrderId) { + WorkOrderUserDetailRespDto workOrderUserDetailRespDto = new WorkOrderUserDetailRespDto(); + + formatBaseWorkOrderDetail(workOrderId, workOrderUserDetailRespDto); + + CloudUserDo cloudUserDo = cloudUserService.getById(workOrderUserDetailRespDto.getUserId()); + workOrderUserDetailRespDto.setUserName(cloudUserDo.getUserName()); + workOrderUserDetailRespDto.setRealName(cloudUserDo.getRealName()); + workOrderUserDetailRespDto.setMobile(cloudUserDo.getMobile()); + if (cloudUserDo.getOrganizationId() > 0) { + workOrderUserDetailRespDto.setOrganizationName(cloudOrganizationService.getById(cloudUserDo + .getOrganizationId()).getOrganizationName()); + } + //修改账号,需要查询旧真实姓名,及新真实姓名 + if (Objects.equals(workOrderUserDetailRespDto.getWorkOrderType(), WorkOrderType.MODIFY_USER)) { + CloudWorkOrderUserDo queryDo = new CloudWorkOrderUserDo(); + queryDo.setWorkOrderId(workOrderId); + QueryWrapper wrapper = new QueryWrapper<>(queryDo); + CloudWorkOrderUserDo cloudWorkOrderUserDo = cloudWorkOrderUserService.getOne(wrapper); + workOrderUserDetailRespDto.setNewRealName(cloudWorkOrderUserDo.getNewRealName()); + workOrderUserDetailRespDto.setRealName(cloudWorkOrderUserDo.getOldRealName()); + } + return workOrderUserDetailRespDto; + } + + + /** + * 审核-云服务器时封装相同的孕妇器详情 封装相同的mc云服务器基础信息 + * + * @param mcServerVmDetailResp + * @param commonServerVmDetailResp + */ + private void commonFormatMcServerDetail(McServerVmDetailResp mcServerVmDetailResp, + CommonServerVmDetailResp commonServerVmDetailResp) { + + commonServerVmDetailResp.setArchitecture(mcServerVmDetailResp.getArchitecture()); + commonServerVmDetailResp.setSystemType(mcServerVmDetailResp.getSystemType()); + commonServerVmDetailResp.setOsMachine(mcServerVmDetailResp.getOsMachine()); + commonServerVmDetailResp.setSelectCluster(mcServerVmDetailResp.getSelectCluster()); + commonServerVmDetailResp.setSelectClusterUuid(mcServerVmDetailResp.getSelectClusterUuid()); + commonServerVmDetailResp.setStorageLocationId(mcServerVmDetailResp.getStorageLocationId()); + commonServerVmDetailResp.setSelectTagIds(mcServerVmDetailResp.getSelectTagIds()); + commonServerVmDetailResp.setSelectTagNames(mcServerVmDetailResp.getSelectTagNames()); + if (Objects.equals(mcServerVmDetailResp.getServerClusterType(), McServerClusterType.AUTO.getValue())) { + commonServerVmDetailResp.setServerClusterType(McServerClusterType.AUTO); + } else if (Objects.equals(mcServerVmDetailResp.getServerClusterType(), McServerClusterType.CUSTOM.getValue())) { + commonServerVmDetailResp.setServerClusterType(McServerClusterType.CUSTOM); + } else if (Objects.equals(mcServerVmDetailResp.getServerClusterType(), + McServerClusterType.BIND_RESOURCE.getValue())) { + commonServerVmDetailResp.setServerClusterType(McServerClusterType.BIND_RESOURCE); + } + } + + /** + * 封装云服务器审核时-计算资源,存储资源 + * + * @param commonServerVmDetailResp + */ + private void commonFormatMcServerClusterAndLocation(String architecture, + CommonServerVmDetailResp commonServerVmDetailResp, + Integer clusterId, + LoginUserVo loginUserVo, Integer workOrderUserId) { + + //获取mc存储位置列表 + List storageLocationList = + mcServerVmService.getMcStorageLocationList(clusterId, loginUserVo); + commonServerVmDetailResp.setStorageLocationList(storageLocationList); + + //根据模板架构获取计算资源节点 + QueryMcClusterParamReq queryMcClusterParamReq = new QueryMcClusterParamReq(); + queryMcClusterParamReq.setPlateformType(architecture); + if (Objects.equals(architecture, McArchitectureType.LOWER_86_64.getName())) { + queryMcClusterParamReq.setPlateformType(McArchitectureType.X86_64.name()); + } + + List clusterList = mcServerVmService.getMcClusterList(clusterId, + queryMcClusterParamReq, loginUserVo); + commonServerVmDetailResp.setClusterList(clusterList); + //查询mc中主机绑定资源 + List clusterBindResourceList = + mcServerVmService.getMcClusterBindResourceList(clusterId, loginUserVo); + commonServerVmDetailResp.setClusterBindResourceList(clusterBindResourceList); + + //查询云管中网络配置信息 + + CloudVdcDo vdcDo = vdcService.getUserOrgBindVdc(workOrderUserId); + List networkList = + networkConfigService.listNetworkListByVdcIdAndClusterId(vdcDo.getId(), clusterId); + commonServerVmDetailResp.setNetworkConfigList(networkList); + } + + @Override + public PassApplyServerVmDetailRespDto passApplyServerVmDetailRespDto(WorkOrderDetailParam workOrderDetailParam, + LoginUserVo loginUserVo) { + + PassApplyServerVmDetailRespDto passApplyServerVmDetailRespDto = new PassApplyServerVmDetailRespDto(); + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderDetailParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + + //查询服务器申请详情表 + CloudWorkOrderServerVmDo queryServerVmDo = new CloudWorkOrderServerVmDo(); + queryServerVmDo.setWorkOrderId(workOrderDetailParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(queryServerVmDo); + CloudWorkOrderServerVmDo serverVmDo = cloudWorkOrderServerVmService.getOne(wrapper); + + passApplyServerVmDetailRespDto.setAliasName(serverVmDo.getServervmName()); + passApplyServerVmDetailRespDto.setApplyServerVmType(serverVmDo.getApplyServervmType()); + passApplyServerVmDetailRespDto.setCpu(serverVmDo.getCpu()); + passApplyServerVmDetailRespDto.setMem(serverVmDo.getMem()); + passApplyServerVmDetailRespDto.setMemUnit(serverVmDo.getMemUnit()); + passApplyServerVmDetailRespDto.setApplyNum(serverVmDo.getApplyNum()); + passApplyServerVmDetailRespDto.setTemplateId(serverVmDo.getTemplateId()); + passApplyServerVmDetailRespDto.setArchitecture(serverVmDo.getArchitecture()); + passApplyServerVmDetailRespDto.setSystemType(serverVmDo.getSystemType()); + passApplyServerVmDetailRespDto.setOsMachine(serverVmDo.getOsMachine()); + + List templateInterfaceList = new ArrayList(); + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.TEMPLATE)) { + //获取模板信息 + QueryMcServerDetailParamReq queryMcServerDetailParamReq = new QueryMcServerDetailParamReq(); + queryMcServerDetailParamReq.setServervmId(serverVmDo.getTemplateId()); + McServerVmDetailResp mcServerVmDetailResp = + mcServerVmService.getMcServerVmDetailByServerVmId(serverVmDo.getClusterId(), + queryMcServerDetailParamReq, + loginUserVo); + passApplyServerVmDetailRespDto.setTemplateName(mcServerVmDetailResp.getAlisname()); + commonFormatMcServerDetail(mcServerVmDetailResp, passApplyServerVmDetailRespDto); + //模板中网卡信息 + templateInterfaceList = mcServerVmDetailResp.getInterfaceList(); + } + + //passApplyServerVmDetailRespDto.setDisks(mcServerVmDetailResp.getDisks()); + passApplyServerVmDetailRespDto.setDisks(new ArrayList<>()); + //查询申请时自定义硬盘信息 + List diskDoList = getDisksByWorkOrderId(serverVmDo.getWorkOrderId()); + if (diskDoList.size() > 0) { + diskDoList.forEach(disk -> { + McServerVmDiskDetailResp diskDto = new McServerVmDiskDetailResp(); + diskDto.setDiskSize(disk.getDiskSize()); + diskDto.setType(disk.getType()); + diskDto.setApplyId(disk.getId()); + diskDto.setModifyType(ModifyType.NONE); + passApplyServerVmDetailRespDto.getDisks().add(diskDto); + }); + } + + passApplyServerVmDetailRespDto.setInterfaceList(new ArrayList<>()); + //查询申请时的网卡列表 + List networkDoList = getNetworkListByWorkOrderId(serverVmDo.getWorkOrderId()); + for (CloudWorkOrderServerVmNetworkDo network : networkDoList) { + if (Objects.equals(network.getType(), ApplyMcServerVmType.custom)) { + McServerVmNetworkDetailResp networkDetailResp = new McServerVmNetworkDetailResp(); + networkDetailResp.setPurpose(network.getPurpose()); + networkDetailResp.setType(ApplyMcServerVmType.custom); + networkDetailResp.setApplyId(network.getId()); + networkDetailResp.setModifyType(ModifyType.NONE); + passApplyServerVmDetailRespDto.getInterfaceList().add(networkDetailResp); + } else { + if (!templateInterfaceList.isEmpty()) { + McServerVmNetworkDetailResp templateInterface = + templateInterfaceList.stream().filter(item -> Objects.equals(item.getId(), + network.getInterfaceId())) + .findFirst().orElse(null); + if (Objects.nonNull(templateInterface)) { + templateInterface.setPurpose(formatNetworkStr(templateInterface.getInterfaceType(), + templateInterface.getPortGroup(), + templateInterface.getVirtualSwitch(), templateInterface.getModelType())); + templateInterface.setApplyId(network.getId()); + templateInterface.setModifyType(ModifyType.NONE); + passApplyServerVmDetailRespDto.getInterfaceList().add(templateInterface); + } + } + + } + } + + + commonFormatMcServerClusterAndLocation(passApplyServerVmDetailRespDto.getArchitecture(), + passApplyServerVmDetailRespDto, + serverVmDo.getClusterId(), loginUserVo, cloudWorkOrderDo.getUserId()); + + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.ISO)) { + //iso光驱文件 + List isoDoList = getIsoByWorkOrderId(serverVmDo.getWorkOrderId()); + List applyIsoList = new ArrayList<>(); + if (!isoDoList.isEmpty()) { + isoDoList.stream().forEach(iso -> { + ApplyServerVmIsoDetailResp isoDetail = new ApplyServerVmIsoDetailResp(); + isoDetail.setApplyId(iso.getId()); + isoDetail.setApplyModifyType(iso.getModifyType()); + isoDetail.setModifyType(iso.getModifyType()); + isoDetail.setIsoFile(iso.getIsoFile()); + applyIsoList.add(isoDetail); + }); + } + passApplyServerVmDetailRespDto.setApplyIsoList(applyIsoList); + + //mc所以光驱文件 + passApplyServerVmDetailRespDto.setAllIsoList(mcServerVmService.mcAllIsoList(serverVmDo.getClusterId(), + loginUserVo)); + + List selectClusterList = + passApplyServerVmDetailRespDto.getClusterList().stream().map(McClusterResp::getServerAddr).collect(Collectors.toList()); + List selectClusterUUIDList = + passApplyServerVmDetailRespDto.getClusterList().stream().map(McClusterResp::getServerId).collect(Collectors.toList()); + passApplyServerVmDetailRespDto.setSelectCluster(String.join(",", selectClusterList)); + passApplyServerVmDetailRespDto.setSelectClusterUuid(String.join(",", selectClusterUUIDList)); + passApplyServerVmDetailRespDto.setStorageLocationId(passApplyServerVmDetailRespDto.getStorageLocationList().get(0).getId()); + } + + + return passApplyServerVmDetailRespDto; + } + + + @Override + public PassModifyServerVmDetailRespDto passModifyServerVmDetail(WorkOrderDetailParam workOrderDetailParam, + LoginUserVo loginUserVo) { + + PassModifyServerVmDetailRespDto passModifyServerVmDetailRespDto = new PassModifyServerVmDetailRespDto(); + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderDetailParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + + //查询变更云服务器申请表 + CloudWorkOrderModifyServerVmDo queryServerVmDo = new CloudWorkOrderModifyServerVmDo(); + queryServerVmDo.setWorkOrderId(workOrderDetailParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(queryServerVmDo); + CloudWorkOrderModifyServerVmDo modifyServerVmDo = cloudWorkOrderModifyServerVmService.getOne(wrapper); + + + passModifyServerVmDetailRespDto.setAliasName(modifyServerVmDo.getServervmName()); + passModifyServerVmDetailRespDto.setCpu(modifyServerVmDo.getCpu()); + passModifyServerVmDetailRespDto.setMem(modifyServerVmDo.getMem()); + passModifyServerVmDetailRespDto.setMemUnit(modifyServerVmDo.getMemUnit()); + + + CloudUserMachineDo userMachineDo = getUserMachineByUuid(modifyServerVmDo.getMachineUuid(), + cloudWorkOrderDo.getUserId()); + + //获取云服务器信息 + QueryMcServerDetailParamReq queryMcServerDetailParamReq = new QueryMcServerDetailParamReq(); + queryMcServerDetailParamReq.setUuid(modifyServerVmDo.getMachineUuid()); + McServerVmDetailResp mcServerVmDetailResp = + mcServerVmService.getMcServerVmDetailByServerVmUuid(userMachineDo.getClusterId(), + queryMcServerDetailParamReq, loginUserVo); + + + commonFormatMcServerDetail(mcServerVmDetailResp, passModifyServerVmDetailRespDto); + + passModifyServerVmDetailRespDto.setDisks(new ArrayList<>()); + //现mc中云服务器磁盘信息 + List oldDisks = mcServerVmDetailResp.getDisks(); + //查询申请时自定义硬盘信息 + List diskDoList = getDisksByWorkOrderId(modifyServerVmDo.getWorkOrderId()); + //用现在mc中磁盘列表和变更申请是进行对比, + oldDisks.forEach(oldDisk -> { + CloudWorkOrderServerVmDiskDo serverVmDiskDo = + diskDoList.stream().filter(diskDo -> Objects.equals(oldDisk.getId(), + diskDo.getDiskId())).findFirst().orElse(null); + if (Objects.isNull(serverVmDiskDo)) { + //说明是变更申请时间,该云服务器在mc中新增的磁盘 + oldDisk.setApplyModifyType(ModifyType.NONE); + oldDisk.setApplyId(0); + } else { + oldDisk.setApplyModifyType(serverVmDiskDo.getModifyType()); + oldDisk.setOldDiskSize(serverVmDiskDo.getOldDiskSize()); + oldDisk.setDiskSize(serverVmDiskDo.getDiskSize()); + oldDisk.setType(serverVmDiskDo.getType()); + oldDisk.setApplyId(serverVmDiskDo.getId()); + } + oldDisk.setModifyType(ModifyType.NONE); + passModifyServerVmDetailRespDto.getDisks().add(oldDisk); + }); + diskDoList.forEach(disk -> { + if (Objects.equals(disk.getDiskId(), 0L)) { + McServerVmDiskDetailResp diskDto = new McServerVmDiskDetailResp(); + diskDto.setDiskSize(disk.getDiskSize()); + diskDto.setId(0L); + diskDto.setType(ApplyMcServerVmType.custom); + diskDto.setApplyModifyType(ModifyType.ADD); + diskDto.setApplyId(disk.getId()); + diskDto.setModifyType(ModifyType.NONE); + passModifyServerVmDetailRespDto.getDisks().add(diskDto); + } + }); + + + //模板中网卡信息 + passModifyServerVmDetailRespDto.setInterfaceList(new ArrayList<>()); + List templateInterfaceList = mcServerVmDetailResp.getInterfaceList(); + //查询申请是自定义网卡信息 + List networkDoList = + getNetworkListByWorkOrderId(modifyServerVmDo.getWorkOrderId()); + //用现在mc中网卡列表和变更申请的网卡进行对比, + templateInterfaceList.forEach(oldInterfaceDo -> { + CloudWorkOrderServerVmNetworkDo serverVmNetworkDo = + networkDoList.stream().filter(network -> Objects.equals(oldInterfaceDo.getId(), + network.getInterfaceId())).findFirst().orElse(null); + oldInterfaceDo.setPurpose(formatNetworkStr(oldInterfaceDo.getInterfaceType(), oldInterfaceDo.getPortGroup(), + oldInterfaceDo.getVirtualSwitch(), oldInterfaceDo.getModelType())); + if (Objects.isNull(serverVmNetworkDo)) { + //说明是变更申请时间,该云服务器在mc中新增的网卡 + oldInterfaceDo.setApplyModifyType(ModifyType.NONE); + oldInterfaceDo.setApplyId(0); + } else { + oldInterfaceDo.setApplyModifyType(serverVmNetworkDo.getModifyType()); + oldInterfaceDo.setApplyId(serverVmNetworkDo.getId()); + } + oldInterfaceDo.setModifyType(ModifyType.NONE); + if (oldInterfaceDo.getAutomaticAcqIp()) { + oldInterfaceDo.setIp(""); + } + passModifyServerVmDetailRespDto.getInterfaceList().add(oldInterfaceDo); + }); + + + networkDoList.forEach(network -> { + if (Objects.equals(network.getInterfaceId(), 0L)) { + //变更申请是新申请的网卡 + McServerVmNetworkDetailResp networkDetailResp = new McServerVmNetworkDetailResp(); + networkDetailResp.setPurpose(network.getPurpose()); + networkDetailResp.setType(ApplyMcServerVmType.custom); + networkDetailResp.setId(0L); + networkDetailResp.setModifyType(ModifyType.NONE); + networkDetailResp.setApplyModifyType(ModifyType.ADD); + networkDetailResp.setApplyId(network.getId()); + passModifyServerVmDetailRespDto.getInterfaceList().add(networkDetailResp); + } + }); + + commonFormatMcServerClusterAndLocation(mcServerVmDetailResp.getArchitecture(), passModifyServerVmDetailRespDto, + userMachineDo.getClusterId(), loginUserVo, cloudWorkOrderDo.getUserId()); + + return passModifyServerVmDetailRespDto; + } + + /* + * 封装网络信息 + * 如 网络类型(Bridge) 交换机(TPlinksafg)端口组(102) + */ + private String formatNetworkStr(String interfaceType, String portGroup, String virtualSwitch, String modelType) { + StringBuilder purposeSb = new StringBuilder(); + + purposeSb.append(KylinCloudManageConstants.NETWORK_TYPE).append(KylinCloudManageConstants.LEFT_BRACKET) + .append(interfaceType).append(KylinCloudManageConstants.RIGHT_BRACKET) + .append(KylinCloudManageConstants.SPACE); + + purposeSb.append(KylinCloudManageConstants.MODEL_TYPE).append(KylinCloudManageConstants + .LEFT_BRACKET).append(modelType) + .append(KylinCloudManageConstants.RIGHT_BRACKET).append(KylinCloudManageConstants.SPACE); + + purposeSb.append(KylinCloudManageConstants.NETWORK_SWITCH).append(KylinCloudManageConstants + .LEFT_BRACKET).append(virtualSwitch) + .append(KylinCloudManageConstants.RIGHT_BRACKET).append(KylinCloudManageConstants.SPACE); + + purposeSb.append(KylinCloudManageConstants.NETWORK_PORT).append(KylinCloudManageConstants.LEFT_BRACKET) + .append(portGroup).append(KylinCloudManageConstants.RIGHT_BRACKET); + + return purposeSb.toString(); + } + + + /** + * 根据申请ID获取,申请时的网络信息 + */ + private List getNetworkListByWorkOrderId(Integer workOrderId) { + CloudWorkOrderServerVmNetworkDo queryNetworkDo = new CloudWorkOrderServerVmNetworkDo(); + queryNetworkDo.setWorkOrderId(workOrderId); + QueryWrapper networkQueryWrapper = new QueryWrapper<>(queryNetworkDo); + List networkDoList = + cloudWorkOrderServerVmNetworkService.list(networkQueryWrapper); + return networkDoList; + } + + + /** + * 根据申请ID获取,申请时的光驱信息 + */ + private List getIsoByWorkOrderId(Integer workOrderId) { + CloudWorkOrderServerVmIsoDo queryIsoDo = new CloudWorkOrderServerVmIsoDo(); + queryIsoDo.setWorkOrderId(workOrderId); + QueryWrapper isoQueryWrapper = new QueryWrapper<>(queryIsoDo); + List isoDoList = cloudWorkOrderServerVmIsoService.list(isoQueryWrapper); + return isoDoList; + } + + /** + * 根据申请ID获取,申请时的网络信息 + */ + private List getDisksByWorkOrderId(Integer workOrderId) { + CloudWorkOrderServerVmDiskDo queryDiskDo = new CloudWorkOrderServerVmDiskDo(); + queryDiskDo.setWorkOrderId(workOrderId); + QueryWrapper diskQueryWrapper = new QueryWrapper<>(queryDiskDo); + List diskDoList = cloudWorkOrderServerVmDiskService.list(diskQueryWrapper); + return diskDoList; + } + + private ArchitectureType changeToKcpArchitectureType(String plateformType) { + + if (Objects.equals(plateformType, McArchitectureType.X86_64.getName()) || Objects.equals(plateformType, + McArchitectureType.LOWER_86_64.getName())) { + return ArchitectureType.X86_64; + } + if (Objects.equals(plateformType, McArchitectureType.ARM.getName()) || Objects.equals(plateformType, + McArchitectureType.AARCH64.name()) || Objects.equals(plateformType, + McArchitectureType.AARCH64.getName())) { + return ArchitectureType.ARM64; + } + if (Objects.equals(plateformType, McArchitectureType.MIPS.getName())) { + return ArchitectureType.MIPS64; + } + if (Objects.equals(plateformType, McArchitectureType.sw_64.getName())) { + return ArchitectureType.SW64; + } + return ArchitectureType.X86_64; + } + + @Override + @Transactional + public void passApplyServerVm(PassApplyServerVmParam passApplyServerVmParam, LoginUserVo loginUserVo) { + + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(passApplyServerVmParam.getWorkOrderId()); + //获取申请详情 + CloudWorkOrderServerVmDo queryServerVmDo = new CloudWorkOrderServerVmDo(); + queryServerVmDo.setWorkOrderId(passApplyServerVmParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(queryServerVmDo); + CloudWorkOrderServerVmDo serverVmDo = cloudWorkOrderServerVmService.getOne(wrapper); + + //校验是否超出申请用户对应组织VDC的资源限制 + int applyServerVmCount = Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.ISO) ? 1 : + passApplyServerVmParam.getVmNumber(); + verifyIfExceedVdcResource(cloudWorkOrderDo.getUserId(), loginUserVo, applyServerVmCount, + passApplyServerVmParam.getVcpus(), + passApplyServerVmParam.getMemory(), passApplyServerVmParam.getDiskList(), + changeToKcpArchitectureType(passApplyServerVmParam.getPlateformType()) + ); + + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.ISO)) { + CheckServerNameParamReq checkServerNameParamReq = new CheckServerNameParamReq(); + checkServerNameParamReq.setServervmName(passApplyServerVmParam.getAliasName()); + mcServerVmService.checkServerNameExist(serverVmDo.getClusterId(), checkServerNameParamReq, loginUserVo); + } + + + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_PASS, + passApplyServerVmParam.getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + + Date now = new Date(); + + serverVmDo.setModifyApplyNum(passApplyServerVmParam.getVmNumber()); + serverVmDo.setModifyCpu(passApplyServerVmParam.getVcpus()); + serverVmDo.setModifyMem(passApplyServerVmParam.getMemory()); + serverVmDo.setUpdateBy(loginUserVo.getUserId()); + serverVmDo.setUpdateTime(now); + serverVmDo.setCloneType(passApplyServerVmParam.getCloneType()); + cloudWorkOrderServerVmService.updateById(serverVmDo); + + + McCreateServerVmParamReq mcCreateServerVmParamReq = new McCreateServerVmParamReq(); + BeanUtils.copyProperties(passApplyServerVmParam, mcCreateServerVmParamReq); + mcCreateServerVmParamReq.setPlateformtype(passApplyServerVmParam.getPlateformType()); + if (Objects.equals(passApplyServerVmParam.getPlateformType(), McArchitectureType.LOWER_86_64.name())) { + mcCreateServerVmParamReq.setPlateformtype(McArchitectureType.X86_64.getName()); + } + if (Objects.equals(passApplyServerVmParam.getPlateformType(), McArchitectureType.AARCH64.name())) { + mcCreateServerVmParamReq.setPlateformtype(McArchitectureType.AARCH64.getName()); + } + mcCreateServerVmParamReq.setSystemVersion(passApplyServerVmParam.getOperatingSystem()); + + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.TEMPLATE)) { + mcCreateServerVmParamReq.setServiceTemplateId(serverVmDo.getTemplateId() + ""); + } + mcCreateServerVmParamReq.setSystemType(passApplyServerVmParam.getSystemType()); + mcCreateServerVmParamReq.setDescription(serverVmDo.getDescription()); + //封装磁盘信息 + List diskCapacity = new ArrayList<>(); + + passApplyServerVmParam.getDiskList().forEach(disk -> { + //非删除类型的传到mc中, + if (!Objects.equals(disk.getModifyType(), ModifyType.DELETE)) { + McCreateServerVmDiskParam mcDisk = new McCreateServerVmDiskParam(); + mcDisk.setId(""); + mcDisk.setDiskCapacity(disk.getDiskCapacity()); + mcDisk.setLastUpdateType(LastUpdateType.add.getValue()); + diskCapacity.add(mcDisk); + } + }); + mcCreateServerVmParamReq.setDiskCapacity(diskCapacity); + //封装网卡信息 + List interfaces = new ArrayList<>(); + passApplyServerVmParam.getNetworkList().forEach(network -> { + //非删除的网卡传到mc中,进行网卡添加 + if (!Objects.equals(network.getModifyType(), ModifyType.DELETE)) { + //模板中自带的网卡信息 + if (Objects.equals(network.getType(), ApplyMcServerVmType.original)) { + McCreateServerVmInterfacesParam mcInterface = new McCreateServerVmInterfacesParam(); + createMcOriginalInterface(mcInterface, network); + interfaces.add(mcInterface); + } else { + //自定义申请的网卡信息 + interfaces.add(formatCustomNetwork(network)); + } + } + + }); + McCreateServerVmInterfacesParam existHostIpConfigParam = + interfaces.stream().filter(item -> item.getLsbind() || item.getManualSetIP() || item.getAutomaticAcqIp()).findFirst().orElse(null); + if (Objects.nonNull(existHostIpConfigParam)) { + mcCreateServerVmParamReq.setExistHostIpConfig(true); + } + mcCreateServerVmParamReq.setInterfaces(interfaces); + CloudUserDo applyUser = cloudUserService.getById(cloudWorkOrderDo.getUserId()); + mcCreateServerVmParamReq.setApplyUser(applyUser.getUserName()); + + //计算资源处理 + mcCreateServerVmParamReq.setClusterType(passApplyServerVmParam.getServerClusterType().getValue()); + mcCreateServerVmParamReq.setSelectResourceTagId(passApplyServerVmParam.getSelectResourceTagId()); + //iso文件处理 + List isoSelect = new ArrayList<>(); + int isoIndex = 0; + if (Objects.nonNull(passApplyServerVmParam.getIsoList()) && !passApplyServerVmParam.getIsoList().isEmpty()) { + for (int i = 0; i < passApplyServerVmParam.getIsoList().size(); i++) { + PassServerVmIsoParam passIso = passApplyServerVmParam.getIsoList().get(i); + if (!Objects.equals(passIso.getModifyType(), ModifyType.DELETE)) { + McCreateServerVmIsoParam isoParam = new McCreateServerVmIsoParam(); + isoParam.setId(null); + isoParam.setIsoSelect(passIso.getIsoFile()); + isoParam.setIndex(isoIndex); + isoParam.setLastUpdateType(LastUpdateType.add.getValue()); + isoParam.setDeviceName("光驱" + isoIndex); + isoSelect.add(isoParam); + isoIndex++; + } + } + } + mcCreateServerVmParamReq.setIsoSelect(isoSelect); + List mcUuidList = new ArrayList<>(); + //调用mc创建云服务器, + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.TEMPLATE)) { + mcCreateServerVmParamReq.setCloneType(passApplyServerVmParam.getCloneType().getValue().toString()); + mcUuidList = mcServerVmService.createMcServerVm(serverVmDo.getClusterId(), mcCreateServerVmParamReq, + loginUserVo, + ApplyServerVmType.TEMPLATE); + } else { + mcUuidList = mcServerVmService.createMcServerVm(serverVmDo.getClusterId(), mcCreateServerVmParamReq, + loginUserVo, + ApplyServerVmType.ISO); + } + if (mcUuidList.isEmpty()) { + throw new KylinException(KylinHttpResponseOrderConstants.CREATE_SERVERVM_ERR); + } + + //计算用户云服务器到期时间, + Date afterMonthDate = DateUtils.getMonthAfter(new Date(), serverVmDo.getUseMonth()); + Date deadlineTime = DateUtils.getDayEndTime(afterMonthDate); + //插入用户拥有的云服务器 + List userMachineDoList = new ArrayList<>(); + mcUuidList.forEach(uuid -> { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeadlineFlag(Boolean.FALSE); + cloudUserMachineDo.setDeadlineTime(deadlineTime); + cloudUserMachineDo.setUserId(cloudWorkOrderDo.getUserId()); + cloudUserMachineDo.setMachineUuid(uuid); + cloudUserMachineDo.setCreateBy(loginUserVo.getUserId()); + cloudUserMachineDo.setDeadlineType(serverVmDo.getDeadlineType()); + cloudUserMachineDo.setCreateTime(now); + cloudUserMachineDo.setClusterId(serverVmDo.getClusterId()); + userMachineDoList.add(cloudUserMachineDo); + }); + userMachineService.saveBatch(userMachineDoList); + + //管理员审核时,可能针对申请的磁盘信息进行了变动,处理变动信息 + handleDisk(passApplyServerVmParam.getDiskList(), loginUserVo, serverVmDo.getWorkOrderId(), now); + //管理员审核时,可能针对申请的网卡信息进行了变动,处理变动信息 + formatHandleNetwork(passApplyServerVmParam.getNetworkList(), loginUserVo, serverVmDo.getWorkOrderId(), now); + //管理员审核时,可能针对申请的ISO进行了变动,处理变动信息 + formatHandleIso(passApplyServerVmParam.getIsoList(), loginUserVo, serverVmDo.getWorkOrderId(), now); + + } + + + /** + * 校验是否超出VDC资源限制 + */ + private void verifyIfExceedVdcResource(Integer applyUsedId, LoginUserVo loginUserVo, Integer applyServerVmNum, + Integer cpu, Integer mem, List diskList, + ArchitectureType architectureType) { + //根据申请用户获取用户对应的组织 + CloudOrganizationDo orgDo = + cloudOrganizationService.getById(cloudUserService.getById(applyUsedId).getOrganizationId()); + //获取组织绑定的VDC + CloudVdcDo vdcDo = vdcService.getVdcByOrgId(orgDo.getId()); + //获取VDC资源使用情况 + VdcUsedResourceDto vdcResourceDto = vdcService.getVdcResourceInfo(vdcDo.getId(), loginUserVo); + + int applyCpu = applyServerVmNum * cpu; + int applyMem = applyServerVmNum * mem; + int applyStorage = + diskList.stream().collect(Collectors.summingInt(PassServerVmDiskParam::getDiskCapacity)) * applyServerVmNum; + + boolean exceedVdcCpu = false; + boolean exceedVdcMem = false; + boolean exceedVdcStorage = false; + StringBuilder exceedVdcResourceSb = + new StringBuilder(); + + //VDC-各架构资源使用情况 + List vdcArchitectureUsedResourceList = + vdcResourceDto.getVdcArchitectureUsedResourceList(); + + VdcArchitectureUsedResourceDto architectureUsedResource = + vdcArchitectureUsedResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), + architectureType)) + .findFirst().orElse(null); + //校验vdc-架构-cpu + if (Objects.isNull(architectureUsedResource) || applyCpu > architectureUsedResource.getSurplusCpu()) { + exceedVdcCpu = true; + } + //校验vdc-架构-内存 + if (Objects.isNull(architectureUsedResource) || applyMem > architectureUsedResource.getSurplusMem()) { + exceedVdcMem = true; + } + //校验存储资源 + if (applyStorage > vdcResourceDto.getSurplusStorage()) { + exceedVdcStorage = true; + } + + if (exceedVdcCpu || exceedVdcMem || exceedVdcStorage) { + exceedVdcResourceSb.append(architectureType.name()).append(KylinCloudManageConstants.ARCHITECTURE); + if (exceedVdcCpu) { + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_CPU); + } + if (exceedVdcMem) { + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_MEM); + } + if (exceedVdcStorage) { + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_STORAGE); + } + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_ALLOCATE); + throw new KylinException(exceedVdcResourceSb.toString()); + } + + } + + + /** + * 管理员审核时,可能变动了申请时的磁盘信息,将新变动的信息进行处理 + */ + private void handleDisk(List diskList, LoginUserVo loginUserVo, + Integer workOrderId, Date now) { + //查询申请时自定义硬盘信息 + List diskDoList = getDisksByWorkOrderId(workOrderId); + + List newInsertDiskList = new ArrayList<>(); + List updateDiskList = new ArrayList<>(); + + diskList.forEach(disk -> { + //管理员审核时,新添加的磁盘 + if (Objects.equals(disk.getModifyType(), ModifyType.ADD)) { + CloudWorkOrderServerVmDiskDo cloudWorkOrderServerVmDiskDo = + formatNewInsertDisk(workOrderId, disk.getDiskCapacity(), loginUserVo, now); + newInsertDiskList.add(cloudWorkOrderServerVmDiskDo); + } else if (Objects.equals(disk.getModifyType(), ModifyType.DELETE)) { + //管理员审核时删除的网卡 + CloudWorkOrderServerVmDiskDo deleteDisk = + diskDoList.stream().filter(item -> Objects.equals(item.getId(), disk.getApplyId())) + .findFirst().orElse(null); + if (Objects.nonNull(deleteDisk)) { + deleteDisk.setModifyType(ModifyType.DELETE); + deleteDisk.setUpdateBy(loginUserVo.getUserId()); + deleteDisk.setUpdateTime(now); + updateDiskList.add(deleteDisk); + } + } else { + //没有变动的磁盘, + CloudWorkOrderServerVmDiskDo noneDisk = + diskDoList.stream().filter(item -> Objects.equals(item.getId(), disk.getApplyId())) + .findFirst().orElse(null); + if (Objects.nonNull(noneDisk)) { + //比较大小是否变动,磁盘大小变动则说明,管理员审核时改了磁盘大小 + if (!Objects.equals(noneDisk.getDiskSize(), disk.getDiskCapacity())) { + noneDisk.setModifyType(ModifyType.MODIFY); + noneDisk.setOldDiskSize(noneDisk.getDiskSize()); + noneDisk.setDiskSize(disk.getDiskCapacity()); + noneDisk.setUpdateBy(loginUserVo.getUserId()); + noneDisk.setUpdateTime(now); + updateDiskList.add(noneDisk); + } + } + } + + }); + if (!newInsertDiskList.isEmpty()) { + cloudWorkOrderServerVmDiskService.saveBatch(newInsertDiskList); + } + + if (!updateDiskList.isEmpty()) { + cloudWorkOrderServerVmDiskService.updateBatchById(updateDiskList); + } + + } + + + /** + * 封装审核时,新增的磁盘 + * + * @param workOrderId + */ + private CloudWorkOrderServerVmDiskDo formatNewInsertDisk(Integer workOrderId, Integer diskSize, + LoginUserVo loginUser, Date now) { + CloudWorkOrderServerVmDiskDo cloudWorkOrderServerVmDiskDo = new CloudWorkOrderServerVmDiskDo(); + cloudWorkOrderServerVmDiskDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmDiskDo.setDiskSize(diskSize); + cloudWorkOrderServerVmDiskDo.setPurpose(""); + cloudWorkOrderServerVmDiskDo.setType(ApplyMcServerVmType.custom); + cloudWorkOrderServerVmDiskDo.setCreateBy(loginUser.getUserId()); + cloudWorkOrderServerVmDiskDo.setCreateTime(now); + cloudWorkOrderServerVmDiskDo.setDiskId(0L); + cloudWorkOrderServerVmDiskDo.setModifyType(ModifyType.ADD); + cloudWorkOrderServerVmDiskDo.setOldDiskSize(diskSize); + return cloudWorkOrderServerVmDiskDo; + } + + /** + * 封装审核时,新增的ISO + * + * @param workOrderId + */ + private CloudWorkOrderServerVmIsoDo formatNewInsertIso(Integer workOrderId, String isoFile, + LoginUserVo loginUser, Date now) { + CloudWorkOrderServerVmIsoDo cloudWorkOrderServerVmIsoDo = new CloudWorkOrderServerVmIsoDo(); + cloudWorkOrderServerVmIsoDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmIsoDo.setOldIsoFile(isoFile); + cloudWorkOrderServerVmIsoDo.setIsoFile(isoFile); + cloudWorkOrderServerVmIsoDo.setCreateBy(loginUser.getUserId()); + cloudWorkOrderServerVmIsoDo.setCreateTime(now); + cloudWorkOrderServerVmIsoDo.setModifyType(ModifyType.ADD); + return cloudWorkOrderServerVmIsoDo; + } + + /** + * 封装审核时,新增的网卡 + * + * @param workOrderId + */ + private CloudWorkOrderServerVmNetworkDo formatNewInsertNetwork(Integer workOrderId, + PassServerVmNetworkParam network, + LoginUserVo loginUser, Date now) { + CloudWorkOrderServerVmNetworkDo cloudWorkOrderServerVmDiskDo = new CloudWorkOrderServerVmNetworkDo(); + cloudWorkOrderServerVmDiskDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmDiskDo.setInterfaceId(0L); + cloudWorkOrderServerVmDiskDo.setPurpose(""); + cloudWorkOrderServerVmDiskDo.setType(ApplyMcServerVmType.custom); + cloudWorkOrderServerVmDiskDo.setCreateBy(loginUser.getUserId()); + cloudWorkOrderServerVmDiskDo.setCreateTime(now); + cloudWorkOrderServerVmDiskDo.setModifyType(ModifyType.ADD); + + cloudWorkOrderServerVmDiskDo.setIpBindMac(network.getIpBindMac()); + cloudWorkOrderServerVmDiskDo.setManualSetIp(network.getManualSetIp()); + cloudWorkOrderServerVmDiskDo.setAutomaticAcqIp(network.getAutomaticAcqIp()); + cloudWorkOrderServerVmDiskDo.setIp(network.getIp()); + cloudWorkOrderServerVmDiskDo.setMask(network.getMask()); + cloudWorkOrderServerVmDiskDo.setGw(network.getGw()); + cloudWorkOrderServerVmDiskDo.setDns1(network.getDns1()); + cloudWorkOrderServerVmDiskDo.setDns2(network.getDns2()); + + //自定义的网络设置 + CloudNetworkConfigDo cloudNetworkConfigDo = networkConfigService.getById(network.getNetworkId()); + cloudWorkOrderServerVmDiskDo.setPurpose(formatNetworkStr(cloudNetworkConfigDo.getInterfaceType(), + cloudNetworkConfigDo.getPortGroup(), + cloudNetworkConfigDo.getVirtualSwitch(), cloudNetworkConfigDo.getModelType())); + return cloudWorkOrderServerVmDiskDo; + } + + /** + * 管理员审核时,可能变动了申请时的网卡信息,将新变动网卡信息进行处理 + * + * @param networkList + * @param loginUserVo + * @param now + */ + private void formatHandleNetwork(List networkList, LoginUserVo loginUserVo, + Integer workOrderId, Date now) { + //查询申请时的网卡列表 + List networkDoList = getNetworkListByWorkOrderId(workOrderId); + List newInsertNetworkList = new ArrayList<>(); + List updateNetworkList = new ArrayList<>(); + + + networkList.forEach(network -> { + if (Objects.equals(network.getModifyType(), ModifyType.ADD)) { + //新增的网卡 + newInsertNetworkList.add(formatNewInsertNetwork(workOrderId, network, loginUserVo, now)); + } else if (Objects.equals(network.getModifyType(), ModifyType.DELETE)) { + //管理员审核时删除的网卡 + CloudWorkOrderServerVmNetworkDo deleteNetwork = + networkDoList.stream().filter(item -> Objects.equals(item.getId(), network.getApplyId())) + .findFirst().orElse(null); + if (Objects.nonNull(deleteNetwork)) { + deleteNetwork.setModifyType(ModifyType.DELETE); + deleteNetwork.setUpdateBy(loginUserVo.getUserId()); + deleteNetwork.setUpdateTime(now); + updateNetworkList.add(deleteNetwork); + } + } else { + if (network.getNetworkId() > 0) { + CloudWorkOrderServerVmNetworkDo customerNetWork = + networkDoList.stream().filter(item -> Objects.equals(item.getId(), network.getApplyId())) + .findFirst().orElse(null); + + if (Objects.nonNull(customerNetWork)) { + customerNetWork.setModifyType(ModifyType.MODIFY); + String oldPurpose = customerNetWork.getPurpose(); + CloudNetworkConfigDo cloudNetworkConfigDo = + networkConfigService.getById(network.getNetworkId()); + String newPurpose = formatNetworkStr(cloudNetworkConfigDo.getInterfaceType(), + cloudNetworkConfigDo.getPortGroup(), + cloudNetworkConfigDo.getVirtualSwitch(), cloudNetworkConfigDo.getModelType()); + customerNetWork.setPurpose(oldPurpose + " —> " + newPurpose); + customerNetWork.setUpdateBy(loginUserVo.getUserId()); + customerNetWork.setUpdateTime(now); + customerNetWork.setIpBindMac(network.getIpBindMac()); + customerNetWork.setManualSetIp(network.getManualSetIp()); + customerNetWork.setAutomaticAcqIp(network.getAutomaticAcqIp()); + customerNetWork.setIp(network.getIp()); + customerNetWork.setMask(network.getMask()); + customerNetWork.setGw(network.getGw()); + customerNetWork.setDns1(network.getDns1()); + customerNetWork.setDns2(network.getDns2()); + updateNetworkList.add(customerNetWork); + } + } else { + CloudWorkOrderServerVmNetworkDo updateNetwork = + networkDoList.stream().filter(item -> Objects.equals(item.getId(), network.getApplyId())) + .findFirst().orElse(null); + if (Objects.nonNull(updateNetwork)) { + updateNetwork.setIpBindMac(network.getIpBindMac()); + updateNetwork.setManualSetIp(network.getManualSetIp()); + updateNetwork.setAutomaticAcqIp(network.getAutomaticAcqIp()); + updateNetwork.setIp(network.getIp()); + updateNetwork.setMask(network.getMask()); + updateNetwork.setGw(network.getGw()); + updateNetwork.setDns1(network.getDns1()); + updateNetwork.setDns2(network.getDns2()); + updateNetworkList.add(updateNetwork); + } + } + } + }); + if (!newInsertNetworkList.isEmpty()) { + cloudWorkOrderServerVmNetworkService.saveBatch(newInsertNetworkList); + } + + if (!updateNetworkList.isEmpty()) { + cloudWorkOrderServerVmNetworkService.updateBatchById(updateNetworkList); + } + } + + + /** + * 管理员审核时,可能变动了申请时的iso信息,将新变动网卡信息进行处理 + * + * @param isoList + * @param loginUserVo + * @param now + */ + private void formatHandleIso(List isoList, LoginUserVo loginUserVo, + Integer workOrderId, Date now) { + //查询申请时的网卡列表 + List isoDoList = getIsoByWorkOrderId(workOrderId); + List newInsertIsoList = new ArrayList<>(); + List updateIsoList = new ArrayList<>(); + if (Objects.nonNull(isoList) && !isoList.isEmpty()) { + isoList.forEach(iso -> { + if (Objects.equals(iso.getModifyType(), ModifyType.ADD)) { + //新增的ISO + newInsertIsoList.add(formatNewInsertIso(workOrderId, iso.getIsoFile(), loginUserVo, now)); + } else if (Objects.equals(iso.getModifyType(), ModifyType.DELETE)) { + //管理员审核时删除的网卡 + CloudWorkOrderServerVmIsoDo deleteIso = + isoDoList.stream().filter(item -> Objects.equals(item.getId(), iso.getApplyId())) + .findFirst().orElse(null); + if (Objects.nonNull(deleteIso)) { + deleteIso.setModifyType(ModifyType.DELETE); + deleteIso.setUpdateBy(loginUserVo.getUserId()); + deleteIso.setUpdateTime(now); + updateIsoList.add(deleteIso); + } + } else { + //没有变动的磁盘, + CloudWorkOrderServerVmIsoDo noneIso = + isoDoList.stream().filter(item -> Objects.equals(item.getId(), iso.getApplyId())) + .findFirst().orElse(null); + if (Objects.nonNull(noneIso)) { + //比较文件名是否改动 + if (!Objects.equals(noneIso.getIsoFile(), iso.getIsoFile())) { + noneIso.setModifyType(ModifyType.MODIFY); + noneIso.setOldIsoFile(noneIso.getIsoFile()); + noneIso.setIsoFile(iso.getIsoFile()); + noneIso.setUpdateBy(loginUserVo.getUserId()); + noneIso.setUpdateTime(now); + updateIsoList.add(noneIso); + } + } + } + }); + if (!newInsertIsoList.isEmpty()) { + cloudWorkOrderServerVmIsoService.saveBatch(newInsertIsoList); + } + + if (!updateIsoList.isEmpty()) { + cloudWorkOrderServerVmIsoService.updateBatchById(updateIsoList); + } + } + + } + + /** + * 封装审核云服务器,变更源服务器,原始的网卡信息 + * + * @return + */ + private void createMcOriginalInterface(McCreateServerVmInterfacesParam mcInterface, + PassServerVmNetworkParam network) { + mcInterface.setInterfaceType(network.getInterfaceType()); + mcInterface.setModeltype(network.getModelType()); + mcInterface.setPortGroup(network.getPortGroupUuid()); + mcInterface.setMacAddress(network.getMacAddressPool()); + mcInterface.setVirtualSwitch(network.getVirtualSwitch()); + mcInterface.setSecurityStrategy(network.getSecurityStrategy()); + //安全组策略 + if (Objects.equals(network.getSecurityStrategy(), NetworkSecurityPolicy.SECURITY_GROUP.getValue())) { + if (Objects.nonNull(network.getSecurityGroupUuid())) { + List securityGroupUuidList = + Arrays.asList(network.getSecurityGroupUuid() + .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList()); + mcInterface.setSecurityGroup(securityGroupUuidList); + } + } + mcInterface.setQueueCount(network.getQueueCount().toString()); + mcInterface.setMtuCount(network.getMtuCount().toString()); + mcInterface.setVirtualFirewall(network.getVirtualFirewall()); + mcInterface.setLastUpdateType(LastUpdateType.add.getValue()); + mcInterface.setLsbind(network.getIpBindMac()); + mcInterface.setManualSetIP(network.getManualSetIp()); + mcInterface.setAutomaticAcqIp(network.getAutomaticAcqIp()); + mcInterface.setIp(network.getAutomaticAcqIp() ? KylinCloudManageConstants.DHCP : network.getIp()); + mcInterface.setMask(network.getMask()); + mcInterface.setGw(network.getGw()); + mcInterface.setDns1(network.getDns1()); + mcInterface.setDns2(network.getDns2()); + } + + /** + * 封装申请的自定义的网卡信息 + */ + private McModifyServerVmInterfacesParam formatCustomNetwork(PassServerVmNetworkParam network) { + McModifyServerVmInterfacesParam mcInterface = new McModifyServerVmInterfacesParam(); + mcInterface.setLastUpdateType(LastUpdateType.add.getValue()); + //自定义的网络设置 + CloudNetworkConfigDo cloudNetworkConfigDo = networkConfigService.getById(network.getNetworkId()); + mcInterface.setInterfaceType(cloudNetworkConfigDo.getInterfaceType()); + mcInterface.setModeltype(cloudNetworkConfigDo.getModelType()); + mcInterface.setPortGroup(cloudNetworkConfigDo.getPortGroupUuid()); + mcInterface.setVirtualSwitch(cloudNetworkConfigDo.getVirtualSwitch()); + mcInterface.setMacAddress(cloudNetworkConfigDo.getAddressPool()); + mcInterface.setLastUpdateType(LastUpdateType.add.getValue()); + mcInterface.setSecurityStrategy(cloudNetworkConfigDo.getSecurityPolicy().getValue()); + if (Objects.equals(cloudNetworkConfigDo.getSecurityPolicy(), NetworkSecurityPolicy.SECURITY_GROUP)) { + if (StringUtils.isNotBlank(cloudNetworkConfigDo.getSecurityGroupUuid())) { + List securityGroupUuidList = + Arrays.asList(cloudNetworkConfigDo.getSecurityGroupUuid() + .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList()); + mcInterface.setSecurityGroup(securityGroupUuidList); + } + } else if (Objects.equals(cloudNetworkConfigDo.getSecurityPolicy(), NetworkSecurityPolicy.VIRTUAL_FIREWALL)) { + mcInterface.setVirtualFirewall(cloudNetworkConfigDo.getVirtualFirewallId()); + } + + mcInterface.setLsbind(network.getIpBindMac()); + mcInterface.setManualSetIP(network.getManualSetIp()); + mcInterface.setAutomaticAcqIp(network.getAutomaticAcqIp()); + mcInterface.setIp(network.getAutomaticAcqIp() ? KylinCloudManageConstants.DHCP : network.getIp()); + mcInterface.setMask(network.getMask()); + mcInterface.setGw(network.getGw()); + mcInterface.setDns1(network.getDns1()); + mcInterface.setDns2(network.getDns2()); + return mcInterface; + } + + /** + * 校验是否超出VDC资源限制 + */ + private void modifyServerVmVerifyIfExceedVdcResource(LoginUserVo loginUserVo, + Integer applyCpu, Integer applyMem, + List diskList, + ArchitectureType architectureType, + CloudUserMachineDo userMachineDo) { + //根据申请用户获取用户对应的组织 + CloudOrganizationDo orgDo = + cloudOrganizationService.getById(cloudUserService.getById(userMachineDo.getUserId()).getOrganizationId()); + //获取组织绑定的VDC + CloudVdcDo vdcDo = vdcService.getVdcByOrgId(orgDo.getId()); + //获取VDC资源使用情况 + VdcUsedResourceDto vdcResourceDto = vdcService.getVdcResourceInfo(vdcDo.getId(), loginUserVo); + + + //根据uuid获取原来云服务器详情 + QueryMcServerDetailParamReq queryMcServerDetailParamReq = new QueryMcServerDetailParamReq(); + queryMcServerDetailParamReq.setUuid(userMachineDo.getMachineUuid()); + McServerVmDetailResp mcServerVmDetailResp = + mcServerVmService.getMcServerVmDetailByServerVmUuid(userMachineDo.getClusterId(), + queryMcServerDetailParamReq, loginUserVo); + //获取审核前云服务器的CPU,磁盘,存储 + int oldMem = mcServerVmDetailResp.getMem(); + int oldCpu = mcServerVmDetailResp.getCpu(); + int oldDiskSize = + mcServerVmDetailResp.getDisks().stream().collect(Collectors.summingInt(McServerVmDiskDetailResp::getDiskSize)); + + int applyStorage = + diskList.stream().filter(item -> !Objects.equals(item.getModifyType(), ModifyType.DELETE)).collect(Collectors.summingInt(PassServerVmDiskParam::getDiskCapacity)); + + boolean exceedVdcCpu = false; + boolean exceedVdcMem = false; + boolean exceedVdcStorage = false; + StringBuilder exceedVdcResourceSb = new StringBuilder(); + //先校验存储资源 + if (applyStorage > (vdcResourceDto.getSurplusStorage() + oldDiskSize)) { + exceedVdcStorage = true; + } + //VDC-各架构资源使用情况 + List vdcArchitectureUsedResourceList = + vdcResourceDto.getVdcArchitectureUsedResourceList(); + + VdcArchitectureUsedResourceDto architectureUsedResource = + vdcArchitectureUsedResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), + architectureType)) + .findFirst().orElse(null); + //校验vdc-架构-cpu + if (Objects.isNull(architectureUsedResource) || applyCpu > (architectureUsedResource.getSurplusCpu() + oldCpu)) { + exceedVdcCpu = true; + } + //校验vdc-架构-内存 + if (Objects.isNull(architectureUsedResource) || applyMem > architectureUsedResource.getSurplusMem() + oldMem) { + exceedVdcMem = true; + } + + if (exceedVdcCpu || exceedVdcMem || exceedVdcStorage) { + exceedVdcResourceSb.append(architectureType.name()).append(KylinCloudManageConstants.ARCHITECTURE); + if (exceedVdcCpu) { + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_CPU); + } + if (exceedVdcMem) { + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_MEM); + } + if (exceedVdcStorage) { + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_STORAGE); + } + exceedVdcResourceSb.append(KylinCloudManageConstants.EXCEED_ALLOCATE); + throw new KylinException(exceedVdcResourceSb.toString()); + } + } + + + @Override + @Transactional + public void passModifyServerVm(PassModifyServerVmParam passModifyServerVmParam, LoginUserVo loginUserVo) { + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(passModifyServerVmParam.getWorkOrderId()); + + //查询变更云服务器申请表 + CloudWorkOrderModifyServerVmDo queryServerVmDo = new CloudWorkOrderModifyServerVmDo(); + queryServerVmDo.setWorkOrderId(passModifyServerVmParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(queryServerVmDo); + CloudWorkOrderModifyServerVmDo modifyServerVmDo = cloudWorkOrderModifyServerVmService.getOne(wrapper); + + //查询用户已经拥有的云服务器 + CloudUserMachineDo userMachineDo = getUserMachineByUuid(modifyServerVmDo.getMachineUuid(), + cloudWorkOrderDo.getUserId()); + + //校验是否超出资源限制 + modifyServerVmVerifyIfExceedVdcResource(loginUserVo, + passModifyServerVmParam.getVcpus(), + passModifyServerVmParam.getMemory(), passModifyServerVmParam.getDiskList(), + changeToKcpArchitectureType(passModifyServerVmParam.getPlateformType()), userMachineDo); + + + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_PASS, + passModifyServerVmParam.getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + + Date updateTime = new Date(); + + + modifyServerVmDo.setCpu(passModifyServerVmParam.getVcpus()); + modifyServerVmDo.setMem(passModifyServerVmParam.getMemory()); + modifyServerVmDo.setUpdateBy(loginUserVo.getUserId()); + modifyServerVmDo.setUpdateTime(updateTime); + cloudWorkOrderModifyServerVmService.updateById(modifyServerVmDo); + + + McModifyServerVmParamReq mcModifyServerVmParamReq = new McModifyServerVmParamReq(); + BeanUtils.copyProperties(passModifyServerVmParam, mcModifyServerVmParamReq); + mcModifyServerVmParamReq.setPlateformtype(passModifyServerVmParam.getPlateformType()); + if (Objects.equals(passModifyServerVmParam.getPlateformType(), McArchitectureType.LOWER_86_64.name())) { + mcModifyServerVmParamReq.setPlateformtype(McArchitectureType.X86_64.name()); + } + if (Objects.equals(passModifyServerVmParam.getPlateformType(), McArchitectureType.AARCH64.name())) { + mcModifyServerVmParamReq.setPlateformtype(McArchitectureType.AARCH64.getName()); + } + + mcModifyServerVmParamReq.setSystemVersion(passModifyServerVmParam.getOperatingSystem()); + mcModifyServerVmParamReq.setSystemType(passModifyServerVmParam.getSystemType()); + mcModifyServerVmParamReq.setUuid(modifyServerVmDo.getMachineUuid()); + //封装磁盘信息 + List diskCapacity = new ArrayList<>(); + passModifyServerVmParam.getDiskList().forEach(disk -> { + + if (disk.getId() > 0 || !Objects.equals(disk.getModifyType(), ModifyType.DELETE)) { + McModifyServerVmDiskParam mcDisk = new McModifyServerVmDiskParam(); + mcDisk.setId(disk.getId().toString()); + mcDisk.setDiskCapacity(disk.getDiskCapacity()); + if (Objects.equals(disk.getId(), 0)) { + mcDisk.setId(""); + mcDisk.setLastUpdateType(LastUpdateType.add.getValue()); + } else { + boolean deleteFlag = Objects.equals(disk.getModifyType(), ModifyType.DELETE); + mcDisk.setLastUpdateType(deleteFlag ? LastUpdateType.delete.getValue() : + LastUpdateType.update.getValue()); + } + diskCapacity.add(mcDisk); + } + }); + mcModifyServerVmParamReq.setDiskCapacity(diskCapacity); + + //封装网卡信息 + List interfaces = new ArrayList<>(); + passModifyServerVmParam.getNetworkList().forEach(network -> { + //变更前原始网卡信息 + if (Objects.nonNull(network.getId()) && network.getId() > 0) { + //说明是update,或者delete + McModifyServerVmInterfacesParam mcInterface = new McModifyServerVmInterfacesParam(); + createMcOriginalInterface(mcInterface, network); + mcInterface.setId(network.getId()); + boolean deleteFlag = Objects.equals(ModifyType.DELETE, network.getModifyType()); + mcInterface.setLastUpdateType(deleteFlag ? LastUpdateType.delete.getValue() : + LastUpdateType.update.getValue()); + interfaces.add(mcInterface); + } else { + //说明是申请自定义网卡信息 + if (!Objects.equals(network.getModifyType(), ModifyType.DELETE)) { + McModifyServerVmInterfacesParam mcInterface = formatCustomNetwork(network); + interfaces.add(mcInterface); + } + } + }); + mcModifyServerVmParamReq.setInterfaces(interfaces); + McCreateServerVmInterfacesParam existHostIpConfigParam = + interfaces.stream().filter(item -> item.getLsbind() || item.getManualSetIP() || item.getAutomaticAcqIp()).findFirst().orElse(null); + if (Objects.nonNull(existHostIpConfigParam)) { + mcModifyServerVmParamReq.setExistHostIpConfig(true); + } + + //计算资源处理 + mcModifyServerVmParamReq.setClusterType(passModifyServerVmParam.getServerClusterType().getValue()); + mcModifyServerVmParamReq.setSelectResourceTagId(passModifyServerVmParam.getSelectResourceTagId()); + + + boolean modifyFlag = mcServerVmService.modifyMcServerVm(userMachineDo.getClusterId(), + mcModifyServerVmParamReq, loginUserVo); + if (!modifyFlag) { + throw new KylinException(KylinHttpResponseOrderConstants.MODIFY_SERVERVM_ERR); + } + + + userMachineDo.setDeadlineTime(modifyServerVmDo.getDeadlineTime()); + //新的截至时间大于当期时间,则该用户已拥有云服务器为非过期 + if (modifyServerVmDo.getDeadlineTime().getTime() > System.currentTimeMillis()) { + userMachineDo.setDeadlineFlag(Boolean.FALSE); + } + userMachineDo.setDeadlineType(modifyServerVmDo.getDeadlineType()); + userMachineDo.setUpdateBy(loginUserVo.getUserId()); + userMachineDo.setUpdateTime(updateTime); + userMachineService.updateById(userMachineDo); + + //管理员审核时,可能针对申请的磁盘信息进行了变动,处理变动信息 + handleDisk(passModifyServerVmParam.getDiskList(), loginUserVo, modifyServerVmDo.getWorkOrderId(), updateTime); + //管理员审核时,可能针对申请的网卡信息进行了变动,处理变动信息 + formatHandleNetwork(passModifyServerVmParam.getNetworkList(), loginUserVo, modifyServerVmDo.getWorkOrderId(), + updateTime); + + } + + @Override + public ApplyDeferredDetailRespDto applyDeferredDetailByWorkOrderId(Integer workOrderId) { + ApplyDeferredDetailRespDto applyDeferredDetailRespDto = new ApplyDeferredDetailRespDto(); + + formatBaseWorkOrderDetail(workOrderId, applyDeferredDetailRespDto); + + + //查询延期申请表 + CloudWorkOrderDeferredMachineDo cloudWorkOrderDeferredMachineDo = new CloudWorkOrderDeferredMachineDo(); + cloudWorkOrderDeferredMachineDo.setWorkOrderId(workOrderId); + QueryWrapper queryWrapper = new QueryWrapper<> + (cloudWorkOrderDeferredMachineDo); + CloudWorkOrderDeferredMachineDo queryDo = deferredMachineService.getOne(queryWrapper); + + applyDeferredDetailRespDto.setOldDeadlineTime(DateUtils.format(queryDo.getOldDeadlineTime())); + applyDeferredDetailRespDto.setNewDeadlineTime(DateUtils.format(queryDo.getDeadlineTime())); + + return applyDeferredDetailRespDto; + } + + @Override + public UserWaitCheckCountParam getWaitCheckCount(LoginUserVo loginUserVo) { + + UserWaitCheckCountParam waitCheckCountParam = new UserWaitCheckCountParam(); + + List userDoList = userService.userVisibleUserList(loginUserVo.getUserId()); + + + if (!userDoList.isEmpty()) { + List userIdList = userDoList.stream().map(CloudUserDo::getId).collect(Collectors.toList()); + CloudWorkOrderDo queryOrderDo = new CloudWorkOrderDo(); + queryOrderDo.setDeleteFlag(false); + queryOrderDo.setStatus(WorkOrderStatus.WAIT_CHECK); + QueryWrapper wrapper = new QueryWrapper<>(queryOrderDo); + wrapper.in("user_id", userIdList); + int waitCheckCheckCount = cloudWorkOrderService.getBaseMapper().selectCount(wrapper); + waitCheckCountParam.setWaitCheckCount(waitCheckCheckCount); + } + return waitCheckCountParam; + } + + + @Override + public PassModifyVdcDetailRespDto passModifyVdcDetail(WorkOrderDetailParam workOrderDetailParam, + LoginUserVo loginUserVo) { + + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderDetailParam.getWorkOrderId()); + judgeAlreadyCheck(cloudWorkOrderDo); + + CloudWorkOrderVdcDo queryCloudWorkOrderVdcDo = new CloudWorkOrderVdcDo(); + queryCloudWorkOrderVdcDo.setWorkOrderId(cloudWorkOrderDo.getId()); + QueryWrapper wrapper = new QueryWrapper<>(queryCloudWorkOrderVdcDo); + CloudWorkOrderVdcDo modifyVdcDo = cloudWorkOrderVdcService.getOne(wrapper); + + + PassModifyVdcDetailRespDto passModifyVdcDetail = new PassModifyVdcDetailRespDto(); + passModifyVdcDetail.setWorkOrderId(cloudWorkOrderDo.getId()); + CloudVdcDo cloudVdcDo = cloudVdcService.getById(modifyVdcDo.getVdcId()); + passModifyVdcDetail.setVdcName(cloudVdcDo.getVdcName()); + CloudOrganizationDo vdcOrg = orgService.getOrgByVdcId(modifyVdcDo.getVdcId()); + passModifyVdcDetail.setOrgName("---"); + if (Objects.nonNull(vdcOrg)) { + passModifyVdcDetail.setOrgName(vdcOrg.getOrganizationName()); + } + passModifyVdcDetail.setFirstVdc(Objects.equals(cloudVdcDo.getParentId(), KylinCommonConstants.TOP_PARENT_ID)); + + //vdc 当前资源 + VdcModifyResourceRespDto vdcModifyResource = vdcService.modifyVdcResourceDetail(modifyVdcDo.getVdcId(), + loginUserVo); + + //存储信息 + passModifyVdcDetail.setApplyStorage(modifyVdcDo.getApplyStorage()); + passModifyVdcDetail.setCurrentStorage(vdcModifyResource.getCurrentStorage()); + passModifyVdcDetail.setUsedStorage(vdcModifyResource.getUsedStorage()); + passModifyVdcDetail.setParentUsableStorage(vdcModifyResource.getParentUsableStorage()); + passModifyVdcDetail.setStorageUnit(vdcModifyResource.getStorageUnit()); + + + //架构资源信息 + CloudWorkOrderVdcCpuMemDo queryCloudWorkOrderVdcCpuMemDo = new CloudWorkOrderVdcCpuMemDo(); + queryCloudWorkOrderVdcCpuMemDo.setWorkOrderId(cloudWorkOrderDo.getId()); + QueryWrapper applyCpuAndMemWrapper = + new QueryWrapper<>(queryCloudWorkOrderVdcCpuMemDo); + List applyResourceList = cloudWorkOrderVdcCpuMemService.list(applyCpuAndMemWrapper); + + + List applyArchitectureResourceList = new ArrayList<>(); + //遍历架构获取架构资源 + List architectureTypeList = Arrays.asList(ArchitectureType.values()); + architectureTypeList.forEach(architectureType -> { + List architectureResourceList = + applyResourceList.stream().filter(item -> Objects.equals(item.getArchitecture(), architectureType)) + .collect(Collectors.toList()); + if (!architectureResourceList.isEmpty()) { + ModifyVdcArchitectureResourceRespDto modifyVdcArchitecture = new ModifyVdcArchitectureResourceRespDto(); + + CloudWorkOrderVdcCpuMemDo applyCpu = + architectureResourceList.stream().filter(item -> Objects.equals(item.getResourceType(), + ArchitectureResourceType.CPU)).findFirst().orElse(null); + + CloudWorkOrderVdcCpuMemDo applyMem = + architectureResourceList.stream().filter(item -> Objects.equals(item.getResourceType(), + ArchitectureResourceType.MEM)).findFirst().orElse(null); + + modifyVdcArchitecture.setApplyCpu(applyCpu.getApplySize()); + modifyVdcArchitecture.setApplyMem(applyMem.getApplySize()); + modifyVdcArchitecture.setArchitectureType(architectureType); + //VDC架构已使用信息 + VdcModifyArchitectureResourceRespDto vdcUsedResource = + vdcModifyResource.getArchitectureResourceList().stream().filter(item -> Objects.equals(item.getArchitectureType(), architectureType)) + .findFirst().orElse(null); + if (Objects.nonNull(vdcUsedResource)) { + modifyVdcArchitecture.setCurrentVcpu(vdcUsedResource.getCurrentVcpu()); + modifyVdcArchitecture.setUsedCpu(vdcUsedResource.getUsedCpu()); + modifyVdcArchitecture.setParentUsableCpu(vdcUsedResource.getParentUsableCpu()); + + modifyVdcArchitecture.setCurrentMem(vdcUsedResource.getCurrentMem()); + modifyVdcArchitecture.setUsedMem(vdcUsedResource.getUsedMem()); + modifyVdcArchitecture.setParentUsableMem(vdcUsedResource.getParentUsableMem()); + + } + applyArchitectureResourceList.add(modifyVdcArchitecture); + } + }); + passModifyVdcDetail.setApplyArchitectureResourceList(applyArchitectureResourceList); + return passModifyVdcDetail; + } + + + @Override + @Transactional + public void passModifyVdc(PassModifyVdcResourceParam passModifyVdcResourceParam, LoginUserVo loginUserVo) { + Integer workOrderId = passModifyVdcResourceParam.getWorkOrderId(); + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderId); + judgeAlreadyCheck(cloudWorkOrderDo); + formatCommonCheckWorkOrder(cloudWorkOrderDo, WorkOrderStatus.CHECK_PASS, + passModifyVdcResourceParam.getAuditOpinion(), loginUserVo); + cloudWorkOrderService.updateById(cloudWorkOrderDo); + + + CloudWorkOrderVdcDo queryCloudWorkOrderVdcDo = new CloudWorkOrderVdcDo(); + queryCloudWorkOrderVdcDo.setWorkOrderId(cloudWorkOrderDo.getId()); + QueryWrapper wrapper = new QueryWrapper<>(queryCloudWorkOrderVdcDo); + CloudWorkOrderVdcDo modifyVdcDo = cloudWorkOrderVdcService.getOne(wrapper); + + modifyVdcDo.setRealStorage(passModifyVdcResourceParam.getRealStorage()); + cloudWorkOrderVdcService.updateById(modifyVdcDo); + + //更新VDC-存储信息 + CloudVdcStorageDo cloudVdcStorageDo = + cloudVdcStorageService.getByVdcId(modifyVdcDo.getVdcId()); + cloudVdcStorageDo.setUpdateBy(loginUserVo.getUserId()); + cloudVdcStorageDo.setUpdateTime(new Date()); + cloudVdcStorageDo.setStorage(passModifyVdcResourceParam.getRealStorage()); + cloudVdcStorageService.updateById(cloudVdcStorageDo); + + //原VDC-CPU和内存资源 + List oldVdcCpuList = cloudVdcCpuService.listVDdcCpuByVdc(modifyVdcDo.getVdcId()); + List oldVdcMemList = cloudVdcMemService.listVdcMemByVdcId(modifyVdcDo.getVdcId()); + + //更新vdc的cpu和资源信息 + List batchUpdateVdcCpuList = new ArrayList<>(); + List batchUpdateVdcMemList = new ArrayList<>(); + + //批量新插入的 + List batchNewInsertVdcCpuList = new ArrayList<>(); + List batchNewInsertVdcMemList = new ArrayList<>(); + + //架构资源信息 + CloudWorkOrderVdcCpuMemDo queryCloudWorkOrderVdcCpuMemDo = new CloudWorkOrderVdcCpuMemDo(); + queryCloudWorkOrderVdcCpuMemDo.setWorkOrderId(cloudWorkOrderDo.getId()); + QueryWrapper applyCpuAndMemWrapper = + new QueryWrapper<>(queryCloudWorkOrderVdcCpuMemDo); + List applyResourceList = cloudWorkOrderVdcCpuMemService.list(applyCpuAndMemWrapper); + + List commitResourceList = + passModifyVdcResourceParam.getArchitectureResourceList(); + applyResourceList.forEach(applyResource -> { + + PassModifyArchitectureResourceParam passModifyResource = + commitResourceList.stream().filter(item -> Objects.equals(item.getArchitectureType(), + applyResource.getArchitecture())).findFirst().orElse(null); + if (Objects.equals(applyResource.getResourceType(), ArchitectureResourceType.CPU)) { + applyResource.setRealSize(passModifyResource.getRealCpu()); + CloudVdcCpuDo oldCpuDo = oldVdcCpuList.stream().filter(item -> Objects.equals(item.getArchitecture(), + applyResource.getArchitecture())) + .findFirst().orElse(null); + if (Objects.nonNull(oldCpuDo)) { + oldCpuDo.setVcpus(passModifyResource.getRealCpu()); + batchUpdateVdcCpuList.add(oldCpuDo); + } else { + //变更前vdc该架构的车贷cpu资源不存在,则新增 + CloudVdcCpuDo newInsertVdcCpuDo = new CloudVdcCpuDo(); + newInsertVdcCpuDo.setVdcId(modifyVdcDo.getVdcId()); + newInsertVdcCpuDo.setVcpus(passModifyResource.getRealCpu()); + newInsertVdcCpuDo.setArchitecture(applyResource.getArchitecture()); + newInsertVdcCpuDo.setCreateBy(loginUserVo.getUserId()); + newInsertVdcCpuDo.setCreateTime(new Date()); + batchNewInsertVdcCpuList.add(newInsertVdcCpuDo); + } + } else if (Objects.equals(applyResource.getResourceType(), ArchitectureResourceType.MEM)) { + applyResource.setRealSize(passModifyResource.getRealMem()); + + CloudVdcMemDo oldMemDo = oldVdcMemList.stream().filter(item -> Objects.equals(item.getArchitecture(), + applyResource.getArchitecture())) + .findFirst().orElse(null); + if (Objects.nonNull(oldMemDo)) { + oldMemDo.setMem(passModifyResource.getRealMem()); + oldMemDo.setMemUnit(applyResource.getUnit()); + batchUpdateVdcMemList.add(oldMemDo); + } else { + //变更前vdc该架构的车贷cpu资源不存在,则新增 + CloudVdcMemDo newInsertVdcMemDo = new CloudVdcMemDo(); + newInsertVdcMemDo.setVdcId(modifyVdcDo.getVdcId()); + newInsertVdcMemDo.setMem(passModifyResource.getRealMem()); + newInsertVdcMemDo.setMemUnit(applyResource.getUnit()); + newInsertVdcMemDo.setArchitecture(applyResource.getArchitecture()); + newInsertVdcMemDo.setCreateBy(loginUserVo.getUserId()); + newInsertVdcMemDo.setCreateTime(new Date()); + batchNewInsertVdcMemList.add(newInsertVdcMemDo); + } + } + applyResource.setUpdateBy(loginUserVo.getUserId()); + applyResource.setUpdateTime(new Date()); + }); + + cloudWorkOrderVdcCpuMemService.updateBatchById(applyResourceList); + + if (!batchUpdateVdcCpuList.isEmpty()) { + cloudVdcCpuService.updateBatchById(batchUpdateVdcCpuList); + } + if (!batchUpdateVdcMemList.isEmpty()) { + cloudVdcMemService.updateBatchById(batchUpdateVdcMemList); + } + if (!batchNewInsertVdcCpuList.isEmpty()) { + cloudVdcCpuService.saveBatch(batchNewInsertVdcCpuList); + } + if (!batchNewInsertVdcMemList.isEmpty()) { + cloudVdcMemService.saveBatch(batchNewInsertVdcMemList); + } + } + + + @Override + public ApplyModifyVdcDetailRespDto applyModifyVdcDetail(WorkOrderDetailParam workOrderDetailParam) { + ApplyModifyVdcDetailRespDto applyModifyVdcDetail = new ApplyModifyVdcDetailRespDto(); + + formatBaseWorkOrderDetail(workOrderDetailParam.getWorkOrderId(), applyModifyVdcDetail); + + + CloudWorkOrderVdcDo queryCloudWorkOrderVdcDo = new CloudWorkOrderVdcDo(); + queryCloudWorkOrderVdcDo.setWorkOrderId(workOrderDetailParam.getWorkOrderId()); + QueryWrapper wrapper = new QueryWrapper<>(queryCloudWorkOrderVdcDo); + CloudWorkOrderVdcDo modifyVdcDo = cloudWorkOrderVdcService.getOne(wrapper); + + CloudVdcDo cloudVdcDo = cloudVdcService.getById(modifyVdcDo.getVdcId()); + applyModifyVdcDetail.setVdcName(cloudVdcDo.getVdcName()); + CloudOrganizationDo vdcOrg = orgService.getOrgByVdcId(modifyVdcDo.getVdcId()); + applyModifyVdcDetail.setOrgName("---"); + if (Objects.nonNull(vdcOrg)) { + applyModifyVdcDetail.setOrgName(vdcOrg.getOrganizationName()); + } + applyModifyVdcDetail.setOldStorage(modifyVdcDo.getOldStorage()); + applyModifyVdcDetail.setApplyStorage(modifyVdcDo.getApplyStorage()); + applyModifyVdcDetail.setRealStorage(modifyVdcDo.getRealStorage()); + applyModifyVdcDetail.setStorageUnit(modifyVdcDo.getStorageUnit()); + //架构资源信息 + CloudWorkOrderVdcCpuMemDo queryCloudWorkOrderVdcCpuMemDo = new CloudWorkOrderVdcCpuMemDo(); + queryCloudWorkOrderVdcCpuMemDo.setWorkOrderId(workOrderDetailParam.getWorkOrderId()); + QueryWrapper applyCpuAndMemWrapper = + new QueryWrapper<>(queryCloudWorkOrderVdcCpuMemDo); + List applyResourceList = cloudWorkOrderVdcCpuMemService.list(applyCpuAndMemWrapper); + + + //架构资源信息 + List applyArchitectureResourceList = new ArrayList<>(); + Map> architectureResourceMap = + applyResourceList.stream().collect(Collectors.groupingBy(CloudWorkOrderVdcCpuMemDo::getArchitecture)); + + architectureResourceMap.forEach((key, list) -> { + ApplyModifyVdcArchitectureResourceRespDto applyModifyVdcArchitectureResource = + new ApplyModifyVdcArchitectureResourceRespDto(); + applyModifyVdcArchitectureResource.setArchitectureType(key); + + CloudWorkOrderVdcCpuMemDo cpuDo = + list.stream().filter(item -> Objects.equals(item.getResourceType(), ArchitectureResourceType.CPU)).findFirst().orElse(null); + applyModifyVdcArchitectureResource.setOldCpu(cpuDo.getOldSize()); + applyModifyVdcArchitectureResource.setApplyCpu(cpuDo.getApplySize()); + applyModifyVdcArchitectureResource.setRealCpu(cpuDo.getRealSize()); + + CloudWorkOrderVdcCpuMemDo memDo = + list.stream().filter(item -> Objects.equals(item.getResourceType(), ArchitectureResourceType.MEM)).findFirst().orElse(null); + + applyModifyVdcArchitectureResource.setOldMem(memDo.getOldSize()); + applyModifyVdcArchitectureResource.setApplyMem(memDo.getApplySize()); + applyModifyVdcArchitectureResource.setRealMem(memDo.getRealSize()); + applyModifyVdcArchitectureResource.setMemUnit(memDo.getUnit()); + + applyArchitectureResourceList.add(applyModifyVdcArchitectureResource); + }); + applyModifyVdcDetail.setApplyArchitectureResourceList(applyArchitectureResourceList); + return applyModifyVdcDetail; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ZoneServiceImpl.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ZoneServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..458906ffc2d84112627911058ff5f0dd1cfb1a74 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/service/impl/ZoneServiceImpl.java @@ -0,0 +1,542 @@ +package com.hnkylin.cloud.manage.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.DateUtils; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseClusterConstants; +import com.hnkylin.cloud.manage.constant.KylinHttpResponseZoneConstants; +import com.hnkylin.cloud.manage.entity.LoginUserVo; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterBaseResource; +import com.hnkylin.cloud.manage.entity.mc.resp.McClusterServerResourceResp; +import com.hnkylin.cloud.manage.entity.req.zone.BaseZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.CreateZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.ModifyZoneParam; +import com.hnkylin.cloud.manage.entity.req.zone.PageZoneParam; +import com.hnkylin.cloud.manage.entity.resp.cluster.PageClusterDetailDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcSameLevelUserUsedArchitectureResourceRespDto; +import com.hnkylin.cloud.manage.entity.resp.vdc.VdcUsedResourceDto; +import com.hnkylin.cloud.manage.entity.resp.zone.*; +import com.hnkylin.cloud.manage.enums.ClusterStatus; +import com.hnkylin.cloud.manage.service.*; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +public class ZoneServiceImpl implements ZoneService { + + + @Resource + private CloudZoneService cloudZoneService; + + @Resource + private CloudZoneClusterService cloudZoneClusterService; + + + @Resource + private RoleService roleService; + + @Resource + private OrgService orgService; + + + @Resource + private CloudOrgVdcService cloudOrgVdcService; + + @Resource + private CloudVdcService cloudVdcService; + + @Resource + private UserService userService; + + @Resource + private VdcService vdcService; + + + @Resource + private ClusterService clusterService; + + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private CloudVdcCpuService cloudVdcCpuService; + + @Resource + private CloudVdcMemService cloudVdcMemService; + + @Resource + private CloudVdcStorageService cloudVdcStorageService; + + + @Override + @Transactional + public void createZone(CreateZoneParam createZoneParam, LoginUserVo loginUserVo) { + //先查询是否重名 + checkIfExistZoneName(createZoneParam.getName()); + Date now = new Date(); + CloudZoneDo zoneDo = new CloudZoneDo(); + BeanUtils.copyProperties(createZoneParam, zoneDo); + zoneDo.setCreateBy(loginUserVo.getUserId()); + zoneDo.setCreateTime(new Date()); + + cloudZoneService.save(zoneDo); + List zoneClusterDoList = createZoneClusterList(createZoneParam.getClusterIdList(), + zoneDo.getId(), now, loginUserVo.getUserId()); + + if (!zoneClusterDoList.isEmpty()) { + cloudZoneClusterService.saveBatch(zoneClusterDoList); + } + } + + /** + * 创建可用区集群关联关系 + * + * @param now + * @param createUserId + * @return + */ + private List createZoneClusterList(Set clusterIdList, Integer zoneId, + Date now, Integer createUserId) { + List zoneClusterDoList = new ArrayList<>(); + clusterIdList.stream().forEach(clusterId -> { + CloudZoneClusterDo zoneClusterDo = new CloudZoneClusterDo(); + zoneClusterDo.setZoneId(zoneId); + zoneClusterDo.setClusterId(clusterId); + zoneClusterDo.setCreateTime(now); + zoneClusterDo.setCreateBy(createUserId); + zoneClusterDoList.add(zoneClusterDo); + }); + return zoneClusterDoList; + } + + /** + * 检查是否存在同名集群 + */ + private void checkIfExistZoneName(String zoneName) { + //判断名称是否已经存在 + CloudZoneDo zoneDo = new CloudZoneDo(); + zoneDo.setName(zoneName); + zoneDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(zoneDo); + List zoneDoList = cloudZoneService.getBaseMapper().selectList(wrapper); + if (!zoneDoList.isEmpty()) { + throw new KylinException(KylinHttpResponseZoneConstants.EXIST_ZONE_NAME); + } + } + + + @Override + @Transactional + public void modifyZone(ModifyZoneParam modifyZoneParam, LoginUserVo loginUserVo) { + + + if (Objects.isNull(modifyZoneParam.getClusterIdList()) || modifyZoneParam.getClusterIdList().isEmpty()) { + throw new KylinException(KylinHttpResponseZoneConstants.CLUSTER_IS_NOT_EMPTY); + } + + CloudZoneDo zoneDo = cloudZoneService.getById(modifyZoneParam.getZoneId()); + if (!Objects.equals(zoneDo.getName(), modifyZoneParam.getName())) { + checkIfExistZoneName(modifyZoneParam.getName()); + } + Date now = new Date(); + zoneDo.setName(modifyZoneParam.getName()); + zoneDo.setRemark(modifyZoneParam.getRemark()); + zoneDo.setUpdateBy(loginUserVo.getUserId()); + zoneDo.setUpdateTime(now); + + cloudZoneService.updateById(zoneDo); + + List zoneClusterDoList = getZoneClusterListByZone(modifyZoneParam.getZoneId()); + List zoneClusterIdList = + zoneClusterDoList.stream().map(CloudZoneClusterDo::getClusterId).collect(Collectors.toList()); + //如果有可用区下有VDC,则不能解绑集群 + List vdcDoList = cloudVdcService.vdcListByZone(modifyZoneParam.getZoneId()); + List canNotUnbindClusterId = new ArrayList<>(); + if (!vdcDoList.isEmpty()) { + zoneClusterIdList.forEach(clusterId -> { + if (!modifyZoneParam.getClusterIdList().contains(clusterId)) { + canNotUnbindClusterId.add(clusterId); + } + + }); + if (!canNotUnbindClusterId.isEmpty()) { + throw new KylinException(KylinHttpResponseZoneConstants.ZONE_BIND_VDC_NOT_UNBIND_CLUSTER); + } + } + + + //先把原来的节点删除 + zoneClusterDoList.stream().forEach(item -> { + item.setDeleteFlag(Boolean.TRUE); + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(now); + }); + if (!zoneClusterDoList.isEmpty()) { + cloudZoneClusterService.updateBatchById(zoneClusterDoList); + } + + List newInsertZoneClusterDoList = createZoneClusterList(modifyZoneParam.getClusterIdList(), + zoneDo.getId(), now, loginUserVo.getUserId()); + + if (!newInsertZoneClusterDoList.isEmpty()) { + cloudZoneClusterService.saveBatch(newInsertZoneClusterDoList); + } + } + + + /** + * 获取可用区和集群绑定关系 + * + * @param zoneId + * @return + */ + private List getZoneClusterListByZone(Integer zoneId) { + //获取已经被绑定过得物理集群 + CloudZoneClusterDo zoneClusterDo = new CloudZoneClusterDo(); + zoneClusterDo.setDeleteFlag(false); + zoneClusterDo.setZoneId(zoneId); + Wrapper zoneClusterWrapper = new QueryWrapper<>(zoneClusterDo); + List zoneClusterList = + cloudZoneClusterService.getBaseMapper().selectList(zoneClusterWrapper); + return zoneClusterList; + } + + + @Override + public PageData pageZone(PageZoneParam pageZoneParam, LoginUserVo loginUserVo) { + + List userVisibleZoneList = visibleZoneListByUserId(loginUserVo.getUserId()); + if (userVisibleZoneList.isEmpty()) { + return new PageData<>(null); + } + + CloudZoneDo queryZoneDo = new CloudZoneDo(); + queryZoneDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(queryZoneDo); + wrapper.in("id", userVisibleZoneList.stream().map(CloudZoneDo::getId).collect(Collectors.toList())); + PageHelper.startPage(pageZoneParam.getPageNo(), pageZoneParam.getPageSize()); + List zoneList = cloudZoneService.getBaseMapper().selectList(wrapper); + PageInfo pageInfo = new PageInfo<>(zoneList); + List pageZoneRespList = new ArrayList<>(); + zoneList.forEach(item -> { + PageZoneRespDto pageZoneRespDto = new PageZoneRespDto(); + BeanUtils.copyProperties(item, pageZoneRespDto); + pageZoneRespDto.setZoneId(item.getId()); + //可用区数据统计 + createZoneCommonDataStatistics(pageZoneRespDto, item.getId(), loginUserVo); + + //获取可用区下物理集群名称 + List clusterDoList = cloudClusterService.listClusterBYZoneId(item.getId()); + if (!clusterDoList.isEmpty()) { + List clusterNameList = + clusterDoList.stream().map(CloudClusterDo::getName).collect(Collectors.toList()); + pageZoneRespDto.setClusterNames(StringUtils.join(clusterNameList, ",")); + } + + pageZoneRespList.add(pageZoneRespDto); + }); + + PageData pageData = new PageData(pageInfo); + pageData.setList(pageZoneRespList); + return pageData; + + } + + /** + * 可用区-通用数据统计 + */ + private void createZoneCommonDataStatistics(PageZoneRespDto pageZoneRespDto, Integer zoneId, + LoginUserVo loginUserVo) { + //获取可用区下物理集群列表 + List clusterDoList = cloudClusterService.listClusterBYZoneId(zoneId); + //从mc获取物理集群数据字眼 + List mcClusterResourceList = clusterService.moreClusterGetMcResource(clusterDoList, + loginUserVo.getUserName()); + //获取可用区下所有物理集群总资源 + //将mcClusterResourceList 可用区下所有物理集群资源进行汇总 + mcClusterResourceList.forEach(mcClusterBaseResource -> { + int totalStorage = + mcClusterBaseResource.getResourceInfo().getStorageTotal().setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + pageZoneRespDto.setStorageTotal(pageZoneRespDto.getStorageTotal() + totalStorage); + + List mcSevers = mcClusterBaseResource.getSevers(); + if (!mcSevers.isEmpty()) { + int totalCpu = mcSevers.stream().mapToInt(McClusterServerResourceResp::getVcpus).sum(); + //转换成GB + int totalMem = + mcSevers.stream().mapToInt(item -> item.getMemory().divide(new BigDecimal("1024")).setScale(0 + , BigDecimal.ROUND_HALF_UP).intValue()).sum(); + pageZoneRespDto.setCpuTotal(pageZoneRespDto.getCpuTotal() + totalCpu); + pageZoneRespDto.setMemTotal(pageZoneRespDto.getMemTotal() + totalMem); + } + + }); + +// //获取可用区下所有一级VDC,计算所有一级VDC资源 +// List zoneFirstVdcDoList = cloudVdcService.getFirstVdcListByZone(zoneId); +// zoneFirstVdcDoList.forEach(firstVdc -> { +// +// //获取分配给一级VDC的cpu +// int firstVdcCpu=cloudVdcCpuService.totalCpuByVdcId(firstVdc.getId()); +// //获取分配给一级VDC的内存 +// CloudVdcMemDo vdcTotalMemDo = cloudVdcMemService.totalMemByVdcId(firstVdc.getId()); +// //获取分配给一级VDC的存储 +// CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(firstVdc.getId()); +// +// zoneDataStatisticsDto.setCpuUsed(zoneDataStatisticsDto.getCpuUsed()+firstVdcCpu); +// zoneDataStatisticsDto.setMemUsed(zoneDataStatisticsDto.getMemUsed()+vdcTotalMemDo.getMem()); +// zoneDataStatisticsDto.setStorageUsed(zoneDataStatisticsDto.getStorageUsed()+vdcTotalStorage.getStorage()); +// +// }); + } + + + @Override + public ZoneInfoDto modifyZoneDetail(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo) { + CloudZoneDo queryZoneDo = cloudZoneService.getById(baseZoneParam.getZoneId()); + ZoneInfoDto zoneInfoDto = new ZoneInfoDto(); + BeanUtils.copyProperties(queryZoneDo, zoneInfoDto); + zoneInfoDto.setZoneId(queryZoneDo.getId()); + return zoneInfoDto; + } + + @Override + public ZoneDetailDto zoneDetail(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo) { + CloudZoneDo queryZoneDo = cloudZoneService.getById(baseZoneParam.getZoneId()); + ZoneDetailDto zoneDetail = new ZoneDetailDto(); + BeanUtils.copyProperties(queryZoneDo, zoneDetail); + zoneDetail.setZoneId(queryZoneDo.getId()); + zoneDetail.setCreateTime(DateUtils.format(queryZoneDo.getCreateTime(), DateUtils.DATE_ALL_PATTEN)); + //可用区已绑定的物理资源 + List clusterDoList = cloudClusterService.listClusterBYZoneId(baseZoneParam.getZoneId()); + //从mc获取物理集群数据资源 + List mcClusterResourceList = clusterService.moreClusterGetMcResource(clusterDoList, + loginUserVo.getUserName()); + + + //在线集群,离线物理集群 + zoneDetail.setClusterTotal(clusterDoList.size()); + zoneDetail.setClusterOnline(mcClusterResourceList.size()); + zoneDetail.setClusterOffline(zoneDetail.getClusterTotal() - zoneDetail.getClusterOnline()); + + //将mcClusterResourceList 可用区下所有物理集群资源进行汇总 + mcClusterResourceList.forEach(mcClusterBaseResource -> { + int totalStorage = + mcClusterBaseResource.getResourceInfo().getStorageTotal().setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + zoneDetail.setStorageTotal(zoneDetail.getStorageTotal() + totalStorage); + + List mcSevers = mcClusterBaseResource.getSevers(); + if (!mcSevers.isEmpty()) { + int totalCpu = mcSevers.stream().mapToInt(McClusterServerResourceResp::getVcpus).sum(); + //转换成GB + int totalMem = + mcSevers.stream().mapToInt(item -> item.getMemory().divide(new BigDecimal("1024")).setScale(0 + , BigDecimal.ROUND_HALF_UP).intValue()).sum(); + zoneDetail.setCpuTotal(zoneDetail.getCpuTotal() + totalCpu); + zoneDetail.setMemTotal(zoneDetail.getMemTotal() + totalMem); + } + + }); + + //获取可用区下所有一级VDC,计算所有一级VDC资源 + List zoneFirstVdcDoList = cloudVdcService.getFirstVdcListByZone(queryZoneDo.getId()); + zoneFirstVdcDoList.forEach(firstVdc -> { + + //获取分配给一级VDC的cpu + int firstVdcCpu = cloudVdcCpuService.totalCpuByVdcId(firstVdc.getId()); + //获取分配给一级VDC的内存 + CloudVdcMemDo vdcTotalMemDo = cloudVdcMemService.totalMemByVdcId(firstVdc.getId()); + //获取分配给一级VDC的存储 + CloudVdcStorageDo vdcTotalStorage = cloudVdcStorageService.getTotalStorageByVdcId(firstVdc.getId()); + + zoneDetail.setCpuUsed(zoneDetail.getCpuUsed() + firstVdcCpu); + zoneDetail.setMemUsed(zoneDetail.getMemUsed() + vdcTotalMemDo.getMem()); + zoneDetail.setStorageUsed(zoneDetail.getStorageUsed() + vdcTotalStorage.getStorage()); + + }); + + if (!mcClusterResourceList.isEmpty()) { + //物理主机个数 + Integer physicalHostTotal = + mcClusterResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getTotalPhysicalHost)); + //在线物理主机个数 + Integer physicalHostOnline = + mcClusterResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getOnlinePhysicalHost)); + ; + //离线物理主机个数 + Integer physicalHostOffline = + mcClusterResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getOfflinePhysicalHost)); + ; + + + //总云服务器个数 + Integer machineTotal = + mcClusterResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getTotalMachine)); + ; + //在线云服务器 + Integer machineOnline = + mcClusterResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getOnlineMachine)); + ; + //离线云服务器 + Integer machineOffline = + mcClusterResourceList.stream().collect(Collectors.summingInt(McClusterBaseResource::getOfflineMachine)); + ; + + zoneDetail.setPhysicalHostTotal(physicalHostTotal); + zoneDetail.setPhysicalHostOnline(physicalHostOnline); + zoneDetail.setPhysicalHostOffline(physicalHostOffline); + zoneDetail.setMachineTotal(machineTotal); + zoneDetail.setMachineOnline(machineOnline); + zoneDetail.setMachineOffline(machineOffline); + } + + return zoneDetail; + } + + + @Override + public List zoneList(LoginUserVo loginUserVo) { + + CloudRoleDo roleDo = roleService.getUserRole(loginUserVo.getUserId()); + + + if (Objects.isNull(roleDo)) { + return new ArrayList<>(); + } + List zoneInfoDtoList = new ArrayList<>(); + + //如果是平台管理用户,则全部可用区为可见 + boolean ifPlatformUser = userService.judgeIfPlatformUser(loginUserVo.getUserId()); + if (ifPlatformUser) { + return createZoneList(new ArrayList<>()); + } + CloudOrganizationDo loginUserOrg = orgService.getByUserId(loginUserVo.getUserId()); + + //如果不是则 查询登录用户对应组织拥有的VDC所关联的可用区 + CloudOrgVdcDo queryCloudOrgVdcDo = new CloudOrgVdcDo(); + queryCloudOrgVdcDo.setDeleteFlag(false); + queryCloudOrgVdcDo.setOrgId(loginUserOrg.getId()); + Wrapper orgVdcWrapper = new QueryWrapper<>(queryCloudOrgVdcDo); + List orgVdcList = cloudOrgVdcService.getBaseMapper().selectList(orgVdcWrapper); + if (orgVdcList.isEmpty()) { + //如果组织没有VDC则返回无可用区 + return zoneInfoDtoList; + } + + CloudVdcDo queryVdcDo = new CloudVdcDo(); + queryVdcDo.setDeleteFlag(false); + QueryWrapper vdcWrapper = new QueryWrapper<>(queryVdcDo); + vdcWrapper.in("id", orgVdcList.stream().map(CloudOrgVdcDo::getVdcId).collect(Collectors.toList())); + List vdcList = cloudVdcService.getBaseMapper().selectList(vdcWrapper); + + if (vdcList.isEmpty()) { + //如果组织没有VDC则返回无可用区 + return zoneInfoDtoList; + } + + return createZoneList(vdcList.stream().map(CloudVdcDo::getZoneId).collect(Collectors.toList())); + + } + + + /** + * 创建可用区列表 + * + * @param zoneIdList + */ + private List createZoneList(List zoneIdList) { + List zoneInfoDtoList = new ArrayList<>(); + CloudZoneDo queryZoneDo = new CloudZoneDo(); + queryZoneDo.setDeleteFlag(false); + QueryWrapper wrapper = new QueryWrapper<>(queryZoneDo); + if (!zoneIdList.isEmpty()) { + wrapper.in("id", zoneIdList); + } + List zoneList = cloudZoneService.getBaseMapper().selectList(wrapper); + + zoneList.forEach(item -> { + ZoneInfoDto zoneInfoDto = new ZoneInfoDto(); + zoneInfoDto.setZoneId(item.getId()); + zoneInfoDto.setName(item.getName()); + zoneInfoDtoList.add(zoneInfoDto); + }); + return zoneInfoDtoList; + } + + @Override + public CloudZoneDo getZoneByClusterId(Integer clusterId) { + return cloudZoneService.getByClusterId(clusterId); + } + + @Override + public List visibleZoneListByUserId(Integer userId) { + //平台管理用户,则全部可用区可见 + boolean ifPlatformUser = userService.judgeIfPlatformUser(userId); + if (ifPlatformUser) { + CloudZoneDo zoneDo = new CloudZoneDo(); + zoneDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(zoneDo); + return cloudZoneService.list(wrapper); + } + CloudVdcDo vdcDo = vdcService.getUserOrgBindVdc(userId); + if (Objects.isNull(vdcDo)) { + return new ArrayList<>(); + } + List zoneDoList = new ArrayList<>(); + CloudZoneDo userZone = cloudZoneService.getById(vdcDo.getZoneId()); + zoneDoList.add(userZone); + return zoneDoList; + } + + @Override + @Transactional + public void deleteZone(BaseZoneParam baseZoneParam, LoginUserVo loginUserVo) { + + //删除可用区限制条件 + //1:没有VDC绑定该可用区 + CloudVdcDo vdcDo = new CloudVdcDo(); + vdcDo.setDeleteFlag(false); + vdcDo.setZoneId(baseZoneParam.getZoneId()); + QueryWrapper wrapper = new QueryWrapper<>(vdcDo); + int zoneVdcCount = cloudVdcService.count(wrapper); + if (zoneVdcCount > 0) { + throw new KylinException(KylinHttpResponseZoneConstants.EXIST_VDC_NOT_DELETE); + } + CloudZoneDo zoneDo = cloudZoneService.getById(baseZoneParam.getZoneId()); + zoneDo.setDeleteFlag(true); + zoneDo.setDeleteBy(loginUserVo.getUserId()); + zoneDo.setDeleteTime(new Date()); + cloudZoneService.updateById(zoneDo); + + //删除可用区绑定的集群的关系记录 + List zoneClusterDoList = + cloudZoneClusterService.listZoneClusterByZone(baseZoneParam.getZoneId()); + zoneClusterDoList.forEach(item -> { + item.setDeleteFlag(true); + item.setDeleteBy(loginUserVo.getUserId()); + item.setDeleteTime(new Date()); + }); + if (!zoneClusterDoList.isEmpty()) { + cloudZoneClusterService.updateBatchById(zoneClusterDoList); + } + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/threadTask/McClusterNoDataThread.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/threadTask/McClusterNoDataThread.java new file mode 100644 index 0000000000000000000000000000000000000000..151732b534005936bbde65d4ae7f62484a1ed4c6 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/threadTask/McClusterNoDataThread.java @@ -0,0 +1,60 @@ +package com.hnkylin.cloud.manage.threadTask; + +import com.alibaba.fastjson.JSON; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.manage.config.MCConfigProperties; +import com.hnkylin.cloud.manage.service.McHttpService; + +import java.util.List; +import java.util.Objects; +import java.util.concurrent.Callable; + + +/** + * 向mc多集群发送无数据获取请假 + */ +public class McClusterNoDataThread implements Callable> { + + + private McHttpService mcHttpService; + + + private String loginUserName; + + private Integer clusterId; + + private String mcInterfaceUrl; + + private Object requestObject; + + + public McClusterNoDataThread(McHttpService mcHttpService, + String loginUserName, + Integer clusterId, String mcInterfaceUrl, Object requestObject) { + //this.latch = latch; + this.mcHttpService = mcHttpService; + this.loginUserName = loginUserName; + this.clusterId = clusterId; + this.mcInterfaceUrl = mcInterfaceUrl; + this.requestObject = requestObject; + } + + @Override + public MCResponseData call() { + MCResponseData mcResponse = null; + try { + mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, requestObject, mcInterfaceUrl, loginUserName + , 0); + if (Objects.nonNull(mcResponse)) { + return mcResponse; + + } + } catch (Exception e) { + e.printStackTrace(); + return null; + + } + return mcResponse; + } +} diff --git a/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/threadTask/McClusterThread.java b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/threadTask/McClusterThread.java new file mode 100644 index 0000000000000000000000000000000000000000..5f831a7619a1423b689eb95b5cf913c34746d4e9 --- /dev/null +++ b/mcp-cloud-manage/src/main/java/com/hnkylin/cloud/manage/threadTask/McClusterThread.java @@ -0,0 +1,57 @@ +package com.hnkylin.cloud.manage.threadTask; + +import com.alibaba.fastjson.JSON; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.manage.service.McHttpService; + +import java.util.Objects; +import java.util.concurrent.Callable; + + +/** + * 通用从mc集群中获取数据线程 + */ +public class McClusterThread implements Callable { + + + private McHttpService mcHttpService; + + + private String loginUserName; + + private Integer clusterId; + + private String mcInterfaceUrl; + + private Object requestObject; + + + public McClusterThread(McHttpService mcHttpService, String loginUserName, + Integer clusterId, String mcInterfaceUrl, Object requestObject) { + //this.latch = latch; + this.mcHttpService = mcHttpService; + this.loginUserName = loginUserName; + this.clusterId = clusterId; + this.mcInterfaceUrl = mcInterfaceUrl; + this.requestObject = requestObject; + } + + @Override + public String call() { + + String mcClusterResponse = null; + try { + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, requestObject, + mcInterfaceUrl, loginUserName, 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + mcClusterResponse = JSON.toJSONString(mcResponse.getData()); + } + } catch (Exception e) { + e.printStackTrace(); + return null; + + } + return mcClusterResponse; + } +} diff --git a/mcp-cloud-manage/src/main/resources/application-dev.yml b/mcp-cloud-manage/src/main/resources/application-dev.yml new file mode 100644 index 0000000000000000000000000000000000000000..93559366f9f9c5832271c2d81ba79e1ab38ebc38 --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/application-dev.yml @@ -0,0 +1,2 @@ +mc-config: + mcLogoLocalFilePath: E:\mcServerVmLogo\ \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/application-prod.yml b/mcp-cloud-manage/src/main/resources/application-prod.yml new file mode 100644 index 0000000000000000000000000000000000000000..49579f8c3b26b2f51f01ce326c99bf350bc7474d --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/application-prod.yml @@ -0,0 +1,14 @@ +server: + ssl: + key-store: classpath:keystore.p12 + key-password: 111111 + key-store-type: PKCS12 + enabled-protocols: TLSv1,TLSv1.1,TLSv1.2 + ciphers: TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DH_DSS_WITH_AES_128_CBC_SHA, TLS_DH_DSS_WITH_AES_256_CBC_SHA, TLS_DH_RSA_WITH_AES_128_CBC_SHA, TLS_DH_RSA_WITH_AES_256_CBC_SHA + client-auth: none + enabled: true + protocol: TLS + key-store-password: 111111 +mc-config: + mcLogoLocalFilePath: /soft/mcServerVmLogo/ + diff --git a/mcp-cloud-manage/src/main/resources/application.yml b/mcp-cloud-manage/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..afa74cc68b344c099d435f8aa1d207a0301533ea --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/application.yml @@ -0,0 +1,156 @@ +server: + servlet: + context-path: /mcp + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + # Tomcat启动初始化的线程数,默认值25 + threads: + max: 500 + min-spare: 30 + port: 8082 +logging: + config: classpath:logback.xml +spring: + thymeleaf: + #模板的模式,支持 HTML, XML TEXT JAVASCRIPT + mode: HTML5 + #编码 可不用配置 + encoding: UTF-8 + #开发配置为false,避免修改模板还要重启服务器 + cache: false + #配置模板路径,默认是templates,可以不用配置 + prefix: classpath:/templates/ + suffix: .html + servlet: + content-type: text/html + datasource: + url: jdbc:mysql://127.0.0.1:3306/mcp?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false + username: root + password: your_password + driver-class-name: com.mysql.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 + min-idle: 5 + max-active: 30 + # 配置获取连接等待超时的时间 + max-wait: 6000 + time-between-connect-error-millis: 10000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + time-between-eviction-runs-millis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + min-evictable-idle-time-millis: 300000 + validation-query: SELECT 1 FROM DUAL + validation-query-timeout: 50000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + # 打开PSCache,并且指定每个连接上PSCache的大小 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙,此处是filter修改的地方 + filter: + commons-log: + enabled: true + connection-logger-name: stat, wall, log4j + # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 + connection-properties: druid.stat.mergeSql:true;druid.stat.slowSqlMillis:5000 + # 合并多个DruidDataSource的监控数据 + use-global-data-source-stat: true + platform: mysql + #schema: classpath*:db/schema.sql + #data: classpath*:db/data.sql + #initialization-mode: always + redis: + # 地址 + host: 127.0.0.1 + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + #password: 123456Qw + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + profiles: + active: dev +mybatis-plus: + mapper-locations: classpath:mapping/*Mapper.xml + type-aliases-package: com.hnkylin.cloud.selfservice.domain,com.hnkylin.cloud.core.domain + global-config: + id-type: 0 + configuration: + default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler +auth: + authExcludeApis: + - /mcp/api/login + - /mcp/error + - /mcp/index +mc-config: + mcPrefix: /kylin + openPrefix: api + commonPrefix: /kylin/api + createServerVmUrl: /createVmServer + createServerVmByIsoUrl: /createVmServerByIso + modifyServerVmUrl: /modifyVmServer + networkConfigUrl: /networkConfigList + listPortGroupByNameUrl: /listPortGroupByName + storageLocationsListUrl: /storageLocationsList + getRealServiceListUrl: /getRealServiceList + getServervmDetailByServevmIdUrl: /getServervmDetailByServevmId + getServervmDetailByUuidUrl: /getServervmDetailByUuid + getDataStoreInfoByNameUrl: /getDataStoreInfoByName + isoListUrl: /isoList + checkVmServerNameUrl: /checkVmServerName + pageStorageUrl: /pageStorage + pagePhysicalHostUrl: /pagePhysicalHost + mcQuickLogin: /kcpOpenApi/kcpQuickLogin + mcClusterBaseResourceUrl: /clusterBaseResource + serverVmList: /getSelfServiceVmList + startServerVmUrl: /selfServiceVmServerStart + shutdownServerVmUrl: /selfServiceShutDown + forcedShutdownServerVmUrl: /selfServiceAbort + forcedRestartServerVmUrl: /selfServiceForceReboot + restartServerVmUrl: /selfServiceReboot + batchStartServerVmUrl: /startSelfServiceForBatch + batchShutdownServerVmUrl: /shutDownSelfServiceForBatch + batchRebootServerVmUrl: /rebootForBatch + batchRemoveMachineToRecycleUrl: /batchRemoveMachineToRecycle + logoPath: /images/hnkylin/ + serverVmVncUrl: /getServerVmVncUrl + serverVmInfoUrl: /kcpServerVmDetail + serverVmSummaryUrl: /kcpServemVmSummary + serverVmAlarmEventUrl: /kcpServemVmAlarmEvents + serverVmNetworkUrl: /kcpServemVmNetworks + serverVmDiskUrl: /kcpServemVmDisks + serverVmMonitorInfoUrl: /listServerVMStatus + serverVmOperateLogUrl: /listTasksByServerId + serverEventsFilterUrl: /serverEventsFilter + pagePhysicalHostEventUrl: /pagePhysicalHostEvent + alarmLogFilterUrl: /alarmLogFilter + pageAlarmLogUrl: /pageAlarmLog + serverVirtualizationEventsFilterUrl: /serverVirtualizationEventsFilter + pageServerVirtualizationEventUrl: /pageServerVirtualizationEvent + listAlarmSettingsUrl: /listAlarmSettings + updateAlarmSettingsUrl: /updateAlarmSettings + getAlarmIntervalUrl: /getAlarmInterval + updateAlarmIntervalUrl: /updateAlarmInterval + alarmNotificationsUrl: /alarmNotifications + checkClusterUserNameAndPasswordUrl: /checkClusterUserNameAndPassword + getClusterBindResourceListUrl: /getClusterBindResourceList + serverVmsUsedResourceUrl: /serverVmsUsedResource + serverVmRunningInfoUrl: /serverVmRunningInfo + ignoreNotificationsUrl: /ignoreNotifications + diff --git a/mcp-cloud-manage/src/main/resources/db/mcp.sql b/mcp-cloud-manage/src/main/resources/db/mcp.sql new file mode 100644 index 0000000000000000000000000000000000000000..dd9507ceb94cd7f3c5163d2e364f1faca77a0fca --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/db/mcp.sql @@ -0,0 +1,1170 @@ +/* + Navicat Premium Data Transfer + + Source Server : 127.0.0.1 + Source Server Type : MySQL + Source Server Version : 50730 + Source Host : 127.0.0.1:3306 + Source Schema : kcp-818server-3 + + Target Server Type : MySQL + Target Server Version : 50730 + File Encoding : 65001 + + Date: 25/11/2023 14:37:42 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for cloud_alarm_config +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_alarm_config`; +CREATE TABLE `cloud_alarm_config` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `resource_type` tinyint(1) NOT NULL COMMENT '资源类型', + `general_alarm` int(11) NOT NULL DEFAULT 0 COMMENT '一般告警值', + `severity_alarm` int(11) NOT NULL DEFAULT 0 COMMENT '严重告警', + `urgent_alarm` int(11) NOT NULL DEFAULT 0 COMMENT '紧急告警', + `duration_time` int(11) NOT NULL DEFAULT 0 COMMENT '持续时间', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'VDC告警设置表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_alarm_config +-- ---------------------------- +INSERT INTO `cloud_alarm_config` VALUES (1, 0, 70, 80, 90, 3, 1, '2022-04-06 14:44:10', 1, '2022-04-08 13:56:48', b'0', NULL, 0); +INSERT INTO `cloud_alarm_config` VALUES (2, 1, 70, 80, 90, 5, 1, '2022-04-06 14:44:29', 1, '2022-04-06 16:08:39', b'0', NULL, 0); +INSERT INTO `cloud_alarm_config` VALUES (3, 2, 70, 80, 90, 5, 1, '2022-04-06 14:44:45', 1, '2022-04-06 16:08:38', b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_alarm_log +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_alarm_log`; +CREATE TABLE `cloud_alarm_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `alarm_level` tinyint(1) NOT NULL DEFAULT 0 COMMENT '告警等级', + `resource_type` tinyint(1) NOT NULL COMMENT '类型', + `alarm_target` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '告警对象', + `target_type` tinyint(1) NULL DEFAULT NULL, + `alarm_detail` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警详情', + `alarm_target_id` int(11) NOT NULL DEFAULT 0 COMMENT '告警对象ID', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_targetId`(`alarm_target_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '平台告警日志' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_alarm_log +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_cluster +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_cluster`; +CREATE TABLE `cloud_cluster` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '集群名称', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '集群描述', + `type` tinyint(1) NOT NULL COMMENT '集群类型', + `cluster_admin_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '集群管理员名称', + `cluster_admin_password` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '集群管理员密码', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '集群管理' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_cluster +-- ---------------------------- +INSERT INTO `cloud_cluster` VALUES (1, '58集群', '58集群', 0, 'mcadmin1', '8fba933048e8369321a71c7852c75a07', 4, '2023-02-01 16:34:51', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_cluster_node +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_cluster_node`; +CREATE TABLE `cloud_cluster_node` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cluster_id` int(11) NOT NULL COMMENT '集群ID', + `http_type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT 'http类型', + `ip_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'ip地址', + `port` int(10) NULL DEFAULT 0 COMMENT '端口号', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_clusterId`(`cluster_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '集群主节点' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_cluster_node +-- ---------------------------- +INSERT INTO `cloud_cluster_node` VALUES (1, 1, 'https://', '10.90.6.58', 8443, 4, '2023-02-01 16:34:51', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_cluster_node` VALUES (2, 1, 'https://', '10.90.6.76', 8443, 4, '2023-02-01 16:34:51', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_network_config +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_network_config`; +CREATE TABLE `cloud_network_config` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vdc_id` int(11) NOT NULL DEFAULT 0, + `cluster_id` int(11) NOT NULL DEFAULT 0, + `network_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网络名称', + `interface_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网络类型', + `address_pool` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地址池', + `address_pool_id` int(11) NOT NULL DEFAULT 0 COMMENT '地址池ID', + `virtual_switch` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '虚拟交换机', + `model_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网卡类型', + `port_group` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '端口组', + `port_group_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '端口组uuid', + `security_policy` tinyint(1) NULL DEFAULT 0 COMMENT '安全策略', + `security_group_uuid` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安全组uuid', + `security_group` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安全组', + `virtual_firewall_id` int(11) NULL DEFAULT 0 COMMENT '虚拟防火墙ID', + `virtual_firewall_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '虚拟防火墙名称', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT NULL COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_cdv`(`vdc_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_network_config +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_org_vdc +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_org_vdc`; +CREATE TABLE `cloud_org_vdc` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `org_id` int(11) NOT NULL DEFAULT 0 COMMENT '组织id', + `vdc_id` int(11) NOT NULL COMMENT 'vdc虚拟数据中心Id', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_orgId`(`org_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = '组织关联VDC关联表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_org_vdc +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_organization +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_organization`; +CREATE TABLE `cloud_organization` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '组织ID', + `organization_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '组织名称', + `parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '上级组织ID', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `index_name`(`organization_name`, `delete_flag`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_organization +-- ---------------------------- +INSERT INTO `cloud_organization` VALUES (1, 'kylinsec', 0, '顶级组织', 1, '2022-04-14 15:27:58', 1, '2022-04-20 17:22:03', b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_permission +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_permission`; +CREATE TABLE `cloud_permission` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `parent_id` int(11) NOT NULL COMMENT '父ID', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '权限名称', + `icon` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT '权限图标', + `route_key` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL COMMENT '权限标识', + `platform_role_permission` bit(1) NULL DEFAULT b'0' COMMENT '平台管理权限 0:不是 1:是', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `index_routeKey`(`route_key`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 63 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = '权限表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_permission +-- ---------------------------- +INSERT INTO `cloud_permission` VALUES (1, 0, '运营', NULL, 'operator', b'1', 0, '2021-11-24 11:36:02', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (2, 1, '组织管理', NULL, 'org', b'1', 0, '2021-11-24 11:37:41', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (3, 2, '查询组织', NULL, 'search_org', b'1', 0, '2021-11-24 11:38:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (4, 2, '添加组织', NULL, 'create_org', b'1', 0, '2021-11-24 11:38:38', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (5, 2, '删除组织', NULL, 'delete_org', b'1', 0, '2021-11-24 11:38:57', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (6, 2, '编辑组织', NULL, 'modify_org', b'1', 0, '2021-11-24 11:39:20', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (7, 2, '组织详情', NULL, 'org_info', b'1', 0, '2021-11-24 11:40:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (8, 1, '权限管理', NULL, 'permission', b'1', 0, '2021-11-24 11:42:25', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (9, 8, '角色管理', NULL, 'role', b'1', 0, '2021-11-24 11:42:52', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (10, 9, '查询角色', NULL, 'search_role', b'1', 0, '2021-11-24 11:43:27', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (11, 9, '添加角色', NULL, 'create_role', b'1', 0, '2021-11-24 11:43:52', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (12, 9, '编辑角色', NULL, 'modify_role', b'1', 0, '2021-11-24 11:44:39', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (13, 9, '删除角色', NULL, 'delete_role', b'1', 0, '2021-11-24 11:45:00', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (14, 9, '查看角色详情', NULL, 'role_info', b'1', 0, '2021-11-24 11:45:34', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (15, 8, '用户管理', NULL, 'user', b'1', 0, '2021-11-24 11:45:55', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (16, 15, '查询用户', NULL, 'search_user', b'1', 0, '2021-11-24 11:46:14', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (17, 15, '添加用户', NULL, 'create_user', b'1', 0, '2021-11-24 11:46:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (18, 15, '编辑用户', NULL, 'modify_user', b'1', 0, '2021-11-24 11:47:34', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (19, 15, '删除用户', NULL, 'delete_user', b'1', 0, '2021-11-24 11:47:54', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (20, 15, '激活用户', NULL, 'active_user', b'1', 0, '2021-11-24 11:48:23', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (21, 0, '资源', NULL, 'resource', b'1', 0, '2021-11-24 11:49:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (22, 21, '物理集群', NULL, 'cluster', b'0', 0, '2021-12-16 16:04:05', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (23, 22, '添加物理集群', NULL, 'create_cluster', b'0', 0, '2021-12-16 16:04:33', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (24, 22, '查询物理集群', NULL, 'search_cluster', b'0', 0, '2021-12-16 16:04:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (25, 22, '物理集群详情', NULL, 'cluster_info', b'0', 0, '2021-12-16 16:05:22', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (26, 22, '编辑物理集群', NULL, 'modify_cluster', b'0', 0, '2021-12-16 16:05:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (27, 22, '删除物理集群', NULL, 'delete_cluster', b'0', 0, '2021-12-16 16:06:02', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (28, 1, '工单管理', NULL, 'workorder', b'1', 0, '2021-12-16 16:27:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (29, 28, '工单审核', NULL, 'check_workorder', b'1', 0, '2021-12-16 16:28:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (30, 28, '网络设置', NULL, 'networkconfig', b'1', 0, '2021-12-16 16:29:09', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (31, 21, '可用区管理', NULL, 'zone', b'0', 0, '2022-01-21 10:04:21', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (32, 31, '添加可用区', NULL, 'create_zone', b'0', 0, '2022-01-21 10:04:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (33, 31, '查询可用区', NULL, 'search_zone', b'0', 0, '2022-01-21 10:05:34', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (34, 31, '编辑可用区', NULL, 'modify_zone', b'0', 0, '2022-01-21 10:06:20', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (35, 31, '可用区详情', NULL, 'zone_info', b'0', 0, '2022-01-21 10:07:02', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (36, 31, '删除可用区', NULL, 'delete_zone', b'0', 0, '2022-01-21 10:07:38', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (37, 21, '虚拟数据中心VDC', NULL, 'vdc', b'1', 0, '2022-01-21 10:08:17', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (38, 37, '添加vdc', NULL, 'create_vdc', b'1', 0, '2022-01-21 10:10:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (39, 37, 'vdc列表查询', NULL, 'search_vdc', b'1', 0, '2022-01-21 10:11:28', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (40, 37, '编辑vdc', NULL, 'modify_vdc', b'1', 0, '2022-01-21 10:11:58', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (41, 37, 'vdc详情', NULL, 'vdc_info', b'1', 0, '2022-01-21 10:12:21', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (42, 37, '删除vdc', NULL, 'delete_vdc', b'1', 0, '2022-01-21 10:12:45', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (43, 21, '云服务器', NULL, 'servervm', b'1', 0, '2022-02-16 10:17:17', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (44, 43, '查询云服务器', NULL, 'search_servervm', b'1', 0, '2022-02-16 10:17:45', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (45, 43, '开机', NULL, 'start_servervm', b'1', 0, '2022-02-16 10:18:14', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (46, 43, '关机', NULL, 'shutdown_servervm', b'1', 0, '2022-02-16 10:18:38', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (47, 43, '强制关机', NULL, 'force_shutdown_servervm', b'1', 0, '2022-02-16 10:19:48', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (48, 43, '重启', NULL, 'restart_servervm', b'1', 0, '2022-02-16 10:20:15', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (49, 43, '强制重启', NULL, 'force_restart_servervm', b'1', 0, '2022-02-16 10:21:22', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (50, 43, '云服务器详情', NULL, 'servervm_info', b'1', 0, '2022-02-16 10:22:09', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (51, 43, '删除云服务器', NULL, 'delete_servervm', b'1', 0, '2022-02-16 10:26:33', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (52, 0, '监控', NULL, 'monitor', b'1', 0, '2022-02-24 17:54:35', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (53, 52, '告警事件', NULL, 'alarmEvent', b'1', 0, '2022-02-24 17:55:36', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (54, 53, '告警日志', NULL, 'alarmLog', b'1', 0, '2022-02-24 17:56:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (55, 54, '导出', NULL, 'exportAlarmLog', b'1', 0, '2022-02-24 17:56:49', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (56, 53, '告警设置', NULL, 'settingAlarm', b'1', 0, '2022-02-24 17:57:15', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (57, 52, '操作日志', NULL, 'operateLog', b'1', 0, '2022-02-24 19:02:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (58, 57, '物理主机事件', NULL, 'serverEvent', b'1', 0, '2022-02-24 19:03:46', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (59, 58, '导出', NULL, 'ecportServerEvent', b'1', 0, '2022-02-24 19:04:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (60, 57, '云服务器时间', NULL, 'cloudServerEvent', b'1', 0, '2022-02-24 19:04:46', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (61, 60, '导出', NULL, 'exportCloudServerEvent', b'1', 0, '2022-02-24 19:05:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_permission` VALUES (62, 37, '变更VDC', NULL, 'apply_vdc', b'1', 0, '2022-04-01 10:49:25', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_role +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_role`; +CREATE TABLE `cloud_role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `role_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '角色名称', + `role_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '角色类型 \r\n0:平台管理,1:组织管理, 2: 自服务', + `default_role` bit(1) NULL DEFAULT b'0' COMMENT '是否系统内置默认角色 0:不是 1:是', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = '角色表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_role +-- ---------------------------- +INSERT INTO `cloud_role` VALUES (1, '系统管理员', 0, b'1', '系统管理员:仅能执行系统业务维护,以及创建/删除帐号的操作', 0, '2021-11-22 16:35:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role` VALUES (2, '安全管理员', 0, b'1', '安全管理员:仅能执行用户、角色的权限管理;', 0, '2021-11-22 16:35:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role` VALUES (3, '安全审计员', 0, b'1', '安全审计员:仅能执行系统日志管理,对其他用户的操作进行审查', 0, '2021-11-22 16:35:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role` VALUES (4, '组织管理员', 1, b'1', '组织管理员:主要是对组织信息以及资源分配,方便使用VDC资源', 0, '2021-11-22 16:35:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role` VALUES (5, '自服务用户', 2, b'1', '自服务用户:通过机构建立的portal平台,实现对云服务器申请、工单管理、账号管理', 0, '2021-11-22 16:35:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role` VALUES (6, '超级管理员', 0, b'1', '超级管理员:拥有管理整个平台的权限', 0, '2022-04-20 20:36:56', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_role_permission +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_role_permission`; +CREATE TABLE `cloud_role_permission` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `role_id` int(11) NOT NULL COMMENT '角色ID', + `permission_id` int(11) NOT NULL COMMENT '权限ID', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_role`(`role_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1188 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = '角色权限表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_role_permission +-- ---------------------------- +INSERT INTO `cloud_role_permission` VALUES (1, 1, 1, 0, '2022-03-08 19:27:17', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (2, 1, 2, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (3, 1, 3, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (4, 1, 4, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (5, 1, 5, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (6, 1, 6, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (7, 1, 7, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (8, 1, 8, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (9, 1, 9, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (10, 1, 10, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (11, 1, 11, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (12, 1, 12, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (13, 1, 13, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (14, 1, 14, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (15, 1, 15, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (16, 1, 16, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (17, 1, 17, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (18, 1, 18, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (19, 1, 19, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (20, 1, 20, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (21, 1, 21, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (22, 1, 22, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (23, 1, 23, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (24, 1, 24, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (25, 1, 25, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (26, 1, 26, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (27, 1, 27, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (28, 1, 28, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (29, 1, 29, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (30, 1, 30, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (31, 1, 31, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (32, 1, 32, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (33, 1, 33, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (34, 1, 34, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (35, 1, 35, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (36, 1, 36, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (37, 1, 37, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (38, 1, 38, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (39, 1, 39, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (40, 1, 40, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (41, 1, 41, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (42, 1, 42, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (43, 1, 43, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (44, 1, 44, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (45, 1, 45, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (46, 1, 46, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (47, 1, 47, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (48, 1, 48, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (49, 1, 49, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (50, 1, 50, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (51, 1, 51, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (52, 1, 52, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (53, 1, 53, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (54, 1, 54, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (55, 1, 55, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (56, 1, 56, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (57, 1, 57, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (58, 1, 58, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (59, 1, 59, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (60, 1, 60, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (61, 1, 61, 1, '2022-03-08 19:33:42', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (62, 2, 1, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (63, 2, 2, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (64, 2, 3, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (65, 2, 8, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (66, 2, 9, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (67, 2, 10, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (68, 2, 11, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (69, 2, 12, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (70, 2, 13, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (71, 2, 14, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (72, 2, 15, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (73, 2, 16, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (74, 2, 18, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (75, 2, 19, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (76, 2, 20, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (77, 2, 52, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (78, 2, 53, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (79, 2, 54, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (80, 2, 55, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (81, 2, 56, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (82, 2, 57, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (83, 2, 58, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (84, 2, 59, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (85, 2, 60, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (86, 2, 61, 1, '2022-03-08 19:40:11', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (87, 3, 52, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (88, 3, 53, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (89, 3, 54, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (90, 3, 55, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (91, 3, 56, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (92, 3, 57, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (93, 3, 58, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (94, 3, 59, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (95, 3, 60, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (96, 3, 61, 1, '2022-03-08 19:40:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (402, 1, 62, 1, '2022-04-01 10:50:09', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (977, 4, 1, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (978, 4, 2, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (979, 4, 3, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (980, 4, 4, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (981, 4, 5, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (982, 4, 6, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (983, 4, 7, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (984, 4, 8, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (991, 4, 15, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (992, 4, 16, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (993, 4, 17, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (994, 4, 18, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (995, 4, 19, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (996, 4, 20, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (997, 4, 21, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (998, 4, 28, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (999, 4, 29, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1000, 4, 30, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1001, 4, 37, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1002, 4, 38, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1003, 4, 39, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1004, 4, 40, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1005, 4, 41, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1006, 4, 42, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1007, 4, 43, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1008, 4, 44, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1009, 4, 45, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1010, 4, 46, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1011, 4, 47, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1012, 4, 48, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1013, 4, 49, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1014, 4, 50, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1015, 4, 51, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1016, 4, 52, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1017, 4, 53, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1018, 4, 54, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1019, 4, 55, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1020, 4, 56, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1021, 4, 57, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1022, 4, 58, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1023, 4, 59, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1024, 4, 60, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1025, 4, 61, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1026, 4, 62, 37, '2022-04-15 17:54:50', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1126, 6, 1, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1127, 6, 2, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1128, 6, 3, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1129, 6, 4, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1130, 6, 5, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1131, 6, 6, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1132, 6, 7, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1133, 6, 8, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1134, 6, 9, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1135, 6, 10, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1136, 6, 11, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1137, 6, 12, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1138, 6, 13, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1139, 6, 14, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1140, 6, 15, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1141, 6, 16, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1142, 6, 17, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1143, 6, 18, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1144, 6, 19, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1145, 6, 20, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1146, 6, 21, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1147, 6, 22, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1148, 6, 23, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1149, 6, 24, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1150, 6, 25, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1151, 6, 26, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1152, 6, 27, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1153, 6, 28, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1154, 6, 29, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1155, 6, 30, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1156, 6, 31, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1157, 6, 32, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1158, 6, 33, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1159, 6, 34, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1160, 6, 35, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1161, 6, 36, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1162, 6, 37, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1163, 6, 38, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1164, 6, 39, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1165, 6, 40, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1166, 6, 41, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1167, 6, 42, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1168, 6, 43, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1169, 6, 44, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1170, 6, 45, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1171, 6, 46, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1172, 6, 47, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1173, 6, 48, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1174, 6, 49, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1175, 6, 50, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1176, 6, 51, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1177, 6, 52, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1178, 6, 53, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1179, 6, 54, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1180, 6, 55, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1181, 6, 56, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1182, 6, 57, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1183, 6, 58, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1184, 6, 59, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1185, 6, 60, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1186, 6, 61, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_role_permission` VALUES (1187, 6, 62, 1, '2022-04-21 10:43:47', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_user +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_user`; +CREATE TABLE `cloud_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', + `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户姓名', + `real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '真实姓名', + `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', + `mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机号', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', + `organization_id` int(11) NOT NULL DEFAULT 0 COMMENT '组织ID', + `user_type` tinyint(4) NULL DEFAULT 0 COMMENT '用户类型 0:自服务用户, 1:云管用户', + `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + `super_user` bit(1) NULL DEFAULT b'0' COMMENT '是否是超级管理员 0:不是 1:是', + `default_user` bit(1) NULL DEFAULT b'0' COMMENT '是否系统内置默认用户 0:不是 1:是', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_org`(`organization_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_user +-- ---------------------------- +INSERT INTO `cloud_user` VALUES (1, 'sysadmin', '系统管理员', '25f9e794323b453885f5181f1b624d0b', NULL, '仅能执行系统业务维护,一级用户管理的操作', 1, 1, 1, 0, '2022-03-08 19:18:55', 0, NULL, b'0', NULL, 0, b'0', b'1'); +INSERT INTO `cloud_user` VALUES (2, 'secadmin', '安全管理员', '25f9e794323b453885f5181f1b624d0b', NULL, '仅能执行角色管理,密码策略管理,用户激活/锁定/解锁的操作,一级系统日志的查看操作', 1, 1, 1, 0, '2022-03-08 19:24:13', 0, NULL, b'0', NULL, 0, b'0', b'1'); +INSERT INTO `cloud_user` VALUES (3, 'secauditor', '审计管理员', '25f9e794323b453885f5181f1b624d0b', NULL, '仅能执行角色管理,密码策略管理,用户激活/锁定/解锁的操作,一级系统日志的查看操作', 1, 1, 1, 0, '2022-03-08 19:24:48', 0, NULL, b'0', NULL, 0, b'0', b'1'); +INSERT INTO `cloud_user` VALUES (4, 'admin', '超级管理员', '25f9e794323b453885f5181f1b624d0b', NULL, '超级管理员', 1, 1, 1, 0, '2022-04-14 15:52:00', 0, NULL, b'0', NULL, 0, b'1', b'1'); + +-- ---------------------------- +-- Table structure for cloud_user_machine +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_user_machine`; +CREATE TABLE `cloud_user_machine` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` int(11) NOT NULL COMMENT '用户ID', + `machine_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'mc中云服务器ID', + `deadline_time` datetime(0) NOT NULL COMMENT '截止时间', + `deadline_type` int(11) NULL DEFAULT 0 COMMENT '到期处理策略', + `deadline_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否过期 0:没有 1:已过期', + `cluster_id` int(11) NOT NULL DEFAULT 0 COMMENT '集群id', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:删除 1:未删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `index_uuid`(`machine_uuid`) USING BTREE, + INDEX `index_user_id`(`user_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户拥有云服务器关联表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_user_machine +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_user_role +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_user_role`; +CREATE TABLE `cloud_user_role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL DEFAULT 0, + `role_id` int(11) NOT NULL, + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:删除 1:未删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_userid`(`user_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = '用户角色关联表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_user_role +-- ---------------------------- +INSERT INTO `cloud_user_role` VALUES (1, 1, 1, 0, '2022-03-08 19:26:47', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_user_role` VALUES (2, 2, 2, 0, '2022-03-08 19:26:56', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_user_role` VALUES (3, 3, 3, 0, '2022-03-08 19:27:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_user_role` VALUES (4, 4, 6, 1, '2022-03-11 10:59:43', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_vcenter +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_vcenter`; +CREATE TABLE `cloud_vcenter` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT '名称', + `remark` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT '描述', + `vcenter_ip` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT 'vcenterIp', + `vcenter_port` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT 'vcenter端口', + `vcenter_account` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT 'vcenter账号', + `vcenter_password` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT 'vcenter账号', + `status` tinyint(1) NULL DEFAULT NULL COMMENT '状态', + `http_type` tinyint(1) NULL DEFAULT NULL COMMENT 'http类型', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = 'vcenter管理表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_vcenter +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_vdc +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_vdc`; +CREATE TABLE `cloud_vdc` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vdc_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'vdc名称', + `parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '父VDC-ID', + `zone_id` int(11) NOT NULL DEFAULT 0 COMMENT '可用区ID', + `remark` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT '描述', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci COMMENT = '虚拟数据中心VDC' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_vdc +-- ---------------------------- +INSERT INTO `cloud_vdc` VALUES (1, '研发一部VDC', 0, 1, '', 1, '2022-09-08 14:46:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_vdc` VALUES (2, '虚拟化VDC', 1, 1, '', 1, '2022-09-08 14:46:43', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_vdc_cpu +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_vdc_cpu`; +CREATE TABLE `cloud_vdc_cpu` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vdc_id` int(11) NOT NULL COMMENT 'vdc ID', + `architecture` tinyint(1) NOT NULL COMMENT '架构类型', + `vcpus` int(11) NULL DEFAULT NULL COMMENT 'cpu', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_vdc`(`vdc_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'vdc-cpu关联表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_vdc_cpu +-- ---------------------------- +INSERT INTO `cloud_vdc_cpu` VALUES (1, 1, 0, 1000, 1, '2022-09-08 14:46:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_vdc_cpu` VALUES (2, 2, 0, 500, 1, '2022-09-08 14:46:43', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_vdc_mem +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_vdc_mem`; +CREATE TABLE `cloud_vdc_mem` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vdc_id` int(11) NOT NULL COMMENT 'vdc ID', + `architecture` tinyint(1) NOT NULL COMMENT '架构类型', + `mem` int(11) NULL DEFAULT NULL COMMENT '内存大小', + `mem_unit` tinyint(1) NULL DEFAULT NULL COMMENT '内存单位', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_vdc`(`vdc_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'vdc-内存关联表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_vdc_mem +-- ---------------------------- +INSERT INTO `cloud_vdc_mem` VALUES (1, 1, 0, 2000, 1, 1, '2022-09-08 14:46:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_vdc_mem` VALUES (2, 2, 0, 1000, 1, 1, '2022-09-08 14:46:43', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_vdc_storage +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_vdc_storage`; +CREATE TABLE `cloud_vdc_storage` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `vdc_id` int(11) NOT NULL COMMENT 'vdc ID', + `storage` int(11) NULL DEFAULT NULL COMMENT '存储大小', + `unit` tinyint(1) NULL DEFAULT NULL COMMENT '单位', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_vdc`(`vdc_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'vdc-存储' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_vdc_storage +-- ---------------------------- +INSERT INTO `cloud_vdc_storage` VALUES (1, 1, 3000, 0, 1, '2022-09-08 14:46:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_vdc_storage` VALUES (2, 2, 2000, 0, 1, '2022-09-08 14:46:43', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_work_order +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order`; +CREATE TABLE `cloud_work_order` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL COMMENT '用户ID', + `type` int(2) NOT NULL COMMENT '工单类型', + `target` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工单对象', + `apply_reason` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '申请原因', + `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '工单状态', + `audit_by` int(11) NOT NULL DEFAULT 0 COMMENT '审核者', + `audit_time` datetime(0) NULL DEFAULT NULL COMMENT '审核时间', + `audit_opinion` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审核时间', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT NULL COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order +-- ---------------------------- +INSERT INTO `cloud_work_order` VALUES (1, 9, 2, 'test-disk', 'test-disk', 1, 1, '2022-09-08 15:38:33', 'pass', 9, '2022-09-08 15:38:23', 1, '2022-09-08 15:38:33', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (2, 9, 3, 'test-disk_3', 'ddd', 1, 1, '2022-09-08 15:57:33', 'pass', 9, '2022-09-08 15:56:51', 1, '2022-09-08 15:57:33', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (3, 9, 3, 'test-disk_3', '啛啛喳喳', 1, 1, '2022-09-08 15:58:13', 'pass', 9, '2022-09-08 15:57:45', 1, '2022-09-08 15:58:13', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (4, 9, 3, 'test-disk_0', '存储', 1, 1, '2022-09-08 15:59:36', 'pass', 9, '2022-09-08 15:59:26', 1, '2022-09-08 15:59:36', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (5, 9, 3, 'test-disk_0', '侧耳', 1, 1, '2022-09-08 16:00:18', 'pass', 9, '2022-09-08 16:00:08', 1, '2022-09-08 16:00:18', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (6, 9, 3, 'test-disk_0', '上试试', 1, 1, '2022-09-08 16:01:21', 'psss', 9, '2022-09-08 16:01:09', 1, '2022-09-08 16:01:21', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (7, 9, 3, 'test-disk_0', 'ccc', 1, 1, '2022-09-08 16:09:54', 'pass', 9, '2022-09-08 16:09:46', 1, '2022-09-08 16:09:54', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (8, 9, 3, 'test-disk_0', 'paass', 1, 1, '2022-09-08 16:10:43', 'pass', 9, '2022-09-08 16:10:26', 1, '2022-09-08 16:10:43', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (9, 9, 3, 'test-disk_0', 'rrrr', 1, 1, '2022-09-08 16:14:44', '擦擦擦', 9, '2022-09-08 16:12:59', 1, '2022-09-08 16:14:44', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (10, 9, 3, 'test-disk_0', 'ddd', 1, 1, '2022-09-08 19:40:28', 'pass', 9, '2022-09-08 19:39:27', 1, '2022-09-08 19:40:28', b'0', NULL, NULL); +INSERT INTO `cloud_work_order` VALUES (11, 9, 2, '45545545', '434', 1, 1, '2022-09-16 16:38:02', 'pass', 9, '2022-09-16 16:35:52', 1, '2022-09-16 16:38:02', b'0', NULL, NULL); + +-- ---------------------------- +-- Table structure for cloud_work_order_deferred_machine +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_deferred_machine`; +CREATE TABLE `cloud_work_order_deferred_machine` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `old_deadline_time` datetime(0) NOT NULL COMMENT '原过期时间', + `deadline_time` datetime(0) NOT NULL COMMENT '截止时间', + `user_machine_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户拥有云服务器关联表ID', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请延期表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_deferred_machine +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_work_order_modify_servervm +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_modify_servervm`; +CREATE TABLE `cloud_work_order_modify_servervm` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `machine_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '云服务器uuid', + `servervm_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '虚拟机名称', + `deadline_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '到期处理策略', + `os_machine` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作系统', + `architecture` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '架构', + `system_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统类型', + `cpu` int(11) NOT NULL DEFAULT 0 COMMENT 'cpu数', + `original_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更前cpu数', + `mem` int(11) NOT NULL COMMENT '内存', + `original_mem` int(11) NOT NULL COMMENT '变更前内存', + `mem_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '内存单位', + `deadline_time` datetime(0) NULL DEFAULT NULL COMMENT '到期时间', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-变更云服务器表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_modify_servervm +-- ---------------------------- +INSERT INTO `cloud_work_order_modify_servervm` VALUES (1, 2, '75e2ed6d-44aa-3e7b-79c0-ea0055f3c567', 'test-disk_3', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 15:56:51', 1, '2022-09-08 15:57:33', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (2, 3, '75e2ed6d-44aa-3e7b-79c0-ea0055f3c567', 'test-disk_3', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 15:57:45', 1, '2022-09-08 15:58:13', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (3, 4, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 15:59:26', 1, '2022-09-08 15:59:36', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (4, 5, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 16:00:08', 1, '2022-09-08 16:00:18', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (5, 6, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 16:01:09', 1, '2022-09-08 16:01:21', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (6, 7, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 16:09:46', 1, '2022-09-08 16:09:54', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (7, 8, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 16:10:26', 1, '2022-09-08 16:10:43', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (8, 9, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 16:12:59', 1, '2022-09-08 16:14:44', b'0', NULL, 0); +INSERT INTO `cloud_work_order_modify_servervm` VALUES (9, 10, '229718d1-e633-3d20-cd46-22ce24e08403', 'test-disk_0', 0, 'KylinsecOS', 'x86_64', '麒麟信安', 1, 1, 1, 1, 1, '2022-10-08 23:59:59', 9, '2022-09-08 19:39:27', 1, '2022-09-08 19:40:28', b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm`; +CREATE TABLE `cloud_work_order_servervm` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `apply_servervm_type` tinyint(11) NULL DEFAULT 0 COMMENT '申请类型', + `clone_type` tinyint(11) NULL DEFAULT 0 COMMENT '创建类型 0:完整克隆 1:链接克隆', + `servervm_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '虚拟机名称', + `apply_num` int(11) NOT NULL DEFAULT 0 COMMENT '申请个数', + `modify_apply_num` int(11) NOT NULL DEFAULT 0 COMMENT '变更后申请个数', + `use_month` int(11) NOT NULL DEFAULT 0 COMMENT '使用月数', + `deadline_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '到期处理策略', + `os_machine` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作系统', + `architecture` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '架构', + `system_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统类型', + `template_id` int(11) NOT NULL COMMENT '模板ID', + `cluster_id` int(11) NULL DEFAULT 0 COMMENT '集群ID', + `cpu` int(11) NOT NULL DEFAULT 0 COMMENT 'cpu数', + `modify_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更后cpu', + `mem` int(11) NOT NULL COMMENT '内存', + `modify_mem` int(11) NULL DEFAULT NULL COMMENT '变更后内存', + `mem_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '内存单位', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注信息', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请云服务器表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_servervm +-- ---------------------------- +INSERT INTO `cloud_work_order_servervm` VALUES (1, 1, 0, 1, 'test-disk', 4, 4, 1, 0, 'KylinsecOS', 'X86_64', '麒麟信安', 12, 1, 1, 1, 1, 1, 1, 'test-disk', 9, '2022-09-08 15:38:23', 1, '2022-09-08 15:38:33', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm` VALUES (2, 11, 0, 1, '45545545', 2, 2, 1, 0, 'KylinsecOS', 'X86_64', '麒麟信安', 4, 1, 1, 1, 1, 1, 1, '34343', 9, '2022-09-16 16:35:52', 1, '2022-09-16 16:38:02', b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm_disk +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm_disk`; +CREATE TABLE `cloud_work_order_servervm_disk` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL DEFAULT 0 COMMENT '工单ID', + `disk_id` int(11) NOT NULL COMMENT '磁盘ID', + `disk_size` int(11) NOT NULL COMMENT '硬盘大小', + `disk_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '硬盘单位 0:GB 1:TB', + `purpose` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用途', + `type` tinyint(4) NULL DEFAULT 0 COMMENT '类型 0:原始,1:自定义', + `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除', + `old_disk_size` int(11) NOT NULL DEFAULT 0 COMMENT '原来磁盘大小', + `old_disk_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '原来磁盘单位 0:GB 1:TB', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 35 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请服务器硬盘详情表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_servervm_disk +-- ---------------------------- +INSERT INTO `cloud_work_order_servervm_disk` VALUES (1, 1, 17, 100, 0, '', 0, 0, 100, 0, 9, '2022-09-08 15:38:23', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (2, 1, 0, 200, 0, 'ces', 1, 1, 200, 0, 9, '2022-09-08 15:38:23', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (3, 2, 25, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 15:56:51', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (4, 2, 26, 200, 0, NULL, 0, 0, 200, 0, 9, '2022-09-08 15:56:51', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (5, 2, 0, 300, 0, '测试', 1, 1, 300, 0, 9, '2022-09-08 15:56:51', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (6, 3, 25, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 15:57:45', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (7, 3, 26, 200, 0, NULL, 0, 3, 200, 0, 9, '2022-09-08 15:57:45', 1, '2022-09-08 15:58:13', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (8, 3, 27, 300, 0, NULL, 0, 0, 300, 0, 9, '2022-09-08 15:57:45', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (9, 4, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 15:59:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (10, 4, 20, 200, 0, NULL, 0, 0, 200, 0, 9, '2022-09-08 15:59:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (11, 4, 0, 300, 0, '测', 1, 1, 300, 0, 9, '2022-09-08 15:59:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (12, 5, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 16:00:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (13, 5, 20, 200, 0, NULL, 0, 3, 200, 0, 9, '2022-09-08 16:00:08', 1, '2022-09-08 16:00:18', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (14, 5, 28, 300, 0, NULL, 0, 0, 300, 0, 9, '2022-09-08 16:00:08', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (15, 6, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 16:01:09', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (16, 6, 28, 300, 0, NULL, 0, 3, 300, 0, 9, '2022-09-08 16:01:09', 1, '2022-09-08 16:01:21', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (17, 7, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 16:09:46', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (18, 7, 0, 300, 0, 'ces', 1, 1, 300, 0, 9, '2022-09-08 16:09:46', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (19, 7, 0, 300, 0, 'ce', 1, 1, 300, 0, 9, '2022-09-08 16:09:46', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (20, 8, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 16:10:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (21, 8, 29, 300, 0, NULL, 0, 3, 300, 0, 9, '2022-09-08 16:10:26', 1, '2022-09-08 16:10:43', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (22, 8, 30, 300, 0, NULL, 0, 3, 300, 0, 9, '2022-09-08 16:10:26', 1, '2022-09-08 16:10:43', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (23, 8, 0, 150, 0, 'ces', 1, 1, 150, 0, 9, '2022-09-08 16:10:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (24, 8, 0, 160, 0, 'ces', 1, 1, 160, 0, 9, '2022-09-08 16:10:26', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (25, 9, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 16:12:59', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (26, 9, 31, 150, 0, NULL, 0, 3, 150, 0, 9, '2022-09-08 16:12:59', 1, '2022-09-08 16:14:44', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (27, 9, 32, 160, 0, NULL, 0, 3, 160, 0, 9, '2022-09-08 16:12:59', 1, '2022-09-08 16:14:44', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (28, 9, 0, 300, 0, 'eeee', 1, 1, 300, 0, 9, '2022-09-08 16:12:59', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (29, 9, 0, 350, 0, '', 1, 1, 350, 0, 1, '2022-09-08 16:14:44', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (30, 10, 19, 100, 0, NULL, 0, 0, 100, 0, 9, '2022-09-08 19:39:27', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (31, 10, 33, 300, 0, NULL, 0, 3, 300, 0, 9, '2022-09-08 19:39:27', 1, '2022-09-08 19:40:28', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (32, 10, 34, 350, 0, NULL, 0, 3, 350, 0, 9, '2022-09-08 19:39:27', 1, '2022-09-08 19:40:28', b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (33, 10, 0, 120, 0, '测试', 1, 1, 120, 0, 9, '2022-09-08 19:39:27', 0, NULL, b'0', NULL, 0); +INSERT INTO `cloud_work_order_servervm_disk` VALUES (34, 11, 8, 100, 0, '', 0, 0, 100, 0, 9, '2022-09-16 16:35:52', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm_iso +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm_iso`; +CREATE TABLE `cloud_work_order_servervm_iso` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `work_order_id` int(11) NOT NULL DEFAULT 0 COMMENT '工单ID', + `iso_file` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT 'iso文件名', + `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除', + `old_iso_file` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL COMMENT '旧iso文件名', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_servervm_iso +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm_network +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm_network`; +CREATE TABLE `cloud_work_order_servervm_network` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `interface_id` int(11) NOT NULL DEFAULT 0 COMMENT '网卡ID', + `purpose` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用途', + `type` tinyint(4) NULL DEFAULT 0 COMMENT '类型 0:原始,1 自定义', + `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除', + `ip_bind_mac` bit(1) NOT NULL DEFAULT b'0' COMMENT 'ip和mac绑定 0:未绑定 1:已绑定', + `manual_set_ip` bit(1) NOT NULL DEFAULT b'0' COMMENT '手动设置ip 0:未设置 1:已设置', + `automatic_acq_ip` bit(1) NOT NULL DEFAULT b'0' COMMENT '自动DHP 0:未设置 1:已设置', + `ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'ip地址', + `mask` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '掩码', + `gw` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网关', + `dns1` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'dns1', + `dns2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'dns2', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请服务器网卡详情表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_servervm_network +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_work_order_user +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_user`; +CREATE TABLE `cloud_work_order_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `old_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '旧真实姓名', + `new_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '新真实姓名', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-变更账号详情表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_user +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_work_order_vdc +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_vdc`; +CREATE TABLE `cloud_work_order_vdc` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `vdc_id` int(11) NOT NULL COMMENT 'vdcId', + `old_storage` int(11) NOT NULL COMMENT '存储大小', + `storage_unit` tinyint(1) NULL DEFAULT NULL COMMENT '存储单位', + `apply_storage` int(11) NULL DEFAULT NULL COMMENT '申请存储大小', + `real_storage` int(11) NULL DEFAULT NULL COMMENT '审核后实际存储大小', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_vdc +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_work_order_vdc_cpu_mem +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_vdc_cpu_mem`; +CREATE TABLE `cloud_work_order_vdc_cpu_mem` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `work_order_id` int(11) NOT NULL COMMENT '变更vdc工单ID', + `resource_type` tinyint(1) NOT NULL COMMENT '资源类型', + `architecture` tinyint(1) NOT NULL COMMENT '架构', + `old_size` int(11) NOT NULL DEFAULT 0 COMMENT '原始大小', + `apply_size` int(11) NOT NULL DEFAULT 0 COMMENT '申请大小', + `real_size` int(11) NOT NULL DEFAULT 0 COMMENT '审核后大小', + `unit` tinyint(1) NULL DEFAULT NULL COMMENT '单位', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_work_order_vdc_cpu_mem +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_zone +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_zone`; +CREATE TABLE `cloud_zone` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '可用区名称', + `type` tinyint(1) NOT NULL COMMENT '集群类型', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '可用区' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_zone +-- ---------------------------- + +-- ---------------------------- +-- Table structure for cloud_zone_cluster +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_zone_cluster`; +CREATE TABLE `cloud_zone_cluster` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `zone_id` int(11) NOT NULL COMMENT '可用区ID', + `cluster_id` int(11) NOT NULL COMMENT '集群ID', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '可用区集群管理关系' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of cloud_zone_cluster +-- ---------------------------- + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/mcp-cloud-manage/src/main/resources/keystore.p12 b/mcp-cloud-manage/src/main/resources/keystore.p12 new file mode 100644 index 0000000000000000000000000000000000000000..7bf21ffd6f40b4218f0923178df1c09bcaab005a Binary files /dev/null and b/mcp-cloud-manage/src/main/resources/keystore.p12 differ diff --git a/mcp-cloud-manage/src/main/resources/logback.xml b/mcp-cloud-manage/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..4f6c1330229868177a8870e83ccd59877577f1d6 --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/logback.xml @@ -0,0 +1,37 @@ + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg %n + + + + + + + + /var/log/kcp/kcp.log + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg %n + + + /var/log/kcp/kcp.log.%d{yyyy-MM-dd} + + 15 + + + + + + + + + + diff --git a/mcp-cloud-manage/src/main/resources/mapping/NetworkMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/NetworkMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..63a1cac52c0b0467031fd9416f31f0383fe1a5b8 --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/NetworkMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/mapping/PermissionMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/PermissionMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..0aca8ea022bb90370295469b05ab875e8867476a --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/PermissionMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/mapping/RoleMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/RoleMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..49b5b8d1cdb7ffbeea07f92c408ca26d5e280120 --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/RoleMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/mapping/UserMachineMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/UserMachineMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..7c7e8dbab8aa9ae5df6e2e23a69c9230df546bbe --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/UserMachineMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/mapping/UserMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/UserMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..e45613d73d51bc7ac2f2280e66bd79a624aabb60 --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/UserMapper.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/mapping/VdcMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/VdcMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..38d1d190ec2c88bc17edd2b2889ea74b7cae2d1b --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/VdcMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/mcp-cloud-manage/src/main/resources/mapping/WorkOrderMapper.xml b/mcp-cloud-manage/src/main/resources/mapping/WorkOrderMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..1b32d11b42c362e1bdcfbde1450e997febb9bfcf --- /dev/null +++ b/mcp-cloud-manage/src/main/resources/mapping/WorkOrderMapper.xml @@ -0,0 +1,45 @@ + + + + + + + + + \ No newline at end of file diff --git a/mcp-self-service/pom.xml b/mcp-self-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..dfb0b4179a47863e944bf4a6df451fc798d79d58 --- /dev/null +++ b/mcp-self-service/pom.xml @@ -0,0 +1,57 @@ + + + + mcp + com.hnkylin + 1.0-SNAPSHOT + + 4.0.0 + + mcp-self-service + + + + + + mysql + mysql-connector-java + + + + + com.alibaba + druid-spring-boot-starter + 1.1.10 + + + + + com.hnkylin + mcp-cloud-core + ${project.version} + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + + + portal + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + \ No newline at end of file diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/KylinSelfServiceApplication.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/KylinSelfServiceApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..bb03df297186a25091e701389d1388e9c53913e8 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/KylinSelfServiceApplication.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"com.hnkylin"}) +@MapperScan({"com.hnkylin.cloud.core.mapper"}) +public class KylinSelfServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(KylinSelfServiceApplication.class, args); + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/AuthExcludeApiProperties.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/AuthExcludeApiProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..e4ef7c83627d42f03ac8d83a5bde71f496622897 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/AuthExcludeApiProperties.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.selfservice.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.List; + + +@Component +@ConfigurationProperties("auth") +public class AuthExcludeApiProperties { + + private List authExcludeApis; + + public List getAuthExcludeApis() { + return authExcludeApis; + } + + public void setAuthExcludeApis(List authExcludeApis) { + this.authExcludeApis = authExcludeApis; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/KcpTaskPoolConfig.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/KcpTaskPoolConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..574a2d8a6579b3df8fb0806acc5ae58971129337 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/KcpTaskPoolConfig.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.selfservice.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.ThreadPoolExecutor; + +@EnableAsync +@Configuration +public class KcpTaskPoolConfig { + + @Bean("mcClusterInfoExecutor") + public ThreadPoolTaskExecutor mcClusterInfoExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(10); + executor.setMaxPoolSize(20); + executor.setQueueCapacity(500); + executor.setKeepAliveSeconds(60); + executor.setThreadNamePrefix("mcClusterInfoExecutor-"); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.setWaitForTasksToCompleteOnShutdown(true); + executor.setAwaitTerminationSeconds(60); + return executor; + } + + @Bean("mcServerVmListExecutor") + public ThreadPoolTaskExecutor mcServerVmListExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(10); + executor.setMaxPoolSize(20); + executor.setQueueCapacity(500); + executor.setKeepAliveSeconds(60); + executor.setThreadNamePrefix("mcServerVmListExecutor-"); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.setWaitForTasksToCompleteOnShutdown(true); + executor.setAwaitTerminationSeconds(60); + return executor; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/MCConfigProperties.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/MCConfigProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..8406ed2b756f34635efb927c3813b198aa3d7736 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/config/MCConfigProperties.java @@ -0,0 +1,105 @@ +package com.hnkylin.cloud.selfservice.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.List; + + +@Component +@ConfigurationProperties("mc-config") +@Data +public class MCConfigProperties { + + + private String mcLogoLocalFilePath; + + + private String mcPrefix; + + //mc请求统一地址 + private String commonPrefix; + + //获取模板列表 + private String templateListUrl; + + //获取模板列表 + private String serverVmList; + + //开机 + private String startServerVmUrl; + //关闭云服务器 + private String shutdownServerVmUrl; + //重启云服务器 + private String restartServerVmUrl; + + //强制关闭云服务器 + private String forcedShutdownServerVmUrl; + //强制重启云服务器 + private String forcedRestartServerVmUrl; + + //批量开机 + private String batchStartServerVmUrl; + //批量关机 + private String batchShutdownServerVmUrl; + + //批量重启 + private String batchRebootServerVmUrl; + + //批量把云服务器放入回收站中 + private String batchRemoveMachineToRecycleUrl; + + + //虚拟机详情概要接口 + private String serverVmInfoUrl; + + //云服务器监控接口 + private String serverVmMonitorInfoUrl; + + //云服务器操作日志接口 + private String serverVmOperateLogUrl; + + //云服务器-创建快照 + private String serverVmCreateSnapshotUrl; + + //云服务器-更新快照 + private String serverVmUpdateSnapshotUrl; + + //云服务器-删除快照 + private String serverVmDeleteSnapshotUrl; + + //云服务器-应用快照 + private String serverVmApplySnapshotUrl; + + //云服务器-快照列表 + private String serverVmSnapshotListUrl; + + //vncUrl + private String serverVmVncUrl; + + //获取云服务器状态接口 + private String serverVmStatusUrl; + + //更新云服务器描述 + private String updateMachineDescriptionUrl; + + + //重置控制台密码 + private String resetRemotePasswordUrl; + + private String getServervmDetailByServevmIdUrl; + + private String logoPath; + + private String isoListUrl; + + private String allOperatingSystemUrl; + + //修改云服务器名称 + private String updateMachineNameUrl; + + //检查云服务器名称是否重复 + private String checkVmServerNameUrl; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/KylinHttpResponseConstants.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/KylinHttpResponseConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..367525944fb3bb338c81240844e47325eecf9d29 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/KylinHttpResponseConstants.java @@ -0,0 +1,55 @@ +package com.hnkylin.cloud.selfservice.constant; + +public interface KylinHttpResponseConstants { + + + //------token + String NOT_EXIST_TOKEN = "token不存在"; + String TOKEN_EXPIRE = "token已过期,请重新登录"; + + + //--------用户 + String ALREADY_EXIST_USER = "该用户名已存在,不能重复注册"; + + String NOT_EXIST_USER = "用户不存在,请重新输入"; + + String PASSWORD_ERR = "密码错误,请重新输入"; + + String USER_NOT_ACTIVATE = "你的账号处于未激活状态,请联系管理员"; + + String NOT_LOING_PERMISSION = "你的账号不能登录自服务平台"; + + String OLD_PASSWORD_ERR = "原密码错误,请重新输入"; + + String UPDATE_REAL_NAME = "修改真实姓名"; + + + //虚拟机 + String TEMPLATE_LIST_ERR = "获取虚拟机列表失败"; + + + String TEMPLATE_DEFAULT = "模板默认自带"; + + String SERVERVM_LIST_ERR = "查询云服务器列表失败"; + + + String OPERATE_ERR = "操作失败"; + + String START_VM_ERR = "开机失败,请联系管理员"; + + String SHUTDOWN_VM_ERR = "关机失败,请联系管理员"; + + String FORCED_SHUTDOWN_VM_ERR = "强制关机失败,请联系管理员"; + + String RESTART_VM_ERR = "重启失败,请联系管理员"; + + String FORCED_RESTART_VM_ERR = "强制重启失败,请联系管理员"; + + String SERVERVM_OVERDUE_NOT_OPERATE = "云服务器已过期不能操作"; + + String BATCH_OPERATE_ERR = "批量操作失败"; + + String SERVER_VM_NAME_EXIST = "云服务器名称已存在,请修改云服务器名称"; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/KylinSelfConstants.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/KylinSelfConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..53dff32cb003c6a89df3b65fa1103b3b5a92ca7a --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/KylinSelfConstants.java @@ -0,0 +1,45 @@ +package com.hnkylin.cloud.selfservice.constant; + + +public interface KylinSelfConstants { + + + /** + * JWT加密密钥 + */ + public final static String KYLIN_TOKEN_SECRET = "kylin-ksvd-self-service"; + + /** + * 请求头中token标识 + */ + String KYLIN_ACCESS_TOKEN = "KYLIN_ACCESS_TOKEN"; + + /** + * 请求头中用户标识云服务器列表定时刷新,定时刷新的不会去更新缓存中redis的过期时间 + */ + String TIME_REFRESH = "TIME_REFRESH"; + + /** + * 网卡-网络类型 + */ + String NETWORK_TYPE = "网络类型"; + + /** + * 网卡-交换机 + */ + String NETWORK_SWITCH = "交换机"; + + + /** + * 网卡-端口组 + */ + String NETWORK_PORT = "端口组"; + + String LEFT_BRACKET = "("; + String RIGHT_BRACKET = ")"; + + String SPACE = " "; + + String GB = "GB"; + +} \ No newline at end of file diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/SelfServiceRedisConstant.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/SelfServiceRedisConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..8598b613b7af9bb5f372d4e8e3ae93608be304c2 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/constant/SelfServiceRedisConstant.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.constant; + +public interface SelfServiceRedisConstant { + + /** + * 自服务用户Token令牌缓存KEY前缀 + */ + String SELF_SERVICE_LOGIN_USER_CACHE = "portal:logintoken"; + + + String MC_LEADER_NODE = "portal:mcnode"; + + + String MC_LEADER_URL_KEY = "mcLeaderUrl_"; + + String MC_NODE_LIST_KEY = "nodeList_"; + + String UID = "uid:"; + + long SELF_SERVICE_LOGIN_USER_CACHE_EXPIRE = 2 * 60 * 60 * 1000; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/DeptCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/DeptCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..1b27f29d26aa2baf082a94ac0efa7492b6632f9f --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/DeptCtrl.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.selfservice.entity.resp.DeptRespDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceDeptService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/dept") +@Slf4j +public class DeptCtrl { + + + @Resource + private SelfServiceDeptService selfServiceDeptService; + + + @PostMapping("/queryDeptList") + public BaseResult> queryDeptList() { + return BaseResult.success(selfServiceDeptService.queryDeptList()); + + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/IndexCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/IndexCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..3bd7262a30e8b038855c7d997a0290d549a04078 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/IndexCtrl.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +/** + * Created by kylin-ksvd on 21-8-5. + */ +@RestController +@RequestMapping("/") +public class IndexCtrl { + + @RequestMapping("/index") + public ModelAndView index() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("index"); + return mv; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/LoginCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/LoginCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..e5d0507948a676d34165984c93815ec1ac84591f --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/LoginCtrl.java @@ -0,0 +1,46 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.LoginUserParam; +import com.hnkylin.cloud.selfservice.entity.resp.TokenRespDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceUserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/api/") +@Slf4j +public class LoginCtrl { + + + @Resource + private SelfServiceUserService selfServiceUserService; + + /** + * 用户登录 + * + * @param loginUserParam 用户参数 + * @return + */ + @ParamCheck + @PostMapping("/login") + public BaseResult login(@ModelCheck(notNull = true) @RequestBody LoginUserParam loginUserParam) { + + return BaseResult.success(selfServiceUserService.login(loginUserParam)); + } + + @PostMapping("/loginOut") + public BaseResult loginOut(@LoginUser LoginUserVo loginUserVo) { + selfServiceUserService.loginOut(loginUserVo); + return BaseResult.success(null); + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/OrganizationCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/OrganizationCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..66fa1066ba906dad1466387319675a03abde0a96 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/OrganizationCtrl.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.selfservice.entity.resp.OrganizationTreeDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceOrganizationService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/api/org") +@Slf4j +public class OrganizationCtrl { + + @Resource + private SelfServiceOrganizationService selfServiceOrganizationService; + + + @PostMapping("/queryOrgList") + public BaseResult> queryOrgList() { + return BaseResult.success(selfServiceOrganizationService.queryOrganizationTree()); + + } + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/ServerVmCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/ServerVmCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..c93f0e7e936dc5be1392cb5a7daa563fa253fe39 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/ServerVmCtrl.java @@ -0,0 +1,383 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.common.servervm.ServerVmBaseParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchOperateParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmMonitorInfoRespDto; +import com.hnkylin.cloud.selfservice.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.core.enums.McStartVmErrorCode; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.mc.req.*; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McOperateSystemResp; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McServerVmInfoResp; +import com.hnkylin.cloud.core.common.servervm.McServerVmLogResp; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McServerVmSnapshotResp; +import com.hnkylin.cloud.selfservice.entity.req.*; +import com.hnkylin.cloud.selfservice.entity.resp.*; +import com.hnkylin.cloud.selfservice.service.SelfServerVmService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +@RestController +@RequestMapping("/api/serverVm") +@Slf4j +public class ServerVmCtrl { + + + @Resource + private SelfServerVmService selfServerVmService; + + @PostMapping("/listServerVmTemplate") + public BaseResult> listServerVmTemplate(@RequestBody SearchTemplateParam searchTemplateParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.listServerVmTemplate(searchTemplateParam, loginUserVo)); + + } + + @PostMapping("/isoList") + public BaseResult> isoList(@LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.isoList(loginUserVo)); + } + + @PostMapping("/applyServerVm") + @ParamCheck + public BaseResult applyServerVm(@ModelCheck(notNull = true) @RequestBody + ApplyServerVmParam applyServerVmParam, @LoginUser LoginUserVo + loginUserVo) { + selfServerVmService.applyServerVm(applyServerVmParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/modifyServerVm") + @ParamCheck + public BaseResult modifyServerVm(@ModelCheck(notNull = true) @RequestBody + ModifyServerVmParam modifyServerVmParam, @LoginUser LoginUserVo + loginUserVo) { + selfServerVmService.modifyServerVm(modifyServerVmParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/applyDeferredMachine") + @ParamCheck + public BaseResult applyDeferredMachine(@ModelCheck(notNull = true) @RequestBody + ApplyDeferredParam applyDeferredParam, @LoginUser + LoginUserVo loginUserVo) { + selfServerVmService.applyDeferredMachine(applyDeferredParam, loginUserVo); + return BaseResult.success(null); + + } + + + @PostMapping("/getServerVmDetail") + public BaseResult getServerVmDetail(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmPageParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.getServerVmDetail(serverVmPageParam, loginUserVo)); + + } + + @PostMapping("/listServerVm") + @ParamCheck + public BaseResult> listServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmPageParam serverVmPageParam, + @LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(selfServerVmService.listServerVm(serverVmPageParam, loginUserVo)); + + } + + + @PostMapping("/deleteServerVm") + @ParamCheck + public BaseResult deleteServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + + return selfServerVmService.deleteServerVm(serverVmBaseParam, loginUserVo); + } + + @PostMapping("/startServerVm") + @ParamCheck + public BaseResult startServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + + McStartVmErrorCode errorCode = selfServerVmService.startServerVm(serverVmBaseParam, loginUserVo); + if (Objects.equals(errorCode, McStartVmErrorCode.SUCCESS)) { + return BaseResult.success(null); + } + return BaseResult.error(errorCode.getErrorMsg()); + + } + + + @PostMapping("/shutdownServerVm") + @ParamCheck + public BaseResult shutdownServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + boolean result = selfServerVmService.shutdownServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.SHUTDOWN_VM_ERR); + + } + + @PostMapping("/forcedShutdownServerVm") + @ParamCheck + public BaseResult forcedShutdownServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + boolean result = selfServerVmService.forcedShutdownServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.FORCED_SHUTDOWN_VM_ERR); + + } + + + @PostMapping("/restartServerVm") + @ParamCheck + public BaseResult restartServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser LoginUserVo + loginUserVo) { + boolean result = selfServerVmService.restartServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.RESTART_VM_ERR); + + } + + @PostMapping("/forcedRestartServerVm") + @ParamCheck + public BaseResult forcedRestartServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + boolean result = selfServerVmService.forcedRestartServerVm(serverVmBaseParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.FORCED_RESTART_VM_ERR); + + } + + @PostMapping("/batchStartServerVm") + @ParamCheck + public BaseResult batchStartServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + + return selfServerVmService.batchStartServerVm(serverVmBatchOperateParam, loginUserVo); + + + } + + @PostMapping("/batchShutdownServerVm") + @ParamCheck + public BaseResult batchShutdownServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + return selfServerVmService.batchShutdownServerVm(serverVmBatchOperateParam, loginUserVo); + + } + + @PostMapping("/batchRebootServerVm") + @ParamCheck + public BaseResult batchRebootServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + return selfServerVmService.batchRebootServerVm(serverVmBatchOperateParam, loginUserVo); + + + } + + @PostMapping("/batchDeleteServerVm") + @ParamCheck + public BaseResult batchDeleteServerVm(@ModelCheck(notNull = true) @RequestBody + ServerVmBatchOperateParam serverVmBatchOperateParam, + @LoginUser LoginUserVo loginUserVo) { + + return selfServerVmService.batchDeleteServerVm(serverVmBatchOperateParam, loginUserVo); + } + + + @PostMapping("/serverVmInfo") + @ParamCheck + public BaseResult serverVmInfo(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.serverVmInfo(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmMonitor") + @ParamCheck + public BaseResult serverVmMonitor(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.serverVmMonitor(serverVmBaseParam, loginUserVo)); + + } + + @PostMapping("/serverVmOperateLog") + @ParamCheck + public BaseResult> serverVmOperateLog(@ModelCheck(notNull = true) @RequestBody + ServerVmOperateLogPageParam + serverVmOperateLogPageParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.serverVmOperateLog(serverVmOperateLogPageParam, loginUserVo)); + + } + + @PostMapping("/createSnapshot") + @ParamCheck + public BaseResult createSnapshot(@ModelCheck(notNull = true) @RequestBody + McServerVmCreateSnapshotReq + mcServerVmCreateSnapshotReq, + @LoginUser LoginUserVo loginUserVo) { + + return selfServerVmService.createSnapshot(mcServerVmCreateSnapshotReq, loginUserVo); + + } + + @PostMapping("/updateSnapshot") + @ParamCheck + public BaseResult updateSnapshot(@ModelCheck(notNull = true) @RequestBody + McServerVmUpdateSnapshotReq + mcServerVmUpdateSnapshotReq, + @LoginUser LoginUserVo loginUserVo) { + + + return selfServerVmService.updateSnapshot(mcServerVmUpdateSnapshotReq, loginUserVo); + } + + @PostMapping("/deleteSnapshot") + @ParamCheck + public BaseResult deleteSnapshot(@ModelCheck(notNull = true) @RequestBody + McServerVmDeleteSnapshotReq + mcServerVmDeleteSnapshotReq, + @LoginUser LoginUserVo loginUserVo) { + + boolean result = selfServerVmService.deleteSnapshot(mcServerVmDeleteSnapshotReq, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + + } + + @PostMapping("/applySnapshot") + @ParamCheck + public BaseResult applySnapshot(@ModelCheck(notNull = true) @RequestBody + McServerVmApplySnapshotReq + mcServerVmApplySnapshotReq, + @LoginUser LoginUserVo loginUserVo) { + + return selfServerVmService.applySnapshot(mcServerVmApplySnapshotReq, loginUserVo); + + } + + @PostMapping("/listSnapshot") + @ParamCheck + public BaseResult> listSnapshot(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.listSnapshot(serverVmBaseParam, loginUserVo)); + } + + @PostMapping("/getVncUrl") + @ParamCheck + public BaseResult getVncUrl(@ModelCheck(notNull = true) @RequestBody + ServerVmBaseParam serverVmBaseParam, + @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.getVncUrl(serverVmBaseParam, loginUserVo)); + } + + @PostMapping("/updateMachineDescription") + @ParamCheck + public BaseResult updateMachineDescription(@ModelCheck(notNull = true) @RequestBody + UpdateServerVmDescriptionParam updateServerVmDescriptionParam, + @LoginUser LoginUserVo loginUserVo) { + + boolean result = selfServerVmService.updateMachineDescription(updateServerVmDescriptionParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + + } + + @PostMapping("/updateMachineName") + @ParamCheck + public BaseResult updateMachineName(@ModelCheck(notNull = true) @RequestBody + UpdateServerVmNameParam updateServerVmNameParam, + @LoginUser LoginUserVo loginUserVo) { + + boolean result = selfServerVmService.updateMachineName(updateServerVmNameParam, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + + } + + @PostMapping("/resetRemotePassword") + @ParamCheck + public BaseResult resetRemotePassword(@ModelCheck(notNull = true) @RequestBody + McServerVmResetRemotePasswordReq remotePasswordReq, + @LoginUser LoginUserVo loginUserVo) { + + boolean result = selfServerVmService.resetRemotePassword(remotePasswordReq, loginUserVo); + if (result) { + return BaseResult.success(null); + + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + } + + @GetMapping("/downLoadServerVmLog") + public BaseResult> downLoadServerVmLog(@RequestParam(name = "mcServerVmLogoPath") String mcServerVmLogoPath, + @RequestParam(name = "mcServerVmLogoName") String mcServerVmLogoName) { + + return BaseResult.success(selfServerVmService.downLoadServerVmLog(mcServerVmLogoPath, mcServerVmLogoName)); + + } + + @PostMapping("/getAllOperatingSystem") + @ParamCheck + public BaseResult> getAllOperatingSystem(@ModelCheck(notNull = true) @RequestBody QueryOperateSystem queryOperateSystem, @LoginUser LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.getAllOperatingSystem(queryOperateSystem, loginUserVo)); + } + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/UserCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/UserCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..d16f70581eea01507a28acd07a0cd8c84a9a1146 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/UserCtrl.java @@ -0,0 +1,67 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.UpdateRealNameParam; +import com.hnkylin.cloud.selfservice.entity.req.UpdatePwdParam; +import com.hnkylin.cloud.selfservice.entity.req.UserRegisterParam; +import com.hnkylin.cloud.selfservice.entity.resp.UserInfoRespDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceUserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/api/user") +@Slf4j +public class UserCtrl { + + + @Resource + private SelfServiceUserService selfServiceUserService; + + /** + * 用户注册 + * + * @param userRegisterParam 注册参数 + * @return + */ + @ParamCheck + @PostMapping("/register") + public BaseResult register(@ModelCheck(notNull = true) @RequestBody UserRegisterParam userRegisterParam) { + selfServiceUserService.register(userRegisterParam); + return BaseResult.success(null); + + } + + @ParamCheck + @PostMapping("/updatePwd") + public BaseResult updatePwd(@ModelCheck(notNull = true) @RequestBody UpdatePwdParam updatePwdParam, + @LoginUser LoginUserVo loginUserVo) { + selfServiceUserService.updatePwd(updatePwdParam, loginUserVo); + return BaseResult.success(null); + + } + + @PostMapping("/userInfo") + public BaseResult userInfo(@LoginUser LoginUserVo loginUserVo) { + return BaseResult.success(selfServiceUserService.userInfo(loginUserVo)); + + } + + @ParamCheck + @PostMapping("/updateRealName") + public BaseResult updateRealName(@ModelCheck(notNull = true) @RequestBody UpdateRealNameParam + updateRealNameParam, @LoginUser LoginUserVo loginUserVo) { + selfServiceUserService.updateRealName(updateRealNameParam, loginUserVo); + return BaseResult.success(null); + + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/WorkOrderCtrl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/WorkOrderCtrl.java new file mode 100644 index 0000000000000000000000000000000000000000..c3abef8e8bd41874d7bde41dd5e5880bee89df5a --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/ctrl/WorkOrderCtrl.java @@ -0,0 +1,123 @@ +package com.hnkylin.cloud.selfservice.ctrl; + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.annotation.ModelCheck; +import com.hnkylin.cloud.core.annotation.ParamCheck; +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.WorkOrderDetailParam; +import com.hnkylin.cloud.selfservice.entity.req.WorkOrderPageParam; +import com.hnkylin.cloud.selfservice.entity.resp.*; +import com.hnkylin.cloud.selfservice.service.SelfServerVmService; +import com.hnkylin.cloud.selfservice.service.SelfServiceUserService; +import com.hnkylin.cloud.selfservice.service.SelfWorkOrderService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/api/workOrder") +@Slf4j +public class WorkOrderCtrl { + + + @Resource + private SelfWorkOrderService selfWorkOrderService; + + @Resource + private SelfServerVmService selfServerVmService; + + @Resource + private SelfServiceUserService selfServiceUserService; + + @PostMapping("/pageWorkOrder") + @ParamCheck + public BaseResult> pageWorkOrder(@ModelCheck(notNull = true) @RequestBody + WorkOrderPageParam + workOrderPageParam, @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(selfWorkOrderService.pageWorkOrder(workOrderPageParam, loginUserVo)); + + } + + + /** + * 注册账号详情 + */ + @PostMapping("/registerUserDetail") + @ParamCheck + public BaseResult registerUserDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(selfServiceUserService.getWorkOrderUserDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + /** + * 修改账号详情 + */ + @PostMapping("/updateUserDetail") + @ParamCheck + public BaseResult updateUserDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(selfServiceUserService.getWorkOrderUserDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + + /** + * 申请虚拟机详情 + */ + @PostMapping("/applyServerVmDetail") + @ParamCheck + public BaseResult getApplyServerVmDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam, @LoginUser + LoginUserVo loginUserVo) { + + return BaseResult.success(selfServerVmService.getApplyServerVmDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId(), loginUserVo)); + + } + + /** + * 变更云服务器详情 + */ + @PostMapping("/modifyServerVmDetail") + @ParamCheck + public BaseResult modifyServerVmDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(selfServerVmService.modifyServerVmDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + /** + * 申请延期云服务器详情 + */ + @PostMapping("/applyDeferredDetail") + @ParamCheck + public BaseResult applyDeferredDetail(@ModelCheck(notNull = true) @RequestBody + WorkOrderDetailParam + workOrderDetailParam) { + + return BaseResult.success(selfServerVmService.applyDeferredDetailByWorkOrderId(workOrderDetailParam + .getWorkOrderId())); + + } + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/LoginUserVo.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/LoginUserVo.java new file mode 100644 index 0000000000000000000000000000000000000000..3c1d8c70805d6fdd028e7dbb235cbb67619cd6a8 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/LoginUserVo.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.selfservice.entity; + +import lombok.Data; + +@Data +public class LoginUserVo { + + private String userName; + + private Integer userId; + + private String token; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/CheckServerNameParamReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/CheckServerNameParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..7e00545f6ce76778d08442df45bc87f785395cbc --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/CheckServerNameParamReq.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import lombok.Data; + +@Data +public class CheckServerNameParamReq { + + private String servervmName; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmApplySnapshotReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmApplySnapshotReq.java new file mode 100644 index 0000000000000000000000000000000000000000..6488c9bfc80fb03e975a7dc058058af2e87e7eed --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmApplySnapshotReq.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +/** + * 应用快照 + * Created by kylin-ksvd on 21-7-17. + */ +@Data +public class McServerVmApplySnapshotReq { + + + @FieldCheck(notNull = true, notNullMessage = "用户服务器uuid不能为空") + private String uuid; + + @FieldCheck(notNull = true, notNullMessage = "快照ID不能为空") + private Integer snapId; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmCreateSnapshotReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmCreateSnapshotReq.java new file mode 100644 index 0000000000000000000000000000000000000000..45ff1440769d2129d4ef04916efd7d2ab83e132d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmCreateSnapshotReq.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +/** + * 创建快照 + * Created by kylin-ksvd on 21-7-17. + */ +@Data +public class McServerVmCreateSnapshotReq { + + + @FieldCheck(notNull = true, notNullMessage = "用户服务器uuid不能为空") + private String uuid; + + + private String description; + + @FieldCheck(notNull = true, notNullMessage = "快照名不能为空") + private String snapName; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmDeleteSnapshotReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmDeleteSnapshotReq.java new file mode 100644 index 0000000000000000000000000000000000000000..d8efb8e38b8403a7446eaf315f3b65db528af304 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmDeleteSnapshotReq.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import lombok.Data; + +/** + * 删除快照 + * Created by kylin-ksvd on 21-7-17. + */ +@Data +public class McServerVmDeleteSnapshotReq { + + + private String uuid; + + private String snapId; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmMonitorReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmMonitorReq.java new file mode 100644 index 0000000000000000000000000000000000000000..c6cf0a85273cd3ee497b5eca8e9456808c041af6 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmMonitorReq.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-7-15. + */ +@Data +public class McServerVmMonitorReq { + + private String uuid; + + private Integer count = 12; + + private Integer timeUnit = 1; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmResetRemotePasswordReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmResetRemotePasswordReq.java new file mode 100644 index 0000000000000000000000000000000000000000..28932c423bcd51fb222d9421ac60c6c0cde041f4 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmResetRemotePasswordReq.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +/** + * 删除快照 + * Created by kylin-ksvd on 21-7-17. + */ +@Data +public class McServerVmResetRemotePasswordReq { + + + @FieldCheck(notNull = true, notNullMessage = "云服务器ID不能为空") + private String uuid; + + @FieldCheck(notNull = true, notNullMessage = "控制台密码不能为空") + private String remotePassword; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmUpdateSnapshotReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmUpdateSnapshotReq.java new file mode 100644 index 0000000000000000000000000000000000000000..54e6c171b97cf0ef92861ef9a5919631a5f8fda9 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/McServerVmUpdateSnapshotReq.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +/** + * 编辑快照 + * Created by kylin-ksvd on 21-7-17. + */ +@Data +public class McServerVmUpdateSnapshotReq { + + @FieldCheck(notNull = true, notNullMessage = "uuid不能为空") + private String uuid; + + @FieldCheck(notNull = true, notNullMessage = "快照ID不能为空") + private Integer snapId; + + private String description; + + @FieldCheck(notNull = true, notNullMessage = "快照名称能为空") + private String snapName; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/PageTemplateReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/PageTemplateReq.java new file mode 100644 index 0000000000000000000000000000000000000000..49caa8ccb16b42e8e44e19feed514ab6a4adc9c2 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/PageTemplateReq.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-7-9. + */ +@Data +public class PageTemplateReq { + + + private Integer page; + + private Integer rows; + + private String searchKey; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/QueryMcServerDetailParamReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/QueryMcServerDetailParamReq.java new file mode 100644 index 0000000000000000000000000000000000000000..15711a0ae1fc04f35ba774478dde6dc8b335a459 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/QueryMcServerDetailParamReq.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import lombok.Data; + +@Data +public class QueryMcServerDetailParamReq { + + private Integer servervmId; + + private String uuid; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/QueryOperateSystem.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/QueryOperateSystem.java new file mode 100644 index 0000000000000000000000000000000000000000..b9300dbd81b78aba4d5b6f33f01bed88b070d88d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/QueryOperateSystem.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class QueryOperateSystem { + + @FieldCheck(notNull = true, notNullMessage = "架构不能为空") + private String plateformtype; + + private Integer clusterId; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/ServerVmOperateLogReq.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/ServerVmOperateLogReq.java new file mode 100644 index 0000000000000000000000000000000000000000..40f711a9ce6f12fb953e36126435be792fe14800 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/ServerVmOperateLogReq.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + +import lombok.Data; + + +/** + * Created by kylin-ksvd on 21-7-9. + */ +@Data +public class ServerVmOperateLogReq { + + private String sidx = "startTime"; + + + private String sord = "desc"; + private Integer page; + + private Integer rows; + + private String uuid; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/UpdateServerVmNameParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/UpdateServerVmNameParam.java new file mode 100644 index 0000000000000000000000000000000000000000..323e213e92f9c786a83bc2497b21feb9d67c3cb4 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/req/UpdateServerVmNameParam.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.selfservice.entity.mc.req; + + +import lombok.Data; + +@Data +public class UpdateServerVmNameParam { + + private String aliasName; + + private String uuid; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/CheckServerNameResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/CheckServerNameResp.java new file mode 100644 index 0000000000000000000000000000000000000000..eb9dcf5b4e39f6a2400702b25e68beb53a422eea --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/CheckServerNameResp.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +@Data +public class CheckServerNameResp { + + + private Boolean exist; +} \ No newline at end of file diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McDiskResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McDiskResp.java new file mode 100644 index 0000000000000000000000000000000000000000..49cba8cf2563cd5a760bc8b0effee47513287091 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McDiskResp.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * 模板中磁盘信息 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McDiskResp { + private Integer id; + private Integer size; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McNetworkResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McNetworkResp.java new file mode 100644 index 0000000000000000000000000000000000000000..31f9d89e59a0a9653ef3c591c081f38909f7a481 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McNetworkResp.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * 模板中网络信息 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McNetworkResp { + private String interfaceType; + private String portGroup; + private String virtualSwitch; + private Integer id; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McOperateSystemResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McOperateSystemResp.java new file mode 100644 index 0000000000000000000000000000000000000000..460f3657b7e4faef46ef924ae16c77d48e973e77 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McOperateSystemResp.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * 模板中磁盘信息 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McOperateSystemResp { + + + private String osType; + + private String osTypeAlias; + + private String systemName; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmCpuInfo.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmCpuInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..eefd2356ecc4d6c3e6f0de626973d150bd25f02b --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmCpuInfo.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * Created by kylin-ksvd on 21-8-18. + * 云服务器概要信息-cpu + */ +@Data +public class McServerVmCpuInfo { + + //cpu核数 + private Integer cpus; + + //cpu使用率 + private BigDecimal usedPercent; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDetailResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..3cc2be37c377e80cdc01b2afb80780010c6eff64 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDetailResp.java @@ -0,0 +1,47 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import lombok.Data; + +/** + * 云服务器基础信息 + * Created by kylin-ksvd on 21-7-15. + */ +@Data +public class McServerVmDetailResp { + + //云服务器名称 + private String alisname; + + //云服务器描述 + private String description; + + //云服务器uuid + private String uuid; + + //云服务器创建时间 + private String createDate; + + //云服务器ip + private String ipAddress; + + //云服务器操作系统 + private String osName; + + //云服务器状态 + private McServerVmStatus status; + + private String architecture; + + private String systemType; + + private String logo; + + private String logoName; + + private String remoteUrl; + + private String remotePassword; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDeviceInfo.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDeviceInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..1fa2f698534a7804e866874b10bede972c608934 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDeviceInfo.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +/** + * 云服务器概要信息,cpu内存,网卡 + * Created by kylin-ksvd on 21-7-15. + */ +@Data +public class McServerVmDeviceInfo { + + + private List disks; + private McServerVmCpuInfo cpu; + private McServerVmMemoryInfo memory; + private List interfaces; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDiskInfo.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDiskInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..51ac3b4d0c8e36748066ea70cbc0f46510f4335e --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmDiskInfo.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * Created by kylin-ksvd on 21-8-18. + * 云服务器概要信息-磁盘 + */ +@Data +public class McServerVmDiskInfo { + + //磁盘id + private Integer id; + //磁盘总大小 + private Integer total; + //已使用 + private Integer used; + //使用率 + private BigDecimal usedPercent; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmInfoResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmInfoResp.java new file mode 100644 index 0000000000000000000000000000000000000000..061d218194d76ce5f47f165138febcf8eb1542c2 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmInfoResp.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * 云服务器详情 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McServerVmInfoResp { + + + //基础信息 + private McServerVmDetailResp machineInfo; + + //概要信息 + private McServerVmDeviceInfo deviceInfo; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmMemoryInfo.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmMemoryInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..501232aee7f0aac61faf1a839a4bdf81c4ac5d73 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmMemoryInfo.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * Created by kylin-ksvd on 21-8-18. + * 云服务器概要信息-内存 + */ +@Data +public class McServerVmMemoryInfo { + + //内存大小 + private Integer memoryTotal; + + //内存使用率 + private BigDecimal memoryPercent; + + private Integer memoryUsed; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmNetworkInfo.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmNetworkInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..e1fd9c3cea10a013527fdb4842efcb5cef1234ec --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmNetworkInfo.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-8-18. + * 云服务器概要信息-网络 + */ +@Data +public class McServerVmNetworkInfo { + + //虚拟交换机名称 + private String virtualSwitch; + //端口组 + private String portGroup; + //mac地址 + private String macAddress; + + private String interfaceType; + + //地址池 + private String macAddressPool; + + //安全组 + private String securityGroup; + + private Integer id; + + private Boolean ipBindMac; + + private Boolean manualSetIp; + + private Boolean automaticAcqIp; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmSnapshotResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmSnapshotResp.java new file mode 100644 index 0000000000000000000000000000000000000000..f97d949691b432974d160f2074c5fd8100825c05 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmSnapshotResp.java @@ -0,0 +1,28 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-7-17. + */ +@Data +public class McServerVmSnapshotResp { + + private Integer id; + + private String alias; + + private String description; + + private String dateCreated; + + private String createUserName; + + private Integer status; + + //private Integer lose; + + private Integer snapType; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmStatusResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmStatusResp.java new file mode 100644 index 0000000000000000000000000000000000000000..d42acb84e8d0b8c23dee391252b9dcd273efa620 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McServerVmStatusResp.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import lombok.Data; + +/** + * 模板中磁盘信息 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McServerVmStatusResp { + + private McServerVmStatus status; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McStartServerResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McStartServerResp.java new file mode 100644 index 0000000000000000000000000000000000000000..f8af05586d66bcd8091b1cdd7175589581fe5259 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McStartServerResp.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +/** + * 云服务器详情 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McStartServerResp { + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateDetailResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..727830703e705556fbe77e182544a78f1c831f8f --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateDetailResp.java @@ -0,0 +1,33 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class McTemplateDetailResp { + + private String alisname; + + private String osMachine; + + private String architecture; + + private String systemType; + + private Integer cpu; + + private Integer mem; + + private String memUnit; + + private String selectCluster; + + private String selectClusterUuid; + + private Integer storageLocationId; + + private List disks; + + private List interfaceList; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateDiskDetailResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateDiskDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..d8848c136f3afb3993dfbd158c3c165238fa7456 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateDiskDetailResp.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.LastUpdateType; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class McTemplateDiskDetailResp { + + private Integer diskSize; + + private Long id; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateListResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateListResp.java new file mode 100644 index 0000000000000000000000000000000000000000..11c8ef3e0cda4e5d22923facbd06eb8d38c44780 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateListResp.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.MemUnit; +import lombok.Data; + +import java.util.List; + +/** + * 模板列表 + * Created by kylin-ksvd on 21-7-14. + */ +@Data +public class McTemplateListResp { + + private Integer id; + + private String name; + + private String operatingSystem; + + private String architecture; + + private String systemType; + + //描述 + private String description; + + //cpu + private Integer cpu; + + //内存 + private Integer mem; + + private MemUnit memUnit; + + private List interfacesList; + + private List disks; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateNetworkDetailResp.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateNetworkDetailResp.java new file mode 100644 index 0000000000000000000000000000000000000000..8442b4ce4a79410078b03e3f8549ff21f3e5274e --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/mc/resp/McTemplateNetworkDetailResp.java @@ -0,0 +1,31 @@ +package com.hnkylin.cloud.selfservice.entity.mc.resp; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import com.hnkylin.cloud.core.enums.LastUpdateType; +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class McTemplateNetworkDetailResp { + + private String virtualSwitch; + + private String portGroup; + + private String portGroupUuid; + + private String macAddress; + + private String interfaceType; + + private String modelType; + + private Long id; + + private Integer applyId; + + //变更类型 + private ModifyType modifyType; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ApplyDeferredParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ApplyDeferredParam.java new file mode 100644 index 0000000000000000000000000000000000000000..012fc3a00b903cdf00bdd504fb2b0d69ca65f813 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ApplyDeferredParam.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class ApplyDeferredParam { + + @FieldCheck(notNull = true, notNullMessage = "用户服务器uuid不能为空") + private String userMachineUuid; + + @FieldCheck(notNull = true, notNullMessage = "申请原因不能为空") + private String applyReason; + + private String machineName; + + @FieldCheck(notNull = true, notNullMessage = "延期时间不能为空") + private String deadlineTime; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ApplyServerVmParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ApplyServerVmParam.java new file mode 100644 index 0000000000000000000000000000000000000000..4501d6d88577ef87b5e79a858533c352348692f9 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ApplyServerVmParam.java @@ -0,0 +1,73 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.ApplyServerVmType; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ApplyServerVmParam { + + + private ApplyServerVmType applyServerVmType = ApplyServerVmType.TEMPLATE; + + + //模板ID + @FieldCheck(notNull = true, notNullMessage = "模板不能为空") + private Integer templateId; + + //操作系统 + private String osMachine; + + //架构 + private String architecture; + + //系统类型 + private String systemType; + + + //虚拟机名称 + @FieldCheck(notNull = true, notNullMessage = "虚拟机名称不能为空") + private String servervmName; + + //申请数量 + @FieldCheck(notNull = true, notNullMessage = "申请数量不能为空") + private Integer applyNum; + + //使用月数 + private Integer useMonth; + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + //cpu + @FieldCheck(notNull = true, notNullMessage = "cpu不能为空") + private Integer cpu; + //内存 + @FieldCheck(notNull = true, notNullMessage = "内存不能为空") + private Integer mem; + + //申请原因 + @FieldCheck(notNull = true, notNullMessage = "申请原因不能为空") + private String applyReason; + + + private String description; + + + //已选择的iso文件 + private List isoList; + + //硬盘信息 + private List diskList; + + + //网卡信息 + private List networkList; + + private Integer clusterId; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/DownLoadMcServerVmLog.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/DownLoadMcServerVmLog.java new file mode 100644 index 0000000000000000000000000000000000000000..bd8bde8e6d177cd94f8802560440b3e2498c0056 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/DownLoadMcServerVmLog.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.req; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class DownLoadMcServerVmLog { + + @FieldCheck(notNull = true, notNullMessage = "图片不能为空") + private String mcServerVmLogoPath; + @FieldCheck(notNull = true, notNullMessage = "图片不能为空") + private String mcServerVmLogoName; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/LoginUserParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/LoginUserParam.java new file mode 100644 index 0000000000000000000000000000000000000000..4a3c0f0648f56dcc226b77b11aa21ed1fb227859 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/LoginUserParam.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.req; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class LoginUserParam { + + @FieldCheck(notNull = true, notNullMessage = "用户名不能为空") + private String userName; + + @FieldCheck(notNull = true, notNullMessage = "密码不能为空") + private String password; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ModifyServerVmParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ModifyServerVmParam.java new file mode 100644 index 0000000000000000000000000000000000000000..885e3a5d54fdde67c9bc172301b932e5bae1fb77 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ModifyServerVmParam.java @@ -0,0 +1,79 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ModifyServerVmParam { + + + //操作系统 + private String osMachine; + + //架构 + private String architecture; + + private String systemType; + + + //虚拟机名称 + @FieldCheck(notNull = true, notNullMessage = "虚拟机名称不能为空") + private String servervmName; + + + @FieldCheck(notNull = true, notNullMessage = "uuid") + private String machineUuid; + + + //是否新添加过期时间 + private boolean addDeadTimeChecked; + + //新添加过期时间 + private Integer addNewDeadTime; + + //新添加过期时间单位 + private String addNewDeadTimeUnit; + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + //cpu + @FieldCheck(notNull = true, notNullMessage = "cpu不能为空") + private Integer cpu; + //内存 + @FieldCheck(notNull = true, notNullMessage = "内存不能为空") + private Integer mem; + + + //变更前cpu + private Integer originalCpu; + + //变更前内存 + private Integer originalMem; + + //内存单位 + private MemUnit memUnit; + + + //申请原因 + @FieldCheck(notNull = true, notNullMessage = "申请原因不能为空") + private String applyReason; + + //硬盘信息 + private List diskList; + + //原来的硬盘信息 + private List oldDiskList; + + + //网卡信息 + private List networkList; + + private List oldNetworkList; + + private Boolean onlyModifyName; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/SearchTemplateParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/SearchTemplateParam.java new file mode 100644 index 0000000000000000000000000000000000000000..eacda5f46d197b4413431c2fcdf1f8d39a73619f --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/SearchTemplateParam.java @@ -0,0 +1,12 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class SearchTemplateParam extends BasePageParam { + + private String searchKey; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmDiskParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmDiskParam.java new file mode 100644 index 0000000000000000000000000000000000000000..f3db860aa589021b676b2f5039733fdfe5107904 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmDiskParam.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import lombok.Data; + +@Data +public class ServerVmDiskParam { + + + private Integer diskSize; + + private String purpose; + + //类型 + private ApplyMcServerVmType type; + + private Long diskId; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmNetworkParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmNetworkParam.java new file mode 100644 index 0000000000000000000000000000000000000000..3a55847af5154ed983f1eed6820c92b4a3d00595 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmNetworkParam.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.enums.ApplyMcServerVmType; +import lombok.Data; + +@Data +public class ServerVmNetworkParam { + + + private String purpose; + + //类型 + private ApplyMcServerVmType type; + + private Long interfaceId; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmOperateLogPageParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmOperateLogPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..1b20c0f5b5c2dd3610c3defd0cd0855f40a7305c --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmOperateLogPageParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class ServerVmOperateLogPageParam extends BasePageParam { + + + @FieldCheck(notNull = true, notNullMessage = "云服务uuid不能为空") + private String serverVmUuid; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmPageParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..a73af1f46aa8cc5920f1f3031736ac67ef354e08 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/ServerVmPageParam.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.common.BasePageParam; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import lombok.Data; + +@Data +public class ServerVmPageParam extends BasePageParam { + + private String searchKey; + + private McServerVmStatus vmStatus; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdatePwdParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdatePwdParam.java new file mode 100644 index 0000000000000000000000000000000000000000..6a87ad692358c852ed4f9c6ab27731cefa9f16a2 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdatePwdParam.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.selfservice.entity.req; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class UpdatePwdParam { + + + @FieldCheck(notNull = true, notNullMessage = "用户密码不能为空") + private String password; + + + @FieldCheck(notNull = true, notNullMessage = "原密码不能为空") + private String oldPassword; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdateRealNameParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdateRealNameParam.java new file mode 100644 index 0000000000000000000000000000000000000000..82a0c7cd591d4437fc1eae9c5f4ea77d14f22beb --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdateRealNameParam.java @@ -0,0 +1,15 @@ +package com.hnkylin.cloud.selfservice.entity.req; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class UpdateRealNameParam { + + + @FieldCheck(notNull = true, notNullMessage = "用户真实姓名不能为空") + private String realName; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdateServerVmDescriptionParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdateServerVmDescriptionParam.java new file mode 100644 index 0000000000000000000000000000000000000000..2b230dcdabd9558ebc0fb6eed891610a6bd983b8 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UpdateServerVmDescriptionParam.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.selfservice.entity.req; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class UpdateServerVmDescriptionParam { + + + @FieldCheck(notNull = true, notNullMessage = "云服务器UUID不能为空") + private String uuid; + + @FieldCheck(notNull = true, notNullMessage = "描述不能为空") + private String description; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UserRegisterParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UserRegisterParam.java new file mode 100644 index 0000000000000000000000000000000000000000..eaa68bd815925e85f250ee7dba381de5ce4b59f5 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/UserRegisterParam.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.selfservice.entity.req; + + +import com.hnkylin.cloud.core.annotation.FieldCheck; +import lombok.Data; + +@Data +public class UserRegisterParam { + + @FieldCheck(notNull = true, notNullMessage = "用户名不能为空") + private String userName; + + private String realName; + + @FieldCheck(notNull = true, notNullMessage = "用户密码不能为空") + private String password; + + private String mobile; + + @FieldCheck(notNull = true, notNullMessage = "申请原因不能为空") + private String applyReason; + + @FieldCheck(notNull = true, notNullMessage = "组织不能为空", minNum = 0, minNumMessage = "组织ID不能小于0") + private Integer organizationId = 0; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/WorkOrderDetailParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/WorkOrderDetailParam.java new file mode 100644 index 0000000000000000000000000000000000000000..dfc6538dfaaab0935559b0ba8ffa868ce10354fd --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/WorkOrderDetailParam.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import lombok.Data; + +@Data +public class WorkOrderDetailParam { + + private Integer workOrderId; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/WorkOrderPageParam.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/WorkOrderPageParam.java new file mode 100644 index 0000000000000000000000000000000000000000..13d9a9705e1d27957cf60fe9628e613a73c55c01 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/req/WorkOrderPageParam.java @@ -0,0 +1,8 @@ +package com.hnkylin.cloud.selfservice.entity.req; + +import com.hnkylin.cloud.core.common.BasePageParam; +import lombok.Data; + +@Data +public class WorkOrderPageParam extends BasePageParam { +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ApplyDeferredDetailRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ApplyDeferredDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..1ec19d108d6848f8a419ed47f530bd6981539a31 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ApplyDeferredDetailRespDto.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + + +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ApplyDeferredDetailRespDto extends BaseWorkOrderDetailDto { + + + //原过期时间 + private String oldDeadlineTime; + + //新过期时间 + private String newDeadlineTime; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ApplyServerVmDetailRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ApplyServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..3c1b4e39d9b6b6289f0692401ce0d9241edb6578 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ApplyServerVmDetailRespDto.java @@ -0,0 +1,81 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + + +import com.hnkylin.cloud.core.enums.ApplyServerVmType; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ApplyServerVmDetailRespDto extends BaseWorkOrderDetailDto { + + + private ApplyServerVmType applyServerVmType; + + private String templateName; + + //操作系统 + private String osMachine; + + private String architecture; + + //使用时间 + private Integer useMonth; + + //申请个数 + private Integer applyNum; + + + //变更后申请个数(审核时管理员可能修改) + private Integer modifyApplyNum; + + //审核时是否变更了申请个数 + private boolean ifModifyApplyNum; + + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + private String deadlineTypeDesc; + + //cpu + private Integer cpu; + + //变更后cpu(审核时管理员可能修改) + private Integer modifyCpu; + + //审核时是否变更了CPU + private boolean ifModifyCpu; + + + //内存 + private Integer mem; + + //变更后(审核时管理员可能修改) + private Integer modifyMem; + + //审核时是否变更了内存 + private boolean ifModifyMem; + + private MemUnit menUtil; + + //申请时间 + private String applyTime; + + private String description; + + //硬盘信息 + private List disks; + + //网卡信息 + private List networks; + + //iso光驱列表 + private List isoList; + + private String clusterName; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/BaseWorkOrderDetailDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/BaseWorkOrderDetailDto.java new file mode 100644 index 0000000000000000000000000000000000000000..250a4484f66ddeb70e109492810354a3af8f0799 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/BaseWorkOrderDetailDto.java @@ -0,0 +1,41 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import lombok.Data; + +@Data +public class BaseWorkOrderDetailDto { + + //工单类型 + private WorkOrderType workOrderType; + + private String workOrderTypeDesc; + + //工单对象 + private String workOrderTarget; + + //工单状态 + private WorkOrderStatus status; + + private String statusDesc; + + //申请时间 + private String applyTime; + + //申请原因 + private String applyReason; + + + //审核意见 + private String auditOpinion; + + //审核时间 + private String auditionTime; + + //审核者 + private String auditionUser; + + //用户Id + private Integer userId; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/DeptRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/DeptRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..c409980c2bbf419071b57a81635d437bf8c679c6 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/DeptRespDto.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class DeptRespDto { + + private Integer deptId; + + private String deptName; + + private Integer parentId; + + private List childDepts; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/IsoRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/IsoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..e02b166455734380818f8eae526e0d9629074d0d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/IsoRespDto.java @@ -0,0 +1,19 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + + +@Data +public class IsoRespDto { + + + private String isoFile; + + private Integer clusterId; + + private String clusterName; + + private String clusterRemark; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ModifyServerVmDetailRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ModifyServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..dc0ede2e92bde23e6e4d4a1098fb6e9ebcfa5bb0 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ModifyServerVmDetailRespDto.java @@ -0,0 +1,59 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + + +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +@Data +public class ModifyServerVmDetailRespDto extends BaseWorkOrderDetailDto { + + + //操作系统 + private String osMachine; + + + private String architecture; + + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + private String deadlineTypeDesc; + + + private String deadLineTime; + + //cpu + private Integer cpu; + + //变更后cpu(审核时管理员可能修改) + private Integer originalCpu; + + //审核时是否变更了CPU + private boolean ifModifyCpu; + + //内存 + private Integer mem; + + //变更前(审核时管理员可能修改) + private Integer originalMem; + + //审核时是否变更了内存 + private boolean ifModifyMem; + + private MemUnit menUtil; + + //申请时间 + private String applyTime; + + //硬盘信息 + private List disks; + + //网卡信息 + private List networks; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/NoVncUrlRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/NoVncUrlRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..c19ac7ae605ec0d01083aa43457f71852ae24d11 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/NoVncUrlRespDto.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + + +@Data +public class NoVncUrlRespDto { + + + private String noVncUrl; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/OrganizationTreeDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/OrganizationTreeDto.java new file mode 100644 index 0000000000000000000000000000000000000000..bfc5154ab4aca94df9bcd69dc7c4add12afd22c3 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/OrganizationTreeDto.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + +import java.util.List; + +@Data +public class OrganizationTreeDto { + + private Integer organizationId; + + private String organizationName; + + private Integer parentId; + + List children; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageServerVmRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageServerVmRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..f6453ab0f7fcccde3567320b205124dcd984b2ee --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageServerVmRespDto.java @@ -0,0 +1,77 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.McServerVmTaskStatus; +import lombok.Data; + +import java.util.Objects; + +@Data +public class PageServerVmRespDto implements Comparable { + + //云服务器id + private Integer serverVmId; + + //云服务器uuid + private String serverVmUuid; + + //云服务器名称 + private String aliasName; + + //云服务器状态 + private McServerVmStatus status; + + //云服务器任务状态 + private McServerVmTaskStatus taskStatus; + + //云服务器ip + private String ip; + + //操作系统 + private String os; + + private String architecture; + + //cpu数 + private Integer cpus; + + //内存大小 + private Integer memory; + + //磁盘大小 + private String disks; + + + private String usage; + + //创建时间 + private String createDate; + + //内存单位 + private String memoryUnit; + + //过期时间 + private Integer deadlineTime; + + //是否已经过期 + private Boolean deadlineFlag; + + //描述 + private String description; + + + @Override + public int compareTo(PageServerVmRespDto obj) { + if (Objects.equals(obj.getStatus(), this.getStatus())) { + return 0; + } else { + if (Objects.equals(obj.getStatus(), McServerVmStatus.AVAILABLE) || Objects.equals(obj.getStatus(), + McServerVmStatus.INSTALLING) || Objects.equals(obj.getStatus(), McServerVmStatus.SUSPEND) || Objects.equals(obj.getStatus(), + McServerVmStatus.CONNECTED)) { + return 1; + } else { + return -1; + } + } + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageUserMachineRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageUserMachineRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..64077eb570de6c4efda7b9e5f461fde718f08701 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageUserMachineRespDto.java @@ -0,0 +1,48 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + +/** + * Created by kylin-ksvd on 21-6-22. + */ +@Data +public class PageUserMachineRespDto { + + + //用户拥有云服务器ID + private Integer userMachineId; + //云服务器id + private Integer machineId; + //云服务器名称 + private String machineName; + //云服务器状态 + private String machineStatus; + //ip地址 + private String ip; + //操作系统 + private String osMachine; + //cpu数 + private Integer cpu; + //内存 + private Integer mem; + //内存单位 + private String memUnit; + //磁盘大小 + private String disk; + //cpu使用率 + private String cpuUsed; + //内存使用率 + private String memUsed; + //磁盘使用率 + private String diskUsed; + //创建时间 + private String createTime; + //截至时间 + private String deadlineTime; + //uuid + private String uuid; + //描述 + private String description; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageWorkOrderRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageWorkOrderRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..76965570c54927d6c449c06a31700acae132e3aa --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/PageWorkOrderRespDto.java @@ -0,0 +1,29 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import lombok.Data; + +@Data +public class PageWorkOrderRespDto { + + private Integer workOrderId; + + private WorkOrderType type; + + private String typeDesc; + + private String target; + + private WorkOrderStatus status; + + private String statusDesc; + + private String applyReason; + + private String auditOpinion; + + private String applyTime; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmDetailRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..70ce98db0280e22fce094500183cac471dd9c846 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmDetailRespDto.java @@ -0,0 +1,45 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.MemUnit; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import lombok.Data; + +import java.util.List; + +/** + * Created by kylin-ksvd on 21-8-17. + */ +@Data +public class ServerVmDetailRespDto { + + + private String aliasName; + + private Integer cpu; + + private Integer mem; + + private MemUnit memUnit; + + private String OsMachine; + + private String architecture; + + private String systemType; + + //磁盘信息 + private List disks; + + private List networks; + + //到期处理策略 + private ServerVmDeadlineType deadlineType; + + private String deadlineTime; + + //云服务器状态 + private McServerVmStatus status; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmDiskDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmDiskDto.java new file mode 100644 index 0000000000000000000000000000000000000000..18e812fa5360843879b7232332b84c65c4b4265a --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmDiskDto.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ServerVmDiskDto { + + //硬盘大小 + private Integer diskSize; + //用途 + private String purpose; + + private Integer diskId; + + private ModifyType modifyType; + + private Integer oldDiskSize; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmIsoDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmIsoDto.java new file mode 100644 index 0000000000000000000000000000000000000000..c6086a6e88106ea634acdc32126f1595f2120500 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmIsoDto.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ServerVmIsoDto { + + + private String isoFile; + + private ModifyType modifyType; + + private String oldIsoFile; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmIsoRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmIsoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..696730e7a5d1aeb7d5872e4a055fdad964f1169c --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmIsoRespDto.java @@ -0,0 +1,23 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +public class ServerVmIsoRespDto { + + + //模板名称 + private String templateName; + + private Integer clusterId; + + private String clusterName; + + private String clusterRemark; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmNetworkDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmNetworkDto.java new file mode 100644 index 0000000000000000000000000000000000000000..30dea179beb846ce81795581647ca338d831621e --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmNetworkDto.java @@ -0,0 +1,30 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import com.hnkylin.cloud.core.enums.ModifyType; +import lombok.Data; + +@Data +public class ServerVmNetworkDto { + //网卡用途 + private String purpose; + + private Integer interfaceId; + + private ModifyType modifyType; + + private Boolean setIpInfo; + + private Boolean ipBindMac; + + private Boolean manualSetIp; + + private Boolean automaticAcqIp; + + private String ip; + private String mask; + + private String gw; + private String dns1; + private String dns2; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmTemplateRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmTemplateRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..93da602c328041d215932d8ed019ba08f2035663 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/ServerVmTemplateRespDto.java @@ -0,0 +1,53 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +public class ServerVmTemplateRespDto { + + + //模板名称 + private String templateName; + + //模板ID + private Integer templateId; + + //操作系统 + private String osMachine; + + //系统类型 + private String systemType; + + //架构 + private String architecture; + + //描述 + private String description; + + //cpu + private Integer cpu; + + //内存 + private Integer mem; + + + //磁盘 + private String diskInfo; + + private List networks; + + //磁盘信息 + private List disks; + + private Integer clusterId; + + private String clusterName; + + private String clusterRemark; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/TokenRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/TokenRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..56e25e966cf15979faec46384115a0a88d91df2c --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/TokenRespDto.java @@ -0,0 +1,9 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + +@Data +public class TokenRespDto { + + private String token; +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/UserInfoRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/UserInfoRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..2240d9098ab17f796a5e40a2e82a105e04a2fa9e --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/UserInfoRespDto.java @@ -0,0 +1,22 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + +@Data +public class UserInfoRespDto { + + private String userName; + + private String realName; + + + private String deptName; + + //private String organizationName; + + private String mobile; + + private String remark; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/VncUrlDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/VncUrlDto.java new file mode 100644 index 0000000000000000000000000000000000000000..d750962f4b99bba1687846233f9acad2cb795bcd --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/VncUrlDto.java @@ -0,0 +1,10 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + +import lombok.Data; + +@Data +public class VncUrlDto { + + private String vncUrl; + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/WorkOrderUserDetailRespDto.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/WorkOrderUserDetailRespDto.java new file mode 100644 index 0000000000000000000000000000000000000000..0b6057faba733f562e286434b6b4ccb4f88402c9 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/entity/resp/WorkOrderUserDetailRespDto.java @@ -0,0 +1,27 @@ +package com.hnkylin.cloud.selfservice.entity.resp; + + +import lombok.Data; + +@Data +public class WorkOrderUserDetailRespDto extends BaseWorkOrderDetailDto { + + + //账号 + private String userName; + + //真实姓名 + private String realName; + + //新真实姓名 + private String newRealName; + + //组织名 + private String organizationName; + + + //手机号 + private String mobile; + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/InterceptorConfig.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/InterceptorConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..9067dac4dc828668a6eb844565b6351012dce2d2 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/InterceptorConfig.java @@ -0,0 +1,43 @@ +package com.hnkylin.cloud.selfservice.interceptor; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; + +import java.util.List; + + +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(managerInterceptor()).excludePathPatterns("/static/**").addPathPatterns("/**"); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); + } + + @Bean + public SelfServiceInterceptor managerInterceptor() { + + return new SelfServiceInterceptor(); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + argumentResolvers.add(loginUserMethodArgumentResolver()); + + } + + @Bean + public LoginUserMethodArgumentResolver loginUserMethodArgumentResolver() { + return new LoginUserMethodArgumentResolver(); + } + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/LoginUserMethodArgumentResolver.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/LoginUserMethodArgumentResolver.java new file mode 100644 index 0000000000000000000000000000000000000000..c0423b25b1cbe833e567206127eeefa4cb1c30ac --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/LoginUserMethodArgumentResolver.java @@ -0,0 +1,52 @@ +package com.hnkylin.cloud.selfservice.interceptor; + + +import com.hnkylin.cloud.core.annotation.LoginUser; +import com.hnkylin.cloud.core.common.JwtUtil; +import com.hnkylin.cloud.core.config.exception.KylinTokenException; +import com.hnkylin.cloud.selfservice.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.selfservice.constant.KylinSelfConstants; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import org.springframework.core.MethodParameter; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +import java.util.Objects; + + +public class LoginUserMethodArgumentResolver implements HandlerMethodArgumentResolver { + + + public LoginUserMethodArgumentResolver() { + + } + + @Override + public boolean supportsParameter(MethodParameter parameter) { + + return parameter.hasParameterAnnotation(LoginUser.class) && parameter.getParameterType().equals(LoginUserVo + .class); + } + + @Override + public Object resolveArgument( + MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, + WebDataBinderFactory binderFactory) { + + String token = webRequest.getHeader(KylinSelfConstants.KYLIN_ACCESS_TOKEN); + if (Objects.isNull(token)) { + throw new KylinTokenException(KylinHttpResponseConstants.NOT_EXIST_TOKEN); + } + String username = JwtUtil.getUsername(token); + String userId = JwtUtil.getUserId(token); + + LoginUserVo loginUserVo = new LoginUserVo(); + loginUserVo.setUserId(Integer.parseInt(userId)); + loginUserVo.setUserName(username); + loginUserVo.setToken(token); + return loginUserVo; + } + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/SelfServiceInterceptor.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/SelfServiceInterceptor.java new file mode 100644 index 0000000000000000000000000000000000000000..4467f253090e36d0bf5e9a18c5c3754456059325 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/interceptor/SelfServiceInterceptor.java @@ -0,0 +1,79 @@ +package com.hnkylin.cloud.selfservice.interceptor; + + +import com.hnkylin.cloud.core.config.exception.KylinTokenException; +import com.hnkylin.cloud.selfservice.config.AuthExcludeApiProperties; +import com.hnkylin.cloud.selfservice.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.selfservice.constant.KylinSelfConstants; +import com.hnkylin.cloud.selfservice.constant.SelfServiceRedisConstant; +import com.hnkylin.cloud.selfservice.service.cache.LoginUserCacheService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + + +@Slf4j +public class SelfServiceInterceptor implements HandlerInterceptor { + + @Autowired + private AuthExcludeApiProperties authExcludeApiProperties; + + @Resource + private LoginUserCacheService loginUserCacheService; + + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws + Exception { + String uri = request.getRequestURI(); + String token = request.getHeader(KylinSelfConstants.KYLIN_ACCESS_TOKEN); + String TIME_REFRESH = request.getHeader(KylinSelfConstants.TIME_REFRESH); + log.info("requestUrl: {}", uri); + List exApis = authExcludeApiProperties.getAuthExcludeApis(); + + if (exApis.contains(uri)) { + return true; + } + + + //判断token是否存在 + if (StringUtils.isBlank(token)) { + throw new KylinTokenException(KylinHttpResponseConstants.NOT_EXIST_TOKEN); + } + Object redisToken = loginUserCacheService.vGet(token); + if (Objects.isNull(redisToken)) { + //token过期,重新登录 + throw new KylinTokenException(KylinHttpResponseConstants.TOKEN_EXPIRE); + } + if (StringUtils.isBlank(TIME_REFRESH)) { + //重新设置token过期时间 + loginUserCacheService.vSet(token, redisToken, SelfServiceRedisConstant.SELF_SERVICE_LOGIN_USER_CACHE_EXPIRE, + TimeUnit.MILLISECONDS); + loginUserCacheService.vSet(SelfServiceRedisConstant.UID + redisToken, token, SelfServiceRedisConstant + .SELF_SERVICE_LOGIN_USER_CACHE_EXPIRE, TimeUnit.MILLISECONDS); + } + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable + ModelAndView modelAndView) throws Exception { + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable + Exception ex) throws Exception { + } + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/runner/KylinSelfServiceRunner.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/runner/KylinSelfServiceRunner.java new file mode 100644 index 0000000000000000000000000000000000000000..325475fe5d552475e6ac4675bd354abacb5ab261 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/runner/KylinSelfServiceRunner.java @@ -0,0 +1,20 @@ +package com.hnkylin.cloud.selfservice.runner; + +import com.hnkylin.cloud.selfservice.service.McNodeService; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +public class KylinSelfServiceRunner implements ApplicationRunner { + + @Resource + private McNodeService mcNodeService; + + @Override + public void run(ApplicationArguments args) throws Exception { + mcNodeService.initMcNodeListToCache(); + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/ServerVmExpireThread.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/ServerVmExpireThread.java new file mode 100644 index 0000000000000000000000000000000000000000..e31acd96ec2a852656a927c96244b67b42632bee --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/ServerVmExpireThread.java @@ -0,0 +1,180 @@ +package com.hnkylin.cloud.selfservice.schedule; + + +import com.alibaba.fastjson.JSON; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; +import com.hnkylin.cloud.core.enums.McServerVmStatus; +import com.hnkylin.cloud.core.enums.ServerVmDeadlineType; +import com.hnkylin.cloud.core.service.CloudUserMachineService; +import com.hnkylin.cloud.core.service.CloudUserService; +import com.hnkylin.cloud.selfservice.config.MCConfigProperties; +import com.hnkylin.cloud.core.common.servervm.ServerVmBaseReq; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchReq; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McServerVmStatusResp; +import com.hnkylin.cloud.selfservice.service.McHttpService; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * 云服务器到期后具体执行的线程 + */ +@Slf4j +public class ServerVmExpireThread implements Runnable { + + + private CloudUserMachineService cloudUserMachineService; + + private MCConfigProperties mcConfigProperties; + + private McHttpService mcHttpService; + + private CloudUserService cloudUserService; + + private CloudUserMachineDo userMachine; + + public ServerVmExpireThread(CloudUserMachineService cloudUserMachineService, + MCConfigProperties mcConfigProperties, McHttpService mcHttpService, + CloudUserService cloudUserService, CloudUserMachineDo userMachine) { + this.cloudUserMachineService = cloudUserMachineService; + this.mcConfigProperties = mcConfigProperties; + this.mcHttpService = mcHttpService; + this.cloudUserService = cloudUserService; + this.userMachine = userMachine; + } + + @Override + public void run() { + Date now = new Date(); + + + CloudUserDo cloudUserDo = cloudUserService.getById(userMachine.getUserId()); + //调用mc接口判断云服务器是否离线状态 + boolean isOfflineFlag = mcServerVmIsOffline(userMachine.getMachineUuid(), cloudUserDo.getUserName()); + + log.info("runServerVmExpireTask,uuid:{},isOfflineFlag:{}", userMachine.getMachineUuid(), isOfflineFlag); + + //先获取云服务器状态, + //到期策略-关机:如果是关机状态,则不用调用mc关机接口,如果不是离线状态,则进行关机操作 + //到期策略-销毁:如果是关机状态,则调用mc销毁接口,如果不是离线状态,则需要先进行关机操作,在调用销毁接口 + if (!isOfflineFlag) { + //不是离线状态 + //调用mc接口进行关机 + boolean shutdownResult = forcedShutdownServerVm(userMachine.getMachineUuid(), cloudUserDo.getUserName()); + log.info("runServerVmExpireTask-forcedShutdown,uuid:{},shutdownResult:{}", + userMachine.getMachineUuid(), shutdownResult); + if (shutdownResult) { + //关机成功,因为MC中关机是异步任务上报,所以等2分钟后,在查一次云服务器状态,如果是离线,则说明关机成功, + //2分钟后不是离线,则说明关机失败了,这次任务就忽略该条过期的云服务器,下次定时任务在执行 + try { + Thread.sleep(2 * 60 * 1000); + boolean offlineFlag = mcServerVmIsOffline(userMachine.getMachineUuid(), cloudUserDo.getUserName()); + log.info("runServerVmExpireTask-wait-2min,uuid:{},isOfflineFlag:{}", userMachine.getMachineUuid(), + offlineFlag); + if (!offlineFlag) { + log.info("runServerVmExpireTask-forcedShutdown-error,uuid:{},shutdown error,tomorrow task run", + userMachine.getMachineUuid()); + return; + } + } catch (InterruptedException e) { + e.printStackTrace(); + return; + } + } else { + //如果关机失败,则同样这次任务就忽略该条过期的云服务器,下次定时任务在执行该云服务器 + log.info("runServerVmExpireTask-forcedShutdown-error,uuid:{},shutdown error,tomorrow task run", + userMachine.getMachineUuid()); + return; + } + } + + if (Objects.equals(userMachine.getDeadlineType(), ServerVmDeadlineType.DESTROY)) { + //销毁策略,调用mc回收云服务器接口 + //调用mc回收云服务器接口 + boolean destroyResult = destroyServerVm(userMachine.getMachineUuid(), cloudUserDo.getUserName()); + log.info("runServerVmExpireTask-destroyResult,uuid:{},destroyResult:{}", + userMachine.getMachineUuid(), destroyResult); + //如果销毁成功,则设置改用户拥有的云服务器已呗删除。(mc中放入了回收站) + if (destroyResult) { + userMachine.setDeleteFlag(Boolean.TRUE); + userMachine.setDeleteTime(now); + userMachine.setDeadlineFlag(Boolean.TRUE); + userMachine.setUpdateTime(now); + cloudUserMachineService.updateById(userMachine); + } + } else if (Objects.equals(userMachine.getDeadlineType(), ServerVmDeadlineType.POWER_OFF)) { + userMachine.setDeadlineFlag(Boolean.TRUE); + userMachine.setUpdateTime(now); + cloudUserMachineService.updateById(userMachine); + } + + } + + + /** + * 判断mc中云服务器接口是否是关机状态 + */ + public boolean mcServerVmIsOffline(String machineUuid, String userName) { + McServerVmStatusResp mcStatus = new McServerVmStatusResp(); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(machineUuid); + + CloudUserMachineDo userMachineDo = cloudUserMachineService.getUserMachineDoByUuid(machineUuid); + + String httpUrl = mcConfigProperties.getServerVmStatusUrl(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, httpUrl, userName, 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + mcStatus = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), McServerVmStatusResp.class); + + } + + return Objects.equals(McServerVmStatus.OFFLINE, mcStatus.getStatus()); + } + + /** + * 调用mc接口进行关机 + */ + private boolean forcedShutdownServerVm(String machineUuid, String userName) { + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(machineUuid); + + CloudUserMachineDo userMachineDo = cloudUserMachineService.getUserMachineDoByUuid(machineUuid); + + return mcHttpService.noDataCommonMcRequest(userMachineDo.getClusterId(), serverVmBaseReq, + mcConfigProperties.getForcedShutdownServerVmUrl(), userName, 0); + } + + /** + * 销毁-调用mc接口将云服务器放入回收站中 + */ + private boolean destroyServerVm(String machineUuid, String userName) { + List serverVmUuids = new ArrayList(); + serverVmUuids.add(machineUuid); + + + ServerVmBatchReq serverVmBatchReq = new ServerVmBatchReq(); + serverVmBatchReq.setUuid(String.join(",", serverVmUuids)); + + CloudUserMachineDo userMachineDo = cloudUserMachineService.getUserMachineDoByUuid(machineUuid); + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBatchReq, mcConfigProperties.getBatchRemoveMachineToRecycleUrl(), userName, 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + return true; + } + return false; + } + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/ServerVmExpireThreadFactory.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/ServerVmExpireThreadFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..fb7eb307369b2de9a34e6c4f7d67d743d6f3a09d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/ServerVmExpireThreadFactory.java @@ -0,0 +1,16 @@ +package com.hnkylin.cloud.selfservice.schedule; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; + +public class ServerVmExpireThreadFactory implements ThreadFactory { + + private final AtomicInteger mThreadNum = new AtomicInteger(1); + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, "serverVmExpireTask-" + mThreadNum.getAndIncrement()); + System.out.println(t.getName() + " has been created"); + return t; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/UserServerVmExpireTask.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/UserServerVmExpireTask.java new file mode 100644 index 0000000000000000000000000000000000000000..771566c1002e519879307d2d94baea02a0de5b86 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/schedule/UserServerVmExpireTask.java @@ -0,0 +1,79 @@ +package com.hnkylin.cloud.selfservice.schedule; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.domain.CloudUserMachineDo; +import com.hnkylin.cloud.core.service.CloudUserMachineService; +import com.hnkylin.cloud.core.service.CloudUserService; +import com.hnkylin.cloud.selfservice.config.MCConfigProperties; +import com.hnkylin.cloud.selfservice.service.McHttpService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.concurrent.*; + +/** + * 云服务器到期处理,定时任务 + */ +@Configuration +@EnableScheduling +@Slf4j +public class UserServerVmExpireTask { + + @Resource + private CloudUserMachineService cloudUserMachineService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private McHttpService mcHttpService; + + @Resource + private CloudUserService cloudUserService; + + + private final int maxThreadSize = 5; + + /** + * 每天凌晨1点进行定时任务 + */ + @Scheduled(cron = "0 0 1 * * ?") + private void runServerVmExpireTask() { + log.info("runServerVmExpireTask-start"); + //查询出今天之前过期的云服务器 + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setDeleteFlag(false); + cloudUserMachineDo.setDeadlineFlag(false); + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + queryWrapper.le("deadline_time", new Date()); + List userMachineDoList = + cloudUserMachineService.list(queryWrapper); + log.info("runServerVmExpireTask-到期云服务器数量:" + userMachineDoList.size()); + + if (userMachineDoList.size() > 0) { + //线程池核心数控制 + int threadCoreSize = userMachineDoList.size() > maxThreadSize ? maxThreadSize : userMachineDoList.size(); + + //定义线程池 + BlockingQueue workQueue = new ArrayBlockingQueue<>(userMachineDoList.size()); + ThreadFactory threadFactory = new ServerVmExpireThreadFactory(); + + ThreadPoolExecutor executor = new ThreadPoolExecutor(threadCoreSize, threadCoreSize, 5, TimeUnit.MINUTES, + workQueue, threadFactory, new ThreadPoolExecutor.AbortPolicy()); + + userMachineDoList.forEach(userMachine -> { + ServerVmExpireThread thread = new ServerVmExpireThread(cloudUserMachineService, mcConfigProperties, + mcHttpService, cloudUserService, userMachine); + executor.execute(thread); + }); + } + } + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McClusterThreadService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McClusterThreadService.java new file mode 100644 index 0000000000000000000000000000000000000000..02008758209aea92ca2f8f7090e1d995c32e4c2d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McClusterThreadService.java @@ -0,0 +1,93 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.selfservice.threadTask.McClusterNoDataThread; +import com.hnkylin.cloud.selfservice.threadTask.McClusterThread; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; + +@Service +public class McClusterThreadService { + + + @Resource + private McHttpService mcHttpService; + + + @Resource + private ThreadPoolTaskExecutor mcClusterInfoExecutor; + + /** + * 多集群向mc发送带数据获取的请求 + * + * @param clusterIdList + * @param loginName + */ + public List threadGetMcResponse(List clusterIdList, + String loginName, String mcInterfaceUrl, List requestObjList) { + //使用线程池 + List> taskList = new ArrayList<>(); + + for (int i = 0; i < clusterIdList.size(); i++) { + McClusterThread thread = new McClusterThread(mcHttpService, loginName, clusterIdList.get(i), mcInterfaceUrl, + requestObjList.isEmpty() ? null : requestObjList.get(i)); + FutureTask futureTask = new FutureTask<>(thread); + taskList.add(futureTask); + mcClusterInfoExecutor.submit(futureTask); + } + + List mcResponseList = new ArrayList<>(); + for (FutureTask task : taskList) { + try { + String mcClusterResponse = task.get(); + mcResponseList.add(mcClusterResponse); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + return mcResponseList; + + } + + /** + * 多集群向mc发送请求 + * + * @param clusterIdList + * @param loginName + */ + public List> threadSendToMc(List clusterIdList, + String loginName, String mcInterfaceUrl, + List requestObjList) { + //使用线程池 + List>> taskList = new ArrayList<>(); + + for (int i = 0; i < clusterIdList.size(); i++) { + McClusterNoDataThread thread = new McClusterNoDataThread(mcHttpService, + loginName, clusterIdList.get(i), mcInterfaceUrl, requestObjList.isEmpty() ? null : + requestObjList.get(i)); + FutureTask> futureTask = new FutureTask<>(thread); + taskList.add(futureTask); + mcClusterInfoExecutor.submit(futureTask); + } + + List> mcResponseList = new ArrayList<>(); + for (FutureTask> task : taskList) { + try { + MCResponseData responseData = task.get(); + mcResponseList.add(responseData); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + return mcResponseList; + + } + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McHttpService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McHttpService.java new file mode 100644 index 0000000000000000000000000000000000000000..223f1e7cf1743d2be817f38a0a889b6979ca1757 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McHttpService.java @@ -0,0 +1,155 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.core.common.McUtils; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.config.exception.KylinMcRequestException; +import com.hnkylin.cloud.selfservice.config.MCConfigProperties; +import jdk.nashorn.api.scripting.JSObject; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +/** + * Created by kylin-ksvd on 21-6-25. + */ +@Service +@Slf4j +public class McHttpService { + + + @Resource + private RestTemplate httpsRestTemplate; + + + @Resource + private McNodeService mcNodeService; + + @Resource + private MCConfigProperties mcConfigProperties; + + + /* + * 不需要响应data的通用和mc请求 + */ + public boolean noDataCommonMcRequest(Integer clusterId, Object requestObj, String httpMcUrl, String userName, + Integer retryIndex) { + List mcNodeList = mcNodeService.getMcNodeListFromCache(clusterId); + int mcNodeListSize = mcNodeList.size(); + try { + if (retryIndex < mcNodeListSize) { + String mcLeaderUrl = getMcLeaderUrl(clusterId, retryIndex); + HttpHeaders httpHeaders = McUtils.createMcHeaders(userName); + log.info("noDataCommonMcRequest-headers:{}", JSON.toJSONString(httpHeaders)); + + requestObj = Objects.isNull(requestObj) ? new Object() : requestObj; + JSONObject reqBodyObj = JSONObject.parseObject(JSON.toJSONString(requestObj)); + String requestUrl = mcLeaderUrl + mcConfigProperties.getCommonPrefix() + httpMcUrl; + log.info("noDataCommonMcRequest-url:{},body:{}", requestUrl, reqBodyObj.toJSONString()); + + + HttpEntity httpEntity = new HttpEntity(reqBodyObj, httpHeaders); + + MCResponseData result = + httpsRestTemplate.postForObject(requestUrl, httpEntity, MCResponseData.class); + + log.info("noDataCommonMcRequest-response:{}", JSON.toJSONString(result)); + if (Objects.isNull(result) && retryIndex < mcNodeListSize - 1) { + return noDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + + if (Objects.equals(MCServerVmConstants.SUCCESS, result.getStatus())) { + mcNodeService.setMcLeaderUrlToCache(mcLeaderUrl, clusterId); + } + return Objects.equals(MCServerVmConstants.SUCCESS, result.getStatus()); + + } + } catch (Exception exception) { + exception.printStackTrace(); + log.debug(exception.getMessage()); + if (retryIndex < mcNodeListSize - 1) { + return noDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + } + throw new KylinException(MCServerVmConstants.MC_NODE_NOT_VISIT); + } + + /* + * 带data响应的的通用和mc请求 + */ + public MCResponseData hasDataCommonMcRequest(Integer clusterId, Object requestObj, String httpMcUrl, + String userName, + Integer retryIndex) { + List mcNodeList = mcNodeService.getMcNodeListFromCache(clusterId); + int mcNodeListSize = mcNodeList.size(); + try { + + if (retryIndex < mcNodeListSize) { + String mcLeaderUrl = getMcLeaderUrl(clusterId, retryIndex); + HttpHeaders httpHeaders = McUtils.createMcHeaders(userName); + log.info("hasDataCommonMcRequest-headers:{}", JSON.toJSONString(httpHeaders)); + + requestObj = Objects.isNull(requestObj) ? new Object() : requestObj; + + JSONObject reqBodyObj = JSONObject.parseObject(JSON.toJSONString(requestObj)); + + String requestUrl = mcLeaderUrl + mcConfigProperties.getCommonPrefix() + httpMcUrl; + log.info("hasDataCommonMcRequest-url:{},body:{},retryIndex:{}", + requestUrl, + reqBodyObj.toJSONString(), retryIndex); + + + HttpEntity httpEntity = new HttpEntity(reqBodyObj, httpHeaders); + + + MCResponseData result = + httpsRestTemplate.postForObject(requestUrl, httpEntity, MCResponseData.class); + log.info("hasDataCommonMcRequest-retryIndex:{},response:{}", retryIndex, JSON.toJSONString(result)); + if (Objects.isNull(result) && retryIndex < mcNodeListSize - 1) { + return hasDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + if (Objects.nonNull(result) && Objects.equals(result.getStatus(), "success")) { + mcNodeService.setMcLeaderUrlToCache(mcLeaderUrl, clusterId); + } + return result; + } + + } catch (Exception exception) { + exception.printStackTrace(); + log.debug(exception.getMessage()); + if (retryIndex < mcNodeListSize - 1) { + return hasDataCommonMcRequest(clusterId, requestObj, httpMcUrl, userName, retryIndex + 1); + } + + } + throw new KylinException(MCServerVmConstants.MC_NODE_NOT_VISIT); + } + + + /** + * 获取mc主节点Url + */ + private String getMcLeaderUrl(Integer clusterId, Integer retryIndex) { + + String mcLeaderUrl = null; + if (Objects.equals(retryIndex, 0)) { + mcLeaderUrl = mcNodeService.getMcLeaderUrlFromCache(clusterId); + if (Objects.nonNull(mcLeaderUrl)) { + return mcLeaderUrl; + } + } + List mcNodeList = mcNodeService.getMcNodeListFromCache(clusterId); + + return mcNodeList.isEmpty() ? null : mcNodeList.get(retryIndex); + } + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McNodeService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McNodeService.java new file mode 100644 index 0000000000000000000000000000000000000000..794c80d7203219bba033c7fd7a9397033b16d667 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/McNodeService.java @@ -0,0 +1,120 @@ +package com.hnkylin.cloud.selfservice.service; + + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.domain.CloudClusterDo; +import com.hnkylin.cloud.core.service.CloudClusterService; +import com.hnkylin.cloud.selfservice.config.MCConfigProperties; +import com.hnkylin.cloud.selfservice.constant.SelfServiceRedisConstant; +import com.hnkylin.cloud.selfservice.service.cache.McLeaderNodeCacheService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + + +@Service +public class McNodeService { + + @Resource + private McLeaderNodeCacheService mcLeaderNodeCacheService; + + @Resource + private CloudClusterService cloudClusterService; + + + /** + * 初始化将mcNode节点列表,放入缓存中 + */ + public void initMcNodeListToCache() { + CloudClusterDo clusterDo = new CloudClusterDo(); + clusterDo.setDeleteFlag(false); + Wrapper wrapper = new QueryWrapper<>(clusterDo); + List clusterDoList = cloudClusterService.list(wrapper); + if (!clusterDoList.isEmpty()) { + clusterDoList.forEach(item -> { + Integer clusterId = item.getId(); + List mcNodeList = cloudClusterService.formatClusterNodeList(item.getId()); + if (!mcNodeList.isEmpty()) { + setMcNodeListToCache(mcNodeList, clusterId); + } + String mcLeaderUrl = getMcLeaderUrlFromCache(clusterId); + if (!mcNodeList.contains(mcLeaderUrl)) { + mcLeaderNodeCacheService.vDelete(SelfServiceRedisConstant.MC_LEADER_URL_KEY + clusterId); + } + if (!mcNodeList.isEmpty()) { + setMcLeaderUrlToCache(mcNodeList.get(0), clusterId); + } + }); + + } + + } + + + /** + * 获取缓存中的mc主节点的url + */ + public String getMcLeaderUrlFromCache(Integer clusterId) { + Object mcLeaderUrl = mcLeaderNodeCacheService.vGet(SelfServiceRedisConstant.MC_LEADER_URL_KEY + clusterId); + if (Objects.nonNull(mcLeaderUrl)) { + return mcLeaderUrl.toString(); + } + List mcNodeList = cloudClusterService.formatClusterNodeList(clusterId); + return mcNodeList.isEmpty() ? null : mcNodeList.get(0); + } + + /** + * 设置mc主节点额url到缓存中 + */ + public void setMcLeaderUrlToCache(String mcLeaderUrl, Integer clusterId) { + mcLeaderNodeCacheService.vSet(SelfServiceRedisConstant.MC_LEADER_URL_KEY + clusterId, mcLeaderUrl); + //修改缓存中的mcNodeList 将当前可用的节点放在list中第一位 + setLeaderUrlFirst(mcLeaderUrl, clusterId); + } + + + /** + * 删除缓存中mc主节点额url + * + * @param clusterId + */ + public void deleteMcLeaderUrlToCache(Integer clusterId) { + mcLeaderNodeCacheService.vDelete(SelfServiceRedisConstant.MC_LEADER_URL_KEY + clusterId); + } + + /** + * 设置mc的CM节点到缓存中 + */ + public void setMcNodeListToCache(List mcNodeList, Integer clusterId) { + mcLeaderNodeCacheService.vSet(SelfServiceRedisConstant.MC_NODE_LIST_KEY + clusterId, mcNodeList); + } + + /** + * 从缓存中读取mc的cm节点列表 + */ + public List getMcNodeListFromCache(Integer clusterId) { + Object mcNodeList = mcLeaderNodeCacheService.vGet(SelfServiceRedisConstant.MC_NODE_LIST_KEY + clusterId); + if (Objects.isNull(mcNodeList)) { + return cloudClusterService.formatClusterNodeList(clusterId); + } + return (List) mcNodeList; + } + + /** + * 修改缓存中的mcNodeList 将当前可用的节点放在list中第一位 + */ + private void setLeaderUrlFirst(String mcLeaderUrl, Integer clusterId) { + List mcNodeList = getMcNodeListFromCache(clusterId); + if (!mcNodeList.isEmpty()) { + mcNodeList.remove(mcLeaderUrl); + mcNodeList.add(0, mcLeaderUrl); + setMcNodeListToCache(mcNodeList, clusterId); + } + } + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServerVmService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServerVmService.java new file mode 100644 index 0000000000000000000000000000000000000000..514ceae165d8fec161b710dfd82d9f54ce7bf363 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServerVmService.java @@ -0,0 +1,227 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.hnkylin.cloud.core.common.BaseResult; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.common.servervm.ServerVmBaseParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmBatchOperateParam; +import com.hnkylin.cloud.core.common.servervm.ServerVmMonitorInfoRespDto; +import com.hnkylin.cloud.core.enums.McStartVmErrorCode; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.mc.req.*; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McOperateSystemResp; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McServerVmInfoResp; +import com.hnkylin.cloud.core.common.servervm.McServerVmLogResp; +import com.hnkylin.cloud.selfservice.entity.mc.resp.McServerVmSnapshotResp; +import com.hnkylin.cloud.selfservice.entity.req.*; +import com.hnkylin.cloud.selfservice.entity.resp.*; +import org.springframework.http.ResponseEntity; + +import java.util.List; + +public interface SelfServerVmService { + + /** + * 获取模板列表 + */ + PageData listServerVmTemplate(SearchTemplateParam searchTemplateParam, + LoginUserVo loginUserVo); + + + /** + * 获取mc-iso列表 + * + * @param loginUserVo + */ + List isoList(LoginUserVo loginUserVo); + + /** + * 申请云服务器 + */ + void applyServerVm(ApplyServerVmParam applyServerVmParam, LoginUserVo loginUserVo); + + + /** + * 变更云服务器 + */ + void modifyServerVm(ModifyServerVmParam modifyServerVmParam, LoginUserVo loginUserVo); + + + /** + * 变更云服务器 + */ + ServerVmDetailRespDto getServerVmDetail(ServerVmBaseParam serverVmPageParam, LoginUserVo loginUserVo); + + /** + * 根据工单ID获取申请服务器工单详情 + */ + ApplyServerVmDetailRespDto getApplyServerVmDetailByWorkOrderId(Integer workOrderId, LoginUserVo loginUserVo); + + /** + * 根据工单ID获取延期云服务器详情 + */ + ApplyDeferredDetailRespDto applyDeferredDetailByWorkOrderId(Integer workOrderId); + + + /** + * 根据工单ID获取获取变更云服务器详情 + */ + ModifyServerVmDetailRespDto modifyServerVmDetailByWorkOrderId(Integer workOrderId); + + + /** + * 申请延期云服务器 + */ + void applyDeferredMachine(ApplyDeferredParam applyDeferredParam, LoginUserVo loginUserVo); + + /** + * 查询用户云服务器 + */ + PageData listServerVm(ServerVmPageParam serverVmPageParam, LoginUserVo loginUserVo); + + + /** + * 删除云服务器 + */ + BaseResult deleteServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器开机 + */ + McStartVmErrorCode startServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务器关机 + */ + boolean shutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务器强制关机 + */ + boolean forcedShutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器重启 + */ + boolean restartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器强制重启 + */ + boolean forcedRestartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务器批量开机 + */ + BaseResult batchStartServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, LoginUserVo loginUserVo); + + /** + * 批量删除 + */ + BaseResult batchDeleteServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo); + + + /** + * 云服务器批量关机 + */ + BaseResult batchShutdownServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo); + + /** + * 云服务器批量重启 + */ + BaseResult batchRebootServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo); + + + /** + * 云服务区器详情-概要 + */ + McServerVmInfoResp serverVmInfo(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /** + * 云服务区器详情-监控 + */ + ServerVmMonitorInfoRespDto serverVmMonitor(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /** + * 云服务区器详情-操作日志 + */ + PageData serverVmOperateLog(ServerVmOperateLogPageParam serverVmOperateLogPageParam, + LoginUserVo loginUserVo); + + /* + * 云服务区器详情-创建快照 + */ + BaseResult createSnapshot(McServerVmCreateSnapshotReq mcServerVmCreateSnapshotReq, LoginUserVo loginUserVo); + + /* + * 云服务区器详情-编辑快照 + */ + BaseResult updateSnapshot(McServerVmUpdateSnapshotReq mcServerVmUpdateSnapshotReq, LoginUserVo loginUserVo); + + /* + * 云服务区器详情-删除快照 + */ + boolean deleteSnapshot(McServerVmDeleteSnapshotReq mcServerVmDeleteSnapshotReq, LoginUserVo loginUserVo); + + /* + * 云服务区器详情-应用快照 + */ + BaseResult applySnapshot(McServerVmApplySnapshotReq mcServerVmApplySnapshotReq, LoginUserVo loginUserVo); + + + /* + * 云服务区器详情-快照列表 + */ + List listSnapshot(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + + /* + * 获取vncUrl + */ + VncUrlDto getVncUrl(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo); + + /* + * 修改云服务器描述 + */ + boolean updateMachineDescription(UpdateServerVmDescriptionParam updateServerVmDescriptionParam, + LoginUserVo loginUserVo); + + /* + * 修改云服务器名称 + */ + boolean updateMachineName(UpdateServerVmNameParam updateServerVmNameParam, + LoginUserVo loginUserVo); + + + /** + * 重置控制台密码 + * + * @param remotePasswordReq + * @param loginUserVo + * @return + */ + boolean resetRemotePassword(McServerVmResetRemotePasswordReq remotePasswordReq, LoginUserVo loginUserVo); + + + /** + * 获取mc云服务器图片 + */ + ResponseEntity downLoadServerVmLog(String mcServerVmLogoPath, String mcServerVmLogoName); + + + /** + * 获取所有操作系统列表 + * + * @param queryOperateSystem + * @param loginUserVo + * @return + */ + List getAllOperatingSystem(QueryOperateSystem queryOperateSystem, LoginUserVo loginUserVo); + + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceDeptService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceDeptService.java new file mode 100644 index 0000000000000000000000000000000000000000..c881d5e486fa63b8169b844694c41e971ef93703 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceDeptService.java @@ -0,0 +1,13 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.hnkylin.cloud.selfservice.entity.resp.DeptRespDto; + +import java.util.List; + +public interface SelfServiceDeptService { + + /** + * 获取部门列表 + */ + List queryDeptList(); +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceOrganizationService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceOrganizationService.java new file mode 100644 index 0000000000000000000000000000000000000000..2633fcd6b5bef954508549adc18449bbcc891812 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceOrganizationService.java @@ -0,0 +1,14 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.hnkylin.cloud.selfservice.entity.resp.OrganizationTreeDto; + +import java.util.List; + +public interface SelfServiceOrganizationService { + + + /** + * 获取组织列表 + */ + List queryOrganizationTree(); +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceUserService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceUserService.java new file mode 100644 index 0000000000000000000000000000000000000000..e1d28bac88426d0c4b84bd86a31906384c1fe866 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfServiceUserService.java @@ -0,0 +1,49 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.LoginUserParam; +import com.hnkylin.cloud.selfservice.entity.req.UpdateRealNameParam; +import com.hnkylin.cloud.selfservice.entity.req.UpdatePwdParam; +import com.hnkylin.cloud.selfservice.entity.req.UserRegisterParam; +import com.hnkylin.cloud.selfservice.entity.resp.WorkOrderUserDetailRespDto; +import com.hnkylin.cloud.selfservice.entity.resp.TokenRespDto; +import com.hnkylin.cloud.selfservice.entity.resp.UserInfoRespDto; + +public interface SelfServiceUserService { + + /** + * 注册 + */ + void register(UserRegisterParam userRegisterParam); + + /** + * 登录 + */ + TokenRespDto login(LoginUserParam loginUserParam); + + /** + * 修改密码 + */ + void updatePwd(UpdatePwdParam updatePwdParam, LoginUserVo loginUserVo); + + /** + * 用户信息 + */ + UserInfoRespDto userInfo(LoginUserVo loginUserVo); + + /** + * 登出 + */ + void loginOut(LoginUserVo loginUserVo); + + /** + * 修改真实姓名 + */ + void updateRealName(UpdateRealNameParam updateRealNameParam, LoginUserVo loginUserVo); + + /** + * 根据工单ID获取注册申请/修改账号 工单详情 + */ + WorkOrderUserDetailRespDto getWorkOrderUserDetailByWorkOrderId(Integer workOrderId); + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfWorkOrderService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfWorkOrderService.java new file mode 100644 index 0000000000000000000000000000000000000000..ce5f268a506855366fbd7fe7b4af800ec3d61878 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/SelfWorkOrderService.java @@ -0,0 +1,21 @@ +package com.hnkylin.cloud.selfservice.service; + +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.WorkOrderPageParam; +import com.hnkylin.cloud.selfservice.entity.resp.BaseWorkOrderDetailDto; +import com.hnkylin.cloud.selfservice.entity.resp.PageWorkOrderRespDto; + +public interface SelfWorkOrderService { + + /** + * 分页获取工单 + */ + PageData pageWorkOrder(WorkOrderPageParam workOrderPageParam, LoginUserVo loginUserVo); + + + /** + * 封装基础的工单详情 + */ + void formatBaseWorkOrderDetail(Integer workOrderId, BaseWorkOrderDetailDto baseWorkOrderDetailDto); +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/LoginUserCacheService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/LoginUserCacheService.java new file mode 100644 index 0000000000000000000000000000000000000000..b1c54f3b4ca2885ccaeb1b9c70831253f6874ce9 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/LoginUserCacheService.java @@ -0,0 +1,8 @@ +package com.hnkylin.cloud.selfservice.service.cache; + +import com.hnkylin.cloud.core.cache.RedisService; + + +public interface LoginUserCacheService extends RedisService { + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/McLeaderNodeCacheService.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/McLeaderNodeCacheService.java new file mode 100644 index 0000000000000000000000000000000000000000..4880cc3e59102a3e3ca88ba0168bf76d41d112d7 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/McLeaderNodeCacheService.java @@ -0,0 +1,11 @@ +package com.hnkylin.cloud.selfservice.service.cache; + +import com.hnkylin.cloud.core.cache.RedisService; + + +/** + * mc主节点缓存,记录切主后的mc主节点,避免频繁重试 + */ +public interface McLeaderNodeCacheService extends RedisService { + +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/impl/LoginUserCacheServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/impl/LoginUserCacheServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..fb8b72327011626ecf37aa086be90dfff215330d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/impl/LoginUserCacheServiceImpl.java @@ -0,0 +1,17 @@ +package com.hnkylin.cloud.selfservice.service.cache.impl; + +import com.hnkylin.cloud.core.cache.RedisServiceImpl; +import com.hnkylin.cloud.selfservice.constant.SelfServiceRedisConstant; +import com.hnkylin.cloud.selfservice.service.cache.LoginUserCacheService; +import org.springframework.stereotype.Service; + + +@Service +public class LoginUserCacheServiceImpl extends RedisServiceImpl implements LoginUserCacheService { + + + @Override + protected String initPrefixKey() { + return SelfServiceRedisConstant.SELF_SERVICE_LOGIN_USER_CACHE; + } +} \ No newline at end of file diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/impl/McLeaderNodeCacheServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/impl/McLeaderNodeCacheServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..297e2004d30d3701b272a827a06e823c5de0dc41 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/cache/impl/McLeaderNodeCacheServiceImpl.java @@ -0,0 +1,18 @@ +package com.hnkylin.cloud.selfservice.service.cache.impl; + +import com.hnkylin.cloud.core.cache.RedisServiceImpl; + +import com.hnkylin.cloud.selfservice.constant.SelfServiceRedisConstant; +import com.hnkylin.cloud.selfservice.service.cache.McLeaderNodeCacheService; +import org.springframework.stereotype.Service; + + +@Service +public class McLeaderNodeCacheServiceImpl extends RedisServiceImpl implements McLeaderNodeCacheService { + + + @Override + protected String initPrefixKey() { + return SelfServiceRedisConstant.MC_LEADER_NODE; + } +} \ No newline at end of file diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfDeptServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfDeptServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8e7bc773281138a55798c6a1dee96ca4afd827af --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfDeptServiceImpl.java @@ -0,0 +1,56 @@ +package com.hnkylin.cloud.selfservice.service.impl; + +import com.hnkylin.cloud.core.domain.CloudDeptDo; +import com.hnkylin.cloud.core.service.CloudDeptService; +import com.hnkylin.cloud.selfservice.entity.resp.DeptRespDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceDeptService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class SelfDeptServiceImpl implements SelfServiceDeptService { + + @Resource + private CloudDeptService cloudDeptService; + + @Override + public List queryDeptList() { + ArrayList list = new ArrayList<>(); + List deptDoList = cloudDeptService.queryAllDeptList(); + for (CloudDeptDo deptDo : deptDoList) { + if (Objects.equals(deptDo.getParentId(), 0)) { + list.add(createDeptRespDto(deptDo, deptDoList)); + } + } + return list; + } + + + /** + * 递归查找子菜单 + */ + private List getChild(Integer parentId, List allDeptList) { + List childList = new ArrayList<>(); + for (CloudDeptDo deptDo : allDeptList) { + if (Objects.equals(parentId, deptDo.getParentId())) { + DeptRespDto deptRespDto = createDeptRespDto(deptDo, allDeptList); + childList.add(deptRespDto); + } + } + return childList; + } + + + private DeptRespDto createDeptRespDto(CloudDeptDo cloudDeptDo, List allDeptList) { + DeptRespDto deptRespDto = new DeptRespDto(); + deptRespDto.setDeptId(cloudDeptDo.getId()); + deptRespDto.setDeptName(cloudDeptDo.getDeptName()); + deptRespDto.setParentId(cloudDeptDo.getParentId()); + deptRespDto.setChildDepts(getChild(cloudDeptDo.getId(), allDeptList)); + return deptRespDto; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfOrganizationServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfOrganizationServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b0d8fd49e751a2cf83e83b22c4a57548e3b3a91d --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfOrganizationServiceImpl.java @@ -0,0 +1,62 @@ +package com.hnkylin.cloud.selfservice.service.impl; + +import com.hnkylin.cloud.core.common.KylinCommonConstants; +import com.hnkylin.cloud.core.domain.CloudOrganizationDo; +import com.hnkylin.cloud.core.service.CloudOrganizationService; +import com.hnkylin.cloud.selfservice.entity.resp.OrganizationTreeDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceOrganizationService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class SelfOrganizationServiceImpl implements SelfServiceOrganizationService { + + @Resource + private CloudOrganizationService cloudOrganizationService; + + + @Override + public List queryOrganizationTree() { + ArrayList list = new ArrayList<>(); + List orgList = cloudOrganizationService.queryAllOrgList(); + + CloudOrganizationDo defaultTopOrg = cloudOrganizationService.getDefaultTopOrg(); + + for (CloudOrganizationDo orgDo : orgList) { + if (Objects.equals(orgDo.getParentId(), defaultTopOrg.getId())) { + list.add(createOrgTreeDto(orgDo, orgList)); + } + } + return list; + } + + + /** + * 递归查找子菜单 + */ + private List getChild(Integer parentId, List allOrgList) { + List childList = new ArrayList<>(); + for (CloudOrganizationDo organizationDo : allOrgList) { + if (Objects.equals(parentId, organizationDo.getParentId())) { + OrganizationTreeDto organizationDto = createOrgTreeDto(organizationDo, allOrgList); + childList.add(organizationDto); + } + } + return childList; + } + + + private OrganizationTreeDto createOrgTreeDto(CloudOrganizationDo cloudOrganizationDo, List + allOrgList) { + OrganizationTreeDto organizationDto = new OrganizationTreeDto(); + organizationDto.setOrganizationId(cloudOrganizationDo.getId()); + organizationDto.setOrganizationName(cloudOrganizationDo.getOrganizationName()); + organizationDto.setParentId(cloudOrganizationDo.getParentId()); + organizationDto.setChildren(getChild(cloudOrganizationDo.getId(), allOrgList)); + return organizationDto; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfServerVmServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfServerVmServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..187815c153e6d4e86b6d57eda3aa734a49a2f2b2 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfServerVmServiceImpl.java @@ -0,0 +1,1946 @@ +package com.hnkylin.cloud.selfservice.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.*; +import com.hnkylin.cloud.core.common.servervm.*; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.*; +import com.hnkylin.cloud.core.enums.*; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.selfservice.config.MCConfigProperties; +import com.hnkylin.cloud.selfservice.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.selfservice.constant.KylinSelfConstants; +import com.hnkylin.cloud.core.enums.McStartVmErrorCode; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.mc.req.*; +import com.hnkylin.cloud.selfservice.entity.mc.resp.*; +import com.hnkylin.cloud.selfservice.entity.req.*; +import com.hnkylin.cloud.selfservice.entity.resp.*; +import com.hnkylin.cloud.selfservice.service.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class SelfServerVmServiceImpl implements SelfServerVmService { + + + @Resource + private CloudWorkOrderService workOrderService; + + @Resource + private CloudWorkOrderServerVmService cloudWorkOrderServerVmService; + + @Resource + private CloudWorkOrderModifyServerVmService cloudWorkOrderModifyServerVmService; + + @Resource + private CloudWorkOrderServerVmDiskService cloudWorkOrderServerVmDiskService; + + @Resource + private CloudWorkOrderServerVmNetworkService cloudWorkOrderServerVmNetworkService; + + + @Resource + private SelfWorkOrderService selfWorkOrderService; + + @Resource + private CloudWorkOrderDeferredMachineService deferredMachineService; + + @Resource + private CloudUserMachineService cloudUserMachineService; + + @Resource + private McHttpService mcHttpService; + + @Resource + private MCConfigProperties mcConfigProperties; + + @Resource + private McNodeService mcNodeService; + + @Resource + private CloudWorkOrderServerVmIsoService cloudWorkOrderServerVmIsoService; + + @Resource + private CloudClusterService cloudClusterService; + + @Resource + private McClusterThreadService mcClusterThreadService; + + + @Override + public PageData listServerVmTemplate(SearchTemplateParam searchTemplateParam, + LoginUserVo loginUserVo) { + PageTemplateReq pageTemplateReq = new PageTemplateReq(); + pageTemplateReq.setPage(searchTemplateParam.getPageNo()); + pageTemplateReq.setRows(searchTemplateParam.getPageSize()); + pageTemplateReq.setSearchKey(searchTemplateParam.getSearchKey()); + + List clusterDoList = cloudClusterService.clusterListByUserId(loginUserVo.getUserId()); + if (clusterDoList.isEmpty()) { + return new PageData(null); + } + if (Objects.equals(clusterDoList.size(), 1)) { + return singleClusterMcTemplate(clusterDoList.get(0), loginUserVo, searchTemplateParam, pageTemplateReq); + } + return manyClusterMcTemplate(clusterDoList, loginUserVo, searchTemplateParam); + } + + + /** + * 单集群中获取mc模板列表 + * + * @param clusterDo + * @param loginUserVo + * @param searchTemplateParam + * @param pageTemplateReq + * @return + */ + private PageData singleClusterMcTemplate(CloudClusterDo clusterDo, LoginUserVo loginUserVo, + SearchTemplateParam searchTemplateParam, + PageTemplateReq pageTemplateReq) { + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterDo.getId(), + pageTemplateReq, mcConfigProperties.getTemplateListUrl(), loginUserVo.getUserName(), 0); + + List templateList = new ArrayList<>(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String templateListStr = JSON.toJSONString(mcResponse.getData()); + McPageResp templatePage = JSONObject.parseObject(templateListStr, new + TypeReference>() { + }); + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(searchTemplateParam.getPageNo()); + mcPageInfo.setPageSize(templatePage.getRows().size()); + mcPageInfo.setRecords(templatePage.getRecords()); + mcPageInfo.setTotal(templatePage.getTotal()); + + templatePage.getRows().forEach(dto -> { + + templateList.add(createTemplateRespDto(dto, clusterDo)); + }); + return new PageData(mcPageInfo, templateList); + } + return new PageData(null); + } + + private PageData manyClusterMcTemplate(List clusterDoList, + LoginUserVo loginUserVo, + SearchTemplateParam searchTemplateParam) { + + List clusterIdList = clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()); + + List mcRequestObjectList = new ArrayList<>(); + clusterIdList.forEach(clusterId -> { + PageTemplateReq pageTemplateReq = new PageTemplateReq(); + pageTemplateReq.setPage(KylinCommonConstants.FIRST_PAGE); + pageTemplateReq.setRows(KylinCommonConstants.DEFAULT_MAX_SIZE); + pageTemplateReq.setSearchKey(searchTemplateParam.getSearchKey()); + mcRequestObjectList.add(pageTemplateReq); + }); + + List mcServerVmList = mcClusterThreadService.threadGetMcResponse(clusterIdList, + loginUserVo.getUserName(), + mcConfigProperties.getTemplateListUrl(), mcRequestObjectList); + + //满足条件的所有模板 + List totalTemplateList = new ArrayList<>(); + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(searchTemplateParam.getPageNo()); + for (int i = 0; i < clusterIdList.size(); i++) { + CloudClusterDo clusterDo = clusterDoList.get(i); + String templateListStr = mcServerVmList.get(i); + if (Objects.nonNull(templateListStr)) { + McPageResp templatePage = JSONObject.parseObject(templateListStr, new + TypeReference>() { + }); + templatePage.getRows().forEach(template -> { + totalTemplateList.add(createTemplateRespDto(template, clusterDo)); + }); + } + } + mcPageInfo.setTotal(mcPageInfo.getRecords()); + mcPageInfo.setRecords(totalTemplateList.size()); + //总页数 + int totalPage = (mcPageInfo.getRecords() - 1) / searchTemplateParam.getPageSize() + 1; + mcPageInfo.setTotal(totalPage); + + //从所有模板列表中截取对应数量的模板 + int totalSize = totalTemplateList.size(); + int subListStart = (searchTemplateParam.getPageNo() - 1) * searchTemplateParam.getPageSize(); + int subListEnd = searchTemplateParam.getPageNo() * searchTemplateParam.getPageSize(); + if (totalSize < subListStart) { + return new PageData(null); + } else if (totalSize >= subListStart && totalSize < subListEnd) { + mcPageInfo.setPageSize(totalSize - subListStart); + return new PageData(mcPageInfo, totalTemplateList.subList(subListStart, totalSize)); + } else { + mcPageInfo.setPageSize(searchTemplateParam.getPageSize()); + return new PageData(mcPageInfo, totalTemplateList.subList(subListStart, subListEnd)); + } + } + + + /** + * 创建mc模板实体 + * + * @param mcTemplate + * @param clusterDo + * @return + */ + private ServerVmTemplateRespDto createTemplateRespDto(McTemplateListResp mcTemplate, CloudClusterDo clusterDo) { + ServerVmTemplateRespDto serverVmTemplateRespDto = + ServerVmTemplateRespDto.builder().templateId(mcTemplate.getId()).architecture(mcTemplate + .getArchitecture()).systemType(mcTemplate.getSystemType()).description(mcTemplate.getDescription()) + .cpu(mcTemplate.getCpu()).mem(mcTemplate.getMem()) + .templateName(mcTemplate.getName()).osMachine(mcTemplate.getOperatingSystem()).build(); + + //内存统一转成GB + Integer mem = mcTemplate.getMem(); + if (Objects.equals(mcTemplate.getMemUnit(), MemUnit.MB)) { + mem = mcTemplate.getMem() / 1024; + } + serverVmTemplateRespDto.setMem(mem); + List networks = new ArrayList<>(); + if (Objects.nonNull(mcTemplate.getInterfacesList()) && !mcTemplate.getInterfacesList().isEmpty()) { + + mcTemplate.getInterfacesList().forEach(network -> { + ServerVmNetworkDto serverVmNetworkDto = new ServerVmNetworkDto(); + serverVmNetworkDto.setPurpose(formatNetworkStr(network.getInterfaceType() + , network.getPortGroup(), network.getVirtualSwitch())); + serverVmNetworkDto.setInterfaceId(network.getId()); + // 拼接成 网络类型(Bridge) 交换机(TPlinksafg)端口组(102) + networks.add(serverVmNetworkDto); + + }); + } + serverVmTemplateRespDto.setNetworks(networks); + List diskSizeList = new ArrayList<>(); + List disks = new ArrayList(); + if (Objects.nonNull(mcTemplate.getDisks()) && !mcTemplate.getDisks().isEmpty()) { + mcTemplate.getDisks().forEach(diskResp -> { + ServerVmDiskDto serverVmDiskDto = new ServerVmDiskDto(); + serverVmDiskDto.setDiskSize(diskResp.getSize()); + serverVmDiskDto.setDiskId(diskResp.getId()); + disks.add(serverVmDiskDto); + diskSizeList.add(diskResp.getSize().toString()); + }); + } + String diskInfo = String.join(",", diskSizeList); + serverVmTemplateRespDto.setDiskInfo(diskInfo); + serverVmTemplateRespDto.setDisks(disks); + serverVmTemplateRespDto.setClusterId(clusterDo.getId()); + serverVmTemplateRespDto.setClusterName(clusterDo.getName()); + serverVmTemplateRespDto.setClusterRemark(clusterDo.getRemark()); + return serverVmTemplateRespDto; + } + + @Override + public List isoList(LoginUserVo loginUserVo) { + List isoList = new ArrayList<>(); + + + List clusterDoList = cloudClusterService.clusterListByUserId(loginUserVo.getUserId()); + + if (clusterDoList.isEmpty()) { + return new ArrayList<>(); + } + if (Objects.equals(clusterDoList.size(), 1)) { + return singleClusterIso(clusterDoList.get(0), loginUserVo); + } else { + return manyClusterIso(clusterDoList, loginUserVo); + } + } + + /** + * 从但集群中获取ISO + * + * @param clusterDo + * @param loginUserVo + * @return + */ + private List singleClusterIso(CloudClusterDo clusterDo, LoginUserVo loginUserVo) { + List isoList = new ArrayList<>(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterDo.getId(), null, + mcConfigProperties.getIsoListUrl(), loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + List list = (List) mcResponse.getData(); + list.forEach(iso -> { + isoList.add(createMcIso(iso, clusterDo)); + }); + } + return isoList; + } + + /** + * 创建mciso实体对象 + * + * @param isoFile + * @param clusterDo + * @return + */ + private IsoRespDto createMcIso(String isoFile, CloudClusterDo clusterDo) { + IsoRespDto iso = new IsoRespDto(); + iso.setIsoFile(isoFile); + iso.setClusterId(clusterDo.getId()); + iso.setClusterName(clusterDo.getName()); + iso.setClusterRemark(clusterDo.getRemark()); + return iso; + } + + /** + * 从多集群中获取iso + * + * @param clusterDoList + * @param loginUserVo + */ + private List manyClusterIso(List clusterDoList, LoginUserVo loginUserVo) { + + List clusterIdList = clusterDoList.stream().map(CloudClusterDo::getId).collect(Collectors.toList()); + List> mcServerVmList = mcClusterThreadService.threadSendToMc(clusterIdList, + loginUserVo.getUserName(), + mcConfigProperties.getIsoListUrl(), new ArrayList<>()); + + List isoList = new ArrayList<>(); + for (int i = 0; i < clusterIdList.size(); i++) { + CloudClusterDo clusterDo = clusterDoList.get(i); + MCResponseData responseData = mcServerVmList.get(i); + if (Objects.nonNull(responseData)) { + List list = (List) responseData.getData(); + list.forEach(iso -> { + isoList.add(createMcIso(iso, clusterDo)); + }); + } + } + return isoList; + } + + @Override + @Transactional + public void applyServerVm(ApplyServerVmParam applyServerVmParam, LoginUserVo loginUserVo) { + Date now = new Date(); + //插入申请工单 + CloudWorkOrderDo cloudWorkOrderDo = new CloudWorkOrderDo(); + cloudWorkOrderDo.setUserId(loginUserVo.getUserId()); + cloudWorkOrderDo.setTarget(applyServerVmParam.getServervmName()); + cloudWorkOrderDo.setStatus(WorkOrderStatus.WAIT_CHECK); + cloudWorkOrderDo.setType(WorkOrderType.APPLY_SERVERVM); + cloudWorkOrderDo.setCreateTime(now); + cloudWorkOrderDo.setApplyReason(applyServerVmParam.getApplyReason()); + cloudWorkOrderDo.setCreateBy(loginUserVo.getUserId()); + workOrderService.save(cloudWorkOrderDo); + + //插入申请虚拟机详情 + CloudWorkOrderServerVmDo cloudWorkOrderServerVmDo = new CloudWorkOrderServerVmDo(); + cloudWorkOrderServerVmDo.setWorkOrderId(cloudWorkOrderDo.getId()); + cloudWorkOrderServerVmDo.setApplyServervmType(applyServerVmParam.getApplyServerVmType()); + cloudWorkOrderServerVmDo.setServervmName(applyServerVmParam.getServervmName()); + cloudWorkOrderServerVmDo.setApplyNum(applyServerVmParam.getApplyNum()); + cloudWorkOrderServerVmDo.setUseMonth(applyServerVmParam.getUseMonth()); + cloudWorkOrderServerVmDo.setDeadlineType(applyServerVmParam.getDeadlineType()); + cloudWorkOrderServerVmDo.setTemplateId(applyServerVmParam.getTemplateId()); + cloudWorkOrderServerVmDo.setOsMachine(applyServerVmParam.getOsMachine()); + cloudWorkOrderServerVmDo.setArchitecture(applyServerVmParam.getArchitecture()); + cloudWorkOrderServerVmDo.setSystemType(applyServerVmParam.getSystemType()); + cloudWorkOrderServerVmDo.setCpu(applyServerVmParam.getCpu()); + cloudWorkOrderServerVmDo.setMem(applyServerVmParam.getMem()); + cloudWorkOrderServerVmDo.setMemUnit(MemUnit.GB); + cloudWorkOrderServerVmDo.setCreateBy(loginUserVo.getUserId()); + cloudWorkOrderServerVmDo.setCreateTime(now); + cloudWorkOrderServerVmDo.setDescription(applyServerVmParam.getDescription()); + cloudWorkOrderServerVmDo.setClusterId(applyServerVmParam.getClusterId()); + cloudWorkOrderServerVmService.save(cloudWorkOrderServerVmDo); + + //磁盘和网卡信息入库 + insertDiskAndNetwork(applyServerVmParam, cloudWorkOrderDo.getId(), loginUserVo.getUserId()); + + //Iso处理 + List isoDoList = new ArrayList<>(); + if (Objects.nonNull(applyServerVmParam.getIsoList()) && !applyServerVmParam.getIsoList().isEmpty()) { + applyServerVmParam.getIsoList().stream().forEach(iso -> { + CloudWorkOrderServerVmIsoDo isoDo = new CloudWorkOrderServerVmIsoDo(); + isoDo.setIsoFile(iso); + isoDo.setWorkOrderId(cloudWorkOrderDo.getId()); + isoDo.setModifyType(ModifyType.NONE); + isoDo.setCreateBy(loginUserVo.getUserId()); + isoDo.setCreateTime(now); + isoDo.setOldIsoFile(iso); + isoDoList.add(isoDo); + }); + cloudWorkOrderServerVmIsoService.saveBatch(isoDoList); + } + } + + + /** + * 磁盘和网卡信息入库处理, + * diskList 磁盘信息 + * networkList 网卡信息 + * networkList 工单ID + * loginUserId 登陆者 + */ + private void insertDiskAndNetwork(ApplyServerVmParam applyServerVmParam, Integer workOrderId, Integer loginUserId) { + Date now = new Date(); + //插入硬盘信息 + List diskList = applyServerVmParam.getDiskList(); + if (Objects.nonNull(diskList) && diskList.size() > 0) { + List diskDoList = new ArrayList<>(); + diskList.forEach(dto -> { + CloudWorkOrderServerVmDiskDo cloudWorkOrderServerVmDiskDo = new CloudWorkOrderServerVmDiskDo(); + cloudWorkOrderServerVmDiskDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmDiskDo.setDiskSize(dto.getDiskSize()); + cloudWorkOrderServerVmDiskDo.setPurpose(dto.getPurpose()); + cloudWorkOrderServerVmDiskDo.setType(dto.getType()); + cloudWorkOrderServerVmDiskDo.setCreateBy(loginUserId); + cloudWorkOrderServerVmDiskDo.setCreateTime(now); + cloudWorkOrderServerVmDiskDo.setDiskId(dto.getDiskId()); + cloudWorkOrderServerVmDiskDo.setModifyType((dto.getDiskId() > 0) ? ModifyType.NONE : ModifyType.ADD); + cloudWorkOrderServerVmDiskDo.setOldDiskSize(dto.getDiskSize()); + diskDoList.add(cloudWorkOrderServerVmDiskDo); + }); + cloudWorkOrderServerVmDiskService.saveBatch(diskDoList); + } + List networkList = applyServerVmParam.getNetworkList(); + //网卡信息 + if (Objects.nonNull(networkList) && networkList.size() > 0) { + List cloudWorkOrderServerVmNetworkDos = new ArrayList<>(); + networkList.forEach(network -> { + CloudWorkOrderServerVmNetworkDo cloudWorkOrderServerVmNetworkDo = new CloudWorkOrderServerVmNetworkDo(); + cloudWorkOrderServerVmNetworkDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmNetworkDo.setPurpose(network.getPurpose()); + cloudWorkOrderServerVmNetworkDo.setType(network.getType()); + cloudWorkOrderServerVmNetworkDo.setCreateBy(loginUserId); + cloudWorkOrderServerVmNetworkDo.setCreateTime(now); + cloudWorkOrderServerVmNetworkDo.setInterfaceId(network.getInterfaceId()); + cloudWorkOrderServerVmNetworkDo.setModifyType((network.getInterfaceId() > 0) ? ModifyType.NONE : + ModifyType.ADD); + cloudWorkOrderServerVmNetworkDos.add(cloudWorkOrderServerVmNetworkDo); + }); + cloudWorkOrderServerVmNetworkService.saveBatch(cloudWorkOrderServerVmNetworkDos); + } + } + + @Override + @Transactional + public void modifyServerVm(ModifyServerVmParam modifyServerVmParam, LoginUserVo loginUserVo) { + + + //如果只是修改了名称,直接调用mc接口进行修改名称,不用新建一个工单 + if (modifyServerVmParam.getOnlyModifyName()) { + UpdateServerVmNameParam updateServerVmNameParam = new UpdateServerVmNameParam(); + updateServerVmNameParam.setAliasName(modifyServerVmParam.getServervmName()); + updateServerVmNameParam.setUuid(modifyServerVmParam.getMachineUuid()); + updateMachineName(updateServerVmNameParam, loginUserVo); + return; + } + + Date now = new Date(); + //插入申请工单 + CloudWorkOrderDo cloudWorkOrderDo = new CloudWorkOrderDo(); + cloudWorkOrderDo.setUserId(loginUserVo.getUserId()); + cloudWorkOrderDo.setTarget(modifyServerVmParam.getServervmName()); + cloudWorkOrderDo.setStatus(WorkOrderStatus.WAIT_CHECK); + cloudWorkOrderDo.setType(WorkOrderType.MODIFY_SERVERVM); + cloudWorkOrderDo.setCreateTime(now); + cloudWorkOrderDo.setApplyReason(modifyServerVmParam.getApplyReason()); + cloudWorkOrderDo.setCreateBy(loginUserVo.getUserId()); + workOrderService.save(cloudWorkOrderDo); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(modifyServerVmParam.getMachineUuid(), + loginUserVo.getUserId()); + + //插入变更云服务器详情 + CloudWorkOrderModifyServerVmDo cloudWorkOrderModifyServerVmDo = new CloudWorkOrderModifyServerVmDo(); + cloudWorkOrderModifyServerVmDo.setMachineUuid(modifyServerVmParam.getMachineUuid()); + cloudWorkOrderModifyServerVmDo.setWorkOrderId(cloudWorkOrderDo.getId()); + cloudWorkOrderModifyServerVmDo.setServervmName(modifyServerVmParam.getServervmName()); + cloudWorkOrderModifyServerVmDo.setDeadlineType(modifyServerVmParam.getDeadlineType()); + cloudWorkOrderModifyServerVmDo.setOsMachine(modifyServerVmParam.getOsMachine()); + cloudWorkOrderModifyServerVmDo.setArchitecture(modifyServerVmParam.getArchitecture()); + cloudWorkOrderModifyServerVmDo.setSystemType(modifyServerVmParam.getSystemType()); + cloudWorkOrderModifyServerVmDo.setCpu(modifyServerVmParam.getCpu()); + cloudWorkOrderModifyServerVmDo.setOriginalCpu(modifyServerVmParam.getOriginalCpu()); + cloudWorkOrderModifyServerVmDo.setMem(modifyServerVmParam.getMem()); + cloudWorkOrderModifyServerVmDo.setOriginalMem(modifyServerVmParam.getOriginalMem()); + cloudWorkOrderModifyServerVmDo.setMemUnit(modifyServerVmParam.getMemUnit()); + cloudWorkOrderModifyServerVmDo.setDeadlineTime(userMachineDo.getDeadlineTime()); + if (modifyServerVmParam.isAddDeadTimeChecked()) { + //获取新添加过期时间 + Integer addNewDeadTime = Objects.equals(modifyServerVmParam.getAddNewDeadTimeUnit(), "YEAR") ? + 12 * modifyServerVmParam.getAddNewDeadTime() : modifyServerVmParam.getAddNewDeadTime(); + cloudWorkOrderModifyServerVmDo.setDeadlineTime(DateUtils.getMonthAfter(userMachineDo.getDeadlineTime(), + addNewDeadTime)); + } + + cloudWorkOrderModifyServerVmDo.setCreateBy(loginUserVo.getUserId()); + cloudWorkOrderModifyServerVmDo.setCreateTime(now); + cloudWorkOrderModifyServerVmService.save(cloudWorkOrderModifyServerVmDo); + + modifyDiskAndNetwork(modifyServerVmParam, cloudWorkOrderDo.getId(), loginUserVo.getUserId()); + + } + + /** + * 磁盘和网卡信息入库处理, + * diskList 磁盘信息 + * networkList 网卡信息 + * networkList 工单ID + * loginUserId 登陆者 + * addApply 是否是申请云服务器 + */ + private void modifyDiskAndNetwork(ModifyServerVmParam modifyServerVmParam, Integer workOrderId, + Integer loginUserId) { + Date now = new Date(); + //插入硬盘信息 + List diskList = modifyServerVmParam.getDiskList(); + List oldDiskList = modifyServerVmParam.getOldDiskList(); + List diskDoList = new ArrayList<>(); + oldDiskList.forEach(oldDisk -> { + //用原来的磁盘和新变动的磁盘进行对比 + ServerVmDiskParam diskParam = diskList.stream().filter(disk -> Objects.equals(oldDisk.getDiskId(), + disk.getDiskId())).findFirst().orElse(null); + boolean deleteFlag = Objects.isNull(diskParam); + CloudWorkOrderServerVmDiskDo cloudWorkOrderServerVmDiskDo = new CloudWorkOrderServerVmDiskDo(); + cloudWorkOrderServerVmDiskDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmDiskDo.setDiskSize(deleteFlag ? oldDisk.getDiskSize() : diskParam.getDiskSize()); + cloudWorkOrderServerVmDiskDo.setPurpose(deleteFlag ? null : diskParam.getPurpose()); + cloudWorkOrderServerVmDiskDo.setType(ApplyMcServerVmType.original); + cloudWorkOrderServerVmDiskDo.setCreateBy(loginUserId); + cloudWorkOrderServerVmDiskDo.setCreateTime(now); + cloudWorkOrderServerVmDiskDo.setDiskId(oldDisk.getDiskId()); + ModifyType modifyType = deleteFlag ? ModifyType.DELETE : + Objects.equals(oldDisk.getDiskSize(), diskParam.getDiskSize()) ? ModifyType.NONE : + ModifyType.MODIFY; + cloudWorkOrderServerVmDiskDo.setModifyType(modifyType); + cloudWorkOrderServerVmDiskDo.setOldDiskSize(oldDisk.getDiskSize()); + diskDoList.add(cloudWorkOrderServerVmDiskDo); + }); + if (Objects.nonNull(diskList) && diskList.size() > 0) { + diskList.forEach(dto -> { + if (Objects.equals(dto.getDiskId(), 0L)) { + //新增的磁盘 + CloudWorkOrderServerVmDiskDo cloudWorkOrderServerVmDiskDo = new CloudWorkOrderServerVmDiskDo(); + cloudWorkOrderServerVmDiskDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmDiskDo.setDiskSize(dto.getDiskSize()); + cloudWorkOrderServerVmDiskDo.setPurpose(dto.getPurpose()); + cloudWorkOrderServerVmDiskDo.setType(ApplyMcServerVmType.custom); + cloudWorkOrderServerVmDiskDo.setCreateBy(loginUserId); + cloudWorkOrderServerVmDiskDo.setCreateTime(now); + cloudWorkOrderServerVmDiskDo.setDiskId(dto.getDiskId()); + cloudWorkOrderServerVmDiskDo.setModifyType(ModifyType.ADD); + cloudWorkOrderServerVmDiskDo.setOldDiskSize(dto.getDiskSize()); + cloudWorkOrderServerVmDiskDo.setDiskId(0L); + diskDoList.add(cloudWorkOrderServerVmDiskDo); + } + }); + } + if (!diskDoList.isEmpty()) { + cloudWorkOrderServerVmDiskService.saveBatch(diskDoList); + } + + //网卡信息 + List networkList = modifyServerVmParam.getNetworkList(); + List oldNetworkList = modifyServerVmParam.getOldNetworkList(); + List cloudWorkOrderServerVmNetworkDos = new ArrayList<>(); + oldNetworkList.forEach(oldNetWork -> { + //用原来的网卡ID和变动后提交的网卡ID进行对比 + ServerVmNetworkParam serverVmNetworkParam = + networkList.stream().filter(network -> Objects.equals(oldNetWork.getInterfaceId(), + network.getInterfaceId())).findFirst().orElse(null); + boolean deleteFlag = Objects.isNull(serverVmNetworkParam); + + CloudWorkOrderServerVmNetworkDo cloudWorkOrderServerVmNetworkDo = new CloudWorkOrderServerVmNetworkDo(); + cloudWorkOrderServerVmNetworkDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmNetworkDo.setPurpose(deleteFlag ? oldNetWork.getPurpose() : + serverVmNetworkParam.getPurpose()); + cloudWorkOrderServerVmNetworkDo.setType(ApplyMcServerVmType.original); + cloudWorkOrderServerVmNetworkDo.setCreateBy(loginUserId); + cloudWorkOrderServerVmNetworkDo.setCreateTime(now); + cloudWorkOrderServerVmNetworkDo.setInterfaceId(oldNetWork.getInterfaceId()); + cloudWorkOrderServerVmNetworkDo.setModifyType(deleteFlag ? ModifyType.DELETE : ModifyType.NONE); + cloudWorkOrderServerVmNetworkDos.add(cloudWorkOrderServerVmNetworkDo); + }); + if (Objects.nonNull(networkList) && networkList.size() > 0) { + networkList.forEach(network -> { + if (Objects.equals(network.getInterfaceId(), 0L)) { + //新增的磁盘 + CloudWorkOrderServerVmNetworkDo cloudWorkOrderServerVmNetworkDo = + new CloudWorkOrderServerVmNetworkDo(); + cloudWorkOrderServerVmNetworkDo.setWorkOrderId(workOrderId); + cloudWorkOrderServerVmNetworkDo.setPurpose(network.getPurpose()); + cloudWorkOrderServerVmNetworkDo.setType(ApplyMcServerVmType.custom); + cloudWorkOrderServerVmNetworkDo.setCreateBy(loginUserId); + cloudWorkOrderServerVmNetworkDo.setCreateTime(now); + cloudWorkOrderServerVmNetworkDo.setInterfaceId(network.getInterfaceId()); + cloudWorkOrderServerVmNetworkDo.setModifyType(ModifyType.ADD); + cloudWorkOrderServerVmNetworkDos.add(cloudWorkOrderServerVmNetworkDo); + } + + }); + } + if (!cloudWorkOrderServerVmNetworkDos.isEmpty()) { + cloudWorkOrderServerVmNetworkService.saveBatch(cloudWorkOrderServerVmNetworkDos); + } + + } + + @Override + public ServerVmDetailRespDto getServerVmDetail(ServerVmBaseParam serverVmPageParam, LoginUserVo loginUserVo) { + + ServerVmDetailRespDto serverVmDetailRespDto = new ServerVmDetailRespDto(); + + McServerVmInfoResp serverVmInfo = serverVmInfo(serverVmPageParam, loginUserVo); + + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmPageParam.getServerVmUuid(), + loginUserVo.getUserId()); + + if (Objects.nonNull(userMachineDo)) { + serverVmDetailRespDto.setDeadlineType(userMachineDo.getDeadlineType()); + serverVmDetailRespDto.setDeadlineTime(DateUtils.format(userMachineDo.getDeadlineTime(), + DateUtils.DATE_YYYY_MM_DD)); + } + + if (Objects.nonNull(serverVmInfo)) { + + if (Objects.nonNull(serverVmInfo.getMachineInfo())) { + serverVmDetailRespDto.setStatus(serverVmInfo.getMachineInfo().getStatus()); + serverVmDetailRespDto.setOsMachine(serverVmInfo.getMachineInfo().getOsName()); + serverVmDetailRespDto.setArchitecture(serverVmInfo.getMachineInfo().getArchitecture()); + serverVmDetailRespDto.setSystemType(serverVmInfo.getMachineInfo().getSystemType()); + serverVmDetailRespDto.setAliasName(serverVmInfo.getMachineInfo().getAlisname()); + } + if (Objects.nonNull(serverVmInfo.getDeviceInfo())) { + serverVmDetailRespDto.setCpu(serverVmInfo.getDeviceInfo().getCpu().getCpus()); + serverVmDetailRespDto.setMem(serverVmInfo.getDeviceInfo().getMemory().getMemoryTotal()); + serverVmDetailRespDto.setMemUnit(MemUnit.GB); + + } + + if (Objects.nonNull(serverVmInfo.getDeviceInfo().getDisks()) && !serverVmInfo.getDeviceInfo().getDisks().isEmpty()) { + List disks = new ArrayList<>(); + serverVmInfo.getDeviceInfo().getDisks().forEach(disk -> { + ServerVmDiskDto serverVmDiskDto = new ServerVmDiskDto(); + serverVmDiskDto.setDiskSize(disk.getTotal()); + serverVmDiskDto.setDiskId(disk.getId()); + disks.add(serverVmDiskDto); + }); + serverVmDetailRespDto.setDisks(disks); + + } + + if (Objects.nonNull(serverVmInfo.getDeviceInfo().getInterfaces()) && !serverVmInfo.getDeviceInfo().getInterfaces().isEmpty()) { + List networks = new ArrayList<>(); + serverVmInfo.getDeviceInfo().getInterfaces().forEach(network -> { + + ServerVmNetworkDto serverVmNetworkDto = new ServerVmNetworkDto(); + serverVmNetworkDto.setPurpose(formatNetworkStr(network.getInterfaceType() + , network.getPortGroup(), network.getVirtualSwitch())); + serverVmNetworkDto.setInterfaceId(network.getId()); + networks.add(serverVmNetworkDto); + }); + serverVmDetailRespDto.setNetworks(networks); + + } + + } + return serverVmDetailRespDto; + } + + /* + * 封装网络信息 + * 如 网络类型(Bridge) 交换机(TPlinksafg)端口组(102) + */ + private String formatNetworkStr(String interfaceType, String portGroup, String virtualSwitch) { + StringBuilder purposeSb = new StringBuilder(); + + purposeSb.append(KylinSelfConstants.NETWORK_TYPE).append(KylinSelfConstants.LEFT_BRACKET) + .append(interfaceType).append(KylinSelfConstants.RIGHT_BRACKET) + .append(KylinSelfConstants.SPACE); + + purposeSb.append(KylinSelfConstants.NETWORK_SWITCH).append(KylinSelfConstants + .LEFT_BRACKET).append(virtualSwitch) + .append(KylinSelfConstants.RIGHT_BRACKET).append(KylinSelfConstants.SPACE); + + purposeSb.append(KylinSelfConstants.NETWORK_PORT).append(KylinSelfConstants.LEFT_BRACKET) + .append(portGroup).append(KylinSelfConstants.RIGHT_BRACKET); + + return purposeSb.toString(); + } + + @Override + public ApplyServerVmDetailRespDto getApplyServerVmDetailByWorkOrderId(Integer workOrderId, + LoginUserVo loginUserVo) { + ApplyServerVmDetailRespDto applyServerVmDetailRespDto = new ApplyServerVmDetailRespDto(); + + selfWorkOrderService.formatBaseWorkOrderDetail(workOrderId, applyServerVmDetailRespDto); + + CloudWorkOrderDo cloudWorkOrderDo = workOrderService.getById(workOrderId); + + //查询服务器申请详情表 + CloudWorkOrderServerVmDo queryServerVmDo = new CloudWorkOrderServerVmDo(); + queryServerVmDo.setWorkOrderId(workOrderId); + QueryWrapper wrapper = new QueryWrapper<>(queryServerVmDo); + CloudWorkOrderServerVmDo serverVmDo = cloudWorkOrderServerVmService.getOne(wrapper); + if (Objects.nonNull(serverVmDo)) { + applyServerVmDetailRespDto.setApplyServerVmType(serverVmDo.getApplyServervmType()); + applyServerVmDetailRespDto.setApplyNum(serverVmDo.getApplyNum()); + applyServerVmDetailRespDto.setIfModifyApplyNum(false); + applyServerVmDetailRespDto.setModifyApplyNum(serverVmDo.getModifyApplyNum()); + + applyServerVmDetailRespDto.setUseMonth(serverVmDo.getUseMonth()); + applyServerVmDetailRespDto.setDeadlineType(serverVmDo.getDeadlineType()); + applyServerVmDetailRespDto.setDeadlineTypeDesc(serverVmDo.getDeadlineType().getDesc()); + applyServerVmDetailRespDto.setOsMachine(serverVmDo.getOsMachine()); + applyServerVmDetailRespDto.setArchitecture(serverVmDo.getArchitecture()); + applyServerVmDetailRespDto.setCpu(serverVmDo.getCpu()); + applyServerVmDetailRespDto.setModifyCpu(serverVmDo.getModifyCpu()); + applyServerVmDetailRespDto.setIfModifyCpu(false); + applyServerVmDetailRespDto.setMem(serverVmDo.getMem()); + applyServerVmDetailRespDto.setModifyMem(serverVmDo.getModifyMem()); + applyServerVmDetailRespDto.setIfModifyMem(false); + applyServerVmDetailRespDto.setDescription(serverVmDo.getDescription()); + + applyServerVmDetailRespDto.setClusterName(cloudClusterService.getById(serverVmDo.getClusterId()).getName()); + + if (Objects.equals(cloudWorkOrderDo.getStatus(), WorkOrderStatus.CHECK_PASS)) { + if (!Objects.equals(serverVmDo.getCpu(), serverVmDo.getModifyCpu())) { + applyServerVmDetailRespDto.setIfModifyCpu(true); + } + if (!Objects.equals(serverVmDo.getMem(), serverVmDo.getModifyMem())) { + applyServerVmDetailRespDto.setIfModifyMem(true); + } + if (!Objects.equals(serverVmDo.getApplyNum(), serverVmDo.getModifyApplyNum())) { + applyServerVmDetailRespDto.setIfModifyApplyNum(true); + } + } + + applyServerVmDetailRespDto.setMenUtil(serverVmDo.getMemUnit()); + //查询硬盘信息 + CloudWorkOrderServerVmDiskDo queryDiskDo = new CloudWorkOrderServerVmDiskDo(); + queryDiskDo.setWorkOrderId(workOrderId); + QueryWrapper diskQueryWrapper = new QueryWrapper<>(queryDiskDo); + List diskDoList = cloudWorkOrderServerVmDiskService.list(diskQueryWrapper); + List disks = new ArrayList<>(); + if (diskDoList.size() > 0) { + diskDoList.forEach(disk -> { + ServerVmDiskDto diskDto = new ServerVmDiskDto(); + diskDto.setDiskSize(disk.getDiskSize()); + diskDto.setPurpose(disk.getPurpose()); + diskDto.setOldDiskSize(disk.getOldDiskSize()); + diskDto.setModifyType(disk.getModifyType()); + disks.add(diskDto); + }); + } + applyServerVmDetailRespDto.setDisks(disks); + + //查询网卡信息 + CloudWorkOrderServerVmNetworkDo queryNetworkDo = new CloudWorkOrderServerVmNetworkDo(); + queryNetworkDo.setWorkOrderId(workOrderId); + QueryWrapper networkQueryWrapper = new QueryWrapper<>(queryNetworkDo); + List networkDoList = + cloudWorkOrderServerVmNetworkService.list(networkQueryWrapper); + List networks = new ArrayList<>(); + networkDoList.forEach(network -> { + ServerVmNetworkDto serverVmNetworkDto = new ServerVmNetworkDto(); + serverVmNetworkDto.setPurpose(network.getPurpose()); + serverVmNetworkDto.setModifyType(network.getModifyType()); + serverVmNetworkDto.setIpBindMac(network.getIpBindMac()); + serverVmNetworkDto.setManualSetIp(network.getManualSetIp()); + serverVmNetworkDto.setAutomaticAcqIp(network.getAutomaticAcqIp()); + serverVmNetworkDto.setIp(network.getIp()); + serverVmNetworkDto.setMask(network.getMask()); + serverVmNetworkDto.setGw(network.getGw()); + serverVmNetworkDto.setDns1(network.getDns1()); + serverVmNetworkDto.setDns2(network.getDns2()); + boolean setIpInfo = network.getIpBindMac() || network.getManualSetIp() || network.getAutomaticAcqIp(); + serverVmNetworkDto.setSetIpInfo(setIpInfo); + networks.add(serverVmNetworkDto); + }); + applyServerVmDetailRespDto.setNetworks(networks); + + //光驱信息 + CloudWorkOrderServerVmIsoDo queryIsoDo = new CloudWorkOrderServerVmIsoDo(); + queryIsoDo.setWorkOrderId(workOrderId); + QueryWrapper isoQueryWrapper = new QueryWrapper<>(queryIsoDo); + List isoDoList = cloudWorkOrderServerVmIsoService.list(isoQueryWrapper); + List isoDtoList = new ArrayList<>(); + if (!isoDoList.isEmpty()) { + isoDoList.stream().forEach(iso -> { + ServerVmIsoDto vmIsoDto = new ServerVmIsoDto(); + vmIsoDto.setIsoFile(iso.getIsoFile()); + vmIsoDto.setModifyType(iso.getModifyType()); + vmIsoDto.setOldIsoFile(iso.getOldIsoFile()); + isoDtoList.add(vmIsoDto); + }); + } + applyServerVmDetailRespDto.setIsoList(isoDtoList); + + if (Objects.equals(serverVmDo.getApplyServervmType(), ApplyServerVmType.TEMPLATE)) { + //获取模板名称 + QueryMcServerDetailParamReq queryMcServerDetailParamReq = new QueryMcServerDetailParamReq(); + queryMcServerDetailParamReq.setServervmId(serverVmDo.getTemplateId()); + McTemplateDetailResp mcTemplateDetailResp = getTemplateDetail(serverVmDo.getClusterId(), + queryMcServerDetailParamReq, + loginUserVo); + if (Objects.nonNull(mcTemplateDetailResp)) { + applyServerVmDetailRespDto.setTemplateName(mcTemplateDetailResp.getAlisname()); + } + } + + } + + return applyServerVmDetailRespDto; + } + + @Override + public ApplyDeferredDetailRespDto applyDeferredDetailByWorkOrderId(Integer workOrderId) { + ApplyDeferredDetailRespDto applyDeferredDetailRespDto = new ApplyDeferredDetailRespDto(); + + selfWorkOrderService.formatBaseWorkOrderDetail(workOrderId, applyDeferredDetailRespDto); + + + //查询延期申请表 + CloudWorkOrderDeferredMachineDo cloudWorkOrderDeferredMachineDo = new CloudWorkOrderDeferredMachineDo(); + cloudWorkOrderDeferredMachineDo.setWorkOrderId(workOrderId); + QueryWrapper queryWrapper = new QueryWrapper<> + (cloudWorkOrderDeferredMachineDo); + CloudWorkOrderDeferredMachineDo queryDo = deferredMachineService.getOne(queryWrapper); + + applyDeferredDetailRespDto.setOldDeadlineTime(DateUtils.format(queryDo.getOldDeadlineTime())); + applyDeferredDetailRespDto.setNewDeadlineTime(DateUtils.format(queryDo.getDeadlineTime())); + + return applyDeferredDetailRespDto; + } + + @Override + public ModifyServerVmDetailRespDto modifyServerVmDetailByWorkOrderId(Integer workOrderId) { + ModifyServerVmDetailRespDto modifyServerVmDetailRespDto = new ModifyServerVmDetailRespDto(); + + selfWorkOrderService.formatBaseWorkOrderDetail(workOrderId, modifyServerVmDetailRespDto); + + //查询变更云服务器详情 + CloudWorkOrderModifyServerVmDo modifyServerVmDo = new CloudWorkOrderModifyServerVmDo(); + modifyServerVmDo.setWorkOrderId(workOrderId); + QueryWrapper wrapper = new QueryWrapper<>(modifyServerVmDo); + CloudWorkOrderModifyServerVmDo serverVmDo = cloudWorkOrderModifyServerVmService.getOne(wrapper); + + //查询用户已经拥有的云服务器 + CloudWorkOrderDo cloudWorkOrderDo = workOrderService.getById(workOrderId); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmDo.getMachineUuid(), + cloudWorkOrderDo.getUserId()); + if (Objects.nonNull(userMachineDo)) { + + + String deadLineTime = DateUtils.format(serverVmDo.getDeadlineTime(), DateUtils.DATE_ALL_PATTEN); + + modifyServerVmDetailRespDto.setDeadLineTime(deadLineTime); + modifyServerVmDetailRespDto.setDeadlineType(serverVmDo.getDeadlineType()); + modifyServerVmDetailRespDto.setDeadlineTypeDesc(serverVmDo.getDeadlineType().getDesc()); + modifyServerVmDetailRespDto.setOsMachine(serverVmDo.getOsMachine()); + modifyServerVmDetailRespDto.setArchitecture(serverVmDo.getArchitecture()); + + modifyServerVmDetailRespDto.setCpu(serverVmDo.getCpu()); + modifyServerVmDetailRespDto.setIfModifyCpu(!Objects.equals(serverVmDo.getCpu(), + serverVmDo.getOriginalCpu())); + modifyServerVmDetailRespDto.setOriginalCpu(serverVmDo.getOriginalCpu()); + + modifyServerVmDetailRespDto.setMem(serverVmDo.getMem()); + modifyServerVmDetailRespDto.setMenUtil(serverVmDo.getMemUnit()); + modifyServerVmDetailRespDto.setOriginalMem(serverVmDo.getOriginalMem()); + modifyServerVmDetailRespDto.setIfModifyMem(!Objects.equals(serverVmDo.getMem(), + serverVmDo.getOriginalMem())); + + + //查询硬盘信息 + CloudWorkOrderServerVmDiskDo queryDiskDo = new CloudWorkOrderServerVmDiskDo(); + queryDiskDo.setWorkOrderId(workOrderId); + QueryWrapper diskQueryWrapper = new QueryWrapper<>(queryDiskDo); + List diskDoList = cloudWorkOrderServerVmDiskService.list(diskQueryWrapper); + List disks = new ArrayList<>(); + if (diskDoList.size() > 0) { + diskDoList.forEach(disk -> { + ServerVmDiskDto diskDto = new ServerVmDiskDto(); + diskDto.setDiskSize(disk.getDiskSize()); + diskDto.setPurpose(disk.getPurpose()); + diskDto.setModifyType(disk.getModifyType()); + diskDto.setOldDiskSize(disk.getOldDiskSize()); + disks.add(diskDto); + }); + } + modifyServerVmDetailRespDto.setDisks(disks); + + //查询网卡信息 + CloudWorkOrderServerVmNetworkDo queryNetworkDo = new CloudWorkOrderServerVmNetworkDo(); + queryNetworkDo.setWorkOrderId(workOrderId); + QueryWrapper networkQueryWrapper = new QueryWrapper<>(queryNetworkDo); + List networkDoList = + cloudWorkOrderServerVmNetworkService.list(networkQueryWrapper); + List networks = new ArrayList<>(); + networkDoList.forEach(network -> { + ServerVmNetworkDto serverVmNetworkDto = new ServerVmNetworkDto(); + serverVmNetworkDto.setPurpose(network.getPurpose()); + serverVmNetworkDto.setModifyType(network.getModifyType()); + serverVmNetworkDto.setIpBindMac(network.getIpBindMac()); + serverVmNetworkDto.setManualSetIp(network.getManualSetIp()); + serverVmNetworkDto.setAutomaticAcqIp(network.getAutomaticAcqIp()); + serverVmNetworkDto.setIp(network.getIp()); + serverVmNetworkDto.setMask(network.getMask()); + serverVmNetworkDto.setGw(network.getGw()); + serverVmNetworkDto.setDns1(network.getDns1()); + serverVmNetworkDto.setDns2(network.getDns2()); + boolean setIpInfo = network.getIpBindMac() || network.getManualSetIp() || network.getAutomaticAcqIp(); + serverVmNetworkDto.setSetIpInfo(setIpInfo); + networks.add(serverVmNetworkDto); + }); + modifyServerVmDetailRespDto.setNetworks(networks); + + } + return modifyServerVmDetailRespDto; + } + + @Override + @Transactional + public void applyDeferredMachine(ApplyDeferredParam applyDeferredParam, LoginUserVo loginUserVo) { + + Date now = new Date(); + //插入申请工单 + CloudWorkOrderDo cloudWorkOrderDo = new CloudWorkOrderDo(); + cloudWorkOrderDo.setUserId(loginUserVo.getUserId()); + cloudWorkOrderDo.setTarget(applyDeferredParam.getMachineName()); + cloudWorkOrderDo.setStatus(WorkOrderStatus.WAIT_CHECK); + cloudWorkOrderDo.setType(WorkOrderType.DEFERRED_SERVERVM); + cloudWorkOrderDo.setCreateTime(now); + cloudWorkOrderDo.setApplyReason(applyDeferredParam.getApplyReason()); + cloudWorkOrderDo.setCreateBy(loginUserVo.getUserId()); + workOrderService.save(cloudWorkOrderDo); + + //查询用户拥有的云服务器详情-获取原过期时间 + CloudUserMachineDo queryDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(applyDeferredParam.getUserMachineUuid(), + cloudWorkOrderDo.getUserId()); + + + Date deadlineTime = DateUtils.parse(applyDeferredParam.getDeadlineTime() + DateUtils.DAY_END, DateUtils + .DATE_ALL_PATTEN); + //插入延期表 + CloudWorkOrderDeferredMachineDo deferredMachineDo = new CloudWorkOrderDeferredMachineDo(); + deferredMachineDo.setWorkOrderId(cloudWorkOrderDo.getId()); + deferredMachineDo.setUserMachineUuid(applyDeferredParam.getUserMachineUuid()); + + deferredMachineDo.setDeadlineTime(deadlineTime); + deferredMachineDo.setOldDeadlineTime(queryDo.getDeadlineTime()); + deferredMachineDo.setCreateBy(loginUserVo.getUserId()); + deferredMachineDo.setCreateTime(now); + deferredMachineService.save(deferredMachineDo); + } + + @Override + public PageData listServerVm(ServerVmPageParam serverVmPageParam, LoginUserVo loginUserVo) { + + //查询用户拥有的云服务器uuid + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + cloudUserMachineDo.setUserId(loginUserVo.getUserId()); + cloudUserMachineDo.setDeleteFlag(false); + //是否过期过滤 + if (Objects.nonNull(serverVmPageParam.getVmStatus()) && !Objects.equals(McServerVmStatus.ALL, + serverVmPageParam.getVmStatus())) { + cloudUserMachineDo.setDeadlineFlag(Objects.equals(McServerVmStatus.OVERDUE, serverVmPageParam.getVmStatus + ())); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(cloudUserMachineDo); + List userMachineDoList = + cloudUserMachineService.list(queryWrapper); + + if (userMachineDoList.isEmpty()) { + return new PageData(null); + } + + + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = + userMachineDoList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + + if (Objects.equals(clusterUserMachineMap.size(), 1)) { + //单集群 + return singleClusterUserMachine(userMachineDoList, serverVmPageParam, loginUserVo, + userMachineDoList.get(0).getClusterId()); + } else { + //多集群 + return manyClusterUserMachine(clusterUserMachineMap, serverVmPageParam, loginUserVo, + userMachineDoList.size()); + } + } + + /** + * 封装请求mc云服务器列表的参数 + * + * @param serverVmPageParam + * @param uuids + * @return + */ + private ServerVmListReq formatSearchMcServerVmParam(ServerVmPageParam serverVmPageParam, List uuids) { + ServerVmListReq serverVmListReq = new ServerVmListReq(); + serverVmListReq.setPage(serverVmPageParam.getPageNo()); + serverVmListReq.setRows(serverVmPageParam.getPageSize()); + serverVmListReq.setVmName(serverVmPageParam.getSearchKey()); + if (Objects.nonNull(serverVmPageParam.getVmStatus()) && !Objects.equals(McServerVmStatus.OVERDUE, + serverVmPageParam.getVmStatus()) && !Objects.equals(McServerVmStatus.ALL, + serverVmPageParam.getVmStatus())) { + serverVmListReq.setVmStatus(serverVmPageParam.getVmStatus()); + } + serverVmListReq.setUuidList(uuids); + return serverVmListReq; + } + + /** + * 单个集群获取云服务器列表 + * + * @param userMachineList + * @param serverVmPageParam + * @param loginUserVo + * @return + */ + private PageData singleClusterUserMachine(List userMachineList, + ServerVmPageParam serverVmPageParam, + LoginUserVo loginUserVo, Integer clusterId) { + + List uuidList = + userMachineList.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmListReq serverVmListReq = formatSearchMcServerVmParam(serverVmPageParam, uuidList); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, serverVmListReq, + mcConfigProperties.getServerVmList(), loginUserVo.getUserName(), 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + McPageResp mcServerVmPage = JSONObject.parseObject(serverListTxt, new + TypeReference>() { + }); + List pageServerVmRespDtoList = new ArrayList<>(); + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcServerVmPage.getPager()); + mcPageInfo.setPageSize(mcServerVmPage.getRows().size()); + mcPageInfo.setRecords(mcServerVmPage.getRecords()); + mcPageInfo.setTotal(mcServerVmPage.getTotal()); + + mcServerVmPage.getRows().forEach(mcServerVm -> { + PageServerVmRespDto pageServerVmRespDto = createMcServerVmPageDetail(clusterId, mcServerVm, + userMachineList, loginUserVo); + pageServerVmRespDtoList.add(pageServerVmRespDto); + }); + return new PageData(mcPageInfo, pageServerVmRespDtoList); + } + return new PageData(null); + } + + /** + * 多集群云云服务器列表 + * + * @param clusterUserMachineMap + * @param serverVmPageParam + * @param loginUserVo + * @return + */ + private PageData manyClusterUserMachine(Map> clusterUserMachineMap, + ServerVmPageParam serverVmPageParam, + LoginUserVo loginUserVo, Integer maxServerVmSize) { + List clusterIdList = new ArrayList<>(); + clusterIdList.addAll(clusterUserMachineMap.keySet()); + List mcRequestObjectList = new ArrayList<>(); + clusterIdList.forEach(clusterId -> { + List uuidList = + clusterUserMachineMap.get(clusterId).stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmListReq serverVmListReq = formatSearchMcServerVmParam(serverVmPageParam, uuidList); + serverVmListReq.setPage(KylinCommonConstants.FIRST_PAGE); + serverVmListReq.setRows(maxServerVmSize); + mcRequestObjectList.add(serverVmListReq); + }); + + List mcServerVmList = mcClusterThreadService.threadGetMcResponse(clusterIdList, + loginUserVo.getUserName(), + mcConfigProperties.getServerVmList(), mcRequestObjectList); + + //多个集群中满足条件的所有的云服务器 + List totalServerVmRespDtoList = new ArrayList<>(); + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(serverVmPageParam.getPageNo()); + for (int i = 0; i < clusterIdList.size(); i++) { + Integer clusterId = clusterIdList.get(i); + String serverVmList = mcServerVmList.get(i); + if (Objects.nonNull(serverVmList)) { + McPageResp mcServerVmPage = JSONObject.parseObject(serverVmList, new + TypeReference>() { + }); + mcServerVmPage.getRows().forEach(mcServerVm -> { + PageServerVmRespDto pageServerVmRespDto = createMcServerVmPageDetail(clusterId, + mcServerVm, clusterUserMachineMap.get(clusterId), loginUserVo); + totalServerVmRespDtoList.add(pageServerVmRespDto); + }); + } + } + mcPageInfo.setTotal(mcPageInfo.getRecords()); + mcPageInfo.setRecords(totalServerVmRespDtoList.size()); + //总页数 + int totalPage = (mcPageInfo.getRecords() - 1) / serverVmPageParam.getPageSize() + 1; + mcPageInfo.setTotal(totalPage); + + //云服务器安装状态排序 + Collections.sort(totalServerVmRespDtoList); + //从所有云服务器列表中,截取页面查询的对应页码的数量 + int totalSize = totalServerVmRespDtoList.size(); + int subListStart = (serverVmPageParam.getPageNo() - 1) * serverVmPageParam.getPageSize(); + int subListEnd = serverVmPageParam.getPageNo() * serverVmPageParam.getPageSize(); + if (totalSize < subListStart) { + return new PageData(null); + } else if (totalSize >= subListStart && totalSize < subListEnd) { + mcPageInfo.setPageSize(totalSize - subListStart); + return new PageData(mcPageInfo, totalServerVmRespDtoList.subList(subListStart, totalSize)); + } else { + mcPageInfo.setPageSize(serverVmPageParam.getPageSize()); + return new PageData(mcPageInfo, totalServerVmRespDtoList.subList(subListStart, subListEnd)); + } + + } + + /** + * 创建云服务器列表数据 + * + * @param clusterId + * @param mcServerVm + * @return + */ + private PageServerVmRespDto createMcServerVmPageDetail(Integer clusterId, McServerVmPageDetailResp mcServerVm, + List userMachineDoList, + LoginUserVo loginUserVo) { + + //根据uuid 过滤,保存起来的用户云服务器。 + CloudUserMachineDo userMachineDo = userMachineDoList.stream().filter(userMachine -> Objects.equals + (mcServerVm.getUuid(), userMachine.getMachineUuid())).findFirst().orElse(null); + PageServerVmRespDto serverVmRespDto = new PageServerVmRespDto(); + //过滤,防止MC中删除了该云服务器,但是自服务中还保留该用户和云服务器的关联关系 + if (Objects.nonNull(userMachineDo)) { + BeanUtils.copyProperties(mcServerVm, serverVmRespDto); + serverVmRespDto.setServerVmId(mcServerVm.getId()); + serverVmRespDto.setServerVmUuid(mcServerVm.getUuid()); + //设置到期时间 到期时间-当前时间=剩余天数 + + serverVmRespDto.setDeadlineTime(DateUtils.differentDaysByMillisecond(new Date(), + userMachineDo.getDeadlineTime())); + serverVmRespDto.setDeadlineFlag(userMachineDo.getDeadlineFlag()); + serverVmRespDto.setCreateDate(DateUtils.format(userMachineDo.getCreateTime(), + DateUtils.DATE_YYYY_MM_DD)); + + + if (userMachineDo.getDeadlineFlag()) { + serverVmRespDto.setStatus(McServerVmStatus.OVERDUE); + } + + serverVmRespDto.setArchitecture(KcpCommonUtil.changeToKcpArchitectureType(mcServerVm.getArchitecture()).getDesc()); + //利用率 + JSONObject usage = new JSONObject(); + if (mcServerVm.getStatus().equals(McServerVmStatus.AVAILABLE) || + mcServerVm.getStatus().equals(McServerVmStatus.SUSPEND) || + mcServerVm.getStatus().equals(McServerVmStatus.INSTALLING) || + mcServerVm.getStatus().equals(McServerVmStatus.CONNECTED)) { + usage.put("cpu", "0"); + //usage.put("disk", "0"); + usage.put("mem", "0"); + } + if (StringUtils.isNotBlank(mcServerVm.getCpuRate())) { + usage.put("cpu", mcServerVm.getCpuRate().replaceAll("%", "")); + } +// if (StringUtils.isNotBlank(mcServerVm.getDiskRate())) { +// usage.put("disk", mcServerVm.getDiskRate().replaceAll("%", "")); +// } + if (StringUtils.isNotBlank(mcServerVm.getMemoryRate())) { + usage.put("mem", mcServerVm.getMemoryRate().replaceAll("%", "")); + } + serverVmRespDto.setUsage(usage.toJSONString()); + } + return serverVmRespDto; + } + + /** + * 从mc查询服务器列表 + */ + private McPageResp listServerVmFromMc(ServerVmListReq serverVmListReq, LoginUserVo + loginUserVo) { + + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(0, serverVmListReq, + mcConfigProperties.getServerVmList(), + loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + McPageResp mcPageResp = JSONObject.parseObject(serverListTxt, new + TypeReference>() { + }); + + return mcPageResp; + } + return null; + + } + + + @Override + @Transactional + public BaseResult deleteServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + List serverVmUuids = new ArrayList(); + serverVmUuids.add(serverVmBaseParam.getServerVmUuid()); + ServerVmBatchOperateParam serverVmBatchOperateParam = new ServerVmBatchOperateParam(); + serverVmBatchOperateParam.setServerVmUuids(serverVmUuids); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + + boolean deleteFlag = singleClusterBatchOperate(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchRemoveMachineToRecycleUrl(), userMachineDo.getClusterId()); + //mc中成功将云服务器放入回收站后,将用户用户拥有的云服务器逻辑删除 + if (deleteFlag) { + deleteUserMachine(loginUserVo, serverVmUuids); + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + } + + + @Override + public McStartVmErrorCode startServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + checkUserMachineIfOverdue(serverVmBaseParam.getServerVmUuid(), loginUserVo.getUserId()); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, + mcConfigProperties.getStartServerVmUrl(), loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + return McStartVmErrorCode.SUCCESS; + } + String error = JSON.parseObject(JSON.toJSONString(mcResponse.getData())).getString("errorCode"); + McStartVmErrorCode errorCode = McStartVmErrorCode.valueOf(error); + return errorCode; + + } + + @Override + public boolean shutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getShutdownServerVmUrl()); + + } + + @Override + public boolean restartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getRestartServerVmUrl()); + + + } + + @Override + public boolean forcedShutdownServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getForcedShutdownServerVmUrl()); + } + + @Override + public boolean forcedRestartServerVm(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + return commonSingleOperate(serverVmBaseParam, loginUserVo, mcConfigProperties.getForcedRestartServerVmUrl()); + + } + + private boolean commonSingleOperate(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo, String httpUrl) { + checkUserMachineIfOverdue(serverVmBaseParam.getServerVmUuid(), loginUserVo.getUserId()); + + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + //调用mc获取响应 + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + return mcHttpService.noDataCommonMcRequest(userMachineDo.getClusterId(), serverVmBaseReq, httpUrl, + loginUserVo.getUserName(), + 0); + } + + /** + * 检查云服务器是否过期 + */ + private void checkUserMachineIfOverdue(String serverVmUuid, Integer userId) { + + + CloudUserMachineDo queryDo = cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmUuid, userId); + if (Objects.isNull(queryDo)) { + throw new KylinException(KylinHttpResponseConstants.OPERATE_ERR); + } + if (queryDo.getDeadlineFlag()) { + throw new KylinException(KylinHttpResponseConstants.SERVERVM_OVERDUE_NOT_OPERATE); + } + } + + + @Override + public BaseResult batchStartServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + return serverVmBatchOperateToMc(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchStartServerVmUrl()); + } + + /** + * 批量删除用户云服务器关联关系 + * + * @param loginUserVo + * @param userMachineUuidList + */ + private void deleteUserMachine(LoginUserVo loginUserVo, List userMachineUuidList) { + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + QueryWrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + wrapper.in("machine_uuid", userMachineUuidList); + List machineList = cloudUserMachineService.list(wrapper); + if (!machineList.isEmpty()) { + Date deleteTime = new Date(); + machineList.forEach(userMachine -> { + userMachine.setDeleteFlag(true); + userMachine.setDeleteBy(loginUserVo.getUserId()); + userMachine.setDeleteTime(deleteTime); + }); + cloudUserMachineService.updateBatchById(machineList); + } + } + + @Override + @Transactional + public BaseResult batchDeleteServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + Map> clusterUserMachineMap = groupByClusterId(serverVmBatchOperateParam); + if (Objects.equals(clusterUserMachineMap.size(), 1)) { + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBatchOperateParam.getServerVmUuids().get(0), + loginUserVo.getUserId()); + boolean deleteFlag = singleClusterBatchOperate(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchRemoveMachineToRecycleUrl(), userMachineDo.getClusterId()); + //mc中成功将云服务器放入回收站后,将用户用户拥有的云服务器逻辑删除 + if (deleteFlag) { + deleteUserMachine(loginUserVo, serverVmBatchOperateParam.getServerVmUuids()); + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + } else { + //选择的云服务器是不同的集群 + List failedClusterList = manyClusterBatchOperate(clusterUserMachineMap, loginUserVo, + mcConfigProperties.getBatchRemoveMachineToRecycleUrl()); + if (failedClusterList.isEmpty()) { + deleteUserMachine(loginUserVo, serverVmBatchOperateParam.getServerVmUuids()); + return BaseResult.success(null); + } + //将操作成功的集群中的,用户云服务器管理关系删除 + List deleteSuccessUuid = new ArrayList<>(); + clusterUserMachineMap.forEach((clusterId, value) -> { + if (!failedClusterList.contains(clusterId)) { + List deleteSuccessClusterUuid = + value.stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + deleteSuccessUuid.addAll(deleteSuccessClusterUuid); + } + }); + if (!deleteSuccessUuid.isEmpty()) { + deleteUserMachine(loginUserVo, deleteSuccessUuid); + } + StringBuilder manyClusterFailedMsg = new StringBuilder(); + failedClusterList.forEach(clusterId -> { + CloudClusterDo failedCluster = cloudClusterService.getById(clusterId); + manyClusterFailedMsg.append(failedCluster.getName()).append(",") + .append(KylinHttpResponseConstants.BATCH_OPERATE_ERR).append(";"); + }); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + } + + @Override + public BaseResult batchShutdownServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + return serverVmBatchOperateToMc(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchShutdownServerVmUrl()); + } + + @Override + public BaseResult batchRebootServerVm(ServerVmBatchOperateParam serverVmBatchOperateParam, + LoginUserVo loginUserVo) { + return serverVmBatchOperateToMc(serverVmBatchOperateParam, loginUserVo, + mcConfigProperties.getBatchRebootServerVmUrl()); + } + + /** + * 根据集群ID,将批量操作进行分组 + * + * @param serverVmBatchOperateParam + * @return + */ + private Map> groupByClusterId(ServerVmBatchOperateParam serverVmBatchOperateParam) { + //根据云服务器列表,进行分类 + CloudUserMachineDo cloudUserMachineDo = new CloudUserMachineDo(); + QueryWrapper wrapper = new QueryWrapper<>(cloudUserMachineDo); + wrapper.in("machine_uuid", serverVmBatchOperateParam.getServerVmUuids()); + List machineList = cloudUserMachineService.list(wrapper); + + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = + machineList.stream().collect(Collectors.groupingBy(CloudUserMachineDo::getClusterId)); + return clusterUserMachineMap; + } + + /** + * 云服务器操作,批量开机/批量关机/批量重启/ + */ + private BaseResult serverVmBatchOperateToMc(ServerVmBatchOperateParam serverVmBatchOperateParam, LoginUserVo + loginUserVo, String httpUrl) { + + + //将用户云服务器安装集群进行分组 + Map> clusterUserMachineMap = groupByClusterId(serverVmBatchOperateParam); + + ServerVmBatchReq serverVmBatchReq = new ServerVmBatchReq(); + serverVmBatchReq.setUuid(String.join(",", serverVmBatchOperateParam.getServerVmUuids())); + + + int clusterMachineMapSize = clusterUserMachineMap.size(); + //选择的云服务器是通一个集群中 + if (Objects.equals(clusterMachineMapSize, 1)) { + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBatchOperateParam.getServerVmUuids().get(0), + loginUserVo.getUserId()); + + boolean singleClusterBatchOperate = singleClusterBatchOperate(serverVmBatchOperateParam, loginUserVo, + httpUrl + , userMachineDo.getClusterId()); + if (singleClusterBatchOperate) { + return BaseResult.success(null); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + } else { + //选择的云服务器是不同的集群 + List failedClusterList = manyClusterBatchOperate(clusterUserMachineMap, loginUserVo, httpUrl); + if (failedClusterList.isEmpty()) { + return BaseResult.success(null); + } + StringBuilder manyClusterFailedMsg = new StringBuilder(); + failedClusterList.forEach(clusterId -> { + CloudClusterDo failedCluster = cloudClusterService.getById(clusterId); + manyClusterFailedMsg.append(failedCluster.getName()).append(",") + .append(KylinHttpResponseConstants.BATCH_OPERATE_ERR).append(";"); + }); + return BaseResult.error(manyClusterFailedMsg.toString()); + } + + } + + /** + * 针对单个云服务器单个操作。 + * + * @param serverVmBatchOperateParam + * @param loginUserVo + * @param httpUrl + * @param clusterId + * @return + */ + private boolean singleClusterBatchOperate(ServerVmBatchOperateParam serverVmBatchOperateParam, LoginUserVo + loginUserVo, String httpUrl, Integer clusterId) { + ServerVmBatchReq serverVmBatchReq = new ServerVmBatchReq(); + serverVmBatchReq.setUuid(String.join(",", serverVmBatchOperateParam.getServerVmUuids())); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, serverVmBatchReq, httpUrl + , loginUserVo.getUserName(), 0); + return Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus()); + + } + + + /** + * 针对多个集群中的批量操作 + * + * @param clusterUserMachineMap + * @param loginUserVo + * @param httpUrl + * @return + */ + private List manyClusterBatchOperate(Map> clusterUserMachineMap, + LoginUserVo + loginUserVo, String httpUrl) { + List clusterIdList = new ArrayList<>(); + clusterIdList.addAll(clusterUserMachineMap.keySet()); + List mcRequestObjectList = new ArrayList<>(); + clusterIdList.forEach(clusterId -> { + List uuidList = + clusterUserMachineMap.get(clusterId).stream().map(CloudUserMachineDo::getMachineUuid).collect(Collectors.toList()); + ServerVmBatchReq serverVmBatchReq = new ServerVmBatchReq(); + serverVmBatchReq.setUuid(String.join(",", uuidList)); + mcRequestObjectList.add(serverVmBatchReq); + }); + List> manyClusterBatchOperateResponse = + mcClusterThreadService.threadSendToMc(clusterIdList, + loginUserVo.getUserName(), + httpUrl, mcRequestObjectList); + + //操作失败的集群 + List failedClusterList = new ArrayList<>(); + for (int i = 0; i < clusterIdList.size(); i++) { + MCResponseData mcResponse = manyClusterBatchOperateResponse.get(i); + if (Objects.isNull(mcResponse) || Objects.equals(mcResponse.getStatus(), MCServerVmConstants.ERROR)) { + failedClusterList.add(clusterIdList.get(i)); + } + } + return failedClusterList; + } + + @Override + public McServerVmInfoResp serverVmInfo(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + McServerVmInfoResp mcServerVmInfoResp = new McServerVmInfoResp(); + + + CloudUserMachineDo queryDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + + if (Objects.nonNull(queryDo)) { + + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(queryDo.getClusterId(), + serverVmBaseReq, + mcConfigProperties.getServerVmInfoUrl(), + loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String mcServerVmDetail = JSON.toJSONString(mcResponse.getData()); + mcServerVmInfoResp = JSON.parseObject(mcServerVmDetail, McServerVmInfoResp.class); + if (Objects.nonNull(mcServerVmInfoResp)) { + + if (StringUtils.isNotBlank(mcServerVmInfoResp.getMachineInfo().getLogo())) { + String logo = mcServerVmInfoResp.getMachineInfo().getLogo(); + mcServerVmInfoResp.getMachineInfo().setLogo(logo); + } + } + if (Objects.nonNull(mcServerVmInfoResp) && queryDo.getDeadlineFlag()) { + mcServerVmInfoResp.getMachineInfo().setStatus(McServerVmStatus.OVERDUE); + + + } + } + } + + return mcServerVmInfoResp; + } + + @Override + public ServerVmMonitorInfoRespDto serverVmMonitor(ServerVmBaseParam serverVmBaseParam, LoginUserVo + loginUserVo) { + List mcServerVmMonitorDetailList = new ArrayList<>(); + + McServerVmMonitorReq serverVmMonitorReq = new McServerVmMonitorReq(); + serverVmMonitorReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmMonitorReq, + mcConfigProperties.getServerVmMonitorInfoUrl(), + loginUserVo.getUserName(), 0); + + ServerVmMonitorInfoRespDto serverVmMonitorInfoRespDto = new ServerVmMonitorInfoRespDto(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverVmMonitorTxt = JSON.toJSONString(mcResponse.getData()); + mcServerVmMonitorDetailList = JSON.parseArray(serverVmMonitorTxt, McServerVmMonitorDetailResp.class); + List timeList = new ArrayList<>(); + List cpuUsed = new ArrayList<>(); + List memUsed = new ArrayList(); + List diskReadSpeed = new ArrayList(); + List diskWriteSpeed = new ArrayList(); + List netWorkInSpeed = new ArrayList(); + List netWorkOutSpeed = new ArrayList(); + + if (!mcServerVmMonitorDetailList.isEmpty()) { + + mcServerVmMonitorDetailList.forEach(monitor -> { + timeList.add(monitor.getDateShow()); + cpuUsed.add(monitor.getCpuUtil()); + memUsed.add(monitor.getMemUtil()); + diskReadSpeed.add(monitor.getDiskReadSpeed()); + diskWriteSpeed.add(monitor.getDiskWriteSpeed()); + netWorkInSpeed.add(monitor.getNetWorkInSpeed()); + netWorkOutSpeed.add(monitor.getNetWorkOutSpeed()); + }); + serverVmMonitorInfoRespDto.setTimeList(timeList); + serverVmMonitorInfoRespDto.setCpuUsed(cpuUsed); + serverVmMonitorInfoRespDto.setMemUsed(memUsed); + serverVmMonitorInfoRespDto.setDiskReadSpeed(diskReadSpeed); + serverVmMonitorInfoRespDto.setDiskWriteSpeed(diskWriteSpeed); + serverVmMonitorInfoRespDto.setNetWorkInSpeed(netWorkInSpeed); + serverVmMonitorInfoRespDto.setNetWorkOutSpeed(netWorkOutSpeed); + } + } + + return serverVmMonitorInfoRespDto; + } + + + @Override + public PageData serverVmOperateLog(ServerVmOperateLogPageParam serverVmOperateLogPageParam, + LoginUserVo loginUserVo) { + PageData pageData = new PageData(null); + + + ServerVmOperateLogReq serverVmOperateLogReq = new ServerVmOperateLogReq(); + serverVmOperateLogReq.setUuid(serverVmOperateLogPageParam.getServerVmUuid()); + serverVmOperateLogReq.setPage(serverVmOperateLogPageParam.getPageNo()); + serverVmOperateLogReq.setRows(serverVmOperateLogPageParam.getPageSize()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmOperateLogPageParam.getServerVmUuid(), + loginUserVo.getUserId()); + + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmOperateLogReq, + mcConfigProperties.getServerVmOperateLogUrl(), + loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String serverListTxt = JSON.toJSONString(mcResponse.getData()); + McPageResp mcServerLogPageResp = JSONObject.parseObject(serverListTxt, new + TypeReference>() { + }); + + if (Objects.nonNull(mcServerLogPageResp)) { + McPageInfo mcPageInfo = new McPageInfo(); + mcPageInfo.setPager(mcServerLogPageResp.getPager()); + mcPageInfo.setPageSize(mcServerLogPageResp.getRows().size()); + mcPageInfo.setRecords(mcServerLogPageResp.getRecords()); + mcPageInfo.setTotal(mcServerLogPageResp.getTotal()); + List mcServerVmLogList = new ArrayList<>(); + mcServerVmLogList = mcServerLogPageResp.getRows(); + pageData = new PageData(mcPageInfo, mcServerVmLogList); + + } + } + + return pageData; + + } + + + @Override + public BaseResult createSnapshot(McServerVmCreateSnapshotReq mcServerVmCreateSnapshotReq, + LoginUserVo loginUserVo) { + + checkUserMachineIfOverdue(mcServerVmCreateSnapshotReq.getUuid(), loginUserVo.getUserId()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(mcServerVmCreateSnapshotReq.getUuid(), + loginUserVo.getUserId()); + + String httpUrl = mcConfigProperties.getServerVmCreateSnapshotUrl(); + return commonSnapshot(userMachineDo.getClusterId(), mcServerVmCreateSnapshotReq, httpUrl, + loginUserVo.getUserName()); + } + + private BaseResult commonSnapshot(Integer clusterId, Object reqObj, String httpUrl, String userName) { + MCResponseData mcResponseData = mcHttpService.hasDataCommonMcRequest(clusterId, + reqObj, httpUrl, userName, 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponseData.getStatus())) { + return BaseResult.success("success"); + } + if (Objects.equals(MCServerVmConstants.ERROR, mcResponseData.getStatus()) && StringUtils.isNotBlank(mcResponseData.getMessage())) { + return BaseResult.error(mcResponseData.getMessage()); + } + return BaseResult.error(KylinHttpResponseConstants.OPERATE_ERR); + } + + @Override + public BaseResult updateSnapshot(McServerVmUpdateSnapshotReq mcServerVmUpdateSnapshotReq, + LoginUserVo loginUserVo) { + checkUserMachineIfOverdue(mcServerVmUpdateSnapshotReq.getUuid(), loginUserVo.getUserId()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(mcServerVmUpdateSnapshotReq.getUuid(), + loginUserVo.getUserId()); + + String httpUrl = mcConfigProperties.getServerVmUpdateSnapshotUrl(); + + return commonSnapshot(userMachineDo.getClusterId(), mcServerVmUpdateSnapshotReq, httpUrl, + loginUserVo.getUserName()); + } + + @Override + public boolean deleteSnapshot(McServerVmDeleteSnapshotReq mcServerVmDeleteSnapshotReq, LoginUserVo loginUserVo) { + checkUserMachineIfOverdue(mcServerVmDeleteSnapshotReq.getUuid(), loginUserVo.getUserId()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(mcServerVmDeleteSnapshotReq.getUuid(), + loginUserVo.getUserId()); + + String httpUrl = mcConfigProperties.getServerVmDeleteSnapshotUrl(); + return mcHttpService.noDataCommonMcRequest(userMachineDo.getClusterId(), mcServerVmDeleteSnapshotReq, httpUrl, + loginUserVo.getUserName(), 0); + } + + @Override + public BaseResult applySnapshot(McServerVmApplySnapshotReq mcServerVmApplySnapshotReq, + LoginUserVo loginUserVo) { + checkUserMachineIfOverdue(mcServerVmApplySnapshotReq.getUuid(), loginUserVo.getUserId()); + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(mcServerVmApplySnapshotReq.getUuid(), + loginUserVo.getUserId()); + String httpUrl = mcConfigProperties.getServerVmApplySnapshotUrl(); + return commonSnapshot(userMachineDo.getClusterId(), mcServerVmApplySnapshotReq, httpUrl, + loginUserVo.getUserName()); + } + + @Override + public List listSnapshot(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + + List snapshotList = new ArrayList<>(); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + String httpUrl = mcConfigProperties.getServerVmSnapshotListUrl(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, httpUrl, loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String snapshotListTxt = JSONArray.toJSONString(mcResponse.getData()); + + snapshotList = JSON.parseArray(snapshotListTxt, McServerVmSnapshotResp.class); + } + return snapshotList; + } + + @Override + public VncUrlDto getVncUrl(ServerVmBaseParam serverVmBaseParam, LoginUserVo loginUserVo) { + VncUrlDto vncUrlDto = new VncUrlDto(); + ServerVmBaseReq serverVmBaseReq = new ServerVmBaseReq(); + serverVmBaseReq.setUuid(serverVmBaseParam.getServerVmUuid()); + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(serverVmBaseParam.getServerVmUuid(), + loginUserVo.getUserId()); + + String httpUrl = mcConfigProperties.getServerVmVncUrl(); + //调用mc获取响应 + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + serverVmBaseReq, + httpUrl, + loginUserVo.getUserName(), 0); + + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + vncUrlDto = JSON.parseObject(JSON.toJSONString(mcResponse.getData()), VncUrlDto.class); + + } + return vncUrlDto; + } + + @Override + public boolean updateMachineDescription(UpdateServerVmDescriptionParam updateServerVmDescriptionParam, + LoginUserVo loginUserVo) { + + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(updateServerVmDescriptionParam.getUuid(), + loginUserVo.getUserId()); + + String httpUrl = mcConfigProperties.getUpdateMachineDescriptionUrl(); + //调用mc获取响应 + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), updateServerVmDescriptionParam, + httpUrl, loginUserVo.getUserName(), 0); + + return Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus()); + + } + + @Override + public boolean updateMachineName(UpdateServerVmNameParam updateServerVmNameParam, LoginUserVo loginUserVo) { + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(updateServerVmNameParam.getUuid(), + loginUserVo.getUserId()); + + checkServerNameExist(updateServerVmNameParam.getAliasName(), loginUserVo, userMachineDo); + + String httpUrl = mcConfigProperties.getUpdateMachineNameUrl(); + //调用mc获取响应 + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), updateServerVmNameParam, + httpUrl, loginUserVo.getUserName(), 0); + + return Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus()); + } + + /** + * 检查云服务器名称是否重复 + * + * @param machineName + * @param loginUserVo + */ + private void checkServerNameExist(String machineName, LoginUserVo loginUserVo, CloudUserMachineDo userMachineDo) { + CheckServerNameParamReq checkServerNameParamReq = new CheckServerNameParamReq(); + checkServerNameParamReq.setServervmName(machineName); + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), checkServerNameParamReq, + mcConfigProperties.getCheckVmServerNameUrl(), + loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String existStr = JSONArray.toJSONString(mcResponse.getData()); + CheckServerNameResp checkServerNameResp = JSON.parseObject(existStr, CheckServerNameResp.class); + if (Objects.nonNull(checkServerNameResp) && checkServerNameResp.getExist()) { + throw new KylinException(KylinHttpResponseConstants.SERVER_VM_NAME_EXIST); + } + } + + } + + @Override + public boolean resetRemotePassword(McServerVmResetRemotePasswordReq remotePasswordReq, LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getResetRemotePasswordUrl(); + //调用mc获取响应 + CloudUserMachineDo userMachineDo = + cloudUserMachineService.getUserMachineDoByUuidAndUserId(remotePasswordReq.getUuid(), + loginUserVo.getUserId()); + + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(userMachineDo.getClusterId(), + remotePasswordReq, + httpUrl, + loginUserVo.getUserName(), 0); + + return Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus()); + } + + /** + * 根据云服务器ID(UUID)获取云服务器(模板详情) + */ + public McTemplateDetailResp getTemplateDetail(Integer clusterId, + QueryMcServerDetailParamReq queryMcServerDetailParamReq, + LoginUserVo loginUserVo) { + String httpUrl = mcConfigProperties.getGetServervmDetailByServevmIdUrl(); + return getMcServerVmDetail(clusterId, queryMcServerDetailParamReq, loginUserVo, httpUrl); + } + + + private McTemplateDetailResp getMcServerVmDetail(Integer clusterId, + QueryMcServerDetailParamReq queryMcServerDetailParamReq, + LoginUserVo loginUserVo, String httpUrl) { + + + //调用mc获取响应 + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(clusterId, queryMcServerDetailParamReq, httpUrl, + loginUserVo.getUserName(), 0); + McTemplateDetailResp mcTemplateDetailResp = new McTemplateDetailResp(); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String mcServerVmDetailStr = JSON.toJSONString(mcResponse.getData()); + mcTemplateDetailResp = JSON.parseObject(mcServerVmDetailStr, McTemplateDetailResp.class); + } + return mcTemplateDetailResp; + } + + @Override + public ResponseEntity downLoadServerVmLog(String mcServerVmLogoPath, String mcServerVmLogoName) { + + try { + String localFilePath = mcConfigProperties.getMcLogoLocalFilePath() + mcServerVmLogoName; + File file = new File(localFilePath); + if (!file.exists()) { + String encodeName = URLEncoder.encode(mcServerVmLogoName, "UTF-8"); + String mcDownLoadUrl = + mcNodeService.getMcLeaderUrlFromCache(0) + mcConfigProperties.getMcPrefix() + + mcConfigProperties.getLogoPath() + encodeName; + file = HttpUtil.downLoadMcServerVmLogo(mcDownLoadUrl, localFilePath); + } + byte[] imageContent; + imageContent = fileToByte(file); + + final HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.IMAGE_PNG); + return new ResponseEntity<>(imageContent, headers, HttpStatus.OK); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static byte[] fileToByte(File img) throws Exception { + byte[] bytes = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + BufferedImage bi; + bi = ImageIO.read(img); + ImageIO.write(bi, "png", baos); + bytes = baos.toByteArray(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + baos.close(); + } + return bytes; + } + + + @Override + public List getAllOperatingSystem(QueryOperateSystem queryOperateSystem, + LoginUserVo loginUserVo) { + List systemList = new ArrayList<>(); + //调用mc获取响应 + MCResponseData mcResponse = + mcHttpService.hasDataCommonMcRequest(queryOperateSystem.getClusterId(), queryOperateSystem, + mcConfigProperties.getAllOperatingSystemUrl(), loginUserVo.getUserName(), 0); + if (Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + String systemListStr = JSON.toJSONString(mcResponse.getData()); + systemList = JSON.parseArray(systemListStr, McOperateSystemResp.class); + } + return systemList; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfServiceUserServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfServiceUserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..dedcb7bc03d48e6cead0559f57108d9510b6e3c1 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfServiceUserServiceImpl.java @@ -0,0 +1,230 @@ +package com.hnkylin.cloud.selfservice.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnkylin.cloud.core.common.JwtUtil; +import com.hnkylin.cloud.core.config.exception.KylinException; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDo; +import com.hnkylin.cloud.core.domain.CloudWorkOrderUserDo; +import com.hnkylin.cloud.core.enums.CloudUserStatus; +import com.hnkylin.cloud.core.enums.UserType; +import com.hnkylin.cloud.core.enums.WorkOrderStatus; +import com.hnkylin.cloud.core.enums.WorkOrderType; +import com.hnkylin.cloud.core.service.*; +import com.hnkylin.cloud.selfservice.constant.KylinHttpResponseConstants; +import com.hnkylin.cloud.selfservice.constant.KylinSelfConstants; +import com.hnkylin.cloud.selfservice.constant.SelfServiceRedisConstant; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.LoginUserParam; +import com.hnkylin.cloud.selfservice.entity.req.UpdateRealNameParam; +import com.hnkylin.cloud.selfservice.entity.req.UpdatePwdParam; +import com.hnkylin.cloud.selfservice.entity.req.UserRegisterParam; +import com.hnkylin.cloud.selfservice.entity.resp.TokenRespDto; +import com.hnkylin.cloud.selfservice.entity.resp.UserInfoRespDto; +import com.hnkylin.cloud.selfservice.entity.resp.WorkOrderUserDetailRespDto; +import com.hnkylin.cloud.selfservice.service.SelfServiceUserService; +import com.hnkylin.cloud.selfservice.service.SelfWorkOrderService; +import com.hnkylin.cloud.selfservice.service.cache.LoginUserCacheService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +@Service +public class SelfServiceUserServiceImpl implements SelfServiceUserService { + + @Resource + private CloudUserService cloudUserService; + + @Resource + private LoginUserCacheService loginUserCacheService; + + @Resource + private CloudDeptService cloudDeptService; + + @Resource + private CloudOrganizationService cloudOrganizationService; + + @Resource + private CloudWorkOrderService workOrderService; + + @Resource + private CloudWorkOrderUserService workOrderUserService; + + @Resource + private SelfWorkOrderService selfWorkOrderService; + + @Override + @Transactional + public void register(UserRegisterParam userRegisterParam) { + + //判断用户名是否已经存在。 + CloudUserDo cloudUserDo = cloudUserService.queryUserByUserName(userRegisterParam.getUserName()); + if (Objects.nonNull(cloudUserDo)) { + throw new KylinException(KylinHttpResponseConstants.ALREADY_EXIST_USER); + } + + Date now = new Date(); + CloudUserDo registerCloudUserDo = CloudUserDo.builder().userName(userRegisterParam.getUserName()) + .realName(userRegisterParam.getRealName()).password(userRegisterParam.getPassword()).remark + (userRegisterParam.getApplyReason()).userType(UserType.selfServiceUser).superUser(false).defaultUser(false) + .status(CloudUserStatus.NO_ACTIVATE).organizationId(userRegisterParam.getOrganizationId()).mobile + (userRegisterParam.getMobile()) + .build(); + registerCloudUserDo.setCreateTime(now); + registerCloudUserDo.setDeleteFlag(Boolean.FALSE); + cloudUserService.save(registerCloudUserDo); + //插入申请工单 + CloudWorkOrderDo cloudWorkOrderDo = new CloudWorkOrderDo(); + cloudWorkOrderDo.setUserId(registerCloudUserDo.getId()); + cloudWorkOrderDo.setTarget(registerCloudUserDo.getUserName()); + cloudWorkOrderDo.setStatus(WorkOrderStatus.WAIT_CHECK); + cloudWorkOrderDo.setType(WorkOrderType.REGISTER_USER); + cloudWorkOrderDo.setCreateTime(now); + cloudWorkOrderDo.setApplyReason(userRegisterParam.getApplyReason()); + cloudWorkOrderDo.setCreateBy(registerCloudUserDo.getId()); + workOrderService.save(cloudWorkOrderDo); + } + + @Override + public TokenRespDto login(LoginUserParam loginUserParam) { + CloudUserDo cloudUserDo = cloudUserService.queryUserByUserName(loginUserParam.getUserName()); + if (Objects.isNull(cloudUserDo)) { + throw new KylinException(KylinHttpResponseConstants.NOT_EXIST_USER); + } + if (!Objects.equals(loginUserParam.getPassword(), cloudUserDo.getPassword())) { + throw new KylinException(KylinHttpResponseConstants.PASSWORD_ERR); + } + if (Objects.equals(cloudUserDo.getStatus(), CloudUserStatus.NO_ACTIVATE)) { + throw new KylinException(KylinHttpResponseConstants.USER_NOT_ACTIVATE); + } + if (!Objects.equals(cloudUserDo.getUserType(), UserType.selfServiceUser)) { + throw new KylinException(KylinHttpResponseConstants.NOT_LOING_PERMISSION); + } + //登录成功,生成token + String token = + JwtUtil.sign(cloudUserDo.getUserName(), cloudUserDo.getId().toString(), KylinSelfConstants + .KYLIN_TOKEN_SECRET); + + //同一用户互斥登录 + Object cacheToken = loginUserCacheService.vGet(SelfServiceRedisConstant.UID + cloudUserDo.getId()); + if (Objects.nonNull(cacheToken)) { + loginUserCacheService.vDelete(SelfServiceRedisConstant.UID + cloudUserDo.getId()); + loginUserCacheService.vDelete(cacheToken.toString()); + } + + //设置token缓存有效时间 + loginUserCacheService.vSet(token, cloudUserDo.getId(), SelfServiceRedisConstant + .SELF_SERVICE_LOGIN_USER_CACHE_EXPIRE, + TimeUnit.MILLISECONDS); + loginUserCacheService.vSet(SelfServiceRedisConstant.UID + cloudUserDo.getId(), token, + SelfServiceRedisConstant.SELF_SERVICE_LOGIN_USER_CACHE_EXPIRE, TimeUnit.MILLISECONDS); + + + TokenRespDto tokenRespDto = new TokenRespDto(); + tokenRespDto.setToken(token); + return tokenRespDto; + } + + @Override + public void updatePwd(UpdatePwdParam updatePwdParam, LoginUserVo loginUserVo) { + CloudUserDo cloudUserDo = cloudUserService.getById(loginUserVo.getUserId()); + if (Objects.isNull(cloudUserDo)) { + throw new KylinException(KylinHttpResponseConstants.NOT_EXIST_USER); + } + if (!Objects.equals(cloudUserDo.getPassword(), updatePwdParam.getOldPassword())) { + throw new KylinException(KylinHttpResponseConstants.OLD_PASSWORD_ERR); + } + cloudUserDo.setPassword(updatePwdParam.getPassword()); + cloudUserDo.setUpdateBy(loginUserVo.getUserId()); + cloudUserDo.setUpdateTime(new Date()); + cloudUserService.updateById(cloudUserDo); + } + + @Override + public UserInfoRespDto userInfo(LoginUserVo loginUserVo) { + UserInfoRespDto userInfoRespDto = new UserInfoRespDto(); + CloudUserDo cloudUserDo = cloudUserService.getById(loginUserVo.getUserId()); + userInfoRespDto.setUserName(cloudUserDo.getUserName()); + userInfoRespDto.setRealName(cloudUserDo.getRealName()); + userInfoRespDto.setMobile(cloudUserDo.getMobile()); + userInfoRespDto.setRemark(cloudUserDo.getRemark()); +// userInfoRespDto.setOrganizationName(cloudOrganizationService.getById(cloudUserDo.getOrganizationId()) +// .getOrganizationName()); + return userInfoRespDto; + } + + @Override + public void loginOut(LoginUserVo loginUserVo) { + Object cacheToken = loginUserCacheService.vGet(SelfServiceRedisConstant.UID + loginUserVo.getUserId()); + if (Objects.nonNull(cacheToken)) { + loginUserCacheService.vDelete(SelfServiceRedisConstant.UID + loginUserVo.getUserId()); + loginUserCacheService.vDelete(cacheToken.toString()); + } + } + + @Override + @Transactional + public void updateRealName(UpdateRealNameParam updateRealNameParam, LoginUserVo loginUserVo) { + CloudUserDo cloudUserDo = cloudUserService.getById(loginUserVo.getUserId()); + if (Objects.isNull(cloudUserDo)) { + throw new KylinException(KylinHttpResponseConstants.NOT_EXIST_USER); + } + Date now = new Date(); + String oldRealName = cloudUserDo.getRealName(); + cloudUserDo.setRealName(updateRealNameParam.getRealName()); + cloudUserDo.setUpdateBy(loginUserVo.getUserId()); + cloudUserDo.setUpdateTime(now); + //插入申请工单 + CloudWorkOrderDo cloudWorkOrderDo = new CloudWorkOrderDo(); + cloudWorkOrderDo.setUserId(cloudUserDo.getId()); + cloudWorkOrderDo.setTarget(cloudUserDo.getUserName()); + cloudWorkOrderDo.setStatus(WorkOrderStatus.WAIT_CHECK); + cloudWorkOrderDo.setType(WorkOrderType.MODIFY_USER); + cloudWorkOrderDo.setCreateTime(now); + cloudWorkOrderDo.setApplyReason(KylinHttpResponseConstants.UPDATE_REAL_NAME); + cloudWorkOrderDo.setCreateBy(cloudUserDo.getId()); + workOrderService.save(cloudWorkOrderDo); + //修改账户工单详情表 + CloudWorkOrderUserDo workOrderUserDo = new CloudWorkOrderUserDo(); + workOrderUserDo.setOldRealName(oldRealName); + workOrderUserDo.setNewRealName(updateRealNameParam.getRealName()); + workOrderUserDo.setWorkOrderId(cloudWorkOrderDo.getId()); + workOrderUserDo.setCreateTime(now); + workOrderUserDo.setCreateBy(cloudUserDo.getId()); + workOrderUserService.save(workOrderUserDo); + + } + + @Override + public WorkOrderUserDetailRespDto getWorkOrderUserDetailByWorkOrderId(Integer workOrderId) { + WorkOrderUserDetailRespDto workOrderUserDetailRespDto = new WorkOrderUserDetailRespDto(); + + selfWorkOrderService.formatBaseWorkOrderDetail(workOrderId, workOrderUserDetailRespDto); + + CloudUserDo cloudUserDo = cloudUserService.getById(workOrderUserDetailRespDto.getUserId()); + workOrderUserDetailRespDto.setUserName(cloudUserDo.getUserName()); + workOrderUserDetailRespDto.setRealName(cloudUserDo.getRealName()); + workOrderUserDetailRespDto.setMobile(cloudUserDo.getMobile()); + if (cloudUserDo.getOrganizationId() > 0) { + workOrderUserDetailRespDto.setOrganizationName(cloudOrganizationService.getById(cloudUserDo + .getOrganizationId()).getOrganizationName()); + } +// if (cloudUserDo.getDeptId() > 0) { +// workOrderUserDetailRespDto.setDeptName(cloudDeptService.getById(cloudUserDo.getDeptId()).getDeptName()); +// } + + //修改账号,需要查询旧真实姓名,及新真实姓名 + if (Objects.equals(workOrderUserDetailRespDto.getWorkOrderType(), WorkOrderType.MODIFY_USER)) { + CloudWorkOrderUserDo queryDo = new CloudWorkOrderUserDo(); + queryDo.setWorkOrderId(workOrderId); + QueryWrapper wrapper = new QueryWrapper<>(queryDo); + CloudWorkOrderUserDo cloudWorkOrderUserDo = workOrderUserService.getOne(wrapper); + workOrderUserDetailRespDto.setNewRealName(cloudWorkOrderUserDo.getNewRealName()); + } + return workOrderUserDetailRespDto; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfWorkOrderServiceImpl.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfWorkOrderServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f363cda446a593bfc6a1f68395efee1ad39b74ec --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/service/impl/SelfWorkOrderServiceImpl.java @@ -0,0 +1,95 @@ +package com.hnkylin.cloud.selfservice.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hnkylin.cloud.core.common.DateUtils; +import com.hnkylin.cloud.core.common.PageData; +import com.hnkylin.cloud.core.domain.CloudUserDo; +import com.hnkylin.cloud.core.domain.CloudWorkOrderDo; +import com.hnkylin.cloud.core.service.CloudUserService; +import com.hnkylin.cloud.core.service.CloudWorkOrderService; +import com.hnkylin.cloud.selfservice.entity.LoginUserVo; +import com.hnkylin.cloud.selfservice.entity.req.WorkOrderPageParam; +import com.hnkylin.cloud.selfservice.entity.resp.BaseWorkOrderDetailDto; +import com.hnkylin.cloud.selfservice.entity.resp.PageWorkOrderRespDto; +import com.hnkylin.cloud.selfservice.service.SelfWorkOrderService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class SelfWorkOrderServiceImpl implements SelfWorkOrderService { + + @Resource + private CloudWorkOrderService cloudWorkOrderService; + + @Resource + private CloudUserService cloudUserService; + + @Override + public PageData pageWorkOrder(WorkOrderPageParam workOrderPageParam, + LoginUserVo loginUserVo) { + + CloudWorkOrderDo cloudWorkOrderDo = new CloudWorkOrderDo(); + cloudWorkOrderDo.setDeleteFlag(Boolean.FALSE); + cloudWorkOrderDo.setUserId(loginUserVo.getUserId()); + QueryWrapper wrapper = new QueryWrapper<>(cloudWorkOrderDo); + wrapper.orderByDesc("id"); + + PageHelper.startPage(workOrderPageParam.getPageNo(), workOrderPageParam.getPageSize()); + List workOrderDoList = cloudWorkOrderService.list(wrapper); + + PageInfo pageInfo = new PageInfo<>(workOrderDoList); + + List list = new ArrayList<>(workOrderDoList.size()); + workOrderDoList.forEach(workOrder -> { + PageWorkOrderRespDto workOrderRespDto = new PageWorkOrderRespDto(); + workOrderRespDto.setWorkOrderId(workOrder.getId()); + workOrderRespDto.setType(workOrder.getType()); + workOrderRespDto.setTypeDesc(workOrder.getType().getDesc()); + workOrderRespDto.setTarget(workOrder.getTarget()); + workOrderRespDto.setStatus(workOrder.getStatus()); + workOrderRespDto.setStatusDesc(workOrder.getStatus().getDesc()); + workOrderRespDto.setApplyReason(workOrder.getApplyReason()); + workOrderRespDto.setAuditOpinion(workOrder.getAuditOpinion()); + workOrderRespDto.setApplyTime(DateUtils.format(workOrder.getCreateTime(), DateUtils.DATE_ALL_PATTEN)); + list.add(workOrderRespDto); + }); + PageData pageData = new PageData(pageInfo); + pageData.setList(list); + + return pageData; + } + + @Override + public void formatBaseWorkOrderDetail(Integer workOrderId, BaseWorkOrderDetailDto baseWorkOrderDetailDto) { + CloudWorkOrderDo cloudWorkOrderDo = cloudWorkOrderService.getById(workOrderId); + baseWorkOrderDetailDto.setWorkOrderTarget(cloudWorkOrderDo.getTarget()); + baseWorkOrderDetailDto.setWorkOrderType(cloudWorkOrderDo.getType()); + baseWorkOrderDetailDto.setWorkOrderTypeDesc(cloudWorkOrderDo.getType().getDesc()); + baseWorkOrderDetailDto.setApplyReason(cloudWorkOrderDo.getApplyReason()); + baseWorkOrderDetailDto.setStatus(cloudWorkOrderDo.getStatus()); + baseWorkOrderDetailDto.setStatusDesc(cloudWorkOrderDo.getStatus().getDesc()); + baseWorkOrderDetailDto.setUserId(cloudWorkOrderDo.getUserId()); + baseWorkOrderDetailDto.setApplyTime(DateUtils.format(cloudWorkOrderDo.getCreateTime(), + DateUtils.DATE_ALL_PATTEN)); + baseWorkOrderDetailDto.setAuditOpinion(cloudWorkOrderDo.getAuditOpinion()); + + if (Objects.nonNull(cloudWorkOrderDo.getAuditTime())) { + baseWorkOrderDetailDto.setAuditionTime(DateUtils.format(cloudWorkOrderDo.getAuditTime(), + DateUtils.DATE_ALL_PATTEN)); + } + if (Objects.nonNull(cloudWorkOrderDo.getAuditBy()) && cloudWorkOrderDo.getAuditBy() > 0) { + CloudUserDo auditionUser = cloudUserService.getById(cloudWorkOrderDo.getAuditBy()); + baseWorkOrderDetailDto.setAuditionUser(auditionUser.getUserName()); + if (StringUtils.isNotBlank(auditionUser.getRealName())) { + baseWorkOrderDetailDto.setAuditionUser(auditionUser.getRealName()); + } + } + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/threadTask/McClusterNoDataThread.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/threadTask/McClusterNoDataThread.java new file mode 100644 index 0000000000000000000000000000000000000000..5e8fafc332eeb8d27542e4d84f0dd3fb929eab3c --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/threadTask/McClusterNoDataThread.java @@ -0,0 +1,55 @@ +package com.hnkylin.cloud.selfservice.threadTask; + +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.selfservice.service.McHttpService; + +import java.util.Objects; +import java.util.concurrent.Callable; + + +/** + * 向mc多集群发送无数据获取请假 + */ +public class McClusterNoDataThread implements Callable> { + + + private McHttpService mcHttpService; + + + private String loginUserName; + + private Integer clusterId; + + private String mcInterfaceUrl; + + private Object requestObject; + + + public McClusterNoDataThread(McHttpService mcHttpService, + String loginUserName, + Integer clusterId, String mcInterfaceUrl, Object requestObject) { + //this.latch = latch; + this.mcHttpService = mcHttpService; + this.loginUserName = loginUserName; + this.clusterId = clusterId; + this.mcInterfaceUrl = mcInterfaceUrl; + this.requestObject = requestObject; + } + + @Override + public MCResponseData call() { + MCResponseData mcResponse = null; + try { + mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, requestObject, mcInterfaceUrl, loginUserName + , 0); + if (Objects.nonNull(mcResponse)) { + return mcResponse; + + } + } catch (Exception e) { + e.printStackTrace(); + + } + return mcResponse; + } +} diff --git a/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/threadTask/McClusterThread.java b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/threadTask/McClusterThread.java new file mode 100644 index 0000000000000000000000000000000000000000..364b347afb5681ff916c4e9a3b2ebb2ce5797f26 --- /dev/null +++ b/mcp-self-service/src/main/java/com/hnkylin/cloud/selfservice/threadTask/McClusterThread.java @@ -0,0 +1,56 @@ +package com.hnkylin.cloud.selfservice.threadTask; + +import com.alibaba.fastjson.JSON; +import com.hnkylin.cloud.core.common.MCResponseData; +import com.hnkylin.cloud.core.common.MCServerVmConstants; +import com.hnkylin.cloud.selfservice.service.McHttpService; + +import java.util.Objects; +import java.util.concurrent.Callable; + + +/** + * 通用从mc集群中获取数据线程 + */ +public class McClusterThread implements Callable { + + + private McHttpService mcHttpService; + + + private String loginUserName; + + private Integer clusterId; + + private String mcInterfaceUrl; + + private Object requestObject; + + + public McClusterThread(McHttpService mcHttpService, String loginUserName, + Integer clusterId, String mcInterfaceUrl, Object requestObject) { + //this.latch = latch; + this.mcHttpService = mcHttpService; + this.loginUserName = loginUserName; + this.clusterId = clusterId; + this.mcInterfaceUrl = mcInterfaceUrl; + this.requestObject = requestObject; + } + + @Override + public String call() { + + String mcClusterResponse = null; + try { + MCResponseData mcResponse = mcHttpService.hasDataCommonMcRequest(clusterId, requestObject, + mcInterfaceUrl, loginUserName, 0); + if (Objects.nonNull(mcResponse) && Objects.equals(MCServerVmConstants.SUCCESS, mcResponse.getStatus())) { + mcClusterResponse = JSON.toJSONString(mcResponse.getData()); + } + } catch (Exception e) { + e.printStackTrace(); + + } + return mcClusterResponse; + } +} diff --git a/mcp-self-service/src/main/resources/application-dev.yml b/mcp-self-service/src/main/resources/application-dev.yml new file mode 100644 index 0000000000000000000000000000000000000000..93559366f9f9c5832271c2d81ba79e1ab38ebc38 --- /dev/null +++ b/mcp-self-service/src/main/resources/application-dev.yml @@ -0,0 +1,2 @@ +mc-config: + mcLogoLocalFilePath: E:\mcServerVmLogo\ \ No newline at end of file diff --git a/mcp-self-service/src/main/resources/application-prod.yml b/mcp-self-service/src/main/resources/application-prod.yml new file mode 100644 index 0000000000000000000000000000000000000000..72e8e342cf07e3ec8b2389da6e3f69f930073227 --- /dev/null +++ b/mcp-self-service/src/main/resources/application-prod.yml @@ -0,0 +1,13 @@ +server: + ssl: + key-store: classpath:keystore.p12 + key-password: 111111 + key-store-type: PKCS12 + enabled-protocols: TLSv1,TLSv1.1,TLSv1.2 + ciphers: TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DH_DSS_WITH_AES_128_CBC_SHA, TLS_DH_DSS_WITH_AES_256_CBC_SHA, TLS_DH_RSA_WITH_AES_128_CBC_SHA, TLS_DH_RSA_WITH_AES_256_CBC_SHA + client-auth: + enabled: true + protocol: TLS + key-store-password: 111111 +mc-config: + mcLogoLocalFilePath: /soft/mcServerVmLogo/ diff --git a/mcp-self-service/src/main/resources/application.yml b/mcp-self-service/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..861254e463f2b523eb12b15cab3a0c839a58542e --- /dev/null +++ b/mcp-self-service/src/main/resources/application.yml @@ -0,0 +1,135 @@ +server: + servlet: + context-path: /portal + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + # Tomcat启动初始化的线程数,默认值25 + threads: + max: 500 + min-spare: 30 + port: 8081 +logging: + config: classpath:logback.xml +spring: + thymeleaf: + #模板的模式,支持 HTML, XML TEXT JAVASCRIPT + mode: HTML5 + #编码 可不用配置 + encoding: UTF-8 + #开发配置为false,避免修改模板还要重启服务器 + cache: false + #配置模板路径,默认是templates,可以不用配置 + prefix: classpath:/templates/ + suffix: .html + servlet: + content-type: text/html + mvc: + static-path-pattern: /static/** + datasource: + url: jdbc:mysql://127.0.0.1:3306/mcp?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false + username: root + password: your_password + driver-class-name: com.mysql.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 + min-idle: 5 + max-active: 30 + # 配置获取连接等待超时的时间 + max-wait: 6000 + time-between-connect-error-millis: 10000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + time-between-eviction-runs-millis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + min-evictable-idle-time-millis: 300000 + validation-query: SELECT 1 FROM DUAL + validation-query-timeout: 50000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + # 打开PSCache,并且指定每个连接上PSCache的大小 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙,此处是filter修改的地方 + filter: + commons-log: + enabled: true + connection-logger-name: stat, wall, log4j + # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 + connection-properties: druid.stat.mergeSql:true;druid.stat.slowSqlMillis:5000 + # 合并多个DruidDataSource的监控数据 + use-global-data-source-stat: true + platform: mysql + redis: + # 地址 + host: 127.0.0.1 + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + #password: 123456Qw + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + profiles: + active: dev +mybatis-plus: + mapper-locations: classpath:mapping/*Mapper.xml + type-aliases-package: com.hnkylin.cloud.selfservice.domain,com.hnkylin.cloud.core.domain + global-config: + id-type: 0 + configuration: + default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler +auth: + authExcludeApis: + - /portal/api/user/register + - /portal/api/login + - /portal/error + - /portal/index + - /portal/api/org/queryOrgList +mc-config: + mcPrefix: /kylin + commonPrefix: /mc/api + templateListUrl: /getTemplates + serverVmList: /getSelfServiceVmList + startServerVmUrl: /selfServiceVmServerStart + shutdownServerVmUrl: /selfServiceShutDown + forcedShutdownServerVmUrl: /selfServiceAbort + forcedRestartServerVmUrl: /selfServiceForceReboot + restartServerVmUrl: /selfServiceReboot + batchStartServerVmUrl: /startSelfServiceForBatch + batchShutdownServerVmUrl: /shutDownSelfServiceForBatch + batchRebootServerVmUrl: /rebootForBatch + serverVmInfoUrl: /selfServiceMachineDetailInfo + serverVmMonitorInfoUrl: /listServerVMStatus + serverVmOperateLogUrl: /listTasksByServerId + serverVmSnapshotListUrl: /serverSnapshotList + serverVmCreateSnapshotUrl: /createServerSnap + serverVmUpdateSnapshotUrl: /updateServerSnapData + serverVmDeleteSnapshotUrl: /deleteServerSnapshot + serverVmApplySnapshotUrl: /applyServerBatchSnap + serverVmVncUrl: /getServerVmVncUrl + batchRemoveMachineToRecycleUrl: /batchRemoveMachineToRecycle + serverVmStatusUrl: /getMachineStatus + updateMachineDescriptionUrl: /updateMachineDescription + resetRemotePasswordUrl: /resetRemotePassword + getServervmDetailByServevmIdUrl: /getServervmDetailByServevmId + logoPath: /images/hnkylin/ + isoListUrl: /isoList + allOperatingSystemUrl: /getAllOperatingSystem + updateMachineNameUrl: /updateMachineName + checkVmServerNameUrl: /checkVmServerName + + diff --git a/mcp-self-service/src/main/resources/db/kcp_data.sql b/mcp-self-service/src/main/resources/db/kcp_data.sql new file mode 100644 index 0000000000000000000000000000000000000000..3318d1dd8538b5602e5fc90793e4f8e20c68cf44 --- /dev/null +++ b/mcp-self-service/src/main/resources/db/kcp_data.sql @@ -0,0 +1,6 @@ +INSERT INTO kcp.cloud_organization (id, organization_name, parent_id, remark, create_by, create_time, update_by, update_time, delete_flag, delete_time, delete_by) VALUES (1, '麒麟信安', 0, null, 0, '2021-06-17 16:04:35', 0, null, false, null, 0); +INSERT INTO kcp.cloud_organization (id, organization_name, parent_id, remark, create_by, create_time, update_by, update_time, delete_flag, delete_time, delete_by) VALUES (2, '陕西麒麟', 1, null, 0, '2021-06-17 16:04:57', 0, null, false, null, 0); +INSERT INTO kcp.cloud_organization (id, organization_name, parent_id, remark, create_by, create_time, update_by, update_time, delete_flag, delete_time, delete_by) VALUES (3, '研发一部', 1, null, 0, '2021-06-17 16:05:37', 0, null, false, null, 0); + +INSERT INTO kcp.cloud_user (id, user_name, real_name, password, mobile, remark, organization_id, user_type, status, +create_by, create_time, update_by, update_time, delete_flag, delete_time, delete_by) VALUES (1, 'admin', '系统管理员', '25f9e794323b453885f5181f1b624d0b', '13000000000', '系统管理员', 1, 1, 1, 0, '2021-08-20 10:05:21', 0, null, false, null, 0); \ No newline at end of file diff --git a/mcp-self-service/src/main/resources/db/kcp_schema.sql b/mcp-self-service/src/main/resources/db/kcp_schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..c8831b4c65318a05f27e3d8040725c0e02366714 --- /dev/null +++ b/mcp-self-service/src/main/resources/db/kcp_schema.sql @@ -0,0 +1,286 @@ +/* + Navicat Premium Data Transfer + + Source Server : 本地 + Source Server Type : MySQL + Source Server Version : 50730 + Source Host : localhost:3306 + Source Schema : kcp + + Target Server Type : MySQL + Target Server Version : 50730 + File Encoding : 65001 + + Date: 01/12/2021 17:42:23 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for cloud_network_config +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_network_config`; +CREATE TABLE `cloud_network_config` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `network_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网络名称', + `interface_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网络类型', + `address_pool` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地址池', + `address_pool_id` int(11) NOT NULL DEFAULT 0 COMMENT '地址池ID', + `virtual_switch` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '虚拟交换机', + `model_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网卡类型', + `port_group` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '端口组', + `port_group_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '端口组uuid', + `security_group_uuid` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安全组uuid', + `security_group` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安全组', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT NULL COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +INSERT INTO `cloud_user` VALUES (1, 'admin', '系统管理员', '25f9e794323b453885f5181f1b624d0b', '13000000000', '系统管理员', 1, 1, 1, 0, '2021-08-20 10:05:21', 0, NULL, b'0', NULL, 0); + +-- ---------------------------- +-- Table structure for cloud_organization +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_organization`; +CREATE TABLE `cloud_organization` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '组织ID', + `organization_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '组织名称', + `parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '上级组织ID', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `index_name`(`organization_name`, `delete_flag`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '组织表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_user +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_user`; +CREATE TABLE `cloud_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', + `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户姓名', + `real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '真实姓名', + `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', + `mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机号', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', + `organization_id` int(11) NOT NULL DEFAULT 0 COMMENT '组织ID', + `user_type` tinyint(4) NULL DEFAULT 0 COMMENT '用户类型 0:自服务用户, 1:云管用户', + `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + INDEX `index_org`(`organization_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_user_machine +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_user_machine`; +CREATE TABLE `cloud_user_machine` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `user_id` int(11) NOT NULL COMMENT '用户ID', + `machine_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'mc中云服务器ID', + `deadline_time` datetime(0) NOT NULL COMMENT '截止时间', + `deadline_type` int(11) NULL DEFAULT 0 COMMENT '到期处理策略', + `deadline_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否过期 0:没有 1:已过期', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:删除 1:未删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `index_uuid`(`machine_uuid`) USING BTREE, + INDEX `index_user_id`(`user_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户拥有云服务器关联表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order`; +CREATE TABLE `cloud_work_order` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL COMMENT '用户ID', + `type` int(2) NOT NULL COMMENT '工单类型', + `target` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工单对象', + `apply_reason` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '申请原因', + `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '工单状态', + `audit_by` int(11) NOT NULL DEFAULT 0 COMMENT '审核者', + `audit_time` datetime(0) NULL DEFAULT NULL COMMENT '审核时间', + `audit_opinion` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审核时间', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT NULL COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order_deferred_machine +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_deferred_machine`; +CREATE TABLE `cloud_work_order_deferred_machine` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `old_deadline_time` datetime(0) NOT NULL COMMENT '原过期时间', + `deadline_time` datetime(0) NOT NULL COMMENT '截止时间', + `user_machine_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户拥有云服务器关联表ID', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请延期表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order_modify_servervm +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_modify_servervm`; +CREATE TABLE `cloud_work_order_modify_servervm` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `machine_uuid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '云服务器uuid', + `servervm_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '虚拟机名称', + `deadline_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '到期处理策略', + `os_machine` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作系统', + `architecture` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '架构', + `system_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统类型', + `cpu` int(11) NOT NULL DEFAULT 0 COMMENT 'cpu数', + `mem` int(11) NOT NULL COMMENT '内存', + `mem_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '内存单位', + `deadline_time` datetime(0) NULL DEFAULT NULL COMMENT '到期时间', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-变更云服务器表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm`; +CREATE TABLE `cloud_work_order_servervm` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `servervm_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '虚拟机名称', + `apply_num` int(11) NOT NULL DEFAULT 0 COMMENT '申请个数', + `use_month` int(11) NOT NULL DEFAULT 0 COMMENT '使用月数', + `deadline_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '到期处理策略', + `os_machine` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作系统', + `architecture` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '架构', + `system_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统类型', + `template_id` int(11) NOT NULL COMMENT '模板ID', + `cpu` int(11) NOT NULL DEFAULT 0 COMMENT 'cpu数', + `modify_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更后cpu', + `mem` int(11) NOT NULL COMMENT '内存', + `modify_mem` int(11) NULL DEFAULT NULL COMMENT '变更后内存', + `mem_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '内存单位', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请云服务器表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm_disk +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm_disk`; +CREATE TABLE `cloud_work_order_servervm_disk` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL DEFAULT 0 COMMENT '工单ID', + `disk_id` int(11) NOT NULL COMMENT '磁盘ID', + `disk_size` int(11) NOT NULL COMMENT '硬盘大小', + `disk_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '硬盘单位 0:GB 1:TB', + `purpose` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用途', + `type` tinyint(4) NULL DEFAULT 0 COMMENT '类型 0:原始,1:自定义', + `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除', + `old_disk_size` int(11) NOT NULL DEFAULT 0 COMMENT '原来磁盘大小', + `old_disk_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '原来磁盘单位 0:GB 1:TB', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请服务器硬盘详情表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order_servervm_network +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_servervm_network`; +CREATE TABLE `cloud_work_order_servervm_network` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `interface_id` int(11) NOT NULL DEFAULT 0 COMMENT '网卡ID', + `purpose` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用途', + `type` tinyint(4) NULL DEFAULT 0 COMMENT '类型 0:原始,1 自定义', + `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除', + `create_by` int(11) NOT NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-申请服务器网卡详情表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cloud_work_order_user +-- ---------------------------- +DROP TABLE IF EXISTS `cloud_work_order_user`; +CREATE TABLE `cloud_work_order_user` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `work_order_id` int(11) NOT NULL COMMENT '工单ID', + `old_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '旧真实姓名', + `new_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '新真实姓名', + `create_by` int(11) NULL DEFAULT 0 COMMENT '创建者', + `create_time` datetime(0) NOT NULL COMMENT '创建时间', + `update_by` int(11) NULL DEFAULT 0 COMMENT '变更者', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '变更时间', + `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:已删除', + `delete_time` datetime(0) NULL DEFAULT NULL COMMENT '删除时间', + `delete_by` int(11) NULL DEFAULT 0 COMMENT '删除者', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `work_order_id`(`work_order_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单-变更账号详情表' ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/mcp-self-service/src/main/resources/db/update_schema.sql b/mcp-self-service/src/main/resources/db/update_schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..8f94481068fb8c8402d49effd0ee0e440bc18b56 --- /dev/null +++ b/mcp-self-service/src/main/resources/db/update_schema.sql @@ -0,0 +1,151 @@ +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +CHANGE COLUMN `apply_id` `work_order_id` int(11) NOT NULL COMMENT '工单ID' AFTER `id`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_network` +CHANGE COLUMN `apply_id` `work_order_id` int(11) NOT NULL COMMENT '工单ID' AFTER `id`; + + + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `system_type` varchar(255) NULL COMMENT '系统类型' AFTER `architecture`; + + +ALTER TABLE `kcp`.`cloud_work_order_modify_servervm` +ADD COLUMN `system_type` varchar(255) NULL COMMENT '系统类型' AFTER `architecture`; + + + +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +ADD COLUMN `apply_delete` bit(1) NULL DEFAULT 0 COMMENT '申请删除 0:否 1:删除' AFTER `type`, +MODIFY COLUMN `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:删除' AFTER `update_time`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +ADD COLUMN `disk_id` int(11) NULL DEFAULT 0 COMMENT '磁盘ID' AFTER `type`; + + + +ALTER TABLE `kcp`.`cloud_work_order_servervm_network` +ADD COLUMN `apply_delete` bit(1) NULL DEFAULT 0 COMMENT '申请删除 0:否 1:删除' AFTER `type`, +MODIFY COLUMN `delete_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除表中 0:未删除 1:删除' AFTER `update_time`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_network` +ADD COLUMN `network_id` int(11) NULL DEFAULT 0 COMMENT 'mc中网卡ID' AFTER `type`; + + + +//2021-10-25 +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +ADD COLUMN `disk_id` bigint(11) NOT NULL DEFAULT 0 COMMENT '磁盘ID' AFTER `work_order_id`; + + +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +ADD COLUMN `disk_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '硬盘单位 0:GB 1:TB' AFTER `disk_size`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +ADD COLUMN `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除' AFTER `type`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_disk` +ADD COLUMN `old_disk_size` int(11) NOT NULL DEFAULT 0 COMMENT '原来磁盘大小' AFTER `modify_type`, +ADD COLUMN `old_disk_unit` tinyint(1) NOT NULL DEFAULT 0 COMMENT '原来磁盘单位 0:GB 1:TB' AFTER `old_disk_size`; + + +ALTER TABLE `kcp`.`cloud_work_order_servervm_network` +ADD COLUMN `interface_id` bigint(11) NOT NULL DEFAULT 0 COMMENT '网卡ID' AFTER `work_order_id`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_network` +ADD COLUMN `modify_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '变更类型 0:无变动 ,1:新增,2:变更,3:删除' AFTER `type`; + + + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `modify_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更后cpu' AFTER `cpu`, +ADD COLUMN `modify_mem` int(11) NULL COMMENT '变更后内存' AFTER `mem`; + +update cloud_work_order_servervm set modify_cpu=cpu,modify_mem=mem; + +ALTER TABLE `kcp`.`cloud_user` +CHANGE COLUMN `nick_name` `real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '真实姓名' AFTER `user_name`; + +ALTER TABLE `kcp`.`cloud_work_order_user` +CHANGE COLUMN `old_nick_name` `old_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '旧真实姓名' AFTER `work_order_id`, +CHANGE COLUMN `new_nick_name` `new_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '新真实姓名' AFTER `old_real_name`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `description` varchar(255) NULL COMMENT '备注信息' AFTER `mem_unit`; + + + + + +/* + * 2021-12-08 + */ +ALTER TABLE `kcp`.`cloud_work_order_modify_servervm` +ADD COLUMN `original_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更前cpu数' AFTER `cpu`, +ADD COLUMN `original_mem` int(11) NOT NULL COMMENT '变更前内存' AFTER `mem`; + + +update cloud_work_order_modify_servervm set original_cpu=cpu,original_mem=mem; + + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `modify_apply_num` int(11) NOT NULL DEFAULT 0 COMMENT '变更后申请个数' AFTER `apply_num`; + +update cloud_work_order_servervm set modify_apply_num=apply_num; + + + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `modify_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更后cpu' AFTER `cpu`, +ADD COLUMN `modify_mem` int(11) NULL COMMENT '变更后内存' AFTER `mem`; + +update cloud_work_order_servervm set modify_cpu=cpu,modify_mem=mem; + +ALTER TABLE `kcp`.`cloud_user` +CHANGE COLUMN `nick_name` `real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '真实姓名' AFTER `user_name`; + +ALTER TABLE `kcp`.`cloud_work_order_user` +CHANGE COLUMN `old_nick_name` `old_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '旧真实姓名' AFTER `work_order_id`, +CHANGE COLUMN `new_nick_name` `new_real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '新真实姓名' AFTER `old_real_name`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `description` varchar(255) NULL COMMENT '备注信息' AFTER `mem_unit`; + + + + + +/* + * 2021-12-08 + */ +ALTER TABLE `kcp`.`cloud_work_order_modify_servervm` +ADD COLUMN `original_cpu` int(11) NOT NULL DEFAULT 0 COMMENT '变更前cpu数' AFTER `cpu`, +ADD COLUMN `original_mem` int(11) NOT NULL COMMENT '变更前内存' AFTER `mem`; + + +update cloud_work_order_modify_servervm set original_cpu=cpu,original_mem=mem; + + +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `modify_apply_num` int(11) NOT NULL DEFAULT 0 COMMENT '变更后申请个数' AFTER `apply_num`; + +update cloud_work_order_servervm set modify_apply_num=apply_num; + + + +#2021-12-23 +ALTER TABLE `kcp`.`cloud_work_order_servervm` +ADD COLUMN `apply_servervm_type` tinyint(11) NULL DEFAULT 0 COMMENT '申请类型' AFTER `work_order_id`; + +ALTER TABLE `kcp`.`cloud_work_order_servervm_network` +ADD COLUMN `ip_bind_mac` bit(1) NOT NULL DEFAULT b'0' COMMENT 'ip和mac绑定 0:未绑定 1:已绑定' AFTER `modify_type`, +ADD COLUMN `manual_set_ip` bit(1) NOT NULL DEFAULT b'0' COMMENT '手动设置ip 0:未设置 1:已设置' AFTER `ip_bind_mac`, +ADD COLUMN `automatic_acq_ip` bit(1) NOT NULL DEFAULT b'0' COMMENT '自动DHP 0:未设置 1:已设置' AFTER `manual_set_ip`, +ADD COLUMN `ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 'ip地址' AFTER `automatic_acq_ip`, +ADD COLUMN `mask` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '掩码' AFTER `ip`, +ADD COLUMN `gw` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '网关' AFTER `mask`, +ADD COLUMN `dns1` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 'dns1' AFTER `gw`, +ADD COLUMN `dns2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 'dns2' AFTER `dns1`; + + + diff --git a/mcp-self-service/src/main/resources/keystore.p12 b/mcp-self-service/src/main/resources/keystore.p12 new file mode 100644 index 0000000000000000000000000000000000000000..7bf21ffd6f40b4218f0923178df1c09bcaab005a Binary files /dev/null and b/mcp-self-service/src/main/resources/keystore.p12 differ diff --git a/mcp-self-service/src/main/resources/logback.xml b/mcp-self-service/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..5b6d53495b54d1160dd79dbf67bbd386b4da584b --- /dev/null +++ b/mcp-self-service/src/main/resources/logback.xml @@ -0,0 +1,37 @@ + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg %n + + + + + + + + /var/log/kcp/portal.log + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg %n + + + /var/log/kcp/portal.log.%d{yyyy-MM-dd} + + 15 + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4beaf9b9ea5bc9b588e572c5a93262e28d1cde97 --- /dev/null +++ b/pom.xml @@ -0,0 +1,87 @@ + + + 4.0.0 + + com.hnkylin + mcp + pom + 1.0-SNAPSHOT + + mcp-self-service + mcp-cloud-core + mcp-cloud-manage + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.1.RELEASE + + + + UTF-8 + 1.8 + 2.1.1.RELEASE + + + + + org.projectlombok + lombok + true + 1.18.18 + + + + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + + com.baomidou + mybatis-plus-boot-starter + 3.2.0 + + + org.springframework.boot + spring-boot-starter-aop + + + com.alibaba + fastjson + 1.2.60 + + + + org.projectlombok + lombok + true + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + + org.apache.maven.plugins + maven-release-plugin + + v@{project.version} + true + + + + + + \ No newline at end of file