Commit 36b44b1c authored by renjie's avatar renjie

Ip接口

parent 1c989b65
...@@ -20,7 +20,7 @@ public class AdminController { ...@@ -20,7 +20,7 @@ public class AdminController {
@Autowired @Autowired
AccountService accountService; AccountService accountService;
@RequestMapping(path = "/subuser/add", method = RequestMethod.POST) @RequestMapping(path = "/subuser/addone", method = RequestMethod.POST)
public ResultDto createSubAccount(Principal principal, @Valid @RequestBody AccountDto user) { public ResultDto createSubAccount(Principal principal, @Valid @RequestBody AccountDto user) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
...@@ -38,7 +38,7 @@ public class AdminController { ...@@ -38,7 +38,7 @@ public class AdminController {
return resultDto; return resultDto;
} }
@RequestMapping(path = "/subuser/update", method = RequestMethod.PUT) @RequestMapping(path = "/subuser/updateone", method = RequestMethod.PUT)
public ResultDto saveSubAccount(Principal principal, @PathVariable String child, @Valid @RequestBody AccountDto user) { public ResultDto saveSubAccount(Principal principal, @PathVariable String child, @Valid @RequestBody AccountDto user) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
......
...@@ -26,7 +26,7 @@ public class AccountDto { ...@@ -26,7 +26,7 @@ public class AccountDto {
private boolean allowedToCreateSubUser; private boolean allowedToCreateSubUser;
private int permission; private int permission = 0;
private int balance; private int balance;
......
...@@ -13,6 +13,7 @@ import com.edgec.browserbackend.account.service.EmailService; ...@@ -13,6 +13,7 @@ import com.edgec.browserbackend.account.service.EmailService;
import com.edgec.browserbackend.account.utils.AccountServicePool; import com.edgec.browserbackend.account.utils.AccountServicePool;
import com.edgec.browserbackend.auth.exception.AuthErrorCode; import com.edgec.browserbackend.auth.exception.AuthErrorCode;
import com.edgec.browserbackend.auth.service.UserAuthService; import com.edgec.browserbackend.auth.service.UserAuthService;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.common.charge.ChargeType; import com.edgec.browserbackend.common.charge.ChargeType;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.edgec.browserbackend.common.commons.utils.CommonStringUtils; import com.edgec.browserbackend.common.commons.utils.CommonStringUtils;
...@@ -558,6 +559,9 @@ public class AccountServiceImpl implements AccountService { ...@@ -558,6 +559,9 @@ public class AccountServiceImpl implements AccountService {
userAuthService.deleteUser(child); userAuthService.deleteUser(child);
repository.delete(childAccount); repository.delete(childAccount);
Account parentAccount = repository.findByName(parent);
parentAccount.setChildCount(parentAccount.getChildCount() - 1);
repository.save(parentAccount);
} }
@Override @Override
...@@ -712,6 +716,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -712,6 +716,10 @@ public class AccountServiceImpl implements AccountService {
if (!existing.isAllowedToCreateSubUser() && !StringUtils.isEmpty(existing.getParent())) if (!existing.isAllowedToCreateSubUser() && !StringUtils.isEmpty(existing.getParent()))
throw new ClientRequestException(AccountErrorCode.NOTALLOWEDTOCREATESUBUSER, "Not allowed to create sub user"); throw new ClientRequestException(AccountErrorCode.NOTALLOWEDTOCREATESUBUSER, "Not allowed to create sub user");
if (existing.getChildCount() >= 1000) {
throw new ClientRequestException(AccountErrorCode.CHILDMAX, "account cannot have more children");
}
existing = repository.findByName(user.getName()); existing = repository.findByName(user.getName());
if (existing != null) if (existing != null)
throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getName()); throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getName());
......
...@@ -3,7 +3,6 @@ package com.edgec.browserbackend.browser.controller; ...@@ -3,7 +3,6 @@ package com.edgec.browserbackend.browser.controller;
import com.edgec.browserbackend.account.dto.ResultDto; import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.browser.dto.*; import com.edgec.browserbackend.browser.dto.*;
import com.edgec.browserbackend.browser.service.IpResourceService; import com.edgec.browserbackend.browser.service.IpResourceService;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -39,15 +38,53 @@ public class IpControlloer { ...@@ -39,15 +38,53 @@ public class IpControlloer {
return resultDto; return resultDto;
} }
void renewIp(String username, IpResourceRequestDto ipResourceRequestDto) { @RequestMapping(value = "/renew", method = RequestMethod.POST)
public ResultDto renewIp(Principal principal, @RequestBody IpResourceRequestDto ipResourceRequestDto) {
ResultDto resultDto = new ResultDto();
try {
resultDto.setData(ipResourceService.renewIp(principal.getName(), ipResourceRequestDto));
resultDto.setStatus(0);
}catch (Exception e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", 80001);
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
} }
void deleteIp(String username, String ipAddr) { @RequestMapping(value = "/del", method = RequestMethod.POST)
public ResultDto deleteIp(Principal principal, @RequestBody IpResourceRequestDto ipResourceRequestDto) {
ResultDto resultDto = new ResultDto();
try {
ipResourceService.deleteIp(principal.getName(), ipResourceRequestDto.getAddr().get(0));
resultDto.setStatus(0);
}catch (Exception e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", 80001);
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
} }
List<IpResourceDto> getIpList(String username, int type, int page, int amount, FilterDto filterDto) { @RequestMapping(value = "/list", method = RequestMethod.POST)
return null; public ResultDto getIpList(Principal principal, IpListRequestDto ipListRequestDto) {
ResultDto resultDto = new ResultDto();
try {
List<IpResourceDto> ipResourceDto = ipResourceService.getIpList(principal.getName(), ipListRequestDto.getType(), ipListRequestDto.getPage(),
ipListRequestDto.getAmount(), ipListRequestDto.getIpFilterDto());
resultDto.setData(ipResourceDto);
resultDto.setStatus(0);
}catch (Exception e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", 80001);
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
} }
} }
...@@ -24,6 +24,7 @@ public class IpResource { ...@@ -24,6 +24,7 @@ public class IpResource {
List<String> bindHistory; List<String> bindHistory;
private boolean isDeleted; private boolean isDeleted;
private String username; private String username;
private String owner;
private String userParent; private String userParent;
private String shopId; private String shopId;
private String shopName; private String shopName;
...@@ -181,4 +182,12 @@ public class IpResource { ...@@ -181,4 +182,12 @@ public class IpResource {
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
} }
...@@ -17,6 +17,8 @@ public class UserShop { ...@@ -17,6 +17,8 @@ public class UserShop {
private String groupId; private String groupId;
private String ipId;
public UserShop(){ public UserShop(){
} }
...@@ -31,6 +33,13 @@ public class UserShop { ...@@ -31,6 +33,13 @@ public class UserShop {
this.groupId = groupId; this.groupId = groupId;
} }
public UserShop(String username, String shopId, String groupId, String ipId) {
this.username = username;
this.shopId = shopId;
this.groupId = groupId;
this.ipId = ipId;
}
public String getId() { public String getId() {
return id; return id;
} }
...@@ -62,4 +71,12 @@ public class UserShop { ...@@ -62,4 +71,12 @@ public class UserShop {
public void setGroupId(String groupId) { public void setGroupId(String groupId) {
this.groupId = groupId; this.groupId = groupId;
} }
public String getIpId() {
return ipId;
}
public void setIpId(String ipId) {
this.ipId = ipId;
}
} }
package com.edgec.browserbackend.browser.dto;
public class IpFilterDto {
String region;
String addr;
String vendor;
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
}
package com.edgec.browserbackend.browser.dto;
import java.util.ArrayList;
import java.util.List;
public class IpListRequestDto {
private int type;
private int page;
private int amount;
private IpFilterDto ipFilterDto;
private List<String> addr = new ArrayList<>();
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public IpFilterDto getIpFilterDto() {
return ipFilterDto;
}
public void setIpFilterDto(IpFilterDto ipFilterDto) {
this.ipFilterDto = ipFilterDto;
}
public List<String> getAddr() {
return addr;
}
public void setAddr(List<String> addr) {
this.addr = addr;
}
}
...@@ -21,6 +21,7 @@ public class IpResourceDto { ...@@ -21,6 +21,7 @@ public class IpResourceDto {
private String username; private String username;
private String details; private String details;
private String password; private String password;
private List<String> protocol;
ShopDto shopDto; ShopDto shopDto;
public IpResourceDto(){ public IpResourceDto(){
...@@ -38,6 +39,7 @@ public class IpResourceDto { ...@@ -38,6 +39,7 @@ public class IpResourceDto {
this.username = ipResource.getUsername(); this.username = ipResource.getUsername();
this.details = ipResource.getDetails(); this.details = ipResource.getDetails();
this.password = ipResource.getPassword(); this.password = ipResource.getPassword();
this.protocol = ipResource.getProtocol();
this.shopDto = shopDto; this.shopDto = shopDto;
} }
...@@ -136,4 +138,12 @@ public class IpResourceDto { ...@@ -136,4 +138,12 @@ public class IpResourceDto {
public void setShopDto(ShopDto shopDto) { public void setShopDto(ShopDto shopDto) {
this.shopDto = shopDto; this.shopDto = shopDto;
} }
public List<String> getProtocol() {
return protocol;
}
public void setProtocol(List<String> protocol) {
this.protocol = protocol;
}
} }
...@@ -16,6 +16,7 @@ public class IpResourceRequestDto { ...@@ -16,6 +16,7 @@ public class IpResourceRequestDto {
private int amount = 1; private int amount = 1;
private boolean autorenew = false; private boolean autorenew = false;
private int ipkeptperiod = 0; private int ipkeptperiod = 0;
private String startscript = "";
private String instanceSpecKey; private String instanceSpecKey;
private String imageKey; private String imageKey;
...@@ -24,7 +25,7 @@ public class IpResourceRequestDto { ...@@ -24,7 +25,7 @@ public class IpResourceRequestDto {
private String system = "linux"; private String system = "linux";
private List<String> iplist = new ArrayList<>(); private List<String> addr = new ArrayList<>();
public String getName() { public String getName() {
return name; return name;
...@@ -86,12 +87,12 @@ public class IpResourceRequestDto { ...@@ -86,12 +87,12 @@ public class IpResourceRequestDto {
return ipkeptperiod; return ipkeptperiod;
} }
public List<String> getIplist() { public List<String> getAddr() {
return iplist; return addr;
} }
public void setIplist(List<String> iplist) { public void setAddr(List<String> addr) {
this.iplist = iplist; this.addr = addr;
} }
public String getInstanceSpecKey() { public String getInstanceSpecKey() {
...@@ -117,4 +118,20 @@ public class IpResourceRequestDto { ...@@ -117,4 +118,20 @@ public class IpResourceRequestDto {
public void setSystem(String system) { public void setSystem(String system) {
this.system = system; this.system = system;
} }
public String getLogintype() {
return logintype;
}
public void setLogintype(String logintype) {
this.logintype = logintype;
}
public String getStartscript() {
return startscript;
}
public void setStartscript(String startscript) {
this.startscript = startscript;
}
} }
package com.edgec.browserbackend.browser.dto;
import java.util.ArrayList;
import java.util.List;
public class RenewIpReturnDto {
List<String> successList = new ArrayList<>();
public List<String> getSuccessList() {
return successList;
}
public void setSuccessList(List<String> successList) {
this.successList = successList;
}
}
package com.edgec.browserbackend.browser.dto; package com.edgec.browserbackend.browser.dto;
import com.edgec.browserbackend.browser.domain.Shop;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
...@@ -11,6 +12,18 @@ public class ShopDto { ...@@ -11,6 +12,18 @@ public class ShopDto {
private String shopPassword; private String shopPassword;
private String shopPlatform; private String shopPlatform;
public ShopDto(){
}
public ShopDto(Shop shop) {
this.shopId = shop.getShopId();
this.shopName = shop.getShopName();
this.shopAccount = shop.getShopAccount();
this.shopPassword = shop.getShopPassword();
this.shopPlatform = shop.getShopPlatform();
}
public String getShopId() { public String getShopId() {
return shopId; return shopId;
} }
......
...@@ -3,7 +3,7 @@ package com.edgec.browserbackend.browser.dto; ...@@ -3,7 +3,7 @@ package com.edgec.browserbackend.browser.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class FilterDto { public class ShopFilterDto {
private String shopName; private String shopName;
private String IpRegion; private String IpRegion;
private String shopAccount; private String shopAccount;
......
...@@ -23,13 +23,11 @@ public class ShopRequestDto { ...@@ -23,13 +23,11 @@ public class ShopRequestDto {
private List<String> toUsers; private List<String> toUsers;
private int type;
private int page = 0; private int page = 0;
private int amount = 50; private int amount = 50;
private FilterDto filter; private ShopFilterDto filter;
public String getIpAddr() { public String getIpAddr() {
return ipAddr; return ipAddr;
...@@ -63,11 +61,11 @@ public class ShopRequestDto { ...@@ -63,11 +61,11 @@ public class ShopRequestDto {
this.group = group; this.group = group;
} }
public FilterDto getFilter() { public ShopFilterDto getFilter() {
return filter; return filter;
} }
public void setFilter(FilterDto filter) { public void setFilter(ShopFilterDto filter) {
this.filter = filter; this.filter = filter;
} }
...@@ -87,14 +85,6 @@ public class ShopRequestDto { ...@@ -87,14 +85,6 @@ public class ShopRequestDto {
this.page = page; this.page = page;
} }
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public List<String> getShopIds() { public List<String> getShopIds() {
return shopIds; return shopIds;
} }
......
package com.edgec.browserbackend.browser.repository; package com.edgec.browserbackend.browser.repository;
import com.edgec.browserbackend.browser.domain.IpResource; import com.edgec.browserbackend.browser.domain.IpResource;
import org.springframework.data.domain.Page;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
public interface IpResourceRepository extends MongoRepository<IpResource, String> { public interface IpResourceRepository extends MongoRepository<IpResource, String> {
IpResource findByAddrAndIsDeleted(String addr, boolean isDeleted); IpResource findByAddrAndIsDeleted(String addr, boolean isDeleted);
List<IpResource> findByOwnerAndShopIdIsNull(String owner);
List<IpResource> findByIdIn(List<String> ipIds);
List<IpResource> findByAddrLikeAndIdIn(String addr, List<String> ipIds);
List<IpResource> findByVendorLikeAndIdIn(String vendor, List<String> ipIds);
List<IpResource> findByRegionLikeAndIdIn(String region, List<String> ipIds);
} }
...@@ -48,6 +48,9 @@ public class GroupServiceImpl implements GroupService { ...@@ -48,6 +48,9 @@ public class GroupServiceImpl implements GroupService {
String id; String id;
try { try {
Group group1 = groupRepository.save(group); Group group1 = groupRepository.save(group);
//可以优化
account.setGroupCount(account.getGroupCount() + 1);
accountRepository.save(account);
id = group1.getId(); id = group1.getId();
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to add group", e.getMessage()); logger.error("fail to add group", e.getMessage());
...@@ -76,9 +79,15 @@ public class GroupServiceImpl implements GroupService { ...@@ -76,9 +79,15 @@ public class GroupServiceImpl implements GroupService {
public void deleteGroup(String username, String groupId) { public void deleteGroup(String username, String groupId) {
if (StringUtils.isBlank(username) || StringUtils.isBlank(groupId)) if (StringUtils.isBlank(username) || StringUtils.isBlank(groupId))
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
Account account = accountRepository.findByName(username);
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
try { try {
userShopRepository.updateGroupId(groupId, null); userShopRepository.updateGroupId(groupId, null);
groupRepository.deleteById(groupId); groupRepository.deleteById(groupId);
//可以优化
account.setGroupCount(account.getGroupCount()-1);
accountRepository.save(account);
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to delete group", e.getMessage()); logger.error("fail to delete group", e.getMessage());
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
......
package com.edgec.browserbackend.browser.service.Impl; 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.domain.User;
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.account.repository.AccountRepository;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode; import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
...@@ -8,7 +9,7 @@ import com.edgec.browserbackend.browser.domain.Group; ...@@ -8,7 +9,7 @@ import com.edgec.browserbackend.browser.domain.Group;
import com.edgec.browserbackend.browser.domain.IpResource; import com.edgec.browserbackend.browser.domain.IpResource;
import com.edgec.browserbackend.browser.domain.Shop; import com.edgec.browserbackend.browser.domain.Shop;
import com.edgec.browserbackend.browser.domain.UserShop; import com.edgec.browserbackend.browser.domain.UserShop;
import com.edgec.browserbackend.browser.dto.FilterDto; import com.edgec.browserbackend.browser.dto.ShopFilterDto;
import com.edgec.browserbackend.browser.dto.ShopResultDto; import com.edgec.browserbackend.browser.dto.ShopResultDto;
import com.edgec.browserbackend.browser.dto.ShopPageInfo; import com.edgec.browserbackend.browser.dto.ShopPageInfo;
import com.edgec.browserbackend.browser.dto.ShopPageResultDto; import com.edgec.browserbackend.browser.dto.ShopPageResultDto;
...@@ -84,6 +85,9 @@ public class ShopServiceImpl implements ShopService { ...@@ -84,6 +85,9 @@ public class ShopServiceImpl implements ShopService {
userShop.setGroupId(shopResultDto.getGroup()); userShop.setGroupId(shopResultDto.getGroup());
} }
userShopRepository.save(userShop); userShopRepository.save(userShop);
//可以优化
account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account);
}catch (Exception e) { }catch (Exception e) {
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
...@@ -144,6 +148,8 @@ public class ShopServiceImpl implements ShopService { ...@@ -144,6 +148,8 @@ public class ShopServiceImpl implements ShopService {
boolean result = userShopRepository.deleteByUsernameAndShopId(username, shopId); boolean result = userShopRepository.deleteByUsernameAndShopId(username, shopId);
if (result) { if (result) {
shopRepository.deleteById(shopId); shopRepository.deleteById(shopId);
account.setShopCount(account.getShopCount() - 1);
accountRepository.save(account);
} else throw new ClientRequestException(AccountErrorCode.NOPERMISSION); } else throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
} }
...@@ -177,6 +183,8 @@ public class ShopServiceImpl implements ShopService { ...@@ -177,6 +183,8 @@ public class ShopServiceImpl implements ShopService {
if (shop.getShopName()!=null) if (shop.getShopName()!=null)
ipResource.setShopName(shop.getShopName()); ipResource.setShopName(shop.getShopName());
ipResourceRepository.save(ipResource); ipResourceRepository.save(ipResource);
userShop.setIpId(ipResource.getId());
userShopRepository.save(userShop);
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to bind shop and ip", e.getMessage()); logger.error("fail to bind shop and ip", e.getMessage());
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
...@@ -207,7 +215,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -207,7 +215,10 @@ public class ShopServiceImpl implements ShopService {
shop.setIpRegion(null); shop.setIpRegion(null);
ipResource.setShopId(null); ipResource.setShopId(null);
ipResource.setShopName(null); ipResource.setShopName(null);
ipResourceRepository.save(ipResource);
shopRepository.save(shop); shopRepository.save(shop);
userShop.setIpId(ipResource.getId());
userShopRepository.save(userShop);
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to unbind", e.getMessage()); logger.error("fail to unbind", e.getMessage());
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
...@@ -261,7 +272,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -261,7 +272,10 @@ public class ShopServiceImpl implements ShopService {
UserShop userShop1 = userShopRepository.findByUsernameAndShopId(x.getName(), shop.getShopId()); UserShop userShop1 = userShopRepository.findByUsernameAndShopId(x.getName(), shop.getShopId());
if (userShop1 != null) if (userShop1 != null)
return; return;
userShopRepository.save(new UserShop(x.getName(), shop.getShopId())); userShop1 = new UserShop(x.getName(), shop.getShopId(), "-1");
if (shop.getIpId() != null)
userShop1.setIpId(shop.getIpId());
userShopRepository.save(userShop1);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to assign", e.getMessage()); logger.error("fail to assign", e.getMessage());
...@@ -271,7 +285,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -271,7 +285,7 @@ public class ShopServiceImpl implements ShopService {
} }
@Override @Override
public ShopPageResultDto getShopList(String username, String groupId, int page, int amout, FilterDto filterDto) { public ShopPageResultDto getShopList(String username, String groupId, int page, int amout, ShopFilterDto shopFilterDto) {
if (amout > 100) if (amout > 100)
amout = 100; amout = 100;
Pageable pageable = PageRequest.of(page, amout); Pageable pageable = PageRequest.of(page, amout);
...@@ -297,12 +311,12 @@ public class ShopServiceImpl implements ShopService { ...@@ -297,12 +311,12 @@ public class ShopServiceImpl implements ShopService {
} }
logger.error("shopIds.size " + shopIds.size()); logger.error("shopIds.size " + shopIds.size());
Page<Shop> shops; Page<Shop> shops;
if (filterDto != null && StringUtils.isNotBlank(filterDto.getIpRegion())) if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getIpRegion()))
shops = shopRepository.findByShopIdInAndIpRegionLike(shopIds, filterDto.getIpRegion(), pageable); shops = shopRepository.findByShopIdInAndIpRegionLike(shopIds, shopFilterDto.getIpRegion(), pageable);
else if (filterDto != null && StringUtils.isNotBlank(filterDto.getShopAccount())) else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopAccount()))
shops = shopRepository.findByShopIdInAndShopAccountLike(shopIds, filterDto.getShopAccount(), pageable); shops = shopRepository.findByShopIdInAndShopAccountLike(shopIds, shopFilterDto.getShopAccount(), pageable);
else if (filterDto != null && StringUtils.isNotBlank(filterDto.getShopName())) else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopName()))
shops = shopRepository.findByShopIdInAndShopNameLike(shopIds, filterDto.getShopName(), pageable); shops = shopRepository.findByShopIdInAndShopNameLike(shopIds, shopFilterDto.getShopName(), pageable);
else else
shops = shopRepository.findByShopIdIn(shopIds, pageable); shops = shopRepository.findByShopIdIn(shopIds, pageable);
if (shops == null || shops.getNumberOfElements() < 1) if (shops == null || shops.getNumberOfElements() < 1)
......
package com.edgec.browserbackend.browser.service; package com.edgec.browserbackend.browser.service;
import com.edgec.browserbackend.browser.dto.FilterDto; import com.edgec.browserbackend.browser.dto.*;
import com.edgec.browserbackend.browser.dto.IpResourceDto;
import com.edgec.browserbackend.browser.dto.IpResourceRequestDto;
import java.util.List; import java.util.List;
public interface IpResourceService { public interface IpResourceService {
List<IpResourceDto> buyIp(String username, IpResourceRequestDto ipResourceRequestDto); List<IpResourceDto> buyIp(String username, IpResourceRequestDto ipResourceRequestDto) throws Exception;
void renewIp(String username, IpResourceRequestDto ipResourceRequestDto) throws Exception; RenewIpReturnDto renewIp(String username, IpResourceRequestDto ipResourceRequestDto) throws Exception;
void deleteIp(String username, String ipAddr) throws Exception; void deleteIp(String username, String ipAddr) throws Exception;
List<IpResourceDto> getIpList(String username, int type, int page, int amount, FilterDto filterDto); List<IpResourceDto> getIpList(String username, int type, int page, int amount, IpFilterDto ipFilterDto);
} }
package com.edgec.browserbackend.browser.service; package com.edgec.browserbackend.browser.service;
import com.edgec.browserbackend.browser.domain.Shop; import com.edgec.browserbackend.browser.domain.Shop;
import com.edgec.browserbackend.browser.dto.FilterDto; import com.edgec.browserbackend.browser.dto.ShopFilterDto;
import com.edgec.browserbackend.browser.dto.ShopPageResultDto; import com.edgec.browserbackend.browser.dto.ShopPageResultDto;
import com.edgec.browserbackend.browser.dto.ShopResultDto; import com.edgec.browserbackend.browser.dto.ShopResultDto;
...@@ -25,5 +25,5 @@ public interface ShopService { ...@@ -25,5 +25,5 @@ public interface ShopService {
void assignShops(String username, List<String> shopIds, List<String> users); void assignShops(String username, List<String> shopIds, List<String> users);
ShopPageResultDto getShopList(String username, String groupId, int page, int amount, FilterDto filterDto); ShopPageResultDto getShopList(String username, String groupId, int page, int amount, ShopFilterDto shopFilterDto);
} }
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