Commit adcd6742 authored by renjie's avatar renjie

推广码

parent 5959bee7
......@@ -482,6 +482,7 @@ public class AccountController {
while((len = fis.read(bt)) != -1) {
os.write(bt,0,len);
}
}catch(Exception e) {
e.printStackTrace();
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
......
......@@ -49,6 +49,8 @@ public class AccountDto {
private Promotion promotion;
private int authorized;
public AccountDto(){
}
......@@ -67,6 +69,7 @@ public class AccountDto {
this.setQueryIpUrlList(account.getQueryIpUrlList());
if (account.getPromotion() != null)
this.setPromotion(account.getPromotion());
this.authorized = account.getAuthorized();
}
public boolean isPrePaid() {
......@@ -229,4 +232,12 @@ public class AccountDto {
public void setPromotion(Promotion promotion) {
this.promotion = promotion;
}
public int getAuthorized() {
return authorized;
}
public void setAuthorized(int authorized) {
this.authorized = authorized;
}
}
......@@ -22,7 +22,9 @@ import org.springframework.data.mongodb.gridfs.GridFsResource;
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRepositoryCustom {
......@@ -76,13 +78,29 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep
GridFSDownloadStream gridFSDownloadStream =
gridFSBucket.openDownloadStream(gridFSFile.getObjectId());
GridFsResource gridFsResource = new GridFsResource(gridFSFile,gridFSDownloadStream);
return gridFsResource.getFile();
InputStream inputStream = gridFsResource.getInputStream();
byte[] f = getBytes(inputStream);
File file = new File(gridFSFile.getFilename() + ".png");
FileOutputStream out = new FileOutputStream(file);
out.write(f);
return file;
} catch (Exception e) {
logger.error(e.getMessage());
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}
}
private byte[] getBytes(InputStream inputStream) throws Exception{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int i = 0;
while (-1!=(i=inputStream.read(b))){
bos.write(b,0,i);
}
return bos.toByteArray();
}
}
......@@ -1068,7 +1068,7 @@ public class AccountServiceImpl implements AccountService {
if (companyAuthorizeDto.getAgency_front() != null && companyAuthorizeDto.getAgency_back() != null) {
agencyFront = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getAgency_front(), "agency-front-" + username);
agencyBack = companyAuthorizeRepository.saveFile(companyAuthorizeDto.getAgency_back(), "agency-back-" + username);
} else
} else if (!(companyAuthorizeDto.getAgency_front() == null && companyAuthorizeDto.getAgency_back() == null))
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
CompanyAuthorize companyAuthorize = new CompanyAuthorize(companyAuthorizeDto);
companyAuthorize.setUsername(username);
......@@ -1091,6 +1091,7 @@ public class AccountServiceImpl implements AccountService {
companyAuthorizeRepository.deleteFile(coporationLicenseFront);
if (companyLicenseId != null)
companyAuthorizeRepository.deleteFile(companyLicenseId);
log.error(e.getMessage());
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}
......@@ -1128,6 +1129,9 @@ public class AccountServiceImpl implements AccountService {
if (agencyLicense_Back != null)
files.add(agencyLicense_Back);
tempFile = FileUtil.putBatchFilesInZip(files, tempFile);
companyLicense.delete();
coporationLicense_Front.delete();
coporationLicense_Back.delete();
return tempFile;
} catch (Exception e) {
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
......
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