Pārlūkot izejas kodu

企业logo64转码,详情跳企业或者顾问

limin 7 gadi atpakaļ
vecāks
revīzija
40e43a18ad

+ 40 - 0
src/main/java/com/goafanti/common/controller/BaseApiController.java

@@ -1,7 +1,10 @@
 package com.goafanti.common.controller;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -215,4 +218,41 @@ public class BaseApiController extends BaseController {
 	protected Result res() {
 		return new Result();
 	}
+	
+	
+	@SuppressWarnings("resource")
+	protected String handleBaseFiles(Result res, String path, boolean isPrivate, byte[] bs, String sign,
+			String uid,String fn) {
+		String fileName = FileUtils.mosaicFileName(fn, isPrivate, path, StringUtils.isBlank(uid) ? TokenManager.getUserId() : uid);
+		OutputStream fos = null;
+		if (bs != null && bs.length>0) {
+			try {
+				if (isPrivate) {
+					File filePath = new File(uploadPrivatePath);
+					if(!filePath.exists()){
+						filePath.mkdirs();
+					}
+					System.out.println("------------"+ uploadPrivatePath + fileName);
+					fos = new FileOutputStream(new File(uploadPrivatePath + fileName));
+				} else {
+					File filePath = new File(uploadPath);
+					if(!filePath.exists()){
+						filePath.mkdirs();
+					}
+					System.out.println("------------"+ uploadPath + fileName);
+					fos = new FileOutputStream(new File(uploadPath + fileName));
+				}
+				fos.write(bs);
+				LoggerUtils.debug(getClass(), fileName + " 文件上传成功");
+			} catch (IllegalStateException | IOException e) {
+				LoggerUtils.error(getClass(), "文件上传失败", e);
+				res.getError().add(buildError("", "文件上传失败!"));
+				return "";
+			}
+		} else {
+			res.getError().add(buildError("", "文件上传失败!"));
+			return "";
+		}
+		return fileName;
+	}
 }

+ 10 - 0
src/main/java/com/goafanti/common/utils/FileUtils.java

@@ -112,6 +112,16 @@ public class FileUtils {
 		}
 		return fileName;
 	}
+	public static String mosaicFileName( String fn, boolean isPrivate, String path, String uid) {
+
+		String fileName = "";
+		if (isPrivate) {
+			fileName = path + uid + "/" + fn;
+		} else {
+			fileName = path + uid + "/" + System.nanoTime() + fn ;
+		}
+		return fileName;
+	}
 
 	/**
 	 * 获取下载文件名称

+ 0 - 1
src/main/java/com/goafanti/user/bo/InputOrganizationIdentity.java

@@ -183,7 +183,6 @@ public class InputOrganizationIdentity {
 	@Size(min = 0, max = 127, message = "{" + ErrorConstants.EMAIL_SIZE_ERROR + "}")
 	private String email;
 	
-	@Size(min = 0, max = 127, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String companyLogoUrl;
 	
 	@Size(min = 0, max = 1, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")

+ 23 - 5
src/main/java/com/goafanti/user/controller/UserApiController.java

@@ -1,6 +1,7 @@
 package com.goafanti.user.controller;
 
 import java.math.BigDecimal;
+import java.util.Base64;
 import java.util.UUID;
 
 import javax.annotation.Resource;
@@ -14,7 +15,6 @@ import org.springframework.util.Assert;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.goafanti.business.service.JtBusinessService;
@@ -44,7 +44,6 @@ import com.goafanti.common.utils.TimeUtils;
 import com.goafanti.common.utils.VerifyCodeUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.easemob.EasemobUtils;
-import com.goafanti.order.enums.AuditState;
 import com.goafanti.user.bo.ExpertUserIdentity;
 import com.goafanti.user.bo.InputOrgPro;
 import com.goafanti.user.bo.InputOrganizationIdentity;
@@ -526,6 +525,7 @@ public class UserApiController extends BaseApiController {
 		}
 		
 		if (res.getError().isEmpty()) {
+			
 			OrganizationIdentity oi = new OrganizationIdentity();
 			User user = new User();
 			BeanUtils.copyProperties(organizationIdentity, oi);
@@ -552,7 +552,7 @@ public class UserApiController extends BaseApiController {
 			return res;
 		}
 		if(StringUtils.isBlank(organizationIdentity.getQq())) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "QQ"));
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "企业QQ"));
 			return res;
 		}
 		if(StringUtils.isBlank(organizationIdentity.getIdentifyName())) {
@@ -575,10 +575,14 @@ public class UserApiController extends BaseApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "荣誉资质"));			
 			return res;
 		}
-		if(null==organizationIdentity.getLicenceProvince()||null==organizationIdentity.getLicenceCity()) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "地区"));
+		if(StringUtils.isBlank(organizationIdentity.getEmail())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "企业邮箱"));			
 			return res;
 		}
+		/*if(null==organizationIdentity.getLicenceProvince()||null==organizationIdentity.getLicenceCity()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "地区"));
+			return res;
+		}*/
 		if(organizationIdentity.getAuthentication() == UserAuthentication.AUTHENTICATION.getCode()
 				&& organizationIdentity.getType() == UserType.PERSONAL.getCode()){
 			res.getError().add(buildError(null, "", "用户已经个人认证"));
@@ -956,6 +960,20 @@ public class UserApiController extends BaseApiController {
 		return res;
 	}
 	
+	@RequestMapping(value="/uploadPicture64")
+	public Result uploadPicture64(String picturebase, String filename,String sign){
+ 		Result res = new Result();
+ 		byte[] bs=Base64.getDecoder().decode(picturebase);
+		AttachmentType attachmentType = AttachmentType.getField(sign);
+        if (attachmentType == AttachmentType.USER_PICTURE) {
+        	filename = filename.substring(filename.indexOf("."));
+        	res.setData(handleBaseFiles(res, "/user/", false,bs, sign, TokenManager.getUserId(),filename));
+        } else {
+            res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
+        }
+		return res;
+	}
 	
 
+
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/patenteDetails.html


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/serviceDetails.html