|  | @ -1,6 +1,7 @@
 | 
	
		
			
				|  |  | package cn.stylefeng.guns.zjxl.cnotroller;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.config.FastDFSConfig;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.sys.modular.user.param.SysUserParam;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.zjxl.model.UploadModel;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.zjxl.model.ZjxlArticleContent;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.zjxl.model.ZjxlBanner;
 | 
	
	
		
			
				|  | @ -12,19 +13,20 @@ import cn.stylefeng.guns.zjxl.service.ZjxlBannerService;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.zjxlUtil.BaseController;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.zjxlUtil.FastDFSUtil;
 | 
	
		
			
				|  |  | import cn.stylefeng.guns.zjxlUtil.PageUtil;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.node.ObjectNode;
 | 
	
		
			
				|  |  | import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiParam;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.json.JSONArray;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestMethod;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestParam;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  | import org.springframework.validation.annotation.Validated;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.Resource;
 | 
	
	
		
			
				|  | @ -32,6 +34,7 @@ import java.io.IOException;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | import java.util.Collections;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.Iterator;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -86,6 +89,15 @@ public class ZjxlBannerCnotroller extends BaseController {
 | 
	
		
			
				|  |  |         ZjxlBanner banner = new ZjxlBanner();
 | 
	
		
			
				|  |  |         banner.setBannerImage(bannerImage);//String
 | 
	
		
			
				|  |  |         banner.setBannerIsLine(bannerIsLine);//integer
 | 
	
		
			
				|  |  |         List<ZjxlBanner> bannerList = bannerService.findBannerAll();
 | 
	
		
			
				|  |  |         if (bannerList.size() > 0){
 | 
	
		
			
				|  |  |             Iterator<ZjxlBanner> bannerIterator = bannerList.iterator();
 | 
	
		
			
				|  |  |             while (bannerIterator.hasNext()){
 | 
	
		
			
				|  |  |                 if (bannerIterator.next().getBannerName().equals(bannerName)){
 | 
	
		
			
				|  |  |                     return write(-1,"该名称已存在");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         banner.setBannerName(bannerName);//string
 | 
	
		
			
				|  |  |         banner.setBannerSort(bannerSort);
 | 
	
		
			
				|  |  |         banner.setBannerType(bannerType);
 | 
	
	
		
			
				|  | @ -96,12 +108,15 @@ public class ZjxlBannerCnotroller extends BaseController {
 | 
	
		
			
				|  |  |             object.put("articleContentType",articleContentList.get(0).getArticleContentType());
 | 
	
		
			
				|  |  |             object.put("articleContentClassify",articleContentList.get(0).getArticleContentClassify());
 | 
	
		
			
				|  |  |             object.put("articleContentSubclassify",articleContentList.get(0).getArticleContentSubclassify());
 | 
	
		
			
				|  |  |             object.put("articleContentTitle",articleContentList.get(0).getArticleContentTitle());
 | 
	
		
			
				|  |  |             banner.setBannerTypeUrl(object.toString());
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             banner.setBannerTypeUrl(bannerTypeUrl);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
 | 
	
		
			
				|  |  |         banner.setBannerCreateTime(df.format(new Date()));// new Date()为获取当前系统时间
 | 
	
		
			
				|  |  |         //设置日期格式
 | 
	
		
			
				|  |  |         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |         // new Date()为获取当前系统时间
 | 
	
		
			
				|  |  |         banner.setBannerCreateTime(df.format(new Date()));
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             logger.info("执行banner添加,参数:"+banner);
 | 
	
		
			
				|  |  |             return write(200,"添加成功","data",bannerService.addBanner(banner));
 | 
	
	
		
			
				|  | @ -127,7 +142,8 @@ public class ZjxlBannerCnotroller extends BaseController {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/updateIsLine", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "修改是否上线")
 | 
	
		
			
				|  |  |     public String updateIsLine(String id,Integer isLine){
 | 
	
		
			
				|  |  |     public String updateIsLine(String id,
 | 
	
		
			
				|  |  |                                Integer isLine){
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             logger.info("修改是否上线:id====="+id+",isLine===="+isLine);
 | 
	
		
			
				|  |  |             if (id == null || isLine == null){
 | 
	
	
		
			
				|  | @ -140,6 +156,63 @@ public class ZjxlBannerCnotroller extends BaseController {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/updataBanner", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "编辑banner")
 | 
	
		
			
				|  |  |     public String updataBanner(@ApiParam(name = "bannerId", value = "bannerId", required = false) @RequestParam(value = "bannerId", required = true)String bannerId,
 | 
	
		
			
				|  |  |                                @ApiParam(name = "bannerName", value = "bannerName", required = false) @RequestParam(value = "bannerName", required = false)String bannerName,
 | 
	
		
			
				|  |  |                                @ApiParam(name = "bannerImage", value = "图片", required = false) @RequestParam(value = "bannerImage", required = false)String bannerImage,
 | 
	
		
			
				|  |  |                                @ApiParam(name = "bannerType", value = "跳转方式: 0-无  1-站内文章  2-外部链接", required = false) @RequestParam(value = "bannerType", required = false)Integer bannerType,
 | 
	
		
			
				|  |  |                                @ApiParam(name = "bannerTypeUrl", value = "跳转链接(如果是站内文章,传文章id)", required = false) @RequestParam(value = "bannerTypeUrl", required = false)String bannerTypeUrl,
 | 
	
		
			
				|  |  |                                @ApiParam(name = "bannerSort", value = "排序", required = false) @RequestParam(value = "bannerSort", required = false)Integer bannerSort,
 | 
	
		
			
				|  |  |                                @ApiParam(name = "bannerIsLine", value = "是否上线", required = false,defaultValue = "0") @RequestParam(value = "bannerIsLine", required = false)Integer bannerIsLine){
 | 
	
		
			
				|  |  |         ZjxlBanner banner = new ZjxlBanner();
 | 
	
		
			
				|  |  |         banner.setBannerId(bannerId);
 | 
	
		
			
				|  |  |         if (bannerType != null){
 | 
	
		
			
				|  |  |             banner.setBannerType(bannerType);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (bannerType != null){
 | 
	
		
			
				|  |  |             if (bannerType == 1){
 | 
	
		
			
				|  |  |                 List<ZjxlArticleContent> articleContentList = articleContentService.findArticleContentById(bannerTypeUrl);
 | 
	
		
			
				|  |  |                 JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |                 object.put("articleContentId",articleContentList.get(0).getArticleContentId());
 | 
	
		
			
				|  |  |                 object.put("articleContentType",articleContentList.get(0).getArticleContentType());
 | 
	
		
			
				|  |  |                 object.put("articleContentClassify",articleContentList.get(0).getArticleContentClassify());
 | 
	
		
			
				|  |  |                 object.put("articleContentSubclassify",articleContentList.get(0).getArticleContentSubclassify());
 | 
	
		
			
				|  |  |                 object.put("articleContentTitle",articleContentList.get(0).getArticleContentTitle());
 | 
	
		
			
				|  |  |                 banner.setBannerTypeUrl(object.toString());
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 banner.setBannerTypeUrl(bannerTypeUrl);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (bannerSort != null){
 | 
	
		
			
				|  |  |             banner.setBannerSort(bannerSort);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<ZjxlBanner> bannerList = bannerService.findBannerAll();
 | 
	
		
			
				|  |  |         if (bannerList.size() > 0){
 | 
	
		
			
				|  |  |             Iterator<ZjxlBanner> bannerIterator = bannerList.iterator();
 | 
	
		
			
				|  |  |             while (bannerIterator.hasNext()){
 | 
	
		
			
				|  |  |                 if (bannerIterator.next().getBannerName().equals(bannerName)){
 | 
	
		
			
				|  |  |                     return write(-1,"该名称已存在");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (bannerName != null){
 | 
	
		
			
				|  |  |             banner.setBannerName(bannerName);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (bannerImage != null){
 | 
	
		
			
				|  |  |             banner.setBannerImage(bannerImage);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (bannerIsLine != null){
 | 
	
		
			
				|  |  |             banner.setBannerIsLine(bannerIsLine);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return write(200,"修改成功","data",bannerService.updateBanner(banner));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             return write(-1,"修改失败");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 聊天附件上传
 | 
	
		
			
				|  |  |      *
 |