注册登录,用户等级,社交,动态,新手任务

Change-Id: I1d3183526517fb3c0dab665e0e7547eefa5c9d76
diff --git a/src/main/java/com/example/myproject/utils/Result.java b/src/main/java/com/example/myproject/utils/Result.java
new file mode 100644
index 0000000..e46f828
--- /dev/null
+++ b/src/main/java/com/example/myproject/utils/Result.java
@@ -0,0 +1,131 @@
+package com.example.myproject.utils;
+
+
+import org.springframework.http.ResponseEntity;
+
+public class Result<T> {
+    private String code;
+    private String msg;
+    private T data;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public T getData() {
+        return data;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    public Result() {
+    }
+
+    public Result(T data) {
+        this.data = data;
+    }
+
+    public static Result success(ResponseEntity<?> resultMap, String 兴趣小组创建成功) {
+        Result result = new Result<>();
+        result.setCode("200");
+        result.setMsg("成功");
+        return result;
+    }
+
+    public static <T> Result<T> success(T data) {
+        Result<T> result = new Result<>(data);
+        result.setCode("200");
+        result.setMsg("成功");
+        return result;
+    }
+    public static <T> Result<T> success(String msg) {
+        Result result = new Result();
+        result.setCode("200");
+        result.setMsg("成功");
+        return result;
+    }
+
+    public static <T> Result<T> success(T data,String msg) {
+        Result<T> result = new Result<>(data);
+        result.setCode("200");
+        result.setMsg(msg);
+        return result;
+    }
+
+    public static Result error(String code, String msg) {
+        Result result = new Result();
+        result.setCode(code);
+        result.setMsg(msg);
+        return result;
+    }
+    /**
+     * 创建一个表示文件大小超出限制的结果对象。
+     *
+     * @return 构造的文件过大错误结果对象
+     */
+    public static Result fileTooLarge() {
+        Result result = new Result();
+        result.setCode("413");
+        result.setMsg("文件大小超出限制。");
+        return result;
+    }
+
+    /**
+     * 创建一个表示文件格式不支持的结果对象。
+     *
+     * @return 构造的文件格式错误结果对象
+     */
+    public static Result unsupportedFileType() {
+        Result result = new Result();
+        result.setCode("415");
+        result.setMsg("不支持的文件格式。");
+        return result;
+    }
+
+    /**
+     * 创建一个表示文件未找到的结果对象。
+     *
+     * @return 构造的文件未找到错误结果对象
+     */
+    public static Result fileNotFound() {
+        Result result = new Result();
+        result.setCode("404");
+        result.setMsg("文件未找到。");
+        return result;
+    }
+
+    /**
+     * 创建一个表示文件存储错误的结果对象。
+     *
+     * @param errorMsg 详细错误信息
+     * @return 构造的文件存储错误结果对象
+     */
+    public static Result fileStorageError(String errorMsg) {
+        Result result = new Result();
+        result.setCode("500");
+        result.setMsg("文件存储错误: " + errorMsg);
+        return result;
+    }
+
+    public static Result permissionDenied() {
+        Result result = new Result();
+        result.setCode("401");
+        result.setMsg("权限不足,无法执行该操作。");
+        return result;
+    }
+
+}
diff --git a/src/main/java/com/example/myproject/utils/VerifyCode.java b/src/main/java/com/example/myproject/utils/VerifyCode.java
deleted file mode 100644
index 689b8ce..0000000
--- a/src/main/java/com/example/myproject/utils/VerifyCode.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package com.example.myproject.utils;
-
-
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Random;
-
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Random;
-
-/*
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Random;
-
-/**
- * @author 阿楠
- * code生成工具类
- */
-public class VerifyCode {
-    /**
-     * 生成验证码图片的宽度
-     */
-    private int width = 100;
-
-    /**
-     * 生成验证码图片的高度
-     */
-    private int height = 30;
-
-    /**
-     * 字符样式
-     */
-    private String[] fontNames = { "宋体", "楷体", "隶书", "微软雅黑" };
-
-    /**
-     * 定义验证码图片的背景颜色为白色
-     */
-    private Color bgColor = new Color(255, 255, 255);
-
-    /**
-     * 生成随机
-     */
-    private Random random = new Random();
-
-    /**
-     * 定义code字符
-     */
-    private String codes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
-    /**
-     * 记录随机字符串
-     */
-    private String text;
-
-    /**
-     * 获取一个随意颜色
-     * @return
-     */
-    private Color randomColor() {
-        int red = random.nextInt(150);
-        int green = random.nextInt(150);
-        int blue = random.nextInt(150);
-        return new Color(red, green, blue);
-    }
-
-    /**
-     * 获取一个随机字体
-     *
-     * @return
-     */
-    private Font randomFont() {
-        String name = fontNames[random.nextInt(fontNames.length)];
-        int style = random.nextInt(4);
-        int size = random.nextInt(5) + 24;
-        return new Font(name, style, size);
-    }
-
-    /**
-     * 获取一个随机字符
-     *
-     * @return
-     */
-    private char randomChar() {
-        return codes.charAt(random.nextInt(codes.length()));
-    }
-
-    /**
-     * 创建一个空白的BufferedImage对象
-     *
-     * @return
-     */
-    private BufferedImage createImage() {
-        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
-        Graphics2D g2 = (Graphics2D) image.getGraphics();
-        //设置验证码图片的背景颜色
-        g2.setColor(bgColor);
-        g2.fillRect(0, 0, width, height);
-        return image;
-    }
-
-    public BufferedImage getImage() {
-        BufferedImage image = createImage();
-        Graphics2D g2 = (Graphics2D) image.getGraphics();
-        StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < 4; i++) {
-            String s = randomChar() + "";
-            sb.append(s);
-            g2.setColor(randomColor());
-            g2.setFont(randomFont());
-            float x = i * width * 1.0f / 4;
-            g2.drawString(s, x, height - 8);
-        }
-        this.text = sb.toString();
-        drawLine(image);
-        return image;
-    }
-
-    /**
-     * 绘制干扰线
-     *
-     * @param image
-     */
-    private void drawLine(BufferedImage image) {
-        Graphics2D g2 = (Graphics2D) image.getGraphics();
-        int num = 5;
-        for (int i = 0; i < num; i++) {
-            int x1 = random.nextInt(width);
-            int y1 = random.nextInt(height);
-            int x2 = random.nextInt(width);
-            int y2 = random.nextInt(height);
-            g2.setColor(randomColor());
-            g2.setStroke(new BasicStroke(1.5f));
-            g2.drawLine(x1, y1, x2, y2);
-        }
-    }
-
-    public String getText() {
-        return text;
-    }
-
-    public static void output(BufferedImage image, OutputStream out) throws IOException {
-        ImageIO.write(image, "JPEG", out);
-    }
-}