Commit 6dbd46bb authored by renjie's avatar renjie

异步任务

parent 3b1002a9
package com.edgec.browserbackend.browser.ErrorCode;
import com.edgec.browserbackend.browser.domain.IpTransaction;
import com.edgec.browserbackend.common.commons.error.ErrorCode;
import com.fasterxml.jackson.annotation.JsonValue;
......@@ -14,7 +15,9 @@ public enum BrowserErrorCode implements ErrorCode {
IPNOTEXIST(BROWSER_BASE+201, "The ip do not exist"),
IPNOTBINDTOSHOP(BROWSER_BASE+202, "The ip do not bind this shop."),
GROUPNOTEXIST(BROWSER_BASE+301, "The group do not exist");
GROUPNOTEXIST(BROWSER_BASE+301, "The group do not exist"),
IPTRANSACTIONNOTEXIST(BROWSER_BASE+401, "The ipTransaction do not exist");
......
......@@ -26,7 +26,7 @@ public class IpControlloer {
public ResultDto buyIp(Principal principal, @RequestBody IpResourceRequestDto ipResourceRequestDto){
ResultDto resultDto = new ResultDto();
try {
List<IpResourceDto> ipResourceDto = ipResourceService.buyIp(principal.getName(), ipResourceRequestDto);
IpTransactionDto ipResourceDto = ipResourceService.buyIp(principal.getName(), ipResourceRequestDto);
resultDto.setData(ipResourceDto);
resultDto.setStatus(0);
} catch (ClientRequestException e) {
......@@ -100,4 +100,22 @@ public class IpControlloer {
}
return resultDto;
}
@RequestMapping(value = "/queryTransaction", method = RequestMethod.POST)
public ResultDto queryTransaction(Principal principal, @RequestBody IpTransactionDto ipTransactionDto) {
ResultDto resultDto = new ResultDto();
try {
IpTransactionDto ipTransactionDto1 = ipResourceService.queryTransaction(principal.getName(), ipTransactionDto.getTid());
resultDto.setData(ipTransactionDto1);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
}
}
......@@ -3,6 +3,8 @@ package com.edgec.browserbackend.browser.domain;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.List;
/**
* @Desc
* @Author jason
......@@ -13,17 +15,19 @@ public class IpTransaction {
@Id
private String tid;
private int username;
private String username;
private long createTime;
private int status;
public int getUsername() {
private List<String> ipIds;
public String getUsername() {
return username;
}
public void setUsername(int username) {
public void setUsername(String username) {
this.username = username;
}
......@@ -50,4 +54,12 @@ public class IpTransaction {
public void setTid(String tid) {
this.tid = tid;
}
public List<String> getIpIds() {
return ipIds;
}
public void setIpIds(List<String> ipIds) {
this.ipIds = ipIds;
}
}
package com.edgec.browserbackend.browser.dto;
import com.edgec.browserbackend.browser.domain.IpTransaction;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.ArrayList;
import java.util.List;
/**
* @Desc
* @Author jason
* @CreateTime 2020/3/18 9:57 上午
**/
@JsonIgnoreProperties(ignoreUnknown = true)
public class IpTransactionDto {
private String tid;
private int status;
private IpResourceDto ipResourceDto;
private List<IpResourceDto> ipResourceDtos;
public IpTransactionDto(){
}
public IpTransactionDto(IpTransaction ipTransaction) {
this.tid = ipTransaction.getTid();
this.status = ipTransaction.getStatus();
ipResourceDtos = new ArrayList<>();
}
public String getTid() {
return tid;
......@@ -26,11 +43,11 @@ public class IpTransactionDto {
this.status = status;
}
public IpResourceDto getIpResourceDto() {
return ipResourceDto;
public List<IpResourceDto> getIpResourceDtos() {
return ipResourceDtos;
}
public void setIpResourceDto(IpResourceDto ipResourceDto) {
this.ipResourceDto = ipResourceDto;
public void setIpResourceDtos(List<IpResourceDto> ipResourceDtos) {
this.ipResourceDtos = ipResourceDtos;
}
}
package com.edgec.browserbackend.browser.repository;
import com.edgec.browserbackend.browser.domain.IpTransaction;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
* @Desc
* @Author jason
* @CreateTime 2020/3/18 5:21 下午
**/
public interface IpTransactionRepository extends MongoRepository<IpTransaction, String> {
}
......@@ -7,7 +7,7 @@ import java.util.List;
public interface IpResourceService {
List<IpResourceDto> buyIp(String username, IpResourceRequestDto ipResourceRequestDto) throws Exception;
IpTransactionDto buyIp(String username, IpResourceRequestDto ipResourceRequestDto) throws Exception;
IpOperationResultDto renewIp(String username, IpResourceRequestDto ipResourceRequestDto) throws Exception;
......
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