Commit adcd6742 authored by renjie's avatar renjie

推广码

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