Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lingxi-lxy-yanshou
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
后端-黄柯铭
lingxi-lxy-yanshou
Commits
78a66ed0
Commit
78a66ed0
authored
Jul 13, 2020
by
xyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整树形参数
parent
fadac665
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
59 deletions
+92
-59
Node.java
.../src/main/java/com/ssy/common/constant/treeNode/Node.java
+5
-0
build.gradle
product-service/build.gradle
+1
-0
TreeUtils.java
...in/java/com/ssy/lingxi/product/common/tree/TreeUtils.java
+2
-3
CommodityController.java
...om/ssy/lingxi/product/controller/CommodityController.java
+24
-12
Commodity.java
...rc/main/java/com/ssy/lingxi/product/entity/Commodity.java
+11
-1
ShopResponse.java
...a/com/ssy/lingxi/product/model/response/ShopResponse.java
+28
-0
ICommodityService.java
...ava/com/ssy/lingxi/product/service/ICommodityService.java
+2
-9
CommodityServiceImpl.java
.../ssy/lingxi/product/serviceImpl/CommodityServiceImpl.java
+15
-30
CustomerCategoryServiceImpl.java
...uct/serviceImpl/customer/CustomerCategoryServiceImpl.java
+2
-2
CategoryServiceImpl.java
...gxi/product/serviceImpl/platform/CategoryServiceImpl.java
+2
-2
No files found.
common/src/main/java/com/ssy/common/constant/treeNode/Node.java
View file @
78a66ed0
...
...
@@ -19,6 +19,11 @@ import java.util.List;
@AllArgsConstructor
public
class
Node
{
/**
* id
*/
@NotEmpty
private
Long
id
;
/**
* 节点key
*/
@NotEmpty
...
...
product-service/build.gradle
View file @
78a66ed0
...
...
@@ -22,6 +22,7 @@ dependencies {
implementation
project
(
':common'
)
implementation
project
(
':platform-manage-service:platform-manage-service-api'
)
implementation
project
(
':sms-service:sms-service-api'
)
implementation
project
(
':warehouse-service:warehouse-service-api'
)
implementation
'org.springframework.boot:spring-boot-starter-actuator'
implementation
'org.springframework.boot:spring-boot-starter-data-jpa'
...
...
product-service/src/main/java/com/ssy/lingxi/product/common/tree/TreeUtils.java
View file @
78a66ed0
...
...
@@ -2,7 +2,6 @@ package com.ssy.lingxi.product.common.tree;
import
com.ssy.common.constant.treeNode.Node
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -19,7 +18,7 @@ public class TreeUtils {
//建立树形结构
public
static
List
<
Node
>
builTree
(
List
<
Node
>
sourceList
,
List
<
Node
>
rootNodeList
){
allNodeList
=
sourceList
;
List
<
Node
>
treeList
=
new
ArrayList
<
Node
>();
List
<
Node
>
treeList
=
new
ArrayList
<>();
for
(
Node
node
:
rootNodeList
)
{
node
=
buildChilTree
(
node
);
treeList
.
add
(
node
);
...
...
@@ -29,7 +28,7 @@ public class TreeUtils {
//递归,建立子树形结构
private
static
Node
buildChilTree
(
Node
pNode
){
List
<
Node
>
childrenList
=
new
ArrayList
<
Node
>();
List
<
Node
>
childrenList
=
new
ArrayList
<>();
for
(
Node
node
:
allNodeList
)
{
String
[]
nodeSplit
=
node
.
getKey
().
split
(
"-"
);
String
[]
pNodeSplit
=
pNode
.
getKey
().
split
(
"-"
);
...
...
product-service/src/main/java/com/ssy/lingxi/product/controller/CommodityController.java
View file @
78a66ed0
...
...
@@ -2,16 +2,20 @@ package com.ssy.lingxi.product.controller;
import
com.ssy.common.model.vo.PageVO
;
import
com.ssy.common.response.PageData
;
import
com.ssy.common.response.ResponseCode
;
import
com.ssy.common.response.Wrapper
;
import
com.ssy.lingxi.product.entity.Commodity
;
import
com.ssy.lingxi.product.entity.CommodityCheckRecord
;
import
com.ssy.lingxi.product.model.request.commodity.CommodityRequest
;
import
com.ssy.lingxi.product.service.ICommodityService
;
import
com.ssy.lingxi.warhouse.api.dto.response.ShopResponse
;
import
com.ssy.lingxi.warhouse.api.feign.ShopControllerFeign
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @menu: 商品管理
...
...
@@ -27,6 +31,9 @@ public class CommodityController extends BaseController{
@Autowired
private
ICommodityService
commodityService
;
@Autowired
private
ShopControllerFeign
shopControllerFeign
;
/**
* 查询商品信息--商品能力
* @param id 商品id
...
...
@@ -71,24 +78,29 @@ public class CommodityController extends BaseController{
}
/**
*
启用/停用
商品--商品能力
*
提交审核
商品--商品能力
* @param id 商品id
* @param isEnable 是否启用
* @return
*/
@RequestMapping
(
value
=
"/
updateCommodityEnable
"
,
method
=
RequestMethod
.
GET
)
public
Wrapper
<
String
>
updateCommodityEnable
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"isEnable"
)
Boolean
isEnable
)
{
return
Wrapper
.
success
(
commodityService
.
updateCommodityEnable
(
id
,
isEnable
));
@RequestMapping
(
value
=
"/
applyCheckCommodity
"
,
method
=
RequestMethod
.
GET
)
public
Wrapper
<
String
>
applyCheckCommodity
(
@RequestParam
(
"id"
)
Long
id
)
{
return
Wrapper
.
success
(
commodityService
.
applyCheckCommodity
(
id
));
}
/**
* 提交审核商品--商品能力
* @param id 商品id
* 获取上架商城--商品能力
* @return
*/
@RequestMapping
(
value
=
"/applyCheckCommodity"
,
method
=
RequestMethod
.
GET
)
public
Wrapper
<
String
>
applyCheckCommodity
(
@RequestParam
(
"id"
)
Long
id
)
{
return
Wrapper
.
success
(
commodityService
.
applyCheckCommodity
(
id
));
@RequestMapping
(
value
=
"/getShop"
,
method
=
RequestMethod
.
GET
)
public
Wrapper
<
List
<
ShopResponse
>>
getShop
()
{
Wrapper
<
List
<
ShopResponse
>>
listWrapper
=
shopControllerFeign
.
shopAll
();
if
(
ResponseCode
.
SUCCESS
.
getCode
()
==
listWrapper
.
getCode
()){
List
<
ShopResponse
>
data
=
listWrapper
.
getData
();
List
<
ShopResponse
>
collect
=
data
.
stream
().
filter
(
shop
->
(
shop
.
getType
()
==
1
||
shop
.
getType
()
==
3
)
&&
shop
.
getState
()
==
1
&&
shop
.
getEnvironment
()
==
1
).
collect
(
Collectors
.
toList
());
return
Wrapper
.
success
(
collect
);
}
else
{
return
Wrapper
.
fail
(
"获取上架商城失败"
);
}
}
/**
...
...
@@ -97,8 +109,8 @@ public class CommodityController extends BaseController{
* @return
*/
@RequestMapping
(
value
=
"/publishCommodity"
,
method
=
RequestMethod
.
GET
)
public
Wrapper
<
String
>
publishCommodity
(
@RequestParam
(
"id"
)
Long
id
)
{
return
Wrapper
.
success
(
commodityService
.
publishCommodity
(
id
));
public
Wrapper
<
String
>
publishCommodity
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"shopIdList"
)
List
<
Integer
>
shopIdList
)
{
return
Wrapper
.
success
(
commodityService
.
publishCommodity
(
id
,
shopIdList
));
}
/**
...
...
product-service/src/main/java/com/ssy/lingxi/product/entity/Commodity.java
View file @
78a66ed0
...
...
@@ -50,7 +50,7 @@ public class Commodity {
* 货品id列表
*/
@JsonManagedReference
@ManyToMany
(
cascade
=
CascadeType
.
ALL
)
@ManyToMany
(
cascade
=
CascadeType
.
PERSIST
)
@JoinTable
(
name
=
"product_commodity_goods"
,
joinColumns
={
@JoinColumn
(
name
=
"commodity_id"
,
referencedColumnName
=
"id"
)},
inverseJoinColumns
={
@JoinColumn
(
name
=
"goods_id"
,
referencedColumnName
=
"id"
)})
...
...
@@ -143,4 +143,14 @@ public class Commodity {
*/
@Column
(
columnDefinition
=
"varchar(300)"
,
nullable
=
true
)
private
String
afterService
;
// /**
// * 商城id列表
// */
// @JsonManagedReference
// @OneToMany(cascade=CascadeType.PERSIST)
// @JoinTable(name="product_commodity_shop",
// joinColumns={ @JoinColumn(name="commodity_id", referencedColumnName="id")},
// inverseJoinColumns={@JoinColumn(name="shop_id")})
// private List<Integer> shopIdList;
}
product-service/src/main/java/com/ssy/lingxi/product/model/response/ShopResponse.java
0 → 100644
View file @
78a66ed0
package
com
.
ssy
.
lingxi
.
product
.
model
.
response
;
import
lombok.Data
;
/**
* @description: 商城实体
* @author: jw.chen
* @version: 2.0.0
* @date: 2020/6/28
*/
@Data
public
class
ShopResponse
{
/**
* 商城ID
*/
private
Long
id
;
/**
* 商城名称
*/
private
String
name
;
/**
* 是否已选择
*/
private
Boolean
state
;
}
product-service/src/main/java/com/ssy/lingxi/product/service/ICommodityService.java
View file @
78a66ed0
...
...
@@ -55,14 +55,6 @@ public interface ICommodityService {
String
deleteCommodity
(
Long
id
);
/**
* 启用/停用
* @param id
* @param isEnable
* @return
*/
String
updateCommodityEnable
(
Long
id
,
Boolean
isEnable
);
/**
* 提交审核
* @param id
* @return
...
...
@@ -72,9 +64,10 @@ public interface ICommodityService {
/**
* 上架商品--商品能力
* @param id
* @param shopIdList
* @return
*/
String
publishCommodity
(
Long
id
);
String
publishCommodity
(
Long
id
,
List
<
Integer
>
shopIdList
);
/**
* 下架商品--商品能力
...
...
product-service/src/main/java/com/ssy/lingxi/product/serviceImpl/CommodityServiceImpl.java
View file @
78a66ed0
...
...
@@ -19,7 +19,6 @@ import com.ssy.lingxi.product.repository.CommodityRepository;
import
com.ssy.lingxi.product.repository.GoodsRepository
;
import
com.ssy.lingxi.product.repository.customer.CustomerAttributeRepository
;
import
com.ssy.lingxi.product.repository.platform.AttributeRepository
;
import
com.ssy.lingxi.product.repository.platform.AttributeValueRepository
;
import
com.ssy.lingxi.product.service.ICommodityService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -55,9 +54,6 @@ public class CommodityServiceImpl implements ICommodityService {
private
CustomerAttributeRepository
customerAttributeRepository
;
@Autowired
private
AttributeValueRepository
attributeValueRepository
;
@Autowired
private
CommodityCheckRecordRepository
commodityCheckRecordRepository
;
/**
...
...
@@ -197,27 +193,14 @@ public class CommodityServiceImpl implements ICommodityService {
@Override
public
String
deleteCommodity
(
Long
id
)
{
//TODO 是否有商品还在使用,如在使用,不能删除
commodityRepository
.
deleteById
(
id
);
return
"删除成功"
;
}
/**
* 启用/停用
* @param id
* @param isEnable
* @return
*/
@Override
public
String
updateCommodityEnable
(
Long
id
,
Boolean
isEnable
){
//TODO 是否有商品还在使用,如在使用,不能删除
//验证数据库中是否存在该数据
Commodity
commodity
=
commodityRepository
.
findById
(
id
).
orElse
(
null
);
if
(
commodity
!=
null
){
//持久化数据
commodity
.
setGoodsList
(
null
);
commodityRepository
.
saveAndFlush
(
commodity
);
return
"设置成功"
;
commodityRepository
.
deleteById
(
id
);
return
"删除成功"
;
}
else
{
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_NOT_EXIST
);
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_NOT_EXIST
);
}
}
...
...
@@ -233,7 +216,7 @@ public class CommodityServiceImpl implements ICommodityService {
if
(
commodity
!=
null
){
Integer
current_status
=
commodity
.
getStatus
();
if
(
StatusEnum
.
Not_Submitted
.
getCode
()
!=
current_status
){
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_STATUS_UNLEGAL
);
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_STATUS_UNLEGAL
);
}
String
time
=
DateUtil
.
formatDateTime
(
new
Date
());
Integer
new_status
=
StatusEnum
.
Not_Check
.
getCode
();
...
...
@@ -252,31 +235,33 @@ public class CommodityServiceImpl implements ICommodityService {
commodityCheckRecordRepository
.
saveAndFlush
(
commodityCheckRecord
);
return
"设置成功"
;
}
else
{
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_NOT_EXIST
);
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_NOT_EXIST
);
}
}
/**
*
发布
商品--商品能力
*
上架
商品--商品能力
* @param id
* @param shopIdList
* @return
*/
@Override
public
String
publishCommodity
(
Long
id
)
{
public
String
publishCommodity
(
Long
id
,
List
<
Integer
>
shopIdList
)
{
//验证数据库中是否存在该数据
Commodity
commodity
=
commodityRepository
.
findById
(
id
).
orElse
(
null
);
if
(
commodity
!=
null
){
Integer
current_status
=
commodity
.
getStatus
();
if
(
StatusEnum
.
Pass
.
getCode
()
!=
current_status
||
StatusEnum
.
Off_Shelf
.
getCode
()
!=
current_status
){
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_STATUS_UNLEGAL
);
if
(
StatusEnum
.
Pass
.
getCode
()
!=
current_status
&&
StatusEnum
.
Off_Shelf
.
getCode
()
!=
current_status
){
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_STATUS_UNLEGAL
);
}
Integer
new_status
=
StatusEnum
.
On_Shelf
.
getCode
();
//持久化数据
commodity
.
setStatus
(
new_status
);
// commodity.setShopIdList(shopIdList);
commodityRepository
.
saveAndFlush
(
commodity
);
return
"设置成功"
;
}
else
{
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_NOT_EXIST
);
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_NOT_EXIST
);
}
}
...
...
@@ -292,7 +277,7 @@ public class CommodityServiceImpl implements ICommodityService {
if
(
commodity
!=
null
){
Integer
current_status
=
commodity
.
getStatus
();
if
(
StatusEnum
.
On_Shelf
.
getCode
()
!=
current_status
){
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_STATUS_UNLEGAL
);
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_STATUS_UNLEGAL
);
}
Integer
new_status
=
StatusEnum
.
Off_Shelf
.
getCode
();
//持久化数据
...
...
@@ -300,7 +285,7 @@ public class CommodityServiceImpl implements ICommodityService {
commodityRepository
.
saveAndFlush
(
commodity
);
return
"设置成功"
;
}
else
{
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
BRAND
_NOT_EXIST
);
throw
new
BusinessException
(
ResponseCode
.
PRODUCT_
COMMODITY
_NOT_EXIST
);
}
}
...
...
product-service/src/main/java/com/ssy/lingxi/product/serviceImpl/customer/CustomerCategoryServiceImpl.java
View file @
78a66ed0
...
...
@@ -47,8 +47,8 @@ public class CustomerCategoryServiceImpl implements ICustomerCategoryService {
List
<
CustomerCategory
>
customerCategoryList
=
customerCategoryRepository
.
findAll
();
if
(!
customerCategoryList
.
isEmpty
()){
//组装树结构
List
<
Node
>
sourceList
=
customerCategoryList
.
stream
().
map
(
c
->
new
Node
(
c
.
getKey
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
List
<
Node
>
resultList
=
customerCategoryList
.
stream
().
filter
(
c
->
c
.
getLevel
()
==
1
).
map
(
c
->
new
Node
(
c
.
getKey
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
List
<
Node
>
sourceList
=
customerCategoryList
.
stream
().
map
(
c
->
new
Node
(
c
.
get
Id
(),
c
.
get
Key
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
List
<
Node
>
resultList
=
customerCategoryList
.
stream
().
filter
(
c
->
c
.
getLevel
()
==
1
).
map
(
c
->
new
Node
(
c
.
get
Id
(),
c
.
get
Key
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
return
TreeUtils
.
builTree
(
sourceList
,
resultList
);
}
else
{
return
new
ArrayList
<>();
...
...
product-service/src/main/java/com/ssy/lingxi/product/serviceImpl/platform/CategoryServiceImpl.java
View file @
78a66ed0
...
...
@@ -44,8 +44,8 @@ public class CategoryServiceImpl implements ICategoryService {
List
<
Category
>
categoryList
=
categoryRepository
.
findAll
();
if
(!
categoryList
.
isEmpty
()){
//组装树结构
List
<
Node
>
sourceList
=
categoryList
.
stream
().
map
(
c
->
new
Node
(
c
.
getKey
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
List
<
Node
>
resultList
=
categoryList
.
stream
().
filter
(
c
->
c
.
getLevel
()
==
1
).
map
(
c
->
new
Node
(
c
.
getKey
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
List
<
Node
>
sourceList
=
categoryList
.
stream
().
map
(
c
->
new
Node
(
c
.
get
Id
(),
c
.
get
Key
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
List
<
Node
>
resultList
=
categoryList
.
stream
().
filter
(
c
->
c
.
getLevel
()
==
1
).
map
(
c
->
new
Node
(
c
.
get
Id
(),
c
.
get
Key
(),
c
.
getName
(),
false
,
new
ArrayList
<>())).
collect
(
Collectors
.
toList
());
return
TreeUtils
.
builTree
(
sourceList
,
resultList
);
}
else
{
return
new
ArrayList
<>();
...
...
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