Browse Source

Merge remote-tracking branch 'origin/master'

bao.zhang 9 years ago
parent
commit
adbeb412b6

+ 6 - 3
src/main/java/com/cloudcross/ssp/model/mapper/banner.sql.xml

@@ -22,6 +22,7 @@
 		b.agent_id as agentId,
 		b.agent_id as agentId,
 		b.advertiser_id as advertiserId,
 		b.advertiser_id as advertiserId,
 		b.agent_id as agentId,
 		b.agent_id as agentId,
+		b.operator_id as operatorId,
 		b.name as name,
 		b.name as name,
 		b.path as path,
 		b.path as path,
 		b.path_small as pathSmall,
 		b.path_small as pathSmall,
@@ -51,7 +52,8 @@
 <resultMap type="com.cloudcross.ssp.model.BannerTemplate" id="bannerTemplate">  
 <resultMap type="com.cloudcross.ssp.model.BannerTemplate" id="bannerTemplate">  
    <id property="id" column="bannerTemplateId"/>  
    <id property="id" column="bannerTemplateId"/>  
    <result property="advertiserId" column="advertiserId"/>
    <result property="advertiserId" column="advertiserId"/>
-   <result property="agentId" column="agentId"/>  
+   <result property="agentId" column="agentId"/>
+   <result property="operatorId" column="operatorId"/>  
    <result property="name" column="name"/>
    <result property="name" column="name"/>
     <result property="path" column="path"/> 
     <result property="path" column="path"/> 
     <result property="pathSmall" column="pathSmall"/>
     <result property="pathSmall" column="pathSmall"/>
@@ -286,7 +288,7 @@
 	
 	
 	<select id="findByParams1" parameterType="map" resultMap="Banner">  
 	<select id="findByParams1" parameterType="map" resultMap="Banner">  
 		select a.status as status1,a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
 		select a.status as status1,a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
-	a.click_address as clickAddress,a.impression_address as impressionAddress, a.checked as checked,a.updated as updated,b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.agent_id as agentId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id   
+	a.click_address as clickAddress,a.impression_address as impressionAddress, a.checked as checked,a.updated as updated,b.id as bannerTemplateId,b.agent_id as agentId,b.operator_id as operatorId,b.advertiser_id as advertiserId,b.agent_id as agentId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id   
 					<where>
 					<where>
 					 a.status != -1 and b.status != -1
 					 a.status != -1 and b.status != -1
 					<if test="orderMark == null">
 					<if test="orderMark == null">
@@ -320,7 +322,8 @@
 	
 	
 	<select id="findByParams2" parameterType="map" resultMap="Banner">  
 	<select id="findByParams2" parameterType="map" resultMap="Banner">  
 		select a.status as status1,a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
 		select a.status as status1,a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
-	a.click_address as clickAddress,a.impression_address as impressionAddress, a.checked as checked,a.updated as updated,b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.agent_id as agentId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id   
+	a.click_address as clickAddress,a.impression_address as impressionAddress, a.checked as checked,a.updated as updated,
+	b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.operator_id as operatorId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id   
 					<where>
 					<where>
 					 a.status != -1 and b.status != -1
 					 a.status != -1 and b.status != -1
 					<if test="orderMark == null">
 					<if test="orderMark == null">

+ 22 - 8
src/main/java/com/cloudcross/ssp/web/advertiser/main/ad/BannerTemplateController.java

