bug--修改上传素材报错,修改本地存储报错

This commit is contained in:
xuwenbo
2020-05-26 11:16:03 +08:00
parent 935e6da667
commit cc9b3063ff
5 changed files with 26 additions and 5 deletions

View File

@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.Setter;
import java.sql.Timestamp;
import java.io.Serializable;
@ -20,7 +22,8 @@ import java.io.Serializable;
* @date 2020-05-13
*/
@Data
@Getter
@Setter
@TableName("local_storage")
public class LocalStorage implements Serializable {
@ -69,6 +72,8 @@ public class LocalStorage implements Serializable {
// @Column(name = "create_time")
@TableField(fill= FieldFill.INSERT)
private Timestamp createTime;
public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) {
this.realName = realName;
this.name = name;

View File

@ -66,8 +66,8 @@ public class LocalStorageController {
@Log("修改文件")
@ApiOperation("修改文件")
@PreAuthorize("@el.check('admin','localStorage:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorage resources){
localStorageService.saveOrUpdate(resources);
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorageDto resources){
localStorageService.updateLocalStorage(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

View File

@ -66,4 +66,10 @@ public interface LocalStorageService extends BaseService<LocalStorage>{
* @throws IOException /
*/
void download(List<LocalStorageDto> localStorageDtos, HttpServletResponse response) throws IOException;
/**
* 修改文件
* @param resources
*/
void updateLocalStorage(LocalStorageDto resources);
}

View File

@ -23,6 +23,8 @@ public class LocalStorageDto implements Serializable {
private String suffix;
private String path;
private String type;
private String size;

View File

@ -17,6 +17,7 @@ import co.yixiang.tools.service.LocalStorageService;
import co.yixiang.tools.service.dto.LocalStorageDto;
import co.yixiang.tools.service.dto.LocalStorageQueryCriteria;
import co.yixiang.tools.service.mapper.LocalStorageMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -100,8 +101,8 @@ public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper,
FileUtil.getSize(multipartFile.getSize()),
SecurityUtils.getUsername()
);
return generator.convert(this.save(localStorage),LocalStorageDto.class);
this.save(localStorage);
return generator.convert(localStorage,LocalStorageDto.class);
}catch (Exception e){
FileUtil.del(file);
throw e;
@ -136,4 +137,11 @@ public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper,
}
FileUtil.downloadExcel(list, response);
}
@Override
public void updateLocalStorage(LocalStorageDto resources) {
LocalStorage localStorage = this.getById(resources.getId());
BeanUtils.copyProperties(resources,localStorage);
this.saveOrUpdate(localStorage);
}
}