mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-10-14 22:20:29 +00:00
update 优化代码
This commit is contained in:
@@ -80,11 +80,8 @@ public class GenController extends BaseController {
|
|||||||
@SaCheckPermission("tool:gen:list")
|
@SaCheckPermission("tool:gen:list")
|
||||||
@GetMapping(value = "/column/{tableId}")
|
@GetMapping(value = "/column/{tableId}")
|
||||||
public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) {
|
public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) {
|
||||||
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
|
|
||||||
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
||||||
dataInfo.setRows(list);
|
return TableDataInfo.build(list);
|
||||||
dataInfo.setTotal(list.size());
|
|
||||||
return dataInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,6 +16,8 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +122,7 @@ public class SysConfigController extends BaseController {
|
|||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{configIds}")
|
@DeleteMapping("/{configIds}")
|
||||||
public R<Void> remove(@PathVariable Long[] configIds) {
|
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||||
configService.deleteConfigByIds(configIds);
|
configService.deleteConfigByIds(Arrays.asList(configIds));
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ public interface ISysConfigService {
|
|||||||
*
|
*
|
||||||
* @param configIds 需要删除的参数ID
|
* @param configIds 需要删除的参数ID
|
||||||
*/
|
*/
|
||||||
void deleteConfigByIds(Long[] configIds);
|
void deleteConfigByIds(List<Long> configIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置参数缓存数据
|
* 重置参数缓存数据
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.dromara.system.service.impl;
|
package org.dromara.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@@ -42,11 +43,10 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
@Override
|
@Override
|
||||||
public SysClientVo queryById(Long id) {
|
public SysClientVo queryById(Long id) {
|
||||||
SysClientVo vo = baseMapper.selectVoById(id);
|
SysClientVo vo = baseMapper.selectVoById(id);
|
||||||
vo.setGrantTypeList(List.of(vo.getGrantType().split(",")));
|
vo.setGrantTypeList(StringUtils.splitList(vo.getGrantType()));
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询客户端管理
|
* 查询客户端管理
|
||||||
*/
|
*/
|
||||||
@@ -63,7 +63,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
public TableDataInfo<SysClientVo> queryPageList(SysClientBo bo, PageQuery pageQuery) {
|
public TableDataInfo<SysClientVo> queryPageList(SysClientBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<SysClient> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<SysClient> lqw = buildQueryWrapper(bo);
|
||||||
Page<SysClientVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<SysClientVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
result.getRecords().forEach(r -> r.setGrantTypeList(List.of(r.getGrantType().split(","))));
|
result.getRecords().forEach(r -> r.setGrantTypeList(StringUtils.splitList(r.getGrantType())));
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +92,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(SysClientBo bo) {
|
public Boolean insertByBo(SysClientBo bo) {
|
||||||
SysClient add = MapstructUtils.convert(bo, SysClient.class);
|
SysClient add = MapstructUtils.convert(bo, SysClient.class);
|
||||||
validEntityBeforeSave(add);
|
add.setGrantType(CollUtil.join(bo.getGrantTypeList(), StringUtils.SEPARATOR));
|
||||||
add.setGrantType(String.join(",", bo.getGrantTypeList()));
|
|
||||||
// 生成clientId
|
// 生成clientId
|
||||||
String clientKey = bo.getClientKey();
|
String clientKey = bo.getClientKey();
|
||||||
String clientSecret = bo.getClientSecret();
|
String clientSecret = bo.getClientSecret();
|
||||||
@@ -112,7 +111,6 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean updateByBo(SysClientBo bo) {
|
public Boolean updateByBo(SysClientBo bo) {
|
||||||
SysClient update = MapstructUtils.convert(bo, SysClient.class);
|
SysClient update = MapstructUtils.convert(bo, SysClient.class);
|
||||||
validEntityBeforeSave(update);
|
|
||||||
update.setGrantType(String.join(",", bo.getGrantTypeList()));
|
update.setGrantType(String.join(",", bo.getGrantTypeList()));
|
||||||
return baseMapper.updateById(update) > 0;
|
return baseMapper.updateById(update) > 0;
|
||||||
}
|
}
|
||||||
@@ -129,22 +127,12 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
.eq(SysClient::getClientId, clientId));
|
.eq(SysClient::getClientId, clientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存前的数据校验
|
|
||||||
*/
|
|
||||||
private void validEntityBeforeSave(SysClient entity) {
|
|
||||||
//TODO 做一些数据校验,如唯一约束
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除客户端管理
|
* 批量删除客户端管理
|
||||||
*/
|
*/
|
||||||
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, allEntries = true)
|
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, allEntries = true)
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if (isValid) {
|
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
|
||||||
}
|
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package org.dromara.system.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -26,7 +25,6 @@ import org.springframework.cache.annotation.CachePut;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -55,7 +53,6 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||||||
* @return 参数配置信息
|
* @return 参数配置信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DS("master")
|
|
||||||
public SysConfigVo selectConfigById(Long configId) {
|
public SysConfigVo selectConfigById(Long configId) {
|
||||||
return baseMapper.selectVoById(configId);
|
return baseMapper.selectVoById(configId);
|
||||||
}
|
}
|
||||||
@@ -81,14 +78,10 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean selectRegisterEnabled(String tenantId) {
|
public boolean selectRegisterEnabled(String tenantId) {
|
||||||
SysConfig retConfig = TenantHelper.dynamic(tenantId, () -> {
|
String configValue = TenantHelper.dynamic(tenantId, () ->
|
||||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
this.selectConfigByKey("sys.account.registerUser")
|
||||||
.eq(SysConfig::getConfigKey, "sys.account.registerUser"));
|
);
|
||||||
});
|
return Convert.toBool(configValue);
|
||||||
if (ObjectUtil.isNull(retConfig)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Convert.toBool(retConfig.getConfigValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,15 +159,15 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||||||
* @param configIds 需要删除的参数ID
|
* @param configIds 需要删除的参数ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteConfigByIds(Long[] configIds) {
|
public void deleteConfigByIds(List<Long> configIds) {
|
||||||
for (Long configId : configIds) {
|
List<SysConfig> list = baseMapper.selectByIds(configIds);
|
||||||
SysConfig config = baseMapper.selectById(configId);
|
list.forEach(config -> {
|
||||||
if (StringUtils.equals(SystemConstants.YES, config.getConfigType())) {
|
if (StringUtils.equals(SystemConstants.YES, config.getConfigType())) {
|
||||||
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
throw new ServiceException(String.format("内置参数【%s】不能删除", config.getConfigKey()));
|
||||||
}
|
}
|
||||||
CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey());
|
CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey());
|
||||||
}
|
});
|
||||||
baseMapper.deleteByIds(Arrays.asList(configIds));
|
baseMapper.deleteByIds(configIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,12 +186,10 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkConfigKeyUnique(SysConfigBo config) {
|
public boolean checkConfigKeyUnique(SysConfigBo config) {
|
||||||
long configId = ObjectUtils.notNull(config.getConfigId(), -1L);
|
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysConfig>()
|
||||||
SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey()));
|
.eq(SysConfig::getConfigKey, config.getConfigKey())
|
||||||
if (ObjectUtil.isNotNull(info) && info.getConfigId() != configId) {
|
.ne(ObjectUtil.isNotNull(config.getConfigId()), SysConfig::getConfigId, config.getConfigId()));
|
||||||
return false;
|
return !exist;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -96,10 +96,8 @@ public class FlwDefinitionServiceImpl implements IFlwDefinitionService {
|
|||||||
LambdaQueryWrapper<FlowDefinition> wrapper = buildQueryWrapper(flowDefinition);
|
LambdaQueryWrapper<FlowDefinition> wrapper = buildQueryWrapper(flowDefinition);
|
||||||
wrapper.in(FlowDefinition::getIsPublish, Arrays.asList(PublishStatus.UNPUBLISHED.getKey(), PublishStatus.EXPIRED.getKey()));
|
wrapper.in(FlowDefinition::getIsPublish, Arrays.asList(PublishStatus.UNPUBLISHED.getKey(), PublishStatus.EXPIRED.getKey()));
|
||||||
Page<FlowDefinition> page = flowDefinitionMapper.selectPage(pageQuery.build(), wrapper);
|
Page<FlowDefinition> page = flowDefinitionMapper.selectPage(pageQuery.build(), wrapper);
|
||||||
TableDataInfo<FlowDefinitionVo> build = TableDataInfo.build();
|
List<FlowDefinitionVo> list = BeanUtil.copyToList(page.getRecords(), FlowDefinitionVo.class);
|
||||||
build.setRows(BeanUtil.copyToList(page.getRecords(), FlowDefinitionVo.class));
|
return new TableDataInfo<>(list, page.getTotal());
|
||||||
build.setTotal(page.getTotal());
|
|
||||||
return build;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<FlowDefinition> buildQueryWrapper(FlowDefinition flowDefinition) {
|
private LambdaQueryWrapper<FlowDefinition> buildQueryWrapper(FlowDefinition flowDefinition) {
|
||||||
|
Reference in New Issue
Block a user