bug--修复个人中心修改头像错误、素材分组问题、以及上传文件问题

This commit is contained in:
taochengbo
2020-05-25 23:47:54 +08:00
parent d57f89b03d
commit f3f0b248cf
7 changed files with 31 additions and 20 deletions

View File

@ -19,6 +19,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
@ -56,8 +58,8 @@ public class LocalStorageController {
@Log("新增文件")
@ApiOperation("新增文件")
@PreAuthorize("@el.check('admin','localStorage:add')")
public ResponseEntity<Object> create(@Validated @RequestBody LocalStorage resources){
return new ResponseEntity<>(localStorageService.save(resources),HttpStatus.CREATED);
public ResponseEntity<Object> create(@RequestParam String name, @RequestParam("file") MultipartFile file){
return new ResponseEntity<>(localStorageService.create(name,file),HttpStatus.CREATED);
}
@PutMapping
@ -65,7 +67,7 @@ public class LocalStorageController {
@ApiOperation("修改文件")
@PreAuthorize("@el.check('admin','localStorage:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorage resources){
localStorageService.updateById(resources);
localStorageService.saveOrUpdate(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

View File

@ -101,7 +101,7 @@ public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper,
SecurityUtils.getUsername()
);
return generator.convert(localStorage,LocalStorageDto.class);
return generator.convert(this.save(localStorage),LocalStorageDto.class);
}catch (Exception e){
FileUtil.del(file);
throw e;