This commit is contained in:
2023-06-21 17:16:46 +08:00
parent 44fb832e64
commit 48001595d2
28 changed files with 201 additions and 79 deletions

View File

@ -1,9 +1,8 @@
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 com.qiaoba.common.database.annotations.SelectOneRow;
import java.util.List;
@ -19,11 +18,11 @@ public interface SysConfigMapper extends BaseMapper<SysConfig> {
/**
* 校验参数键名是否唯一
*
* @param page 分页信息
* @param sysConfig 参数配置信息
* @return 结果
*/
String checkKeyIsExist(Page page, @Param("sysConfig") SysConfig sysConfig);
@SelectOneRow
String checkKeyIsExist(SysConfig sysConfig);
/**
* 通过主键批量查询列表

View File

@ -2,6 +2,7 @@ package com.qiaoba.module.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiaoba.api.system.entity.SysDept;
import com.qiaoba.common.database.annotations.SelectOneRow;
import java.util.List;
@ -20,6 +21,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
* @param dept 部门信息
* @return 结果
*/
@SelectOneRow
int checkDeptNameUnique(SysDept dept);
/**
@ -36,6 +38,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
* @param deptId deptId
* @return != null -> 是
*/
@SelectOneRow
String existChild(String deptId);
/**
@ -44,6 +47,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
* @param deptId deptId
* @return != null -> 是
*/
@SelectOneRow
String existUsed(String deptId);
}

View File

@ -2,7 +2,15 @@ package com.qiaoba.module.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiaoba.api.system.entity.SysDictData;
import com.qiaoba.common.database.annotations.SelectOneRow;
/**
* 字典数据管理 数据层
*
* @author ailanyin
* @version 1.0
* @since 2022-09-22 04:20:28
*/
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
/**
@ -11,6 +19,7 @@ public interface SysDictDataMapper extends BaseMapper<SysDictData> {
* @param sysDictData sysDictData
* @return 已存在的值
*/
@SelectOneRow
String checkDictLabelUnique(SysDictData sysDictData);
/**
@ -19,5 +28,6 @@ public interface SysDictDataMapper extends BaseMapper<SysDictData> {
* @param sysDictData sysDictData
* @return 已存在的值
*/
@SelectOneRow
String checkDictValueUnique(SysDictData sysDictData);
}

View File

@ -1,9 +1,8 @@
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;
import com.qiaoba.common.database.annotations.SelectOneRow;
import java.util.List;
@ -19,18 +18,18 @@ public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
/**
* 校验字典类型是否唯一
*
* @param page 分页参数
* @param sysDictType 字典类型
* @return dictType
*/
String checkDictTypeUnique(Page page, @Param("sysDictType") SysDictType sysDictType);
@SelectOneRow
String checkDictTypeUnique(SysDictType sysDictType);
/**
* 校验是否允许删除
*
* @param page 分页参数
* @param ids ids
* @param ids ids
* @return typeName
*/
String checkAllowDelete(Page page, @Param("list") List<String> ids);
@SelectOneRow
String checkAllowDelete(List<String> ids);
}

View File

@ -2,6 +2,7 @@ package com.qiaoba.module.system.mapper;
import com.qiaoba.api.system.entity.SysMenu;
import com.qiaoba.api.system.entity.vo.SysMenuVo;
import com.qiaoba.common.database.annotations.SelectOneRow;
import com.qiaoba.common.database.mapper.BaseMapperPlus;
import java.util.List;
@ -22,6 +23,7 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, Sy
* @param sysMenu 菜单
* @return count
*/
@SelectOneRow
String checkMenuNameUnique(SysMenu sysMenu);
/**
@ -30,6 +32,7 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, Sy
* @param menuId menuId
* @return != null -> 是
*/
@SelectOneRow
String existChild(String menuId);
/**
@ -38,6 +41,7 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, Sy
* @param menuId menuId
* @return 绑定的角色名称
*/
@SelectOneRow
String existUsed(String menuId);
/**

View File

@ -2,6 +2,7 @@ package com.qiaoba.module.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiaoba.api.system.entity.SysPost;
import com.qiaoba.common.database.annotations.SelectOneRow;
/**
* 岗位管理 数据层
@ -18,6 +19,7 @@ public interface SysPostMapper extends BaseMapper<SysPost> {
* @param sysPost 岗位名称
* @return 结果
*/
@SelectOneRow
String checkPostNameUnique(SysPost sysPost);
/**
@ -26,6 +28,7 @@ public interface SysPostMapper extends BaseMapper<SysPost> {
* @param sysPost 岗位编码
* @return 结果
*/
@SelectOneRow
String checkPostCodeUnique(SysPost sysPost);
}

View File

@ -2,6 +2,7 @@ package com.qiaoba.module.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiaoba.api.system.entity.SysRole;
import com.qiaoba.common.database.annotations.SelectOneRow;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -21,6 +22,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
* @param role role
* @return != null -> 不唯一
*/
@SelectOneRow
String checkRoleNameUnique(SysRole role);
/**
@ -29,6 +31,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
* @param role role
* @return != null -> 不唯一
*/
@SelectOneRow
String checkRoleKeyUnique(SysRole role);
/**
@ -37,6 +40,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
* @param ids ids
* @return 已绑定的人名
*/
@SelectOneRow
String selectBindUserByRoleId(@Param("list") List<String> ids);
/**

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qiaoba.api.system.entity.SysUser;
import com.qiaoba.api.system.entity.param.SysUserParam;
import com.qiaoba.api.system.entity.vo.SysUserVo;
import com.qiaoba.common.database.annotations.SelectOneRow;
import com.qiaoba.module.system.templates.SysUserExport;
import org.apache.ibatis.annotations.Param;
@ -25,6 +26,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @param sysUser sysUser
* @return count
*/
@SelectOneRow
int checkUsernameUnique(SysUser sysUser);
/**
@ -33,6 +35,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @param sysUser sysUser
* @return count
*/
@SelectOneRow
int checkPhoneUnique(SysUser sysUser);
/**
@ -41,6 +44,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @param sysUser sysUser
* @return count
*/
@SelectOneRow
int checkEmailUnique(SysUser sysUser);
/**

View File

@ -130,7 +130,7 @@ public class SysConfigServiceImpl implements SysConfigService {
}
private void checkKeyIsExist(SysConfig sysConfig) {
if (StrUtil.isNotBlank(sysConfigMapper.checkKeyIsExist(PageQuery.limit1(), sysConfig))) {
if (StrUtil.isNotBlank(sysConfigMapper.checkKeyIsExist(sysConfig))) {
throw new ServiceException(ConfigErrorCode.KEY_EXIST.getCode(), ConfigErrorCode.KEY_EXIST.getMsg());
}
}

View File

@ -69,14 +69,14 @@ public class SysDictTypeServiceImpl implements SysDictTypeService {
private void checkAllowInsertOrUpdate(SysDictType sysDictType) {
String dictType = sysDictTypeMapper.checkDictTypeUnique(PageQuery.limit1(), sysDictType);
String dictType = sysDictTypeMapper.checkDictTypeUnique(sysDictType);
if (StrUtil.isNotBlank(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(PageQuery.limit1(), ids);
String typeName = sysDictTypeMapper.checkAllowDelete(ids);
if (StrUtil.isNotBlank(typeName)) {
throw new ServiceException(DictErrorCode.HAS_DATA.getCode(), StrUtil.format(DictErrorCode.HAS_DATA.getMsg(), typeName));
}

View File

@ -5,9 +5,9 @@
<mapper namespace="com.qiaoba.module.system.mapper.SysConfigMapper">
<select id="checkKeyIsExist" resultType="string">
select config_key from sys_config
where config_key = #{sysConfig.configKey}
<if test="sysConfig.configId !=null">
and config_id != #{sysConfig.configId}
where config_key = #{configKey}
<if test="configId !=null">
and config_id != #{configId}
</if>
</select>

View File

@ -8,7 +8,6 @@
select count(1) from sys_dept
where dept_name = #{deptName} and parent_id = #{parentId}
<if test="deptId != null and deptId != ''">and dept_id != #{deptId}</if>
limit 1
</select>
<select id="selectDeptIdsByRoleId" resultType="string">
@ -20,11 +19,11 @@
</select>
<select id="existChild" resultType="string">
SELECT dept_id FROM sys_dept where parent_id = #{deptId} LIMIT 1
SELECT dept_id FROM sys_dept where parent_id = #{deptId}
</select>
<select id="existUsed" resultType="string">
SELECT nickname from sys_user where dept_id = #{deptId} limit 1
SELECT nickname from sys_user where dept_id = #{deptId}
</select>
</mapper>

View File

@ -9,7 +9,6 @@
<if test="dictCode != null and dictCode != ''">
and dict_code != #{dictCode}
</if>
limit 1
</select>
<select id="checkDictValueUnique" resultType="string">
@ -17,6 +16,5 @@
<if test="dictCode != null and dictCode != ''">
and dict_code != #{dictCode}
</if>
limit 1
</select>
</mapper>

View File

@ -6,9 +6,9 @@
<select id="checkDictTypeUnique" resultType="string">
select dict_type from sys_dict_type
where dict_type = #{sysDictType.dictType}
<if test="sysDictType.dictId != null and sysDictType.dictId != ''">
and dict_id != #{sysDictType.dictId}
where dict_type = #{dictType}
<if test="dictId != null and dictId != ''">
and dict_id != #{dictId}
</if>
</select>

View File

@ -13,7 +13,7 @@
</select>
<select id="existChild" resultType="string">
select menu_id from sys_menu where parent_id = #{menuId} limit 1
select menu_id from sys_menu where parent_id = #{menuId}
</select>
<select id="existUsed" resultType="string">
@ -21,7 +21,7 @@
FROM sys_role_menu t1
left join sys_role t2
on t1.role_id = t2.role_id
where t1.menu_id = #{menuId} limit 1
where t1.menu_id = #{menuId}
</select>
<select id="selectMenuIdsByRoleId" resultType="string">

View File

@ -10,7 +10,6 @@
<if test="postId != null and postId != ''">
and post_id != #{postId}
</if>
limit 1
</select>
<select id="checkPostCodeUnique" resultType="string">
@ -19,7 +18,6 @@
<if test="postId != null and postId != ''">
and post_id != #{postId}
</if>
limit 1
</select>
</mapper>

View File

@ -10,7 +10,6 @@
<if test="roleId != null and roleId != 0">
and role_id != #{roleId}
</if>
limit 1
</select>
<select id="checkRoleKeyUnique" parameterType="String" resultType="string">
@ -19,7 +18,6 @@
<if test="roleId != null and roleId != 0">
and role_id != #{roleId}
</if>
limit 1
</select>
<select id="selectBindUserByRoleId" resultType="string">
@ -31,6 +29,5 @@
<foreach collection="list" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
LIMIT 1
</select>
</mapper>

View File

@ -150,19 +150,16 @@
<select id="checkUsernameUnique" resultType="int">
select count(*) from sys_user where username = #{username}
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
limit 1
</select>
<select id="checkPhoneUnique" resultType="int">
select count(*) from sys_user where phone = #{phone}
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
limit 1
</select>
<select id="checkEmailUnique" resultType="int">
select count(*) from sys_user where email = #{email}
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
limit 1
</select>
</mapper>