yujian
2019-03-22 3d3dcd4fe9603c0792134a1179ddd14abfb22bfe
悬浮大图广告调整
4个文件已修改
161 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/FloatADAdminController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/FloatADMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/FloatAD.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/FloatADAdminController.java
@@ -62,26 +62,7 @@
        }
    }
//    /**
//     * 保存信息
//     *
//     * @param callback
//     * @param special
//     * @param out
//     */
//    @RequestMapping(value = "save")
//    public void save(String callback, @RequestParam("file") CommonsMultipartFile[] file, FloatAD floatAD,
//            String jumpType, PrintWriter out) {
//        try {
//            floatADervice.saveObject(file, floatAD, jumpType);
//            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
//        } catch (FloatADException e) {
//            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
//        } catch (Exception e) {
//            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
//            e.printStackTrace();
//        }
//    }
    /**
     * 修改排序
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/FloatADMapper.java
@@ -51,7 +51,7 @@
     * @param position
     * @return
     */
    int countByPosition(@Param("position") String position);
    int getMaxOrderByPosition(@Param("position") String position);
    /**
     * 查询有效弹出框
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/FloatAD.java
@@ -61,12 +61,12 @@
    private boolean jumpNeedLogin;
    // 起始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "fa_start_time")
    private Date startTime;
    // 结束日期
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "fa_end_time")
    private Date endTime;
@@ -90,6 +90,10 @@
    @Column(name = "fa_update_time")
    private Date updateTime;
    // 起始时间
    private String startTime_str;
    // 结束时间
    private String endTime_str;
    
    
    
@@ -204,4 +208,22 @@
    public void setShowMode(String showMode) {
        this.showMode = showMode;
    }
    public String getStartTime_str() {
        return startTime_str;
    }
    public void setStartTime_str(String startTime_str) {
        this.startTime_str = startTime_str;
    }
    public String getEndTime_str() {
        return endTime_str;
    }
    public void setEndTime_str(String endTime_str) {
        this.endTime_str = endTime_str;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java
@@ -58,21 +58,25 @@
        }
        
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date startTime = record.getStartTime();
            if (startTime != null) {
                record.setStartTime(format.parse(format.format(startTime)));
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            String startTime_str = record.getStartTime_str();
            if (startTime_str != null && startTime_str.trim().length() > 0) {
                startTime_str = startTime_str.replaceAll("T", " ");
                record.setStartTime(format.parse(startTime_str));
            }
            
            Date endTime = record.getEndTime();
            if (endTime != null) {
                record.setEndTime(format.parse(format.format(endTime)));
            String endTime_str = record.getEndTime_str();
            if (endTime_str != null && endTime_str.trim().length() > 0) {
                endTime_str = endTime_str.replaceAll("T", " ");
                record.setEndTime(format.parse(endTime_str));
            }
            
        } catch (ParseException e) {
            e.printStackTrace();
        }
        
        // 图片上传
        String picture = null;
        if (file != null) {
            picture = uploadPicture(file);
@@ -80,11 +84,14 @@
        
        Long id = record.getId();
        if (id == null) {
            int maxOrder = floatADMapper.countByPosition(position);
            int maxOrder = floatADMapper.getMaxOrderByPosition(position);
            record.setPicture(picture);
            Integer state = record.getState();
            if (state == null) {
            record.setState(0);
            }
            record.setOrder(maxOrder + 1);
            record.setJumpNeedLogin(false);
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            floatADMapper.insert(record);
@@ -96,9 +103,10 @@
            }
            
            if (picture != null && picture.trim().length() > 0) {
                // 删除老图
                removePicture(resultObj.getPicture());
                // 存储新图
                record.setPicture(picture);
                // 删除已存在图片
                removePicture(resultObj);
            } else {
                record.setPicture(resultObj.getPicture());
            }
@@ -110,6 +118,38 @@
        }
    }
    
    /**
     * 上传图片
     * @param file
     * @return
     * @throws Exception
     */
    public String uploadPicture(MultipartFile file) throws Exception {
        // 文件解析
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        // 文件路径
        String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
        // 执行上传
        String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
        return fileLink;
    }
    /**
     * 删除图片-不更新数据库
     * @param record
     * @throws Exception
     */
    public void removePicture(String picture) throws Exception {
        if (picture != null && picture.trim().length() > 0) {
            COSManager.getInstance().deleteFile(picture);
        }
    }
    
    @Override
    @Transactional
@@ -155,45 +195,12 @@
        
        // 删除已存在图片
        for (FloatAD floatAD: listSwiper) {
            removePicture(floatAD);
            removePicture(floatAD.getPicture());
        }
        
        return floatADMapper.deleteByPrimaryKeyList(list);
    }
    /**
     * 上传图片
     * @param file
     * @return
     * @throws Exception
     */
    public String uploadPicture(MultipartFile file) throws Exception {
        // 文件解析
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        // 文件路径
        String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
        // 执行上传
        String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
        return fileLink;
    }
    /**
     * 删除图片-不更新数据库
     * @param record
     * @throws Exception
     */
    public void removePicture(FloatAD record) throws Exception {
        String picture = record.getPicture();
        if (picture != null && picture.trim().length() > 0) {
            COSManager.getInstance().deleteFile(picture);
        }
    }
    
    @Override
@@ -206,6 +213,21 @@
        
        for (FloatAD floatAD : listQuery) {
            
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
            Date startTime = floatAD.getStartTime();
            if (startTime == null) {
                floatAD.setStartTime_str("");
            } else {
                floatAD.setStartTime_str(sdf.format(startTime));
            }
            Date endTime = floatAD.getEndTime();
            if (endTime == null) {
                floatAD.setEndTime_str("");
            } else {
                floatAD.setEndTime_str(sdf.format(endTime));
            }
            String params = floatAD.getParams();
            if (params == null) {
                floatAD.setParams("");