first commit
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
UPDATE sys_dept set tenant_id = '2';
|
||||
UPDATE sys_menu set tenant_id = '2';
|
||||
UPDATE sys_post set tenant_id = '2';
|
||||
UPDATE sys_role set tenant_id = '2';
|
||||
UPDATE sys_user set tenant_id = '2';
|
||||
UPDATE sys_config set tenant_id = '2';
|
||||
UPDATE sys_login_log set tenant_id = '2';
|
||||
UPDATE sys_role_dept set tenant_id = '2';
|
||||
UPDATE sys_role_menu set tenant_id = '2';
|
||||
UPDATE sys_user_post set tenant_id = '2';
|
||||
UPDATE sys_user_role set tenant_id = '2';
|
||||
UPDATE sys_dict_data set tenant_id = '2';
|
||||
UPDATE sys_dict_type set tenant_id = '2';
|
||||
UPDATE sys_dept set tenant_id = '1';
|
||||
UPDATE sys_menu set tenant_id = '1';
|
||||
UPDATE sys_post set tenant_id = '1';
|
||||
UPDATE sys_role set tenant_id = '1';
|
||||
UPDATE sys_user set tenant_id = '1';
|
||||
UPDATE sys_config set tenant_id = '1';
|
||||
UPDATE sys_login_log set tenant_id = '1';
|
||||
UPDATE sys_role_dept set tenant_id = '1';
|
||||
UPDATE sys_role_menu set tenant_id = '1';
|
||||
UPDATE sys_user_post set tenant_id = '1';
|
||||
UPDATE sys_user_role set tenant_id = '1';
|
||||
UPDATE sys_dict_data set tenant_id = '1';
|
||||
UPDATE sys_dict_type set tenant_id = '1';
|
@ -33,7 +33,7 @@ mybatis-plus:
|
||||
# MyBatis 自动映射时未知列或未知属性处理策
|
||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||
autoMappingUnknownColumnBehavior: NONE
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.qiaoba.common.base.code;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 系统配置错误code
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/6/12 13:34
|
||||
*/
|
||||
@Getter
|
||||
public enum ConfigErrorCode {
|
||||
|
||||
/**
|
||||
* 系统内置-禁止删除
|
||||
*/
|
||||
SYS_NOT_ALLOW_DELETE(5020, "系统内置不允许删除!"),
|
||||
|
||||
/**
|
||||
* Key已存在
|
||||
*/
|
||||
KEY_EXIST(5021, "参数键名已存在, 操作失败!");
|
||||
|
||||
private final Integer code;
|
||||
private final String msg;
|
||||
|
||||
ConfigErrorCode(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.qiaoba.common.base.code;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 字典错误code
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/6/12 13:34
|
||||
*/
|
||||
@Getter
|
||||
public enum DictErrorCode {
|
||||
|
||||
/**
|
||||
* 类型已存在
|
||||
*/
|
||||
TYPE_EXIST(5030, "类型[{}]已存在, 不允许新增或修改!"),
|
||||
|
||||
/**
|
||||
* 存在数据
|
||||
*/
|
||||
HAS_DATA(5031, "字典[{}]已绑定数据, 请解绑后删除!");
|
||||
|
||||
private final Integer code;
|
||||
private final String msg;
|
||||
|
||||
DictErrorCode(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
@ -9,9 +9,10 @@ import java.io.Serializable;
|
||||
/**
|
||||
* 分页查询实体类
|
||||
*
|
||||
* @author Lion Li
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023-04-23 20:33:43
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class PageQuery implements Serializable {
|
||||
|
||||
@ -46,4 +47,12 @@ public class PageQuery implements Serializable {
|
||||
return new Page<>(pageNum, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只查第一条数据
|
||||
*
|
||||
* @return page
|
||||
*/
|
||||
public static Page limit1() {
|
||||
return new Page<>(1, 1);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.qiaoba.common.database.monitor;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.qiaoba.common.base.constants.TenantConstant;
|
||||
import com.qiaoba.common.base.context.BaseContext;
|
||||
import com.qiaoba.common.base.enums.DataBaseEnum;
|
||||
import com.qiaoba.common.database.config.DynamicDataSourceConfig;
|
||||
import com.qiaoba.common.database.entity.DynamicDataSource;
|
||||
|
@ -43,7 +43,7 @@ public class ExceptionAdvice {
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
@ResponseBody
|
||||
public AjaxResult handlerServiceException(ServiceException e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
return Objects.isNull(e.getErrorCode()) ? AjaxResult.error(e.getMessage()) : AjaxResult.error(e.getErrorCode(), e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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