fix: 为mapper加上and,修改部分代码生成器

This commit is contained in:
bunny 2024-10-11 16:47:15 +08:00
parent 955cc4aa65
commit 31b9bd8cb3
20 changed files with 201 additions and 75 deletions

View File

@ -22,7 +22,7 @@
<where> <where>
#foreach($field in $pageQueryMap) #foreach($field in $pageQueryMap)
<if test="dto.${field.property} != null and dto.${field.property} != ''"> <if test="dto.${field.property} != null and dto.${field.property} != ''">
$field.column like CONCAT('%',#{dto.${field.property}},'%') and $field.column like CONCAT('%',#{dto.${field.property}},'%')
</if> </if>
#end #end
</where> </where>

View File

@ -8,6 +8,8 @@ import type { FormItemProps } from '${typesPath}';
import { $t } from '@/plugins/i18n'; import { $t } from '@/plugins/i18n';
export const formRef = ref(); export const formRef = ref();
// 删除ids
export const deleteIds = ref([]);
const ${lowercaseName}Store = use${originalName}Store(); const ${lowercaseName}Store = use${originalName}Store();
/** /**
@ -103,3 +105,23 @@ export const onDelete = async (row: any) => {
await ${lowercaseName}Store.delete${originalName}([id]); await ${lowercaseName}Store.delete${originalName}([id]);
await onSearch(); await onSearch();
}; };
/**
* 批量删除
*/
export const onDeleteBatch = async () => {
const ids = deleteIds.value;
// 是否确认删除
const result = await messageBox({
title: $t('confirm_delete'),
showMessage: false,
confirmMessage: undefined,
cancelMessage: $t('cancel_delete'),
});
if (!result) return;
// 删除数据
await ${lowercaseName}Store.delete${originalName}(ids);
await onSearch();
};

View File

@ -4,7 +4,7 @@
import PureTableBar from '@/components/TableBar/src/bar'; import PureTableBar from '@/components/TableBar/src/bar';
import AddFill from '@iconify-icons/ri/add-circle-line'; import AddFill from '@iconify-icons/ri/add-circle-line';
import PureTable from '@pureadmin/table'; import PureTable from '@pureadmin/table';
import { onAdd, onDelete, onSearch, onUpdate } from '${hookPath}'; import { onAdd, onDelete, onSearch, onUpdate, deleteIds } from '${hookPath}';
import Delete from '@iconify-icons/ep/delete'; import Delete from '@iconify-icons/ep/delete';
import EditPen from '@iconify-icons/ep/edit-pen'; import EditPen from '@iconify-icons/ep/edit-pen';
import Refresh from '@iconify-icons/ep/refresh'; import Refresh from '@iconify-icons/ep/refresh';
@ -34,19 +34,27 @@
await onSearch(); await onSearch();
}; };
/**
* * 选择多行
* @param rows
*/
const onSelectionChange = (rows: Array<any>) => {
deleteIds.value = rows.map((row: any) => row.id);
};
/** /**
* 重置表单 * 重置表单
* @param formEl * @param formEl
*/ */
const resetForm = async formEl => { const resetForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return; if (!formEl) return;
formEl.resetFields(); formEl.resetFields();
await onSearch(); await onSearch();
}; };
onMounted(() => { onMounted(() => {
onSearch(); onSearch();
}); });
</script> </script>
<template> <template>
@ -66,6 +74,11 @@
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch"> <PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
<template #buttons> <template #buttons>
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button> <el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
<!-- 批量删除按钮 -->
<el-button v-show="deleteIds.length > 0" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
{{ $t('delete_batches') }}
</el-button>
</template> </template>
<template v-slot="{ size, dynamicColumns }"> <template v-slot="{ size, dynamicColumns }">

View File

@ -41,8 +41,16 @@ public class GlobalExceptionHandler {
// 解析异常 // 解析异常
String jsonParseError = "JSON parse error (.*)"; String jsonParseError = "JSON parse error (.*)";
Matcher jsonParseErrorMatcher = Pattern.compile(jsonParseError).matcher(message); Matcher jsonParseErrorMatcher = Pattern.compile(jsonParseError).matcher(message);
if (jsonParseErrorMatcher.find()) if (jsonParseErrorMatcher.find()) {
return Result.error(null, 500, "JSON解析异常 " + jsonParseErrorMatcher.group(1)); return Result.error(null, 500, "JSON解析异常 " + jsonParseErrorMatcher.group(1));
}
// 数据过大
String dataTooLongError = "Data too long for column (.*?) at row 1";
Matcher dataTooLongErrorMatcher = Pattern.compile(dataTooLongError).matcher(message);
if (dataTooLongErrorMatcher.find()) {
return Result.error(null, 500, dataTooLongErrorMatcher.group(1) + " 字段数据过大");
}
return Result.error(null, 500, "服务器异常"); return Result.error(null, 500, "服务器异常");
} }

View File

@ -31,6 +31,7 @@ public enum ResultCodeEnum {
EMAIL_CODE_EMPTY(201, "邮箱验证码过期或不存在"), EMAIL_CODE_EMPTY(201, "邮箱验证码过期或不存在"),
DATA_EXIST(201, "数据已存在"), DATA_EXIST(201, "数据已存在"),
DATA_NOT_EXIST(201, "数据不存在"), DATA_NOT_EXIST(201, "数据不存在"),
EMAIL_EXIST(201, "邮箱已存在"),
REQUEST_IS_EMPTY(201, "请求数据为空"), REQUEST_IS_EMPTY(201, "请求数据为空"),
DATA_TOO_LARGE(201, "请求数据为空"), DATA_TOO_LARGE(201, "请求数据为空"),
USER_IS_EMPTY(201, "用户不存在"), USER_IS_EMPTY(201, "用户不存在"),

View File

@ -66,9 +66,9 @@ public class EmailUsersController {
@Operation(summary = "更新邮箱用户状态", description = "更新邮箱用户状态") @Operation(summary = "更新邮箱用户状态", description = "更新邮箱用户状态")
@PutMapping("updateEmailUserStatus") @PutMapping("updateEmailUserStatus")
public Mono<Result<String>> updateEmailUserStatus(@Valid @RequestBody EmailUserUpdateStatusDto dto) { public Result<String> updateEmailUserStatus(@Valid @RequestBody EmailUserUpdateStatusDto dto) {
emailUsersService.updateEmailUserStatus(dto); emailUsersService.updateEmailUserStatus(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS)); return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
} }
@Operation(summary = "删除邮箱用户发送配置", description = "删除邮箱用户发送配置") @Operation(summary = "删除邮箱用户发送配置", description = "删除邮箱用户发送配置")

View File

@ -3,23 +3,30 @@ package cn.bunny.services.factory;
import cn.bunny.common.service.exception.BunnyException; import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.utils.mail.MailSenderUtil; import cn.bunny.common.service.utils.mail.MailSenderUtil;
import cn.bunny.dao.entity.system.EmailTemplate; import cn.bunny.dao.entity.system.EmailTemplate;
import cn.bunny.dao.entity.system.EmailUsers;
import cn.bunny.dao.pojo.common.EmailSend; import cn.bunny.dao.pojo.common.EmailSend;
import cn.bunny.dao.pojo.common.EmailSendInit; import cn.bunny.dao.pojo.common.EmailSendInit;
import cn.bunny.dao.pojo.common.EmailTemplateTypes; import cn.bunny.dao.pojo.common.EmailTemplateTypes;
import cn.bunny.dao.pojo.result.ResultCodeEnum; import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.services.mapper.EmailTemplateMapper; import cn.bunny.services.mapper.EmailTemplateMapper;
import cn.bunny.services.mapper.EmailUsersMapper;
import cn.hutool.captcha.CaptchaUtil; import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha; import cn.hutool.captcha.CircleCaptcha;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.mail.MessagingException; import jakarta.mail.MessagingException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class EmailFactory { public class EmailFactory {
@Autowired @Autowired
private EmailTemplateMapper emailTemplateMapper; private EmailTemplateMapper emailTemplateMapper;
@Autowired
private EmailUsersMapper emailUsersMapper;
/** /**
* 生成邮箱验证码 * 生成邮箱验证码
* *
@ -58,4 +65,18 @@ public class EmailFactory {
return code; return code;
} }
/**
* 判断邮箱是否添加
*
* @param isDefault 邮箱是否为默认
*/
public void updateEmailUserDefault(Boolean isDefault) {
EmailUsers emailUsers = new EmailUsers();
// 判断状态如果是默认将所有的内容都设为false
if (isDefault) {
emailUsers.setIsDefault(false);
emailUsersMapper.update(emailUsers, Wrappers.<EmailUsers>lambdaUpdate().eq(EmailUsers::getIsDefault, true));
}
}
} }

View File

@ -1,20 +1,26 @@
package cn.bunny.services.service.impl; package cn.bunny.services.service.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.system.email.EmailUserUpdateStatusDto; import cn.bunny.dao.dto.system.email.EmailUserUpdateStatusDto;
import cn.bunny.dao.dto.system.email.EmailUsersAddDto; import cn.bunny.dao.dto.system.email.EmailUsersAddDto;
import cn.bunny.dao.dto.system.email.EmailUsersDto; import cn.bunny.dao.dto.system.email.EmailUsersDto;
import cn.bunny.dao.dto.system.email.EmailUsersUpdateDto; import cn.bunny.dao.dto.system.email.EmailUsersUpdateDto;
import cn.bunny.dao.entity.system.EmailUsers; import cn.bunny.dao.entity.system.EmailUsers;
import cn.bunny.dao.pojo.result.PageResult; import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.system.email.EmailUsersVo; import cn.bunny.dao.vo.system.email.EmailUsersVo;
import cn.bunny.services.factory.EmailFactory;
import cn.bunny.services.mapper.EmailUsersMapper; import cn.bunny.services.mapper.EmailUsersMapper;
import cn.bunny.services.service.EmailUsersService; import cn.bunny.services.service.EmailUsersService;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -27,8 +33,12 @@ import java.util.List;
* @since 2024-10-10 15:19:22 * @since 2024-10-10 15:19:22
*/ */
@Service @Service
@Transactional
public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUsers> implements EmailUsersService { public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUsers> implements EmailUsersService {
@Autowired
private EmailFactory emailFactory;
/** /**
* * 邮箱用户发送配置 服务实现类 * * 邮箱用户发送配置 服务实现类
* *
@ -62,12 +72,21 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
*/ */
@Override @Override
public void addEmailUsers(@Valid EmailUsersAddDto dto) { public void addEmailUsers(@Valid EmailUsersAddDto dto) {
// 判断邮箱是否添加
String email = dto.getEmail();
List<EmailUsers> emailUsersList = list(Wrappers.<EmailUsers>lambdaQuery().eq(EmailUsers::getEmail, dto.getEmail()));
if (!emailUsersList.isEmpty()) throw new BunnyException(ResultCodeEnum.EMAIL_EXIST);
// 更新邮箱默认状态
emailFactory.updateEmailUserDefault(dto.getIsDefault());
// 保存数据 // 保存数据
EmailUsers emailUsers = new EmailUsers(); EmailUsers emailUsers = new EmailUsers();
BeanUtils.copyProperties(dto, emailUsers); BeanUtils.copyProperties(dto, emailUsers);
save(emailUsers); save(emailUsers);
} }
/** /**
* 更新邮箱用户发送配置 * 更新邮箱用户发送配置
* *
@ -75,6 +94,9 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
*/ */
@Override @Override
public void updateEmailUsers(@Valid EmailUsersUpdateDto dto) { public void updateEmailUsers(@Valid EmailUsersUpdateDto dto) {
// 更新邮箱默认状态
emailFactory.updateEmailUserDefault(dto.getIsDefault());
// 更新内容 // 更新内容
EmailUsers emailUsers = new EmailUsers(); EmailUsers emailUsers = new EmailUsers();
BeanUtils.copyProperties(dto, emailUsers); BeanUtils.copyProperties(dto, emailUsers);
@ -98,6 +120,9 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
*/ */
@Override @Override
public void updateEmailUserStatus(EmailUserUpdateStatusDto dto) { public void updateEmailUserStatus(EmailUserUpdateStatusDto dto) {
// 更新邮箱默认状态
emailFactory.updateEmailUserDefault(dto.getIsDefault());
EmailUsers emailUsers = new EmailUsers(); EmailUsers emailUsers = new EmailUsers();
BeanUtils.copyProperties(dto, emailUsers); BeanUtils.copyProperties(dto, emailUsers);
updateById(emailUsers); updateById(emailUsers);

View File

@ -6,7 +6,7 @@ management:
web: web:
exposure: exposure:
include: "*" include: "*"
base-path: /actuator base-path: /admin
info: info:
env: env:
enabled: true enabled: true

View File

@ -28,13 +28,13 @@
from sys_dept from sys_dept
<where> <where>
<if test="dto.parentId != null and dto.parentId != ''"> <if test="dto.parentId != null and dto.parentId != ''">
parent_id like CONCAT('%',#{dto.parentId},'%') and parent_id like CONCAT('%',#{dto.parentId},'%')
</if> </if>
<if test="dto.deptName != null and dto.deptName != ''"> <if test="dto.deptName != null and dto.deptName != ''">
dept_name like CONCAT('%',#{dto.deptName},'%') and dept_name like CONCAT('%',#{dto.deptName},'%')
</if> </if>
<if test="dto.summary != null and dto.summary != ''"> <if test="dto.summary != null and dto.summary != ''">
summary like CONCAT('%',#{dto.summary},'%') and summary like CONCAT('%',#{dto.summary},'%')
</if> </if>
</where> </where>
order by update_time order by update_time

View File

@ -29,16 +29,16 @@
from sys_email_template from sys_email_template
<where> <where>
<if test="dto.templateName != null and dto.templateName != ''"> <if test="dto.templateName != null and dto.templateName != ''">
template_name like CONCAT('%',#{dto.templateName},'%') and template_name like CONCAT('%',#{dto.templateName},'%')
</if> </if>
<if test="dto.subject != null and dto.subject != ''"> <if test="dto.subject != null and dto.subject != ''">
subject like CONCAT('%',#{dto.subject},'%') and subject like CONCAT('%',#{dto.subject},'%')
</if> </if>
<if test="dto.body != null and dto.body != ''"> <if test="dto.body != null and dto.body != ''">
body like CONCAT('%',#{dto.body},'%') and body like CONCAT('%',#{dto.body},'%')
</if> </if>
<if test="dto.type != null and dto.type != ''"> <if test="dto.type != null and dto.type != ''">
type like CONCAT('%',#{dto.type},'%') and type like CONCAT('%',#{dto.type},'%')
</if> </if>
</where> </where>
order by update_time desc order by update_time desc

View File

@ -31,22 +31,22 @@
from sys_email_users from sys_email_users
<where> <where>
<if test="dto.email != null and dto.email != ''"> <if test="dto.email != null and dto.email != ''">
email like CONCAT('%',#{dto.email},'%') and email like CONCAT('%',#{dto.email},'%')
</if> </if>
<if test="dto.emailTemplate != null and dto.emailTemplate != ''"> <if test="dto.emailTemplate != null and dto.emailTemplate != ''">
email_template like CONCAT('%',#{dto.emailTemplate},'%') and email_template like CONCAT('%',#{dto.emailTemplate},'%')
</if> </if>
<if test="dto.host != null and dto.host != ''"> <if test="dto.host != null and dto.host != ''">
host like CONCAT('%',#{dto.host},'%') and host like CONCAT('%',#{dto.host},'%')
</if> </if>
<if test="dto.port != null and dto.port != ''"> <if test="dto.port != null and dto.port != ''">
port like CONCAT('%',#{dto.port},'%') and port like CONCAT('%',#{dto.port},'%')
</if> </if>
<if test="dto.smtpAgreement != null and dto.smtpAgreement != ''"> <if test="dto.smtpAgreement != null and dto.smtpAgreement != ''">
smtp_agreement like CONCAT('%',#{dto.smtpAgreement},'%') and smtp_agreement like CONCAT('%',#{dto.smtpAgreement},'%')
</if> </if>
</where> </where>
order by update_time desc order by create_time desc
</select> </select>
<!-- 物理删除邮箱用户发送配置 --> <!-- 物理删除邮箱用户发送配置 -->

View File

@ -24,20 +24,21 @@
<!-- 分页查询系统文件表内容 --> <!-- 分页查询系统文件表内容 -->
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Files"> <select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Files">
select <include refid="Base_Column_List"/> select
<include refid="Base_Column_List"/>
from sys_files from sys_files
<where> <where>
<if test="dto.filename != null and dto.filename != ''"> <if test="dto.filename != null and dto.filename != ''">
filename like CONCAT('%',#{dto.filename},'%') and filename like CONCAT('%',#{dto.filename},'%')
</if> </if>
<if test="dto.filepath != null and dto.filepath != ''"> <if test="dto.filepath != null and dto.filepath != ''">
filepath like CONCAT('%',#{dto.filepath},'%') and filepath like CONCAT('%',#{dto.filepath},'%')
</if> </if>
<if test="dto.fileType != null and dto.fileType != ''"> <if test="dto.fileType != null and dto.fileType != ''">
file_type like CONCAT('%',#{dto.fileType},'%') and file_type like CONCAT('%',#{dto.fileType},'%')
</if> </if>
<if test="dto.downloadCount != null and dto.downloadCount != ''"> <if test="dto.downloadCount != null and dto.downloadCount != ''">
download_count like CONCAT('%',#{dto.downloadCount},'%') and download_count like CONCAT('%',#{dto.downloadCount},'%')
</if> </if>
</where> </where>
order by update_time order by update_time

View File

@ -37,13 +37,13 @@
from sys_i18n from sys_i18n
<where> <where>
<if test="dto.keyName != null and dto.keyName != ''"> <if test="dto.keyName != null and dto.keyName != ''">
key_name like CONCAT('%',#{dto.keyName},'%') and key_name like CONCAT('%',#{dto.keyName},'%')
</if> </if>
<if test="dto.translation != null and dto.translation != ''"> <if test="dto.translation != null and dto.translation != ''">
translation like CONCAT('%',#{dto.translation},'%') and translation like CONCAT('%',#{dto.translation},'%')
</if> </if>
<if test="dto.typeName != null and dto.typeName != ''"> <if test="dto.typeName != null and dto.typeName != ''">
type_name like CONCAT('%',#{dto.typeName},'%') and type_name like CONCAT('%',#{dto.typeName},'%')
</if> </if>
</where> </where>
order by update_time order by update_time

View File

@ -26,10 +26,10 @@
from sys_menu_icon from sys_menu_icon
<where> <where>
<if test="dto.iconCode != null and dto.iconCode != ''"> <if test="dto.iconCode != null and dto.iconCode != ''">
icon_code like CONCAT('%',#{dto.iconCode},'%') and icon_code like CONCAT('%',#{dto.iconCode},'%')
</if> </if>
<if test="dto.iconName != null and dto.iconName != ''"> <if test="dto.iconName != null and dto.iconName != ''">
icon_name like CONCAT('%',#{dto.iconName},'%') and icon_name like CONCAT('%',#{dto.iconName},'%')
</if> </if>
</where> </where>
order by update_time desc order by update_time desc

View File

@ -28,13 +28,13 @@
from sys_power from sys_power
<where> <where>
<if test="dto.powerCode != null and dto.powerCode != ''"> <if test="dto.powerCode != null and dto.powerCode != ''">
power_code like CONCAT('%',#{dto.powerCode},'%') and power_code like CONCAT('%',#{dto.powerCode},'%')
</if> </if>
<if test="dto.powerName != null and dto.powerName != ''"> <if test="dto.powerName != null and dto.powerName != ''">
power_name like CONCAT('%',#{dto.powerName},'%') and power_name like CONCAT('%',#{dto.powerName},'%')
</if> </if>
<if test="dto.requestUrl != null and dto.requestUrl != ''"> <if test="dto.requestUrl != null and dto.requestUrl != ''">
request_url like CONCAT('%',#{dto.requestUrl},'%') and request_url like CONCAT('%',#{dto.requestUrl},'%')
</if> </if>
</where> </where>
order by update_time desc order by update_time desc

View File

@ -26,10 +26,10 @@
from sys_role from sys_role
<where> <where>
<if test="dto.roleCode != null and dto.roleCode != ''"> <if test="dto.roleCode != null and dto.roleCode != ''">
role_code like CONCAT('%',#{dto.roleCode},'%') and role_code like CONCAT('%',#{dto.roleCode},'%')
</if> </if>
<if test="dto.description != null and dto.description != ''"> <if test="dto.description != null and dto.description != ''">
description like CONCAT('%',#{dto.description},'%') and description like CONCAT('%',#{dto.description},'%')
</if> </if>
</where> </where>
order by update_time order by update_time

View File

@ -70,10 +70,10 @@
from sys_router from sys_router
<where> <where>
<if test="dto.title != null and dto.title != ''"> <if test="dto.title != null and dto.title != ''">
title like CONCAT('%',#{dto.title},'%') and title like CONCAT('%',#{dto.title},'%')
</if> </if>
<if test="dto.visible != null"> <if test="dto.visible != null">
visible = #{dto.visible} and visible = #{dto.visible}
</if> </if>
</where> </where>
order by router_rank order by router_rank

View File

@ -35,28 +35,28 @@
from sys_user user left join sys_user_dept user_dept on user.id = user_dept.user_id from sys_user user left join sys_user_dept user_dept on user.id = user_dept.user_id
<where> <where>
<if test="dto.username != null and dto.username != ''"> <if test="dto.username != null and dto.username != ''">
username like CONCAT('%',#{dto.username},'%') and username like CONCAT('%',#{dto.username},'%')
</if> </if>
<if test="dto.nickName != null and dto.nickName != ''"> <if test="dto.nickName != null and dto.nickName != ''">
nick_name like CONCAT('%',#{dto.nickName},'%') and nick_name like CONCAT('%',#{dto.nickName},'%')
</if> </if>
<if test="dto.email != null and dto.email != ''"> <if test="dto.email != null and dto.email != ''">
email like CONCAT('%',#{dto.email},'%') and email like CONCAT('%',#{dto.email},'%')
</if> </if>
<if test="dto.phone != null and dto.phone != ''"> <if test="dto.phone != null and dto.phone != ''">
phone like CONCAT('%',#{dto.phone},'%') and phone like CONCAT('%',#{dto.phone},'%')
</if> </if>
<if test="dto.sex != null and dto.sex != ''"> <if test="dto.sex != null and dto.sex != ''">
sex = #{dto.sex} and sex = #{dto.sex}
</if> </if>
<if test="dto.summary != null and dto.summary != ''"> <if test="dto.summary != null and dto.summary != ''">
summary like CONCAT('%',#{dto.summary},'%') and summary like CONCAT('%',#{dto.summary},'%')
</if> </if>
<if test="dto.status != null and dto.status != ''"> <if test="dto.status != null and dto.status != ''">
status = #{dto.status} and status = #{dto.status}
</if> </if>
<if test="dto.deptIds != null and dto.deptIds.size() > 0"> <if test="dto.deptIds != null and dto.deptIds.size() > 0">
user_dept.dept_id in and user_dept.dept_id in
<foreach collection="dto.deptIds" item="id" open="(" close=")" separator=","> <foreach collection="dto.deptIds" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>

View File

@ -0,0 +1,35 @@
package cn.bunny.service;
import java.util.HashSet;
import java.util.Set;
class Solution {
public int longestConsecutive(int[] nums) {
if (nums.length == 0) {
return 0;
}
Set<Integer> numSet = new HashSet<>();
for (int num : nums) {
numSet.add(num);
}
int longestStreak = 0;
for (int num : numSet) {
if (!numSet.contains(num - 1)) {
int currentStreak = 1;
while (numSet.contains(num + 1)) {
num++;
currentStreak++;
}
// 更新最长连续序列长度
longestStreak = Math.max(longestStreak, currentStreak);
}
}
return longestStreak;
}
}