xuhy
2023-03-22 1edcf19be5f339219210894c45a77d9d507b2586
user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java
@@ -6,6 +6,8 @@
import com.supersavedriving.user.modular.system.service.IAppUserService;
import com.supersavedriving.user.modular.system.service.IDriverService;
import com.supersavedriving.user.modular.system.util.ResultUtil;
import com.supersavedriving.user.modular.system.util.UUIDUtil;
import com.supersavedriving.user.modular.system.util.huawei.OBSUtil;
import com.supersavedriving.user.modular.system.warpper.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -16,8 +18,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.List;
/**
@@ -157,4 +161,26 @@
            return new ResponseWarpper(500, e.getMessage());
        }
    }
    @ResponseBody
    @PostMapping("/api/appUser/uploadImg")
//    @ServiceLog(name = "上传头像图片", url = "/api/appUser/uploadImg")
    @ApiOperation(value = "上传头像图片", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "图片文件", name = "file", required = true, dataType = "file"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<String> uploadImg(MultipartFile file){
        try {
            InputStream inputStream = file.getInputStream();
            String name = file.getName();
            name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf("."));
            String s = OBSUtil.putObjectToBucket(inputStream, name);
            return ResponseWarpper.success(s);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
}