Fixing .gitignore
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
package com.peanut.modules.oss.controller;
|
||||
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.oss.service.OssService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oss/fileoss")
|
||||
@CrossOrigin
|
||||
@Api("oss")
|
||||
public class OssController {
|
||||
|
||||
@Autowired
|
||||
private OssService ossService;
|
||||
|
||||
//上传头像的方法
|
||||
@PostMapping
|
||||
@ApiOperation("上传")
|
||||
public R uploadOssFile(MultipartFile file) {
|
||||
|
||||
//获取上传文件 MultipartFile
|
||||
//返回上传到oss的路径
|
||||
String url = ossService.uploadFileAvatar(file);
|
||||
return R.ok().put("url",url);
|
||||
}
|
||||
}
|
||||
package com.peanut.modules.oss.controller;
|
||||
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.oss.service.OssService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oss/fileoss")
|
||||
@CrossOrigin
|
||||
@Api("oss")
|
||||
public class OssController {
|
||||
|
||||
@Autowired
|
||||
private OssService ossService;
|
||||
|
||||
//上传头像的方法
|
||||
@PostMapping
|
||||
@ApiOperation("上传")
|
||||
public R uploadOssFile(MultipartFile file) {
|
||||
|
||||
//获取上传文件 MultipartFile
|
||||
//返回上传到oss的路径
|
||||
String url = ossService.uploadFileAvatar(file);
|
||||
return R.ok().put("url",url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,122 @@
|
||||
/**
|
||||
* Copyright (c) 2016-2019 人人开源 All rights reserved.
|
||||
*
|
||||
* https://www.renren.io
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.peanut.modules.oss.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.peanut.common.exception.RRException;
|
||||
import com.peanut.common.utils.ConfigConstant;
|
||||
import com.peanut.common.utils.Constant;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.validator.ValidatorUtils;
|
||||
import com.peanut.modules.oss.cloud.CloudStorageConfig;
|
||||
import com.peanut.modules.oss.cloud.OSSFactory;
|
||||
import com.peanut.modules.oss.entity.SysOssEntity;
|
||||
import com.peanut.modules.oss.service.SysOssService;
|
||||
import com.peanut.modules.sys.service.SysConfigService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/oss")
|
||||
public class SysOssController {
|
||||
@Autowired
|
||||
private SysOssService sysOssService;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
private final static String KEY = ConfigConstant.CLOUD_STORAGE_CONFIG_KEY;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = sysOssService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 云存储配置信息
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R config(){
|
||||
CloudStorageConfig config = sysConfigService.getConfigObject(KEY, CloudStorageConfig.class);
|
||||
|
||||
return R.ok().put("config", config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存云存储配置信息
|
||||
*/
|
||||
@PostMapping("/saveConfig")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R saveConfig(@RequestBody CloudStorageConfig config){
|
||||
//校验类型
|
||||
ValidatorUtils.validateEntity(config);
|
||||
ValidatorUtils.validateEntity(config, Constant.CloudService.getByValue(config.getType()));
|
||||
|
||||
sysConfigService.updateValueByKey(KEY, new Gson().toJson(config));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new RRException("上传文件不能为空");
|
||||
}
|
||||
|
||||
//上传文件
|
||||
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
String url = OSSFactory.build().uploadSuffix(file.getBytes(), suffix);
|
||||
|
||||
//保存文件信息
|
||||
SysOssEntity ossEntity = new SysOssEntity();
|
||||
ossEntity.setUrl(url);
|
||||
ossEntity.setCreateDate(new Date());
|
||||
sysOssService.save(ossEntity);
|
||||
|
||||
return R.ok().put("url", url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
sysOssService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2016-2019 人人开源 All rights reserved.
|
||||
*
|
||||
* https://www.renren.io
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.peanut.modules.oss.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.peanut.common.exception.RRException;
|
||||
import com.peanut.common.utils.ConfigConstant;
|
||||
import com.peanut.common.utils.Constant;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.validator.ValidatorUtils;
|
||||
import com.peanut.modules.oss.cloud.CloudStorageConfig;
|
||||
import com.peanut.modules.oss.cloud.OSSFactory;
|
||||
import com.peanut.modules.oss.entity.SysOssEntity;
|
||||
import com.peanut.modules.oss.service.SysOssService;
|
||||
import com.peanut.modules.sys.service.SysConfigService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/oss")
|
||||
public class SysOssController {
|
||||
@Autowired
|
||||
private SysOssService sysOssService;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
private final static String KEY = ConfigConstant.CLOUD_STORAGE_CONFIG_KEY;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = sysOssService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 云存储配置信息
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R config(){
|
||||
CloudStorageConfig config = sysConfigService.getConfigObject(KEY, CloudStorageConfig.class);
|
||||
|
||||
return R.ok().put("config", config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存云存储配置信息
|
||||
*/
|
||||
@PostMapping("/saveConfig")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R saveConfig(@RequestBody CloudStorageConfig config){
|
||||
//校验类型
|
||||
ValidatorUtils.validateEntity(config);
|
||||
ValidatorUtils.validateEntity(config, Constant.CloudService.getByValue(config.getType()));
|
||||
|
||||
sysConfigService.updateValueByKey(KEY, new Gson().toJson(config));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
throw new RRException("上传文件不能为空");
|
||||
}
|
||||
|
||||
//上传文件
|
||||
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
String url = OSSFactory.build().uploadSuffix(file.getBytes(), suffix);
|
||||
|
||||
//保存文件信息
|
||||
SysOssEntity ossEntity = new SysOssEntity();
|
||||
ossEntity.setUrl(url);
|
||||
ossEntity.setCreateDate(new Date());
|
||||
sysOssService.save(ossEntity);
|
||||
|
||||
return R.ok().put("url", url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("sys:oss:all")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
sysOssService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user