@@ -220,6 +220,7 @@ public class BannerTemplateController extends SimpleController {
 
 
 	public @ResponseBody String upload(Model model,HttpServletResponse response,HttpServletRequest request,Long advertiserId) throws IOException{  
 	public @ResponseBody String upload(Model model,HttpServletResponse response,HttpServletRequest request,Long advertiserId) throws IOException{  
 		String uploadName;
 		String uploadName;
+		String resetName;
 		String fileType;
 		String fileType;
 		//文件路径
 		//文件路径
 		String path;
 		String path;
@@ -251,10 +252,11 @@ public class BannerTemplateController extends SimpleController {
 			if(file != null){ 
 			if(file != null){ 
 				//取得当前上传文件的文件名称(不加路径)  
 				//取得当前上传文件的文件名称(不加路径)  
 				uploadName = file.getOriginalFilename();  
 				uploadName = file.getOriginalFilename();  
-				
+				resetName = resetName(uploadName);
 				//获取文件类型
 				//获取文件类型
 				 fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 				 fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 				 
 				 
+				 
 				//判断文件类型
 				//判断文件类型
 				  if(!noStuffixSet.contains(fileType)){
 				  if(!noStuffixSet.contains(fileType)){
 						return "不支持此文件类型";
 						return "不支持此文件类型";
@@ -268,7 +270,8 @@ public class BannerTemplateController extends SimpleController {
 					
 					
 					
 					
 					//处理上传文件路径
 					//处理上传文件路径
-					path = getLocalFilePath(uploadName);
+					path = getLocalFilePath(resetName);
+					System.out.println(path);
 					System.out.println("qqqqqqq+==="+path);
 					System.out.println("qqqqqqq+==="+path);
 					
 					
 					File localFile = new File(path); 
 					File localFile = new File(path); 
@@ -295,13 +298,13 @@ public class BannerTemplateController extends SimpleController {
 				//取上传文件父级目录
 				//取上传文件父级目录
 				String absolutePath = localFile.getParentFile().getAbsolutePath();
 				String absolutePath = localFile.getParentFile().getAbsolutePath();
 				//生成缩略图路径名
 				//生成缩略图路径名
-				pathSmall = absolutePath.concat(File.separator).concat("small_").concat(uploadName);
+				pathSmall = absolutePath.concat(File.separator).concat("small_").concat(resetName);
 				//生成缩略图
 				//生成缩略图
 				compressPicture(localFile,pathSmall,150,60);
 				compressPicture(localFile,pathSmall,150,60);
 				//判断是否需要缩放
 				//判断是否需要缩放
 				if((width*_height)==(_width*height)){
 				if((width*_height)==(_width*height)){
 					//压缩文件上传路径
 					//压缩文件上传路径
-					 String compressPath =absolutePath.concat(File.separator).concat("compress_").concat(uploadName);
+					 String compressPath =absolutePath.concat(File.separator).concat("compress_").concat(resetName);
 					 //生成压缩图
 					 //生成压缩图
 					 compressPicture(localFile,compressPath, _width,_height);
 					 compressPicture(localFile,compressPath, _width,_height);
 					//设置文件上传路径
 					//设置文件上传路径
@@ -340,6 +343,7 @@ public class BannerTemplateController extends SimpleController {
 
 
 	public @ResponseBody String replace(Model model,HttpServletResponse response,HttpServletRequest request,Long bannerTemplateId) throws IOException{  
 	public @ResponseBody String replace(Model model,HttpServletResponse response,HttpServletRequest request,Long bannerTemplateId) throws IOException{  
 		String uploadName;
 		String uploadName;
+		String resetName;
 		String fileType;
 		String fileType;
 		//文件路径
 		//文件路径
 		String path;
 		String path;
@@ -366,6 +370,7 @@ public class BannerTemplateController extends SimpleController {
 			if(file != null){ 
 			if(file != null){ 
 				//取得当前上传文件的文件名称(不加路径)  
 				//取得当前上传文件的文件名称(不加路径)  
 				uploadName = file.getOriginalFilename();  
 				uploadName = file.getOriginalFilename();  
+				resetName = resetName(uploadName);
 				
 				
 				//获取文件类型
 				//获取文件类型
 				 fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 				 fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
@@ -379,7 +384,7 @@ public class BannerTemplateController extends SimpleController {
 				if(uploadName.trim() !=""){  
 				if(uploadName.trim() !=""){  
 					
 					
 					//处理上传文件路径
 					//处理上传文件路径
-					path = getLocalFilePath(uploadName);
+					path = getLocalFilePath(resetName);
 					
 					
 					File localFile = new File(path); 
 					File localFile = new File(path); 
 					//上传目录不存在,则新建目录
 					//上传目录不存在,则新建目录
@@ -397,13 +402,13 @@ public class BannerTemplateController extends SimpleController {
 					//取上传文件父级目录
 					//取上传文件父级目录
 					String absolutePath = localFile.getParentFile().getAbsolutePath();
 					String absolutePath = localFile.getParentFile().getAbsolutePath();
 					//生成缩略图路径名
 					//生成缩略图路径名
-					pathSmall = absolutePath.concat(File.separator).concat("small_").concat(uploadName);
+					pathSmall = absolutePath.concat(File.separator).concat("small_").concat(resetName);
 					//生成缩略图
 					//生成缩略图
 					compressPicture(localFile,pathSmall,150,60);
 					compressPicture(localFile,pathSmall,150,60);
 					
 					
 					if((width*_height)==(_width*height)){
 					if((width*_height)==(_width*height)){
 						//压缩文件上传路径
 						//压缩文件上传路径
-						 String compressPath =absolutePath.concat(File.separator).concat("compress_").concat(uploadName);
+						 String compressPath =absolutePath.concat(File.separator).concat("compress_").concat(resetName);
 						 //生成压缩图
 						 //生成压缩图
 						 compressPicture(localFile,compressPath, _width,_height);
 						 compressPicture(localFile,compressPath, _width,_height);
 						//设置文件上传路径
 						//设置文件上传路径
@@ -436,7 +441,16 @@ public class BannerTemplateController extends SimpleController {
 	}
 	}
 	
 	
 	
 	
-
+//处理图片名称
+	public String resetName(String uploadName){
+		String fileType =  fileType = uploadName.substring(uploadName.lastIndexOf("."));
+		uploadName = new StringBuilder()
+					.append(System.currentTimeMillis())
+					.append(fileType)
+					.toString();
+		return uploadName;
+	}
+	
 	
 	
 //处理上传文件的绝对路径
 //处理上传文件的绝对路径
 public String getLocalFilePath(String fileName){
 public String getLocalFilePath(String fileName){

+ 15 - 6
src/main/java/com/cloudcross/ssp/web/advertiser/main/ad/target/AdController.java

@@ -434,6 +434,7 @@ public class AdController extends SimpleController {
 	
 	
 	HttpSession session = request.getSession();	
 	HttpSession session = request.getSession();	
 	String uploadName = null;
 	String uploadName = null;
+	String resetName;
 	String path = null;
 	String path = null;
 	String pathSmall = null;
 	String pathSmall = null;
 	String fileType = null;
 	String fileType = null;
@@ -454,6 +455,7 @@ public class AdController extends SimpleController {
 				if(file != null){ 
 				if(file != null){ 
 					
 					
 					uploadName = file.getOriginalFilename();  
 					uploadName = file.getOriginalFilename();  
+					resetName = resetName(uploadName);
 					//取上传文件类型
 					//取上传文件类型
 					fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 					fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 					
 					
@@ -467,11 +469,9 @@ public class AdController extends SimpleController {
 					//判断文件名书否存在
 					//判断文件名书否存在
 					if(uploadName.trim() !=""){  
 					if(uploadName.trim() !=""){  
 	
 	
-						//添加上传文件标记
-						String fileName = file.getOriginalFilename();  
 						
 						
 						//获取上传路径
 						//获取上传路径
-						path = getLocalFilePath(fileName);
+						path = getLocalFilePath(resetName);
 						
 						
 				try{
 				try{
 						//新建上传路径下文件
 						//新建上传路径下文件
@@ -498,7 +498,7 @@ public class AdController extends SimpleController {
 			} 
 			} 
 		}
 		}
 
 
-		return path;
+		return path+"--"+uploadName;
 	}
 	}
 	
 	
 	/**
 	/**
@@ -527,6 +527,7 @@ public class AdController extends SimpleController {
 			if(paramMap.containsKey("uploadPath")&&paramMap.get("uploadPath")!=""
 			if(paramMap.containsKey("uploadPath")&&paramMap.get("uploadPath")!=""
 					&&paramMap.get("uploadPath")!=null){
 					&&paramMap.get("uploadPath")!=null){
 				String uploadName = banner.getBannerTemplate().getName();
 				String uploadName = banner.getBannerTemplate().getName();
+				String resetName = redirect(uploadName);
 				String fileType = uploadName.substring(uploadName.lastIndexOf(".")+1);
 				String fileType = uploadName.substring(uploadName.lastIndexOf(".")+1);
 				String filePath = (String)paramMap.get("uploadPath");
 				String filePath = (String)paramMap.get("uploadPath");
 				
 				
@@ -539,7 +540,7 @@ public class AdController extends SimpleController {
 				//取上传文件父级目录
 				//取上传文件父级目录
 				String absolutePath = uploadFile.getParentFile().getAbsolutePath();
 				String absolutePath = uploadFile.getParentFile().getAbsolutePath();
 				//生成缩略图路径名
 				//生成缩略图路径名
-				String pathSmall = absolutePath.concat(File.separator).concat("small_").concat(uploadName);
+				String pathSmall = absolutePath.concat(File.separator).concat("small_").concat(resetName);
 				//生成缩略图
 				//生成缩略图
 				compressPicture(uploadFile,pathSmall, 150,60);
 				compressPicture(uploadFile,pathSmall, 150,60);
 				
 				
@@ -896,7 +897,15 @@ public class AdController extends SimpleController {
 	}
 	}
 	
 	
 	
 	
-
+	//处理图片名称
+		public String resetName(String uploadName){
+			String fileType =  fileType = uploadName.substring(uploadName.lastIndexOf("."));
+			uploadName = new StringBuilder()
+						.append(System.currentTimeMillis())
+						.append(fileType)
+						.toString();
+			return uploadName;
+		}
 	
 	
 	//处理上传文件的绝对路径
 	//处理上传文件的绝对路径
 	public String getLocalFilePath(String fileName){
 	public String getLocalFilePath(String fileName){

+ 15 - 58
src/main/java/com/cloudcross/ssp/web/advertiser/main/ad/target/CreateBannerController.java

@@ -265,6 +265,7 @@ public class CreateBannerController extends SimpleController{
 
 
 	public @ResponseBody String upload(Model model,HttpServletResponse response,HttpServletRequest request) throws IOException{  
 	public @ResponseBody String upload(Model model,HttpServletResponse response,HttpServletRequest request) throws IOException{  
 		String uploadName;
 		String uploadName;
+		String resetName;
 		String fileType;
 		String fileType;
 		//文件路径
 		//文件路径
 		String path;
 		String path;
@@ -296,7 +297,7 @@ public class CreateBannerController extends SimpleController{
 			if(file != null){ 
 			if(file != null){ 
 				//取得当前上传文件的文件名称(不加路径)  
 				//取得当前上传文件的文件名称(不加路径)  
 				uploadName = file.getOriginalFilename();  
 				uploadName = file.getOriginalFilename();  
-				
+				resetName = resetName(uploadName);
 				//获取文件类型
 				//获取文件类型
 				 fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 				 fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
 				 
 				 
@@ -309,7 +310,7 @@ public class CreateBannerController extends SimpleController{
 				if(uploadName.trim() !=""){  
 				if(uploadName.trim() !=""){  
 					
 					
 					//处理上传文件路径
 					//处理上传文件路径
-					path = getLocalFilePath(uploadName);
+					path = getLocalFilePath(resetName);
 					
 					
 					File localFile = new File(path); 
 					File localFile = new File(path); 
 					//上传目录不存在,则新建目录
 					//上传目录不存在,则新建目录
@@ -334,13 +335,13 @@ public class CreateBannerController extends SimpleController{
 				//取上传文件父级目录
 				//取上传文件父级目录
 				String absolutePath = localFile.getParentFile().getAbsolutePath();
 				String absolutePath = localFile.getParentFile().getAbsolutePath();
 				//生成缩略图路径名
 				//生成缩略图路径名
-				pathSmall = absolutePath.concat(File.separator).concat("small_").concat(uploadName);
+				pathSmall = absolutePath.concat(File.separator).concat("small_").concat(resetName);
 				//生成缩略图
 				//生成缩略图
 				compressPicture(localFile,pathSmall,150,60);
 				compressPicture(localFile,pathSmall,150,60);
 				//判断是否需要缩放
 				//判断是否需要缩放
 				if((width*_height)==(_width*height)){
 				if((width*_height)==(_width*height)){
 					//压缩文件上传路径
 					//压缩文件上传路径
-					 String compressPath =absolutePath.concat(File.separator).concat("compress_").concat(uploadName);
+					 String compressPath =absolutePath.concat(File.separator).concat("compress_").concat(resetName);
 					 //生成压缩图
 					 //生成压缩图
 					 compressPicture(localFile,compressPath, _width,_height);
 					 compressPicture(localFile,compressPath, _width,_height);
 					//设置文件上传路径
 					//设置文件上传路径
@@ -418,65 +419,21 @@ public class CreateBannerController extends SimpleController{
 						return responseStr;
 						return responseStr;
 			}
 			}
 			
 			
-		}	
+		}
 				return responseStr; 
 				return responseStr; 
 	}
 	}
 	
 	
 	
 	
-	
-	 //取素材的大小
-	public BannerTemplate setWidthAndHeight(BannerTemplate bannerTemplate,String urls,String fileType){
-	    //本地上传的文件
-					 if("jpeg".equalsIgnoreCase(fileType)||"jpg".equalsIgnoreCase(fileType) ||"gif".equalsIgnoreCase(fileType)||"png".equalsIgnoreCase(fileType)){
-						 //把文件读取到本地	
-						 File file = new File(urls);
-						 	FileInputStream istream = null;
-							try {
-								istream = new FileInputStream(file);
-							} catch (FileNotFoundException e1) {
-								// TODO Auto-generated catch block
-								e1.printStackTrace();
-							}
-							BufferedImage image=null;
-							try {
-								image = javax.imageio.ImageIO.read(istream);
-							} catch (IOException e) {
-								e.printStackTrace();
-							}
-							if(image!=null){
-								bannerTemplate.setWidth((long)image.getWidth());
-								bannerTemplate.setHeight((long)image.getHeight());
-							}else{
-								System.out.println("aaaa");
-							}
-							try {
-								istream.close();
-							} catch (IOException e) {
-								
-								e.printStackTrace();
-							}
-					 }else if("swf".equalsIgnoreCase(fileType)){      //swf文件类型的设置
-						 File file=new File(urls);
-							SWFHeader swfh = new SWFHeader();
-							try {
-								swfh = SWFHeader.load(file);
-								bannerTemplate.setWidth((long)swfh.getWidth());
-								bannerTemplate.setHeight((long)swfh.getHeight());
-							} catch (IOException e) {
-								// TODO Auto-generated catch block
-								
-								e.printStackTrace();
-							} catch (IllegalAccessException e) {
-								// TODO Auto-generated catch block
-								
-								e.printStackTrace();
-							}
-					 }
-
-		return bannerTemplate;
-	}
-	
 
 
+	//处理图片名称
+		public String resetName(String uploadName){
+			String fileType =  fileType = uploadName.substring(uploadName.lastIndexOf("."));
+			uploadName = new StringBuilder()
+						.append(System.currentTimeMillis())
+						.append(fileType)
+						.toString();
+			return uploadName;
+		}
 	
 	
 //获取上传文件的绝对路径
 //获取上传文件的绝对路径
 public String getLocalFilePath(String fileName){
 public String getLocalFilePath(String fileName){

+ 9 - 4
src/main/webapp/assets/js/advertiser/adBanner.js

@@ -79,12 +79,17 @@ $(document).ready(function(){
 			autoUpload: true,
 			autoUpload: true,
 			url: ctx+'/advertiser/main/ad/target/ad/upload?bannerId='+$("#bannerId").val(),		
 			url: ctx+'/advertiser/main/ad/target/ad/upload?bannerId='+$("#bannerId").val(),		
 			done:function(e,data){
 			done:function(e,data){
-				var path = data.result;
-				if(path.indexOf("不支持") < 0){
-					var file_name = path.split("\\")[path.split("\\").length-1];
+				var path = data.result;			
+				if(path.indexOf("~") < 0){
+					var file_name = path.split("--")[path.split("--").length-1];
+					var file_path = path.split("--")[path.split("--").length-2];
+					alert(file_name);
+					alert(file_path);
 					$("#bannerTemplateName").val(file_name);
 					$("#bannerTemplateName").val(file_name);
 					$("#bannerTemplateName1").val(file_name); 
 					$("#bannerTemplateName1").val(file_name); 
-					$("#upload-path").val(data.result);
+					$("#upload-path").val(file_path);
+				}else{
+					alert(path);
 				}
 				}
 			}
 			}
 		});
 		});