first commit
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package com.qiaoba.module.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.qiaoba.api.system.entity.SysConfig;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -17,10 +19,11 @@ public interface SysConfigMapper extends BaseMapper<SysConfig> {
|
||||
/**
|
||||
* 校验参数键名是否唯一
|
||||
*
|
||||
* @param page 分页信息
|
||||
* @param sysConfig 参数配置信息
|
||||
* @return 结果
|
||||
*/
|
||||
String checkKeyIsExist(SysConfig sysConfig);
|
||||
String checkKeyIsExist(Page page, @Param("sysConfig") SysConfig sysConfig);
|
||||
|
||||
/**
|
||||
* 通过主键批量查询列表
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.qiaoba.module.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.qiaoba.api.system.entity.SysDictType;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -18,16 +19,18 @@ public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
|
||||
/**
|
||||
* 校验字典类型是否唯一
|
||||
*
|
||||
* @param dict 字典类型
|
||||
* @param page 分页参数
|
||||
* @param sysDictType 字典类型
|
||||
* @return dictType
|
||||
*/
|
||||
String checkDictTypeUnique(SysDictType dict);
|
||||
String checkDictTypeUnique(Page page, @Param("sysDictType") SysDictType sysDictType);
|
||||
|
||||
/**
|
||||
* 校验是否允许删除
|
||||
*
|
||||
* @param ids ids
|
||||
* @param page 分页参数
|
||||
* @param ids ids
|
||||
* @return typeName
|
||||
*/
|
||||
String checkAllowDelete(@Param("list") List<String> ids);
|
||||
String checkAllowDelete(Page page, @Param("list") List<String> ids);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.qiaoba.api.system.entity.SysConfig;
|
||||
import com.qiaoba.api.system.entity.param.SysConfigParam;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.code.ConfigErrorCode;
|
||||
import com.qiaoba.common.base.constants.BaseConstant;
|
||||
import com.qiaoba.common.base.constants.ConfigConstant;
|
||||
import com.qiaoba.common.base.exceptions.ServiceException;
|
||||
@ -78,7 +79,7 @@ public class SysConfigServiceImpl implements SysConfigService {
|
||||
return BaseConstant.HANDLE_ERROR;
|
||||
}
|
||||
if (BaseConstant.YES.equals(sysConfig.getConfigType())) {
|
||||
throw new ServiceException("系统内置不允许删除!");
|
||||
throw new ServiceException(ConfigErrorCode.SYS_NOT_ALLOW_DELETE.getCode(), ConfigErrorCode.SYS_NOT_ALLOW_DELETE.getMsg());
|
||||
}
|
||||
redisService.del(ConfigConstant.SYS_CONFIG_KEY_PREFIX + sysConfig.getConfigKey());
|
||||
return sysConfigMapper.deleteById(configId);
|
||||
@ -93,7 +94,7 @@ public class SysConfigServiceImpl implements SysConfigService {
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
for (SysConfig config : configs) {
|
||||
if (BaseConstant.YES.equals(config.getConfigType())) {
|
||||
throw new ServiceException("系统内置不允许删除!");
|
||||
throw new ServiceException(ConfigErrorCode.SYS_NOT_ALLOW_DELETE.getCode(), ConfigErrorCode.SYS_NOT_ALLOW_DELETE.getMsg());
|
||||
}
|
||||
delKeys.add(ConfigConstant.SYS_CONFIG_KEY_PREFIX + config.getConfigKey());
|
||||
}
|
||||
@ -129,8 +130,8 @@ public class SysConfigServiceImpl implements SysConfigService {
|
||||
}
|
||||
|
||||
private void checkKeyIsExist(SysConfig sysConfig) {
|
||||
if (StrUtil.isNotBlank(sysConfigMapper.checkKeyIsExist(sysConfig))) {
|
||||
throw new ServiceException("参数Key已存在, 操作失败!");
|
||||
if (StrUtil.isNotBlank(sysConfigMapper.checkKeyIsExist(PageQuery.limit1(), sysConfig))) {
|
||||
throw new ServiceException(ConfigErrorCode.KEY_EXIST.getCode(), ConfigErrorCode.KEY_EXIST.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.qiaoba.api.system.entity.SysDictType;
|
||||
import com.qiaoba.api.system.entity.param.SysDictTypeParam;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.code.DictErrorCode;
|
||||
import com.qiaoba.common.base.exceptions.ServiceException;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
import com.qiaoba.common.redis.service.RedisService;
|
||||
import com.qiaoba.module.system.mapper.SysDictTypeMapper;
|
||||
import com.qiaoba.module.system.service.SysDictTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -29,8 +29,6 @@ import java.util.List;
|
||||
public class SysDictTypeServiceImpl implements SysDictTypeService {
|
||||
|
||||
private final SysDictTypeMapper sysDictTypeMapper;
|
||||
private final RedisService redisService;
|
||||
|
||||
|
||||
@Override
|
||||
public int insert(SysDictType sysDictType) {
|
||||
@ -71,16 +69,16 @@ public class SysDictTypeServiceImpl implements SysDictTypeService {
|
||||
|
||||
|
||||
private void checkAllowInsertOrUpdate(SysDictType sysDictType) {
|
||||
String dictType = sysDictTypeMapper.checkDictTypeUnique(sysDictType);
|
||||
String dictType = sysDictTypeMapper.checkDictTypeUnique(PageQuery.limit1(), sysDictType);
|
||||
if (StrUtil.isNotBlank(dictType)) {
|
||||
throw new ServiceException(StrUtil.format("类型[{}]已存在, 不允许新增或修改", dictType));
|
||||
throw new ServiceException(DictErrorCode.TYPE_EXIST.getCode(), StrUtil.format(DictErrorCode.TYPE_EXIST.getMsg(), dictType));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAllowDelete(List<String> ids) {
|
||||
String typeName = sysDictTypeMapper.checkAllowDelete(ids);
|
||||
String typeName = sysDictTypeMapper.checkAllowDelete(PageQuery.limit1(), ids);
|
||||
if (StrUtil.isNotBlank(typeName)) {
|
||||
throw new ServiceException(StrUtil.format("字典[{}]已绑定数据, 请解绑后删除", typeName));
|
||||
throw new ServiceException(DictErrorCode.HAS_DATA.getCode(), StrUtil.format(DictErrorCode.HAS_DATA.getMsg(), typeName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,10 @@
|
||||
<mapper namespace="com.qiaoba.module.system.mapper.SysConfigMapper">
|
||||
<select id="checkKeyIsExist" resultType="string">
|
||||
select config_key from sys_config
|
||||
where config_key = #{configKey}
|
||||
<if test="configId !=null">
|
||||
and config_id != #{configId}
|
||||
where config_key = #{sysConfig.configKey}
|
||||
<if test="sysConfig.configId !=null">
|
||||
and config_id != #{sysConfig.configId}
|
||||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="com.qiaoba.api.system.entity.SysConfig">
|
||||
|
@ -6,11 +6,10 @@
|
||||
|
||||
<select id="checkDictTypeUnique" resultType="string">
|
||||
select dict_type from sys_dict_type
|
||||
where dict_type = #{dictType}
|
||||
<if test="dictId != null and dictId != ''">
|
||||
and dict_id != #{dictId}
|
||||
where dict_type = #{sysDictType.dictType}
|
||||
<if test="sysDictType.dictId != null and sysDictType.dictId != ''">
|
||||
and dict_id != #{sysDictType.dictId}
|
||||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkAllowDelete" resultType="string">
|
||||
@ -20,6 +19,6 @@
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and t2.dict_code is not null limit 1
|
||||
and t2.dict_code is not null
|
||||
</select>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user