Pu Zhibing
2025-03-19 e064c1165e0f7047e0a0d564569cd7c418009e67
Merge remote-tracking branch 'origin/2.0' into 2.0
2个文件已修改
1个文件已添加
145 ■■■■■ 已修改文件
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/util/MyFileUtil.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TShopController.java
@@ -567,8 +567,6 @@
                tStore.setOperatorId(UserExt.getUser().getObjectId());
            }
            user.setObjectId(tStore.getId());
            userService.updateById(user);
            // 添加门店
            HashMap<String, String> map1 = new HashMap<>();
            map1.put("sign","0DB011836143EEE2C2E072967C9F4E4B");
@@ -591,7 +589,8 @@
            Integer integer = Integer.valueOf(space_id);
            tStore.setId(integer);
            storeService.save(tStore);
            System.err.println(tStore);
            user.setObjectId(tStore.getId());
            userService.updateById(user);
            ArrayList<StoreConfig> storeConfigs = new ArrayList<>();
            for (int i = 1; i < 9; i++) {
                StoreConfig storeConfig = new StoreConfig();
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/util/MyFileUtil.java
New file
@@ -0,0 +1,129 @@
package com.dsh.guns.modular.system.controller.util;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.file.Files;
/**
 * @author RainbowCloud
 */
public class MyFileUtil {
    /**
     * 将 File 转换为 MultipartFile。
     *
     * @param file      要转换的文件
     * @param fieldName 字段名,通常用于表单中的文件字段名
     * @return 转换后的 MultipartFile
     * @throws IOException 如果发生I/O错误
     */
    public static MultipartFile fileToMultipartFile(File file, String fieldName) throws IOException {
        try {
            if (file == null || !file.exists()) {
                throw new FileNotFoundException("文件未找到:" + file);
            }
            byte[] content = Files.readAllBytes(file.toPath());
            return new ByteArrayMultipartFile(content, file.getName(), fieldName, Files.probeContentType(file.toPath()));
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            // 删除临时文件
            file.delete();
        }
    }
    /**
     * 将 MultipartFile 转换为 File。
     *
     * @param multipartFile 要转换的 MultipartFile
     * @return 转换后的 File
     * @throws IOException 如果发生I/O错误
     */
    public static File multipartFileToFile(MultipartFile multipartFile) throws IOException {
        if (multipartFile.isEmpty()) {
            throw new IOException("传入的MultipartFile为空");
        }
        String originalFilename = multipartFile.getOriginalFilename();
        String tempFileSuffix = originalFilename != null ? originalFilename.substring(originalFilename.lastIndexOf('.')) : ".tmp";
        File tempFile = File.createTempFile("temp", tempFileSuffix);
        try (InputStream ins = multipartFile.getInputStream();
             OutputStream os = new FileOutputStream(tempFile)) {
            byte[] buffer = new byte[8192];
            int bytesRead;
            while ((bytesRead = ins.read(buffer)) != -1) {
                os.write(buffer, 0, bytesRead);
            }
        }
        return tempFile;
    }
    /**
     * 内置一个简单的 MultipartFile 实现类,用于File转换
     */
    private static class ByteArrayMultipartFile implements MultipartFile {
        private final byte[] content;
        private final String name;
        private final String originalFilename;
        private final String contentType;
        /**
         * 构造函数
         *
         * @param content         文件内容
         * @param originalFilename 文件原始名字
         * @param name            字段名
         * @param contentType     文件类型
         */
        public ByteArrayMultipartFile(byte[] content, String originalFilename, String name, String contentType) {
            this.content = content;
            this.originalFilename = originalFilename;
            this.name = name;
            this.contentType = contentType;
        }
        @Override
        public String getName() {
            return this.name;
        }
        @Override
        public String getOriginalFilename() {
            return this.originalFilename;
        }
        @Override
        public String getContentType() {
            return this.contentType;
        }
        @Override
        public boolean isEmpty() {
            return (this.content == null || this.content.length == 0);
        }
        @Override
        public long getSize() {
            return this.content.length;
        }
        @Override
        public byte[] getBytes() {
            return this.content;
        }
        @Override
        public InputStream getInputStream() {
            return new ByteArrayInputStream(this.content);
        }
        @Override
        public void transferTo(File dest) throws IOException, IllegalStateException {
            try (OutputStream os = new FileOutputStream(dest)) {
                os.write(this.content);
            }
        }
    }
}
cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
@@ -150,10 +150,11 @@
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
            //判断当前用户是否是员工
            AppUser appUser1 = appUserClient.queryAppUser(uid);
            User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1));
            if (null != one) {
            //判断当前用户是否是员工
            List<User> one = userService.list(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1));
            if (!one.isEmpty()) {
                return ResultUtil.success(1);
            }
            //普通用户校验当前时间是否在预约时间段内
@@ -209,8 +210,8 @@
            }
            //判断当前用户是否是员工
            AppUser appUser1 = appUserClient.queryAppUser(uid);
            User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1));
            if (null != one) {
            List<User> one = userService.list(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1));
            if (!one.isEmpty()) {
                Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId);
                return ResultUtil.success();
            }