use of com.qiwenshare.file.domain.SysParam in project qiwen-file by qiwenshare.
the class StorageService method checkStorage.
public boolean checkStorage(Long userId, Long fileSize) {
LambdaQueryWrapper<StorageBean> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StorageBean::getUserId, userId);
StorageBean storageBean = storageMapper.selectOne(lambdaQueryWrapper);
Long totalStorageSize = null;
if (storageBean == null || storageBean.getTotalStorageSize() == null) {
LambdaQueryWrapper<SysParam> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(SysParam::getSysParamKey, "totalStorageSize");
SysParam sysParam = sysParamMapper.selectOne(lambdaQueryWrapper1);
totalStorageSize = Long.parseLong(sysParam.getSysParamValue());
storageBean = new StorageBean();
storageBean.setUserId(userId);
storageBean.setTotalStorageSize(totalStorageSize);
storageMapper.insert(storageBean);
} else {
totalStorageSize = storageBean.getTotalStorageSize();
}
if (totalStorageSize != null) {
totalStorageSize = totalStorageSize * 1024 * 1024;
}
Long storageSize = userFileMapper.selectStorageSizeByUserId(userId);
if (storageSize == null) {
storageSize = 0L;
}
if (storageSize + fileSize > totalStorageSize) {
return false;
}
return true;
}
use of com.qiwenshare.file.domain.SysParam in project qiwen-file by qiwenshare.
the class SysParamController method groupList.
@Operation(summary = "查询系统参数组", tags = { "系统参数管理" })
@RequestMapping(value = "/grouplist", method = RequestMethod.GET)
@ResponseBody
public RestResult<Map> groupList(@Parameter(description = "查询参数dto", required = false) QueryGroupParamDTO queryGroupParamDTO) {
List<SysParam> list = sysParamService.list(new QueryWrapper<SysParam>().lambda().eq(SysParam::getGroupName, queryGroupParamDTO.getGroupName()));
Map<String, Object> result = new HashMap<>();
for (SysParam sysParam : list) {
result.put(sysParam.getSysParamKey(), sysParam.getSysParamValue());
}
return RestResult.success().data(result);
}
use of com.qiwenshare.file.domain.SysParam in project qiwen-file by qiwenshare.
the class StorageService method getTotalStorageSize.
public Long getTotalStorageSize(Long userId) {
LambdaQueryWrapper<StorageBean> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StorageBean::getUserId, userId);
StorageBean storageBean = storageMapper.selectOne(lambdaQueryWrapper);
Long totalStorageSize = null;
if (storageBean == null || storageBean.getTotalStorageSize() == null) {
LambdaQueryWrapper<SysParam> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(SysParam::getSysParamKey, "totalStorageSize");
SysParam sysParam = sysParamMapper.selectOne(lambdaQueryWrapper1);
totalStorageSize = Long.parseLong(sysParam.getSysParamValue());
storageBean = new StorageBean();
storageBean.setUserId(userId);
storageBean.setTotalStorageSize(totalStorageSize);
storageMapper.insert(storageBean);
} else {
totalStorageSize = storageBean.getTotalStorageSize();
}
if (totalStorageSize != null) {
totalStorageSize = totalStorageSize * 1024 * 1024;
}
return totalStorageSize;
}
use of com.qiwenshare.file.domain.SysParam in project qiwen-file by qiwenshare.
the class SysParamService method getValue.
@Override
public String getValue(String key) {
SysParam sysParam = new SysParam();
sysParam.setSysParamKey(key);
List<SysParam> list = sysParamMapper.selectList(new QueryWrapper<>(sysParam));
if (list != null && !list.isEmpty()) {
return list.get(0).getSysParamValue();
}
return null;
}
Aggregations