Commit 3b295221 authored by renjie's avatar renjie

分配店铺修改

parent 6194bfef
...@@ -6,6 +6,6 @@ public interface UserShopRepositoryCustom { ...@@ -6,6 +6,6 @@ public interface UserShopRepositoryCustom {
void updateGroupId(String groupId_old, String groupId_new); void updateGroupId(String groupId_old, String groupId_new);
boolean deleteByShopIdExceptOwner(String shopId); boolean deleteByShopIdExceptOwner(String shopId, String owner);
} }
...@@ -42,10 +42,10 @@ public class UserShopRepositoryCustomImpl implements UserShopRepositoryCustom { ...@@ -42,10 +42,10 @@ public class UserShopRepositoryCustomImpl implements UserShopRepositoryCustom {
} }
@Override @Override
public boolean deleteByShopIdExceptOwner(String shopId) { public boolean deleteByShopIdExceptOwner(String shopId, String owner) {
Document doc = new Document(); Document doc = new Document();
BasicQuery basicQuery = new BasicQuery(doc); BasicQuery basicQuery = new BasicQuery(doc);
basicQuery.addCriteria(where("shopId").is(shopId)); basicQuery.addCriteria(where("shopId").is(shopId).and("username").ne(owner));
DeleteResult operation = mongoTemplate.remove(basicQuery, UserShop.class); DeleteResult operation = mongoTemplate.remove(basicQuery, UserShop.class);
if (operation.getDeletedCount() < 1) if (operation.getDeletedCount() < 1)
return false; return false;
......
...@@ -272,8 +272,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -272,8 +272,7 @@ public class ShopServiceImpl implements ShopService {
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
shops.stream().forEach(shop -> { shops.stream().forEach(shop -> {
try { try {
//todo 不删除owner userShopRepository.deleteByShopIdExceptOwner(shop.getShopId(), shop.getOwner());
userShopRepository.deleteByShopIdExceptOwner(shop.getShopId());
for (Account account1 : accounts) { for (Account account1 : accounts) {
UserShop userShop1 = userShopRepository.findByUsernameAndShopId(account1.getName(), shop.getShopId()); UserShop userShop1 = userShopRepository.findByUsernameAndShopId(account1.getName(), shop.getShopId());
if (userShop1 != null) if (userShop1 != null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment