bug--修改上传素材报错,修改本地存储报错
This commit is contained in:
@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -20,7 +22,8 @@ import java.io.Serializable;
|
|||||||
* @date 2020-05-13
|
* @date 2020-05-13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Getter
|
||||||
|
@Setter
|
||||||
@TableName("local_storage")
|
@TableName("local_storage")
|
||||||
public class LocalStorage implements Serializable {
|
public class LocalStorage implements Serializable {
|
||||||
|
|
||||||
@ -69,6 +72,8 @@ public class LocalStorage implements Serializable {
|
|||||||
// @Column(name = "create_time")
|
// @Column(name = "create_time")
|
||||||
@TableField(fill= FieldFill.INSERT)
|
@TableField(fill= FieldFill.INSERT)
|
||||||
private Timestamp createTime;
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
|
||||||
public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) {
|
public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) {
|
||||||
this.realName = realName;
|
this.realName = realName;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -66,8 +66,8 @@ public class LocalStorageController {
|
|||||||
@Log("修改文件")
|
@Log("修改文件")
|
||||||
@ApiOperation("修改文件")
|
@ApiOperation("修改文件")
|
||||||
@PreAuthorize("@el.check('admin','localStorage:edit')")
|
@PreAuthorize("@el.check('admin','localStorage:edit')")
|
||||||
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorage resources){
|
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorageDto resources){
|
||||||
localStorageService.saveOrUpdate(resources);
|
localStorageService.updateLocalStorage(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,4 +66,10 @@ public interface LocalStorageService extends BaseService<LocalStorage>{
|
|||||||
* @throws IOException /
|
* @throws IOException /
|
||||||
*/
|
*/
|
||||||
void download(List<LocalStorageDto> localStorageDtos, HttpServletResponse response) throws IOException;
|
void download(List<LocalStorageDto> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文件
|
||||||
|
* @param resources
|
||||||
|
*/
|
||||||
|
void updateLocalStorage(LocalStorageDto resources);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ public class LocalStorageDto implements Serializable {
|
|||||||
|
|
||||||
private String suffix;
|
private String suffix;
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private String size;
|
private String size;
|
||||||
|
@ -17,6 +17,7 @@ import co.yixiang.tools.service.LocalStorageService;
|
|||||||
import co.yixiang.tools.service.dto.LocalStorageDto;
|
import co.yixiang.tools.service.dto.LocalStorageDto;
|
||||||
import co.yixiang.tools.service.dto.LocalStorageQueryCriteria;
|
import co.yixiang.tools.service.dto.LocalStorageQueryCriteria;
|
||||||
import co.yixiang.tools.service.mapper.LocalStorageMapper;
|
import co.yixiang.tools.service.mapper.LocalStorageMapper;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
@ -100,8 +101,8 @@ public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper,
|
|||||||
FileUtil.getSize(multipartFile.getSize()),
|
FileUtil.getSize(multipartFile.getSize()),
|
||||||
SecurityUtils.getUsername()
|
SecurityUtils.getUsername()
|
||||||
);
|
);
|
||||||
|
this.save(localStorage);
|
||||||
return generator.convert(this.save(localStorage),LocalStorageDto.class);
|
return generator.convert(localStorage,LocalStorageDto.class);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
FileUtil.del(file);
|
FileUtil.del(file);
|
||||||
throw e;
|
throw e;
|
||||||
@ -136,4 +137,11 @@ public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper,
|
|||||||
}
|
}
|
||||||
FileUtil.downloadExcel(list, response);
|
FileUtil.downloadExcel(list, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLocalStorage(LocalStorageDto resources) {
|
||||||
|
LocalStorage localStorage = this.getById(resources.getId());
|
||||||
|
BeanUtils.copyProperties(resources,localStorage);
|
||||||
|
this.saveOrUpdate(localStorage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user