Commit 45d74932 authored by renjie's avatar renjie

shop接口修改

parent 12d5e24f
...@@ -42,6 +42,12 @@ public class Account { ...@@ -42,6 +42,12 @@ public class Account {
private List<String> whiteList = new ArrayList<>(); private List<String> whiteList = new ArrayList<>();
private int childCount = 0;
private int groupCount = 0;
private int shopCount = 0;
public Date getSignupDate() { public Date getSignupDate() {
return signupDate; return signupDate;
} }
...@@ -178,4 +184,28 @@ public class Account { ...@@ -178,4 +184,28 @@ public class Account {
public void setWhiteList(List<String> whiteList) { public void setWhiteList(List<String> whiteList) {
this.whiteList = whiteList; this.whiteList = whiteList;
} }
public int getChildCount() {
return childCount;
}
public void setChildCount(int childCount) {
this.childCount = childCount;
}
public int getGroupCount() {
return groupCount;
}
public void setGroupCount(int groupCount) {
this.groupCount = groupCount;
}
public int getShopCount() {
return shopCount;
}
public void setShopCount(int shopCount) {
this.shopCount = shopCount;
}
} }
...@@ -51,7 +51,10 @@ public enum AccountErrorCode implements ErrorCode { ...@@ -51,7 +51,10 @@ public enum AccountErrorCode implements ErrorCode {
/** alipay errors */ /** alipay errors */
ALIPAYERROR(ACCOUNT_BASE+130, "Alipay order generation error"), ALIPAYERROR(ACCOUNT_BASE+130, "Alipay order generation error"),
NOPERMISSION(ACCOUNT_BASE+140, "You have no right to do this operarion"); NOPERMISSION(ACCOUNT_BASE+140, "You have no right to do this operarion"),
GROUPMAX(ACCOUNT_BASE+141, "You can not have more groups"),
SHOPMAX(ACCOUNT_BASE+141, "You can not have more shops"),
CHILDMAX(ACCOUNT_BASE+141, "You can not have more subUsers");
......
...@@ -2,7 +2,7 @@ package com.edgec.browserbackend.browser.dto; ...@@ -2,7 +2,7 @@ package com.edgec.browserbackend.browser.dto;
public class ShopPageInfo { public class ShopPageInfo {
int currentPage; int currentPage;
int totalPage; int totalPages;
int totalShops; int totalShops;
public int getCurrentPage() { public int getCurrentPage() {
...@@ -13,12 +13,12 @@ public class ShopPageInfo { ...@@ -13,12 +13,12 @@ public class ShopPageInfo {
this.currentPage = currentPage; this.currentPage = currentPage;
} }
public int getTotalPage() { public int getTotalPages() {
return totalPage; return totalPages;
} }
public void setTotalPage(int totalPage) { public void setTotalPages(int totalPage) {
this.totalPage = totalPage; this.totalPages = totalPage;
} }
public int getTotalShops() { public int getTotalShops() {
......
...@@ -2,6 +2,7 @@ package com.edgec.browserbackend.browser.service.Impl; ...@@ -2,6 +2,7 @@ package com.edgec.browserbackend.browser.service.Impl;
import com.edgec.browserbackend.account.domain.Account; import com.edgec.browserbackend.account.domain.Account;
import com.edgec.browserbackend.account.exception.AccountErrorCode; import com.edgec.browserbackend.account.exception.AccountErrorCode;
import com.edgec.browserbackend.account.repository.AccountRepository;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode; import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.browser.domain.Group; import com.edgec.browserbackend.browser.domain.Group;
import com.edgec.browserbackend.browser.dto.GroupDto; import com.edgec.browserbackend.browser.dto.GroupDto;
...@@ -23,6 +24,9 @@ public class GroupServiceImpl implements GroupService { ...@@ -23,6 +24,9 @@ public class GroupServiceImpl implements GroupService {
private final Logger logger = LoggerFactory.getLogger(GroupServiceImpl.class); private final Logger logger = LoggerFactory.getLogger(GroupServiceImpl.class);
@Autowired
private AccountRepository accountRepository;
@Autowired @Autowired
private GroupRepository groupRepository; private GroupRepository groupRepository;
...@@ -33,6 +37,11 @@ public class GroupServiceImpl implements GroupService { ...@@ -33,6 +37,11 @@ public class GroupServiceImpl implements GroupService {
public String addGroup(String username, String groupName) { public String addGroup(String username, String groupName) {
if (StringUtils.isBlank(username) || StringUtils.isBlank(groupName)) if (StringUtils.isBlank(username) || StringUtils.isBlank(groupName))
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
Account account = accountRepository.findByName(username);
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
if (account.getGroupCount() >= 100)
throw new ClientRequestException(AccountErrorCode.GROUPMAX);
Group group = new Group(); Group group = new Group();
group.setOwner(username); group.setOwner(username);
group.setName(groupName); group.setName(groupName);
......
...@@ -65,6 +65,9 @@ public class ShopServiceImpl implements ShopService { ...@@ -65,6 +65,9 @@ public class ShopServiceImpl implements ShopService {
if (account.getPermission() < 4) { if (account.getPermission() < 4) {
throw new ClientRequestException(AccountErrorCode.NOPERMISSION); throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
} }
if (account.getShopCount() >= 10000) {
throw new ClientRequestException(AccountErrorCode.SHOPMAX);
}
UserShop us = userShopRepository.findByUsernameAndShopId(username, shopDto.getShopId()); UserShop us = userShopRepository.findByUsernameAndShopId(username, shopDto.getShopId());
Group group = groupRepository.findById(shopDto.getGroup()).orElse(null); Group group = groupRepository.findById(shopDto.getGroup()).orElse(null);
if (group == null) { if (group == null) {
...@@ -317,7 +320,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -317,7 +320,7 @@ public class ShopServiceImpl implements ShopService {
shopPageResultDto.setShopList(shopDtoPage.getContent()); shopPageResultDto.setShopList(shopDtoPage.getContent());
ShopPageInfo shopPageInfo = new ShopPageInfo(); ShopPageInfo shopPageInfo = new ShopPageInfo();
shopPageInfo.setCurrentPage(shopDtoPage.getPageable().getPageNumber() + 1); shopPageInfo.setCurrentPage(shopDtoPage.getPageable().getPageNumber() + 1);
shopPageInfo.setTotalPage(shopDtoPage.getTotalPages()); shopPageInfo.setTotalPages(shopDtoPage.getTotalPages());
shopPageInfo.setTotalShops(shopDtos.size()); shopPageInfo.setTotalShops(shopDtos.size());
shopPageResultDto.setShopPage(shopPageInfo); shopPageResultDto.setShopPage(shopPageInfo);
return shopPageResultDto; return shopPageResultDto;
......
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