Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
custom-server
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhonghong
custom-server
Commits
e1b52fab
Commit
e1b52fab
authored
Jun 04, 2026
by
pfh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom商品迁移
parent
22ab4ed1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
236 additions
and
0 deletions
+236
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/CustomProductBlacklistService.java
+21
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/CustomProductFactoryPriceIntervalRelService.java
+10
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/CustomProductWarehouseRelService.java
+28
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/impl/CustomProductBlacklistServiceImpl.java
+82
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/impl/CustomProductFactoryPriceIntervalRelServiceImpl.java
+22
-0
custom-server-app/src/main/java/com/jomalls/custom/app/service/impl/CustomProductWarehouseRelServiceImpl.java
+73
-0
No files found.
custom-server-app/src/main/java/com/jomalls/custom/app/service/CustomProductBlacklistService.java
View file @
e1b52fab
...
...
@@ -59,5 +59,26 @@ public interface CustomProductBlacklistService {
*/
void
deleteById
(
Integer
id
);
/**
* 批量保存黑名单
*
* @param productId 产品ID
* @param diyUserIds DIY用户ID列表
*/
void
saveBatch
(
Integer
productId
,
List
<
Integer
>
diyUserIds
);
/**
* 批量保存多个产品的黑名单
* @param productIds
* @param diyUserIds
*/
void
saveBatchProduct
(
List
<
Integer
>
productIds
,
List
<
Integer
>
diyUserIds
);
/**
* 根据产品ID获取DIY用户ID列表
* @param productId
* @return
*/
List
<
Integer
>
getDiyUserIdsByProductId
(
Integer
productId
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/CustomProductFactoryPriceIntervalRelService.java
View file @
e1b52fab
...
...
@@ -3,6 +3,8 @@ package com.jomalls.custom.app.service;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jomalls.custom.app.vo.CustomProductFactoryPriceIntervalRelPageVO
;
import
com.jomalls.custom.app.vo.CustomProductFactoryPriceIntervalRelVO
;
import
com.jomalls.custom.dal.entity.CustomProductFactoryPriceIntervalRelEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
@@ -59,5 +61,13 @@ public interface CustomProductFactoryPriceIntervalRelService {
*/
void
deleteById
(
Integer
id
);
/**
* 批量保存工厂价格区间关联
* 逻辑:先删除该产品下的所有旧数据,再批量插入新数据
* @param data 待保存的数据列表
* @param productId 产品ID
*/
void
saveBatch
(
List
<
CustomProductFactoryPriceIntervalRelEntity
>
data
,
Integer
productId
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/CustomProductWarehouseRelService.java
View file @
e1b52fab
...
...
@@ -3,6 +3,8 @@ package com.jomalls.custom.app.service;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jomalls.custom.app.vo.CustomProductWarehouseRelPageVO
;
import
com.jomalls.custom.app.vo.CustomProductWarehouseRelVO
;
import
com.jomalls.custom.dal.entity.CustomProductWarehouseRelEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
@@ -59,5 +61,31 @@ public interface CustomProductWarehouseRelService {
*/
void
deleteById
(
Integer
id
);
/**
* 根据仓库ID获取关联列表
*/
List
<
CustomProductWarehouseRelEntity
>
getListByWareHouseId
(
Long
warehouseId
);
/**
* 根据产品ID获取关联列表
*/
List
<
CustomProductWarehouseRelEntity
>
getListByProductId
(
Long
productId
);
/**
* 根据产品ID获取仓库ID列表
*/
List
<
Long
>
getWarehouseIdsByProductId
(
Long
productId
);
/**
* 批量保存产品与仓库的关联
* 逻辑:先删除该产品现有的所有关联,再批量插入新的
*/
void
saveBatch
(
Integer
productId
,
List
<
Long
>
warehouseIds
);
/**
* 根据产品ID删除关联
* 注意:原 TS 代码支持手动传入 transaction,Java 中通常使用 @Transactional 注解管理事务
*/
void
deleteByProductId
(
Integer
productId
);
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/impl/CustomProductBlacklistServiceImpl.java
View file @
e1b52fab
package
com
.
jomalls
.
custom
.
app
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.jomalls.custom.app.exception.ServiceException
;
import
com.jomalls.custom.app.vo.CustomProductBlacklistPageVO
;
import
com.jomalls.custom.app.vo.CustomProductBlacklistVO
;
...
...
@@ -16,7 +18,9 @@ import org.springframework.dao.DuplicateKeyException;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -93,4 +97,82 @@ public class CustomProductBlacklistServiceImpl implements CustomProductBlacklist
customProductBlacklistDomainService
.
removeById
(
id
);
}
/**
* 批量保存黑名单
*
* @param productId 产品ID
* @param diyUserIds DIY用户ID列表
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
saveBatch
(
Integer
productId
,
List
<
Integer
>
diyUserIds
)
{
customProductBlacklistDomainService
.
remove
(
new
LambdaQueryWrapper
<
CustomProductBlacklistEntity
>()
.
eq
(
CustomProductBlacklistEntity:
:
getProductId
,
productId
));
if
(
CollectionUtils
.
isEmpty
(
diyUserIds
))
{
return
;
}
List
<
CustomProductBlacklistEntity
>
blacklistEntities
=
diyUserIds
.
stream
()
.
map
(
diyUserId
->
{
CustomProductBlacklistEntity
entity
=
new
CustomProductBlacklistEntity
();
entity
.
setProductId
(
productId
);
entity
.
setDiyUserId
(
diyUserId
);
return
entity
;
})
.
collect
(
Collectors
.
toList
());
customProductBlacklistDomainService
.
saveBatch
(
blacklistEntities
);
}
/**
* 批量保存多个产品的黑名单
* @param productIds
* @param diyUserIds
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
saveBatchProduct
(
List
<
Integer
>
productIds
,
List
<
Integer
>
diyUserIds
)
{
if
(
CollectionUtils
.
isEmpty
(
productIds
)
||
CollectionUtils
.
isEmpty
(
diyUserIds
))
{
return
;
}
// 1. 删除这些产品下现有的所有黑名单
customProductBlacklistDomainService
.
remove
(
new
LambdaQueryWrapper
<
CustomProductBlacklistEntity
>()
.
in
(
CustomProductBlacklistEntity:
:
getProductId
,
productIds
));
List
<
CustomProductBlacklistEntity
>
tempList
=
new
ArrayList
<>();
for
(
Integer
productId
:
productIds
)
{
for
(
Integer
diyUserId
:
diyUserIds
)
{
CustomProductBlacklistEntity
entity
=
new
CustomProductBlacklistEntity
();
entity
.
setProductId
(
productId
);
entity
.
setDiyUserId
(
diyUserId
);
tempList
.
add
(
entity
);
}
}
if
(!
tempList
.
isEmpty
())
{
customProductBlacklistDomainService
.
saveBatch
(
tempList
);
}
}
/**
* 根据产品ID获取DIY用户ID列表
* @param productId
* @return
*/
@Override
public
List
<
Integer
>
getDiyUserIdsByProductId
(
Integer
productId
)
{
if
(
productId
==
null
)
{
return
new
ArrayList
<>();
}
List
<
CustomProductBlacklistEntity
>
list
=
customProductBlacklistDomainService
.
list
(
new
LambdaQueryWrapper
<
CustomProductBlacklistEntity
>()
.
eq
(
CustomProductBlacklistEntity:
:
getProductId
,
productId
)
.
select
(
CustomProductBlacklistEntity:
:
getDiyUserId
)
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
new
ArrayList
<>();
}
return
list
.
stream
()
.
map
(
CustomProductBlacklistEntity:
:
getDiyUserId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
}
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/impl/CustomProductFactoryPriceIntervalRelServiceImpl.java
View file @
e1b52fab
package
com
.
jomalls
.
custom
.
app
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.jomalls.custom.app.exception.ServiceException
;
import
com.jomalls.custom.app.vo.CustomProductFactoryPriceIntervalRelPageVO
;
import
com.jomalls.custom.app.vo.CustomProductFactoryPriceIntervalRelVO
;
...
...
@@ -93,4 +95,24 @@ public class CustomProductFactoryPriceIntervalRelServiceImpl implements CustomPr
customProductFactoryPriceIntervalRelDomainService
.
removeById
(
id
);
}
/**
* 批量保存工厂价格区间关联
* 逻辑:先删除该产品下的所有旧数据,再批量插入新数据
* @param data 待保存的数据列表
* @param productId 产品ID
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveBatch
(
List
<
CustomProductFactoryPriceIntervalRelEntity
>
data
,
Integer
productId
)
{
customProductFactoryPriceIntervalRelDomainService
.
remove
(
new
LambdaQueryWrapper
<
CustomProductFactoryPriceIntervalRelEntity
>()
.
eq
(
CustomProductFactoryPriceIntervalRelEntity:
:
getProductId
,
productId
));
if
(
CollectionUtils
.
isEmpty
(
data
))
{
return
;
}
for
(
CustomProductFactoryPriceIntervalRelEntity
item
:
data
)
{
item
.
setProductId
(
productId
);
}
customProductFactoryPriceIntervalRelDomainService
.
saveBatch
(
data
);
}
}
custom-server-app/src/main/java/com/jomalls/custom/app/service/impl/CustomProductWarehouseRelServiceImpl.java
View file @
e1b52fab
package
com
.
jomalls
.
custom
.
app
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.jomalls.custom.app.exception.ServiceException
;
import
com.jomalls.custom.app.vo.CustomProductWarehouseRelPageVO
;
import
com.jomalls.custom.app.vo.CustomProductWarehouseRelVO
;
...
...
@@ -16,6 +18,7 @@ import org.springframework.dao.DuplicateKeyException;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -93,4 +96,74 @@ public class CustomProductWarehouseRelServiceImpl implements CustomProductWareho
customProductWarehouseRelDomainService
.
removeById
(
id
);
}
/**
* 根据仓库ID获取关联列表
*/
@Override
public
List
<
CustomProductWarehouseRelEntity
>
getListByWareHouseId
(
Long
warehouseId
)
{
return
customProductWarehouseRelDomainService
.
list
(
new
LambdaQueryWrapper
<
CustomProductWarehouseRelEntity
>()
.
eq
(
CustomProductWarehouseRelEntity:
:
getWarehouseId
,
warehouseId
));
}
/**
* 根据产品ID获取关联列表
*/
@Override
public
List
<
CustomProductWarehouseRelEntity
>
getListByProductId
(
Long
productId
)
{
return
customProductWarehouseRelDomainService
.
list
(
new
LambdaQueryWrapper
<
CustomProductWarehouseRelEntity
>()
.
eq
(
CustomProductWarehouseRelEntity:
:
getProductId
,
productId
));
}
/**
* 根据产品ID获取仓库ID列表
*/
@Override
public
List
<
Long
>
getWarehouseIdsByProductId
(
Long
productId
)
{
List
<
CustomProductWarehouseRelEntity
>
rels
=
customProductWarehouseRelDomainService
.
list
(
new
LambdaQueryWrapper
<
CustomProductWarehouseRelEntity
>()
.
eq
(
CustomProductWarehouseRelEntity:
:
getProductId
,
productId
)
.
select
(
CustomProductWarehouseRelEntity:
:
getWarehouseId
));
// 只查询需要的字段以提高性能
if
(
CollectionUtils
.
isEmpty
(
rels
))
{
return
null
;
}
return
rels
.
stream
()
.
map
(
CustomProductWarehouseRelEntity:
:
getWarehouseId
)
.
collect
(
Collectors
.
toList
());
}
/**
* 根据产品ID删除关联
* 注意:原 TS 代码支持手动传入 transaction,Java 中通常使用 @Transactional 注解管理事务
*/
@Override
public
void
deleteByProductId
(
Integer
productId
)
{
customProductWarehouseRelDomainService
.
remove
(
new
LambdaQueryWrapper
<
CustomProductWarehouseRelEntity
>()
.
eq
(
CustomProductWarehouseRelEntity:
:
getProductId
,
productId
));
}
/**
* 批量保存产品与仓库的关联
* 逻辑:先删除该产品现有的所有关联,再批量插入新的
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveBatch
(
Integer
productId
,
List
<
Long
>
warehouseIds
)
{
this
.
deleteByProductId
(
productId
);
if
(
CollectionUtils
.
isEmpty
(
warehouseIds
))
{
return
;
}
List
<
CustomProductWarehouseRelEntity
>
relList
=
new
ArrayList
<>();
for
(
Long
warehouseId
:
warehouseIds
)
{
CustomProductWarehouseRelEntity
rel
=
new
CustomProductWarehouseRelEntity
();
rel
.
setProductId
(
productId
);
rel
.
setWarehouseId
(
warehouseId
);
relList
.
add
(
rel
);
}
customProductWarehouseRelDomainService
.
saveBatch
(
relList
);
}
}
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