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
edcce9cb
authored
Aug 13, 2025
by
Jony.L
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决方案重构
parent
0fe9c219
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
923 additions
and
288 deletions
+923
-288
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/SolutionController.java
+105
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionMenuRespVO.java
+29
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionPageReqVO.java
+58
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionRespVO.java
+76
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionSaveReqVO.java
+61
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/app/index/ApiController.java
+70
-65
computility-module-biz/src/main/java/com/luhu/computility/module/biz/dal/dataobject/solution/SolutionDO.java
+81
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/dal/mysql/solution/SolutionMapper.java
+40
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/enums/ErrorCodeConstants.java
+1
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/service/order/OrderServiceImpl.java
+1
-1
computility-module-biz/src/main/java/com/luhu/computility/module/biz/service/solution/SolutionService.java
+65
-0
computility-module-biz/src/main/java/com/luhu/computility/module/biz/service/solution/SolutionServiceImpl.java
+100
-0
computility-module-biz/src/main/resources/mapper/solution/SolutionMapper.xml
+13
-0
computility-module-mall/computility-module-product/src/test/java/com/luhu/computility/module/product/service/sku/ProductSkuServiceTest.java
+207
-207
computility-module-mall/computility-module-trade/src/main/java/com/luhu/computility/module/trade/service/order/TradeOrderUpdateServiceImpl.java
+1
-1
computility-module-system/src/main/java/com/luhu/computility/module/system/util/dict/DictUtils.java
+10
-14
computility-server/src/main/resources/logback-spring.xml
+5
-0
No files found.
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/SolutionController.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
admin
.
solution
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Operation
;
import
javax.validation.constraints.*
;
import
javax.validation.*
;
import
javax.servlet.http.*
;
import
java.util.*
;
import
java.io.IOException
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
com.luhu.computility.framework.excel.core.util.ExcelUtils
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
static
com
.
luhu
.
computility
.
framework
.
apilog
.
core
.
enums
.
OperateTypeEnum
.*;
import
com.luhu.computility.module.biz.controller.admin.solution.vo.*
;
import
com.luhu.computility.module.biz.dal.dataobject.solution.SolutionDO
;
import
com.luhu.computility.module.biz.service.solution.SolutionService
;
@Tag
(
name
=
"管理后台 - 解决方案"
)
@RestController
@RequestMapping
(
"/biz/solution"
)
@Validated
public
class
SolutionController
{
@Resource
private
SolutionService
solutionService
;
@PostMapping
(
"/create"
)
@Operation
(
summary
=
"创建解决方案"
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:create')"
)
public
CommonResult
<
Long
>
createSolution
(
@Valid
@RequestBody
SolutionSaveReqVO
createReqVO
)
{
return
success
(
solutionService
.
createSolution
(
createReqVO
));
}
@PutMapping
(
"/update"
)
@Operation
(
summary
=
"更新解决方案"
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:update')"
)
public
CommonResult
<
Boolean
>
updateSolution
(
@Valid
@RequestBody
SolutionSaveReqVO
updateReqVO
)
{
solutionService
.
updateSolution
(
updateReqVO
);
return
success
(
true
);
}
@DeleteMapping
(
"/delete"
)
@Operation
(
summary
=
"删除解决方案"
)
@Parameter
(
name
=
"id"
,
description
=
"编号"
,
required
=
true
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:delete')"
)
public
CommonResult
<
Boolean
>
deleteSolution
(
@RequestParam
(
"id"
)
Long
id
)
{
solutionService
.
deleteSolution
(
id
);
return
success
(
true
);
}
@DeleteMapping
(
"/delete-list"
)
@Parameter
(
name
=
"ids"
,
description
=
"编号"
,
required
=
true
)
@Operation
(
summary
=
"批量删除解决方案"
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:delete')"
)
public
CommonResult
<
Boolean
>
deleteSolutionList
(
@RequestParam
(
"ids"
)
List
<
Long
>
ids
)
{
solutionService
.
deleteSolutionListByIds
(
ids
);
return
success
(
true
);
}
@GetMapping
(
"/get"
)
@Operation
(
summary
=
"获得解决方案"
)
@Parameter
(
name
=
"id"
,
description
=
"编号"
,
required
=
true
,
example
=
"1024"
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:query')"
)
public
CommonResult
<
SolutionRespVO
>
getSolution
(
@RequestParam
(
"id"
)
Long
id
)
{
SolutionDO
solution
=
solutionService
.
getSolution
(
id
);
return
success
(
BeanUtils
.
toBean
(
solution
,
SolutionRespVO
.
class
));
}
@GetMapping
(
"/page"
)
@Operation
(
summary
=
"获得解决方案分页"
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:query')"
)
public
CommonResult
<
PageResult
<
SolutionRespVO
>>
getSolutionPage
(
@Valid
SolutionPageReqVO
pageReqVO
)
{
PageResult
<
SolutionDO
>
pageResult
=
solutionService
.
getSolutionPage
(
pageReqVO
);
return
success
(
BeanUtils
.
toBean
(
pageResult
,
SolutionRespVO
.
class
));
}
@GetMapping
(
"/export-excel"
)
@Operation
(
summary
=
"导出解决方案 Excel"
)
@PreAuthorize
(
"@ss.hasPermission('biz:solution:export')"
)
@ApiAccessLog
(
operateType
=
EXPORT
)
public
void
exportSolutionExcel
(
@Valid
SolutionPageReqVO
pageReqVO
,
HttpServletResponse
response
)
throws
IOException
{
pageReqVO
.
setPageSize
(
PageParam
.
PAGE_SIZE_NONE
);
List
<
SolutionDO
>
list
=
solutionService
.
getSolutionPage
(
pageReqVO
).
getList
();
// 导出 Excel
ExcelUtils
.
write
(
response
,
"解决方案.xls"
,
"数据"
,
SolutionRespVO
.
class
,
BeanUtils
.
toBean
(
list
,
SolutionRespVO
.
class
));
}
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionMenuRespVO.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
admin
.
solution
.
vo
;
import
lombok.Data
;
/**
* @Author: jony
* @Date : 2025/8/13 08:43
* @VERSION v1.0
*/
@Data
public
class
SolutionMenuRespVO
{
/**
* 主键
*/
private
Long
id
;
/**
* 方案类别
*/
private
Integer
category
;
/**
* 行业类别
*/
private
Integer
industryCategory
;
/**
* 标题(行业)
*/
private
String
titleIndustry
;
}
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionPageReqVO.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
admin
.
solution
.
vo
;
import
lombok.*
;
import
java.util.*
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDateTime
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Schema
(
description
=
"管理后台 - 解决方案分页 Request VO"
)
@Data
public
class
SolutionPageReqVO
extends
PageParam
{
@Schema
(
description
=
"方案类别"
)
private
Integer
category
;
@Schema
(
description
=
"行业类别"
)
private
Integer
industryCategory
;
@Schema
(
description
=
"标题(行业)"
)
private
String
titleIndustry
;
@Schema
(
description
=
"标题(解决方案)"
)
private
String
titleSolution
;
@Schema
(
description
=
"标题(咨询)"
)
private
String
titleConsult
;
@Schema
(
description
=
"行业概述"
)
private
String
industryInfo
;
@Schema
(
description
=
"解决方案"
)
private
String
solutionInfo
;
@Schema
(
description
=
"咨询流程"
)
private
String
consultInfo
;
@Schema
(
description
=
"状态:0-已下架,1-已上架"
,
example
=
"2"
)
private
Integer
groundingStatus
;
@Schema
(
description
=
"创建时间"
)
@DateTimeFormat
(
pattern
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
private
LocalDateTime
[]
createTime
;
@Schema
(
description
=
"创建者"
)
private
String
creator
;
@Schema
(
description
=
"更新者"
)
private
String
updater
;
@Schema
(
description
=
"备注"
,
example
=
"随便"
)
private
String
remark
;
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionRespVO.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
admin
.
solution
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.*
;
import
java.util.*
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDateTime
;
import
com.alibaba.excel.annotation.*
;
@Schema
(
description
=
"管理后台 - 解决方案 Response VO"
)
@Data
@ExcelIgnoreUnannotated
public
class
SolutionRespVO
{
@Schema
(
description
=
"主键"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"21367"
)
@ExcelProperty
(
"主键"
)
private
Long
id
;
@Schema
(
description
=
"方案类别"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@ExcelProperty
(
"方案类别"
)
private
Boolean
category
;
@Schema
(
description
=
"行业类别"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@ExcelProperty
(
"行业类别"
)
private
Boolean
industryCategory
;
@Schema
(
description
=
"标题(行业)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@ExcelProperty
(
"标题(行业)"
)
private
String
titleIndustry
;
@Schema
(
description
=
"标题(解决方案)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@ExcelProperty
(
"标题(解决方案)"
)
private
String
titleSolution
;
@Schema
(
description
=
"标题(咨询)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@ExcelProperty
(
"标题(咨询)"
)
private
String
titleConsult
;
@Schema
(
description
=
"行业概述"
)
@ExcelProperty
(
"行业概述"
)
private
String
industryInfo
;
@Schema
(
description
=
"解决方案"
)
@ExcelProperty
(
"解决方案"
)
private
String
solutionInfo
;
@Schema
(
description
=
"咨询流程"
)
@ExcelProperty
(
"咨询流程"
)
private
String
consultInfo
;
@Schema
(
description
=
"状态:0-已下架,1-已上架"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"2"
)
@ExcelProperty
(
"状态:0-已下架,1-已上架"
)
private
Boolean
groundingStatus
;
@Schema
(
description
=
"创建时间"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@ExcelProperty
(
"创建时间"
)
private
LocalDateTime
createTime
;
@Schema
(
description
=
"创建者"
)
@ExcelProperty
(
"创建者"
)
private
String
createBy
;
@Schema
(
description
=
"更新者"
)
@ExcelProperty
(
"更新者"
)
private
String
updateBy
;
@Schema
(
description
=
"备注"
,
example
=
"随便"
)
@ExcelProperty
(
"备注"
)
private
String
remark
;
@Schema
(
description
=
"删除标志(0代表存在 2代表删除)"
)
@ExcelProperty
(
"删除标志(0代表存在 2代表删除)"
)
private
String
delFlag
;
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/admin/solution/vo/SolutionSaveReqVO.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
controller
.
admin
.
solution
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.*
;
import
java.util.*
;
import
javax.validation.constraints.*
;
@Schema
(
description
=
"管理后台 - 解决方案新增/修改 Request VO"
)
@Data
public
class
SolutionSaveReqVO
{
@Schema
(
description
=
"主键"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"21367"
)
private
Long
id
;
@Schema
(
description
=
"方案类别"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@NotNull
(
message
=
"方案类别不能为空"
)
private
Boolean
category
;
@Schema
(
description
=
"行业类别"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@NotNull
(
message
=
"行业类别不能为空"
)
private
Boolean
industryCategory
;
@Schema
(
description
=
"标题(行业)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@NotEmpty
(
message
=
"标题(行业)不能为空"
)
private
String
titleIndustry
;
@Schema
(
description
=
"标题(解决方案)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@NotEmpty
(
message
=
"标题(解决方案)不能为空"
)
private
String
titleSolution
;
@Schema
(
description
=
"标题(咨询)"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@NotEmpty
(
message
=
"标题(咨询)不能为空"
)
private
String
titleConsult
;
@Schema
(
description
=
"行业概述"
)
private
String
industryInfo
;
@Schema
(
description
=
"解决方案"
)
private
String
solutionInfo
;
@Schema
(
description
=
"咨询流程"
)
private
String
consultInfo
;
@Schema
(
description
=
"状态:0-已下架,1-已上架"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"2"
)
@NotNull
(
message
=
"状态:0-已下架,1-已上架不能为空"
)
private
Boolean
groundingStatus
;
@Schema
(
description
=
"创建者"
)
private
String
createBy
;
@Schema
(
description
=
"更新者"
)
private
String
updateBy
;
@Schema
(
description
=
"备注"
,
example
=
"随便"
)
private
String
remark
;
@Schema
(
description
=
"删除标志(0代表存在 2代表删除)"
)
private
String
delFlag
;
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/controller/app/index/ApiController.java
View file @
edcce9cb
...
@@ -2,6 +2,8 @@ package com.luhu.computility.module.biz.controller.app.index;
...
@@ -2,6 +2,8 @@ package com.luhu.computility.module.biz.controller.app.index;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.math.Money
;
import
cn.hutool.core.math.Money
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
...
@@ -10,13 +12,18 @@ import com.luhu.computility.framework.common.util.object.BeanUtils;
...
@@ -10,13 +12,18 @@ 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.BannerInfoPageReqVO
;
import
com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoRespVO
;
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.admin.computilityinformation.vo.ComputilityInformationRespVO
;
import
com.luhu.computility.module.biz.controller.admin.solution.vo.SolutionMenuRespVO
;
import
com.luhu.computility.module.biz.controller.admin.solution.vo.SolutionPageReqVO
;
import
com.luhu.computility.module.biz.controller.app.index.vo.BizOrderCreateReqVO
;
import
com.luhu.computility.module.biz.controller.app.index.vo.BizOrderCreateReqVO
;
import
com.luhu.computility.module.biz.controller.app.index.vo.ResourcesDetailRespVO
;
import
com.luhu.computility.module.biz.controller.app.index.vo.ResourcesDetailRespVO
;
import
com.luhu.computility.module.biz.controller.client.dto.MenuDTO
;
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.dal.dataobject.bannerinfo.BannerInfoDO
;
import
com.luhu.computility.module.biz.dal.dataobject.solution.SolutionDO
;
import
com.luhu.computility.module.biz.dal.mysql.solution.SolutionMapper
;
import
com.luhu.computility.module.biz.service.bannerinfo.BannerInfoService
;
import
com.luhu.computility.module.biz.service.bannerinfo.BannerInfoService
;
import
com.luhu.computility.module.biz.service.order.OrderService
;
import
com.luhu.computility.module.biz.service.order.OrderService
;
import
com.luhu.computility.module.biz.service.resources.ResourcesDetailService
;
import
com.luhu.computility.module.biz.service.resources.ResourcesDetailService
;
import
com.luhu.computility.module.biz.service.solution.SolutionService
;
import
com.luhu.computility.module.product.dal.dataobject.category.ProductCategoryDO
;
import
com.luhu.computility.module.product.dal.dataobject.category.ProductCategoryDO
;
import
com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO
;
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.dal.dataobject.spu.ProductSpuDO
;
...
@@ -83,6 +90,11 @@ public class ApiController {
...
@@ -83,6 +90,11 @@ public class ApiController {
private
OrderService
orderService
;
private
OrderService
orderService
;
@Resource
@Resource
private
ResourcesDetailService
resourcesDetailService
;
private
ResourcesDetailService
resourcesDetailService
;
@Resource
private
SolutionService
solutionService
;
@Resource
private
SolutionMapper
solutionMapper
;
/*
/*
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
...
@@ -193,90 +205,83 @@ public class ApiController {
...
@@ -193,90 +205,83 @@ public class ApiController {
List
<
ResourcesDetailRespVO
>
computeRespVOS
=
new
ArrayList
<>();
List
<
ResourcesDetailRespVO
>
computeRespVOS
=
new
ArrayList
<>();
for
(
ProductSkuDO
productSkuDO
:
skuDOList
)
{
//处理每个sku对应的cpu、gpu、内存、存储、时长等需要展示的字段
for
(
ProductSkuDO
productSkuDO
:
skuDOList
)
{
//处理每个sku对应的cpu、gpu、内存、存储、时长等需要展示的字段
List
<
ProductSkuDO
.
Property
>
properties
=
productSkuDO
.
getProperties
();
computeRespVOS
.
add
(
resourcesDetailService
.
getResourcesDetailBySkuDO
(
productSkuDO
));
String
spuName
=
productSpuService
.
getSpu
(
productSkuDO
.
getSpuId
()).
getName
();
//spuName实际上是每个服务器的名字
ResourcesDetailRespVO
computeRespVO
=
new
ResourcesDetailRespVO
();
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
.
setId
(
productSkuDO
.
getId
());
computeRespVO
.
setModel
(
spuName
);
}
computeRespVO
.
setPublicPrice
(
String
.
format
(
"%.2f"
,
productSkuDO
.
getPrice
()/
100.0
));
computeRespVOS
.
add
(
computeRespVO
);
}
}
return
success
(
computeRespVOS
);
return
success
(
computeRespVOS
);
}
}
/**
/**
* 订单 - 计算机资源详情
* 订单 - 计算机资源详情
*/
*/
// @ApiOperation(value = "计算机资源 - 详情2",notes = "计算机资源详情2")
// @ApiOperation(value = "计算机资源 - 详情2",notes = "计算机资源详情2")
@GetMapping
(
value
=
"/getRDetail"
)
@GetMapping
(
value
=
"/getRDetail"
)
@ResponseBody
@ResponseBody
public
CommonResult
<
ResourcesDetailRespVO
>
getResourceDetail
(
@Param
(
value
=
"id"
)
@NotNull
(
message
=
"计算机资源编号不能为空"
)
Long
id
){
public
CommonResult
<
ResourcesDetailRespVO
>
getResourceDetail
(
@Param
(
value
=
"id"
)
@NotNull
(
message
=
"计算机资源编号不能为空"
)
Long
id
)
{
ProductSkuDO
skuDO
=
productSkuService
.
getSku
(
id
);
ProductSkuDO
skuDO
=
productSkuService
.
getSku
(
id
);
ResourcesDetailRespVO
resourcesDetailBySkuDO
=
resourcesDetailService
.
getResourcesDetailBySkuDO
(
skuDO
);
ResourcesDetailRespVO
resourcesDetailBySkuDO
=
resourcesDetailService
.
getResourcesDetailBySkuDO
(
skuDO
);
return
success
(
resourcesDetailBySkuDO
);
return
success
(
resourcesDetailBySkuDO
);
}
}
@PostMapping
(
value
=
"/bizOrderSubmit"
)
@PostMapping
(
value
=
"/bizOrderSubmit"
)
public
CommonResult
<
Long
>
bizOrderSubmit
(
BizOrderCreateReqVO
bizOrderCreateReqVO
){
public
CommonResult
<
Long
>
bizOrderSubmit
(
BizOrderCreateReqVO
bizOrderCreateReqVO
)
{
Long
skuId
=
bizOrderCreateReqVO
.
getSkuId
();
Long
skuId
=
bizOrderCreateReqVO
.
getSkuId
();
orderService
.
bizOrderSubmit
(
skuId
);
orderService
.
bizOrderSubmit
(
skuId
);
return
null
;
return
null
;
}
}
// *//**
// *行业应用二级菜单
/**
// *//*
* 行业应用二级菜单
// @ApiOperation(value = "行业应用二级菜单",notes = "行业应用二级菜单")
*/
// @GetMapping(value = "/industryMenu")
@GetMapping
(
value
=
"/industryMenu"
)
// @ResponseBody
@ResponseBody
// public R<JSONArray> industryMenu() {
public
CommonResult
<
JSONArray
>
industryMenu
()
{
// Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status", "已上架"));
//取所有已上架的解决方案
// BizSolution bizSolution = new BizSolution();
Integer
groundingStatus
=
Integer
.
valueOf
(
DictUtils
.
getDictValue
(
"grounding_status"
,
"已上架"
));
// bizSolution.setGroundingStatus(groundingStatus);
SolutionPageReqVO
solutionPageReqVO
=
new
SolutionPageReqVO
();
// List<BizSolutionVO> bizSolutions = bizSolutionService.selectSolutionByIdAndName(bizSolution);
solutionPageReqVO
.
setGroundingStatus
(
groundingStatus
);
// Map<Integer, List<BizSolutionVO>> category =
// bizSolutions.stream().collect(Collectors.groupingBy(BizSolutionVO::getCategory));
// List<SolutionDO> solutionDOList = solutionMapper.selectSolutionList(solutionPageReqVO);
//
List
<
SolutionDO
>
solutionDOList
=
solutionService
.
selectSolutionList
(
solutionPageReqVO
);
// JSONArray categoryArray = new JSONArray();
List
<
SolutionMenuRespVO
>
solutionVOList
=
solutionDOList
.
stream
().
map
(
solutionDO
->
{
// for (Map.Entry<Integer, List<BizSolutionVO>> entry : category.entrySet()) {
SolutionMenuRespVO
solutionMenuRespVO
=
new
SolutionMenuRespVO
();
// JSONObject jsonObject = new JSONObject();
BeanUtils
.
copyProperties
(
solutionDO
,
solutionMenuRespVO
);
// jsonObject.put("name", DictUtils.getDictLabel("solution_category", String.valueOf(entry.getKey())));
return
solutionMenuRespVO
;
// jsonObject.put("value", entry.getKey());
}).
collect
(
Collectors
.
toList
());
// JSONArray jsonArray = new JSONArray();
//根据方案类别(category)分组 0是行业解决方案 1是通用解决方案 这里实际上都是三级菜单里面的东西
// Map<Integer, List<BizSolutionVO>> industryMap =
Map
<
Integer
,
List
<
SolutionMenuRespVO
>>
category
=
// entry.getValue().stream().collect(Collectors.groupingBy(BizSolutionVO::getIndustryCategory));
solutionVOList
.
stream
().
collect
(
Collectors
.
groupingBy
(
SolutionMenuRespVO:
:
getCategory
));
// for (Map.Entry<Integer, List<BizSolutionVO>> integerListEntry : industryMap.entrySet()) {
// JSONObject industry = new JSONObject();
// industry.put("name", DictUtils.getDictLabel("industry_category", String.valueOf(integerListEntry.getKey())));
JSONArray
categoryArray
=
new
JSONArray
();
// industry.put("value", integerListEntry.getKey());
//根据方案类别(category)在字典“solution_category”里分别取上面两级菜单的数据,dict_value对应category
// industry.put("child",
for
(
Map
.
Entry
<
Integer
,
List
<
SolutionMenuRespVO
>>
entry
:
category
.
entrySet
())
{
// entry.getValue().stream().filter(object -> object.getIndustryCategory().equals(integerListEntry.getKey())).collect(Collectors.toList()));
JSONObject
jsonObject
=
new
JSONObject
();
// jsonArray.add(industry);
//这里取的是一级菜单
// }
jsonObject
.
put
(
"name"
,
DictUtils
.
getDictLabel
(
"solution_category"
,
String
.
valueOf
(
entry
.
getKey
())));
// jsonObject.put("child", jsonArray);
jsonObject
.
put
(
"value"
,
entry
.
getKey
());
// categoryArray.add(jsonObject);
JSONArray
jsonArray
=
new
JSONArray
();
// }
//把表里取出来的solutionVOList根据行业类别分组,即0:金融、1:工业、2:企业数字化等,例如行业解决方案里目前只有一个“金融”
// return R.ok(categoryArray);
Map
<
Integer
,
List
<
SolutionMenuRespVO
>>
industryMap
=
// }
entry
.
getValue
().
stream
().
collect
(
Collectors
.
groupingBy
(
SolutionMenuRespVO:
:
getIndustryCategory
));
for
(
Map
.
Entry
<
Integer
,
List
<
SolutionMenuRespVO
>>
integerListEntry
:
industryMap
.
entrySet
())
{
JSONObject
industry
=
new
JSONObject
();
//这里才是
industry
.
put
(
"name"
,
DictUtils
.
getDictLabel
(
"industry_category"
,
String
.
valueOf
(
integerListEntry
.
getKey
())));
industry
.
put
(
"value"
,
integerListEntry
.
getKey
());
//过滤出List<SolutionMenuRespVO>中IndustryCategory与integerListEntry的key相同的SolutionMenuRespVO
//为二级菜单匹配三级菜单内容
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
success
(
categoryArray
);
}
// *//**
// *//**
...
...
computility-module-biz/src/main/java/com/luhu/computility/module/biz/dal/dataobject/solution/SolutionDO.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
dal
.
dataobject
.
solution
;
import
lombok.*
;
import
java.util.*
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.luhu.computility.framework.mybatis.core.dataobject.BaseDO
;
/**
* 解决方案 DO
*
* @author 测试号02
*/
@TableName
(
"biz_solution"
)
@KeySequence
(
"biz_solution_seq"
)
// 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ToString
(
callSuper
=
true
)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
SolutionDO
extends
BaseDO
{
/**
* 主键
*/
@TableId
private
Long
id
;
/**
* 方案类别
*/
private
Integer
category
;
/**
* 行业类别
*/
private
Integer
industryCategory
;
/**
* 标题(行业)
*/
private
String
titleIndustry
;
/**
* 标题(解决方案)
*/
private
String
titleSolution
;
/**
* 标题(咨询)
*/
private
String
titleConsult
;
/**
* 行业概述
*/
private
String
industryInfo
;
/**
* 解决方案
*/
private
String
solutionInfo
;
/**
* 咨询流程
*/
private
String
consultInfo
;
/**
* 状态:0-已下架,1-已上架
*/
private
Integer
groundingStatus
;
/**
* 创建者
*/
private
String
creator
;
/**
* 更新者
*/
private
String
updater
;
/**
* 备注
*/
private
String
remark
;
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/dal/mysql/solution/SolutionMapper.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
dal
.
mysql
.
solution
;
import
java.util.*
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX
;
import
com.luhu.computility.module.biz.dal.dataobject.solution.SolutionDO
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.luhu.computility.module.biz.controller.admin.solution.vo.*
;
/**
* 解决方案 Mapper
*
* @author 测试号02
*/
@Mapper
public
interface
SolutionMapper
extends
BaseMapperX
<
SolutionDO
>
{
default
PageResult
<
SolutionDO
>
selectPage
(
SolutionPageReqVO
reqVO
)
{
return
selectPage
(
reqVO
,
new
LambdaQueryWrapperX
<
SolutionDO
>()
.
eqIfPresent
(
SolutionDO:
:
getCategory
,
reqVO
.
getCategory
())
.
eqIfPresent
(
SolutionDO:
:
getIndustryCategory
,
reqVO
.
getIndustryCategory
())
.
eqIfPresent
(
SolutionDO:
:
getTitleIndustry
,
reqVO
.
getTitleIndustry
())
.
eqIfPresent
(
SolutionDO:
:
getTitleSolution
,
reqVO
.
getTitleSolution
())
.
eqIfPresent
(
SolutionDO:
:
getTitleConsult
,
reqVO
.
getTitleConsult
())
.
eqIfPresent
(
SolutionDO:
:
getIndustryInfo
,
reqVO
.
getIndustryInfo
())
.
eqIfPresent
(
SolutionDO:
:
getSolutionInfo
,
reqVO
.
getSolutionInfo
())
.
eqIfPresent
(
SolutionDO:
:
getConsultInfo
,
reqVO
.
getConsultInfo
())
.
eqIfPresent
(
SolutionDO:
:
getGroundingStatus
,
reqVO
.
getGroundingStatus
())
.
betweenIfPresent
(
SolutionDO:
:
getCreateTime
,
reqVO
.
getCreateTime
())
.
eqIfPresent
(
SolutionDO:
:
getCreator
,
reqVO
.
getCreator
())
.
eqIfPresent
(
SolutionDO:
:
getUpdater
,
reqVO
.
getUpdater
())
.
eqIfPresent
(
SolutionDO:
:
getRemark
,
reqVO
.
getRemark
())
.
orderByDesc
(
SolutionDO:
:
getId
));
}
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/enums/ErrorCodeConstants.java
View file @
edcce9cb
...
@@ -22,4 +22,5 @@ public interface ErrorCodeConstants {
...
@@ -22,4 +22,5 @@ public interface ErrorCodeConstants {
ErrorCode
PARTNER_NOT_EXISTS
=
new
ErrorCode
(
1_040_016_000
,
"合作伙伴管理不存在"
);
ErrorCode
PARTNER_NOT_EXISTS
=
new
ErrorCode
(
1_040_016_000
,
"合作伙伴管理不存在"
);
ErrorCode
SOLUTION_NOT_EXISTS
=
new
ErrorCode
(
1_040_017_000
,
"解决方案不存在"
);
}
}
computility-module-biz/src/main/java/com/luhu/computility/module/biz/service/order/OrderServiceImpl.java
View file @
edcce9cb
...
@@ -50,7 +50,7 @@ public class OrderServiceImpl implements OrderService {
...
@@ -50,7 +50,7 @@ public class OrderServiceImpl implements OrderService {
orderSaveReqVO
.
setCpu
(
resourcesDetailRespVO
.
getCpuId
());
orderSaveReqVO
.
setCpu
(
resourcesDetailRespVO
.
getCpuId
());
orderSaveReqVO
.
setMemory
(
resourcesDetailRespVO
.
getMemoryId
());
orderSaveReqVO
.
setMemory
(
resourcesDetailRespVO
.
getMemoryId
());
orderSaveReqVO
.
setStorage
(
resourcesDetailRespVO
.
getStorageId
());
orderSaveReqVO
.
setStorage
(
resourcesDetailRespVO
.
getStorageId
());
// orderSaveReqVO.
}
}
...
...
computility-module-biz/src/main/java/com/luhu/computility/module/biz/service/solution/SolutionService.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
service
.
solution
;
import
java.util.*
;
import
javax.validation.*
;
import
com.luhu.computility.module.biz.controller.admin.solution.vo.*
;
import
com.luhu.computility.module.biz.dal.dataobject.solution.SolutionDO
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
/**
* 解决方案 Service 接口
*
* @author 测试号02
*/
public
interface
SolutionService
{
/**
* 创建解决方案
*
* @param createReqVO 创建信息
* @return 编号
*/
Long
createSolution
(
@Valid
SolutionSaveReqVO
createReqVO
);
/**
* 更新解决方案
*
* @param updateReqVO 更新信息
*/
void
updateSolution
(
@Valid
SolutionSaveReqVO
updateReqVO
);
/**
* 删除解决方案
*
* @param id 编号
*/
void
deleteSolution
(
Long
id
);
/**
* 批量删除解决方案
*
* @param ids 编号
*/
void
deleteSolutionListByIds
(
List
<
Long
>
ids
);
/**
* 获得解决方案
*
* @param id 编号
* @return 解决方案
*/
SolutionDO
getSolution
(
Long
id
);
/**
* 获得解决方案分页
*
* @param pageReqVO 分页查询
* @return 解决方案分页
*/
PageResult
<
SolutionDO
>
getSolutionPage
(
SolutionPageReqVO
pageReqVO
);
List
<
SolutionDO
>
selectSolutionList
(
SolutionPageReqVO
pageReqVO
);
}
\ No newline at end of file
computility-module-biz/src/main/java/com/luhu/computility/module/biz/service/solution/SolutionServiceImpl.java
0 → 100644
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
biz
.
service
.
solution
;
import
cn.hutool.core.collection.CollUtil
;
import
com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
com.luhu.computility.module.biz.controller.admin.solution.vo.*
;
import
com.luhu.computility.module.biz.dal.dataobject.solution.SolutionDO
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
import
com.luhu.computility.module.biz.dal.mysql.solution.SolutionMapper
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
collection
.
CollectionUtils
.
convertList
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
collection
.
CollectionUtils
.
diffList
;
import
static
com
.
luhu
.
computility
.
module
.
biz
.
enums
.
ErrorCodeConstants
.*;
/**
* 解决方案 Service 实现类
*
* @author 测试号02
*/
@Service
@Validated
public
class
SolutionServiceImpl
implements
SolutionService
{
@Resource
private
SolutionMapper
solutionMapper
;
@Override
public
Long
createSolution
(
SolutionSaveReqVO
createReqVO
)
{
// 插入
SolutionDO
solution
=
BeanUtils
.
toBean
(
createReqVO
,
SolutionDO
.
class
);
solutionMapper
.
insert
(
solution
);
// 返回
return
solution
.
getId
();
}
@Override
public
void
updateSolution
(
SolutionSaveReqVO
updateReqVO
)
{
// 校验存在
validateSolutionExists
(
updateReqVO
.
getId
());
// 更新
SolutionDO
updateObj
=
BeanUtils
.
toBean
(
updateReqVO
,
SolutionDO
.
class
);
solutionMapper
.
updateById
(
updateObj
);
}
@Override
public
void
deleteSolution
(
Long
id
)
{
// 校验存在
validateSolutionExists
(
id
);
// 删除
solutionMapper
.
deleteById
(
id
);
}
@Override
public
void
deleteSolutionListByIds
(
List
<
Long
>
ids
)
{
// 删除
solutionMapper
.
deleteByIds
(
ids
);
}
private
void
validateSolutionExists
(
Long
id
)
{
if
(
solutionMapper
.
selectById
(
id
)
==
null
)
{
throw
exception
(
SOLUTION_NOT_EXISTS
);
}
}
@Override
public
SolutionDO
getSolution
(
Long
id
)
{
return
solutionMapper
.
selectById
(
id
);
}
@Override
public
PageResult
<
SolutionDO
>
getSolutionPage
(
SolutionPageReqVO
pageReqVO
)
{
return
solutionMapper
.
selectPage
(
pageReqVO
);
}
@Override
public
List
<
SolutionDO
>
selectSolutionList
(
SolutionPageReqVO
reqVO
)
{
LambdaQueryWrapperX
<
SolutionDO
>
wrapper
=
new
LambdaQueryWrapperX
<
SolutionDO
>()
.
eqIfPresent
(
SolutionDO:
:
getGroundingStatus
,
reqVO
.
getGroundingStatus
())
.
orderByDesc
(
SolutionDO:
:
getId
);
List
<
SolutionDO
>
result
=
solutionMapper
.
selectList
(
wrapper
);
return
result
;
}
}
\ No newline at end of file
computility-module-biz/src/main/resources/mapper/solution/SolutionMapper.xml
0 → 100644
View file @
edcce9cb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.luhu.computility.module.biz.dal.mysql.solution.SolutionMapper"
>
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
computility-module-mall/computility-module-product/src/test/java/com/luhu/computility/module/product/service/sku/ProductSkuServiceTest.java
View file @
edcce9cb
package
com
.
luhu
.
computility
.
module
.
product
.
service
.
sku
;
//
package com.luhu.computility.module.product.service.sku;
//
import
cn.hutool.core.util.RandomUtil
;
//
import cn.hutool.core.util.RandomUtil;
import
com.luhu.computility.framework.test.core.ut.BaseDbUnitTest
;
//
import com.luhu.computility.framework.test.core.ut.BaseDbUnitTest;
import
com.luhu.computility.framework.test.core.util.AssertUtils
;
//
import com.luhu.computility.framework.test.core.util.AssertUtils;
import
com.luhu.computility.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO
;
//
import com.luhu.computility.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
import
com.luhu.computility.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO
;
//
import com.luhu.computility.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
import
com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO
;
//
import com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO;
import
com.luhu.computility.module.product.dal.mysql.sku.ProductSkuMapper
;
//
import com.luhu.computility.module.product.dal.mysql.sku.ProductSkuMapper;
import
com.luhu.computility.module.product.service.property.ProductPropertyService
;
//
import com.luhu.computility.module.product.service.property.ProductPropertyService;
import
com.luhu.computility.module.product.service.property.ProductPropertyValueService
;
//
import com.luhu.computility.module.product.service.property.ProductPropertyValueService;
import
com.luhu.computility.module.product.service.spu.ProductSpuService
;
//
import com.luhu.computility.module.product.service.spu.ProductSpuService;
import
org.junit.jupiter.api.Disabled
;
//
import org.junit.jupiter.api.Disabled;
import
org.junit.jupiter.api.Test
;
//
import org.junit.jupiter.api.Test;
import
org.springframework.boot.test.mock.mockito.MockBean
;
//
import org.springframework.boot.test.mock.mockito.MockBean;
import
org.springframework.context.annotation.Import
;
//
import org.springframework.context.annotation.Import;
//
import
javax.annotation.Resource
;
//
import javax.annotation.Resource;
import
java.util.Arrays
;
//
import java.util.Arrays;
import
java.util.List
;
//
import java.util.List;
//
import
static
com
.
luhu
.
computility
.
framework
.
test
.
core
.
util
.
AssertUtils
.
assertPojoEquals
;
//
import static com.luhu.computility.framework.test.core.util.AssertUtils.assertPojoEquals;
import
static
com
.
luhu
.
computility
.
framework
.
test
.
core
.
util
.
AssertUtils
.
assertServiceException
;
//
import static com.luhu.computility.framework.test.core.util.AssertUtils.assertServiceException;
import
static
com
.
luhu
.
computility
.
framework
.
test
.
core
.
util
.
RandomUtils
.
randomPojo
;
//
import static com.luhu.computility.framework.test.core.util.RandomUtils.randomPojo;
import
static
com
.
luhu
.
computility
.
module
.
product
.
enums
.
ErrorCodeConstants
.
SKU_NOT_EXISTS
;
//
import static com.luhu.computility.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
import
static
com
.
luhu
.
computility
.
module
.
product
.
enums
.
ErrorCodeConstants
.
SKU_STOCK_NOT_ENOUGH
;
//
import static com.luhu.computility.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH;
import
static
java
.
util
.
Collections
.
singletonList
;
//
import static java.util.Collections.singletonList;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
//
import static org.junit.jupiter.api.Assertions.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
argThat
;
//
import static org.mockito.ArgumentMatchers.argThat;
import
static
org
.
mockito
.
Mockito
.
verify
;
//
import static org.mockito.Mockito.verify;
//
/**
/
//
**
* {@link ProductSkuServiceImpl} 的单元测试
//
* {@link ProductSkuServiceImpl} 的单元测试
*
//
*
* @author 芋道源码
//
* @author 芋道源码
*/
//
*/
@Disabled
// TODO 芋艿:后续 fix 补充的单测
//
@Disabled // TODO 芋艿:后续 fix 补充的单测
@Import
(
ProductSkuServiceImpl
.
class
)
//
@Import(ProductSkuServiceImpl.class)
public
class
ProductSkuServiceTest
extends
BaseDbUnitTest
{
//
public class ProductSkuServiceTest extends BaseDbUnitTest {
//
@Resource
//
@Resource
private
ProductSkuService
productSkuService
;
//
private ProductSkuService productSkuService;
//
@Resource
//
@Resource
private
ProductSkuMapper
productSkuMapper
;
//
private ProductSkuMapper productSkuMapper;
//
@MockBean
//
@MockBean
private
ProductSpuService
productSpuService
;
//
private ProductSpuService productSpuService;
@MockBean
//
@MockBean
private
ProductPropertyService
productPropertyService
;
//
private ProductPropertyService productPropertyService;
@MockBean
//
@MockBean
private
ProductPropertyValueService
productPropertyValueService
;
//
private ProductPropertyValueService productPropertyValueService;
//
public
Long
generateId
()
{
//
public Long generateId() {
return
RandomUtil
.
randomLong
(
100000
,
999999
);
//
return RandomUtil.randomLong(100000, 999999);
}
//
}
//
@Test
//
@Test
public
void
testUpdateSkuList
()
{
//
public void testUpdateSkuList() {
// mock 数据
//
// mock 数据
ProductSkuDO
sku01
=
randomPojo
(
ProductSkuDO
.
class
,
o
->
{
// 测试更新
//
ProductSkuDO sku01 = randomPojo(ProductSkuDO.class, o -> { // 测试更新
o
.
setSpuId
(
1L
);
//
o.setSpuId(1L);
o
.
setProperties
(
singletonList
(
new
ProductSkuDO
.
Property
(
//
o.setProperties(singletonList(new ProductSkuDO.Property(
10L
,
"颜色"
,
20L
,
"红色"
)));
//
10L, "颜色", 20L, "红色")));
});
//
});
productSkuMapper
.
insert
(
sku01
);
//
productSkuMapper.insert(sku01);
ProductSkuDO
sku02
=
randomPojo
(
ProductSkuDO
.
class
,
o
->
{
// 测试删除
//
ProductSkuDO sku02 = randomPojo(ProductSkuDO.class, o -> { // 测试删除
o
.
setSpuId
(
1L
);
//
o.setSpuId(1L);
o
.
setProperties
(
singletonList
(
new
ProductSkuDO
.
Property
(
//
o.setProperties(singletonList(new ProductSkuDO.Property(
10L
,
"颜色"
,
30L
,
"蓝色"
)));
//
10L, "颜色", 30L, "蓝色")));
//
});
//
});
productSkuMapper
.
insert
(
sku02
);
//
productSkuMapper.insert(sku02);
// 准备参数
//
// 准备参数
Long
spuId
=
1L
;
//
Long spuId = 1L;
String
spuName
=
"测试商品"
;
//
String spuName = "测试商品";
List
<
ProductSkuSaveReqVO
>
skus
=
Arrays
.
asList
(
//
List<ProductSkuSaveReqVO> skus = Arrays.asList(
randomPojo
(
ProductSkuSaveReqVO
.
class
,
o
->
{
// 测试更新
//
randomPojo(ProductSkuSaveReqVO.class, o -> { // 测试更新
o
.
setProperties
(
singletonList
(
new
ProductSkuSaveReqVO
.
Property
(
//
o.setProperties(singletonList(new ProductSkuSaveReqVO.Property(
10L
,
"颜色"
,
20L
,
"红色"
)));
//
10L, "颜色", 20L, "红色")));
}),
//
}),
randomPojo
(
ProductSkuSaveReqVO
.
class
,
o
->
{
// 测试新增
//
randomPojo(ProductSkuSaveReqVO.class, o -> { // 测试新增
o
.
setProperties
(
singletonList
(
new
ProductSkuSaveReqVO
.
Property
(
//
o.setProperties(singletonList(new ProductSkuSaveReqVO.Property(
10L
,
"颜色"
,
20L
,
"红色"
)));
//
10L, "颜色", 20L, "红色")));
})
//
})
);
//
);
//
// 调用
//
// 调用
productSkuService
.
updateSkuList
(
spuId
,
skus
);
//
productSkuService.updateSkuList(spuId, skus);
// 断言
//
// 断言
List
<
ProductSkuDO
>
dbSkus
=
productSkuMapper
.
selectListBySpuId
(
spuId
);
//
List<ProductSkuDO> dbSkus = productSkuMapper.selectListBySpuId(spuId);
assertEquals
(
dbSkus
.
size
(),
2
);
//
assertEquals(dbSkus.size(), 2);
// 断言更新的
//
// 断言更新的
assertEquals
(
dbSkus
.
get
(
0
).
getId
(),
sku01
.
getId
());
//
assertEquals(dbSkus.get(0).getId(), sku01.getId());
assertPojoEquals
(
dbSkus
.
get
(
0
),
skus
.
get
(
0
),
"properties"
);
//
assertPojoEquals(dbSkus.get(0), skus.get(0), "properties");
assertEquals
(
skus
.
get
(
0
).
getProperties
().
size
(),
1
);
//
assertEquals(skus.get(0).getProperties().size(), 1);
assertPojoEquals
(
dbSkus
.
get
(
0
).
getProperties
().
get
(
0
),
skus
.
get
(
0
).
getProperties
().
get
(
0
));
//
assertPojoEquals(dbSkus.get(0).getProperties().get(0), skus.get(0).getProperties().get(0));
// 断言新增的
//
// 断言新增的
assertNotEquals
(
dbSkus
.
get
(
1
).
getId
(),
sku02
.
getId
());
//
assertNotEquals(dbSkus.get(1).getId(), sku02.getId());
assertPojoEquals
(
dbSkus
.
get
(
1
),
skus
.
get
(
1
),
"properties"
);
//
assertPojoEquals(dbSkus.get(1), skus.get(1), "properties");
assertEquals
(
skus
.
get
(
1
).
getProperties
().
size
(),
1
);
//
assertEquals(skus.get(1).getProperties().size(), 1);
assertPojoEquals
(
dbSkus
.
get
(
1
).
getProperties
().
get
(
0
),
skus
.
get
(
1
).
getProperties
().
get
(
0
));
//
assertPojoEquals(dbSkus.get(1).getProperties().get(0), skus.get(1).getProperties().get(0));
}
//
}
//
@Test
//
@Test
public
void
testUpdateSkuStock_incrSuccess
()
{
//
public void testUpdateSkuStock_incrSuccess() {
// 准备参数
//
// 准备参数
ProductSkuUpdateStockReqDTO
updateStockReqDTO
=
new
ProductSkuUpdateStockReqDTO
()
//
ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO()
.
setItems
(
singletonList
(
new
ProductSkuUpdateStockReqDTO
.
Item
().
setId
(
1L
).
setIncrCount
(
10
)));
//
.setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(10)));
// mock 数据
//
// mock 数据
productSkuMapper
.
insert
(
randomPojo
(
ProductSkuDO
.
class
,
o
->
{
//
productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> {
o
.
setId
(
1L
).
setSpuId
(
10L
).
setStock
(
20
);
//
o.setId(1L).setSpuId(10L).setStock(20);
o
.
getProperties
().
forEach
(
p
->
{
//
o.getProperties().forEach(p -> {
// 指定 id 范围 解决 Value too long
//
// 指定 id 范围 解决 Value too long
p
.
setPropertyId
(
generateId
());
//
p.setPropertyId(generateId());
p
.
setValueId
(
generateId
());
//
p.setValueId(generateId());
});
//
});
}));
//
}));
//
// 调用
//
// 调用
productSkuService
.
updateSkuStock
(
updateStockReqDTO
);
//
productSkuService.updateSkuStock(updateStockReqDTO);
// 断言
//
// 断言
ProductSkuDO
sku
=
productSkuMapper
.
selectById
(
1L
);
//
ProductSkuDO sku = productSkuMapper.selectById(1L);
assertEquals
(
sku
.
getStock
(),
30
);
//
assertEquals(sku.getStock(), 30);
verify
(
productSpuService
).
updateSpuStock
(
argThat
(
spuStockIncrCounts
->
{
//
verify(productSpuService).updateSpuStock(argThat(spuStockIncrCounts -> {
assertEquals
(
spuStockIncrCounts
.
size
(),
1
);
//
assertEquals(spuStockIncrCounts.size(), 1);
assertEquals
(
spuStockIncrCounts
.
get
(
10L
),
10
);
//
assertEquals(spuStockIncrCounts.get(10L), 10);
return
true
;
//
return true;
}));
//
}));
}
//
}
//
@Test
//
@Test
public
void
testUpdateSkuStock_decrSuccess
()
{
//
public void testUpdateSkuStock_decrSuccess() {
// 准备参数
//
// 准备参数
ProductSkuUpdateStockReqDTO
updateStockReqDTO
=
new
ProductSkuUpdateStockReqDTO
()
//
ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO()
.
setItems
(
singletonList
(
new
ProductSkuUpdateStockReqDTO
.
Item
().
setId
(
1L
).
setIncrCount
(-
10
)));
//
.setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(-10)));
// mock 数据
//
// mock 数据
productSkuMapper
.
insert
(
randomPojo
(
ProductSkuDO
.
class
,
o
->
{
//
productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> {
o
.
setId
(
1L
).
setSpuId
(
10L
).
setStock
(
20
);
//
o.setId(1L).setSpuId(10L).setStock(20);
o
.
getProperties
().
forEach
(
p
->
{
//
o.getProperties().forEach(p -> {
// 指定 id 范围 解决 Value too long
//
// 指定 id 范围 解决 Value too long
p
.
setPropertyId
(
generateId
());
//
p.setPropertyId(generateId());
p
.
setValueId
(
generateId
());
//
p.setValueId(generateId());
});
//
});
}));
//
}));
//
// 调用
//
// 调用
productSkuService
.
updateSkuStock
(
updateStockReqDTO
);
//
productSkuService.updateSkuStock(updateStockReqDTO);
// 断言
//
// 断言
ProductSkuDO
sku
=
productSkuMapper
.
selectById
(
1L
);
//
ProductSkuDO sku = productSkuMapper.selectById(1L);
assertEquals
(
sku
.
getStock
(),
10
);
//
assertEquals(sku.getStock(), 10);
verify
(
productSpuService
).
updateSpuStock
(
argThat
(
spuStockIncrCounts
->
{
//
verify(productSpuService).updateSpuStock(argThat(spuStockIncrCounts -> {
assertEquals
(
spuStockIncrCounts
.
size
(),
1
);
//
assertEquals(spuStockIncrCounts.size(), 1);
assertEquals
(
spuStockIncrCounts
.
get
(
10L
),
-
10
);
//
assertEquals(spuStockIncrCounts.get(10L), -10);
return
true
;
//
return true;
}));
//
}));
}
//
}
//
@Test
//
@Test
public
void
testUpdateSkuStock_decrFail
()
{
//
public void testUpdateSkuStock_decrFail() {
// 准备参数
//
// 准备参数
ProductSkuUpdateStockReqDTO
updateStockReqDTO
=
new
ProductSkuUpdateStockReqDTO
()
//
ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO()
.
setItems
(
singletonList
(
new
ProductSkuUpdateStockReqDTO
.
Item
().
setId
(
1L
).
setIncrCount
(-
30
)));
//
.setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(-30)));
// mock 数据
//
// mock 数据
productSkuMapper
.
insert
(
randomPojo
(
ProductSkuDO
.
class
,
o
->
{
//
productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> {
o
.
setId
(
1L
).
setSpuId
(
10L
).
setStock
(
20
);
//
o.setId(1L).setSpuId(10L).setStock(20);
o
.
getProperties
().
forEach
(
p
->
{
//
o.getProperties().forEach(p -> {
// 指定 id 范围 解决 Value too long
//
// 指定 id 范围 解决 Value too long
p
.
setPropertyId
(
generateId
());
//
p.setPropertyId(generateId());
p
.
setValueId
(
generateId
());
//
p.setValueId(generateId());
});
//
});
}));
//
}));
// 调用并断言
//
// 调用并断言
AssertUtils
.
assertServiceException
(()
->
productSkuService
.
updateSkuStock
(
updateStockReqDTO
),
//
AssertUtils.assertServiceException(() -> productSkuService.updateSkuStock(updateStockReqDTO),
SKU_STOCK_NOT_ENOUGH
);
//
SKU_STOCK_NOT_ENOUGH);
}
//
}
//
@Test
//
@Test
public
void
testDeleteSku_success
()
{
//
public void testDeleteSku_success() {
ProductSkuDO
dbSku
=
randomPojo
(
ProductSkuDO
.
class
,
o
->
{
//
ProductSkuDO dbSku = randomPojo(ProductSkuDO.class, o -> {
o
.
setId
(
generateId
()).
setSpuId
(
generateId
());
//
o.setId(generateId()).setSpuId(generateId());
o
.
getProperties
().
forEach
(
p
->
{
//
o.getProperties().forEach(p -> {
// 指定 id 范围 解决 Value too long
//
// 指定 id 范围 解决 Value too long
p
.
setPropertyId
(
generateId
());
//
p.setPropertyId(generateId());
p
.
setValueId
(
generateId
());
//
p.setValueId(generateId());
});
//
});
});
//
});
// mock 数据
//
// mock 数据
productSkuMapper
.
insert
(
dbSku
);
//
productSkuMapper.insert(dbSku);
// 准备参数
//
// 准备参数
Long
id
=
dbSku
.
getId
();
//
Long id = dbSku.getId();
//
// 调用
//
// 调用
productSkuService
.
deleteSku
(
id
);
//
productSkuService.deleteSku(id);
// 校验数据不存在了
//
// 校验数据不存在了
assertNull
(
productSkuMapper
.
selectById
(
id
));
//
assertNull(productSkuMapper.selectById(id));
}
//
}
//
@Test
//
@Test
public
void
testDeleteSku_notExists
()
{
//
public void testDeleteSku_notExists() {
// 准备参数
//
// 准备参数
Long
id
=
1L
;
//
Long id = 1L;
//
// 调用, 并断言异常
//
// 调用, 并断言异常
assertServiceException
(()
->
productSkuService
.
deleteSku
(
id
),
SKU_NOT_EXISTS
);
//
assertServiceException(() -> productSkuService.deleteSku(id), SKU_NOT_EXISTS);
}
//
}
}
//
}
computility-module-mall/computility-module-trade/src/main/java/com/luhu/computility/module/trade/service/order/TradeOrderUpdateServiceImpl.java
View file @
edcce9cb
...
@@ -164,7 +164,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
...
@@ -164,7 +164,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
* @return 订单价格
* @return 订单价格
*/
*/
private
TradePriceCalculateRespBO
calculatePrice
(
Long
userId
,
AppTradeOrderSettlementReqVO
settlementReqVO
)
{
private
TradePriceCalculateRespBO
calculatePrice
(
Long
userId
,
AppTradeOrderSettlementReqVO
settlementReqVO
)
{
// 1. 如果来自购物车,则获得购物车的商品
// 1. 如果来自购物车,则获得购物车的商品
,cartId为空则立即购买
List
<
CartDO
>
cartList
=
cartService
.
getCartList
(
userId
,
List
<
CartDO
>
cartList
=
cartService
.
getCartList
(
userId
,
convertSet
(
settlementReqVO
.
getItems
(),
AppTradeOrderSettlementReqVO
.
Item
::
getCartId
));
convertSet
(
settlementReqVO
.
getItems
(),
AppTradeOrderSettlementReqVO
.
Item
::
getCartId
));
...
...
computility-module-system/src/main/java/com/luhu/computility/module/system/util/dict/DictUtils.java
View file @
edcce9cb
...
@@ -2,6 +2,7 @@ package com.luhu.computility.module.system.util.dict;
...
@@ -2,6 +2,7 @@ package com.luhu.computility.module.system.util.dict;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson2.JSONArray
;
import
com.alibaba.fastjson2.JSONArray
;
import
com.luhu.computility.framework.common.core.redis.RedisCache
;
import
com.luhu.computility.framework.common.core.redis.RedisCache
;
import
com.luhu.computility.framework.common.util.spring.SpringUtils
;
import
com.luhu.computility.framework.common.util.spring.SpringUtils
;
...
@@ -42,27 +43,22 @@ public class DictUtils {
...
@@ -42,27 +43,22 @@ public class DictUtils {
* @return dictDatas 字典数据列表
* @return dictDatas 字典数据列表
*/
*/
public
static
List
<
DictDataDO
>
getDictCache
(
String
key
)
{
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
));
Object
cacheObj
=
SpringUtils
.
getBean
(
RedisCache
.
class
).
getCacheObject
(
getCacheKey
(
key
));
if
(
cacheObj
==
null
)
{
if
(
cacheObj
==
null
)
{
return
null
;
return
null
;
}
}
List
<
DictDataDO
>
dictList
;
// 统一将缓存对象转为 JSON 字符串,再解析为 List<DictDataDO>
if
(
cacheObj
instanceof
JSONArray
)
{
String
jsonStr
;
// 新数据:JSONArray 直接转 List
if
(
cacheObj
instanceof
String
)
{
dictList
=
((
JSONArray
)
cacheObj
).
toJavaList
(
DictDataDO
.
class
);
jsonStr
=
(
String
)
cacheObj
;
}
else
if
(
cacheObj
instanceof
ArrayList
)
{
dictList
=
(
List
<
DictDataDO
>)
cacheObj
;
}
else
{
}
else
{
//
其他未知类型,返回空列表(避免报错)
//
如果是对象/列表,先转为 JSON 字符串
dictList
=
new
ArrayList
<>(
);
jsonStr
=
JSON
.
toJSONString
(
cacheObj
);
}
}
return
dictList
;
// 解析 JSON 字符串为 List<DictDataDO>
return
JSON
.
parseArray
(
jsonStr
,
DictDataDO
.
class
);
}
}
/**
/**
...
...
computility-server/src/main/resources/logback-spring.xml
View file @
edcce9cb
...
@@ -56,6 +56,11 @@
...
@@ -56,6 +56,11 @@
</encoder>
</encoder>
</appender>
</appender>
<logger
name=
"com.luhu.computility.module"
level=
"DEBUG"
additivity=
"false"
>
<appender-ref
ref=
"STDOUT"
/>
<appender-ref
ref=
"GRPC"
/>
</logger>
<!-- 本地环境 -->
<!-- 本地环境 -->
<springProfile
name=
"local"
>
<springProfile
name=
"local"
>
<root
level=
"INFO"
>
<root
level=
"INFO"
>
...
...
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