Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
955b441b
authored
Aug 06, 2025
by
Jony.L
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品展示 初步提交
parent
fb777398
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1217 additions
and
581 deletions
+1217
-581
computility-framework/computility-common/pom.xml
+4
-0
computility-framework/computility-common/src/main/java/com/luhu/computility/framework/common/core/redis/RedisCache.java
+265
-0
computility-framework/computility-spring-boot-starter-web/src/main/java/com/luhu/computility/framework/web/config/ComputilityWebAutoConfiguration.java
+14
-14
computility-framework/computility-spring-boot-starter-web/src/main/java/com/luhu/computility/framework/web/core/handler/GlobalExceptionHandler.java
+21
-13
computility-module-biz/pom.xml
+7
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/app/index/ApiController.java
+620
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/app/index/vo/ComputeRespVO.java
+29
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/client/ApiController.java
+0
-552
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/client/dto/MenuDTO.java
+20
-0
computility-module-mall/computility-module-product/src/main/java/com/luhu/computility/module/product/service/spu/ProductSpuService.java
+8
-0
computility-module-mall/computility-module-product/src/main/java/com/luhu/computility/module/product/service/spu/ProductSpuServiceImpl.java
+8
-0
computility-module-system/pom.xml
+6
-0
computility-module-system/src/main/java/com/luhu/computility/module/system/service/dict/DictTypeServiceImpl.java
+29
-0
computility-module-system/src/main/java/com/luhu/computility/module/system/util/dict/DictUtils.java
+182
-0
computility-server/src/main/java/com/luhu/computility/server/ComputilityServerApplication.java
+4
-2
No files found.
computility-framework/computility-common/pom.xml
View file @
955b441b
...
...
@@ -144,6 +144,10 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-redis
</artifactId>
</dependency>
</dependencies>
</project>
computility-framework/computility-common/src/main/java/com/luhu/computility/framework/common/core/redis/RedisCache.java
0 → 100644
View file @
955b441b
package
com
.
luhu
.
computility
.
framework
.
common
.
core
.
redis
;
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
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
/**
* @Author: jony
* @Date : 2025/7/30 16:52
* @VERSION v1.0
*/
@SuppressWarnings
(
value
=
{
"unchecked"
,
"rawtypes"
})
@Component
public
class
RedisCache
{
@Autowired
public
RedisTemplate
redisTemplate
;
/**
* 缓存基本的对象,Integer、String、实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
*/
public
<
T
>
void
setCacheObject
(
final
String
key
,
final
T
value
)
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
);
}
/**
* 缓存基本的对象,Integer、String、实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
*/
public
<
T
>
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 Redis键
* @return 有效时间
*/
public
long
getExpire
(
final
String
key
)
{
return
redisTemplate
.
getExpire
(
key
);
}
/**
* 判断 key是否存在
*
* @param key 键
* @return true 存在 false不存在
*/
public
Boolean
hasKey
(
String
key
)
{
return
redisTemplate
.
hasKey
(
key
);
}
/**
* 获得缓存的基本对象。
*
* @param key 缓存键值
* @return 缓存键值对应的数据
*/
public
<
T
>
T
getCacheObject
(
final
String
key
)
{
ValueOperations
<
String
,
T
>
operation
=
redisTemplate
.
opsForValue
();
return
operation
.
get
(
key
);
}
/**
* 删除单个对象
*
* @param key
*/
public
boolean
deleteObject
(
final
String
key
)
{
return
redisTemplate
.
delete
(
key
);
}
/**
* 删除集合对象
*
* @param collection 多个对象
* @return
*/
public
boolean
deleteObject
(
final
Collection
collection
)
{
return
redisTemplate
.
delete
(
collection
)
>
0
;
}
/**
* 缓存List数据
*
* @param key 缓存的键值
* @param dataList 待缓存的List数据
* @return 缓存的对象
*/
public
<
T
>
long
setCacheList
(
final
String
key
,
final
List
<
T
>
dataList
)
{
Long
count
=
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
dataList
);
return
count
==
null
?
0
:
count
;
}
/**
* 获得缓存的list对象
*
* @param key 缓存的键值
* @return 缓存键值对应的数据
*/
public
<
T
>
List
<
T
>
getCacheList
(
final
String
key
)
{
return
redisTemplate
.
opsForList
().
range
(
key
,
0
,
-
1
);
}
/**
* 缓存Set
*
* @param key 缓存键值
* @param dataSet 缓存的数据
* @return 缓存数据的对象
*/
public
<
T
>
BoundSetOperations
<
String
,
T
>
setCacheSet
(
final
String
key
,
final
Set
<
T
>
dataSet
)
{
BoundSetOperations
<
String
,
T
>
setOperation
=
redisTemplate
.
boundSetOps
(
key
);
Iterator
<
T
>
it
=
dataSet
.
iterator
();
while
(
it
.
hasNext
())
{
setOperation
.
add
(
it
.
next
());
}
return
setOperation
;
}
/**
* 获得缓存的set
*
* @param key
* @return
*/
public
<
T
>
Set
<
T
>
getCacheSet
(
final
String
key
)
{
return
redisTemplate
.
opsForSet
().
members
(
key
);
}
/**
* 缓存Map
*
* @param key
* @param dataMap
*/
public
<
T
>
void
setCacheMap
(
final
String
key
,
final
Map
<
String
,
T
>
dataMap
)
{
if
(
dataMap
!=
null
)
{
redisTemplate
.
opsForHash
().
putAll
(
key
,
dataMap
);
}
}
/**
* 获得缓存的Map
*
* @param key
* @return
*/
public
<
T
>
Map
<
String
,
T
>
getCacheMap
(
final
String
key
)
{
return
redisTemplate
.
opsForHash
().
entries
(
key
);
}
/**
* 往Hash中存入数据
*
* @param key Redis键
* @param hKey Hash键
* @param value 值
*/
public
<
T
>
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
>
T
getCacheMapValue
(
final
String
key
,
final
String
hKey
)
{
HashOperations
<
String
,
String
,
T
>
opsForHash
=
redisTemplate
.
opsForHash
();
return
opsForHash
.
get
(
key
,
hKey
);
}
/**
* 获取多个Hash中的数据
*
* @param key Redis键
* @param hKeys Hash键集合
* @return Hash对象集合
*/
public
<
T
>
List
<
T
>
getMultiCacheMapValue
(
final
String
key
,
final
Collection
<
Object
>
hKeys
)
{
return
redisTemplate
.
opsForHash
().
multiGet
(
key
,
hKeys
);
}
/**
* 删除Hash中的某条数据
*
* @param key Redis键
* @param hKey Hash键
* @return 是否成功
*/
public
boolean
deleteCacheMapValue
(
final
String
key
,
final
String
hKey
)
{
return
redisTemplate
.
opsForHash
().
delete
(
key
,
hKey
)
>
0
;
}
/**
* 获得缓存的基本对象列表
*
* @param pattern 字符串前缀
* @return 对象列表
*/
public
Collection
<
String
>
keys
(
final
String
pattern
)
{
return
redisTemplate
.
keys
(
pattern
);
}
}
computility-framework/computility-spring-boot-starter-web/src/main/java/com/luhu/computility/framework/web/config/ComputilityWebAutoConfiguration.java
View file @
955b441b
...
...
@@ -34,11 +34,11 @@ public class ComputilityWebAutoConfiguration implements WebMvcConfigurer {
@Resource
private
WebProperties
webProperties
;
/**
* 应用名
*/
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
//
/**
//
* 应用名
//
*/
//
@Value("${spring.application.name}")
//
private String applicationName;
@Override
public
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
...
...
@@ -58,16 +58,16 @@ public class ComputilityWebAutoConfiguration implements WebMvcConfigurer {
&&
antPathMatcher
.
match
(
api
.
getController
(),
clazz
.
getPackage
().
getName
()));
// 仅仅匹配 controller 包
}
@Bean
@SuppressWarnings
(
"SpringJavaInjectionPointsAutowiringInspection"
)
public
GlobalExceptionHandler
globalExceptionHandler
(
ApiErrorLogCommonApi
apiErrorLogApi
)
{
return
new
GlobalExceptionHandler
(
applicationName
,
apiErrorLogApi
);
}
//
@Bean
//
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
//
public GlobalExceptionHandler globalExceptionHandler(ApiErrorLogCommonApi apiErrorLogApi) {
//
return new GlobalExceptionHandler(applicationName, apiErrorLogApi);
//
}
@Bean
public
GlobalResponseBodyHandler
globalResponseBodyHandler
()
{
return
new
GlobalResponseBodyHandler
();
}
//
@Bean
//
public GlobalResponseBodyHandler globalResponseBodyHandler() {
//
return new GlobalResponseBodyHandler();
//
}
@Bean
@SuppressWarnings
(
"InstantiationOfUtilityClass"
)
...
...
computility-framework/computility-spring-boot-starter-web/src/main/java/com/luhu/computility/framework/web/core/handler/GlobalExceptionHandler.java
View file @
955b441b
...
...
@@ -18,6 +18,7 @@ import com.luhu.computility.framework.common.biz.infra.logger.dto.ApiErrorLogCre
import
com.fasterxml.jackson.databind.exc.InvalidFormatException
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.converter.HttpMessageNotReadableException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.util.Assert
;
...
...
@@ -49,7 +50,7 @@ import static com.luhu.computility.framework.common.exception.enums.GlobalErrorC
* @author 芋道源码
*/
@RestControllerAdvice
@AllArgsConstructor
//
@AllArgsConstructor
@Slf4j
public
class
GlobalExceptionHandler
{
...
...
@@ -60,15 +61,22 @@ public class GlobalExceptionHandler {
@SuppressWarnings
(
"SpringJavaInjectionPointsAutowiringInspection"
)
private
final
String
applicationName
;
private
final
ApiErrorLogCommonApi
apiErrorLogApi
;
public
GlobalExceptionHandler
(
@Value
(
"${spring.application.name}"
)
String
applicationName
,
// 直接注入配置值
ApiErrorLogCommonApi
apiErrorLogApi
)
{
this
.
applicationName
=
applicationName
;
this
.
apiErrorLogApi
=
apiErrorLogApi
;
}
/**
* 处理所有异常,主要是提供给 Filter 使用
* 因为 Filter 不走 SpringMVC 的流程,但是我们又需要兜底处理异常,所以这里提供一个全量的异常处理过程,保持逻辑统一。
*
* @param request 请求
* @param ex 异常
* @param ex
异常
* @return 通用返回
*/
public
CommonResult
<?>
allExceptionHandler
(
HttpServletRequest
request
,
Throwable
ex
)
{
...
...
@@ -110,7 +118,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求参数缺失
*
*
<p>
* 例如说,接口上设置了 @RequestParam("xx") 参数,结果并未传递 xx 参数
*/
@ExceptionHandler
(
value
=
MissingServletRequestParameterException
.
class
)
...
...
@@ -121,7 +129,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求参数类型错误
*
*
<p>
* 例如说,接口上设置了 @RequestParam("xx") 参数为 Integer,结果传递 xx 参数类型为 String
*/
@ExceptionHandler
(
MethodArgumentTypeMismatchException
.
class
)
...
...
@@ -168,16 +176,16 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求参数类型错误
*
*
<p>
* 例如说,接口上设置了 @RequestBody实体中 xx 属性类型为 Integer,结果传递 xx 参数类型为 String
*/
@ExceptionHandler
(
HttpMessageNotReadableException
.
class
)
public
CommonResult
<?>
methodArgumentTypeInvalidFormatExceptionHandler
(
HttpMessageNotReadableException
ex
)
{
log
.
warn
(
"[methodArgumentTypeInvalidFormatExceptionHandler]"
,
ex
);
if
(
ex
.
getCause
()
instanceof
InvalidFormatException
)
{
if
(
ex
.
getCause
()
instanceof
InvalidFormatException
)
{
InvalidFormatException
invalidFormatException
=
(
InvalidFormatException
)
ex
.
getCause
();
return
CommonResult
.
error
(
BAD_REQUEST
.
getCode
(),
String
.
format
(
"请求参数类型错误:%s"
,
invalidFormatException
.
getValue
()));
}
else
{
}
else
{
return
defaultExceptionHandler
(
ServletUtils
.
getRequest
(),
ex
);
}
}
...
...
@@ -204,7 +212,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求地址不存在
*
*
<p>
* 注意,它需要设置如下两个配置项:
* 1. spring.mvc.throw-exception-if-no-handler-found 为 true
* 2. spring.mvc.static-path-pattern 为 /statics/**
...
...
@@ -226,7 +234,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求方法不正确
*
*
<p>
* 例如说,A 接口的方法为 GET 方式,结果请求方法为 POST 方式,导致不匹配
*/
@ExceptionHandler
(
HttpRequestMethodNotSupportedException
.
class
)
...
...
@@ -237,7 +245,7 @@ public class GlobalExceptionHandler {
/**
* 处理 Spring Security 权限不足的异常
*
*
<p>
* 来源是,使用 @PreAuthorize 注解,AOP 进行权限拦截
*/
@ExceptionHandler
(
value
=
AccessDeniedException
.
class
)
...
...
@@ -249,7 +257,7 @@ public class GlobalExceptionHandler {
/**
* 处理业务异常 ServiceException
*
*
<p>
* 例如说,商品库存不足,用户手机号已存在。
*/
@ExceptionHandler
(
value
=
ServiceException
.
class
)
...
...
@@ -300,7 +308,7 @@ public class GlobalExceptionHandler {
// 执行插入 errorLog
apiErrorLogApi
.
createApiErrorLogAsync
(
errorLog
);
}
catch
(
Throwable
th
)
{
log
.
error
(
"[createExceptionLog][url({}) log({}) 发生异常]"
,
req
.
getRequestURI
(),
JsonUtils
.
toJsonString
(
errorLog
),
th
);
log
.
error
(
"[createExceptionLog][url({}) log({}) 发生异常]"
,
req
.
getRequestURI
(),
JsonUtils
.
toJsonString
(
errorLog
),
th
);
}
}
...
...
computility-module-biz/pom.xml
View file @
955b441b
...
...
@@ -17,6 +17,13 @@
</description>
<dependencies>
<dependency>
<groupId>
com.luhu
</groupId>
<artifactId>
computility-module-product
</artifactId>
<version>
${revision}
</version>
</dependency>
<dependency>
<groupId>
com.luhu
</groupId>
<artifactId>
computility-module-system
</artifactId>
...
...
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/app/index/ApiController.java
0 → 100644
View file @
955b441b
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
app
.
index
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.math.Money
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
import
com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoPageReqVO
;
import
com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoRespVO
;
import
com.luhu.computility.module.biz.controller.admin.computilityinformation.vo.ComputilityInformationRespVO
;
import
com.luhu.computility.module.biz.controller.app.index.vo.ComputeRespVO
;
import
com.luhu.computility.module.biz.controller.client.dto.MenuDTO
;
import
com.luhu.computility.module.biz.dal.dataobject.bannerinfo.BannerInfoDO
;
import
com.luhu.computility.module.biz.service.bannerinfo.BannerInfoService
;
import
com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO
;
import
com.luhu.computility.module.product.dal.dataobject.spu.ProductSpuDO
;
import
com.luhu.computility.module.product.enums.spu.ProductSpuStatusEnum
;
import
com.luhu.computility.module.product.service.sku.ProductSkuService
;
import
com.luhu.computility.module.product.service.spu.ProductSpuService
;
import
com.luhu.computility.module.system.dal.dataobject.dict.DictDataDO
;
import
com.luhu.computility.module.system.util.dict.DictUtils
;
import
io.netty.util.internal.ObjectUtil
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.java.Log
;
import
org.apache.ibatis.annotations.Param
;
import
org.checkerframework.checker.units.qual.C
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.cache.RedisCache
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
com
.
luhu
.
computility
.
module
.
product
.
enums
.
ErrorCodeConstants
.
SPU_NOT_ENABLE
;
import
static
com
.
luhu
.
computility
.
module
.
product
.
enums
.
ErrorCodeConstants
.
SPU_NOT_EXISTS
;
/**
* 接口实现控制层
*
* @author fanjiang.zeng
*/
@Tag
(
name
=
"管理后台 - banner页管理"
)
@RestController
@RequestMapping
(
"/api/v1"
)
@Validated
public
class
ApiController
{
@Resource
private
ProductSpuService
productSpuService
;
@Resource
private
ProductSkuService
productSkuService
;
/*
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private BannerInfoService bannerInfoService;
*//**
*banner接口
*//*
@ApiAccessLog
@Operation(summary = "banner接口", description = "banner接口")
@GetMapping(value = "/banner")
public CommonResult<List<BannerInfoRespVO>> getBannerInfo(@Valid BannerInfoPageReqVO reqVO) {
List<BannerInfoDO> bannerInfoDOS = bannerInfoService.getBannerInfo(reqVO);
return success(BeanUtils.toBean(bannerInfoDOS, BannerInfoRespVO.class));
}
*//**
*计算资源首页展示
*//*
@Operation(summary = "计算资源首页展示", description = "计算资源首页展示")
@GetMapping(value = "/computility")
@ApiAccessLog
public CommonResult<List<ComputilityInformationRespVO>> getComputilityInformation(@Valid ComputilityInformationRespVO reqVO) {
List<BannerInfoDO> bannerInfoDOS = bannerInfoService.getBannerInfo(reqVO);
return success(BeanUtils.toBean(bannerInfoDOS, BannerInfoRespVO.class));
}
*//**
*计算资源列表获取
*//*
@ApiOperation(value = "计算资源列表获取",notes = "计算资源列表获取")
@GetMapping(value = "/computilityList")
@ResponseBody
public R<List<BizComputility>> computilityList(BizComputility bizComputility){
List<BizComputility> list =
bizComputilityService.selectBizComputilityList(bizComputility);
return R.ok(list);
}
*/
/**
* 计算资源详情
*//*
@ApiOperation(value = "计算资源详情",notes = "计算资源详情")
@GetMapping(value = "/computilityDetail")
@ResponseBody
public R<ComputilityDetailDTO> computilityDetail(@Param(value = "id") Long id){
Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status","已上架"));
BizComputility computility =
bizComputilityService.selectBizComputilityById(id);
ComputilityDetailDTO computilityDetailDTO = new ComputilityDetailDTO();
BeanUtils.copyProperties(computility, computilityDetailDTO);
BizComputilityAccessory bizComputilityAccessory = new BizComputilityAccessory();
bizComputilityAccessory.setGroundingStatus(groundingStatus);
computilityDetailDTO.setAccessories(bizComputilityAccessoryService.selectBizComputilityAccessoryList(bizComputilityAccessory));
return R.ok(computilityDetailDTO);
}
/**
*计算资源二级菜单
*/
// @ApiOperation(value = "计算资源二级菜单",notes = "计算资源二级菜单")
@GetMapping
(
value
=
"/computilityMenu"
)
@ResponseBody
public
CommonResult
<
List
<
MenuDTO
>>
computilityMenu
()
{
List
<
MenuDTO
>
menuDTOList
=
getMenus
(
"application_category"
);
return
success
(
menuDTOList
);
}
private
List
<
MenuDTO
>
getMenus
(
String
type
)
{
List
<
DictDataDO
>
dictData
=
DictUtils
.
getDictCache
(
type
);
List
<
MenuDTO
>
list
=
new
ArrayList
<>();
dictData
.
forEach
(
item
->
{
MenuDTO
menuDTO
=
new
MenuDTO
();
menuDTO
.
setName
(
item
.
getLabel
());
menuDTO
.
setValue
(
item
.
getValue
());
list
.
add
(
menuDTO
);
});
return
list
;
}
/**
* 根据应用类别返回对应计算机资源列表
*/
@GetMapping
(
value
=
"/getRListByCategory"
)
@ResponseBody
public
CommonResult
<
List
<
ComputeRespVO
>>
getResourceListByCategory
(
@NotNull
(
message
=
"计算机资源编号不能为空"
)
Integer
categoryId
)
{
/**
* 根据前段传的categoryId,去product_spu表查对应的多个spu
* 每个spu会有多个对应的sku,目前都要展示出来
*/
List
<
ProductSpuDO
>
spuList
=
productSpuService
.
getSpuListByCategoryId
(
Convert
.
toLong
(
categoryId
));
if
(
spuList
==
null
)
{
throw
exception
(
SPU_NOT_EXISTS
);
}
// 获得商品 SKU
List
<
Long
>
spuIdList
=
spuList
.
stream
()
.
map
(
ProductSpuDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
List
<
ProductSkuDO
>
skuDOList
=
productSkuService
.
getSkuListBySpuId
(
spuIdList
);
List
<
ComputeRespVO
>
computeRespVOS
=
new
ArrayList
<
ComputeRespVO
>();
for
(
ProductSkuDO
productSkuDO
:
skuDOList
)
{
//处理每个sku对应的cpu、gpu、内存、存储、时长等需要展示的字段
List
<
ProductSkuDO
.
Property
>
properties
=
productSkuDO
.
getProperties
();
String
spuName
=
productSpuService
.
getSpu
(
productSkuDO
.
getSpuId
()).
getName
();
//spuName实际上是每个服务器的名字
ComputeRespVO
computeRespVO
=
new
ComputeRespVO
();
for
(
ProductSkuDO
.
Property
property
:
properties
)
{
switch
(
Convert
.
toInt
(
property
.
getPropertyId
()))
{
case
18
:
computeRespVO
.
setCpu
(
property
.
getValueName
());
break
;
case
19
:
computeRespVO
.
setGpu
(
property
.
getValueName
());
break
;
case
20
:
computeRespVO
.
setMemory
(
property
.
getValueName
());
break
;
case
21
:
computeRespVO
.
setStorage
(
property
.
getValueName
());
break
;
case
22
:
computeRespVO
.
setTerm
(
property
.
getValueName
());
break
;
}
computeRespVO
.
setModel
(
spuName
);
}
computeRespVO
.
setPublicPrice
(
String
.
format
(
"%.2f"
,
productSkuDO
.
getPrice
()/
100.0
));
computeRespVOS
.
add
(
computeRespVO
);
}
return
success
(
computeRespVOS
);
// startPage();
// BizComputility bizComputility = new BizComputility();
// bizComputility.setCategory(nav);
// Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status", "已上架"));
// bizComputility.setGroundingStatus(groundingStatus);
//
// List<BizComputility> bizComputilities = bizComputilityService.selectBizComputilityDetailList(bizComputility);
// List<BizResourceDetail> bizResourceDetails = new ArrayList<>();
// bizComputilities.forEach(item -> {
// BizResourceDetail bizResourceDetail = bizComputilityService.bizResourceDetail(item);
// bizResourceDetails.add(bizResourceDetail);
// });
// return getDataTable(bizResourceDetails,bizComputilities);
}
// *//**
// *行业应用二级菜单
// *//*
// @ApiOperation(value = "行业应用二级菜单",notes = "行业应用二级菜单")
// @GetMapping(value = "/industryMenu")
// @ResponseBody
// public R<JSONArray> industryMenu() {
// Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status", "已上架"));
// BizSolution bizSolution = new BizSolution();
// bizSolution.setGroundingStatus(groundingStatus);
// List<BizSolutionVO> bizSolutions = bizSolutionService.selectSolutionByIdAndName(bizSolution);
// Map<Integer, List<BizSolutionVO>> category =
// bizSolutions.stream().collect(Collectors.groupingBy(BizSolutionVO::getCategory));
//
// JSONArray categoryArray = new JSONArray();
// for (Map.Entry<Integer, List<BizSolutionVO>> entry : category.entrySet()) {
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("name", DictUtils.getDictLabel("solution_category", String.valueOf(entry.getKey())));
// jsonObject.put("value", entry.getKey());
// JSONArray jsonArray = new JSONArray();
// Map<Integer, List<BizSolutionVO>> industryMap =
// entry.getValue().stream().collect(Collectors.groupingBy(BizSolutionVO::getIndustryCategory));
// for (Map.Entry<Integer, List<BizSolutionVO>> integerListEntry : industryMap.entrySet()) {
// JSONObject industry = new JSONObject();
// industry.put("name", DictUtils.getDictLabel("industry_category", String.valueOf(integerListEntry.getKey())));
// industry.put("value", integerListEntry.getKey());
// industry.put("child",
// entry.getValue().stream().filter(object -> object.getIndustryCategory().equals(integerListEntry.getKey())).collect(Collectors.toList()));
// jsonArray.add(industry);
// }
// jsonObject.put("child", jsonArray);
// categoryArray.add(jsonObject);
// }
// return R.ok(categoryArray);
// }
// *//**
// *行业应用详情-解决方案
// *//*
// @ApiOperation(value = "行业应用详情-解决方案",notes = "行业应用详情-解决方案")
// @GetMapping(value = "/solutionDetail")
// @ResponseBody
// public R solutionDetail(@Param(value = "id") Long id){
// //业务实现部分
// BizSolution detail = bizSolutionService.selectBizSolutionById(id);
// if(detail != null) {
// return R.ok(detail);
// }else {
// return R.fail("无法获取详情,请重试!");
// }
// }
// *//**
// *活动咨询列表
// *//*
// @ApiOperation(value = "活动咨询列表",notes = "活动咨询列表")
// @GetMapping(value = "/information")
// @ResponseBody
// public R<List<BizInformation>> information(BizInformation bizInformation){
// //业务实现部分
// Integer showStatus = Integer.valueOf(DictUtils.getDictValue("show_status","已显示"));
// bizInformation.setShowStatus(showStatus);
// List<BizInformation> list = bizInformationService.selectBizInformationList(bizInformation);
// if(list != null) {
// return R.ok(list);
// }else {
// return R.fail("无法获取详情,请重试!");
// }
// }
// *//**
// *活动咨询详情
// *//*
// @ApiOperation(value = "活动咨询详情",notes = "活动咨询详情")
// @GetMapping(value = "/informationDetail")
// @ResponseBody
// public R<BizInformation> informationDetail(@Param(value = "id") Long id){
// //业务实现部分
// BizInformation detail = bizInformationService.selectBizInformationById(id);
// if(detail != null) {
// return R.ok(detail);
// }else {
// return R.fail("无法获取详情,请重试!");
// }
// }
//
//
// *//**
// *组件服务类型
// *//*
// @ApiOperation(value = "组件服务类型",notes = "组件服务类型")
// @GetMapping(value = "/assemblyType")
// @ResponseBody
// public R<JSONArray> assemblyType(){
// JSONArray jsonArray = new JSONArray();
// List<SysDictData> dataList = DictUtils.getDictCache("assembly_type");
// dataList.forEach(e->{
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("name",e.getDictLabel());
// jsonObject.put("value",e.getDictValue());
// jsonArray.add(jsonObject);
// });
// return R.ok(jsonArray);
// }
//
// *//**
// *组件服务列表
// *//*
// @ApiOperation(value = "组件服务列表",notes = "组件服务列表")
// @GetMapping(value = "/assemblyList")
// @ResponseBody
// public R<List<BizAssembly>> assemblyList(@Param(value = "type") int type){
// BizAssembly bizAssembly = new BizAssembly();
// Integer showStatus = Integer.valueOf(DictUtils.getDictValue("show_status","已显示"));
// Integer assemblyType = Integer.valueOf(DictUtils.getDictValue("assembly_type","全部"));
// bizAssembly.setShowStatus(showStatus);
// if(type != assemblyType) {
// bizAssembly.setAssemblyType(type);
// }
// List<BizAssembly> bizAssemblies = bizAssemblyService.selectBizAssemblyList(bizAssembly);
// return R.ok(bizAssemblies);
// }
//
// *//**
// *合作伙伴列表
// *//*
// @ApiOperation(value = "合作伙伴列表",notes = "合作伙伴列表")
// @GetMapping(value = "/partnerList")
// @ResponseBody
// public R<List<BizPartner>> partnerList(){
// BizPartner bizPartner = new BizPartner();
// Integer showStatus = Integer.valueOf(DictUtils.getDictValue("show_status","已显示"));
// bizPartner.setShowStatus(showStatus);
// List<BizPartner> bizPartners = bizPartnerService.selectBizPartnerList(bizPartner);
// return R.ok(bizPartners);
// }
//
// *//**
// * 订单 - 计算机资源详情
// *//*
// @ApiOperation(value = "计算机资源 - 详情2",notes = "计算机资源详情2")
// @GetMapping(value = "/getRDetail")
// @ResponseBody
// public R<BizResourceDetailRespVO> getResourceDetail(@Param(value = "id") @NotNull(message = "计算机资源编号不能为空") Long id){
// BizResourceDetailRespVO getResourceDetail = bizComputilityService.getResourceDetail(id);
// return R.ok(getResourceDetail);
// }
//
// *//**
// * 订单-我的订单列表
// *//*
// @GetMapping("/orderMyList")
// @ApiOperation("订单-我的订单列表")
// @ResponseBody
// public TableDataInfo list(BizOrder bizOrder)
// {
// boolean b = SecurityUtils.hasRole("admin");
// if (!b){
// bizOrder.setApplyUser(SecurityUtils.getUserId());
// }
// startPage();
// List<BizOrderDetailRespVO> list = bizOrderService.selectBizOrderDetailList(bizOrder);
// return getDataTable(list);
// }
//
// *//**
// * 订单-计算接口
// *//*
// @ApiOperation(value = "订单-计算接口",notes = "订单-计算接口")
// @PostMapping(value = "/orderComputer")
// @ResponseBody
// public R<ComputerPriceRespVO> order(@RequestBody BizResourceOrderSavaVO bizResourceOrderSavaVO){
// return R.ok(bizOrderService.computerOrderPrice(bizResourceOrderSavaVO));
// }
//
// *//**
// * 获取订单管理-需求单管理详细信息
// *//*
// @GetMapping(value = "/{id}")
// @ApiOperation("订单-订单详细信息")
// @ResponseBody
// public R<BizOrderDetailRespVO> getInfo(@PathVariable("id") Long id)
// {
// return R.ok(bizOrderService.selectBizOrderDetailById(id));
// }
//
// *//**
// * 订单 - 购买接口
// *//*
// @ApiOperation(value = "订单 - 购买接口",notes = "订单 - 购买接口")
// @PostMapping(value = "/orderBuy")
// @ResponseBody
// public R<Long> buy(@RequestBody BizResourceOrderSavaVO bizResourceOrderSavaVO){
// return R.ok(bizOrderService.orderBuy(bizResourceOrderSavaVO));
// }
//
// *//**
// * 订单 - 提交
// *//*
// @ApiOperation(value = "订单 - 提交",notes = "订单 - 提交")
// @PostMapping(value = "/orderSubmit")
// @ResponseBody
// public R<Long> submit(@RequestBody OrderId orderId){
// return R.ok(bizOrderService.submitOrder(orderId));
// }
//
// *//**
// * 订单 - 取消
// *//*
// @ApiOperation(value = "订单 - 取消",notes = "订单 - 取消")
// @PostMapping(value = "/orderCancel")
// @ResponseBody
// public R<Integer> cancel(@RequestBody OrderId orderId){
// BizOrder bizOrder = bizOrderService.vailSelectBizOrderById(orderId.getId());
// if (!bizOrder.getOrderStatus().equals(OrderStatus.审核中.getCode())){
// throw new ServiceException(500 , "订单状态错误,无法取消");
// }
// bizOrder.setOrderStatus(OrderStatus.已取消.getCode());
// return R.ok(bizOrderService.updateBizOrder(bizOrder));
// }
//
//
//
// *//**
// * 购物车- 列表
// *//*
// @GetMapping("/list")
// @ApiOperation("购物车 - 列表")
// @ResponseBody
// public TableDataInfo list()
// {
// startPage();
// BizShopping bizShopping = new BizShopping();
// bizShopping.setUserId(SecurityUtils.getUserId());
// List<BizShoppingDetail> list = bizShoppingService.selectBizShoppingSDetailList(bizShopping);
// return getDataTable(list);
// }
//
// @ApiOperation(value = "购物车 - 添加接口",notes = "购物车 - 添加接口")
// @PostMapping(value = "shoppingAdd")
// @ResponseBody
// public R<Long> shoppingAdd(@RequestBody BizResourceOrderSavaVO savaVO)
// {
// return R.ok(bizShoppingService.shoppingAdd(savaVO));
// }
//
// @ApiOperation(value = "购物车 - 提交接口",notes = "购物车 - 提交接口")
// @GetMapping(value = "shoppingComputer/{ids}")
// @ResponseBody
// public R<String> shoppingComputer(@PathVariable @NotEmpty(message = "编号不能为空") Long[] ids)
// {
// bizOrderService.submitShoppingOrder(ids);
// return R.ok("提交成功");
// }
//
// @ApiOperation(value = "购物车 - 计算接口",notes = "购物车 - 计算接口")
// @GetMapping(value = "shoppingComputerVo/{ids}")
// @ResponseBody
// public R<ComputerPriceRespVO> shoppingComputerVo(@PathVariable @NotEmpty(message = "编号不能为空") Long[] ids)
// {
// BigDecimal totalPublicPrice = new BigDecimal(0);
// BigDecimal totalInnerPrice = new BigDecimal(0);
// for (Long id : ids) {
// BizShopping bizShopping = bizShoppingService.vailSelectBizShoppingById(id);
// totalInnerPrice = totalInnerPrice.add(bizShopping.getInnerTotalPrice());
// totalPublicPrice = totalPublicPrice.add(bizShopping.getPublicTotalPrice());
// }
// ComputerPriceRespVO computerPriceRespVO = new ComputerPriceRespVO();
// computerPriceRespVO.setTotalInnerPrice(totalInnerPrice.toString());
// computerPriceRespVO.setTotalPulicPrice(totalPublicPrice.toString());
// return R.ok(computerPriceRespVO);
// }
//
//
// *//**
// * 购物车 - 删除管理
// *//*
// @Log(title = "购物车管理", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// @ApiOperation("购物车 - 删除管理")
// @ResponseBody
// public R<Integer> remove(@PathVariable Long[] ids)
// {
// return R.ok(bizShoppingService.deleteBizShoppingByIds(ids));
// }
//
//
// *//**
// * 购物车 - 数量修改
// *//*
// @Log(title = "购物车 - 数量修改", businessType = BusinessType.UPDATE)
// @PutMapping("/shoppingEdit")
// @ApiOperation("购物车 - 数量修改")
// @ResponseBody
// public R<ComputerPriceRespVO> edit(@RequestBody ShoppingNumSaveVO saveVO)
// {
// BizShopping bizShopping = bizShoppingService.selectBizShoppingById(saveVO.getId());
// //修改价格 对外
// BigDecimal onPublicePrice = bizShopping.getPublicTotalPrice().divide(new BigDecimal(bizShopping.getUseNum()));
// BigDecimal publicTotal = onPublicePrice.multiply(new BigDecimal(saveVO.getUseNum()));
// bizShopping.setPublicTotalPrice(publicTotal);
// //修改价格 对内
// BigDecimal onInnerPrice = bizShopping.getInnerTotalPrice().divide(new BigDecimal(bizShopping.getUseNum()));
// BigDecimal innerPrice = onInnerPrice.multiply(new BigDecimal(saveVO.getUseNum()));
// bizShopping.setInnerTotalPrice(innerPrice);
//
// bizShopping.setUseNum(saveVO.getUseNum());
// bizShoppingService.updateBizShopping(bizShopping);
// ComputerPriceRespVO computerPriceRespVO = new ComputerPriceRespVO();
// computerPriceRespVO.setTotalPulicPrice(bizShopping.getPublicTotalPrice().toString());
// computerPriceRespVO.setTotalInnerPrice(bizShopping.getInnerTotalPrice().toString());
// return R.ok(computerPriceRespVO);
// }
//
//
// *//**
// * 新增企业人认证审核
// *//*
// @Log(title = "企业人认证审核", businessType = BusinessType.INSERT)
// @PostMapping("/enterpriseAudit")
// @ApiOperation("企业人认证 - 新增")
// @ResponseBody
// public R<Long> add(@RequestBody BizEnterpriseAuditSaveVO saveVO)
// {
// return R.ok(bizEnterpriseAuditService.insertBizEnterpriseAuditLong(saveVO));
// }
//
// *//**
// * 根据用户查询企业认证信息和用户信息
// *//*
// @GetMapping("/enterpriseAudit")
// @ApiOperation("企业人认证 - 根据用户查询企业认证信息和用户信息")
// @ResponseBody
// public R<BizEnterpriseAuditUser> enterpriseAudit()
// {
// return R.ok(bizEnterpriseAuditService.selectBizEnterpriseAuditByUserId());
// }
//
// *//**
// * 订单 - 驳回理由
// *//*
// @GetMapping(value = "/orderReason/{id}")
// @ApiOperation("订单 - 驳回理由")
// @ResponseBody
// public R<String> getOrderReason(@PathVariable("id") Long id)
// {
// BizOrder bizOrder = bizOrderService.vailSelectBizOrderById(id);
// //判断状态
// if (!OrderStatus.已驳回.getCode().equals(bizOrder.getOrderStatus())) {
// throw new ServiceException(500 , "订单状态错误");
// }
// return R.ok(bizOrder.getRemark());
// }
//
// *//**
// * 根据用户编号获取详细信息
// *//*
// @GetMapping(value = { "/userInfo" })
// @ApiOperation("用户信息 - 用户信息")
// @ResponseBody
// public R<SysUser> getUserInfo()
// {
// Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
// userService.checkUserDataScope(userId);
// SysUser sysUser = userService.selectUserById(userId);
// return R.ok(sysUser);
// }
//
//
// public static void main(String[] args) {
// final Integer[] result = {0};
// for(int i=0;i<=10;i++){
// int finalI = i;
// new Thread(){
// @Override
// public void run() {
// System.out.println(finalI);
// result[0] = finalI;
// }
// }.start();
// }
//
// while (result[0] == 10) {
// System.out.println("我执行完了");
// break;
// }
// }*/
}
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/app/index/vo/ComputeRespVO.java
0 → 100644
View file @
955b441b
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
app
.
index
.
vo
;
import
lombok.Data
;
/**
* 计算资源首页 Response VO
*
* @Author: jony
* @Date : 2025/8/5 14:41
* @VERSION v1.0
*/
@Data
public
class
ComputeRespVO
{
private
String
model
;
private
String
cpu
;
private
String
gpu
;
private
String
memory
;
private
String
storage
;
private
String
term
;
private
String
publicPrice
;
}
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/client/ApiController.java
deleted
100644 → 0
View file @
fb777398
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
client
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
import
com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoPageReqVO
;
import
com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoRespVO
;
import
com.luhu.computility.module.biz.controller.admin.computilityinformation.vo.ComputilityInformationRespVO
;
import
com.luhu.computility.module.biz.dal.dataobject.bannerinfo.BannerInfoDO
;
import
com.luhu.computility.module.biz.service.bannerinfo.BannerInfoService
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.java.Log
;
import
org.apache.ibatis.annotations.Param
;
import
org.checkerframework.checker.units.qual.C
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.cache.RedisCache
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
/**
* 接口实现控制层
* @author fanjiang.zeng
*/
@Tag
(
name
=
"管理后台 - banner页管理"
)
@RestController
@RequestMapping
(
"/api/v1"
)
@Validated
public
class
ApiController
{
/*
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private BannerInfoService bannerInfoService;
*//**
*banner接口
*//*
@ApiAccessLog
@Operation(summary = "banner接口", description = "banner接口")
@GetMapping(value = "/banner")
public CommonResult<List<BannerInfoRespVO>> getBannerInfo(@Valid BannerInfoPageReqVO reqVO) {
List<BannerInfoDO> bannerInfoDOS = bannerInfoService.getBannerInfo(reqVO);
return success(BeanUtils.toBean(bannerInfoDOS, BannerInfoRespVO.class));
}
*//**
*计算资源首页展示
*//*
@Operation(summary = "计算资源首页展示", description = "计算资源首页展示")
@GetMapping(value = "/computility")
@ApiAccessLog
public CommonResult<List<ComputilityInformationRespVO>> getComputilityInformation(@Valid ComputilityInformationRespVO reqVO) {
List<BannerInfoDO> bannerInfoDOS = bannerInfoService.getBannerInfo(reqVO);
return success(BeanUtils.toBean(bannerInfoDOS, BannerInfoRespVO.class));
}
*//**
*计算资源列表获取
*//*
@ApiOperation(value = "计算资源列表获取",notes = "计算资源列表获取")
@GetMapping(value = "/computilityList")
@ResponseBody
public R<List<BizComputility>> computilityList(BizComputility bizComputility){
List<BizComputility> list =
bizComputilityService.selectBizComputilityList(bizComputility);
return R.ok(list);
}
*//**
*计算资源详情
*//*
@ApiOperation(value = "计算资源详情",notes = "计算资源详情")
@GetMapping(value = "/computilityDetail")
@ResponseBody
public R<ComputilityDetailDTO> computilityDetail(@Param(value = "id") Long id){
Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status","已上架"));
BizComputility computility =
bizComputilityService.selectBizComputilityById(id);
ComputilityDetailDTO computilityDetailDTO = new ComputilityDetailDTO();
BeanUtils.copyProperties(computility, computilityDetailDTO);
BizComputilityAccessory bizComputilityAccessory = new BizComputilityAccessory();
bizComputilityAccessory.setGroundingStatus(groundingStatus);
computilityDetailDTO.setAccessories(bizComputilityAccessoryService.selectBizComputilityAccessoryList(bizComputilityAccessory));
return R.ok(computilityDetailDTO);
}
*//**
*计算资源二级菜单
*//*
@ApiOperation(value = "计算资源二级菜单",notes = "计算资源二级菜单")
@GetMapping(value = "/computilityMenu")
@ResponseBody
public R<List<MenuDTO>> computilityMenu(){
List<MenuDTO> menuDTOList = getMenus("application_category");
return R.ok(menuDTOList);
}
private List<MenuDTO> getMenus(String type) {
List<SysDictData> dictData = DictUtils.getDictCache(type);
List<MenuDTO> list = new ArrayList<>();
dictData.forEach(item -> {
MenuDTO menuDTO = new MenuDTO();
menuDTO.setName(item.getDictLabel());
menuDTO.setValue(item.getDictValue());
list.add(menuDTO);
});
return list;
}
*//**
*行业应用二级菜单
*//*
@ApiOperation(value = "行业应用二级菜单",notes = "行业应用二级菜单")
@GetMapping(value = "/industryMenu")
@ResponseBody
public R<JSONArray> industryMenu() {
Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status", "已上架"));
BizSolution bizSolution = new BizSolution();
bizSolution.setGroundingStatus(groundingStatus);
List<BizSolutionVO> bizSolutions = bizSolutionService.selectSolutionByIdAndName(bizSolution);
Map<Integer, List<BizSolutionVO>> category =
bizSolutions.stream().collect(Collectors.groupingBy(BizSolutionVO::getCategory));
JSONArray categoryArray = new JSONArray();
for (Map.Entry<Integer, List<BizSolutionVO>> entry : category.entrySet()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", DictUtils.getDictLabel("solution_category", String.valueOf(entry.getKey())));
jsonObject.put("value", entry.getKey());
JSONArray jsonArray = new JSONArray();
Map<Integer, List<BizSolutionVO>> industryMap =
entry.getValue().stream().collect(Collectors.groupingBy(BizSolutionVO::getIndustryCategory));
for (Map.Entry<Integer, List<BizSolutionVO>> integerListEntry : industryMap.entrySet()) {
JSONObject industry = new JSONObject();
industry.put("name", DictUtils.getDictLabel("industry_category", String.valueOf(integerListEntry.getKey())));
industry.put("value", integerListEntry.getKey());
industry.put("child",
entry.getValue().stream().filter(object -> object.getIndustryCategory().equals(integerListEntry.getKey())).collect(Collectors.toList()));
jsonArray.add(industry);
}
jsonObject.put("child", jsonArray);
categoryArray.add(jsonObject);
}
return R.ok(categoryArray);
}
*//**
*行业应用详情-解决方案
*//*
@ApiOperation(value = "行业应用详情-解决方案",notes = "行业应用详情-解决方案")
@GetMapping(value = "/solutionDetail")
@ResponseBody
public R solutionDetail(@Param(value = "id") Long id){
//业务实现部分
BizSolution detail = bizSolutionService.selectBizSolutionById(id);
if(detail != null) {
return R.ok(detail);
}else {
return R.fail("无法获取详情,请重试!");
}
}
*//**
*活动咨询列表
*//*
@ApiOperation(value = "活动咨询列表",notes = "活动咨询列表")
@GetMapping(value = "/information")
@ResponseBody
public R<List<BizInformation>> information(BizInformation bizInformation){
//业务实现部分
Integer showStatus = Integer.valueOf(DictUtils.getDictValue("show_status","已显示"));
bizInformation.setShowStatus(showStatus);
List<BizInformation> list = bizInformationService.selectBizInformationList(bizInformation);
if(list != null) {
return R.ok(list);
}else {
return R.fail("无法获取详情,请重试!");
}
}
*//**
*活动咨询详情
*//*
@ApiOperation(value = "活动咨询详情",notes = "活动咨询详情")
@GetMapping(value = "/informationDetail")
@ResponseBody
public R<BizInformation> informationDetail(@Param(value = "id") Long id){
//业务实现部分
BizInformation detail = bizInformationService.selectBizInformationById(id);
if(detail != null) {
return R.ok(detail);
}else {
return R.fail("无法获取详情,请重试!");
}
}
*//**
*组件服务类型
*//*
@ApiOperation(value = "组件服务类型",notes = "组件服务类型")
@GetMapping(value = "/assemblyType")
@ResponseBody
public R<JSONArray> assemblyType(){
JSONArray jsonArray = new JSONArray();
List<SysDictData> dataList = DictUtils.getDictCache("assembly_type");
dataList.forEach(e->{
JSONObject jsonObject = new JSONObject();
jsonObject.put("name",e.getDictLabel());
jsonObject.put("value",e.getDictValue());
jsonArray.add(jsonObject);
});
return R.ok(jsonArray);
}
*//**
*组件服务列表
*//*
@ApiOperation(value = "组件服务列表",notes = "组件服务列表")
@GetMapping(value = "/assemblyList")
@ResponseBody
public R<List<BizAssembly>> assemblyList(@Param(value = "type") int type){
BizAssembly bizAssembly = new BizAssembly();
Integer showStatus = Integer.valueOf(DictUtils.getDictValue("show_status","已显示"));
Integer assemblyType = Integer.valueOf(DictUtils.getDictValue("assembly_type","全部"));
bizAssembly.setShowStatus(showStatus);
if(type != assemblyType) {
bizAssembly.setAssemblyType(type);
}
List<BizAssembly> bizAssemblies = bizAssemblyService.selectBizAssemblyList(bizAssembly);
return R.ok(bizAssemblies);
}
*//**
*合作伙伴列表
*//*
@ApiOperation(value = "合作伙伴列表",notes = "合作伙伴列表")
@GetMapping(value = "/partnerList")
@ResponseBody
public R<List<BizPartner>> partnerList(){
BizPartner bizPartner = new BizPartner();
Integer showStatus = Integer.valueOf(DictUtils.getDictValue("show_status","已显示"));
bizPartner.setShowStatus(showStatus);
List<BizPartner> bizPartners = bizPartnerService.selectBizPartnerList(bizPartner);
return R.ok(bizPartners);
}
*//**
* 根据应用类别返回对应计算机资源列表
*//*
@ApiOperation(value = "计算机资源 - 根据应用类别返回对应计算机资源列表",notes = "根据应用类别返回对应计算机资源列表")
@GetMapping(value = "/getRListByCategory")
@ResponseBody
public TableDataInfo getResourceListByCategory(@NotNull(message = "计算机资源编号不能为空") Integer nav) {
startPage();
BizComputility bizComputility = new BizComputility();
bizComputility.setCategory(nav);
Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status", "已上架"));
bizComputility.setGroundingStatus(groundingStatus);
List<BizComputility> bizComputilities = bizComputilityService.selectBizComputilityDetailList(bizComputility);
List<BizResourceDetail> bizResourceDetails = new ArrayList<>();
bizComputilities.forEach(item -> {
BizResourceDetail bizResourceDetail = bizComputilityService.bizResourceDetail(item);
bizResourceDetails.add(bizResourceDetail);
});
return getDataTable(bizResourceDetails,bizComputilities);
}
*//**
* 订单 - 计算机资源详情
*//*
@ApiOperation(value = "计算机资源 - 详情2",notes = "计算机资源详情2")
@GetMapping(value = "/getRDetail")
@ResponseBody
public R<BizResourceDetailRespVO> getResourceDetail(@Param(value = "id") @NotNull(message = "计算机资源编号不能为空") Long id){
BizResourceDetailRespVO getResourceDetail = bizComputilityService.getResourceDetail(id);
return R.ok(getResourceDetail);
}
*//**
* 订单-我的订单列表
*//*
@GetMapping("/orderMyList")
@ApiOperation("订单-我的订单列表")
@ResponseBody
public TableDataInfo list(BizOrder bizOrder)
{
boolean b = SecurityUtils.hasRole("admin");
if (!b){
bizOrder.setApplyUser(SecurityUtils.getUserId());
}
startPage();
List<BizOrderDetailRespVO> list = bizOrderService.selectBizOrderDetailList(bizOrder);
return getDataTable(list);
}
*//**
* 订单-计算接口
*//*
@ApiOperation(value = "订单-计算接口",notes = "订单-计算接口")
@PostMapping(value = "/orderComputer")
@ResponseBody
public R<ComputerPriceRespVO> order(@RequestBody BizResourceOrderSavaVO bizResourceOrderSavaVO){
return R.ok(bizOrderService.computerOrderPrice(bizResourceOrderSavaVO));
}
*//**
* 获取订单管理-需求单管理详细信息
*//*
@GetMapping(value = "/{id}")
@ApiOperation("订单-订单详细信息")
@ResponseBody
public R<BizOrderDetailRespVO> getInfo(@PathVariable("id") Long id)
{
return R.ok(bizOrderService.selectBizOrderDetailById(id));
}
*//**
* 订单 - 购买接口
*//*
@ApiOperation(value = "订单 - 购买接口",notes = "订单 - 购买接口")
@PostMapping(value = "/orderBuy")
@ResponseBody
public R<Long> buy(@RequestBody BizResourceOrderSavaVO bizResourceOrderSavaVO){
return R.ok(bizOrderService.orderBuy(bizResourceOrderSavaVO));
}
*//**
* 订单 - 提交
*//*
@ApiOperation(value = "订单 - 提交",notes = "订单 - 提交")
@PostMapping(value = "/orderSubmit")
@ResponseBody
public R<Long> submit(@RequestBody OrderId orderId){
return R.ok(bizOrderService.submitOrder(orderId));
}
*//**
* 订单 - 取消
*//*
@ApiOperation(value = "订单 - 取消",notes = "订单 - 取消")
@PostMapping(value = "/orderCancel")
@ResponseBody
public R<Integer> cancel(@RequestBody OrderId orderId){
BizOrder bizOrder = bizOrderService.vailSelectBizOrderById(orderId.getId());
if (!bizOrder.getOrderStatus().equals(OrderStatus.审核中.getCode())){
throw new ServiceException(500 , "订单状态错误,无法取消");
}
bizOrder.setOrderStatus(OrderStatus.已取消.getCode());
return R.ok(bizOrderService.updateBizOrder(bizOrder));
}
*//**
* 购物车- 列表
*//*
@GetMapping("/list")
@ApiOperation("购物车 - 列表")
@ResponseBody
public TableDataInfo list()
{
startPage();
BizShopping bizShopping = new BizShopping();
bizShopping.setUserId(SecurityUtils.getUserId());
List<BizShoppingDetail> list = bizShoppingService.selectBizShoppingSDetailList(bizShopping);
return getDataTable(list);
}
@ApiOperation(value = "购物车 - 添加接口",notes = "购物车 - 添加接口")
@PostMapping(value = "shoppingAdd")
@ResponseBody
public R<Long> shoppingAdd(@RequestBody BizResourceOrderSavaVO savaVO)
{
return R.ok(bizShoppingService.shoppingAdd(savaVO));
}
@ApiOperation(value = "购物车 - 提交接口",notes = "购物车 - 提交接口")
@GetMapping(value = "shoppingComputer/{ids}")
@ResponseBody
public R<String> shoppingComputer(@PathVariable @NotEmpty(message = "编号不能为空") Long[] ids)
{
bizOrderService.submitShoppingOrder(ids);
return R.ok("提交成功");
}
@ApiOperation(value = "购物车 - 计算接口",notes = "购物车 - 计算接口")
@GetMapping(value = "shoppingComputerVo/{ids}")
@ResponseBody
public R<ComputerPriceRespVO> shoppingComputerVo(@PathVariable @NotEmpty(message = "编号不能为空") Long[] ids)
{
BigDecimal totalPublicPrice = new BigDecimal(0);
BigDecimal totalInnerPrice = new BigDecimal(0);
for (Long id : ids) {
BizShopping bizShopping = bizShoppingService.vailSelectBizShoppingById(id);
totalInnerPrice = totalInnerPrice.add(bizShopping.getInnerTotalPrice());
totalPublicPrice = totalPublicPrice.add(bizShopping.getPublicTotalPrice());
}
ComputerPriceRespVO computerPriceRespVO = new ComputerPriceRespVO();
computerPriceRespVO.setTotalInnerPrice(totalInnerPrice.toString());
computerPriceRespVO.setTotalPulicPrice(totalPublicPrice.toString());
return R.ok(computerPriceRespVO);
}
*//**
* 购物车 - 删除管理
*//*
@Log(title = "购物车管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("购物车 - 删除管理")
@ResponseBody
public R<Integer> remove(@PathVariable Long[] ids)
{
return R.ok(bizShoppingService.deleteBizShoppingByIds(ids));
}
*//**
* 购物车 - 数量修改
*//*
@Log(title = "购物车 - 数量修改", businessType = BusinessType.UPDATE)
@PutMapping("/shoppingEdit")
@ApiOperation("购物车 - 数量修改")
@ResponseBody
public R<ComputerPriceRespVO> edit(@RequestBody ShoppingNumSaveVO saveVO)
{
BizShopping bizShopping = bizShoppingService.selectBizShoppingById(saveVO.getId());
//修改价格 对外
BigDecimal onPublicePrice = bizShopping.getPublicTotalPrice().divide(new BigDecimal(bizShopping.getUseNum()));
BigDecimal publicTotal = onPublicePrice.multiply(new BigDecimal(saveVO.getUseNum()));
bizShopping.setPublicTotalPrice(publicTotal);
//修改价格 对内
BigDecimal onInnerPrice = bizShopping.getInnerTotalPrice().divide(new BigDecimal(bizShopping.getUseNum()));
BigDecimal innerPrice = onInnerPrice.multiply(new BigDecimal(saveVO.getUseNum()));
bizShopping.setInnerTotalPrice(innerPrice);
bizShopping.setUseNum(saveVO.getUseNum());
bizShoppingService.updateBizShopping(bizShopping);
ComputerPriceRespVO computerPriceRespVO = new ComputerPriceRespVO();
computerPriceRespVO.setTotalPulicPrice(bizShopping.getPublicTotalPrice().toString());
computerPriceRespVO.setTotalInnerPrice(bizShopping.getInnerTotalPrice().toString());
return R.ok(computerPriceRespVO);
}
*//**
* 新增企业人认证审核
*//*
@Log(title = "企业人认证审核", businessType = BusinessType.INSERT)
@PostMapping("/enterpriseAudit")
@ApiOperation("企业人认证 - 新增")
@ResponseBody
public R<Long> add(@RequestBody BizEnterpriseAuditSaveVO saveVO)
{
return R.ok(bizEnterpriseAuditService.insertBizEnterpriseAuditLong(saveVO));
}
*//**
* 根据用户查询企业认证信息和用户信息
*//*
@GetMapping("/enterpriseAudit")
@ApiOperation("企业人认证 - 根据用户查询企业认证信息和用户信息")
@ResponseBody
public R<BizEnterpriseAuditUser> enterpriseAudit()
{
return R.ok(bizEnterpriseAuditService.selectBizEnterpriseAuditByUserId());
}
*//**
* 订单 - 驳回理由
*//*
@GetMapping(value = "/orderReason/{id}")
@ApiOperation("订单 - 驳回理由")
@ResponseBody
public R<String> getOrderReason(@PathVariable("id") Long id)
{
BizOrder bizOrder = bizOrderService.vailSelectBizOrderById(id);
//判断状态
if (!OrderStatus.已驳回.getCode().equals(bizOrder.getOrderStatus())) {
throw new ServiceException(500 , "订单状态错误");
}
return R.ok(bizOrder.getRemark());
}
*//**
* 根据用户编号获取详细信息
*//*
@GetMapping(value = { "/userInfo" })
@ApiOperation("用户信息 - 用户信息")
@ResponseBody
public R<SysUser> getUserInfo()
{
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
userService.checkUserDataScope(userId);
SysUser sysUser = userService.selectUserById(userId);
return R.ok(sysUser);
}
public static void main(String[] args) {
final Integer[] result = {0};
for(int i=0;i<=10;i++){
int finalI = i;
new Thread(){
@Override
public void run() {
System.out.println(finalI);
result[0] = finalI;
}
}.start();
}
while (result[0] == 10) {
System.out.println("我执行完了");
break;
}
}*/
}
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/client/dto/MenuDTO.java
0 → 100644
View file @
955b441b
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
client
.
dto
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Author: jony
* @Date : 2025/8/1 09:51
* @VERSION v1.0
*/
@Schema
(
description
=
"客户端 - 首页二级菜单接口返回 DTO"
)
@Data
public
class
MenuDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
value
;
}
computility-module-mall/computility-module-product/src/main/java/com/luhu/computility/module/product/service/spu/ProductSpuService.java
View file @
955b441b
...
...
@@ -61,6 +61,14 @@ public interface ProductSpuService {
ProductSpuDO
getSpu
(
Long
id
,
boolean
includeDeleted
);
/**
* 根据categoryId获得商品 SPU 列表
*
* @param categoryId
* @return
*/
List
<
ProductSpuDO
>
getSpuListByCategoryId
(
Long
categoryId
);
/**
* 获得商品 SPU 列表
*
* @param ids 编号数组
...
...
computility-module-mall/computility-module-product/src/main/java/com/luhu/computility/module/product/service/spu/ProductSpuServiceImpl.java
View file @
955b441b
...
...
@@ -198,6 +198,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
}
@Override
public
List
<
ProductSpuDO
>
getSpuListByCategoryId
(
Long
categoryId
){
if
(
ObjectUtil
.
isEmpty
(
categoryId
))
{
return
Collections
.
emptyList
();
}
return
productSpuMapper
.
selectList
(
"category_id"
,
categoryId
);
}
@Override
public
List
<
ProductSpuDO
>
getSpuList
(
Collection
<
Long
>
ids
)
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
return
Collections
.
emptyList
();
...
...
computility-module-system/pom.xml
View file @
955b441b
...
...
@@ -113,6 +113,12 @@
<groupId>
com.anji-plus
</groupId>
<artifactId>
captcha-spring-boot-starter
</artifactId>
<!-- 验证码,一般用于登录使用 -->
</dependency>
<dependency>
<groupId>
com.alibaba.fastjson2
</groupId>
<artifactId>
fastjson2
</artifactId>
<version>
2.0.43
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
...
...
computility-module-system/src/main/java/com/luhu/computility/module/system/service/dict/DictTypeServiceImpl.java
View file @
955b441b
package
com
.
luhu
.
computility
.
module
.
system
.
service
.
dict
;
import
cn.hutool.core.util.StrUtil
;
import
com.luhu.computility.framework.common.core.redis.RedisCache
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.util.date.LocalDateTimeUtils
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
import
com.luhu.computility.framework.common.util.spring.SpringUtils
;
import
com.luhu.computility.framework.dict.core.DictFrameworkUtils
;
import
com.luhu.computility.module.system.controller.admin.dict.vo.type.DictTypePageReqVO
;
import
com.luhu.computility.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO
;
import
com.luhu.computility.module.system.dal.dataobject.dict.DictDataDO
;
import
com.luhu.computility.module.system.dal.dataobject.dict.DictTypeDO
;
import
com.luhu.computility.module.system.dal.mysql.dict.DictDataMapper
;
import
com.luhu.computility.module.system.dal.mysql.dict.DictTypeMapper
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.luhu.computility.module.system.util.dict.DictUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
com
.
luhu
.
computility
.
module
.
system
.
enums
.
ErrorCodeConstants
.*;
...
...
@@ -32,6 +42,25 @@ public class DictTypeServiceImpl implements DictTypeService {
@Resource
private
DictTypeMapper
dictTypeMapper
;
@Resource
private
DictDataMapper
dictDataMapper
;
/**
* 项目启动时,初始化字典到缓存
*/
@PostConstruct
public
void
init
(){
loadingDictCache
();
}
private
void
loadingDictCache
(){
List
<
DictDataDO
>
dictDataList
=
dictDataMapper
.
selectListByStatusAndDictType
(
0
,
null
);
Map
<
String
,
List
<
DictDataDO
>>
dictDataMap
=
dictDataList
.
stream
().
collect
(
Collectors
.
groupingBy
(
DictDataDO:
:
getDictType
));
for
(
Map
.
Entry
<
String
,
List
<
DictDataDO
>>
entry
:
dictDataMap
.
entrySet
()){
DictUtils
.
setDictCache
(
entry
.
getKey
(),
entry
.
getValue
().
stream
().
sorted
(
Comparator
.
comparing
(
DictDataDO:
:
getSort
)).
collect
(
Collectors
.
toList
()));
}
}
@Override
public
PageResult
<
DictTypeDO
>
getDictTypePage
(
DictTypePageReqVO
pageReqVO
)
{
return
dictTypeMapper
.
selectPage
(
pageReqVO
);
...
...
computility-module-system/src/main/java/com/luhu/computility/module/system/util/dict/DictUtils.java
0 → 100644
View file @
955b441b
package
com
.
luhu
.
computility
.
module
.
system
.
util
.
dict
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson2.JSONArray
;
import
com.luhu.computility.framework.common.core.redis.RedisCache
;
import
com.luhu.computility.framework.common.util.spring.SpringUtils
;
import
com.luhu.computility.module.system.dal.dataobject.dict.DictDataDO
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 字典工具类
*
* @Author: jony
* @Date : 2025/7/31 09:55
* @VERSION v1.0
*/
public
class
DictUtils
{
/**
* 分隔符
*/
public
static
final
String
SEPARATOR
=
","
;
/**
* 设置字典缓存
*
* @param key 参数键
* @param dictDatas 字典数据列表
*/
public
static
void
setDictCache
(
String
key
,
List
<
DictDataDO
>
dictDatas
)
{
SpringUtils
.
getBean
(
RedisCache
.
class
).
setCacheObject
(
getCacheKey
(
key
),
dictDatas
);
}
/**
* 获取字典缓存
*
* @param key 参数键
* @return dictDatas 字典数据列表
*/
public
static
List
<
DictDataDO
>
getDictCache
(
String
key
)
{
// JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
// if (ObjectUtil.isNotNull(arrayCache)) {
// return arrayCache.toJavaList(DictDataDO.class);
// }
// return null;
Object
cacheObj
=
SpringUtils
.
getBean
(
RedisCache
.
class
).
getCacheObject
(
getCacheKey
(
key
));
if
(
cacheObj
==
null
)
{
return
null
;
}
List
<
DictDataDO
>
dictList
;
if
(
cacheObj
instanceof
JSONArray
)
{
// 新数据:JSONArray 直接转 List
dictList
=
((
JSONArray
)
cacheObj
).
toJavaList
(
DictDataDO
.
class
);
}
else
if
(
cacheObj
instanceof
ArrayList
)
{
dictList
=
(
List
<
DictDataDO
>)
cacheObj
;
}
else
{
// 其他未知类型,返回空列表(避免报错)
dictList
=
new
ArrayList
<>();
}
return
dictList
;
}
/**
* 根据字典类型和字典值获取字典标签
*
* @param dictType 字典类型
* @param dictValue 字典值
* @return 字典标签
*/
public
static
String
getDictLabel
(
String
dictType
,
String
dictValue
)
{
return
getDictLabel
(
dictType
,
dictValue
,
SEPARATOR
);
}
/**
* 根据字典类型和字典标签获取字典值
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @return 字典值
*/
public
static
String
getDictValue
(
String
dictType
,
String
dictLabel
)
{
return
getDictValue
(
dictType
,
dictLabel
,
SEPARATOR
);
}
/**
* 根据字典类型和字典值获取字典标签
*
* @param dictType 字典类型
* @param dictValue 字典值
* @param separator 分隔符
* @return 字典标签
*/
public
static
String
getDictLabel
(
String
dictType
,
String
dictValue
,
String
separator
)
{
StringBuilder
propertyString
=
new
StringBuilder
();
List
<
DictDataDO
>
datas
=
getDictCache
(
dictType
);
if
(
ObjectUtil
.
isNotNull
(
datas
))
{
if
(
StringUtils
.
containsAny
(
separator
,
dictValue
))
{
for
(
DictDataDO
dict
:
datas
)
{
for
(
String
value
:
dictValue
.
split
(
separator
))
{
if
(
value
.
equals
(
dict
.
getValue
()))
{
propertyString
.
append
(
dict
.
getLabel
()).
append
(
separator
);
break
;
}
}
}
}
else
{
for
(
DictDataDO
dict
:
datas
)
{
if
(
dictValue
.
equals
(
dict
.
getValue
()))
{
return
dict
.
getLabel
();
}
}
}
}
return
StringUtils
.
stripEnd
(
propertyString
.
toString
(),
separator
);
}
/**
* 根据字典类型和字典标签获取字典值
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @param separator 分隔符
* @return 字典值
*/
public
static
String
getDictValue
(
String
dictType
,
String
dictLabel
,
String
separator
)
{
StringBuilder
propertyString
=
new
StringBuilder
();
List
<
DictDataDO
>
datas
=
getDictCache
(
dictType
);
if
(
StringUtils
.
containsAny
(
separator
,
dictLabel
)
&&
ObjectUtil
.
isNotEmpty
(
datas
))
{
for
(
DictDataDO
dict
:
datas
)
{
for
(
String
label
:
dictLabel
.
split
(
separator
))
{
if
(
label
.
equals
(
dict
.
getLabel
()))
{
propertyString
.
append
(
dict
.
getValue
()).
append
(
separator
);
break
;
}
}
}
}
else
{
for
(
DictDataDO
dict
:
datas
)
{
if
(
dictLabel
.
equals
(
dict
.
getLabel
()))
{
return
dict
.
getValue
();
}
}
}
return
StringUtils
.
stripEnd
(
propertyString
.
toString
(),
separator
);
}
/**
* 删除指定字典缓存
*
* @param key 字典键
*/
public
static
void
removeDictCache
(
String
key
)
{
SpringUtils
.
getBean
(
RedisCache
.
class
).
deleteObject
(
getCacheKey
(
key
));
}
/**
* 清空字典缓存
*/
public
static
void
clearDictCache
()
{
// Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*");
SpringUtils
.
getBean
(
RedisCache
.
class
).
deleteObject
(
"*"
);
}
/**
* 设置cache key
*
* @param configKey 参数键
* @return 缓存键key
*/
public
static
String
getCacheKey
(
String
configKey
)
{
// return CacheConstants.SYS_DICT_KEY + configKey;
return
"sys_dict:"
+
configKey
;
}
}
computility-server/src/main/java/com/luhu/computility/server/ComputilityServerApplication.java
View file @
955b441b
package
com
.
luhu
.
computility
.
server
;
import
com.luhu.computility.module.system.dal.mysql.dict.DictDataMapper
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
* 项目的启动类
...
...
@@ -13,7 +15,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @author 芋道源码
*/
@SuppressWarnings
(
"SpringComponentScan"
)
// 忽略 IDEA 无法识别 ${computility.info.base-package}
@SpringBootApplication
(
scanBasePackages
=
{
"${computility.info.base-package}.server"
,
"${computility.info.base-package}.module"
})
@SpringBootApplication
(
scanBasePackages
=
{
"${computility.info.base-package}.server"
,
"${computility.info.base-package}.module"
,
"${computility.info.base-package}.framework"
})
public
class
ComputilityServerApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -21,7 +23,7 @@ public class ComputilityServerApplication {
// 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
SpringApplication
.
run
(
ComputilityServerApplication
.
class
,
args
);
ConfigurableApplicationContext
run
=
SpringApplication
.
run
(
ComputilityServerApplication
.
class
,
args
);
// new SpringApplicationBuilder(ComputilityServerApplication.class)
// .applicationStartup(new BufferingApplicationStartup(20480))
// .run(args);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment