Browse Source

2020-01-15 年前修改

hugeng 4 years ago
parent
commit
4b34c6e6ca

+ 45 - 41
src/main/java/com/yc/education/controller/BaseController.java

@@ -213,50 +213,54 @@ public class BaseController {
             for (Map.Entry<String, List<MultipartFile>> entry : entries) {
                 value = entry.getValue();
             }
-            for (int i = 0; i < value.size(); i++) {
-                MultipartFile multipartFile = value.get(i);
-                // 由CommonsMultipartFile继承而来,拥有上面的方法.
-                // 如果文件不为空,则进行处理
-                if (!multipartFile.isEmpty()) {
-                    // 存放产生的随机数
-                    String sms = "";
-                    // 生成三位数的随机数
-                    StringBuffer buf = new StringBuffer();
-                    for (int j = 0; j < 3; j++) {
-                        buf.append(str[rand.nextInt(10)]);
-                    }
-                    // 对图片文件名进行处理,取得最后的6个字符,然后以"."为分隔符取得文件后缀
-                    String originalFileName = multipartFile.getOriginalFilename();
-
-                    // 取得后缀
-                    String suffixString = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
-
-                    // 设定文件名称
-                    String fileName = sms + System.currentTimeMillis() + i + "." + suffixString;
-
-                    //
-                    String path = request.getSession().getServletContext().getRealPath("/");
-                    String contextPath = request.getSession().getServletContext().getContextPath();
-
-                    File localFile = new File(path + "upload/" + fileName);
-                    System.err.println(path + "upload\\" + fileName);
-
-                    try {
-                        multipartFile.transferTo(localFile);
-                        // 将图片名称和相对路径存到数据库中
-                        paths.add("/pic/chat/" + fileName);
-                        if (!"".equals(pathString)) {
-                            pathString = contextPath + "/upload/" + fileName + "," + pathString;
-                        } else {
-                            pathString = contextPath + "/upload/" + fileName;
+            if (value.size() <= 9) {
+                for (int i = 0; i < value.size(); i++) {
+                    MultipartFile multipartFile = value.get(i);
+                    // 由CommonsMultipartFile继承而来,拥有上面的方法.
+                    // 如果文件不为空,则进行处理
+                    if (!multipartFile.isEmpty()) {
+                        // 存放产生的随机数
+                        String sms = "";
+                        // 生成三位数的随机数
+                        StringBuffer buf = new StringBuffer();
+                        for (int j = 0; j < 3; j++) {
+                            buf.append(str[rand.nextInt(10)]);
+                        }
+                        // 对图片文件名进行处理,取得最后的6个字符,然后以"."为分隔符取得文件后缀
+                        String originalFileName = multipartFile.getOriginalFilename();
+
+                        // 取得后缀
+                        String suffixString = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
+
+                        // 设定文件名称
+                        String fileName = sms + System.currentTimeMillis() + i + "." + suffixString;
+
+                        //
+                        String path = request.getSession().getServletContext().getRealPath("/");
+                        String contextPath = request.getSession().getServletContext().getContextPath();
+
+                        File localFile = new File(path + "upload/" + fileName);
+                        System.err.println(path + "upload\\" + fileName);
+
+                        try {
+                            multipartFile.transferTo(localFile);
+                            // 将图片名称和相对路径存到数据库中
+                            paths.add("/pic/chat/" + fileName);
+                            if (!"".equals(pathString)) {
+                                pathString = contextPath + "/upload/" + fileName + "," + pathString;
+                            } else {
+                                pathString = contextPath + "/upload/" + fileName;
+                            }
+                            allpath = path + "upload/" + fileName;
+                        } catch (IllegalStateException e) {
+                            e.printStackTrace();
+                        } catch (IOException e) {
+                            e.printStackTrace();
                         }
-                        allpath = path + "upload/" + fileName;
-                    } catch (IllegalStateException e) {
-                        e.printStackTrace();
-                    } catch (IOException e) {
-                        e.printStackTrace();
                     }
                 }
+            } else {
+                pathString = "";
             }
         }
         // pathString="cao";

+ 3 - 37
src/main/java/com/yc/education/controller/IndexController.java

@@ -149,19 +149,19 @@ public class IndexController {
                                   @RequestParam(required = false, defaultValue = "0") int typeid,
                                   @RequestParam(required = false, defaultValue = "3") int types,
                                   HttpSession httpSession, HttpServletRequest httpServletRequest) {
-        ModelAndView modelAndView = new ModelAndView("sechindex");
+        ModelAndView modelAndView = new ModelAndView();
         List<Forum> forums = new ArrayList<>();
         List<Forum> reforums = new ArrayList<>();
         try {
             if (!StringUtils.isEmpty(title)) {
-                forums.addAll(forumService.forumListByUsersId(0, page, rows, title, types, typeid));
+                forums = forumService.forumListByUsersId(0, page, rows, title, types, typeid);
                 for (Forum forum : forums) {
                     if (!forum.getIsdel().equals(0) || !forum.getStatus().equals(1)) {
                         reforums.add(forum);
                     }
                 }
             } else {
-                forums.addAll(forumService.forumListByType(page, rows, type, typeid));
+                forums = forumService.forumListByType(page, rows, type, typeid);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -175,40 +175,6 @@ public class IndexController {
             List<Downloadlist> downloadlists = downloadlistService.downloadListByUsersidOrForumid(users.getId(), 0);
             modelAndView.addObject("downloadlists", downloadlists);
         }
-//        try {
-//            for (Forum forum : forums) {
-//                if (!StringUtils.isEmpty(forum.getTypes()))
-//                    if (forum.getTypes().contains(",")) {
-//                        String[] split = forum.getTypes().split(",");
-//                        for (String s : split) {
-//                            if (s.equals(typeid)) {
-//                                addforums.add(forum);
-//                            }
-//                        }
-//                    } else {
-//                        if (forum.getTypes().equals(typeid)) {
-//                            addforums.add(forum);
-//                        }
-//                    }
-//                if (!StringUtils.isEmpty(forum.getIda()))
-//                    if (forum.getIda().contains(",")) {
-//                        String[] split = forum.getIda().split(",");
-//                        for (String s : split) {
-//                            if (s.equals(typeid)) {
-//                                addforums.add(forum);
-//                            }
-//                        }
-//                    } else {
-//                        if (forum.getIda().equals(typeid)) {
-//                            addforums.add(forum);
-//                        }
-//                    }
-//            }
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        forums.removeAll(reforums);
-//        forums.retainAll(addforums);
         List<Banners> findall = bannersService.findall();
         modelAndView.addObject("findall", findall);
         modelAndView.addObject("pageInfo", new PageInfo<>(forums));

+ 16 - 7
src/main/webapp/WEB-INF/jsp/index.jsp

@@ -122,7 +122,9 @@ To change this template use File | Settings | File Templates.
                         </div>
                     </div>
                     <form id="forum" method="post" action="forumadd">
-                        <div id="content-publish" class="content-publish" style="display: none;">
+						
+                        <div id="content-publish" class="content-publish" style="display: none; position:relative;">
+							<a class="closebtn">关闭</a>
                             <div class="title-area">
                                 <span>能分享的不只是图纸,试一试?</span><span class="text">个字</span><span class="num">0</span><span
                                     class="text">已输入</span>
@@ -837,7 +839,6 @@ To change this template use File | Settings | File Templates.
     <c:forEach items='${downloadlists}' var="download">
     downloadarr.push('${download}');
     </c:forEach>
-
     var title = '${title}';
     var type = '${type}';
     var types = '${types}';
@@ -935,7 +936,7 @@ To change this template use File | Settings | File Templates.
                             }
                             imgurlhtml = imgurlhtml + '</ul>';
                         }
-                        if (x.htype != null && x.htype != '') {
+                        if (x.htype != null) {
                             for (var p = 0; p < x.htype.length; p++) {
                                 if (x.htype[p] != null && x.htype[p] != '') {
                                     htypehtml = '<a class="mess-tag select htypes"  id=' + x.htype[p].id + ' >#' + x.htype[p].title + '</a>' + htypehtml;
@@ -943,10 +944,13 @@ To change this template use File | Settings | File Templates.
                             }
                         }
                         if (x.fileurl != null && x.fileurl != '') {
+
                             if (downloadarr != null && downloadarr != '') {
                                 var vals = 1;
                                 for (var q = 0; q < downloadarr.length; q++) {
                                     var w = downloadarr[q];
+                                    console.log(x.id)
+                                    console.log(w.forumid)
                                     if (w.forumid == x.id) {
                                         vals = 2;
                                     }
@@ -1162,10 +1166,6 @@ To change this template use File | Settings | File Templates.
     $("#mits").click(function () {
         var title = $("#title").val();
         var texts = $("#texts").val();
-        if (usersid == null || usersid == '') {
-            layer.msg("请登录后操作");
-            return false;
-        }
         if (title == null || title == '') {
             layer.msg("标题不能为空");
             return false;
@@ -1174,6 +1174,10 @@ To change this template use File | Settings | File Templates.
             layer.msg("正文不能为空");
             return false;
         }
+        if (usersid == null || usersid == '') {
+            layer.msg("请登录后操作");
+            return false;
+        }
         $("#forum").submit();
     })
 
@@ -1284,6 +1288,11 @@ To change this template use File | Settings | File Templates.
             $("#content-publish").show();
             $(this).hide();
         });
+		
+		$(".closebtn").click(function () {
+            $("#content-publish").hide();
+			$(".fb_enter").show();
+        });
 
         $(".limits").click(function () {
             if ($(this).children(".pub-sel").hasClass("open")) {

+ 26 - 20
src/main/webapp/WEB-INF/jsp/person.jsp

@@ -81,6 +81,7 @@ To change this template use File | Settings | File Templates.
                     <form id="forum" method="post" action="forumedit">
                         <div class="fb_bg"></div>
                         <div id="content-publish" class="content-publish fb_tc" style="display: none;">
+                            <a class="closebtn">关闭</a>
                             <div class="title-area">
                                 <span class="text">个字</span><span
                                     class="num">0</span><span
@@ -168,10 +169,8 @@ To change this template use File | Settings | File Templates.
                                                         class="upload-hide" multiple="multiple">
                                                     <div class="mdlman-pgrs">
                                                     </div>
-                                                    <p class="hint" id="hint">
-                                                        可以上传不超过9张的图片
-
-                                                    </p>
+                                                    <div class="hint" id="hint">
+                                                    </div>
                                                     <div>
                                                         <ul class="pic-list clearfix">
                                                         </ul>
@@ -856,11 +855,9 @@ To change this template use File | Settings | File Templates.
                             }
                             imgurlhtml = imgurlhtml + '</ul>';
                         }
-                        if (x.htype != null && x.htype != '') {
-                            for (var p = 0; p < x.htype.length; p++) {
-                                if (x.htype[p] != null && x.htype[p] != '') {
-                                    htypehtml = '<a class="mess-tag select" id=' + x.htype[p].id + ' >#' + x.htype[p].title + '</a>' + htypehtml;
-                                }
+                        for (var p = 0; p < x.htype.length; p++) {
+                            if (x.htype[p] != null && x.htype[p] != '') {
+                                htypehtml = '<a class="mess-tag select" id=' + x.htype[p].id + ' >#' + x.htype[p].title + '</a>' + htypehtml;
                             }
                         }
                         if (x.fileurl != null && x.fileurl != '') {
@@ -1159,16 +1156,20 @@ To change this template use File | Settings | File Templates.
                     $("#imgurl").val(obj.imgurl);
                     // imgs
                     var htmls = '';
-                    if (obj.imgurl.indexOf(",") != -1) {
-                        var ims = obj.imgurl.split(",");
-                        for (var i = 0; i < ims.length; i++) {
-                            var imss = ims[i];
-                            htmls = "<div><a class='delsimg' id=" + imss + ">删除</a> <img src=" + imss + " id='imgs' width='50px'></div>" + htmls;
+                    if (obj.imgurl != '' && obj.imgurl != null) {
+                        if (obj.imgurl.indexOf(",") != -1) {
+                            var ims = obj.imgurl.split(",");
+                            for (var i = 0; i < ims.length; i++) {
+                                var imss = ims[i];
+                                htmls = "<div class='pic_list'><a class='delsimg' id=" + imss + ">删除</a> <img src=" + imss + " id='imgs' width='50px'></div>" + htmls;
+                            }
+                        } else {
+                            htmls = "<div class='pic_list'><a class='delsimg' id=" + imss + ">删除</a> <img src=" + obj.imgurl + " id='imgs'  width='50px'></div>";
                         }
-                    } else {
-                        htmls = "<div><a class='delsimg' id=" + imss + ">删除</a> <img src=" + obj.imgurl + " id='imgs'  width='50px'></div>";
+                        $("#hint").html(htmls);
+                    }else {
+                        $("#hint").text("可以上传不超过9张的图片");
                     }
-                    $("#hint").append(htmls);
                     var html = '';
                     for (var i = 0; i < obj.htype.length; i++) {
                         var x = obj.htype[i];
@@ -1179,9 +1180,14 @@ To change this template use File | Settings | File Templates.
             }, "json");
             $("#content-publish").show();
             $(".fb_bg").show();
-            $(this).hide();
+
         });
 
+        $(".closebtn").click(function () {
+            $("#content-publish").hide();
+            $(".fb_bg").hide();
+            $('#hint').text("可以上传不超过9张的图片");
+        });
         $("body").on('click', ".delsimg", function (e) {
             $(this).parent().remove();
             var imgs = $(this).attr("id");
@@ -1301,10 +1307,10 @@ To change this template use File | Settings | File Templates.
                                     var ims = obj.message.split(",");
                                     for (var i = 0; i < ims.length; i++) {
                                         var imss = ims[i];
-                                        htmls = "<div><a class='delsimg' id=" + imss + ">删除</a> <img src=" + imss + " id='imgs' width='50px'></div>" + htmls;
+                                        htmls = "<div class='pic_list'><a class='delsimg' id=" + imss + ">删除</a> <img src=" + imss + " id='imgs' width='50px'></div>" + htmls;
                                     }
                                 } else {
-                                    htmls = "<div><a class='delsimg' id=" + message + ">删除</a> <img src=" + message + " id='imgs'  width='50px'></div>"
+                                    htmls = "<div class='pic_list'><a class='delsimg' id=" + message + ">删除</a> <img src=" + message + " id='imgs'  width='50px'></div>"
                                 }
                                 $("#hint").append(htmls);
                             } else {

+ 10 - 6
src/main/webapp/WEB-INF/jsp/sechindex.jsp

@@ -99,6 +99,7 @@ To change this template use File | Settings | File Templates.
                 <div class="index-center">
                     <form id="forum" method="post" action="forumadd">
                         <div id="content-publish" class="content-publish" style="display: none;">
+							<a class="closebtn">关闭</a>
                             <div class="title-area">
                                 <span>能分享的不只是图纸,试一试?</span><span class="text">个字</span><span class="num">0</span><span
                                     class="text">已输入</span>
@@ -700,11 +701,9 @@ To change this template use File | Settings | File Templates.
                             }
                             imgurlhtml = imgurlhtml + '</ul>';
                         }
-                        if (x.htype != null && x.htype != '') {
-                            for (var p = 0; p < x.htype.length; p++) {
-                                if (x.htype[p] != null && x.htype[p] != '') {
-                                    htypehtml = '<a class="mess-tag select" id=' + x.htype[p].id + ' >#' + x.htype[p].title + '</a>' + htypehtml;
-                                }
+                        for (var p = 0; p < x.htype.length; p++) {
+                            if (x.htype[p] != null && x.htype[p] != '') {
+                                htypehtml = '<a class="mess-tag select" id=' + x.htype[p].id + ' >#' + x.htype[p].title + '</a>' + htypehtml;
                             }
                         }
                         if (x.fileurl != null && x.fileurl != '') {
@@ -1036,7 +1035,12 @@ To change this template use File | Settings | File Templates.
             $("#content-publish").show();
             $(this).hide();
         });
-
+		
+		$(".closebtn").click(function () {
+            $("#content-publish").hide();
+			$(".fb_enter").show();
+        });
+		
         $(".limits").click(function () {
             if ($(this).children(".pub-sel").hasClass("open")) {
                 $(this).children(".pub-sel").removeClass("open")