Преглед изворни кода

修复bug, 图片一张上传

Memory_LG пре 1 недеља
родитељ
комит
cf7a6d2d34

+ 21 - 27
qmjszx-admin/src/main/java/beilv/web/controller/system/SysNoticeController.java

@@ -1,12 +1,5 @@
 package beilv.web.controller.system;
 
-import java.util.List;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.ModelMap;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
 import beilv.common.annotation.Log;
 import beilv.common.core.controller.BaseController;
 import beilv.common.core.domain.AjaxResult;
@@ -14,16 +7,23 @@ import beilv.common.core.page.TableDataInfo;
 import beilv.common.enums.BusinessType;
 import beilv.system.domain.SysNotice;
 import beilv.system.service.ISysNoticeService;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * 公告 信息操作处理
- * 
+ *
  * @author ruoyi
  */
 @Controller
 @RequestMapping("/system/notice")
-public class SysNoticeController extends BaseController
-{
+public class SysNoticeController extends BaseController {
     private String prefix = "system/notice";
 
     @Autowired
@@ -31,8 +31,7 @@ public class SysNoticeController extends BaseController
 
     @RequiresPermissions("system:notice:view")
     @GetMapping()
-    public String notice()
-    {
+    public String notice() {
         return prefix + "/notice";
     }
 
@@ -42,8 +41,7 @@ public class SysNoticeController extends BaseController
     @RequiresPermissions("system:notice:list")
     @PostMapping("/list")
     @ResponseBody
-    public TableDataInfo list(SysNotice notice)
-    {
+    public TableDataInfo list(SysNotice notice) {
         startPage();
         List<SysNotice> list = noticeService.selectNoticeList(notice);
         return getDataTable(list);
@@ -54,8 +52,7 @@ public class SysNoticeController extends BaseController
      */
     @RequiresPermissions("system:notice:add")
     @GetMapping("/add")
-    public String add()
-    {
+    public String add() {
         return prefix + "/add";
     }
 
@@ -66,8 +63,7 @@ public class SysNoticeController extends BaseController
     @Log(title = "通知公告", businessType = BusinessType.INSERT)
     @PostMapping("/add")
     @ResponseBody
-    public AjaxResult addSave(@Validated SysNotice notice)
-    {
+    public AjaxResult addSave(@Validated SysNotice notice) {
         notice.setCreateBy(getLoginName());
         return toAjax(noticeService.insertNotice(notice));
     }
@@ -77,9 +73,10 @@ public class SysNoticeController extends BaseController
      */
     @RequiresPermissions("system:notice:edit")
     @GetMapping("/edit/{noticeId}")
-    public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
-    {
-        mmap.put("notice", noticeService.selectNoticeById(noticeId));
+    public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap) {
+        SysNotice sysNotice = noticeService.selectNoticeById(noticeId);
+        sysNotice.setFile(sysNotice.getNoticeImg());
+        mmap.put("notice", sysNotice);
         return prefix + "/edit";
     }
 
@@ -90,8 +87,7 @@ public class SysNoticeController extends BaseController
     @Log(title = "通知公告", businessType = BusinessType.UPDATE)
     @PostMapping("/edit")
     @ResponseBody
-    public AjaxResult editSave(@Validated SysNotice notice)
-    {
+    public AjaxResult editSave(@Validated SysNotice notice) {
         notice.setUpdateBy(getLoginName());
         return toAjax(noticeService.updateNotice(notice));
     }
@@ -101,8 +97,7 @@ public class SysNoticeController extends BaseController
      */
     @RequiresPermissions("system:notice:list")
     @GetMapping("/view/{noticeId}")
-    public String view(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
-    {
+    public String view(@PathVariable("noticeId") Long noticeId, ModelMap mmap) {
         mmap.put("notice", noticeService.selectNoticeById(noticeId));
         return prefix + "/view";
     }
@@ -114,8 +109,7 @@ public class SysNoticeController extends BaseController
     @Log(title = "通知公告", businessType = BusinessType.DELETE)
     @PostMapping("/remove")
     @ResponseBody
-    public AjaxResult remove(String ids)
-    {
+    public AjaxResult remove(String ids) {
         return toAjax(noticeService.deleteNoticeByIds(ids));
     }
 

+ 1 - 7
qmjszx-admin/src/main/resources/templates/competition/add.html

@@ -191,13 +191,7 @@
         }).on('fileuploaded', function (event, data, previewId, index) {
             var inputName = event.currentTarget.id;
             var fullUrl = data.response.url; // 获取完整的URL
-            var urlObject = new URL(fullUrl);
-            var relativePath = urlObject.pathname; // 获取路径部分
-            var newBaseUrl = "http://localhost"; // 新的URL
-            var absoluteUrl = newBaseUrl + relativePath; // 拼接完整的URL
-
-            // 直接设置输入框的值为新上传的图片URL
-            $("input[name='" + inputName + "']").val(absoluteUrl);
+            $("input[name='" + inputName + "']").val(fullUrl); // 只保留最新的图片 URL
         }).on('fileremoved', function (event, key, jqXHR, pd) {
             var inputName = event.currentTarget.id;
             // 移除文件后,清空输入框的值

+ 1 - 9
qmjszx-admin/src/main/resources/templates/competition/edit.html

@@ -266,16 +266,8 @@
                 multiple: false,
             }).on('fileuploaded', function (event, data, previewId, index) {
                 var inputName = event.currentTarget.id;
-                var existingValue = $("input[name='" + inputName + "']").val();
                 var fullUrl = data.response.url; // 获取完整的URL
-                var urlObject = new URL(fullUrl);
-                var relativePath = urlObject.pathname; // 获取路径部分
-                // var newBaseUrl = "http://192.168.4.27"; // 新的基URL
-                var newBaseUrl = "http://localhost"; // 新的基URL
-                var absoluteUrl = newBaseUrl + relativePath; // 拼接完整的URL
-
-                // 如果已经存在值,则替换为新值
-                $("input[name='" + inputName + "']").val(absoluteUrl);
+                $("input[name='" + inputName + "']").val(fullUrl); // 只保留最新的图片 URL
             }).on('fileremoved', function (event, id, index) {
                 var inputName = event.currentTarget.id;
                 $("input[name='" + inputName + "']").val(''); // 移除后清空输入框

+ 1 - 0
qmjszx-admin/src/main/resources/templates/information/add.html

@@ -126,6 +126,7 @@
             maxFileSize: 10240,
             multiple: true,
         }).on('fileuploaded', function (event, data, previewId, index) {
+            debugger
             var inputName = event.currentTarget.id;
             var existingValue = $("input[name='" + inputName + "']").val();
             var newValue = data.response.url;

+ 28 - 3
qmjszx-admin/src/main/resources/templates/order/order.html

@@ -89,7 +89,13 @@
                 },
                 {
                     field: 'paid',
-                    title: '支付状态'
+                    title: '支付状态',
+                    formatter: function (value, row, index) {
+                        var statusMap = {
+                            0:'待支付',1:'已支付',2:'退款',3:'取消'
+                        };
+                        return statusMap[value] || '未知';
+                    }
                 },
                 {
                     field: 'payTime',
@@ -97,11 +103,30 @@
                 },
                 {
                     field: 'payType',
-                    title: '支付方式'
+                    title: '支付方式',
+                    formatter: function (value, row, index) {
+                        var payTypeMap = {
+                            1: '微信支付',
+                            2: '余额支付'
+                        };
+                        return payTypeMap[value] || '未知';
+                    }
                 },
                 {
                     field: 'status',
-                    title: '订单状态'
+                    title: '订单状态',
+                    formatter: function (value, row, index) {
+                        var statusMap = {
+                            '-1': '取消',
+                            '0': '未支付',
+                            '1': '待发货',
+                            '2': '待收货',
+                            '3': '待评价',
+                            '4': '已完成',
+                            '5': '待成团'
+                    };
+                        return statusMap[value] || '未知';
+                    }
                 }]
         };
         $.table.init(options);

+ 10 - 9
qmjszx-admin/src/main/resources/templates/system/notice/add.html

@@ -63,9 +63,9 @@
 				<div class="form-group">
 					<label class="col-sm-2 control-label">图片:</label>
 					<div class="col-sm-10">
-						<input type="hidden" name="noticeImg">
+						<input type="hidden" name="file">
 						<div class="file-loading">
-							<input class="form-control file-upload" id="noticeImg" name="file" type="file"  >
+							<input class="form-control file-upload" id="file" name="file" type="file"  >
 						</div>
 					</div>
 				</div>
@@ -107,14 +107,15 @@
 				multiple: false,
 			}).on('fileuploaded', function (event, data, previewId, index) {
 				var inputName = event.currentTarget.id;
-				var fullUrl = data.response.url; // 获取完整的URL
-				var urlObject = new URL(fullUrl);
-				var relativePath = urlObject.pathname; // 获取路径部分
-				var newBaseUrl = "http://localhost"; // 新的基URL
-				var absoluteUrl = newBaseUrl + relativePath; // 拼接完整的URL
+				var existingValue = $("input[name='" + inputName + "']").val();
+				var newValue = data.response.url;
 
-				// 直接设置输入框的值为新上传的图片URL
-				$("input[name='" + inputName + "']").val(absoluteUrl);
+				// 如果已经存在值,则在后面加上逗号分隔的新值
+				if (existingValue) {
+					$("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+				} else {
+					$("input[name='" + inputName + "']").val(newValue);
+				}
 			}).on('fileremoved', function (event, key, jqXHR, pd) {
 				var inputName = event.currentTarget.id;
 				// 移除文件后,清空输入框的值

+ 37 - 12
qmjszx-admin/src/main/resources/templates/system/notice/edit.html

@@ -65,8 +65,9 @@
                     <label class="col-sm-2 control-label">图片:</label>
                     <div class="col-sm-10">
                         <input type="hidden" name="noticeImg" th:field="*{noticeImg}">
+                        <input type="hidden" name="file" th:field="*{file}">
                         <div class="file-loading">
-                            <input class="form-control file-upload" id="noticeImg" name="file" type="file" >
+                            <input class="form-control file-upload" id="file" name="file" type="file" >
                         </div>
                     </div>
                 </div>
@@ -86,9 +87,33 @@
 				followingToolbar: false,
 				dialogsInBody: true,
 				callbacks: {
-	                onImageUpload: function (files) {
-	                    sendFile(files[0], this);
-	                }
+                    onChange: function(contents, $edittable) {
+                        $("input[name='" + this.id + "']").val(contents);
+                    },
+                    onImageUpload: function(files) {
+                        var obj = this;
+                        var data = new FormData();
+                        data.append("file", files[0]);
+                        $.ajax({
+                            type: "post",
+                            url: ctx + "common/upload",
+                            data: data,
+                            cache: false,
+                            contentType: false,
+                            processData: false,
+                            dataType: 'json',
+                            success: function(result) {
+                                if (result.code == web_status.SUCCESS) {
+                                    $('#' + obj.id).summernote('editor.insertImage', result.url);
+                                } else {
+                                    $.modal.alertError(result.msg);
+                                }
+                            },
+                            error: function(error) {
+                                $.modal.alertWarning("图片上传失败。");
+                            }
+                        });
+                    }
 	            }
 		    });
 			var content = $("#noticeContent").val();
@@ -108,19 +133,19 @@
                 maxFileCount: 1,
                 allowedFileExtensions: ['jpg', 'png'],
                 maxFileSize: 10240,
+                overwriteInitial:true,
                 multiple: false,
             }).on('fileuploaded', function (event, data, previewId, index) {
                 var inputName = event.currentTarget.id;
                 var existingValue = $("input[name='" + inputName + "']").val();
-                var fullUrl = data.response.url; // 获取完整的URL
-                var urlObject = new URL(fullUrl);
-                var relativePath = urlObject.pathname; // 获取路径部分
-                // var newBaseUrl = "http://192.168.4.27"; // 新的基URL
-                var newBaseUrl = "http://localhost"; // 新的基URL
-                var absoluteUrl = newBaseUrl + relativePath; // 拼接完整的URL
+                var newValue = data.response.url;
 
-                // 如果已经存在值,则替换为新值
-                $("input[name='" + inputName + "']").val(absoluteUrl);
+                // 如果已经存在值,则在后面加上逗号分隔的新值
+                if (existingValue) {
+                    $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+                } else {
+                    $("input[name='" + inputName + "']").val(newValue);
+                }
             }).on('fileremoved', function (event, id, index) {
                 var inputName = event.currentTarget.id;
                 $("input[name='" + inputName + "']").val(''); // 移除后清空输入框

+ 1 - 1
qmjszx-business/src/main/java/beilv/order/domain/StoreOrder.java

@@ -141,7 +141,7 @@ public class StoreOrder extends BaseEntity {
     private Integer status;
 
     /**
-     * 0 未退款 1 申请中 2 已退款
+     * 支付状态: 0 未退款 1 申请中 2 已退款
      */
     @Excel(name = "0 未退款 1 申请中 2 已退款")
     private Integer refundStatus;

+ 1 - 0
qmjszx-system/src/main/java/beilv/system/domain/SysNotice.java

@@ -47,6 +47,7 @@ public class SysNotice extends BaseEntity
 
     /** 图片 */
     private String noticeImg;
+    private String file;
 
     public Long getNoticeId()
     {

+ 26 - 29
qmjszx-system/src/main/java/beilv/system/service/impl/SysNoticeServiceImpl.java

@@ -1,75 +1,75 @@
 package beilv.system.service.impl;
 
-import java.util.List;
-
-import beilv.common.utils.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.stereotype.Service;
 import beilv.common.core.text.Convert;
+import beilv.common.utils.DateUtils;
 import beilv.system.domain.SysNotice;
 import beilv.system.mapper.SysNoticeMapper;
 import beilv.system.service.ISysNoticeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * 公告 服务层实现
- * 
+ *
  * @author ruoyi
  * @date 2018-06-25
  */
 @Service
-public class SysNoticeServiceImpl implements ISysNoticeService
-{
+public class SysNoticeServiceImpl implements ISysNoticeService {
     @Autowired
     private SysNoticeMapper noticeMapper;
 
     /**
      * 查询公告信息
-     * 
+     *
      * @param noticeId 公告ID
      * @return 公告信息
      */
     @Override
-    public SysNotice selectNoticeById(Long noticeId)
-    {
+    public SysNotice selectNoticeById(Long noticeId) {
         return noticeMapper.selectNoticeById(noticeId);
     }
 
     /**
      * 查询公告列表
-     * 
+     *
      * @param notice 公告信息
      * @return 公告集合
      */
     @Override
-    public List<SysNotice> selectNoticeList(SysNotice notice)
-    {
-        return noticeMapper.selectNoticeList(notice);
+    public List<SysNotice> selectNoticeList(SysNotice notice) {
+        List<SysNotice> sysNotices = noticeMapper.selectNoticeList(notice);
+        sysNotices.forEach(sysNotice -> {
+            sysNotice.setFile(sysNotice.getNoticeImg());
+        });
+        return sysNotices;
     }
 
     /**
      * 新增公告
-     * 
+     *
      * @param notice 公告信息
      * @return 结果
      */
     @Override
-    public int insertNotice(SysNotice notice)
-    {
+    public int insertNotice(SysNotice notice) {
         notice.setReleaseTime(DateUtils.getNowDate());
+        notice.setNoticeImg(notice.getFile());
         return noticeMapper.insertNotice(notice);
     }
 
     /**
      * 修改公告
-     * 
+     *
      * @param notice 公告信息
      * @return 结果
      */
     @Override
-    public int updateNotice(SysNotice notice)
-    {
+    public int updateNotice(SysNotice notice) {
         notice.setReleaseTime(DateUtils.getNowDate());
+        notice.setNoticeImg(notice.getFile());
 //        List<SysNotice> top = noticeMapper.getTopNotice(notice);
 //        if (top != null && !top.isEmpty() && notice.getTopped().equals("Y")) {
 //            // 已有置顶记录,且新的置顶状态为 "Y" 但不是同一个记录
@@ -84,25 +84,22 @@ public class SysNoticeServiceImpl implements ISysNoticeService
 
     /**
      * 删除公告对象
-     * 
+     *
      * @param ids 需要删除的数据ID
      * @return 结果
      */
     @Override
-    public int deleteNoticeByIds(String ids)
-    {
+    public int deleteNoticeByIds(String ids) {
         return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids));
     }
 
     @Override
-    public List<SysNotice> selectNoticeListApp(SysNotice notice)
-    {
+    public List<SysNotice> selectNoticeListApp(SysNotice notice) {
         return noticeMapper.selectNoticeListApp(notice);
     }
 
     @Override
-    public int selectNoticeCount(SysNotice notice)
-    {
+    public int selectNoticeCount(SysNotice notice) {
         return noticeMapper.selectNoticeCount(notice);
     }
 }