vor 8 Monaten
Ursprung
Commit
3ef22e43ef

+ 2 - 2
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/master/ipInfo/controller/IpInfoController.java

@@ -23,9 +23,9 @@ import java.util.List;
  * @date 2025-03-09
  */
 @Controller
-@RequestMapping("/system/ipInfo")
+@RequestMapping("/master/ipInfo")
 public class IpInfoController extends BaseController {
-    private final String prefix = "system/ipInfo";
+    private final String prefix = "master/ipInfo";
 
     @Resource
     private IIpInfoService ipInfoService;

+ 24 - 0
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/system/SysFileUploadController.java

@@ -43,6 +43,30 @@ public class SysFileUploadController extends BaseController {
         return ajaxResult;
     }
 
+    @PostMapping("/avatar")
+    public AjaxResult designerAvatar(MultipartFile imageFile, @RequestHeader(required = false, name = "X-File-Type") String xFileType) {
+        EUploadFileType eUploadFileType = EUploadFileType.AVATAR;
+        EUploadFileType[] eUploadFileTypes = EUploadFileType.values();
+        for (EUploadFileType uploadFileType : eUploadFileTypes) {
+            if (uploadFileType.getVal().equals(xFileType)) {
+                eUploadFileType = uploadFileType;
+                break;
+            }
+        }
+
+        AjaxResult ajaxResult = AjaxResult.success();
+        try {
+            ajaxResult.put("imageUrl", this.upload(imageFile, eUploadFileType));
+        } catch (Exception ex) {
+            if (ex instanceof InvalidExtensionException) {
+                ajaxResult = AjaxResult.error("文件格式错误,请选择图片文件");
+            } else {
+                ajaxResult = AjaxResult.error();
+            }
+        }
+        return ajaxResult;
+    }
+
     @PostMapping("/video")
     public AjaxResult video(MultipartFile videoFile) {
         AjaxResult ajaxResult = AjaxResult.success();

+ 5 - 6
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/designer/add.html

@@ -38,9 +38,8 @@
     <script th:inline="javascript">
         var prefix = ctx + "master/designer"
         $('#designerAvatarUrl').change(function () {
-            var fileSize = 0;
-            fileSize = this. files[0].size;
-            fileSize=Math. round( fileSize/1024*100)/100;
+            var fileSize = this.files[0].size;
+            fileSize = Math.round(fileSize/1024*100)/100;
 
             if(fileSize>2048){
                 layer.msg('上传文件不得大于2M,请重新上传。', {time: 3000, icon:6});
@@ -56,7 +55,7 @@
                 var formdata = new FormData();
                 formdata.append("imageFile", this.files[0]);
                 $.ajax({
-                    url: ctx + "common/upload/file/image",
+                    url: ctx + "common/upload/file/designerAvatar",
                     data: formdata,
                     type: "post",
                     processData: false,
@@ -66,11 +65,11 @@
                         $.modal.disable();
                     },
                     success: function (result) {
-                        if (result.code == web_status.SUCCESS) {
+                        if (result.code === web_status.SUCCESS) {
                             $('#designerAvatarImg').attr('src', result.imageUrl);
                             $('#designerAvatar').val(result.imageUrl);
                             $.modal.alertSuccess(result.msg)
-                        } else if (result.code == web_status.WARNING) {
+                        } else if (result.code === web_status.WARNING) {
                             $.modal.alertWarning(result.msg)
                         } else {
                             $.modal.alertError(result.msg);

+ 4 - 5
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/designer/edit.html

@@ -39,9 +39,8 @@
     <script th:inline="javascript">
         var prefix = ctx + "master/designer";
         $('#designerAvatarUrl').change(function () {
-            var fileSize = 0;
-            fileSize = this. files[0].size;
-            fileSize=Math. round( fileSize/1024*100)/100;
+            var fileSize = this.files[0].size;
+            fileSize = Math.round(fileSize/1024*100)/100;
 
             if(fileSize>2048){
                 layer.msg('上传文件不得大于2M,请重新上传。', {time: 3000, icon:6});
@@ -67,11 +66,11 @@
                         $.modal.disable();
                     },
                     success: function (result) {
-                        if (result.code == web_status.SUCCESS) {
+                        if (result.code === web_status.SUCCESS) {
                             $('#designerAvatarImg').attr('src', result.imageUrl);
                             $('#designerAvatar').val(result.imageUrl);
                             $.modal.alertSuccess(result.msg)
-                        } else if (result.code == web_status.WARNING) {
+                        } else if (result.code === web_status.WARNING) {
                             $.modal.alertWarning(result.msg)
                         } else {
                             $.modal.alertError(result.msg);

+ 53 - 15
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/ipInfo/add.html

@@ -5,10 +5,10 @@
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
-        <form class="form-horizontal m" id="form-ipinfo-add">
+        <form class="form-horizontal m" id="form-ipInfo-add">
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label">文创品牌名:</label>
+                    <label class="col-sm-3 control-label">文创品牌名:</label>
                     <div class="col-sm-8">
                         <input name="ipName" class="form-control" type="text">
                     </div>
@@ -16,9 +16,11 @@
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label">ip图片:</label>
+                    <label class="col-sm-3 control-label">文创图片:</label>
                     <div class="col-sm-8">
-                        <input name="ipUrl" class="form-control" type="text">
+                        <img id="ipUrlImg" width="30%" height="30%" src="">
+                        <input type="file" class="form-control" name="ipInfoUrl" id="ipInfoUrl" accept="image/*"/>
+                        <input type="hidden" class="form-control" name="ipUrl" id="ipUrl" />
                     </div>
                 </div>
             </div>
@@ -38,26 +40,62 @@
                     </div>
                 </div>
             </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label">删除标志:</label>
-                    <div class="col-sm-8">
-                        <input name="delFlag" class="form-control" type="text">
-                    </div>
-                </div>
-            </div>
         </form>
     </div>
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
-        var prefix = ctx + "system/ipinfo"
-        $("#form-ipinfo-add").validate({
+        var prefix = ctx + "master/ipInfo"
+        $('#ipInfoUrl').change(function () {
+            var fileSize = this.files[0].size;
+            fileSize = Math.round(fileSize/1024*100)/100;
+
+            if(fileSize>2048){
+                layer.msg('上传文件不得大于2M,请重新上传。', {time: 3000, icon:6});
+                return false;
+            }
+
+            if (!/image\/\w+/.test(this.files[0].type)) {
+                layer.msg('上传的不是图片文件,请重新上传。', {time: 3000, icon:6});
+                return false;
+            }
+
+            if ($(this).val()) {
+                var formdata = new FormData();
+                formdata.append("imageFile", this.files[0]);
+                $.ajax({
+                    url: ctx + "common/upload/file/image",
+                    data: formdata,
+                    type: "post",
+                    processData: false,
+                    contentType: false,
+                    beforeSend: function () {
+                        $.modal.loading("正在处理中,请稍后...");
+                        $.modal.disable();
+                    },
+                    success: function (result) {
+                        if (result.code === web_status.SUCCESS) {
+                            $('#ipUrlImg').attr('src', result.imageUrl);
+                            $('#ipUrl').val(result.imageUrl);
+                            $.modal.alertSuccess(result.msg)
+                        } else if (result.code === web_status.WARNING) {
+                            $.modal.alertWarning(result.msg)
+                        } else {
+                            $.modal.alertError(result.msg);
+                        }
+                        $.modal.closeLoading();
+                        $.modal.enable();
+                    }
+                })
+            }
+        });
+
+        $("#form-ipInfo-add").validate({
             focusCleanup: true
         });
 
         function submitHandler() {
             if ($.validate.form()) {
-                $.operate.save(prefix + "/add", $('#form-ipinfo-add').serialize());
+                $.operate.save(prefix + "/add", $('#form-ipInfo-add').serialize());
             }
         }
     </script>

+ 51 - 5
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/ipInfo/edit.html

@@ -5,7 +5,7 @@
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
-        <form class="form-horizontal m" id="form-ipinfo-edit" th:object="${ipinfo}">
+        <form class="form-horizontal m" id="form-ipInfo-edit" th:object="${ipInfo}">
             <input name="ipId" th:field="*{ipInfoId}" type="hidden">
             <div class="col-xs-12">
                 <div class="form-group">
@@ -19,7 +19,9 @@
                 <div class="form-group">
                     <label class="col-sm-3 control-label">ip图片:</label>
                     <div class="col-sm-8">
-                        <input name="ipUrl" th:field="*{ipUrl}" class="form-control" type="text">
+                        <img id="ipUrlImg" width="30%" height="30%">
+                        <input type="file" class="form-control" name="ipInfoUrl" id="ipInfoUrl" accept="image/*"/>
+                        <input type="hidden" lass="form-control" name="ipUrl" id="ipUrl" />
                     </div>
                 </div>
             </div>
@@ -51,14 +53,58 @@
     </div>
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
-        var prefix = ctx + "system/ipinfo";
-        $("#form-ipinfo-edit").validate({
+        var prefix = ctx + "master/ipInfo";
+        $('#ipInfoUrl').change(function () {
+            var fileSize = this.files[0].size;
+            fileSize = Math.round(fileSize/1024*100)/100;
+
+            if(fileSize>2048){
+                layer.msg('上传文件不得大于2M,请重新上传。', {time: 3000, icon:6});
+                return false;
+            }
+
+            if (!/image\/\w+/.test(this.files[0].type)) {
+                layer.msg('上传的不是图片文件,请重新上传。', {time: 3000, icon:6});
+                return false;
+            }
+
+            if ($(this).val()) {
+                var formdata = new FormData();
+                formdata.append("imageFile", this.files[0]);
+                $.ajax({
+                    url: ctx + "common/upload/file/image",
+                    data: formdata,
+                    type: "post",
+                    processData: false,
+                    contentType: false,
+                    beforeSend: function () {
+                        $.modal.loading("正在处理中,请稍后...");
+                        $.modal.disable();
+                    },
+                    success: function (result) {
+                        if (result.code === web_status.SUCCESS) {
+                            $('#ipUrlImg').attr('src', result.imageUrl);
+                            $('#ipUrl').val(result.imageUrl);
+                            $.modal.alertSuccess(result.msg)
+                        } else if (result.code === web_status.WARNING) {
+                            $.modal.alertWarning(result.msg)
+                        } else {
+                            $.modal.alertError(result.msg);
+                        }
+                        $.modal.closeLoading();
+                        $.modal.enable();
+                    }
+                })
+            }
+        });
+
+        $("#form-ipInfo-edit").validate({
             focusCleanup: true
         });
 
         function submitHandler() {
             if ($.validate.form()) {
-                $.operate.save(prefix + "/edit", $('#form-ipinfo-edit').serialize());
+                $.operate.save(prefix + "/edit", $('#form-ipInfo-edit').serialize());
             }
         }
     </script>

+ 39 - 95
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/ipInfo/ipInfo.html

@@ -11,42 +11,10 @@
                     <div class="select-list">
                         <ul>
                             <li>
-                                <label>文创品牌名:</label>
+                                <label>品牌名:</label>
                                 <input type="text" name="ipName"/>
                             </li>
                             <li>
-                                <label>ip图片:</label>
-                                <input type="text" name="ipUrl"/>
-                            </li>
-                            <li>
-                                <label>色号:</label>
-                                <input type="text" name="colorNo"/>
-                            </li>
-                            <li>
-                                <label>显示顺序:</label>
-                                <input type="text" name="sort"/>
-                            </li>
-                            <li>
-                                <label>删除标志:</label>
-                                <input type="text" name="delFlag"/>
-                            </li>
-                            <li>
-                                <label>创建者:</label>
-                                <input type="text" name="createUser"/>
-                            </li>
-                            <li>
-                                <label>创建时间:</label>
-                                <input type="text" class="time-input" placeholder="请选择创建时间" name="createTime"/>
-                            </li>
-                            <li>
-                                <label>更新者:</label>
-                                <input type="text" name="updateUser"/>
-                            </li>
-                            <li>
-                                <label>更新时间:</label>
-                                <input type="text" class="time-input" placeholder="请选择更新时间" name="updateTime"/>
-                            </li>
-                            <li>
                                 <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                 <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                             </li>
@@ -56,18 +24,15 @@
             </div>
 
             <div class="btn-group-sm" id="toolbar" role="group">
-                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ipinfo:add">
+                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="master:ipInfo:add">
                     <i class="fa fa-plus"></i> 添加
                 </a>
-                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:ipinfo:edit">
+                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="master:ipInfo:edit">
                     <i class="fa fa-edit"></i> 修改
                 </a>
-                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:ipinfo:remove">
+                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="master:ipInfo:remove">
                     <i class="fa fa-remove"></i> 删除
                 </a>
-                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:ipinfo:export">
-                    <i class="fa fa-download"></i> 导出
-                </a>
             </div>
             <div class="col-sm-12 select-table table-striped">
                 <table id="bootstrap-table"></table>
@@ -76,9 +41,9 @@
     </div>
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
-        var editFlag = [[${@permission.hasPermi('system:ipinfo:edit')}]];
-        var removeFlag = [[${@permission.hasPermi('system:ipinfo:remove')}]];
-        var prefix = ctx + "system/ipinfo";
+        var editFlag = [[${@permission.hasPermi('system:ipInfo:edit')}]];
+        var removeFlag = [[${@permission.hasPermi('system:ipInfo:remove')}]];
+        var prefix = ctx + "master/ipInfo";
 
         $(function() {
             var options = {
@@ -88,60 +53,39 @@
                 removeUrl: prefix + "/remove",
                 exportUrl: prefix + "/export",
                 modalName: "文创品牌",
-                columns: [{
-                    checkbox: true
-                },
-                {
-                    field: 'ipId',
-                    title: '主键',
-                    visible: false
-                },
-                {
-                    field: 'ipName',
-                    title: '文创品牌名'
-                },
-                {
-                    field: 'ipUrl',
-                    title: 'ip图片'
-                },
-                {
-                    field: 'colorNo',
-                    title: '色号'
-                },
-                {
-                    field: 'sort',
-                    title: '显示顺序'
-                },
-                {
-                    field: 'delFlag',
-                    title: '删除标志'
-                },
-                {
-                    field: 'createUser',
-                    title: '创建者'
-                },
-                {
-                    field: 'createTime',
-                    title: '创建时间'
-                },
-                {
-                    field: 'updateUser',
-                    title: '更新者'
-                },
-                {
-                    field: 'updateTime',
-                    title: '更新时间'
-                },
-                {
-                    title: '操作',
-                    align: 'center',
-                    formatter: function(value, row, index) {
-                        var actions = [];
-                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ipId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
-                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ipId + '\')"><i class="fa fa-remove"></i>删除</a>');
-                        return actions.join('');
+                columns: [
+                    {
+                        field: 'ipId',
+                        title: '主键',
+                        visible: false
+                    },
+                    {
+                        field: 'ipName',
+                        title: '文创品牌名'
+                    },
+                    {
+                        field: 'ipUrl',
+                        title: 'IP图片'
+                    },
+                    {
+                        field: 'colorNo',
+                        title: '色号'
+                    },
+                    {
+                        field: 'sort',
+                        title: '显示顺序'
+                    },
+                    {
+                        title: '操作',
+                        align: 'center',
+                        formatter: function(value, row, index) {
+                            var actions = [];
+                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ipId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ipId + '\')"><i class="fa fa-remove"></i>删除</a>');
+                            return actions.join('');
+                        }
                     }
-                }]
+                ]
             };
             $.table.init(options);
         });

+ 1 - 6
08.src/Xingxi/xingxi-common/src/main/java/com/xingxi/common/core/controller/BaseController.java

@@ -120,17 +120,12 @@ public class BaseController {
     protected String upload(MultipartFile file, EUploadFileType eUploadFileType) {
         String filePath = eUploadFileType.getPath();
         if (file != null && !file.isEmpty()) {
-            if (eUploadFileType.equals(EUploadFileType.IMAGE) ||
-                    eUploadFileType.equals(EUploadFileType.MERC) ||
-                    eUploadFileType.equals(EUploadFileType.VOUCHER)) {
+            if (eUploadFileType.equals(EUploadFileType.IMAGE)) {
                 return FileUploadUtils.upload(filePath, file, MimeTypeUtils.IMAGE_EXTENSION);
             }
             if (eUploadFileType.equals(EUploadFileType.VIDEO)) {
                 return FileUploadUtils.upload(filePath, file, MimeTypeUtils.MEDIA_EXTENSION);
             }
-            if (eUploadFileType.equals(EUploadFileType.EXCEL)) {
-                return FileUploadUtils.upload(filePath, file, MimeTypeUtils.EXCEL_EXTENSION);
-            }
         }
         return null;
     }

+ 2 - 5
08.src/Xingxi/xingxi-common/src/main/java/com/xingxi/common/enums/EUploadFileType.java

@@ -11,12 +11,9 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum EUploadFileType implements BaseEnum {
-    MERC("merc", "public/merc/privacy", "身份证和营业执照之类"),
-    VOUCHER("voucher", "public/merc/voucher", "业务凭证"),
-    INVOICE("invoice", "public/merc/invoice", "发票"),
+    AVATAR("avatar", "public/avatar", "各种头像"),
     IMAGE("image", "public/image", "各种公共图片"),
-    VIDEO("video", "public/video", "视频"),
-    EXCEL("excel", "public/file", "视频");
+    VIDEO("video", "public/video", "视频");
 
     private final String val;
     private final String path;